From 039d52e413371ff48b9f0f22bd0daf50b8a2513e Mon Sep 17 00:00:00 2001 From: Geo Miller Date: Wed, 1 Mar 2017 16:11:04 -0500 Subject: [PATCH 01/61] sting => String --- docs/configuration.asciidoc | 2 +- docs/logging.asciidoc | 6 +++--- scripts/generate/templates/configuration_docs.tmpl | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/configuration.asciidoc b/docs/configuration.asciidoc index 8126647e2..1327c6cac 100644 --- a/docs/configuration.asciidoc +++ b/docs/configuration.asciidoc @@ -29,7 +29,7 @@ Default::: ------ -`httpAuth`[[config-http-auth]]:: `String` -- Specifies the default http auth as a sting with username and password separated by a colon (eg. `user:pass`). Applies to any host defined in the original config, and any hosts discovered while sniffing. +`httpAuth`[[config-http-auth]]:: `String` -- Specifies the default http auth as a String with username and password separated by a colon (eg. `user:pass`). Applies to any host defined in the original config, and any hosts discovered while sniffing. `log`[[config-log]]:: `String, String[], Object, Object[], Constructor` -- Unless a constructor is specified, this sets the output settings for the bundled logger. See the section on configuring-logging[logging] for more information. diff --git a/docs/logging.asciidoc b/docs/logging.asciidoc index 6afb3327e..901bd9e2f 100644 --- a/docs/logging.asciidoc +++ b/docs/logging.asciidoc @@ -160,9 +160,9 @@ Logs in a format that can be executed with bash, where everything is commented e Options: `curlHost`::: -`Sting` -- Default is `"localhost"`. +`String` -- Default is `"localhost"`. `curlPort`::: -`Sting` -- Default is `9200`. +`String` -- Default is `9200`. `"stream"`:: Send log messages to a WriteableStream @@ -173,4 +173,4 @@ Options: `WriteableStream` -- object to write to. `"console"`:: -Default logger for the browser build, logs to the console when one exists. \ No newline at end of file +Default logger for the browser build, logs to the console when one exists. diff --git a/scripts/generate/templates/configuration_docs.tmpl b/scripts/generate/templates/configuration_docs.tmpl index 2c6ed1bb4..75a4071e0 100644 --- a/scripts/generate/templates/configuration_docs.tmpl +++ b/scripts/generate/templates/configuration_docs.tmpl @@ -29,7 +29,7 @@ Default::: ------ -`httpAuth`[[config-http-auth]]:: `String` -- Specifies the default http auth as a sting with username and password separated by a colon (eg. `user:pass`). Applies to any host defined in the original config, and any hosts discovered while sniffing. +`httpAuth`[[config-http-auth]]:: `String` -- Specifies the default http auth as a String with username and password separated by a colon (eg. `user:pass`). Applies to any host defined in the original config, and any hosts discovered while sniffing. `log`[[config-log]]:: `String, String[], Object, Object[], Constructor` -- Unless a constructor is specified, this sets the output settings for the bundled logger. See the section on configuring-logging[logging] for more information. From f64344fbc08469df6489edc83fc42ddf31eb4785 Mon Sep 17 00:00:00 2001 From: spalger Date: Mon, 3 Apr 2017 17:57:46 -0700 Subject: [PATCH 02/61] bump api version to 5.3 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index dbdd69ec2..d2853a976 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,9 @@ "blanket": { "pattern": "specified in test/unit/coverage.js" }, - "default_api_branch": "5.2", + "default_api_branch": "5.3", "supported_es_branches": [ + "5.3", "5.2", "5.1", "5.0", @@ -34,7 +35,6 @@ ], "unstable_es_branches": [ "5.x", - "5.3", "master" ] }, From f47ca0023ee38e74b57d6adafe146d6a97a19f17 Mon Sep 17 00:00:00 2001 From: spalger Date: Mon, 3 Apr 2017 17:57:55 -0700 Subject: [PATCH 03/61] [apis] regenerate --- docs/api_methods.asciidoc | 26 +- docs/api_methods_5_2.asciidoc | 5363 +++++++++++++++++++++++++++++++++ docs/configuration.asciidoc | 7 +- docs/index.asciidoc | 2 + src/lib/apis/5_3.js | 12 +- src/lib/apis/5_x.js | 239 +- src/lib/apis/browser_index.js | 5 +- src/lib/apis/index.js | 4 +- src/lib/apis/master.js | 243 +- 9 files changed, 5811 insertions(+), 90 deletions(-) create mode 100644 docs/api_methods_5_2.asciidoc diff --git a/docs/api_methods.asciidoc b/docs/api_methods.asciidoc index cb9f7ca21..676000f08 100644 --- a/docs/api_methods.asciidoc +++ b/docs/api_methods.asciidoc @@ -1,5 +1,5 @@ [[api-reference]] -== 5.2 API +== 5.3 API NOTE: This is currently the default API, but in upcoming versions that will change. We recommend setting the `apiVersion` config param when you instantiate your client to make sure that the API does not change unexpectedly. @@ -521,7 +521,7 @@ Options::: <> -- Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) `scrollSize`:: <> -- Size on the scroll request powering the update_by_query -`waitForCompletion`:: +`[waitForCompletion=true]`:: <> -- Should the request should block until the delete-by-query is complete. `requestsPerSecond`:: <> -- The throttle for this request in sub-requests per second. -1 means no throttle. @@ -1535,7 +1535,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc <> -- Time each individual bulk request should wait for shards that are unavailable. `waitForActiveShards`:: <> -- Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) -`waitForCompletion`:: +`[waitForCompletion=true]`:: <> -- Should the request should block until the reindex is complete. `requestsPerSecond`:: <> -- The throttle to set on this request in sub-requests per second. -1 means no throttle. @@ -2275,7 +2275,7 @@ Options::: <> -- Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) `scrollSize`:: <> -- Size on the scroll request powering the update_by_query -`waitForCompletion`:: +`[waitForCompletion=true]`:: <> -- Should the request should block until the update by query operation is complete. `requestsPerSecond`:: <> -- The throttle to set on this request in sub-requests per second. -1 means no throttle. @@ -3345,8 +3345,6 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc [horizontal] `flatSettings`:: <> -- Return settings in flat format (default: false) -`human`:: -<> -- Whether to return time and byte values in human-readable format. `timeout`:: <> -- Explicit operation timeout `nodeId`:: @@ -3925,8 +3923,6 @@ Options::: `flatSettings`:: <> -- Return settings in flat format (default: false) -`human`:: -<> -- Whether to return version and creation date values in human-readable format. `includeDefaults`:: <> -- Whether to return all default setting for each of the indices. `index`:: @@ -4091,8 +4087,6 @@ Options::: <> -- Return settings in flat format (default: false) `local`:: <> -- Return local information, do not retrieve the state from master node (default: false) -`human`:: -<> -- Whether to return version and creation date values in human-readable format. `includeDefaults`:: <> -- Whether to return all default setting for each of the indices. `index`:: @@ -4161,8 +4155,6 @@ Options::: * `"none"` * `"all"` -`human`:: -<> -- Whether to return time and byte values in human-readable format. `index`:: <>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices @@ -4385,8 +4377,6 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc <> -- Whether to display detailed information about shard recovery `activeOnly`:: <> -- Display only those recoveries that are currently on-going -`human`:: -<> -- Whether to return time and byte values in human-readable format. `index`:: <>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices @@ -4498,8 +4488,6 @@ Options::: * `"none"` * `"all"` -`human`:: -<> -- Whether to return time and byte values in human-readable format. `operationThreading`:: anything -- TODO: ? `verbose`:: @@ -4607,8 +4595,6 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc <>, <>, <> -- A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) `groups`:: <>, <>, <> -- A comma-separated list of search groups for `search` index metric -`human`:: -<> -- Whether to return time and byte values in human-readable format. `[level=indices]`:: <> -- Return stats aggregated at cluster, index or shard level Options::: @@ -4939,8 +4925,6 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc [horizontal] `flatSettings`:: <> -- Return settings in flat format (default: false) -`human`:: -<> -- Whether to return time and byte values in human-readable format. `timeout`:: <> -- Explicit operation timeout `nodeId`:: @@ -4976,8 +4960,6 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc <>, <>, <> -- A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) `groups`:: <> -- A comma-separated list of search groups for `search` index metric -`human`:: -<> -- Whether to return time and byte values in human-readable format. `[level=node]`:: <> -- Return indices stats aggregated at index, node or shard level Options::: diff --git a/docs/api_methods_5_2.asciidoc b/docs/api_methods_5_2.asciidoc new file mode 100644 index 000000000..b02ca0dee --- /dev/null +++ b/docs/api_methods_5_2.asciidoc @@ -0,0 +1,5363 @@ +[[api-reference-5-2]] +== 5.2 API + + +NOTE: At this time, you must opt into the 5.2 API by setting the `apiVersion` config parameter. + + +[[api-bulk-5-2]] +=== `bulk` + +[source,js] +-------- +client.bulk([params, [callback]]) +-------- + +Perform many index/delete operations in a single API call. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-bulk.html[the elasticsearch docs] for more information pertaining to this method. + +.Perform three operations in a single request +[source,js] +--------- +client.bulk({ + body: [ + // action description + { index: { _index: 'myindex', _type: 'mytype', _id: 1 } }, + // the document to index + { title: 'foo' }, + // action description + { update: { _index: 'myindex', _type: 'mytype', _id: 2 } }, + // the document to update + { doc: { title: 'foo' } }, + // action description + { delete: { _index: 'myindex', _type: 'mytype', _id: 3 } }, + // no document needed for this delete + ] +}, function (err, resp) { + // ... +}); +--------- + + +*Params* + +[horizontal] +`waitForActiveShards`:: +<> -- Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) +`refresh`:: +<> -- If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. +Options::: + * `"true"` + * `"false"` + * `"wait_for"` + * `""` + +`routing`:: +<> -- Specific routing value +`timeout`:: +<> -- Explicit operation timeout +`type`:: +<> -- Default document type for items which don't provide one +`fields`:: +<>, <>, <> -- Default comma-separated list of fields to return in the response for updates, can be overridden on each sub-request +`_source`:: +<>, <>, <> -- True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request +`_sourceExclude`:: +<>, <>, <> -- Default list of fields to exclude from the returned _source field, can be overridden on each sub-request +`_sourceInclude`:: +<>, <>, <> -- Default list of fields to extract and return from the _source field, can be overridden on each sub-request +`pipeline`:: +<> -- The pipeline id to preprocess incoming documents with +`index`:: +<> -- Default index for items which don't provide one +`body`:: +<>, <> -- The request body, as either an array of objects or new-line delimited JSON objects. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-bulk.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-clearscroll-5-2]] +=== `clearScroll` + +[source,js] +-------- +client.clearScroll([params, [callback]]) +-------- + +Clear the scroll request created by specifying the scroll parameter to search. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-request-scroll.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`scrollId`:: +<>, <>, <> -- A comma-separated list of scroll IDs to clear +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-request-scroll.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-count-5-2]] +=== `count` + +[source,js] +-------- +client.count([params, [callback]]) +-------- + +Get the number of documents for the cluster, index, type, or a query. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-count.html[the elasticsearch docs] for more information pertaining to this method. + +.Get the number of all documents in the cluster +[source,js] +--------- +client.count(function (error, response, status) { + // check for and handle error + var count = response.count; +}); +--------- + +.Get the number of documents in an index +[source,js] +--------- +client.count({ + index: 'index_name' +}, function (error, response) { + // ... +}); +--------- + +.Get the number of documents matching a query +[source,js] +--------- +client.count({ + index: 'index_name', + body: { + query: { + filtered: { + filter: { + terms: { + foo: ['bar'] + } + } + } + } + } +}, function (err, response) { + // ... +}); +--------- + + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`minScore`:: +<> -- Include only documents with a specific `_score` value in the result +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`routing`:: +<> -- Specific routing value +`q`:: +<> -- Query in the Lucene query string syntax +`analyzer`:: +<> -- The analyzer to use for the query string +`analyzeWildcard`:: +<> -- Specify whether wildcard and prefix queries should be analyzed (default: false) +`[defaultOperator=OR]`:: +<> -- The default operator for query string query (AND or OR) +Options::: + * `"AND"` + * `"OR"` + +`df`:: +<> -- The field to use as default where no field prefix is given in the query string +`lenient`:: +<> -- Specify whether format-based query failures (such as providing text to a numeric field) should be ignored +`index`:: +<>, <>, <> -- A comma-separated list of indices to restrict the results +`type`:: +<>, <>, <> -- A comma-separated list of types to restrict the results +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-count.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-countpercolate-5-2]] +=== `countPercolate` + +[source,js] +-------- +client.countPercolate([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-percolate.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`routing`:: +<>, <>, <> -- A comma-separated list of specific routing values +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`percolateIndex`:: +<> -- The index to count percolate the document into. Defaults to index. +`percolateType`:: +<> -- The type to count percolate document into. Defaults to type. +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"external"` + * `"external_gte"` + * `"force"` + +`index`:: +<> -- The index of the document being count percolated. +`type`:: +<> -- The type of the document being count percolated. +`id`:: +<> -- Substitute the document in the request body with a document that is known by the specified id. On top of the id, the index and type parameter will be used to retrieve the document from within the cluster. +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-percolate.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-create-5-2]] +=== `create` + +[source,js] +-------- +client.create([params, [callback]]) +-------- + +Adds a typed JSON document in a specific index, making it searchable. If a document with the same `index`, `type`, and `id` already exists, an error will occur. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-index_.html[the elasticsearch docs] for more information pertaining to this method. + +.Create a document +[source,js] +--------- +client.create({ + index: 'myindex', + type: 'mytype', + id: '1', + body: { + title: 'Test 1', + tags: ['y', 'z'], + published: true, + published_at: '2013-01-01', + counter: 1 + } +}, function (error, response) { + // ... +}); +--------- + + +*Params* + +[horizontal] +`waitForActiveShards`:: +<> -- Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) +`parent`:: +<> -- ID of the parent document +`refresh`:: +<> -- If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. +Options::: + * `"true"` + * `"false"` + * `"wait_for"` + * `""` + +`routing`:: +<> -- Specific routing value +`timeout`:: +<> -- Explicit operation timeout +`timestamp`:: +Timestamp -- Explicit timestamp for the document +`ttl`:: +<> -- Expiration time for the document +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"external"` + * `"external_gte"` + * `"force"` + +`pipeline`:: +<> -- The pipeline id to preprocess incoming documents with +`id`:: +<> -- Document ID +`index`:: +<> -- The name of the index +`type`:: +<> -- The type of the document +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-index_.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-delete-5-2]] +=== `delete` + +[source,js] +-------- +client.delete([params, [callback]]) +-------- + +Delete a typed JSON document from a specific index based on its id. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-delete.html[the elasticsearch docs] for more information pertaining to this method. + +.Delete the document `/myindex/mytype/1` +[source,js] +--------- +client.delete({ + index: 'myindex', + type: 'mytype', + id: '1' +}, function (error, response) { + // ... +}); +--------- + + +*Params* + +[horizontal] +`waitForActiveShards`:: +<> -- Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) +`parent`:: +<> -- ID of parent document +`refresh`:: +<> -- If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. +Options::: + * `"true"` + * `"false"` + * `"wait_for"` + * `""` + +`routing`:: +<> -- Specific routing value +`timeout`:: +<> -- Explicit operation timeout +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"external"` + * `"external_gte"` + * `"force"` + +`id`:: +<> -- The document ID +`index`:: +<> -- The name of the index +`type`:: +<> -- The type of the document +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-delete.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-deletebyquery-5-2]] +=== `deleteByQuery` + +[source,js] +-------- +client.deleteByQuery([params, [callback]]) +-------- + +Delete documents from one or more indices and one or more types based on a query. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-delete-by-query.html[the elasticsearch docs] for more information pertaining to this method. + +.Deleting documents with a simple query +[source,js] +--------- +client.deleteByQuery({ + index: 'myindex', + q: 'test' +}, function (error, response) { + // ... +}); +--------- + +.Deleting documents using the Query DSL +[source,js] +--------- +client.deleteByQuery({ + index: 'posts', + body: { + query: { + term: { published: false } + } + } +}, function (error, response) { + // ... +}); +--------- + + +*Params* + +[horizontal] +`analyzer`:: +<> -- The analyzer to use for the query string +`analyzeWildcard`:: +<> -- Specify whether wildcard and prefix queries should be analyzed (default: false) +`[defaultOperator=OR]`:: +<> -- The default operator for query string query (AND or OR) +Options::: + * `"AND"` + * `"OR"` + +`df`:: +<> -- The field to use as default where no field prefix is given in the query string +`from`:: +<> -- Starting offset (default: 0) +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[conflicts=abort]`:: +<> -- What to do when the delete-by-query hits version conflicts? +Options::: + * `"abort"` + * `"proceed"` + +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`lenient`:: +<> -- Specify whether format-based query failures (such as providing text to a numeric field) should be ignored +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`q`:: +<> -- Query in the Lucene query string syntax +`routing`:: +<>, <>, <> -- A comma-separated list of specific routing values +`scroll`:: +<> -- Specify how long a consistent view of the index should be maintained for scrolled search +`searchType`:: +<> -- Search operation type +Options::: + * `"query_then_fetch"` + * `"dfs_query_then_fetch"` + +`searchTimeout`:: +<> -- Explicit timeout for each search request. Defaults to no timeout. +`size`:: +<> -- Number of hits to return (default: 10) +`sort`:: +<>, <>, <> -- A comma-separated list of : pairs +`_source`:: +<>, <>, <> -- True or false to return the _source field or not, or a list of fields to return +`_sourceExclude`:: +<>, <>, <> -- A list of fields to exclude from the returned _source field +`_sourceInclude`:: +<>, <>, <> -- A list of fields to extract and return from the _source field +`terminateAfter`:: +<> -- The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. +`stats`:: +<>, <>, <> -- Specific 'tag' of the request for logging and statistical purposes +`version`:: +<> -- Specify whether to return document version as part of a hit +`requestCache`:: +<> -- Specify if request cache should be used for this request or not, defaults to index level setting +`refresh`:: +<> -- Should the effected indexes be refreshed? +`[timeout=1m]`:: +<> -- Time each individual bulk request should wait for shards that are unavailable. +`waitForActiveShards`:: +<> -- Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) +`scrollSize`:: +<> -- Size on the scroll request powering the update_by_query +`waitForCompletion`:: +<> -- Should the request should block until the delete-by-query is complete. +`requestsPerSecond`:: +<> -- The throttle for this request in sub-requests per second. -1 means no throttle. +`[slices=1]`:: +<> -- The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. +`index`:: +<>, <>, <> -- A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices +`type`:: +<>, <>, <> -- A comma-separated list of document types to search; leave empty to perform the operation on all types +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-delete-by-query.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-deletescript-5-2]] +=== `deleteScript` + +[source,js] +-------- +client.deleteScript([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-scripting.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`id`:: +<> -- Script ID +`lang`:: +<> -- Script language +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-scripting.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-deletetemplate-5-2]] +=== `deleteTemplate` + +[source,js] +-------- +client.deleteTemplate([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-template.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`id`:: +<> -- Template ID +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-template.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-exists-5-2]] +=== `exists` + +[source,js] +-------- +client.exists([params, [callback]]) +-------- + +Returns a boolean indicating whether or not a given document exists. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-get.html[the elasticsearch docs] for more information pertaining to this method. + +.Check that the document `/myindex/mytype/1` exist +[source,js] +--------- +client.exists({ + index: 'myindex', + type: 'mytype', + id: 1 +}, function (error, exists) { + if (exists === true) { + // ... + } else { + // ... + } +}); +--------- + + +*Params* + +[horizontal] +`parent`:: +<> -- The ID of the parent document +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`realtime`:: +<> -- Specify whether to perform the operation in realtime or search mode +`refresh`:: +<> -- Refresh the shard containing the document before performing the operation +`routing`:: +<> -- Specific routing value +`id`:: +<> -- The document ID +`index`:: +<> -- The name of the index +`type`:: +<> -- The type of the document (use `_all` to fetch the first document matching the ID across all types) +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-get.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-explain-5-2]] +=== `explain` + +[source,js] +-------- +client.explain([params, [callback]]) +-------- + +Provides details about a specific document's score in relation to a specific query. It will also tell you if the document matches the specified query. Also check out http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-percolate.html[percolaters]. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-explain.html[the elasticsearch docs] for more information pertaining to this method. + +.See how a document is scored against a simple query +[source,js] +--------- +client.explain({ + // the document to test + index: 'myindex', + type: 'mytype', + id: '1', + + // the query to score it against + q: 'field:value' +}, function (error, response) { + // ... +}); +--------- + +.See how a document is scored against a query written in the Query DSL +[source,js] +--------- +client.explain({ + index: 'myindex', + type: 'mytype', + id: '1', + body: { + query: { + match: { title: 'test' } + } + } +}, function (error, response) { + // ... +}); +--------- + + +*Params* + +[horizontal] +`analyzeWildcard`:: +<> -- Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false) +`analyzer`:: +<> -- The analyzer for the query string query +`[defaultOperator=OR]`:: +<> -- The default operator for query string query (AND or OR) +Options::: + * `"AND"` + * `"OR"` + +`df`:: +<> -- The default field for query string query (default: _all) +`storedFields`:: +<>, <>, <> -- A comma-separated list of stored fields to return in the response +`lenient`:: +<> -- Specify whether format-based query failures (such as providing text to a numeric field) should be ignored +`parent`:: +<> -- The ID of the parent document +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`q`:: +<> -- Query in the Lucene query string syntax +`routing`:: +<> -- Specific routing value +`_source`:: +<>, <>, <> -- True or false to return the _source field or not, or a list of fields to return +`_sourceExclude`:: +<>, <>, <> -- A list of fields to exclude from the returned _source field +`_sourceInclude`:: +<>, <>, <> -- A list of fields to extract and return from the _source field +`id`:: +<> -- The document ID +`index`:: +<> -- The name of the index +`type`:: +<> -- The type of the document +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-explain.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-fieldstats-5-2]] +=== `fieldStats` + +[source,js] +-------- +client.fieldStats([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-field-stats.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`fields`:: +<>, <>, <> -- A comma-separated list of fields for to get field statistics for (min value, max value, and more) +`[level=cluster]`:: +<> -- Defines if field stats should be returned on a per index level or on a cluster wide level +Options::: + * `"indices"` + * `"cluster"` + +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-field-stats.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-get-5-2]] +=== `get` + +[source,js] +-------- +client.get([params, [callback]]) +-------- + +Get a typed JSON document from the index based on its id. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-get.html[the elasticsearch docs] for more information pertaining to this method. + +.Get `/myindex/mytype/1` +[source,js] +--------- +client.get({ + index: 'myindex', + type: 'mytype', + id: 1 +}, function (error, response) { + // ... +}); +--------- + + +*Params* + +[horizontal] +`storedFields`:: +<>, <>, <> -- A comma-separated list of stored fields to return in the response +`parent`:: +<> -- The ID of the parent document +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`realtime`:: +<> -- Specify whether to perform the operation in realtime or search mode +`refresh`:: +<> -- Refresh the shard containing the document before performing the operation +`routing`:: +<> -- Specific routing value +`_source`:: +<>, <>, <> -- True or false to return the _source field or not, or a list of fields to return +`_sourceExclude`:: +<>, <>, <> -- A list of fields to exclude from the returned _source field +`_sourceInclude`:: +<>, <>, <> -- A list of fields to extract and return from the _source field +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"external"` + * `"external_gte"` + * `"force"` + +`id`:: +<> -- The document ID +`index`:: +<> -- The name of the index +`type`:: +<> -- The type of the document (use `_all` to fetch the first document matching the ID across all types) + +link:#[back to top] + +[[api-getscript-5-2]] +=== `getScript` + +[source,js] +-------- +client.getScript([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-scripting.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`id`:: +<> -- Script ID +`lang`:: +<> -- Script language + +link:#[back to top] + +[[api-getsource-5-2]] +=== `getSource` + +[source,js] +-------- +client.getSource([params, [callback]]) +-------- + +Get the source of a document by its index, type and id. + + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-get.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`parent`:: +<> -- The ID of the parent document +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`realtime`:: +<> -- Specify whether to perform the operation in realtime or search mode +`refresh`:: +<> -- Refresh the shard containing the document before performing the operation +`routing`:: +<> -- Specific routing value +`_source`:: +<>, <>, <> -- True or false to return the _source field or not, or a list of fields to return +`_sourceExclude`:: +<>, <>, <> -- A list of fields to exclude from the returned _source field +`_sourceInclude`:: +<>, <>, <> -- A list of fields to extract and return from the _source field +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"external"` + * `"external_gte"` + * `"force"` + +`id`:: +<> -- The document ID +`index`:: +<> -- The name of the index +`type`:: +<> -- The type of the document; use `_all` to fetch the first document matching the ID across all types + +link:#[back to top] + +[[api-gettemplate-5-2]] +=== `getTemplate` + +[source,js] +-------- +client.getTemplate([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-template.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`id`:: +<> -- Template ID + +link:#[back to top] + +[[api-index-5-2]] +=== `index` + +[source,js] +-------- +client.index([params, [callback]]) +-------- + +Stores a typed JSON document in an index, making it searchable. When the `id` param is not set, a unique id will be auto-generated. When you specify an `id` either a new document will be created, or an existing document will be updated. To enforce "put-if-absent" behavior set the `opType` to `"create"` or use the `create()` method. + +Optimistic concurrency control is performed, when the `version` argument is specified. By default, no version checks are performed. + +By default, the document will be available for `get()` actions immediately, but will only be available for searching after an index refresh (which can happen automatically or manually). See <>. + + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-index_.html[the elasticsearch docs] for more information pertaining to this method. + +.Create or update a document +[source,js] +--------- +client.index({ + index: 'myindex', + type: 'mytype', + id: '1', + body: { + title: 'Test 1', + tags: ['y', 'z'], + published: true, + } +}, function (error, response) { + +}); +--------- + + +*Params* + +[horizontal] +`waitForActiveShards`:: +<> -- Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) +`[opType=index]`:: +<> -- Explicit operation type +Options::: + * `"index"` + * `"create"` + +`parent`:: +<> -- ID of the parent document +`refresh`:: +<> -- If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. +Options::: + * `"true"` + * `"false"` + * `"wait_for"` + * `""` + +`routing`:: +<> -- Specific routing value +`timeout`:: +<> -- Explicit operation timeout +`timestamp`:: +Timestamp -- Explicit timestamp for the document +`ttl`:: +<> -- Expiration time for the document +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"external"` + * `"external_gte"` + * `"force"` + +`pipeline`:: +<> -- The pipeline id to preprocess incoming documents with +`id`:: +<> -- Document ID +`index`:: +<> -- The name of the index +`type`:: +<> -- The type of the document +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-index_.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-info-5-2]] +=== `info` + +[source,js] +-------- +client.info([params, [callback]]) +-------- + +Get basic info from the current cluster. + +Check the *<>* and https://www.elastic.co/guide/[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + + +[[api-mget-5-2]] +=== `mget` + +[source,js] +-------- +client.mget([params, [callback]]) +-------- + +Get multiple documents based on an index, type (optional) and ids. The body required by mget can take two forms: an array of document locations, or an array of document ids. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-multi-get.html[the elasticsearch docs] for more information pertaining to this method. + +.An array of doc locations. Useful for getting documents from different indices. +[source,js] +--------- +client.mget({ + body: { + docs: [ + { _index: 'indexA', _type: 'typeA', _id: '1' }, + { _index: 'indexB', _type: 'typeB', _id: '1' }, + { _index: 'indexC', _type: 'typeC', _id: '1' } + ] + } +}, function(error, response){ + // ... +}); +--------- + +.An array of ids. You must also specify the `index` and `type` that apply to all of the ids. +[source,js] +--------- +client.mget({ + index: 'myindex', + type: 'mytype', + body: { + ids: [1, 2, 3] + } +}, function(error, response){ + // ... +}); +--------- + + +*Params* + +[horizontal] +`storedFields`:: +<>, <>, <> -- A comma-separated list of stored fields to return in the response +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`realtime`:: +<> -- Specify whether to perform the operation in realtime or search mode +`refresh`:: +<> -- Refresh the shard containing the document before performing the operation +`routing`:: +<> -- Specific routing value +`_source`:: +<>, <>, <> -- True or false to return the _source field or not, or a list of fields to return +`_sourceExclude`:: +<>, <>, <> -- A list of fields to exclude from the returned _source field +`_sourceInclude`:: +<>, <>, <> -- A list of fields to extract and return from the _source field +`index`:: +<> -- The name of the index +`type`:: +<> -- The type of the document +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-multi-get.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-mpercolate-5-2]] +=== `mpercolate` + +[source,js] +-------- +client.mpercolate([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-percolate.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`index`:: +<> -- The index of the document being count percolated to use as default +`type`:: +<> -- The type of the document being percolated to use as default. +`body`:: +<>, <> -- The request body, as either an array of objects or new-line delimited JSON objects. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-percolate.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-msearch-5-2]] +=== `msearch` + +[source,js] +-------- +client.msearch([params, [callback]]) +-------- + +Execute several search requests within the same request. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-multi-search.html[the elasticsearch docs] for more information pertaining to this method. + +.Perform multiple different searches, the body is made up of meta/data pairs +[source,js] +--------- +client.msearch({ + body: [ + // match all query, on all indices and types + {}, + { query: { match_all: {} } }, + + // query_string query, on index/mytype + { index: 'myindex', type: 'mytype' }, + { query: { query_string: { query: '"Test 1"' } } } + ] +}); +--------- + + + +*Params* + +[horizontal] +`searchType`:: +<> -- Search operation type +Options::: + * `"query_then_fetch"` + * `"query_and_fetch"` + * `"dfs_query_then_fetch"` + * `"dfs_query_and_fetch"` + +`maxConcurrentSearches`:: +<> -- Controls the maximum number of concurrent searches the multi search api will execute +`index`:: +<>, <>, <> -- A comma-separated list of index names to use as default +`type`:: +<>, <>, <> -- A comma-separated list of document types to use as default +`body`:: +<>, <> -- The request body, as either an array of objects or new-line delimited JSON objects. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-multi-search.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-msearchtemplate-5-2]] +=== `msearchTemplate` + +[source,js] +-------- +client.msearchTemplate([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`searchType`:: +<> -- Search operation type +Options::: + * `"query_then_fetch"` + * `"query_and_fetch"` + * `"dfs_query_then_fetch"` + * `"dfs_query_and_fetch"` + +`index`:: +<>, <>, <> -- A comma-separated list of index names to use as default +`type`:: +<>, <>, <> -- A comma-separated list of document types to use as default +`body`:: +<>, <> -- The request body, as either an array of objects or new-line delimited JSON objects. See https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-mtermvectors-5-2]] +=== `mtermvectors` + +[source,js] +-------- +client.mtermvectors([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-multi-termvectors.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ids`:: +<>, <>, <> -- A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body +`termStatistics`:: +<> -- Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". +`[fieldStatistics=true]`:: +<> -- Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". +`fields`:: +<>, <>, <> -- A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body "params" or "docs". +`[offsets=true]`:: +<> -- Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". +`[positions=true]`:: +<> -- Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". +`[payloads=true]`:: +<> -- Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body "params" or "docs". +`routing`:: +<> -- Specific routing value. Applies to all returned documents unless otherwise specified in body "params" or "docs". +`parent`:: +<> -- Parent id of documents. Applies to all returned documents unless otherwise specified in body "params" or "docs". +`realtime`:: +<> -- Specifies if requests are real-time as opposed to near-real-time (default: true). +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"external"` + * `"external_gte"` + * `"force"` + +`index`:: +<> -- The index in which the document resides. +`type`:: +<> -- The type of the document. +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-multi-termvectors.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-percolate-5-2]] +=== `percolate` + +[source,js] +-------- +client.percolate([params, [callback]]) +-------- + +Match a document against registered percolator queries. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-percolate.html[the elasticsearch docs] for more information pertaining to this method. + +.First, Register queries named “alert-1” and “alert-2” for the “myindex” index +[source,js] +--------- +client.index({ + index: 'myindex', + type: '.percolator', + id: 'alert-1', + body: { + // This query will be run against documents sent to percolate + query: { + query_string: { + query: 'foo' + } + } + } +}, function (error, response) { + // ... +}); + +client.index({ + index: 'myindex', + type: '.percolator', + id: 'alert-2', + body: { + // This query will also be run against documents sent to percolate + query: { + query_string: { + query: 'bar' + } + } + } +}, function (error, response) { + // ... +}); +--------- + +.Then you can send documents to learn which query `_percolator` queries they match +[source,js] +--------- +client.percolate({ + index: 'myindex', + type: 'mytype', + body: { + doc: { + title: "Foo" + } + } +}, function (error, response) { + // response would equal + // { + // total: 1, + // matches: [ { _index: 'myindex', _id: 'alert-1' } ] + // } +}); + +client.percolate({ + index: 'myindex', + type: 'mytype', + body: { + doc: { + title: "Foo Bar" + } + } +}, function (error, response) { + // response would equal + // { + // total: 2, + // matches: [ + // { _index: 'myindex', _id: 'alert-1' }, + // { _index: 'myindex', _id: 'alert-2' } + // ] + // } +}); +--------- + + +*Params* + +[horizontal] +`routing`:: +<>, <>, <> -- A comma-separated list of specific routing values +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`percolateIndex`:: +<> -- The index to percolate the document into. Defaults to index. +`percolateType`:: +<> -- The type to percolate document into. Defaults to type. +`percolateRouting`:: +<> -- The routing value to use when percolating the existing document. +`percolatePreference`:: +<> -- Which shard to prefer when executing the percolate request. +`percolateFormat`:: +<> -- Return an array of matching query IDs instead of objects +Options::: + * `"ids"` + +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"external"` + * `"external_gte"` + * `"force"` + +`index`:: +<> -- The index of the document being percolated. +`type`:: +<> -- The type of the document being percolated. +`id`:: +<> -- Substitute the document in the request body with a document that is known by the specified id. On top of the id, the index and type parameter will be used to retrieve the document from within the cluster. +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-percolate.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-ping-5-2]] +=== `ping` + +[source,js] +-------- +client.ping([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + + +[[api-putscript-5-2]] +=== `putScript` + +[source,js] +-------- +client.putScript([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-scripting.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`id`:: +<> -- Script ID +`lang`:: +<> -- Script language +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-scripting.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-puttemplate-5-2]] +=== `putTemplate` + +[source,js] +-------- +client.putTemplate([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-template.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`id`:: +<> -- Template ID +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-template.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-reindex-5-2]] +=== `reindex` + +[source,js] +-------- +client.reindex([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-reindex.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`refresh`:: +<> -- Should the effected indexes be refreshed? +`[timeout=1m]`:: +<> -- Time each individual bulk request should wait for shards that are unavailable. +`waitForActiveShards`:: +<> -- Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) +`waitForCompletion`:: +<> -- Should the request should block until the reindex is complete. +`requestsPerSecond`:: +<> -- The throttle to set on this request in sub-requests per second. -1 means no throttle. +`[slices=1]`:: +<> -- The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-reindex.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-reindexrethrottle-5-2]] +=== `reindexRethrottle` + +[source,js] +-------- +client.reindexRethrottle([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-reindex.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`requestsPerSecond`:: +<> -- The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. +`taskId`:: +<> -- The task id to rethrottle +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-reindex.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-rendersearchtemplate-5-2]] +=== `renderSearchTemplate` + +[source,js] +-------- +client.renderSearchTemplate([params, [callback]]) +-------- + +// no description + +Check the *<>* and http://www.elasticsearch.org/guide/en/elasticsearch/reference/5.x/search-template.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`id`:: +<> -- The id of the stored search template +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/5.x/search-template.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-scroll-5-2]] +=== `scroll` + +[source,js] +-------- +client.scroll([params, [callback]]) +-------- + +Scroll a search request (retrieve the next set of results) after specifying the scroll parameter in a `search()` call. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-request-scroll.html[the elasticsearch docs] for more information pertaining to this method. + +.Collect every title in the index that contains the word "test" +[source,js] +--------- +var allTitles = []; + +// first we do a search, and specify a scroll timeout +client.search({ + index: 'myindex', + scroll: '30s', // keep the search results "scrollable" for 30 seconds + source: ['title'], // filter the source to only include the title field + q: 'title:test' +}, function getMoreUntilDone(error, response) { + // collect the title from each response + response.hits.hits.forEach(function (hit) { + allTitles.push(hit._source.title); + }); + + if (response.hits.total > allTitles.length) { + // ask elasticsearch for the next set of hits from this search + client.scroll({ + scrollId: response._scroll_id, + scroll: '30s' + }, getMoreUntilDone); + } else { + console.log('every "test" title', allTitles); + } +}); +--------- + + + +*Params* + +[horizontal] +`scroll`:: +<> -- Specify how long a consistent view of the index should be maintained for scrolled search +`scrollId`:: +<> -- The scroll ID +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-request-scroll.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-search-5-2]] +=== `search` + +[source,js] +-------- +client.search([params, [callback]]) +-------- + +Return documents matching a query, aggregations/facets, highlighted snippets, suggestions, and more. Write your queries as either http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-uri-request.html[simple query strings] in the `q` parameter, or by specifying a http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-body.html[full request definition] using the http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html[Elasticsearch Query DSL] in the `body` parameter. + +TIP: https://github.com/fullscale/elastic.js[elastic.js], https://github.com/holidayextras/esq[esq], or https://github.com/danpaz/bodybuilder[bodybuilder] can be used to make building query bodies easier. + + + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-search.html[the elasticsearch docs] for more information pertaining to this method. + +.Search with a simple query string query +[source,js] +--------- +client.search({ + index: 'myindex', + q: 'title:test' +}, function (error, response) { + // ... +}); +--------- + +.Passing a full request definition in the Elasticsearch's Query DSL as a `Hash` +[source,js] +--------- +client.search({ + index: 'myindex', + body: { + query: { + match: { + title: 'test' + } + }, + facets: { + tags: { + terms: { + field: 'tags' + } + } + } + } +}, function (error, response) { + // ... +}); +--------- + + +*Params* + +[horizontal] +`analyzer`:: +<> -- The analyzer to use for the query string +`analyzeWildcard`:: +<> -- Specify whether wildcard and prefix queries should be analyzed (default: false) +`[defaultOperator=OR]`:: +<> -- The default operator for query string query (AND or OR) +Options::: + * `"AND"` + * `"OR"` + +`df`:: +<> -- The field to use as default where no field prefix is given in the query string +`explain`:: +<> -- Specify whether to return detailed information about score computation as part of a hit +`storedFields`:: +<>, <>, <> -- A comma-separated list of stored fields to return as part of a hit +`docvalueFields`:: +<>, <>, <> -- A comma-separated list of fields to return as the docvalue representation of a field for each hit +`fielddataFields`:: +<>, <>, <> -- A comma-separated list of fields to return as the docvalue representation of a field for each hit +`from`:: +<> -- Starting offset (default: 0) +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`lenient`:: +<> -- Specify whether format-based query failures (such as providing text to a numeric field) should be ignored +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`q`:: +<> -- Query in the Lucene query string syntax +`routing`:: +<>, <>, <> -- A comma-separated list of specific routing values +`scroll`:: +<> -- Specify how long a consistent view of the index should be maintained for scrolled search +`searchType`:: +<> -- Search operation type +Options::: + * `"query_then_fetch"` + * `"dfs_query_then_fetch"` + +`size`:: +<> -- Number of hits to return (default: 10) +`sort`:: +<>, <>, <> -- A comma-separated list of : pairs +`_source`:: +<>, <>, <> -- True or false to return the _source field or not, or a list of fields to return +`_sourceExclude`:: +<>, <>, <> -- A list of fields to exclude from the returned _source field +`_sourceInclude`:: +<>, <>, <> -- A list of fields to extract and return from the _source field +`terminateAfter`:: +<> -- The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. +`stats`:: +<>, <>, <> -- Specific 'tag' of the request for logging and statistical purposes +`suggestField`:: +<> -- Specify which field to use for suggestions +`[suggestMode=missing]`:: +<> -- Specify suggest mode +Options::: + * `"missing"` + * `"popular"` + * `"always"` + +`suggestSize`:: +<> -- How many suggestions to return in response +`suggestText`:: +<> -- The source text for which the suggestions should be returned +`timeout`:: +<> -- Explicit operation timeout +`trackScores`:: +<> -- Whether to calculate and return scores even if they are not used for sorting +`version`:: +<> -- Specify whether to return document version as part of a hit +`requestCache`:: +<> -- Specify if request cache should be used for this request or not, defaults to index level setting +`index`:: +<>, <>, <> -- A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices +`type`:: +<>, <>, <> -- A comma-separated list of document types to search; leave empty to perform the operation on all types +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-search.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-searchshards-5-2]] +=== `searchShards` + +[source,js] +-------- +client.searchShards([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-shards.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`routing`:: +<> -- Specific routing value +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`index`:: +<>, <>, <> -- A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices +`type`:: +<>, <>, <> -- A comma-separated list of document types to search; leave empty to perform the operation on all types +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-shards.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-searchtemplate-5-2]] +=== `searchTemplate` + +[source,js] +-------- +client.searchTemplate([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`routing`:: +<>, <>, <> -- A comma-separated list of specific routing values +`scroll`:: +<> -- Specify how long a consistent view of the index should be maintained for scrolled search +`searchType`:: +<> -- Search operation type +Options::: + * `"query_then_fetch"` + * `"query_and_fetch"` + * `"dfs_query_then_fetch"` + * `"dfs_query_and_fetch"` + +`explain`:: +<> -- Specify whether to return detailed information about score computation as part of a hit +`profile`:: +<> -- Specify whether to profile the query execution +`index`:: +<>, <>, <> -- A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices +`type`:: +<>, <>, <> -- A comma-separated list of document types to search; leave empty to perform the operation on all types +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-suggest-5-2]] +=== `suggest` + +[source,js] +-------- +client.suggest([params, [callback]]) +-------- + +The suggest feature suggests similar looking terms based on a provided text by using a specific suggester. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-suggesters.html[the elasticsearch docs] for more information pertaining to this method. + +.Return query terms suggestions (“auto-correction”) +[source,js] +--------- +client.suggest({ +index: 'myindex', +body: { + mysuggester: { + text: 'tset', + term: { + field: 'title' + } + } +} +}, function (error, response) { +// response will be formatted like so: +// +// { +// ... +// mysuggester: [ +// { +// text: "tset", +// ... +// options: [ +// { +// text: "test", +// score: 0.75, +// freq: 5 +// } +// ] +// } +// ] +// } +}); +--------- + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`routing`:: +<> -- Specific routing value +`index`:: +<>, <>, <> -- A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-suggesters.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-termvectors-5-2]] +=== `termvectors` + +[source,js] +-------- +client.termvectors([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-termvectors.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`termStatistics`:: +<> -- Specifies if total term frequency and document frequency should be returned. +`[fieldStatistics=true]`:: +<> -- Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. +`fields`:: +<>, <>, <> -- A comma-separated list of fields to return. +`[offsets=true]`:: +<> -- Specifies if term offsets should be returned. +`[positions=true]`:: +<> -- Specifies if term positions should be returned. +`[payloads=true]`:: +<> -- Specifies if term payloads should be returned. +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random). +`routing`:: +<> -- Specific routing value. +`parent`:: +<> -- Parent id of documents. +`realtime`:: +<> -- Specifies if request is real-time as opposed to near-real-time (default: true). +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"external"` + * `"external_gte"` + * `"force"` + +`index`:: +<> -- The index in which the document resides. +`type`:: +<> -- The type of the document. +`id`:: +<> -- The id of the document, when not specified a doc param should be supplied. +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-termvectors.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-update-5-2]] +=== `update` + +[source,js] +-------- +client.update([params, [callback]]) +-------- + +Update parts of a document. The required body parameter can contain one of two things: + + * a partial document, which will be merged with the existing one. + * a `script` which will update the document content + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-update.html[the elasticsearch docs] for more information pertaining to this method. + +.Update document title using partial document +[source,js] +--------- +client.update({ + index: 'myindex', + type: 'mytype', + id: '1', + body: { + // put the partial document under the `doc` key + doc: { + title: 'Updated' + } + } +}, function (error, response) { + // ... +}) +--------- + +.Add a tag to document `tags` property using a `script` +[source,js] +--------- +client.update({ + index: 'myindex', + type: 'mytype', + id: '1', + body: { + script: 'ctx._source.tags += tag', + params: { tag: 'some new tag' } + } +}, function (error, response) { + // ... +}); +--------- + +.Increment a document counter by 1 or initialize it, when the document does not exist +[source,js] +--------- +client.update({ + index: 'myindex', + type: 'mytype', + id: '777', + body: { + script: 'ctx._source.counter += 1', + upsert: { + counter: 1 + } + } +}, function (error, response) { + // ... +}) +--------- + +.Delete a document if it's tagged “to-delete” +[source,js] +--------- +client.update({ + index: 'myindex', + type: 'mytype', + id: '1', + body: { + script: 'ctx._source.tags.contains(tag) ? ctx.op = "delete" : ctx.op = "none"', + params: { + tag: 'to-delete' + } + } +}, function (error, response) { + // ... +}); +--------- + + +*Params* + +[horizontal] +`waitForActiveShards`:: +<> -- Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) +`fields`:: +<>, <>, <> -- A comma-separated list of fields to return in the response +`_source`:: +<>, <>, <> -- True or false to return the _source field or not, or a list of fields to return +`_sourceExclude`:: +<>, <>, <> -- A list of fields to exclude from the returned _source field +`_sourceInclude`:: +<>, <>, <> -- A list of fields to extract and return from the _source field +`lang`:: +<> -- The script language (default: painless) +`parent`:: +<> -- ID of the parent document. Is is only used for routing and when for the upsert request +`refresh`:: +<> -- If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. +Options::: + * `"true"` + * `"false"` + * `"wait_for"` + * `""` + +`retryOnConflict`:: +<> -- Specify how many times should the operation be retried when a conflict occurs (default: 0) +`routing`:: +<> -- Specific routing value +`timeout`:: +<> -- Explicit operation timeout +`timestamp`:: +Timestamp -- Explicit timestamp for the document +`ttl`:: +<> -- Expiration time for the document +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"force"` + +`id`:: +<> -- Document ID +`index`:: +<> -- The name of the index +`type`:: +<> -- The type of the document +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-update.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-updatebyquery-5-2]] +=== `updateByQuery` + +[source,js] +-------- +client.updateByQuery([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-update-by-query.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`analyzer`:: +<> -- The analyzer to use for the query string +`analyzeWildcard`:: +<> -- Specify whether wildcard and prefix queries should be analyzed (default: false) +`[defaultOperator=OR]`:: +<> -- The default operator for query string query (AND or OR) +Options::: + * `"AND"` + * `"OR"` + +`df`:: +<> -- The field to use as default where no field prefix is given in the query string +`from`:: +<> -- Starting offset (default: 0) +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[conflicts=abort]`:: +<> -- What to do when the update by query hits version conflicts? +Options::: + * `"abort"` + * `"proceed"` + +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`lenient`:: +<> -- Specify whether format-based query failures (such as providing text to a numeric field) should be ignored +`pipeline`:: +<> -- Ingest pipeline to set on index requests made by this action. (default: none) +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`q`:: +<> -- Query in the Lucene query string syntax +`routing`:: +<>, <>, <> -- A comma-separated list of specific routing values +`scroll`:: +<> -- Specify how long a consistent view of the index should be maintained for scrolled search +`searchType`:: +<> -- Search operation type +Options::: + * `"query_then_fetch"` + * `"dfs_query_then_fetch"` + +`searchTimeout`:: +<> -- Explicit timeout for each search request. Defaults to no timeout. +`size`:: +<> -- Number of hits to return (default: 10) +`sort`:: +<>, <>, <> -- A comma-separated list of : pairs +`_source`:: +<>, <>, <> -- True or false to return the _source field or not, or a list of fields to return +`_sourceExclude`:: +<>, <>, <> -- A list of fields to exclude from the returned _source field +`_sourceInclude`:: +<>, <>, <> -- A list of fields to extract and return from the _source field +`terminateAfter`:: +<> -- The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. +`stats`:: +<>, <>, <> -- Specific 'tag' of the request for logging and statistical purposes +`version`:: +<> -- Specify whether to return document version as part of a hit +`versionType`:: +<> -- Should the document increment the version number (internal) on hit or not (reindex) +`requestCache`:: +<> -- Specify if request cache should be used for this request or not, defaults to index level setting +`refresh`:: +<> -- Should the effected indexes be refreshed? +`[timeout=1m]`:: +<> -- Time each individual bulk request should wait for shards that are unavailable. +`waitForActiveShards`:: +<> -- Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) +`scrollSize`:: +<> -- Size on the scroll request powering the update_by_query +`waitForCompletion`:: +<> -- Should the request should block until the update by query operation is complete. +`requestsPerSecond`:: +<> -- The throttle to set on this request in sub-requests per second. -1 means no throttle. +`[slices=1]`:: +<> -- The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. +`index`:: +<>, <>, <> -- A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices +`type`:: +<>, <>, <> -- A comma-separated list of document types to search; leave empty to perform the operation on all types +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-update-by-query.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-cat-aliases-5-2]] +=== `cat.aliases` + +[source,js] +-------- +client.cat.aliases([params, [callback]]) +-------- + +// no description + +Check the *<>* and http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers +`name`:: +<>, <>, <> -- A comma-separated list of alias names to return + +link:#[back to top] + +[[api-cat-allocation-5-2]] +=== `cat.allocation` + +[source,js] +-------- +client.cat.allocation([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-allocation.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`bytes`:: +<> -- The unit in which to display byte values +Options::: + * `"b"` + * `"k"` + * `"kb"` + * `"m"` + * `"mb"` + * `"g"` + * `"gb"` + * `"t"` + * `"tb"` + * `"p"` + * `"pb"` + +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers +`nodeId`:: +<>, <>, <> -- A comma-separated list of node IDs or names to limit the returned information + +link:#[back to top] + +[[api-cat-count-5-2]] +=== `cat.count` + +[source,js] +-------- +client.cat.count([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-count.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers +`index`:: +<>, <>, <> -- A comma-separated list of index names to limit the returned information + +link:#[back to top] + +[[api-cat-fielddata-5-2]] +=== `cat.fielddata` + +[source,js] +-------- +client.cat.fielddata([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-fielddata.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`bytes`:: +<> -- The unit in which to display byte values +Options::: + * `"b"` + * `"k"` + * `"kb"` + * `"m"` + * `"mb"` + * `"g"` + * `"gb"` + * `"t"` + * `"tb"` + * `"p"` + * `"pb"` + +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers +`fields`:: +<>, <>, <> -- A comma-separated list of fields to return the fielddata size + +link:#[back to top] + +[[api-cat-health-5-2]] +=== `cat.health` + +[source,js] +-------- +client.cat.health([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-health.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`[ts=true]`:: +<> -- Set to false to disable timestamping +`v`:: +<> -- Verbose mode. Display column headers + +link:#[back to top] + +[[api-cat-help-5-2]] +=== `cat.help` + +[source,js] +-------- +client.cat.help([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by + +link:#[back to top] + +[[api-cat-indices-5-2]] +=== `cat.indices` + +[source,js] +-------- +client.cat.indices([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-indices.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`bytes`:: +<> -- The unit in which to display byte values +Options::: + * `"b"` + * `"k"` + * `"m"` + * `"g"` + +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`health`:: +<> -- A health status ("green", "yellow", or "red" to filter only indices matching the specified health status +Options::: + * `"green"` + * `"yellow"` + * `"red"` + +`help`:: +<> -- Return help information +`pri`:: +<> -- Set to true to return stats only for primary shards +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers +`index`:: +<>, <>, <> -- A comma-separated list of index names to limit the returned information + +link:#[back to top] + +[[api-cat-master-5-2]] +=== `cat.master` + +[source,js] +-------- +client.cat.master([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-master.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers + +link:#[back to top] + +[[api-cat-nodeattrs-5-2]] +=== `cat.nodeattrs` + +[source,js] +-------- +client.cat.nodeattrs([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-nodeattrs.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers + +link:#[back to top] + +[[api-cat-nodes-5-2]] +=== `cat.nodes` + +[source,js] +-------- +client.cat.nodes([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-nodes.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`fullId`:: +<> -- Return the full node ID instead of the shortened version (default: false) +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers + +link:#[back to top] + +[[api-cat-pendingtasks-5-2]] +=== `cat.pendingTasks` + +[source,js] +-------- +client.cat.pendingTasks([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-pending-tasks.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers + +link:#[back to top] + +[[api-cat-plugins-5-2]] +=== `cat.plugins` + +[source,js] +-------- +client.cat.plugins([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-plugins.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers + +link:#[back to top] + +[[api-cat-recovery-5-2]] +=== `cat.recovery` + +[source,js] +-------- +client.cat.recovery([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-recovery.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`bytes`:: +<> -- The unit in which to display byte values +Options::: + * `"b"` + * `"k"` + * `"kb"` + * `"m"` + * `"mb"` + * `"g"` + * `"gb"` + * `"t"` + * `"tb"` + * `"p"` + * `"pb"` + +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers +`index`:: +<>, <>, <> -- A comma-separated list of index names to limit the returned information + +link:#[back to top] + +[[api-cat-repositories-5-2]] +=== `cat.repositories` + +[source,js] +-------- +client.cat.repositories([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-repositories.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`local`:: +<> -- Return local information, do not retrieve the state from master node +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers + +link:#[back to top] + +[[api-cat-segments-5-2]] +=== `cat.segments` + +[source,js] +-------- +client.cat.segments([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-segments.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers +`index`:: +<>, <>, <> -- A comma-separated list of index names to limit the returned information + +link:#[back to top] + +[[api-cat-shards-5-2]] +=== `cat.shards` + +[source,js] +-------- +client.cat.shards([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-shards.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers +`index`:: +<>, <>, <> -- A comma-separated list of index names to limit the returned information + +link:#[back to top] + +[[api-cat-snapshots-5-2]] +=== `cat.snapshots` + +[source,js] +-------- +client.cat.snapshots([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-snapshots.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`ignoreUnavailable`:: +<> -- Set to true to ignore unavailable snapshots +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers +`repository`:: +<>, <>, <> -- Name of repository from which to fetch the snapshot information + +link:#[back to top] + +[[api-cat-tasks-5-2]] +=== `cat.tasks` + +[source,js] +-------- +client.cat.tasks([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/tasks.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`nodeId`:: +<>, <>, <> -- A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes +`actions`:: +<>, <>, <> -- A comma-separated list of actions that should be returned. Leave empty to return all. +`detailed`:: +<> -- Return detailed task information (default: false) +`parentNode`:: +<> -- Return tasks with specified parent node. +`parentTask`:: +<> -- Return tasks with specified parent task id. Set to -1 to return all. +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers + +link:#[back to top] + +[[api-cat-templates-5-2]] +=== `cat.templates` + +[source,js] +-------- +client.cat.templates([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-templates.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers +`name`:: +<> -- A pattern that returned template names must match + +link:#[back to top] + +[[api-cat-threadpool-5-2]] +=== `cat.threadPool` + +[source,js] +-------- +client.cat.threadPool([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-thread-pool.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`size`:: +<> -- The multiplier in which to display values +Options::: + * `""` + * `"k"` + * `"m"` + * `"g"` + * `"t"` + * `"p"` + +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers +`threadPoolPatterns`:: +<>, <>, <> -- A comma-separated list of regular-expressions to filter the thread pools in the output + +link:#[back to top] + +[[api-cluster-allocationexplain-5-2]] +=== `cluster.allocationExplain` + +[source,js] +-------- +client.cluster.allocationExplain([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-allocation-explain.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`includeYesDecisions`:: +<> -- Return 'YES' decisions in explanation (default: false) +`includeDiskInfo`:: +<> -- Return information about disk usage and shard sizes (default: false) +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-allocation-explain.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-cluster-getsettings-5-2]] +=== `cluster.getSettings` + +[source,js] +-------- +client.cluster.getSettings([params, [callback]]) +-------- + +Get cluster settings (previously set with `putSettings()`) + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-update-settings.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`flatSettings`:: +<> -- Return settings in flat format (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`timeout`:: +<> -- Explicit operation timeout +`includeDefaults`:: +<> -- Whether to return all default clusters setting. + +link:#[back to top] + +[[api-cluster-health-5-2]] +=== `cluster.health` + +[source,js] +-------- +client.cluster.health([params, [callback]]) +-------- + +Get a very simple status on the health of the cluster. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-health.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`[level=cluster]`:: +<> -- Specify the level of detail for returned information +Options::: + * `"cluster"` + * `"indices"` + * `"shards"` + +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`timeout`:: +<> -- Explicit operation timeout +`waitForActiveShards`:: +<> -- Wait until the specified number of shards is active +`waitForNodes`:: +<> -- Wait until the specified number of nodes is available +`waitForEvents`:: +<> -- Wait until all currently queued events with the given priority are processed +Options::: + * `"immediate"` + * `"urgent"` + * `"high"` + * `"normal"` + * `"low"` + * `"languid"` + +`waitForNoRelocatingShards`:: +<> -- Whether to wait until there are no relocating shards in the cluster +`waitForStatus`:: +<> -- Wait until cluster is in a specific state +Options::: + * `"green"` + * `"yellow"` + * `"red"` + +`index`:: +<>, <>, <> -- Limit the information returned to a specific index + +link:#[back to top] + +[[api-cluster-pendingtasks-5-2]] +=== `cluster.pendingTasks` + +[source,js] +-------- +client.cluster.pendingTasks([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-pending.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Specify timeout for connection to master + +link:#[back to top] + +[[api-cluster-putsettings-5-2]] +=== `cluster.putSettings` + +[source,js] +-------- +client.cluster.putSettings([params, [callback]]) +-------- + +Update cluster wide specific settings. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-update-settings.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`flatSettings`:: +<> -- Return settings in flat format (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`timeout`:: +<> -- Explicit operation timeout +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-update-settings.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-cluster-reroute-5-2]] +=== `cluster.reroute` + +[source,js] +-------- +client.cluster.reroute([params, [callback]]) +-------- + +Explicitly execute a cluster reroute allocation command including specific commands. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-reroute.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`dryRun`:: +<> -- Simulate the operation only and return the resulting state +`explain`:: +<> -- Return an explanation of why the commands can or cannot be executed +`retryFailed`:: +<> -- Retries allocation of shards that are blocked due to too many subsequent allocation failures +`metric`:: +<>, <>, <> -- Limit the information returned to the specified metrics. Defaults to all but metadata +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`timeout`:: +<> -- Explicit operation timeout +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-reroute.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-cluster-state-5-2]] +=== `cluster.state` + +[source,js] +-------- +client.cluster.state([params, [callback]]) +-------- + +Get comprehensive details about the state of the whole cluster (indices settings, allocations, etc). + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-state.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Specify timeout for connection to master +`flatSettings`:: +<> -- Return settings in flat format (default: false) +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +`metric`:: +<>, <>, <> -- Limit the information returned to the specified metrics + +link:#[back to top] + +[[api-cluster-stats-5-2]] +=== `cluster.stats` + +[source,js] +-------- +client.cluster.stats([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-stats.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`flatSettings`:: +<> -- Return settings in flat format (default: false) +`human`:: +<> -- Whether to return time and byte values in human-readable format. +`timeout`:: +<> -- Explicit operation timeout +`nodeId`:: +<>, <>, <> -- A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +link:#[back to top] + +[[api-indices-analyze-5-2]] +=== `indices.analyze` + +[source,js] +-------- +client.indices.analyze([params, [callback]]) +-------- + +Perform the analysis process on a text and return the tokens breakdown of the text. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-analyze.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`analyzer`:: +<> -- The name of the analyzer to use +`charFilter`:: +<>, <>, <> -- A comma-separated list of character filters to use for the analysis +`field`:: +<> -- Use the analyzer configured for this field (instead of passing the analyzer name) +`filter`:: +<>, <>, <> -- A comma-separated list of filters to use for the analysis +`index`:: +<> -- The name of the index to scope the operation +`preferLocal`:: +<> -- With `true`, specify that a local shard should be used if available, with `false`, use a random shard (default: true) +`text`:: +<>, <>, <> -- The text on which the analysis should be performed (when request body is not used) +`tokenizer`:: +<> -- The name of the tokenizer to use for the analysis +`explain`:: +<> -- With `true`, outputs more advanced details. (default: false) +`attributes`:: +<>, <>, <> -- A comma-separated list of token attributes to output, this parameter works only with `explain=true` +`[format=detailed]`:: +<> -- Format of the output +Options::: + * `"detailed"` + * `"text"` + +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-analyze.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-clearcache-5-2]] +=== `indices.clearCache` + +[source,js] +-------- +client.indices.clearCache([params, [callback]]) +-------- + +Clear either all caches or specific cached associated with one ore more indices. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-clearcache.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`fieldData`:: +<> -- Clear field data +`fielddata`:: +<> -- Clear field data +`fields`:: +<>, <>, <> -- A comma-separated list of fields to clear when using the `field_data` parameter (default: all) +`query`:: +<> -- Clear query caches +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`index`:: +<>, <>, <> -- A comma-separated list of index name to limit the operation +`recycler`:: +<> -- Clear the recycler cache +`request`:: +<> -- Clear request cache +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-clearcache.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-close-5-2]] +=== `indices.close` + +[source,js] +-------- +client.indices.close([params, [callback]]) +-------- + +Close an index to remove its overhead from the cluster. Closed index is blocked for read/write operations. + + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-open-close.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`timeout`:: +<> -- Explicit operation timeout +`masterTimeout`:: +<> -- Specify timeout for connection to master +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`index`:: +<>, <>, <> -- A comma separated list of indices to close +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-open-close.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-create-5-2]] +=== `indices.create` + +[source,js] +-------- +client.indices.create([params, [callback]]) +-------- + +Create an index in Elasticsearch. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-create-index.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`waitForActiveShards`:: +<> -- Set the number of active shards to wait for before the operation returns. +`timeout`:: +<> -- Explicit operation timeout +`masterTimeout`:: +<> -- Specify timeout for connection to master +`updateAllTypes`:: +<> -- Whether to update the mapping for all fields with the same name across all types or not +`index`:: +<> -- The name of the index +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-create-index.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-delete-5-2]] +=== `indices.delete` + +[source,js] +-------- +client.indices.delete([params, [callback]]) +-------- + +Delete an index in Elasticsearch + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-delete-index.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`timeout`:: +<> -- Explicit operation timeout +`masterTimeout`:: +<> -- Specify timeout for connection to master +`index`:: +<>, <>, <> -- A comma-separated list of indices to delete; use `_all` or `*` string to delete all indices +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-delete-index.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-deletealias-5-2]] +=== `indices.deleteAlias` + +[source,js] +-------- +client.indices.deleteAlias([params, [callback]]) +-------- + +Delete a specific alias. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`timeout`:: +<> -- Explicit timestamp for the document +`masterTimeout`:: +<> -- Specify timeout for connection to master +`index`:: +<>, <>, <> -- A comma-separated list of index names (supports wildcards); use `_all` for all indices +`name`:: +<>, <>, <> -- A comma-separated list of aliases to delete (supports wildcards); use `_all` to delete all aliases for the specified indices. +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-deletetemplate-5-2]] +=== `indices.deleteTemplate` + +[source,js] +-------- +client.indices.deleteTemplate([params, [callback]]) +-------- + +Delete an index template by its name. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`timeout`:: +<> -- Explicit operation timeout +`masterTimeout`:: +<> -- Specify timeout for connection to master +`name`:: +<> -- The name of the template +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-exists-5-2]] +=== `indices.exists` + +[source,js] +-------- +client.indices.exists([params, [callback]]) +-------- + +Return a boolean indicating whether given index exists. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-exists.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`index`:: +<>, <>, <> -- A comma-separated list of indices to check +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-exists.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-existsalias-5-2]] +=== `indices.existsAlias` + +[source,js] +-------- +client.indices.existsAlias([params, [callback]]) +-------- + +Return a boolean indicating whether given alias exists. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open,closed]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`index`:: +<>, <>, <> -- A comma-separated list of index names to filter aliases +`name`:: +<>, <>, <> -- A comma-separated list of alias names to return +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-existstemplate-5-2]] +=== `indices.existsTemplate` + +[source,js] +-------- +client.indices.existsTemplate([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`name`:: +<> -- The name of the template +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-existstype-5-2]] +=== `indices.existsType` + +[source,js] +-------- +client.indices.existsType([params, [callback]]) +-------- + +Check if a type/types exists in an index/indices. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-types-exists.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` to check the types across all indices +`type`:: +<>, <>, <> -- A comma-separated list of document types to check +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-types-exists.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-flush-5-2]] +=== `indices.flush` + +[source,js] +-------- +client.indices.flush([params, [callback]]) +-------- + +Explicitly flush one or more indices. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-flush.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`force`:: +<> -- Whether a flush should be forced even if it is not necessarily needed ie. if no changes will be committed to the index. This is useful if transaction log IDs should be incremented even if no uncommitted changes are present. (This setting can be considered as internal) +`waitIfOngoing`:: +<> -- If set to true the flush operation will block until the flush can be executed if another flush operation is already executing. The default is true. If set to false the flush will be skipped iff if another flush operation is already running. +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string for all indices +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-flush.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-flushsynced-5-2]] +=== `indices.flushSynced` + +[source,js] +-------- +client.indices.flushSynced([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-synced-flush.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string for all indices +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-synced-flush.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-forcemerge-5-2]] +=== `indices.forcemerge` + +[source,js] +-------- +client.indices.forcemerge([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-forcemerge.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`flush`:: +<> -- Specify whether the index should be flushed after performing the operation (default: true) +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`maxNumSegments`:: +<> -- The number of segments the index should be merged into (default: dynamic) +`onlyExpungeDeletes`:: +<> -- Specify whether the operation should only expunge deleted documents +`operationThreading`:: +anything -- TODO: ? +`waitForMerge`:: +<> -- Specify whether the request should block until the merge process is finished (default: true) +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-forcemerge.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-get-5-2]] +=== `indices.get` + +[source,js] +-------- +client.indices.get([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-get-index.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`ignoreUnavailable`:: +<> -- Ignore unavailable indexes (default: false) +`allowNoIndices`:: +<> -- Ignore if a wildcard expression resolves to no concrete indices (default: false) +`[expandWildcards=open]`:: +<> -- Whether wildcard expressions should get expanded to open or closed indices (default: open) +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`flatSettings`:: +<> -- Return settings in flat format (default: false) +`human`:: +<> -- Whether to return version and creation date values in human-readable format. +`includeDefaults`:: +<> -- Whether to return all default setting for each of the indices. +`index`:: +<>, <>, <> -- A comma-separated list of index names +`feature`:: +<>, <>, <> -- A comma-separated list of features + +link:#[back to top] + +[[api-indices-getalias-5-2]] +=== `indices.getAlias` + +[source,js] +-------- +client.indices.getAlias([params, [callback]]) +-------- + +Retrieve a specified alias. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=all]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`index`:: +<>, <>, <> -- A comma-separated list of index names to filter aliases +`name`:: +<>, <>, <> -- A comma-separated list of alias names to return + +link:#[back to top] + +[[api-indices-getfieldmapping-5-2]] +=== `indices.getFieldMapping` + +[source,js] +-------- +client.indices.getFieldMapping([params, [callback]]) +-------- + +Retrieve mapping definition of a specific field. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-get-field-mapping.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`includeDefaults`:: +<> -- Whether the default mapping values should be returned as well +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`index`:: +<>, <>, <> -- A comma-separated list of index names +`type`:: +<>, <>, <> -- A comma-separated list of document types +`fields`:: +<>, <>, <> -- A comma-separated list of fields + +link:#[back to top] + +[[api-indices-getmapping-5-2]] +=== `indices.getMapping` + +[source,js] +-------- +client.indices.getMapping([params, [callback]]) +-------- + +Retrieve mapping definition of index or index/type. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-get-mapping.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`index`:: +<>, <>, <> -- A comma-separated list of index names +`type`:: +<>, <>, <> -- A comma-separated list of document types + +link:#[back to top] + +[[api-indices-getsettings-5-2]] +=== `indices.getSettings` + +[source,js] +-------- +client.indices.getSettings([params, [callback]]) +-------- + +Retrieve settings for one or more (or all) indices. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-get-settings.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open,closed]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`flatSettings`:: +<> -- Return settings in flat format (default: false) +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`human`:: +<> -- Whether to return version and creation date values in human-readable format. +`includeDefaults`:: +<> -- Whether to return all default setting for each of the indices. +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +`name`:: +<>, <>, <> -- The name of the settings that should be included + +link:#[back to top] + +[[api-indices-gettemplate-5-2]] +=== `indices.getTemplate` + +[source,js] +-------- +client.indices.getTemplate([params, [callback]]) +-------- + +Retrieve an index template by its name. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`flatSettings`:: +<> -- Return settings in flat format (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`name`:: +<>, <>, <> -- The comma separated names of the index templates + +link:#[back to top] + +[[api-indices-getupgrade-5-2]] +=== `indices.getUpgrade` + +[source,js] +-------- +client.indices.getUpgrade([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-upgrade.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`human`:: +<> -- Whether to return time and byte values in human-readable format. +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + +link:#[back to top] + +[[api-indices-open-5-2]] +=== `indices.open` + +[source,js] +-------- +client.indices.open([params, [callback]]) +-------- + +Open a closed index, making it available for search. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-open-close.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`timeout`:: +<> -- Explicit operation timeout +`masterTimeout`:: +<> -- Specify timeout for connection to master +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=closed]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`index`:: +<>, <>, <> -- A comma separated list of indices to open +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-open-close.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-putalias-5-2]] +=== `indices.putAlias` + +[source,js] +-------- +client.indices.putAlias([params, [callback]]) +-------- + +Create an alias for a specific index/indices. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`timeout`:: +<> -- Explicit timestamp for the document +`masterTimeout`:: +<> -- Specify timeout for connection to master +`index`:: +<>, <>, <> -- A comma-separated list of index names the alias should point to (supports wildcards); use `_all` to perform the operation on all indices. +`name`:: +<> -- The name of the alias to be created or updated +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-putmapping-5-2]] +=== `indices.putMapping` + +[source,js] +-------- +client.indices.putMapping([params, [callback]]) +-------- + +Register specific mapping definition for a specific type. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-put-mapping.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`timeout`:: +<> -- Explicit operation timeout +`masterTimeout`:: +<> -- Specify timeout for connection to master +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`updateAllTypes`:: +<> -- Whether to update the mapping for all fields with the same name across all types or not +`index`:: +<>, <>, <> -- A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. +`type`:: +<> -- The name of the document type +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-put-mapping.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-putsettings-5-2]] +=== `indices.putSettings` + +[source,js] +-------- +client.indices.putSettings([params, [callback]]) +-------- + +Change specific index level settings in real time. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-update-settings.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Specify timeout for connection to master +`preserveExisting`:: +<> -- Whether to update existing settings. If set to `true` existing settings on an index remain unchanged, the default is `false` +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`flatSettings`:: +<> -- Return settings in flat format (default: false) +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-update-settings.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-puttemplate-5-2]] +=== `indices.putTemplate` + +[source,js] +-------- +client.indices.putTemplate([params, [callback]]) +-------- + +Create an index template that will automatically be applied to new indices created. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`order`:: +<> -- The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers) +`create`:: +<> -- Whether the index template should only be added if new or can also replace an existing one +`timeout`:: +<> -- Explicit operation timeout +`masterTimeout`:: +<> -- Specify timeout for connection to master +`flatSettings`:: +<> -- Return settings in flat format (default: false) +`name`:: +<> -- The name of the template +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-recovery-5-2]] +=== `indices.recovery` + +[source,js] +-------- +client.indices.recovery([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-recovery.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`detailed`:: +<> -- Whether to display detailed information about shard recovery +`activeOnly`:: +<> -- Display only those recoveries that are currently on-going +`human`:: +<> -- Whether to return time and byte values in human-readable format. +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + +link:#[back to top] + +[[api-indices-refresh-5-2]] +=== `indices.refresh` + +[source,js] +-------- +client.indices.refresh([params, [callback]]) +-------- + +Explicitly refresh one or more index, making all operations performed since the last refresh available for search. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-refresh.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`force`:: +<> -- Force a refresh even if not required +`operationThreading`:: +anything -- TODO: ? +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-refresh.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-rollover-5-2]] +=== `indices.rollover` + +[source,js] +-------- +client.indices.rollover([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-rollover-index.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`timeout`:: +<> -- Explicit operation timeout +`dryRun`:: +<> -- If set to true the rollover action will only be validated but not actually performed even if a condition matches. The default is false +`masterTimeout`:: +<> -- Specify timeout for connection to master +`waitForActiveShards`:: +<> -- Set the number of active shards to wait for on the newly created rollover index before the operation returns. +`alias`:: +<> -- The name of the alias to rollover +`newIndex`:: +<> -- The name of the rollover index +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-rollover-index.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-segments-5-2]] +=== `indices.segments` + +[source,js] +-------- +client.indices.segments([params, [callback]]) +-------- + +Retrieve low level segments information that a Lucene index (shard level) is built with. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-segments.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`human`:: +<> -- Whether to return time and byte values in human-readable format. +`operationThreading`:: +anything -- TODO: ? +`verbose`:: +<> -- Includes detailed memory usage by Lucene. +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + +link:#[back to top] + +[[api-indices-shardstores-5-2]] +=== `indices.shardStores` + +[source,js] +-------- +client.indices.shardStores([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-shards-stores.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`status`:: +<>, <>, <> -- A comma-separated list of statuses used to filter on shards to get store information for +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`operationThreading`:: +anything -- TODO: ? +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + +link:#[back to top] + +[[api-indices-shrink-5-2]] +=== `indices.shrink` + +[source,js] +-------- +client.indices.shrink([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-shrink-index.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`timeout`:: +<> -- Explicit operation timeout +`masterTimeout`:: +<> -- Specify timeout for connection to master +`waitForActiveShards`:: +<> -- Set the number of active shards to wait for on the shrunken index before the operation returns. +`index`:: +<> -- The name of the source index to shrink +`target`:: +<> -- The name of the target index to shrink into +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-shrink-index.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-stats-5-2]] +=== `indices.stats` + +[source,js] +-------- +client.indices.stats([params, [callback]]) +-------- + +Retrieve statistics on different operations happening on an index. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-stats.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`completionFields`:: +<>, <>, <> -- A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards) +`fielddataFields`:: +<>, <>, <> -- A comma-separated list of fields for `fielddata` index metric (supports wildcards) +`fields`:: +<>, <>, <> -- A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) +`groups`:: +<>, <>, <> -- A comma-separated list of search groups for `search` index metric +`human`:: +<> -- Whether to return time and byte values in human-readable format. +`[level=indices]`:: +<> -- Return stats aggregated at cluster, index or shard level +Options::: + * `"cluster"` + * `"indices"` + * `"shards"` + +`types`:: +<>, <>, <> -- A comma-separated list of document types for the `indexing` index metric +`includeSegmentFileSizes`:: +<> -- Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +`metric`:: +<>, <>, <> -- Limit the information returned the specific metrics. + +link:#[back to top] + +[[api-indices-updatealiases-5-2]] +=== `indices.updateAliases` + +[source,js] +-------- +client.indices.updateAliases([params, [callback]]) +-------- + +Update specified aliases. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html[the elasticsearch docs] for more information pertaining to this method. + +.Perform an atomic alias swap, for a rotating index +[source,js] +--------- +client.indices.updateAliases({ + body: { + actions: [ + { remove: { index: 'logstash-2014.04', alias: 'logstash-current' } }, + { add: { index: 'logstash-2014.05', alias: 'logstash-current' } } + ] + } +}).then(function (response) { + // ... +}, errorHandler); +--------- + + +*Params* + +[horizontal] +`timeout`:: +<> -- Request timeout +`masterTimeout`:: +<> -- Specify timeout for connection to master +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-upgrade-5-2]] +=== `indices.upgrade` + +[source,js] +-------- +client.indices.upgrade([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-upgrade.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`waitForCompletion`:: +<> -- Specify whether the request should block until the all segments are upgraded (default: false) +`onlyAncientSegments`:: +<> -- If true, only ancient (an older Lucene major release) segments will be upgraded +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-upgrade.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-validatequery-5-2]] +=== `indices.validateQuery` + +[source,js] +-------- +client.indices.validateQuery([params, [callback]]) +-------- + +Validate a potentially expensive query without executing it. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-validate.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`explain`:: +<> -- Return detailed information about the error +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`operationThreading`:: +anything -- TODO: ? +`q`:: +<> -- Query in the Lucene query string syntax +`analyzer`:: +<> -- The analyzer to use for the query string +`analyzeWildcard`:: +<> -- Specify whether wildcard and prefix queries should be analyzed (default: false) +`[defaultOperator=OR]`:: +<> -- The default operator for query string query (AND or OR) +Options::: + * `"AND"` + * `"OR"` + +`df`:: +<> -- The field to use as default where no field prefix is given in the query string +`lenient`:: +<> -- Specify whether format-based query failures (such as providing text to a numeric field) should be ignored +`rewrite`:: +<> -- Provide a more detailed explanation showing the actual Lucene query that will be executed. +`index`:: +<>, <>, <> -- A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices +`type`:: +<>, <>, <> -- A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-validate.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-ingest-deletepipeline-5-2]] +=== `ingest.deletePipeline` + +[source,js] +-------- +client.ingest.deletePipeline([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/plugins/5.x/ingest.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`timeout`:: +<> -- Explicit operation timeout +`id`:: +<> -- Pipeline ID +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/plugins/5.x/ingest.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-ingest-getpipeline-5-2]] +=== `ingest.getPipeline` + +[source,js] +-------- +client.ingest.getPipeline([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/plugins/5.x/ingest.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`id`:: +<> -- Comma separated list of pipeline ids. Wildcards supported + +link:#[back to top] + +[[api-ingest-putpipeline-5-2]] +=== `ingest.putPipeline` + +[source,js] +-------- +client.ingest.putPipeline([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/plugins/5.x/ingest.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`timeout`:: +<> -- Explicit operation timeout +`id`:: +<> -- Pipeline ID +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/plugins/5.x/ingest.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-ingest-simulate-5-2]] +=== `ingest.simulate` + +[source,js] +-------- +client.ingest.simulate([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/plugins/5.x/ingest.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`verbose`:: +<> -- Verbose mode. Display data output for each processor in executed pipeline +`id`:: +<> -- Pipeline ID +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/plugins/5.x/ingest.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-nodes-hotthreads-5-2]] +=== `nodes.hotThreads` + +[source,js] +-------- +client.nodes.hotThreads([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-nodes-hot-threads.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`interval`:: +<> -- The interval for the second sampling of threads +`snapshots`:: +<> -- Number of samples of thread stacktrace (default: 10) +`threads`:: +<> -- Specify the number of threads to provide information for (default: 3) +`ignoreIdleThreads`:: +<> -- Don't show threads that are in known-idle places, such as waiting on a socket select or pulling from an empty task queue (default: true) +`type`:: +<> -- The type to sample (default: cpu) +Options::: + * `"cpu"` + * `"wait"` + * `"block"` + +`timeout`:: +<> -- Explicit operation timeout +`nodeId`:: +<>, <>, <> -- A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +link:#[back to top] + +[[api-nodes-info-5-2]] +=== `nodes.info` + +[source,js] +-------- +client.nodes.info([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-nodes-info.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`flatSettings`:: +<> -- Return settings in flat format (default: false) +`human`:: +<> -- Whether to return time and byte values in human-readable format. +`timeout`:: +<> -- Explicit operation timeout +`nodeId`:: +<>, <>, <> -- A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes +`metric`:: +<>, <>, <> -- A comma-separated list of metrics you wish returned. Leave empty to return all. + +link:#[back to top] + +[[api-nodes-stats-5-2]] +=== `nodes.stats` + +[source,js] +-------- +client.nodes.stats([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-nodes-stats.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`completionFields`:: +<>, <>, <> -- A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards) +`fielddataFields`:: +<>, <>, <> -- A comma-separated list of fields for `fielddata` index metric (supports wildcards) +`fields`:: +<>, <>, <> -- A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) +`groups`:: +<> -- A comma-separated list of search groups for `search` index metric +`human`:: +<> -- Whether to return time and byte values in human-readable format. +`[level=node]`:: +<> -- Return indices stats aggregated at index, node or shard level +Options::: + * `"indices"` + * `"node"` + * `"shards"` + +`types`:: +<>, <>, <> -- A comma-separated list of document types for the `indexing` index metric +`timeout`:: +<> -- Explicit operation timeout +`includeSegmentFileSizes`:: +<> -- Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) +`metric`:: +<>, <>, <> -- Limit the information returned to the specified metrics +`indexMetric`:: +<>, <>, <> -- Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified. +`nodeId`:: +<>, <>, <> -- A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +link:#[back to top] + +[[api-snapshot-create-5-2]] +=== `snapshot.create` + +[source,js] +-------- +client.snapshot.create([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`waitForCompletion`:: +<> -- Should this request wait until the operation has completed before returning +`repository`:: +<> -- A repository name +`snapshot`:: +<> -- A snapshot name +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-snapshot-createrepository-5-2]] +=== `snapshot.createRepository` + +[source,js] +-------- +client.snapshot.createRepository([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`timeout`:: +<> -- Explicit operation timeout +`verify`:: +<> -- Whether to verify the repository after creation +`repository`:: +<> -- A repository name +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-snapshot-delete-5-2]] +=== `snapshot.delete` + +[source,js] +-------- +client.snapshot.delete([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`repository`:: +<> -- A repository name +`snapshot`:: +<> -- A snapshot name +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-snapshot-deleterepository-5-2]] +=== `snapshot.deleteRepository` + +[source,js] +-------- +client.snapshot.deleteRepository([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`timeout`:: +<> -- Explicit operation timeout +`repository`:: +<>, <>, <> -- A comma-separated list of repository names +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-snapshot-get-5-2]] +=== `snapshot.get` + +[source,js] +-------- +client.snapshot.get([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`ignoreUnavailable`:: +<> -- Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown +`repository`:: +<> -- A repository name +`snapshot`:: +<>, <>, <> -- A comma-separated list of snapshot names + +link:#[back to top] + +[[api-snapshot-getrepository-5-2]] +=== `snapshot.getRepository` + +[source,js] +-------- +client.snapshot.getRepository([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`repository`:: +<>, <>, <> -- A comma-separated list of repository names + +link:#[back to top] + +[[api-snapshot-restore-5-2]] +=== `snapshot.restore` + +[source,js] +-------- +client.snapshot.restore([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`waitForCompletion`:: +<> -- Should this request wait until the operation has completed before returning +`repository`:: +<> -- A repository name +`snapshot`:: +<> -- A snapshot name +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-snapshot-status-5-2]] +=== `snapshot.status` + +[source,js] +-------- +client.snapshot.status([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`ignoreUnavailable`:: +<> -- Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown +`repository`:: +<> -- A repository name +`snapshot`:: +<>, <>, <> -- A comma-separated list of snapshot names + +link:#[back to top] + +[[api-snapshot-verifyrepository-5-2]] +=== `snapshot.verifyRepository` + +[source,js] +-------- +client.snapshot.verifyRepository([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`timeout`:: +<> -- Explicit operation timeout +`repository`:: +<> -- A repository name +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-tasks-cancel-5-2]] +=== `tasks.cancel` + +[source,js] +-------- +client.tasks.cancel([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/tasks.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`nodeId`:: +<>, <>, <> -- A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes +`actions`:: +<>, <>, <> -- A comma-separated list of actions that should be cancelled. Leave empty to cancel all. +`parentNode`:: +<> -- Cancel tasks with specified parent node. +`parentTask`:: +<> -- Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all. +`taskId`:: +<> -- Cancel the task with specified task id (node_id:task_number) +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/tasks.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-tasks-get-5-2]] +=== `tasks.get` + +[source,js] +-------- +client.tasks.get([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/tasks.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`waitForCompletion`:: +<> -- Wait for the matching tasks to complete (default: false) +`taskId`:: +<> -- Return the task with specified id (node_id:task_number) + +link:#[back to top] + +[[api-tasks-list-5-2]] +=== `tasks.list` + +[source,js] +-------- +client.tasks.list([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/tasks.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`nodeId`:: +<>, <>, <> -- A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes +`actions`:: +<>, <>, <> -- A comma-separated list of actions that should be returned. Leave empty to return all. +`detailed`:: +<> -- Return detailed task information (default: false) +`parentNode`:: +<> -- Return tasks with specified parent node. +`parentTask`:: +<> -- Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all. +`waitForCompletion`:: +<> -- Wait for the matching tasks to complete (default: false) +`[groupBy=nodes]`:: +<> -- Group tasks by nodes or parent/child relationships +Options::: + * `"nodes"` + * `"parents"` + + +link:#[back to top] diff --git a/docs/configuration.asciidoc b/docs/configuration.asciidoc index 1327c6cac..58adba2cf 100644 --- a/docs/configuration.asciidoc +++ b/docs/configuration.asciidoc @@ -52,9 +52,10 @@ Default in Node::: + WARNING: This default will track the latest version of Elasticsearch, and is only intended to be used during development. It is highly recommended that you set this parameter in all code that is headed to production. -Default ::: `'5.2'` +Default ::: `'5.3'` Options in node ::: + * `'5.3'` * `'5.2'` * `'5.1'` * `'5.0'` @@ -62,17 +63,15 @@ Options in node ::: * `'1.7'` * `'0.90'` * `'5.x'` (unstable) - * `'5.3'` (unstable) * `'master'` (unstable) Options in the browser ::: + * `'5.3'` * `'5.2'` * `'5.1'` * `'5.0'` * `'2.4'` - * `'1.7'` * `'5.x'` (unstable) - * `'5.3'` (unstable) * `'master'` (unstable) diff --git a/docs/index.asciidoc b/docs/index.asciidoc index d0193dc56..d4c6785fa 100644 --- a/docs/index.asciidoc +++ b/docs/index.asciidoc @@ -22,6 +22,8 @@ include::development.asciidoc[] include::api_methods.asciidoc[] +include::api_methods_5_2.asciidoc[] + include::api_methods_5_1.asciidoc[] include::api_methods_5_0.asciidoc[] diff --git a/src/lib/apis/5_3.js b/src/lib/apis/5_3.js index ddc654c99..3eb40a175 100644 --- a/src/lib/apis/5_3.js +++ b/src/lib/apis/5_3.js @@ -1968,7 +1968,7 @@ api['delete'] = ca({ * @param {<>} [params.timeout=1m] - Time each individual bulk request should wait for shards that are unavailable. * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) * @param {<>} params.scrollSize - Size on the scroll request powering the update_by_query - * @param {<>} params.waitForCompletion - Should the request should block until the delete-by-query is complete. + * @param {<>} [params.waitForCompletion=true] - Should the request should block until the delete-by-query is complete. * @param {<>} params.requestsPerSecond - The throttle for this request in sub-requests per second. -1 means no throttle. * @param {<>} [params.slices=1] - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. * @param {<>, <>, <>} params.index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices @@ -2100,7 +2100,7 @@ api.deleteByQuery = ca({ }, waitForCompletion: { type: 'boolean', - 'default': false, + 'default': true, name: 'wait_for_completion' }, requestsPerSecond: { @@ -5738,7 +5738,7 @@ api.putTemplate = ca({ * @param {<>} params.refresh - Should the effected indexes be refreshed? * @param {<>} [params.timeout=1m] - Time each individual bulk request should wait for shards that are unavailable. * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - * @param {<>} params.waitForCompletion - Should the request should block until the reindex is complete. + * @param {<>} [params.waitForCompletion=true] - Should the request should block until the reindex is complete. * @param {<>} params.requestsPerSecond - The throttle to set on this request in sub-requests per second. -1 means no throttle. * @param {<>} [params.slices=1] - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. */ @@ -5757,7 +5757,7 @@ api.reindex = ca({ }, waitForCompletion: { type: 'boolean', - 'default': false, + 'default': true, name: 'wait_for_completion' }, requestsPerSecond: { @@ -6966,7 +6966,7 @@ api.update = ca({ * @param {<>} [params.timeout=1m] - Time each individual bulk request should wait for shards that are unavailable. * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) * @param {<>} params.scrollSize - Size on the scroll request powering the update_by_query - * @param {<>} params.waitForCompletion - Should the request should block until the update by query operation is complete. + * @param {<>} [params.waitForCompletion=true] - Should the request should block until the update by query operation is complete. * @param {<>} params.requestsPerSecond - The throttle to set on this request in sub-requests per second. -1 means no throttle. * @param {<>} [params.slices=1] - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. * @param {<>, <>, <>} params.index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices @@ -7105,7 +7105,7 @@ api.updateByQuery = ca({ }, waitForCompletion: { type: 'boolean', - 'default': false, + 'default': true, name: 'wait_for_completion' }, requestsPerSecond: { diff --git a/src/lib/apis/5_x.js b/src/lib/apis/5_x.js index 0eb71b7a1..2f7445b9e 100644 --- a/src/lib/apis/5_x.js +++ b/src/lib/apis/5_x.js @@ -1968,7 +1968,7 @@ api['delete'] = ca({ * @param {<>} [params.timeout=1m] - Time each individual bulk request should wait for shards that are unavailable. * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) * @param {<>} params.scrollSize - Size on the scroll request powering the update_by_query - * @param {<>} params.waitForCompletion - Should the request should block until the delete-by-query is complete. + * @param {<>} [params.waitForCompletion=true] - Should the request should block until the delete-by-query is complete. * @param {<>} params.requestsPerSecond - The throttle for this request in sub-requests per second. -1 means no throttle. * @param {<>} [params.slices=1] - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. * @param {<>, <>, <>} params.index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices @@ -2100,7 +2100,7 @@ api.deleteByQuery = ca({ }, waitForCompletion: { type: 'boolean', - 'default': false, + 'default': true, name: 'wait_for_completion' }, requestsPerSecond: { @@ -2192,17 +2192,27 @@ api.deleteTemplate = ca({ * Perform a [exists](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-get.html) request * * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.storedFields - A comma-separated list of stored fields to return in the response * @param {<>} params.parent - The ID of the parent document * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) * @param {<>} params.realtime - Specify whether to perform the operation in realtime or search mode * @param {<>} params.refresh - Refresh the shard containing the document before performing the operation * @param {<>} params.routing - Specific routing value + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type * @param {<>} params.id - The document ID * @param {<>} params.index - The name of the index * @param {<>} params.type - The type of the document (use `_all` to fetch the first document matching the ID across all types) */ api.exists = ca({ params: { + storedFields: { + type: 'list', + name: 'stored_fields' + }, parent: { type: 'string' }, @@ -2217,6 +2227,30 @@ api.exists = ca({ }, routing: { type: 'string' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' } }, url: { @@ -2236,6 +2270,83 @@ api.exists = ca({ method: 'HEAD' }); +/** + * Perform a [existsSource](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.parent - The ID of the parent document + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.realtime - Specify whether to perform the operation in realtime or search mode + * @param {<>} params.refresh - Refresh the shard containing the document before performing the operation + * @param {<>} params.routing - Specific routing value + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.id - The document ID + * @param {<>} params.index - The name of the index + * @param {<>} params.type - The type of the document; use `_all` to fetch the first document matching the ID across all types + */ +api.existsSource = ca({ + params: { + parent: { + type: 'string' + }, + preference: { + type: 'string' + }, + realtime: { + type: 'boolean' + }, + refresh: { + type: 'boolean' + }, + routing: { + type: 'string' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + } + }, + url: { + fmt: '/<%=index%>/<%=type%>/<%=id%>/_source', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + method: 'HEAD' +}); + /** * Perform a [explain](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-explain.html) request * @@ -2326,6 +2437,57 @@ api.explain = ca({ method: 'POST' }); +/** + * Perform a [fieldCaps](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.fields - A comma-separated list of field names + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + */ +api.fieldCaps = ca({ + params: { + fields: { + type: 'list' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + } + }, + urls: [ + { + fmt: '/<%=index%>/_field_caps', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_field_caps' + } + ], + method: 'POST' +}); + /** * Perform a [fieldStats](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-field-stats.html) request * @@ -2787,6 +2949,7 @@ api.indices.prototype.analyze = ca({ * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. * @param {<>, <>, <>} params.index - A comma-separated list of index name to limit the operation * @param {<>} params.recycler - Clear the recycler cache + * @param {<>} params.requestCache - Clear request cache * @param {<>} params.request - Clear request cache */ api.indices.prototype.clearCache = ca({ @@ -2829,6 +2992,10 @@ api.indices.prototype.clearCache = ca({ recycler: { type: 'boolean' }, + requestCache: { + type: 'boolean', + name: 'request_cache' + }, request: { type: 'boolean' } @@ -3031,17 +3198,22 @@ api.indices.prototype.deleteTemplate = ca({ }); /** - * Perform a [indices.exists](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-exists.html) request + * Perform a [indices.exists](http://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-exists.html) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) - * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) - * @param {<>, <>, <>} params.index - A comma-separated list of indices to check + * @param {<>} params.ignoreUnavailable - Ignore unavailable indexes (default: false) + * @param {<>} params.allowNoIndices - Ignore if a wildcard expression resolves to no concrete indices (default: false) + * @param {<>} [params.expandWildcards=open] - Whether wildcard expressions should get expanded to open or closed indices (default: open) + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.includeDefaults - Whether to return all default setting for each of the indices. + * @param {<>, <>, <>} params.index - A comma-separated list of index names */ api.indices.prototype.exists = ca({ params: { + local: { + type: 'boolean' + }, ignoreUnavailable: { type: 'boolean', name: 'ignore_unavailable' @@ -3061,8 +3233,14 @@ api.indices.prototype.exists = ca({ ], name: 'expand_wildcards' }, - local: { - type: 'boolean' + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, + includeDefaults: { + type: 'boolean', + 'default': false, + name: 'include_defaults' } }, url: { @@ -3082,7 +3260,7 @@ api.indices.prototype.exists = ca({ * @param {Object} params - An object with parameters used to carry out this action * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * @param {<>} [params.expandWildcards=open,closed] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} [params.expandWildcards=all] - Whether to expand wildcard expression to concrete indices that are open, closed or both. * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) * @param {<>, <>, <>} params.index - A comma-separated list of index names to filter aliases * @param {<>, <>, <>} params.name - A comma-separated list of alias names to return @@ -3099,10 +3277,7 @@ api.indices.prototype.existsAlias = ca({ }, expandWildcards: { type: 'enum', - 'default': [ - 'open', - 'closed' - ], + 'default': 'all', options: [ 'open', 'closed', @@ -3134,14 +3309,6 @@ api.indices.prototype.existsAlias = ca({ type: 'list' } } - }, - { - fmt: '/<%=index%>/_alias', - req: { - index: { - type: 'list' - } - } } ], method: 'HEAD' @@ -3151,12 +3318,17 @@ api.indices.prototype.existsAlias = ca({ * Perform a [indices.existsTemplate](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html) request * * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.flatSettings - Return settings in flat format (default: false) * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) - * @param {<>} params.name - The name of the template + * @param {<>, <>, <>} params.name - The comma separated names of the index templates */ api.indices.prototype.existsTemplate = ca({ params: { + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, masterTimeout: { type: 'time', name: 'master_timeout' @@ -3169,7 +3341,7 @@ api.indices.prototype.existsTemplate = ca({ fmt: '/_template/<%=name%>', req: { name: { - type: 'string' + type: 'list' } } }, @@ -4648,6 +4820,7 @@ api.indices.prototype.upgrade = ca({ * @param {<>} params.df - The field to use as default where no field prefix is given in the query string * @param {<>} params.lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored * @param {<>} params.rewrite - Provide a more detailed explanation showing the actual Lucene query that will be executed. + * @param {<>} params.allShards - Execute validation on all shards instead of one random shard per index * @param {<>, <>, <>} params.index - A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices * @param {<>, <>, <>} params.type - A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types */ @@ -4705,6 +4878,10 @@ api.indices.prototype.validateQuery = ca({ }, rewrite: { type: 'boolean' + }, + allShards: { + type: 'boolean', + name: 'all_shards' } }, urls: [ @@ -5748,7 +5925,7 @@ api.putTemplate = ca({ * @param {<>} params.refresh - Should the effected indexes be refreshed? * @param {<>} [params.timeout=1m] - Time each individual bulk request should wait for shards that are unavailable. * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - * @param {<>} params.waitForCompletion - Should the request should block until the reindex is complete. + * @param {<>} [params.waitForCompletion=true] - Should the request should block until the reindex is complete. * @param {<>} params.requestsPerSecond - The throttle to set on this request in sub-requests per second. -1 means no throttle. * @param {<>} [params.slices=1] - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. */ @@ -5767,7 +5944,7 @@ api.reindex = ca({ }, waitForCompletion: { type: 'boolean', - 'default': false, + 'default': true, name: 'wait_for_completion' }, requestsPerSecond: { @@ -5911,6 +6088,7 @@ api.scroll = ca({ * @param {<>} params.typedKeys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response * @param {<>} params.version - Specify whether to return document version as part of a hit * @param {<>} params.requestCache - Specify if request cache should be used for this request or not, defaults to index level setting + * @param {<>} [params.batchedReduceSize=512] - The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. * @param {<>, <>, <>} params.index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices * @param {<>, <>, <>} params.type - A comma-separated list of document types to search; leave empty to perform the operation on all types */ @@ -6058,6 +6236,11 @@ api.search = ca({ requestCache: { type: 'boolean', name: 'request_cache' + }, + batchedReduceSize: { + type: 'number', + 'default': 512, + name: 'batched_reduce_size' } }, urls: [ @@ -6986,7 +7169,7 @@ api.update = ca({ * @param {<>} [params.timeout=1m] - Time each individual bulk request should wait for shards that are unavailable. * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) * @param {<>} params.scrollSize - Size on the scroll request powering the update_by_query - * @param {<>} params.waitForCompletion - Should the request should block until the update by query operation is complete. + * @param {<>} [params.waitForCompletion=true] - Should the request should block until the update by query operation is complete. * @param {<>} params.requestsPerSecond - The throttle to set on this request in sub-requests per second. -1 means no throttle. * @param {<>} [params.slices=1] - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. * @param {<>, <>, <>} params.index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices @@ -7125,7 +7308,7 @@ api.updateByQuery = ca({ }, waitForCompletion: { type: 'boolean', - 'default': false, + 'default': true, name: 'wait_for_completion' }, requestsPerSecond: { diff --git a/src/lib/apis/browser_index.js b/src/lib/apis/browser_index.js index 2e2fdb64f..413df42bb 100644 --- a/src/lib/apis/browser_index.js +++ b/src/lib/apis/browser_index.js @@ -1,11 +1,10 @@ module.exports = { - '_default': require('./5_2'), + '_default': require('./5_3'), + '5.3': require('./5_3'), '5.2': require('./5_2'), '5.1': require('./5_1'), '5.0': require('./5_0'), '2.4': require('./2_4'), - '1.7': require('./1_7'), '5.x': require('./5_x'), - '5.3': require('./5_3'), 'master': require('./master') }; diff --git a/src/lib/apis/index.js b/src/lib/apis/index.js index 646ae83d8..0046ee4d0 100644 --- a/src/lib/apis/index.js +++ b/src/lib/apis/index.js @@ -1,5 +1,6 @@ module.exports = { - get '_default'() { return require('./5_2'); }, + get '_default'() { return require('./5_3'); }, + get '5.3'() { return require('./5_3'); }, get '5.2'() { return require('./5_2'); }, get '5.1'() { return require('./5_1'); }, get '5.0'() { return require('./5_0'); }, @@ -7,6 +8,5 @@ module.exports = { get '1.7'() { return require('./1_7'); }, get '0.90'() { return require('./0_90'); }, get '5.x'() { return require('./5_x'); }, - get '5.3'() { return require('./5_3'); }, get 'master'() { return require('./master'); }, }; diff --git a/src/lib/apis/master.js b/src/lib/apis/master.js index 111fc72b6..d9d97b4d7 100644 --- a/src/lib/apis/master.js +++ b/src/lib/apis/master.js @@ -1869,7 +1869,7 @@ api['delete'] = ca({ * @param {<>} [params.timeout=1m] - Time each individual bulk request should wait for shards that are unavailable. * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) * @param {<>} params.scrollSize - Size on the scroll request powering the update_by_query - * @param {<>} params.waitForCompletion - Should the request should block until the delete-by-query is complete. + * @param {<>} [params.waitForCompletion=true] - Should the request should block until the delete-by-query is complete. * @param {<>} params.requestsPerSecond - The throttle for this request in sub-requests per second. -1 means no throttle. * @param {<>} [params.slices=1] - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. * @param {<>, <>, <>} params.index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices @@ -2001,7 +2001,7 @@ api.deleteByQuery = ca({ }, waitForCompletion: { type: 'boolean', - 'default': false, + 'default': true, name: 'wait_for_completion' }, requestsPerSecond: { @@ -2093,17 +2093,27 @@ api.deleteTemplate = ca({ * Perform a [exists](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request * * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.storedFields - A comma-separated list of stored fields to return in the response * @param {<>} params.parent - The ID of the parent document * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) * @param {<>} params.realtime - Specify whether to perform the operation in realtime or search mode * @param {<>} params.refresh - Refresh the shard containing the document before performing the operation * @param {<>} params.routing - Specific routing value + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type * @param {<>} params.id - The document ID * @param {<>} params.index - The name of the index * @param {<>} params.type - The type of the document (use `_all` to fetch the first document matching the ID across all types) */ api.exists = ca({ params: { + storedFields: { + type: 'list', + name: 'stored_fields' + }, parent: { type: 'string' }, @@ -2118,6 +2128,30 @@ api.exists = ca({ }, routing: { type: 'string' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' } }, url: { @@ -2137,6 +2171,83 @@ api.exists = ca({ method: 'HEAD' }); +/** + * Perform a [existsSource](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.parent - The ID of the parent document + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.realtime - Specify whether to perform the operation in realtime or search mode + * @param {<>} params.refresh - Refresh the shard containing the document before performing the operation + * @param {<>} params.routing - Specific routing value + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.id - The document ID + * @param {<>} params.index - The name of the index + * @param {<>} params.type - The type of the document; use `_all` to fetch the first document matching the ID across all types + */ +api.existsSource = ca({ + params: { + parent: { + type: 'string' + }, + preference: { + type: 'string' + }, + realtime: { + type: 'boolean' + }, + refresh: { + type: 'boolean' + }, + routing: { + type: 'string' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + } + }, + url: { + fmt: '/<%=index%>/<%=type%>/<%=id%>/_source', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + method: 'HEAD' +}); + /** * Perform a [explain](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-explain.html) request * @@ -2227,6 +2338,57 @@ api.explain = ca({ method: 'POST' }); +/** + * Perform a [fieldCaps](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.fields - A comma-separated list of field names + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + */ +api.fieldCaps = ca({ + params: { + fields: { + type: 'list' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + } + }, + urls: [ + { + fmt: '/<%=index%>/_field_caps', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_field_caps' + } + ], + method: 'POST' +}); + /** * Perform a [fieldStats](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-stats.html) request * @@ -2655,6 +2817,7 @@ api.indices.prototype.analyze = ca({ * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. * @param {<>, <>, <>} params.index - A comma-separated list of index name to limit the operation * @param {<>} params.recycler - Clear the recycler cache + * @param {<>} params.requestCache - Clear request cache * @param {<>} params.request - Clear request cache */ api.indices.prototype.clearCache = ca({ @@ -2697,6 +2860,10 @@ api.indices.prototype.clearCache = ca({ recycler: { type: 'boolean' }, + requestCache: { + type: 'boolean', + name: 'request_cache' + }, request: { type: 'boolean' } @@ -2902,12 +3069,27 @@ api.indices.prototype.deleteTemplate = ca({ * Perform a [indices.exists](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-exists.html) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) - * @param {<>, <>, <>} params.index - A comma-separated list of indices to check + * @param {<>} params.ignoreUnavailable - Ignore unavailable indexes (default: false) + * @param {<>} params.allowNoIndices - Ignore if a wildcard expression resolves to no concrete indices (default: false) + * @param {<>} [params.expandWildcards=open] - Whether wildcard expressions should get expanded to open or closed indices (default: open) + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.includeDefaults - Whether to return all default setting for each of the indices. + * @param {<>, <>, <>} params.index - A comma-separated list of index names */ api.indices.prototype.exists = ca({ params: { + local: { + type: 'boolean' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, expandWildcards: { type: 'enum', 'default': 'open', @@ -2919,8 +3101,14 @@ api.indices.prototype.exists = ca({ ], name: 'expand_wildcards' }, - local: { - type: 'boolean' + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, + includeDefaults: { + type: 'boolean', + 'default': false, + name: 'include_defaults' } }, url: { @@ -2940,7 +3128,7 @@ api.indices.prototype.exists = ca({ * @param {Object} params - An object with parameters used to carry out this action * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * @param {<>} [params.expandWildcards=open,closed] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} [params.expandWildcards=all] - Whether to expand wildcard expression to concrete indices that are open, closed or both. * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) * @param {<>, <>, <>} params.index - A comma-separated list of index names to filter aliases * @param {<>, <>, <>} params.name - A comma-separated list of alias names to return @@ -2957,10 +3145,7 @@ api.indices.prototype.existsAlias = ca({ }, expandWildcards: { type: 'enum', - 'default': [ - 'open', - 'closed' - ], + 'default': 'all', options: [ 'open', 'closed', @@ -2992,14 +3177,6 @@ api.indices.prototype.existsAlias = ca({ type: 'list' } } - }, - { - fmt: '/<%=index%>/_alias', - req: { - index: { - type: 'list' - } - } } ], method: 'HEAD' @@ -3009,12 +3186,17 @@ api.indices.prototype.existsAlias = ca({ * Perform a [indices.existsTemplate](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html) request * * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.flatSettings - Return settings in flat format (default: false) * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) - * @param {<>} params.name - The name of the template + * @param {<>, <>, <>} params.name - The comma separated names of the index templates */ api.indices.prototype.existsTemplate = ca({ params: { + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, masterTimeout: { type: 'time', name: 'master_timeout' @@ -3027,7 +3209,7 @@ api.indices.prototype.existsTemplate = ca({ fmt: '/_template/<%=name%>', req: { name: { - type: 'string' + type: 'list' } } }, @@ -4504,6 +4686,7 @@ api.indices.prototype.upgrade = ca({ * @param {<>} params.df - The field to use as default where no field prefix is given in the query string * @param {<>} params.lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored * @param {<>} params.rewrite - Provide a more detailed explanation showing the actual Lucene query that will be executed. + * @param {<>} params.allShards - Execute validation on all shards instead of one random shard per index * @param {<>, <>, <>} params.index - A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices * @param {<>, <>, <>} params.type - A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types */ @@ -4561,6 +4744,10 @@ api.indices.prototype.validateQuery = ca({ }, rewrite: { type: 'boolean' + }, + allShards: { + type: 'boolean', + name: 'all_shards' } }, urls: [ @@ -5427,7 +5614,7 @@ api.putTemplate = ca({ * @param {<>} params.refresh - Should the effected indexes be refreshed? * @param {<>} [params.timeout=1m] - Time each individual bulk request should wait for shards that are unavailable. * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - * @param {<>} params.waitForCompletion - Should the request should block until the reindex is complete. + * @param {<>} [params.waitForCompletion=true] - Should the request should block until the reindex is complete. * @param {<>} params.requestsPerSecond - The throttle to set on this request in sub-requests per second. -1 means no throttle. * @param {<>} [params.slices=1] - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. */ @@ -5446,7 +5633,7 @@ api.reindex = ca({ }, waitForCompletion: { type: 'boolean', - 'default': false, + 'default': true, name: 'wait_for_completion' }, requestsPerSecond: { @@ -5587,6 +5774,7 @@ api.scroll = ca({ * @param {<>} params.typedKeys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response * @param {<>} params.version - Specify whether to return document version as part of a hit * @param {<>} params.requestCache - Specify if request cache should be used for this request or not, defaults to index level setting + * @param {<>} [params.batchedReduceSize=512] - The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. * @param {<>, <>, <>} params.index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices * @param {<>, <>, <>} params.type - A comma-separated list of document types to search; leave empty to perform the operation on all types */ @@ -5734,6 +5922,11 @@ api.search = ca({ requestCache: { type: 'boolean', name: 'request_cache' + }, + batchedReduceSize: { + type: 'number', + 'default': 512, + name: 'batched_reduce_size' } }, urls: [ @@ -6594,7 +6787,7 @@ api.update = ca({ * @param {<>} [params.timeout=1m] - Time each individual bulk request should wait for shards that are unavailable. * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) * @param {<>} params.scrollSize - Size on the scroll request powering the update_by_query - * @param {<>} params.waitForCompletion - Should the request should block until the update by query operation is complete. + * @param {<>} [params.waitForCompletion=true] - Should the request should block until the update by query operation is complete. * @param {<>} params.requestsPerSecond - The throttle to set on this request in sub-requests per second. -1 means no throttle. * @param {<>} [params.slices=1] - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. * @param {<>, <>, <>} params.index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices @@ -6733,7 +6926,7 @@ api.updateByQuery = ca({ }, waitForCompletion: { type: 'boolean', - 'default': false, + 'default': true, name: 'wait_for_completion' }, requestsPerSecond: { From 87cc201c0693a30953033c7d15dd4019f61b2b0f Mon Sep 17 00:00:00 2001 From: spalger Date: Mon, 3 Apr 2017 18:34:41 -0700 Subject: [PATCH 04/61] [http] accept and document rest of params for agentkeepalive --- .../generate/templates/configuration_docs.tmpl | 15 +++++++++++---- src/lib/connectors/http.js | 12 +++++++----- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/scripts/generate/templates/configuration_docs.tmpl b/scripts/generate/templates/configuration_docs.tmpl index 75a4071e0..9ef8d13e2 100644 --- a/scripts/generate/templates/configuration_docs.tmpl +++ b/scripts/generate/templates/configuration_docs.tmpl @@ -128,22 +128,29 @@ Default::: `60000` Default::: `3000` +`maxSockets`[[config-keep-alive-max-sockets]]:: `Number` -- Maximum number of sockets to allow per host. + +Default::: `Infinity` + `keepAlive`[[config-keep-alive]]:: `Boolean` -- Should the connections to the node be kept open forever? This behavior is recommended when you are connecting directly to Elasticsearch. Default::: `true` +`keepAliveInterval`[[config-keep-alive-interval]]:: `Number` -- How often, in milliseconds, should TCP KeepAlive packets be sent over sockets being kept alive. Only relevant if `keepAlive` is set to `true`. -`maxSockets`[[config-max-sockets]]:: `Number` -- Maximum number of concurrent requests that can be made to any node. +Default::: `1000` -Default::: `10` +`keepAliveMaxFreeSockets`[[config-keep-alive-max-free-sockets]]:: `Number` -- Maximum number of inactive sockets to keep connected to a node. Only relevant if `keepAlive` is set to `true`. +Default::: `256` -`minSockets`[[config-min-sockets]]:: `Number` -- Minimum number of sockets to keep connected to a node, only applies when `keepAlive` is true -Default::: `10` +`keepAliveFreeSocketTimeout`[[config-keep-alive-free-socket-timeout]]:: `Number` -- Sets inactive sockets to timeout after milliseconds of inactivity. Only relevant if `keepAlive` is set to `true`. + +Default::: `60000` `suggestCompression`[[config-suggest-compression]]:: `Boolean` -- The client should inform Elasticsearch, on each request, that it can accept compressed responses. In order for the responses to actually be compressed, you must enable `http.compression` in Elasticsearch. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-http.html[these docs] for additional info. diff --git a/src/lib/connectors/http.js b/src/lib/connectors/http.js index 269c64f80..4368f1b2d 100644 --- a/src/lib/connectors/http.js +++ b/src/lib/connectors/http.js @@ -38,11 +38,11 @@ function HttpConnector(host, config) { this.useSsl = this.host.protocol === 'https'; config = _.defaults(config || {}, { + maxSockets: Infinity, keepAlive: true, - minSockets: 10, - // 10 makes sense but 11 actually keeps 10 sockets around - // https://github.com/mikeal/forever-agent/issues/8 - maxSockets: 11 + keepAliveInterval: 1000, + keepAliveMaxFreeSockets: 256, + keepAliveFreeSocketTimeout: 60000 }); this.agent = config.createNodeAgent ? config.createNodeAgent(this, config) : this.createAgent(config); @@ -90,8 +90,10 @@ HttpConnector.prototype.createAgent = function (config) { HttpConnector.prototype.makeAgentConfig = function (config) { var agentConfig = { keepAlive: config.keepAlive, + keepAliveMsecs: config.keepAliveInterval, maxSockets: config.maxSockets, - minSockets: config.minSockets + maxFreeSockets: config.keepAliveMaxFreeSockets, + freeSocketKeepAliveTimeout: config.keepAliveFreeSocketTimeout }; if (this.useSsl) { From 1ac2d30dbd9d6ea84b758ed76d57c1bf3b51d26f Mon Sep 17 00:00:00 2001 From: spalger Date: Mon, 3 Apr 2017 18:35:31 -0700 Subject: [PATCH 05/61] [docs/config] regenerate --- docs/configuration.asciidoc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/configuration.asciidoc b/docs/configuration.asciidoc index 58adba2cf..99a5a045c 100644 --- a/docs/configuration.asciidoc +++ b/docs/configuration.asciidoc @@ -134,22 +134,29 @@ Default::: `60000` Default::: `3000` +`maxSockets`[[config-keep-alive-max-sockets]]:: `Number` -- Maximum number of sockets to allow per host. + +Default::: `Infinity` + `keepAlive`[[config-keep-alive]]:: `Boolean` -- Should the connections to the node be kept open forever? This behavior is recommended when you are connecting directly to Elasticsearch. Default::: `true` +`keepAliveInterval`[[config-keep-alive-interval]]:: `Number` -- How often, in milliseconds, should TCP KeepAlive packets be sent over sockets being kept alive. Only relevant if `keepAlive` is set to `true`. -`maxSockets`[[config-max-sockets]]:: `Number` -- Maximum number of concurrent requests that can be made to any node. +Default::: `1000` -Default::: `10` +`keepAliveMaxFreeSockets`[[config-keep-alive-max-free-sockets]]:: `Number` -- Maximum number of inactive sockets to keep connected to a node. Only relevant if `keepAlive` is set to `true`. +Default::: `256` -`minSockets`[[config-min-sockets]]:: `Number` -- Minimum number of sockets to keep connected to a node, only applies when `keepAlive` is true -Default::: `10` +`keepAliveFreeSocketTimeout`[[config-keep-alive-free-socket-timeout]]:: `Number` -- Sets inactive sockets to timeout after milliseconds of inactivity. Only relevant if `keepAlive` is set to `true`. + +Default::: `60000` `suggestCompression`[[config-suggest-compression]]:: `Boolean` -- The client should inform Elasticsearch, on each request, that it can accept compressed responses. In order for the responses to actually be compressed, you must enable `http.compression` in Elasticsearch. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-http.html[these docs] for additional info. From 94e27d592262c404477c8dcc8c827ab4a1fe8700 Mon Sep 17 00:00:00 2001 From: spalger Date: Mon, 3 Apr 2017 18:38:58 -0700 Subject: [PATCH 06/61] [changelog] update --- docs/changelog.asciidoc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/changelog.asciidoc b/docs/changelog.asciidoc index 2606cb23e..d3aac5925 100644 --- a/docs/changelog.asciidoc +++ b/docs/changelog.asciidoc @@ -1,11 +1,12 @@ [[changelog]] == Changelog -=== 13.0.0-beta1 (Feb 14 2017) +=== 13.0.0 (Apr 4 2016) - * apiVersion `"5.2"` is now the default + * apiVersion `"5.3"` is now the default * Fixed the way that http addresses are sniffed from the cluster https://github.com/elastic/elasticsearch-js/issues/496[#496] * Switched back to `agentkeepalive` for managing keep-alive connections https://github.com/elastic/elasticsearch-js/issues/476[#476] + * `keepAlive*` settings have changed, and the defaults have been updated to match node.js/agentkeep defaults https://github.com/elastic/elasticsearch-js/commit/87cc201c0693a30953033c7d15dd4019f61b2b0f[87cc201] * `bulk` and other APIs that send line-delimited JSON bodies now use the `Content-Type: application/x-ndjson` header https://github.com/elastic/elasticsearch-js/pull/507[#507] * minor changes to `apiVersion` will no longer be released as a major release ** When we decided to have elasticsearch-js support multiple version of Elasticsearch, we included an `apiVersion` configuration paramter for users to choose the API that each client should expose. This setting had a default value that matched the most recent version of Elasticsearch at the time of release. Since Elasticsearch didn't make specific guarantees about backwards compatibility elasticsearch-js released a new major version every time the default `apiVersion` changed. From a30d362409835b9318fe92f1099242ffb3f63566 Mon Sep 17 00:00:00 2001 From: Christian Tellnes Date: Tue, 4 Apr 2017 14:46:36 +0200 Subject: [PATCH 07/61] export console logger in non browser environments When using this library in eg. AWS Lambda environment the console logger is a lot more usefull than stdio. --- src/lib/loggers/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/loggers/index.js b/src/lib/loggers/index.js index 195a1d19d..fb75cfb2d 100644 --- a/src/lib/loggers/index.js +++ b/src/lib/loggers/index.js @@ -1,4 +1,5 @@ module.exports = { + console: require('./console'), file: require('./file'), stream: require('./stream'), stdio: require('./stdio'), From 5431f761107a36200d451190cc29af90e35488ef Mon Sep 17 00:00:00 2001 From: spalger Date: Tue, 4 Apr 2017 20:10:18 -0700 Subject: [PATCH 08/61] [changelog] mention #523 --- docs/changelog.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.asciidoc b/docs/changelog.asciidoc index d3aac5925..b82d6af27 100644 --- a/docs/changelog.asciidoc +++ b/docs/changelog.asciidoc @@ -8,6 +8,7 @@ * Switched back to `agentkeepalive` for managing keep-alive connections https://github.com/elastic/elasticsearch-js/issues/476[#476] * `keepAlive*` settings have changed, and the defaults have been updated to match node.js/agentkeep defaults https://github.com/elastic/elasticsearch-js/commit/87cc201c0693a30953033c7d15dd4019f61b2b0f[87cc201] * `bulk` and other APIs that send line-delimited JSON bodies now use the `Content-Type: application/x-ndjson` header https://github.com/elastic/elasticsearch-js/pull/507[#507] + * `"console"` reporter is now available in Node.js for environments where that is preferred to `"stdout"` https://github.com/elastic/elasticsearch-js/pull/496[#523] * minor changes to `apiVersion` will no longer be released as a major release ** When we decided to have elasticsearch-js support multiple version of Elasticsearch, we included an `apiVersion` configuration paramter for users to choose the API that each client should expose. This setting had a default value that matched the most recent version of Elasticsearch at the time of release. Since Elasticsearch didn't make specific guarantees about backwards compatibility elasticsearch-js released a new major version every time the default `apiVersion` changed. + From a60028b1e96d90b828d3f5728117f8bb52a83fdf Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 5 Apr 2017 12:27:47 -0700 Subject: [PATCH 09/61] [clientAction] properly remove the param from all paramAsBody transformations --- src/lib/client_action.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/client_action.js b/src/lib/client_action.js index 9322f46b5..3b602f67b 100644 --- a/src/lib/client_action.js +++ b/src/lib/client_action.js @@ -258,11 +258,11 @@ function exec(transport, spec, params, cb) { if (typeof spec.paramAsBody === 'object') { params.body = {}; params.body[spec.paramAsBody.body] = params[spec.paramAsBody.param]; + delete params[spec.paramAsBody.param]; } else { params.body = params[spec.paramAsBody]; + delete params[spec.paramAsBody]; } - - delete params[spec.paramAsBody]; } // verify that we have the body if needed From 2c8a1c03d4e9e06b408ccb092fdd242606a9e9e8 Mon Sep 17 00:00:00 2001 From: Thiago Souza Date: Mon, 24 Apr 2017 14:30:33 -0300 Subject: [PATCH 10/61] Update Browser Builds docs (#528) * Document how to properly install using npm * The standard elasticsearch-js build does not works in browser anymore * The React sample can be confusing nowadays. Since it refers to an older version that used to work in the browser, now that there is a browser specific build, the sample is somewhat confusing. * Closes https://github.com/elastic/elasticsearch-js/issues/527 Since it refers to an older version that used to work in the browser, now that there is a browser specific build, the sample is somewhat confusing. * Fix typo --- docs/browser_builds.asciidoc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/browser_builds.asciidoc b/docs/browser_builds.asciidoc index c0aac0be1..2eb9eb63a 100644 --- a/docs/browser_builds.asciidoc +++ b/docs/browser_builds.asciidoc @@ -13,11 +13,17 @@ If you use bower to manage your dependencies, then just run: bower install elasticsearch --------- +=== NPM +If you use npm to manage your dependencies, then just run: + +[source,shell] +--------- +npm install elasticsearch-browser +--------- + === Download * v13.0.0-beta2: https://download.elasticsearch.org/elasticsearch/elasticsearch-js/elasticsearch-js-13.0.0-beta2.zip[zip], https://download.elasticsearch.org/elasticsearch/elasticsearch-js/elasticsearch-js-13.0.0-beta2.tar.gz[tar.gz] -NOTE: Here's an example that integrates elasticsearch.js with React https://github.com/scotchfield/elasticsearch-react-example/[on GitHub] - === Angular Build * Registers an `esFactory` factory in the `"elasticsearch"` module * Uses Angular's `$http` service From eaccaa09a879015e73eb9f6bd241a75b98fcd58f Mon Sep 17 00:00:00 2001 From: spalger Date: Mon, 24 Apr 2017 10:36:01 -0700 Subject: [PATCH 11/61] tag master as 14.0 snapshot --- README.md | 2 +- docs/browser_builds.asciidoc | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 62f660bb2..6d3abccf2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# elasticsearch.js 13.0.0-beta2 +# elasticsearch.js 14.0.0-SNAPSHOT The official low-level Elasticsearch client for Node.js and the browser. diff --git a/docs/browser_builds.asciidoc b/docs/browser_builds.asciidoc index 2eb9eb63a..81277bf51 100644 --- a/docs/browser_builds.asciidoc +++ b/docs/browser_builds.asciidoc @@ -22,7 +22,7 @@ npm install elasticsearch-browser --------- === Download - * v13.0.0-beta2: https://download.elasticsearch.org/elasticsearch/elasticsearch-js/elasticsearch-js-13.0.0-beta2.zip[zip], https://download.elasticsearch.org/elasticsearch/elasticsearch-js/elasticsearch-js-13.0.0-beta2.tar.gz[tar.gz] + * v14.0.0-SNAPSHOT: https://download.elasticsearch.org/elasticsearch/elasticsearch-js/elasticsearch-js-14.0.0-SNAPSHOT.zip[zip], https://download.elasticsearch.org/elasticsearch/elasticsearch-js/elasticsearch-js-14.0.0-SNAPSHOT.tar.gz[tar.gz] === Angular Build * Registers an `esFactory` factory in the `"elasticsearch"` module diff --git a/package.json b/package.json index d2853a976..495830903 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "description": "The official low-level Elasticsearch client for Node.js and the browser.", "main": "src/elasticsearch.js", "homepage": "http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html", - "version": "13.0.0-beta2", + "version": "14.0.0-SNAPSHOT", "keywords": [ "elasticsearch", "mapping", From f31aa27b6efa3b29744ed8e709931057f0f79789 Mon Sep 17 00:00:00 2001 From: spalger Date: Mon, 24 Apr 2017 10:47:55 -0700 Subject: [PATCH 12/61] [changelog] Correct 13.0.0 release date --- docs/changelog.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog.asciidoc b/docs/changelog.asciidoc index b82d6af27..288ece816 100644 --- a/docs/changelog.asciidoc +++ b/docs/changelog.asciidoc @@ -1,7 +1,7 @@ [[changelog]] == Changelog -=== 13.0.0 (Apr 4 2016) +=== 13.0.0 (Apr 24 2016) * apiVersion `"5.3"` is now the default * Fixed the way that http addresses are sniffed from the cluster https://github.com/elastic/elasticsearch-js/issues/496[#496] From 0d322d82e3b69c9d5928f137ec8290451830d671 Mon Sep 17 00:00:00 2001 From: Charitha Sathkumara Date: Tue, 25 Apr 2017 17:39:06 -0700 Subject: [PATCH 13/61] Fixed sample JS code variable naming (#534) --- docs/host.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/host.asciidoc b/docs/host.asciidoc index 98bc353c8..cd21f0fc7 100644 --- a/docs/host.asciidoc +++ b/docs/host.asciidoc @@ -85,7 +85,7 @@ var client = new elasticsearch.Client({ weight: 50 } ], - selector: function (hosts) { + selector: function (nodes) { var myCountry = process.env.COUNTRY; // first try to find a node that is in the same country var selection = _.find(nodes, function (node) { From b7c9073fa6b01c8f26caa1c958884568ce289e72 Mon Sep 17 00:00:00 2001 From: Brandon Kobel Date: Mon, 1 May 2017 18:56:22 -0400 Subject: [PATCH 14/61] Manually incrementing the hardcoded master version to 6.0 (#535) * Manually incrementing the hardcoded master version to 6.0 * Adding branch_versions to the package.json * Modifying the way branch_versions work --- package.json | 5 ++++- scripts/Version.js | 9 +++++---- src/lib/apis/5_x.js | 15 ++++++++++++++- src/lib/apis/master.js | 25 ++++++++++++++++++++++--- 4 files changed, 45 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 495830903..7fa2ef542 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,10 @@ "unstable_es_branches": [ "5.x", "master" - ] + ], + "branch_versions": { + "master": "6.0" + } }, "devDependencies": { "@spalger/eslint-config-personal": "^0.4.0", diff --git a/scripts/Version.js b/scripts/Version.js index 7d639e4ec..e7a0624eb 100644 --- a/scripts/Version.js +++ b/scripts/Version.js @@ -1,6 +1,7 @@ var _ = require('lodash'); var pkg = require('../package.json'); var branches = pkg.config.supported_es_branches; +var branchVersions = pkg.config.branch_versions; var semver = require('semver'); var maxMinorVersion = function (majorV) { @@ -18,14 +19,14 @@ function Version(v) { Version.fromBranch = function (branch) { var m; - // master === the highest version number - if (branch === 'master') return new Version('5.0.0'); + var branchVersion = branchVersions[branch]; + var versionString = branchVersion ? branchVersion : branch; // n.m -> n.m.0 - if (m = branch.match(/^\d+\.\d+$/)) return new Version(branch + '.0'); + if (m = versionString.match(/^\d+\.\d+$/)) return new Version(versionString + '.0'); // n.x -> n.(maxVersion + 1).0 - if (m = branch.match(/^(\d+)\.x$/i)) return maxMinorVersion(m[1]).increment('minor'); + if (m = versionString.match(/^(\d+)\.x$/i)) return maxMinorVersion(m[1]).increment('minor'); throw new Error('unable to convert branch "' + branch + '" to semver'); }; diff --git a/src/lib/apis/5_x.js b/src/lib/apis/5_x.js index 2f7445b9e..63a9f4270 100644 --- a/src/lib/apis/5_x.js +++ b/src/lib/apis/5_x.js @@ -11,7 +11,7 @@ var ca = require('../client_action').makeFactoryWithModifier(function (spec) { var namespace = require('../client_action').namespaceFactory; var api = module.exports = {}; -api._namespaces = ['cat', 'cluster', 'indices', 'ingest', 'nodes', 'snapshot', 'tasks']; +api._namespaces = ['cat', 'cluster', 'indices', 'ingest', 'nodes', 'remote', 'snapshot', 'tasks']; /** * Perform a [bulk](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-bulk.html) request @@ -5990,6 +5990,19 @@ api.reindexRethrottle = ca({ method: 'POST' }); +api.remote = namespace(); + +/** + * Perform a [remote.info](http://www.elastic.co/guide/en/elasticsearch/reference/master/remote-info.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + */ +api.remote.prototype.info = ca({ + url: { + fmt: '/_remote/info' + } +}); + /** * Perform a [renderSearchTemplate](http://www.elasticsearch.org/guide/en/elasticsearch/reference/5.x/search-template.html) request * diff --git a/src/lib/apis/master.js b/src/lib/apis/master.js index d9d97b4d7..449fa1a36 100644 --- a/src/lib/apis/master.js +++ b/src/lib/apis/master.js @@ -11,7 +11,7 @@ var ca = require('../client_action').makeFactoryWithModifier(function (spec) { var namespace = require('../client_action').namespaceFactory; var api = module.exports = {}; -api._namespaces = ['cat', 'cluster', 'indices', 'ingest', 'nodes', 'snapshot', 'tasks']; +api._namespaces = ['cat', 'cluster', 'indices', 'ingest', 'nodes', 'remote', 'snapshot', 'tasks']; /** * Perform a [bulk](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html) request @@ -1206,7 +1206,10 @@ api.clearScroll = ca({ fmt: '/_search/scroll' } ], - paramAsBody: 'scrollId', + paramAsBody: { + param: 'scrollId', + body: 'scroll_id' + }, method: 'DELETE' }); @@ -5679,6 +5682,19 @@ api.reindexRethrottle = ca({ method: 'POST' }); +api.remote = namespace(); + +/** + * Perform a [remote.info](http://www.elastic.co/guide/en/elasticsearch/reference/master/remote-info.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + */ +api.remote.prototype.info = ca({ + url: { + fmt: '/_remote/info' + } +}); + /** * Perform a [renderSearchTemplate](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-template.html) request * @@ -5732,7 +5748,10 @@ api.scroll = ca({ fmt: '/_search/scroll' } ], - paramAsBody: 'scrollId', + paramAsBody: { + param: 'scrollId', + body: 'scroll_id' + }, method: 'POST' }); From b67f3b313d8af921e66df3fcbc9c722dc3b4d7fe Mon Sep 17 00:00:00 2001 From: Suhas Karanth Date: Tue, 2 May 2017 04:27:08 +0530 Subject: [PATCH 15/61] Add elastic-builder to list of query building libraries. (#538) * Add elastic-builder to list of query building libraries. * Update search and api_conventions docs as well --- docs/_descriptions/search.asciidoc | 2 +- docs/api_conventions.asciidoc | 2 +- docs/api_methods.asciidoc | 2 +- docs/api_methods_2_4.asciidoc | 2 +- docs/api_methods_5_0.asciidoc | 2 +- docs/api_methods_5_1.asciidoc | 2 +- docs/api_methods_5_2.asciidoc | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/_descriptions/search.asciidoc b/docs/_descriptions/search.asciidoc index 2f18ee136..82e979173 100644 --- a/docs/_descriptions/search.asciidoc +++ b/docs/_descriptions/search.asciidoc @@ -1,4 +1,4 @@ Return documents matching a query, aggregations/facets, highlighted snippets, suggestions, and more. Write your queries as either http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-uri-request.html[simple query strings] in the `q` parameter, or by specifying a http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-body.html[full request definition] using the http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html[Elasticsearch Query DSL] in the `body` parameter. -TIP: https://github.com/fullscale/elastic.js[elastic.js], https://github.com/holidayextras/esq[esq], or https://github.com/danpaz/bodybuilder[bodybuilder] can be used to make building query bodies easier. +TIP: https://github.com/danpaz/bodybuilder[bodybuilder], https://github.com/holidayextras/esq[esq], https://github.com/sudo-suhas/elastic-builder[elastic-builder] or https://github.com/fullscale/elastic.js[elastic.js] can be used to make building query bodies easier. diff --git a/docs/api_conventions.asciidoc b/docs/api_conventions.asciidoc index 3338d958d..62532e262 100755 --- a/docs/api_conventions.asciidoc +++ b/docs/api_conventions.asciidoc @@ -11,7 +11,7 @@ By default, all api methods accept the following parameters. They are omitted fr `body`:: `String, Anything` -- The body to send along with this request. If the body is a string it will be passed along as is, otherwise it is passed to the serializer and converted to either JSON or a newline separated list of JSON objects based on the API method. + -NOTE: the https://github.com/fullscale/elastic.js[elastic.js] or https://github.com/danpaz/bodybuilder[bodybuilder] libraries can be used to make building request bodies simpler. +NOTE: the https://github.com/danpaz/bodybuilder[bodybuilder], https://github.com/sudo-suhas/elastic-builder[elastic-builder] or https://github.com/fullscale/elastic.js[elastic.js] libraries can be used to make building request bodies simpler. `ignore`:: + diff --git a/docs/api_methods.asciidoc b/docs/api_methods.asciidoc index 676000f08..7a1f1ace7 100644 --- a/docs/api_methods.asciidoc +++ b/docs/api_methods.asciidoc @@ -1663,7 +1663,7 @@ client.search([params, [callback]]) Return documents matching a query, aggregations/facets, highlighted snippets, suggestions, and more. Write your queries as either http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-uri-request.html[simple query strings] in the `q` parameter, or by specifying a http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-body.html[full request definition] using the http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html[Elasticsearch Query DSL] in the `body` parameter. -TIP: https://github.com/fullscale/elastic.js[elastic.js], https://github.com/holidayextras/esq[esq], or https://github.com/danpaz/bodybuilder[bodybuilder] can be used to make building query bodies easier. +TIP: https://github.com/danpaz/bodybuilder[bodybuilder], https://github.com/holidayextras/esq[esq], or https://github.com/sudo-suhas/elastic-builder[elastic-builder] can be used to make building query bodies easier. diff --git a/docs/api_methods_2_4.asciidoc b/docs/api_methods_2_4.asciidoc index bafa965c3..5ca431da5 100644 --- a/docs/api_methods_2_4.asciidoc +++ b/docs/api_methods_2_4.asciidoc @@ -1560,7 +1560,7 @@ client.search([params, [callback]]) Return documents matching a query, aggregations/facets, highlighted snippets, suggestions, and more. Write your queries as either http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-uri-request.html[simple query strings] in the `q` parameter, or by specifying a http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-body.html[full request definition] using the http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html[Elasticsearch Query DSL] in the `body` parameter. -TIP: https://github.com/fullscale/elastic.js[elastic.js], https://github.com/holidayextras/esq[esq], or https://github.com/danpaz/bodybuilder[bodybuilder] can be used to make building query bodies easier. +TIP: https://github.com/fullscale/elastic.js[elastic.js], https://github.com/holidayextras/esq[esq], https://github.com/danpaz/bodybuilder[bodybuilder], or https://github.com/sudo-suhas/elastic-builder[elastic-builder] can be used to make building query bodies easier. diff --git a/docs/api_methods_5_0.asciidoc b/docs/api_methods_5_0.asciidoc index a0257fa93..707f81347 100644 --- a/docs/api_methods_5_0.asciidoc +++ b/docs/api_methods_5_0.asciidoc @@ -1665,7 +1665,7 @@ client.search([params, [callback]]) Return documents matching a query, aggregations/facets, highlighted snippets, suggestions, and more. Write your queries as either http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-uri-request.html[simple query strings] in the `q` parameter, or by specifying a http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-body.html[full request definition] using the http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html[Elasticsearch Query DSL] in the `body` parameter. -TIP: https://github.com/fullscale/elastic.js[elastic.js], https://github.com/holidayextras/esq[esq], or https://github.com/danpaz/bodybuilder[bodybuilder] can be used to make building query bodies easier. +TIP: https://github.com/danpaz/bodybuilder[bodybuilder], https://github.com/holidayextras/esq[esq], or https://github.com/sudo-suhas/elastic-builder[elastic-builder] can be used to make building query bodies easier. diff --git a/docs/api_methods_5_1.asciidoc b/docs/api_methods_5_1.asciidoc index 93c15d030..4c5e5978e 100644 --- a/docs/api_methods_5_1.asciidoc +++ b/docs/api_methods_5_1.asciidoc @@ -1663,7 +1663,7 @@ client.search([params, [callback]]) Return documents matching a query, aggregations/facets, highlighted snippets, suggestions, and more. Write your queries as either http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-uri-request.html[simple query strings] in the `q` parameter, or by specifying a http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-body.html[full request definition] using the http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html[Elasticsearch Query DSL] in the `body` parameter. -TIP: https://github.com/fullscale/elastic.js[elastic.js], https://github.com/holidayextras/esq[esq], or https://github.com/danpaz/bodybuilder[bodybuilder] can be used to make building query bodies easier. +TIP: https://github.com/danpaz/bodybuilder[bodybuilder], https://github.com/holidayextras/esq[esq], or https://github.com/sudo-suhas/elastic-builder[elastic-builder] can be used to make building query bodies easier. diff --git a/docs/api_methods_5_2.asciidoc b/docs/api_methods_5_2.asciidoc index b02ca0dee..c9e16fc05 100644 --- a/docs/api_methods_5_2.asciidoc +++ b/docs/api_methods_5_2.asciidoc @@ -1663,7 +1663,7 @@ client.search([params, [callback]]) Return documents matching a query, aggregations/facets, highlighted snippets, suggestions, and more. Write your queries as either http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-uri-request.html[simple query strings] in the `q` parameter, or by specifying a http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-body.html[full request definition] using the http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html[Elasticsearch Query DSL] in the `body` parameter. -TIP: https://github.com/fullscale/elastic.js[elastic.js], https://github.com/holidayextras/esq[esq], or https://github.com/danpaz/bodybuilder[bodybuilder] can be used to make building query bodies easier. +TIP: https://github.com/danpaz/bodybuilder[bodybuilder], https://github.com/holidayextras/esq[esq], or https://github.com/sudo-suhas/elastic-builder[elastic-builder] can be used to make building query bodies easier. From b345e0b13d0b00b5b37a861e4839eb31d6eb81eb Mon Sep 17 00:00:00 2001 From: spalger Date: Mon, 1 May 2017 16:29:24 -0700 Subject: [PATCH 16/61] define description overrides by version, like examples --- docs/_descriptions/search.asciidoc | 2 +- docs/_descriptions/search_0.90.asciidoc | 2 + docs/_descriptions/search_1.x.asciidoc | 4 ++ docs/_descriptions/search_2.x.asciidoc | 4 ++ docs/_examples/scroll.asciidoc | 12 ++--- ...oll_5.0+.asciidoc => scroll_<5.0.asciidoc} | 14 +++--- docs/api_methods.asciidoc | 2 +- docs/api_methods_0_90.asciidoc | 3 +- docs/api_methods_1_7.asciidoc | 3 +- docs/api_methods_2_4.asciidoc | 3 +- docs/api_methods_5_0.asciidoc | 2 +- docs/api_methods_5_1.asciidoc | 2 +- docs/api_methods_5_2.asciidoc | 2 +- package.json | 5 +- scripts/Version.js | 47 ++++++++++++++----- scripts/generate/js_api.js | 10 +++- scripts/generate/overrides.js | 29 ++++++++++-- scripts/generate/templates/api_methods.tmpl | 2 +- scripts/generate/templates/index.js | 12 ----- 19 files changed, 102 insertions(+), 58 deletions(-) create mode 100644 docs/_descriptions/search_0.90.asciidoc create mode 100644 docs/_descriptions/search_1.x.asciidoc create mode 100644 docs/_descriptions/search_2.x.asciidoc rename docs/_examples/{scroll_5.0+.asciidoc => scroll_<5.0.asciidoc} (63%) diff --git a/docs/_descriptions/search.asciidoc b/docs/_descriptions/search.asciidoc index 82e979173..b2cc6fda3 100644 --- a/docs/_descriptions/search.asciidoc +++ b/docs/_descriptions/search.asciidoc @@ -1,4 +1,4 @@ Return documents matching a query, aggregations/facets, highlighted snippets, suggestions, and more. Write your queries as either http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-uri-request.html[simple query strings] in the `q` parameter, or by specifying a http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-body.html[full request definition] using the http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html[Elasticsearch Query DSL] in the `body` parameter. -TIP: https://github.com/danpaz/bodybuilder[bodybuilder], https://github.com/holidayextras/esq[esq], https://github.com/sudo-suhas/elastic-builder[elastic-builder] or https://github.com/fullscale/elastic.js[elastic.js] can be used to make building query bodies easier. +TIP: https://github.com/danpaz/bodybuilder[bodybuilder] and https://github.com/sudo-suhas/elastic-builder[elastic-builder] can be used to make building query bodies easier. diff --git a/docs/_descriptions/search_0.90.asciidoc b/docs/_descriptions/search_0.90.asciidoc new file mode 100644 index 000000000..fe71efceb --- /dev/null +++ b/docs/_descriptions/search_0.90.asciidoc @@ -0,0 +1,2 @@ +Return documents matching a query, aggregations/facets, highlighted snippets, suggestions, and more. Write your queries as either http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-uri-request.html[simple query strings] in the `q` parameter, or by specifying a http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-body.html[full request definition] using the http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html[Elasticsearch Query DSL] in the `body` parameter. + diff --git a/docs/_descriptions/search_1.x.asciidoc b/docs/_descriptions/search_1.x.asciidoc new file mode 100644 index 000000000..3f7e06e5e --- /dev/null +++ b/docs/_descriptions/search_1.x.asciidoc @@ -0,0 +1,4 @@ +Return documents matching a query, aggregations/facets, highlighted snippets, suggestions, and more. Write your queries as either http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-uri-request.html[simple query strings] in the `q` parameter, or by specifying a http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-body.html[full request definition] using the http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html[Elasticsearch Query DSL] in the `body` parameter. + +TIP: https://github.com/danpaz/bodybuilder[bodybuilder], https://github.com/holidayextras/esq[esq], and https://github.com/fullscale/elastic.js[elastic.js] can be used to make building query bodies easier. + diff --git a/docs/_descriptions/search_2.x.asciidoc b/docs/_descriptions/search_2.x.asciidoc new file mode 100644 index 000000000..6ac0400d6 --- /dev/null +++ b/docs/_descriptions/search_2.x.asciidoc @@ -0,0 +1,4 @@ +Return documents matching a query, aggregations/facets, highlighted snippets, suggestions, and more. Write your queries as either http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-uri-request.html[simple query strings] in the `q` parameter, or by specifying a http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-body.html[full request definition] using the http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html[Elasticsearch Query DSL] in the `body` parameter. + +TIP: https://github.com/danpaz/bodybuilder[bodybuilder], https://github.com/sudo-suhas/elastic-builder[elastic-builder], and https://github.com/holidayextras/esq[esq] can be used to make building query bodies easier. + diff --git a/docs/_examples/scroll.asciidoc b/docs/_examples/scroll.asciidoc index ef169e650..02e8269db 100644 --- a/docs/_examples/scroll.asciidoc +++ b/docs/_examples/scroll.asciidoc @@ -6,19 +6,17 @@ var allTitles = []; // first we do a search, and specify a scroll timeout client.search({ index: 'myindex', - // Set to 30 seconds because we are calling right back - scroll: '30s', - search_type: 'scan', - fields: ['title'], + scroll: '30s', // keep the search results "scrollable" for 30 seconds + source: ['title'], // filter the source to only include the title field q: 'title:test' }, function getMoreUntilDone(error, response) { // collect the title from each response response.hits.hits.forEach(function (hit) { - allTitles.push(hit.fields.title); + allTitles.push(hit._source.title); }); - if (response.hits.total !== allTitles.length) { - // now we can call scroll over and over + if (response.hits.total > allTitles.length) { + // ask elasticsearch for the next set of hits from this search client.scroll({ scrollId: response._scroll_id, scroll: '30s' diff --git a/docs/_examples/scroll_5.0+.asciidoc b/docs/_examples/scroll_<5.0.asciidoc similarity index 63% rename from docs/_examples/scroll_5.0+.asciidoc rename to docs/_examples/scroll_<5.0.asciidoc index 02e8269db..36fcfa923 100644 --- a/docs/_examples/scroll_5.0+.asciidoc +++ b/docs/_examples/scroll_<5.0.asciidoc @@ -6,17 +6,19 @@ var allTitles = []; // first we do a search, and specify a scroll timeout client.search({ index: 'myindex', - scroll: '30s', // keep the search results "scrollable" for 30 seconds - source: ['title'], // filter the source to only include the title field + // Set to 30 seconds because we are calling right back + scroll: '30s', + search_type: 'scan', + fields: ['title'], q: 'title:test' }, function getMoreUntilDone(error, response) { // collect the title from each response response.hits.hits.forEach(function (hit) { - allTitles.push(hit._source.title); + allTitles.push(hit.fields.title); }); - if (response.hits.total > allTitles.length) { - // ask elasticsearch for the next set of hits from this search + if (response.hits.total !== allTitles.length) { + // now we can call scroll over and over client.scroll({ scrollId: response._scroll_id, scroll: '30s' @@ -25,4 +27,4 @@ client.search({ console.log('every "test" title', allTitles); } }); ---------- +--------- \ No newline at end of file diff --git a/docs/api_methods.asciidoc b/docs/api_methods.asciidoc index 7a1f1ace7..899c0b996 100644 --- a/docs/api_methods.asciidoc +++ b/docs/api_methods.asciidoc @@ -1663,7 +1663,7 @@ client.search([params, [callback]]) Return documents matching a query, aggregations/facets, highlighted snippets, suggestions, and more. Write your queries as either http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-uri-request.html[simple query strings] in the `q` parameter, or by specifying a http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-body.html[full request definition] using the http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html[Elasticsearch Query DSL] in the `body` parameter. -TIP: https://github.com/danpaz/bodybuilder[bodybuilder], https://github.com/holidayextras/esq[esq], or https://github.com/sudo-suhas/elastic-builder[elastic-builder] can be used to make building query bodies easier. +TIP: https://github.com/danpaz/bodybuilder[bodybuilder] and https://github.com/sudo-suhas/elastic-builder[elastic-builder] can be used to make building query bodies easier. diff --git a/docs/api_methods_0_90.asciidoc b/docs/api_methods_0_90.asciidoc index 09da3c043..23f6ad2d4 100644 --- a/docs/api_methods_0_90.asciidoc +++ b/docs/api_methods_0_90.asciidoc @@ -1132,7 +1132,6 @@ client.search({ --------- - *Params* [horizontal] @@ -1155,7 +1154,7 @@ client.search([params, [callback]]) Return documents matching a query, aggregations/facets, highlighted snippets, suggestions, and more. Write your queries as either http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-uri-request.html[simple query strings] in the `q` parameter, or by specifying a http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-body.html[full request definition] using the http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html[Elasticsearch Query DSL] in the `body` parameter. -TIP: https://github.com/fullscale/elastic.js[elastic.js], https://github.com/holidayextras/esq[esq], or https://github.com/danpaz/bodybuilder[bodybuilder] can be used to make building query bodies easier. +TIP: https://github.com/danpaz/bodybuilder[bodybuilder], https://github.com/holidayextras/esq[esq], and https://github.com/fullscale/elastic.js[elastic.js] can be used to make building query bodies easier. diff --git a/docs/api_methods_1_7.asciidoc b/docs/api_methods_1_7.asciidoc index 46dbfac57..0c2f50a63 100644 --- a/docs/api_methods_1_7.asciidoc +++ b/docs/api_methods_1_7.asciidoc @@ -1625,7 +1625,6 @@ client.search({ --------- - *Params* [horizontal] @@ -1648,7 +1647,7 @@ client.search([params, [callback]]) Return documents matching a query, aggregations/facets, highlighted snippets, suggestions, and more. Write your queries as either http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-uri-request.html[simple query strings] in the `q` parameter, or by specifying a http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-body.html[full request definition] using the http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html[Elasticsearch Query DSL] in the `body` parameter. -TIP: https://github.com/fullscale/elastic.js[elastic.js], https://github.com/holidayextras/esq[esq], or https://github.com/danpaz/bodybuilder[bodybuilder] can be used to make building query bodies easier. +TIP: https://github.com/danpaz/bodybuilder[bodybuilder], https://github.com/holidayextras/esq[esq], and https://github.com/fullscale/elastic.js[elastic.js] can be used to make building query bodies easier. diff --git a/docs/api_methods_2_4.asciidoc b/docs/api_methods_2_4.asciidoc index 5ca431da5..6be56d9ba 100644 --- a/docs/api_methods_2_4.asciidoc +++ b/docs/api_methods_2_4.asciidoc @@ -1537,7 +1537,6 @@ client.search({ --------- - *Params* [horizontal] @@ -1560,7 +1559,7 @@ client.search([params, [callback]]) Return documents matching a query, aggregations/facets, highlighted snippets, suggestions, and more. Write your queries as either http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-uri-request.html[simple query strings] in the `q` parameter, or by specifying a http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-body.html[full request definition] using the http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html[Elasticsearch Query DSL] in the `body` parameter. -TIP: https://github.com/fullscale/elastic.js[elastic.js], https://github.com/holidayextras/esq[esq], https://github.com/danpaz/bodybuilder[bodybuilder], or https://github.com/sudo-suhas/elastic-builder[elastic-builder] can be used to make building query bodies easier. +TIP: https://github.com/danpaz/bodybuilder[bodybuilder], https://github.com/sudo-suhas/elastic-builder[elastic-builder], and https://github.com/holidayextras/esq[esq] can be used to make building query bodies easier. diff --git a/docs/api_methods_5_0.asciidoc b/docs/api_methods_5_0.asciidoc index 707f81347..27d94633d 100644 --- a/docs/api_methods_5_0.asciidoc +++ b/docs/api_methods_5_0.asciidoc @@ -1665,7 +1665,7 @@ client.search([params, [callback]]) Return documents matching a query, aggregations/facets, highlighted snippets, suggestions, and more. Write your queries as either http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-uri-request.html[simple query strings] in the `q` parameter, or by specifying a http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-body.html[full request definition] using the http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html[Elasticsearch Query DSL] in the `body` parameter. -TIP: https://github.com/danpaz/bodybuilder[bodybuilder], https://github.com/holidayextras/esq[esq], or https://github.com/sudo-suhas/elastic-builder[elastic-builder] can be used to make building query bodies easier. +TIP: https://github.com/danpaz/bodybuilder[bodybuilder] and https://github.com/sudo-suhas/elastic-builder[elastic-builder] can be used to make building query bodies easier. diff --git a/docs/api_methods_5_1.asciidoc b/docs/api_methods_5_1.asciidoc index 4c5e5978e..f1a9281ca 100644 --- a/docs/api_methods_5_1.asciidoc +++ b/docs/api_methods_5_1.asciidoc @@ -1663,7 +1663,7 @@ client.search([params, [callback]]) Return documents matching a query, aggregations/facets, highlighted snippets, suggestions, and more. Write your queries as either http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-uri-request.html[simple query strings] in the `q` parameter, or by specifying a http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-body.html[full request definition] using the http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html[Elasticsearch Query DSL] in the `body` parameter. -TIP: https://github.com/danpaz/bodybuilder[bodybuilder], https://github.com/holidayextras/esq[esq], or https://github.com/sudo-suhas/elastic-builder[elastic-builder] can be used to make building query bodies easier. +TIP: https://github.com/danpaz/bodybuilder[bodybuilder] and https://github.com/sudo-suhas/elastic-builder[elastic-builder] can be used to make building query bodies easier. diff --git a/docs/api_methods_5_2.asciidoc b/docs/api_methods_5_2.asciidoc index c9e16fc05..fde12fec5 100644 --- a/docs/api_methods_5_2.asciidoc +++ b/docs/api_methods_5_2.asciidoc @@ -1663,7 +1663,7 @@ client.search([params, [callback]]) Return documents matching a query, aggregations/facets, highlighted snippets, suggestions, and more. Write your queries as either http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-uri-request.html[simple query strings] in the `q` parameter, or by specifying a http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-body.html[full request definition] using the http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html[Elasticsearch Query DSL] in the `body` parameter. -TIP: https://github.com/danpaz/bodybuilder[bodybuilder], https://github.com/holidayextras/esq[esq], or https://github.com/sudo-suhas/elastic-builder[elastic-builder] can be used to make building query bodies easier. +TIP: https://github.com/danpaz/bodybuilder[bodybuilder] and https://github.com/sudo-suhas/elastic-builder[elastic-builder] can be used to make building query bodies easier. diff --git a/package.json b/package.json index 7fa2ef542..495830903 100644 --- a/package.json +++ b/package.json @@ -36,10 +36,7 @@ "unstable_es_branches": [ "5.x", "master" - ], - "branch_versions": { - "master": "6.0" - } + ] }, "devDependencies": { "@spalger/eslint-config-personal": "^0.4.0", diff --git a/scripts/Version.js b/scripts/Version.js index e7a0624eb..e685ae393 100644 --- a/scripts/Version.js +++ b/scripts/Version.js @@ -1,13 +1,34 @@ var _ = require('lodash'); var pkg = require('../package.json'); -var branches = pkg.config.supported_es_branches; -var branchVersions = pkg.config.branch_versions; +var branches = [...pkg.config.supported_es_branches, ...pkg.config.unstable_es_branches]; var semver = require('semver'); -var maxMinorVersion = function (majorV) { - var versions = branches.map(function (v) { return v + '.0'; }); - return new Version(semver.maxSatisfying(versions, '^' + majorV)); -}; +function nextMajorVersion() { + const largestMajor = branches + .map(v => parseFloat(v.split('.')[0])) + .filter(n => !isNaN(n)) + .sort((a, b) => b - a) + .shift() + + return new Version(`${largestMajor + 1}.0.0`) +} + +function nextMinorVersion(major) { + const largestMinor = branches + .map(v => v.split('.').map(parseFloat).slice(0, 2)) + // ensure all tuples have length 2 + .filter(vt => vt.length === 2) + // ensure all values in tuples are not NaN + .filter(vt => vt.every(v => !isNaN(v))) + // ensure that major version in tuple matches major (both as a string) + .filter(vt => `${vt[0]}` === `${major}`) + // sort by the minor version in each tuple + .sort((vta, vtb) => vtb[1] - vta[1]) + // get the minor version from the first tuple + .shift()[1]; + + return new Version(`${major}.${largestMinor + 1}.0`); +} function Version(v) { this.version = v; @@ -17,16 +38,15 @@ function Version(v) { } Version.fromBranch = function (branch) { - var m; - - var branchVersion = branchVersions[branch]; - var versionString = branchVersion ? branchVersion : branch; - // n.m -> n.m.0 - if (m = versionString.match(/^\d+\.\d+$/)) return new Version(versionString + '.0'); + if (/^\d+\.\d+$/.test(branch)) return new Version(branch + '.0'); // n.x -> n.(maxVersion + 1).0 - if (m = versionString.match(/^(\d+)\.x$/i)) return maxMinorVersion(m[1]).increment('minor'); + const match = branch.match(/^(\d+)\.x$/i) + if (match) return nextMinorVersion(match[1]); + + // master => (maxMajorVersion + 1).0.0 + if (branch === 'master') return nextMajorVersion() throw new Error('unable to convert branch "' + branch + '" to semver'); }; @@ -36,6 +56,7 @@ Version.prototype.increment = function (which) { }; Version.prototype.satisfies = function (range) { + debugger return semver.satisfies(this.version, range); }; diff --git a/scripts/generate/js_api.js b/scripts/generate/js_api.js index 0a4a06a6e..edaa1f203 100644 --- a/scripts/generate/js_api.js +++ b/scripts/generate/js_api.js @@ -27,7 +27,8 @@ module.exports = function (branch, done) { mergeConcatParams: {}, paramAsBody: {}, clientActionModifier: false, - examples: {} + examples: {}, + descriptions: {}, }); var steps = [ @@ -115,12 +116,19 @@ module.exports = function (branch, done) { [].concat(apiSpec.actions, apiSpec.proxies) .forEach(function (action) { var examplePath = overrides.examples[action.name] || action.name + '.asciidoc'; + var descriptionPath = overrides.descriptions[action.name] || action.name + '.asciidoc'; try { action.examples = fs.readFileSync(fromRoot('docs/_examples', examplePath), 'utf8'); } catch (e) { action.examples = '// no examples'; } + + try { + action.description = fs.readFileSync(fromRoot('docs/_descriptions', descriptionPath), 'utf8'); + } catch (e) { + action.description = '// no description'; + } }) done(); diff --git a/scripts/generate/overrides.js b/scripts/generate/overrides.js index 4076462a0..ee406a062 100644 --- a/scripts/generate/overrides.js +++ b/scripts/generate/overrides.js @@ -249,9 +249,6 @@ function (spec) { '/_update_by_query/{task_id}/_rethrottle', '/_delete_by_query/{task_id}/_rethrottle' ] - }, - examples: { - scroll: 'scroll_5.0+.asciidoc' } }, { @@ -266,5 +263,31 @@ function (spec) { body: 'scroll_id' } } + }, + // description overrides by major version + { + version: '0.90.x', + descriptions: { + search: 'search_1.x.asciidoc' + } + }, + { + version: '1.x', + descriptions: { + search: 'search_1.x.asciidoc' + } + }, + { + version: '2.x', + descriptions: { + search: 'search_2.x.asciidoc' + } + }, + // examples changed at 5.0 + { + version: '<5.0.0', + examples: { + scroll: 'scroll_<5.0.asciidoc' + } } ]; diff --git a/scripts/generate/templates/api_methods.tmpl b/scripts/generate/templates/api_methods.tmpl index c7cecd050..5e8bc1393 100644 --- a/scripts/generate/templates/api_methods.tmpl +++ b/scripts/generate/templates/api_methods.tmpl @@ -21,7 +21,7 @@ _.each(actions, function (action) { client.<%= action.name %>([params, [callback]]) -------- -<%= description(action.name) %> +<%= action.description %> Check the *<>* and <%= action.docUrl %>[the elasticsearch docs] for more information pertaining to this method. diff --git a/scripts/generate/templates/index.js b/scripts/generate/templates/index.js index 97256ebf3..aec6069dd 100644 --- a/scripts/generate/templates/index.js +++ b/scripts/generate/templates/index.js @@ -54,18 +54,6 @@ var templateGlobals = { return block.split('\n\n').join('\n+\n'); }, - description: function (action) { - try { - return fs.readFileSync(path.join(__dirname, '../../../docs/_descriptions/' + action + '.asciidoc')); - } catch (e) { - if (~e.message.indexOf('ENOENT')) { - return '// no description'; - } else { - throw e; - } - } - }, - paramType: function (type, paramName) { switch (type && type.toLowerCase ? type.toLowerCase() : 'any') { case 'time': From 23a4a193cf26eb75e30c0789faa7b4107cdd7020 Mon Sep 17 00:00:00 2001 From: spalger Date: Mon, 1 May 2017 16:30:39 -0700 Subject: [PATCH 17/61] add 5.4 to unstable branches --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 495830903..34749cc90 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ ], "unstable_es_branches": [ "5.x", + "5.4", "master" ] }, From b4a5650ab03447ffece94c8632ed24fd37a07b43 Mon Sep 17 00:00:00 2001 From: spalger Date: Mon, 1 May 2017 16:31:44 -0700 Subject: [PATCH 18/61] [apis] regenerate --- docs/configuration.asciidoc | 2 + src/lib/apis/5_4.js | 7359 +++++++++++++++++++++++++++++++++ src/lib/apis/browser_index.js | 1 + src/lib/apis/index.js | 1 + 4 files changed, 7363 insertions(+) create mode 100644 src/lib/apis/5_4.js diff --git a/docs/configuration.asciidoc b/docs/configuration.asciidoc index 99a5a045c..368559c87 100644 --- a/docs/configuration.asciidoc +++ b/docs/configuration.asciidoc @@ -63,6 +63,7 @@ Options in node ::: * `'1.7'` * `'0.90'` * `'5.x'` (unstable) + * `'5.4'` (unstable) * `'master'` (unstable) Options in the browser ::: @@ -72,6 +73,7 @@ Options in the browser ::: * `'5.0'` * `'2.4'` * `'5.x'` (unstable) + * `'5.4'` (unstable) * `'master'` (unstable) diff --git a/src/lib/apis/5_4.js b/src/lib/apis/5_4.js new file mode 100644 index 000000000..63a9f4270 --- /dev/null +++ b/src/lib/apis/5_4.js @@ -0,0 +1,7359 @@ +var ca = require('../client_action').makeFactoryWithModifier(function (spec) { + return require('../utils').merge(spec, { + params: { + filterPath: { + type: 'list', + name: 'filter_path' + } + } + }); +}); +var namespace = require('../client_action').namespaceFactory; +var api = module.exports = {}; + +api._namespaces = ['cat', 'cluster', 'indices', 'ingest', 'nodes', 'remote', 'snapshot', 'tasks']; + +/** + * Perform a [bulk](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-bulk.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {<>} params.refresh - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + * @param {<>} params.routing - Specific routing value + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.type - Default document type for items which don't provide one + * @param {<>, <>, <>} params.fields - Default comma-separated list of fields to return in the response for updates, can be overridden on each sub-request + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request + * @param {<>, <>, <>} params._sourceExclude - Default list of fields to exclude from the returned _source field, can be overridden on each sub-request + * @param {<>, <>, <>} params._sourceInclude - Default list of fields to extract and return from the _source field, can be overridden on each sub-request + * @param {<>} params.pipeline - The pipeline id to preprocess incoming documents with + * @param {<>} params.index - Default index for items which don't provide one + */ +api.bulk = ca({ + params: { + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + }, + refresh: { + type: 'enum', + options: [ + 'true', + 'false', + 'wait_for', + '' + ] + }, + routing: { + type: 'string' + }, + timeout: { + type: 'time' + }, + type: { + type: 'string' + }, + fields: { + type: 'list' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + }, + pipeline: { + type: 'string' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_bulk', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + } + } + }, + { + fmt: '/<%=index%>/_bulk', + req: { + index: { + type: 'string' + } + } + }, + { + fmt: '/_bulk' + } + ], + needBody: true, + bulkBody: true, + method: 'POST' +}); + +api.cat = namespace(); + +/** + * Perform a [cat.aliases](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + * @param {<>, <>, <>} params.name - A comma-separated list of alias names to return + */ +api.cat.prototype.aliases = ca({ + params: { + format: { + type: 'string' + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/_cat/aliases/<%=name%>', + req: { + name: { + type: 'list' + } + } + }, + { + fmt: '/_cat/aliases' + } + ] +}); + +/** + * Perform a [cat.allocation](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-allocation.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.bytes - The unit in which to display byte values + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + * @param {<>, <>, <>} params.nodeId - A comma-separated list of node IDs or names to limit the returned information + */ +api.cat.prototype.allocation = ca({ + params: { + format: { + type: 'string' + }, + bytes: { + type: 'enum', + options: [ + 'b', + 'k', + 'kb', + 'm', + 'mb', + 'g', + 'gb', + 't', + 'tb', + 'p', + 'pb' + ] + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/_cat/allocation/<%=nodeId%>', + req: { + nodeId: { + type: 'list' + } + } + }, + { + fmt: '/_cat/allocation' + } + ] +}); + +/** + * Perform a [cat.count](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-count.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + * @param {<>, <>, <>} params.index - A comma-separated list of index names to limit the returned information + */ +api.cat.prototype.count = ca({ + params: { + format: { + type: 'string' + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/_cat/count/<%=index%>', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_cat/count' + } + ] +}); + +/** + * Perform a [cat.fielddata](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-fielddata.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.bytes - The unit in which to display byte values + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + * @param {<>, <>, <>} params.fields - A comma-separated list of fields to return the fielddata size + */ +api.cat.prototype.fielddata = ca({ + params: { + format: { + type: 'string' + }, + bytes: { + type: 'enum', + options: [ + 'b', + 'k', + 'kb', + 'm', + 'mb', + 'g', + 'gb', + 't', + 'tb', + 'p', + 'pb' + ] + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + }, + fields: { + type: 'list' + } + }, + urls: [ + { + fmt: '/_cat/fielddata/<%=fields%>', + req: { + fields: { + type: 'list' + } + } + }, + { + fmt: '/_cat/fielddata' + } + ] +}); + +/** + * Perform a [cat.health](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-health.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} [params.ts=true] - Set to false to disable timestamping + * @param {<>} params.v - Verbose mode. Display column headers + */ +api.cat.prototype.health = ca({ + params: { + format: { + type: 'string' + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + ts: { + type: 'boolean', + 'default': true + }, + v: { + type: 'boolean', + 'default': false + } + }, + url: { + fmt: '/_cat/health' + } +}); + +/** + * Perform a [cat.help](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + */ +api.cat.prototype.help = ca({ + params: { + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + } + }, + url: { + fmt: '/_cat' + } +}); + +/** + * Perform a [cat.indices](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-indices.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.bytes - The unit in which to display byte values + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.health - A health status ("green", "yellow", or "red" to filter only indices matching the specified health status + * @param {<>} params.help - Return help information + * @param {<>} params.pri - Set to true to return stats only for primary shards + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + * @param {<>, <>, <>} params.index - A comma-separated list of index names to limit the returned information + */ +api.cat.prototype.indices = ca({ + params: { + format: { + type: 'string' + }, + bytes: { + type: 'enum', + options: [ + 'b', + 'k', + 'm', + 'g' + ] + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + health: { + type: 'enum', + 'default': null, + options: [ + 'green', + 'yellow', + 'red' + ] + }, + help: { + type: 'boolean', + 'default': false + }, + pri: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/_cat/indices/<%=index%>', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_cat/indices' + } + ] +}); + +/** + * Perform a [cat.master](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-master.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + */ +api.cat.prototype.master = ca({ + params: { + format: { + type: 'string' + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + url: { + fmt: '/_cat/master' + } +}); + +/** + * Perform a [cat.nodeattrs](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-nodeattrs.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + */ +api.cat.prototype.nodeattrs = ca({ + params: { + format: { + type: 'string' + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + url: { + fmt: '/_cat/nodeattrs' + } +}); + +/** + * Perform a [cat.nodes](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-nodes.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.fullId - Return the full node ID instead of the shortened version (default: false) + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + */ +api.cat.prototype.nodes = ca({ + params: { + format: { + type: 'string' + }, + fullId: { + type: 'boolean', + name: 'full_id' + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + url: { + fmt: '/_cat/nodes' + } +}); + +/** + * Perform a [cat.pendingTasks](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-pending-tasks.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + */ +api.cat.prototype.pendingTasks = ca({ + params: { + format: { + type: 'string' + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + url: { + fmt: '/_cat/pending_tasks' + } +}); + +/** + * Perform a [cat.plugins](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-plugins.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + */ +api.cat.prototype.plugins = ca({ + params: { + format: { + type: 'string' + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + url: { + fmt: '/_cat/plugins' + } +}); + +/** + * Perform a [cat.recovery](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-recovery.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.bytes - The unit in which to display byte values + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + * @param {<>, <>, <>} params.index - A comma-separated list of index names to limit the returned information + */ +api.cat.prototype.recovery = ca({ + params: { + format: { + type: 'string' + }, + bytes: { + type: 'enum', + options: [ + 'b', + 'k', + 'kb', + 'm', + 'mb', + 'g', + 'gb', + 't', + 'tb', + 'p', + 'pb' + ] + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/_cat/recovery/<%=index%>', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_cat/recovery' + } + ] +}); + +/** + * Perform a [cat.repositories](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-repositories.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.local - Return local information, do not retrieve the state from master node + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + */ +api.cat.prototype.repositories = ca({ + params: { + format: { + type: 'string' + }, + local: { + type: 'boolean', + 'default': false + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + url: { + fmt: '/_cat/repositories' + } +}); + +/** + * Perform a [cat.segments](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-segments.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + * @param {<>, <>, <>} params.index - A comma-separated list of index names to limit the returned information + */ +api.cat.prototype.segments = ca({ + params: { + format: { + type: 'string' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/_cat/segments/<%=index%>', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_cat/segments' + } + ] +}); + +/** + * Perform a [cat.shards](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-shards.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + * @param {<>, <>, <>} params.index - A comma-separated list of index names to limit the returned information + */ +api.cat.prototype.shards = ca({ + params: { + format: { + type: 'string' + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/_cat/shards/<%=index%>', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_cat/shards' + } + ] +}); + +/** + * Perform a [cat.snapshots](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-snapshots.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.ignoreUnavailable - Set to true to ignore unavailable snapshots + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + * @param {<>, <>, <>} params.repository - Name of repository from which to fetch the snapshot information + */ +api.cat.prototype.snapshots = ca({ + params: { + format: { + type: 'string' + }, + ignoreUnavailable: { + type: 'boolean', + 'default': false, + name: 'ignore_unavailable' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/_cat/snapshots/<%=repository%>', + req: { + repository: { + type: 'list' + } + } + }, + { + fmt: '/_cat/snapshots' + } + ] +}); + +/** + * Perform a [cat.tasks](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/tasks.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>, <>, <>} params.nodeId - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * @param {<>, <>, <>} params.actions - A comma-separated list of actions that should be returned. Leave empty to return all. + * @param {<>} params.detailed - Return detailed task information (default: false) + * @param {<>} params.parentNode - Return tasks with specified parent node. + * @param {<>} params.parentTask - Return tasks with specified parent task id. Set to -1 to return all. + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + */ +api.cat.prototype.tasks = ca({ + params: { + format: { + type: 'string' + }, + nodeId: { + type: 'list', + name: 'node_id' + }, + actions: { + type: 'list' + }, + detailed: { + type: 'boolean' + }, + parentNode: { + type: 'string', + name: 'parent_node' + }, + parentTask: { + type: 'number', + name: 'parent_task' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + url: { + fmt: '/_cat/tasks' + } +}); + +/** + * Perform a [cat.templates](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-templates.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + * @param {<>} params.name - A pattern that returned template names must match + */ +api.cat.prototype.templates = ca({ + params: { + format: { + type: 'string' + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/_cat/templates/<%=name%>', + req: { + name: { + type: 'string' + } + } + }, + { + fmt: '/_cat/templates' + } + ] +}); + +/** + * Perform a [cat.threadPool](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-thread-pool.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.size - The multiplier in which to display values + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + * @param {<>, <>, <>} params.threadPoolPatterns - A comma-separated list of regular-expressions to filter the thread pools in the output + */ +api.cat.prototype.threadPool = ca({ + params: { + format: { + type: 'string' + }, + size: { + type: 'enum', + options: [ + '', + 'k', + 'm', + 'g', + 't', + 'p' + ] + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/_cat/thread_pool/<%=threadPoolPatterns%>', + req: { + threadPoolPatterns: { + type: 'list' + } + } + }, + { + fmt: '/_cat/thread_pool' + } + ] +}); + +/** + * Perform a [clearScroll](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-request-scroll.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.scrollId - A comma-separated list of scroll IDs to clear + */ +api.clearScroll = ca({ + urls: [ + { + fmt: '/_search/scroll/<%=scrollId%>', + req: { + scrollId: { + type: 'list' + } + } + }, + { + fmt: '/_search/scroll' + } + ], + paramAsBody: { + param: 'scrollId', + body: 'scroll_id' + }, + method: 'DELETE' +}); + +api.cluster = namespace(); + +/** + * Perform a [cluster.allocationExplain](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-allocation-explain.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.includeYesDecisions - Return 'YES' decisions in explanation (default: false) + * @param {<>} params.includeDiskInfo - Return information about disk usage and shard sizes (default: false) + */ +api.cluster.prototype.allocationExplain = ca({ + params: { + includeYesDecisions: { + type: 'boolean', + name: 'include_yes_decisions' + }, + includeDiskInfo: { + type: 'boolean', + name: 'include_disk_info' + } + }, + url: { + fmt: '/_cluster/allocation/explain' + }, + method: 'POST' +}); + +/** + * Perform a [cluster.getSettings](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-update-settings.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.includeDefaults - Whether to return all default clusters setting. + */ +api.cluster.prototype.getSettings = ca({ + params: { + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + timeout: { + type: 'time' + }, + includeDefaults: { + type: 'boolean', + 'default': false, + name: 'include_defaults' + } + }, + url: { + fmt: '/_cluster/settings' + } +}); + +/** + * Perform a [cluster.health](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-health.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} [params.level=cluster] - Specify the level of detail for returned information + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.waitForActiveShards - Wait until the specified number of shards is active + * @param {<>} params.waitForNodes - Wait until the specified number of nodes is available + * @param {<>} params.waitForEvents - Wait until all currently queued events with the given priority are processed + * @param {<>} params.waitForNoRelocatingShards - Whether to wait until there are no relocating shards in the cluster + * @param {<>} params.waitForStatus - Wait until cluster is in a specific state + * @param {<>, <>, <>} params.index - Limit the information returned to a specific index + */ +api.cluster.prototype.health = ca({ + params: { + level: { + type: 'enum', + 'default': 'cluster', + options: [ + 'cluster', + 'indices', + 'shards' + ] + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + timeout: { + type: 'time' + }, + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + }, + waitForNodes: { + type: 'string', + name: 'wait_for_nodes' + }, + waitForEvents: { + type: 'enum', + options: [ + 'immediate', + 'urgent', + 'high', + 'normal', + 'low', + 'languid' + ], + name: 'wait_for_events' + }, + waitForNoRelocatingShards: { + type: 'boolean', + name: 'wait_for_no_relocating_shards' + }, + waitForStatus: { + type: 'enum', + 'default': null, + options: [ + 'green', + 'yellow', + 'red' + ], + name: 'wait_for_status' + } + }, + urls: [ + { + fmt: '/_cluster/health/<%=index%>', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_cluster/health' + } + ] +}); + +/** + * Perform a [cluster.pendingTasks](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-pending.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Specify timeout for connection to master + */ +api.cluster.prototype.pendingTasks = ca({ + params: { + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + } + }, + url: { + fmt: '/_cluster/pending_tasks' + } +}); + +/** + * Perform a [cluster.putSettings](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-update-settings.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.timeout - Explicit operation timeout + */ +api.cluster.prototype.putSettings = ca({ + params: { + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + timeout: { + type: 'time' + } + }, + url: { + fmt: '/_cluster/settings' + }, + method: 'PUT' +}); + +/** + * Perform a [cluster.reroute](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-reroute.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.dryRun - Simulate the operation only and return the resulting state + * @param {<>} params.explain - Return an explanation of why the commands can or cannot be executed + * @param {<>} params.retryFailed - Retries allocation of shards that are blocked due to too many subsequent allocation failures + * @param {<>, <>, <>} params.metric - Limit the information returned to the specified metrics. Defaults to all but metadata + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.timeout - Explicit operation timeout + */ +api.cluster.prototype.reroute = ca({ + params: { + dryRun: { + type: 'boolean', + name: 'dry_run' + }, + explain: { + type: 'boolean' + }, + retryFailed: { + type: 'boolean', + name: 'retry_failed' + }, + metric: { + type: 'list', + options: [ + '_all', + 'blocks', + 'metadata', + 'nodes', + 'routing_table', + 'master_node', + 'version' + ] + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + timeout: { + type: 'time' + } + }, + url: { + fmt: '/_cluster/reroute' + }, + method: 'POST' +}); + +/** + * Perform a [cluster.state](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-state.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @param {<>, <>, <>} params.metric - Limit the information returned to the specified metrics + */ +api.cluster.prototype.state = ca({ + params: { + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + } + }, + urls: [ + { + fmt: '/_cluster/state/<%=metric%>/<%=index%>', + req: { + metric: { + type: 'list', + options: [ + '_all', + 'blocks', + 'metadata', + 'nodes', + 'routing_table', + 'routing_nodes', + 'master_node', + 'version' + ] + }, + index: { + type: 'list' + } + } + }, + { + fmt: '/_cluster/state/<%=metric%>', + req: { + metric: { + type: 'list', + options: [ + '_all', + 'blocks', + 'metadata', + 'nodes', + 'routing_table', + 'routing_nodes', + 'master_node', + 'version' + ] + } + } + }, + { + fmt: '/_cluster/state' + } + ] +}); + +/** + * Perform a [cluster.stats](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-stats.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>, <>, <>} params.nodeId - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + */ +api.cluster.prototype.stats = ca({ + params: { + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, + timeout: { + type: 'time' + } + }, + urls: [ + { + fmt: '/_cluster/stats/nodes/<%=nodeId%>', + req: { + nodeId: { + type: 'list' + } + } + }, + { + fmt: '/_cluster/stats' + } + ] +}); + +/** + * Perform a [count](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-count.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.minScore - Include only documents with a specific `_score` value in the result + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.routing - Specific routing value + * @param {<>} params.q - Query in the Lucene query string syntax + * @param {<>} params.analyzer - The analyzer to use for the query string + * @param {<>} params.analyzeWildcard - Specify whether wildcard and prefix queries should be analyzed (default: false) + * @param {<>} [params.defaultOperator=OR] - The default operator for query string query (AND or OR) + * @param {<>} params.df - The field to use as default where no field prefix is given in the query string + * @param {<>} params.lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * @param {<>, <>, <>} params.index - A comma-separated list of indices to restrict the results + * @param {<>, <>, <>} params.type - A comma-separated list of types to restrict the results + */ +api.count = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + minScore: { + type: 'number', + name: 'min_score' + }, + preference: { + type: 'string' + }, + routing: { + type: 'string' + }, + q: { + type: 'string' + }, + analyzer: { + type: 'string' + }, + analyzeWildcard: { + type: 'boolean', + name: 'analyze_wildcard' + }, + defaultOperator: { + type: 'enum', + 'default': 'OR', + options: [ + 'AND', + 'OR' + ], + name: 'default_operator' + }, + df: { + type: 'string' + }, + lenient: { + type: 'boolean' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_count', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_count', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_count' + } + ], + method: 'POST' +}); + +/** + * Perform a [countPercolate](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-percolate.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.routing - A comma-separated list of specific routing values + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.percolateIndex - The index to count percolate the document into. Defaults to index. + * @param {<>} params.percolateType - The type to count percolate document into. Defaults to type. + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.index - The index of the document being count percolated. + * @param {<>} params.type - The type of the document being count percolated. + * @param {<>} params.id - Substitute the document in the request body with a document that is known by the specified id. On top of the id, the index and type parameter will be used to retrieve the document from within the cluster. + */ +api.countPercolate = ca({ + params: { + routing: { + type: 'list' + }, + preference: { + type: 'string' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + percolateIndex: { + type: 'string', + name: 'percolate_index' + }, + percolateType: { + type: 'string', + name: 'percolate_type' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/<%=id%>/_percolate/count', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + { + fmt: '/<%=index%>/<%=type%>/_percolate/count', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + } + } + } + ], + method: 'POST' +}); + +/** + * Perform a [create](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-index_.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {<>} params.parent - ID of the parent document + * @param {<>} params.refresh - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + * @param {<>} params.routing - Specific routing value + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.timestamp - Explicit timestamp for the document + * @param {<>} params.ttl - Expiration time for the document + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.pipeline - The pipeline id to preprocess incoming documents with + * @param {<>} params.id - Document ID + * @param {<>} params.index - The name of the index + * @param {<>} params.type - The type of the document + */ +api.create = ca({ + params: { + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + }, + parent: { + type: 'string' + }, + refresh: { + type: 'enum', + options: [ + 'true', + 'false', + 'wait_for', + '' + ] + }, + routing: { + type: 'string' + }, + timeout: { + type: 'time' + }, + timestamp: { + type: 'time' + }, + ttl: { + type: 'time' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + }, + pipeline: { + type: 'string' + } + }, + url: { + fmt: '/<%=index%>/<%=type%>/<%=id%>/_create', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + needBody: true, + method: 'POST' +}); + +/** + * Perform a [delete](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-delete.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {<>} params.parent - ID of parent document + * @param {<>} params.refresh - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + * @param {<>} params.routing - Specific routing value + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.id - The document ID + * @param {<>} params.index - The name of the index + * @param {<>} params.type - The type of the document + */ +api['delete'] = ca({ + params: { + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + }, + parent: { + type: 'string' + }, + refresh: { + type: 'enum', + options: [ + 'true', + 'false', + 'wait_for', + '' + ] + }, + routing: { + type: 'string' + }, + timeout: { + type: 'time' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + } + }, + url: { + fmt: '/<%=index%>/<%=type%>/<%=id%>', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + method: 'DELETE' +}); + +/** + * Perform a [deleteByQuery](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-delete-by-query.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.analyzer - The analyzer to use for the query string + * @param {<>} params.analyzeWildcard - Specify whether wildcard and prefix queries should be analyzed (default: false) + * @param {<>} [params.defaultOperator=OR] - The default operator for query string query (AND or OR) + * @param {<>} params.df - The field to use as default where no field prefix is given in the query string + * @param {<>} params.from - Starting offset (default: 0) + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.conflicts=abort] - What to do when the delete-by-query hits version conflicts? + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.q - Query in the Lucene query string syntax + * @param {<>, <>, <>} params.routing - A comma-separated list of specific routing values + * @param {<>} params.scroll - Specify how long a consistent view of the index should be maintained for scrolled search + * @param {<>} params.searchType - Search operation type + * @param {<>} params.searchTimeout - Explicit timeout for each search request. Defaults to no timeout. + * @param {<>} params.size - Number of hits to return (default: 10) + * @param {<>, <>, <>} params.sort - A comma-separated list of : pairs + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.terminateAfter - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. + * @param {<>, <>, <>} params.stats - Specific 'tag' of the request for logging and statistical purposes + * @param {<>} params.version - Specify whether to return document version as part of a hit + * @param {<>} params.requestCache - Specify if request cache should be used for this request or not, defaults to index level setting + * @param {<>} params.refresh - Should the effected indexes be refreshed? + * @param {<>} [params.timeout=1m] - Time each individual bulk request should wait for shards that are unavailable. + * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {<>} params.scrollSize - Size on the scroll request powering the update_by_query + * @param {<>} [params.waitForCompletion=true] - Should the request should block until the delete-by-query is complete. + * @param {<>} params.requestsPerSecond - The throttle for this request in sub-requests per second. -1 means no throttle. + * @param {<>} [params.slices=1] - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. + * @param {<>, <>, <>} params.index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * @param {<>, <>, <>} params.type - A comma-separated list of document types to search; leave empty to perform the operation on all types + */ +api.deleteByQuery = ca({ + params: { + analyzer: { + type: 'string' + }, + analyzeWildcard: { + type: 'boolean', + name: 'analyze_wildcard' + }, + defaultOperator: { + type: 'enum', + 'default': 'OR', + options: [ + 'AND', + 'OR' + ], + name: 'default_operator' + }, + df: { + type: 'string' + }, + from: { + type: 'number' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + conflicts: { + type: 'enum', + 'default': 'abort', + options: [ + 'abort', + 'proceed' + ] + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + lenient: { + type: 'boolean' + }, + preference: { + type: 'string' + }, + q: { + type: 'string' + }, + routing: { + type: 'list' + }, + scroll: { + type: 'time' + }, + searchType: { + type: 'enum', + options: [ + 'query_then_fetch', + 'dfs_query_then_fetch' + ], + name: 'search_type' + }, + searchTimeout: { + type: 'time', + name: 'search_timeout' + }, + size: { + type: 'number' + }, + sort: { + type: 'list' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + }, + terminateAfter: { + type: 'number', + name: 'terminate_after' + }, + stats: { + type: 'list' + }, + version: { + type: 'boolean' + }, + requestCache: { + type: 'boolean', + name: 'request_cache' + }, + refresh: { + type: 'boolean' + }, + timeout: { + type: 'time', + 'default': '1m' + }, + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + }, + scrollSize: { + type: 'number', + name: 'scroll_size' + }, + waitForCompletion: { + type: 'boolean', + 'default': true, + name: 'wait_for_completion' + }, + requestsPerSecond: { + type: 'number', + 'default': 0, + name: 'requests_per_second' + }, + slices: { + type: 'number', + 'default': 1 + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_delete_by_query', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_delete_by_query', + req: { + index: { + type: 'list' + } + } + } + ], + needBody: true, + method: 'POST' +}); + +/** + * Perform a [deleteScript](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-scripting.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.id - Script ID + * @param {<>} params.lang - Script language + */ +api.deleteScript = ca({ + urls: [ + { + fmt: '/_scripts/<%=lang%>/<%=id%>', + req: { + lang: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + { + fmt: '/_scripts/<%=lang%>', + req: { + lang: { + type: 'string' + } + } + } + ], + method: 'DELETE' +}); + +/** + * Perform a [deleteTemplate](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-template.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.id - Template ID + */ +api.deleteTemplate = ca({ + url: { + fmt: '/_search/template/<%=id%>', + req: { + id: { + type: 'string' + } + } + }, + method: 'DELETE' +}); + +/** + * Perform a [exists](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-get.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.storedFields - A comma-separated list of stored fields to return in the response + * @param {<>} params.parent - The ID of the parent document + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.realtime - Specify whether to perform the operation in realtime or search mode + * @param {<>} params.refresh - Refresh the shard containing the document before performing the operation + * @param {<>} params.routing - Specific routing value + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.id - The document ID + * @param {<>} params.index - The name of the index + * @param {<>} params.type - The type of the document (use `_all` to fetch the first document matching the ID across all types) + */ +api.exists = ca({ + params: { + storedFields: { + type: 'list', + name: 'stored_fields' + }, + parent: { + type: 'string' + }, + preference: { + type: 'string' + }, + realtime: { + type: 'boolean' + }, + refresh: { + type: 'boolean' + }, + routing: { + type: 'string' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + } + }, + url: { + fmt: '/<%=index%>/<%=type%>/<%=id%>', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + method: 'HEAD' +}); + +/** + * Perform a [existsSource](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.parent - The ID of the parent document + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.realtime - Specify whether to perform the operation in realtime or search mode + * @param {<>} params.refresh - Refresh the shard containing the document before performing the operation + * @param {<>} params.routing - Specific routing value + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.id - The document ID + * @param {<>} params.index - The name of the index + * @param {<>} params.type - The type of the document; use `_all` to fetch the first document matching the ID across all types + */ +api.existsSource = ca({ + params: { + parent: { + type: 'string' + }, + preference: { + type: 'string' + }, + realtime: { + type: 'boolean' + }, + refresh: { + type: 'boolean' + }, + routing: { + type: 'string' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + } + }, + url: { + fmt: '/<%=index%>/<%=type%>/<%=id%>/_source', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + method: 'HEAD' +}); + +/** + * Perform a [explain](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-explain.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.analyzeWildcard - Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false) + * @param {<>} params.analyzer - The analyzer for the query string query + * @param {<>} [params.defaultOperator=OR] - The default operator for query string query (AND or OR) + * @param {<>} params.df - The default field for query string query (default: _all) + * @param {<>, <>, <>} params.storedFields - A comma-separated list of stored fields to return in the response + * @param {<>} params.lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * @param {<>} params.parent - The ID of the parent document + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.q - Query in the Lucene query string syntax + * @param {<>} params.routing - Specific routing value + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.id - The document ID + * @param {<>} params.index - The name of the index + * @param {<>} params.type - The type of the document + */ +api.explain = ca({ + params: { + analyzeWildcard: { + type: 'boolean', + name: 'analyze_wildcard' + }, + analyzer: { + type: 'string' + }, + defaultOperator: { + type: 'enum', + 'default': 'OR', + options: [ + 'AND', + 'OR' + ], + name: 'default_operator' + }, + df: { + type: 'string' + }, + storedFields: { + type: 'list', + name: 'stored_fields' + }, + lenient: { + type: 'boolean' + }, + parent: { + type: 'string' + }, + preference: { + type: 'string' + }, + q: { + type: 'string' + }, + routing: { + type: 'string' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + } + }, + url: { + fmt: '/<%=index%>/<%=type%>/<%=id%>/_explain', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + method: 'POST' +}); + +/** + * Perform a [fieldCaps](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.fields - A comma-separated list of field names + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + */ +api.fieldCaps = ca({ + params: { + fields: { + type: 'list' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + } + }, + urls: [ + { + fmt: '/<%=index%>/_field_caps', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_field_caps' + } + ], + method: 'POST' +}); + +/** + * Perform a [fieldStats](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-field-stats.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.fields - A comma-separated list of fields for to get field statistics for (min value, max value, and more) + * @param {<>} [params.level=cluster] - Defines if field stats should be returned on a per index level or on a cluster wide level + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + */ +api.fieldStats = ca({ + params: { + fields: { + type: 'list' + }, + level: { + type: 'enum', + 'default': 'cluster', + options: [ + 'indices', + 'cluster' + ] + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + } + }, + urls: [ + { + fmt: '/<%=index%>/_field_stats', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_field_stats' + } + ], + method: 'POST' +}); + +/** + * Perform a [get](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-get.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.storedFields - A comma-separated list of stored fields to return in the response + * @param {<>} params.parent - The ID of the parent document + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.realtime - Specify whether to perform the operation in realtime or search mode + * @param {<>} params.refresh - Refresh the shard containing the document before performing the operation + * @param {<>} params.routing - Specific routing value + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.id - The document ID + * @param {<>} params.index - The name of the index + * @param {<>} params.type - The type of the document (use `_all` to fetch the first document matching the ID across all types) + */ +api.get = ca({ + params: { + storedFields: { + type: 'list', + name: 'stored_fields' + }, + parent: { + type: 'string' + }, + preference: { + type: 'string' + }, + realtime: { + type: 'boolean' + }, + refresh: { + type: 'boolean' + }, + routing: { + type: 'string' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + } + }, + url: { + fmt: '/<%=index%>/<%=type%>/<%=id%>', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + } +}); + +/** + * Perform a [getScript](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-scripting.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.id - Script ID + * @param {<>} params.lang - Script language + */ +api.getScript = ca({ + urls: [ + { + fmt: '/_scripts/<%=lang%>/<%=id%>', + req: { + lang: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + { + fmt: '/_scripts/<%=lang%>', + req: { + lang: { + type: 'string' + } + } + } + ] +}); + +/** + * Perform a [getSource](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-get.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.parent - The ID of the parent document + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.realtime - Specify whether to perform the operation in realtime or search mode + * @param {<>} params.refresh - Refresh the shard containing the document before performing the operation + * @param {<>} params.routing - Specific routing value + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.id - The document ID + * @param {<>} params.index - The name of the index + * @param {<>} params.type - The type of the document; use `_all` to fetch the first document matching the ID across all types + */ +api.getSource = ca({ + params: { + parent: { + type: 'string' + }, + preference: { + type: 'string' + }, + realtime: { + type: 'boolean' + }, + refresh: { + type: 'boolean' + }, + routing: { + type: 'string' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + } + }, + url: { + fmt: '/<%=index%>/<%=type%>/<%=id%>/_source', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + } +}); + +/** + * Perform a [getTemplate](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-template.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.id - Template ID + */ +api.getTemplate = ca({ + url: { + fmt: '/_search/template/<%=id%>', + req: { + id: { + type: 'string' + } + } + } +}); + +/** + * Perform a [index](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-index_.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {<>} [params.opType=index] - Explicit operation type + * @param {<>} params.parent - ID of the parent document + * @param {<>} params.refresh - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + * @param {<>} params.routing - Specific routing value + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.timestamp - Explicit timestamp for the document + * @param {<>} params.ttl - Expiration time for the document + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.pipeline - The pipeline id to preprocess incoming documents with + * @param {<>} params.id - Document ID + * @param {<>} params.index - The name of the index + * @param {<>} params.type - The type of the document + */ +api.index = ca({ + params: { + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + }, + opType: { + type: 'enum', + 'default': 'index', + options: [ + 'index', + 'create' + ], + name: 'op_type' + }, + parent: { + type: 'string' + }, + refresh: { + type: 'enum', + options: [ + 'true', + 'false', + 'wait_for', + '' + ] + }, + routing: { + type: 'string' + }, + timeout: { + type: 'time' + }, + timestamp: { + type: 'time' + }, + ttl: { + type: 'time' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + }, + pipeline: { + type: 'string' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/<%=id%>', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + { + fmt: '/<%=index%>/<%=type%>', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + } + } + } + ], + needBody: true, + method: 'POST' +}); + +api.indices = namespace(); + +/** + * Perform a [indices.analyze](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-analyze.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.analyzer - The name of the analyzer to use + * @param {<>, <>, <>} params.charFilter - A comma-separated list of character filters to use for the analysis + * @param {<>} params.field - Use the analyzer configured for this field (instead of passing the analyzer name) + * @param {<>, <>, <>} params.filter - A comma-separated list of filters to use for the analysis + * @param {<>} params.index - The name of the index to scope the operation + * @param {<>} params.preferLocal - With `true`, specify that a local shard should be used if available, with `false`, use a random shard (default: true) + * @param {<>, <>, <>} params.text - The text on which the analysis should be performed (when request body is not used) + * @param {<>} params.tokenizer - The name of the tokenizer to use for the analysis + * @param {<>} params.explain - With `true`, outputs more advanced details. (default: false) + * @param {<>, <>, <>} params.attributes - A comma-separated list of token attributes to output, this parameter works only with `explain=true` + * @param {<>} [params.format=detailed] - Format of the output + */ +api.indices.prototype.analyze = ca({ + params: { + analyzer: { + type: 'string' + }, + charFilter: { + type: 'list', + name: 'char_filter' + }, + field: { + type: 'string' + }, + filter: { + type: 'list' + }, + index: { + type: 'string' + }, + preferLocal: { + type: 'boolean', + name: 'prefer_local' + }, + text: { + type: 'list' + }, + tokenizer: { + type: 'string' + }, + explain: { + type: 'boolean' + }, + attributes: { + type: 'list' + }, + format: { + type: 'enum', + 'default': 'detailed', + options: [ + 'detailed', + 'text' + ] + } + }, + urls: [ + { + fmt: '/<%=index%>/_analyze', + req: { + index: { + type: 'string' + } + } + }, + { + fmt: '/_analyze' + } + ], + method: 'POST' +}); + +/** + * Perform a [indices.clearCache](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-clearcache.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.fieldData - Clear field data + * @param {<>} params.fielddata - Clear field data + * @param {<>, <>, <>} params.fields - A comma-separated list of fields to clear when using the `field_data` parameter (default: all) + * @param {<>} params.query - Clear query caches + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>, <>, <>} params.index - A comma-separated list of index name to limit the operation + * @param {<>} params.recycler - Clear the recycler cache + * @param {<>} params.requestCache - Clear request cache + * @param {<>} params.request - Clear request cache + */ +api.indices.prototype.clearCache = ca({ + params: { + fieldData: { + type: 'boolean', + name: 'field_data' + }, + fielddata: { + type: 'boolean' + }, + fields: { + type: 'list' + }, + query: { + type: 'boolean' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + index: { + type: 'list' + }, + recycler: { + type: 'boolean' + }, + requestCache: { + type: 'boolean', + name: 'request_cache' + }, + request: { + type: 'boolean' + } + }, + urls: [ + { + fmt: '/<%=index%>/_cache/clear', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_cache/clear' + } + ], + method: 'POST' +}); + +/** + * Perform a [indices.close](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-open-close.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>, <>, <>} params.index - A comma separated list of indices to close + */ +api.indices.prototype.close = ca({ + params: { + timeout: { + type: 'time' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + } + }, + url: { + fmt: '/<%=index%>/_close', + req: { + index: { + type: 'list' + } + } + }, + method: 'POST' +}); + +/** + * Perform a [indices.create](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-create-index.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.waitForActiveShards - Set the number of active shards to wait for before the operation returns. + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>} params.updateAllTypes - Whether to update the mapping for all fields with the same name across all types or not + * @param {<>} params.index - The name of the index + */ +api.indices.prototype.create = ca({ + params: { + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + }, + timeout: { + type: 'time' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + updateAllTypes: { + type: 'boolean', + name: 'update_all_types' + } + }, + url: { + fmt: '/<%=index%>', + req: { + index: { + type: 'string' + } + } + }, + method: 'PUT' +}); + +/** + * Perform a [indices.delete](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-delete-index.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>, <>, <>} params.index - A comma-separated list of indices to delete; use `_all` or `*` string to delete all indices + */ +api.indices.prototype['delete'] = ca({ + params: { + timeout: { + type: 'time' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + } + }, + url: { + fmt: '/<%=index%>', + req: { + index: { + type: 'list' + } + } + }, + method: 'DELETE' +}); + +/** + * Perform a [indices.deleteAlias](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.timeout - Explicit timestamp for the document + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>, <>, <>} params.index - A comma-separated list of index names (supports wildcards); use `_all` for all indices + * @param {<>, <>, <>} params.name - A comma-separated list of aliases to delete (supports wildcards); use `_all` to delete all aliases for the specified indices. + */ +api.indices.prototype.deleteAlias = ca({ + params: { + timeout: { + type: 'time' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + } + }, + url: { + fmt: '/<%=index%>/_alias/<%=name%>', + req: { + index: { + type: 'list' + }, + name: { + type: 'list' + } + } + }, + method: 'DELETE' +}); + +/** + * Perform a [indices.deleteTemplate](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>} params.name - The name of the template + */ +api.indices.prototype.deleteTemplate = ca({ + params: { + timeout: { + type: 'time' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + } + }, + url: { + fmt: '/_template/<%=name%>', + req: { + name: { + type: 'string' + } + } + }, + method: 'DELETE' +}); + +/** + * Perform a [indices.exists](http://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-exists.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.ignoreUnavailable - Ignore unavailable indexes (default: false) + * @param {<>} params.allowNoIndices - Ignore if a wildcard expression resolves to no concrete indices (default: false) + * @param {<>} [params.expandWildcards=open] - Whether wildcard expressions should get expanded to open or closed indices (default: open) + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.includeDefaults - Whether to return all default setting for each of the indices. + * @param {<>, <>, <>} params.index - A comma-separated list of index names + */ +api.indices.prototype.exists = ca({ + params: { + local: { + type: 'boolean' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, + includeDefaults: { + type: 'boolean', + 'default': false, + name: 'include_defaults' + } + }, + url: { + fmt: '/<%=index%>', + req: { + index: { + type: 'list' + } + } + }, + method: 'HEAD' +}); + +/** + * Perform a [indices.existsAlias](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=all] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>, <>, <>} params.index - A comma-separated list of index names to filter aliases + * @param {<>, <>, <>} params.name - A comma-separated list of alias names to return + */ +api.indices.prototype.existsAlias = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'all', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + local: { + type: 'boolean' + } + }, + urls: [ + { + fmt: '/<%=index%>/_alias/<%=name%>', + req: { + index: { + type: 'list' + }, + name: { + type: 'list' + } + } + }, + { + fmt: '/_alias/<%=name%>', + req: { + name: { + type: 'list' + } + } + } + ], + method: 'HEAD' +}); + +/** + * Perform a [indices.existsTemplate](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>, <>, <>} params.name - The comma separated names of the index templates + */ +api.indices.prototype.existsTemplate = ca({ + params: { + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + local: { + type: 'boolean' + } + }, + url: { + fmt: '/_template/<%=name%>', + req: { + name: { + type: 'list' + } + } + }, + method: 'HEAD' +}); + +/** + * Perform a [indices.existsType](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-types-exists.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` to check the types across all indices + * @param {<>, <>, <>} params.type - A comma-separated list of document types to check + */ +api.indices.prototype.existsType = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + local: { + type: 'boolean' + } + }, + url: { + fmt: '/<%=index%>/_mapping/<%=type%>', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + } + } + }, + method: 'HEAD' +}); + +/** + * Perform a [indices.flush](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-flush.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.force - Whether a flush should be forced even if it is not necessarily needed ie. if no changes will be committed to the index. This is useful if transaction log IDs should be incremented even if no uncommitted changes are present. (This setting can be considered as internal) + * @param {<>} params.waitIfOngoing - If set to true the flush operation will block until the flush can be executed if another flush operation is already executing. The default is true. If set to false the flush will be skipped iff if another flush operation is already running. + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string for all indices + */ +api.indices.prototype.flush = ca({ + params: { + force: { + type: 'boolean' + }, + waitIfOngoing: { + type: 'boolean', + name: 'wait_if_ongoing' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + } + }, + urls: [ + { + fmt: '/<%=index%>/_flush', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_flush' + } + ], + method: 'POST' +}); + +/** + * Perform a [indices.flushSynced](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-synced-flush.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string for all indices + */ +api.indices.prototype.flushSynced = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + } + }, + urls: [ + { + fmt: '/<%=index%>/_flush/synced', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_flush/synced' + } + ], + method: 'POST' +}); + +/** + * Perform a [indices.forcemerge](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-forcemerge.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.flush - Specify whether the index should be flushed after performing the operation (default: true) + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.maxNumSegments - The number of segments the index should be merged into (default: dynamic) + * @param {<>} params.onlyExpungeDeletes - Specify whether the operation should only expunge deleted documents + * @param {anything} params.operationThreading - TODO: ? + * @param {<>} params.waitForMerge - Specify whether the request should block until the merge process is finished (default: true) + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + */ +api.indices.prototype.forcemerge = ca({ + params: { + flush: { + type: 'boolean' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + maxNumSegments: { + type: 'number', + name: 'max_num_segments' + }, + onlyExpungeDeletes: { + type: 'boolean', + name: 'only_expunge_deletes' + }, + operationThreading: { + name: 'operation_threading' + }, + waitForMerge: { + type: 'boolean', + name: 'wait_for_merge' + } + }, + urls: [ + { + fmt: '/<%=index%>/_forcemerge', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_forcemerge' + } + ], + method: 'POST' +}); + +/** + * Perform a [indices.get](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-get-index.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.ignoreUnavailable - Ignore unavailable indexes (default: false) + * @param {<>} params.allowNoIndices - Ignore if a wildcard expression resolves to no concrete indices (default: false) + * @param {<>} [params.expandWildcards=open] - Whether wildcard expressions should get expanded to open or closed indices (default: open) + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.includeDefaults - Whether to return all default setting for each of the indices. + * @param {<>, <>, <>} params.index - A comma-separated list of index names + * @param {<>, <>, <>} params.feature - A comma-separated list of features + */ +api.indices.prototype.get = ca({ + params: { + local: { + type: 'boolean' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, + includeDefaults: { + type: 'boolean', + 'default': false, + name: 'include_defaults' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=feature%>', + req: { + index: { + type: 'list' + }, + feature: { + type: 'list', + options: [ + '_settings', + '_mappings', + '_aliases' + ] + } + } + }, + { + fmt: '/<%=index%>', + req: { + index: { + type: 'list' + } + } + } + ] +}); + +/** + * Perform a [indices.getAlias](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=all] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>, <>, <>} params.index - A comma-separated list of index names to filter aliases + * @param {<>, <>, <>} params.name - A comma-separated list of alias names to return + */ +api.indices.prototype.getAlias = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'all', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + local: { + type: 'boolean' + } + }, + urls: [ + { + fmt: '/<%=index%>/_alias/<%=name%>', + req: { + index: { + type: 'list' + }, + name: { + type: 'list' + } + } + }, + { + fmt: '/_alias/<%=name%>', + req: { + name: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_alias', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_alias' + } + ] +}); + +/** + * Perform a [indices.getFieldMapping](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-get-field-mapping.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.includeDefaults - Whether the default mapping values should be returned as well + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>, <>, <>} params.index - A comma-separated list of index names + * @param {<>, <>, <>} params.type - A comma-separated list of document types + * @param {<>, <>, <>} params.fields - A comma-separated list of fields + */ +api.indices.prototype.getFieldMapping = ca({ + params: { + includeDefaults: { + type: 'boolean', + name: 'include_defaults' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + local: { + type: 'boolean' + } + }, + urls: [ + { + fmt: '/<%=index%>/_mapping/<%=type%>/field/<%=fields%>', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + }, + fields: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_mapping/field/<%=fields%>', + req: { + index: { + type: 'list' + }, + fields: { + type: 'list' + } + } + }, + { + fmt: '/_mapping/<%=type%>/field/<%=fields%>', + req: { + type: { + type: 'list' + }, + fields: { + type: 'list' + } + } + }, + { + fmt: '/_mapping/field/<%=fields%>', + req: { + fields: { + type: 'list' + } + } + } + ] +}); + +/** + * Perform a [indices.getMapping](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-get-mapping.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>, <>, <>} params.index - A comma-separated list of index names + * @param {<>, <>, <>} params.type - A comma-separated list of document types + */ +api.indices.prototype.getMapping = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + local: { + type: 'boolean' + } + }, + urls: [ + { + fmt: '/<%=index%>/_mapping/<%=type%>', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_mapping', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_mapping/<%=type%>', + req: { + type: { + type: 'list' + } + } + }, + { + fmt: '/_mapping' + } + ] +}); + +/** + * Perform a [indices.getSettings](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-get-settings.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open,closed] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.includeDefaults - Whether to return all default setting for each of the indices. + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @param {<>, <>, <>} params.name - The name of the settings that should be included + */ +api.indices.prototype.getSettings = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': [ + 'open', + 'closed' + ], + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, + local: { + type: 'boolean' + }, + includeDefaults: { + type: 'boolean', + 'default': false, + name: 'include_defaults' + } + }, + urls: [ + { + fmt: '/<%=index%>/_settings/<%=name%>', + req: { + index: { + type: 'list' + }, + name: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_settings', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_settings/<%=name%>', + req: { + name: { + type: 'list' + } + } + }, + { + fmt: '/_settings' + } + ] +}); + +/** + * Perform a [indices.getTemplate](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>, <>, <>} params.name - The comma separated names of the index templates + */ +api.indices.prototype.getTemplate = ca({ + params: { + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + local: { + type: 'boolean' + } + }, + urls: [ + { + fmt: '/_template/<%=name%>', + req: { + name: { + type: 'list' + } + } + }, + { + fmt: '/_template' + } + ] +}); + +/** + * Perform a [indices.getUpgrade](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-upgrade.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + */ +api.indices.prototype.getUpgrade = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + } + }, + urls: [ + { + fmt: '/<%=index%>/_upgrade', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_upgrade' + } + ] +}); + +/** + * Perform a [indices.open](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-open-close.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=closed] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>, <>, <>} params.index - A comma separated list of indices to open + */ +api.indices.prototype.open = ca({ + params: { + timeout: { + type: 'time' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'closed', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + } + }, + url: { + fmt: '/<%=index%>/_open', + req: { + index: { + type: 'list' + } + } + }, + method: 'POST' +}); + +/** + * Perform a [indices.putAlias](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.timeout - Explicit timestamp for the document + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>, <>, <>} params.index - A comma-separated list of index names the alias should point to (supports wildcards); use `_all` to perform the operation on all indices. + * @param {<>} params.name - The name of the alias to be created or updated + */ +api.indices.prototype.putAlias = ca({ + params: { + timeout: { + type: 'time' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + } + }, + url: { + fmt: '/<%=index%>/_alias/<%=name%>', + req: { + index: { + type: 'list' + }, + name: { + type: 'string' + } + } + }, + method: 'PUT' +}); + +/** + * Perform a [indices.putMapping](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-put-mapping.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.updateAllTypes - Whether to update the mapping for all fields with the same name across all types or not + * @param {<>, <>, <>} params.index - A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. + * @param {<>} params.type - The name of the document type + */ +api.indices.prototype.putMapping = ca({ + params: { + timeout: { + type: 'time' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + updateAllTypes: { + type: 'boolean', + name: 'update_all_types' + } + }, + urls: [ + { + fmt: '/<%=index%>/_mapping/<%=type%>', + req: { + index: { + type: 'list' + }, + type: { + type: 'string' + } + } + }, + { + fmt: '/_mapping/<%=type%>', + req: { + type: { + type: 'string' + } + } + } + ], + needBody: true, + method: 'PUT' +}); + +/** + * Perform a [indices.putSettings](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-update-settings.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>} params.preserveExisting - Whether to update existing settings. If set to `true` existing settings on an index remain unchanged, the default is `false` + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + */ +api.indices.prototype.putSettings = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + preserveExisting: { + type: 'boolean', + name: 'preserve_existing' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + flatSettings: { + type: 'boolean', + name: 'flat_settings' + } + }, + urls: [ + { + fmt: '/<%=index%>/_settings', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_settings' + } + ], + needBody: true, + method: 'PUT' +}); + +/** + * Perform a [indices.putTemplate](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.order - The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers) + * @param {<>} params.create - Whether the index template should only be added if new or can also replace an existing one + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.name - The name of the template + */ +api.indices.prototype.putTemplate = ca({ + params: { + order: { + type: 'number' + }, + create: { + type: 'boolean', + 'default': false + }, + timeout: { + type: 'time' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + flatSettings: { + type: 'boolean', + name: 'flat_settings' + } + }, + url: { + fmt: '/_template/<%=name%>', + req: { + name: { + type: 'string' + } + } + }, + needBody: true, + method: 'PUT' +}); + +/** + * Perform a [indices.recovery](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-recovery.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.detailed - Whether to display detailed information about shard recovery + * @param {<>} params.activeOnly - Display only those recoveries that are currently on-going + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + */ +api.indices.prototype.recovery = ca({ + params: { + detailed: { + type: 'boolean', + 'default': false + }, + activeOnly: { + type: 'boolean', + 'default': false, + name: 'active_only' + } + }, + urls: [ + { + fmt: '/<%=index%>/_recovery', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_recovery' + } + ] +}); + +/** + * Perform a [indices.refresh](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-refresh.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.force - Force a refresh even if not required + * @param {anything} params.operationThreading - TODO: ? + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + */ +api.indices.prototype.refresh = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + force: { + type: 'boolean', + 'default': false + }, + operationThreading: { + name: 'operation_threading' + } + }, + urls: [ + { + fmt: '/<%=index%>/_refresh', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_refresh' + } + ], + method: 'POST' +}); + +/** + * Perform a [indices.rollover](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-rollover-index.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.dryRun - If set to true the rollover action will only be validated but not actually performed even if a condition matches. The default is false + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>} params.waitForActiveShards - Set the number of active shards to wait for on the newly created rollover index before the operation returns. + * @param {<>} params.alias - The name of the alias to rollover + * @param {<>} params.newIndex - The name of the rollover index + */ +api.indices.prototype.rollover = ca({ + params: { + timeout: { + type: 'time' + }, + dryRun: { + type: 'boolean', + name: 'dry_run' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + } + }, + urls: [ + { + fmt: '/<%=alias%>/_rollover/<%=newIndex%>', + req: { + alias: { + type: 'string' + }, + newIndex: { + type: 'string' + } + } + }, + { + fmt: '/<%=alias%>/_rollover', + req: { + alias: { + type: 'string' + } + } + } + ], + method: 'POST' +}); + +/** + * Perform a [indices.segments](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-segments.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {anything} params.operationThreading - TODO: ? + * @param {<>} params.verbose - Includes detailed memory usage by Lucene. + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + */ +api.indices.prototype.segments = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + operationThreading: { + name: 'operation_threading' + }, + verbose: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/<%=index%>/_segments', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_segments' + } + ] +}); + +/** + * Perform a [indices.shardStores](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-shards-stores.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.status - A comma-separated list of statuses used to filter on shards to get store information for + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {anything} params.operationThreading - TODO: ? + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + */ +api.indices.prototype.shardStores = ca({ + params: { + status: { + type: 'list', + options: [ + 'green', + 'yellow', + 'red', + 'all' + ] + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + operationThreading: { + name: 'operation_threading' + } + }, + urls: [ + { + fmt: '/<%=index%>/_shard_stores', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_shard_stores' + } + ] +}); + +/** + * Perform a [indices.shrink](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-shrink-index.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>} params.waitForActiveShards - Set the number of active shards to wait for on the shrunken index before the operation returns. + * @param {<>} params.index - The name of the source index to shrink + * @param {<>} params.target - The name of the target index to shrink into + */ +api.indices.prototype.shrink = ca({ + params: { + timeout: { + type: 'time' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + } + }, + url: { + fmt: '/<%=index%>/_shrink/<%=target%>', + req: { + index: { + type: 'string' + }, + target: { + type: 'string' + } + } + }, + method: 'POST' +}); + +/** + * Perform a [indices.stats](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-stats.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.completionFields - A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards) + * @param {<>, <>, <>} params.fielddataFields - A comma-separated list of fields for `fielddata` index metric (supports wildcards) + * @param {<>, <>, <>} params.fields - A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) + * @param {<>, <>, <>} params.groups - A comma-separated list of search groups for `search` index metric + * @param {<>} [params.level=indices] - Return stats aggregated at cluster, index or shard level + * @param {<>, <>, <>} params.types - A comma-separated list of document types for the `indexing` index metric + * @param {<>} params.includeSegmentFileSizes - Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @param {<>, <>, <>} params.metric - Limit the information returned the specific metrics. + */ +api.indices.prototype.stats = ca({ + params: { + completionFields: { + type: 'list', + name: 'completion_fields' + }, + fielddataFields: { + type: 'list', + name: 'fielddata_fields' + }, + fields: { + type: 'list' + }, + groups: { + type: 'list' + }, + level: { + type: 'enum', + 'default': 'indices', + options: [ + 'cluster', + 'indices', + 'shards' + ] + }, + types: { + type: 'list' + }, + includeSegmentFileSizes: { + type: 'boolean', + 'default': false, + name: 'include_segment_file_sizes' + } + }, + urls: [ + { + fmt: '/<%=index%>/_stats/<%=metric%>', + req: { + index: { + type: 'list' + }, + metric: { + type: 'list', + options: [ + '_all', + 'completion', + 'docs', + 'fielddata', + 'query_cache', + 'flush', + 'get', + 'indexing', + 'merge', + 'percolate', + 'request_cache', + 'refresh', + 'search', + 'segments', + 'store', + 'warmer', + 'suggest' + ] + } + } + }, + { + fmt: '/_stats/<%=metric%>', + req: { + metric: { + type: 'list', + options: [ + '_all', + 'completion', + 'docs', + 'fielddata', + 'query_cache', + 'flush', + 'get', + 'indexing', + 'merge', + 'percolate', + 'request_cache', + 'refresh', + 'search', + 'segments', + 'store', + 'warmer', + 'suggest' + ] + } + } + }, + { + fmt: '/<%=index%>/_stats', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_stats' + } + ] +}); + +/** + * Perform a [indices.updateAliases](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.timeout - Request timeout + * @param {<>} params.masterTimeout - Specify timeout for connection to master + */ +api.indices.prototype.updateAliases = ca({ + params: { + timeout: { + type: 'time' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + } + }, + url: { + fmt: '/_aliases' + }, + needBody: true, + method: 'POST' +}); + +/** + * Perform a [indices.upgrade](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-upgrade.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.waitForCompletion - Specify whether the request should block until the all segments are upgraded (default: false) + * @param {<>} params.onlyAncientSegments - If true, only ancient (an older Lucene major release) segments will be upgraded + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + */ +api.indices.prototype.upgrade = ca({ + params: { + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + waitForCompletion: { + type: 'boolean', + name: 'wait_for_completion' + }, + onlyAncientSegments: { + type: 'boolean', + name: 'only_ancient_segments' + } + }, + urls: [ + { + fmt: '/<%=index%>/_upgrade', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_upgrade' + } + ], + method: 'POST' +}); + +/** + * Perform a [indices.validateQuery](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-validate.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.explain - Return detailed information about the error + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {anything} params.operationThreading - TODO: ? + * @param {<>} params.q - Query in the Lucene query string syntax + * @param {<>} params.analyzer - The analyzer to use for the query string + * @param {<>} params.analyzeWildcard - Specify whether wildcard and prefix queries should be analyzed (default: false) + * @param {<>} [params.defaultOperator=OR] - The default operator for query string query (AND or OR) + * @param {<>} params.df - The field to use as default where no field prefix is given in the query string + * @param {<>} params.lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * @param {<>} params.rewrite - Provide a more detailed explanation showing the actual Lucene query that will be executed. + * @param {<>} params.allShards - Execute validation on all shards instead of one random shard per index + * @param {<>, <>, <>} params.index - A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices + * @param {<>, <>, <>} params.type - A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types + */ +api.indices.prototype.validateQuery = ca({ + params: { + explain: { + type: 'boolean' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + operationThreading: { + name: 'operation_threading' + }, + q: { + type: 'string' + }, + analyzer: { + type: 'string' + }, + analyzeWildcard: { + type: 'boolean', + name: 'analyze_wildcard' + }, + defaultOperator: { + type: 'enum', + 'default': 'OR', + options: [ + 'AND', + 'OR' + ], + name: 'default_operator' + }, + df: { + type: 'string' + }, + lenient: { + type: 'boolean' + }, + rewrite: { + type: 'boolean' + }, + allShards: { + type: 'boolean', + name: 'all_shards' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_validate/query', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_validate/query', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_validate/query' + } + ], + method: 'POST' +}); + +/** + * Perform a [info](https://www.elastic.co/guide/) request + * + * @param {Object} params - An object with parameters used to carry out this action + */ +api.info = ca({ + url: { + fmt: '/' + } +}); + +api.ingest = namespace(); + +/** + * Perform a [ingest.deletePipeline](https://www.elastic.co/guide/en/elasticsearch/plugins/5.x/ingest.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.id - Pipeline ID + */ +api.ingest.prototype.deletePipeline = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + timeout: { + type: 'time' + } + }, + url: { + fmt: '/_ingest/pipeline/<%=id%>', + req: { + id: { + type: 'string' + } + } + }, + method: 'DELETE' +}); + +/** + * Perform a [ingest.getPipeline](https://www.elastic.co/guide/en/elasticsearch/plugins/5.x/ingest.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.id - Comma separated list of pipeline ids. Wildcards supported + */ +api.ingest.prototype.getPipeline = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + } + }, + urls: [ + { + fmt: '/_ingest/pipeline/<%=id%>', + req: { + id: { + type: 'string' + } + } + }, + { + fmt: '/_ingest/pipeline' + } + ] +}); + +/** + * Perform a [ingest.putPipeline](https://www.elastic.co/guide/en/elasticsearch/plugins/5.x/ingest.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.id - Pipeline ID + */ +api.ingest.prototype.putPipeline = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + timeout: { + type: 'time' + } + }, + url: { + fmt: '/_ingest/pipeline/<%=id%>', + req: { + id: { + type: 'string' + } + } + }, + needBody: true, + method: 'PUT' +}); + +/** + * Perform a [ingest.simulate](https://www.elastic.co/guide/en/elasticsearch/plugins/5.x/ingest.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.verbose - Verbose mode. Display data output for each processor in executed pipeline + * @param {<>} params.id - Pipeline ID + */ +api.ingest.prototype.simulate = ca({ + params: { + verbose: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/_ingest/pipeline/<%=id%>/_simulate', + req: { + id: { + type: 'string' + } + } + }, + { + fmt: '/_ingest/pipeline/_simulate' + } + ], + needBody: true, + method: 'POST' +}); + +/** + * Perform a [mget](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-multi-get.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.storedFields - A comma-separated list of stored fields to return in the response + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.realtime - Specify whether to perform the operation in realtime or search mode + * @param {<>} params.refresh - Refresh the shard containing the document before performing the operation + * @param {<>} params.routing - Specific routing value + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.index - The name of the index + * @param {<>} params.type - The type of the document + */ +api.mget = ca({ + params: { + storedFields: { + type: 'list', + name: 'stored_fields' + }, + preference: { + type: 'string' + }, + realtime: { + type: 'boolean' + }, + refresh: { + type: 'boolean' + }, + routing: { + type: 'string' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_mget', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + } + } + }, + { + fmt: '/<%=index%>/_mget', + req: { + index: { + type: 'string' + } + } + }, + { + fmt: '/_mget' + } + ], + needBody: true, + method: 'POST' +}); + +/** + * Perform a [mpercolate](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-percolate.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.index - The index of the document being count percolated to use as default + * @param {<>} params.type - The type of the document being percolated to use as default. + */ +api.mpercolate = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_mpercolate', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + } + } + }, + { + fmt: '/<%=index%>/_mpercolate', + req: { + index: { + type: 'string' + } + } + }, + { + fmt: '/_mpercolate' + } + ], + needBody: true, + bulkBody: true, + method: 'POST' +}); + +/** + * Perform a [msearch](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-multi-search.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.searchType - Search operation type + * @param {<>} params.maxConcurrentSearches - Controls the maximum number of concurrent searches the multi search api will execute + * @param {<>} params.typedKeys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * @param {<>, <>, <>} params.index - A comma-separated list of index names to use as default + * @param {<>, <>, <>} params.type - A comma-separated list of document types to use as default + */ +api.msearch = ca({ + params: { + searchType: { + type: 'enum', + options: [ + 'query_then_fetch', + 'query_and_fetch', + 'dfs_query_then_fetch', + 'dfs_query_and_fetch' + ], + name: 'search_type' + }, + maxConcurrentSearches: { + type: 'number', + name: 'max_concurrent_searches' + }, + typedKeys: { + type: 'boolean', + name: 'typed_keys' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_msearch', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_msearch', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_msearch' + } + ], + needBody: true, + bulkBody: true, + method: 'POST' +}); + +/** + * Perform a [msearchTemplate](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.searchType - Search operation type + * @param {<>} params.typedKeys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * @param {<>, <>, <>} params.index - A comma-separated list of index names to use as default + * @param {<>, <>, <>} params.type - A comma-separated list of document types to use as default + */ +api.msearchTemplate = ca({ + params: { + searchType: { + type: 'enum', + options: [ + 'query_then_fetch', + 'query_and_fetch', + 'dfs_query_then_fetch', + 'dfs_query_and_fetch' + ], + name: 'search_type' + }, + typedKeys: { + type: 'boolean', + name: 'typed_keys' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_msearch/template', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_msearch/template', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_msearch/template' + } + ], + needBody: true, + bulkBody: true, + method: 'POST' +}); + +/** + * Perform a [mtermvectors](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-multi-termvectors.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.ids - A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body + * @param {<>} params.termStatistics - Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {<>} [params.fieldStatistics=true] - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {<>, <>, <>} params.fields - A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {<>} [params.offsets=true] - Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {<>} [params.positions=true] - Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {<>} [params.payloads=true] - Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {<>} params.routing - Specific routing value. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {<>} params.parent - Parent id of documents. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {<>} params.realtime - Specifies if requests are real-time as opposed to near-real-time (default: true). + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.index - The index in which the document resides. + * @param {<>} params.type - The type of the document. + */ +api.mtermvectors = ca({ + params: { + ids: { + type: 'list', + required: false + }, + termStatistics: { + type: 'boolean', + 'default': false, + required: false, + name: 'term_statistics' + }, + fieldStatistics: { + type: 'boolean', + 'default': true, + required: false, + name: 'field_statistics' + }, + fields: { + type: 'list', + required: false + }, + offsets: { + type: 'boolean', + 'default': true, + required: false + }, + positions: { + type: 'boolean', + 'default': true, + required: false + }, + payloads: { + type: 'boolean', + 'default': true, + required: false + }, + preference: { + type: 'string', + required: false + }, + routing: { + type: 'string', + required: false + }, + parent: { + type: 'string', + required: false + }, + realtime: { + type: 'boolean', + required: false + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_mtermvectors', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + } + } + }, + { + fmt: '/<%=index%>/_mtermvectors', + req: { + index: { + type: 'string' + } + } + }, + { + fmt: '/_mtermvectors' + } + ], + method: 'POST' +}); + +api.nodes = namespace(); + +/** + * Perform a [nodes.hotThreads](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-nodes-hot-threads.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.interval - The interval for the second sampling of threads + * @param {<>} params.snapshots - Number of samples of thread stacktrace (default: 10) + * @param {<>} params.threads - Specify the number of threads to provide information for (default: 3) + * @param {<>} params.ignoreIdleThreads - Don't show threads that are in known-idle places, such as waiting on a socket select or pulling from an empty task queue (default: true) + * @param {<>} params.type - The type to sample (default: cpu) + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>, <>, <>} params.nodeId - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + */ +api.nodes.prototype.hotThreads = ca({ + params: { + interval: { + type: 'time' + }, + snapshots: { + type: 'number' + }, + threads: { + type: 'number' + }, + ignoreIdleThreads: { + type: 'boolean', + name: 'ignore_idle_threads' + }, + type: { + type: 'enum', + options: [ + 'cpu', + 'wait', + 'block' + ] + }, + timeout: { + type: 'time' + } + }, + urls: [ + { + fmt: '/_nodes/<%=nodeId%>/hotthreads', + req: { + nodeId: { + type: 'list' + } + } + }, + { + fmt: '/_nodes/hotthreads' + } + ] +}); + +/** + * Perform a [nodes.info](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-nodes-info.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>, <>, <>} params.nodeId - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * @param {<>, <>, <>} params.metric - A comma-separated list of metrics you wish returned. Leave empty to return all. + */ +api.nodes.prototype.info = ca({ + params: { + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, + timeout: { + type: 'time' + } + }, + urls: [ + { + fmt: '/_nodes/<%=nodeId%>/<%=metric%>', + req: { + nodeId: { + type: 'list' + }, + metric: { + type: 'list', + options: [ + 'settings', + 'os', + 'process', + 'jvm', + 'thread_pool', + 'transport', + 'http', + 'plugins', + 'ingest' + ] + } + } + }, + { + fmt: '/_nodes/<%=nodeId%>', + req: { + nodeId: { + type: 'list' + } + } + }, + { + fmt: '/_nodes/<%=metric%>', + req: { + metric: { + type: 'list', + options: [ + 'settings', + 'os', + 'process', + 'jvm', + 'thread_pool', + 'transport', + 'http', + 'plugins', + 'ingest' + ] + } + } + }, + { + fmt: '/_nodes' + } + ] +}); + +/** + * Perform a [nodes.stats](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-nodes-stats.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.completionFields - A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards) + * @param {<>, <>, <>} params.fielddataFields - A comma-separated list of fields for `fielddata` index metric (supports wildcards) + * @param {<>, <>, <>} params.fields - A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) + * @param {<>} params.groups - A comma-separated list of search groups for `search` index metric + * @param {<>} [params.level=node] - Return indices stats aggregated at index, node or shard level + * @param {<>, <>, <>} params.types - A comma-separated list of document types for the `indexing` index metric + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.includeSegmentFileSizes - Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) + * @param {<>, <>, <>} params.metric - Limit the information returned to the specified metrics + * @param {<>, <>, <>} params.indexMetric - Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified. + * @param {<>, <>, <>} params.nodeId - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + */ +api.nodes.prototype.stats = ca({ + params: { + completionFields: { + type: 'list', + name: 'completion_fields' + }, + fielddataFields: { + type: 'list', + name: 'fielddata_fields' + }, + fields: { + type: 'list' + }, + groups: { + type: 'boolean' + }, + level: { + type: 'enum', + 'default': 'node', + options: [ + 'indices', + 'node', + 'shards' + ] + }, + types: { + type: 'list' + }, + timeout: { + type: 'time' + }, + includeSegmentFileSizes: { + type: 'boolean', + 'default': false, + name: 'include_segment_file_sizes' + } + }, + urls: [ + { + fmt: '/_nodes/<%=nodeId%>/stats/<%=metric%>/<%=indexMetric%>', + req: { + nodeId: { + type: 'list' + }, + metric: { + type: 'list', + options: [ + '_all', + 'breaker', + 'fs', + 'http', + 'indices', + 'jvm', + 'os', + 'process', + 'thread_pool', + 'transport', + 'discovery' + ] + }, + indexMetric: { + type: 'list', + options: [ + '_all', + 'completion', + 'docs', + 'fielddata', + 'query_cache', + 'flush', + 'get', + 'indexing', + 'merge', + 'percolate', + 'request_cache', + 'refresh', + 'search', + 'segments', + 'store', + 'warmer', + 'suggest' + ] + } + } + }, + { + fmt: '/_nodes/<%=nodeId%>/stats/<%=metric%>', + req: { + nodeId: { + type: 'list' + }, + metric: { + type: 'list', + options: [ + '_all', + 'breaker', + 'fs', + 'http', + 'indices', + 'jvm', + 'os', + 'process', + 'thread_pool', + 'transport', + 'discovery' + ] + } + } + }, + { + fmt: '/_nodes/stats/<%=metric%>/<%=indexMetric%>', + req: { + metric: { + type: 'list', + options: [ + '_all', + 'breaker', + 'fs', + 'http', + 'indices', + 'jvm', + 'os', + 'process', + 'thread_pool', + 'transport', + 'discovery' + ] + }, + indexMetric: { + type: 'list', + options: [ + '_all', + 'completion', + 'docs', + 'fielddata', + 'query_cache', + 'flush', + 'get', + 'indexing', + 'merge', + 'percolate', + 'request_cache', + 'refresh', + 'search', + 'segments', + 'store', + 'warmer', + 'suggest' + ] + } + } + }, + { + fmt: '/_nodes/<%=nodeId%>/stats', + req: { + nodeId: { + type: 'list' + } + } + }, + { + fmt: '/_nodes/stats/<%=metric%>', + req: { + metric: { + type: 'list', + options: [ + '_all', + 'breaker', + 'fs', + 'http', + 'indices', + 'jvm', + 'os', + 'process', + 'thread_pool', + 'transport', + 'discovery' + ] + } + } + }, + { + fmt: '/_nodes/stats' + } + ] +}); + +/** + * Perform a [percolate](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-percolate.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.routing - A comma-separated list of specific routing values + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.percolateIndex - The index to percolate the document into. Defaults to index. + * @param {<>} params.percolateType - The type to percolate document into. Defaults to type. + * @param {<>} params.percolateRouting - The routing value to use when percolating the existing document. + * @param {<>} params.percolatePreference - Which shard to prefer when executing the percolate request. + * @param {<>} params.percolateFormat - Return an array of matching query IDs instead of objects + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.index - The index of the document being percolated. + * @param {<>} params.type - The type of the document being percolated. + * @param {<>} params.id - Substitute the document in the request body with a document that is known by the specified id. On top of the id, the index and type parameter will be used to retrieve the document from within the cluster. + */ +api.percolate = ca({ + params: { + routing: { + type: 'list' + }, + preference: { + type: 'string' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + percolateIndex: { + type: 'string', + name: 'percolate_index' + }, + percolateType: { + type: 'string', + name: 'percolate_type' + }, + percolateRouting: { + type: 'string', + name: 'percolate_routing' + }, + percolatePreference: { + type: 'string', + name: 'percolate_preference' + }, + percolateFormat: { + type: 'enum', + options: [ + 'ids' + ], + name: 'percolate_format' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/<%=id%>/_percolate', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + { + fmt: '/<%=index%>/<%=type%>/_percolate', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + } + } + } + ], + method: 'POST' +}); + +/** + * Perform a [ping](https://www.elastic.co/guide/) request + * + * @param {Object} params - An object with parameters used to carry out this action + */ +api.ping = ca({ + url: { + fmt: '/' + }, + requestTimeout: 3000, + method: 'HEAD' +}); + +/** + * Perform a [putScript](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-scripting.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.id - Script ID + * @param {<>} params.lang - Script language + */ +api.putScript = ca({ + urls: [ + { + fmt: '/_scripts/<%=lang%>/<%=id%>', + req: { + lang: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + { + fmt: '/_scripts/<%=lang%>', + req: { + lang: { + type: 'string' + } + } + } + ], + needBody: true, + method: 'PUT' +}); + +/** + * Perform a [putTemplate](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-template.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.id - Template ID + */ +api.putTemplate = ca({ + url: { + fmt: '/_search/template/<%=id%>', + req: { + id: { + type: 'string' + } + } + }, + needBody: true, + method: 'PUT' +}); + +/** + * Perform a [reindex](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-reindex.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.refresh - Should the effected indexes be refreshed? + * @param {<>} [params.timeout=1m] - Time each individual bulk request should wait for shards that are unavailable. + * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {<>} [params.waitForCompletion=true] - Should the request should block until the reindex is complete. + * @param {<>} params.requestsPerSecond - The throttle to set on this request in sub-requests per second. -1 means no throttle. + * @param {<>} [params.slices=1] - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. + */ +api.reindex = ca({ + params: { + refresh: { + type: 'boolean' + }, + timeout: { + type: 'time', + 'default': '1m' + }, + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + }, + waitForCompletion: { + type: 'boolean', + 'default': true, + name: 'wait_for_completion' + }, + requestsPerSecond: { + type: 'number', + 'default': 0, + name: 'requests_per_second' + }, + slices: { + type: 'number', + 'default': 1 + } + }, + url: { + fmt: '/_reindex' + }, + needBody: true, + method: 'POST' +}); + +/** + * Perform a [reindexRethrottle](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-reindex.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.requestsPerSecond - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. + * @param {<>} params.taskId - The task id to rethrottle + */ +api.reindexRethrottle = ca({ + params: { + requestsPerSecond: { + type: 'number', + required: true, + name: 'requests_per_second' + } + }, + url: { + fmt: '/_reindex/<%=taskId%>/_rethrottle', + req: { + taskId: { + type: 'string' + } + } + }, + method: 'POST' +}); + +api.remote = namespace(); + +/** + * Perform a [remote.info](http://www.elastic.co/guide/en/elasticsearch/reference/master/remote-info.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + */ +api.remote.prototype.info = ca({ + url: { + fmt: '/_remote/info' + } +}); + +/** + * Perform a [renderSearchTemplate](http://www.elasticsearch.org/guide/en/elasticsearch/reference/5.x/search-template.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.id - The id of the stored search template + */ +api.renderSearchTemplate = ca({ + urls: [ + { + fmt: '/_render/template/<%=id%>', + req: { + id: { + type: 'string' + } + } + }, + { + fmt: '/_render/template' + } + ], + method: 'POST' +}); + +/** + * Perform a [scroll](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-request-scroll.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.scroll - Specify how long a consistent view of the index should be maintained for scrolled search + * @param {<>} params.scrollId - The scroll ID + */ +api.scroll = ca({ + params: { + scroll: { + type: 'time' + }, + scrollId: { + type: 'string', + name: 'scroll_id' + } + }, + urls: [ + { + fmt: '/_search/scroll/<%=scrollId%>', + req: { + scrollId: { + type: 'string' + } + } + }, + { + fmt: '/_search/scroll' + } + ], + paramAsBody: { + param: 'scrollId', + body: 'scroll_id' + }, + method: 'POST' +}); + +/** + * Perform a [search](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-search.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.analyzer - The analyzer to use for the query string + * @param {<>} params.analyzeWildcard - Specify whether wildcard and prefix queries should be analyzed (default: false) + * @param {<>} [params.defaultOperator=OR] - The default operator for query string query (AND or OR) + * @param {<>} params.df - The field to use as default where no field prefix is given in the query string + * @param {<>} params.explain - Specify whether to return detailed information about score computation as part of a hit + * @param {<>, <>, <>} params.storedFields - A comma-separated list of stored fields to return as part of a hit + * @param {<>, <>, <>} params.docvalueFields - A comma-separated list of fields to return as the docvalue representation of a field for each hit + * @param {<>, <>, <>} params.fielddataFields - A comma-separated list of fields to return as the docvalue representation of a field for each hit + * @param {<>} params.from - Starting offset (default: 0) + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.q - Query in the Lucene query string syntax + * @param {<>, <>, <>} params.routing - A comma-separated list of specific routing values + * @param {<>} params.scroll - Specify how long a consistent view of the index should be maintained for scrolled search + * @param {<>} params.searchType - Search operation type + * @param {<>} params.size - Number of hits to return (default: 10) + * @param {<>, <>, <>} params.sort - A comma-separated list of : pairs + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.terminateAfter - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. + * @param {<>, <>, <>} params.stats - Specific 'tag' of the request for logging and statistical purposes + * @param {<>} params.suggestField - Specify which field to use for suggestions + * @param {<>} [params.suggestMode=missing] - Specify suggest mode + * @param {<>} params.suggestSize - How many suggestions to return in response + * @param {<>} params.suggestText - The source text for which the suggestions should be returned + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.trackScores - Whether to calculate and return scores even if they are not used for sorting + * @param {<>} params.typedKeys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * @param {<>} params.version - Specify whether to return document version as part of a hit + * @param {<>} params.requestCache - Specify if request cache should be used for this request or not, defaults to index level setting + * @param {<>} [params.batchedReduceSize=512] - The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. + * @param {<>, <>, <>} params.index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * @param {<>, <>, <>} params.type - A comma-separated list of document types to search; leave empty to perform the operation on all types + */ +api.search = ca({ + params: { + analyzer: { + type: 'string' + }, + analyzeWildcard: { + type: 'boolean', + name: 'analyze_wildcard' + }, + defaultOperator: { + type: 'enum', + 'default': 'OR', + options: [ + 'AND', + 'OR' + ], + name: 'default_operator' + }, + df: { + type: 'string' + }, + explain: { + type: 'boolean' + }, + storedFields: { + type: 'list', + name: 'stored_fields' + }, + docvalueFields: { + type: 'list', + name: 'docvalue_fields' + }, + fielddataFields: { + type: 'list', + name: 'fielddata_fields' + }, + from: { + type: 'number' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + lenient: { + type: 'boolean' + }, + preference: { + type: 'string' + }, + q: { + type: 'string' + }, + routing: { + type: 'list' + }, + scroll: { + type: 'time' + }, + searchType: { + type: 'enum', + options: [ + 'query_then_fetch', + 'dfs_query_then_fetch' + ], + name: 'search_type' + }, + size: { + type: 'number' + }, + sort: { + type: 'list' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + }, + terminateAfter: { + type: 'number', + name: 'terminate_after' + }, + stats: { + type: 'list' + }, + suggestField: { + type: 'string', + name: 'suggest_field' + }, + suggestMode: { + type: 'enum', + 'default': 'missing', + options: [ + 'missing', + 'popular', + 'always' + ], + name: 'suggest_mode' + }, + suggestSize: { + type: 'number', + name: 'suggest_size' + }, + suggestText: { + type: 'string', + name: 'suggest_text' + }, + timeout: { + type: 'time' + }, + trackScores: { + type: 'boolean', + name: 'track_scores' + }, + typedKeys: { + type: 'boolean', + name: 'typed_keys' + }, + version: { + type: 'boolean' + }, + requestCache: { + type: 'boolean', + name: 'request_cache' + }, + batchedReduceSize: { + type: 'number', + 'default': 512, + name: 'batched_reduce_size' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_search', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_search', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_search' + } + ], + method: 'POST' +}); + +/** + * Perform a [searchShards](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-shards.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.routing - Specific routing value + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>, <>, <>} params.index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * @param {<>, <>, <>} params.type - A comma-separated list of document types to search; leave empty to perform the operation on all types + */ +api.searchShards = ca({ + params: { + preference: { + type: 'string' + }, + routing: { + type: 'string' + }, + local: { + type: 'boolean' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_search_shards', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_search_shards', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_search_shards' + } + ], + method: 'POST' +}); + +/** + * Perform a [searchTemplate](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>, <>, <>} params.routing - A comma-separated list of specific routing values + * @param {<>} params.scroll - Specify how long a consistent view of the index should be maintained for scrolled search + * @param {<>} params.searchType - Search operation type + * @param {<>} params.explain - Specify whether to return detailed information about score computation as part of a hit + * @param {<>} params.profile - Specify whether to profile the query execution + * @param {<>} params.typedKeys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * @param {<>, <>, <>} params.index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * @param {<>, <>, <>} params.type - A comma-separated list of document types to search; leave empty to perform the operation on all types + */ +api.searchTemplate = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + preference: { + type: 'string' + }, + routing: { + type: 'list' + }, + scroll: { + type: 'time' + }, + searchType: { + type: 'enum', + options: [ + 'query_then_fetch', + 'query_and_fetch', + 'dfs_query_then_fetch', + 'dfs_query_and_fetch' + ], + name: 'search_type' + }, + explain: { + type: 'boolean' + }, + profile: { + type: 'boolean' + }, + typedKeys: { + type: 'boolean', + name: 'typed_keys' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_search/template', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_search/template', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_search/template' + } + ], + method: 'POST' +}); + +api.snapshot = namespace(); + +/** + * Perform a [snapshot.create](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.waitForCompletion - Should this request wait until the operation has completed before returning + * @param {<>} params.repository - A repository name + * @param {<>} params.snapshot - A snapshot name + */ +api.snapshot.prototype.create = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + waitForCompletion: { + type: 'boolean', + 'default': false, + name: 'wait_for_completion' + } + }, + url: { + fmt: '/_snapshot/<%=repository%>/<%=snapshot%>', + req: { + repository: { + type: 'string' + }, + snapshot: { + type: 'string' + } + } + }, + method: 'POST' +}); + +/** + * Perform a [snapshot.createRepository](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.verify - Whether to verify the repository after creation + * @param {<>} params.repository - A repository name + */ +api.snapshot.prototype.createRepository = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + timeout: { + type: 'time' + }, + verify: { + type: 'boolean' + } + }, + url: { + fmt: '/_snapshot/<%=repository%>', + req: { + repository: { + type: 'string' + } + } + }, + needBody: true, + method: 'POST' +}); + +/** + * Perform a [snapshot.delete](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.repository - A repository name + * @param {<>} params.snapshot - A snapshot name + */ +api.snapshot.prototype['delete'] = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + } + }, + url: { + fmt: '/_snapshot/<%=repository%>/<%=snapshot%>', + req: { + repository: { + type: 'string' + }, + snapshot: { + type: 'string' + } + } + }, + method: 'DELETE' +}); + +/** + * Perform a [snapshot.deleteRepository](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>, <>, <>} params.repository - A comma-separated list of repository names + */ +api.snapshot.prototype.deleteRepository = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + timeout: { + type: 'time' + } + }, + url: { + fmt: '/_snapshot/<%=repository%>', + req: { + repository: { + type: 'list' + } + } + }, + method: 'DELETE' +}); + +/** + * Perform a [snapshot.get](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.ignoreUnavailable - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown + * @param {<>} params.repository - A repository name + * @param {<>, <>, <>} params.snapshot - A comma-separated list of snapshot names + */ +api.snapshot.prototype.get = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + } + }, + url: { + fmt: '/_snapshot/<%=repository%>/<%=snapshot%>', + req: { + repository: { + type: 'string' + }, + snapshot: { + type: 'list' + } + } + } +}); + +/** + * Perform a [snapshot.getRepository](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>, <>, <>} params.repository - A comma-separated list of repository names + */ +api.snapshot.prototype.getRepository = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + local: { + type: 'boolean' + } + }, + urls: [ + { + fmt: '/_snapshot/<%=repository%>', + req: { + repository: { + type: 'list' + } + } + }, + { + fmt: '/_snapshot' + } + ] +}); + +/** + * Perform a [snapshot.restore](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.waitForCompletion - Should this request wait until the operation has completed before returning + * @param {<>} params.repository - A repository name + * @param {<>} params.snapshot - A snapshot name + */ +api.snapshot.prototype.restore = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + waitForCompletion: { + type: 'boolean', + 'default': false, + name: 'wait_for_completion' + } + }, + url: { + fmt: '/_snapshot/<%=repository%>/<%=snapshot%>/_restore', + req: { + repository: { + type: 'string' + }, + snapshot: { + type: 'string' + } + } + }, + method: 'POST' +}); + +/** + * Perform a [snapshot.status](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.ignoreUnavailable - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown + * @param {<>} params.repository - A repository name + * @param {<>, <>, <>} params.snapshot - A comma-separated list of snapshot names + */ +api.snapshot.prototype.status = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + } + }, + urls: [ + { + fmt: '/_snapshot/<%=repository%>/<%=snapshot%>/_status', + req: { + repository: { + type: 'string' + }, + snapshot: { + type: 'list' + } + } + }, + { + fmt: '/_snapshot/<%=repository%>/_status', + req: { + repository: { + type: 'string' + } + } + }, + { + fmt: '/_snapshot/_status' + } + ] +}); + +/** + * Perform a [snapshot.verifyRepository](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.repository - A repository name + */ +api.snapshot.prototype.verifyRepository = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + timeout: { + type: 'time' + } + }, + url: { + fmt: '/_snapshot/<%=repository%>/_verify', + req: { + repository: { + type: 'string' + } + } + }, + method: 'POST' +}); + +/** + * Perform a [suggest](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-suggesters.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.routing - Specific routing value + * @param {<>, <>, <>} params.index - A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices + */ +api.suggest = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + preference: { + type: 'string' + }, + routing: { + type: 'string' + } + }, + urls: [ + { + fmt: '/<%=index%>/_suggest', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_suggest' + } + ], + needBody: true, + method: 'POST' +}); + +api.tasks = namespace(); + +/** + * Perform a [tasks.cancel](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/tasks.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.nodeId - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * @param {<>, <>, <>} params.actions - A comma-separated list of actions that should be cancelled. Leave empty to cancel all. + * @param {<>} params.parentNode - Cancel tasks with specified parent node. + * @param {<>} params.parentTask - Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all. + * @param {<>} params.taskId - Cancel the task with specified task id (node_id:task_number) + */ +api.tasks.prototype.cancel = ca({ + params: { + nodeId: { + type: 'list', + name: 'node_id' + }, + actions: { + type: 'list' + }, + parentNode: { + type: 'string', + name: 'parent_node' + }, + parentTask: { + type: 'string', + name: 'parent_task' + } + }, + urls: [ + { + fmt: '/_tasks/<%=taskId%>/_cancel', + req: { + taskId: { + type: 'string' + } + } + }, + { + fmt: '/_tasks/_cancel' + } + ], + method: 'POST' +}); + +/** + * Perform a [tasks.get](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/tasks.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.waitForCompletion - Wait for the matching tasks to complete (default: false) + * @param {<>} params.taskId - Return the task with specified id (node_id:task_number) + */ +api.tasks.prototype.get = ca({ + params: { + waitForCompletion: { + type: 'boolean', + name: 'wait_for_completion' + } + }, + url: { + fmt: '/_tasks/<%=taskId%>', + req: { + taskId: { + type: 'string' + } + } + } +}); + +/** + * Perform a [tasks.list](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/tasks.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.nodeId - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * @param {<>, <>, <>} params.actions - A comma-separated list of actions that should be returned. Leave empty to return all. + * @param {<>} params.detailed - Return detailed task information (default: false) + * @param {<>} params.parentNode - Return tasks with specified parent node. + * @param {<>} params.parentTask - Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all. + * @param {<>} params.waitForCompletion - Wait for the matching tasks to complete (default: false) + * @param {<>} [params.groupBy=nodes] - Group tasks by nodes or parent/child relationships + */ +api.tasks.prototype.list = ca({ + params: { + nodeId: { + type: 'list', + name: 'node_id' + }, + actions: { + type: 'list' + }, + detailed: { + type: 'boolean' + }, + parentNode: { + type: 'string', + name: 'parent_node' + }, + parentTask: { + type: 'string', + name: 'parent_task' + }, + waitForCompletion: { + type: 'boolean', + name: 'wait_for_completion' + }, + groupBy: { + type: 'enum', + 'default': 'nodes', + options: [ + 'nodes', + 'parents' + ], + name: 'group_by' + } + }, + url: { + fmt: '/_tasks' + } +}); + +/** + * Perform a [termvectors](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-termvectors.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.termStatistics - Specifies if total term frequency and document frequency should be returned. + * @param {<>} [params.fieldStatistics=true] - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. + * @param {<>, <>, <>} params.fields - A comma-separated list of fields to return. + * @param {<>} [params.offsets=true] - Specifies if term offsets should be returned. + * @param {<>} [params.positions=true] - Specifies if term positions should be returned. + * @param {<>} [params.payloads=true] - Specifies if term payloads should be returned. + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random). + * @param {<>} params.routing - Specific routing value. + * @param {<>} params.parent - Parent id of documents. + * @param {<>} params.realtime - Specifies if request is real-time as opposed to near-real-time (default: true). + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.index - The index in which the document resides. + * @param {<>} params.type - The type of the document. + * @param {<>} params.id - The id of the document, when not specified a doc param should be supplied. + */ +api.termvectors = ca({ + params: { + termStatistics: { + type: 'boolean', + 'default': false, + required: false, + name: 'term_statistics' + }, + fieldStatistics: { + type: 'boolean', + 'default': true, + required: false, + name: 'field_statistics' + }, + fields: { + type: 'list', + required: false + }, + offsets: { + type: 'boolean', + 'default': true, + required: false + }, + positions: { + type: 'boolean', + 'default': true, + required: false + }, + payloads: { + type: 'boolean', + 'default': true, + required: false + }, + preference: { + type: 'string', + required: false + }, + routing: { + type: 'string', + required: false + }, + parent: { + type: 'string', + required: false + }, + realtime: { + type: 'boolean', + required: false + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/<%=id%>/_termvectors', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + { + fmt: '/<%=index%>/<%=type%>/_termvectors', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + } + } + } + ], + method: 'POST' +}); + +/** + * Perform a [update](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-update.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {<>, <>, <>} params.fields - A comma-separated list of fields to return in the response + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.lang - The script language (default: painless) + * @param {<>} params.parent - ID of the parent document. Is is only used for routing and when for the upsert request + * @param {<>} params.refresh - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + * @param {<>} params.retryOnConflict - Specify how many times should the operation be retried when a conflict occurs (default: 0) + * @param {<>} params.routing - Specific routing value + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.timestamp - Explicit timestamp for the document + * @param {<>} params.ttl - Expiration time for the document + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.id - Document ID + * @param {<>} params.index - The name of the index + * @param {<>} params.type - The type of the document + */ +api.update = ca({ + params: { + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + }, + fields: { + type: 'list' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + }, + lang: { + type: 'string' + }, + parent: { + type: 'string' + }, + refresh: { + type: 'enum', + options: [ + 'true', + 'false', + 'wait_for', + '' + ] + }, + retryOnConflict: { + type: 'number', + name: 'retry_on_conflict' + }, + routing: { + type: 'string' + }, + timeout: { + type: 'time' + }, + timestamp: { + type: 'time' + }, + ttl: { + type: 'time' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'force' + ], + name: 'version_type' + } + }, + url: { + fmt: '/<%=index%>/<%=type%>/<%=id%>/_update', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + method: 'POST' +}); + +/** + * Perform a [updateByQuery](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-update-by-query.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.analyzer - The analyzer to use for the query string + * @param {<>} params.analyzeWildcard - Specify whether wildcard and prefix queries should be analyzed (default: false) + * @param {<>} [params.defaultOperator=OR] - The default operator for query string query (AND or OR) + * @param {<>} params.df - The field to use as default where no field prefix is given in the query string + * @param {<>} params.from - Starting offset (default: 0) + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.conflicts=abort] - What to do when the update by query hits version conflicts? + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * @param {<>} params.pipeline - Ingest pipeline to set on index requests made by this action. (default: none) + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.q - Query in the Lucene query string syntax + * @param {<>, <>, <>} params.routing - A comma-separated list of specific routing values + * @param {<>} params.scroll - Specify how long a consistent view of the index should be maintained for scrolled search + * @param {<>} params.searchType - Search operation type + * @param {<>} params.searchTimeout - Explicit timeout for each search request. Defaults to no timeout. + * @param {<>} params.size - Number of hits to return (default: 10) + * @param {<>, <>, <>} params.sort - A comma-separated list of : pairs + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.terminateAfter - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. + * @param {<>, <>, <>} params.stats - Specific 'tag' of the request for logging and statistical purposes + * @param {<>} params.version - Specify whether to return document version as part of a hit + * @param {<>} params.versionType - Should the document increment the version number (internal) on hit or not (reindex) + * @param {<>} params.requestCache - Specify if request cache should be used for this request or not, defaults to index level setting + * @param {<>} params.refresh - Should the effected indexes be refreshed? + * @param {<>} [params.timeout=1m] - Time each individual bulk request should wait for shards that are unavailable. + * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {<>} params.scrollSize - Size on the scroll request powering the update_by_query + * @param {<>} [params.waitForCompletion=true] - Should the request should block until the update by query operation is complete. + * @param {<>} params.requestsPerSecond - The throttle to set on this request in sub-requests per second. -1 means no throttle. + * @param {<>} [params.slices=1] - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. + * @param {<>, <>, <>} params.index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * @param {<>, <>, <>} params.type - A comma-separated list of document types to search; leave empty to perform the operation on all types + */ +api.updateByQuery = ca({ + params: { + analyzer: { + type: 'string' + }, + analyzeWildcard: { + type: 'boolean', + name: 'analyze_wildcard' + }, + defaultOperator: { + type: 'enum', + 'default': 'OR', + options: [ + 'AND', + 'OR' + ], + name: 'default_operator' + }, + df: { + type: 'string' + }, + from: { + type: 'number' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + conflicts: { + type: 'enum', + 'default': 'abort', + options: [ + 'abort', + 'proceed' + ] + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + lenient: { + type: 'boolean' + }, + pipeline: { + type: 'string' + }, + preference: { + type: 'string' + }, + q: { + type: 'string' + }, + routing: { + type: 'list' + }, + scroll: { + type: 'time' + }, + searchType: { + type: 'enum', + options: [ + 'query_then_fetch', + 'dfs_query_then_fetch' + ], + name: 'search_type' + }, + searchTimeout: { + type: 'time', + name: 'search_timeout' + }, + size: { + type: 'number' + }, + sort: { + type: 'list' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + }, + terminateAfter: { + type: 'number', + name: 'terminate_after' + }, + stats: { + type: 'list' + }, + version: { + type: 'boolean' + }, + versionType: { + type: 'boolean', + name: 'version_type' + }, + requestCache: { + type: 'boolean', + name: 'request_cache' + }, + refresh: { + type: 'boolean' + }, + timeout: { + type: 'time', + 'default': '1m' + }, + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + }, + scrollSize: { + type: 'number', + name: 'scroll_size' + }, + waitForCompletion: { + type: 'boolean', + 'default': true, + name: 'wait_for_completion' + }, + requestsPerSecond: { + type: 'number', + 'default': 0, + name: 'requests_per_second' + }, + slices: { + type: 'number', + 'default': 1 + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_update_by_query', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_update_by_query', + req: { + index: { + type: 'list' + } + } + } + ], + method: 'POST' +}); diff --git a/src/lib/apis/browser_index.js b/src/lib/apis/browser_index.js index 413df42bb..2290a3d3f 100644 --- a/src/lib/apis/browser_index.js +++ b/src/lib/apis/browser_index.js @@ -6,5 +6,6 @@ module.exports = { '5.0': require('./5_0'), '2.4': require('./2_4'), '5.x': require('./5_x'), + '5.4': require('./5_4'), 'master': require('./master') }; diff --git a/src/lib/apis/index.js b/src/lib/apis/index.js index 0046ee4d0..a0154486c 100644 --- a/src/lib/apis/index.js +++ b/src/lib/apis/index.js @@ -8,5 +8,6 @@ module.exports = { get '1.7'() { return require('./1_7'); }, get '0.90'() { return require('./0_90'); }, get '5.x'() { return require('./5_x'); }, + get '5.4'() { return require('./5_4'); }, get 'master'() { return require('./master'); }, }; From 036fb89f747e2998508b3ac525d629d1a79ae922 Mon Sep 17 00:00:00 2001 From: spalger Date: Mon, 1 May 2017 16:49:18 -0700 Subject: [PATCH 19/61] remove debugger --- scripts/Version.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/Version.js b/scripts/Version.js index e685ae393..b3bde3838 100644 --- a/scripts/Version.js +++ b/scripts/Version.js @@ -21,7 +21,7 @@ function nextMinorVersion(major) { // ensure all values in tuples are not NaN .filter(vt => vt.every(v => !isNaN(v))) // ensure that major version in tuple matches major (both as a string) - .filter(vt => `${vt[0]}` === `${major}`) + .filter(vt => vt[0] === parseFloat(major)) // sort by the minor version in each tuple .sort((vta, vtb) => vtb[1] - vta[1]) // get the minor version from the first tuple @@ -56,7 +56,6 @@ Version.prototype.increment = function (which) { }; Version.prototype.satisfies = function (range) { - debugger return semver.satisfies(this.version, range); }; From cbb66cc6f37cacda4ff7773f051a70da6e8fb87e Mon Sep 17 00:00:00 2001 From: spalger Date: Mon, 8 May 2017 12:18:41 -0700 Subject: [PATCH 20/61] correct 13.0.0 release date --- docs/changelog.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog.asciidoc b/docs/changelog.asciidoc index 288ece816..845ff4b74 100644 --- a/docs/changelog.asciidoc +++ b/docs/changelog.asciidoc @@ -1,7 +1,7 @@ [[changelog]] == Changelog -=== 13.0.0 (Apr 24 2016) +=== 13.0.0 (Apr 24 2017) * apiVersion `"5.3"` is now the default * Fixed the way that http addresses are sniffed from the cluster https://github.com/elastic/elasticsearch-js/issues/496[#496] From 35b342550ef7bfcb08069743d513633ba5b6f12b Mon Sep 17 00:00:00 2001 From: Spencer Date: Tue, 9 May 2017 14:11:02 -0700 Subject: [PATCH 21/61] add a `castToArray` option to paramAsBody spec (#541) --- scripts/generate/overrides.js | 10 ++++++++++ src/lib/client_action.js | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/generate/overrides.js b/scripts/generate/overrides.js index ee406a062..fd8aa9c52 100644 --- a/scripts/generate/overrides.js +++ b/scripts/generate/overrides.js @@ -289,5 +289,15 @@ function (spec) { examples: { scroll: 'scroll_<5.0.asciidoc' } + }, + { + version: '>=5.3,<5.5', + paramAsBody: { + clearScroll: { + param: 'scrollId', + body: 'scroll_id', + castToArray: true, + } + } } ]; diff --git a/src/lib/client_action.js b/src/lib/client_action.js index 3b602f67b..a8d6d26d1 100644 --- a/src/lib/client_action.js +++ b/src/lib/client_action.js @@ -257,7 +257,11 @@ function exec(transport, spec, params, cb) { if (!params.body && spec.paramAsBody) { if (typeof spec.paramAsBody === 'object') { params.body = {}; - params.body[spec.paramAsBody.body] = params[spec.paramAsBody.param]; + if (spec.paramAsBody.castToArray) { + params.body[spec.paramAsBody.body] = [].concat(params[spec.paramAsBody.param]); + } else { + params.body[spec.paramAsBody.body] = params[spec.paramAsBody.param]; + } delete params[spec.paramAsBody.param]; } else { params.body = params[spec.paramAsBody]; From 053e78eabb53b4f7745024beb75fa44d95179433 Mon Sep 17 00:00:00 2001 From: spalger Date: Tue, 9 May 2017 14:36:48 -0700 Subject: [PATCH 22/61] update changelog --- docs/changelog.asciidoc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/changelog.asciidoc b/docs/changelog.asciidoc index 845ff4b74..9d1266032 100644 --- a/docs/changelog.asciidoc +++ b/docs/changelog.asciidoc @@ -1,6 +1,10 @@ [[changelog]] == Changelog +=== 13.0.1 (May 9 2017) + + * Fixed the way that `clearScroll` handles it's `scrollId` param https://github.com/elastic/elasticsearch-js/pull/541[#541] + === 13.0.0 (Apr 24 2017) * apiVersion `"5.3"` is now the default From cac980ad14cca48762c2180b6d765ed3765f9172 Mon Sep 17 00:00:00 2001 From: spalger Date: Mon, 12 Jun 2017 10:52:18 -0700 Subject: [PATCH 23/61] upgrade 5.4 to supported branch, 5.5 as upstable --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 34749cc90..b55ff534b 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ }, "default_api_branch": "5.3", "supported_es_branches": [ + "5.4", "5.3", "5.2", "5.1", @@ -35,7 +36,7 @@ ], "unstable_es_branches": [ "5.x", - "5.4", + "5.5", "master" ] }, From 7272941c1b58ae78a1752a12122026337e7ecd5e Mon Sep 17 00:00:00 2001 From: spalger Date: Mon, 12 Jun 2017 10:52:27 -0700 Subject: [PATCH 24/61] [apis] regenerate --- docs/api_methods_5_4.asciidoc | 5493 ++++++++++++++++++++++++ docs/configuration.asciidoc | 7 +- docs/index.asciidoc | 2 + src/lib/apis/5_5.js | 7368 +++++++++++++++++++++++++++++++++ src/lib/apis/5_x.js | 22 +- src/lib/apis/browser_index.js | 4 +- src/lib/apis/index.js | 3 +- src/lib/apis/master.js | 129 +- 8 files changed, 12993 insertions(+), 35 deletions(-) create mode 100644 docs/api_methods_5_4.asciidoc create mode 100644 src/lib/apis/5_5.js diff --git a/docs/api_methods_5_4.asciidoc b/docs/api_methods_5_4.asciidoc new file mode 100644 index 000000000..5f25e9fb4 --- /dev/null +++ b/docs/api_methods_5_4.asciidoc @@ -0,0 +1,5493 @@ +[[api-reference-5-4]] +== 5.4 API + + +NOTE: At this time, you must opt into the 5.4 API by setting the `apiVersion` config parameter. + + +[[api-bulk-5-4]] +=== `bulk` + +[source,js] +-------- +client.bulk([params, [callback]]) +-------- + +Perform many index/delete operations in a single API call. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-bulk.html[the elasticsearch docs] for more information pertaining to this method. + +.Perform three operations in a single request +[source,js] +--------- +client.bulk({ + body: [ + // action description + { index: { _index: 'myindex', _type: 'mytype', _id: 1 } }, + // the document to index + { title: 'foo' }, + // action description + { update: { _index: 'myindex', _type: 'mytype', _id: 2 } }, + // the document to update + { doc: { title: 'foo' } }, + // action description + { delete: { _index: 'myindex', _type: 'mytype', _id: 3 } }, + // no document needed for this delete + ] +}, function (err, resp) { + // ... +}); +--------- + + +*Params* + +[horizontal] +`waitForActiveShards`:: +<> -- Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) +`refresh`:: +<> -- If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. +Options::: + * `"true"` + * `"false"` + * `"wait_for"` + * `""` + +`routing`:: +<> -- Specific routing value +`timeout`:: +<> -- Explicit operation timeout +`type`:: +<> -- Default document type for items which don't provide one +`fields`:: +<>, <>, <> -- Default comma-separated list of fields to return in the response for updates, can be overridden on each sub-request +`_source`:: +<>, <>, <> -- True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request +`_sourceExclude`:: +<>, <>, <> -- Default list of fields to exclude from the returned _source field, can be overridden on each sub-request +`_sourceInclude`:: +<>, <>, <> -- Default list of fields to extract and return from the _source field, can be overridden on each sub-request +`pipeline`:: +<> -- The pipeline id to preprocess incoming documents with +`index`:: +<> -- Default index for items which don't provide one +`body`:: +<>, <> -- The request body, as either an array of objects or new-line delimited JSON objects. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-bulk.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-clearscroll-5-4]] +=== `clearScroll` + +[source,js] +-------- +client.clearScroll([params, [callback]]) +-------- + +Clear the scroll request created by specifying the scroll parameter to search. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-request-scroll.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`scrollId`:: +<>, <>, <> -- A comma-separated list of scroll IDs to clear +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-request-scroll.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-count-5-4]] +=== `count` + +[source,js] +-------- +client.count([params, [callback]]) +-------- + +Get the number of documents for the cluster, index, type, or a query. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-count.html[the elasticsearch docs] for more information pertaining to this method. + +.Get the number of all documents in the cluster +[source,js] +--------- +client.count(function (error, response, status) { + // check for and handle error + var count = response.count; +}); +--------- + +.Get the number of documents in an index +[source,js] +--------- +client.count({ + index: 'index_name' +}, function (error, response) { + // ... +}); +--------- + +.Get the number of documents matching a query +[source,js] +--------- +client.count({ + index: 'index_name', + body: { + query: { + filtered: { + filter: { + terms: { + foo: ['bar'] + } + } + } + } + } +}, function (err, response) { + // ... +}); +--------- + + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`minScore`:: +<> -- Include only documents with a specific `_score` value in the result +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`routing`:: +<> -- Specific routing value +`q`:: +<> -- Query in the Lucene query string syntax +`analyzer`:: +<> -- The analyzer to use for the query string +`analyzeWildcard`:: +<> -- Specify whether wildcard and prefix queries should be analyzed (default: false) +`[defaultOperator=OR]`:: +<> -- The default operator for query string query (AND or OR) +Options::: + * `"AND"` + * `"OR"` + +`df`:: +<> -- The field to use as default where no field prefix is given in the query string +`lenient`:: +<> -- Specify whether format-based query failures (such as providing text to a numeric field) should be ignored +`index`:: +<>, <>, <> -- A comma-separated list of indices to restrict the results +`type`:: +<>, <>, <> -- A comma-separated list of types to restrict the results +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-count.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-countpercolate-5-4]] +=== `countPercolate` + +[source,js] +-------- +client.countPercolate([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-percolate.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`routing`:: +<>, <>, <> -- A comma-separated list of specific routing values +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`percolateIndex`:: +<> -- The index to count percolate the document into. Defaults to index. +`percolateType`:: +<> -- The type to count percolate document into. Defaults to type. +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"external"` + * `"external_gte"` + * `"force"` + +`index`:: +<> -- The index of the document being count percolated. +`type`:: +<> -- The type of the document being count percolated. +`id`:: +<> -- Substitute the document in the request body with a document that is known by the specified id. On top of the id, the index and type parameter will be used to retrieve the document from within the cluster. +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-percolate.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-create-5-4]] +=== `create` + +[source,js] +-------- +client.create([params, [callback]]) +-------- + +Adds a typed JSON document in a specific index, making it searchable. If a document with the same `index`, `type`, and `id` already exists, an error will occur. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-index_.html[the elasticsearch docs] for more information pertaining to this method. + +.Create a document +[source,js] +--------- +client.create({ + index: 'myindex', + type: 'mytype', + id: '1', + body: { + title: 'Test 1', + tags: ['y', 'z'], + published: true, + published_at: '2013-01-01', + counter: 1 + } +}, function (error, response) { + // ... +}); +--------- + + +*Params* + +[horizontal] +`waitForActiveShards`:: +<> -- Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) +`parent`:: +<> -- ID of the parent document +`refresh`:: +<> -- If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. +Options::: + * `"true"` + * `"false"` + * `"wait_for"` + * `""` + +`routing`:: +<> -- Specific routing value +`timeout`:: +<> -- Explicit operation timeout +`timestamp`:: +Timestamp -- Explicit timestamp for the document +`ttl`:: +<> -- Expiration time for the document +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"external"` + * `"external_gte"` + * `"force"` + +`pipeline`:: +<> -- The pipeline id to preprocess incoming documents with +`id`:: +<> -- Document ID +`index`:: +<> -- The name of the index +`type`:: +<> -- The type of the document +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-index_.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-delete-5-4]] +=== `delete` + +[source,js] +-------- +client.delete([params, [callback]]) +-------- + +Delete a typed JSON document from a specific index based on its id. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-delete.html[the elasticsearch docs] for more information pertaining to this method. + +.Delete the document `/myindex/mytype/1` +[source,js] +--------- +client.delete({ + index: 'myindex', + type: 'mytype', + id: '1' +}, function (error, response) { + // ... +}); +--------- + + +*Params* + +[horizontal] +`waitForActiveShards`:: +<> -- Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) +`parent`:: +<> -- ID of parent document +`refresh`:: +<> -- If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. +Options::: + * `"true"` + * `"false"` + * `"wait_for"` + * `""` + +`routing`:: +<> -- Specific routing value +`timeout`:: +<> -- Explicit operation timeout +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"external"` + * `"external_gte"` + * `"force"` + +`id`:: +<> -- The document ID +`index`:: +<> -- The name of the index +`type`:: +<> -- The type of the document +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-delete.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-deletebyquery-5-4]] +=== `deleteByQuery` + +[source,js] +-------- +client.deleteByQuery([params, [callback]]) +-------- + +Delete documents from one or more indices and one or more types based on a query. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-delete-by-query.html[the elasticsearch docs] for more information pertaining to this method. + +.Deleting documents with a simple query +[source,js] +--------- +client.deleteByQuery({ + index: 'myindex', + q: 'test' +}, function (error, response) { + // ... +}); +--------- + +.Deleting documents using the Query DSL +[source,js] +--------- +client.deleteByQuery({ + index: 'posts', + body: { + query: { + term: { published: false } + } + } +}, function (error, response) { + // ... +}); +--------- + + +*Params* + +[horizontal] +`analyzer`:: +<> -- The analyzer to use for the query string +`analyzeWildcard`:: +<> -- Specify whether wildcard and prefix queries should be analyzed (default: false) +`[defaultOperator=OR]`:: +<> -- The default operator for query string query (AND or OR) +Options::: + * `"AND"` + * `"OR"` + +`df`:: +<> -- The field to use as default where no field prefix is given in the query string +`from`:: +<> -- Starting offset (default: 0) +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[conflicts=abort]`:: +<> -- What to do when the delete-by-query hits version conflicts? +Options::: + * `"abort"` + * `"proceed"` + +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`lenient`:: +<> -- Specify whether format-based query failures (such as providing text to a numeric field) should be ignored +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`q`:: +<> -- Query in the Lucene query string syntax +`routing`:: +<>, <>, <> -- A comma-separated list of specific routing values +`scroll`:: +<> -- Specify how long a consistent view of the index should be maintained for scrolled search +`searchType`:: +<> -- Search operation type +Options::: + * `"query_then_fetch"` + * `"dfs_query_then_fetch"` + +`searchTimeout`:: +<> -- Explicit timeout for each search request. Defaults to no timeout. +`size`:: +<> -- Number of hits to return (default: 10) +`sort`:: +<>, <>, <> -- A comma-separated list of : pairs +`_source`:: +<>, <>, <> -- True or false to return the _source field or not, or a list of fields to return +`_sourceExclude`:: +<>, <>, <> -- A list of fields to exclude from the returned _source field +`_sourceInclude`:: +<>, <>, <> -- A list of fields to extract and return from the _source field +`terminateAfter`:: +<> -- The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. +`stats`:: +<>, <>, <> -- Specific 'tag' of the request for logging and statistical purposes +`version`:: +<> -- Specify whether to return document version as part of a hit +`requestCache`:: +<> -- Specify if request cache should be used for this request or not, defaults to index level setting +`refresh`:: +<> -- Should the effected indexes be refreshed? +`[timeout=1m]`:: +<> -- Time each individual bulk request should wait for shards that are unavailable. +`waitForActiveShards`:: +<> -- Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) +`scrollSize`:: +<> -- Size on the scroll request powering the update_by_query +`[waitForCompletion=true]`:: +<> -- Should the request should block until the delete-by-query is complete. +`requestsPerSecond`:: +<> -- The throttle for this request in sub-requests per second. -1 means no throttle. +`[slices=1]`:: +<> -- The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. +`index`:: +<>, <>, <> -- A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices +`type`:: +<>, <>, <> -- A comma-separated list of document types to search; leave empty to perform the operation on all types +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-delete-by-query.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-deletescript-5-4]] +=== `deleteScript` + +[source,js] +-------- +client.deleteScript([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-scripting.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`id`:: +<> -- Script ID +`lang`:: +<> -- Script language +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-scripting.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-deletetemplate-5-4]] +=== `deleteTemplate` + +[source,js] +-------- +client.deleteTemplate([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-template.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`id`:: +<> -- Template ID +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-template.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-exists-5-4]] +=== `exists` + +[source,js] +-------- +client.exists([params, [callback]]) +-------- + +Returns a boolean indicating whether or not a given document exists. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-get.html[the elasticsearch docs] for more information pertaining to this method. + +.Check that the document `/myindex/mytype/1` exist +[source,js] +--------- +client.exists({ + index: 'myindex', + type: 'mytype', + id: 1 +}, function (error, exists) { + if (exists === true) { + // ... + } else { + // ... + } +}); +--------- + + +*Params* + +[horizontal] +`storedFields`:: +<>, <>, <> -- A comma-separated list of stored fields to return in the response +`parent`:: +<> -- The ID of the parent document +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`realtime`:: +<> -- Specify whether to perform the operation in realtime or search mode +`refresh`:: +<> -- Refresh the shard containing the document before performing the operation +`routing`:: +<> -- Specific routing value +`_source`:: +<>, <>, <> -- True or false to return the _source field or not, or a list of fields to return +`_sourceExclude`:: +<>, <>, <> -- A list of fields to exclude from the returned _source field +`_sourceInclude`:: +<>, <>, <> -- A list of fields to extract and return from the _source field +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"external"` + * `"external_gte"` + * `"force"` + +`id`:: +<> -- The document ID +`index`:: +<> -- The name of the index +`type`:: +<> -- The type of the document (use `_all` to fetch the first document matching the ID across all types) +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-get.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-existssource-5-4]] +=== `existsSource` + +[source,js] +-------- +client.existsSource([params, [callback]]) +-------- + +// no description + +Check the *<>* and http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`parent`:: +<> -- The ID of the parent document +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`realtime`:: +<> -- Specify whether to perform the operation in realtime or search mode +`refresh`:: +<> -- Refresh the shard containing the document before performing the operation +`routing`:: +<> -- Specific routing value +`_source`:: +<>, <>, <> -- True or false to return the _source field or not, or a list of fields to return +`_sourceExclude`:: +<>, <>, <> -- A list of fields to exclude from the returned _source field +`_sourceInclude`:: +<>, <>, <> -- A list of fields to extract and return from the _source field +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"external"` + * `"external_gte"` + * `"force"` + +`id`:: +<> -- The document ID +`index`:: +<> -- The name of the index +`type`:: +<> -- The type of the document; use `_all` to fetch the first document matching the ID across all types +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-explain-5-4]] +=== `explain` + +[source,js] +-------- +client.explain([params, [callback]]) +-------- + +Provides details about a specific document's score in relation to a specific query. It will also tell you if the document matches the specified query. Also check out http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-percolate.html[percolaters]. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-explain.html[the elasticsearch docs] for more information pertaining to this method. + +.See how a document is scored against a simple query +[source,js] +--------- +client.explain({ + // the document to test + index: 'myindex', + type: 'mytype', + id: '1', + + // the query to score it against + q: 'field:value' +}, function (error, response) { + // ... +}); +--------- + +.See how a document is scored against a query written in the Query DSL +[source,js] +--------- +client.explain({ + index: 'myindex', + type: 'mytype', + id: '1', + body: { + query: { + match: { title: 'test' } + } + } +}, function (error, response) { + // ... +}); +--------- + + +*Params* + +[horizontal] +`analyzeWildcard`:: +<> -- Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false) +`analyzer`:: +<> -- The analyzer for the query string query +`[defaultOperator=OR]`:: +<> -- The default operator for query string query (AND or OR) +Options::: + * `"AND"` + * `"OR"` + +`df`:: +<> -- The default field for query string query (default: _all) +`storedFields`:: +<>, <>, <> -- A comma-separated list of stored fields to return in the response +`lenient`:: +<> -- Specify whether format-based query failures (such as providing text to a numeric field) should be ignored +`parent`:: +<> -- The ID of the parent document +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`q`:: +<> -- Query in the Lucene query string syntax +`routing`:: +<> -- Specific routing value +`_source`:: +<>, <>, <> -- True or false to return the _source field or not, or a list of fields to return +`_sourceExclude`:: +<>, <>, <> -- A list of fields to exclude from the returned _source field +`_sourceInclude`:: +<>, <>, <> -- A list of fields to extract and return from the _source field +`id`:: +<> -- The document ID +`index`:: +<> -- The name of the index +`type`:: +<> -- The type of the document +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-explain.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-fieldcaps-5-4]] +=== `fieldCaps` + +[source,js] +-------- +client.fieldCaps([params, [callback]]) +-------- + +// no description + +Check the *<>* and http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`fields`:: +<>, <>, <> -- A comma-separated list of field names +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-fieldstats-5-4]] +=== `fieldStats` + +[source,js] +-------- +client.fieldStats([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-field-stats.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`fields`:: +<>, <>, <> -- A comma-separated list of fields for to get field statistics for (min value, max value, and more) +`[level=cluster]`:: +<> -- Defines if field stats should be returned on a per index level or on a cluster wide level +Options::: + * `"indices"` + * `"cluster"` + +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-field-stats.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-get-5-4]] +=== `get` + +[source,js] +-------- +client.get([params, [callback]]) +-------- + +Get a typed JSON document from the index based on its id. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-get.html[the elasticsearch docs] for more information pertaining to this method. + +.Get `/myindex/mytype/1` +[source,js] +--------- +client.get({ + index: 'myindex', + type: 'mytype', + id: 1 +}, function (error, response) { + // ... +}); +--------- + + +*Params* + +[horizontal] +`storedFields`:: +<>, <>, <> -- A comma-separated list of stored fields to return in the response +`parent`:: +<> -- The ID of the parent document +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`realtime`:: +<> -- Specify whether to perform the operation in realtime or search mode +`refresh`:: +<> -- Refresh the shard containing the document before performing the operation +`routing`:: +<> -- Specific routing value +`_source`:: +<>, <>, <> -- True or false to return the _source field or not, or a list of fields to return +`_sourceExclude`:: +<>, <>, <> -- A list of fields to exclude from the returned _source field +`_sourceInclude`:: +<>, <>, <> -- A list of fields to extract and return from the _source field +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"external"` + * `"external_gte"` + * `"force"` + +`id`:: +<> -- The document ID +`index`:: +<> -- The name of the index +`type`:: +<> -- The type of the document (use `_all` to fetch the first document matching the ID across all types) + +link:#[back to top] + +[[api-getscript-5-4]] +=== `getScript` + +[source,js] +-------- +client.getScript([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-scripting.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`id`:: +<> -- Script ID +`lang`:: +<> -- Script language + +link:#[back to top] + +[[api-getsource-5-4]] +=== `getSource` + +[source,js] +-------- +client.getSource([params, [callback]]) +-------- + +Get the source of a document by its index, type and id. + + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-get.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`parent`:: +<> -- The ID of the parent document +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`realtime`:: +<> -- Specify whether to perform the operation in realtime or search mode +`refresh`:: +<> -- Refresh the shard containing the document before performing the operation +`routing`:: +<> -- Specific routing value +`_source`:: +<>, <>, <> -- True or false to return the _source field or not, or a list of fields to return +`_sourceExclude`:: +<>, <>, <> -- A list of fields to exclude from the returned _source field +`_sourceInclude`:: +<>, <>, <> -- A list of fields to extract and return from the _source field +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"external"` + * `"external_gte"` + * `"force"` + +`id`:: +<> -- The document ID +`index`:: +<> -- The name of the index +`type`:: +<> -- The type of the document; use `_all` to fetch the first document matching the ID across all types + +link:#[back to top] + +[[api-gettemplate-5-4]] +=== `getTemplate` + +[source,js] +-------- +client.getTemplate([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-template.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`id`:: +<> -- Template ID + +link:#[back to top] + +[[api-index-5-4]] +=== `index` + +[source,js] +-------- +client.index([params, [callback]]) +-------- + +Stores a typed JSON document in an index, making it searchable. When the `id` param is not set, a unique id will be auto-generated. When you specify an `id` either a new document will be created, or an existing document will be updated. To enforce "put-if-absent" behavior set the `opType` to `"create"` or use the `create()` method. + +Optimistic concurrency control is performed, when the `version` argument is specified. By default, no version checks are performed. + +By default, the document will be available for `get()` actions immediately, but will only be available for searching after an index refresh (which can happen automatically or manually). See <>. + + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-index_.html[the elasticsearch docs] for more information pertaining to this method. + +.Create or update a document +[source,js] +--------- +client.index({ + index: 'myindex', + type: 'mytype', + id: '1', + body: { + title: 'Test 1', + tags: ['y', 'z'], + published: true, + } +}, function (error, response) { + +}); +--------- + + +*Params* + +[horizontal] +`waitForActiveShards`:: +<> -- Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) +`[opType=index]`:: +<> -- Explicit operation type +Options::: + * `"index"` + * `"create"` + +`parent`:: +<> -- ID of the parent document +`refresh`:: +<> -- If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. +Options::: + * `"true"` + * `"false"` + * `"wait_for"` + * `""` + +`routing`:: +<> -- Specific routing value +`timeout`:: +<> -- Explicit operation timeout +`timestamp`:: +Timestamp -- Explicit timestamp for the document +`ttl`:: +<> -- Expiration time for the document +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"external"` + * `"external_gte"` + * `"force"` + +`pipeline`:: +<> -- The pipeline id to preprocess incoming documents with +`id`:: +<> -- Document ID +`index`:: +<> -- The name of the index +`type`:: +<> -- The type of the document +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-index_.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-info-5-4]] +=== `info` + +[source,js] +-------- +client.info([params, [callback]]) +-------- + +Get basic info from the current cluster. + +Check the *<>* and https://www.elastic.co/guide/[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + + +[[api-mget-5-4]] +=== `mget` + +[source,js] +-------- +client.mget([params, [callback]]) +-------- + +Get multiple documents based on an index, type (optional) and ids. The body required by mget can take two forms: an array of document locations, or an array of document ids. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-multi-get.html[the elasticsearch docs] for more information pertaining to this method. + +.An array of doc locations. Useful for getting documents from different indices. +[source,js] +--------- +client.mget({ + body: { + docs: [ + { _index: 'indexA', _type: 'typeA', _id: '1' }, + { _index: 'indexB', _type: 'typeB', _id: '1' }, + { _index: 'indexC', _type: 'typeC', _id: '1' } + ] + } +}, function(error, response){ + // ... +}); +--------- + +.An array of ids. You must also specify the `index` and `type` that apply to all of the ids. +[source,js] +--------- +client.mget({ + index: 'myindex', + type: 'mytype', + body: { + ids: [1, 2, 3] + } +}, function(error, response){ + // ... +}); +--------- + + +*Params* + +[horizontal] +`storedFields`:: +<>, <>, <> -- A comma-separated list of stored fields to return in the response +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`realtime`:: +<> -- Specify whether to perform the operation in realtime or search mode +`refresh`:: +<> -- Refresh the shard containing the document before performing the operation +`routing`:: +<> -- Specific routing value +`_source`:: +<>, <>, <> -- True or false to return the _source field or not, or a list of fields to return +`_sourceExclude`:: +<>, <>, <> -- A list of fields to exclude from the returned _source field +`_sourceInclude`:: +<>, <>, <> -- A list of fields to extract and return from the _source field +`index`:: +<> -- The name of the index +`type`:: +<> -- The type of the document +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-multi-get.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-mpercolate-5-4]] +=== `mpercolate` + +[source,js] +-------- +client.mpercolate([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-percolate.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`index`:: +<> -- The index of the document being count percolated to use as default +`type`:: +<> -- The type of the document being percolated to use as default. +`body`:: +<>, <> -- The request body, as either an array of objects or new-line delimited JSON objects. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-percolate.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-msearch-5-4]] +=== `msearch` + +[source,js] +-------- +client.msearch([params, [callback]]) +-------- + +Execute several search requests within the same request. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-multi-search.html[the elasticsearch docs] for more information pertaining to this method. + +.Perform multiple different searches, the body is made up of meta/data pairs +[source,js] +--------- +client.msearch({ + body: [ + // match all query, on all indices and types + {}, + { query: { match_all: {} } }, + + // query_string query, on index/mytype + { index: 'myindex', type: 'mytype' }, + { query: { query_string: { query: '"Test 1"' } } } + ] +}); +--------- + + + +*Params* + +[horizontal] +`searchType`:: +<> -- Search operation type +Options::: + * `"query_then_fetch"` + * `"query_and_fetch"` + * `"dfs_query_then_fetch"` + * `"dfs_query_and_fetch"` + +`maxConcurrentSearches`:: +<> -- Controls the maximum number of concurrent searches the multi search api will execute +`typedKeys`:: +<> -- Specify whether aggregation and suggester names should be prefixed by their respective types in the response +`index`:: +<>, <>, <> -- A comma-separated list of index names to use as default +`type`:: +<>, <>, <> -- A comma-separated list of document types to use as default +`body`:: +<>, <> -- The request body, as either an array of objects or new-line delimited JSON objects. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-multi-search.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-msearchtemplate-5-4]] +=== `msearchTemplate` + +[source,js] +-------- +client.msearchTemplate([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`searchType`:: +<> -- Search operation type +Options::: + * `"query_then_fetch"` + * `"query_and_fetch"` + * `"dfs_query_then_fetch"` + * `"dfs_query_and_fetch"` + +`typedKeys`:: +<> -- Specify whether aggregation and suggester names should be prefixed by their respective types in the response +`index`:: +<>, <>, <> -- A comma-separated list of index names to use as default +`type`:: +<>, <>, <> -- A comma-separated list of document types to use as default +`body`:: +<>, <> -- The request body, as either an array of objects or new-line delimited JSON objects. See https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-mtermvectors-5-4]] +=== `mtermvectors` + +[source,js] +-------- +client.mtermvectors([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-multi-termvectors.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ids`:: +<>, <>, <> -- A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body +`termStatistics`:: +<> -- Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". +`[fieldStatistics=true]`:: +<> -- Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". +`fields`:: +<>, <>, <> -- A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body "params" or "docs". +`[offsets=true]`:: +<> -- Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". +`[positions=true]`:: +<> -- Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". +`[payloads=true]`:: +<> -- Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body "params" or "docs". +`routing`:: +<> -- Specific routing value. Applies to all returned documents unless otherwise specified in body "params" or "docs". +`parent`:: +<> -- Parent id of documents. Applies to all returned documents unless otherwise specified in body "params" or "docs". +`realtime`:: +<> -- Specifies if requests are real-time as opposed to near-real-time (default: true). +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"external"` + * `"external_gte"` + * `"force"` + +`index`:: +<> -- The index in which the document resides. +`type`:: +<> -- The type of the document. +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-multi-termvectors.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-percolate-5-4]] +=== `percolate` + +[source,js] +-------- +client.percolate([params, [callback]]) +-------- + +Match a document against registered percolator queries. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-percolate.html[the elasticsearch docs] for more information pertaining to this method. + +.First, Register queries named “alert-1” and “alert-2” for the “myindex” index +[source,js] +--------- +client.index({ + index: 'myindex', + type: '.percolator', + id: 'alert-1', + body: { + // This query will be run against documents sent to percolate + query: { + query_string: { + query: 'foo' + } + } + } +}, function (error, response) { + // ... +}); + +client.index({ + index: 'myindex', + type: '.percolator', + id: 'alert-2', + body: { + // This query will also be run against documents sent to percolate + query: { + query_string: { + query: 'bar' + } + } + } +}, function (error, response) { + // ... +}); +--------- + +.Then you can send documents to learn which query `_percolator` queries they match +[source,js] +--------- +client.percolate({ + index: 'myindex', + type: 'mytype', + body: { + doc: { + title: "Foo" + } + } +}, function (error, response) { + // response would equal + // { + // total: 1, + // matches: [ { _index: 'myindex', _id: 'alert-1' } ] + // } +}); + +client.percolate({ + index: 'myindex', + type: 'mytype', + body: { + doc: { + title: "Foo Bar" + } + } +}, function (error, response) { + // response would equal + // { + // total: 2, + // matches: [ + // { _index: 'myindex', _id: 'alert-1' }, + // { _index: 'myindex', _id: 'alert-2' } + // ] + // } +}); +--------- + + +*Params* + +[horizontal] +`routing`:: +<>, <>, <> -- A comma-separated list of specific routing values +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`percolateIndex`:: +<> -- The index to percolate the document into. Defaults to index. +`percolateType`:: +<> -- The type to percolate document into. Defaults to type. +`percolateRouting`:: +<> -- The routing value to use when percolating the existing document. +`percolatePreference`:: +<> -- Which shard to prefer when executing the percolate request. +`percolateFormat`:: +<> -- Return an array of matching query IDs instead of objects +Options::: + * `"ids"` + +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"external"` + * `"external_gte"` + * `"force"` + +`index`:: +<> -- The index of the document being percolated. +`type`:: +<> -- The type of the document being percolated. +`id`:: +<> -- Substitute the document in the request body with a document that is known by the specified id. On top of the id, the index and type parameter will be used to retrieve the document from within the cluster. +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-percolate.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-ping-5-4]] +=== `ping` + +[source,js] +-------- +client.ping([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + + +[[api-putscript-5-4]] +=== `putScript` + +[source,js] +-------- +client.putScript([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-scripting.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`id`:: +<> -- Script ID +`lang`:: +<> -- Script language +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-scripting.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-puttemplate-5-4]] +=== `putTemplate` + +[source,js] +-------- +client.putTemplate([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-template.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`id`:: +<> -- Template ID +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-template.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-reindex-5-4]] +=== `reindex` + +[source,js] +-------- +client.reindex([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-reindex.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`refresh`:: +<> -- Should the effected indexes be refreshed? +`[timeout=1m]`:: +<> -- Time each individual bulk request should wait for shards that are unavailable. +`waitForActiveShards`:: +<> -- Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) +`[waitForCompletion=true]`:: +<> -- Should the request should block until the reindex is complete. +`requestsPerSecond`:: +<> -- The throttle to set on this request in sub-requests per second. -1 means no throttle. +`[slices=1]`:: +<> -- The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-reindex.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-reindexrethrottle-5-4]] +=== `reindexRethrottle` + +[source,js] +-------- +client.reindexRethrottle([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-reindex.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`requestsPerSecond`:: +<> -- The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. +`taskId`:: +<> -- The task id to rethrottle +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-reindex.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-rendersearchtemplate-5-4]] +=== `renderSearchTemplate` + +[source,js] +-------- +client.renderSearchTemplate([params, [callback]]) +-------- + +// no description + +Check the *<>* and http://www.elasticsearch.org/guide/en/elasticsearch/reference/5.x/search-template.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`id`:: +<> -- The id of the stored search template +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/5.x/search-template.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-scroll-5-4]] +=== `scroll` + +[source,js] +-------- +client.scroll([params, [callback]]) +-------- + +Scroll a search request (retrieve the next set of results) after specifying the scroll parameter in a `search()` call. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-request-scroll.html[the elasticsearch docs] for more information pertaining to this method. + +.Collect every title in the index that contains the word "test" +[source,js] +--------- +var allTitles = []; + +// first we do a search, and specify a scroll timeout +client.search({ + index: 'myindex', + scroll: '30s', // keep the search results "scrollable" for 30 seconds + source: ['title'], // filter the source to only include the title field + q: 'title:test' +}, function getMoreUntilDone(error, response) { + // collect the title from each response + response.hits.hits.forEach(function (hit) { + allTitles.push(hit._source.title); + }); + + if (response.hits.total > allTitles.length) { + // ask elasticsearch for the next set of hits from this search + client.scroll({ + scrollId: response._scroll_id, + scroll: '30s' + }, getMoreUntilDone); + } else { + console.log('every "test" title', allTitles); + } +}); +--------- + + + +*Params* + +[horizontal] +`scroll`:: +<> -- Specify how long a consistent view of the index should be maintained for scrolled search +`scrollId`:: +<> -- The scroll ID +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-request-scroll.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-search-5-4]] +=== `search` + +[source,js] +-------- +client.search([params, [callback]]) +-------- + +Return documents matching a query, aggregations/facets, highlighted snippets, suggestions, and more. Write your queries as either http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-uri-request.html[simple query strings] in the `q` parameter, or by specifying a http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-body.html[full request definition] using the http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html[Elasticsearch Query DSL] in the `body` parameter. + +TIP: https://github.com/danpaz/bodybuilder[bodybuilder] and https://github.com/sudo-suhas/elastic-builder[elastic-builder] can be used to make building query bodies easier. + + + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-search.html[the elasticsearch docs] for more information pertaining to this method. + +.Search with a simple query string query +[source,js] +--------- +client.search({ + index: 'myindex', + q: 'title:test' +}, function (error, response) { + // ... +}); +--------- + +.Passing a full request definition in the Elasticsearch's Query DSL as a `Hash` +[source,js] +--------- +client.search({ + index: 'myindex', + body: { + query: { + match: { + title: 'test' + } + }, + facets: { + tags: { + terms: { + field: 'tags' + } + } + } + } +}, function (error, response) { + // ... +}); +--------- + + +*Params* + +[horizontal] +`analyzer`:: +<> -- The analyzer to use for the query string +`analyzeWildcard`:: +<> -- Specify whether wildcard and prefix queries should be analyzed (default: false) +`[defaultOperator=OR]`:: +<> -- The default operator for query string query (AND or OR) +Options::: + * `"AND"` + * `"OR"` + +`df`:: +<> -- The field to use as default where no field prefix is given in the query string +`explain`:: +<> -- Specify whether to return detailed information about score computation as part of a hit +`storedFields`:: +<>, <>, <> -- A comma-separated list of stored fields to return as part of a hit +`docvalueFields`:: +<>, <>, <> -- A comma-separated list of fields to return as the docvalue representation of a field for each hit +`fielddataFields`:: +<>, <>, <> -- A comma-separated list of fields to return as the docvalue representation of a field for each hit +`from`:: +<> -- Starting offset (default: 0) +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`lenient`:: +<> -- Specify whether format-based query failures (such as providing text to a numeric field) should be ignored +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`q`:: +<> -- Query in the Lucene query string syntax +`routing`:: +<>, <>, <> -- A comma-separated list of specific routing values +`scroll`:: +<> -- Specify how long a consistent view of the index should be maintained for scrolled search +`searchType`:: +<> -- Search operation type +Options::: + * `"query_then_fetch"` + * `"dfs_query_then_fetch"` + +`size`:: +<> -- Number of hits to return (default: 10) +`sort`:: +<>, <>, <> -- A comma-separated list of : pairs +`_source`:: +<>, <>, <> -- True or false to return the _source field or not, or a list of fields to return +`_sourceExclude`:: +<>, <>, <> -- A list of fields to exclude from the returned _source field +`_sourceInclude`:: +<>, <>, <> -- A list of fields to extract and return from the _source field +`terminateAfter`:: +<> -- The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. +`stats`:: +<>, <>, <> -- Specific 'tag' of the request for logging and statistical purposes +`suggestField`:: +<> -- Specify which field to use for suggestions +`[suggestMode=missing]`:: +<> -- Specify suggest mode +Options::: + * `"missing"` + * `"popular"` + * `"always"` + +`suggestSize`:: +<> -- How many suggestions to return in response +`suggestText`:: +<> -- The source text for which the suggestions should be returned +`timeout`:: +<> -- Explicit operation timeout +`trackScores`:: +<> -- Whether to calculate and return scores even if they are not used for sorting +`typedKeys`:: +<> -- Specify whether aggregation and suggester names should be prefixed by their respective types in the response +`version`:: +<> -- Specify whether to return document version as part of a hit +`requestCache`:: +<> -- Specify if request cache should be used for this request or not, defaults to index level setting +`[batchedReduceSize=512]`:: +<> -- The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. +`index`:: +<>, <>, <> -- A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices +`type`:: +<>, <>, <> -- A comma-separated list of document types to search; leave empty to perform the operation on all types +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-search.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-searchshards-5-4]] +=== `searchShards` + +[source,js] +-------- +client.searchShards([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-shards.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`routing`:: +<> -- Specific routing value +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`index`:: +<>, <>, <> -- A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices +`type`:: +<>, <>, <> -- A comma-separated list of document types to search; leave empty to perform the operation on all types +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-shards.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-searchtemplate-5-4]] +=== `searchTemplate` + +[source,js] +-------- +client.searchTemplate([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`routing`:: +<>, <>, <> -- A comma-separated list of specific routing values +`scroll`:: +<> -- Specify how long a consistent view of the index should be maintained for scrolled search +`searchType`:: +<> -- Search operation type +Options::: + * `"query_then_fetch"` + * `"query_and_fetch"` + * `"dfs_query_then_fetch"` + * `"dfs_query_and_fetch"` + +`explain`:: +<> -- Specify whether to return detailed information about score computation as part of a hit +`profile`:: +<> -- Specify whether to profile the query execution +`typedKeys`:: +<> -- Specify whether aggregation and suggester names should be prefixed by their respective types in the response +`index`:: +<>, <>, <> -- A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices +`type`:: +<>, <>, <> -- A comma-separated list of document types to search; leave empty to perform the operation on all types +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-suggest-5-4]] +=== `suggest` + +[source,js] +-------- +client.suggest([params, [callback]]) +-------- + +The suggest feature suggests similar looking terms based on a provided text by using a specific suggester. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-suggesters.html[the elasticsearch docs] for more information pertaining to this method. + +.Return query terms suggestions (“auto-correction”) +[source,js] +--------- +client.suggest({ +index: 'myindex', +body: { + mysuggester: { + text: 'tset', + term: { + field: 'title' + } + } +} +}, function (error, response) { +// response will be formatted like so: +// +// { +// ... +// mysuggester: [ +// { +// text: "tset", +// ... +// options: [ +// { +// text: "test", +// score: 0.75, +// freq: 5 +// } +// ] +// } +// ] +// } +}); +--------- + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`routing`:: +<> -- Specific routing value +`index`:: +<>, <>, <> -- A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-suggesters.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-termvectors-5-4]] +=== `termvectors` + +[source,js] +-------- +client.termvectors([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-termvectors.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`termStatistics`:: +<> -- Specifies if total term frequency and document frequency should be returned. +`[fieldStatistics=true]`:: +<> -- Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. +`fields`:: +<>, <>, <> -- A comma-separated list of fields to return. +`[offsets=true]`:: +<> -- Specifies if term offsets should be returned. +`[positions=true]`:: +<> -- Specifies if term positions should be returned. +`[payloads=true]`:: +<> -- Specifies if term payloads should be returned. +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random). +`routing`:: +<> -- Specific routing value. +`parent`:: +<> -- Parent id of documents. +`realtime`:: +<> -- Specifies if request is real-time as opposed to near-real-time (default: true). +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"external"` + * `"external_gte"` + * `"force"` + +`index`:: +<> -- The index in which the document resides. +`type`:: +<> -- The type of the document. +`id`:: +<> -- The id of the document, when not specified a doc param should be supplied. +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-termvectors.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-update-5-4]] +=== `update` + +[source,js] +-------- +client.update([params, [callback]]) +-------- + +Update parts of a document. The required body parameter can contain one of two things: + + * a partial document, which will be merged with the existing one. + * a `script` which will update the document content + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-update.html[the elasticsearch docs] for more information pertaining to this method. + +.Update document title using partial document +[source,js] +--------- +client.update({ + index: 'myindex', + type: 'mytype', + id: '1', + body: { + // put the partial document under the `doc` key + doc: { + title: 'Updated' + } + } +}, function (error, response) { + // ... +}) +--------- + +.Add a tag to document `tags` property using a `script` +[source,js] +--------- +client.update({ + index: 'myindex', + type: 'mytype', + id: '1', + body: { + script: 'ctx._source.tags += tag', + params: { tag: 'some new tag' } + } +}, function (error, response) { + // ... +}); +--------- + +.Increment a document counter by 1 or initialize it, when the document does not exist +[source,js] +--------- +client.update({ + index: 'myindex', + type: 'mytype', + id: '777', + body: { + script: 'ctx._source.counter += 1', + upsert: { + counter: 1 + } + } +}, function (error, response) { + // ... +}) +--------- + +.Delete a document if it's tagged “to-delete” +[source,js] +--------- +client.update({ + index: 'myindex', + type: 'mytype', + id: '1', + body: { + script: 'ctx._source.tags.contains(tag) ? ctx.op = "delete" : ctx.op = "none"', + params: { + tag: 'to-delete' + } + } +}, function (error, response) { + // ... +}); +--------- + + +*Params* + +[horizontal] +`waitForActiveShards`:: +<> -- Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) +`fields`:: +<>, <>, <> -- A comma-separated list of fields to return in the response +`_source`:: +<>, <>, <> -- True or false to return the _source field or not, or a list of fields to return +`_sourceExclude`:: +<>, <>, <> -- A list of fields to exclude from the returned _source field +`_sourceInclude`:: +<>, <>, <> -- A list of fields to extract and return from the _source field +`lang`:: +<> -- The script language (default: painless) +`parent`:: +<> -- ID of the parent document. Is is only used for routing and when for the upsert request +`refresh`:: +<> -- If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. +Options::: + * `"true"` + * `"false"` + * `"wait_for"` + * `""` + +`retryOnConflict`:: +<> -- Specify how many times should the operation be retried when a conflict occurs (default: 0) +`routing`:: +<> -- Specific routing value +`timeout`:: +<> -- Explicit operation timeout +`timestamp`:: +Timestamp -- Explicit timestamp for the document +`ttl`:: +<> -- Expiration time for the document +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"force"` + +`id`:: +<> -- Document ID +`index`:: +<> -- The name of the index +`type`:: +<> -- The type of the document +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-update.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-updatebyquery-5-4]] +=== `updateByQuery` + +[source,js] +-------- +client.updateByQuery([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-update-by-query.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`analyzer`:: +<> -- The analyzer to use for the query string +`analyzeWildcard`:: +<> -- Specify whether wildcard and prefix queries should be analyzed (default: false) +`[defaultOperator=OR]`:: +<> -- The default operator for query string query (AND or OR) +Options::: + * `"AND"` + * `"OR"` + +`df`:: +<> -- The field to use as default where no field prefix is given in the query string +`from`:: +<> -- Starting offset (default: 0) +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[conflicts=abort]`:: +<> -- What to do when the update by query hits version conflicts? +Options::: + * `"abort"` + * `"proceed"` + +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`lenient`:: +<> -- Specify whether format-based query failures (such as providing text to a numeric field) should be ignored +`pipeline`:: +<> -- Ingest pipeline to set on index requests made by this action. (default: none) +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`q`:: +<> -- Query in the Lucene query string syntax +`routing`:: +<>, <>, <> -- A comma-separated list of specific routing values +`scroll`:: +<> -- Specify how long a consistent view of the index should be maintained for scrolled search +`searchType`:: +<> -- Search operation type +Options::: + * `"query_then_fetch"` + * `"dfs_query_then_fetch"` + +`searchTimeout`:: +<> -- Explicit timeout for each search request. Defaults to no timeout. +`size`:: +<> -- Number of hits to return (default: 10) +`sort`:: +<>, <>, <> -- A comma-separated list of : pairs +`_source`:: +<>, <>, <> -- True or false to return the _source field or not, or a list of fields to return +`_sourceExclude`:: +<>, <>, <> -- A list of fields to exclude from the returned _source field +`_sourceInclude`:: +<>, <>, <> -- A list of fields to extract and return from the _source field +`terminateAfter`:: +<> -- The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. +`stats`:: +<>, <>, <> -- Specific 'tag' of the request for logging and statistical purposes +`version`:: +<> -- Specify whether to return document version as part of a hit +`versionType`:: +<> -- Should the document increment the version number (internal) on hit or not (reindex) +`requestCache`:: +<> -- Specify if request cache should be used for this request or not, defaults to index level setting +`refresh`:: +<> -- Should the effected indexes be refreshed? +`[timeout=1m]`:: +<> -- Time each individual bulk request should wait for shards that are unavailable. +`waitForActiveShards`:: +<> -- Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) +`scrollSize`:: +<> -- Size on the scroll request powering the update_by_query +`[waitForCompletion=true]`:: +<> -- Should the request should block until the update by query operation is complete. +`requestsPerSecond`:: +<> -- The throttle to set on this request in sub-requests per second. -1 means no throttle. +`[slices=1]`:: +<> -- The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. +`index`:: +<>, <>, <> -- A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices +`type`:: +<>, <>, <> -- A comma-separated list of document types to search; leave empty to perform the operation on all types +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-update-by-query.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-cat-aliases-5-4]] +=== `cat.aliases` + +[source,js] +-------- +client.cat.aliases([params, [callback]]) +-------- + +// no description + +Check the *<>* and http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers +`name`:: +<>, <>, <> -- A comma-separated list of alias names to return + +link:#[back to top] + +[[api-cat-allocation-5-4]] +=== `cat.allocation` + +[source,js] +-------- +client.cat.allocation([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-allocation.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`bytes`:: +<> -- The unit in which to display byte values +Options::: + * `"b"` + * `"k"` + * `"kb"` + * `"m"` + * `"mb"` + * `"g"` + * `"gb"` + * `"t"` + * `"tb"` + * `"p"` + * `"pb"` + +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers +`nodeId`:: +<>, <>, <> -- A comma-separated list of node IDs or names to limit the returned information + +link:#[back to top] + +[[api-cat-count-5-4]] +=== `cat.count` + +[source,js] +-------- +client.cat.count([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-count.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers +`index`:: +<>, <>, <> -- A comma-separated list of index names to limit the returned information + +link:#[back to top] + +[[api-cat-fielddata-5-4]] +=== `cat.fielddata` + +[source,js] +-------- +client.cat.fielddata([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-fielddata.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`bytes`:: +<> -- The unit in which to display byte values +Options::: + * `"b"` + * `"k"` + * `"kb"` + * `"m"` + * `"mb"` + * `"g"` + * `"gb"` + * `"t"` + * `"tb"` + * `"p"` + * `"pb"` + +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers +`fields`:: +<>, <>, <> -- A comma-separated list of fields to return the fielddata size + +link:#[back to top] + +[[api-cat-health-5-4]] +=== `cat.health` + +[source,js] +-------- +client.cat.health([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-health.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`[ts=true]`:: +<> -- Set to false to disable timestamping +`v`:: +<> -- Verbose mode. Display column headers + +link:#[back to top] + +[[api-cat-help-5-4]] +=== `cat.help` + +[source,js] +-------- +client.cat.help([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by + +link:#[back to top] + +[[api-cat-indices-5-4]] +=== `cat.indices` + +[source,js] +-------- +client.cat.indices([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-indices.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`bytes`:: +<> -- The unit in which to display byte values +Options::: + * `"b"` + * `"k"` + * `"m"` + * `"g"` + +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`health`:: +<> -- A health status ("green", "yellow", or "red" to filter only indices matching the specified health status +Options::: + * `"green"` + * `"yellow"` + * `"red"` + +`help`:: +<> -- Return help information +`pri`:: +<> -- Set to true to return stats only for primary shards +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers +`index`:: +<>, <>, <> -- A comma-separated list of index names to limit the returned information + +link:#[back to top] + +[[api-cat-master-5-4]] +=== `cat.master` + +[source,js] +-------- +client.cat.master([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-master.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers + +link:#[back to top] + +[[api-cat-nodeattrs-5-4]] +=== `cat.nodeattrs` + +[source,js] +-------- +client.cat.nodeattrs([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-nodeattrs.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers + +link:#[back to top] + +[[api-cat-nodes-5-4]] +=== `cat.nodes` + +[source,js] +-------- +client.cat.nodes([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-nodes.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`fullId`:: +<> -- Return the full node ID instead of the shortened version (default: false) +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers + +link:#[back to top] + +[[api-cat-pendingtasks-5-4]] +=== `cat.pendingTasks` + +[source,js] +-------- +client.cat.pendingTasks([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-pending-tasks.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers + +link:#[back to top] + +[[api-cat-plugins-5-4]] +=== `cat.plugins` + +[source,js] +-------- +client.cat.plugins([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-plugins.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers + +link:#[back to top] + +[[api-cat-recovery-5-4]] +=== `cat.recovery` + +[source,js] +-------- +client.cat.recovery([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-recovery.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`bytes`:: +<> -- The unit in which to display byte values +Options::: + * `"b"` + * `"k"` + * `"kb"` + * `"m"` + * `"mb"` + * `"g"` + * `"gb"` + * `"t"` + * `"tb"` + * `"p"` + * `"pb"` + +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers +`index`:: +<>, <>, <> -- A comma-separated list of index names to limit the returned information + +link:#[back to top] + +[[api-cat-repositories-5-4]] +=== `cat.repositories` + +[source,js] +-------- +client.cat.repositories([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-repositories.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`local`:: +<> -- Return local information, do not retrieve the state from master node +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers + +link:#[back to top] + +[[api-cat-segments-5-4]] +=== `cat.segments` + +[source,js] +-------- +client.cat.segments([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-segments.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers +`index`:: +<>, <>, <> -- A comma-separated list of index names to limit the returned information + +link:#[back to top] + +[[api-cat-shards-5-4]] +=== `cat.shards` + +[source,js] +-------- +client.cat.shards([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-shards.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers +`index`:: +<>, <>, <> -- A comma-separated list of index names to limit the returned information + +link:#[back to top] + +[[api-cat-snapshots-5-4]] +=== `cat.snapshots` + +[source,js] +-------- +client.cat.snapshots([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-snapshots.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`ignoreUnavailable`:: +<> -- Set to true to ignore unavailable snapshots +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers +`repository`:: +<>, <>, <> -- Name of repository from which to fetch the snapshot information + +link:#[back to top] + +[[api-cat-tasks-5-4]] +=== `cat.tasks` + +[source,js] +-------- +client.cat.tasks([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/tasks.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`nodeId`:: +<>, <>, <> -- A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes +`actions`:: +<>, <>, <> -- A comma-separated list of actions that should be returned. Leave empty to return all. +`detailed`:: +<> -- Return detailed task information (default: false) +`parentNode`:: +<> -- Return tasks with specified parent node. +`parentTask`:: +<> -- Return tasks with specified parent task id. Set to -1 to return all. +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers + +link:#[back to top] + +[[api-cat-templates-5-4]] +=== `cat.templates` + +[source,js] +-------- +client.cat.templates([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-templates.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers +`name`:: +<> -- A pattern that returned template names must match + +link:#[back to top] + +[[api-cat-threadpool-5-4]] +=== `cat.threadPool` + +[source,js] +-------- +client.cat.threadPool([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-thread-pool.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`format`:: +<> -- a short version of the Accept header, e.g. json, yaml +`size`:: +<> -- The multiplier in which to display values +Options::: + * `""` + * `"k"` + * `"m"` + * `"g"` + * `"t"` + * `"p"` + +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`h`:: +<>, <>, <> -- Comma-separated list of column names to display +`help`:: +<> -- Return help information +`s`:: +<>, <>, <> -- Comma-separated list of column names or column aliases to sort by +`v`:: +<> -- Verbose mode. Display column headers +`threadPoolPatterns`:: +<>, <>, <> -- A comma-separated list of regular-expressions to filter the thread pools in the output + +link:#[back to top] + +[[api-cluster-allocationexplain-5-4]] +=== `cluster.allocationExplain` + +[source,js] +-------- +client.cluster.allocationExplain([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-allocation-explain.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`includeYesDecisions`:: +<> -- Return 'YES' decisions in explanation (default: false) +`includeDiskInfo`:: +<> -- Return information about disk usage and shard sizes (default: false) +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-allocation-explain.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-cluster-getsettings-5-4]] +=== `cluster.getSettings` + +[source,js] +-------- +client.cluster.getSettings([params, [callback]]) +-------- + +Get cluster settings (previously set with `putSettings()`) + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-update-settings.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`flatSettings`:: +<> -- Return settings in flat format (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`timeout`:: +<> -- Explicit operation timeout +`includeDefaults`:: +<> -- Whether to return all default clusters setting. + +link:#[back to top] + +[[api-cluster-health-5-4]] +=== `cluster.health` + +[source,js] +-------- +client.cluster.health([params, [callback]]) +-------- + +Get a very simple status on the health of the cluster. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-health.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`[level=cluster]`:: +<> -- Specify the level of detail for returned information +Options::: + * `"cluster"` + * `"indices"` + * `"shards"` + +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`timeout`:: +<> -- Explicit operation timeout +`waitForActiveShards`:: +<> -- Wait until the specified number of shards is active +`waitForNodes`:: +<> -- Wait until the specified number of nodes is available +`waitForEvents`:: +<> -- Wait until all currently queued events with the given priority are processed +Options::: + * `"immediate"` + * `"urgent"` + * `"high"` + * `"normal"` + * `"low"` + * `"languid"` + +`waitForNoRelocatingShards`:: +<> -- Whether to wait until there are no relocating shards in the cluster +`waitForStatus`:: +<> -- Wait until cluster is in a specific state +Options::: + * `"green"` + * `"yellow"` + * `"red"` + +`index`:: +<>, <>, <> -- Limit the information returned to a specific index + +link:#[back to top] + +[[api-cluster-pendingtasks-5-4]] +=== `cluster.pendingTasks` + +[source,js] +-------- +client.cluster.pendingTasks([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-pending.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Specify timeout for connection to master + +link:#[back to top] + +[[api-cluster-putsettings-5-4]] +=== `cluster.putSettings` + +[source,js] +-------- +client.cluster.putSettings([params, [callback]]) +-------- + +Update cluster wide specific settings. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-update-settings.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`flatSettings`:: +<> -- Return settings in flat format (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`timeout`:: +<> -- Explicit operation timeout +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-update-settings.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-cluster-reroute-5-4]] +=== `cluster.reroute` + +[source,js] +-------- +client.cluster.reroute([params, [callback]]) +-------- + +Explicitly execute a cluster reroute allocation command including specific commands. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-reroute.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`dryRun`:: +<> -- Simulate the operation only and return the resulting state +`explain`:: +<> -- Return an explanation of why the commands can or cannot be executed +`retryFailed`:: +<> -- Retries allocation of shards that are blocked due to too many subsequent allocation failures +`metric`:: +<>, <>, <> -- Limit the information returned to the specified metrics. Defaults to all but metadata +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`timeout`:: +<> -- Explicit operation timeout +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-reroute.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-cluster-state-5-4]] +=== `cluster.state` + +[source,js] +-------- +client.cluster.state([params, [callback]]) +-------- + +Get comprehensive details about the state of the whole cluster (indices settings, allocations, etc). + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-state.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`masterTimeout`:: +<> -- Specify timeout for connection to master +`flatSettings`:: +<> -- Return settings in flat format (default: false) +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +`metric`:: +<>, <>, <> -- Limit the information returned to the specified metrics + +link:#[back to top] + +[[api-cluster-stats-5-4]] +=== `cluster.stats` + +[source,js] +-------- +client.cluster.stats([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-stats.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`flatSettings`:: +<> -- Return settings in flat format (default: false) +`timeout`:: +<> -- Explicit operation timeout +`nodeId`:: +<>, <>, <> -- A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +link:#[back to top] + +[[api-indices-analyze-5-4]] +=== `indices.analyze` + +[source,js] +-------- +client.indices.analyze([params, [callback]]) +-------- + +Perform the analysis process on a text and return the tokens breakdown of the text. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-analyze.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`analyzer`:: +<> -- The name of the analyzer to use +`charFilter`:: +<>, <>, <> -- A comma-separated list of character filters to use for the analysis +`field`:: +<> -- Use the analyzer configured for this field (instead of passing the analyzer name) +`filter`:: +<>, <>, <> -- A comma-separated list of filters to use for the analysis +`index`:: +<> -- The name of the index to scope the operation +`preferLocal`:: +<> -- With `true`, specify that a local shard should be used if available, with `false`, use a random shard (default: true) +`text`:: +<>, <>, <> -- The text on which the analysis should be performed (when request body is not used) +`tokenizer`:: +<> -- The name of the tokenizer to use for the analysis +`explain`:: +<> -- With `true`, outputs more advanced details. (default: false) +`attributes`:: +<>, <>, <> -- A comma-separated list of token attributes to output, this parameter works only with `explain=true` +`[format=detailed]`:: +<> -- Format of the output +Options::: + * `"detailed"` + * `"text"` + +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-analyze.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-clearcache-5-4]] +=== `indices.clearCache` + +[source,js] +-------- +client.indices.clearCache([params, [callback]]) +-------- + +Clear either all caches or specific cached associated with one ore more indices. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-clearcache.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`fieldData`:: +<> -- Clear field data +`fielddata`:: +<> -- Clear field data +`fields`:: +<>, <>, <> -- A comma-separated list of fields to clear when using the `field_data` parameter (default: all) +`query`:: +<> -- Clear query caches +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`index`:: +<>, <>, <> -- A comma-separated list of index name to limit the operation +`recycler`:: +<> -- Clear the recycler cache +`requestCache`:: +<> -- Clear request cache +`request`:: +<> -- Clear request cache +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-clearcache.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-close-5-4]] +=== `indices.close` + +[source,js] +-------- +client.indices.close([params, [callback]]) +-------- + +Close an index to remove its overhead from the cluster. Closed index is blocked for read/write operations. + + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-open-close.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`timeout`:: +<> -- Explicit operation timeout +`masterTimeout`:: +<> -- Specify timeout for connection to master +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`index`:: +<>, <>, <> -- A comma separated list of indices to close +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-open-close.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-create-5-4]] +=== `indices.create` + +[source,js] +-------- +client.indices.create([params, [callback]]) +-------- + +Create an index in Elasticsearch. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-create-index.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`waitForActiveShards`:: +<> -- Set the number of active shards to wait for before the operation returns. +`timeout`:: +<> -- Explicit operation timeout +`masterTimeout`:: +<> -- Specify timeout for connection to master +`updateAllTypes`:: +<> -- Whether to update the mapping for all fields with the same name across all types or not +`index`:: +<> -- The name of the index +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-create-index.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-delete-5-4]] +=== `indices.delete` + +[source,js] +-------- +client.indices.delete([params, [callback]]) +-------- + +Delete an index in Elasticsearch + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-delete-index.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`timeout`:: +<> -- Explicit operation timeout +`masterTimeout`:: +<> -- Specify timeout for connection to master +`index`:: +<>, <>, <> -- A comma-separated list of indices to delete; use `_all` or `*` string to delete all indices +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-delete-index.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-deletealias-5-4]] +=== `indices.deleteAlias` + +[source,js] +-------- +client.indices.deleteAlias([params, [callback]]) +-------- + +Delete a specific alias. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`timeout`:: +<> -- Explicit timestamp for the document +`masterTimeout`:: +<> -- Specify timeout for connection to master +`index`:: +<>, <>, <> -- A comma-separated list of index names (supports wildcards); use `_all` for all indices +`name`:: +<>, <>, <> -- A comma-separated list of aliases to delete (supports wildcards); use `_all` to delete all aliases for the specified indices. +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-deletetemplate-5-4]] +=== `indices.deleteTemplate` + +[source,js] +-------- +client.indices.deleteTemplate([params, [callback]]) +-------- + +Delete an index template by its name. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`timeout`:: +<> -- Explicit operation timeout +`masterTimeout`:: +<> -- Specify timeout for connection to master +`name`:: +<> -- The name of the template +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-exists-5-4]] +=== `indices.exists` + +[source,js] +-------- +client.indices.exists([params, [callback]]) +-------- + +Return a boolean indicating whether given index exists. + +Check the *<>* and http://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-exists.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`ignoreUnavailable`:: +<> -- Ignore unavailable indexes (default: false) +`allowNoIndices`:: +<> -- Ignore if a wildcard expression resolves to no concrete indices (default: false) +`[expandWildcards=open]`:: +<> -- Whether wildcard expressions should get expanded to open or closed indices (default: open) +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`flatSettings`:: +<> -- Return settings in flat format (default: false) +`includeDefaults`:: +<> -- Whether to return all default setting for each of the indices. +`index`:: +<>, <>, <> -- A comma-separated list of index names +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See http://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-exists.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-existsalias-5-4]] +=== `indices.existsAlias` + +[source,js] +-------- +client.indices.existsAlias([params, [callback]]) +-------- + +Return a boolean indicating whether given alias exists. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=all]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`index`:: +<>, <>, <> -- A comma-separated list of index names to filter aliases +`name`:: +<>, <>, <> -- A comma-separated list of alias names to return +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-existstemplate-5-4]] +=== `indices.existsTemplate` + +[source,js] +-------- +client.indices.existsTemplate([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`flatSettings`:: +<> -- Return settings in flat format (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`name`:: +<>, <>, <> -- The comma separated names of the index templates +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-existstype-5-4]] +=== `indices.existsType` + +[source,js] +-------- +client.indices.existsType([params, [callback]]) +-------- + +Check if a type/types exists in an index/indices. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-types-exists.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` to check the types across all indices +`type`:: +<>, <>, <> -- A comma-separated list of document types to check +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-types-exists.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-flush-5-4]] +=== `indices.flush` + +[source,js] +-------- +client.indices.flush([params, [callback]]) +-------- + +Explicitly flush one or more indices. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-flush.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`force`:: +<> -- Whether a flush should be forced even if it is not necessarily needed ie. if no changes will be committed to the index. This is useful if transaction log IDs should be incremented even if no uncommitted changes are present. (This setting can be considered as internal) +`waitIfOngoing`:: +<> -- If set to true the flush operation will block until the flush can be executed if another flush operation is already executing. The default is true. If set to false the flush will be skipped iff if another flush operation is already running. +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string for all indices +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-flush.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-flushsynced-5-4]] +=== `indices.flushSynced` + +[source,js] +-------- +client.indices.flushSynced([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-synced-flush.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string for all indices +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-synced-flush.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-forcemerge-5-4]] +=== `indices.forcemerge` + +[source,js] +-------- +client.indices.forcemerge([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-forcemerge.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`flush`:: +<> -- Specify whether the index should be flushed after performing the operation (default: true) +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`maxNumSegments`:: +<> -- The number of segments the index should be merged into (default: dynamic) +`onlyExpungeDeletes`:: +<> -- Specify whether the operation should only expunge deleted documents +`operationThreading`:: +anything -- TODO: ? +`waitForMerge`:: +<> -- Specify whether the request should block until the merge process is finished (default: true) +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-forcemerge.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-get-5-4]] +=== `indices.get` + +[source,js] +-------- +client.indices.get([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-get-index.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`ignoreUnavailable`:: +<> -- Ignore unavailable indexes (default: false) +`allowNoIndices`:: +<> -- Ignore if a wildcard expression resolves to no concrete indices (default: false) +`[expandWildcards=open]`:: +<> -- Whether wildcard expressions should get expanded to open or closed indices (default: open) +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`flatSettings`:: +<> -- Return settings in flat format (default: false) +`includeDefaults`:: +<> -- Whether to return all default setting for each of the indices. +`index`:: +<>, <>, <> -- A comma-separated list of index names +`feature`:: +<>, <>, <> -- A comma-separated list of features + +link:#[back to top] + +[[api-indices-getalias-5-4]] +=== `indices.getAlias` + +[source,js] +-------- +client.indices.getAlias([params, [callback]]) +-------- + +Retrieve a specified alias. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=all]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`index`:: +<>, <>, <> -- A comma-separated list of index names to filter aliases +`name`:: +<>, <>, <> -- A comma-separated list of alias names to return + +link:#[back to top] + +[[api-indices-getfieldmapping-5-4]] +=== `indices.getFieldMapping` + +[source,js] +-------- +client.indices.getFieldMapping([params, [callback]]) +-------- + +Retrieve mapping definition of a specific field. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-get-field-mapping.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`includeDefaults`:: +<> -- Whether the default mapping values should be returned as well +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`index`:: +<>, <>, <> -- A comma-separated list of index names +`type`:: +<>, <>, <> -- A comma-separated list of document types +`fields`:: +<>, <>, <> -- A comma-separated list of fields + +link:#[back to top] + +[[api-indices-getmapping-5-4]] +=== `indices.getMapping` + +[source,js] +-------- +client.indices.getMapping([params, [callback]]) +-------- + +Retrieve mapping definition of index or index/type. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-get-mapping.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`index`:: +<>, <>, <> -- A comma-separated list of index names +`type`:: +<>, <>, <> -- A comma-separated list of document types + +link:#[back to top] + +[[api-indices-getsettings-5-4]] +=== `indices.getSettings` + +[source,js] +-------- +client.indices.getSettings([params, [callback]]) +-------- + +Retrieve settings for one or more (or all) indices. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-get-settings.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open,closed]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`flatSettings`:: +<> -- Return settings in flat format (default: false) +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`includeDefaults`:: +<> -- Whether to return all default setting for each of the indices. +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +`name`:: +<>, <>, <> -- The name of the settings that should be included + +link:#[back to top] + +[[api-indices-gettemplate-5-4]] +=== `indices.getTemplate` + +[source,js] +-------- +client.indices.getTemplate([params, [callback]]) +-------- + +Retrieve an index template by its name. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`flatSettings`:: +<> -- Return settings in flat format (default: false) +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`name`:: +<>, <>, <> -- The comma separated names of the index templates + +link:#[back to top] + +[[api-indices-getupgrade-5-4]] +=== `indices.getUpgrade` + +[source,js] +-------- +client.indices.getUpgrade([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-upgrade.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + +link:#[back to top] + +[[api-indices-open-5-4]] +=== `indices.open` + +[source,js] +-------- +client.indices.open([params, [callback]]) +-------- + +Open a closed index, making it available for search. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-open-close.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`timeout`:: +<> -- Explicit operation timeout +`masterTimeout`:: +<> -- Specify timeout for connection to master +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=closed]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`index`:: +<>, <>, <> -- A comma separated list of indices to open +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-open-close.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-putalias-5-4]] +=== `indices.putAlias` + +[source,js] +-------- +client.indices.putAlias([params, [callback]]) +-------- + +Create an alias for a specific index/indices. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`timeout`:: +<> -- Explicit timestamp for the document +`masterTimeout`:: +<> -- Specify timeout for connection to master +`index`:: +<>, <>, <> -- A comma-separated list of index names the alias should point to (supports wildcards); use `_all` to perform the operation on all indices. +`name`:: +<> -- The name of the alias to be created or updated +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-putmapping-5-4]] +=== `indices.putMapping` + +[source,js] +-------- +client.indices.putMapping([params, [callback]]) +-------- + +Register specific mapping definition for a specific type. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-put-mapping.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`timeout`:: +<> -- Explicit operation timeout +`masterTimeout`:: +<> -- Specify timeout for connection to master +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`updateAllTypes`:: +<> -- Whether to update the mapping for all fields with the same name across all types or not +`index`:: +<>, <>, <> -- A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. +`type`:: +<> -- The name of the document type +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-put-mapping.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-putsettings-5-4]] +=== `indices.putSettings` + +[source,js] +-------- +client.indices.putSettings([params, [callback]]) +-------- + +Change specific index level settings in real time. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-update-settings.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Specify timeout for connection to master +`preserveExisting`:: +<> -- Whether to update existing settings. If set to `true` existing settings on an index remain unchanged, the default is `false` +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`flatSettings`:: +<> -- Return settings in flat format (default: false) +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-update-settings.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-puttemplate-5-4]] +=== `indices.putTemplate` + +[source,js] +-------- +client.indices.putTemplate([params, [callback]]) +-------- + +Create an index template that will automatically be applied to new indices created. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`order`:: +<> -- The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers) +`create`:: +<> -- Whether the index template should only be added if new or can also replace an existing one +`timeout`:: +<> -- Explicit operation timeout +`masterTimeout`:: +<> -- Specify timeout for connection to master +`flatSettings`:: +<> -- Return settings in flat format (default: false) +`name`:: +<> -- The name of the template +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-recovery-5-4]] +=== `indices.recovery` + +[source,js] +-------- +client.indices.recovery([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-recovery.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`detailed`:: +<> -- Whether to display detailed information about shard recovery +`activeOnly`:: +<> -- Display only those recoveries that are currently on-going +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + +link:#[back to top] + +[[api-indices-refresh-5-4]] +=== `indices.refresh` + +[source,js] +-------- +client.indices.refresh([params, [callback]]) +-------- + +Explicitly refresh one or more index, making all operations performed since the last refresh available for search. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-refresh.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`force`:: +<> -- Force a refresh even if not required +`operationThreading`:: +anything -- TODO: ? +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-refresh.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-rollover-5-4]] +=== `indices.rollover` + +[source,js] +-------- +client.indices.rollover([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-rollover-index.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`timeout`:: +<> -- Explicit operation timeout +`dryRun`:: +<> -- If set to true the rollover action will only be validated but not actually performed even if a condition matches. The default is false +`masterTimeout`:: +<> -- Specify timeout for connection to master +`waitForActiveShards`:: +<> -- Set the number of active shards to wait for on the newly created rollover index before the operation returns. +`alias`:: +<> -- The name of the alias to rollover +`newIndex`:: +<> -- The name of the rollover index +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-rollover-index.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-segments-5-4]] +=== `indices.segments` + +[source,js] +-------- +client.indices.segments([params, [callback]]) +-------- + +Retrieve low level segments information that a Lucene index (shard level) is built with. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-segments.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`operationThreading`:: +anything -- TODO: ? +`verbose`:: +<> -- Includes detailed memory usage by Lucene. +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + +link:#[back to top] + +[[api-indices-shardstores-5-4]] +=== `indices.shardStores` + +[source,js] +-------- +client.indices.shardStores([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-shards-stores.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`status`:: +<>, <>, <> -- A comma-separated list of statuses used to filter on shards to get store information for +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`operationThreading`:: +anything -- TODO: ? +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + +link:#[back to top] + +[[api-indices-shrink-5-4]] +=== `indices.shrink` + +[source,js] +-------- +client.indices.shrink([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-shrink-index.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`timeout`:: +<> -- Explicit operation timeout +`masterTimeout`:: +<> -- Specify timeout for connection to master +`waitForActiveShards`:: +<> -- Set the number of active shards to wait for on the shrunken index before the operation returns. +`index`:: +<> -- The name of the source index to shrink +`target`:: +<> -- The name of the target index to shrink into +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-shrink-index.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-stats-5-4]] +=== `indices.stats` + +[source,js] +-------- +client.indices.stats([params, [callback]]) +-------- + +Retrieve statistics on different operations happening on an index. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-stats.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`completionFields`:: +<>, <>, <> -- A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards) +`fielddataFields`:: +<>, <>, <> -- A comma-separated list of fields for `fielddata` index metric (supports wildcards) +`fields`:: +<>, <>, <> -- A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) +`groups`:: +<>, <>, <> -- A comma-separated list of search groups for `search` index metric +`[level=indices]`:: +<> -- Return stats aggregated at cluster, index or shard level +Options::: + * `"cluster"` + * `"indices"` + * `"shards"` + +`types`:: +<>, <>, <> -- A comma-separated list of document types for the `indexing` index metric +`includeSegmentFileSizes`:: +<> -- Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +`metric`:: +<>, <>, <> -- Limit the information returned the specific metrics. + +link:#[back to top] + +[[api-indices-updatealiases-5-4]] +=== `indices.updateAliases` + +[source,js] +-------- +client.indices.updateAliases([params, [callback]]) +-------- + +Update specified aliases. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html[the elasticsearch docs] for more information pertaining to this method. + +.Perform an atomic alias swap, for a rotating index +[source,js] +--------- +client.indices.updateAliases({ + body: { + actions: [ + { remove: { index: 'logstash-2014.04', alias: 'logstash-current' } }, + { add: { index: 'logstash-2014.05', alias: 'logstash-current' } } + ] + } +}).then(function (response) { + // ... +}, errorHandler); +--------- + + +*Params* + +[horizontal] +`timeout`:: +<> -- Request timeout +`masterTimeout`:: +<> -- Specify timeout for connection to master +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-upgrade-5-4]] +=== `indices.upgrade` + +[source,js] +-------- +client.indices.upgrade([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-upgrade.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`waitForCompletion`:: +<> -- Specify whether the request should block until the all segments are upgraded (default: false) +`onlyAncientSegments`:: +<> -- If true, only ancient (an older Lucene major release) segments will be upgraded +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-upgrade.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-indices-validatequery-5-4]] +=== `indices.validateQuery` + +[source,js] +-------- +client.indices.validateQuery([params, [callback]]) +-------- + +Validate a potentially expensive query without executing it. + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-validate.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`explain`:: +<> -- Return detailed information about the error +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`operationThreading`:: +anything -- TODO: ? +`q`:: +<> -- Query in the Lucene query string syntax +`analyzer`:: +<> -- The analyzer to use for the query string +`analyzeWildcard`:: +<> -- Specify whether wildcard and prefix queries should be analyzed (default: false) +`[defaultOperator=OR]`:: +<> -- The default operator for query string query (AND or OR) +Options::: + * `"AND"` + * `"OR"` + +`df`:: +<> -- The field to use as default where no field prefix is given in the query string +`lenient`:: +<> -- Specify whether format-based query failures (such as providing text to a numeric field) should be ignored +`rewrite`:: +<> -- Provide a more detailed explanation showing the actual Lucene query that will be executed. +`allShards`:: +<> -- Execute validation on all shards instead of one random shard per index +`index`:: +<>, <>, <> -- A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices +`type`:: +<>, <>, <> -- A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-validate.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-ingest-deletepipeline-5-4]] +=== `ingest.deletePipeline` + +[source,js] +-------- +client.ingest.deletePipeline([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/plugins/5.x/ingest.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`timeout`:: +<> -- Explicit operation timeout +`id`:: +<> -- Pipeline ID +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/plugins/5.x/ingest.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-ingest-getpipeline-5-4]] +=== `ingest.getPipeline` + +[source,js] +-------- +client.ingest.getPipeline([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/plugins/5.x/ingest.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`id`:: +<> -- Comma separated list of pipeline ids. Wildcards supported + +link:#[back to top] + +[[api-ingest-putpipeline-5-4]] +=== `ingest.putPipeline` + +[source,js] +-------- +client.ingest.putPipeline([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/plugins/5.x/ingest.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`timeout`:: +<> -- Explicit operation timeout +`id`:: +<> -- Pipeline ID +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/plugins/5.x/ingest.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-ingest-simulate-5-4]] +=== `ingest.simulate` + +[source,js] +-------- +client.ingest.simulate([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/plugins/5.x/ingest.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`verbose`:: +<> -- Verbose mode. Display data output for each processor in executed pipeline +`id`:: +<> -- Pipeline ID +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/plugins/5.x/ingest.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-nodes-hotthreads-5-4]] +=== `nodes.hotThreads` + +[source,js] +-------- +client.nodes.hotThreads([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-nodes-hot-threads.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`interval`:: +<> -- The interval for the second sampling of threads +`snapshots`:: +<> -- Number of samples of thread stacktrace (default: 10) +`threads`:: +<> -- Specify the number of threads to provide information for (default: 3) +`ignoreIdleThreads`:: +<> -- Don't show threads that are in known-idle places, such as waiting on a socket select or pulling from an empty task queue (default: true) +`type`:: +<> -- The type to sample (default: cpu) +Options::: + * `"cpu"` + * `"wait"` + * `"block"` + +`timeout`:: +<> -- Explicit operation timeout +`nodeId`:: +<>, <>, <> -- A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +link:#[back to top] + +[[api-nodes-info-5-4]] +=== `nodes.info` + +[source,js] +-------- +client.nodes.info([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-nodes-info.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`flatSettings`:: +<> -- Return settings in flat format (default: false) +`timeout`:: +<> -- Explicit operation timeout +`nodeId`:: +<>, <>, <> -- A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes +`metric`:: +<>, <>, <> -- A comma-separated list of metrics you wish returned. Leave empty to return all. + +link:#[back to top] + +[[api-nodes-stats-5-4]] +=== `nodes.stats` + +[source,js] +-------- +client.nodes.stats([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-nodes-stats.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`completionFields`:: +<>, <>, <> -- A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards) +`fielddataFields`:: +<>, <>, <> -- A comma-separated list of fields for `fielddata` index metric (supports wildcards) +`fields`:: +<>, <>, <> -- A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) +`groups`:: +<> -- A comma-separated list of search groups for `search` index metric +`[level=node]`:: +<> -- Return indices stats aggregated at index, node or shard level +Options::: + * `"indices"` + * `"node"` + * `"shards"` + +`types`:: +<>, <>, <> -- A comma-separated list of document types for the `indexing` index metric +`timeout`:: +<> -- Explicit operation timeout +`includeSegmentFileSizes`:: +<> -- Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) +`metric`:: +<>, <>, <> -- Limit the information returned to the specified metrics +`indexMetric`:: +<>, <>, <> -- Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified. +`nodeId`:: +<>, <>, <> -- A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +link:#[back to top] + +[[api-remote-info-5-4]] +=== `remote.info` + +[source,js] +-------- +client.remote.info([params, [callback]]) +-------- + +// no description + +Check the *<>* and http://www.elastic.co/guide/en/elasticsearch/reference/master/remote-info.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + + +[[api-snapshot-create-5-4]] +=== `snapshot.create` + +[source,js] +-------- +client.snapshot.create([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`waitForCompletion`:: +<> -- Should this request wait until the operation has completed before returning +`repository`:: +<> -- A repository name +`snapshot`:: +<> -- A snapshot name +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-snapshot-createrepository-5-4]] +=== `snapshot.createRepository` + +[source,js] +-------- +client.snapshot.createRepository([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`timeout`:: +<> -- Explicit operation timeout +`verify`:: +<> -- Whether to verify the repository after creation +`repository`:: +<> -- A repository name +`body`:: +<>, <> -- The request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-snapshot-delete-5-4]] +=== `snapshot.delete` + +[source,js] +-------- +client.snapshot.delete([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`repository`:: +<> -- A repository name +`snapshot`:: +<> -- A snapshot name +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-snapshot-deleterepository-5-4]] +=== `snapshot.deleteRepository` + +[source,js] +-------- +client.snapshot.deleteRepository([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`timeout`:: +<> -- Explicit operation timeout +`repository`:: +<>, <>, <> -- A comma-separated list of repository names +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-snapshot-get-5-4]] +=== `snapshot.get` + +[source,js] +-------- +client.snapshot.get([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`ignoreUnavailable`:: +<> -- Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown +`repository`:: +<> -- A repository name +`snapshot`:: +<>, <>, <> -- A comma-separated list of snapshot names + +link:#[back to top] + +[[api-snapshot-getrepository-5-4]] +=== `snapshot.getRepository` + +[source,js] +-------- +client.snapshot.getRepository([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) +`repository`:: +<>, <>, <> -- A comma-separated list of repository names + +link:#[back to top] + +[[api-snapshot-restore-5-4]] +=== `snapshot.restore` + +[source,js] +-------- +client.snapshot.restore([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`waitForCompletion`:: +<> -- Should this request wait until the operation has completed before returning +`repository`:: +<> -- A repository name +`snapshot`:: +<> -- A snapshot name +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-snapshot-status-5-4]] +=== `snapshot.status` + +[source,js] +-------- +client.snapshot.status([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`ignoreUnavailable`:: +<> -- Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown +`repository`:: +<> -- A repository name +`snapshot`:: +<>, <>, <> -- A comma-separated list of snapshot names + +link:#[back to top] + +[[api-snapshot-verifyrepository-5-4]] +=== `snapshot.verifyRepository` + +[source,js] +-------- +client.snapshot.verifyRepository([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`masterTimeout`:: +<> -- Explicit operation timeout for connection to master node +`timeout`:: +<> -- Explicit operation timeout +`repository`:: +<> -- A repository name +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-tasks-cancel-5-4]] +=== `tasks.cancel` + +[source,js] +-------- +client.tasks.cancel([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/tasks.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`nodeId`:: +<>, <>, <> -- A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes +`actions`:: +<>, <>, <> -- A comma-separated list of actions that should be cancelled. Leave empty to cancel all. +`parentNode`:: +<> -- Cancel tasks with specified parent node. +`parentTask`:: +<> -- Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all. +`taskId`:: +<> -- Cancel the task with specified task id (node_id:task_number) +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/tasks.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + +[[api-tasks-get-5-4]] +=== `tasks.get` + +[source,js] +-------- +client.tasks.get([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/tasks.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`waitForCompletion`:: +<> -- Wait for the matching tasks to complete (default: false) +`taskId`:: +<> -- Return the task with specified id (node_id:task_number) + +link:#[back to top] + +[[api-tasks-list-5-4]] +=== `tasks.list` + +[source,js] +-------- +client.tasks.list([params, [callback]]) +-------- + +// no description + +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/tasks.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`nodeId`:: +<>, <>, <> -- A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes +`actions`:: +<>, <>, <> -- A comma-separated list of actions that should be returned. Leave empty to return all. +`detailed`:: +<> -- Return detailed task information (default: false) +`parentNode`:: +<> -- Return tasks with specified parent node. +`parentTask`:: +<> -- Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all. +`waitForCompletion`:: +<> -- Wait for the matching tasks to complete (default: false) +`[groupBy=nodes]`:: +<> -- Group tasks by nodes or parent/child relationships +Options::: + * `"nodes"` + * `"parents"` + + +link:#[back to top] diff --git a/docs/configuration.asciidoc b/docs/configuration.asciidoc index 368559c87..2c62d9c28 100644 --- a/docs/configuration.asciidoc +++ b/docs/configuration.asciidoc @@ -55,6 +55,7 @@ WARNING: This default will track the latest version of Elasticsearch, and is onl Default ::: `'5.3'` Options in node ::: + * `'5.4'` * `'5.3'` * `'5.2'` * `'5.1'` @@ -63,17 +64,17 @@ Options in node ::: * `'1.7'` * `'0.90'` * `'5.x'` (unstable) - * `'5.4'` (unstable) + * `'5.5'` (unstable) * `'master'` (unstable) Options in the browser ::: + * `'5.4'` * `'5.3'` * `'5.2'` * `'5.1'` * `'5.0'` - * `'2.4'` * `'5.x'` (unstable) - * `'5.4'` (unstable) + * `'5.5'` (unstable) * `'master'` (unstable) diff --git a/docs/index.asciidoc b/docs/index.asciidoc index d4c6785fa..c0c83da5a 100644 --- a/docs/index.asciidoc +++ b/docs/index.asciidoc @@ -20,6 +20,8 @@ include::logging.asciidoc[] include::development.asciidoc[] +include::api_methods_5_4.asciidoc[] + include::api_methods.asciidoc[] include::api_methods_5_2.asciidoc[] diff --git a/src/lib/apis/5_5.js b/src/lib/apis/5_5.js new file mode 100644 index 000000000..b787581c5 --- /dev/null +++ b/src/lib/apis/5_5.js @@ -0,0 +1,7368 @@ +var ca = require('../client_action').makeFactoryWithModifier(function (spec) { + return require('../utils').merge(spec, { + params: { + filterPath: { + type: 'list', + name: 'filter_path' + } + } + }); +}); +var namespace = require('../client_action').namespaceFactory; +var api = module.exports = {}; + +api._namespaces = ['cat', 'cluster', 'indices', 'ingest', 'nodes', 'remote', 'snapshot', 'tasks']; + +/** + * Perform a [bulk](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-bulk.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {<>} params.refresh - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + * @param {<>} params.routing - Specific routing value + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.type - Default document type for items which don't provide one + * @param {<>, <>, <>} params.fields - Default comma-separated list of fields to return in the response for updates, can be overridden on each sub-request + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request + * @param {<>, <>, <>} params._sourceExclude - Default list of fields to exclude from the returned _source field, can be overridden on each sub-request + * @param {<>, <>, <>} params._sourceInclude - Default list of fields to extract and return from the _source field, can be overridden on each sub-request + * @param {<>} params.pipeline - The pipeline id to preprocess incoming documents with + * @param {<>} params.index - Default index for items which don't provide one + */ +api.bulk = ca({ + params: { + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + }, + refresh: { + type: 'enum', + options: [ + 'true', + 'false', + 'wait_for', + '' + ] + }, + routing: { + type: 'string' + }, + timeout: { + type: 'time' + }, + type: { + type: 'string' + }, + fields: { + type: 'list' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + }, + pipeline: { + type: 'string' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_bulk', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + } + } + }, + { + fmt: '/<%=index%>/_bulk', + req: { + index: { + type: 'string' + } + } + }, + { + fmt: '/_bulk' + } + ], + needBody: true, + bulkBody: true, + method: 'POST' +}); + +api.cat = namespace(); + +/** + * Perform a [cat.aliases](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + * @param {<>, <>, <>} params.name - A comma-separated list of alias names to return + */ +api.cat.prototype.aliases = ca({ + params: { + format: { + type: 'string' + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/_cat/aliases/<%=name%>', + req: { + name: { + type: 'list' + } + } + }, + { + fmt: '/_cat/aliases' + } + ] +}); + +/** + * Perform a [cat.allocation](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-allocation.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.bytes - The unit in which to display byte values + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + * @param {<>, <>, <>} params.nodeId - A comma-separated list of node IDs or names to limit the returned information + */ +api.cat.prototype.allocation = ca({ + params: { + format: { + type: 'string' + }, + bytes: { + type: 'enum', + options: [ + 'b', + 'k', + 'kb', + 'm', + 'mb', + 'g', + 'gb', + 't', + 'tb', + 'p', + 'pb' + ] + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/_cat/allocation/<%=nodeId%>', + req: { + nodeId: { + type: 'list' + } + } + }, + { + fmt: '/_cat/allocation' + } + ] +}); + +/** + * Perform a [cat.count](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-count.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + * @param {<>, <>, <>} params.index - A comma-separated list of index names to limit the returned information + */ +api.cat.prototype.count = ca({ + params: { + format: { + type: 'string' + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/_cat/count/<%=index%>', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_cat/count' + } + ] +}); + +/** + * Perform a [cat.fielddata](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-fielddata.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.bytes - The unit in which to display byte values + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + * @param {<>, <>, <>} params.fields - A comma-separated list of fields to return the fielddata size + */ +api.cat.prototype.fielddata = ca({ + params: { + format: { + type: 'string' + }, + bytes: { + type: 'enum', + options: [ + 'b', + 'k', + 'kb', + 'm', + 'mb', + 'g', + 'gb', + 't', + 'tb', + 'p', + 'pb' + ] + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + }, + fields: { + type: 'list' + } + }, + urls: [ + { + fmt: '/_cat/fielddata/<%=fields%>', + req: { + fields: { + type: 'list' + } + } + }, + { + fmt: '/_cat/fielddata' + } + ] +}); + +/** + * Perform a [cat.health](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-health.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} [params.ts=true] - Set to false to disable timestamping + * @param {<>} params.v - Verbose mode. Display column headers + */ +api.cat.prototype.health = ca({ + params: { + format: { + type: 'string' + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + ts: { + type: 'boolean', + 'default': true + }, + v: { + type: 'boolean', + 'default': false + } + }, + url: { + fmt: '/_cat/health' + } +}); + +/** + * Perform a [cat.help](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + */ +api.cat.prototype.help = ca({ + params: { + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + } + }, + url: { + fmt: '/_cat' + } +}); + +/** + * Perform a [cat.indices](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-indices.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.bytes - The unit in which to display byte values + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.health - A health status ("green", "yellow", or "red" to filter only indices matching the specified health status + * @param {<>} params.help - Return help information + * @param {<>} params.pri - Set to true to return stats only for primary shards + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + * @param {<>, <>, <>} params.index - A comma-separated list of index names to limit the returned information + */ +api.cat.prototype.indices = ca({ + params: { + format: { + type: 'string' + }, + bytes: { + type: 'enum', + options: [ + 'b', + 'k', + 'm', + 'g' + ] + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + health: { + type: 'enum', + 'default': null, + options: [ + 'green', + 'yellow', + 'red' + ] + }, + help: { + type: 'boolean', + 'default': false + }, + pri: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/_cat/indices/<%=index%>', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_cat/indices' + } + ] +}); + +/** + * Perform a [cat.master](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-master.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + */ +api.cat.prototype.master = ca({ + params: { + format: { + type: 'string' + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + url: { + fmt: '/_cat/master' + } +}); + +/** + * Perform a [cat.nodeattrs](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-nodeattrs.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + */ +api.cat.prototype.nodeattrs = ca({ + params: { + format: { + type: 'string' + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + url: { + fmt: '/_cat/nodeattrs' + } +}); + +/** + * Perform a [cat.nodes](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-nodes.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.fullId - Return the full node ID instead of the shortened version (default: false) + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + */ +api.cat.prototype.nodes = ca({ + params: { + format: { + type: 'string' + }, + fullId: { + type: 'boolean', + name: 'full_id' + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + url: { + fmt: '/_cat/nodes' + } +}); + +/** + * Perform a [cat.pendingTasks](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-pending-tasks.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + */ +api.cat.prototype.pendingTasks = ca({ + params: { + format: { + type: 'string' + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + url: { + fmt: '/_cat/pending_tasks' + } +}); + +/** + * Perform a [cat.plugins](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-plugins.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + */ +api.cat.prototype.plugins = ca({ + params: { + format: { + type: 'string' + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + url: { + fmt: '/_cat/plugins' + } +}); + +/** + * Perform a [cat.recovery](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-recovery.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.bytes - The unit in which to display byte values + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + * @param {<>, <>, <>} params.index - A comma-separated list of index names to limit the returned information + */ +api.cat.prototype.recovery = ca({ + params: { + format: { + type: 'string' + }, + bytes: { + type: 'enum', + options: [ + 'b', + 'k', + 'kb', + 'm', + 'mb', + 'g', + 'gb', + 't', + 'tb', + 'p', + 'pb' + ] + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/_cat/recovery/<%=index%>', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_cat/recovery' + } + ] +}); + +/** + * Perform a [cat.repositories](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-repositories.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.local - Return local information, do not retrieve the state from master node + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + */ +api.cat.prototype.repositories = ca({ + params: { + format: { + type: 'string' + }, + local: { + type: 'boolean', + 'default': false + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + url: { + fmt: '/_cat/repositories' + } +}); + +/** + * Perform a [cat.segments](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-segments.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + * @param {<>, <>, <>} params.index - A comma-separated list of index names to limit the returned information + */ +api.cat.prototype.segments = ca({ + params: { + format: { + type: 'string' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/_cat/segments/<%=index%>', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_cat/segments' + } + ] +}); + +/** + * Perform a [cat.shards](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-shards.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + * @param {<>, <>, <>} params.index - A comma-separated list of index names to limit the returned information + */ +api.cat.prototype.shards = ca({ + params: { + format: { + type: 'string' + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/_cat/shards/<%=index%>', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_cat/shards' + } + ] +}); + +/** + * Perform a [cat.snapshots](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-snapshots.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.ignoreUnavailable - Set to true to ignore unavailable snapshots + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + * @param {<>, <>, <>} params.repository - Name of repository from which to fetch the snapshot information + */ +api.cat.prototype.snapshots = ca({ + params: { + format: { + type: 'string' + }, + ignoreUnavailable: { + type: 'boolean', + 'default': false, + name: 'ignore_unavailable' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/_cat/snapshots/<%=repository%>', + req: { + repository: { + type: 'list' + } + } + }, + { + fmt: '/_cat/snapshots' + } + ] +}); + +/** + * Perform a [cat.tasks](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/tasks.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>, <>, <>} params.nodeId - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * @param {<>, <>, <>} params.actions - A comma-separated list of actions that should be returned. Leave empty to return all. + * @param {<>} params.detailed - Return detailed task information (default: false) + * @param {<>} params.parentNode - Return tasks with specified parent node. + * @param {<>} params.parentTask - Return tasks with specified parent task id. Set to -1 to return all. + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + */ +api.cat.prototype.tasks = ca({ + params: { + format: { + type: 'string' + }, + nodeId: { + type: 'list', + name: 'node_id' + }, + actions: { + type: 'list' + }, + detailed: { + type: 'boolean' + }, + parentNode: { + type: 'string', + name: 'parent_node' + }, + parentTask: { + type: 'number', + name: 'parent_task' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + url: { + fmt: '/_cat/tasks' + } +}); + +/** + * Perform a [cat.templates](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-templates.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + * @param {<>} params.name - A pattern that returned template names must match + */ +api.cat.prototype.templates = ca({ + params: { + format: { + type: 'string' + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/_cat/templates/<%=name%>', + req: { + name: { + type: 'string' + } + } + }, + { + fmt: '/_cat/templates' + } + ] +}); + +/** + * Perform a [cat.threadPool](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cat-thread-pool.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.format - a short version of the Accept header, e.g. json, yaml + * @param {<>} params.size - The multiplier in which to display values + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>, <>, <>} params.h - Comma-separated list of column names to display + * @param {<>} params.help - Return help information + * @param {<>, <>, <>} params.s - Comma-separated list of column names or column aliases to sort by + * @param {<>} params.v - Verbose mode. Display column headers + * @param {<>, <>, <>} params.threadPoolPatterns - A comma-separated list of regular-expressions to filter the thread pools in the output + */ +api.cat.prototype.threadPool = ca({ + params: { + format: { + type: 'string' + }, + size: { + type: 'enum', + options: [ + '', + 'k', + 'm', + 'g', + 't', + 'p' + ] + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + h: { + type: 'list' + }, + help: { + type: 'boolean', + 'default': false + }, + s: { + type: 'list' + }, + v: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/_cat/thread_pool/<%=threadPoolPatterns%>', + req: { + threadPoolPatterns: { + type: 'list' + } + } + }, + { + fmt: '/_cat/thread_pool' + } + ] +}); + +/** + * Perform a [clearScroll](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-request-scroll.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.scrollId - A comma-separated list of scroll IDs to clear + */ +api.clearScroll = ca({ + urls: [ + { + fmt: '/_search/scroll/<%=scrollId%>', + req: { + scrollId: { + type: 'list' + } + } + }, + { + fmt: '/_search/scroll' + } + ], + paramAsBody: { + param: 'scrollId', + body: 'scroll_id' + }, + method: 'DELETE' +}); + +api.cluster = namespace(); + +/** + * Perform a [cluster.allocationExplain](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-allocation-explain.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.includeYesDecisions - Return 'YES' decisions in explanation (default: false) + * @param {<>} params.includeDiskInfo - Return information about disk usage and shard sizes (default: false) + */ +api.cluster.prototype.allocationExplain = ca({ + params: { + includeYesDecisions: { + type: 'boolean', + name: 'include_yes_decisions' + }, + includeDiskInfo: { + type: 'boolean', + name: 'include_disk_info' + } + }, + url: { + fmt: '/_cluster/allocation/explain' + }, + method: 'POST' +}); + +/** + * Perform a [cluster.getSettings](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-update-settings.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.includeDefaults - Whether to return all default clusters setting. + */ +api.cluster.prototype.getSettings = ca({ + params: { + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + timeout: { + type: 'time' + }, + includeDefaults: { + type: 'boolean', + 'default': false, + name: 'include_defaults' + } + }, + url: { + fmt: '/_cluster/settings' + } +}); + +/** + * Perform a [cluster.health](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-health.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} [params.level=cluster] - Specify the level of detail for returned information + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.waitForActiveShards - Wait until the specified number of shards is active + * @param {<>} params.waitForNodes - Wait until the specified number of nodes is available + * @param {<>} params.waitForEvents - Wait until all currently queued events with the given priority are processed + * @param {<>} params.waitForNoRelocatingShards - Whether to wait until there are no relocating shards in the cluster + * @param {<>} params.waitForStatus - Wait until cluster is in a specific state + * @param {<>, <>, <>} params.index - Limit the information returned to a specific index + */ +api.cluster.prototype.health = ca({ + params: { + level: { + type: 'enum', + 'default': 'cluster', + options: [ + 'cluster', + 'indices', + 'shards' + ] + }, + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + timeout: { + type: 'time' + }, + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + }, + waitForNodes: { + type: 'string', + name: 'wait_for_nodes' + }, + waitForEvents: { + type: 'enum', + options: [ + 'immediate', + 'urgent', + 'high', + 'normal', + 'low', + 'languid' + ], + name: 'wait_for_events' + }, + waitForNoRelocatingShards: { + type: 'boolean', + name: 'wait_for_no_relocating_shards' + }, + waitForStatus: { + type: 'enum', + 'default': null, + options: [ + 'green', + 'yellow', + 'red' + ], + name: 'wait_for_status' + } + }, + urls: [ + { + fmt: '/_cluster/health/<%=index%>', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_cluster/health' + } + ] +}); + +/** + * Perform a [cluster.pendingTasks](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-pending.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Specify timeout for connection to master + */ +api.cluster.prototype.pendingTasks = ca({ + params: { + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + } + }, + url: { + fmt: '/_cluster/pending_tasks' + } +}); + +/** + * Perform a [cluster.putSettings](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-update-settings.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.timeout - Explicit operation timeout + */ +api.cluster.prototype.putSettings = ca({ + params: { + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + timeout: { + type: 'time' + } + }, + url: { + fmt: '/_cluster/settings' + }, + method: 'PUT' +}); + +/** + * Perform a [cluster.reroute](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-reroute.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.dryRun - Simulate the operation only and return the resulting state + * @param {<>} params.explain - Return an explanation of why the commands can or cannot be executed + * @param {<>} params.retryFailed - Retries allocation of shards that are blocked due to too many subsequent allocation failures + * @param {<>, <>, <>} params.metric - Limit the information returned to the specified metrics. Defaults to all but metadata + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.timeout - Explicit operation timeout + */ +api.cluster.prototype.reroute = ca({ + params: { + dryRun: { + type: 'boolean', + name: 'dry_run' + }, + explain: { + type: 'boolean' + }, + retryFailed: { + type: 'boolean', + name: 'retry_failed' + }, + metric: { + type: 'list', + options: [ + '_all', + 'blocks', + 'metadata', + 'nodes', + 'routing_table', + 'master_node', + 'version' + ] + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + timeout: { + type: 'time' + } + }, + url: { + fmt: '/_cluster/reroute' + }, + method: 'POST' +}); + +/** + * Perform a [cluster.state](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-state.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @param {<>, <>, <>} params.metric - Limit the information returned to the specified metrics + */ +api.cluster.prototype.state = ca({ + params: { + local: { + type: 'boolean' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + } + }, + urls: [ + { + fmt: '/_cluster/state/<%=metric%>/<%=index%>', + req: { + metric: { + type: 'list', + options: [ + '_all', + 'blocks', + 'metadata', + 'nodes', + 'routing_table', + 'routing_nodes', + 'master_node', + 'version' + ] + }, + index: { + type: 'list' + } + } + }, + { + fmt: '/_cluster/state/<%=metric%>', + req: { + metric: { + type: 'list', + options: [ + '_all', + 'blocks', + 'metadata', + 'nodes', + 'routing_table', + 'routing_nodes', + 'master_node', + 'version' + ] + } + } + }, + { + fmt: '/_cluster/state' + } + ] +}); + +/** + * Perform a [cluster.stats](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-stats.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>, <>, <>} params.nodeId - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + */ +api.cluster.prototype.stats = ca({ + params: { + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, + timeout: { + type: 'time' + } + }, + urls: [ + { + fmt: '/_cluster/stats/nodes/<%=nodeId%>', + req: { + nodeId: { + type: 'list' + } + } + }, + { + fmt: '/_cluster/stats' + } + ] +}); + +/** + * Perform a [count](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-count.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.minScore - Include only documents with a specific `_score` value in the result + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.routing - Specific routing value + * @param {<>} params.q - Query in the Lucene query string syntax + * @param {<>} params.analyzer - The analyzer to use for the query string + * @param {<>} params.analyzeWildcard - Specify whether wildcard and prefix queries should be analyzed (default: false) + * @param {<>} [params.defaultOperator=OR] - The default operator for query string query (AND or OR) + * @param {<>} params.df - The field to use as default where no field prefix is given in the query string + * @param {<>} params.lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * @param {<>, <>, <>} params.index - A comma-separated list of indices to restrict the results + * @param {<>, <>, <>} params.type - A comma-separated list of types to restrict the results + */ +api.count = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + minScore: { + type: 'number', + name: 'min_score' + }, + preference: { + type: 'string' + }, + routing: { + type: 'string' + }, + q: { + type: 'string' + }, + analyzer: { + type: 'string' + }, + analyzeWildcard: { + type: 'boolean', + name: 'analyze_wildcard' + }, + defaultOperator: { + type: 'enum', + 'default': 'OR', + options: [ + 'AND', + 'OR' + ], + name: 'default_operator' + }, + df: { + type: 'string' + }, + lenient: { + type: 'boolean' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_count', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_count', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_count' + } + ], + method: 'POST' +}); + +/** + * Perform a [countPercolate](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-percolate.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.routing - A comma-separated list of specific routing values + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.percolateIndex - The index to count percolate the document into. Defaults to index. + * @param {<>} params.percolateType - The type to count percolate document into. Defaults to type. + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.index - The index of the document being count percolated. + * @param {<>} params.type - The type of the document being count percolated. + * @param {<>} params.id - Substitute the document in the request body with a document that is known by the specified id. On top of the id, the index and type parameter will be used to retrieve the document from within the cluster. + */ +api.countPercolate = ca({ + params: { + routing: { + type: 'list' + }, + preference: { + type: 'string' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + percolateIndex: { + type: 'string', + name: 'percolate_index' + }, + percolateType: { + type: 'string', + name: 'percolate_type' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/<%=id%>/_percolate/count', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + { + fmt: '/<%=index%>/<%=type%>/_percolate/count', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + } + } + } + ], + method: 'POST' +}); + +/** + * Perform a [create](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-index_.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {<>} params.parent - ID of the parent document + * @param {<>} params.refresh - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + * @param {<>} params.routing - Specific routing value + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.timestamp - Explicit timestamp for the document + * @param {<>} params.ttl - Expiration time for the document + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.pipeline - The pipeline id to preprocess incoming documents with + * @param {<>} params.id - Document ID + * @param {<>} params.index - The name of the index + * @param {<>} params.type - The type of the document + */ +api.create = ca({ + params: { + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + }, + parent: { + type: 'string' + }, + refresh: { + type: 'enum', + options: [ + 'true', + 'false', + 'wait_for', + '' + ] + }, + routing: { + type: 'string' + }, + timeout: { + type: 'time' + }, + timestamp: { + type: 'time' + }, + ttl: { + type: 'time' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + }, + pipeline: { + type: 'string' + } + }, + url: { + fmt: '/<%=index%>/<%=type%>/<%=id%>/_create', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + needBody: true, + method: 'POST' +}); + +/** + * Perform a [delete](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-delete.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {<>} params.parent - ID of parent document + * @param {<>} params.refresh - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + * @param {<>} params.routing - Specific routing value + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.id - The document ID + * @param {<>} params.index - The name of the index + * @param {<>} params.type - The type of the document + */ +api['delete'] = ca({ + params: { + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + }, + parent: { + type: 'string' + }, + refresh: { + type: 'enum', + options: [ + 'true', + 'false', + 'wait_for', + '' + ] + }, + routing: { + type: 'string' + }, + timeout: { + type: 'time' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + } + }, + url: { + fmt: '/<%=index%>/<%=type%>/<%=id%>', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + method: 'DELETE' +}); + +/** + * Perform a [deleteByQuery](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-delete-by-query.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.analyzer - The analyzer to use for the query string + * @param {<>} params.analyzeWildcard - Specify whether wildcard and prefix queries should be analyzed (default: false) + * @param {<>} [params.defaultOperator=OR] - The default operator for query string query (AND or OR) + * @param {<>} params.df - The field to use as default where no field prefix is given in the query string + * @param {<>} params.from - Starting offset (default: 0) + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.conflicts=abort] - What to do when the delete-by-query hits version conflicts? + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.q - Query in the Lucene query string syntax + * @param {<>, <>, <>} params.routing - A comma-separated list of specific routing values + * @param {<>} params.scroll - Specify how long a consistent view of the index should be maintained for scrolled search + * @param {<>} params.searchType - Search operation type + * @param {<>} params.searchTimeout - Explicit timeout for each search request. Defaults to no timeout. + * @param {<>} params.size - Number of hits to return (default: 10) + * @param {<>, <>, <>} params.sort - A comma-separated list of : pairs + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.terminateAfter - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. + * @param {<>, <>, <>} params.stats - Specific 'tag' of the request for logging and statistical purposes + * @param {<>} params.version - Specify whether to return document version as part of a hit + * @param {<>} params.requestCache - Specify if request cache should be used for this request or not, defaults to index level setting + * @param {<>} params.refresh - Should the effected indexes be refreshed? + * @param {<>} [params.timeout=1m] - Time each individual bulk request should wait for shards that are unavailable. + * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {<>} params.scrollSize - Size on the scroll request powering the update_by_query + * @param {<>} [params.waitForCompletion=true] - Should the request should block until the delete-by-query is complete. + * @param {<>} params.requestsPerSecond - The throttle for this request in sub-requests per second. -1 means no throttle. + * @param {<>} [params.slices=1] - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. + * @param {<>, <>, <>} params.index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * @param {<>, <>, <>} params.type - A comma-separated list of document types to search; leave empty to perform the operation on all types + */ +api.deleteByQuery = ca({ + params: { + analyzer: { + type: 'string' + }, + analyzeWildcard: { + type: 'boolean', + name: 'analyze_wildcard' + }, + defaultOperator: { + type: 'enum', + 'default': 'OR', + options: [ + 'AND', + 'OR' + ], + name: 'default_operator' + }, + df: { + type: 'string' + }, + from: { + type: 'number' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + conflicts: { + type: 'enum', + 'default': 'abort', + options: [ + 'abort', + 'proceed' + ] + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + lenient: { + type: 'boolean' + }, + preference: { + type: 'string' + }, + q: { + type: 'string' + }, + routing: { + type: 'list' + }, + scroll: { + type: 'time' + }, + searchType: { + type: 'enum', + options: [ + 'query_then_fetch', + 'dfs_query_then_fetch' + ], + name: 'search_type' + }, + searchTimeout: { + type: 'time', + name: 'search_timeout' + }, + size: { + type: 'number' + }, + sort: { + type: 'list' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + }, + terminateAfter: { + type: 'number', + name: 'terminate_after' + }, + stats: { + type: 'list' + }, + version: { + type: 'boolean' + }, + requestCache: { + type: 'boolean', + name: 'request_cache' + }, + refresh: { + type: 'boolean' + }, + timeout: { + type: 'time', + 'default': '1m' + }, + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + }, + scrollSize: { + type: 'number', + name: 'scroll_size' + }, + waitForCompletion: { + type: 'boolean', + 'default': true, + name: 'wait_for_completion' + }, + requestsPerSecond: { + type: 'number', + 'default': 0, + name: 'requests_per_second' + }, + slices: { + type: 'number', + 'default': 1 + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_delete_by_query', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_delete_by_query', + req: { + index: { + type: 'list' + } + } + } + ], + needBody: true, + method: 'POST' +}); + +/** + * Perform a [deleteScript](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-scripting.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.id - Script ID + * @param {<>} params.lang - Script language + */ +api.deleteScript = ca({ + urls: [ + { + fmt: '/_scripts/<%=lang%>/<%=id%>', + req: { + lang: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + { + fmt: '/_scripts/<%=lang%>', + req: { + lang: { + type: 'string' + } + } + } + ], + method: 'DELETE' +}); + +/** + * Perform a [deleteTemplate](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-template.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.id - Template ID + */ +api.deleteTemplate = ca({ + url: { + fmt: '/_search/template/<%=id%>', + req: { + id: { + type: 'string' + } + } + }, + method: 'DELETE' +}); + +/** + * Perform a [exists](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-get.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.storedFields - A comma-separated list of stored fields to return in the response + * @param {<>} params.parent - The ID of the parent document + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.realtime - Specify whether to perform the operation in realtime or search mode + * @param {<>} params.refresh - Refresh the shard containing the document before performing the operation + * @param {<>} params.routing - Specific routing value + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.id - The document ID + * @param {<>} params.index - The name of the index + * @param {<>} params.type - The type of the document (use `_all` to fetch the first document matching the ID across all types) + */ +api.exists = ca({ + params: { + storedFields: { + type: 'list', + name: 'stored_fields' + }, + parent: { + type: 'string' + }, + preference: { + type: 'string' + }, + realtime: { + type: 'boolean' + }, + refresh: { + type: 'boolean' + }, + routing: { + type: 'string' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + } + }, + url: { + fmt: '/<%=index%>/<%=type%>/<%=id%>', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + method: 'HEAD' +}); + +/** + * Perform a [existsSource](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.parent - The ID of the parent document + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.realtime - Specify whether to perform the operation in realtime or search mode + * @param {<>} params.refresh - Refresh the shard containing the document before performing the operation + * @param {<>} params.routing - Specific routing value + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.id - The document ID + * @param {<>} params.index - The name of the index + * @param {<>} params.type - The type of the document; use `_all` to fetch the first document matching the ID across all types + */ +api.existsSource = ca({ + params: { + parent: { + type: 'string' + }, + preference: { + type: 'string' + }, + realtime: { + type: 'boolean' + }, + refresh: { + type: 'boolean' + }, + routing: { + type: 'string' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + } + }, + url: { + fmt: '/<%=index%>/<%=type%>/<%=id%>/_source', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + method: 'HEAD' +}); + +/** + * Perform a [explain](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-explain.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.analyzeWildcard - Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false) + * @param {<>} params.analyzer - The analyzer for the query string query + * @param {<>} [params.defaultOperator=OR] - The default operator for query string query (AND or OR) + * @param {<>} params.df - The default field for query string query (default: _all) + * @param {<>, <>, <>} params.storedFields - A comma-separated list of stored fields to return in the response + * @param {<>} params.lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * @param {<>} params.parent - The ID of the parent document + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.q - Query in the Lucene query string syntax + * @param {<>} params.routing - Specific routing value + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.id - The document ID + * @param {<>} params.index - The name of the index + * @param {<>} params.type - The type of the document + */ +api.explain = ca({ + params: { + analyzeWildcard: { + type: 'boolean', + name: 'analyze_wildcard' + }, + analyzer: { + type: 'string' + }, + defaultOperator: { + type: 'enum', + 'default': 'OR', + options: [ + 'AND', + 'OR' + ], + name: 'default_operator' + }, + df: { + type: 'string' + }, + storedFields: { + type: 'list', + name: 'stored_fields' + }, + lenient: { + type: 'boolean' + }, + parent: { + type: 'string' + }, + preference: { + type: 'string' + }, + q: { + type: 'string' + }, + routing: { + type: 'string' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + } + }, + url: { + fmt: '/<%=index%>/<%=type%>/<%=id%>/_explain', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + method: 'POST' +}); + +/** + * Perform a [fieldCaps](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.fields - A comma-separated list of field names + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + */ +api.fieldCaps = ca({ + params: { + fields: { + type: 'list' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + } + }, + urls: [ + { + fmt: '/<%=index%>/_field_caps', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_field_caps' + } + ], + method: 'POST' +}); + +/** + * Perform a [fieldStats](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-field-stats.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.fields - A comma-separated list of fields for to get field statistics for (min value, max value, and more) + * @param {<>} [params.level=cluster] - Defines if field stats should be returned on a per index level or on a cluster wide level + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + */ +api.fieldStats = ca({ + params: { + fields: { + type: 'list' + }, + level: { + type: 'enum', + 'default': 'cluster', + options: [ + 'indices', + 'cluster' + ] + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + } + }, + urls: [ + { + fmt: '/<%=index%>/_field_stats', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_field_stats' + } + ], + method: 'POST' +}); + +/** + * Perform a [get](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-get.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.storedFields - A comma-separated list of stored fields to return in the response + * @param {<>} params.parent - The ID of the parent document + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.realtime - Specify whether to perform the operation in realtime or search mode + * @param {<>} params.refresh - Refresh the shard containing the document before performing the operation + * @param {<>} params.routing - Specific routing value + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.id - The document ID + * @param {<>} params.index - The name of the index + * @param {<>} params.type - The type of the document (use `_all` to fetch the first document matching the ID across all types) + */ +api.get = ca({ + params: { + storedFields: { + type: 'list', + name: 'stored_fields' + }, + parent: { + type: 'string' + }, + preference: { + type: 'string' + }, + realtime: { + type: 'boolean' + }, + refresh: { + type: 'boolean' + }, + routing: { + type: 'string' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + } + }, + url: { + fmt: '/<%=index%>/<%=type%>/<%=id%>', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + } +}); + +/** + * Perform a [getScript](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-scripting.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.id - Script ID + * @param {<>} params.lang - Script language + */ +api.getScript = ca({ + urls: [ + { + fmt: '/_scripts/<%=lang%>/<%=id%>', + req: { + lang: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + { + fmt: '/_scripts/<%=lang%>', + req: { + lang: { + type: 'string' + } + } + } + ] +}); + +/** + * Perform a [getSource](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-get.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.parent - The ID of the parent document + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.realtime - Specify whether to perform the operation in realtime or search mode + * @param {<>} params.refresh - Refresh the shard containing the document before performing the operation + * @param {<>} params.routing - Specific routing value + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.id - The document ID + * @param {<>} params.index - The name of the index + * @param {<>} params.type - The type of the document; use `_all` to fetch the first document matching the ID across all types + */ +api.getSource = ca({ + params: { + parent: { + type: 'string' + }, + preference: { + type: 'string' + }, + realtime: { + type: 'boolean' + }, + refresh: { + type: 'boolean' + }, + routing: { + type: 'string' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + } + }, + url: { + fmt: '/<%=index%>/<%=type%>/<%=id%>/_source', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + } +}); + +/** + * Perform a [getTemplate](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-template.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.id - Template ID + */ +api.getTemplate = ca({ + url: { + fmt: '/_search/template/<%=id%>', + req: { + id: { + type: 'string' + } + } + } +}); + +/** + * Perform a [index](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-index_.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {<>} [params.opType=index] - Explicit operation type + * @param {<>} params.parent - ID of the parent document + * @param {<>} params.refresh - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + * @param {<>} params.routing - Specific routing value + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.timestamp - Explicit timestamp for the document + * @param {<>} params.ttl - Expiration time for the document + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.pipeline - The pipeline id to preprocess incoming documents with + * @param {<>} params.id - Document ID + * @param {<>} params.index - The name of the index + * @param {<>} params.type - The type of the document + */ +api.index = ca({ + params: { + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + }, + opType: { + type: 'enum', + 'default': 'index', + options: [ + 'index', + 'create' + ], + name: 'op_type' + }, + parent: { + type: 'string' + }, + refresh: { + type: 'enum', + options: [ + 'true', + 'false', + 'wait_for', + '' + ] + }, + routing: { + type: 'string' + }, + timeout: { + type: 'time' + }, + timestamp: { + type: 'time' + }, + ttl: { + type: 'time' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + }, + pipeline: { + type: 'string' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/<%=id%>', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + { + fmt: '/<%=index%>/<%=type%>', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + } + } + } + ], + needBody: true, + method: 'POST' +}); + +api.indices = namespace(); + +/** + * Perform a [indices.analyze](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-analyze.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.analyzer - The name of the analyzer to use + * @param {<>, <>, <>} params.charFilter - A comma-separated list of character filters to use for the analysis + * @param {<>} params.field - Use the analyzer configured for this field (instead of passing the analyzer name) + * @param {<>, <>, <>} params.filter - A comma-separated list of filters to use for the analysis + * @param {<>} params.index - The name of the index to scope the operation + * @param {<>} params.preferLocal - With `true`, specify that a local shard should be used if available, with `false`, use a random shard (default: true) + * @param {<>, <>, <>} params.text - The text on which the analysis should be performed (when request body is not used) + * @param {<>} params.tokenizer - The name of the tokenizer to use for the analysis + * @param {<>} params.explain - With `true`, outputs more advanced details. (default: false) + * @param {<>, <>, <>} params.attributes - A comma-separated list of token attributes to output, this parameter works only with `explain=true` + * @param {<>} [params.format=detailed] - Format of the output + */ +api.indices.prototype.analyze = ca({ + params: { + analyzer: { + type: 'string' + }, + charFilter: { + type: 'list', + name: 'char_filter' + }, + field: { + type: 'string' + }, + filter: { + type: 'list' + }, + index: { + type: 'string' + }, + preferLocal: { + type: 'boolean', + name: 'prefer_local' + }, + text: { + type: 'list' + }, + tokenizer: { + type: 'string' + }, + explain: { + type: 'boolean' + }, + attributes: { + type: 'list' + }, + format: { + type: 'enum', + 'default': 'detailed', + options: [ + 'detailed', + 'text' + ] + } + }, + urls: [ + { + fmt: '/<%=index%>/_analyze', + req: { + index: { + type: 'string' + } + } + }, + { + fmt: '/_analyze' + } + ], + method: 'POST' +}); + +/** + * Perform a [indices.clearCache](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-clearcache.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.fieldData - Clear field data + * @param {<>} params.fielddata - Clear field data + * @param {<>, <>, <>} params.fields - A comma-separated list of fields to clear when using the `field_data` parameter (default: all) + * @param {<>} params.query - Clear query caches + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>, <>, <>} params.index - A comma-separated list of index name to limit the operation + * @param {<>} params.recycler - Clear the recycler cache + * @param {<>} params.requestCache - Clear request cache + * @param {<>} params.request - Clear request cache + */ +api.indices.prototype.clearCache = ca({ + params: { + fieldData: { + type: 'boolean', + name: 'field_data' + }, + fielddata: { + type: 'boolean' + }, + fields: { + type: 'list' + }, + query: { + type: 'boolean' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + index: { + type: 'list' + }, + recycler: { + type: 'boolean' + }, + requestCache: { + type: 'boolean', + name: 'request_cache' + }, + request: { + type: 'boolean' + } + }, + urls: [ + { + fmt: '/<%=index%>/_cache/clear', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_cache/clear' + } + ], + method: 'POST' +}); + +/** + * Perform a [indices.close](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-open-close.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>, <>, <>} params.index - A comma separated list of indices to close + */ +api.indices.prototype.close = ca({ + params: { + timeout: { + type: 'time' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + } + }, + url: { + fmt: '/<%=index%>/_close', + req: { + index: { + type: 'list' + } + } + }, + method: 'POST' +}); + +/** + * Perform a [indices.create](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-create-index.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.waitForActiveShards - Set the number of active shards to wait for before the operation returns. + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>} params.updateAllTypes - Whether to update the mapping for all fields with the same name across all types or not + * @param {<>} params.index - The name of the index + */ +api.indices.prototype.create = ca({ + params: { + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + }, + timeout: { + type: 'time' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + updateAllTypes: { + type: 'boolean', + name: 'update_all_types' + } + }, + url: { + fmt: '/<%=index%>', + req: { + index: { + type: 'string' + } + } + }, + method: 'PUT' +}); + +/** + * Perform a [indices.delete](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-delete-index.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>, <>, <>} params.index - A comma-separated list of indices to delete; use `_all` or `*` string to delete all indices + */ +api.indices.prototype['delete'] = ca({ + params: { + timeout: { + type: 'time' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + } + }, + url: { + fmt: '/<%=index%>', + req: { + index: { + type: 'list' + } + } + }, + method: 'DELETE' +}); + +/** + * Perform a [indices.deleteAlias](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.timeout - Explicit timestamp for the document + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>, <>, <>} params.index - A comma-separated list of index names (supports wildcards); use `_all` for all indices + * @param {<>, <>, <>} params.name - A comma-separated list of aliases to delete (supports wildcards); use `_all` to delete all aliases for the specified indices. + */ +api.indices.prototype.deleteAlias = ca({ + params: { + timeout: { + type: 'time' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + } + }, + url: { + fmt: '/<%=index%>/_alias/<%=name%>', + req: { + index: { + type: 'list' + }, + name: { + type: 'list' + } + } + }, + method: 'DELETE' +}); + +/** + * Perform a [indices.deleteTemplate](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>} params.name - The name of the template + */ +api.indices.prototype.deleteTemplate = ca({ + params: { + timeout: { + type: 'time' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + } + }, + url: { + fmt: '/_template/<%=name%>', + req: { + name: { + type: 'string' + } + } + }, + method: 'DELETE' +}); + +/** + * Perform a [indices.exists](http://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-exists.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.ignoreUnavailable - Ignore unavailable indexes (default: false) + * @param {<>} params.allowNoIndices - Ignore if a wildcard expression resolves to no concrete indices (default: false) + * @param {<>} [params.expandWildcards=open] - Whether wildcard expressions should get expanded to open or closed indices (default: open) + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.includeDefaults - Whether to return all default setting for each of the indices. + * @param {<>, <>, <>} params.index - A comma-separated list of index names + */ +api.indices.prototype.exists = ca({ + params: { + local: { + type: 'boolean' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, + includeDefaults: { + type: 'boolean', + 'default': false, + name: 'include_defaults' + } + }, + url: { + fmt: '/<%=index%>', + req: { + index: { + type: 'list' + } + } + }, + method: 'HEAD' +}); + +/** + * Perform a [indices.existsAlias](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=all] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>, <>, <>} params.index - A comma-separated list of index names to filter aliases + * @param {<>, <>, <>} params.name - A comma-separated list of alias names to return + */ +api.indices.prototype.existsAlias = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'all', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + local: { + type: 'boolean' + } + }, + urls: [ + { + fmt: '/<%=index%>/_alias/<%=name%>', + req: { + index: { + type: 'list' + }, + name: { + type: 'list' + } + } + }, + { + fmt: '/_alias/<%=name%>', + req: { + name: { + type: 'list' + } + } + } + ], + method: 'HEAD' +}); + +/** + * Perform a [indices.existsTemplate](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>, <>, <>} params.name - The comma separated names of the index templates + */ +api.indices.prototype.existsTemplate = ca({ + params: { + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + local: { + type: 'boolean' + } + }, + url: { + fmt: '/_template/<%=name%>', + req: { + name: { + type: 'list' + } + } + }, + method: 'HEAD' +}); + +/** + * Perform a [indices.existsType](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-types-exists.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` to check the types across all indices + * @param {<>, <>, <>} params.type - A comma-separated list of document types to check + */ +api.indices.prototype.existsType = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + local: { + type: 'boolean' + } + }, + url: { + fmt: '/<%=index%>/_mapping/<%=type%>', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + } + } + }, + method: 'HEAD' +}); + +/** + * Perform a [indices.flush](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-flush.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.force - Whether a flush should be forced even if it is not necessarily needed ie. if no changes will be committed to the index. This is useful if transaction log IDs should be incremented even if no uncommitted changes are present. (This setting can be considered as internal) + * @param {<>} params.waitIfOngoing - If set to true the flush operation will block until the flush can be executed if another flush operation is already executing. The default is true. If set to false the flush will be skipped iff if another flush operation is already running. + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string for all indices + */ +api.indices.prototype.flush = ca({ + params: { + force: { + type: 'boolean' + }, + waitIfOngoing: { + type: 'boolean', + name: 'wait_if_ongoing' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + } + }, + urls: [ + { + fmt: '/<%=index%>/_flush', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_flush' + } + ], + method: 'POST' +}); + +/** + * Perform a [indices.flushSynced](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-synced-flush.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string for all indices + */ +api.indices.prototype.flushSynced = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + } + }, + urls: [ + { + fmt: '/<%=index%>/_flush/synced', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_flush/synced' + } + ], + method: 'POST' +}); + +/** + * Perform a [indices.forcemerge](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-forcemerge.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.flush - Specify whether the index should be flushed after performing the operation (default: true) + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.maxNumSegments - The number of segments the index should be merged into (default: dynamic) + * @param {<>} params.onlyExpungeDeletes - Specify whether the operation should only expunge deleted documents + * @param {anything} params.operationThreading - TODO: ? + * @param {<>} params.waitForMerge - Specify whether the request should block until the merge process is finished (default: true) + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + */ +api.indices.prototype.forcemerge = ca({ + params: { + flush: { + type: 'boolean' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + maxNumSegments: { + type: 'number', + name: 'max_num_segments' + }, + onlyExpungeDeletes: { + type: 'boolean', + name: 'only_expunge_deletes' + }, + operationThreading: { + name: 'operation_threading' + }, + waitForMerge: { + type: 'boolean', + name: 'wait_for_merge' + } + }, + urls: [ + { + fmt: '/<%=index%>/_forcemerge', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_forcemerge' + } + ], + method: 'POST' +}); + +/** + * Perform a [indices.get](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-get-index.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.ignoreUnavailable - Ignore unavailable indexes (default: false) + * @param {<>} params.allowNoIndices - Ignore if a wildcard expression resolves to no concrete indices (default: false) + * @param {<>} [params.expandWildcards=open] - Whether wildcard expressions should get expanded to open or closed indices (default: open) + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.includeDefaults - Whether to return all default setting for each of the indices. + * @param {<>, <>, <>} params.index - A comma-separated list of index names + * @param {<>, <>, <>} params.feature - A comma-separated list of features + */ +api.indices.prototype.get = ca({ + params: { + local: { + type: 'boolean' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, + includeDefaults: { + type: 'boolean', + 'default': false, + name: 'include_defaults' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=feature%>', + req: { + index: { + type: 'list' + }, + feature: { + type: 'list', + options: [ + '_settings', + '_mappings', + '_aliases' + ] + } + } + }, + { + fmt: '/<%=index%>', + req: { + index: { + type: 'list' + } + } + } + ] +}); + +/** + * Perform a [indices.getAlias](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=all] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>, <>, <>} params.index - A comma-separated list of index names to filter aliases + * @param {<>, <>, <>} params.name - A comma-separated list of alias names to return + */ +api.indices.prototype.getAlias = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'all', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + local: { + type: 'boolean' + } + }, + urls: [ + { + fmt: '/<%=index%>/_alias/<%=name%>', + req: { + index: { + type: 'list' + }, + name: { + type: 'list' + } + } + }, + { + fmt: '/_alias/<%=name%>', + req: { + name: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_alias', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_alias' + } + ] +}); + +/** + * Perform a [indices.getFieldMapping](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-get-field-mapping.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.includeDefaults - Whether the default mapping values should be returned as well + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>, <>, <>} params.index - A comma-separated list of index names + * @param {<>, <>, <>} params.type - A comma-separated list of document types + * @param {<>, <>, <>} params.fields - A comma-separated list of fields + */ +api.indices.prototype.getFieldMapping = ca({ + params: { + includeDefaults: { + type: 'boolean', + name: 'include_defaults' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + local: { + type: 'boolean' + } + }, + urls: [ + { + fmt: '/<%=index%>/_mapping/<%=type%>/field/<%=fields%>', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + }, + fields: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_mapping/field/<%=fields%>', + req: { + index: { + type: 'list' + }, + fields: { + type: 'list' + } + } + }, + { + fmt: '/_mapping/<%=type%>/field/<%=fields%>', + req: { + type: { + type: 'list' + }, + fields: { + type: 'list' + } + } + }, + { + fmt: '/_mapping/field/<%=fields%>', + req: { + fields: { + type: 'list' + } + } + } + ] +}); + +/** + * Perform a [indices.getMapping](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-get-mapping.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>, <>, <>} params.index - A comma-separated list of index names + * @param {<>, <>, <>} params.type - A comma-separated list of document types + */ +api.indices.prototype.getMapping = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + local: { + type: 'boolean' + } + }, + urls: [ + { + fmt: '/<%=index%>/_mapping/<%=type%>', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_mapping', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_mapping/<%=type%>', + req: { + type: { + type: 'list' + } + } + }, + { + fmt: '/_mapping' + } + ] +}); + +/** + * Perform a [indices.getSettings](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-get-settings.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open,closed] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.includeDefaults - Whether to return all default setting for each of the indices. + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @param {<>, <>, <>} params.name - The name of the settings that should be included + */ +api.indices.prototype.getSettings = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': [ + 'open', + 'closed' + ], + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, + local: { + type: 'boolean' + }, + includeDefaults: { + type: 'boolean', + 'default': false, + name: 'include_defaults' + } + }, + urls: [ + { + fmt: '/<%=index%>/_settings/<%=name%>', + req: { + index: { + type: 'list' + }, + name: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_settings', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_settings/<%=name%>', + req: { + name: { + type: 'list' + } + } + }, + { + fmt: '/_settings' + } + ] +}); + +/** + * Perform a [indices.getTemplate](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>, <>, <>} params.name - The comma separated names of the index templates + */ +api.indices.prototype.getTemplate = ca({ + params: { + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + local: { + type: 'boolean' + } + }, + urls: [ + { + fmt: '/_template/<%=name%>', + req: { + name: { + type: 'list' + } + } + }, + { + fmt: '/_template' + } + ] +}); + +/** + * Perform a [indices.getUpgrade](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-upgrade.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + */ +api.indices.prototype.getUpgrade = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + } + }, + urls: [ + { + fmt: '/<%=index%>/_upgrade', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_upgrade' + } + ] +}); + +/** + * Perform a [indices.open](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-open-close.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=closed] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>, <>, <>} params.index - A comma separated list of indices to open + */ +api.indices.prototype.open = ca({ + params: { + timeout: { + type: 'time' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'closed', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + } + }, + url: { + fmt: '/<%=index%>/_open', + req: { + index: { + type: 'list' + } + } + }, + method: 'POST' +}); + +/** + * Perform a [indices.putAlias](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.timeout - Explicit timestamp for the document + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>, <>, <>} params.index - A comma-separated list of index names the alias should point to (supports wildcards); use `_all` to perform the operation on all indices. + * @param {<>} params.name - The name of the alias to be created or updated + */ +api.indices.prototype.putAlias = ca({ + params: { + timeout: { + type: 'time' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + } + }, + url: { + fmt: '/<%=index%>/_alias/<%=name%>', + req: { + index: { + type: 'list' + }, + name: { + type: 'string' + } + } + }, + method: 'PUT' +}); + +/** + * Perform a [indices.putMapping](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-put-mapping.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.updateAllTypes - Whether to update the mapping for all fields with the same name across all types or not + * @param {<>, <>, <>} params.index - A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. + * @param {<>} params.type - The name of the document type + */ +api.indices.prototype.putMapping = ca({ + params: { + timeout: { + type: 'time' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + updateAllTypes: { + type: 'boolean', + name: 'update_all_types' + } + }, + urls: [ + { + fmt: '/<%=index%>/_mapping/<%=type%>', + req: { + index: { + type: 'list' + }, + type: { + type: 'string' + } + } + }, + { + fmt: '/_mapping/<%=type%>', + req: { + type: { + type: 'string' + } + } + } + ], + needBody: true, + method: 'PUT' +}); + +/** + * Perform a [indices.putSettings](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-update-settings.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>} params.preserveExisting - Whether to update existing settings. If set to `true` existing settings on an index remain unchanged, the default is `false` + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + */ +api.indices.prototype.putSettings = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + preserveExisting: { + type: 'boolean', + name: 'preserve_existing' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + flatSettings: { + type: 'boolean', + name: 'flat_settings' + } + }, + urls: [ + { + fmt: '/<%=index%>/_settings', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_settings' + } + ], + needBody: true, + method: 'PUT' +}); + +/** + * Perform a [indices.putTemplate](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.order - The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers) + * @param {<>} params.create - Whether the index template should only be added if new or can also replace an existing one + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.name - The name of the template + */ +api.indices.prototype.putTemplate = ca({ + params: { + order: { + type: 'number' + }, + create: { + type: 'boolean', + 'default': false + }, + timeout: { + type: 'time' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + flatSettings: { + type: 'boolean', + name: 'flat_settings' + } + }, + url: { + fmt: '/_template/<%=name%>', + req: { + name: { + type: 'string' + } + } + }, + needBody: true, + method: 'PUT' +}); + +/** + * Perform a [indices.recovery](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-recovery.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.detailed - Whether to display detailed information about shard recovery + * @param {<>} params.activeOnly - Display only those recoveries that are currently on-going + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + */ +api.indices.prototype.recovery = ca({ + params: { + detailed: { + type: 'boolean', + 'default': false + }, + activeOnly: { + type: 'boolean', + 'default': false, + name: 'active_only' + } + }, + urls: [ + { + fmt: '/<%=index%>/_recovery', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_recovery' + } + ] +}); + +/** + * Perform a [indices.refresh](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-refresh.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.force - Force a refresh even if not required + * @param {anything} params.operationThreading - TODO: ? + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + */ +api.indices.prototype.refresh = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + force: { + type: 'boolean', + 'default': false + }, + operationThreading: { + name: 'operation_threading' + } + }, + urls: [ + { + fmt: '/<%=index%>/_refresh', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_refresh' + } + ], + method: 'POST' +}); + +/** + * Perform a [indices.rollover](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-rollover-index.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.dryRun - If set to true the rollover action will only be validated but not actually performed even if a condition matches. The default is false + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>} params.waitForActiveShards - Set the number of active shards to wait for on the newly created rollover index before the operation returns. + * @param {<>} params.alias - The name of the alias to rollover + * @param {<>} params.newIndex - The name of the rollover index + */ +api.indices.prototype.rollover = ca({ + params: { + timeout: { + type: 'time' + }, + dryRun: { + type: 'boolean', + name: 'dry_run' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + } + }, + urls: [ + { + fmt: '/<%=alias%>/_rollover/<%=newIndex%>', + req: { + alias: { + type: 'string' + }, + newIndex: { + type: 'string' + } + } + }, + { + fmt: '/<%=alias%>/_rollover', + req: { + alias: { + type: 'string' + } + } + } + ], + method: 'POST' +}); + +/** + * Perform a [indices.segments](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-segments.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {anything} params.operationThreading - TODO: ? + * @param {<>} params.verbose - Includes detailed memory usage by Lucene. + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + */ +api.indices.prototype.segments = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + operationThreading: { + name: 'operation_threading' + }, + verbose: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/<%=index%>/_segments', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_segments' + } + ] +}); + +/** + * Perform a [indices.shardStores](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-shards-stores.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.status - A comma-separated list of statuses used to filter on shards to get store information for + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {anything} params.operationThreading - TODO: ? + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + */ +api.indices.prototype.shardStores = ca({ + params: { + status: { + type: 'list', + options: [ + 'green', + 'yellow', + 'red', + 'all' + ] + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + operationThreading: { + name: 'operation_threading' + } + }, + urls: [ + { + fmt: '/<%=index%>/_shard_stores', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_shard_stores' + } + ] +}); + +/** + * Perform a [indices.shrink](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-shrink-index.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.masterTimeout - Specify timeout for connection to master + * @param {<>} params.waitForActiveShards - Set the number of active shards to wait for on the shrunken index before the operation returns. + * @param {<>} params.index - The name of the source index to shrink + * @param {<>} params.target - The name of the target index to shrink into + */ +api.indices.prototype.shrink = ca({ + params: { + timeout: { + type: 'time' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + } + }, + url: { + fmt: '/<%=index%>/_shrink/<%=target%>', + req: { + index: { + type: 'string' + }, + target: { + type: 'string' + } + } + }, + method: 'POST' +}); + +/** + * Perform a [indices.stats](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-stats.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.completionFields - A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards) + * @param {<>, <>, <>} params.fielddataFields - A comma-separated list of fields for `fielddata` index metric (supports wildcards) + * @param {<>, <>, <>} params.fields - A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) + * @param {<>, <>, <>} params.groups - A comma-separated list of search groups for `search` index metric + * @param {<>} [params.level=indices] - Return stats aggregated at cluster, index or shard level + * @param {<>, <>, <>} params.types - A comma-separated list of document types for the `indexing` index metric + * @param {<>} params.includeSegmentFileSizes - Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @param {<>, <>, <>} params.metric - Limit the information returned the specific metrics. + */ +api.indices.prototype.stats = ca({ + params: { + completionFields: { + type: 'list', + name: 'completion_fields' + }, + fielddataFields: { + type: 'list', + name: 'fielddata_fields' + }, + fields: { + type: 'list' + }, + groups: { + type: 'list' + }, + level: { + type: 'enum', + 'default': 'indices', + options: [ + 'cluster', + 'indices', + 'shards' + ] + }, + types: { + type: 'list' + }, + includeSegmentFileSizes: { + type: 'boolean', + 'default': false, + name: 'include_segment_file_sizes' + } + }, + urls: [ + { + fmt: '/<%=index%>/_stats/<%=metric%>', + req: { + index: { + type: 'list' + }, + metric: { + type: 'list', + options: [ + '_all', + 'completion', + 'docs', + 'fielddata', + 'query_cache', + 'flush', + 'get', + 'indexing', + 'merge', + 'percolate', + 'request_cache', + 'refresh', + 'search', + 'segments', + 'store', + 'warmer', + 'suggest' + ] + } + } + }, + { + fmt: '/_stats/<%=metric%>', + req: { + metric: { + type: 'list', + options: [ + '_all', + 'completion', + 'docs', + 'fielddata', + 'query_cache', + 'flush', + 'get', + 'indexing', + 'merge', + 'percolate', + 'request_cache', + 'refresh', + 'search', + 'segments', + 'store', + 'warmer', + 'suggest' + ] + } + } + }, + { + fmt: '/<%=index%>/_stats', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_stats' + } + ] +}); + +/** + * Perform a [indices.updateAliases](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.timeout - Request timeout + * @param {<>} params.masterTimeout - Specify timeout for connection to master + */ +api.indices.prototype.updateAliases = ca({ + params: { + timeout: { + type: 'time' + }, + masterTimeout: { + type: 'time', + name: 'master_timeout' + } + }, + url: { + fmt: '/_aliases' + }, + needBody: true, + method: 'POST' +}); + +/** + * Perform a [indices.upgrade](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-upgrade.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.waitForCompletion - Specify whether the request should block until the all segments are upgraded (default: false) + * @param {<>} params.onlyAncientSegments - If true, only ancient (an older Lucene major release) segments will be upgraded + * @param {<>, <>, <>} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + */ +api.indices.prototype.upgrade = ca({ + params: { + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + waitForCompletion: { + type: 'boolean', + name: 'wait_for_completion' + }, + onlyAncientSegments: { + type: 'boolean', + name: 'only_ancient_segments' + } + }, + urls: [ + { + fmt: '/<%=index%>/_upgrade', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_upgrade' + } + ], + method: 'POST' +}); + +/** + * Perform a [indices.validateQuery](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-validate.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.explain - Return detailed information about the error + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {anything} params.operationThreading - TODO: ? + * @param {<>} params.q - Query in the Lucene query string syntax + * @param {<>} params.analyzer - The analyzer to use for the query string + * @param {<>} params.analyzeWildcard - Specify whether wildcard and prefix queries should be analyzed (default: false) + * @param {<>} [params.defaultOperator=OR] - The default operator for query string query (AND or OR) + * @param {<>} params.df - The field to use as default where no field prefix is given in the query string + * @param {<>} params.lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * @param {<>} params.rewrite - Provide a more detailed explanation showing the actual Lucene query that will be executed. + * @param {<>} params.allShards - Execute validation on all shards instead of one random shard per index + * @param {<>, <>, <>} params.index - A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices + * @param {<>, <>, <>} params.type - A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types + */ +api.indices.prototype.validateQuery = ca({ + params: { + explain: { + type: 'boolean' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + operationThreading: { + name: 'operation_threading' + }, + q: { + type: 'string' + }, + analyzer: { + type: 'string' + }, + analyzeWildcard: { + type: 'boolean', + name: 'analyze_wildcard' + }, + defaultOperator: { + type: 'enum', + 'default': 'OR', + options: [ + 'AND', + 'OR' + ], + name: 'default_operator' + }, + df: { + type: 'string' + }, + lenient: { + type: 'boolean' + }, + rewrite: { + type: 'boolean' + }, + allShards: { + type: 'boolean', + name: 'all_shards' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_validate/query', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_validate/query', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_validate/query' + } + ], + method: 'POST' +}); + +/** + * Perform a [info](https://www.elastic.co/guide/) request + * + * @param {Object} params - An object with parameters used to carry out this action + */ +api.info = ca({ + url: { + fmt: '/' + } +}); + +api.ingest = namespace(); + +/** + * Perform a [ingest.deletePipeline](https://www.elastic.co/guide/en/elasticsearch/plugins/5.x/ingest.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.id - Pipeline ID + */ +api.ingest.prototype.deletePipeline = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + timeout: { + type: 'time' + } + }, + url: { + fmt: '/_ingest/pipeline/<%=id%>', + req: { + id: { + type: 'string' + } + } + }, + method: 'DELETE' +}); + +/** + * Perform a [ingest.getPipeline](https://www.elastic.co/guide/en/elasticsearch/plugins/5.x/ingest.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.id - Comma separated list of pipeline ids. Wildcards supported + */ +api.ingest.prototype.getPipeline = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + } + }, + urls: [ + { + fmt: '/_ingest/pipeline/<%=id%>', + req: { + id: { + type: 'string' + } + } + }, + { + fmt: '/_ingest/pipeline' + } + ] +}); + +/** + * Perform a [ingest.putPipeline](https://www.elastic.co/guide/en/elasticsearch/plugins/5.x/ingest.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.id - Pipeline ID + */ +api.ingest.prototype.putPipeline = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + timeout: { + type: 'time' + } + }, + url: { + fmt: '/_ingest/pipeline/<%=id%>', + req: { + id: { + type: 'string' + } + } + }, + needBody: true, + method: 'PUT' +}); + +/** + * Perform a [ingest.simulate](https://www.elastic.co/guide/en/elasticsearch/plugins/5.x/ingest.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.verbose - Verbose mode. Display data output for each processor in executed pipeline + * @param {<>} params.id - Pipeline ID + */ +api.ingest.prototype.simulate = ca({ + params: { + verbose: { + type: 'boolean', + 'default': false + } + }, + urls: [ + { + fmt: '/_ingest/pipeline/<%=id%>/_simulate', + req: { + id: { + type: 'string' + } + } + }, + { + fmt: '/_ingest/pipeline/_simulate' + } + ], + needBody: true, + method: 'POST' +}); + +/** + * Perform a [mget](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-multi-get.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.storedFields - A comma-separated list of stored fields to return in the response + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.realtime - Specify whether to perform the operation in realtime or search mode + * @param {<>} params.refresh - Refresh the shard containing the document before performing the operation + * @param {<>} params.routing - Specific routing value + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.index - The name of the index + * @param {<>} params.type - The type of the document + */ +api.mget = ca({ + params: { + storedFields: { + type: 'list', + name: 'stored_fields' + }, + preference: { + type: 'string' + }, + realtime: { + type: 'boolean' + }, + refresh: { + type: 'boolean' + }, + routing: { + type: 'string' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_mget', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + } + } + }, + { + fmt: '/<%=index%>/_mget', + req: { + index: { + type: 'string' + } + } + }, + { + fmt: '/_mget' + } + ], + needBody: true, + method: 'POST' +}); + +/** + * Perform a [mpercolate](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-percolate.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.index - The index of the document being count percolated to use as default + * @param {<>} params.type - The type of the document being percolated to use as default. + */ +api.mpercolate = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_mpercolate', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + } + } + }, + { + fmt: '/<%=index%>/_mpercolate', + req: { + index: { + type: 'string' + } + } + }, + { + fmt: '/_mpercolate' + } + ], + needBody: true, + bulkBody: true, + method: 'POST' +}); + +/** + * Perform a [msearch](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-multi-search.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.searchType - Search operation type + * @param {<>} params.maxConcurrentSearches - Controls the maximum number of concurrent searches the multi search api will execute + * @param {<>} params.typedKeys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * @param {<>, <>, <>} params.index - A comma-separated list of index names to use as default + * @param {<>, <>, <>} params.type - A comma-separated list of document types to use as default + */ +api.msearch = ca({ + params: { + searchType: { + type: 'enum', + options: [ + 'query_then_fetch', + 'query_and_fetch', + 'dfs_query_then_fetch', + 'dfs_query_and_fetch' + ], + name: 'search_type' + }, + maxConcurrentSearches: { + type: 'number', + name: 'max_concurrent_searches' + }, + typedKeys: { + type: 'boolean', + name: 'typed_keys' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_msearch', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_msearch', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_msearch' + } + ], + needBody: true, + bulkBody: true, + method: 'POST' +}); + +/** + * Perform a [msearchTemplate](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.searchType - Search operation type + * @param {<>} params.typedKeys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * @param {<>} params.maxConcurrentSearches - Controls the maximum number of concurrent searches the multi search api will execute + * @param {<>, <>, <>} params.index - A comma-separated list of index names to use as default + * @param {<>, <>, <>} params.type - A comma-separated list of document types to use as default + */ +api.msearchTemplate = ca({ + params: { + searchType: { + type: 'enum', + options: [ + 'query_then_fetch', + 'query_and_fetch', + 'dfs_query_then_fetch', + 'dfs_query_and_fetch' + ], + name: 'search_type' + }, + typedKeys: { + type: 'boolean', + name: 'typed_keys' + }, + maxConcurrentSearches: { + type: 'number', + name: 'max_concurrent_searches' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_msearch/template', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_msearch/template', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_msearch/template' + } + ], + needBody: true, + bulkBody: true, + method: 'POST' +}); + +/** + * Perform a [mtermvectors](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-multi-termvectors.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.ids - A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body + * @param {<>} params.termStatistics - Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {<>} [params.fieldStatistics=true] - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {<>, <>, <>} params.fields - A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {<>} [params.offsets=true] - Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {<>} [params.positions=true] - Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {<>} [params.payloads=true] - Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {<>} params.routing - Specific routing value. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {<>} params.parent - Parent id of documents. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {<>} params.realtime - Specifies if requests are real-time as opposed to near-real-time (default: true). + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.index - The index in which the document resides. + * @param {<>} params.type - The type of the document. + */ +api.mtermvectors = ca({ + params: { + ids: { + type: 'list', + required: false + }, + termStatistics: { + type: 'boolean', + 'default': false, + required: false, + name: 'term_statistics' + }, + fieldStatistics: { + type: 'boolean', + 'default': true, + required: false, + name: 'field_statistics' + }, + fields: { + type: 'list', + required: false + }, + offsets: { + type: 'boolean', + 'default': true, + required: false + }, + positions: { + type: 'boolean', + 'default': true, + required: false + }, + payloads: { + type: 'boolean', + 'default': true, + required: false + }, + preference: { + type: 'string', + required: false + }, + routing: { + type: 'string', + required: false + }, + parent: { + type: 'string', + required: false + }, + realtime: { + type: 'boolean', + required: false + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_mtermvectors', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + } + } + }, + { + fmt: '/<%=index%>/_mtermvectors', + req: { + index: { + type: 'string' + } + } + }, + { + fmt: '/_mtermvectors' + } + ], + method: 'POST' +}); + +api.nodes = namespace(); + +/** + * Perform a [nodes.hotThreads](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-nodes-hot-threads.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.interval - The interval for the second sampling of threads + * @param {<>} params.snapshots - Number of samples of thread stacktrace (default: 10) + * @param {<>} params.threads - Specify the number of threads to provide information for (default: 3) + * @param {<>} params.ignoreIdleThreads - Don't show threads that are in known-idle places, such as waiting on a socket select or pulling from an empty task queue (default: true) + * @param {<>} params.type - The type to sample (default: cpu) + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>, <>, <>} params.nodeId - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + */ +api.nodes.prototype.hotThreads = ca({ + params: { + interval: { + type: 'time' + }, + snapshots: { + type: 'number' + }, + threads: { + type: 'number' + }, + ignoreIdleThreads: { + type: 'boolean', + name: 'ignore_idle_threads' + }, + type: { + type: 'enum', + options: [ + 'cpu', + 'wait', + 'block' + ] + }, + timeout: { + type: 'time' + } + }, + urls: [ + { + fmt: '/_nodes/<%=nodeId%>/hotthreads', + req: { + nodeId: { + type: 'list' + } + } + }, + { + fmt: '/_nodes/hotthreads' + } + ] +}); + +/** + * Perform a [nodes.info](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-nodes-info.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.flatSettings - Return settings in flat format (default: false) + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>, <>, <>} params.nodeId - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * @param {<>, <>, <>} params.metric - A comma-separated list of metrics you wish returned. Leave empty to return all. + */ +api.nodes.prototype.info = ca({ + params: { + flatSettings: { + type: 'boolean', + name: 'flat_settings' + }, + timeout: { + type: 'time' + } + }, + urls: [ + { + fmt: '/_nodes/<%=nodeId%>/<%=metric%>', + req: { + nodeId: { + type: 'list' + }, + metric: { + type: 'list', + options: [ + 'settings', + 'os', + 'process', + 'jvm', + 'thread_pool', + 'transport', + 'http', + 'plugins', + 'ingest' + ] + } + } + }, + { + fmt: '/_nodes/<%=nodeId%>', + req: { + nodeId: { + type: 'list' + } + } + }, + { + fmt: '/_nodes/<%=metric%>', + req: { + metric: { + type: 'list', + options: [ + 'settings', + 'os', + 'process', + 'jvm', + 'thread_pool', + 'transport', + 'http', + 'plugins', + 'ingest' + ] + } + } + }, + { + fmt: '/_nodes' + } + ] +}); + +/** + * Perform a [nodes.stats](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-nodes-stats.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.completionFields - A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards) + * @param {<>, <>, <>} params.fielddataFields - A comma-separated list of fields for `fielddata` index metric (supports wildcards) + * @param {<>, <>, <>} params.fields - A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) + * @param {<>} params.groups - A comma-separated list of search groups for `search` index metric + * @param {<>} [params.level=node] - Return indices stats aggregated at index, node or shard level + * @param {<>, <>, <>} params.types - A comma-separated list of document types for the `indexing` index metric + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.includeSegmentFileSizes - Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) + * @param {<>, <>, <>} params.metric - Limit the information returned to the specified metrics + * @param {<>, <>, <>} params.indexMetric - Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified. + * @param {<>, <>, <>} params.nodeId - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + */ +api.nodes.prototype.stats = ca({ + params: { + completionFields: { + type: 'list', + name: 'completion_fields' + }, + fielddataFields: { + type: 'list', + name: 'fielddata_fields' + }, + fields: { + type: 'list' + }, + groups: { + type: 'boolean' + }, + level: { + type: 'enum', + 'default': 'node', + options: [ + 'indices', + 'node', + 'shards' + ] + }, + types: { + type: 'list' + }, + timeout: { + type: 'time' + }, + includeSegmentFileSizes: { + type: 'boolean', + 'default': false, + name: 'include_segment_file_sizes' + } + }, + urls: [ + { + fmt: '/_nodes/<%=nodeId%>/stats/<%=metric%>/<%=indexMetric%>', + req: { + nodeId: { + type: 'list' + }, + metric: { + type: 'list', + options: [ + '_all', + 'breaker', + 'fs', + 'http', + 'indices', + 'jvm', + 'os', + 'process', + 'thread_pool', + 'transport', + 'discovery' + ] + }, + indexMetric: { + type: 'list', + options: [ + '_all', + 'completion', + 'docs', + 'fielddata', + 'query_cache', + 'flush', + 'get', + 'indexing', + 'merge', + 'percolate', + 'request_cache', + 'refresh', + 'search', + 'segments', + 'store', + 'warmer', + 'suggest' + ] + } + } + }, + { + fmt: '/_nodes/<%=nodeId%>/stats/<%=metric%>', + req: { + nodeId: { + type: 'list' + }, + metric: { + type: 'list', + options: [ + '_all', + 'breaker', + 'fs', + 'http', + 'indices', + 'jvm', + 'os', + 'process', + 'thread_pool', + 'transport', + 'discovery' + ] + } + } + }, + { + fmt: '/_nodes/stats/<%=metric%>/<%=indexMetric%>', + req: { + metric: { + type: 'list', + options: [ + '_all', + 'breaker', + 'fs', + 'http', + 'indices', + 'jvm', + 'os', + 'process', + 'thread_pool', + 'transport', + 'discovery' + ] + }, + indexMetric: { + type: 'list', + options: [ + '_all', + 'completion', + 'docs', + 'fielddata', + 'query_cache', + 'flush', + 'get', + 'indexing', + 'merge', + 'percolate', + 'request_cache', + 'refresh', + 'search', + 'segments', + 'store', + 'warmer', + 'suggest' + ] + } + } + }, + { + fmt: '/_nodes/<%=nodeId%>/stats', + req: { + nodeId: { + type: 'list' + } + } + }, + { + fmt: '/_nodes/stats/<%=metric%>', + req: { + metric: { + type: 'list', + options: [ + '_all', + 'breaker', + 'fs', + 'http', + 'indices', + 'jvm', + 'os', + 'process', + 'thread_pool', + 'transport', + 'discovery' + ] + } + } + }, + { + fmt: '/_nodes/stats' + } + ] +}); + +/** + * Perform a [percolate](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-percolate.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.routing - A comma-separated list of specific routing values + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.percolateIndex - The index to percolate the document into. Defaults to index. + * @param {<>} params.percolateType - The type to percolate document into. Defaults to type. + * @param {<>} params.percolateRouting - The routing value to use when percolating the existing document. + * @param {<>} params.percolatePreference - Which shard to prefer when executing the percolate request. + * @param {<>} params.percolateFormat - Return an array of matching query IDs instead of objects + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.index - The index of the document being percolated. + * @param {<>} params.type - The type of the document being percolated. + * @param {<>} params.id - Substitute the document in the request body with a document that is known by the specified id. On top of the id, the index and type parameter will be used to retrieve the document from within the cluster. + */ +api.percolate = ca({ + params: { + routing: { + type: 'list' + }, + preference: { + type: 'string' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + percolateIndex: { + type: 'string', + name: 'percolate_index' + }, + percolateType: { + type: 'string', + name: 'percolate_type' + }, + percolateRouting: { + type: 'string', + name: 'percolate_routing' + }, + percolatePreference: { + type: 'string', + name: 'percolate_preference' + }, + percolateFormat: { + type: 'enum', + options: [ + 'ids' + ], + name: 'percolate_format' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/<%=id%>/_percolate', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + { + fmt: '/<%=index%>/<%=type%>/_percolate', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + } + } + } + ], + method: 'POST' +}); + +/** + * Perform a [ping](https://www.elastic.co/guide/) request + * + * @param {Object} params - An object with parameters used to carry out this action + */ +api.ping = ca({ + url: { + fmt: '/' + }, + requestTimeout: 3000, + method: 'HEAD' +}); + +/** + * Perform a [putScript](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-scripting.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.id - Script ID + * @param {<>} params.lang - Script language + */ +api.putScript = ca({ + urls: [ + { + fmt: '/_scripts/<%=lang%>/<%=id%>', + req: { + lang: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + { + fmt: '/_scripts/<%=lang%>', + req: { + lang: { + type: 'string' + } + } + } + ], + needBody: true, + method: 'PUT' +}); + +/** + * Perform a [putTemplate](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-template.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.id - Template ID + */ +api.putTemplate = ca({ + url: { + fmt: '/_search/template/<%=id%>', + req: { + id: { + type: 'string' + } + } + }, + needBody: true, + method: 'PUT' +}); + +/** + * Perform a [reindex](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-reindex.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.refresh - Should the effected indexes be refreshed? + * @param {<>} [params.timeout=1m] - Time each individual bulk request should wait for shards that are unavailable. + * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {<>} [params.waitForCompletion=true] - Should the request should block until the reindex is complete. + * @param {<>} params.requestsPerSecond - The throttle to set on this request in sub-requests per second. -1 means no throttle. + * @param {<>} [params.slices=1] - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. + */ +api.reindex = ca({ + params: { + refresh: { + type: 'boolean' + }, + timeout: { + type: 'time', + 'default': '1m' + }, + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + }, + waitForCompletion: { + type: 'boolean', + 'default': true, + name: 'wait_for_completion' + }, + requestsPerSecond: { + type: 'number', + 'default': 0, + name: 'requests_per_second' + }, + slices: { + type: 'number', + 'default': 1 + } + }, + url: { + fmt: '/_reindex' + }, + needBody: true, + method: 'POST' +}); + +/** + * Perform a [reindexRethrottle](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-reindex.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.requestsPerSecond - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. + * @param {<>} params.taskId - The task id to rethrottle + */ +api.reindexRethrottle = ca({ + params: { + requestsPerSecond: { + type: 'number', + required: true, + name: 'requests_per_second' + } + }, + url: { + fmt: '/_reindex/<%=taskId%>/_rethrottle', + req: { + taskId: { + type: 'string' + } + } + }, + method: 'POST' +}); + +api.remote = namespace(); + +/** + * Perform a [remote.info](http://www.elastic.co/guide/en/elasticsearch/reference/master/remote-info.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + */ +api.remote.prototype.info = ca({ + url: { + fmt: '/_remote/info' + } +}); + +/** + * Perform a [renderSearchTemplate](http://www.elasticsearch.org/guide/en/elasticsearch/reference/5.x/search-template.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.id - The id of the stored search template + */ +api.renderSearchTemplate = ca({ + urls: [ + { + fmt: '/_render/template/<%=id%>', + req: { + id: { + type: 'string' + } + } + }, + { + fmt: '/_render/template' + } + ], + method: 'POST' +}); + +/** + * Perform a [scroll](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-request-scroll.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.scroll - Specify how long a consistent view of the index should be maintained for scrolled search + * @param {<>} params.scrollId - The scroll ID + */ +api.scroll = ca({ + params: { + scroll: { + type: 'time' + }, + scrollId: { + type: 'string', + name: 'scroll_id' + } + }, + urls: [ + { + fmt: '/_search/scroll/<%=scrollId%>', + req: { + scrollId: { + type: 'string' + } + } + }, + { + fmt: '/_search/scroll' + } + ], + paramAsBody: { + param: 'scrollId', + body: 'scroll_id' + }, + method: 'POST' +}); + +/** + * Perform a [search](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-search.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.analyzer - The analyzer to use for the query string + * @param {<>} params.analyzeWildcard - Specify whether wildcard and prefix queries should be analyzed (default: false) + * @param {<>} [params.defaultOperator=OR] - The default operator for query string query (AND or OR) + * @param {<>} params.df - The field to use as default where no field prefix is given in the query string + * @param {<>} params.explain - Specify whether to return detailed information about score computation as part of a hit + * @param {<>, <>, <>} params.storedFields - A comma-separated list of stored fields to return as part of a hit + * @param {<>, <>, <>} params.docvalueFields - A comma-separated list of fields to return as the docvalue representation of a field for each hit + * @param {<>, <>, <>} params.fielddataFields - A comma-separated list of fields to return as the docvalue representation of a field for each hit + * @param {<>} params.from - Starting offset (default: 0) + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.q - Query in the Lucene query string syntax + * @param {<>, <>, <>} params.routing - A comma-separated list of specific routing values + * @param {<>} params.scroll - Specify how long a consistent view of the index should be maintained for scrolled search + * @param {<>} params.searchType - Search operation type + * @param {<>} params.size - Number of hits to return (default: 10) + * @param {<>, <>, <>} params.sort - A comma-separated list of : pairs + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.terminateAfter - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. + * @param {<>, <>, <>} params.stats - Specific 'tag' of the request for logging and statistical purposes + * @param {<>} params.suggestField - Specify which field to use for suggestions + * @param {<>} [params.suggestMode=missing] - Specify suggest mode + * @param {<>} params.suggestSize - How many suggestions to return in response + * @param {<>} params.suggestText - The source text for which the suggestions should be returned + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.trackScores - Whether to calculate and return scores even if they are not used for sorting + * @param {<>} params.typedKeys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * @param {<>} params.version - Specify whether to return document version as part of a hit + * @param {<>} params.requestCache - Specify if request cache should be used for this request or not, defaults to index level setting + * @param {<>} [params.batchedReduceSize=512] - The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. + * @param {<>, <>, <>} params.index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * @param {<>, <>, <>} params.type - A comma-separated list of document types to search; leave empty to perform the operation on all types + */ +api.search = ca({ + params: { + analyzer: { + type: 'string' + }, + analyzeWildcard: { + type: 'boolean', + name: 'analyze_wildcard' + }, + defaultOperator: { + type: 'enum', + 'default': 'OR', + options: [ + 'AND', + 'OR' + ], + name: 'default_operator' + }, + df: { + type: 'string' + }, + explain: { + type: 'boolean' + }, + storedFields: { + type: 'list', + name: 'stored_fields' + }, + docvalueFields: { + type: 'list', + name: 'docvalue_fields' + }, + fielddataFields: { + type: 'list', + name: 'fielddata_fields' + }, + from: { + type: 'number' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + lenient: { + type: 'boolean' + }, + preference: { + type: 'string' + }, + q: { + type: 'string' + }, + routing: { + type: 'list' + }, + scroll: { + type: 'time' + }, + searchType: { + type: 'enum', + options: [ + 'query_then_fetch', + 'dfs_query_then_fetch' + ], + name: 'search_type' + }, + size: { + type: 'number' + }, + sort: { + type: 'list' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + }, + terminateAfter: { + type: 'number', + name: 'terminate_after' + }, + stats: { + type: 'list' + }, + suggestField: { + type: 'string', + name: 'suggest_field' + }, + suggestMode: { + type: 'enum', + 'default': 'missing', + options: [ + 'missing', + 'popular', + 'always' + ], + name: 'suggest_mode' + }, + suggestSize: { + type: 'number', + name: 'suggest_size' + }, + suggestText: { + type: 'string', + name: 'suggest_text' + }, + timeout: { + type: 'time' + }, + trackScores: { + type: 'boolean', + name: 'track_scores' + }, + typedKeys: { + type: 'boolean', + name: 'typed_keys' + }, + version: { + type: 'boolean' + }, + requestCache: { + type: 'boolean', + name: 'request_cache' + }, + batchedReduceSize: { + type: 'number', + 'default': 512, + name: 'batched_reduce_size' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_search', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_search', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_search' + } + ], + method: 'POST' +}); + +/** + * Perform a [searchShards](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-shards.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.routing - Specific routing value + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>, <>, <>} params.index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * @param {<>, <>, <>} params.type - A comma-separated list of document types to search; leave empty to perform the operation on all types + */ +api.searchShards = ca({ + params: { + preference: { + type: 'string' + }, + routing: { + type: 'string' + }, + local: { + type: 'boolean' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_search_shards', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_search_shards', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_search_shards' + } + ], + method: 'POST' +}); + +/** + * Perform a [searchTemplate](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>, <>, <>} params.routing - A comma-separated list of specific routing values + * @param {<>} params.scroll - Specify how long a consistent view of the index should be maintained for scrolled search + * @param {<>} params.searchType - Search operation type + * @param {<>} params.explain - Specify whether to return detailed information about score computation as part of a hit + * @param {<>} params.profile - Specify whether to profile the query execution + * @param {<>} params.typedKeys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * @param {<>, <>, <>} params.index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * @param {<>, <>, <>} params.type - A comma-separated list of document types to search; leave empty to perform the operation on all types + */ +api.searchTemplate = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + preference: { + type: 'string' + }, + routing: { + type: 'list' + }, + scroll: { + type: 'time' + }, + searchType: { + type: 'enum', + options: [ + 'query_then_fetch', + 'query_and_fetch', + 'dfs_query_then_fetch', + 'dfs_query_and_fetch' + ], + name: 'search_type' + }, + explain: { + type: 'boolean' + }, + profile: { + type: 'boolean' + }, + typedKeys: { + type: 'boolean', + name: 'typed_keys' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_search/template', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_search/template', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_search/template' + } + ], + method: 'POST' +}); + +api.snapshot = namespace(); + +/** + * Perform a [snapshot.create](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.waitForCompletion - Should this request wait until the operation has completed before returning + * @param {<>} params.repository - A repository name + * @param {<>} params.snapshot - A snapshot name + */ +api.snapshot.prototype.create = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + waitForCompletion: { + type: 'boolean', + 'default': false, + name: 'wait_for_completion' + } + }, + url: { + fmt: '/_snapshot/<%=repository%>/<%=snapshot%>', + req: { + repository: { + type: 'string' + }, + snapshot: { + type: 'string' + } + } + }, + method: 'POST' +}); + +/** + * Perform a [snapshot.createRepository](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.verify - Whether to verify the repository after creation + * @param {<>} params.repository - A repository name + */ +api.snapshot.prototype.createRepository = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + timeout: { + type: 'time' + }, + verify: { + type: 'boolean' + } + }, + url: { + fmt: '/_snapshot/<%=repository%>', + req: { + repository: { + type: 'string' + } + } + }, + needBody: true, + method: 'POST' +}); + +/** + * Perform a [snapshot.delete](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.repository - A repository name + * @param {<>} params.snapshot - A snapshot name + */ +api.snapshot.prototype['delete'] = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + } + }, + url: { + fmt: '/_snapshot/<%=repository%>/<%=snapshot%>', + req: { + repository: { + type: 'string' + }, + snapshot: { + type: 'string' + } + } + }, + method: 'DELETE' +}); + +/** + * Perform a [snapshot.deleteRepository](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>, <>, <>} params.repository - A comma-separated list of repository names + */ +api.snapshot.prototype.deleteRepository = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + timeout: { + type: 'time' + } + }, + url: { + fmt: '/_snapshot/<%=repository%>', + req: { + repository: { + type: 'list' + } + } + }, + method: 'DELETE' +}); + +/** + * Perform a [snapshot.get](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.ignoreUnavailable - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown + * @param {<>} params.verbose - Whether to show verbose snapshot info or only show the basic info found in the repository index blob + * @param {<>} params.repository - A repository name + * @param {<>, <>, <>} params.snapshot - A comma-separated list of snapshot names + */ +api.snapshot.prototype.get = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + verbose: { + type: 'boolean' + } + }, + url: { + fmt: '/_snapshot/<%=repository%>/<%=snapshot%>', + req: { + repository: { + type: 'string' + }, + snapshot: { + type: 'list' + } + } + } +}); + +/** + * Perform a [snapshot.getRepository](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.local - Return local information, do not retrieve the state from master node (default: false) + * @param {<>, <>, <>} params.repository - A comma-separated list of repository names + */ +api.snapshot.prototype.getRepository = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + local: { + type: 'boolean' + } + }, + urls: [ + { + fmt: '/_snapshot/<%=repository%>', + req: { + repository: { + type: 'list' + } + } + }, + { + fmt: '/_snapshot' + } + ] +}); + +/** + * Perform a [snapshot.restore](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.waitForCompletion - Should this request wait until the operation has completed before returning + * @param {<>} params.repository - A repository name + * @param {<>} params.snapshot - A snapshot name + */ +api.snapshot.prototype.restore = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + waitForCompletion: { + type: 'boolean', + 'default': false, + name: 'wait_for_completion' + } + }, + url: { + fmt: '/_snapshot/<%=repository%>/<%=snapshot%>/_restore', + req: { + repository: { + type: 'string' + }, + snapshot: { + type: 'string' + } + } + }, + method: 'POST' +}); + +/** + * Perform a [snapshot.status](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.ignoreUnavailable - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown + * @param {<>} params.repository - A repository name + * @param {<>, <>, <>} params.snapshot - A comma-separated list of snapshot names + */ +api.snapshot.prototype.status = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + } + }, + urls: [ + { + fmt: '/_snapshot/<%=repository%>/<%=snapshot%>/_status', + req: { + repository: { + type: 'string' + }, + snapshot: { + type: 'list' + } + } + }, + { + fmt: '/_snapshot/<%=repository%>/_status', + req: { + repository: { + type: 'string' + } + } + }, + { + fmt: '/_snapshot/_status' + } + ] +}); + +/** + * Perform a [snapshot.verifyRepository](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.repository - A repository name + */ +api.snapshot.prototype.verifyRepository = ca({ + params: { + masterTimeout: { + type: 'time', + name: 'master_timeout' + }, + timeout: { + type: 'time' + } + }, + url: { + fmt: '/_snapshot/<%=repository%>/_verify', + req: { + repository: { + type: 'string' + } + } + }, + method: 'POST' +}); + +/** + * Perform a [suggest](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-suggesters.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.routing - Specific routing value + * @param {<>, <>, <>} params.index - A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices + */ +api.suggest = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + preference: { + type: 'string' + }, + routing: { + type: 'string' + } + }, + urls: [ + { + fmt: '/<%=index%>/_suggest', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_suggest' + } + ], + needBody: true, + method: 'POST' +}); + +api.tasks = namespace(); + +/** + * Perform a [tasks.cancel](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/tasks.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.nodeId - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * @param {<>, <>, <>} params.actions - A comma-separated list of actions that should be cancelled. Leave empty to cancel all. + * @param {<>} params.parentNode - Cancel tasks with specified parent node. + * @param {<>} params.parentTask - Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all. + * @param {<>} params.taskId - Cancel the task with specified task id (node_id:task_number) + */ +api.tasks.prototype.cancel = ca({ + params: { + nodeId: { + type: 'list', + name: 'node_id' + }, + actions: { + type: 'list' + }, + parentNode: { + type: 'string', + name: 'parent_node' + }, + parentTask: { + type: 'string', + name: 'parent_task' + } + }, + urls: [ + { + fmt: '/_tasks/<%=taskId%>/_cancel', + req: { + taskId: { + type: 'string' + } + } + }, + { + fmt: '/_tasks/_cancel' + } + ], + method: 'POST' +}); + +/** + * Perform a [tasks.get](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/tasks.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.waitForCompletion - Wait for the matching tasks to complete (default: false) + * @param {<>} params.taskId - Return the task with specified id (node_id:task_number) + */ +api.tasks.prototype.get = ca({ + params: { + waitForCompletion: { + type: 'boolean', + name: 'wait_for_completion' + } + }, + url: { + fmt: '/_tasks/<%=taskId%>', + req: { + taskId: { + type: 'string' + } + } + } +}); + +/** + * Perform a [tasks.list](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/tasks.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>, <>, <>} params.nodeId - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * @param {<>, <>, <>} params.actions - A comma-separated list of actions that should be returned. Leave empty to return all. + * @param {<>} params.detailed - Return detailed task information (default: false) + * @param {<>} params.parentNode - Return tasks with specified parent node. + * @param {<>} params.parentTask - Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all. + * @param {<>} params.waitForCompletion - Wait for the matching tasks to complete (default: false) + * @param {<>} [params.groupBy=nodes] - Group tasks by nodes or parent/child relationships + */ +api.tasks.prototype.list = ca({ + params: { + nodeId: { + type: 'list', + name: 'node_id' + }, + actions: { + type: 'list' + }, + detailed: { + type: 'boolean' + }, + parentNode: { + type: 'string', + name: 'parent_node' + }, + parentTask: { + type: 'string', + name: 'parent_task' + }, + waitForCompletion: { + type: 'boolean', + name: 'wait_for_completion' + }, + groupBy: { + type: 'enum', + 'default': 'nodes', + options: [ + 'nodes', + 'parents' + ], + name: 'group_by' + } + }, + url: { + fmt: '/_tasks' + } +}); + +/** + * Perform a [termvectors](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-termvectors.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.termStatistics - Specifies if total term frequency and document frequency should be returned. + * @param {<>} [params.fieldStatistics=true] - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. + * @param {<>, <>, <>} params.fields - A comma-separated list of fields to return. + * @param {<>} [params.offsets=true] - Specifies if term offsets should be returned. + * @param {<>} [params.positions=true] - Specifies if term positions should be returned. + * @param {<>} [params.payloads=true] - Specifies if term payloads should be returned. + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random). + * @param {<>} params.routing - Specific routing value. + * @param {<>} params.parent - Parent id of documents. + * @param {<>} params.realtime - Specifies if request is real-time as opposed to near-real-time (default: true). + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.index - The index in which the document resides. + * @param {<>} params.type - The type of the document. + * @param {<>} params.id - The id of the document, when not specified a doc param should be supplied. + */ +api.termvectors = ca({ + params: { + termStatistics: { + type: 'boolean', + 'default': false, + required: false, + name: 'term_statistics' + }, + fieldStatistics: { + type: 'boolean', + 'default': true, + required: false, + name: 'field_statistics' + }, + fields: { + type: 'list', + required: false + }, + offsets: { + type: 'boolean', + 'default': true, + required: false + }, + positions: { + type: 'boolean', + 'default': true, + required: false + }, + payloads: { + type: 'boolean', + 'default': true, + required: false + }, + preference: { + type: 'string', + required: false + }, + routing: { + type: 'string', + required: false + }, + parent: { + type: 'string', + required: false + }, + realtime: { + type: 'boolean', + required: false + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'external', + 'external_gte', + 'force' + ], + name: 'version_type' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/<%=id%>/_termvectors', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + { + fmt: '/<%=index%>/<%=type%>/_termvectors', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + } + } + } + ], + method: 'POST' +}); + +/** + * Perform a [update](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-update.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {<>, <>, <>} params.fields - A comma-separated list of fields to return in the response + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.lang - The script language (default: painless) + * @param {<>} params.parent - ID of the parent document. Is is only used for routing and when for the upsert request + * @param {<>} params.refresh - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + * @param {<>} params.retryOnConflict - Specify how many times should the operation be retried when a conflict occurs (default: 0) + * @param {<>} params.routing - Specific routing value + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>} params.timestamp - Explicit timestamp for the document + * @param {<>} params.ttl - Expiration time for the document + * @param {<>} params.version - Explicit version number for concurrency control + * @param {<>} params.versionType - Specific version type + * @param {<>} params.id - Document ID + * @param {<>} params.index - The name of the index + * @param {<>} params.type - The type of the document + */ +api.update = ca({ + params: { + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + }, + fields: { + type: 'list' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + }, + lang: { + type: 'string' + }, + parent: { + type: 'string' + }, + refresh: { + type: 'enum', + options: [ + 'true', + 'false', + 'wait_for', + '' + ] + }, + retryOnConflict: { + type: 'number', + name: 'retry_on_conflict' + }, + routing: { + type: 'string' + }, + timeout: { + type: 'time' + }, + timestamp: { + type: 'time' + }, + ttl: { + type: 'time' + }, + version: { + type: 'number' + }, + versionType: { + type: 'enum', + options: [ + 'internal', + 'force' + ], + name: 'version_type' + } + }, + url: { + fmt: '/<%=index%>/<%=type%>/<%=id%>/_update', + req: { + index: { + type: 'string' + }, + type: { + type: 'string' + }, + id: { + type: 'string' + } + } + }, + method: 'POST' +}); + +/** + * Perform a [updateByQuery](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-update-by-query.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.analyzer - The analyzer to use for the query string + * @param {<>} params.analyzeWildcard - Specify whether wildcard and prefix queries should be analyzed (default: false) + * @param {<>} [params.defaultOperator=OR] - The default operator for query string query (AND or OR) + * @param {<>} params.df - The field to use as default where no field prefix is given in the query string + * @param {<>} params.from - Starting offset (default: 0) + * @param {<>} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {<>} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {<>} [params.conflicts=abort] - What to do when the update by query hits version conflicts? + * @param {<>} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {<>} params.lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * @param {<>} params.pipeline - Ingest pipeline to set on index requests made by this action. (default: none) + * @param {<>} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {<>} params.q - Query in the Lucene query string syntax + * @param {<>, <>, <>} params.routing - A comma-separated list of specific routing values + * @param {<>} params.scroll - Specify how long a consistent view of the index should be maintained for scrolled search + * @param {<>} params.searchType - Search operation type + * @param {<>} params.searchTimeout - Explicit timeout for each search request. Defaults to no timeout. + * @param {<>} params.size - Number of hits to return (default: 10) + * @param {<>, <>, <>} params.sort - A comma-separated list of : pairs + * @param {<>, <>, <>} params._source - True or false to return the _source field or not, or a list of fields to return + * @param {<>, <>, <>} params._sourceExclude - A list of fields to exclude from the returned _source field + * @param {<>, <>, <>} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {<>} params.terminateAfter - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. + * @param {<>, <>, <>} params.stats - Specific 'tag' of the request for logging and statistical purposes + * @param {<>} params.version - Specify whether to return document version as part of a hit + * @param {<>} params.versionType - Should the document increment the version number (internal) on hit or not (reindex) + * @param {<>} params.requestCache - Specify if request cache should be used for this request or not, defaults to index level setting + * @param {<>} params.refresh - Should the effected indexes be refreshed? + * @param {<>} [params.timeout=1m] - Time each individual bulk request should wait for shards that are unavailable. + * @param {<>} params.waitForActiveShards - Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {<>} params.scrollSize - Size on the scroll request powering the update_by_query + * @param {<>} [params.waitForCompletion=true] - Should the request should block until the update by query operation is complete. + * @param {<>} params.requestsPerSecond - The throttle to set on this request in sub-requests per second. -1 means no throttle. + * @param {<>} [params.slices=1] - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. + * @param {<>, <>, <>} params.index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * @param {<>, <>, <>} params.type - A comma-separated list of document types to search; leave empty to perform the operation on all types + */ +api.updateByQuery = ca({ + params: { + analyzer: { + type: 'string' + }, + analyzeWildcard: { + type: 'boolean', + name: 'analyze_wildcard' + }, + defaultOperator: { + type: 'enum', + 'default': 'OR', + options: [ + 'AND', + 'OR' + ], + name: 'default_operator' + }, + df: { + type: 'string' + }, + from: { + type: 'number' + }, + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + conflicts: { + type: 'enum', + 'default': 'abort', + options: [ + 'abort', + 'proceed' + ] + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed', + 'none', + 'all' + ], + name: 'expand_wildcards' + }, + lenient: { + type: 'boolean' + }, + pipeline: { + type: 'string' + }, + preference: { + type: 'string' + }, + q: { + type: 'string' + }, + routing: { + type: 'list' + }, + scroll: { + type: 'time' + }, + searchType: { + type: 'enum', + options: [ + 'query_then_fetch', + 'dfs_query_then_fetch' + ], + name: 'search_type' + }, + searchTimeout: { + type: 'time', + name: 'search_timeout' + }, + size: { + type: 'number' + }, + sort: { + type: 'list' + }, + _source: { + type: 'list' + }, + _sourceExclude: { + type: 'list', + name: '_source_exclude' + }, + _sourceInclude: { + type: 'list', + name: '_source_include' + }, + terminateAfter: { + type: 'number', + name: 'terminate_after' + }, + stats: { + type: 'list' + }, + version: { + type: 'boolean' + }, + versionType: { + type: 'boolean', + name: 'version_type' + }, + requestCache: { + type: 'boolean', + name: 'request_cache' + }, + refresh: { + type: 'boolean' + }, + timeout: { + type: 'time', + 'default': '1m' + }, + waitForActiveShards: { + type: 'string', + name: 'wait_for_active_shards' + }, + scrollSize: { + type: 'number', + name: 'scroll_size' + }, + waitForCompletion: { + type: 'boolean', + 'default': true, + name: 'wait_for_completion' + }, + requestsPerSecond: { + type: 'number', + 'default': 0, + name: 'requests_per_second' + }, + slices: { + type: 'number', + 'default': 1 + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_update_by_query', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_update_by_query', + req: { + index: { + type: 'list' + } + } + } + ], + method: 'POST' +}); diff --git a/src/lib/apis/5_x.js b/src/lib/apis/5_x.js index 63a9f4270..bc106e4ab 100644 --- a/src/lib/apis/5_x.js +++ b/src/lib/apis/5_x.js @@ -11,7 +11,7 @@ var ca = require('../client_action').makeFactoryWithModifier(function (spec) { var namespace = require('../client_action').namespaceFactory; var api = module.exports = {}; -api._namespaces = ['cat', 'cluster', 'indices', 'ingest', 'nodes', 'remote', 'snapshot', 'tasks']; +api._namespaces = ['cat', 'cluster', 'indices', 'ingest', 'ingest.processor', 'nodes', 'remote', 'snapshot', 'tasks']; /** * Perform a [bulk](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-bulk.html) request @@ -4982,6 +4982,17 @@ api.ingest.prototype.getPipeline = ca({ ] }); +/** + * Perform a [ingest.processor.grok](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + */ +api.ingest.prototype.processor.prototype.grok = ca({ + url: { + fmt: '/_ingest/processor/grok' + } +}); + /** * Perform a [ingest.putPipeline](https://www.elastic.co/guide/en/elasticsearch/plugins/5.x/ingest.html) request * @@ -5243,6 +5254,7 @@ api.msearch = ca({ * @param {Object} params - An object with parameters used to carry out this action * @param {<>} params.searchType - Search operation type * @param {<>} params.typedKeys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * @param {<>} params.maxConcurrentSearches - Controls the maximum number of concurrent searches the multi search api will execute * @param {<>, <>, <>} params.index - A comma-separated list of index names to use as default * @param {<>, <>, <>} params.type - A comma-separated list of document types to use as default */ @@ -5261,6 +5273,10 @@ api.msearchTemplate = ca({ typedKeys: { type: 'boolean', name: 'typed_keys' + }, + maxConcurrentSearches: { + type: 'number', + name: 'max_concurrent_searches' } }, urls: [ @@ -6584,6 +6600,7 @@ api.snapshot.prototype.deleteRepository = ca({ * @param {Object} params - An object with parameters used to carry out this action * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node * @param {<>} params.ignoreUnavailable - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown + * @param {<>} params.verbose - Whether to show verbose snapshot info or only show the basic info found in the repository index blob * @param {<>} params.repository - A repository name * @param {<>, <>, <>} params.snapshot - A comma-separated list of snapshot names */ @@ -6596,6 +6613,9 @@ api.snapshot.prototype.get = ca({ ignoreUnavailable: { type: 'boolean', name: 'ignore_unavailable' + }, + verbose: { + type: 'boolean' } }, url: { diff --git a/src/lib/apis/browser_index.js b/src/lib/apis/browser_index.js index 2290a3d3f..6b1e0d7a9 100644 --- a/src/lib/apis/browser_index.js +++ b/src/lib/apis/browser_index.js @@ -1,11 +1,11 @@ module.exports = { + '5.4': require('./5_4'), '_default': require('./5_3'), '5.3': require('./5_3'), '5.2': require('./5_2'), '5.1': require('./5_1'), '5.0': require('./5_0'), - '2.4': require('./2_4'), '5.x': require('./5_x'), - '5.4': require('./5_4'), + '5.5': require('./5_5'), 'master': require('./master') }; diff --git a/src/lib/apis/index.js b/src/lib/apis/index.js index a0154486c..9b0b1e9b4 100644 --- a/src/lib/apis/index.js +++ b/src/lib/apis/index.js @@ -1,4 +1,5 @@ module.exports = { + get '5.4'() { return require('./5_4'); }, get '_default'() { return require('./5_3'); }, get '5.3'() { return require('./5_3'); }, get '5.2'() { return require('./5_2'); }, @@ -8,6 +9,6 @@ module.exports = { get '1.7'() { return require('./1_7'); }, get '0.90'() { return require('./0_90'); }, get '5.x'() { return require('./5_x'); }, - get '5.4'() { return require('./5_4'); }, + get '5.5'() { return require('./5_5'); }, get 'master'() { return require('./master'); }, }; diff --git a/src/lib/apis/master.js b/src/lib/apis/master.js index 449fa1a36..f5a0c8e88 100644 --- a/src/lib/apis/master.js +++ b/src/lib/apis/master.js @@ -11,7 +11,7 @@ var ca = require('../client_action').makeFactoryWithModifier(function (spec) { var namespace = require('../client_action').namespaceFactory; var api = module.exports = {}; -api._namespaces = ['cat', 'cluster', 'indices', 'ingest', 'nodes', 'remote', 'snapshot', 'tasks']; +api._namespaces = ['cat', 'cluster', 'indices', 'ingest', 'ingest.processor', 'nodes', 'remote', 'snapshot', 'tasks']; /** * Perform a [bulk](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html) request @@ -3453,7 +3453,6 @@ api.indices.prototype.forcemerge = ca({ * @param {<>} params.flatSettings - Return settings in flat format (default: false) * @param {<>} params.includeDefaults - Whether to return all default setting for each of the indices. * @param {<>, <>, <>} params.index - A comma-separated list of index names - * @param {<>, <>, <>} params.feature - A comma-separated list of features */ api.indices.prototype.get = ca({ params: { @@ -3489,32 +3488,14 @@ api.indices.prototype.get = ca({ name: 'include_defaults' } }, - urls: [ - { - fmt: '/<%=index%>/<%=feature%>', - req: { - index: { - type: 'list' - }, - feature: { - type: 'list', - options: [ - '_settings', - '_mappings', - '_aliases' - ] - } - } - }, - { - fmt: '/<%=index%>', - req: { - index: { - type: 'list' - } + url: { + fmt: '/<%=index%>', + req: { + index: { + type: 'list' } } - ] + } }); /** @@ -4851,6 +4832,17 @@ api.ingest.prototype.getPipeline = ca({ ] }); +/** + * Perform a [ingest.processor.grok](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + */ +api.ingest.prototype.processor.prototype.grok = ca({ + url: { + fmt: '/_ingest/processor/grok' + } +}); + /** * Perform a [ingest.putPipeline](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request * @@ -5051,6 +5043,7 @@ api.msearch = ca({ * @param {Object} params - An object with parameters used to carry out this action * @param {<>} params.searchType - Search operation type * @param {<>} params.typedKeys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * @param {<>} params.maxConcurrentSearches - Controls the maximum number of concurrent searches the multi search api will execute * @param {<>, <>, <>} params.index - A comma-separated list of index names to use as default * @param {<>, <>, <>} params.type - A comma-separated list of document types to use as default */ @@ -5069,6 +5062,10 @@ api.msearchTemplate = ca({ typedKeys: { type: 'boolean', name: 'typed_keys' + }, + maxConcurrentSearches: { + type: 'number', + name: 'max_concurrent_searches' } }, urls: [ @@ -5545,6 +5542,67 @@ api.nodes.prototype.stats = ca({ ] }); +/** + * Perform a [nodes.usage](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.human - Whether to return time and byte values in human-readable format. + * @param {<>} params.timeout - Explicit operation timeout + * @param {<>, <>, <>} params.metric - Limit the information returned to the specified metrics + * @param {<>, <>, <>} params.nodeId - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + */ +api.nodes.prototype.usage = ca({ + params: { + human: { + type: 'boolean', + 'default': false + }, + timeout: { + type: 'time' + } + }, + urls: [ + { + fmt: '/_nodes/<%=nodeId%>/usage/<%=metric%>', + req: { + nodeId: { + type: 'list' + }, + metric: { + type: 'list', + options: [ + '_all', + 'rest_actions' + ] + } + } + }, + { + fmt: '/_nodes/<%=nodeId%>/usage', + req: { + nodeId: { + type: 'list' + } + } + }, + { + fmt: '/_nodes/usage/<%=metric%>', + req: { + metric: { + type: 'list', + options: [ + '_all', + 'rest_actions' + ] + } + } + }, + { + fmt: '/_nodes/usage' + } + ] +}); + /** * Perform a [ping](http://www.elastic.co/guide/) request * @@ -5562,10 +5620,16 @@ api.ping = ca({ * Perform a [putScript](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html) request * * @param {Object} params - An object with parameters used to carry out this action + * @param {<>} params.context - Context name to compile script against * @param {<>} params.id - Script ID * @param {<>} params.lang - Script language */ api.putScript = ca({ + params: { + context: { + type: 'string' + } + }, urls: [ { fmt: '/_scripts/<%=lang%>/<%=id%>', @@ -5579,9 +5643,9 @@ api.putScript = ca({ } }, { - fmt: '/_scripts/<%=lang%>', + fmt: '/_scripts/<%=id%>', req: { - lang: { + id: { type: 'string' } } @@ -5790,6 +5854,7 @@ api.scroll = ca({ * @param {<>} params.suggestText - The source text for which the suggestions should be returned * @param {<>} params.timeout - Explicit operation timeout * @param {<>} params.trackScores - Whether to calculate and return scores even if they are not used for sorting + * @param {<>} params.trackTotalHits - Indicate if the number of documents that match the query should be tracked * @param {<>} params.typedKeys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response * @param {<>} params.version - Specify whether to return document version as part of a hit * @param {<>} params.requestCache - Specify if request cache should be used for this request or not, defaults to index level setting @@ -5931,6 +5996,10 @@ api.search = ca({ type: 'boolean', name: 'track_scores' }, + trackTotalHits: { + type: 'boolean', + name: 'track_total_hits' + }, typedKeys: { type: 'boolean', name: 'typed_keys' @@ -6264,6 +6333,7 @@ api.snapshot.prototype.deleteRepository = ca({ * @param {Object} params - An object with parameters used to carry out this action * @param {<>} params.masterTimeout - Explicit operation timeout for connection to master node * @param {<>} params.ignoreUnavailable - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown + * @param {<>} params.verbose - Whether to show verbose snapshot info or only show the basic info found in the repository index blob * @param {<>} params.repository - A repository name * @param {<>, <>, <>} params.snapshot - A comma-separated list of snapshot names */ @@ -6276,6 +6346,9 @@ api.snapshot.prototype.get = ca({ ignoreUnavailable: { type: 'boolean', name: 'ignore_unavailable' + }, + verbose: { + type: 'boolean' } }, url: { From 50898d3fc5fcce6a894a5d1dfee71dd819954ddd Mon Sep 17 00:00:00 2001 From: spalger Date: Mon, 12 Jun 2017 10:54:15 -0700 Subject: [PATCH 25/61] change default api branch to 5.4 --- docs/api_methods.asciidoc | 170 ++++++- ..._5_4.asciidoc => api_methods_5_3.asciidoc} | 416 ++++++------------ docs/configuration.asciidoc | 2 +- docs/index.asciidoc | 4 +- package.json | 2 +- src/lib/apis/browser_index.js | 2 +- src/lib/apis/index.js | 2 +- 7 files changed, 299 insertions(+), 299 deletions(-) rename docs/{api_methods_5_4.asciidoc => api_methods_5_3.asciidoc} (95%) diff --git a/docs/api_methods.asciidoc b/docs/api_methods.asciidoc index 899c0b996..334feb120 100644 --- a/docs/api_methods.asciidoc +++ b/docs/api_methods.asciidoc @@ -1,5 +1,5 @@ [[api-reference]] -== 5.3 API +== 5.4 API NOTE: This is currently the default API, but in upcoming versions that will change. We recommend setting the `apiVersion` config param when you instantiate your client to make sure that the API does not change unexpectedly. @@ -620,6 +620,8 @@ client.exists({ *Params* [horizontal] +`storedFields`:: +<>, <>, <> -- A comma-separated list of stored fields to return in the response `parent`:: <> -- The ID of the parent document `preference`:: @@ -630,6 +632,22 @@ client.exists({ <> -- Refresh the shard containing the document before performing the operation `routing`:: <> -- Specific routing value +`_source`:: +<>, <>, <> -- True or false to return the _source field or not, or a list of fields to return +`_sourceExclude`:: +<>, <>, <> -- A list of fields to exclude from the returned _source field +`_sourceInclude`:: +<>, <>, <> -- A list of fields to extract and return from the _source field +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"external"` + * `"external_gte"` + * `"force"` + `id`:: <> -- The document ID `index`:: @@ -641,6 +659,61 @@ client.exists({ link:#[back to top] +[[api-existssource]] +=== `existsSource` + +[source,js] +-------- +client.existsSource([params, [callback]]) +-------- + +// no description + +Check the *<>* and http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`parent`:: +<> -- The ID of the parent document +`preference`:: +<> -- Specify the node or shard the operation should be performed on (default: random) +`realtime`:: +<> -- Specify whether to perform the operation in realtime or search mode +`refresh`:: +<> -- Refresh the shard containing the document before performing the operation +`routing`:: +<> -- Specific routing value +`_source`:: +<>, <>, <> -- True or false to return the _source field or not, or a list of fields to return +`_sourceExclude`:: +<>, <>, <> -- A list of fields to exclude from the returned _source field +`_sourceInclude`:: +<>, <>, <> -- A list of fields to extract and return from the _source field +`version`:: +<> -- Explicit version number for concurrency control +`versionType`:: +<> -- Specific version type +Options::: + * `"internal"` + * `"external"` + * `"external_gte"` + * `"force"` + +`id`:: +<> -- The document ID +`index`:: +<> -- The name of the index +`type`:: +<> -- The type of the document; use `_all` to fetch the first document matching the ID across all types +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + [[api-explain]] === `explain` @@ -731,6 +804,45 @@ Options::: link:#[back to top] +[[api-fieldcaps]] +=== `fieldCaps` + +[source,js] +-------- +client.fieldCaps([params, [callback]]) +-------- + +// no description + +Check the *<>* and http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + +*Params* + +[horizontal] +`fields`:: +<>, <>, <> -- A comma-separated list of field names +`ignoreUnavailable`:: +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +`allowNoIndices`:: +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +`[expandWildcards=open]`:: +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +Options::: + * `"open"` + * `"closed"` + * `"none"` + * `"all"` + +`index`:: +<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +`body`:: +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html[the elasticsearch docs] for details about what can be specified here. + +link:#[back to top] + [[api-fieldstats]] === `fieldStats` @@ -1199,6 +1311,8 @@ Options::: `maxConcurrentSearches`:: <> -- Controls the maximum number of concurrent searches the multi search api will execute +`typedKeys`:: +<> -- Specify whether aggregation and suggester names should be prefixed by their respective types in the response `index`:: <>, <>, <> -- A comma-separated list of index names to use as default `type`:: @@ -1234,6 +1348,8 @@ Options::: * `"dfs_query_then_fetch"` * `"dfs_query_and_fetch"` +`typedKeys`:: +<> -- Specify whether aggregation and suggester names should be prefixed by their respective types in the response `index`:: <>, <>, <> -- A comma-separated list of index names to use as default `type`:: @@ -1789,10 +1905,14 @@ Options::: <> -- Explicit operation timeout `trackScores`:: <> -- Whether to calculate and return scores even if they are not used for sorting +`typedKeys`:: +<> -- Specify whether aggregation and suggester names should be prefixed by their respective types in the response `version`:: <> -- Specify whether to return document version as part of a hit `requestCache`:: <> -- Specify if request cache should be used for this request or not, defaults to index level setting +`[batchedReduceSize=512]`:: +<> -- The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. `index`:: <>, <>, <> -- A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices `type`:: @@ -1895,6 +2015,8 @@ Options::: <> -- Specify whether to return detailed information about score computation as part of a hit `profile`:: <> -- Specify whether to profile the query execution +`typedKeys`:: +<> -- Specify whether aggregation and suggester names should be prefixed by their respective types in the response `index`:: <>, <>, <> -- A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices `type`:: @@ -3443,6 +3565,8 @@ Options::: <>, <>, <> -- A comma-separated list of index name to limit the operation `recycler`:: <> -- Clear the recycler cache +`requestCache`:: +<> -- Clear request cache `request`:: <> -- Clear request cache `body`:: @@ -3624,7 +3748,7 @@ client.indices.exists([params, [callback]]) Return a boolean indicating whether given index exists. -Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-exists.html[the elasticsearch docs] for more information pertaining to this method. +Check the *<>* and http://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-exists.html[the elasticsearch docs] for more information pertaining to this method. // no examples @@ -3632,24 +3756,28 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc *Params* [horizontal] +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) `ignoreUnavailable`:: -<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) +<> -- Ignore unavailable indexes (default: false) `allowNoIndices`:: -<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +<> -- Ignore if a wildcard expression resolves to no concrete indices (default: false) `[expandWildcards=open]`:: -<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. +<> -- Whether wildcard expressions should get expanded to open or closed indices (default: open) Options::: * `"open"` * `"closed"` * `"none"` * `"all"` -`local`:: -<> -- Return local information, do not retrieve the state from master node (default: false) +`flatSettings`:: +<> -- Return settings in flat format (default: false) +`includeDefaults`:: +<> -- Whether to return all default setting for each of the indices. `index`:: -<>, <>, <> -- A comma-separated list of indices to check +<>, <>, <> -- A comma-separated list of index names `body`:: -<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-exists.html[the elasticsearch docs] for details about what can be specified here. +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See http://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-exists.html[the elasticsearch docs] for details about what can be specified here. link:#[back to top] @@ -3675,7 +3803,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc <> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) `allowNoIndices`:: <> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) -`[expandWildcards=open,closed]`:: +`[expandWildcards=all]`:: <> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. Options::: * `"open"` @@ -3712,12 +3840,14 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc *Params* [horizontal] +`flatSettings`:: +<> -- Return settings in flat format (default: false) `masterTimeout`:: <> -- Explicit operation timeout for connection to master node `local`:: <> -- Return local information, do not retrieve the state from master node (default: false) `name`:: -<> -- The name of the template +<>, <>, <> -- The comma separated names of the index templates `body`:: <>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html[the elasticsearch docs] for details about what can be specified here. @@ -4746,6 +4876,8 @@ Options::: <> -- Specify whether format-based query failures (such as providing text to a numeric field) should be ignored `rewrite`:: <> -- Provide a more detailed explanation showing the actual Lucene query that will be executed. +`allShards`:: +<> -- Execute validation on all shards instead of one random shard per index `index`:: <>, <>, <> -- A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices `type`:: @@ -4982,6 +5114,22 @@ Options::: link:#[back to top] +[[api-remote-info]] +=== `remote.info` + +[source,js] +-------- +client.remote.info([params, [callback]]) +-------- + +// no description + +Check the *<>* and http://www.elastic.co/guide/en/elasticsearch/reference/master/remote-info.html[the elasticsearch docs] for more information pertaining to this method. + +// no examples + + + [[api-snapshot-create]] === `snapshot.create` diff --git a/docs/api_methods_5_4.asciidoc b/docs/api_methods_5_3.asciidoc similarity index 95% rename from docs/api_methods_5_4.asciidoc rename to docs/api_methods_5_3.asciidoc index 5f25e9fb4..c041487b6 100644 --- a/docs/api_methods_5_4.asciidoc +++ b/docs/api_methods_5_3.asciidoc @@ -1,11 +1,11 @@ -[[api-reference-5-4]] -== 5.4 API +[[api-reference-5-3]] +== 5.3 API -NOTE: At this time, you must opt into the 5.4 API by setting the `apiVersion` config parameter. +NOTE: At this time, you must opt into the 5.3 API by setting the `apiVersion` config parameter. -[[api-bulk-5-4]] +[[api-bulk-5-3]] === `bulk` [source,js] @@ -76,7 +76,7 @@ Options::: link:#[back to top] -[[api-clearscroll-5-4]] +[[api-clearscroll-5-3]] === `clearScroll` [source,js] @@ -101,7 +101,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-count-5-4]] +[[api-count-5-3]] === `count` [source,js] @@ -201,7 +201,7 @@ Options::: link:#[back to top] -[[api-countpercolate-5-4]] +[[api-countpercolate-5-3]] === `countPercolate` [source,js] @@ -260,7 +260,7 @@ Options::: link:#[back to top] -[[api-create-5-4]] +[[api-create-5-3]] === `create` [source,js] @@ -338,7 +338,7 @@ Options::: link:#[back to top] -[[api-delete-5-4]] +[[api-delete-5-3]] === `delete` [source,js] @@ -403,7 +403,7 @@ Options::: link:#[back to top] -[[api-deletebyquery-5-4]] +[[api-deletebyquery-5-3]] === `deleteByQuery` [source,js] @@ -536,7 +536,7 @@ Options::: link:#[back to top] -[[api-deletescript-5-4]] +[[api-deletescript-5-3]] === `deleteScript` [source,js] @@ -563,7 +563,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-deletetemplate-5-4]] +[[api-deletetemplate-5-3]] === `deleteTemplate` [source,js] @@ -588,7 +588,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-exists-5-4]] +[[api-exists-5-3]] === `exists` [source,js] @@ -620,8 +620,6 @@ client.exists({ *Params* [horizontal] -`storedFields`:: -<>, <>, <> -- A comma-separated list of stored fields to return in the response `parent`:: <> -- The ID of the parent document `preference`:: @@ -632,22 +630,6 @@ client.exists({ <> -- Refresh the shard containing the document before performing the operation `routing`:: <> -- Specific routing value -`_source`:: -<>, <>, <> -- True or false to return the _source field or not, or a list of fields to return -`_sourceExclude`:: -<>, <>, <> -- A list of fields to exclude from the returned _source field -`_sourceInclude`:: -<>, <>, <> -- A list of fields to extract and return from the _source field -`version`:: -<> -- Explicit version number for concurrency control -`versionType`:: -<> -- Specific version type -Options::: - * `"internal"` - * `"external"` - * `"external_gte"` - * `"force"` - `id`:: <> -- The document ID `index`:: @@ -659,62 +641,7 @@ Options::: link:#[back to top] -[[api-existssource-5-4]] -=== `existsSource` - -[source,js] --------- -client.existsSource([params, [callback]]) --------- - -// no description - -Check the *<>* and http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html[the elasticsearch docs] for more information pertaining to this method. - -// no examples - - -*Params* - -[horizontal] -`parent`:: -<> -- The ID of the parent document -`preference`:: -<> -- Specify the node or shard the operation should be performed on (default: random) -`realtime`:: -<> -- Specify whether to perform the operation in realtime or search mode -`refresh`:: -<> -- Refresh the shard containing the document before performing the operation -`routing`:: -<> -- Specific routing value -`_source`:: -<>, <>, <> -- True or false to return the _source field or not, or a list of fields to return -`_sourceExclude`:: -<>, <>, <> -- A list of fields to exclude from the returned _source field -`_sourceInclude`:: -<>, <>, <> -- A list of fields to extract and return from the _source field -`version`:: -<> -- Explicit version number for concurrency control -`versionType`:: -<> -- Specific version type -Options::: - * `"internal"` - * `"external"` - * `"external_gte"` - * `"force"` - -`id`:: -<> -- The document ID -`index`:: -<> -- The name of the index -`type`:: -<> -- The type of the document; use `_all` to fetch the first document matching the ID across all types -`body`:: -<>, <> -- An optional request body, as either JSON or a JSON serializable object. See http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html[the elasticsearch docs] for details about what can be specified here. - -link:#[back to top] - -[[api-explain-5-4]] +[[api-explain-5-3]] === `explain` [source,js] @@ -804,46 +731,7 @@ Options::: link:#[back to top] -[[api-fieldcaps-5-4]] -=== `fieldCaps` - -[source,js] --------- -client.fieldCaps([params, [callback]]) --------- - -// no description - -Check the *<>* and http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html[the elasticsearch docs] for more information pertaining to this method. - -// no examples - - -*Params* - -[horizontal] -`fields`:: -<>, <>, <> -- A comma-separated list of field names -`ignoreUnavailable`:: -<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) -`allowNoIndices`:: -<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) -`[expandWildcards=open]`:: -<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. -Options::: - * `"open"` - * `"closed"` - * `"none"` - * `"all"` - -`index`:: -<>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices -`body`:: -<>, <> -- An optional request body, as either JSON or a JSON serializable object. See http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html[the elasticsearch docs] for details about what can be specified here. - -link:#[back to top] - -[[api-fieldstats-5-4]] +[[api-fieldstats-5-3]] === `fieldStats` [source,js] @@ -888,7 +776,7 @@ Options::: link:#[back to top] -[[api-get-5-4]] +[[api-get-5-3]] === `get` [source,js] @@ -953,7 +841,7 @@ Options::: link:#[back to top] -[[api-getscript-5-4]] +[[api-getscript-5-3]] === `getScript` [source,js] @@ -978,7 +866,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-getsource-5-4]] +[[api-getsource-5-3]] === `getSource` [source,js] @@ -1032,7 +920,7 @@ Options::: link:#[back to top] -[[api-gettemplate-5-4]] +[[api-gettemplate-5-3]] === `getTemplate` [source,js] @@ -1055,7 +943,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-index-5-4]] +[[api-index-5-3]] === `index` [source,js] @@ -1142,7 +1030,7 @@ Options::: link:#[back to top] -[[api-info-5-4]] +[[api-info-5-3]] === `info` [source,js] @@ -1158,7 +1046,7 @@ Check the *<>* and https://www.elastic.co/guide/[the elasticsea -[[api-mget-5-4]] +[[api-mget-5-3]] === `mget` [source,js] @@ -1229,7 +1117,7 @@ client.mget({ link:#[back to top] -[[api-mpercolate-5-4]] +[[api-mpercolate-5-3]] === `mpercolate` [source,js] @@ -1268,7 +1156,7 @@ Options::: link:#[back to top] -[[api-msearch-5-4]] +[[api-msearch-5-3]] === `msearch` [source,js] @@ -1311,8 +1199,6 @@ Options::: `maxConcurrentSearches`:: <> -- Controls the maximum number of concurrent searches the multi search api will execute -`typedKeys`:: -<> -- Specify whether aggregation and suggester names should be prefixed by their respective types in the response `index`:: <>, <>, <> -- A comma-separated list of index names to use as default `type`:: @@ -1322,7 +1208,7 @@ Options::: link:#[back to top] -[[api-msearchtemplate-5-4]] +[[api-msearchtemplate-5-3]] === `msearchTemplate` [source,js] @@ -1348,8 +1234,6 @@ Options::: * `"dfs_query_then_fetch"` * `"dfs_query_and_fetch"` -`typedKeys`:: -<> -- Specify whether aggregation and suggester names should be prefixed by their respective types in the response `index`:: <>, <>, <> -- A comma-separated list of index names to use as default `type`:: @@ -1359,7 +1243,7 @@ Options::: link:#[back to top] -[[api-mtermvectors-5-4]] +[[api-mtermvectors-5-3]] === `mtermvectors` [source,js] @@ -1418,7 +1302,7 @@ Options::: link:#[back to top] -[[api-percolate-5-4]] +[[api-percolate-5-3]] === `percolate` [source,js] @@ -1559,7 +1443,7 @@ Options::: link:#[back to top] -[[api-ping-5-4]] +[[api-ping-5-3]] === `ping` [source,js] @@ -1575,7 +1459,7 @@ Check the *<>* and https://www.elastic.co/guide/[the elasticsea -[[api-putscript-5-4]] +[[api-putscript-5-3]] === `putScript` [source,js] @@ -1602,7 +1486,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-puttemplate-5-4]] +[[api-puttemplate-5-3]] === `putTemplate` [source,js] @@ -1627,7 +1511,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-reindex-5-4]] +[[api-reindex-5-3]] === `reindex` [source,js] @@ -1662,7 +1546,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-reindexrethrottle-5-4]] +[[api-reindexrethrottle-5-3]] === `reindexRethrottle` [source,js] @@ -1689,7 +1573,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-rendersearchtemplate-5-4]] +[[api-rendersearchtemplate-5-3]] === `renderSearchTemplate` [source,js] @@ -1714,7 +1598,7 @@ Check the *<>* and http://www.elasticsearch.org/guide/en/elasti link:#[back to top] -[[api-scroll-5-4]] +[[api-scroll-5-3]] === `scroll` [source,js] @@ -1769,7 +1653,7 @@ client.search({ link:#[back to top] -[[api-search-5-4]] +[[api-search-5-3]] === `search` [source,js] @@ -1905,14 +1789,10 @@ Options::: <> -- Explicit operation timeout `trackScores`:: <> -- Whether to calculate and return scores even if they are not used for sorting -`typedKeys`:: -<> -- Specify whether aggregation and suggester names should be prefixed by their respective types in the response `version`:: <> -- Specify whether to return document version as part of a hit `requestCache`:: <> -- Specify if request cache should be used for this request or not, defaults to index level setting -`[batchedReduceSize=512]`:: -<> -- The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. `index`:: <>, <>, <> -- A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices `type`:: @@ -1922,7 +1802,7 @@ Options::: link:#[back to top] -[[api-searchshards-5-4]] +[[api-searchshards-5-3]] === `searchShards` [source,js] @@ -1967,7 +1847,7 @@ Options::: link:#[back to top] -[[api-searchtemplate-5-4]] +[[api-searchtemplate-5-3]] === `searchTemplate` [source,js] @@ -2015,8 +1895,6 @@ Options::: <> -- Specify whether to return detailed information about score computation as part of a hit `profile`:: <> -- Specify whether to profile the query execution -`typedKeys`:: -<> -- Specify whether aggregation and suggester names should be prefixed by their respective types in the response `index`:: <>, <>, <> -- A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices `type`:: @@ -2026,7 +1904,7 @@ Options::: link:#[back to top] -[[api-suggest-5-4]] +[[api-suggest-5-3]] === `suggest` [source,js] @@ -2100,7 +1978,7 @@ Options::: link:#[back to top] -[[api-termvectors-5-4]] +[[api-termvectors-5-3]] === `termvectors` [source,js] @@ -2159,7 +2037,7 @@ Options::: link:#[back to top] -[[api-update-5-4]] +[[api-update-5-3]] === `update` [source,js] @@ -2299,7 +2177,7 @@ Options::: link:#[back to top] -[[api-updatebyquery-5-4]] +[[api-updatebyquery-5-3]] === `updateByQuery` [source,js] @@ -2412,7 +2290,7 @@ Options::: link:#[back to top] -[[api-cat-aliases-5-4]] +[[api-cat-aliases-5-3]] === `cat.aliases` [source,js] @@ -2449,7 +2327,7 @@ Check the *<>* and http://www.elasticsearch.org/guide/en/elasti link:#[back to top] -[[api-cat-allocation-5-4]] +[[api-cat-allocation-5-3]] === `cat.allocation` [source,js] @@ -2501,7 +2379,7 @@ Options::: link:#[back to top] -[[api-cat-count-5-4]] +[[api-cat-count-5-3]] === `cat.count` [source,js] @@ -2538,7 +2416,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-cat-fielddata-5-4]] +[[api-cat-fielddata-5-3]] === `cat.fielddata` [source,js] @@ -2590,7 +2468,7 @@ Options::: link:#[back to top] -[[api-cat-health-5-4]] +[[api-cat-health-5-3]] === `cat.health` [source,js] @@ -2627,7 +2505,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-cat-help-5-4]] +[[api-cat-help-5-3]] === `cat.help` [source,js] @@ -2652,7 +2530,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-cat-indices-5-4]] +[[api-cat-indices-5-3]] === `cat.indices` [source,js] @@ -2706,7 +2584,7 @@ Options::: link:#[back to top] -[[api-cat-master-5-4]] +[[api-cat-master-5-3]] === `cat.master` [source,js] @@ -2741,7 +2619,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-cat-nodeattrs-5-4]] +[[api-cat-nodeattrs-5-3]] === `cat.nodeattrs` [source,js] @@ -2776,7 +2654,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-cat-nodes-5-4]] +[[api-cat-nodes-5-3]] === `cat.nodes` [source,js] @@ -2813,7 +2691,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-cat-pendingtasks-5-4]] +[[api-cat-pendingtasks-5-3]] === `cat.pendingTasks` [source,js] @@ -2848,7 +2726,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-cat-plugins-5-4]] +[[api-cat-plugins-5-3]] === `cat.plugins` [source,js] @@ -2883,7 +2761,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-cat-recovery-5-4]] +[[api-cat-recovery-5-3]] === `cat.recovery` [source,js] @@ -2933,7 +2811,7 @@ Options::: link:#[back to top] -[[api-cat-repositories-5-4]] +[[api-cat-repositories-5-3]] === `cat.repositories` [source,js] @@ -2968,7 +2846,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-cat-segments-5-4]] +[[api-cat-segments-5-3]] === `cat.segments` [source,js] @@ -3001,7 +2879,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-cat-shards-5-4]] +[[api-cat-shards-5-3]] === `cat.shards` [source,js] @@ -3038,7 +2916,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-cat-snapshots-5-4]] +[[api-cat-snapshots-5-3]] === `cat.snapshots` [source,js] @@ -3075,7 +2953,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-cat-tasks-5-4]] +[[api-cat-tasks-5-3]] === `cat.tasks` [source,js] @@ -3116,7 +2994,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-cat-templates-5-4]] +[[api-cat-templates-5-3]] === `cat.templates` [source,js] @@ -3153,7 +3031,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-cat-threadpool-5-4]] +[[api-cat-threadpool-5-3]] === `cat.threadPool` [source,js] @@ -3200,7 +3078,7 @@ Options::: link:#[back to top] -[[api-cluster-allocationexplain-5-4]] +[[api-cluster-allocationexplain-5-3]] === `cluster.allocationExplain` [source,js] @@ -3227,7 +3105,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-cluster-getsettings-5-4]] +[[api-cluster-getsettings-5-3]] === `cluster.getSettings` [source,js] @@ -3256,7 +3134,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-cluster-health-5-4]] +[[api-cluster-health-5-3]] === `cluster.health` [source,js] @@ -3315,7 +3193,7 @@ Options::: link:#[back to top] -[[api-cluster-pendingtasks-5-4]] +[[api-cluster-pendingtasks-5-3]] === `cluster.pendingTasks` [source,js] @@ -3340,7 +3218,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-cluster-putsettings-5-4]] +[[api-cluster-putsettings-5-3]] === `cluster.putSettings` [source,js] @@ -3369,7 +3247,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-cluster-reroute-5-4]] +[[api-cluster-reroute-5-3]] === `cluster.reroute` [source,js] @@ -3404,7 +3282,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-cluster-state-5-4]] +[[api-cluster-state-5-3]] === `cluster.state` [source,js] @@ -3447,7 +3325,7 @@ Options::: link:#[back to top] -[[api-cluster-stats-5-4]] +[[api-cluster-stats-5-3]] === `cluster.stats` [source,js] @@ -3474,7 +3352,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-indices-analyze-5-4]] +[[api-indices-analyze-5-3]] === `indices.analyze` [source,js] @@ -3523,7 +3401,7 @@ Options::: link:#[back to top] -[[api-indices-clearcache-5-4]] +[[api-indices-clearcache-5-3]] === `indices.clearCache` [source,js] @@ -3565,8 +3443,6 @@ Options::: <>, <>, <> -- A comma-separated list of index name to limit the operation `recycler`:: <> -- Clear the recycler cache -`requestCache`:: -<> -- Clear request cache `request`:: <> -- Clear request cache `body`:: @@ -3574,7 +3450,7 @@ Options::: link:#[back to top] -[[api-indices-close-5-4]] +[[api-indices-close-5-3]] === `indices.close` [source,js] @@ -3616,7 +3492,7 @@ Options::: link:#[back to top] -[[api-indices-create-5-4]] +[[api-indices-create-5-3]] === `indices.create` [source,js] @@ -3649,7 +3525,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-indices-delete-5-4]] +[[api-indices-delete-5-3]] === `indices.delete` [source,js] @@ -3678,7 +3554,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-indices-deletealias-5-4]] +[[api-indices-deletealias-5-3]] === `indices.deleteAlias` [source,js] @@ -3709,7 +3585,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-indices-deletetemplate-5-4]] +[[api-indices-deletetemplate-5-3]] === `indices.deleteTemplate` [source,js] @@ -3738,7 +3614,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-indices-exists-5-4]] +[[api-indices-exists-5-3]] === `indices.exists` [source,js] @@ -3748,7 +3624,7 @@ client.indices.exists([params, [callback]]) Return a boolean indicating whether given index exists. -Check the *<>* and http://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-exists.html[the elasticsearch docs] for more information pertaining to this method. +Check the *<>* and https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-exists.html[the elasticsearch docs] for more information pertaining to this method. // no examples @@ -3756,32 +3632,28 @@ Check the *<>* and http://www.elastic.co/guide/en/elasticsearch *Params* [horizontal] -`local`:: -<> -- Return local information, do not retrieve the state from master node (default: false) `ignoreUnavailable`:: -<> -- Ignore unavailable indexes (default: false) +<> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) `allowNoIndices`:: -<> -- Ignore if a wildcard expression resolves to no concrete indices (default: false) +<> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) `[expandWildcards=open]`:: -<> -- Whether wildcard expressions should get expanded to open or closed indices (default: open) +<> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. Options::: * `"open"` * `"closed"` * `"none"` * `"all"` -`flatSettings`:: -<> -- Return settings in flat format (default: false) -`includeDefaults`:: -<> -- Whether to return all default setting for each of the indices. +`local`:: +<> -- Return local information, do not retrieve the state from master node (default: false) `index`:: -<>, <>, <> -- A comma-separated list of index names +<>, <>, <> -- A comma-separated list of indices to check `body`:: -<>, <> -- An optional request body, as either JSON or a JSON serializable object. See http://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-exists.html[the elasticsearch docs] for details about what can be specified here. +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-exists.html[the elasticsearch docs] for details about what can be specified here. link:#[back to top] -[[api-indices-existsalias-5-4]] +[[api-indices-existsalias-5-3]] === `indices.existsAlias` [source,js] @@ -3803,7 +3675,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc <> -- Whether specified concrete indices should be ignored when unavailable (missing or closed) `allowNoIndices`:: <> -- Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) -`[expandWildcards=all]`:: +`[expandWildcards=open,closed]`:: <> -- Whether to expand wildcard expression to concrete indices that are open, closed or both. Options::: * `"open"` @@ -3822,7 +3694,7 @@ Options::: link:#[back to top] -[[api-indices-existstemplate-5-4]] +[[api-indices-existstemplate-5-3]] === `indices.existsTemplate` [source,js] @@ -3840,20 +3712,18 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc *Params* [horizontal] -`flatSettings`:: -<> -- Return settings in flat format (default: false) `masterTimeout`:: <> -- Explicit operation timeout for connection to master node `local`:: <> -- Return local information, do not retrieve the state from master node (default: false) `name`:: -<>, <>, <> -- The comma separated names of the index templates +<> -- The name of the template `body`:: <>, <> -- An optional request body, as either JSON or a JSON serializable object. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html[the elasticsearch docs] for details about what can be specified here. link:#[back to top] -[[api-indices-existstype-5-4]] +[[api-indices-existstype-5-3]] === `indices.existsType` [source,js] @@ -3894,7 +3764,7 @@ Options::: link:#[back to top] -[[api-indices-flush-5-4]] +[[api-indices-flush-5-3]] === `indices.flush` [source,js] @@ -3935,7 +3805,7 @@ Options::: link:#[back to top] -[[api-indices-flushsynced-5-4]] +[[api-indices-flushsynced-5-3]] === `indices.flushSynced` [source,js] @@ -3972,7 +3842,7 @@ Options::: link:#[back to top] -[[api-indices-forcemerge-5-4]] +[[api-indices-forcemerge-5-3]] === `indices.forcemerge` [source,js] @@ -4019,7 +3889,7 @@ anything -- TODO: ? link:#[back to top] -[[api-indices-get-5-4]] +[[api-indices-get-5-3]] === `indices.get` [source,js] @@ -4062,7 +3932,7 @@ Options::: link:#[back to top] -[[api-indices-getalias-5-4]] +[[api-indices-getalias-5-3]] === `indices.getAlias` [source,js] @@ -4101,7 +3971,7 @@ Options::: link:#[back to top] -[[api-indices-getfieldmapping-5-4]] +[[api-indices-getfieldmapping-5-3]] === `indices.getFieldMapping` [source,js] @@ -4144,7 +4014,7 @@ Options::: link:#[back to top] -[[api-indices-getmapping-5-4]] +[[api-indices-getmapping-5-3]] === `indices.getMapping` [source,js] @@ -4183,7 +4053,7 @@ Options::: link:#[back to top] -[[api-indices-getsettings-5-4]] +[[api-indices-getsettings-5-3]] === `indices.getSettings` [source,js] @@ -4226,7 +4096,7 @@ Options::: link:#[back to top] -[[api-indices-gettemplate-5-4]] +[[api-indices-gettemplate-5-3]] === `indices.getTemplate` [source,js] @@ -4255,7 +4125,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-indices-getupgrade-5-4]] +[[api-indices-getupgrade-5-3]] === `indices.getUpgrade` [source,js] @@ -4290,7 +4160,7 @@ Options::: link:#[back to top] -[[api-indices-open-5-4]] +[[api-indices-open-5-3]] === `indices.open` [source,js] @@ -4331,7 +4201,7 @@ Options::: link:#[back to top] -[[api-indices-putalias-5-4]] +[[api-indices-putalias-5-3]] === `indices.putAlias` [source,js] @@ -4362,7 +4232,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-indices-putmapping-5-4]] +[[api-indices-putmapping-5-3]] === `indices.putMapping` [source,js] @@ -4407,7 +4277,7 @@ Options::: link:#[back to top] -[[api-indices-putsettings-5-4]] +[[api-indices-putsettings-5-3]] === `indices.putSettings` [source,js] @@ -4450,7 +4320,7 @@ Options::: link:#[back to top] -[[api-indices-puttemplate-5-4]] +[[api-indices-puttemplate-5-3]] === `indices.putTemplate` [source,js] @@ -4485,7 +4355,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-indices-recovery-5-4]] +[[api-indices-recovery-5-3]] === `indices.recovery` [source,js] @@ -4512,7 +4382,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-indices-refresh-5-4]] +[[api-indices-refresh-5-3]] === `indices.refresh` [source,js] @@ -4553,7 +4423,7 @@ anything -- TODO: ? link:#[back to top] -[[api-indices-rollover-5-4]] +[[api-indices-rollover-5-3]] === `indices.rollover` [source,js] @@ -4588,7 +4458,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-indices-segments-5-4]] +[[api-indices-segments-5-3]] === `indices.segments` [source,js] @@ -4627,7 +4497,7 @@ anything -- TODO: ? link:#[back to top] -[[api-indices-shardstores-5-4]] +[[api-indices-shardstores-5-3]] === `indices.shardStores` [source,js] @@ -4666,7 +4536,7 @@ anything -- TODO: ? link:#[back to top] -[[api-indices-shrink-5-4]] +[[api-indices-shrink-5-3]] === `indices.shrink` [source,js] @@ -4699,7 +4569,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-indices-stats-5-4]] +[[api-indices-stats-5-3]] === `indices.stats` [source,js] @@ -4743,7 +4613,7 @@ Options::: link:#[back to top] -[[api-indices-updatealiases-5-4]] +[[api-indices-updatealiases-5-3]] === `indices.updateAliases` [source,js] @@ -4783,7 +4653,7 @@ client.indices.updateAliases({ link:#[back to top] -[[api-indices-upgrade-5-4]] +[[api-indices-upgrade-5-3]] === `indices.upgrade` [source,js] @@ -4824,7 +4694,7 @@ Options::: link:#[back to top] -[[api-indices-validatequery-5-4]] +[[api-indices-validatequery-5-3]] === `indices.validateQuery` [source,js] @@ -4876,8 +4746,6 @@ Options::: <> -- Specify whether format-based query failures (such as providing text to a numeric field) should be ignored `rewrite`:: <> -- Provide a more detailed explanation showing the actual Lucene query that will be executed. -`allShards`:: -<> -- Execute validation on all shards instead of one random shard per index `index`:: <>, <>, <> -- A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices `type`:: @@ -4887,7 +4755,7 @@ Options::: link:#[back to top] -[[api-ingest-deletepipeline-5-4]] +[[api-ingest-deletepipeline-5-3]] === `ingest.deletePipeline` [source,js] @@ -4916,7 +4784,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-ingest-getpipeline-5-4]] +[[api-ingest-getpipeline-5-3]] === `ingest.getPipeline` [source,js] @@ -4941,7 +4809,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-ingest-putpipeline-5-4]] +[[api-ingest-putpipeline-5-3]] === `ingest.putPipeline` [source,js] @@ -4970,7 +4838,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-ingest-simulate-5-4]] +[[api-ingest-simulate-5-3]] === `ingest.simulate` [source,js] @@ -4997,7 +4865,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-nodes-hotthreads-5-4]] +[[api-nodes-hotthreads-5-3]] === `nodes.hotThreads` [source,js] @@ -5037,7 +4905,7 @@ Options::: link:#[back to top] -[[api-nodes-info-5-4]] +[[api-nodes-info-5-3]] === `nodes.info` [source,js] @@ -5066,7 +4934,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-nodes-stats-5-4]] +[[api-nodes-stats-5-3]] === `nodes.stats` [source,js] @@ -5114,23 +4982,7 @@ Options::: link:#[back to top] -[[api-remote-info-5-4]] -=== `remote.info` - -[source,js] --------- -client.remote.info([params, [callback]]) --------- - -// no description - -Check the *<>* and http://www.elastic.co/guide/en/elasticsearch/reference/master/remote-info.html[the elasticsearch docs] for more information pertaining to this method. - -// no examples - - - -[[api-snapshot-create-5-4]] +[[api-snapshot-create-5-3]] === `snapshot.create` [source,js] @@ -5161,7 +5013,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-snapshot-createrepository-5-4]] +[[api-snapshot-createrepository-5-3]] === `snapshot.createRepository` [source,js] @@ -5192,7 +5044,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-snapshot-delete-5-4]] +[[api-snapshot-delete-5-3]] === `snapshot.delete` [source,js] @@ -5221,7 +5073,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-snapshot-deleterepository-5-4]] +[[api-snapshot-deleterepository-5-3]] === `snapshot.deleteRepository` [source,js] @@ -5250,7 +5102,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-snapshot-get-5-4]] +[[api-snapshot-get-5-3]] === `snapshot.get` [source,js] @@ -5279,7 +5131,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-snapshot-getrepository-5-4]] +[[api-snapshot-getrepository-5-3]] === `snapshot.getRepository` [source,js] @@ -5306,7 +5158,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-snapshot-restore-5-4]] +[[api-snapshot-restore-5-3]] === `snapshot.restore` [source,js] @@ -5337,7 +5189,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-snapshot-status-5-4]] +[[api-snapshot-status-5-3]] === `snapshot.status` [source,js] @@ -5366,7 +5218,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-snapshot-verifyrepository-5-4]] +[[api-snapshot-verifyrepository-5-3]] === `snapshot.verifyRepository` [source,js] @@ -5395,7 +5247,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-tasks-cancel-5-4]] +[[api-tasks-cancel-5-3]] === `tasks.cancel` [source,js] @@ -5428,7 +5280,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-tasks-get-5-4]] +[[api-tasks-get-5-3]] === `tasks.get` [source,js] @@ -5453,7 +5305,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc link:#[back to top] -[[api-tasks-list-5-4]] +[[api-tasks-list-5-3]] === `tasks.list` [source,js] diff --git a/docs/configuration.asciidoc b/docs/configuration.asciidoc index 2c62d9c28..9ac886ab2 100644 --- a/docs/configuration.asciidoc +++ b/docs/configuration.asciidoc @@ -52,7 +52,7 @@ Default in Node::: + WARNING: This default will track the latest version of Elasticsearch, and is only intended to be used during development. It is highly recommended that you set this parameter in all code that is headed to production. -Default ::: `'5.3'` +Default ::: `'5.4'` Options in node ::: * `'5.4'` diff --git a/docs/index.asciidoc b/docs/index.asciidoc index c0c83da5a..9612746b5 100644 --- a/docs/index.asciidoc +++ b/docs/index.asciidoc @@ -20,10 +20,10 @@ include::logging.asciidoc[] include::development.asciidoc[] -include::api_methods_5_4.asciidoc[] - include::api_methods.asciidoc[] +include::api_methods_5_3.asciidoc[] + include::api_methods_5_2.asciidoc[] include::api_methods_5_1.asciidoc[] diff --git a/package.json b/package.json index b55ff534b..1b12ff1af 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "blanket": { "pattern": "specified in test/unit/coverage.js" }, - "default_api_branch": "5.3", + "default_api_branch": "5.4", "supported_es_branches": [ "5.4", "5.3", diff --git a/src/lib/apis/browser_index.js b/src/lib/apis/browser_index.js index 6b1e0d7a9..59ad39b43 100644 --- a/src/lib/apis/browser_index.js +++ b/src/lib/apis/browser_index.js @@ -1,6 +1,6 @@ module.exports = { + '_default': require('./5_4'), '5.4': require('./5_4'), - '_default': require('./5_3'), '5.3': require('./5_3'), '5.2': require('./5_2'), '5.1': require('./5_1'), diff --git a/src/lib/apis/index.js b/src/lib/apis/index.js index 9b0b1e9b4..be488c9ef 100644 --- a/src/lib/apis/index.js +++ b/src/lib/apis/index.js @@ -1,6 +1,6 @@ module.exports = { + get '_default'() { return require('./5_4'); }, get '5.4'() { return require('./5_4'); }, - get '_default'() { return require('./5_3'); }, get '5.3'() { return require('./5_3'); }, get '5.2'() { return require('./5_2'); }, get '5.1'() { return require('./5_1'); }, From 07d48ab8d2b89df00c77ff15841219ed4d6a3714 Mon Sep 17 00:00:00 2001 From: spalger Date: Mon, 12 Jun 2017 12:41:35 -0700 Subject: [PATCH 26/61] [apis] regenerate --- docs/api_methods.asciidoc | 10 +++++----- src/lib/apis/5_4.js | 6 +++--- src/lib/apis/5_5.js | 6 +++--- src/lib/apis/5_x.js | 4 ++-- src/lib/apis/master.js | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/api_methods.asciidoc b/docs/api_methods.asciidoc index 334feb120..2f8f2e5db 100644 --- a/docs/api_methods.asciidoc +++ b/docs/api_methods.asciidoc @@ -669,7 +669,7 @@ client.existsSource([params, [callback]]) // no description -Check the *<>* and http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html[the elasticsearch docs] for more information pertaining to this method. +Check the *<>* and http://www.elastic.co/guide/en/elasticsearch/reference/5.4/docs-get.html[the elasticsearch docs] for more information pertaining to this method. // no examples @@ -710,7 +710,7 @@ Options::: `type`:: <> -- The type of the document; use `_all` to fetch the first document matching the ID across all types `body`:: -<>, <> -- An optional request body, as either JSON or a JSON serializable object. See http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html[the elasticsearch docs] for details about what can be specified here. +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See http://www.elastic.co/guide/en/elasticsearch/reference/5.4/docs-get.html[the elasticsearch docs] for details about what can be specified here. link:#[back to top] @@ -814,7 +814,7 @@ client.fieldCaps([params, [callback]]) // no description -Check the *<>* and http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html[the elasticsearch docs] for more information pertaining to this method. +Check the *<>* and http://www.elastic.co/guide/en/elasticsearch/reference/5.4/search-field-caps.html[the elasticsearch docs] for more information pertaining to this method. // no examples @@ -839,7 +839,7 @@ Options::: `index`:: <>, <>, <> -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices `body`:: -<>, <> -- An optional request body, as either JSON or a JSON serializable object. See http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html[the elasticsearch docs] for details about what can be specified here. +<>, <> -- An optional request body, as either JSON or a JSON serializable object. See http://www.elastic.co/guide/en/elasticsearch/reference/5.4/search-field-caps.html[the elasticsearch docs] for details about what can be specified here. link:#[back to top] @@ -5124,7 +5124,7 @@ client.remote.info([params, [callback]]) // no description -Check the *<>* and http://www.elastic.co/guide/en/elasticsearch/reference/master/remote-info.html[the elasticsearch docs] for more information pertaining to this method. +Check the *<>* and http://www.elastic.co/guide/en/elasticsearch/reference/5.4/cluster-remote-info.html[the elasticsearch docs] for more information pertaining to this method. // no examples diff --git a/src/lib/apis/5_4.js b/src/lib/apis/5_4.js index 63a9f4270..bcc6463b8 100644 --- a/src/lib/apis/5_4.js +++ b/src/lib/apis/5_4.js @@ -2271,7 +2271,7 @@ api.exists = ca({ }); /** - * Perform a [existsSource](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request + * Perform a [existsSource](http://www.elastic.co/guide/en/elasticsearch/reference/5.4/docs-get.html) request * * @param {Object} params - An object with parameters used to carry out this action * @param {<>} params.parent - The ID of the parent document @@ -2438,7 +2438,7 @@ api.explain = ca({ }); /** - * Perform a [fieldCaps](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html) request + * Perform a [fieldCaps](http://www.elastic.co/guide/en/elasticsearch/reference/5.4/search-field-caps.html) request * * @param {Object} params - An object with parameters used to carry out this action * @param {<>, <>, <>} params.fields - A comma-separated list of field names @@ -5993,7 +5993,7 @@ api.reindexRethrottle = ca({ api.remote = namespace(); /** - * Perform a [remote.info](http://www.elastic.co/guide/en/elasticsearch/reference/master/remote-info.html) request + * Perform a [remote.info](http://www.elastic.co/guide/en/elasticsearch/reference/5.4/cluster-remote-info.html) request * * @param {Object} params - An object with parameters used to carry out this action */ diff --git a/src/lib/apis/5_5.js b/src/lib/apis/5_5.js index b787581c5..f7d0ff39c 100644 --- a/src/lib/apis/5_5.js +++ b/src/lib/apis/5_5.js @@ -2271,7 +2271,7 @@ api.exists = ca({ }); /** - * Perform a [existsSource](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request + * Perform a [existsSource](http://www.elastic.co/guide/en/elasticsearch/reference/5.5/docs-get.html) request * * @param {Object} params - An object with parameters used to carry out this action * @param {<>} params.parent - The ID of the parent document @@ -2438,7 +2438,7 @@ api.explain = ca({ }); /** - * Perform a [fieldCaps](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html) request + * Perform a [fieldCaps](http://www.elastic.co/guide/en/elasticsearch/reference/5.5/search-field-caps.html) request * * @param {Object} params - An object with parameters used to carry out this action * @param {<>, <>, <>} params.fields - A comma-separated list of field names @@ -5998,7 +5998,7 @@ api.reindexRethrottle = ca({ api.remote = namespace(); /** - * Perform a [remote.info](http://www.elastic.co/guide/en/elasticsearch/reference/master/remote-info.html) request + * Perform a [remote.info](http://www.elastic.co/guide/en/elasticsearch/reference/5.5/cluster-remote-info.html) request * * @param {Object} params - An object with parameters used to carry out this action */ diff --git a/src/lib/apis/5_x.js b/src/lib/apis/5_x.js index bc106e4ab..cb90e4194 100644 --- a/src/lib/apis/5_x.js +++ b/src/lib/apis/5_x.js @@ -2438,7 +2438,7 @@ api.explain = ca({ }); /** - * Perform a [fieldCaps](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html) request + * Perform a [fieldCaps](http://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-field-caps.html) request * * @param {Object} params - An object with parameters used to carry out this action * @param {<>, <>, <>} params.fields - A comma-separated list of field names @@ -6009,7 +6009,7 @@ api.reindexRethrottle = ca({ api.remote = namespace(); /** - * Perform a [remote.info](http://www.elastic.co/guide/en/elasticsearch/reference/master/remote-info.html) request + * Perform a [remote.info](http://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-remote-info.html) request * * @param {Object} params - An object with parameters used to carry out this action */ diff --git a/src/lib/apis/master.js b/src/lib/apis/master.js index f5a0c8e88..2d3169074 100644 --- a/src/lib/apis/master.js +++ b/src/lib/apis/master.js @@ -5749,7 +5749,7 @@ api.reindexRethrottle = ca({ api.remote = namespace(); /** - * Perform a [remote.info](http://www.elastic.co/guide/en/elasticsearch/reference/master/remote-info.html) request + * Perform a [remote.info](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-remote-info.html) request * * @param {Object} params - An object with parameters used to carry out this action */ From 629c7498ae51a7192595de0cb82bb77c0b0895cf Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 15:42:56 -0700 Subject: [PATCH 27/61] [generate] handle methods with more than one namespace --- scripts/generate/js_api.js | 10 +++++----- scripts/generate/templates/api_file.tmpl | 7 ++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/scripts/generate/js_api.js b/scripts/generate/js_api.js index edaa1f203..a1b971149 100644 --- a/scripts/generate/js_api.js +++ b/scripts/generate/js_api.js @@ -75,11 +75,11 @@ module.exports = function (branch, done) { // collect the namespaces from the action locations var namespaces = _.filter(_.map(actions, function (action) { - if (~action.location.indexOf('.')) { - var path = action.location.split('.').slice(0, -1); - _.pull(path, 'prototype'); - return path.join('.'); - } + return action.location + .split('.') + .slice(0, -1) + .filter(step => step !== 'prototype') + .join('.prototype.') })); // seperate the proxy actions diff --git a/scripts/generate/templates/api_file.tmpl b/scripts/generate/templates/api_file.tmpl index daf749b3d..569de5035 100644 --- a/scripts/generate/templates/api_file.tmpl +++ b/scripts/generate/templates/api_file.tmpl @@ -10,7 +10,12 @@ var api = module.exports = {}; api._namespaces = <%= stringify(namespaces) %>;<% _.each(actions, function (action) { - var namespace = action.location.split('.').shift(); + const namespace = action.location + .split('.') + .slice(0, -1) + .filter(step => step !== 'prototype') + .join('.prototype.'); + if (_.include(namespaces, namespace)) { _.pull(namespaces, namespace); %> From b7ff19dc0cd229f7ba7bb6ee966ad18b23e1ca79 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 15:43:12 -0700 Subject: [PATCH 28/61] [apis] regenerate --- docs/api_methods_2_4.asciidoc | 2 +- src/lib/apis/2_4.js | 2 +- src/lib/apis/5_x.js | 4 +++- src/lib/apis/master.js | 4 +++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/api_methods_2_4.asciidoc b/docs/api_methods_2_4.asciidoc index 6be56d9ba..a9e13894a 100644 --- a/docs/api_methods_2_4.asciidoc +++ b/docs/api_methods_2_4.asciidoc @@ -1460,7 +1460,7 @@ Check the *<>* and https://www.elastic.co/guide/en/elasticsearc [horizontal] `requestsPerSecond`:: -<> -- The throttle to set on this request in sub-requests per second. 0 means set no throttle. As does "unlimited". Otherwise it must be a float. +<> -- The throttle to set on this request in sub-requests per second. "unlimited" means set no throttle, otherwise it must be a float greater than 0. `taskId`:: <> -- The task id to rethrottle `body`:: diff --git a/src/lib/apis/2_4.js b/src/lib/apis/2_4.js index d0dbf44e9..18082d073 100644 --- a/src/lib/apis/2_4.js +++ b/src/lib/apis/2_4.js @@ -5279,7 +5279,7 @@ api.reindex = ca({ * Perform a [reindexRethrottle](https://www.elastic.co/guide/en/elasticsearch/reference/2.4/docs-reindex.html) request * * @param {Object} params - An object with parameters used to carry out this action - * @param {<>} params.requestsPerSecond - The throttle to set on this request in sub-requests per second. 0 means set no throttle. As does "unlimited". Otherwise it must be a float. + * @param {<>} params.requestsPerSecond - The throttle to set on this request in sub-requests per second. "unlimited" means set no throttle, otherwise it must be a float greater than 0. * @param {<>} params.taskId - The task id to rethrottle */ api.reindexRethrottle = ca({ diff --git a/src/lib/apis/5_x.js b/src/lib/apis/5_x.js index cb90e4194..88d7c6890 100644 --- a/src/lib/apis/5_x.js +++ b/src/lib/apis/5_x.js @@ -11,7 +11,7 @@ var ca = require('../client_action').makeFactoryWithModifier(function (spec) { var namespace = require('../client_action').namespaceFactory; var api = module.exports = {}; -api._namespaces = ['cat', 'cluster', 'indices', 'ingest', 'ingest.processor', 'nodes', 'remote', 'snapshot', 'tasks']; +api._namespaces = ['cat', 'cluster', 'indices', 'ingest', 'ingest.prototype.processor', 'nodes', 'remote', 'snapshot', 'tasks']; /** * Perform a [bulk](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/docs-bulk.html) request @@ -4982,6 +4982,8 @@ api.ingest.prototype.getPipeline = ca({ ] }); +api.ingest.prototype.processor = namespace(); + /** * Perform a [ingest.processor.grok](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request * diff --git a/src/lib/apis/master.js b/src/lib/apis/master.js index 2d3169074..82fa6aa0e 100644 --- a/src/lib/apis/master.js +++ b/src/lib/apis/master.js @@ -11,7 +11,7 @@ var ca = require('../client_action').makeFactoryWithModifier(function (spec) { var namespace = require('../client_action').namespaceFactory; var api = module.exports = {}; -api._namespaces = ['cat', 'cluster', 'indices', 'ingest', 'ingest.processor', 'nodes', 'remote', 'snapshot', 'tasks']; +api._namespaces = ['cat', 'cluster', 'indices', 'ingest', 'ingest.prototype.processor', 'nodes', 'remote', 'snapshot', 'tasks']; /** * Perform a [bulk](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html) request @@ -4832,6 +4832,8 @@ api.ingest.prototype.getPipeline = ca({ ] }); +api.ingest.prototype.processor = namespace(); + /** * Perform a [ingest.processor.grok](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request * From 87685c353eeed4135833d926933ceda18bdabda3 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 16:08:53 -0700 Subject: [PATCH 29/61] add link to changelog in readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6d3abccf2..7fa14b582 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ Check out the [Browser Builds](http://www.elastic.co/guide/en/elasticsearch/clie - [Browser Builds](http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/browser-builds.html) - [API](http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html) - [Configuration](http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/configuration.html) + - [Changelog](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/changelog.html) - [Development/Contributing](https://github.com/elastic/elasticsearch-js/blob/master/CONTRIBUTING.md) - [Extending Core Components](http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/extending_core_components.html) - [Logging](http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/logging.html) From 256bff1c37ba1a5131c0807459ed7778ab8a46fb Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 18:33:08 -0700 Subject: [PATCH 30/61] use yarn for dependency management --- CONTRIBUTING.md | 2 +- scripts/jenkins.sh | 15 +- yarn.lock | 4778 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 4786 insertions(+), 9 deletions(-) create mode 100644 yarn.lock diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 69bb0d71f..25cf1e7c1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,7 +15,7 @@ Please write test cases to exercise your changes. 1. Install dev dependencies. ```sh - npm install + yarn ``` 2. Install Grunt. diff --git a/scripts/jenkins.sh b/scripts/jenkins.sh index f3f55c88c..4193a50c2 100644 --- a/scripts/jenkins.sh +++ b/scripts/jenkins.sh @@ -43,19 +43,18 @@ function install_node { echo "installing node $version"; crit nvm install "$version" +} - if [[ "$(which npm)" == "" ]]; then - echo "npm is missing, reinstalling node version $version"; - crit nvm deactivate; - crit nvm uninstall "$version"; - install_node "$version"; - return - fi +function install_yarn { + mkdir .bin + curl -L https://github.com/yarnpkg/yarn/releases/download/v0.24.2/yarn-0.24.2.js > .bin/yarn + chmod +x .bin/yarn + PATH="$(pwd)/.bin:$PATH" } get_lock install_node "$(cat ./.node-version)" -npm install +yarn release_lock ES_PATH_REPO="./.es-snapshot-repos/$EXECUTOR_NUMBER/" ES_PORT=$((9400 + EXECUTOR_NUMBER)) RUN=NODE_UNIT,NODE_INTEGRATION VERBOSE=true node ./scripts/ci.js diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 000000000..8129200a0 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,4778 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@elastic/eslint-config-kibana@^0.6.1": + version "0.6.1" + resolved "https://registry.yarnpkg.com/@elastic/eslint-config-kibana/-/eslint-config-kibana-0.6.1.tgz#27cf0a42f8f585cd005855a87a2ab1d1f162dd99" + +"@elastic/eslint-plugin-kibana-custom@^1.0.3": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@elastic/eslint-plugin-kibana-custom/-/eslint-plugin-kibana-custom-1.0.3.tgz#259aea947d6abaaa2f50431696231def2a522926" + +abbrev@1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.0.tgz#d0554c2256636e2f56e7c2e5ad183f859428d81f" + +accepts@~1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.3.tgz#c3ca7434938648c3e0d9c1e328dd68b622c284ca" + dependencies: + mime-types "~2.1.11" + negotiator "0.6.1" + +acorn-jsx@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-3.0.1.tgz#afdf9488fb1ecefc8348f6fb22f464e32a58b36b" + dependencies: + acorn "^3.0.4" + +acorn@^1.0.3: + version "1.2.2" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-1.2.2.tgz#c8ce27de0acc76d896d2b1fad3df588d9e82f014" + +acorn@^3.0.0, acorn@^3.0.4: + version "3.3.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a" + +acorn@^5.0.1: + version "5.0.3" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.0.3.tgz#c460df08491463f028ccb82eab3730bf01087b3d" + +agent-base@2: + version "2.1.1" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-2.1.1.tgz#d6de10d5af6132d5bd692427d46fc538539094c7" + dependencies: + extend "~3.0.0" + semver "~5.0.1" + +agentkeepalive@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-2.2.0.tgz#c5d1bd4b129008f1163f236f86e5faea2026e2ef" + +ajv-keywords@^1.0.0: + version "1.5.1" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.1.tgz#314dd0a4b3368fad3dfcdc54ede6171b886daf3c" + +ajv@^4.7.0, ajv@^4.9.1: + version "4.11.8" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536" + dependencies: + co "^4.6.0" + json-stable-stringify "^1.0.1" + +align-text@^0.1.1, align-text@^0.1.3: + version "0.1.4" + resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" + dependencies: + kind-of "^3.0.2" + longest "^1.0.1" + repeat-string "^1.5.2" + +amdefine@>=0.0.4: + version "1.0.1" + resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" + +ansi-escapes@^1.1.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-1.4.0.tgz#d3a8a83b319aa67793662b13e761c7911422306e" + +ansi-regex@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" + +ansi-styles@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" + +anymatch@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-1.3.0.tgz#a3e52fa39168c825ff57b0248126ce5a8ff95507" + dependencies: + arrify "^1.0.0" + micromatch "^2.1.5" + +aproba@^1.0.3: + version "1.1.2" + resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.1.2.tgz#45c6629094de4e96f693ef7eab74ae079c240fc1" + +archiver-utils@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/archiver-utils/-/archiver-utils-1.3.0.tgz#e50b4c09c70bf3d680e32ff1b7994e9f9d895174" + dependencies: + glob "^7.0.0" + graceful-fs "^4.1.0" + lazystream "^1.0.0" + lodash "^4.8.0" + normalize-path "^2.0.0" + readable-stream "^2.0.0" + +archiver@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/archiver/-/archiver-1.3.0.tgz#4f2194d6d8f99df3f531e6881f14f15d55faaf22" + dependencies: + archiver-utils "^1.3.0" + async "^2.0.0" + buffer-crc32 "^0.2.1" + glob "^7.0.0" + lodash "^4.8.0" + readable-stream "^2.0.0" + tar-stream "^1.5.0" + walkdir "^0.0.11" + zip-stream "^1.1.0" + +are-we-there-yet@~1.1.2: + version "1.1.4" + resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz#bb5dca382bb94f05e15194373d16fd3ba1ca110d" + dependencies: + delegates "^1.0.0" + readable-stream "^2.0.6" + +argparse@^1.0.2, argparse@^1.0.7: + version "1.0.9" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.9.tgz#73d83bc263f86e97f8cc4f6bae1b0e90a7d22c86" + dependencies: + sprintf-js "~1.0.2" + +"argparse@~ 0.1.11": + version "0.1.16" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-0.1.16.tgz#cfd01e0fbba3d6caed049fbd758d40f65196f57c" + dependencies: + underscore "~1.7.0" + underscore.string "~2.4.0" + +arr-diff@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf" + dependencies: + arr-flatten "^1.0.1" + +arr-flatten@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.0.3.tgz#a274ed85ac08849b6bd7847c4580745dc51adfb1" + +array-differ@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-1.0.0.tgz#eff52e3758249d33be402b8bb8e564bb2b5d4031" + +array-find-index@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" + +array-flatten@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" + +array-union@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" + dependencies: + array-uniq "^1.0.1" + +array-uniq@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" + +array-unique@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" + +arrify@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" + +asn1@0.1.11: + version "0.1.11" + resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.1.11.tgz#559be18376d08a4ec4dbe80877d27818639b2df7" + +asn1@~0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.3.tgz#dac8787713c9966849fc8180777ebe9c1ddf3b86" + +assert-plus@1.0.0, assert-plus@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + +assert-plus@^0.1.5: + version "0.1.5" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.1.5.tgz#ee74009413002d84cec7219c6ac811812e723160" + +assert-plus@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234" + +assert@^1.1.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/assert/-/assert-1.4.1.tgz#99912d591836b5a6f5b345c0f07eefc08fc65d91" + dependencies: + util "0.10.3" + +async-each@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d" + +async@^0.9.0, async@~0.9.0: + version "0.9.2" + resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d" + +async@^1.3.0, async@^1.5.0, async@^1.5.2, async@~1.5.2: + version "1.5.2" + resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" + +async@^2.0.0, async@^2.0.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/async/-/async-2.4.1.tgz#62a56b279c98a11d0987096a01cc3eeb8eb7bbd7" + dependencies: + lodash "^4.14.0" + +async@~0.1.22: + version "0.1.22" + resolved "https://registry.yarnpkg.com/async/-/async-0.1.22.tgz#0fc1aaa088a0e3ef0ebe2d8831bab0dcf8845061" + +async@~0.2.6: + version "0.2.10" + resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1" + +async@~0.8.0: + version "0.8.0" + resolved "https://registry.yarnpkg.com/async/-/async-0.8.0.tgz#ee65ec77298c2ff1456bc4418a052d0f06435112" + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + +aws-sign2@~0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.5.0.tgz#c57103f7a17fc037f02d7c2e64b602ea223f7d63" + +aws-sign2@~0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" + +aws4@^1.2.1: + version "1.6.0" + resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" + +babel-code-frame@^6.16.0, babel-code-frame@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4" + dependencies: + chalk "^1.1.0" + esutils "^2.0.2" + js-tokens "^3.0.0" + +babel-eslint@^7.2.3: + version "7.2.3" + resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-7.2.3.tgz#b2fe2d80126470f5c19442dc757253a897710827" + dependencies: + babel-code-frame "^6.22.0" + babel-traverse "^6.23.1" + babel-types "^6.23.0" + babylon "^6.17.0" + +babel-messages@^6.23.0: + version "6.23.0" + resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e" + dependencies: + babel-runtime "^6.22.0" + +babel-runtime@^6.22.0: + version "6.23.0" + resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.23.0.tgz#0a9489f144de70efb3ce4300accdb329e2fc543b" + dependencies: + core-js "^2.4.0" + regenerator-runtime "^0.10.0" + +babel-traverse@^6.23.1: + version "6.25.0" + resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.25.0.tgz#2257497e2fcd19b89edc13c4c91381f9512496f1" + dependencies: + babel-code-frame "^6.22.0" + babel-messages "^6.23.0" + babel-runtime "^6.22.0" + babel-types "^6.25.0" + babylon "^6.17.2" + debug "^2.2.0" + globals "^9.0.0" + invariant "^2.2.0" + lodash "^4.2.0" + +babel-types@^6.23.0, babel-types@^6.25.0: + version "6.25.0" + resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.25.0.tgz#70afb248d5660e5d18f811d91c8303b54134a18e" + dependencies: + babel-runtime "^6.22.0" + esutils "^2.0.2" + lodash "^4.2.0" + to-fast-properties "^1.0.1" + +babylon@^6.17.0, babylon@^6.17.2: + version "6.17.3" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.3.tgz#1327d709950b558f204e5352587fd0290f8d8e48" + +balanced-match@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" + +base64-js@^1.0.2: + version "1.2.0" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.0.tgz#a39992d723584811982be5e290bb6a53d86700f1" + +batch@0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/batch/-/batch-0.5.0.tgz#fd2e05a7a5d696b4db9314013e285d8ff3557ec3" + +batch@0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/batch/-/batch-0.6.1.tgz#dc34314f4e679318093fc760272525f94bf25c16" + +bcrypt-pbkdf@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz#63bc5dcb61331b92bc05fd528953c33462a06f8d" + dependencies: + tweetnacl "^0.14.3" + +bcryptjs@^2.3.0: + version "2.4.3" + resolved "https://registry.yarnpkg.com/bcryptjs/-/bcryptjs-2.4.3.tgz#9ab5627b93e60621ff7cdac5da9733027df1d0cb" + +big.js@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.1.3.tgz#4cada2193652eb3ca9ec8e55c9015669c9806978" + +binary-extensions@^1.0.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.8.0.tgz#48ec8d16df4377eae5fa5884682480af4d95c774" + +bl@^1.0.0, bl@~1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/bl/-/bl-1.0.3.tgz#fc5421a28fd4226036c3b3891a66a25bc64d226e" + dependencies: + readable-stream "~2.0.5" + +bl@~0.9.0: + version "0.9.5" + resolved "https://registry.yarnpkg.com/bl/-/bl-0.9.5.tgz#c06b797af085ea00bc527afc8efcf11de2232054" + dependencies: + readable-stream "~1.0.26" + +blanket@1.1.6: + version "1.1.6" + resolved "https://registry.yarnpkg.com/blanket/-/blanket-1.1.6.tgz#ff93783dfe08b4f8baa790cd46948f5f3c6fd152" + dependencies: + esprima "~1.0.2" + falafel "~0.1.6" + xtend "~2.1.1" + +blanket@^1.2.3: + version "1.2.3" + resolved "https://registry.yarnpkg.com/blanket/-/blanket-1.2.3.tgz#151b4987c3bd84552bb5f03b90ef5f7e5931e473" + dependencies: + acorn "^1.0.3" + falafel "~1.2.0" + foreach "^2.0.5" + isarray "0.0.1" + object-keys "^1.0.6" + xtend "~4.0.0" + +block-stream@*: + version "0.0.9" + resolved "https://registry.yarnpkg.com/block-stream/-/block-stream-0.0.9.tgz#13ebfe778a03205cfe03751481ebb4b3300c126a" + dependencies: + inherits "~2.0.0" + +bluebird@^2.9.14, bluebird@^2.9.30: + version "2.11.0" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.11.0.tgz#534b9033c022c9579c56ba3b3e5a5caafbb650e1" + +bluebird@~2.10.2: + version "2.10.2" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.10.2.tgz#024a5517295308857f14f91f1106fc3b555f446b" + +body-parser@~1.14.0: + version "1.14.2" + resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.14.2.tgz#1015cb1fe2c443858259581db53332f8d0cf50f9" + dependencies: + bytes "2.2.0" + content-type "~1.0.1" + debug "~2.2.0" + depd "~1.1.0" + http-errors "~1.3.1" + iconv-lite "0.4.13" + on-finished "~2.3.0" + qs "5.2.0" + raw-body "~2.1.5" + type-is "~1.6.10" + +boom@0.4.x: + version "0.4.2" + resolved "https://registry.yarnpkg.com/boom/-/boom-0.4.2.tgz#7a636e9ded4efcefb19cef4947a3c67dfaee911b" + dependencies: + hoek "0.9.x" + +boom@2.x.x: + version "2.10.1" + resolved "https://registry.yarnpkg.com/boom/-/boom-2.10.1.tgz#39c8918ceff5799f83f9492a848f625add0c766f" + dependencies: + hoek "2.x.x" + +brace-expansion@^1.1.7: + version "1.1.8" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292" + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +braces@^1.8.2: + version "1.8.5" + resolved "https://registry.yarnpkg.com/braces/-/braces-1.8.5.tgz#ba77962e12dff969d6b76711e914b737857bf6a7" + dependencies: + expand-range "^1.8.1" + preserve "^0.2.0" + repeat-element "^1.1.2" + +browserify-aes@0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/browserify-aes/-/browserify-aes-0.4.0.tgz#067149b668df31c4b58533e02d01e806d8608e2c" + dependencies: + inherits "^2.0.1" + +browserify-zlib@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/browserify-zlib/-/browserify-zlib-0.1.4.tgz#bb35f8a519f600e0fa6b8485241c979d0141fb2d" + dependencies: + pako "~0.2.0" + +buffer-crc32@0.2.1, buffer-crc32@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.1.tgz#be3e5382fc02b6d6324956ac1af98aa98b08534c" + +buffer@^4.9.0: + version "4.9.1" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-4.9.1.tgz#6d1bb601b07a4efced97094132093027c95bc298" + dependencies: + base64-js "^1.0.2" + ieee754 "^1.1.4" + isarray "^1.0.0" + +builtin-modules@^1.0.0, builtin-modules@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" + +builtin-status-codes@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" + +bytes@0.2.1, bytes@~0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-0.2.1.tgz#555b08abcb063f8975905302523e4cd4ffdfdf31" + +bytes@2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-2.2.0.tgz#fd35464a403f6f9117c2de3609ecff9cae000588" + +bytes@2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-2.3.0.tgz#d5b680a165b6201739acb611542aabc2d8ceb070" + +bytes@2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-2.4.0.tgz#7d97196f9d5baf7f6935e25985549edd2a6c2339" + +caller-path@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/caller-path/-/caller-path-0.1.0.tgz#94085ef63581ecd3daa92444a8fe94e82577751f" + dependencies: + callsites "^0.2.0" + +callsites@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/callsites/-/callsites-0.2.0.tgz#afab96262910a7f33c19a5775825c69f34e350ca" + +camelcase-keys@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-2.1.0.tgz#308beeaffdf28119051efa1d932213c91b8f92e7" + dependencies: + camelcase "^2.0.0" + map-obj "^1.0.0" + +camelcase@^1.0.2: + version "1.2.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39" + +camelcase@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" + +caseless@~0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7" + +caseless@~0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" + +caseless@~0.9.0: + version "0.9.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.9.0.tgz#b7b65ce6bf1413886539cfd533f0b30effa9cf88" + +center-align@^0.1.1: + version "0.1.3" + resolved "https://registry.yarnpkg.com/center-align/-/center-align-0.1.3.tgz#aa0d32629b6ee972200411cbd4461c907bc2b7ad" + dependencies: + align-text "^0.1.3" + lazy-cache "^1.0.3" + +chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3, chalk@~1.1.1: + version "1.1.3" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" + dependencies: + ansi-styles "^2.2.1" + escape-string-regexp "^1.0.2" + has-ansi "^2.0.0" + strip-ansi "^3.0.0" + supports-color "^2.0.0" + +chokidar@^1.0.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468" + dependencies: + anymatch "^1.3.0" + async-each "^1.0.0" + glob-parent "^2.0.0" + inherits "^2.0.1" + is-binary-path "^1.0.0" + is-glob "^2.0.0" + path-is-absolute "^1.0.0" + readdirp "^2.0.0" + optionalDependencies: + fsevents "^1.0.0" + +circular-json@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.1.tgz#be8b36aefccde8b3ca7aa2d6afc07a37242c0d2d" + +cli-color@~0.3.2: + version "0.3.3" + resolved "https://registry.yarnpkg.com/cli-color/-/cli-color-0.3.3.tgz#12d5bdd158ff8a0b0db401198913c03df069f6f5" + dependencies: + d "~0.1.1" + es5-ext "~0.10.6" + memoizee "~0.3.8" + timers-ext "0.1" + +cli-cursor@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-1.0.2.tgz#64da3f7d56a54412e59794bd62dc35295e8f2987" + dependencies: + restore-cursor "^1.0.1" + +cli-table@~0.3.0: + version "0.3.1" + resolved "https://registry.yarnpkg.com/cli-table/-/cli-table-0.3.1.tgz#f53b05266a8b1a0b934b3d0821e6e2dc5914ae23" + dependencies: + colors "1.0.3" + +cli-width@^1.0.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-1.1.1.tgz#a4d293ef67ebb7b88d4a4d42c0ccf00c4d1e366d" + +cli-width@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.1.0.tgz#b234ca209b29ef66fc518d9b98d5847b00edf00a" + +cliui@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-2.1.0.tgz#4b475760ff80264c762c3a1719032e91c7fea0d1" + dependencies: + center-align "^0.1.1" + right-align "^0.1.1" + wordwrap "0.0.2" + +clone@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.2.tgz#260b7a99ebb1edfe247538175f783243cb19d149" + +co@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" + +code-point-at@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" + +coffee-script@^1.10.0, coffee-script@^1.9.0, coffee-script@~1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/coffee-script/-/coffee-script-1.10.0.tgz#12938bcf9be1948fa006f92e0c4c9e81705108c0" + +coffee-script@~1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/coffee-script/-/coffee-script-1.3.3.tgz#150d6b4cb522894369efed6a2101c20bc7f4a4f4" + +colors@1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b" + +colors@~0.6.2: + version "0.6.2" + resolved "https://registry.yarnpkg.com/colors/-/colors-0.6.2.tgz#2423fe6678ac0c5dae8852e5d0e5be08c997abcc" + +colors@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63" + +combined-stream@^1.0.5, combined-stream@~1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009" + dependencies: + delayed-stream "~1.0.0" + +combined-stream@~0.0.4, combined-stream@~0.0.5: + version "0.0.7" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-0.0.7.tgz#0137e657baa5a7541c57ac37ac5fc07d73b4dc1f" + dependencies: + delayed-stream "0.0.5" + +commander@0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-0.6.1.tgz#fa68a14f6a945d54dbbe50d8cdb3320e9e3b1a06" + +commander@1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/commander/-/commander-1.3.2.tgz#8a8f30ec670a6fdd64af52f1914b907d79ead5b5" + dependencies: + keypress "0.1.x" + +commander@2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.3.0.tgz#fd430e889832ec353b9acd1de217c11cb3eef873" + +commander@^2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" + dependencies: + graceful-readlink ">= 1.0.0" + +compress-commons@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/compress-commons/-/compress-commons-1.2.0.tgz#58587092ef20d37cb58baf000112c9278ff73b9f" + dependencies: + buffer-crc32 "^0.2.1" + crc32-stream "^2.0.0" + normalize-path "^2.0.0" + readable-stream "^2.0.0" + +compressible@~2.0.8: + version "2.0.10" + resolved "https://registry.yarnpkg.com/compressible/-/compressible-2.0.10.tgz#feda1c7f7617912732b29bf8cf26252a20b9eecd" + dependencies: + mime-db ">= 1.27.0 < 2" + +compression@^1.5.2: + version "1.6.2" + resolved "https://registry.yarnpkg.com/compression/-/compression-1.6.2.tgz#cceb121ecc9d09c52d7ad0c3350ea93ddd402bc3" + dependencies: + accepts "~1.3.3" + bytes "2.3.0" + compressible "~2.0.8" + debug "~2.2.0" + on-headers "~1.0.1" + vary "~1.1.0" + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + +concat-stream@^1.4.1, concat-stream@^1.5.2: + version "1.6.0" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7" + dependencies: + inherits "^2.0.3" + readable-stream "^2.2.2" + typedarray "^0.0.6" + +connect-history-api-fallback@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/connect-history-api-fallback/-/connect-history-api-fallback-1.3.0.tgz#e51d17f8f0ef0db90a64fdb47de3051556e9f169" + +connect@2.12.0: + version "2.12.0" + resolved "https://registry.yarnpkg.com/connect/-/connect-2.12.0.tgz#31d8fa0dcacdf1908d822bd2923be8a2d2a7ed9a" + dependencies: + batch "0.5.0" + buffer-crc32 "0.2.1" + bytes "0.2.1" + cookie "0.1.0" + cookie-signature "1.0.1" + debug ">= 0.7.3 < 1" + fresh "0.2.0" + methods "0.1.0" + multiparty "2.2.0" + negotiator "0.3.0" + pause "0.0.1" + qs "0.6.6" + raw-body "1.1.2" + send "0.1.4" + uid2 "0.0.3" + +console-browserify@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.1.0.tgz#f0241c45730a9fc6323b206dbf38edc741d0bb10" + dependencies: + date-now "^0.1.4" + +console-control-strings@^1.0.0, console-control-strings@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" + +constants-browserify@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/constants-browserify/-/constants-browserify-1.0.0.tgz#c20b96d8c617748aaf1c16021760cd27fcb8cb75" + +contains-path@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/contains-path/-/contains-path-0.1.0.tgz#fe8cf184ff6670b6baef01a9d4861a5cbec4120a" + +content-disposition@0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.2.tgz#0cf68bb9ddf5f2be7961c3a85178cb85dba78cb4" + +content-type@~1.0.1, content-type@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.2.tgz#b7d113aee7a8dd27bd21133c4dc2529df1721eed" + +cookie-signature@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.1.tgz#44e072148af01e6e8e24afbf12690d68ae698ecb" + +cookie-signature@1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" + +cookie@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.1.0.tgz#90eb469ddce905c866de687efc43131d8801f9d0" + +cookie@0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" + +core-js@^2.4.0: + version "2.4.1" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.4.1.tgz#4de911e667b0eae9124e34254b53aea6fc618d3e" + +core-util-is@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + +coveralls@2.11.2: + version "2.11.2" + resolved "https://registry.yarnpkg.com/coveralls/-/coveralls-2.11.2.tgz#d4d982016cb2f9da89d77ab204d86a8537e6a12d" + dependencies: + js-yaml "3.0.1" + lcov-parse "0.0.6" + log-driver "1.2.4" + request "2.40.0" + +crc32-stream@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/crc32-stream/-/crc32-stream-2.0.0.tgz#e3cdd3b4df3168dd74e3de3fbbcb7b297fe908f4" + dependencies: + crc "^3.4.4" + readable-stream "^2.0.0" + +crc@^3.4.4: + version "3.4.4" + resolved "https://registry.yarnpkg.com/crc/-/crc-3.4.4.tgz#9da1e980e3bd44fc5c93bf5ab3da3378d85e466b" + +cryptiles@0.2.x: + version "0.2.2" + resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-0.2.2.tgz#ed91ff1f17ad13d3748288594f8a48a0d26f325c" + dependencies: + boom "0.4.x" + +cryptiles@2.x.x: + version "2.0.5" + resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8" + dependencies: + boom "2.x.x" + +crypto-browserify@3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.3.0.tgz#b9fc75bb4a0ed61dcf1cd5dae96eb30c9c3e506c" + dependencies: + browserify-aes "0.4.0" + pbkdf2-compat "2.0.1" + ripemd160 "0.2.0" + sha.js "2.2.6" + +cson-parser@^1.0.6: + version "1.3.5" + resolved "https://registry.yarnpkg.com/cson-parser/-/cson-parser-1.3.5.tgz#7ec675e039145533bf2a6a856073f1599d9c2d24" + dependencies: + coffee-script "^1.10.0" + +cson@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/cson/-/cson-3.0.2.tgz#83ee9089db3c254bec1e98e498d9aacf11adcc54" + dependencies: + coffee-script "^1.9.0" + cson-parser "^1.0.6" + extract-opts "^3.0.1" + requirefresh "^2.0.0" + safefs "^4.0.0" + +ctype@0.5.3: + version "0.5.3" + resolved "https://registry.yarnpkg.com/ctype/-/ctype-0.5.3.tgz#82c18c2461f74114ef16c135224ad0b9144ca12f" + +currently-unhandled@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" + dependencies: + array-find-index "^1.0.1" + +d@1: + version "1.0.0" + resolved "https://registry.yarnpkg.com/d/-/d-1.0.0.tgz#754bb5bfe55451da69a58b94d45f4c5b0462d58f" + dependencies: + es5-ext "^0.10.9" + +d@~0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/d/-/d-0.1.1.tgz#da184c535d18d8ee7ba2aa229b914009fae11309" + dependencies: + es5-ext "~0.10.2" + +dashdash@^1.12.0: + version "1.14.1" + resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" + dependencies: + assert-plus "^1.0.0" + +date-now@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b" + +dateformat@1.0.2-1.2.3: + version "1.0.2-1.2.3" + resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-1.0.2-1.2.3.tgz#b0220c02de98617433b72851cf47de3df2cdbee9" + +dateformat@~1.0.12: + version "1.0.12" + resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-1.0.12.tgz#9f124b67594c937ff706932e4a642cca8dbbfee9" + dependencies: + get-stdin "^4.0.1" + meow "^3.3.0" + +debug@*, debug@2, debug@2.6.8, debug@^2.1.1, debug@^2.2.0, debug@^2.6.6: + version "2.6.8" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" + dependencies: + ms "2.0.0" + +debug@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.0.0.tgz#89bd9df6732b51256bc6705342bba02ed12131ef" + dependencies: + ms "0.6.2" + +debug@2.2.0, debug@~2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" + dependencies: + ms "0.7.1" + +debug@2.6.7: + version "2.6.7" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.7.tgz#92bad1f6d05bbb6bba22cca88bcd0ec894c2861e" + dependencies: + ms "2.0.0" + +"debug@>= 0.7.3 < 1": + version "0.8.1" + resolved "https://registry.yarnpkg.com/debug/-/debug-0.8.1.tgz#20ff4d26f5e422cb68a1bacbbb61039ad8c1c130" + +debug@~0.7.0: + version "0.7.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-0.7.4.tgz#06e1ea8082c2cb14e39806e22e2f6f757f92af39" + +decamelize@^1.0.0, decamelize@^1.1.2: + version "1.2.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + +deep-extend@~0.4.0: + version "0.4.2" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f" + +deep-is@~0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" + +del@^2.0.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/del/-/del-2.2.2.tgz#c12c981d067846c84bcaf862cff930d907ffd1a8" + dependencies: + globby "^5.0.0" + is-path-cwd "^1.0.0" + is-path-in-cwd "^1.0.0" + object-assign "^4.0.1" + pify "^2.0.0" + pinkie-promise "^2.0.0" + rimraf "^2.2.8" + +delayed-stream@0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-0.0.5.tgz#d4b1f43a93e8296dfe02694f4680bc37a313c73f" + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + +delegates@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" + +depd@1.1.0, depd@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.0.tgz#e1bd82c6aab6ced965b97b88b17ed3e528ca18c3" + +destroy@~1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" + +diff@1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/diff/-/diff-1.0.8.tgz#343276308ec991b7bc82267ed55bc1411f971666" + +diff@1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-1.4.0.tgz#7f28d2eb9ee7b15a97efd89ce63dcfdaa3ccbabf" + +doctrine@1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-1.5.0.tgz#379dce730f6166f76cefa4e6707a159b02c5a6fa" + dependencies: + esutils "^2.0.2" + isarray "^1.0.0" + +doctrine@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.0.0.tgz#c73d8d2909d22291e1a007a395804da8b665fe63" + dependencies: + esutils "^2.0.2" + isarray "^1.0.0" + +domain-browser@^1.1.1: + version "1.1.7" + resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.1.7.tgz#867aa4b093faa05f1de08c06f4d7b21fdf8698bc" + +eachr@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/eachr/-/eachr-3.2.0.tgz#2c35e43ea086516f7997cf80b7aa64d55a4a4484" + dependencies: + editions "^1.1.1" + typechecker "^4.3.0" + +ecc-jsbn@~0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" + dependencies: + jsbn "~0.1.0" + +editions@^1.1.1, editions@^1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/editions/-/editions-1.3.3.tgz#0907101bdda20fac3cbe334c27cbd0688dc99a5b" + +ee-first@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" + +emojis-list@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" + +encodeurl@~1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.1.tgz#79e3d58655346909fe6f0f45a5de68103b294d20" + +end-of-stream@^1.0.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.0.tgz#7a90d833efda6cfa6eac0f4949dbb0fad3a63206" + dependencies: + once "^1.4.0" + +enhanced-resolve@~0.9.0: + version "0.9.1" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-0.9.1.tgz#4d6e689b3725f86090927ccc86cd9f1635b89e2e" + dependencies: + graceful-fs "^4.1.2" + memory-fs "^0.2.0" + tapable "^0.1.8" + +errno@^0.1.3: + version "0.1.4" + resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.4.tgz#b896e23a9e5e8ba33871fc996abd3635fc9a1c7d" + dependencies: + prr "~0.0.0" + +error-ex@^1.2.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc" + dependencies: + is-arrayish "^0.2.1" + +es5-ext@^0.10.14, es5-ext@^0.10.9, es5-ext@~0.10.11, es5-ext@~0.10.14, es5-ext@~0.10.2, es5-ext@~0.10.5, es5-ext@~0.10.6: + version "0.10.23" + resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.23.tgz#7578b51be974207a5487821b56538c224e4e7b38" + dependencies: + es6-iterator "2" + es6-symbol "~3.1" + +es6-iterator@2, es6-iterator@^2.0.1, es6-iterator@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.1.tgz#8e319c9f0453bf575d374940a655920e59ca5512" + dependencies: + d "1" + es5-ext "^0.10.14" + es6-symbol "^3.1" + +es6-iterator@~0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-0.1.3.tgz#d6f58b8c4fc413c249b4baa19768f8e4d7c8944e" + dependencies: + d "~0.1.1" + es5-ext "~0.10.5" + es6-symbol "~2.0.1" + +es6-map@^0.1.3: + version "0.1.5" + resolved "https://registry.yarnpkg.com/es6-map/-/es6-map-0.1.5.tgz#9136e0503dcc06a301690f0bb14ff4e364e949f0" + dependencies: + d "1" + es5-ext "~0.10.14" + es6-iterator "~2.0.1" + es6-set "~0.1.5" + es6-symbol "~3.1.1" + event-emitter "~0.3.5" + +es6-set@~0.1.5: + version "0.1.5" + resolved "https://registry.yarnpkg.com/es6-set/-/es6-set-0.1.5.tgz#d2b3ec5d4d800ced818db538d28974db0a73ccb1" + dependencies: + d "1" + es5-ext "~0.10.14" + es6-iterator "~2.0.1" + es6-symbol "3.1.1" + event-emitter "~0.3.5" + +es6-symbol@3.1.1, es6-symbol@^3.1, es6-symbol@^3.1.1, es6-symbol@~3.1, es6-symbol@~3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.1.tgz#bf00ef4fdab6ba1b46ecb7b629b4c7ed5715cc77" + dependencies: + d "1" + es5-ext "~0.10.14" + +es6-symbol@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-2.0.1.tgz#761b5c67cfd4f1d18afb234f691d678682cb3bf3" + dependencies: + d "~0.1.1" + es5-ext "~0.10.5" + +es6-weak-map@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/es6-weak-map/-/es6-weak-map-2.0.2.tgz#5e3ab32251ffd1538a1f8e5ffa1357772f92d96f" + dependencies: + d "1" + es5-ext "^0.10.14" + es6-iterator "^2.0.1" + es6-symbol "^3.1.1" + +es6-weak-map@~0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/es6-weak-map/-/es6-weak-map-0.1.4.tgz#706cef9e99aa236ba7766c239c8b9e286ea7d228" + dependencies: + d "~0.1.1" + es5-ext "~0.10.6" + es6-iterator "~0.1.3" + es6-symbol "~2.0.1" + +escape-html@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" + +escape-string-regexp@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz#4dbc2fe674e71949caf3fb2695ce7f2dc1d9a8d1" + +escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + +escope@^3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/escope/-/escope-3.6.0.tgz#e01975e812781a163a6dadfdd80398dc64c889c3" + dependencies: + es6-map "^0.1.3" + es6-weak-map "^2.0.1" + esrecurse "^4.1.0" + estraverse "^4.1.1" + +eslint-import-resolver-node@^0.2.0: + version "0.2.3" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.2.3.tgz#5add8106e8c928db2cba232bcd9efa846e3da16c" + dependencies: + debug "^2.2.0" + object-assign "^4.0.1" + resolve "^1.1.6" + +eslint-module-utils@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.0.0.tgz#a6f8c21d901358759cdc35dbac1982ae1ee58bce" + dependencies: + debug "2.2.0" + pkg-dir "^1.0.0" + +eslint-plugin-babel@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-babel/-/eslint-plugin-babel-4.1.1.tgz#ef285c87039b67beb3bbd227f5b0eed4fb376b87" + +eslint-plugin-import@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.3.0.tgz#37c801e0ada0e296cbdf20c3f393acb5b52af36b" + dependencies: + builtin-modules "^1.1.1" + contains-path "^0.1.0" + debug "^2.2.0" + doctrine "1.5.0" + eslint-import-resolver-node "^0.2.0" + eslint-module-utils "^2.0.0" + has "^1.0.1" + lodash.cond "^4.3.0" + minimatch "^3.0.3" + read-pkg-up "^2.0.0" + +eslint-plugin-mocha@^4.10.1: + version "4.10.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-mocha/-/eslint-plugin-mocha-4.10.1.tgz#c63ccb83933bdb01d2bef922332dc4c44b30f3f8" + dependencies: + ramda "^0.24.1" + +eslint-plugin-react@^7.1.0: + version "7.1.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.1.0.tgz#27770acf39f5fd49cd0af4083ce58104eb390d4c" + dependencies: + doctrine "^2.0.0" + has "^1.0.1" + jsx-ast-utils "^1.4.1" + +eslint@^3.19.0: + version "3.19.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.19.0.tgz#c8fc6201c7f40dd08941b87c085767386a679acc" + dependencies: + babel-code-frame "^6.16.0" + chalk "^1.1.3" + concat-stream "^1.5.2" + debug "^2.1.1" + doctrine "^2.0.0" + escope "^3.6.0" + espree "^3.4.0" + esquery "^1.0.0" + estraverse "^4.2.0" + esutils "^2.0.2" + file-entry-cache "^2.0.0" + glob "^7.0.3" + globals "^9.14.0" + ignore "^3.2.0" + imurmurhash "^0.1.4" + inquirer "^0.12.0" + is-my-json-valid "^2.10.0" + is-resolvable "^1.0.0" + js-yaml "^3.5.1" + json-stable-stringify "^1.0.0" + levn "^0.3.0" + lodash "^4.0.0" + mkdirp "^0.5.0" + natural-compare "^1.4.0" + optionator "^0.8.2" + path-is-inside "^1.0.1" + pluralize "^1.2.1" + progress "^1.1.8" + require-uncached "^1.0.2" + shelljs "^0.7.5" + strip-bom "^3.0.0" + strip-json-comments "~2.0.1" + table "^3.7.8" + text-table "~0.2.0" + user-home "^2.0.0" + +espree@^3.4.0: + version "3.4.3" + resolved "https://registry.yarnpkg.com/espree/-/espree-3.4.3.tgz#2910b5ccd49ce893c2ffffaab4fd8b3a31b82374" + dependencies: + acorn "^5.0.1" + acorn-jsx "^3.0.0" + +esprima@^2.6.0: + version "2.7.3" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581" + +esprima@^3.1.1: + version "3.1.3" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633" + +"esprima@~ 1.0.2", esprima@~1.0.2: + version "1.0.4" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-1.0.4.tgz#9f557e08fc3b4d26ece9dd34f8fbf476b62585ad" + +esquery@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.0.tgz#cfba8b57d7fba93f17298a8a006a04cda13d80fa" + dependencies: + estraverse "^4.0.0" + +esrecurse@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.1.0.tgz#4713b6536adf7f2ac4f327d559e7756bff648220" + dependencies: + estraverse "~4.1.0" + object-assign "^4.0.1" + +estraverse@^4.0.0, estraverse@^4.1.1, estraverse@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" + +estraverse@~4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.1.1.tgz#f6caca728933a850ef90661d0e17982ba47111a2" + +esutils@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" + +etag@~1.8.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.0.tgz#6f631aef336d6c46362b51764044ce216be3c051" + +event-emitter@~0.3.4, event-emitter@~0.3.5: + version "0.3.5" + resolved "https://registry.yarnpkg.com/event-emitter/-/event-emitter-0.3.5.tgz#df8c69eef1647923c7157b9ce83840610b02cc39" + dependencies: + d "1" + es5-ext "~0.10.14" + +eventemitter2@~0.4.13: + version "0.4.14" + resolved "https://registry.yarnpkg.com/eventemitter2/-/eventemitter2-0.4.14.tgz#8f61b75cde012b2e9eb284d4545583b5643b61ab" + +eventemitter3@1.x.x: + version "1.2.0" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-1.2.0.tgz#1c86991d816ad1e504750e73874224ecf3bec508" + +events@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" + +eventsource@0.1.6: + version "0.1.6" + resolved "https://registry.yarnpkg.com/eventsource/-/eventsource-0.1.6.tgz#0acede849ed7dd1ccc32c811bb11b944d4f29232" + dependencies: + original ">=0.0.5" + +exit-hook@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8" + +exit@~0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" + +expand-brackets@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" + dependencies: + is-posix-bracket "^0.1.0" + +expand-range@^1.8.1: + version "1.8.2" + resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-1.8.2.tgz#a299effd335fe2721ebae8e257ec79644fc85337" + dependencies: + fill-range "^2.1.0" + +expect.js@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/expect.js/-/expect.js-0.3.1.tgz#b0a59a0d2eff5437544ebf0ceaa6015841d09b5b" + +express@^4.13.3: + version "4.15.3" + resolved "https://registry.yarnpkg.com/express/-/express-4.15.3.tgz#bab65d0f03aa80c358408972fc700f916944b662" + dependencies: + accepts "~1.3.3" + array-flatten "1.1.1" + content-disposition "0.5.2" + content-type "~1.0.2" + cookie "0.3.1" + cookie-signature "1.0.6" + debug "2.6.7" + depd "~1.1.0" + encodeurl "~1.0.1" + escape-html "~1.0.3" + etag "~1.8.0" + finalhandler "~1.0.3" + fresh "0.5.0" + merge-descriptors "1.0.1" + methods "~1.1.2" + on-finished "~2.3.0" + parseurl "~1.3.1" + path-to-regexp "0.1.7" + proxy-addr "~1.1.4" + qs "6.4.0" + range-parser "~1.2.0" + send "0.15.3" + serve-static "1.12.3" + setprototypeof "1.0.3" + statuses "~1.3.1" + type-is "~1.6.15" + utils-merge "1.0.0" + vary "~1.1.1" + +express@~3.4.7: + version "3.4.8" + resolved "https://registry.yarnpkg.com/express/-/express-3.4.8.tgz#aa7a8986de07053337f4bc5ed9a6453d9cc8e2e1" + dependencies: + buffer-crc32 "0.2.1" + commander "1.3.2" + connect "2.12.0" + cookie "0.1.0" + cookie-signature "1.0.1" + debug ">= 0.7.3 < 1" + fresh "0.2.0" + merge-descriptors "0.0.1" + methods "0.1.0" + mkdirp "0.3.5" + range-parser "0.0.4" + send "0.1.4" + +extend@3, extend@^3.0.0, extend@~3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" + +extglob@^0.3.1: + version "0.3.2" + resolved "https://registry.yarnpkg.com/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1" + dependencies: + is-extglob "^1.0.0" + +extract-opts@^3.0.1: + version "3.3.1" + resolved "https://registry.yarnpkg.com/extract-opts/-/extract-opts-3.3.1.tgz#5abbedc98c0d5202e3278727f9192d7e086c6be1" + dependencies: + eachr "^3.2.0" + editions "^1.1.1" + typechecker "^4.3.0" + +extsprintf@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550" + +falafel@~0.1.6: + version "0.1.6" + resolved "https://registry.yarnpkg.com/falafel/-/falafel-0.1.6.tgz#3084cf3d41b59d15c813be6f259557fdc82b0660" + dependencies: + esprima "~1.0.2" + +falafel@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/falafel/-/falafel-1.2.0.tgz#c18d24ef5091174a497f318cd24b026a25cddab4" + dependencies: + acorn "^1.0.3" + foreach "^2.0.5" + isarray "0.0.1" + object-keys "^1.0.6" + +fast-levenshtein@~2.0.4: + version "2.0.6" + resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" + +faye-websocket@^0.10.0, faye-websocket@~0.10.0: + version "0.10.0" + resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.10.0.tgz#4e492f8d04dfb6f89003507f6edbf2d501e7c6f4" + dependencies: + websocket-driver ">=0.5.1" + +faye-websocket@~0.11.0: + version "0.11.1" + resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.11.1.tgz#f0efe18c4f56e4f40afc7e06c719fd5ee6188f38" + dependencies: + websocket-driver ">=0.5.1" + +fg-lodash@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/fg-lodash/-/fg-lodash-0.0.2.tgz#988352537f427da6af222129bb63acca49e62fa3" + dependencies: + lodash "^2.4.1" + underscore.string "~2.3.3" + +figures@^1.0.1, figures@^1.3.5: + version "1.7.0" + resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e" + dependencies: + escape-string-regexp "^1.0.5" + object-assign "^4.1.0" + +file-entry-cache@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-2.0.0.tgz#c392990c3e684783d838b8c84a45d8a048458361" + dependencies: + flat-cache "^1.2.1" + object-assign "^4.0.1" + +file-sync-cmp@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/file-sync-cmp/-/file-sync-cmp-0.1.1.tgz#a5e7a8ffbfa493b43b923bbd4ca89a53b63b612b" + +filename-regex@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26" + +fill-range@^2.1.0: + version "2.2.3" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-2.2.3.tgz#50b77dfd7e469bc7492470963699fe7a8485a723" + dependencies: + is-number "^2.1.0" + isobject "^2.0.0" + randomatic "^1.1.3" + repeat-element "^1.1.2" + repeat-string "^1.5.2" + +finalhandler@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.0.3.tgz#ef47e77950e999780e86022a560e3217e0d0cc89" + dependencies: + debug "2.6.7" + encodeurl "~1.0.1" + escape-html "~1.0.3" + on-finished "~2.3.0" + parseurl "~1.3.1" + statuses "~1.3.1" + unpipe "~1.0.0" + +find-root@~0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/find-root/-/find-root-0.1.2.tgz#98d2267cff1916ccaf2743b3a0eea81d79d7dcd1" + +find-up@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" + dependencies: + path-exists "^2.0.0" + pinkie-promise "^2.0.0" + +find-up@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" + dependencies: + locate-path "^2.0.0" + +findup-sync@~0.1.2: + version "0.1.3" + resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-0.1.3.tgz#7f3e7a97b82392c653bf06589bd85190e93c3683" + dependencies: + glob "~3.2.9" + lodash "~2.4.1" + +findup-sync@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-0.3.0.tgz#37930aa5d816b777c03445e1966cc6790a4c0b16" + dependencies: + glob "~5.0.0" + +flat-cache@^1.2.1: + version "1.2.2" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.2.2.tgz#fa86714e72c21db88601761ecf2f555d1abc6b96" + dependencies: + circular-json "^0.3.1" + del "^2.0.2" + graceful-fs "^4.1.2" + write "^0.2.1" + +for-in@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" + +for-own@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/for-own/-/for-own-0.1.5.tgz#5265c681a4f294dabbf17c9509b6763aa84510ce" + dependencies: + for-in "^1.0.1" + +foreach@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99" + +forever-agent@~0.5.0: + version "0.5.2" + resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.5.2.tgz#6d0e09c4921f94a27f63d3b49c5feff1ea4c5130" + +forever-agent@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" + +form-data@~0.1.0: + version "0.1.4" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-0.1.4.tgz#91abd788aba9702b1aabfa8bc01031a2ac9e3b12" + dependencies: + async "~0.9.0" + combined-stream "~0.0.4" + mime "~1.2.11" + +form-data@~0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-0.2.0.tgz#26f8bc26da6440e299cbdcfb69035c4f77a6e466" + dependencies: + async "~0.9.0" + combined-stream "~0.0.4" + mime-types "~2.0.3" + +form-data@~1.0.0-rc3: + version "1.0.1" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-1.0.1.tgz#ae315db9a4907fa065502304a66d7733475ee37c" + dependencies: + async "^2.0.1" + combined-stream "^1.0.5" + mime-types "^2.1.11" + +form-data@~2.1.1: + version "2.1.4" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.4.tgz#33c183acf193276ecaa98143a69e94bfee1750d1" + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.5" + mime-types "^2.1.12" + +formatio@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/formatio/-/formatio-1.1.1.tgz#5ed3ccd636551097383465d996199100e86161e9" + dependencies: + samsam "~1.1" + +forwarded@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.0.tgz#19ef9874c4ae1c297bcf078fde63a09b66a84363" + +fresh@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.2.0.tgz#bfd9402cf3df12c4a4c310c79f99a3dde13d34a7" + +fresh@0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.0.tgz#f474ca5e6a9246d6fd8e0953cfa9b9c805afa78e" + +fs-extra@^0.24.0: + version "0.24.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.24.0.tgz#d4e4342a96675cb7846633a6099249332b539952" + dependencies: + graceful-fs "^4.1.2" + jsonfile "^2.1.0" + path-is-absolute "^1.0.0" + rimraf "^2.2.8" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + +fsevents@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.1.2.tgz#3282b713fb3ad80ede0e9fcf4611b5aa6fc033f4" + dependencies: + nan "^2.3.0" + node-pre-gyp "^0.6.36" + +fstream-ignore@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/fstream-ignore/-/fstream-ignore-1.0.5.tgz#9c31dae34767018fe1d249b24dada67d092da105" + dependencies: + fstream "^1.0.0" + inherits "2" + minimatch "^3.0.0" + +fstream@^1.0.0, fstream@^1.0.10, fstream@^1.0.2: + version "1.0.11" + resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.11.tgz#5c1fb1f117477114f0632a0eb4b71b3cb0fd3171" + dependencies: + graceful-fs "^4.1.2" + inherits "~2.0.0" + mkdirp ">=0.5 0" + rimraf "2" + +function-bind@^1.0.2: + version "1.1.0" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771" + +gauge@~2.7.3: + version "2.7.4" + resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" + dependencies: + aproba "^1.0.3" + console-control-strings "^1.0.0" + has-unicode "^2.0.0" + object-assign "^4.1.0" + signal-exit "^3.0.0" + string-width "^1.0.1" + strip-ansi "^3.0.1" + wide-align "^1.1.0" + +gaze@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/gaze/-/gaze-1.1.2.tgz#847224677adb8870d679257ed3388fdb61e40105" + dependencies: + globule "^1.0.0" + +generate-function@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.0.0.tgz#6858fe7c0969b7d4e9093337647ac79f60dfbe74" + +generate-object-property@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/generate-object-property/-/generate-object-property-1.2.0.tgz#9c0e1c40308ce804f4783618b937fa88f99d50d0" + dependencies: + is-property "^1.0.0" + +get-stdin@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" + +getobject@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/getobject/-/getobject-0.1.0.tgz#047a449789fa160d018f5486ed91320b6ec7885c" + +getpass@^0.1.1: + version "0.1.7" + resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" + dependencies: + assert-plus "^1.0.0" + +glob-base@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" + dependencies: + glob-parent "^2.0.0" + is-glob "^2.0.0" + +glob-parent@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-2.0.0.tgz#81383d72db054fcccf5336daa902f182f6edbb28" + dependencies: + is-glob "^2.0.0" + +glob@3.2.11, glob@~3.2.7, glob@~3.2.9: + version "3.2.11" + resolved "https://registry.yarnpkg.com/glob/-/glob-3.2.11.tgz#4a973f635b9190f715d10987d5c00fd2815ebe3d" + dependencies: + inherits "2" + minimatch "0.3" + +glob@3.2.3: + version "3.2.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-3.2.3.tgz#e313eeb249c7affaa5c475286b0e115b59839467" + dependencies: + graceful-fs "~2.0.0" + inherits "2" + minimatch "~0.2.11" + +glob@^6.0.1: + version "6.0.4" + resolved "https://registry.yarnpkg.com/glob/-/glob-6.0.4.tgz#0f08860f6a155127b2fadd4f9ce24b1aab6e4d22" + dependencies: + inflight "^1.0.4" + inherits "2" + minimatch "2 || 3" + once "^1.3.0" + path-is-absolute "^1.0.0" + +glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@~7.1.1: + version "7.1.2" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +glob@~3.1.21: + version "3.1.21" + resolved "https://registry.yarnpkg.com/glob/-/glob-3.1.21.tgz#d29e0a055dea5138f4d07ed40e8982e83c2066cd" + dependencies: + graceful-fs "~1.2.0" + inherits "1" + minimatch "~0.2.11" + +glob@~5.0.0, glob@~5.0.15: + version "5.0.15" + resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" + dependencies: + inflight "^1.0.4" + inherits "2" + minimatch "2 || 3" + once "^1.3.0" + path-is-absolute "^1.0.0" + +glob@~7.0.0: + version "7.0.6" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.0.6.tgz#211bafaf49e525b8cd93260d14ab136152b3f57a" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.2" + once "^1.3.0" + path-is-absolute "^1.0.0" + +globals@^9.0.0, globals@^9.14.0: + version "9.18.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" + +globby@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-5.0.0.tgz#ebd84667ca0dbb330b99bcfc68eac2bc54370e0d" + dependencies: + array-union "^1.0.1" + arrify "^1.0.0" + glob "^7.0.3" + object-assign "^4.0.1" + pify "^2.0.0" + pinkie-promise "^2.0.0" + +globule@^1.0.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/globule/-/globule-1.2.0.tgz#1dc49c6822dd9e8a2fa00ba2a295006e8664bd09" + dependencies: + glob "~7.1.1" + lodash "~4.17.4" + minimatch "~3.0.2" + +graceful-fs@^4.1.0, graceful-fs@^4.1.2, graceful-fs@^4.1.4, graceful-fs@^4.1.6: + version "4.1.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" + +graceful-fs@~1.2.0: + version "1.2.3" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-1.2.3.tgz#15a4806a57547cb2d2dbf27f42e89a8c3451b364" + +graceful-fs@~2.0.0: + version "2.0.3" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-2.0.3.tgz#7cd2cdb228a4a3f36e95efa6cc142de7d1a136d0" + +"graceful-readlink@>= 1.0.0": + version "1.0.1" + resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" + +growl@1.8.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/growl/-/growl-1.8.1.tgz#4b2dec8d907e93db336624dcec0183502f8c9428" + +growl@1.9.2: + version "1.9.2" + resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f" + +grunt-cli@^1.2.0, grunt-cli@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/grunt-cli/-/grunt-cli-1.2.0.tgz#562b119ebb069ddb464ace2845501be97b35b6a8" + dependencies: + findup-sync "~0.3.0" + grunt-known-options "~1.1.0" + nopt "~3.0.6" + resolve "~1.1.0" + +grunt-contrib-clean@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/grunt-contrib-clean/-/grunt-contrib-clean-1.1.0.tgz#564abf2d0378a983a15b9e3f30ee75b738c40638" + dependencies: + async "^1.5.2" + rimraf "^2.5.1" + +grunt-contrib-compress@^1.2.0: + version "1.4.3" + resolved "https://registry.yarnpkg.com/grunt-contrib-compress/-/grunt-contrib-compress-1.4.3.tgz#01ceffb9c637f52e7081f463750983d0a3b0fa73" + dependencies: + archiver "^1.3.0" + chalk "^1.1.1" + lodash "^4.7.0" + pretty-bytes "^4.0.2" + stream-buffers "^2.1.0" + optionalDependencies: + iltorb "^1.0.13" + +grunt-contrib-concat@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/grunt-contrib-concat/-/grunt-contrib-concat-1.0.1.tgz#61509863084e871d7e86de48c015259ed97745bd" + dependencies: + chalk "^1.0.0" + source-map "^0.5.3" + +grunt-contrib-copy@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/grunt-contrib-copy/-/grunt-contrib-copy-1.0.0.tgz#7060c6581e904b8ab0d00f076e0a8f6e3e7c3573" + dependencies: + chalk "^1.1.1" + file-sync-cmp "^0.1.0" + +grunt-contrib-uglify@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/grunt-contrib-uglify/-/grunt-contrib-uglify-1.0.2.tgz#ae67a46f9153edd4cb11813a55eb69c70d7db2fb" + dependencies: + chalk "^1.0.0" + lodash "^4.0.1" + maxmin "^1.1.0" + uglify-js "~2.6.2" + uri-path "^1.0.0" + +grunt-contrib-watch@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/grunt-contrib-watch/-/grunt-contrib-watch-1.0.0.tgz#84a1a7a1d6abd26ed568413496c73133e990018f" + dependencies: + async "^1.5.0" + gaze "^1.0.0" + lodash "^3.10.1" + tiny-lr "^0.2.1" + +grunt-esvm@^3.2.8: + version "3.2.9" + resolved "https://registry.yarnpkg.com/grunt-esvm/-/grunt-esvm-3.2.9.tgz#f9c617aa3ba0c953042edf9ded0d73b26d426519" + dependencies: + bluebird "^2.9.30" + cli-color "~0.3.2" + cli-table "~0.3.0" + libesvm "^3.8.3" + lodash "^3.9.3" + moment "^2.10.3" + wreck "^5.6.0" + +grunt-known-options@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/grunt-known-options/-/grunt-known-options-1.1.0.tgz#a4274eeb32fa765da5a7a3b1712617ce3b144149" + +grunt-legacy-log-utils@~0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/grunt-legacy-log-utils/-/grunt-legacy-log-utils-0.1.1.tgz#c0706b9dd9064e116f36f23fe4e6b048672c0f7e" + dependencies: + colors "~0.6.2" + lodash "~2.4.1" + underscore.string "~2.3.3" + +grunt-legacy-log-utils@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/grunt-legacy-log-utils/-/grunt-legacy-log-utils-1.0.0.tgz#a7b8e2d0fb35b5a50f4af986fc112749ebc96f3d" + dependencies: + chalk "~1.1.1" + lodash "~4.3.0" + +grunt-legacy-log@~0.1.0: + version "0.1.3" + resolved "https://registry.yarnpkg.com/grunt-legacy-log/-/grunt-legacy-log-0.1.3.tgz#ec29426e803021af59029f87d2f9cd7335a05531" + dependencies: + colors "~0.6.2" + grunt-legacy-log-utils "~0.1.1" + hooker "~0.2.3" + lodash "~2.4.1" + underscore.string "~2.3.3" + +grunt-legacy-log@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/grunt-legacy-log/-/grunt-legacy-log-1.0.0.tgz#fb86f1809847bc07dc47843f9ecd6cacb62df2d5" + dependencies: + colors "~1.1.2" + grunt-legacy-log-utils "~1.0.0" + hooker "~0.2.3" + lodash "~3.10.1" + underscore.string "~3.2.3" + +grunt-legacy-util@~0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/grunt-legacy-util/-/grunt-legacy-util-0.2.0.tgz#93324884dbf7e37a9ff7c026dff451d94a9e554b" + dependencies: + async "~0.1.22" + exit "~0.1.1" + getobject "~0.1.0" + hooker "~0.2.3" + lodash "~0.9.2" + underscore.string "~2.2.1" + which "~1.0.5" + +grunt-legacy-util@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/grunt-legacy-util/-/grunt-legacy-util-1.0.0.tgz#386aa78dc6ed50986c2b18957265b1b48abb9b86" + dependencies: + async "~1.5.2" + exit "~0.1.1" + getobject "~0.1.0" + hooker "~0.2.3" + lodash "~4.3.0" + underscore.string "~3.2.3" + which "~1.2.1" + +grunt-mocha-cov@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/grunt-mocha-cov/-/grunt-mocha-cov-0.4.0.tgz#8023966db058753741b8578dace63c6f71021d7a" + dependencies: + blanket "1.1.6" + coveralls "2.11.2" + lcov-parse "0.0.9" + lodash.defaults "3.0.0" + mkdirp "0.5.0" + mocha "2.2.1" + mocha-lcov-reporter "0.0.2" + request "2.53.0" + +grunt-open@~0.2.2: + version "0.2.3" + resolved "https://registry.yarnpkg.com/grunt-open/-/grunt-open-0.2.3.tgz#145ac45026a57fcfaa433ffd7398ae46d2bd3957" + dependencies: + open "~0.0.4" + +grunt-prompt@^1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/grunt-prompt/-/grunt-prompt-1.3.3.tgz#c5b43bec3aa29aa6962ac6611a896712fcba6791" + dependencies: + inquirer "^0.11.0" + lodash "^3.10.1" + +grunt-run@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/grunt-run/-/grunt-run-0.6.0.tgz#6dc8f4e592a0c900fb93d608d73286465022d648" + dependencies: + lodash "^3.10.0" + strip-ansi "^3.0.0" + +grunt-s3@~0.2.0-alpha.3: + version "0.2.0-alpha.3" + resolved "https://registry.yarnpkg.com/grunt-s3/-/grunt-s3-0.2.0-alpha.3.tgz#e3329d2caa6ed93c4dbc0397e257caa68ae9ee7c" + dependencies: + grunt "0.4.x" + knox "0.8.x" + mime "~1.2.5" + temporary "0.0.5" + underscore.deferred "~0.1.4" + +grunt-saucelabs@^8.6.2: + version "8.6.3" + resolved "https://registry.yarnpkg.com/grunt-saucelabs/-/grunt-saucelabs-8.6.3.tgz#ecc5140badfd77e79eb76abde28da719eaf0f01e" + dependencies: + colors "~1.1.2" + lodash "~4.0.0" + q "~1.4.1" + requestretry "~1.9.0" + sauce-tunnel "~2.4.0" + saucelabs "~1.0.1" + +grunt-webpack@^1.0.11: + version "1.0.18" + resolved "https://registry.yarnpkg.com/grunt-webpack/-/grunt-webpack-1.0.18.tgz#ff26c43ff35bae6cca707a93c4bcdd950a3ecbb7" + dependencies: + lodash "^4.7.0" + +grunt@0.4.x: + version "0.4.5" + resolved "https://registry.yarnpkg.com/grunt/-/grunt-0.4.5.tgz#56937cd5194324adff6d207631832a9d6ba4e7f0" + dependencies: + async "~0.1.22" + coffee-script "~1.3.3" + colors "~0.6.2" + dateformat "1.0.2-1.2.3" + eventemitter2 "~0.4.13" + exit "~0.1.1" + findup-sync "~0.1.2" + getobject "~0.1.0" + glob "~3.1.21" + grunt-legacy-log "~0.1.0" + grunt-legacy-util "~0.2.0" + hooker "~0.2.3" + iconv-lite "~0.2.11" + js-yaml "~2.0.5" + lodash "~0.9.2" + minimatch "~0.2.12" + nopt "~1.0.10" + rimraf "~2.2.8" + underscore.string "~2.2.1" + which "~1.0.5" + +grunt@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/grunt/-/grunt-1.0.1.tgz#e8778764e944b18f32bb0f10b9078475c9dfb56b" + dependencies: + coffee-script "~1.10.0" + dateformat "~1.0.12" + eventemitter2 "~0.4.13" + exit "~0.1.1" + findup-sync "~0.3.0" + glob "~7.0.0" + grunt-cli "~1.2.0" + grunt-known-options "~1.1.0" + grunt-legacy-log "~1.0.0" + grunt-legacy-util "~1.0.0" + iconv-lite "~0.4.13" + js-yaml "~3.5.2" + minimatch "~3.0.0" + nopt "~3.0.6" + path-is-absolute "~1.0.0" + rimraf "~2.2.8" + +gzip-size@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/gzip-size/-/gzip-size-1.0.0.tgz#66cf8b101047227b95bace6ea1da0c177ed5c22f" + dependencies: + browserify-zlib "^0.1.4" + concat-stream "^1.4.1" + +har-schema@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-1.0.5.tgz#d263135f43307c02c602afc8fe95970c0151369e" + +har-validator@~2.0.2: + version "2.0.6" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-2.0.6.tgz#cdcbc08188265ad119b6a5a7c8ab70eecfb5d27d" + dependencies: + chalk "^1.1.1" + commander "^2.9.0" + is-my-json-valid "^2.12.4" + pinkie-promise "^2.0.0" + +har-validator@~4.2.1: + version "4.2.1" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-4.2.1.tgz#33481d0f1bbff600dd203d75812a6a5fba002e2a" + dependencies: + ajv "^4.9.1" + har-schema "^1.0.5" + +has-ansi@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" + dependencies: + ansi-regex "^2.0.0" + +has-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" + +has-unicode@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" + +has@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28" + dependencies: + function-bind "^1.0.2" + +hawk@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/hawk/-/hawk-1.1.1.tgz#87cd491f9b46e4e2aeaca335416766885d2d1ed9" + dependencies: + boom "0.4.x" + cryptiles "0.2.x" + hoek "0.9.x" + sntp "0.2.x" + +hawk@~2.3.0: + version "2.3.1" + resolved "https://registry.yarnpkg.com/hawk/-/hawk-2.3.1.tgz#1e731ce39447fa1d0f6d707f7bceebec0fd1ec1f" + dependencies: + boom "2.x.x" + cryptiles "2.x.x" + hoek "2.x.x" + sntp "1.x.x" + +hawk@~3.1.0, hawk@~3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4" + dependencies: + boom "2.x.x" + cryptiles "2.x.x" + hoek "2.x.x" + sntp "1.x.x" + +hoek@0.9.x: + version "0.9.1" + resolved "https://registry.yarnpkg.com/hoek/-/hoek-0.9.1.tgz#3d322462badf07716ea7eb85baf88079cddce505" + +hoek@2.x.x: + version "2.16.3" + resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" + +hooker@~0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/hooker/-/hooker-0.2.3.tgz#b834f723cc4a242aa65963459df6d984c5d3d959" + +hosted-git-info@^2.1.4: + version "2.4.2" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.4.2.tgz#0076b9f46a270506ddbaaea56496897460612a67" + +http-errors@~1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.3.1.tgz#197e22cdebd4198585e8694ef6786197b91ed942" + dependencies: + inherits "~2.0.1" + statuses "1" + +http-errors@~1.6.1: + version "1.6.1" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.1.tgz#5f8b8ed98aca545656bf572997387f904a722257" + dependencies: + depd "1.1.0" + inherits "2.0.3" + setprototypeof "1.0.3" + statuses ">= 1.3.1 < 2" + +http-proxy-middleware@~0.17.1: + version "0.17.4" + resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-0.17.4.tgz#642e8848851d66f09d4f124912846dbaeb41b833" + dependencies: + http-proxy "^1.16.2" + is-glob "^3.1.0" + lodash "^4.17.2" + micromatch "^2.3.11" + +http-proxy@^1.16.2: + version "1.16.2" + resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.16.2.tgz#06dff292952bf64dbe8471fa9df73066d4f37742" + dependencies: + eventemitter3 "1.x.x" + requires-port "1.x.x" + +http-signature@~0.10.0: + version "0.10.1" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-0.10.1.tgz#4fbdac132559aa8323121e540779c0a012b27e66" + dependencies: + asn1 "0.1.11" + assert-plus "^0.1.5" + ctype "0.5.3" + +http-signature@~0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-0.11.0.tgz#1796cf67a001ad5cd6849dca0991485f09089fe6" + dependencies: + asn1 "0.1.11" + assert-plus "^0.1.5" + ctype "0.5.3" + +http-signature@~1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.1.1.tgz#df72e267066cd0ac67fb76adf8e134a8fbcf91bf" + dependencies: + assert-plus "^0.2.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + +https-browserify@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-0.0.1.tgz#3f91365cabe60b77ed0ebba24b454e3e09d95a82" + +https-proxy-agent@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-1.0.0.tgz#35f7da6c48ce4ddbfa264891ac593ee5ff8671e6" + dependencies: + agent-base "2" + debug "2" + extend "3" + +iconv-lite@0.4.13: + version "0.4.13" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.13.tgz#1f88aba4ab0b1508e8312acc39345f36e992e2f2" + +iconv-lite@~0.2.11: + version "0.2.11" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.2.11.tgz#1ce60a3a57864a292d1321ff4609ca4bb965adc8" + +iconv-lite@~0.4.13: + version "0.4.18" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.18.tgz#23d8656b16aae6742ac29732ea8f0336a4789cf2" + +ieee754@^1.1.4: + version "1.1.8" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4" + +ignore@^3.2.0: + version "3.3.3" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.3.tgz#432352e57accd87ab3110e82d3fea0e47812156d" + +iltorb@^1.0.13: + version "1.3.1" + resolved "https://registry.yarnpkg.com/iltorb/-/iltorb-1.3.1.tgz#47270458ec6837c422c26c9282f00e63196e95f9" + dependencies: + nan "^2.6.1" + node-pre-gyp "^0.6.34" + +imurmurhash@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" + +indent-string@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-2.1.0.tgz#8e2d48348742121b4a8218b7a137e9a52049dc80" + dependencies: + repeating "^2.0.0" + +indexof@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/indexof/-/indexof-0.0.1.tgz#82dc336d232b9062179d05ab3293a66059fd435d" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + dependencies: + once "^1.3.0" + wrappy "1" + +inherit@^2.2.2: + version "2.2.6" + resolved "https://registry.yarnpkg.com/inherit/-/inherit-2.2.6.tgz#f1614b06c8544e8128e4229c86347db73ad9788d" + +inherits@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-1.0.2.tgz#ca4309dadee6b54cc0b8d247e8d7c7a0975bdc9b" + +inherits@2, inherits@2.0.3, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.0, inherits@~2.0.1: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + +inherits@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1" + +ini@~1.3.0: + version "1.3.4" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e" + +inquirer@^0.11.0: + version "0.11.4" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-0.11.4.tgz#81e3374e8361beaff2d97016206d359d0b32fa4d" + dependencies: + ansi-escapes "^1.1.0" + ansi-regex "^2.0.0" + chalk "^1.0.0" + cli-cursor "^1.0.1" + cli-width "^1.0.1" + figures "^1.3.5" + lodash "^3.3.1" + readline2 "^1.0.1" + run-async "^0.1.0" + rx-lite "^3.1.2" + string-width "^1.0.1" + strip-ansi "^3.0.0" + through "^2.3.6" + +inquirer@^0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-0.12.0.tgz#1ef2bfd63504df0bc75785fff8c2c41df12f077e" + dependencies: + ansi-escapes "^1.1.0" + ansi-regex "^2.0.0" + chalk "^1.0.0" + cli-cursor "^1.0.1" + cli-width "^2.0.0" + figures "^1.3.5" + lodash "^4.3.0" + readline2 "^1.0.1" + run-async "^0.1.0" + rx-lite "^3.1.2" + string-width "^1.0.1" + strip-ansi "^3.0.0" + through "^2.3.6" + +interpret@^0.6.4: + version "0.6.6" + resolved "https://registry.yarnpkg.com/interpret/-/interpret-0.6.6.tgz#fecd7a18e7ce5ca6abfb953e1f86213a49f1625b" + +interpret@^1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.3.tgz#cbc35c62eeee73f19ab7b10a801511401afc0f90" + +invariant@^2.2.0: + version "2.2.2" + resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360" + dependencies: + loose-envify "^1.0.0" + +ipaddr.js@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.3.0.tgz#1e03a52fdad83a8bbb2b25cbf4998b4cffcd3dec" + +is-arrayish@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" + +is-binary-path@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-1.0.1.tgz#75f16642b480f187a711c814161fd3a4a7655898" + dependencies: + binary-extensions "^1.0.0" + +is-buffer@^1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc" + +is-builtin-module@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-1.0.0.tgz#540572d34f7ac3119f8f76c30cbc1b1e037affbe" + dependencies: + builtin-modules "^1.0.0" + +is-dotfile@^1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.3.tgz#a6a2f32ffd2dfb04f5ca25ecd0f6b83cf798a1e1" + +is-equal-shallow@^0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz#2238098fc221de0bcfa5d9eac4c45d638aa1c534" + dependencies: + is-primitive "^2.0.0" + +is-extendable@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" + +is-extglob@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0" + +is-extglob@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + +is-finite@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa" + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" + +is-glob@^2.0.0, is-glob@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863" + dependencies: + is-extglob "^1.0.0" + +is-glob@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a" + dependencies: + is-extglob "^2.1.0" + +is-my-json-valid@^2.10.0, is-my-json-valid@^2.12.4: + version "2.16.0" + resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.16.0.tgz#f079dd9bfdae65ee2038aae8acbc86ab109e3693" + dependencies: + generate-function "^2.0.0" + generate-object-property "^1.1.0" + jsonpointer "^4.0.0" + xtend "^4.0.0" + +is-number@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" + dependencies: + kind-of "^3.0.2" + +is-number@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" + dependencies: + kind-of "^3.0.2" + +is-path-cwd@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-1.0.0.tgz#d225ec23132e89edd38fda767472e62e65f1106d" + +is-path-in-cwd@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-path-in-cwd/-/is-path-in-cwd-1.0.0.tgz#6477582b8214d602346094567003be8a9eac04dc" + dependencies: + is-path-inside "^1.0.0" + +is-path-inside@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.0.tgz#fc06e5a1683fbda13de667aff717bbc10a48f37f" + dependencies: + path-is-inside "^1.0.1" + +is-posix-bracket@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4" + +is-primitive@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" + +is-property@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" + +is-resolvable@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.0.0.tgz#8df57c61ea2e3c501408d100fb013cf8d6e0cc62" + dependencies: + tryit "^1.0.1" + +is-typedarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" + +is-utf8@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" + +isarray@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" + +isarray@1.0.0, isarray@^1.0.0, isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + +isobject@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" + dependencies: + isarray "1.0.0" + +isstream@~0.1.1, isstream@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" + +jade@0.26.3: + version "0.26.3" + resolved "https://registry.yarnpkg.com/jade/-/jade-0.26.3.tgz#8f10d7977d8d79f2f6ff862a81b0513ccb25686c" + dependencies: + commander "0.6.1" + mkdirp "0.3.0" + +jit-grunt@~0.10.0: + version "0.10.0" + resolved "https://registry.yarnpkg.com/jit-grunt/-/jit-grunt-0.10.0.tgz#008c3a7fe1e96bd0d84e260ea1fa1783457f79c2" + +jquery@^2.2.3: + version "2.2.4" + resolved "https://registry.yarnpkg.com/jquery/-/jquery-2.2.4.tgz#2c89d6889b5eac522a7eea32c14521559c6cbf02" + +js-tokens@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7" + +js-yaml@3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.0.1.tgz#76405fea5bce30fc8f405d48c6dca7f0a32c6afe" + dependencies: + argparse "~ 0.1.11" + esprima "~ 1.0.2" + +js-yaml@^3.5.1, js-yaml@^3.5.2, js-yaml@^3.6.0: + version "3.8.4" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.8.4.tgz#520b4564f86573ba96662af85a8cafa7b4b5a6f6" + dependencies: + argparse "^1.0.7" + esprima "^3.1.1" + +js-yaml@~2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-2.0.5.tgz#a25ae6509999e97df278c6719da11bd0687743a8" + dependencies: + argparse "~ 0.1.11" + esprima "~ 1.0.2" + +js-yaml@~3.4.3: + version "3.4.6" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.4.6.tgz#6be1b23f6249f53d293370fd4d1aaa63ce1b4eb0" + dependencies: + argparse "^1.0.2" + esprima "^2.6.0" + inherit "^2.2.2" + +js-yaml@~3.5.2: + version "3.5.5" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.5.5.tgz#0377c38017cabc7322b0d1fbcd25a491641f2fbe" + dependencies: + argparse "^1.0.2" + esprima "^2.6.0" + +jsbn@~0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" + +json-schema@0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" + +json-stable-stringify@^1.0.0, json-stable-stringify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" + dependencies: + jsonify "~0.0.0" + +json-stringify-safe@~5.0.0, json-stringify-safe@~5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + +json3@^3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1" + +json5@^0.5.0: + version "0.5.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" + +jsonfile@^2.1.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8" + optionalDependencies: + graceful-fs "^4.1.6" + +jsonify@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" + +jsonpointer@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9" + +jsprim@^1.2.2: + version "1.4.0" + resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.0.tgz#a3b87e40298d8c380552d8cc7628a0bb95a22918" + dependencies: + assert-plus "1.0.0" + extsprintf "1.0.2" + json-schema "0.2.3" + verror "1.3.6" + +jsx-ast-utils@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-1.4.1.tgz#3867213e8dd79bf1e8f2300c0cfc1efb182c0df1" + +keypress@0.1.x: + version "0.1.0" + resolved "https://registry.yarnpkg.com/keypress/-/keypress-0.1.0.tgz#4a3188d4291b66b4f65edb99f806aa9ae293592a" + +kind-of@^3.0.2: + version "3.2.2" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" + dependencies: + is-buffer "^1.1.5" + +kind-of@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57" + dependencies: + is-buffer "^1.1.5" + +knox@0.8.x: + version "0.8.10" + resolved "https://registry.yarnpkg.com/knox/-/knox-0.8.10.tgz#6a2edcdac1d2ae379d1e1994d559b95c283b2588" + dependencies: + debug "~0.7.0" + mime "*" + stream-counter "~0.1.0" + xml2js "0.2.x" + +lazy-cache@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e" + +lazystream@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/lazystream/-/lazystream-1.0.0.tgz#f6995fe0f820392f61396be89462407bb77168e4" + dependencies: + readable-stream "^2.0.5" + +lcov-parse@0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/lcov-parse/-/lcov-parse-0.0.6.tgz#819e5da8bf0791f9d3f39eea5ed1868187f11175" + +lcov-parse@0.0.9: + version "0.0.9" + resolved "https://registry.yarnpkg.com/lcov-parse/-/lcov-parse-0.0.9.tgz#dddc893082aea7856477a3b8df86265ccab3ec04" + +levn@^0.3.0, levn@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" + dependencies: + prelude-ls "~1.1.2" + type-check "~0.3.2" + +libesvm@^3.8.3: + version "3.8.3" + resolved "https://registry.yarnpkg.com/libesvm/-/libesvm-3.8.3.tgz#fca17ac33332badb0bc1846d2b11771c57ea3b29" + dependencies: + bcryptjs "^2.3.0" + bluebird "~2.10.2" + fs-extra "^0.24.0" + glob "^6.0.1" + js-yaml "^3.5.2" + lodash "~2.4.1" + lodash.defaultsdeep "^4.3.5" + lodash.forown "^4.1.0" + lodash.isplainobject "^4.0.4" + lodash.set "^4.1.0" + lodash.snakecase "^4.1.1" + mkdirp "~0.5.0" + moment "^2.7.0" + node-uuid "^1.4.7" + properties-parser "^0.2.3" + rcloader "^0.1.4" + request "~2.65.0" + rimraf "~2.2.8" + semver "~4.3.6" + split "~0.3.2" + tar "~2.2.1 " + temp "^0.8.0" + through2 "~0.6.3" + +livereload-js@^2.2.0: + version "2.2.2" + resolved "https://registry.yarnpkg.com/livereload-js/-/livereload-js-2.2.2.tgz#6c87257e648ab475bc24ea257457edcc1f8d0bc2" + +load-grunt-config@^0.19.2: + version "0.19.2" + resolved "https://registry.yarnpkg.com/load-grunt-config/-/load-grunt-config-0.19.2.tgz#52090d4a20c6e63f74a7648f249b19e7b7fcec24" + dependencies: + cson "~3.0.2" + glob "~5.0.15" + jit-grunt "~0.10.0" + js-yaml "~3.4.3" + load-grunt-tasks "~3.3.0" + lodash "~3.10.1" + +load-grunt-tasks@^3.5.0: + version "3.5.2" + resolved "https://registry.yarnpkg.com/load-grunt-tasks/-/load-grunt-tasks-3.5.2.tgz#0728561180fd20ff8a6927505852fc58aaea0c88" + dependencies: + arrify "^1.0.0" + multimatch "^2.0.0" + pkg-up "^1.0.0" + resolve-pkg "^0.1.0" + +load-grunt-tasks@~3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/load-grunt-tasks/-/load-grunt-tasks-3.3.0.tgz#be5892909458d93ddf769eb4bc685102080c6321" + dependencies: + arrify "^1.0.0" + multimatch "^2.0.0" + pkg-up "^1.0.0" + +load-json-file@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" + dependencies: + graceful-fs "^4.1.2" + parse-json "^2.2.0" + pify "^2.0.0" + pinkie-promise "^2.0.0" + strip-bom "^2.0.0" + +load-json-file@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-2.0.0.tgz#7947e42149af80d696cbf797bcaabcfe1fe29ca8" + dependencies: + graceful-fs "^4.1.2" + parse-json "^2.2.0" + pify "^2.0.0" + strip-bom "^3.0.0" + +loader-utils@^0.2.11: + version "0.2.17" + resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.17.tgz#f86e6374d43205a6e6c60e9196f17c0299bfb348" + dependencies: + big.js "^3.1.3" + emojis-list "^2.0.0" + json5 "^0.5.0" + object-assign "^4.0.1" + +locate-path@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" + dependencies: + p-locate "^2.0.0" + path-exists "^3.0.0" + +lodash._arraycopy@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/lodash._arraycopy/-/lodash._arraycopy-3.0.0.tgz#76e7b7c1f1fb92547374878a562ed06a3e50f6e1" + +lodash._baseassign@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz#8c38a099500f215ad09e59f1722fd0c52bfe0a4e" + dependencies: + lodash._basecopy "^3.0.0" + lodash.keys "^3.0.0" + +lodash._basecopy@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36" + +lodash._bindcallback@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e" + +lodash._createassigner@^3.0.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/lodash._createassigner/-/lodash._createassigner-3.1.1.tgz#838a5bae2fdaca63ac22dee8e19fa4e6d6970b11" + dependencies: + lodash._bindcallback "^3.0.0" + lodash._isiterateecall "^3.0.0" + lodash.restparam "^3.0.0" + +lodash._getnative@^3.0.0: + version "3.9.1" + resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" + +lodash._isiterateecall@^3.0.0: + version "3.0.9" + resolved "https://registry.yarnpkg.com/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz#5203ad7ba425fae842460e696db9cf3e6aac057c" + +lodash.assign@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-3.2.0.tgz#3ce9f0234b4b2223e296b8fa0ac1fee8ebca64fa" + dependencies: + lodash._baseassign "^3.0.0" + lodash._createassigner "^3.0.0" + lodash.keys "^3.0.0" + +lodash.clonedeep@^4.3.2: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" + +lodash.cond@^4.3.0: + version "4.5.2" + resolved "https://registry.yarnpkg.com/lodash.cond/-/lodash.cond-4.5.2.tgz#f471a1da486be60f6ab955d17115523dd1d255d5" + +lodash.defaults@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-3.0.0.tgz#8f1984541e88b00218ca0900f9d8959038c72e9a" + dependencies: + lodash._arraycopy "^3.0.0" + lodash.assign "^3.0.0" + +lodash.defaultsdeep@^4.3.5: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.defaultsdeep/-/lodash.defaultsdeep-4.6.0.tgz#bec1024f85b1bd96cbea405b23c14ad6443a6f81" + +lodash.forown@^4.1.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.forown/-/lodash.forown-4.4.0.tgz#85115cf04f73ef966eced52511d3893cc46683af" + +lodash.get@^4.4.2: + version "4.4.2" + resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" + +lodash.isarguments@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" + +lodash.isarray@^3.0.0: + version "3.0.4" + resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55" + +lodash.isempty@^4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.isempty/-/lodash.isempty-4.4.0.tgz#6f86cbedd8be4ec987be9aaf33c9684db1b31e7e" + +lodash.isplainobject@^4.0.4: + version "4.0.6" + resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb" + +lodash.keys@^3.0.0: + version "3.1.2" + resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a" + dependencies: + lodash._getnative "^3.0.0" + lodash.isarguments "^3.0.0" + lodash.isarray "^3.0.0" + +lodash.restparam@^3.0.0: + version "3.6.1" + resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805" + +lodash.set@^4.1.0: + version "4.3.2" + resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23" + +lodash.snakecase@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz#39d714a35357147837aefd64b5dcbb16becd8f8d" + +lodash.trimend@^4.5.1: + version "4.5.1" + resolved "https://registry.yarnpkg.com/lodash.trimend/-/lodash.trimend-4.5.1.tgz#12804437286b98cad8996b79414e11300114082f" + +lodash@2.4.2, lodash@^2.4.1, lodash@~2.4.1: + version "2.4.2" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-2.4.2.tgz#fadd834b9683073da179b3eae6d9c0d15053f73e" + +lodash@^3.0.1, lodash@^3.10.0, lodash@^3.10.1, lodash@^3.3.1, lodash@^3.9.3, lodash@~3.10.1: + version "3.10.1" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" + +lodash@^4.0.0, lodash@^4.0.1, lodash@^4.14.0, lodash@^4.17.2, lodash@^4.2.0, lodash@^4.3.0, lodash@^4.7.0, lodash@^4.8.0, lodash@~4.17.4: + version "4.17.4" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" + +lodash@~0.9.2: + version "0.9.2" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-0.9.2.tgz#8f3499c5245d346d682e5b0d3b40767e09f1a92c" + +lodash@~4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.0.1.tgz#cd8c902c9e03f2e69ce3e0e456d505ab89eb98f4" + +lodash@~4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.3.0.tgz#efd9c4a6ec53f3b05412429915c3e4824e4d25a4" + +log-driver@1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/log-driver/-/log-driver-1.2.4.tgz#2d62d7faef45d8a71341961a04b0761eca99cfa3" + +lolex@1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/lolex/-/lolex-1.3.2.tgz#7c3da62ffcb30f0f5a80a2566ca24e45d8a01f31" + +longest@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" + +loose-envify@^1.0.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848" + dependencies: + js-tokens "^3.0.0" + +loud-rejection@^1.0.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" + dependencies: + currently-unhandled "^0.4.1" + signal-exit "^3.0.0" + +lru-cache@2: + version "2.7.3" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.7.3.tgz#6d4524e8b955f95d4f5b58851ce21dd72fb4e952" + +lru-queue@0.1: + version "0.1.0" + resolved "https://registry.yarnpkg.com/lru-queue/-/lru-queue-0.1.0.tgz#2738bd9f0d3cf4f84490c5736c48699ac632cda3" + dependencies: + es5-ext "~0.10.2" + +map-obj@^1.0.0, map-obj@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" + +maxmin@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/maxmin/-/maxmin-1.1.0.tgz#71365e84a99dd8f8b3f7d5fde2f00d1e7f73be61" + dependencies: + chalk "^1.0.0" + figures "^1.0.1" + gzip-size "^1.0.0" + pretty-bytes "^1.0.0" + +media-typer@0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" + +memoizee@~0.3.8: + version "0.3.10" + resolved "https://registry.yarnpkg.com/memoizee/-/memoizee-0.3.10.tgz#4eca0d8aed39ec9d017f4c5c2f2f6432f42e5c8f" + dependencies: + d "~0.1.1" + es5-ext "~0.10.11" + es6-weak-map "~0.1.4" + event-emitter "~0.3.4" + lru-queue "0.1" + next-tick "~0.2.2" + timers-ext "0.1" + +memory-fs@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.2.0.tgz#f2bb25368bc121e391c2520de92969caee0a0290" + +memory-fs@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.3.0.tgz#7bcc6b629e3a43e871d7e29aca6ae8a7f15cbb20" + dependencies: + errno "^0.1.3" + readable-stream "^2.0.1" + +memory-fs@~0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.4.1.tgz#3a9a20b8462523e447cfbc7e8bb80ed667bfc552" + dependencies: + errno "^0.1.3" + readable-stream "^2.0.1" + +meow@^3.1.0, meow@^3.3.0: + version "3.7.0" + resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb" + dependencies: + camelcase-keys "^2.0.0" + decamelize "^1.1.2" + loud-rejection "^1.0.0" + map-obj "^1.0.1" + minimist "^1.1.3" + normalize-package-data "^2.3.4" + object-assign "^4.0.1" + read-pkg-up "^1.0.1" + redent "^1.0.0" + trim-newlines "^1.0.0" + +merge-descriptors@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-0.0.1.tgz#2ff0980c924cf81d0b5d1fb601177cb8bb56c0d0" + +merge-descriptors@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" + +methods@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/methods/-/methods-0.1.0.tgz#335d429eefd21b7bacf2e9c922a8d2bd14a30e4f" + +methods@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" + +micromatch@^2.1.5, micromatch@^2.3.11: + version "2.3.11" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565" + dependencies: + arr-diff "^2.0.0" + array-unique "^0.2.1" + braces "^1.8.2" + expand-brackets "^0.1.4" + extglob "^0.3.1" + filename-regex "^2.0.0" + is-extglob "^1.0.0" + is-glob "^2.0.1" + kind-of "^3.0.2" + normalize-path "^2.0.1" + object.omit "^2.0.0" + parse-glob "^3.0.4" + regex-cache "^0.4.2" + +"mime-db@>= 1.27.0 < 2", mime-db@~1.27.0: + version "1.27.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.27.0.tgz#820f572296bbd20ec25ed55e5b5de869e5436eb1" + +mime-db@~1.12.0: + version "1.12.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.12.0.tgz#3d0c63180f458eb10d325aaa37d7c58ae312e9d7" + +mime-types@^2.1.11, mime-types@^2.1.12, mime-types@~2.1.11, mime-types@~2.1.15, mime-types@~2.1.7: + version "2.1.15" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.15.tgz#a4ebf5064094569237b8cf70046776d09fc92aed" + dependencies: + mime-db "~1.27.0" + +mime-types@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-1.0.2.tgz#995ae1392ab8affcbfcb2641dd054e943c0d5dce" + +mime-types@~2.0.1, mime-types@~2.0.3: + version "2.0.14" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.0.14.tgz#310e159db23e077f8bb22b748dabfa4957140aa6" + dependencies: + mime-db "~1.12.0" + +mime@*, mime@1.3.4, mime@^1.3.4: + version "1.3.4" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.3.4.tgz#115f9e3b6b3daf2959983cb38f149a2d40eb5d53" + +mime@~1.2.11, mime@~1.2.5, mime@~1.2.9: + version "1.2.11" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.2.11.tgz#58203eed86e3a5ef17aed2b7d9ebd47f0a60dd10" + +minimatch@0.3: + version "0.3.0" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-0.3.0.tgz#275d8edaac4f1bb3326472089e7949c8394699dd" + dependencies: + lru-cache "2" + sigmund "~1.0.0" + +"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4, minimatch@~3.0.0, minimatch@~3.0.2: + version "3.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" + dependencies: + brace-expansion "^1.1.7" + +minimatch@~0.2.11, minimatch@~0.2.12: + version "0.2.14" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-0.2.14.tgz#c74e780574f63c6f9a090e90efbe6ef53a6a756a" + dependencies: + lru-cache "2" + sigmund "~1.0.0" + +minimist@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" + +minimist@^1.1.3, minimist@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + +minimist@~0.0.1: + version "0.0.10" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" + +mkdirp@0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.3.0.tgz#1bbf5ab1ba827af23575143490426455f481fe1e" + +mkdirp@0.3.5: + version "0.3.5" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.3.5.tgz#de3e5f8961c88c787ee1368df849ac4413eca8d7" + +mkdirp@0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.0.tgz#1d73076a6df986cd9344e15e71fcc05a4c9abf12" + dependencies: + minimist "0.0.8" + +mkdirp@0.5.1, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0: + version "0.5.1" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" + dependencies: + minimist "0.0.8" + +mocha-lcov-reporter@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/mocha-lcov-reporter/-/mocha-lcov-reporter-0.0.1.tgz#02670491db57ee6cb1fe7392e813700f6e336a21" + +mocha-lcov-reporter@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/mocha-lcov-reporter/-/mocha-lcov-reporter-0.0.2.tgz#add13ad24158431570cada442c614edc5e4feb95" + +mocha-screencast-reporter@~0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/mocha-screencast-reporter/-/mocha-screencast-reporter-0.1.4.tgz#2f4790c3970725eac4c17fc532eb60fd8d55b792" + +mocha@2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-2.2.1.tgz#04a2f8aeb149fe50177e00a7ef5d08c639e9126b" + dependencies: + commander "2.3.0" + debug "2.0.0" + diff "1.0.8" + escape-string-regexp "1.0.2" + glob "3.2.3" + growl "1.8.1" + jade "0.26.3" + mkdirp "0.5.0" + supports-color "~1.2.0" + +mocha@^2.2.5: + version "2.5.3" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-2.5.3.tgz#161be5bdeb496771eb9b35745050b622b5aefc58" + dependencies: + commander "2.3.0" + debug "2.2.0" + diff "1.4.0" + escape-string-regexp "1.0.2" + glob "3.2.11" + growl "1.9.2" + jade "0.26.3" + mkdirp "0.5.1" + supports-color "1.2.0" + to-iso-string "0.0.2" + +moment@^2.10.3, moment@^2.13.0, moment@^2.7.0: + version "2.18.1" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f" + +ms@0.6.2: + version "0.6.2" + resolved "https://registry.yarnpkg.com/ms/-/ms-0.6.2.tgz#d89c2124c6fdc1353d65a8b77bf1aac4b193708c" + +ms@0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + +multimatch@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/multimatch/-/multimatch-2.1.0.tgz#9c7906a22fb4c02919e2f5f75161b4cdbd4b2a2b" + dependencies: + array-differ "^1.0.0" + array-union "^1.0.1" + arrify "^1.0.0" + minimatch "^3.0.0" + +multiparty@2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/multiparty/-/multiparty-2.2.0.tgz#a567c2af000ad22dc8f2a653d91978ae1f5316f4" + dependencies: + readable-stream "~1.1.9" + stream-counter "~0.2.0" + +mute-stream@0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.5.tgz#8fbfabb0a98a253d3184331f9e8deb7372fac6c0" + +nan@^2.3.0, nan@^2.6.1: + version "2.6.2" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45" + +natural-compare@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" + +negotiator@0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.3.0.tgz#706d692efeddf574d57ea9fb1ab89a4fa7ee8f60" + +negotiator@0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9" + +next-tick@1: + version "1.0.0" + resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c" + +next-tick@~0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-0.2.2.tgz#75da4a927ee5887e39065880065b7336413b310d" + +nock@~0.28.3: + version "0.28.3" + resolved "https://registry.yarnpkg.com/nock/-/nock-0.28.3.tgz#638292b4de96996b03e1c822f1e14e33e5ee0ebd" + dependencies: + propagate "0.2.x" + +node-libs-browser@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/node-libs-browser/-/node-libs-browser-0.7.0.tgz#3e272c0819e308935e26674408d7af0e1491b83b" + dependencies: + assert "^1.1.1" + browserify-zlib "^0.1.4" + buffer "^4.9.0" + console-browserify "^1.1.0" + constants-browserify "^1.0.0" + crypto-browserify "3.3.0" + domain-browser "^1.1.1" + events "^1.0.0" + https-browserify "0.0.1" + os-browserify "^0.2.0" + path-browserify "0.0.0" + process "^0.11.0" + punycode "^1.2.4" + querystring-es3 "^0.2.0" + readable-stream "^2.0.5" + stream-browserify "^2.0.1" + stream-http "^2.3.1" + string_decoder "^0.10.25" + timers-browserify "^2.0.2" + tty-browserify "0.0.0" + url "^0.11.0" + util "^0.10.3" + vm-browserify "0.0.4" + +node-pre-gyp@^0.6.34, node-pre-gyp@^0.6.36: + version "0.6.36" + resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.36.tgz#db604112cb74e0d477554e9b505b17abddfab786" + dependencies: + mkdirp "^0.5.1" + nopt "^4.0.1" + npmlog "^4.0.2" + rc "^1.1.7" + request "^2.81.0" + rimraf "^2.6.1" + semver "^5.3.0" + tar "^2.2.1" + tar-pack "^3.4.0" + +node-uuid@^1.4.7, node-uuid@~1.4.0, node-uuid@~1.4.3: + version "1.4.8" + resolved "https://registry.yarnpkg.com/node-uuid/-/node-uuid-1.4.8.tgz#b040eb0923968afabf8d32fb1f17f1167fdab907" + +nopt@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.1.tgz#d0d4685afd5415193c8c7505602d0d17cd64474d" + dependencies: + abbrev "1" + osenv "^0.1.4" + +nopt@~1.0.10: + version "1.0.10" + resolved "https://registry.yarnpkg.com/nopt/-/nopt-1.0.10.tgz#6ddd21bd2a31417b92727dd585f8a6f37608ebee" + dependencies: + abbrev "1" + +nopt@~3.0.6: + version "3.0.6" + resolved "https://registry.yarnpkg.com/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9" + dependencies: + abbrev "1" + +normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: + version "2.3.8" + resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.3.8.tgz#d819eda2a9dedbd1ffa563ea4071d936782295bb" + dependencies: + hosted-git-info "^2.1.4" + is-builtin-module "^1.0.0" + semver "2 || 3 || 4 || 5" + validate-npm-package-license "^3.0.1" + +normalize-path@^2.0.0, normalize-path@^2.0.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" + dependencies: + remove-trailing-separator "^1.0.1" + +npmlog@^4.0.2: + version "4.1.0" + resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.0.tgz#dc59bee85f64f00ed424efb2af0783df25d1c0b5" + dependencies: + are-we-there-yet "~1.1.2" + console-control-strings "~1.1.0" + gauge "~2.7.3" + set-blocking "~2.0.0" + +null-loader@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/null-loader/-/null-loader-0.1.1.tgz#17be9abfcd3ff0e1512f6fc4afcb1f5039378fae" + +number-is-nan@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" + +oauth-sign@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.3.0.tgz#cb540f93bb2b22a7d5941691a288d60e8ea9386e" + +oauth-sign@~0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.6.0.tgz#7dbeae44f6ca454e1f168451d630746735813ce3" + +oauth-sign@~0.8.0, oauth-sign@~0.8.1: + version "0.8.2" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" + +object-assign@^4.0.1, object-assign@^4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + +object-keys@^1.0.6: + version "1.0.11" + resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d" + +object-keys@~0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-0.4.0.tgz#28a6aae7428dd2c3a92f3d95f21335dd204e0336" + +object.omit@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa" + dependencies: + for-own "^0.1.4" + is-extendable "^0.1.1" + +on-finished@~2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" + dependencies: + ee-first "1.1.1" + +on-headers@~1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/on-headers/-/on-headers-1.0.1.tgz#928f5d0f470d49342651ea6794b0857c100693f7" + +once@^1.3.0, once@^1.3.3, once@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + dependencies: + wrappy "1" + +onetime@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-1.1.0.tgz#a1f7838f8314c516f05ecefcbc4ccfe04b4ed789" + +open@0.0.5, open@~0.0.4: + version "0.0.5" + resolved "https://registry.yarnpkg.com/open/-/open-0.0.5.tgz#42c3e18ec95466b6bf0dc42f3a2945c3f0cad8fc" + +optimist@~0.6.0, optimist@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686" + dependencies: + minimist "~0.0.1" + wordwrap "~0.0.2" + +optionator@^0.8.2: + version "0.8.2" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" + dependencies: + deep-is "~0.1.3" + fast-levenshtein "~2.0.4" + levn "~0.3.0" + prelude-ls "~1.1.2" + type-check "~0.3.2" + wordwrap "~1.0.0" + +original@>=0.0.5: + version "1.0.0" + resolved "https://registry.yarnpkg.com/original/-/original-1.0.0.tgz#9147f93fa1696d04be61e01bd50baeaca656bd3b" + dependencies: + url-parse "1.0.x" + +os-browserify@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.2.1.tgz#63fc4ccee5d2d7763d26bbf8601078e6c2e0044f" + +os-homedir@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" + +os-tmpdir@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + +osenv@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.4.tgz#42fe6d5953df06c8064be6f176c3d05aaaa34644" + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.0" + +p-limit@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.1.0.tgz#b07ff2d9a5d88bec806035895a2bab66a27988bc" + +p-locate@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43" + dependencies: + p-limit "^1.1.0" + +"package@>= 1.0.0 < 1.2.0": + version "1.0.1" + resolved "https://registry.yarnpkg.com/package/-/package-1.0.1.tgz#d25a1f99e2506dcb27d6704b83dca8a312e4edcc" + +pako@~0.2.0: + version "0.2.9" + resolved "https://registry.yarnpkg.com/pako/-/pako-0.2.9.tgz#f3f7522f4ef782348da8161bad9ecfd51bf83a75" + +parse-glob@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c" + dependencies: + glob-base "^0.3.0" + is-dotfile "^1.0.0" + is-extglob "^1.0.0" + is-glob "^2.0.0" + +parse-json@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" + dependencies: + error-ex "^1.2.0" + +parseurl@~1.3.0, parseurl@~1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.1.tgz#c8ab8c9223ba34888aa64a297b28853bec18da56" + +path-browserify@0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.0.tgz#a0b870729aae214005b7d5032ec2cbbb0fb4451a" + +path-exists@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" + dependencies: + pinkie-promise "^2.0.0" + +path-exists@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" + +path-is-absolute@^1.0.0, path-is-absolute@~1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + +path-is-inside@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" + +path-to-regexp@0.1.7: + version "0.1.7" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" + +path-type@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" + dependencies: + graceful-fs "^4.1.2" + pify "^2.0.0" + pinkie-promise "^2.0.0" + +path-type@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-2.0.0.tgz#f012ccb8415b7096fc2daa1054c3d72389594c73" + dependencies: + pify "^2.0.0" + +pause@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/pause/-/pause-0.0.1.tgz#1d408b3fdb76923b9543d96fb4c9dfd535d9cb5d" + +pbkdf2-compat@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pbkdf2-compat/-/pbkdf2-compat-2.0.1.tgz#b6e0c8fa99494d94e0511575802a59a5c142f288" + +performance-now@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5" + +pify@^2.0.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" + +pinkie-promise@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" + dependencies: + pinkie "^2.0.0" + +pinkie@^2.0.0: + version "2.0.4" + resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" + +pkg-dir@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-1.0.0.tgz#7a4b508a8d5bb2d629d447056ff4e9c9314cf3d4" + dependencies: + find-up "^1.0.0" + +pkg-up@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/pkg-up/-/pkg-up-1.0.0.tgz#3e08fb461525c4421624a33b9f7e6d0af5b05a26" + dependencies: + find-up "^1.0.0" + +pluralize@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-1.2.1.tgz#d1a21483fd22bb41e58a12fa3421823140897c45" + +prelude-ls@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" + +preserve@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" + +pretty-bytes@^1.0.0: + version "1.0.4" + resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-1.0.4.tgz#0a22e8210609ad35542f8c8d5d2159aff0751c84" + dependencies: + get-stdin "^4.0.1" + meow "^3.1.0" + +pretty-bytes@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-4.0.2.tgz#b2bf82e7350d65c6c33aa95aaa5a4f6327f61cd9" + +process-nextick-args@~1.0.6: + version "1.0.7" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" + +process@^0.11.0: + version "0.11.10" + resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" + +progress@^1.1.8: + version "1.1.8" + resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be" + +propagate@0.2.x: + version "0.2.2" + resolved "https://registry.yarnpkg.com/propagate/-/propagate-0.2.2.tgz#17a116d25daf2094426d7d6844d26232c9d6926b" + +properties-parser@^0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/properties-parser/-/properties-parser-0.2.3.tgz#f7591255f707abbff227c7b56b637dbb0373a10f" + +proxy-addr@~1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-1.1.4.tgz#27e545f6960a44a627d9b44467e35c1b6b4ce2f3" + dependencies: + forwarded "~0.1.0" + ipaddr.js "1.3.0" + +prr@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/prr/-/prr-0.0.0.tgz#1a84b85908325501411853d0081ee3fa86e2926a" + +punycode@1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" + +punycode@^1.2.4, punycode@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" + +q@~1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/q/-/q-1.4.1.tgz#55705bcd93c5f3673530c2c2cbc0c2b3addc286e" + +qs@0.6.6: + version "0.6.6" + resolved "https://registry.yarnpkg.com/qs/-/qs-0.6.6.tgz#6e015098ff51968b8a3c819001d5f2c89bc4b107" + +qs@5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-5.2.0.tgz#a9f31142af468cb72b25b30136ba2456834916be" + +qs@6.4.0, qs@~6.4.0: + version "6.4.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233" + +qs@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/qs/-/qs-1.0.2.tgz#50a93e2b5af6691c31bcea5dae78ee6ea1903768" + +qs@~2.3.1: + version "2.3.3" + resolved "https://registry.yarnpkg.com/qs/-/qs-2.3.3.tgz#e9e85adbe75da0bbe4c8e0476a086290f863b404" + +qs@~5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-5.1.0.tgz#4d932e5c7ea411cca76a312d39a606200fd50cd9" + +qs@~5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/qs/-/qs-5.2.1.tgz#801fee030e0b9450d6385adc48a4cc55b44aedfc" + +querystring-es3@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73" + +querystring@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" + +querystringify@0.0.x: + version "0.0.4" + resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-0.0.4.tgz#0cf7f84f9463ff0ae51c4c4b142d95be37724d9c" + +querystringify@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-1.0.0.tgz#6286242112c5b712fa654e526652bf6a13ff05cb" + +ramda@^0.24.1: + version "0.24.1" + resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.24.1.tgz#c3b7755197f35b8dc3502228262c4c91ddb6b857" + +randomatic@^1.1.3: + version "1.1.7" + resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-1.1.7.tgz#c7abe9cc8b87c0baa876b19fde83fd464797e38c" + dependencies: + is-number "^3.0.0" + kind-of "^4.0.0" + +range-parser@0.0.4: + version "0.0.4" + resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-0.0.4.tgz#c0427ffef51c10acba0782a46c9602e744ff620b" + +range-parser@^1.0.3, range-parser@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e" + +raw-body@1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-1.1.2.tgz#c74b3004dea5defd1696171106ac740ec31d62be" + dependencies: + bytes "~0.2.1" + +raw-body@~2.1.5: + version "2.1.7" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.1.7.tgz#adfeace2e4fb3098058014d08c072dcc59758774" + dependencies: + bytes "2.4.0" + iconv-lite "0.4.13" + unpipe "1.0.0" + +rc@^1.1.7: + version "1.2.1" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.1.tgz#2e03e8e42ee450b8cb3dce65be1bf8974e1dfd95" + dependencies: + deep-extend "~0.4.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~2.0.1" + +rcfinder@^0.1.6: + version "0.1.9" + resolved "https://registry.yarnpkg.com/rcfinder/-/rcfinder-0.1.9.tgz#f3e80f387ddf9ae80ae30a4100329642eae81115" + dependencies: + lodash.clonedeep "^4.3.2" + +rcloader@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/rcloader/-/rcloader-0.1.4.tgz#d0c902f0444983a2ee5a6907937c6a79ca704509" + dependencies: + lodash "^3.0.1" + rcfinder "^0.1.6" + +read-pkg-up@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" + dependencies: + find-up "^1.0.0" + read-pkg "^1.0.0" + +read-pkg-up@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-2.0.0.tgz#6b72a8048984e0c41e79510fd5e9fa99b3b549be" + dependencies: + find-up "^2.0.0" + read-pkg "^2.0.0" + +read-pkg@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" + dependencies: + load-json-file "^1.0.0" + normalize-package-data "^2.3.2" + path-type "^1.0.0" + +read-pkg@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-2.0.0.tgz#8ef1c0623c6a6db0dc6713c4bfac46332b2368f8" + dependencies: + load-json-file "^2.0.0" + normalize-package-data "^2.3.2" + path-type "^2.0.0" + +"readable-stream@>=1.0.33-1 <1.1.0-0", readable-stream@~1.0.17, readable-stream@~1.0.2, readable-stream@~1.0.26, readable-stream@~1.0.33: + version "1.0.34" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.2.2, readable-stream@^2.2.6: + version "2.2.11" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.11.tgz#0796b31f8d7688007ff0b93a8088d34aa17c0f72" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "~1.0.0" + process-nextick-args "~1.0.6" + safe-buffer "~5.0.1" + string_decoder "~1.0.0" + util-deprecate "~1.0.1" + +readable-stream@~1.1.8, readable-stream@~1.1.9: + version "1.1.14" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readable-stream@~2.0.5: + version "2.0.6" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.0.6.tgz#8f90341e68a53ccc928788dacfcd11b36eb9b78e" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "~1.0.0" + process-nextick-args "~1.0.6" + string_decoder "~0.10.x" + util-deprecate "~1.0.1" + +readdirp@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.1.0.tgz#4ed0ad060df3073300c48440373f72d1cc642d78" + dependencies: + graceful-fs "^4.1.2" + minimatch "^3.0.2" + readable-stream "^2.0.2" + set-immediate-shim "^1.0.1" + +readline2@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/readline2/-/readline2-1.0.1.tgz#41059608ffc154757b715d9989d199ffbf372e35" + dependencies: + code-point-at "^1.0.0" + is-fullwidth-code-point "^1.0.0" + mute-stream "0.0.5" + +rechoir@^0.6.2: + version "0.6.2" + resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" + dependencies: + resolve "^1.1.6" + +redent@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde" + dependencies: + indent-string "^2.1.0" + strip-indent "^1.0.1" + +regenerator-runtime@^0.10.0: + version "0.10.5" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658" + +regex-cache@^0.4.2: + version "0.4.3" + resolved "https://registry.yarnpkg.com/regex-cache/-/regex-cache-0.4.3.tgz#9b1a6c35d4d0dfcef5711ae651e8e9d3d7114145" + dependencies: + is-equal-shallow "^0.1.3" + is-primitive "^2.0.0" + +remove-trailing-separator@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.0.2.tgz#69b062d978727ad14dc6b56ba4ab772fd8d70511" + +repeat-element@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a" + +repeat-string@^1.5.2: + version "1.6.1" + resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" + +repeating@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" + dependencies: + is-finite "^1.0.0" + +request@2.40.0: + version "2.40.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.40.0.tgz#4dd670f696f1e6e842e66b4b5e839301ab9beb67" + dependencies: + forever-agent "~0.5.0" + json-stringify-safe "~5.0.0" + mime-types "~1.0.1" + node-uuid "~1.4.0" + qs "~1.0.0" + optionalDependencies: + aws-sign2 "~0.5.0" + form-data "~0.1.0" + hawk "1.1.1" + http-signature "~0.10.0" + oauth-sign "~0.3.0" + stringstream "~0.0.4" + tough-cookie ">=0.12.0" + tunnel-agent "~0.4.0" + +request@2.53.0: + version "2.53.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.53.0.tgz#180a3ae92b7b639802e4f9545dd8fcdeb71d760c" + dependencies: + aws-sign2 "~0.5.0" + bl "~0.9.0" + caseless "~0.9.0" + combined-stream "~0.0.5" + forever-agent "~0.5.0" + form-data "~0.2.0" + hawk "~2.3.0" + http-signature "~0.10.0" + isstream "~0.1.1" + json-stringify-safe "~5.0.0" + mime-types "~2.0.1" + node-uuid "~1.4.0" + oauth-sign "~0.6.0" + qs "~2.3.1" + stringstream "~0.0.4" + tough-cookie ">=0.12.0" + tunnel-agent "~0.4.0" + +request@^2.67.0, request@^2.74.x, request@^2.81.0: + version "2.81.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0" + dependencies: + aws-sign2 "~0.6.0" + aws4 "^1.2.1" + caseless "~0.12.0" + combined-stream "~1.0.5" + extend "~3.0.0" + forever-agent "~0.6.1" + form-data "~2.1.1" + har-validator "~4.2.1" + hawk "~3.1.3" + http-signature "~1.1.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.7" + oauth-sign "~0.8.1" + performance-now "^0.2.0" + qs "~6.4.0" + safe-buffer "^5.0.1" + stringstream "~0.0.4" + tough-cookie "~2.3.0" + tunnel-agent "^0.6.0" + uuid "^3.0.0" + +request@~2.65.0: + version "2.65.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.65.0.tgz#cc1a3bc72b96254734fc34296da322f9486ddeba" + dependencies: + aws-sign2 "~0.6.0" + bl "~1.0.0" + caseless "~0.11.0" + combined-stream "~1.0.5" + extend "~3.0.0" + forever-agent "~0.6.1" + form-data "~1.0.0-rc3" + har-validator "~2.0.2" + hawk "~3.1.0" + http-signature "~0.11.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.7" + node-uuid "~1.4.3" + oauth-sign "~0.8.0" + qs "~5.2.0" + stringstream "~0.0.4" + tough-cookie "~2.2.0" + tunnel-agent "~0.4.1" + +requestretry@~1.9.0: + version "1.9.1" + resolved "https://registry.yarnpkg.com/requestretry/-/requestretry-1.9.1.tgz#0a2a004eaf211969c4cc2cfebf3fe9e57b92c74e" + dependencies: + extend "^3.0.0" + fg-lodash "0.0.2" + request "^2.74.x" + when "~3.7.5" + +require-uncached@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/require-uncached/-/require-uncached-1.0.3.tgz#4e0d56d6c9662fd31e43011c4b95aa49955421d3" + dependencies: + caller-path "^0.1.0" + resolve-from "^1.0.0" + +requirefresh@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/requirefresh/-/requirefresh-2.1.0.tgz#742dccc20f3a96918d66c6f1597dc8ffebc4f6f5" + dependencies: + editions "^1.1.1" + +requires-port@1.0.x, requires-port@1.x.x: + version "1.0.0" + resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" + +resolve-from@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226" + +resolve-from@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-2.0.0.tgz#9480ab20e94ffa1d9e80a804c7ea147611966b57" + +resolve-pkg@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/resolve-pkg/-/resolve-pkg-0.1.0.tgz#02cc993410e2936962bd97166a1b077da9725531" + dependencies: + resolve-from "^2.0.0" + +resolve@^1.1.6, resolve@~1.1.0: + version "1.1.7" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" + +restore-cursor@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-1.0.1.tgz#34661f46886327fed2991479152252df92daa541" + dependencies: + exit-hook "^1.0.0" + onetime "^1.0.0" + +right-align@^0.1.1: + version "0.1.3" + resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef" + dependencies: + align-text "^0.1.1" + +rimraf@2, rimraf@^2.2.8, rimraf@^2.5.1, rimraf@^2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d" + dependencies: + glob "^7.0.5" + +rimraf@~2.2.6, rimraf@~2.2.8: + version "2.2.8" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.2.8.tgz#e439be2aaee327321952730f99a8929e4fc50582" + +ripemd160@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-0.2.0.tgz#2bf198bde167cacfa51c0a928e84b68bbe171fce" + +run-async@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/run-async/-/run-async-0.1.0.tgz#c8ad4a5e110661e402a7d21b530e009f25f8e389" + dependencies: + once "^1.3.0" + +rx-lite@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-3.1.2.tgz#19ce502ca572665f3b647b10939f97fd1615f102" + +safe-buffer@^5.0.1, safe-buffer@~5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.0.1.tgz#d263ca54696cd8a306b5ca6551e92de57918fbe7" + +safefs@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/safefs/-/safefs-4.1.0.tgz#f82aeb4bdd7ae51f653eb20f6728b3058c8d6445" + dependencies: + editions "^1.1.1" + graceful-fs "^4.1.4" + +samsam@1.1.2, samsam@~1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.1.2.tgz#bec11fdc83a9fda063401210e40176c3024d1567" + +sauce-tunnel@~2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/sauce-tunnel/-/sauce-tunnel-2.4.0.tgz#fb436f203deb7a8c53ed583c2569870de5b32b43" + dependencies: + chalk "^1.1.1" + request "^2.67.0" + split "^1.0.0" + +saucelabs@~1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/saucelabs/-/saucelabs-1.0.1.tgz#b50a100d9c5a4140748b35335a6e5d70017dadf9" + dependencies: + https-proxy-agent "^1.0.0" + +sax@0.5.x: + version "0.5.8" + resolved "https://registry.yarnpkg.com/sax/-/sax-0.5.8.tgz#d472db228eb331c2506b0e8c15524adb939d12c1" + +"semver@2 || 3 || 4 || 5", semver@^5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" + +semver@^4.3.6, semver@~4.3.6: + version "4.3.6" + resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.6.tgz#300bc6e0e86374f7ba61068b5b1ecd57fc6532da" + +semver@~5.0.1: + version "5.0.3" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.0.3.tgz#77466de589cd5d3c95f138aa78bc569a3cb5d27a" + +send@0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/send/-/send-0.1.4.tgz#be70d8d1be01de61821af13780b50345a4f71abd" + dependencies: + debug "*" + fresh "0.2.0" + mime "~1.2.9" + range-parser "0.0.4" + +send@0.15.3: + version "0.15.3" + resolved "https://registry.yarnpkg.com/send/-/send-0.15.3.tgz#5013f9f99023df50d1bd9892c19e3defd1d53309" + dependencies: + debug "2.6.7" + depd "~1.1.0" + destroy "~1.0.4" + encodeurl "~1.0.1" + escape-html "~1.0.3" + etag "~1.8.0" + fresh "0.5.0" + http-errors "~1.6.1" + mime "1.3.4" + ms "2.0.0" + on-finished "~2.3.0" + range-parser "~1.2.0" + statuses "~1.3.1" + +serve-index@^1.7.2: + version "1.9.0" + resolved "https://registry.yarnpkg.com/serve-index/-/serve-index-1.9.0.tgz#d2b280fc560d616ee81b48bf0fa82abed2485ce7" + dependencies: + accepts "~1.3.3" + batch "0.6.1" + debug "2.6.8" + escape-html "~1.0.3" + http-errors "~1.6.1" + mime-types "~2.1.15" + parseurl "~1.3.1" + +serve-static@1.12.3: + version "1.12.3" + resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.12.3.tgz#9f4ba19e2f3030c547f8af99107838ec38d5b1e2" + dependencies: + encodeurl "~1.0.1" + escape-html "~1.0.3" + parseurl "~1.3.1" + send "0.15.3" + +set-blocking@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + +set-immediate-shim@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz#4b2b1b27eb808a9f8dcc481a58e5e56f599f3f61" + +setimmediate@^1.0.4: + version "1.0.5" + resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" + +setprototypeof@1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.0.3.tgz#66567e37043eeb4f04d91bd658c0cbefb55b8e04" + +sha.js@2.2.6: + version "2.2.6" + resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.2.6.tgz#17ddeddc5f722fb66501658895461977867315ba" + +shelljs@^0.7.5: + version "0.7.8" + resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.8.tgz#decbcf874b0d1e5fb72e14b164a9683048e9acb3" + dependencies: + glob "^7.0.0" + interpret "^1.0.0" + rechoir "^0.6.2" + +sigmund@~1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590" + +signal-exit@^3.0.0: + version "3.0.2" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" + +sinon@^1.17.4: + version "1.17.7" + resolved "https://registry.yarnpkg.com/sinon/-/sinon-1.17.7.tgz#4542a4f49ba0c45c05eb2e9dd9d203e2b8efe0bf" + dependencies: + formatio "1.1.1" + lolex "1.3.2" + samsam "1.1.2" + util ">=0.10.3 <1" + +slice-ansi@0.0.4: + version "0.0.4" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-0.0.4.tgz#edbf8903f66f7ce2f8eafd6ceed65e264c831b35" + +sntp@0.2.x: + version "0.2.4" + resolved "https://registry.yarnpkg.com/sntp/-/sntp-0.2.4.tgz#fb885f18b0f3aad189f824862536bceeec750900" + dependencies: + hoek "0.9.x" + +sntp@1.x.x: + version "1.0.9" + resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198" + dependencies: + hoek "2.x.x" + +sockjs-client@^1.0.3: + version "1.1.4" + resolved "https://registry.yarnpkg.com/sockjs-client/-/sockjs-client-1.1.4.tgz#5babe386b775e4cf14e7520911452654016c8b12" + dependencies: + debug "^2.6.6" + eventsource "0.1.6" + faye-websocket "~0.11.0" + inherits "^2.0.1" + json3 "^3.3.2" + url-parse "^1.1.8" + +sockjs@^0.3.15: + version "0.3.18" + resolved "https://registry.yarnpkg.com/sockjs/-/sockjs-0.3.18.tgz#d9b289316ca7df77595ef299e075f0f937eb4207" + dependencies: + faye-websocket "^0.10.0" + uuid "^2.0.2" + +source-list-map@~0.1.7: + version "0.1.8" + resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-0.1.8.tgz#c550b2ab5427f6b3f21f5afead88c4f5587b2106" + +source-map@^0.5.3, source-map@~0.5.1: + version "0.5.6" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" + +source-map@~0.4.1: + version "0.4.4" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b" + dependencies: + amdefine ">=0.0.4" + +spdx-correct@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-1.0.2.tgz#4b3073d933ff51f3912f03ac5519498a4150db40" + dependencies: + spdx-license-ids "^1.0.2" + +spdx-expression-parse@~1.0.0: + version "1.0.4" + resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz#9bdf2f20e1f40ed447fbe273266191fced51626c" + +spdx-license-ids@^1.0.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz#c9df7a3424594ade6bd11900d596696dc06bac57" + +split@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/split/-/split-1.0.0.tgz#c4395ce683abcd254bc28fe1dabb6e5c27dcffae" + dependencies: + through "2" + +split@~0.3.2: + version "0.3.3" + resolved "https://registry.yarnpkg.com/split/-/split-0.3.3.tgz#cd0eea5e63a211dfff7eb0f091c4133e2d0dd28f" + dependencies: + through "2" + +sprintf-js@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + +sshpk@^1.7.0: + version "1.13.1" + resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.13.1.tgz#512df6da6287144316dc4c18fe1cf1d940739be3" + dependencies: + asn1 "~0.2.3" + assert-plus "^1.0.0" + dashdash "^1.12.0" + getpass "^0.1.1" + optionalDependencies: + bcrypt-pbkdf "^1.0.0" + ecc-jsbn "~0.1.1" + jsbn "~0.1.0" + tweetnacl "~0.14.0" + +statuses@1, "statuses@>= 1.3.1 < 2", statuses@~1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e" + +stream-browserify@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/stream-browserify/-/stream-browserify-2.0.1.tgz#66266ee5f9bdb9940a4e4514cafb43bb71e5c9db" + dependencies: + inherits "~2.0.1" + readable-stream "^2.0.2" + +stream-buffers@^2.1.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/stream-buffers/-/stream-buffers-2.2.0.tgz#91d5f5130d1cef96dcfa7f726945188741d09ee4" + +stream-cache@~0.0.1: + version "0.0.2" + resolved "https://registry.yarnpkg.com/stream-cache/-/stream-cache-0.0.2.tgz#1ac5ad6832428ca55667dbdee395dad4e6db118f" + +stream-counter@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/stream-counter/-/stream-counter-0.1.0.tgz#a035e429361fb57f361606e17fcd8a8b9677327b" + dependencies: + readable-stream "~1.0.2" + +stream-counter@~0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/stream-counter/-/stream-counter-0.2.0.tgz#ded266556319c8b0e222812b9cf3b26fa7d947de" + dependencies: + readable-stream "~1.1.8" + +stream-http@^2.3.1: + version "2.7.2" + resolved "https://registry.yarnpkg.com/stream-http/-/stream-http-2.7.2.tgz#40a050ec8dc3b53b33d9909415c02c0bf1abfbad" + dependencies: + builtin-status-codes "^3.0.0" + inherits "^2.0.1" + readable-stream "^2.2.6" + to-arraybuffer "^1.0.0" + xtend "^4.0.0" + +string-width@^1.0.1, string-width@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" + dependencies: + code-point-at "^1.0.0" + is-fullwidth-code-point "^1.0.0" + strip-ansi "^3.0.0" + +string-width@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.0.0.tgz#635c5436cc72a6e0c387ceca278d4e2eec52687e" + dependencies: + is-fullwidth-code-point "^2.0.0" + strip-ansi "^3.0.0" + +string_decoder@^0.10.25, string_decoder@~0.10.x: + version "0.10.31" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" + +string_decoder@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.2.tgz#b29e1f4e1125fa97a10382b8a533737b7491e179" + dependencies: + safe-buffer "~5.0.1" + +stringstream@~0.0.4: + version "0.0.5" + resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878" + +strip-ansi@^3.0.0, strip-ansi@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" + dependencies: + ansi-regex "^2.0.0" + +strip-bom@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" + dependencies: + is-utf8 "^0.2.0" + +strip-bom@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" + +strip-indent@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-1.0.1.tgz#0c7962a6adefa7bbd4ac366460a638552ae1a0a2" + dependencies: + get-stdin "^4.0.1" + +strip-json-comments@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + +supports-color@1.2.0, supports-color@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-1.2.0.tgz#ff1ed1e61169d06b3cf2d588e188b18d8847e17e" + +supports-color@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" + +supports-color@^3.1.0, supports-color@^3.1.1: + version "3.2.3" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6" + dependencies: + has-flag "^1.0.0" + +table@^3.7.8: + version "3.8.3" + resolved "https://registry.yarnpkg.com/table/-/table-3.8.3.tgz#2bbc542f0fda9861a755d3947fefd8b3f513855f" + dependencies: + ajv "^4.7.0" + ajv-keywords "^1.0.0" + chalk "^1.1.1" + lodash "^4.0.0" + slice-ansi "0.0.4" + string-width "^2.0.0" + +tapable@^0.1.8, tapable@~0.1.8: + version "0.1.10" + resolved "https://registry.yarnpkg.com/tapable/-/tapable-0.1.10.tgz#29c35707c2b70e50d07482b5d202e8ed446dafd4" + +tar-pack@^3.4.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/tar-pack/-/tar-pack-3.4.0.tgz#23be2d7f671a8339376cbdb0b8fe3fdebf317984" + dependencies: + debug "^2.2.0" + fstream "^1.0.10" + fstream-ignore "^1.0.5" + once "^1.3.3" + readable-stream "^2.1.4" + rimraf "^2.5.1" + tar "^2.2.1" + uid-number "^0.0.6" + +tar-stream@^1.5.0: + version "1.5.4" + resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-1.5.4.tgz#36549cf04ed1aee9b2a30c0143252238daf94016" + dependencies: + bl "^1.0.0" + end-of-stream "^1.0.0" + readable-stream "^2.0.0" + xtend "^4.0.0" + +tar@^2.2.1, "tar@~2.2.1 ": + version "2.2.1" + resolved "https://registry.yarnpkg.com/tar/-/tar-2.2.1.tgz#8e4d2a256c0e2185c6b18ad694aec968b83cb1d1" + dependencies: + block-stream "*" + fstream "^1.0.2" + inherits "2" + +temp@^0.8.0: + version "0.8.3" + resolved "https://registry.yarnpkg.com/temp/-/temp-0.8.3.tgz#e0c6bc4d26b903124410e4fed81103014dfc1f59" + dependencies: + os-tmpdir "^1.0.0" + rimraf "~2.2.6" + +temporary@0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/temporary/-/temporary-0.0.5.tgz#e2916b72176517a6c8fb67d3fa78a568e9b27865" + dependencies: + package ">= 1.0.0 < 1.2.0" + +terminus@~1.0.10: + version "1.0.12" + resolved "https://registry.yarnpkg.com/terminus/-/terminus-1.0.12.tgz#0a93ad36d95c06259100db60615252862ac17773" + dependencies: + readable-stream "~1.0.33" + xtend "~4.0.0" + +text-table@~0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" + +through2-map@~1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/through2-map/-/through2-map-1.4.0.tgz#7cb13e7c9ef00c7a93c742567f9d2e51168ff7f5" + dependencies: + terminus "~1.0.10" + through2 "~0.5.1" + xtend "^3.0.0" + +through2@~0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/through2/-/through2-0.5.1.tgz#dfdd012eb9c700e2323fd334f38ac622ab372da7" + dependencies: + readable-stream "~1.0.17" + xtend "~3.0.0" + +through2@~0.6.3: + version "0.6.5" + resolved "https://registry.yarnpkg.com/through2/-/through2-0.6.5.tgz#41ab9c67b29d57209071410e1d7a7a968cd3ad48" + dependencies: + readable-stream ">=1.0.33-1 <1.1.0-0" + xtend ">=4.0.0 <4.1.0-0" + +through@2, through@^2.3.6: + version "2.3.8" + resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" + +timers-browserify@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/timers-browserify/-/timers-browserify-2.0.2.tgz#ab4883cf597dcd50af211349a00fbca56ac86b86" + dependencies: + setimmediate "^1.0.4" + +timers-ext@0.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/timers-ext/-/timers-ext-0.1.2.tgz#61cc47a76c1abd3195f14527f978d58ae94c5204" + dependencies: + es5-ext "~0.10.14" + next-tick "1" + +tiny-lr@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/tiny-lr/-/tiny-lr-0.2.1.tgz#b3fdba802e5d56a33c2f6f10794b32e477ac729d" + dependencies: + body-parser "~1.14.0" + debug "~2.2.0" + faye-websocket "~0.10.0" + livereload-js "^2.2.0" + parseurl "~1.3.0" + qs "~5.1.0" + +to-arraybuffer@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43" + +to-fast-properties@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" + +to-iso-string@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/to-iso-string/-/to-iso-string-0.0.2.tgz#4dc19e664dfccbe25bd8db508b00c6da158255d1" + +tough-cookie@>=0.12.0, tough-cookie@~2.3.0: + version "2.3.2" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.2.tgz#f081f76e4c85720e6c37a5faced737150d84072a" + dependencies: + punycode "^1.4.1" + +tough-cookie@~2.2.0: + version "2.2.2" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.2.2.tgz#c83a1830f4e5ef0b93ef2a3488e724f8de016ac7" + +trim-newlines@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" + +tryit@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/tryit/-/tryit-1.0.3.tgz#393be730a9446fd1ead6da59a014308f36c289cb" + +tty-browserify@0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6" + +tunnel-agent@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" + dependencies: + safe-buffer "^5.0.1" + +tunnel-agent@~0.4.0, tunnel-agent@~0.4.1: + version "0.4.3" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb" + +tweetnacl@^0.14.3, tweetnacl@~0.14.0: + version "0.14.5" + resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" + +type-check@~0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" + dependencies: + prelude-ls "~1.1.2" + +type-is@~1.6.10, type-is@~1.6.15: + version "1.6.15" + resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.15.tgz#cab10fb4909e441c82842eafe1ad646c81804410" + dependencies: + media-typer "0.3.0" + mime-types "~2.1.15" + +typechecker@^4.3.0: + version "4.4.1" + resolved "https://registry.yarnpkg.com/typechecker/-/typechecker-4.4.1.tgz#f97b95f51b038417212d677d45a373ee7bced7e6" + dependencies: + editions "^1.3.3" + +typedarray@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" + +uglify-js@~2.6.2: + version "2.6.4" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.6.4.tgz#65ea2fb3059c9394692f15fed87c2b36c16b9adf" + dependencies: + async "~0.2.6" + source-map "~0.5.1" + uglify-to-browserify "~1.0.0" + yargs "~3.10.0" + +uglify-js@~2.7.3: + version "2.7.5" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.7.5.tgz#4612c0c7baaee2ba7c487de4904ae122079f2ca8" + dependencies: + async "~0.2.6" + source-map "~0.5.1" + uglify-to-browserify "~1.0.0" + yargs "~3.10.0" + +uglify-to-browserify@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" + +uid-number@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" + +uid2@0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/uid2/-/uid2-0.0.3.tgz#483126e11774df2f71b8b639dcd799c376162b82" + +underscore.deferred@~0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/underscore.deferred/-/underscore.deferred-0.1.5.tgz#47ead60c988bf0cf3220bf8843f362e0e824e689" + +underscore.string@~2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/underscore.string/-/underscore.string-2.2.1.tgz#d7c0fa2af5d5a1a67f4253daee98132e733f0f19" + +underscore.string@~2.3.3: + version "2.3.3" + resolved "https://registry.yarnpkg.com/underscore.string/-/underscore.string-2.3.3.tgz#71c08bf6b428b1133f37e78fa3a21c82f7329b0d" + +underscore.string@~2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/underscore.string/-/underscore.string-2.4.0.tgz#8cdd8fbac4e2d2ea1e7e2e8097c42f442280f85b" + +underscore.string@~3.2.3: + version "3.2.3" + resolved "https://registry.yarnpkg.com/underscore.string/-/underscore.string-3.2.3.tgz#806992633665d5e5fcb4db1fb3a862eb68e9e6da" + +underscore@~1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.7.0.tgz#6bbaf0877500d36be34ecaa584e0db9fef035209" + +unpipe@1.0.0, unpipe@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" + +uri-path@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/uri-path/-/uri-path-1.0.0.tgz#9747f018358933c31de0fccfd82d138e67262e32" + +url-parse@1.0.x: + version "1.0.5" + resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.0.5.tgz#0854860422afdcfefeb6c965c662d4800169927b" + dependencies: + querystringify "0.0.x" + requires-port "1.0.x" + +url-parse@^1.1.8: + version "1.1.9" + resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.1.9.tgz#c67f1d775d51f0a18911dd7b3ffad27bb9e5bd19" + dependencies: + querystringify "~1.0.0" + requires-port "1.0.x" + +url@^0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/url/-/url-0.11.0.tgz#3838e97cfc60521eb73c525a8e55bfdd9e2e28f1" + dependencies: + punycode "1.3.2" + querystring "0.2.0" + +user-home@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/user-home/-/user-home-2.0.0.tgz#9c70bfd8169bc1dcbf48604e0f04b8b49cde9e9f" + dependencies: + os-homedir "^1.0.0" + +util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + +util@0.10.3, "util@>=0.10.3 <1", util@^0.10.3: + version "0.10.3" + resolved "https://registry.yarnpkg.com/util/-/util-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9" + dependencies: + inherits "2.0.1" + +utils-merge@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.0.tgz#0294fb922bb9375153541c4f7096231f287c8af8" + +uuid@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.3.tgz#67e2e863797215530dff318e5bf9dcebfd47b21a" + +uuid@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" + +validate-npm-package-license@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc" + dependencies: + spdx-correct "~1.0.0" + spdx-expression-parse "~1.0.0" + +vary@~1.1.0, vary@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.1.tgz#67535ebb694c1d52257457984665323f587e8d37" + +verror@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/verror/-/verror-1.3.6.tgz#cff5df12946d297d2baaefaa2689e25be01c005c" + dependencies: + extsprintf "1.0.2" + +vm-browserify@0.0.4: + version "0.0.4" + resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-0.0.4.tgz#5d7ea45bbef9e4a6ff65f95438e0a87c357d5a73" + dependencies: + indexof "0.0.1" + +walkdir@^0.0.11: + version "0.0.11" + resolved "https://registry.yarnpkg.com/walkdir/-/walkdir-0.0.11.tgz#a16d025eb931bd03b52f308caed0f40fcebe9532" + +watchpack@^0.2.1: + version "0.2.9" + resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-0.2.9.tgz#62eaa4ab5e5ba35fdfc018275626e3c0f5e3fb0b" + dependencies: + async "^0.9.0" + chokidar "^1.0.0" + graceful-fs "^4.1.2" + +webpack-core@~0.6.9: + version "0.6.9" + resolved "https://registry.yarnpkg.com/webpack-core/-/webpack-core-0.6.9.tgz#fc571588c8558da77be9efb6debdc5a3b172bdc2" + dependencies: + source-list-map "~0.1.7" + source-map "~0.4.1" + +webpack-dev-middleware@^1.10.2: + version "1.10.2" + resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-1.10.2.tgz#2e252ce1dfb020dbda1ccb37df26f30ab014dbd1" + dependencies: + memory-fs "~0.4.1" + mime "^1.3.4" + path-is-absolute "^1.0.0" + range-parser "^1.0.3" + +webpack-dev-server@^1.14.1: + version "1.16.5" + resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-1.16.5.tgz#0cbd5f2d2ac8d4e593aacd5c9702e7bbd5e59892" + dependencies: + compression "^1.5.2" + connect-history-api-fallback "^1.3.0" + express "^4.13.3" + http-proxy-middleware "~0.17.1" + open "0.0.5" + optimist "~0.6.1" + serve-index "^1.7.2" + sockjs "^0.3.15" + sockjs-client "^1.0.3" + stream-cache "~0.0.1" + strip-ansi "^3.0.0" + supports-color "^3.1.1" + webpack-dev-middleware "^1.10.2" + +webpack@^1.13.0: + version "1.15.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-1.15.0.tgz#4ff31f53db03339e55164a9d468ee0324968fe98" + dependencies: + acorn "^3.0.0" + async "^1.3.0" + clone "^1.0.2" + enhanced-resolve "~0.9.0" + interpret "^0.6.4" + loader-utils "^0.2.11" + memory-fs "~0.3.0" + mkdirp "~0.5.0" + node-libs-browser "^0.7.0" + optimist "~0.6.0" + supports-color "^3.1.0" + tapable "~0.1.8" + uglify-js "~2.7.3" + watchpack "^0.2.1" + webpack-core "~0.6.9" + +websocket-driver@>=0.5.1: + version "0.6.5" + resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.6.5.tgz#5cb2556ceb85f4373c6d8238aa691c8454e13a36" + dependencies: + websocket-extensions ">=0.1.1" + +websocket-extensions@>=0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.1.tgz#76899499c184b6ef754377c2dbb0cd6cb55d29e7" + +when@~3.7.5: + version "3.7.8" + resolved "https://registry.yarnpkg.com/when/-/when-3.7.8.tgz#c7130b6a7ea04693e842cdc9e7a1f2aa39a39f82" + +which@~1.0.5: + version "1.0.9" + resolved "https://registry.yarnpkg.com/which/-/which-1.0.9.tgz#460c1da0f810103d0321a9b633af9e575e64486f" + +which@~1.2.1: + version "1.2.14" + resolved "https://registry.yarnpkg.com/which/-/which-1.2.14.tgz#9a87c4378f03e827cecaf1acdf56c736c01c14e5" + dependencies: + isexe "^2.0.0" + +wide-align@^1.1.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.2.tgz#571e0f1b0604636ebc0dfc21b0339bbe31341710" + dependencies: + string-width "^1.0.2" + +window-size@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d" + +wordwrap@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" + +wordwrap@~0.0.2: + version "0.0.3" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" + +wordwrap@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + +wreck@^5.6.0: + version "5.6.1" + resolved "https://registry.yarnpkg.com/wreck/-/wreck-5.6.1.tgz#aff003040013889d75619b5c71870dd2a8dd069a" + dependencies: + boom "2.x.x" + hoek "2.x.x" + +write@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/write/-/write-0.2.1.tgz#5fc03828e264cea3fe91455476f7a3c566cb0757" + dependencies: + mkdirp "^0.5.1" + +xml2js@0.2.x: + version "0.2.8" + resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.2.8.tgz#9b81690931631ff09d1957549faf54f4f980b3c2" + dependencies: + sax "0.5.x" + +xmlbuilder@~0.4.3: + version "0.4.3" + resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-0.4.3.tgz#c4614ba74e0ad196e609c9272cd9e1ddb28a8a58" + +"xtend@>=4.0.0 <4.1.0-0", xtend@^4.0.0, xtend@~4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" + +xtend@^3.0.0, xtend@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-3.0.0.tgz#5cce7407baf642cba7becda568111c493f59665a" + +xtend@~2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-2.1.2.tgz#6efecc2a4dad8e6962c4901b337ce7ba87b5d28b" + dependencies: + object-keys "~0.4.0" + +yargs@~3.10.0: + version "3.10.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1" + dependencies: + camelcase "^1.0.2" + cliui "^2.1.0" + decamelize "^1.0.0" + window-size "0.1.0" + +zip-stream@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/zip-stream/-/zip-stream-1.1.1.tgz#5216b48bbb4d2651f64d5c6e6f09eb4a7399d557" + dependencies: + archiver-utils "^1.3.0" + compress-commons "^1.1.0" + lodash "^4.8.0" + readable-stream "^2.0.0" From dd6d1d2f2aacd33954373a32ae8ad14c0f8b04d3 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 18:31:32 -0700 Subject: [PATCH 31/61] upgrade to kibana eslint config with exceptions --- .eslintignore | 10 +++++++--- .eslintrc | 49 ++++++++++++------------------------------------- package.json | 20 ++++++++++---------- 3 files changed, 29 insertions(+), 50 deletions(-) diff --git a/.eslintignore b/.eslintignore index 1fa83a552..8b4271e3c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,7 @@ -src/_* -src/bower_es_js -src/lib/apis +/src/_* +/src/bower_es_js +/src/lib/apis +/node_modules +/bower_components +/dist +/html_docs \ No newline at end of file diff --git a/.eslintrc b/.eslintrc index 3904b1015..d1e249f98 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,41 +1,16 @@ --- -extends: "@spalger/personal/es6" - -env: - node: true +extends: "@elastic/eslint-config-kibana" rules: - comma-dangle: off - semi: off - func-names: off - no-var: off - vars-on-top: off - new-cap: off - global-require: off - no-param-reassign: off - padded-blocks: off - brace-style: off - consistent-return: off - default-case: off - dot-notation: off - eqeqeq: warn - max-len: off - no-cond-assign: off - no-console: off - no-else-return: off - no-empty: off - no-restricted-syntax: warn - no-shadow: warn - no-undef: warn - no-underscore-dangle: off - no-unused-expressions: warn + no-var: warn no-unused-vars: warn - no-use-before-define: off - object-shorthand: off - one-var: off - one-var-declaration-per-line: off - prefer-arrow-callback: off - prefer-rest-params: off - prefer-template: off - quote-props: off - yoda: off + semi: warn + one-var: warn + new-cap: warn + space-unary-ops: warn + dot-notation: warn + quotes: warn + no-use-before-define: warn + no-empty: warn + space-before-function-paren: warn + no-restricted-globals: warn \ No newline at end of file diff --git a/package.json b/package.json index 1b12ff1af..30f14d473 100644 --- a/package.json +++ b/package.json @@ -41,16 +41,17 @@ ] }, "devDependencies": { - "@spalger/eslint-config-personal": "^0.4.0", + "@elastic/eslint-config-kibana": "^0.6.1", + "@elastic/eslint-plugin-kibana-custom": "^1.0.3", "async": "~0.8.0", - "babel-eslint": "^6.0.4", + "babel-eslint": "^7.2.3", "blanket": "^1.2.3", "bluebird": "^2.9.14", - "eslint": "^2.9.0", - "eslint-config-airbnb": "^8.0.0", - "eslint-plugin-import": "^1.6.1", - "eslint-plugin-jsx-a11y": "^1.0.4", - "eslint-plugin-react": "^5.0.1", + "eslint": "^3.19.0", + "eslint-plugin-babel": "^4.1.1", + "eslint-plugin-import": "^2.3.0", + "eslint-plugin-mocha": "^4.10.1", + "eslint-plugin-react": "^7.1.0", "expect.js": "^0.3.1", "express": "~3.4.7", "find-root": "~0.1.1", @@ -108,10 +109,9 @@ "scripts": { "test": "grunt test", "generate": "node scripts/generate", - "grunt": "grunt", - "eslint": "eslint src scripts test grunt Gruntfile.js" + "grunt": "grunt" }, "engines": { "node": ">=0.8" } -} \ No newline at end of file +} From 59a810af37141a02a85bfd3cb4d867d40839d79d Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 18:40:19 -0700 Subject: [PATCH 32/61] move to .eslintrc file with extension --- .eslintrc => .eslintrc.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .eslintrc => .eslintrc.yaml (100%) diff --git a/.eslintrc b/.eslintrc.yaml similarity index 100% rename from .eslintrc rename to .eslintrc.yaml From 105c39a4e5e1f16e4634e610cba13c9f3588d1b4 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 18:42:35 -0700 Subject: [PATCH 33/61] bump node version requirement to 6.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 30f14d473..b5d0039c3 100644 --- a/package.json +++ b/package.json @@ -112,6 +112,6 @@ "grunt": "grunt" }, "engines": { - "node": ">=0.8" + "node": ">=6.0" } } From e71ffc809ca1cb5ca0e01184807ef7b70ed8778d Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 18:46:48 -0700 Subject: [PATCH 34/61] transition test/.estlinrc too --- test/{.eslintrc => .eslintrc.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{.eslintrc => .eslintrc.yaml} (100%) diff --git a/test/.eslintrc b/test/.eslintrc.yaml similarity index 100% rename from test/.eslintrc rename to test/.eslintrc.yaml From da8e558817b5dc1cde29997574f978dc3cf21ae6 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 18:47:01 -0700 Subject: [PATCH 35/61] correct path to root eslint config --- test/.eslintrc.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/.eslintrc.yaml b/test/.eslintrc.yaml index 8e7cc14b9..f7c8af50d 100644 --- a/test/.eslintrc.yaml +++ b/test/.eslintrc.yaml @@ -1,4 +1,4 @@ --- -extends: ../.eslintrc +extends: ../.eslintrc.yaml env: mocha: true From 3d75c6ff0ff5150913efdcd6ed5abaec37be7dcb Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 18:48:24 -0700 Subject: [PATCH 36/61] use eslint autofix to start fixing violations --- .eslintrc.yaml | 3 +- grunt/config/esvm.js | 22 +-- grunt/config/mochacov.js | 14 +- grunt/config/run.js | 4 +- grunt/config/s3.js | 2 +- grunt/config/saucelabs-mocha.js | 2 +- grunt/config/webpack.js | 2 +- grunt/tasks.js | 22 +-- grunt/utils.js | 24 +-- scripts/Version.js | 20 +- scripts/_spawn.js | 18 +- scripts/ci.js | 64 +++--- scripts/generate/api_index.js | 14 +- scripts/generate/configuration_docs.js | 10 +- scripts/generate/doc_index.js | 12 +- scripts/generate/index.js | 54 ++--- scripts/generate/js_api.js | 114 +++++------ scripts/generate/templates/index.js | 18 +- scripts/generate/yaml_tests.js | 30 +-- scripts/release/bower.js | 18 +- src/elasticsearch.angular.js | 6 +- src/elasticsearch.jquery.js | 4 +- src/lib/client.js | 8 +- src/lib/client_action.js | 32 +-- src/lib/connection.js | 20 +- src/lib/connection_pool.js | 48 ++--- src/lib/connectors/angular.js | 10 +- src/lib/connectors/browser_index.js | 4 +- src/lib/connectors/http.js | 52 ++--- src/lib/connectors/jquery.js | 8 +- src/lib/connectors/xhr.js | 30 +-- src/lib/errors.js | 40 ++-- src/lib/host.js | 42 ++-- src/lib/log.js | 14 +- src/lib/logger.js | 8 +- src/lib/loggers/console.js | 6 +- src/lib/loggers/file.js | 8 +- src/lib/loggers/stdio.js | 8 +- src/lib/loggers/stream.js | 6 +- src/lib/loggers/tracer.js | 22 +-- src/lib/nodes_to_host.js | 16 +- src/lib/selectors/round_robin.js | 2 +- src/lib/serializers/angular.js | 4 +- src/lib/serializers/json.js | 4 +- src/lib/transport.js | 82 ++++---- src/lib/transport/find_common_protocol.js | 8 +- .../transport/sniff_on_connection_fault.js | 16 +- src/lib/utils.js | 38 ++-- test/fixtures/keepalive.js | 16 +- test/fixtures/keepalive_server.js | 8 +- test/integration/yaml_suite/client_manager.js | 26 +-- test/integration/yaml_suite/run.js | 28 +-- test/integration/yaml_suite/yaml_doc.js | 108 +++++----- test/integration/yaml_suite/yaml_file.js | 10 +- test/mocks/browser_server.js | 24 +-- test/mocks/incomming_message.js | 6 +- test/mocks/request.js | 6 +- test/mocks/server.js | 2 +- test/mocks/writable_stream.js | 18 +- test/unit/browser_builds/angular.js | 28 +-- test/unit/browser_builds/generic.js | 8 +- test/unit/browser_builds/jquery.js | 6 +- test/unit/buffer_flush_tests.js | 22 +-- test/unit/coverage.js | 2 +- test/unit/generic_logger_tests.js | 60 +++--- test/unit/index.js | 2 +- test/unit/specs/abstract_logger.js | 14 +- test/unit/specs/client.js | 30 +-- test/unit/specs/client_action.js | 60 +++--- test/unit/specs/connection_abstract.js | 58 +++--- test/unit/specs/connection_pool.js | 62 +++--- test/unit/specs/console_logger.js | 18 +- test/unit/specs/errors.js | 14 +- test/unit/specs/file_logger.js | 30 +-- test/unit/specs/host.js | 62 +++--- test/unit/specs/http_connector.js | 170 ++++++++-------- test/unit/specs/json_serializer.js | 42 ++-- test/unit/specs/log.js | 48 ++--- test/unit/specs/nodes_to_host_callback.js | 14 +- test/unit/specs/random_selector.js | 12 +- test/unit/specs/round_robin_selector.js | 12 +- test/unit/specs/stdio_logger.js | 36 ++-- test/unit/specs/stream_logger.js | 34 ++-- test/unit/specs/tracer_logger.js | 20 +- test/unit/specs/transport.js | 184 +++++++++--------- test/unit/specs/transport_with_server.js | 66 +++---- test/unit/specs/utils.js | 48 ++--- test/unit/specs/yaml_test_reader.js | 6 +- test/utils/auto_release_stub.js | 8 +- test/utils/expect_sub_object.js | 4 +- test/utils/jenkins-reporter.js | 50 ++--- test/utils/make_j_unit_xml.js | 24 +-- test/utils/server.js | 38 ++-- webpack_config/angular.js | 6 +- webpack_config/browser.js | 6 +- webpack_config/jquery.js | 6 +- webpack_config/lib.js | 10 +- 97 files changed, 1293 insertions(+), 1292 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index d1e249f98..1d2b8ec67 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -13,4 +13,5 @@ rules: no-use-before-define: warn no-empty: warn space-before-function-paren: warn - no-restricted-globals: warn \ No newline at end of file + no-restricted-globals: warn + prefer-const: warn \ No newline at end of file diff --git a/grunt/config/esvm.js b/grunt/config/esvm.js index 1bd4a64ba..130383e69 100644 --- a/grunt/config/esvm.js +++ b/grunt/config/esvm.js @@ -1,14 +1,14 @@ -var get = require('lodash.get'); -var utils = require('../utils'); -var fromRoot = require('path').join.bind(null, __dirname, '..', '..'); +const get = require('lodash.get'); +const utils = require('../utils'); +const fromRoot = require('path').join.bind(null, __dirname, '..', '..'); -var release = process.env.ES_RELEASE; -var ref = process.env.ES_REF; -var port = parseFloat(get(process.env, 'ES_PORT', 9400)); -var host = get(process.env, 'ES_HOST', 'localhost'); +const release = process.env.ES_RELEASE; +const ref = process.env.ES_REF; +const port = parseFloat(get(process.env, 'ES_PORT', 9400)); +const host = get(process.env, 'ES_HOST', 'localhost'); -var Version = require('../../scripts/Version'); -var versionedOpts = [ +const Version = require('../../scripts/Version'); +const versionedOpts = [ { version: '*', directory: fromRoot('esvm'), @@ -90,8 +90,8 @@ utils.branches.forEach(function (branch) { // ci target, based on env variables (function () { - var v; - var opts = { + let v; + const opts = { config: { 'http.port': port } diff --git a/grunt/config/mochacov.js b/grunt/config/mochacov.js index dd896a0a7..052ee45f4 100644 --- a/grunt/config/mochacov.js +++ b/grunt/config/mochacov.js @@ -1,12 +1,12 @@ -var root = require('find-root')(__dirname); -var rel = require('path').resolve.bind(null, root); -var rootReq = function (p) { return require(rel(p)); }; -var _ = rootReq('src/lib/utils'); -var grunt = require('grunt'); +const root = require('find-root')(__dirname); +const rel = require('path').resolve.bind(null, root); +const rootReq = function (p) { return require(rel(p)); }; +const _ = rootReq('src/lib/utils'); +const grunt = require('grunt'); -var JENKINS_REPORTER = rel('test/utils/jenkins-reporter.js'); +const JENKINS_REPORTER = rel('test/utils/jenkins-reporter.js'); -var config = { +const config = { unit: { src: 'test/unit/index.js', options: { diff --git a/grunt/config/run.js b/grunt/config/run.js index 053d522ff..dfd526dbe 100644 --- a/grunt/config/run.js +++ b/grunt/config/run.js @@ -1,6 +1,6 @@ -var utils = require('../utils'); +const utils = require('../utils'); -var config = { +const config = { generate: { exec: 'node ./scripts/generate/index.js', options: { diff --git a/grunt/config/s3.js b/grunt/config/s3.js index 0bca06e86..5fa220f50 100644 --- a/grunt/config/s3.js +++ b/grunt/config/s3.js @@ -1,4 +1,4 @@ -var config = {}; +let config = {}; try { config = require('../../.aws-config.json'); } catch (e) {} diff --git a/grunt/config/saucelabs-mocha.js b/grunt/config/saucelabs-mocha.js index 54b681983..39c6e6e51 100644 --- a/grunt/config/saucelabs-mocha.js +++ b/grunt/config/saucelabs-mocha.js @@ -1,4 +1,4 @@ -var slk = require('../../test/utils/slk'); +const slk = require('../../test/utils/slk'); module.exports = { all: { options: { diff --git a/grunt/config/webpack.js b/grunt/config/webpack.js index 86406ddd8..6de3dec10 100644 --- a/grunt/config/webpack.js +++ b/grunt/config/webpack.js @@ -4,4 +4,4 @@ module.exports = { require('../../webpack_config/angular'), require('../../webpack_config/jquery'), ] -} +}; diff --git a/grunt/tasks.js b/grunt/tasks.js index ddd797f3a..a6d179ab7 100644 --- a/grunt/tasks.js +++ b/grunt/tasks.js @@ -1,8 +1,8 @@ module.exports = function (grunt) { - var Promise = require('bluebird'); - var utils = require('./utils'); - var readFile = Promise.promisify(require('fs').readFile); - var writeFile = Promise.promisify(require('fs').writeFile); + const Promise = require('bluebird'); + const utils = require('./utils'); + const readFile = Promise.promisify(require('fs').readFile); + const writeFile = Promise.promisify(require('fs').writeFile); // Default task runs the build process. @@ -11,12 +11,12 @@ module.exports = function (grunt) { ]); grunt.registerTask('test', function (branch) { - var tasks = [ + const tasks = [ branch ? 'run:generate_' + branch : 'run:generate', 'mochacov:unit' ]; - var branches = branch ? [branch] : utils.branches; + const branches = branch ? [branch] : utils.branches; process.env.ES_PORT = process.env.ES_PORT || 9400; process.env.ES_HOST = process.env.ES_HOST || 'localhost'; @@ -38,10 +38,10 @@ module.exports = function (grunt) { ]); grunt.registerTask('version', function (nextVersion) { - var root = require('path').join.bind(null, __dirname, '..'); - var readmePath = root('README.md'); - var packagePath = root('package.json'); - var browserBuildsPath = root('docs/browser_builds.asciidoc'); + const root = require('path').join.bind(null, __dirname, '..'); + const readmePath = root('README.md'); + const packagePath = root('package.json'); + const browserBuildsPath = root('docs/browser_builds.asciidoc'); Promise.all([ require(packagePath), @@ -49,7 +49,7 @@ module.exports = function (grunt) { readFile(browserBuildsPath, 'utf8') ]) .spread(function (pkg, readme, browserBuilds) { - var current = pkg.version; + const current = pkg.version; pkg.version = nextVersion; browserBuilds = utils.replaceAll(browserBuilds, current, nextVersion); diff --git a/grunt/utils.js b/grunt/utils.js index a880791b6..32b4b88dc 100644 --- a/grunt/utils.js +++ b/grunt/utils.js @@ -1,10 +1,10 @@ -var _ = require('../src/lib/utils'); +const _ = require('../src/lib/utils'); -var root = require('find-root')(__dirname); -var pkg = require(root + '/package.json'); -var stable = pkg.config.supported_es_branches; -var unstable = pkg.config.unstable_es_branches; -var branches = [].concat(stable, unstable); +const root = require('find-root')(__dirname); +const pkg = require(root + '/package.json'); +const stable = pkg.config.supported_es_branches; +const unstable = pkg.config.unstable_es_branches; +const branches = [].concat(stable, unstable); var utils = { branchSuffix: function (branch) { @@ -29,7 +29,7 @@ utils.minorVersion = function (version) { * increment the version based on the release "type" */ utils.increaseVersion = function (version, type) { - var i; + let i; switch (type) { case 'major': i = 0; @@ -47,14 +47,14 @@ utils.increaseVersion = function (version, type) { } // breakout the current version - var next = version.split('.').map(function (n) { + const next = version.split('.').map(function (n) { return parseInt(n, 10); }); // increment the version type next[i] += 1; // clear out all following numbers - for (i ++; i < next.length; i++) next[i] = 0; + for (i++; i < next.length; i++) next[i] = 0; // join back together with '.' return next.join('.'); }; @@ -63,9 +63,9 @@ utils.increaseVersion = function (version, type) { * replace all instances of `replace` with `replacement` without creating a regexp object */ utils.replaceAll = function (str, replace, replacement) { - var out = ''; - var remaining = str; - var i = 0; + let out = ''; + let remaining = str; + let i = 0; while (~(i = remaining.indexOf(replace))) { out += remaining.substring(0, i) + replacement; diff --git a/scripts/Version.js b/scripts/Version.js index b3bde3838..dc3f5a8e2 100644 --- a/scripts/Version.js +++ b/scripts/Version.js @@ -1,16 +1,16 @@ -var _ = require('lodash'); -var pkg = require('../package.json'); -var branches = [...pkg.config.supported_es_branches, ...pkg.config.unstable_es_branches]; -var semver = require('semver'); +const _ = require('lodash'); +const pkg = require('../package.json'); +const branches = [...pkg.config.supported_es_branches, ...pkg.config.unstable_es_branches]; +const semver = require('semver'); function nextMajorVersion() { const largestMajor = branches .map(v => parseFloat(v.split('.')[0])) .filter(n => !isNaN(n)) .sort((a, b) => b - a) - .shift() + .shift(); - return new Version(`${largestMajor + 1}.0.0`) + return new Version(`${largestMajor + 1}.0.0`); } function nextMinorVersion(major) { @@ -42,11 +42,11 @@ Version.fromBranch = function (branch) { if (/^\d+\.\d+$/.test(branch)) return new Version(branch + '.0'); // n.x -> n.(maxVersion + 1).0 - const match = branch.match(/^(\d+)\.x$/i) + const match = branch.match(/^(\d+)\.x$/i); if (match) return nextMinorVersion(match[1]); // master => (maxMajorVersion + 1).0.0 - if (branch === 'master') return nextMajorVersion() + if (branch === 'master') return nextMajorVersion(); throw new Error('unable to convert branch "' + branch + '" to semver'); }; @@ -66,9 +66,9 @@ Version.prototype.mergeOpts = function (versioned, overrides) { const candidates = versioned .filter(o => this.satisfies(o.version)) - .map(o => _.omit(o, 'version')) + .map(o => _.omit(o, 'version')); - return _.merge({}, overrides || {}, ...candidates) + return _.merge({}, overrides || {}, ...candidates); }; module.exports = Version; diff --git a/scripts/_spawn.js b/scripts/_spawn.js index 3efdd7d99..3911fc756 100644 --- a/scripts/_spawn.js +++ b/scripts/_spawn.js @@ -1,11 +1,11 @@ module.exports = _spawn; -var map = require('through2-map'); -var split = require('split'); -var chalk = require('chalk'); -var spawn = require('child_process').spawn; -var path = require('path'); -var root = path.resolve(__dirname, '../'); +const map = require('through2-map'); +const split = require('split'); +const chalk = require('chalk'); +const spawn = require('child_process').spawn; +const path = require('path'); +const root = path.resolve(__dirname, '../'); function indent(line) { line = String(line).trim(); @@ -26,7 +26,7 @@ function _spawn(cmd, args, opts, cb) { opts.verbose = false; } - var conf = { + const conf = { stdio: [ 'ignore', opts.verbose ? 'pipe' : 'ignore', @@ -34,7 +34,7 @@ function _spawn(cmd, args, opts, cb) { ] }; - var subdir; + let subdir; if (opts.cwd) { conf.cwd = opts.cwd; @@ -43,7 +43,7 @@ function _spawn(cmd, args, opts, cb) { console.log(chalk.white.bold((subdir ? subdir + ' ' : '') + '$ ') + cmd + ' ' + args.join(' ')); - var cp = spawn(cmd, args, conf); + const cp = spawn(cmd, args, conf); if (opts.verbose) { consume(cp.stdout); diff --git a/scripts/ci.js b/scripts/ci.js index bc6bda3d3..471f24caf 100644 --- a/scripts/ci.js +++ b/scripts/ci.js @@ -17,25 +17,25 @@ * *******/ -var Promise = require('bluebird'); -var _ = require('lodash'); -var through2 = require('through2'); -var map = require('through2-map'); -var split = require('split'); -var join = require('path').join; -var cp = require('child_process'); -var chalk = require('chalk'); -var format = require('util').format; - -var NL_RE = /(\r?\n)/g; -var ROOT = join(__dirname, '..'); -var GRUNT = join(ROOT, 'node_modules', '.bin', 'grunt'); -var ENV = _.clone(process.env); -var JENKINS = !!ENV.JENKINS_HOME; -var TASKS = []; - -var output; // main output stream -var taskOut; // task output stream +const Promise = require('bluebird'); +const _ = require('lodash'); +const through2 = require('through2'); +const map = require('through2-map'); +const split = require('split'); +const join = require('path').join; +const cp = require('child_process'); +const chalk = require('chalk'); +const format = require('util').format; + +const NL_RE = /(\r?\n)/g; +const ROOT = join(__dirname, '..'); +const GRUNT = join(ROOT, 'node_modules', '.bin', 'grunt'); +const ENV = _.clone(process.env); +const JENKINS = !!ENV.JENKINS_HOME; +const TASKS = []; + +let output; // main output stream +let taskOut; // task output stream task('NODE_UNIT', true, function () { if (!JENKINS) { @@ -46,11 +46,11 @@ task('NODE_UNIT', true, function () { }); task('NODE_INTEGRATION', true, function () { - var branch = ENV.ES_REF; + const branch = ENV.ES_REF; return node('scripts/generate', '--no-api', '--branch', branch) .then(function () { - var target = (JENKINS ? 'jenkins_' : '') + 'integration:' + branch; + const target = (JENKINS ? 'jenkins_' : '') + 'integration:' + branch; return grunt('esvm:ci_env', 'mocha_' + target, 'esvm_shutdown:ci_env'); }); }); @@ -58,9 +58,9 @@ task('NODE_INTEGRATION', true, function () { task('SAUCE_LABS', false, function () { return new Promise(function (resolve, reject) { // build the clients and start the server, once the server is ready call trySaucelabs() - var serverTasks = ['browser_clients:build', 'run:browser_test_server:keepalive']; + const serverTasks = ['browser_clients:build', 'run:browser_test_server:keepalive']; spawn(GRUNT, serverTasks, function (proc) { - var toLines = split(); + const toLines = split(); proc.stdout .pipe(toLines) @@ -83,14 +83,14 @@ task('SAUCE_LABS', false, function () { .catch(_.noop); // attempt to run tests on saucelabs and retry if it fails - var saucelabsAttempts = 0; + let saucelabsAttempts = 0; function trySaucelabs() { saucelabsAttempts++; return new Promise(function (resolve, reject) { log(chalk.green('saucelabs attempt #', saucelabsAttempts)); spawn(GRUNT, ['saucelabs-mocha'], function (cp) { - var failedTests = 0; + let failedTests = 0; cp.stdout .pipe(split()) .pipe(map(function (line) { @@ -141,7 +141,7 @@ execTask('SETUP', function () { } } - var match; + let match; if (match = ENV.ES_V.match(/^(.*)_nightly$/)) { return [match[1], null]; } @@ -206,7 +206,7 @@ execTask('SETUP', function () { * utils ******/ function log() { - var chunk = format.apply(null, arguments); + const chunk = format.apply(null, arguments); (taskOut || output || process.stdout).write(chunk + '\n'); } @@ -218,15 +218,15 @@ function logImportant(text) { function push(m) { return function () { - var args = _.toArray(arguments); - var cb = args.pop(); + const args = _.toArray(arguments); + const cb = args.pop(); this.push(m.apply(this, args)); cb(); }; } function indent() { - var str = through2( + const str = through2( push(function (chunk) { return String(chunk).replace(NL_RE, '$1 '); }), push(function () { return '\n'; }) ); @@ -281,7 +281,7 @@ function execTask(name, task) { function spawn(file, args, block) { return new Promise(function (resolve, reject) { - var proc = cp.spawn(file, args, { + const proc = cp.spawn(file, args, { cwd: ROOT, env: ENV, stdio: [0, 'pipe', 'pipe'] @@ -290,7 +290,7 @@ function spawn(file, args, block) { proc.stdout.pipe(taskOut, { end: false }); proc.stderr.pipe(taskOut, { end: false }); - var stdout = ''; + let stdout = ''; proc.stdout .pipe(through2(function (chunk, enc, cb) { stdout += chunk; diff --git a/scripts/generate/api_index.js b/scripts/generate/api_index.js index ef538c0ac..0c9b69d5d 100644 --- a/scripts/generate/api_index.js +++ b/scripts/generate/api_index.js @@ -1,13 +1,13 @@ module.exports = function (done) { - var _ = require('../../src/lib/utils'); - var utils = require('../../grunt/utils'); + const _ = require('../../src/lib/utils'); + const utils = require('../../grunt/utils'); - var chalk = require('chalk'); - var fromRoot = _.partial(require('path').join, require('find-root')(__dirname)); - var write = require('fs').writeFileSync; + const chalk = require('chalk'); + const fromRoot = _.partial(require('path').join, require('find-root')(__dirname)); + const write = require('fs').writeFileSync; - var nodeApiIndex = fromRoot('src/lib/apis/index.js'); - var browserApiIndex = fromRoot('src/lib/apis/browser_index.js'); + const nodeApiIndex = fromRoot('src/lib/apis/index.js'); + const browserApiIndex = fromRoot('src/lib/apis/browser_index.js'); write(nodeApiIndex, require('./templates').apiIndex({ branches: utils.branches diff --git a/scripts/generate/configuration_docs.js b/scripts/generate/configuration_docs.js index 939e8bdae..1df965925 100644 --- a/scripts/generate/configuration_docs.js +++ b/scripts/generate/configuration_docs.js @@ -1,11 +1,11 @@ module.exports = function (done) { - var _ = require('../../src/lib/utils'); + const _ = require('../../src/lib/utils'); - var chalk = require('chalk'); - var fromRoot = _.partial(require('path').join, require('find-root')(__dirname)); - var write = require('fs').writeFile; + const chalk = require('chalk'); + const fromRoot = _.partial(require('path').join, require('find-root')(__dirname)); + const write = require('fs').writeFile; - var outputPath = fromRoot('docs/configuration.asciidoc'); + const outputPath = fromRoot('docs/configuration.asciidoc'); write(outputPath, require('./templates').configurationDocs(), 'utf8', done); console.log(chalk.white.bold('wrote'), 'configuration docs to', outputPath); }; diff --git a/scripts/generate/doc_index.js b/scripts/generate/doc_index.js index 07cea06f2..37839181c 100644 --- a/scripts/generate/doc_index.js +++ b/scripts/generate/doc_index.js @@ -1,12 +1,12 @@ module.exports = function (done) { - var _ = require('../../src/lib/utils'); - var utils = require('../../grunt/utils'); + const _ = require('../../src/lib/utils'); + const utils = require('../../grunt/utils'); - var chalk = require('chalk'); - var fromRoot = _.partial(require('path').join, require('find-root')(__dirname)); - var write = require('fs').writeFile; + const chalk = require('chalk'); + const fromRoot = _.partial(require('path').join, require('find-root')(__dirname)); + const write = require('fs').writeFile; - var outputPath = fromRoot('docs/index.asciidoc'); + const outputPath = fromRoot('docs/index.asciidoc'); write(outputPath, require('./templates').docsIndex({ apiFiles: utils.stableBranches.map(function (branch) { diff --git a/scripts/generate/index.js b/scripts/generate/index.js index 95f385255..9df5077f6 100644 --- a/scripts/generate/index.js +++ b/scripts/generate/index.js @@ -1,8 +1,8 @@ /* jshint curly: false */ -var async = require('async'); -var fs = require('fs'); -var spawn = require('../_spawn'); -var argv = require('optimist') +const async = require('async'); +const fs = require('fs'); +const spawn = require('../_spawn'); +let argv = require('optimist') .options({ verbose: { alias: 'v', @@ -27,15 +27,15 @@ var argv = require('optimist') } }); -var path = require('path'); -var fromRoot = path.join.bind(path, require('find-root')(__dirname)); -var utils = require(fromRoot('grunt/utils')); -var _ = require(fromRoot('src/lib/utils')); -var esUrl = process.env.ES_REPO +const path = require('path'); +const fromRoot = path.join.bind(path, require('find-root')(__dirname)); +const utils = require(fromRoot('grunt/utils')); +const _ = require(fromRoot('src/lib/utils')); +const esUrl = process.env.ES_REPO ? path.resolve(process.cwd(), process.env.ES_REPO) : 'https://github.com/elastic/elasticsearch.git'; -var branches; +let branches; if (process.env.npm_config_argv) { // when called by NPM @@ -51,7 +51,7 @@ if (argv.branch) { branches = utils.branches; } -var paths = { +const paths = { root: fromRoot('.'), src: fromRoot('src'), esSrc: fromRoot('src/_elasticsearch_'), @@ -70,7 +70,7 @@ var paths = { }; function isDirectory(dir) { - var stat; + let stat; try { stat = fs.statSync(dir); } catch (e) {} return (stat && stat.isDirectory()); } @@ -129,15 +129,15 @@ function initStep() { } function fetchBranchesStep() { - var branchArgs = branches.map(function (b) { return b + ':' + b; }); + const branchArgs = branches.map(function (b) { return b + ':' + b; }); return spawnStep('git', ['fetch', '--no-tags', '--force', 'origin'].concat(branchArgs), paths.esSrc); } function findGeneratedApiFiles() { - var anyApiMethodDocs = /^(configuration|index|api_methods).*\.asciidoc$/; - var anyApiJsFiled = /^.+\.js$/; - var allBranches = _.isEqual(branches, utils.branches); + const anyApiMethodDocs = /^(configuration|index|api_methods).*\.asciidoc$/; + const anyApiJsFiled = /^.+\.js$/; + const allBranches = _.isEqual(branches, utils.branches); if (allBranches) { return [ @@ -147,11 +147,11 @@ function findGeneratedApiFiles() { } return branches.reduce(function (files, branch) { - var b = _.snakeCase(branch); + const b = _.snakeCase(branch); files.push(dirOpts(paths.docs, 'api_methods_' + b + '.asciidoc')); - var isDefault = branch === utils.branches._default; + const isDefault = branch === utils.branches._default; if (isDefault) { files.push(dirOpts(paths.docs, 'api_methods.asciidoc')); } @@ -164,8 +164,8 @@ function findGeneratedApiFiles() { function clearGeneratedFiles() { - var esArchives = /^_elasticsearch_(master|[\dx_]+|\.tar)$/; - var generatedFiles = []; + const esArchives = /^_elasticsearch_(master|[\dx_]+|\.tar)$/; + const generatedFiles = []; if (argv.api) { generatedFiles.push(findGeneratedApiFiles()); @@ -173,7 +173,7 @@ function clearGeneratedFiles() { generatedFiles.push(dirRegex(paths.src, esArchives)); - var rmSteps = _.chain(generatedFiles) + const rmSteps = _.chain(generatedFiles) .flatten() .uniq() .map(function (path) { @@ -191,7 +191,7 @@ function clearGeneratedFiles() { function removePrevArchive(branch) { if (!argv.update) return; - var dir = paths.getArchiveDir(branch); + const dir = paths.getArchiveDir(branch); if (!isDirectory(dir)) return; return spawnStep('rm', ['-rf', dir], paths.root); @@ -199,10 +199,10 @@ function removePrevArchive(branch) { function createArchive(branch) { return function (done) { - var dir = paths.getArchiveDir(branch); - var tarball = paths.getArchiveTarball(branch); - var specPathInRepo = paths.getSpecPathInRepo(branch); - var subDirCount = _.countBy(specPathInRepo, p => p === '/').true || 0; + const dir = paths.getArchiveDir(branch); + const tarball = paths.getArchiveTarball(branch); + const specPathInRepo = paths.getSpecPathInRepo(branch); + const subDirCount = _.countBy(specPathInRepo, p => p === '/').true || 0; if (isDirectory(dir)) { console.log(branch + ' archive already exists'); @@ -227,7 +227,7 @@ function generateStep(branch) { }; } -var steps = [ +const steps = [ initStep(), clearGeneratedFiles(), fetchBranchesStep() diff --git a/scripts/generate/js_api.js b/scripts/generate/js_api.js index a1b971149..d14b33397 100644 --- a/scripts/generate/js_api.js +++ b/scripts/generate/js_api.js @@ -3,26 +3,26 @@ module.exports = function (branch, done) { * Read the API actions form the rest-api-spec repo. * @type {[type]} */ - var _ = require('../../src/lib/utils'); - var utils = require('../../grunt/utils'); - var fs = require('fs'); - var async = require('async'); - var chalk = require('chalk'); - var path = require('path'); - var fromRoot = path.join.bind(path, require('find-root')(__dirname)); - var templates = require('./templates'); - var Version = require('../Version'); - var urlParamRE = /\{(\w+)\}/g; - - var files; // populated in readSpecFiles - var apiSpec; // populated by parseSpecFiles - var docVars; // slightly modified clone of apiSpec for the docs - - var branchSuffix = utils.branchSuffix(branch); - var esDir = fromRoot('src/_elasticsearch_' + _.snakeCase(branch)); - - var version = Version.fromBranch(branch); - var overrides = version.mergeOpts(require('./overrides'), { + const _ = require('../../src/lib/utils'); + const utils = require('../../grunt/utils'); + const fs = require('fs'); + const async = require('async'); + const chalk = require('chalk'); + const path = require('path'); + const fromRoot = path.join.bind(path, require('find-root')(__dirname)); + const templates = require('./templates'); + const Version = require('../Version'); + const urlParamRE = /\{(\w+)\}/g; + + let files; // populated in readSpecFiles + let apiSpec; // populated by parseSpecFiles + let docVars; // slightly modified clone of apiSpec for the docs + + const branchSuffix = utils.branchSuffix(branch); + const esDir = fromRoot('src/_elasticsearch_' + _.snakeCase(branch)); + + const version = Version.fromBranch(branch); + const overrides = version.mergeOpts(require('./overrides'), { aliases: {}, mergeConcatParams: {}, paramAsBody: {}, @@ -31,7 +31,7 @@ module.exports = function (branch, done) { descriptions: {}, }); - var steps = [ + const steps = [ readSpecFiles, parseSpecFiles, writeApiFile @@ -51,13 +51,13 @@ module.exports = function (branch, done) { }); function readSpecFiles(done) { - var apiDir = path.join(esDir, 'rest-api-spec/api/'); + const apiDir = path.join(esDir, 'rest-api-spec/api/'); files = fs.readdirSync(apiDir) .filter(function (filename) { - return filename[0] !== '_' + return filename[0] !== '_'; }) .map(function (filename) { - var module = require(apiDir + filename); + const module = require(apiDir + filename); delete require.cache[apiDir + filename]; return module; }); @@ -65,7 +65,7 @@ module.exports = function (branch, done) { } function parseSpecFiles(done) { - var actions = []; + const actions = []; files.forEach(function (spec) { __puke__transformSpec(spec).forEach(function (action) { @@ -74,16 +74,16 @@ module.exports = function (branch, done) { }); // collect the namespaces from the action locations - var namespaces = _.filter(_.map(actions, function (action) { + const namespaces = _.filter(_.map(actions, function (action) { return action.location .split('.') .slice(0, -1) .filter(step => step !== 'prototype') - .join('.prototype.') + .join('.prototype.'); })); // seperate the proxy actions - var groups = _.groupBy(actions, function (action) { + const groups = _.groupBy(actions, function (action) { return action.proxy ? 'proxies' : 'normal'; }); @@ -95,7 +95,7 @@ module.exports = function (branch, done) { }; if (!_.find(apiSpec.actions, { name: 'create' })) { - var create = _.assign( + const create = _.assign( {}, _.cloneDeep(_.find(apiSpec.actions, { name: 'index' })), { @@ -115,8 +115,8 @@ module.exports = function (branch, done) { [].concat(apiSpec.actions, apiSpec.proxies) .forEach(function (action) { - var examplePath = overrides.examples[action.name] || action.name + '.asciidoc'; - var descriptionPath = overrides.descriptions[action.name] || action.name + '.asciidoc'; + const examplePath = overrides.examples[action.name] || action.name + '.asciidoc'; + const descriptionPath = overrides.descriptions[action.name] || action.name + '.asciidoc'; try { action.examples = fs.readFileSync(fromRoot('docs/_examples', examplePath), 'utf8'); @@ -129,13 +129,13 @@ module.exports = function (branch, done) { } catch (e) { action.description = '// no description'; } - }) + }); done(); } function writeApiFile(done) { - var outputPath = fromRoot('src/lib/apis/' + _.snakeCase(branch) + '.js'); + const outputPath = fromRoot('src/lib/apis/' + _.snakeCase(branch) + '.js'); fs.writeFileSync(outputPath, templates.apiFile(apiSpec)); console.log(chalk.white.bold('wrote'), apiSpec.actions.length, 'api actions to', outputPath); done(); @@ -173,7 +173,7 @@ module.exports = function (branch, done) { } function writeMethodDocs(done) { - var filename = fromRoot('docs/api_methods' + branchSuffix + '.asciidoc'); + const filename = fromRoot('docs/api_methods' + branchSuffix + '.asciidoc'); fs.writeFile( filename, templates.apiMethods(docVars), @@ -187,7 +187,7 @@ module.exports = function (branch, done) { } function __puke__transformSpec(spec) { // eslint-disable-line - var actions = []; + const actions = []; // itterate all of the specs within the file, should only be one _.each(spec, function (def, name) { @@ -198,10 +198,10 @@ module.exports = function (branch, done) { def.documentation = 'http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat.html'; } - var steps = name.split('.'); + const steps = name.split('.'); function transformParamKeys(note, param, key) { - var cmlKey = _.camelCase(key); + const cmlKey = _.camelCase(key); if (cmlKey !== key) { param.name = key; } @@ -211,24 +211,24 @@ module.exports = function (branch, done) { def.url.params = _.transform(def.url.params, transformParamKeys, {}); def.url.parts = _.transform(def.url.parts, transformParamKeys, {}); - var allParams = _.extend({}, def.url.params, def.url.parts); + const allParams = _.extend({}, def.url.params, def.url.parts); _.forOwn(allParams, (paramSpec, paramName) => { - const toMerge = _.get(overrides, ['mergeConcatParams', name, paramName]) + const toMerge = _.get(overrides, ['mergeConcatParams', name, paramName]); if (toMerge) { _.merge(paramSpec, toMerge, (dest, src) => { if (_.isArray(dest) && _.isArray(src)) { - return dest.concat(src) + return dest.concat(src); } - }) + }); } if (paramSpec.options) { - const invalidOpts = paramSpec.options.some(opt => typeof opt !== 'string') - if (invalidOpts) throw new Error(`${name} has options that are not strings...`) + const invalidOpts = paramSpec.options.some(opt => typeof opt !== 'string'); + if (invalidOpts) throw new Error(`${name} has options that are not strings...`); } - }) + }); - var spec = { + const spec = { name: name, methods: _.map(def.methods, function (m) { return m.toUpperCase(); }), params: def.url.params, @@ -248,15 +248,15 @@ module.exports = function (branch, done) { spec.requestTimeout = 3000; } - var urls = _.difference(def.url.paths, overrides.aliases[name]); - var urlSignatures = []; + let urls = _.difference(def.url.paths, overrides.aliases[name]); + const urlSignatures = []; urls = _.map(urls, function (url) { - var optionalVars = {}; - var requiredVars = {}; - var param; - var name; - var target; - var match; + const optionalVars = {}; + const requiredVars = {}; + let param; + let name; + let target; + let match; if (url.charAt(0) !== '/') { url = '/' + url; @@ -317,10 +317,10 @@ module.exports = function (branch, done) { } // escape method names with "special" keywords - var location = spec.name.split('.').join('.prototype.') + const location = spec.name.split('.').join('.prototype.') .replace(/(^|\.)(delete|default)(\.|$)/g, '[\'$2\']'); - var action = { + const action = { _methods: spec.methods, spec: _.pick(spec, [ 'params', @@ -339,7 +339,7 @@ module.exports = function (branch, done) { }; function hasMethod(/* ...methods */) { - for (var i = 0; i < arguments.length; i++) { + for (let i = 0; i < arguments.length; i++) { if (~action._methods.indexOf(arguments[i])) { continue; } else { @@ -352,7 +352,7 @@ module.exports = function (branch, done) { return hasMethod.apply(null, arguments) && arguments.length === action._methods.length; } - var method; + let method; if (action._methods.length === 1) { method = action._methods[0]; diff --git a/scripts/generate/templates/index.js b/scripts/generate/templates/index.js index aec6069dd..82a262359 100644 --- a/scripts/generate/templates/index.js +++ b/scripts/generate/templates/index.js @@ -1,8 +1,8 @@ -var _ = require('../../../src/lib/utils'); -var utils = require('../../../grunt/utils'); -var fs = require('fs'); -var path = require('path'); +const _ = require('../../../src/lib/utils'); +const utils = require('../../../grunt/utils'); +const fs = require('fs'); +const path = require('path'); /** @@ -31,20 +31,20 @@ function stringify(thing, pretty) { * We'll collect the templates here * @type {Object} */ -var templates = {}; +const templates = {}; /** * These keys will be available as local variables to each template * @type {Object} */ -var templateGlobals = { +const templateGlobals = { stringify: stringify, _: _, indent: function (block, spaces) { - var indent = _.repeat(' ', spaces); + const indent = _.repeat(' ', spaces); return block.split('\n').map(function (line) { return indent + line; }).join('\n'); @@ -58,7 +58,7 @@ var templateGlobals = { switch (type && type.toLowerCase ? type.toLowerCase() : 'any') { case 'time': case 'duration': - if (paramName === 'timestamp') return 'Timestamp' + if (paramName === 'timestamp') return 'Timestamp'; return '<>'; case 'any': return 'anything'; @@ -96,7 +96,7 @@ var templateGlobals = { }; fs.readdirSync(path.resolve(__dirname)).forEach(function (filename) { - var name = filename.replace(/\..+$/, ''); + const name = filename.replace(/\..+$/, ''); if (name !== 'index') { templates[name] = _.template( fs.readFileSync(path.resolve(__dirname, filename), 'utf8'), diff --git a/scripts/generate/yaml_tests.js b/scripts/generate/yaml_tests.js index 093695b1a..de4f4ba76 100644 --- a/scripts/generate/yaml_tests.js +++ b/scripts/generate/yaml_tests.js @@ -2,16 +2,16 @@ module.exports = function (branch, done) { /** * Creates a JSON version of the YAML test suite that can be simply bundled for use in the browser. */ - var jsYaml = require('js-yaml'); - var fs = require('fs'); - var async = require('async'); - var chalk = require('chalk'); - var path = require('path'); - var fromRoot = path.join.bind(path, require('find-root')(__dirname)); - var _ = require(fromRoot('src/lib/utils')); - var tests = {}; // populated in readYamlTests + const jsYaml = require('js-yaml'); + const fs = require('fs'); + const async = require('async'); + const chalk = require('chalk'); + const path = require('path'); + const fromRoot = path.join.bind(path, require('find-root')(__dirname)); + const _ = require(fromRoot('src/lib/utils')); + const tests = {}; // populated in readYamlTests - var esDir = fromRoot('src/_elasticsearch_' + _.snakeCase(branch)); + const esDir = fromRoot('src/_elasticsearch_' + _.snakeCase(branch)); // generate the yaml tests async.series([ @@ -21,16 +21,16 @@ module.exports = function (branch, done) { ], done); function readYamlTests(done) { - var testDir = path.join(esDir, 'rest-api-spec/test/'); + const testDir = path.join(esDir, 'rest-api-spec/test/'); function readDirectories(dir) { fs.readdirSync(dir).forEach(function (filename) { - var filePath = path.join(dir, filename); - var stat = fs.statSync(filePath); + const filePath = path.join(dir, filename); + const stat = fs.statSync(filePath); if (stat.isDirectory()) { readDirectories(filePath); } else if (filename.match(/\.yaml$/)) { - var file = tests[path.relative(testDir, filePath)] = []; + const file = tests[path.relative(testDir, filePath)] = []; jsYaml.loadAll(fs.readFileSync(filePath, 'utf8'), function (doc) { file.push(doc); }); @@ -43,14 +43,14 @@ module.exports = function (branch, done) { } function writeYamlTests(done) { - var testFile = fromRoot('test/integration/yaml_suite/yaml_tests_' + _.snakeCase(branch) + '.json'); + const testFile = fromRoot('test/integration/yaml_suite/yaml_tests_' + _.snakeCase(branch) + '.json'); fs.writeFileSync(testFile, JSON.stringify(tests, null, ' '), 'utf8'); console.log(chalk.white.bold('wrote') + ' YAML tests as JSON to', testFile); done(); } function writeTestIndex(done) { - var file = fromRoot('test/integration/yaml_suite/index_' + _.snakeCase(branch) + '.js'); + const file = fromRoot('test/integration/yaml_suite/index_' + _.snakeCase(branch) + '.js'); fs.writeFileSync(file, 'require(\'./run\')(\'' + branch + '\');\n', 'utf8'); console.log(chalk.white.bold('wrote') + ' YAML index to', file); done(); diff --git a/scripts/release/bower.js b/scripts/release/bower.js index 3705c1dcb..c00c61763 100644 --- a/scripts/release/bower.js +++ b/scripts/release/bower.js @@ -1,15 +1,15 @@ -var fs = require('fs'); -var spawn = require('../_spawn'); -var async = require('async'); -var _ = require('lodash'); +const fs = require('fs'); +const spawn = require('../_spawn'); +const async = require('async'); +const _ = require('lodash'); -var root = require('path').join(__dirname, '../..'); -var bowerDir = root + '/src/bower_es_js'; +const root = require('path').join(__dirname, '../..'); +const bowerDir = root + '/src/bower_es_js'; // get both the bower and node package files -var bowerJson = require(bowerDir + '/bower.json'); -var bowerPackageJson = require(bowerDir + '/package.json'); -var esjsJson = require(root + '/package.json'); +const bowerJson = require(bowerDir + '/bower.json'); +const bowerPackageJson = require(bowerDir + '/package.json'); +const esjsJson = require(root + '/package.json'); // update the version to match the node version bowerJson.version = esjsJson.version; diff --git a/src/elasticsearch.angular.js b/src/elasticsearch.angular.js index 514374714..b25fd3255 100644 --- a/src/elasticsearch.angular.js +++ b/src/elasticsearch.angular.js @@ -4,8 +4,8 @@ * * It will also instruct the client to use Angular's $http service for it's ajax requests */ -var AngularConnector = require('./lib/connectors/angular'); -var Client = require('./lib/client'); +const AngularConnector = require('./lib/connectors/angular'); +const Client = require('./lib/client'); process.angular_build = true; @@ -13,7 +13,7 @@ process.angular_build = true; angular.module('elasticsearch', []) .factory('esFactory', ['$injector', '$q', function ($injector, $q) { - var factory = function (config) { + const factory = function (config) { config = config || {}; config.connectionClass = AngularConnector; config.$injector = $injector; diff --git a/src/elasticsearch.jquery.js b/src/elasticsearch.jquery.js index 740a2ee1f..a05f8c442 100644 --- a/src/elasticsearch.jquery.js +++ b/src/elasticsearch.jquery.js @@ -1,10 +1,10 @@ /* global jQuery */ (function ($) { process.jquery_build = true; - var es = require('./elasticsearch'); + const es = require('./elasticsearch'); function defer() { - var def = $.Deferred(); + const def = $.Deferred(); // def.promise is usually a property (in normal implementations) // we override the promise to keep things working def.promise = def.promise(); diff --git a/src/lib/client.js b/src/lib/client.js index a50c869ac..5c6ed4bd9 100755 --- a/src/lib/client.js +++ b/src/lib/client.js @@ -26,9 +26,9 @@ module.exports = Client; -var Transport = require('./transport'); -var clientAction = require('./client_action'); -var _ = require('./utils'); +const Transport = require('./transport'); +const clientAction = require('./client_action'); +const _ = require('./utils'); function Client(config) { config = config || {}; @@ -71,7 +71,7 @@ function Client(config) { config.sniffEndpoint = '/_cluster/nodes'; } - var Constructor = EsApiClient; + let Constructor = EsApiClient; if (config.plugins) { Constructor.prototype = _.cloneDeep(Constructor.prototype); diff --git a/src/lib/client_action.js b/src/lib/client_action.js index a8d6d26d1..975d7bdfe 100644 --- a/src/lib/client_action.js +++ b/src/lib/client_action.js @@ -1,5 +1,5 @@ -var _ = require('./utils'); +const _ = require('./utils'); /** * Constructs a client action factory that uses specific defaults @@ -37,7 +37,7 @@ exports.namespaceFactory = function () { function makeFactoryWithModifier(modifier) { modifier = modifier || _.identity; - var factory = function (spec) { + const factory = function (spec) { spec = modifier(spec); if (!_.isPlainObject(spec.params)) { @@ -63,7 +63,7 @@ function makeFactoryWithModifier(modifier) { if (typeof cb === 'function') { _.nextTick(cb, e); } else { - var def = this.transport.defer(); + const def = this.transport.defer(); def.reject(e); return def.promise; } @@ -96,7 +96,7 @@ function makeFactoryWithModifier(modifier) { return factory; } -var castType = { +const castType = { 'enum': function validSelection(param, val, name) { if (_.isString(val) && val.indexOf(',') > -1) { val = commaSepList(val); @@ -108,7 +108,7 @@ var castType = { }).join(','); } - for (var i = 0; i < param.options.length; i++) { + for (let i = 0; i < param.options.length; i++) { if (param.options[i] === String(val)) { return param.options[i]; } @@ -183,7 +183,7 @@ var castType = { }; function resolveUrl(url, params) { - var vars = {}, i, key; + let vars = {}, i, key; if (url.req) { // url has required params @@ -192,7 +192,7 @@ function resolveUrl(url, params) { url.reqParamKeys = _.keys(url.req); } - for (i = 0; i < url.reqParamKeys.length; i ++) { + for (i = 0; i < url.reqParamKeys.length; i++) { key = url.reqParamKeys[i]; if (!params.hasOwnProperty(key) || params[key] == null) { // missing a required param @@ -214,7 +214,7 @@ function resolveUrl(url, params) { url.optParamKeys = _.keys(url.opt); } - for (i = 0; i < url.optParamKeys.length; i ++) { + for (i = 0; i < url.optParamKeys.length; i++) { key = url.optParamKeys[i]; if (params[key]) { if (castType[url.opt[key].type] || params[key] == null) { @@ -223,7 +223,7 @@ function resolveUrl(url, params) { vars[key] = params[key]; } } else { - vars[key] = url.opt[key]['default']; + vars[key] = url.opt[key].default; } } } @@ -243,11 +243,11 @@ function resolveUrl(url, params) { function exec(transport, spec, params, cb) { - var request = { + const request = { method: spec.method }; - var query = {}; - var i; + const query = {}; + let i; // pass the timeout from the spec if (spec.requestTimeout) { @@ -297,7 +297,7 @@ function exec(transport, spec, params, cb) { if (!request.path) { // there must have been some mimimun requirements that were not met - var minUrl = spec.url || spec.urls[spec.urls.length - 1]; + const minUrl = spec.url || spec.urls[spec.urls.length - 1]; throw new TypeError('Unable to build a path with those params. Supply at least ' + _.keys(minUrl.req).join(', ')); } @@ -312,7 +312,7 @@ function exec(transport, spec, params, cb) { }, []); } - for (var key in params) { + for (const key in params) { if (params.hasOwnProperty(key) && params[key] != null) { switch (key) { case 'body': @@ -339,7 +339,7 @@ function exec(transport, spec, params, cb) { query[paramSpec.name] = params[key]; } - if (paramSpec['default'] && query[paramSpec.name] === paramSpec['default']) { + if (paramSpec.default && query[paramSpec.name] === paramSpec.default) { delete query[paramSpec.name]; } } @@ -350,7 +350,7 @@ function exec(transport, spec, params, cb) { } } - for (i = 0; i < spec.requireParamKeys.length; i ++) { + for (i = 0; i < spec.requireParamKeys.length; i++) { if (!query.hasOwnProperty(spec.requireParamKeys[i])) { throw new TypeError('Missing required parameter ' + spec.requireParamKeys[i]); } diff --git a/src/lib/connection.js b/src/lib/connection.js index 93c8c38a6..df3b2cd14 100644 --- a/src/lib/connection.js +++ b/src/lib/connection.js @@ -1,10 +1,10 @@ module.exports = ConnectionAbstract; -var _ = require('./utils'); -var EventEmitter = require('events').EventEmitter; -var Log = require('./log'); -var Host = require('./host'); -var errors = require('./errors'); +const _ = require('./utils'); +const EventEmitter = require('events').EventEmitter; +const Log = require('./log'); +const Host = require('./host'); +const errors = require('./errors'); /** * Abstract class used for Connection classes @@ -52,10 +52,10 @@ ConnectionAbstract.prototype.ping = function (params, cb) { cb = typeof cb === 'function' ? cb : null; } - var requestTimeout = this.pingTimeout; - var requestTimeoutId; - var aborted; - var abort; + let requestTimeout = this.pingTimeout; + let requestTimeoutId; + let aborted; + let abort; if (params && params.hasOwnProperty('requestTimeout')) { requestTimeout = params.requestTimeout; @@ -88,7 +88,7 @@ ConnectionAbstract.prototype.ping = function (params, cb) { }; ConnectionAbstract.prototype.setStatus = function (status) { - var origStatus = this.status; + const origStatus = this.status; this.status = status; this.emit('status set', status, origStatus, this); diff --git a/src/lib/connection_pool.js b/src/lib/connection_pool.js index 87c6dfcb9..6d51e4302 100644 --- a/src/lib/connection_pool.js +++ b/src/lib/connection_pool.js @@ -9,8 +9,8 @@ module.exports = ConnectionPool; -var _ = require('./utils'); -var Log = require('./log'); +const _ = require('./utils'); +const Log = require('./log'); function ConnectionPool(config) { config = config || {}; @@ -107,14 +107,14 @@ ConnectionPool.prototype.select = function (cb) { * @param {ConnectionAbstract} connection - the connection object itself */ ConnectionPool.prototype.onStatusSet = _.handler(function (status, oldStatus, connection) { - var index; + let index; - var died = (status === 'dead'); - var wasAlreadyDead = (died && oldStatus === 'dead'); - var revived = (!died && oldStatus === 'dead'); - var noChange = (oldStatus === status); - var from = this._conns[oldStatus]; - var to = this._conns[status]; + const died = (status === 'dead'); + const wasAlreadyDead = (died && oldStatus === 'dead'); + const revived = (!died && oldStatus === 'dead'); + const noChange = (oldStatus === status); + const from = this._conns[oldStatus]; + const to = this._conns[status]; if (noChange && !died) { return true; @@ -150,8 +150,8 @@ ConnectionPool.prototype.onStatusSet = _.handler(function (status, oldStatus, co * @param {ConnectionAbstract} connection */ ConnectionPool.prototype._onConnectionRevived = function (connection) { - var timeout; - for (var i = 0; i < this._timeouts.length; i++) { + let timeout; + for (let i = 0; i < this._timeouts.length; i++) { if (this._timeouts[i].conn === connection) { timeout = this._timeouts[i]; if (timeout.id) { @@ -169,9 +169,9 @@ ConnectionPool.prototype._onConnectionRevived = function (connection) { * @param {Boolean} alreadyWasDead - If the connection was preivously dead this must be set to true */ ConnectionPool.prototype._onConnectionDied = function (connection, alreadyWasDead) { - var timeout; + let timeout; if (alreadyWasDead) { - for (var i = 0; i < this._timeouts.length; i++) { + for (let i = 0; i < this._timeouts.length; i++) { if (this._timeouts[i].conn === connection) { timeout = this._timeouts[i]; break; @@ -198,17 +198,17 @@ ConnectionPool.prototype._onConnectionDied = function (connection, alreadyWasDea clearTimeout(timeout.id); } - var ms = this.calcDeadTimeout(timeout.attempt, this.deadTimeout); + const ms = this.calcDeadTimeout(timeout.attempt, this.deadTimeout); timeout.id = setTimeout(timeout.revive, ms); timeout.runAt = _.now() + ms; }; ConnectionPool.prototype._selectDeadConnection = function (cb) { - var orderedTimeouts = _.sortBy(this._timeouts, 'runAt'); - var log = this.log; + const orderedTimeouts = _.sortBy(this._timeouts, 'runAt'); + const log = this.log; process.nextTick(function next() { - var timeout = orderedTimeouts.shift(); + const timeout = orderedTimeouts.shift(); if (!timeout) { cb(void 0); return; @@ -247,7 +247,7 @@ ConnectionPool.prototype._selectDeadConnection = function (cb) { * @param {Number} [limit] - optional limit on the number of connections to return */ ConnectionPool.prototype.getConnections = function (status, limit) { - var list; + let list; if (status) { list = this._conns[status]; } else { @@ -304,11 +304,11 @@ ConnectionPool.prototype.removeConnection = function (connection) { * @param {Host[]} hosts - An array of Host instances. */ ConnectionPool.prototype.setHosts = function (hosts) { - var connection; - var i; - var id; - var host; - var toRemove = _.clone(this.index); + let connection; + let i; + let id; + let host; + const toRemove = _.clone(this.index); for (i = 0; i < hosts.length; i++) { host = hosts[i]; @@ -322,7 +322,7 @@ ConnectionPool.prototype.setHosts = function (hosts) { } } - var removeIds = _.keys(toRemove); + const removeIds = _.keys(toRemove); for (i = 0; i < removeIds.length; i++) { this.removeConnection(this.index[removeIds[i]]); } diff --git a/src/lib/connectors/angular.js b/src/lib/connectors/angular.js index 3336c7462..0b65590b6 100644 --- a/src/lib/connectors/angular.js +++ b/src/lib/connectors/angular.js @@ -6,14 +6,14 @@ */ module.exports = AngularConnector; -var _ = require('../utils'); -var ConnectionAbstract = require('../connection'); -var ConnectionFault = require('../errors').ConnectionFault; +const _ = require('../utils'); +const ConnectionAbstract = require('../connection'); +const ConnectionFault = require('../errors').ConnectionFault; function AngularConnector(host, config) { ConnectionAbstract.call(this, host, config); - var self = this; + const self = this; config.$injector.invoke(['$http', '$q', function ($http, $q) { self.$q = $q; self.$http = $http; @@ -23,7 +23,7 @@ function AngularConnector(host, config) { _.inherits(AngularConnector, ConnectionAbstract); AngularConnector.prototype.request = function (params, cb) { - var abort = this.$q.defer(); + const abort = this.$q.defer(); this.$http({ method: params.method, diff --git a/src/lib/connectors/browser_index.js b/src/lib/connectors/browser_index.js index 8553ee8da..ebe1dd399 100644 --- a/src/lib/connectors/browser_index.js +++ b/src/lib/connectors/browser_index.js @@ -1,9 +1,9 @@ -var opts = { +const opts = { xhr: require('./xhr'), jquery: require('./jquery'), angular: require('./angular') }; -var _ = require('../utils'); +const _ = require('../utils'); // remove modules that have been ignored by browserify _.each(opts, function (conn, name) { diff --git a/src/lib/connectors/http.js b/src/lib/connectors/http.js index 4368f1b2d..c8ea501c0 100644 --- a/src/lib/connectors/http.js +++ b/src/lib/connectors/http.js @@ -8,16 +8,16 @@ */ module.exports = HttpConnector; -var handles = { +const handles = { http: require('http'), https: require('https') }; -var _ = require('../utils'); -var parseUrl = require('url').parse; -var qs = require('querystring'); -var AgentKeepAlive = require('agentkeepalive'); -var ConnectionAbstract = require('../connection'); -var zlib = require('zlib'); +const _ = require('../utils'); +const parseUrl = require('url').parse; +const qs = require('querystring'); +const AgentKeepAlive = require('agentkeepalive'); +const ConnectionAbstract = require('../connection'); +const zlib = require('zlib'); /** * Connector used to talk to an elasticsearch node via HTTP @@ -51,9 +51,9 @@ _.inherits(HttpConnector, ConnectionAbstract); HttpConnector.prototype.onStatusSet = _.handler(function (status) { if (status === 'closed') { - var agent = this.agent; - var toRemove = []; - var collectSockets = function (sockets, host) { + const agent = this.agent; + const toRemove = []; + const collectSockets = function (sockets, host) { _.each(sockets, function (s) { if (s) toRemove.push([host, s]); }); @@ -65,7 +65,7 @@ HttpConnector.prototype.onStatusSet = _.handler(function (status) { _.each(agent.sockets, collectSockets); _.each(agent.freeSockets, collectSockets); _.each(toRemove, function (args) { - var host = args[0], socket = args[1]; + let host = args[0], socket = args[1]; agent.removeSocket(socket, parseUrl(host)); socket.destroy(); }); @@ -73,7 +73,7 @@ HttpConnector.prototype.onStatusSet = _.handler(function (status) { }); HttpConnector.prototype.createAgent = function (config) { - var Agent = this.hand.Agent; // the class + let Agent = this.hand.Agent; // the class if (config.forever) { config.keepAlive = config.forever; @@ -88,7 +88,7 @@ HttpConnector.prototype.createAgent = function (config) { }; HttpConnector.prototype.makeAgentConfig = function (config) { - var agentConfig = { + const agentConfig = { keepAlive: config.keepAlive, keepAliveMsecs: config.keepAliveInterval, maxSockets: config.maxSockets, @@ -105,9 +105,9 @@ HttpConnector.prototype.makeAgentConfig = function (config) { HttpConnector.prototype.makeReqParams = function (params) { params = params || {}; - var host = this.host; + const host = this.host; - var reqParams = { + const reqParams = { method: params.method || 'GET', protocol: host.protocol + ':', hostname: host.host, @@ -121,7 +121,7 @@ HttpConnector.prototype.makeReqParams = function (params) { reqParams.path = '/'; } - var query = host.getQuery(params.query); + const query = host.getQuery(params.query); if (query) { reqParams.path = reqParams.path + '?' + qs.stringify(query); } @@ -130,19 +130,19 @@ HttpConnector.prototype.makeReqParams = function (params) { }; HttpConnector.prototype.request = function (params, cb) { - var incoming; - var timeoutId; - var request; - var status = 0; - var headers = {}; - var log = this.log; - var response; + let incoming; + let timeoutId; + let request; + let status = 0; + let headers = {}; + const log = this.log; + let response; - var reqParams = this.makeReqParams(params); + const reqParams = this.makeReqParams(params); // general clean-up procedure to run after the request // completes, has an error, or is aborted. - var cleanUp = _.bind(function (err) { + const cleanUp = _.bind(function (err) { clearTimeout(timeoutId); request && request.removeAllListeners(); @@ -166,7 +166,7 @@ HttpConnector.prototype.request = function (params, cb) { headers = incoming.headers; response = ''; - var encoding = (headers['content-encoding'] || '').toLowerCase(); + const encoding = (headers['content-encoding'] || '').toLowerCase(); if (encoding === 'gzip' || encoding === 'deflate') { incoming = incoming.pipe(zlib.createUnzip()); } diff --git a/src/lib/connectors/jquery.js b/src/lib/connectors/jquery.js index f935e0497..a61da5c38 100644 --- a/src/lib/connectors/jquery.js +++ b/src/lib/connectors/jquery.js @@ -7,9 +7,9 @@ */ module.exports = JqueryConnector; -var _ = require('../utils'); -var ConnectionAbstract = require('../connection'); -var ConnectionFault = require('../errors').ConnectionFault; +const _ = require('../utils'); +const ConnectionAbstract = require('../connection'); +const ConnectionFault = require('../errors').ConnectionFault; function JqueryConnector(host, config) { ConnectionAbstract.call(this, host, config); @@ -17,7 +17,7 @@ function JqueryConnector(host, config) { _.inherits(JqueryConnector, ConnectionAbstract); JqueryConnector.prototype.request = function (params, cb) { - var ajax = { + const ajax = { url: this.host.makeUrl(params), data: params.body, type: params.method, diff --git a/src/lib/connectors/xhr.js b/src/lib/connectors/xhr.js index 2b21539a6..1afe05561 100644 --- a/src/lib/connectors/xhr.js +++ b/src/lib/connectors/xhr.js @@ -7,10 +7,10 @@ module.exports = XhrConnector; /* jshint browser:true */ -var _ = require('../utils'); -var ConnectionAbstract = require('../connection'); -var ConnectionFault = require('../errors').ConnectionFault; -var asyncDefault = !(navigator && /PhantomJS/i.test(navigator.userAgent)); +const _ = require('../utils'); +const ConnectionAbstract = require('../connection'); +const ConnectionFault = require('../errors').ConnectionFault; +const asyncDefault = !(navigator && /PhantomJS/i.test(navigator.userAgent)); function XhrConnector(host, config) { ConnectionAbstract.call(this, host, config); @@ -21,7 +21,7 @@ _.inherits(XhrConnector, ConnectionAbstract); * Simply returns an XHR object cross browser * @type {Function} */ -var getXhr = _.noop; +let getXhr = _.noop; if (typeof XMLHttpRequest !== 'undefined') { // rewrite the getXhr method to always return the native implementation @@ -34,7 +34,7 @@ if (typeof XMLHttpRequest !== 'undefined') { .map(function (appName) { /* jshint unused: false */ try { - var test = new window.ActiveXObject(appName); // eslint-disable-line no-unused-vars + const test = new window.ActiveXObject(appName); // eslint-disable-line no-unused-vars return function () { return new window.ActiveXObject(appName); }; @@ -51,19 +51,19 @@ if (!getXhr) { } XhrConnector.prototype.request = function (params, cb) { - var xhr = getXhr(); - var timeoutId; - var host = this.host; - var log = this.log; + const xhr = getXhr(); + let timeoutId; + const host = this.host; + const log = this.log; - var url = host.makeUrl(params); - var headers = host.getHeaders(params.headers); - var async = params.async === false ? false : asyncDefault; + const url = host.makeUrl(params); + const headers = host.getHeaders(params.headers); + const async = params.async === false ? false : asyncDefault; xhr.open(params.method || 'GET', url, async); if (headers) { - for (var key in headers) { + for (const key in headers) { if (headers[key] !== void 0) { xhr.setRequestHeader(key, headers[key]); } @@ -74,7 +74,7 @@ XhrConnector.prototype.request = function (params, cb) { if (xhr.readyState === 4) { clearTimeout(timeoutId); log.trace(params.method, url, params.body, xhr.responseText, xhr.status); - var err = xhr.status ? void 0 : new ConnectionFault(xhr.statusText || 'Request failed to complete.'); + const err = xhr.status ? void 0 : new ConnectionFault(xhr.statusText || 'Request failed to complete.'); cb(err, xhr.responseText, xhr.status); } }; diff --git a/src/lib/errors.js b/src/lib/errors.js index 377da5772..f6b8d6e30 100644 --- a/src/lib/errors.js +++ b/src/lib/errors.js @@ -1,8 +1,8 @@ -var _ = require('./utils'); -var errors = module.exports; +const _ = require('./utils'); +const errors = module.exports; -var canCapture = (typeof Error.captureStackTrace === 'function'); -var canStack = !!(new Error()).stack; +const canCapture = (typeof Error.captureStackTrace === 'function'); +const canStack = !!(new Error()).stack; function ErrorAbstract(msg, constructor, metadata) { this.message = msg; @@ -91,7 +91,7 @@ errors.RequestTypeError = function RequestTypeError(feature) { }; _.inherits(errors.RequestTypeError, ErrorAbstract); -var statusCodes = [ +const statusCodes = [ [300, 'Multiple Choices'], [301, 'Moved Permanently'], [302, 'Found'], @@ -137,18 +137,18 @@ var statusCodes = [ ]; _.each(statusCodes, function createStatusCodeError(tuple) { - var status = tuple[0]; - var names = tuple[1]; - var allNames = [].concat(names, status); - var primaryName = allNames[0]; - var className = _.studlyCase(primaryName); + const status = tuple[0]; + const names = tuple[1]; + let allNames = [].concat(names, status); + const primaryName = allNames[0]; + const className = _.studlyCase(primaryName); allNames = _.uniq(allNames.concat(className)); function StatusCodeError(msg, metadata) { this.status = status; this.displayName = className; - var esErrObject = null; + let esErrObject = null; if (_.isPlainObject(msg)) { esErrObject = msg; msg = null; @@ -167,7 +167,7 @@ _.each(statusCodes, function createStatusCodeError(tuple) { memo += '[' + cause.type + '] ' + cause.reason; - var extraData = _.omit(cause, ['type', 'reason']); + const extraData = _.omit(cause, ['type', 'reason']); if (_.size(extraData)) { memo += ', with ' + prettyPrint(extraData); } @@ -192,20 +192,20 @@ _.each(statusCodes, function createStatusCodeError(tuple) { function prettyPrint(data) { - const path = [] + const path = []; return (function print(v) { if (typeof v === 'object') { - if (path.indexOf(v) > -1) return '[circular]' - path.push(v) + if (path.indexOf(v) > -1) return '[circular]'; + path.push(v); try { return '{ ' + _.map(v, function (subv, name) { - return name + '=' + print(subv) - }).join(' & ') + ' }' + return name + '=' + print(subv); + }).join(' & ') + ' }'; } finally { - path.pop() + path.pop(); } } else { - return JSON.stringify(v) + return JSON.stringify(v); } - }(data)) + }(data)); } diff --git a/src/lib/host.js b/src/lib/host.js index 3ccddbfbf..6e5c8b48b 100644 --- a/src/lib/host.js +++ b/src/lib/host.js @@ -4,13 +4,13 @@ */ module.exports = Host; -var url = require('url'); -var qs = require('querystring'); -var _ = require('./utils'); +const url = require('url'); +const qs = require('querystring'); +const _ = require('./utils'); -var startsWithProtocolRE = /^([a-z]+:)?\/\//; -var defaultProto = 'http:'; -var btoa; +const startsWithProtocolRE = /^([a-z]+:)?\/\//; +let defaultProto = 'http:'; +let btoa; if (typeof window !== 'undefined' && typeof window.location !== 'undefined') { defaultProto = window.location.protocol; @@ -21,13 +21,13 @@ btoa = btoa || function (data) { return (new Buffer(data, 'utf8')).toString('base64'); }; -var urlParseFields = [ +const urlParseFields = [ 'protocol', 'hostname', 'pathname', 'port', 'auth', 'query' ]; -var simplify = ['host', 'path']; +const simplify = ['host', 'path']; -var sslDefaults = { +const sslDefaults = { pfx: null, key: null, passphrase: null, @@ -61,11 +61,11 @@ function Host(config, globalConfig) { this.ssl = _.defaults({}, config.ssl || {}, globalConfig.ssl || {}, sslDefaults); if (typeof config === 'string') { - var firstColon = config.indexOf(':'); - var firstSlash = config.indexOf('/'); - var noSlash = firstSlash === -1; - var portNoPath = firstColon > -1 && noSlash; - var portWithPath = !portNoPath && firstColon < firstSlash; + const firstColon = config.indexOf(':'); + const firstSlash = config.indexOf('/'); + const noSlash = firstSlash === -1; + const portNoPath = firstColon > -1 && noSlash; + const portWithPath = !portNoPath && firstColon < firstSlash; if ((noSlash || portNoPath || portWithPath) && !startsWithProtocolRE.test(config)) { config = defaultProto + '//' + config; } @@ -73,7 +73,7 @@ function Host(config, globalConfig) { // default logic for the port is to use 9200 for the default. When a string is specified though, // we will use the default from the protocol of the string. if (!config.port) { - var proto = config.protocol || 'http'; + let proto = config.protocol || 'http'; if (proto.charAt(proto.length - 1) === ':') { proto = proto.substring(0, proto.length - 1); } @@ -86,7 +86,7 @@ function Host(config, globalConfig) { if (_.isObject(config)) { // move hostname/portname to host/port semi-intelligently. _.each(simplify, function (to) { - var from = to + 'name'; + const from = to + 'name'; if (config[from] && config[to]) { if (config[to].indexOf(config[from]) === 0) { config[to] = config[from]; @@ -101,7 +101,7 @@ function Host(config, globalConfig) { } if (!config.auth && globalConfig.httpAuth) { - config.auth = globalConfig.httpAuth + config.auth = globalConfig.httpAuth; } if (config.auth) { @@ -145,14 +145,14 @@ function Host(config, globalConfig) { Host.prototype.makeUrl = function (params) { params = params || {}; // build the port - var port = ''; + let port = ''; if (this.port !== Host.defaultPorts[this.protocol]) { // add an actual port port = ':' + this.port; } // build the path - var path = '' + (this.path || '') + (params.path || ''); + let path = '' + (this.path || '') + (params.path || ''); // if path doesn't start with '/' add it. if (path.charAt(0) !== '/') { @@ -160,7 +160,7 @@ Host.prototype.makeUrl = function (params) { } // build the query string - var query = qs.stringify(this.getQuery(params.query)); + const query = qs.stringify(this.getQuery(params.query)); if (this.host) { return this.protocol + '://' + this.host + port + path + (query ? '?' + query : ''); @@ -175,7 +175,7 @@ function objectPropertyGetter(prop, preOverride) { overrides = preOverride.call(this, overrides); } - var obj = this[prop]; + let obj = this[prop]; if (!obj && !overrides) { return null; } diff --git a/src/lib/log.js b/src/lib/log.js index 804d601f8..fc4f4a511 100644 --- a/src/lib/log.js +++ b/src/lib/log.js @@ -1,6 +1,6 @@ -var _ = require('./utils'); -var url = require('url'); -var EventEmitter = require('events').EventEmitter; +const _ = require('./utils'); +const url = require('url'); +const EventEmitter = require('events').EventEmitter; /** * Log bridge, which is an [EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter) @@ -21,8 +21,8 @@ function Log(config) { config = config || {}; if (!config.log) return; - var i; - var outputs; + let i; + let outputs; if (_.isArrayOfStrings(config.log)) { outputs = [{ @@ -158,7 +158,7 @@ Log.parseLevels = function (input) { /* fall through */ case 'object': if (_.isArray(input)) { - var valid = _.intersection(input, Log.levels); + const valid = _.intersection(input, Log.levels); if (valid.length === input.length) { return valid; } @@ -209,7 +209,7 @@ Log.prototype.addOutput = function (config) { config.levels = Log.parseLevels(config.levels || config.level || 'warning'); delete config.level; - var Logger = _.funcEnum(config, 'type', Log.loggers, process.browser ? 'console' : 'stdio'); + const Logger = _.funcEnum(config, 'type', Log.loggers, process.browser ? 'console' : 'stdio'); return new Logger(this, config); }; diff --git a/src/lib/logger.js b/src/lib/logger.js index 5732d7fed..2105d183d 100644 --- a/src/lib/logger.js +++ b/src/lib/logger.js @@ -1,4 +1,4 @@ -var _ = require('./utils'); +const _ = require('./utils'); /** * Abstract class providing common functionality to loggers @@ -27,7 +27,7 @@ function padNumToTen(n) { * @return {String} - Timestamp in ISO 8601 UTC */ LoggerAbstract.prototype.timestamp = function () { - var d = new Date(); + const d = new Date(); return d.getUTCFullYear() + '-' + padNumToTen(d.getUTCMonth() + 1) + '-' + padNumToTen(d.getUTCDate()) + 'T' + @@ -37,7 +37,7 @@ LoggerAbstract.prototype.timestamp = function () { }; function indent(text, spaces) { - var space = _.repeat(' ', spaces || 2); + const space = _.repeat(' ', spaces || 2); return (text || '').split(/\r?\n/).map(function (line) { return space + line; }).join('\n'); @@ -65,7 +65,7 @@ LoggerAbstract.prototype.setupListeners = function (levels) { this.listeningLevels = []; _.each(levels, _.bind(function (level) { - var fnName = 'on' + _.ucfirst(level); + const fnName = 'on' + _.ucfirst(level); if (this.bound[fnName]) { this.listeningLevels.push(level); this.log.on(level, this.bound[fnName]); diff --git a/src/lib/loggers/console.js b/src/lib/loggers/console.js index d5ec9771f..223f0a4ca 100644 --- a/src/lib/loggers/console.js +++ b/src/lib/loggers/console.js @@ -12,8 +12,8 @@ module.exports = Console; -var LoggerAbstract = require('../logger'); -var _ = require('../utils'); +const LoggerAbstract = require('../logger'); +const _ = require('../utils'); function Console(log, config) { LoggerAbstract.call(this, log, config); @@ -48,7 +48,7 @@ Console.prototype.write = function (label, message, to) { * @return {undefined} */ Console.prototype.onError = _.handler(function (e) { - var to = console.error ? 'error' : 'log'; + const to = console.error ? 'error' : 'log'; this.write(e.name === 'Error' ? 'ERROR' : e.name, e.stack || e.message, to); }); diff --git a/src/lib/loggers/file.js b/src/lib/loggers/file.js index 4b4357f96..ddc97c23c 100755 --- a/src/lib/loggers/file.js +++ b/src/lib/loggers/file.js @@ -11,9 +11,9 @@ module.exports = File; -var StreamLogger = require('./stream'); -var _ = require('../utils'); -var fs = require('fs'); +const StreamLogger = require('./stream'); +const _ = require('../utils'); +const fs = require('fs'); function File(log, config) { config = config || {}; @@ -32,7 +32,7 @@ function File(log, config) { _.inherits(File, StreamLogger); File.prototype.onProcessExit = _.handler(function () { - var toWrite = _.getUnwrittenFromStream(this.stream); + const toWrite = _.getUnwrittenFromStream(this.stream); if (toWrite) { fs.appendFileSync(this.path, toWrite); } diff --git a/src/lib/loggers/stdio.js b/src/lib/loggers/stdio.js index 1ba868d33..a58a7d73e 100755 --- a/src/lib/loggers/stdio.js +++ b/src/lib/loggers/stdio.js @@ -12,14 +12,14 @@ module.exports = Stdio; -var chalk = require('chalk'); +const chalk = require('chalk'); // let the user define if they want color in the client config. chalk.enabled = true; -var LoggerAbstract = require('../logger'); -var _ = require('../utils'); +const LoggerAbstract = require('../logger'); +const _ = require('../utils'); -var defaultColors = { +const defaultColors = { error: chalk.red.bold, warning: chalk.yellow.bold, info: chalk.cyan.bold, diff --git a/src/lib/loggers/stream.js b/src/lib/loggers/stream.js index 235440d15..6f075c4e5 100755 --- a/src/lib/loggers/stream.js +++ b/src/lib/loggers/stream.js @@ -12,8 +12,8 @@ module.exports = Stream; -var LoggerAbstract = require('../logger'); -var _ = require('../utils'); +const LoggerAbstract = require('../logger'); +const _ = require('../utils'); function Stream(log, config) { LoggerAbstract.call(this, log, config); @@ -36,7 +36,7 @@ Stream.prototype.cleanUpListeners = _.handler(function () { // flush the write buffer to stderr synchronously Stream.prototype.onProcessExit = _.handler(function () { // process is dying, lets manually flush the buffer synchronously to stderr. - var unwritten = _.getUnwrittenFromStream(this.stream); + const unwritten = _.getUnwrittenFromStream(this.stream); if (unwritten) { console.error('Log stream did not get to finish writing. Flushing to stderr'); console.error(unwritten); diff --git a/src/lib/loggers/tracer.js b/src/lib/loggers/tracer.js index c79b48c5e..96bf28ea7 100755 --- a/src/lib/loggers/tracer.js +++ b/src/lib/loggers/tracer.js @@ -12,10 +12,10 @@ module.exports = Tracer; -var StreamLogger = require('./stream'); -var fs = require('fs'); -var _ = require('../utils'); -var url = require('url'); +const StreamLogger = require('./stream'); +const fs = require('fs'); +const _ = require('../utils'); +const url = require('url'); function Tracer(log, config) { if (config.path === false) { @@ -31,22 +31,22 @@ function Tracer(log, config) { } _.inherits(Tracer, StreamLogger); -var usefulUrlFields = ['protocol', 'slashes', 'port', 'hostname', 'pathname', 'query']; +const usefulUrlFields = ['protocol', 'slashes', 'port', 'hostname', 'pathname', 'query']; Tracer.prototype._formatTraceMessage = function (req) { - var reqUrl = _.pick(url.parse(req.url, true, false), usefulUrlFields); + const reqUrl = _.pick(url.parse(req.url, true, false), usefulUrlFields); - var originalHost = url.format(_.pick(reqUrl, 'protocol', 'hostname', 'port')); + const originalHost = url.format(_.pick(reqUrl, 'protocol', 'hostname', 'port')); reqUrl.port = this.curlPort; reqUrl.hostname = this.curlHost; reqUrl.query = _.defaults(reqUrl.query || {}, { pretty: true }); /* jshint quotmark: double */ - var curlCall = + const curlCall = '# ' + originalHost + '\n' + - "curl '" + url.format(reqUrl).replace(/'/g, "\\'") + "' -X" + req.method.toUpperCase() + - (req.body ? " -d '" + this._prettyJson(req.body) + "'" : ''); + 'curl \'' + url.format(reqUrl).replace(/'/g, '\\\'') + '\' -X' + req.method.toUpperCase() + + (req.body ? ' -d \'' + this._prettyJson(req.body) + '\'' : ''); /* jshint quotmark: single */ return { @@ -62,7 +62,7 @@ function comment(str) { } Tracer.prototype.write = function (label, msg) { - var lead = comment(label + ': ' + this.timestamp()) + '\n'; + const lead = comment(label + ': ' + this.timestamp()) + '\n'; if (typeof msg === 'string') { this.stream.write(lead + comment(msg) + '\n\n', 'utf8'); } else { diff --git a/src/lib/nodes_to_host.js b/src/lib/nodes_to_host.js index c87ce9041..af05105e8 100644 --- a/src/lib/nodes_to_host.js +++ b/src/lib/nodes_to_host.js @@ -1,14 +1,14 @@ -var _ = require('./utils'); +const _ = require('./utils'); -var extractHostPartsRE1x = /\[(?:(.*)\/)?(.+?):(\d+)\]/; +const extractHostPartsRE1x = /\[(?:(.*)\/)?(.+?):(\d+)\]/; function makeNodeParser(hostProp) { return function (nodes) { return _.transform(nodes, function (hosts, node, id) { - var address = _.get(node, hostProp) + let address = _.get(node, hostProp); if (!address) return; - var host = { + const host = { host: undefined, port: undefined, _meta: { @@ -18,13 +18,13 @@ function makeNodeParser(hostProp) { } }; - var malformedError = new Error( + const malformedError = new Error( 'Malformed ' + hostProp + '.' + ' Got ' + JSON.stringify(address) + ' and expected it to match "{hostname?}/{ip}:{port}".' ); - var matches1x = extractHostPartsRE1x.exec(address); + const matches1x = extractHostPartsRE1x.exec(address); if (matches1x) { host.host = matches1x[1] || matches1x[2]; host.port = parseInt(matches1x[3], 10); @@ -33,7 +33,7 @@ function makeNodeParser(hostProp) { } if (address.indexOf('/') > -1) { - var withHostParts = address.split('/'); + const withHostParts = address.split('/'); if (withHostParts.length !== 2) throw malformedError; host.host = withHostParts.shift(); @@ -44,7 +44,7 @@ function makeNodeParser(hostProp) { throw malformedError; } - var addressParts = address.split(':'); + const addressParts = address.split(':'); if (addressParts.length !== 2) { throw malformedError; } diff --git a/src/lib/selectors/round_robin.js b/src/lib/selectors/round_robin.js index e7de6858c..c2294524a 100644 --- a/src/lib/selectors/round_robin.js +++ b/src/lib/selectors/round_robin.js @@ -7,7 +7,7 @@ * @return {Connection} - The selected connection */ module.exports = function (connections) { - var connection = connections[0]; + const connection = connections[0]; connections.push(connections.shift()); return connection; }; diff --git a/src/lib/serializers/angular.js b/src/lib/serializers/angular.js index 1548badc1..efa6f2efd 100644 --- a/src/lib/serializers/angular.js +++ b/src/lib/serializers/angular.js @@ -1,6 +1,6 @@ /* global angular */ -var _ = require('../utils'); -var JsonSerializer = require('../serializers/json'); +const _ = require('../utils'); +const JsonSerializer = require('../serializers/json'); function AngularSerializer() {} _.inherits(AngularSerializer, JsonSerializer); diff --git a/src/lib/serializers/json.js b/src/lib/serializers/json.js index 3f9f8d646..15d4cbcd8 100755 --- a/src/lib/serializers/json.js +++ b/src/lib/serializers/json.js @@ -4,7 +4,7 @@ */ module.exports = Json; -var _ = require('../utils'); +const _ = require('../utils'); function Json() {} @@ -44,7 +44,7 @@ Json.prototype.deserialize = function (str) { }; Json.prototype.bulkBody = function (val) { - var body = '', i; + let body = '', i; if (_.isArray(val)) { for (i = 0; i < val.length; i++) { diff --git a/src/lib/transport.js b/src/lib/transport.js index dbbc0f45c..99b037cb9 100644 --- a/src/lib/transport.js +++ b/src/lib/transport.js @@ -4,25 +4,25 @@ */ module.exports = Transport; -var _ = require('./utils'); -var errors = require('./errors'); -var Host = require('./host'); -var patchSniffOnConnectionFault = require('./transport/sniff_on_connection_fault'); -var findCommonProtocol = require('./transport/find_common_protocol'); +const _ = require('./utils'); +const errors = require('./errors'); +const Host = require('./host'); +const patchSniffOnConnectionFault = require('./transport/sniff_on_connection_fault'); +const findCommonProtocol = require('./transport/find_common_protocol'); function Transport(config) { - var self = this; + const self = this; config = self._config = config || {}; - var LogClass = (typeof config.log === 'function') ? config.log : require('./log'); + const LogClass = (typeof config.log === 'function') ? config.log : require('./log'); config.log = self.log = new LogClass(config); // setup the connection pool - var ConnectionPool = _.funcEnum(config, 'connectionPool', Transport.connectionPools, 'main'); + const ConnectionPool = _.funcEnum(config, 'connectionPool', Transport.connectionPools, 'main'); self.connectionPool = new ConnectionPool(config); // setup the serializer - var Serializer = _.funcEnum(config, 'serializer', Transport.serializers, 'json'); + const Serializer = _.funcEnum(config, 'serializer', Transport.serializers, 'json'); self.serializer = new Serializer(config); // setup the nodesToHostCallback @@ -42,14 +42,14 @@ function Transport(config) { } // randomizeHosts option - var randomizeHosts = config.hasOwnProperty('randomizeHosts') ? !!config.randomizeHosts : true; + const randomizeHosts = config.hasOwnProperty('randomizeHosts') ? !!config.randomizeHosts : true; if (config.host) { config.hosts = config.host; } if (config.hosts) { - var hostsConfig = _.createArray(config.hosts, function (val) { + let hostsConfig = _.createArray(config.hosts, function (val) { if (_.isPlainObject(val) || _.isString(val) || val instanceof Host) { return val; } @@ -104,10 +104,10 @@ Transport.prototype.defer = function () { throw new Error( 'No Promise implementation found. In order for elasticsearch-js to create promises ' + 'either specify the `defer` configuration or include a global Promise shim' - ) + ); } - var defer = {}; + const defer = {}; defer.promise = new Promise(function (resolve, reject) { defer.resolve = resolve; defer.reject = reject; @@ -133,19 +133,19 @@ Transport.prototype.defer = function () { * @param {Function} cb - A function to call back with (error, responseBody, responseStatus) */ Transport.prototype.request = function (params, cb) { - var self = this; - var remainingRetries = this.maxRetries; - var requestTimeout = this.requestTimeout; - - var connection; // set in sendReqWithConnection - var aborted = false; // several connector will respond with an error when the request is aborted - var requestAborter; // an abort function, returned by connection#request() - var requestTimeoutId; // the id of the ^timeout - var ret; // the object returned to the user, might be a promise - var defer; // the defer object, will be set when we are using promises. - - var body = params.body; - var headers = !params.headers ? {} : _.transform(params.headers, function (headers, val, name) { + const self = this; + let remainingRetries = this.maxRetries; + let requestTimeout = this.requestTimeout; + + let connection; // set in sendReqWithConnection + let aborted = false; // several connector will respond with an error when the request is aborted + let requestAborter; // an abort function, returned by connection#request() + let requestTimeoutId; // the id of the ^timeout + let ret; // the object returned to the user, might be a promise + let defer; // the defer object, will be set when we are using promises. + + let body = params.body; + const headers = !params.headers ? {} : _.transform(params.headers, function (headers, val, name) { headers[String(name).toLowerCase()] = val; }); @@ -173,8 +173,8 @@ Transport.prototype.request = function (params, cb) { // serialize the body if (body) { - var serializer = self.serializer; - var serializeFn = serializer[params.bulkBody ? 'bulkBody' : 'serialize']; + const serializer = self.serializer; + const serializeFn = serializer[params.bulkBody ? 'bulkBody' : 'serialize']; body = serializeFn.call(serializer, body); if (!headers['content-type']) { @@ -230,7 +230,7 @@ Transport.prototype.request = function (params, cb) { if (err) { connection.setStatus('dead'); - var errMsg = err.message || ''; + let errMsg = err.message || ''; errMsg = '\n' + @@ -261,8 +261,8 @@ Transport.prototype.request = function (params, cb) { } self._timeout(requestTimeoutId); - var parsedBody; - var isJson = !headers || (headers['content-type'] && ~headers['content-type'].indexOf('application/json')); + let parsedBody; + const isJson = !headers || (headers['content-type'] && ~headers['content-type'].indexOf('application/json')); if (!err && body) { if (isJson) { @@ -283,7 +283,7 @@ Transport.prototype.request = function (params, cb) { && (!params.ignore || !_.include(params.ignore, status)) ) { - var errorMetadata = _.pick(params.req, ['path', 'query', 'body']); + const errorMetadata = _.pick(params.req, ['path', 'query', 'body']); errorMetadata.statusCode = status; errorMetadata.response = body; @@ -356,8 +356,8 @@ Transport.prototype.request = function (params, cb) { Transport.prototype._timeout = function (cb, delay) { if (this.closed) return; - var id; - var timers = this._timers || (this._timers = []); + let id; + const timers = this._timers || (this._timers = []); if ('function' !== typeof cb) { id = cb; @@ -378,7 +378,7 @@ Transport.prototype._timeout = function (cb, delay) { if (id) { clearTimeout(id); - var i = this._timers.indexOf(id); + const i = this._timers.indexOf(id); if (i !== -1) { this._timers.splice(i, 1); } @@ -392,10 +392,10 @@ Transport.prototype._timeout = function (cb, delay) { * @param {Function} cb - Function to call back once complete */ Transport.prototype.sniff = function (cb) { - var self = this; - var nodesToHostCallback = this.nodesToHostCallback; - var log = this.log; - var sniffedNodesProtocol = this.sniffedNodesProtocol; + const self = this; + const nodesToHostCallback = this.nodesToHostCallback; + const log = this.log; + const sniffedNodesProtocol = this.sniffedNodesProtocol; // make cb a function if it isn't cb = typeof cb === 'function' ? cb : _.noop; @@ -414,7 +414,7 @@ Transport.prototype.sniff = function (cb) { method: 'GET' }, function (err, resp, status) { if (!err && resp && resp.nodes) { - var hostsConfigs; + let hostsConfigs; try { hostsConfigs = nodesToHostCallback(resp.nodes); @@ -441,7 +441,7 @@ Transport.prototype.sniff = function (cb) { * that will be used to create Host objects. */ Transport.prototype.setHosts = function (hostsConfigs) { - var globalConfig = this._config; + const globalConfig = this._config; this.connectionPool.setHosts(_.map(hostsConfigs, function (conf) { return (conf instanceof Host) ? conf : new Host(conf, globalConfig); })); diff --git a/src/lib/transport/find_common_protocol.js b/src/lib/transport/find_common_protocol.js index ae1a0f536..9f64c35fc 100644 --- a/src/lib/transport/find_common_protocol.js +++ b/src/lib/transport/find_common_protocol.js @@ -1,14 +1,14 @@ -var isEmpty = require('lodash.isempty'); +const isEmpty = require('lodash.isempty'); module.exports = function (hosts) { if (isEmpty(hosts)) return false; - var commonProtocol = hosts.shift().protocol; - for (var i = 0; i < hosts.length; i++) { + const commonProtocol = hosts.shift().protocol; + for (let i = 0; i < hosts.length; i++) { if (commonProtocol !== hosts[i].protocol) { return false; } } return commonProtocol; -} +}; diff --git a/src/lib/transport/sniff_on_connection_fault.js b/src/lib/transport/sniff_on_connection_fault.js index e7bd8c089..06ce3acdd 100644 --- a/src/lib/transport/sniff_on_connection_fault.js +++ b/src/lib/transport/sniff_on_connection_fault.js @@ -1,4 +1,4 @@ -var _ = require('../utils'); +const _ = require('../utils'); /** @@ -11,9 +11,9 @@ var _ = require('../utils'); * @return {undefined} */ module.exports = function setupSniffOnConnectionFault(transport) { - var failures = 0; - var pool = transport.connectionPool; - var originalOnDied = pool._onConnectionDied; + let failures = 0; + const pool = transport.connectionPool; + const originalOnDied = pool._onConnectionDied; // do the actual sniff, if the sniff is unable to // connect to a node this function will be called again by the connectionPool @@ -24,8 +24,8 @@ module.exports = function setupSniffOnConnectionFault(transport) { // create a function that will count down to a // point n milliseconds into the future - var countdownTo = function (ms) { - var start = _.now(); + const countdownTo = function (ms) { + const start = _.now(); return function () { return start - ms; }; @@ -33,12 +33,12 @@ module.exports = function setupSniffOnConnectionFault(transport) { // overwrite the function, but still call it pool._onConnectionDied = function (connection, wasAlreadyDead) { - var ret = originalOnDied.call(pool, connection, wasAlreadyDead); + const ret = originalOnDied.call(pool, connection, wasAlreadyDead); // clear the failures if this is the first failure we have seen failures = work.timerId ? failures + 1 : 0; - var ms = pool.calcDeadTimeout(failures, 1000); + const ms = pool.calcDeadTimeout(failures, 1000); if (work.timerId && ms < work.timerId && work.countdown()) { // clear the timer diff --git a/src/lib/utils.js b/src/lib/utils.js index 20cd9edbb..e1303a5e4 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -1,6 +1,6 @@ -var path = require('path'); -var nodeUtils = require('util'); -var lodash = require('lodash'); +const path = require('path'); +const nodeUtils = require('util'); +const lodash = require('lodash'); /** * Custom utils library, basically a modified version of [lodash](http://lodash.com/docs) + @@ -10,7 +10,7 @@ var lodash = require('lodash'); * @class utils * @static */ -var _ = lodash.assign({}, lodash, nodeUtils); +const _ = lodash.assign({}, lodash, nodeUtils); /** * Link to [path.join](http://nodejs.org/api/path.html#path_path_join_path1_path2) @@ -67,7 +67,7 @@ _.each([ 'Function', 'RegExp' ], function (type) { - var check = _['is' + type]; + const check = _['is' + type]; _['isArrayOf' + type + 's'] = function (arr) { // quick shallow check of arrays @@ -94,10 +94,10 @@ _.ucfirst = function (word) { */ function adjustWordCase(firstWordCap, otherWordsCap, sep) { return function (string) { - var i = 0; - var words = []; - var word = ''; - var code, c, upper, lower; + let i = 0; + const words = []; + let word = ''; + let code, c, upper, lower; for (; i < string.length; i++) { code = string.charCodeAt(i); @@ -210,7 +210,7 @@ _.isNumeric = function (val) { }; // regexp to test for intervals -var intervalRE = /^(\d+(?:\.\d+)?)(M|w|d|h|m|s|y|ms)$/; +const intervalRE = /^(\d+(?:\.\d+)?)(M|w|d|h|m|s|y|ms)$/; /** * Test if a string represents an interval (eg. 1m, 2Y) @@ -315,7 +315,7 @@ _.scheduled = _.handler; */ _.makeBoundMethods = function (obj) { obj.bound = {}; - for (var prop in obj) { + for (const prop in obj) { // dearest maintainer, we want to look through the prototype if (typeof obj[prop] === 'function' && obj[prop]._provideBound === true) { obj.bound[prop] = _.bind(obj[prop], obj); @@ -332,7 +332,7 @@ _.noop = function () {}; * @return {Function|undefined} - If a valid option was specified, then the constructor is returned */ _.funcEnum = function (config, name, opts, def) { - var val = config[name]; + const val = config[name]; switch (typeof val) { case 'undefined': return opts[def]; @@ -371,9 +371,9 @@ _.funcEnum = function (config, name, opts, def) { */ _.createArray = function (input, transform) { transform = typeof transform === 'function' ? transform : _.identity; - var output = []; - var item; - var i; + const output = []; + let item; + let i; if (!_.isArray(input)) { input = [input]; @@ -399,11 +399,11 @@ _.createArray = function (input, transform) { * @return {string} - the remaining test to be written to the stream */ _.getUnwrittenFromStream = function (stream) { - var writeBuffer = _.getStreamWriteBuffer(stream); + const writeBuffer = _.getStreamWriteBuffer(stream); if (!writeBuffer) return; // flush the write buffer - var out = ''; + let out = ''; if (!writeBuffer.length) return out; _.each(writeBuffer, function (writeReq) { @@ -423,7 +423,7 @@ _.getUnwrittenFromStream = function (stream) { _.getStreamWriteBuffer = function (stream) { if (!stream || !stream._writableState) return; - var writeState = stream._writableState; + const writeState = stream._writableState; if (writeState.getBuffer) { return writeState.getBuffer(); @@ -433,7 +433,7 @@ _.getStreamWriteBuffer = function (stream) { }; _.clearWriteStreamBuffer = function (stream) { - var buffer = _.getStreamWriteBuffer(stream); + const buffer = _.getStreamWriteBuffer(stream); return buffer && buffer.splice(0); }; diff --git a/test/fixtures/keepalive.js b/test/fixtures/keepalive.js index 63c30c9b1..df5f74d31 100644 --- a/test/fixtures/keepalive.js +++ b/test/fixtures/keepalive.js @@ -1,10 +1,10 @@ -var clock = require('sinon').useFakeTimers(); -var Client = require('../../src/elasticsearch').Client; -var _ = require('lodash'); -var times = require('async').times; +const clock = require('sinon').useFakeTimers(); +const Client = require('../../src/elasticsearch').Client; +const _ = require('lodash'); +const times = require('async').times; process.once('message', function (port) { - var es = new Client({ + const es = new Client({ host: 'http://127.0.0.1/' + port, log: false }); @@ -19,8 +19,8 @@ process.once('message', function (port) { }, done); clock.tick(10); }, function (err) { - var conns = es.transport.connectionPool._conns; - var sockets = _([].concat(conns.dead, conns.alive)) + const conns = es.transport.connectionPool._conns; + const sockets = _([].concat(conns.dead, conns.alive)) .transform(function (sockets, conn) { sockets.push(_.values(conn.agent.sockets), _.values(conn.agent.freeSockets)); }, []) @@ -29,7 +29,7 @@ process.once('message', function (port) { es.close(); - var out = { + const out = { socketCount: err || sockets.length, remaining: _.filter(sockets, { destroyed: true }).length - sockets.length, timeouts: _.size(clock.timers) && _.map(clock.timers, 'func').map(String) diff --git a/test/fixtures/keepalive_server.js b/test/fixtures/keepalive_server.js index e0d365878..c55f7b109 100644 --- a/test/fixtures/keepalive_server.js +++ b/test/fixtures/keepalive_server.js @@ -4,13 +4,13 @@ // which prevent sinon from being able to ensure // timeouts aren't being left behind -var express = require('express'); -var app = express().post('/_search', function (req, res) { +const express = require('express'); +const app = express().post('/_search', function (req, res) { res.json(200, { hits: { hits: [] } }); }); -var server = require('http').createServer(app); +const server = require('http').createServer(app); server.listen(function () { - var port = server.address().port; + const port = server.address().port; process.connected ? process.send(port) : console.log(port); }); diff --git a/test/integration/yaml_suite/client_manager.js b/test/integration/yaml_suite/client_manager.js index 372a7b427..02eb7e72e 100644 --- a/test/integration/yaml_suite/client_manager.js +++ b/test/integration/yaml_suite/client_manager.js @@ -1,22 +1,22 @@ -var BROWSER = process.env.browser; -var VERBOSE = process.env.VERBOSE; -var JENKINS = !!process.env.JENKINS_HOME; +const BROWSER = process.env.browser; +const VERBOSE = process.env.VERBOSE; +const JENKINS = !!process.env.JENKINS_HOME; -var es; +let es; if (BROWSER) { es = window.elasticsearch; } else { es = require('../../../src/elasticsearch'); } -var _ = require('../../../src/lib/utils'); -var path = require('path'); -var fs = require('fs'); -var fromRoot = _.bindKey(path, 'join', require('find-root')(__dirname)); -var Bluebird = require('bluebird'); +const _ = require('../../../src/lib/utils'); +const path = require('path'); +const fs = require('fs'); +const fromRoot = _.bindKey(path, 'join', require('find-root')(__dirname)); +const Bluebird = require('bluebird'); // current client -var client = null; +let client = null; module.exports = { create: function create(apiVersion, port, host, cb) { @@ -24,8 +24,8 @@ module.exports = { doCreateClient({ logConfig: null }, function () { - var attemptsRemaining = 60; - var timeout = 500; + let attemptsRemaining = 60; + const timeout = 500; (function ping() { client.info({ @@ -59,7 +59,7 @@ module.exports = { options = {}; } - var logConfig = {}; + let logConfig = {}; if (_.has(options, 'logConfig')) { logConfig = options.logConfig; } else { diff --git a/test/integration/yaml_suite/run.js b/test/integration/yaml_suite/run.js index 9ec43a994..5fcce9e33 100644 --- a/test/integration/yaml_suite/run.js +++ b/test/integration/yaml_suite/run.js @@ -1,18 +1,18 @@ module.exports = function (branch) { - var path = require('path'); - var jsYaml = require('js-yaml'); - var YamlFile = require('./yaml_file'); - var root = require('find-root')(__dirname); - var rootReq = function (loc) { return require(path.join(root, loc)); }; - var _ = rootReq('src/lib/utils'); - var utils = rootReq('grunt/utils'); - var es = rootReq('src/elasticsearch'); - var clientManager = require('./client_manager'); + const path = require('path'); + const jsYaml = require('js-yaml'); + const YamlFile = require('./yaml_file'); + const root = require('find-root')(__dirname); + const rootReq = function (loc) { return require(path.join(root, loc)); }; + const _ = rootReq('src/lib/utils'); + const utils = rootReq('grunt/utils'); + const es = rootReq('src/elasticsearch'); + const clientManager = require('./client_manager'); - var port = parseInt(process.env.ES_PORT || 9200, 10); - var host = process.env.ES_HOST || 'localhost'; - var _release = branch.match(/^v(\d+\.\d+)\.\d+$/); - var apiVersion = _release ? _release[1] : branch; + const port = parseInt(process.env.ES_PORT || 9200, 10); + const host = process.env.ES_HOST || 'localhost'; + const _release = branch.match(/^v(\d+\.\d+)\.\d+$/); + const apiVersion = _release ? _release[1] : branch; console.log(' branch:', branch); console.log(' port:', port); @@ -32,7 +32,7 @@ module.exports = function (branch) { return clientManager.get().clearEs(); }); - var files = _.map(require('./yaml_tests_' + _.snakeCase(branch) + '.json'), function (docs, filename) { + const files = _.map(require('./yaml_tests_' + _.snakeCase(branch) + '.json'), function (docs, filename) { return new YamlFile(filename, docs); }); diff --git a/test/integration/yaml_suite/yaml_doc.js b/test/integration/yaml_suite/yaml_doc.js index cd7911536..237c08f51 100644 --- a/test/integration/yaml_suite/yaml_doc.js +++ b/test/integration/yaml_suite/yaml_doc.js @@ -9,39 +9,39 @@ */ module.exports = YamlDoc; -var _ = require('lodash'); -var expect = require('expect.js'); -var clientManager = require('./client_manager'); -var inspect = require('util').inspect; +const _ = require('lodash'); +const expect = require('expect.js'); +const clientManager = require('./client_manager'); +const inspect = require('util').inspect; -var implementedFeatures = ['gtelte', 'regex', 'benchmark', 'stash_in_path', 'groovy_scripting']; +const implementedFeatures = ['gtelte', 'regex', 'benchmark', 'stash_in_path', 'groovy_scripting']; /** * The version that ES is running, in comparable string form XXX-XXX-XXX, fetched when needed * @type {String} */ -var ES_VERSION = null; +let ES_VERSION = null; // core expression for finding a version -var versionExp = '((?:\\d+\\.){0,2}\\d+)(?:[\\.\\-]\\w+)?|'; +const versionExp = '((?:\\d+\\.){0,2}\\d+)(?:[\\.\\-]\\w+)?|'; // match all whitespace within a "regexp" match arg -var reWhitespaceRE = /\s+/g; +const reWhitespaceRE = /\s+/g; // match all comments within a "regexp" match arg -var reCommentsRE = /([\S\s]?)#[^\n]*\n/g; +const reCommentsRE = /([\S\s]?)#[^\n]*\n/g; /** * Regular Expression to extract a version number from a string * @type {RegExp} */ -var versionRE = new RegExp('^(?:' + versionExp + ')$'); +const versionRE = new RegExp('^(?:' + versionExp + ')$'); /** * Regular Expression to extract a version range from a string * @type {RegExp} */ -var versionRangeRE = new RegExp('^(?:' + versionExp + ')\\s*\\-\\s*(?:' + versionExp + ')$'); +const versionRangeRE = new RegExp('^(?:' + versionExp + ')\\s*\\-\\s*(?:' + versionExp + ')$'); /** * Fetches the client.info, and parses out the version number to a comparable string @@ -70,7 +70,7 @@ function versionToComparableString(version, def) { return def; } - var parts = _.map(version.split('.'), function (part) { + const parts = _.map(version.split('.'), function (part) { part = '' + _.parseInt(part); return (new Array(Math.max(4 - part.length, 0))).join('0') + part; }); @@ -106,7 +106,7 @@ function rangeMatchesCurrentVersion(rangeString, done) { function YamlDoc(doc, file) { - var self = this; + const self = this; self.file = file; self.description = _.keys(doc).shift(); @@ -116,7 +116,7 @@ function YamlDoc(doc, file) { // setup the actions, creating a bound and testable method for each self._actions = _.map(self.flattenTestActions(doc[self.description]), function (action) { // get the method that will do the action - var method = self['do_' + action.name]; + const method = self['do_' + action.name]; // check that it's a function expect(method || 'YamlDoc#' + action.name).to.be.a('function'); @@ -175,14 +175,14 @@ function YamlDoc(doc, file) { YamlDoc.compareRangeToVersion = function (range, version) { expect(range).to.match(versionRangeRE); - var rangeMatch = versionRangeRE.exec(range); + const rangeMatch = versionRangeRE.exec(range); expect(version).to.match(versionRE); - var versionMatch = versionRE.exec(version); + const versionMatch = versionRE.exec(version); - var min = versionToComparableString(rangeMatch[1], -Infinity); - var max = versionToComparableString(rangeMatch[2], Infinity); - var comp = versionToComparableString(versionMatch[1], Infinity); + const min = versionToComparableString(rangeMatch[1], -Infinity); + const max = versionToComparableString(rangeMatch[2], Infinity); + const comp = versionToComparableString(versionMatch[1], Infinity); return (min === -Infinity || min <= comp) && (max === Infinity || max >= comp); }; @@ -199,7 +199,7 @@ YamlDoc.prototype = { flattenTestActions: function (config) { // creates [ [ {name:"", args:"" }, ... ], ... ] // from [ {name:args, name:args}, {name:args} ] - var actionSets = _.map(config, function (set) { + const actionSets = _.map(config, function (set) { return _.map(_.toPairs(set), function (pair) { return { name: pair[0], args: pair[1] }; }); @@ -219,7 +219,7 @@ YamlDoc.prototype = { * @return {undefined} */ each: function (ittr) { - for (var i = 0; i < this._actions.length; i++) { + for (let i = 0; i < this._actions.length; i++) { if (ittr(this._actions[i].testable, this._actions[i].name) === false) { break; } @@ -249,9 +249,9 @@ YamlDoc.prototype = { * @return {*} - The value requested, or undefined if it was not found */ get: function (path, from) { - var self = this; - var log = process.env.LOG_GETS && !from ? console.log.bind(console) : function () {}; - var i; + const self = this; + const log = process.env.LOG_GETS && !from ? console.log.bind(console) : function () {}; + let i; if (path === '$body') { // shortcut, the test just wants the whole body @@ -273,10 +273,10 @@ YamlDoc.prototype = { log('getting', path, 'from', from); - var steps = _.map(path ? path.replace(/\\\./g, '\uffff').split('.') : [], function (step) { + const steps = _.map(path ? path.replace(/\\\./g, '\uffff').split('.') : [], function (step) { return step.replace(/\uffff/g, '.'); }); - var remainingSteps; + let remainingSteps; for (i = 0; from != null && i < steps.length; i++) { if (from[steps[i]] === void 0) { @@ -319,8 +319,8 @@ YamlDoc.prototype = { } if (args.features) { - var features = Array.isArray(args.features) ? args.features : [args.features]; - var notImplemented = _.difference(features, implementedFeatures); + const features = Array.isArray(args.features) ? args.features : [args.features]; + const notImplemented = _.difference(features, implementedFeatures); if (notImplemented.length) { if (this.description === 'setup') { @@ -343,10 +343,10 @@ YamlDoc.prototype = { * @return {[type]} [description] */ do_do: function (args, done) { - var catcher; + let catcher; if (process.env.LOG_DO) { - var __done = done; + const __done = done; done = function (err, resp) { console.log('doing', clientActionName, 'with', params); console.log('got', resp); @@ -388,7 +388,7 @@ YamlDoc.prototype = { delete args.catch; - var inputParams = {}; + const inputParams = {}; // resolve the headers for a request if (args.headers) { @@ -396,25 +396,25 @@ YamlDoc.prototype = { delete args.headers; } - var otherKeys = _.keys(args); - var action = otherKeys.shift(); + const otherKeys = _.keys(args); + const action = otherKeys.shift(); if (otherKeys.length) { return done(new TypeError('Unexpected top-level args to "do": ' + otherKeys.join(', '))); } - var client = clientManager.get(); + const client = clientManager.get(); var clientActionName = _.map(action.split('.'), _.camelCase).join('.'); - var clientAction = this.get(clientActionName, client); + const clientAction = this.get(clientActionName, client); _.assign(inputParams, args[action]); var params = _.transform(inputParams, _.bind(function (params, val, name) { - var camelName = _.camelCase(name); + const camelName = _.camelCase(name); // search through the params and url peices to find this param name - var paramName = name; - var spec = clientAction && clientAction.spec; - var knownParam = spec && spec.params && spec.params[camelName]; - var knownUrlParam = spec && !knownParam && !!_.find(spec.url ? [spec.url] : spec.urls, function (url) { + let paramName = name; + const spec = clientAction && clientAction.spec; + const knownParam = spec && spec.params && spec.params[camelName]; + const knownUrlParam = spec && !knownParam && !!_.find(spec.url ? [spec.url] : spec.urls, function (url) { if ((url.opt && url.opt[camelName]) || (url.req && url.req[camelName])) { return true; } @@ -447,8 +447,8 @@ YamlDoc.prototype = { catcher = null; } - var timeoutId; - var cb = _.bind(function (error, body) { + let timeoutId; + const cb = _.bind(function (error, body) { this._last_requests_response = body; clearTimeout(timeoutId); @@ -473,7 +473,7 @@ YamlDoc.prototype = { done(error); }, this); - var req = clientAction.call(client, params, cb); + const req = clientAction.call(client, params, cb); timeoutId = setTimeout(function () { // request timed out, so we will skip the rest of the tests and continue req.abort(); @@ -507,7 +507,7 @@ YamlDoc.prototype = { * @return {undefined} */ do_is_true: function (path) { - var val = this.get(path); + const val = this.get(path); try { expect(Boolean(val)).to.be(true, 'path: ' + path); } catch (e) { @@ -523,7 +523,7 @@ YamlDoc.prototype = { * @return {undefined} */ do_is_false: function (path) { - var val = this.get(path); + const val = this.get(path); try { expect(Boolean(val)).to.be(false, 'path: ' + path); } catch (e) { @@ -563,7 +563,7 @@ YamlDoc.prototype = { * @return {undefined} */ do_match: function (args) { - var self = this; + const self = this; // recursively replace all $var within args _.forOwn(args, function recurse(val, key, lvl) { @@ -579,10 +579,10 @@ YamlDoc.prototype = { }); _.forOwn(args, _.bind(function (match, path) { - var origMatch = match; + const origMatch = match; - var maybeRE = false; - var usedRE = false; + let maybeRE = false; + let usedRE = false; if (_.isString(match)) { // convert the matcher into a compatible string for building a regexp @@ -599,8 +599,8 @@ YamlDoc.prototype = { // whitespace is represented with \s .replace(reWhitespaceRE, ''); - var startsWithSlash = maybeRE[0] === '/'; - var endsWithSlash = maybeRE[maybeRE.length - 1] === '/'; + const startsWithSlash = maybeRE[0] === '/'; + const endsWithSlash = maybeRE[maybeRE.length - 1] === '/'; if (startsWithSlash && endsWithSlash) { usedRE = true; @@ -608,8 +608,8 @@ YamlDoc.prototype = { } } - var val = this.get(path); - var test = 'eql'; + let val = this.get(path); + let test = 'eql'; if (match instanceof RegExp) { test = 'match'; @@ -622,7 +622,7 @@ YamlDoc.prototype = { try { expect(val).to[test](match); } catch (e) { - var msg = [ + const msg = [ '\nUnable to match', inspect(match), 'with the path', diff --git a/test/integration/yaml_suite/yaml_file.js b/test/integration/yaml_suite/yaml_file.js index b96529fc6..7d2ae83ad 100644 --- a/test/integration/yaml_suite/yaml_file.js +++ b/test/integration/yaml_suite/yaml_file.js @@ -6,13 +6,13 @@ */ module.exports = YamlFile; -var YamlDoc = require('./yaml_doc'); -var clientManager = require('./client_manager'); -var _ = require('../../../src/lib/utils'); -var async = require('async'); +const YamlDoc = require('./yaml_doc'); +const clientManager = require('./client_manager'); +const _ = require('../../../src/lib/utils'); +const async = require('async'); function YamlFile(filename, docs) { - var file = this; + const file = this; // file level skipping flag file.skipping = false; diff --git a/test/mocks/browser_server.js b/test/mocks/browser_server.js index 3d0010519..7e9e66ded 100644 --- a/test/mocks/browser_server.js +++ b/test/mocks/browser_server.js @@ -1,22 +1,22 @@ -var interceptors = []; -var complete = []; -var MockHttpRequest = require('./browser_http'); -var XhrServer = MockHttpRequest.MockHttpServer; -var parseUrl = MockHttpRequest.prototype.parseUri; -var _ = require('lodash'); +const interceptors = []; +const complete = []; +const MockHttpRequest = require('./browser_http'); +const XhrServer = MockHttpRequest.MockHttpServer; +const parseUrl = MockHttpRequest.prototype.parseUri; +const _ = require('lodash'); -var server = new XhrServer(function (request) { - var reqDetails = { +const server = new XhrServer(function (request) { + const reqDetails = { method: request.method, host: request.urlParts.host, path: request.urlParts.relative }; - var response = _.find(interceptors, reqDetails); + const response = _.find(interceptors, reqDetails); if (response) { // remove of tick down the times if (response.times === 1) { - var i = interceptors.indexOf(response); + const i = interceptors.indexOf(response); complete.push(interceptors.splice(i, 1)); } else { response.times--; @@ -31,8 +31,8 @@ var server = new XhrServer(function (request) { server.start(); var mockNock = module.exports = function (url) { - var parsedUrl = parseUrl(url); - var req = { + const parsedUrl = parseUrl(url); + const req = { method: 'GET', host: parsedUrl.host, times: 1 diff --git a/test/mocks/incomming_message.js b/test/mocks/incomming_message.js index ce29326cd..2c218b45a 100644 --- a/test/mocks/incomming_message.js +++ b/test/mocks/incomming_message.js @@ -6,9 +6,9 @@ */ module.exports = MockIncommingMessage; -var sinon = require('sinon'); -var util = require('util'); -var Readable = require('stream').Readable; +const sinon = require('sinon'); +const util = require('util'); +let Readable = require('stream').Readable; if (!Readable) { Readable = require('events').EventEmitter; diff --git a/test/mocks/request.js b/test/mocks/request.js index 01314c6e0..79a8819d2 100644 --- a/test/mocks/request.js +++ b/test/mocks/request.js @@ -5,9 +5,9 @@ */ module.exports = MockRequest; -var sinon = require('sinon'); -var util = require('util'); -var http = require('http'); +const sinon = require('sinon'); +const util = require('util'); +const http = require('http'); function MockRequest() { sinon.stub(this, 'end'); diff --git a/test/mocks/server.js b/test/mocks/server.js index 740fc6fae..89c175a6f 100644 --- a/test/mocks/server.js +++ b/test/mocks/server.js @@ -1,3 +1,3 @@ -var nock = require('nock'); +const nock = require('nock'); nock.disableNetConnect(); module.exports = nock; diff --git a/test/mocks/writable_stream.js b/test/mocks/writable_stream.js index 1907b233c..12f311051 100644 --- a/test/mocks/writable_stream.js +++ b/test/mocks/writable_stream.js @@ -3,9 +3,9 @@ * @type {Constuctor} */ -var util = require('util'); -var MockWritableStream; // defined simply for 0.10+, in detail for older versions -var Writable = require('stream').Writable; +const util = require('util'); +let MockWritableStream; // defined simply for 0.10+, in detail for older versions +const Writable = require('stream').Writable; if (Writable) { @@ -18,7 +18,7 @@ if (Writable) { util.inherits(MockWritableStream, Writable); } else { // Node < 0.10 did not provide a usefull stream abstract - var Stream = require('stream').Stream; + const Stream = require('stream').Stream; module.exports = MockWritableStream = function (opts) { Stream.call(this); this.writable = true; @@ -31,8 +31,8 @@ if (Writable) { return false; } - var cb; - if (typeof(arguments[arguments.length - 1]) === 'function') { + let cb; + if (typeof (arguments[arguments.length - 1]) === 'function') { cb = arguments[arguments.length - 1]; } @@ -42,9 +42,9 @@ if (Writable) { }; MockWritableStream.prototype.end = function (data, encoding, cb) { - if (typeof(data) === 'function') { + if (typeof (data) === 'function') { cb = data; - } else if (typeof(encoding) === 'function') { + } else if (typeof (encoding) === 'function') { cb = encoding; this.write(data); } else if (arguments.length > 0) { @@ -54,7 +54,7 @@ if (Writable) { }; MockWritableStream.prototype.destroy = function (cb) { - var self = this; + const self = this; if (!this.writable) { if (cb) { diff --git a/test/unit/browser_builds/angular.js b/test/unit/browser_builds/angular.js index aa021498b..9f8e84842 100644 --- a/test/unit/browser_builds/angular.js +++ b/test/unit/browser_builds/angular.js @@ -1,23 +1,23 @@ /* global angular */ -var _ = require('lodash'); -var expect = require('expect.js'); -var Promise = require('bluebird'); -var sinon = require('sinon'); +const _ = require('lodash'); +const expect = require('expect.js'); +const Promise = require('bluebird'); +const sinon = require('sinon'); describe('Angular esFactory', function () { before(function () { require('../../../src/elasticsearch.angular.js'); }); - var uuid = (function () { var i = 0; return function () { return ++i; }; }()); - var esFactory; - var $http; - var $rootScope; - var $httpBackend; + const uuid = (function () { let i = 0; return function () { return ++i; }; }()); + let esFactory; + let $http; + let $rootScope; + let $httpBackend; function bootstrap(env) { beforeEach(function () { - var promiseProvider = _.noop; + let promiseProvider = _.noop; if (env.bluebirdPromises) { promiseProvider = function ($provide) { $provide.service('$q', function () { @@ -59,7 +59,7 @@ describe('Angular esFactory', function () { }); it('returns a new client when it is called', function () { - var client = esFactory({ + const client = esFactory({ hosts: null }); @@ -69,10 +69,10 @@ describe('Angular esFactory', function () { }); it('returns an error created by calling a method incorrectly', function () { - var client = esFactory({ hosts: null }); - var err; + const client = esFactory({ hosts: null }); + let err; - var prom = client.get().then(function () { + const prom = client.get().then(function () { throw new Error('expected request to fail'); }, function (err) { expect(err).to.have.property('message'); diff --git a/test/unit/browser_builds/generic.js b/test/unit/browser_builds/generic.js index e523fe7c9..93b82a934 100644 --- a/test/unit/browser_builds/generic.js +++ b/test/unit/browser_builds/generic.js @@ -1,8 +1,8 @@ -var expect = require('expect.js'); -var Transport = require('../../../src/lib/transport'); +const expect = require('expect.js'); +const Transport = require('../../../src/lib/transport'); describe('elasticsearch namespace', function () { - var es = window.elasticsearch; + const es = window.elasticsearch; it('is defined on the window', function () { expect(es).to.be.ok(); }); @@ -12,7 +12,7 @@ describe('elasticsearch namespace', function () { }); it('can create a client', function () { - var client = new es.Client({ hosts: null }); + const client = new es.Client({ hosts: null }); expect(client).to.have.keys('transport'); expect(client.transport).to.be.a(es.Transport); client.close(); diff --git a/test/unit/browser_builds/jquery.js b/test/unit/browser_builds/jquery.js index 11e04ad63..62e246277 100644 --- a/test/unit/browser_builds/jquery.js +++ b/test/unit/browser_builds/jquery.js @@ -1,6 +1,6 @@ /* global $ */ -var expect = require('expect.js'); -var Transport = require('../../../src/lib/transport'); +const expect = require('expect.js'); +const Transport = require('../../../src/lib/transport'); describe('jQuery.es namespace', function () { it('is defined on the global jQuery', function () { @@ -12,7 +12,7 @@ describe('jQuery.es namespace', function () { }); it('can create a client', function () { - var client = new $.es.Client({ hosts: null }); + const client = new $.es.Client({ hosts: null }); expect(client).to.have.keys('transport'); expect(client.transport).to.be.a($.es.Transport); client.close(); diff --git a/test/unit/buffer_flush_tests.js b/test/unit/buffer_flush_tests.js index 4d61a7ed8..285015e57 100644 --- a/test/unit/buffer_flush_tests.js +++ b/test/unit/buffer_flush_tests.js @@ -1,16 +1,16 @@ module.exports = function (makeLogger) { - var expect = require('expect.js'); - var stub = require('../utils/auto_release_stub').make(); - var fs = require('fs'); - var once = require('events').EventEmitter.prototype.once; - var _ = require('lodash'); + const expect = require('expect.js'); + const stub = require('../utils/auto_release_stub').make(); + const fs = require('fs'); + const once = require('events').EventEmitter.prototype.once; + const _ = require('lodash'); describe('buffer flush', function () { if (require('stream').Writable) { it('writes everything in the buffer to console.error', function () { - var line = 'This string is written 10 times to create buffered output\n'; + const line = 'This string is written 10 times to create buffered output\n'; - var exitHandler; + let exitHandler; stub(process, 'once', function (event, handler) { if (event === 'exit') { exitHandler = handler; @@ -18,7 +18,7 @@ module.exports = function (makeLogger) { once.call(process, event, handler); }); - var logger = makeLogger(); + const logger = makeLogger(); // write the line 10 times _.times(10, function () { @@ -26,7 +26,7 @@ module.exports = function (makeLogger) { }); // collect everything that is written to fs.appendFileSync - var flushedOutput = ''; + let flushedOutput = ''; stub(fs, 'appendFileSync', function (path, str) { flushedOutput += str; }); @@ -40,7 +40,7 @@ module.exports = function (makeLogger) { }); } else { it('does not fall apart with non streams2 streams', function () { - var exitHandler; + let exitHandler; stub(process, 'once', function (event, handler) { if (event === 'exit') { exitHandler = handler; @@ -48,7 +48,7 @@ module.exports = function (makeLogger) { once.call(process, event, handler); }); - var logger = makeLogger(); + const logger = makeLogger(); expect(function () { // call the event handler diff --git a/test/unit/coverage.js b/test/unit/coverage.js index a59557d9d..dde3445ed 100644 --- a/test/unit/coverage.js +++ b/test/unit/coverage.js @@ -1,4 +1,4 @@ -var blanket = require('blanket')({ +const blanket = require('blanket')({ pattern: require('path').join(__dirname, '../../src') }); diff --git a/test/unit/generic_logger_tests.js b/test/unit/generic_logger_tests.js index 42f788ceb..e92452bd1 100644 --- a/test/unit/generic_logger_tests.js +++ b/test/unit/generic_logger_tests.js @@ -1,13 +1,13 @@ -var expect = require('expect.js'); -var Log = require('../../src/lib/log'); -var LoggerAbstract = require('../../src/lib/logger'); -var TracerLogger = require('../../src/lib/loggers/tracer'); -var now = new Date('2013-03-01T00:00:00Z'); -var sinon = require('sinon'); +const expect = require('expect.js'); +const Log = require('../../src/lib/log'); +const LoggerAbstract = require('../../src/lib/logger'); +const TracerLogger = require('../../src/lib/loggers/tracer'); +const now = new Date('2013-03-01T00:00:00Z'); +const sinon = require('sinon'); module.exports = function (makeLogger) { - var stub = require('../utils/auto_release_stub').make(); - var parent = new Log(); + const stub = require('../utils/auto_release_stub').make(); + const parent = new Log(); afterEach(function () { parent.close(); @@ -15,7 +15,7 @@ module.exports = function (makeLogger) { describe('Constuctor', function () { it('calls setupListeners, passes its new levels', function () { - var logger = makeLogger(parent); + let logger = makeLogger(parent); stub(logger.constructor.prototype, 'setupListeners'); parent.close(); @@ -24,21 +24,21 @@ module.exports = function (makeLogger) { }); it('listens for the loggers\' "closing" event', function () { - var logger = makeLogger(parent); + const logger = makeLogger(parent); expect(parent.listenerCount('closing')).to.eql(1); }); }); describe('listening levels', function () { it('calls cleanUpListeners when the listeners are being setup', function () { - var logger = makeLogger(); + const logger = makeLogger(); stub(logger, 'cleanUpListeners'); logger.setupListeners([]); expect(logger.cleanUpListeners).to.have.property('callCount', 1); }); it('listens to just error when log is explicitly error', function () { - var logger = makeLogger(parent, 'error'); + const logger = makeLogger(parent, 'error'); expect(parent.listenerCount('error')).to.eql(1); expect(parent.listenerCount('warning')).to.eql(0); expect(parent.listenerCount('info')).to.eql(0); @@ -47,7 +47,7 @@ module.exports = function (makeLogger) { }); it('listens for all the events when level is "trace"', function () { - var logger = makeLogger(parent, 'trace'); + const logger = makeLogger(parent, 'trace'); expect(parent.listenerCount('error')).to.eql(1); expect(parent.listenerCount('warning')).to.eql(1); expect(parent.listenerCount('info')).to.eql(1); @@ -56,7 +56,7 @@ module.exports = function (makeLogger) { }); it('listens for specific events when level is an array', function () { - var logger = makeLogger(parent, ['error', 'trace']); + const logger = makeLogger(parent, ['error', 'trace']); expect(parent.listenerCount('error')).to.eql(1); expect(parent.listenerCount('warning')).to.eql(0); expect(parent.listenerCount('info')).to.eql(0); @@ -65,8 +65,8 @@ module.exports = function (makeLogger) { }); it('sets the logLevel property to the new levels', function () { - var logger = makeLogger(); - var levels = ['error']; + const logger = makeLogger(); + let levels = ['error']; logger.setupListeners(levels); expect(logger.listeningLevels).to.eql(levels).and.not.be(levels); @@ -80,14 +80,14 @@ module.exports = function (makeLogger) { }); it('rejects listening levels it can not listen to', function () { - var logger = makeLogger(); + const logger = makeLogger(); expect(function () { logger.setupListeners(['scream']); }).to.throwError(/unable to listen/i); }); it('emits events because something is listening', function () { - var logger = makeLogger(parent, 'trace'); + const logger = makeLogger(parent, 'trace'); stub(parent, 'emit'); parent.error(new Error('error message')); @@ -110,7 +110,7 @@ module.exports = function (makeLogger) { describe('#timestamp', function () { it('returns in the right format', function () { stub.autoRelease(sinon.useFakeTimers(now.getTime())); - var logger = makeLogger(); + const logger = makeLogger(); expect(logger.timestamp()).to.eql('2013-03-01T00:00:00Z'); }); }); @@ -118,7 +118,7 @@ module.exports = function (makeLogger) { describe('#format', function () { it('returns a single string with the message indented', function () { stub.autoRelease(sinon.useFakeTimers(now.getTime())); - var logger = makeLogger(); + const logger = makeLogger(); expect(logger.format('LABEL', 'MSG')).to.eql( 'LABEL: 2013-03-01T00:00:00Z\n' + ' MSG\n' + @@ -128,7 +128,7 @@ module.exports = function (makeLogger) { it('properly indents multi-line messages', function () { stub.autoRelease(sinon.useFakeTimers(now.getTime())); - var logger = makeLogger(); + const logger = makeLogger(); expect(logger.format('LABEL', 'MSG\nwith\nseveral lines')).to.eql( 'LABEL: 2013-03-01T00:00:00Z\n' + ' MSG\n' + @@ -141,7 +141,7 @@ module.exports = function (makeLogger) { describe('#onError', function () { it('uses the Error name when it is not just "Error"', function () { - var logger = makeLogger(); + const logger = makeLogger(); stub(logger, 'write', function (label, msg) { expect(label).to.eql('TypeError'); }); @@ -151,7 +151,7 @@ module.exports = function (makeLogger) { }); it('uses "ERROR" when the error name is "Error"', function () { - var logger = makeLogger(); + const logger = makeLogger(); stub(logger, 'write', function (label, msg) { expect(label).to.eql('ERROR'); }); @@ -163,7 +163,7 @@ module.exports = function (makeLogger) { describe('#onWarning', function () { it('uses the "WARNING" label', function () { - var logger = makeLogger(); + const logger = makeLogger(); stub(logger, 'write', function (label, msg) { expect(label).to.eql('WARNING'); }); @@ -172,7 +172,7 @@ module.exports = function (makeLogger) { }); it('echos the message', function () { - var logger = makeLogger(); + const logger = makeLogger(); stub(logger, 'write', function (label, msg) { expect(msg).to.eql('message'); }); @@ -184,7 +184,7 @@ module.exports = function (makeLogger) { describe('#onInfo', function () { it('uses the "INFO" label', function () { - var logger = makeLogger(); + const logger = makeLogger(); stub(logger, 'write', function (label, msg) { expect(label).to.eql('INFO'); }); @@ -193,7 +193,7 @@ module.exports = function (makeLogger) { }); it('echos the message', function () { - var logger = makeLogger(); + const logger = makeLogger(); stub(logger, 'write', function (label, msg) { expect(msg).to.eql('message'); }); @@ -205,7 +205,7 @@ module.exports = function (makeLogger) { describe('#onDebug', function () { it('uses the "DEBUG" label', function () { - var logger = makeLogger(); + const logger = makeLogger(); stub(logger, 'write', function (label, msg) { expect(label).to.eql('DEBUG'); }); @@ -214,7 +214,7 @@ module.exports = function (makeLogger) { }); it('echos the message', function () { - var logger = makeLogger(); + const logger = makeLogger(); stub(logger, 'write', function (label, msg) { expect(msg).to.eql('message'); }); @@ -226,7 +226,7 @@ module.exports = function (makeLogger) { describe('#onTrace', function () { it('uses the "TRACE" label', function () { - var logger = makeLogger(); + const logger = makeLogger(); stub(logger, 'write', function (label, msg) { expect(label).to.eql('TRACE'); }); diff --git a/test/unit/index.js b/test/unit/index.js index ed696a9c4..53d4e162a 100644 --- a/test/unit/index.js +++ b/test/unit/index.js @@ -1,6 +1,6 @@ require('bluebird').longStackTraces(); -var specDir = __dirname + '/specs'; +const specDir = __dirname + '/specs'; require('fs').readdirSync(specDir).forEach(function (file) { require(specDir + '/' + file); }); diff --git a/test/unit/specs/abstract_logger.js b/test/unit/specs/abstract_logger.js index 577c0fc9f..e64217d35 100644 --- a/test/unit/specs/abstract_logger.js +++ b/test/unit/specs/abstract_logger.js @@ -1,11 +1,11 @@ describe('Logger Abstract', function () { - var expect = require('expect.js'); - var sinon = require('sinon'); - var Log = require('../../../src/lib/log'); - var LoggerAbstract = require('../../../src/lib/logger'); + const expect = require('expect.js'); + const sinon = require('sinon'); + const Log = require('../../../src/lib/log'); + const LoggerAbstract = require('../../../src/lib/logger'); - var parentLog; - var stub = require('../../utils/auto_release_stub').make(); + let parentLog; + const stub = require('../../utils/auto_release_stub').make(); function makeLogger(parent, levels) { return new LoggerAbstract(parent || parentLog, { @@ -24,7 +24,7 @@ describe('Logger Abstract', function () { describe('#write', function () { it('requires that it is overwritten', function () { expect(function () { - var logger = makeLogger(); + const logger = makeLogger(); logger.write(); }).to.throwError(/overwritten/); }); diff --git a/test/unit/specs/client.js b/test/unit/specs/client.js index 0be3338f5..6d42b48cc 100644 --- a/test/unit/specs/client.js +++ b/test/unit/specs/client.js @@ -1,12 +1,12 @@ describe('Client instances creation', function () { - var stream = require('stream'); - var util = require('util'); + const stream = require('stream'); + const util = require('util'); - var es = require('../../../src/elasticsearch'); - var apis = require('../../../src/lib/apis'); - var expect = require('expect.js'); - var stub = require('../../utils/auto_release_stub').make(); - var client; + const es = require('../../../src/elasticsearch'); + const apis = require('../../../src/lib/apis'); + const expect = require('expect.js'); + const stub = require('../../utils/auto_release_stub').make(); + let client; describe('', function () { beforeEach(function () { @@ -18,16 +18,16 @@ describe('Client instances creation', function () { }); it('throws an error linking to the es module when you try to instanciate the exports', function () { - var Es = es; + const Es = es; expect(function () { - var c = new Es(); - return c + const c = new Es(); + return c; }).to.throwError(/previous "elasticsearch" module/); }); - var pkg = require('../../../package.json'); - var def = pkg.config.default_api_branch; - var prev = pkg.config.supported_es_branches[pkg.config.supported_es_branches.indexOf(def) + 1]; + const pkg = require('../../../package.json'); + const def = pkg.config.default_api_branch; + const prev = pkg.config.supported_es_branches[pkg.config.supported_es_branches.indexOf(def) + 1]; it('inherits the ' + def + ' API by default', function () { expect(client.bulk).to.be(apis[def].bulk); @@ -44,7 +44,7 @@ describe('Client instances creation', function () { }); it('closing the client causes it\'s transport to be closed', function () { - var called = false; + let called = false; client.transport.close = function () { called = true; }; @@ -72,7 +72,7 @@ describe('Client instances creation', function () { done(); }; - var client = new es.Client({ + const client = new es.Client({ log: [ { type: 'stream', stream: new NullStream() } ] diff --git a/test/unit/specs/client_action.js b/test/unit/specs/client_action.js index 1b755ee16..57f7e7be1 100644 --- a/test/unit/specs/client_action.js +++ b/test/unit/specs/client_action.js @@ -1,8 +1,8 @@ -var ca = require('../../../src/lib/client_action').factory; -var proxy = require('../../../src/lib/client_action').proxyFactory; -var expect = require('expect.js'); -var _ = require('lodash'); -var Promise = require('bluebird'); +const ca = require('../../../src/lib/client_action').factory; +const proxy = require('../../../src/lib/client_action').proxyFactory; +const expect = require('expect.js'); +const _ = require('lodash'); +const Promise = require('bluebird'); /** * Creates a simple mock of the client, whose "transport" has a request @@ -60,13 +60,13 @@ function makeClientActionProxy(fn, spec) { describe('Client Action runner', function () { - var action; + let action; // used to check that params are not clobbered - var params = (function () { - var _stash = {}; + const params = (function () { + let _stash = {}; afterEach(function () { _stash = {}; }); - var make = function (params) { + const make = function (params) { _stash.orig = params; _stash.copy = _.clone(params); return params; @@ -92,7 +92,7 @@ describe('Client Action runner', function () { describe('clientAction::proxy', function () { it('proxies to the passed function', function () { - var action = makeClientActionProxy(function (params, cb) { + const action = makeClientActionProxy(function (params, cb) { throw new Error('proxy function called'); }); @@ -102,8 +102,8 @@ describe('Client Action runner', function () { }); it('provides the proper context', function (done) { - var client; - var action = makeClientActionProxy(function (params, cb) { + let client; + const action = makeClientActionProxy(function (params, cb) { client = this; process.nextTick(function () { cb(void 0, params); @@ -117,7 +117,7 @@ describe('Client Action runner', function () { }); it('handles passing just the callback', function () { - var action = makeClientActionProxy(function (params, cb) { + const action = makeClientActionProxy(function (params, cb) { expect(_.isObject(params)).to.be.ok(); expect(cb).to.be.a('function'); }); @@ -126,7 +126,7 @@ describe('Client Action runner', function () { }); it('supports a param transformation function', function () { - var action = makeClientActionProxy(function (params, cb) { + const action = makeClientActionProxy(function (params, cb) { expect(params).to.have.property('transformed'); }, { transform: function (params) { @@ -138,8 +138,8 @@ describe('Client Action runner', function () { }); it('returns the proxied function\'s return value', function () { - var football = {}; - var action = makeClientActionProxy(function (params, cb) { + const football = {}; + const action = makeClientActionProxy(function (params, cb) { return football; }); @@ -537,7 +537,7 @@ describe('Client Action runner', function () { }); it('accepts numbers, strings, and dates', function (done) { - var now = new Date(); + const now = new Date(); action({ one: '42', @@ -587,7 +587,7 @@ describe('Client Action runner', function () { describe('passing of control params from spec', function () { it('passes bulkBody', function (done) { - var action = makeClientAction({ + const action = makeClientAction({ bulkBody: true }); @@ -598,7 +598,7 @@ describe('Client Action runner', function () { }); it('sets castExists when the method in the spec is HEAD', function (done) { - var action = makeClientAction({ + const action = makeClientAction({ method: 'HEAD' }); @@ -610,12 +610,12 @@ describe('Client Action runner', function () { }); describe('body handling', function () { - var action = makeClientAction({ + const action = makeClientAction({ needsBody: true }); it('passed the body when it is set', function (done) { - var body = '{"JSON":"PLEASE"}'; + const body = '{"JSON":"PLEASE"}'; action({ body: body }, function (err, params) { expect(params.body).to.be(body); @@ -635,7 +635,7 @@ describe('Client Action runner', function () { describe('passing of http method', function () { it('uppercases and passed the default method', function (done) { - var action = makeClientAction({ + const action = makeClientAction({ method: 'POST' }); @@ -646,7 +646,7 @@ describe('Client Action runner', function () { }); it('uppercases and passed the default method', function (done) { - var action = makeClientAction({ + const action = makeClientAction({ method: 'POST' }); @@ -659,7 +659,7 @@ describe('Client Action runner', function () { describe('passing of ignore param', function () { it('passes ignore as an array', function (done) { - var action = makeClientAction({}); + const action = makeClientAction({}); action({ ignore: 404 }, function (err, params) { expect(params.ignore).to.eql([404]); done(); @@ -669,7 +669,7 @@ describe('Client Action runner', function () { describe('passing requestTimeout', function () { it('passes passes the spec value by default', function (done) { - var action = makeClientAction({ + const action = makeClientAction({ requestTimeout: 100 }); @@ -680,7 +680,7 @@ describe('Client Action runner', function () { }); it('passes the provided value', function (done) { - var action = makeClientAction({ + const action = makeClientAction({ requestTimeout: 100 }); @@ -691,7 +691,7 @@ describe('Client Action runner', function () { }); it('passes nothing be default', function (done) { - var action = makeClientAction({}); + const action = makeClientAction({}); action({}, function (err, params) { expect(params.requestTimeout).be(void 0); @@ -702,7 +702,7 @@ describe('Client Action runner', function () { describe('url resolver', function () { - var action = makeClientAction({ + const action = makeClientAction({ urls: [ { fmt: '/<%=index%>/<%=type%>/<%=id%>/<%=thing%>', @@ -767,7 +767,7 @@ describe('Client Action runner', function () { }); describe('param collection', function () { - var action = makeClientAction({ + const action = makeClientAction({ params: { a: { type: 'list', required: true }, b: { type: 'duration', 'default': '15m' }, @@ -853,7 +853,7 @@ describe('Client Action runner', function () { }); it('does not modify the incoming params object', function () { - var action = makeClientAction({ + const action = makeClientAction({ url: { req: { index: { type: 'string' } diff --git a/test/unit/specs/connection_abstract.js b/test/unit/specs/connection_abstract.js index f9b67ff33..87dfe3801 100644 --- a/test/unit/specs/connection_abstract.js +++ b/test/unit/specs/connection_abstract.js @@ -1,42 +1,42 @@ -var ConnectionAbstract = require('../../../src/lib/connection'); -var Host = require('../../../src/lib/host'); -var sinon = require('sinon'); -var expect = require('expect.js'); -var _ = require('lodash'); -var errors = require('../../../src/lib/errors'); +const ConnectionAbstract = require('../../../src/lib/connection'); +const Host = require('../../../src/lib/host'); +const sinon = require('sinon'); +const expect = require('expect.js'); +const _ = require('lodash'); +const errors = require('../../../src/lib/errors'); -var stub = require('../../utils/auto_release_stub').make(); +const stub = require('../../utils/auto_release_stub').make(); describe('Connection Abstract', function () { - var host = new Host('localhost:9200'); + const host = new Host('localhost:9200'); it('constructs with defaults for host, and bound', function () { - var conn = new ConnectionAbstract(host); + const conn = new ConnectionAbstract(host); expect(conn.host).to.be(host); }); it('requires a valid host', function () { expect(function () { - var conn = new ConnectionAbstract(); + const conn = new ConnectionAbstract(); }).to.throwError(TypeError); expect(function () { - var conn = new ConnectionAbstract({}); + const conn = new ConnectionAbstract({}); }).to.throwError(TypeError); }); it('required that the request method is overridden', function () { expect(function () { - var conn = new ConnectionAbstract(host); + const conn = new ConnectionAbstract(host); conn.request(); }).to.throwError(/overwrit/); }); describe('#ping', function () { it('accpets just a callback', function () { - var conn = new ConnectionAbstract(host); + const conn = new ConnectionAbstract(host); stub(conn, 'request'); - var cb = function () {}; + const cb = function () {}; conn.ping(cb); expect(conn.request.callCount).to.eql(1); expect(conn.request.lastCall.args[0]).to.be.a('object'); @@ -44,7 +44,7 @@ describe('Connection Abstract', function () { }); it('accpets just params', function () { - var conn = new ConnectionAbstract(host); + const conn = new ConnectionAbstract(host); stub(conn, 'request'); conn.ping({}); expect(conn.request.callCount).to.eql(1); @@ -53,9 +53,9 @@ describe('Connection Abstract', function () { }); it('allows overriding the requestTimeout, method, and path', function () { - var conn = new ConnectionAbstract(host); + const conn = new ConnectionAbstract(host); stub(conn, 'request'); - var params = { + const params = { method: 'HEAD', path: '/', requestTimeout: 10000 @@ -67,8 +67,8 @@ describe('Connection Abstract', function () { }); it('defaults to the pingTimeout in the config', function () { - var conn = new ConnectionAbstract(host, { pingTimeout: 5000 }); - var clock = sinon.useFakeTimers('setTimeout', 'clearTimeout'); + const conn = new ConnectionAbstract(host, { pingTimeout: 5000 }); + const clock = sinon.useFakeTimers('setTimeout', 'clearTimeout'); stub.autoRelease(clock); stub(conn, 'request'); @@ -80,17 +80,17 @@ describe('Connection Abstract', function () { }); it('calls it\'s own request method', function () { - var conn = new ConnectionAbstract(host); + const conn = new ConnectionAbstract(host); stub(conn, 'request'); conn.ping(); expect(conn.request.callCount).to.eql(1); }); it('sets a timer for the request', function (done) { - var conn = new ConnectionAbstract(host); - var clock = sinon.useFakeTimers('setTimeout', 'clearTimeout'); + const conn = new ConnectionAbstract(host); + const clock = sinon.useFakeTimers('setTimeout', 'clearTimeout'); stub.autoRelease(clock); - var order = 0; + let order = 0; stub(conn, 'request', function (params, cb) { setTimeout(function () { @@ -113,10 +113,10 @@ describe('Connection Abstract', function () { }); }); it('calls the requestAborter if req takes too long', function (done) { - var conn = new ConnectionAbstract(host); - var clock = sinon.useFakeTimers('setTimeout', 'clearTimeout'); + const conn = new ConnectionAbstract(host); + const clock = sinon.useFakeTimers('setTimeout', 'clearTimeout'); stub.autoRelease(clock); - var order = 0; + let order = 0; stub(conn, 'request', function (params, cb) { setTimeout(function () { @@ -148,8 +148,8 @@ describe('Connection Abstract', function () { describe('#setStatus', function () { it('emits the "status set" event with `new`, `old` & `conn` args', function () { - var conn = new ConnectionAbstract(host); - var emitted = false; + const conn = new ConnectionAbstract(host); + let emitted = false; conn.emit = function (eventName) { emitted = { @@ -164,7 +164,7 @@ describe('Connection Abstract', function () { }); it('stores the status in this.status', function () { - var conn = new ConnectionAbstract(host); + const conn = new ConnectionAbstract(host); conn.setStatus('closed'); expect(conn.status).to.eql('closed'); diff --git a/test/unit/specs/connection_pool.js b/test/unit/specs/connection_pool.js index 0b4c8b5c3..fe8e6f4f9 100644 --- a/test/unit/specs/connection_pool.js +++ b/test/unit/specs/connection_pool.js @@ -1,11 +1,11 @@ -var ConnectionPool = require('../../../src/lib/connection_pool'); -var Host = require('../../../src/lib/host'); -var ConnectionAbstract = require('../../../src/lib/connection'); -var _ = require('lodash'); -var EventEmitter = require('events').EventEmitter; -var expect = require('expect.js'); -var sinon = require('sinon'); -var stub = require('../../utils/auto_release_stub').make(); +const ConnectionPool = require('../../../src/lib/connection_pool'); +const Host = require('../../../src/lib/host'); +const ConnectionAbstract = require('../../../src/lib/connection'); +const _ = require('lodash'); +const EventEmitter = require('events').EventEmitter; +const expect = require('expect.js'); +const sinon = require('sinon'); +const stub = require('../../utils/auto_release_stub').make(); function listenerCount(emitter, event) { if (EventEmitter.listenerCount) { @@ -19,7 +19,7 @@ function listenerCount(emitter, event) { describe('Connection Pool', function () { describe('Adding/Removing/Syncing Connections', function () { - var pool, host, connection, host2, connection2; + let pool, host, connection, host2, connection2; beforeEach(function () { pool = new ConnectionPool({}); @@ -93,7 +93,7 @@ describe('Connection Pool', function () { }); describe('Connection selection', function () { - var pool, host, host2; + let pool, host, host2; beforeEach(function () { pool = new ConnectionPool({}); @@ -135,7 +135,7 @@ describe('Connection Pool', function () { return list[0]; }; - var selected = null; + let selected = null; pool.select(function (err, selection) { if (err) { throw err; } @@ -163,20 +163,20 @@ describe('Connection Pool', function () { describe('Connection selection with no living nodes', function () { it('should ping all of the dead nodes, in order of oldest timeout, and return the first that\'s okay', function (done) { - var clock = sinon.useFakeTimers('setTimeout', 'clearTimeout'); + const clock = sinon.useFakeTimers('setTimeout', 'clearTimeout'); stub.autoRelease(clock); - var pool = new ConnectionPool({ + const pool = new ConnectionPool({ deadTimeout: 10000 }); - var connections = [ + const connections = [ new ConnectionAbstract(new Host('http://localhost:9200/')), new ConnectionAbstract(new Host('http://localhost:9201/')), new ConnectionAbstract(new Host('http://localhost:9202/')), new ConnectionAbstract(new Host('http://localhost:9203/')) ]; - var pingQueue = _.shuffle(connections); - var expectedSelection = pingQueue[pingQueue.length - 1]; + const pingQueue = _.shuffle(connections); + const expectedSelection = pingQueue[pingQueue.length - 1]; _.each(pingQueue, function (conn) { pool.addConnection(conn); @@ -184,7 +184,7 @@ describe('Connection Pool', function () { if (typeof params === 'function') { cb = params; } - var expectedConn = pingQueue.shift(); + const expectedConn = pingQueue.shift(); expect(conn).to.be(expectedConn); if (pingQueue.length) { process.nextTick(function () { @@ -211,7 +211,7 @@ describe('Connection Pool', function () { }); describe('Connection state management', function () { - var pool, host, host2, connection, connection2; + let pool, host, host2, connection, connection2; beforeEach(function () { pool = new ConnectionPool({}); @@ -243,12 +243,12 @@ describe('Connection Pool', function () { }); it('clears and resets the timeout when a connection redies', function () { - var clock = sinon.useFakeTimers(); + const clock = sinon.useFakeTimers(); stub.autoRelease(clock); connection.setStatus('dead'); expect(_.size(clock.timers)).to.eql(1); - var id = _(clock.timers).keys().first(); + const id = _(clock.timers).keys().first(); // it re-dies connection.setStatus('dead'); @@ -257,8 +257,8 @@ describe('Connection Pool', function () { }); it('does nothing when a connection is re-alive', function () { - var last = pool._conns.alive[pool._conns.alive.length - 1]; - var first = pool._conns.alive[0]; + const last = pool._conns.alive[pool._conns.alive.length - 1]; + const first = pool._conns.alive[0]; expect(last).to.not.be(first); @@ -286,17 +286,17 @@ describe('Connection Pool', function () { describe('#getConnections', function () { it('will return all values from the alive list by default', function () { - var pool = new ConnectionPool({}); + const pool = new ConnectionPool({}); pool._conns.alive = new Array(1000); - var length = pool._conns.alive.length; + let length = pool._conns.alive.length; while (length--) { pool._conns.alive[length] = length; } - var result = pool.getConnections(); + const result = pool.getConnections(); expect(result.length).to.be(1000); expect(_.reduce(result, function (sum, num) { - sum += num + sum += num; return sum; }, 0)).to.eql(499500); }); @@ -304,14 +304,14 @@ describe('Connection Pool', function () { describe('#calcDeadTimeout', function () { it('should be configurable via config.calcDeadTimeout', function () { - var pool = new ConnectionPool({ + const pool = new ConnectionPool({ calcDeadTimeout: 'flat' }); expect(pool.calcDeadTimeout).to.be(ConnectionPool.calcDeadTimeoutOptions.flat); pool.close(); }); it('"flat" always returns the base timeout', function () { - var pool = new ConnectionPool({ + const pool = new ConnectionPool({ calcDeadTimeout: 'flat' }); expect(pool.calcDeadTimeout(0, 1000)).to.eql(1000); @@ -319,7 +319,7 @@ describe('Connection Pool', function () { expect(pool.calcDeadTimeout(25, 10000)).to.eql(10000); }); it('"exponential" always increases the timeout based on the attempts', function () { - var pool = new ConnectionPool({ + const pool = new ConnectionPool({ calcDeadTimeout: 'exponential' }); expect(pool.calcDeadTimeout(0, 1000)).to.eql(1000); @@ -327,7 +327,7 @@ describe('Connection Pool', function () { expect(pool.calcDeadTimeout(25, 10000)).to.be.greaterThan(10000); }); it('"exponential" produces predicatable results', function () { - var pool = new ConnectionPool({ + const pool = new ConnectionPool({ calcDeadTimeout: 'exponential' }); expect(pool.calcDeadTimeout(0, 1000)).to.eql(1000); @@ -336,7 +336,7 @@ describe('Connection Pool', function () { expect(pool.calcDeadTimeout(25, 30000)).to.eql(18e5); }); it('"exponential" repects config.maxDeadtimeout', function () { - var pool = new ConnectionPool({ + const pool = new ConnectionPool({ calcDeadTimeout: 'exponential', maxDeadTimeout: 10000 }); diff --git a/test/unit/specs/console_logger.js b/test/unit/specs/console_logger.js index f7bacbeb0..2e38e6954 100644 --- a/test/unit/specs/console_logger.js +++ b/test/unit/specs/console_logger.js @@ -1,8 +1,8 @@ -var Log = require('../../../src/lib/log'); -var ConsoleLogger = require('../../../src/lib/loggers/console'); -var sinon = require('sinon'); -var expect = require('expect.js'); -var parentLog; +const Log = require('../../../src/lib/log'); +const ConsoleLogger = require('../../../src/lib/loggers/console'); +const sinon = require('sinon'); +const expect = require('expect.js'); +let parentLog; beforeEach(function () { parentLog = new Log(); @@ -14,24 +14,24 @@ afterEach(function () { function makeLogger(parent, levels) { parent = parent || parentLog; - var config = { + const config = { levels: Log.parseLevels(levels || 'trace') }; return new ConsoleLogger(parent, config); } -var stub = require('../../utils/auto_release_stub').make(); +const stub = require('../../utils/auto_release_stub').make(); describe('Console Logger', function () { require('../generic_logger_tests')(makeLogger); it('checks before using unique logging functions, falls back to #log()', function () { - var _warning = console.warn; + const _warning = console.warn; console.warn = null; sinon.stub(console, 'log'); - var logger = makeLogger(); + const logger = makeLogger(); logger.onWarning('message'); expect(console.log.callCount).to.be(1); diff --git a/test/unit/specs/errors.js b/test/unit/specs/errors.js index fb885c0e3..2a3b782e4 100644 --- a/test/unit/specs/errors.js +++ b/test/unit/specs/errors.js @@ -1,12 +1,12 @@ -var errors = require('../../../src/lib/errors'); -var expect = require('expect.js'); -var _ = require('lodash'); +const errors = require('../../../src/lib/errors'); +const expect = require('expect.js'); +const _ = require('lodash'); _.each(errors, function (CustomError, name) { if (name.charAt(0) !== '_') { describe(name, function () { it('extend the ErrorAbstract and Error classes', function () { - var err = new CustomError(); + const err = new CustomError(); expect(err).to.be.an(Error); expect(err).to.be.an(errors._Abstract); }); @@ -16,9 +16,9 @@ _.each(errors, function (CustomError, name) { describe('Error Abstract', function () { it('provides a stack property in the browser', function () { - var isBrowser = process.browser; + const isBrowser = process.browser; process.browser = true; - var err = new errors._Abstract(); + const err = new errors._Abstract(); process.browser = isBrowser; expect(err.stack).to.be.a('string'); @@ -27,7 +27,7 @@ describe('Error Abstract', function () { describe('StatusCodeError', function () { it('exposes status code as a number', function () { - var err = new errors['404'](); + const err = new errors['404'](); expect(err.status).to.be(404); expect(err.status).to.not.be('404'); }); diff --git a/test/unit/specs/file_logger.js b/test/unit/specs/file_logger.js index 4766cae6b..a4d6835ee 100644 --- a/test/unit/specs/file_logger.js +++ b/test/unit/specs/file_logger.js @@ -1,13 +1,13 @@ describe('File Logger', function () { - var Log = require('../../../src/lib/log'); - var FileLogger = require('../../../src/lib/loggers/file'); - var once = require('events').EventEmitter.prototype.once; - var _ = require('../../../src/lib/utils'); - var parentLog; - var logger; - var expect = require('expect.js'); - var fs = require('fs'); - var stub = require('../../utils/auto_release_stub').make(); + const Log = require('../../../src/lib/log'); + const FileLogger = require('../../../src/lib/loggers/file'); + const once = require('events').EventEmitter.prototype.once; + const _ = require('../../../src/lib/utils'); + let parentLog; + let logger; + const expect = require('expect.js'); + const fs = require('fs'); + const stub = require('../../utils/auto_release_stub').make(); beforeEach(function () { parentLog = new Log(); @@ -36,9 +36,9 @@ describe('File Logger', function () { describe('buffer flush', function () { if (require('stream').Writable) { it('writes everything in the buffer to console.error', function () { - var line = 'This string is written 10 times to create buffered output\n'; + const line = 'This string is written 10 times to create buffered output\n'; - var exitHandler; + let exitHandler; stub(process, 'once', function (event, handler) { if (event === 'exit') { exitHandler = handler; @@ -46,7 +46,7 @@ describe('File Logger', function () { once.call(process, event, handler); }); - var logger = makeLogger(); + const logger = makeLogger(); // write the line 10 times _.times(10, function () { @@ -54,7 +54,7 @@ describe('File Logger', function () { }); // collect everything that is written to fs.appendFileSync - var flushedOutput = ''; + let flushedOutput = ''; stub(fs, 'appendFileSync', function (path, str) { flushedOutput += str; }); @@ -68,7 +68,7 @@ describe('File Logger', function () { }); } else { it('does not fall apart with non streams2 streams', function () { - var exitHandler; + let exitHandler; stub(process, 'once', function (event, handler) { if (event === 'exit') { exitHandler = handler; @@ -76,7 +76,7 @@ describe('File Logger', function () { once.call(process, event, handler); }); - var logger = makeLogger(); + const logger = makeLogger(); expect(function () { // call the event handler diff --git a/test/unit/specs/host.js b/test/unit/specs/host.js index 74589bbef..a56669f0f 100644 --- a/test/unit/specs/host.js +++ b/test/unit/specs/host.js @@ -1,10 +1,10 @@ -var Host = require('../../../src/lib/host'); -var _ = require('lodash'); -var expect = require('expect.js'); -var url = require('url'); -var expectSubObject = require('../../utils/expect_sub_object'); +const Host = require('../../../src/lib/host'); +const _ = require('lodash'); +const expect = require('expect.js'); +const url = require('url'); +const expectSubObject = require('../../utils/expect_sub_object'); -var hostDefaults = { +const hostDefaults = { protocol: 'http', host: 'localhost', port: 9200, @@ -24,20 +24,20 @@ var hostDefaults = { } }; -var base64 = function (str) { - var buffer = Buffer.from ? Buffer.from(str, 'utf8') : new Buffer(str, 'utf8') - return buffer.toString('base64') -} +const base64 = function (str) { + const buffer = Buffer.from ? Buffer.from(str, 'utf8') : new Buffer(str, 'utf8'); + return buffer.toString('base64'); +}; describe('Host class', function () { describe('construction', function () { it('properly sets the defaults', function () { - var host = new Host(); + const host = new Host(); expect(host).to.eql(hostDefaults); }); it('accepts a string for query', function () { - var host = new Host({ query: 'beep=boop' }); + const host = new Host({ query: 'beep=boop' }); expect(host.query).to.eql({ beep: 'boop' @@ -45,15 +45,15 @@ describe('Host class', function () { }); it('accepts other generic params', function () { - var headers = { 'X-Special-Routing-Header': 'pie' }; - var host = new Host({ headers: headers }); + const headers = { 'X-Special-Routing-Header': 'pie' }; + const host = new Host({ headers: headers }); expect(host.headers).to.eql(headers); }); describe('from a string', function () { it('accepts a string for the entire url', function () { - var host = new Host('john:dude@pizza.com:420/pizza/cheese?shrooms=true'); + const host = new Host('john:dude@pizza.com:420/pizza/cheese?shrooms=true'); expectSubObject(host, { protocol: 'http', @@ -67,7 +67,7 @@ describe('Host class', function () { }); it('uses the default port based on the protocol', function () { - var host; + let host; host = new Host('https://google.com/'); expect(host.port).to.be(443); @@ -82,7 +82,7 @@ describe('Host class', function () { }); it('parses simple urls properly', function () { - var host; + let host; host = new Host('localhost'); expect(host.host).to.be('localhost'); @@ -108,19 +108,19 @@ describe('Host class', function () { describe('based on the output from url.parse', function () { it('might cause weird things to happen', function () { - var parsedUrl = url.parse('pizza.com:888'); + const parsedUrl = url.parse('pizza.com:888'); // I imagine most people don't expect expect(parsedUrl.protocol).to.eql('pizza.com:'); expect(parsedUrl.host).to.eql('888'); - var host = new Host(parsedUrl); + const host = new Host(parsedUrl); expect(host.protocol).to.eql('pizza.com'); expect(host.host).to.eql('888'); }); it('will cause extra properties', function () { - var host = new Host(url.parse('https://joe:diner@pizza.com:888/path?query=yes#section')); + const host = new Host(url.parse('https://joe:diner@pizza.com:888/path?query=yes#section')); expect(host.protocol).to.eql('https'); expect(host.host).to.eql('pizza.com'); expect(host.port).to.eql(888); @@ -135,13 +135,13 @@ describe('Host class', function () { }); it('ignores anything that\'s not a string or object-y', function () { - var host = new Host(1234); + const host = new Host(1234); expect(host).to.eql(hostDefaults); }); it('defaults auth values from the `httpAuth` setting', function () { - var host = new Host('http://localhost:9200/', { + const host = new Host('http://localhost:9200/', { httpAuth: 'username:password' }); @@ -151,7 +151,7 @@ describe('Host class', function () { describe('#makeUrl', function () { it('merges parameters', function () { - var host = new Host({ + const host = new Host({ path: '/prefix', query: { user_id: 123 @@ -167,7 +167,7 @@ describe('Host class', function () { }); it('ensures that path starts with a forward-slash', function () { - var host = new Host(); + const host = new Host(); host.path = 'prefix'; expect(host.makeUrl({ path: '/this and that' })) @@ -175,14 +175,14 @@ describe('Host class', function () { }); it('does not try to prevent double forward-slashes', function () { - var host = new Host({ path: 'prefix/' }); + const host = new Host({ path: 'prefix/' }); expect(host.makeUrl({ path: '/this and that' })) .to.be('http://localhost:9200/prefix//this%20and%20that'); }); it('creates proper url without any params', function () { - var host = new Host({}); + let host = new Host({}); expect(host.makeUrl()).to.be('http://localhost:9200/'); host = new Host({ host: 'john', port: 80 }); @@ -193,7 +193,7 @@ describe('Host class', function () { }); it('outputs valid relative urls when the host is empty', function () { - var host = new Host({ + const host = new Host({ host: false, path: '/path', query: { this: 'that' } @@ -205,7 +205,7 @@ describe('Host class', function () { describe('#toString', function () { it('produces the same output as makeUrl when it is called without params', function () { - var host = new Host({ + const host = new Host({ path: '/pasta', host: 'google.com' }); @@ -216,7 +216,7 @@ describe('Host class', function () { describe('#getHeaders', function () { it('merges the passed in headers with the default headers', function () { - var host = new Host({ headers: { 'Joe-Smith': 'present' } }); + const host = new Host({ headers: { 'Joe-Smith': 'present' } }); expect(host.getHeaders({ 'John-Smith': 'present' @@ -227,7 +227,7 @@ describe('Host class', function () { }); it('overrides the default headers with the passed in headers', function () { - var host = new Host({ headers: { 'Joe-Smith': 'present' } }); + const host = new Host({ headers: { 'Joe-Smith': 'present' } }); expect(host.getHeaders({ 'John-Smith': 'present', @@ -239,7 +239,7 @@ describe('Host class', function () { }); it('adds Accept-Encoding header when the suggestCompression setting is true', function () { - var host = new Host({ suggestCompression: true }); + const host = new Host({ suggestCompression: true }); expect(host.getHeaders()).to.eql({ 'Accept-Encoding': 'gzip,deflate' }); diff --git a/test/unit/specs/http_connector.js b/test/unit/specs/http_connector.js index 74d070063..c9b66acc3 100644 --- a/test/unit/specs/http_connector.js +++ b/test/unit/specs/http_connector.js @@ -1,32 +1,32 @@ describe('Http Connector', function () { - var _ = require('lodash'); - var expect = require('expect.js'); - var nock = require('nock'); - var sinon = require('sinon'); - var util = require('util'); - var parseUrl = require('url').parse; - var http = require('http'); - var https = require('https'); - var AgentKeepAlive = require('agentkeepalive'); - - var Host = require('../../../src/lib/host'); - var errors = require('../../../src/lib/errors'); - var HttpConnection = require('../../../src/lib/connectors/http'); - var ConnectionAbstract = require('../../../src/lib/connection'); - - var expectSubObject = require('../../utils/expect_sub_object'); - var MockRequest = require('../../mocks/request'); - var MockIncommingMessage = require('../../mocks/incomming_message'); - var zlib = require('zlib'); + const _ = require('lodash'); + const expect = require('expect.js'); + const nock = require('nock'); + const sinon = require('sinon'); + const util = require('util'); + const parseUrl = require('url').parse; + const http = require('http'); + const https = require('https'); + const AgentKeepAlive = require('agentkeepalive'); + + const Host = require('../../../src/lib/host'); + const errors = require('../../../src/lib/errors'); + const HttpConnection = require('../../../src/lib/connectors/http'); + const ConnectionAbstract = require('../../../src/lib/connection'); + + const expectSubObject = require('../../utils/expect_sub_object'); + const MockRequest = require('../../mocks/request'); + const MockIncommingMessage = require('../../mocks/incomming_message'); + const zlib = require('zlib'); nock.disableNetConnect(); - var stub = require('../../utils/auto_release_stub').make(); + const stub = require('../../utils/auto_release_stub').make(); function makeStubReqMethod(prep) { return function (params, cb) { - var req = new MockRequest(); + const req = new MockRequest(); if (prep) { prep(req, params, cb); } @@ -45,12 +45,12 @@ describe('Http Connector', function () { describe('Constructor', function () { it('creates an object that extends ConnectionAbstract', function () { - var con = new HttpConnection(new Host()); + const con = new HttpConnection(new Host()); expect(con).to.be.a(ConnectionAbstract); }); it('sets certain defaults', function () { - var con = new HttpConnection(new Host()); + const con = new HttpConnection(new Host()); expect(con.hand).to.be(require('http')); // con.requestTimeout @@ -62,27 +62,27 @@ describe('Http Connector', function () { it('expects the host to have a protocol of http or https', function () { expect(function () { - var con = new HttpConnection(new Host('thrifty://es.com/stuff')); + const con = new HttpConnection(new Host('thrifty://es.com/stuff')); }).to.throwError(/invalid protocol/i); }); it('allows defining a custom agent', function () { - var football = {}; - var con = new HttpConnection(new Host(), { createNodeAgent: _.constant(football) }); + const football = {}; + const con = new HttpConnection(new Host(), { createNodeAgent: _.constant(football) }); expect(con.agent).to.be(football); }); it('allows setting agent to false', function () { - var con = new HttpConnection(new Host(), { createNodeAgent: _.constant(false) }); + const con = new HttpConnection(new Host(), { createNodeAgent: _.constant(false) }); expect(con.agent).to.be(false); }); }); describe('#makeReqParams', function () { it('properly reads the host object', function () { - var host = new Host('john:dude@pizza.com:9200/pizza/cheese?shrooms=true'); - var con = new HttpConnection(host, {}); - var reqParams = con.makeReqParams(); + const host = new Host('john:dude@pizza.com:9200/pizza/cheese?shrooms=true'); + const con = new HttpConnection(host, {}); + const reqParams = con.makeReqParams(); expect(reqParams).to.not.have.property('auth'); expect(reqParams).to.eql({ @@ -97,13 +97,13 @@ describe('Http Connector', function () { }); it('merges a query object with the hosts\'', function () { - var con = new HttpConnection(new Host({ + const con = new HttpConnection(new Host({ query: { user_id: 123 } })); - var reqParams = con.makeReqParams({ + const reqParams = con.makeReqParams({ query: { jvm: 'yes' } @@ -113,8 +113,8 @@ describe('Http Connector', function () { }); it('merges the path prefix', function () { - var con = new HttpConnection(new Host('https://google.com/path/prefix/for/user/1')); - var reqParams = con.makeReqParams({ + const con = new HttpConnection(new Host('https://google.com/path/prefix/for/user/1')); + const reqParams = con.makeReqParams({ method: 'GET', path: '/items', query: { @@ -128,9 +128,9 @@ describe('Http Connector', function () { }); it('merges the query', function () { - var con = new HttpConnection(new Host('http://google.com/pref-x?userId=12345&token=42069')); + const con = new HttpConnection(new Host('http://google.com/pref-x?userId=12345&token=42069')); - var reqParams = con.makeReqParams({ + const reqParams = con.makeReqParams({ method: 'PUT', path: '/stuff', query: { @@ -144,9 +144,9 @@ describe('Http Connector', function () { }); it('Works well with minimum params', function () { - var con = new HttpConnection(new Host('http://google.com/')); + const con = new HttpConnection(new Host('http://google.com/')); - var reqParams = con.makeReqParams({ + const reqParams = con.makeReqParams({ method: 'PUT', path: '/stuff' }); @@ -170,7 +170,7 @@ describe('Http Connector', function () { }); it('calls http based on the host', function (done) { - var con = new HttpConnection(new Host('http://google.com/')); + const con = new HttpConnection(new Host('http://google.com/')); con.request({}, function () { expect(http.request.callCount).to.be(1); expect(https.request.callCount).to.be(0); @@ -180,7 +180,7 @@ describe('Http Connector', function () { }); it('calls https based on the host', function (done) { - var con = new HttpConnection(new Host('https://google.com/')); + const con = new HttpConnection(new Host('https://google.com/')); con.request({}, function () { expect(http.request.callCount).to.be(0); expect(https.request.callCount).to.be(1); @@ -190,7 +190,7 @@ describe('Http Connector', function () { }); it('does not log error events', function (done) { - var con = new HttpConnection(new Host('http://google.com/')); + const con = new HttpConnection(new Host('http://google.com/')); stub(con.log, 'error'); stub(con.log, 'trace'); @@ -217,7 +217,7 @@ describe('Http Connector', function () { }); it('logs error events', function (done) { - var con = new HttpConnection(new Host('http://google.com/')); + const con = new HttpConnection(new Host('http://google.com/')); stub(con.log, 'error'); @@ -238,7 +238,7 @@ describe('Http Connector', function () { function makeStubReqWithMsgWhichErrorsMidBody(err) { return makeStubReqMethod(function (req, params, cb) { process.nextTick(function () { - var incom = new MockIncommingMessage(); + const incom = new MockIncommingMessage(); incom.statusCode = 200; setTimeout(function () { incom.emit('data', '{ "not json"'); @@ -250,7 +250,7 @@ describe('Http Connector', function () { } it('does not log errors', function (done) { - var con = new HttpConnection(new Host('https://google.com/')); + const con = new HttpConnection(new Host('https://google.com/')); stub(con.log, 'error'); stub(https, 'request', makeStubReqWithMsgWhichErrorsMidBody()); @@ -261,7 +261,7 @@ describe('Http Connector', function () { }); it('passes the original error on', function (done) { - var con = new HttpConnection(new Host('https://google.com/')); + const con = new HttpConnection(new Host('https://google.com/')); stub(https, 'request', makeStubReqWithMsgWhichErrorsMidBody(new Error('no more message :('))); con.request({}, function (err, resp, status) { @@ -272,7 +272,7 @@ describe('Http Connector', function () { }); it('does not pass the partial body along', function (done) { - var con = new HttpConnection(new Host('https://google.com/')); + const con = new HttpConnection(new Host('https://google.com/')); stub(https, 'request', makeStubReqWithMsgWhichErrorsMidBody()); con.request({}, function (err, resp, status) { @@ -282,7 +282,7 @@ describe('Http Connector', function () { }); it('does not pass the status code along', function (done) { - var con = new HttpConnection(new Host('https://google.com/')); + const con = new HttpConnection(new Host('https://google.com/')); stub(https, 'request', makeStubReqWithMsgWhichErrorsMidBody()); con.request({}, function (err, resp, status) { @@ -294,9 +294,9 @@ describe('Http Connector', function () { describe('#request\'s responder', function () { it('collects the whole request body', function (done) { - var server = nock('http://esjs.com:9200/'); - var con = new HttpConnection(new Host('http://esjs.com:9200/')); - var body = '{ "USER": "doc" }'; + const server = nock('http://esjs.com:9200/'); + const con = new HttpConnection(new Host('http://esjs.com:9200/')); + const body = '{ "USER": "doc" }'; server .get('/users/1') @@ -315,13 +315,13 @@ describe('Http Connector', function () { }); it('collects the whole request body (gzip compressed)', function (done) { - var server = nock('http://esjs.com:9200/'); - var con = new HttpConnection(new Host('http://esjs.com:9200/')); - var elements = []; - for (var i = 0; i < 500; i++) { + const server = nock('http://esjs.com:9200/'); + const con = new HttpConnection(new Host('http://esjs.com:9200/')); + const elements = []; + for (let i = 0; i < 500; i++) { elements.push({ USER: 'doc' }); } - var body = JSON.stringify(elements); + const body = JSON.stringify(elements); zlib.gzip(body, function (err, compressedBody) { server .get('/users/1') @@ -341,13 +341,13 @@ describe('Http Connector', function () { }); it('collects the whole request body (deflate compressed)', function (done) { - var server = nock('http://esjs.com:9200/'); - var con = new HttpConnection(new Host('http://esjs.com:9200/')); - var elements = []; - for (var i = 0; i < 500; i++) { + const server = nock('http://esjs.com:9200/'); + const con = new HttpConnection(new Host('http://esjs.com:9200/')); + const elements = []; + for (let i = 0; i < 500; i++) { elements.push({ USER: 'doc' }); } - var body = JSON.stringify(elements); + const body = JSON.stringify(elements); zlib.deflate(body, function (err, compressedBody) { server .get('/users/1') @@ -367,9 +367,9 @@ describe('Http Connector', function () { }); it('Can handle decompression errors', function (done) { - var server = nock('http://esjs.com:9200/'); - var con = new HttpConnection(new Host('http://esjs.com:9200/')); - var body = 'blah'; + const server = nock('http://esjs.com:9200/'); + const con = new HttpConnection(new Host('http://esjs.com:9200/')); + const body = 'blah'; server .get('/users/1') .reply(200, body, { 'Content-Encoding': 'gzip' }); @@ -387,9 +387,9 @@ describe('Http Connector', function () { }); it('Ignores serialization errors', function (done) { - var server = nock('http://esjs.com:9200/'); - var con = new HttpConnection(new Host('http://esjs.com:9200/')); - var body = '{ "USER":'; + const server = nock('http://esjs.com:9200/'); + const con = new HttpConnection(new Host('http://esjs.com:9200/')); + const body = '{ "USER":'; // partial body server @@ -410,9 +410,9 @@ describe('Http Connector', function () { describe('HTTP specifics', function () { it('uses TCP no delay', function (done) { - var con = new HttpConnection(new Host('localhost')); + const con = new HttpConnection(new Host('localhost')); stub(http.ClientRequest.prototype, 'setNoDelay'); - var server = nock('http://localhost/').get('/').reply(200); + const server = nock('http://localhost/').get('/').reply(200); con.request({}, function (err, resp, status) { expect(http.ClientRequest.prototype.setNoDelay.callCount).to.eql(1); @@ -423,11 +423,11 @@ describe('Http Connector', function () { }); it('sets the Content-Length header properly', function (done) { - var con = new HttpConnection(new Host('localhost')); + const con = new HttpConnection(new Host('localhost')); stub(http.ClientRequest.prototype, 'setHeader'); - var server = nock('http://localhost/').get('/').reply(200); + const server = nock('http://localhost/').get('/').reply(200); - var body = 'pasta and 𝄞'; + const body = 'pasta and 𝄞'; expect(body.length).to.eql(12); // nope expect(Buffer.byteLength(body, 'utf8')).to.eql(14); // yep @@ -441,9 +441,9 @@ describe('Http Connector', function () { }); it('does not set the Accept-Encoding header by default', function (done) { - var con = new HttpConnection(new Host()); - var respBody = 'i should not be encoded'; - var server = nock('http://localhost:9200/') + const con = new HttpConnection(new Host()); + const respBody = 'i should not be encoded'; + const server = nock('http://localhost:9200/') .matchHeader('accept-encoding', undefined) .get('/') .once() @@ -457,9 +457,9 @@ describe('Http Connector', function () { }); it('sets the Accept-Encoding header when specified', function (done) { - var con = new HttpConnection(new Host({ suggestCompression: true })); - var respBody = 'i should be encoded'; - var server = nock('http://localhost:9200/') + const con = new HttpConnection(new Host({ suggestCompression: true })); + const respBody = 'i should be encoded'; + const server = nock('http://localhost:9200/') .matchHeader('accept-encoding', 'gzip,deflate') .get('/') .once() @@ -476,12 +476,12 @@ describe('Http Connector', function () { describe('Connection cleanup', function () { it('destroys any connections created', function (done) { this.timeout(5 * 60 * 1000); - var cp = require('child_process'); - var path = require('path'); - var fixture = _.partial(path.join, __dirname, '../../fixtures'); - var timeout; // start the timeout once we hear back from the client + const cp = require('child_process'); + const path = require('path'); + const fixture = _.partial(path.join, __dirname, '../../fixtures'); + let timeout; // start the timeout once we hear back from the client - var server = cp.fork(fixture('keepalive_server.js')) + const server = cp.fork(fixture('keepalive_server.js')) .on('message', function (port) { client.send(port); }); @@ -507,8 +507,8 @@ describe('Http Connector', function () { }); it('properly removes all elements from the socket', function () { - var con = new HttpConnection(new Host('localhost')); - var sockets = [ + const con = new HttpConnection(new Host('localhost')); + const sockets = [ { destroy: function () {} }, { destroy: function () {} }, { destroy: function () {} }, @@ -520,7 +520,7 @@ describe('Http Connector', function () { { destroy: function () {} }, { destroy: function () {} } ]; - var name = con.agent.getName(parseUrl('http://localhost/')); + const name = con.agent.getName(parseUrl('http://localhost/')); con.agent.sockets[name] = sockets; con.setStatus('closed'); expect(sockets).to.eql([]); diff --git a/test/unit/specs/json_serializer.js b/test/unit/specs/json_serializer.js index 9a876ba0f..012710bc7 100644 --- a/test/unit/specs/json_serializer.js +++ b/test/unit/specs/json_serializer.js @@ -1,8 +1,8 @@ describe('JSON serializer', function () { - var JsonSerializer = require('../../../src/lib/serializers/json'); - var expect = require('expect.js'); - var sinon = require('sinon'); - var stub = require('../../utils/auto_release_stub').make(); + const JsonSerializer = require('../../../src/lib/serializers/json'); + const expect = require('expect.js'); + const sinon = require('sinon'); + const stub = require('../../utils/auto_release_stub').make(); function makeSerializer() { return new JsonSerializer(); @@ -10,29 +10,29 @@ describe('JSON serializer', function () { describe('#serialize', function () { it('defers to JSON.stringify', function () { - var stub = sinon.stub(JSON, 'stringify'); - var ser = makeSerializer(); + const stub = sinon.stub(JSON, 'stringify'); + const ser = makeSerializer(); ser.serialize({ some: 'object' }); expect(stub.callCount).to.eql(1); stub.restore(); }); it('does not modify strings', function () { - var ser = makeSerializer(); - var thing = 'pretend that I am serialized'; + const ser = makeSerializer(); + const thing = 'pretend that I am serialized'; expect(ser.serialize(thing)).to.be(thing); }); it('returns nothing for invalid values', function () { - var ser = makeSerializer(); + const ser = makeSerializer(); expect(ser.serialize(null)).to.be(undefined); expect(ser.serialize(false)).to.be(undefined); }); it('throws serialization errors', function () { - var ser = makeSerializer(); - var thing = { name: 'thing' }; + const ser = makeSerializer(); + const thing = { name: 'thing' }; thing.self = thing; expect(function () { @@ -44,46 +44,46 @@ describe('JSON serializer', function () { describe('#deserialize', function () { it('defers to JSON.parse', function () { stub(JSON, 'parse'); - var ser = makeSerializer(); + const ser = makeSerializer(); ser.deserialize('{ "some": "JSON" }'); expect(JSON.parse.callCount).to.eql(1); }); it('ignores non string values', function () { - var ser = makeSerializer(); - var thing = ['pretend that I am not here']; + const ser = makeSerializer(); + const thing = ['pretend that I am not here']; expect(ser.deserialize(thing)).to.be(undefined); expect(ser.deserialize(null)).to.be(undefined); expect(ser.deserialize(false)).to.be(undefined); }); it('catches serialization errors, returns nothing', function () { - var ser = makeSerializer(); - var thing = '{ name: \'thing\' }'; + const ser = makeSerializer(); + const thing = '{ name: \'thing\' }'; expect(ser.deserialize(thing)).to.be(undefined); }); }); describe('#bulkBody', function () { - var body = [ + const body = [ { index: 'thing' }, { document: 'hi' } ]; - var bulk = '{"index":"thing"}\n{"document":"hi"}\n'; + const bulk = '{"index":"thing"}\n{"document":"hi"}\n'; it('creates a string out of an array of obejcts', function () { - var ser = makeSerializer(); + const ser = makeSerializer(); expect(ser.bulkBody(body)).to.eql(bulk); }); it('adds a newline to the end of strings', function () { - var ser = makeSerializer(); + const ser = makeSerializer(); expect(ser.bulkBody(bulk.substr(0, bulk.length - 1))).to.eql(bulk); }); it('throws an error for anything else', function () { - var ser = makeSerializer(); + const ser = makeSerializer(); expect(function () { ser.bulkBody({}); }).to.throwError(); diff --git a/test/unit/specs/log.js b/test/unit/specs/log.js index fd37b9a99..562ecfffd 100644 --- a/test/unit/specs/log.js +++ b/test/unit/specs/log.js @@ -1,6 +1,6 @@ -var Log = require('../../../src/lib/log'); -var _ = require('lodash'); -var expect = require('expect.js'); +const Log = require('../../../src/lib/log'); +const _ = require('lodash'); +const expect = require('expect.js'); describe('Log class', function () { describe('::parseLevels', function () { @@ -32,7 +32,7 @@ describe('Log class', function () { }); describe('#addOutput', function () { - var log; + let log; Log.loggers.stub = function (log, config) { this.config = config; @@ -47,7 +47,7 @@ describe('Log class', function () { }); it('Accepts a config object with `level: "{{level}}"`', function () { - var logger = log.addOutput({ + const logger = log.addOutput({ type: 'stub', level: 'warning' }); @@ -58,7 +58,7 @@ describe('Log class', function () { }); it('Accepts a config object with `level: ["{{level}}"]`', function () { - var logger = log.addOutput({ + const logger = log.addOutput({ type: 'stub', level: ['warning'] }); @@ -70,7 +70,7 @@ describe('Log class', function () { it('Accepts a config object with `levels: "{{level}}"`', function () { - var logger = log.addOutput({ + const logger = log.addOutput({ type: 'stub', levels: 'warning' }); @@ -81,7 +81,7 @@ describe('Log class', function () { }); it('Accepts a config object with `levels: ["{{level}}"]`', function () { - var logger = log.addOutput({ + const logger = log.addOutput({ type: 'stub', level: ['warning'] }); @@ -100,15 +100,15 @@ describe('Log class', function () { expect(Log.join([{ foo: 'bar' }])).to.eql('{\n "foo": "bar"\n}\n'); }); - it('fully stringifies deeply nested objects', function() { - var object = { foo: { bar: { baz: 'value' } } }; - var expected = '{\n "bar": {\n "baz": "value"\n }\n}\n'; + it('fully stringifies deeply nested objects', function () { + const object = { foo: { bar: { baz: 'value' } } }; + const expected = '{\n "bar": {\n "baz": "value"\n }\n}\n'; expect(Log.join(object)).to.eql(expected); }); }); describe('instance without any outputs', function () { - var log; + let log; beforeEach(function () { log = new Log(); }); @@ -128,7 +128,7 @@ describe('Log class', function () { }); describe('instance without one output listening to all events', function () { - var log, call; + let log, call; beforeEach(function () { call = void 0; log = new Log({ @@ -154,7 +154,7 @@ describe('Log class', function () { }); it('should emit an "error" event with an Error object arg', function () { - var err = new Error('error'); + const err = new Error('error'); log.error(err); expect(call.event).to.eql('error'); expect(call.args[0]).to.be(err); @@ -200,7 +200,7 @@ describe('Log class', function () { describe('constructor', function () { it('looks for output config options at config.log', function () { - var log = new Log({ log: { type: process.browser ? 'console' : 'stdio', level: 'error' } }); + const log = new Log({ log: { type: process.browser ? 'console' : 'stdio', level: 'error' } }); expect(log.listenerCount('error')).to.eql(1); expect(log.listenerCount('warning')).to.eql(0); expect(log.listenerCount('info')).to.eql(0); @@ -209,7 +209,7 @@ describe('Log class', function () { }); it('accepts a string and treat it as a log level', function () { - var log = new Log({ log: 'error' }); + const log = new Log({ log: 'error' }); expect(log.listenerCount('error')).to.eql(1); expect(log.listenerCount('warning')).to.eql(0); expect(log.listenerCount('info')).to.eql(0); @@ -218,7 +218,7 @@ describe('Log class', function () { }); it('accepts an array of strings and treat it as a log level config', function () { - var log = new Log({ log: ['error', 'trace'] }); + const log = new Log({ log: ['error', 'trace'] }); expect(log.listenerCount('error')).to.eql(1); expect(log.listenerCount('warning')).to.eql(0); expect(log.listenerCount('info')).to.eql(0); @@ -227,7 +227,7 @@ describe('Log class', function () { }); it('accepts an array of output config objects', function () { - var log = new Log({ log: [{ level: 'error' }, { level: 'trace' }] }); + const log = new Log({ log: [{ level: 'error' }, { level: 'trace' }] }); expect(log.listenerCount('error')).to.eql(2); expect(log.listenerCount('warning')).to.eql(1); expect(log.listenerCount('info')).to.eql(1); @@ -237,22 +237,22 @@ describe('Log class', function () { it('rejects numbers and other truthy data-types', function () { expect(function () { - var log = new Log({ log: 1515 }); + const log = new Log({ log: 1515 }); }).to.throwError(/invalid logging output config/i); expect(function () { - var log = new Log({ log: /regexp/ }); + const log = new Log({ log: /regexp/ }); }).to.throwError(/invalid logging output config/i); expect(function () { - var log = new Log({ log: new Date() }); + const log = new Log({ log: new Date() }); }).to.throwError(/invalid logging output config/i); expect(function () { - var log = new Log({ log: [1515] }); + const log = new Log({ log: [1515] }); }).to.throwError(/invalid logging output config/i); expect(function () { - var log = new Log({ log: [/regexp/] }); + const log = new Log({ log: [/regexp/] }); }).to.throwError(/invalid logging output config/i); expect(function () { - var log = new Log({ log: [new Date()] }); + const log = new Log({ log: [new Date()] }); }).to.throwError(/invalid logging output config/i); }); }); diff --git a/test/unit/specs/nodes_to_host_callback.js b/test/unit/specs/nodes_to_host_callback.js index cd161ace3..10bfa79e5 100644 --- a/test/unit/specs/nodes_to_host_callback.js +++ b/test/unit/specs/nodes_to_host_callback.js @@ -1,11 +1,11 @@ describe('Nodes to host callback', function () { - var callback = require('../../../src/lib/nodes_to_host'); - var expect = require('expect.js'); + const callback = require('../../../src/lib/nodes_to_host'); + const expect = require('expect.js'); - var nodes90 = require('../../fixtures/short_node_list.0.90.json'); - var nodes10 = require('../../fixtures/short_node_list.1.0.json'); - var nodes20 = require('../../fixtures/short_node_list.2.0.json'); - var nodes50 = require('../../fixtures/short_node_list.5.0.json'); + const nodes90 = require('../../fixtures/short_node_list.0.90.json'); + const nodes10 = require('../../fixtures/short_node_list.1.0.json'); + const nodes20 = require('../../fixtures/short_node_list.2.0.json'); + const nodes50 = require('../../fixtures/short_node_list.5.0.json'); context('0.x style', function () { it('properly creates host objects', function () { @@ -109,7 +109,7 @@ describe('Nodes to host callback', function () { it('ignores hosts that don\'t have an http_host property', function () { - var hosts = callback({ + const hosts = callback({ node_id: { not: 'much of a node' } diff --git a/test/unit/specs/random_selector.js b/test/unit/specs/random_selector.js index 91b0149b0..e91c14713 100644 --- a/test/unit/specs/random_selector.js +++ b/test/unit/specs/random_selector.js @@ -1,14 +1,14 @@ describe('Random Selector', function () { - var randomSelector = require('../../../src/lib/selectors/random'); - var _ = require('lodash'); - var expect = require('expect.js'); + const randomSelector = require('../../../src/lib/selectors/random'); + const _ = require('lodash'); + const expect = require('expect.js'); it('chooses a selection by random', function () { - var log = { a: 0, b: 0, c: 0 }; - var choices = _.keys(log); + const log = { a: 0, b: 0, c: 0 }; + const choices = _.keys(log); _.times(1000, function () { - var choice = randomSelector(choices); + const choice = randomSelector(choices); log[choice]++; }); diff --git a/test/unit/specs/round_robin_selector.js b/test/unit/specs/round_robin_selector.js index 2298a0180..00c175af5 100644 --- a/test/unit/specs/round_robin_selector.js +++ b/test/unit/specs/round_robin_selector.js @@ -1,12 +1,12 @@ describe('Round Robin Selector', function () { - var selector = require('../../../src/lib/selectors/round_robin'); - var _ = require('lodash'); - var expect = require('expect.js'); + const selector = require('../../../src/lib/selectors/round_robin'); + const _ = require('lodash'); + const expect = require('expect.js'); it('chooses options in order', function () { - var options = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]; - var expected = _.clone(options); - var selections = []; + const options = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]; + const expected = _.clone(options); + const selections = []; _.times(options.length, function () { selections.push(selector(options)); diff --git a/test/unit/specs/stdio_logger.js b/test/unit/specs/stdio_logger.js index 6e4d5c833..fc8356bf6 100644 --- a/test/unit/specs/stdio_logger.js +++ b/test/unit/specs/stdio_logger.js @@ -1,10 +1,10 @@ describe('Stdio Logger', function () { - var Log = require('../../../src/lib/log'); - var StdioLogger = require('../../../src/lib/loggers/stdio'); - var expect = require('expect.js'); - var sinon = require('sinon'); - var parentLog; + const Log = require('../../../src/lib/log'); + const StdioLogger = require('../../../src/lib/loggers/stdio'); + const expect = require('expect.js'); + const sinon = require('sinon'); + let parentLog; beforeEach(function () { parentLog = new Log(); @@ -16,37 +16,37 @@ describe('Stdio Logger', function () { function makeLogger(parent, levels) { parent = parent || parentLog; - var config = { + const config = { levels: Log.parseLevels(levels || 'trace') }; return new StdioLogger(parent, config); } - var stub = require('../../utils/auto_release_stub').make(); + const stub = require('../../utils/auto_release_stub').make(); require('../generic_logger_tests')(makeLogger); describe('colorizing', function () { - var chalk = require('chalk'); - var now = '2013-01-01T00:00:00Z'; - var nowDate = new Date(now); - var nowTime = nowDate.getTime(); - var clock; + const chalk = require('chalk'); + const now = '2013-01-01T00:00:00Z'; + const nowDate = new Date(now); + const nowTime = nowDate.getTime(); + let clock; beforeEach(function () { stub.autoRelease(sinon.useFakeTimers(nowTime)); }); it('uses colors when it\'s supported', function () { - var logger = makeLogger(); - var hasColor = require('chalk').supportsColor; + const logger = makeLogger(); + const hasColor = require('chalk').supportsColor; expect(logger.color).to.be(hasColor); }); it('obeys the logger.color === false', function () { - var logger = makeLogger(); + const logger = makeLogger(); stub(process.stdout, 'write'); - var withoutColor = 'Elasticsearch INFO: ' + now + '\n something\n\n'; + const withoutColor = 'Elasticsearch INFO: ' + now + '\n something\n\n'; logger.color = false; logger.onInfo('something'); @@ -54,10 +54,10 @@ describe('Stdio Logger', function () { }); it('obeys the logger.color === true', function () { - var logger = makeLogger(); + const logger = makeLogger(); stub(process.stdout, 'write'); - var withoutColor = 'Elasticsearch DEBUG: ' + now + '\n be weary\n\n'; + const withoutColor = 'Elasticsearch DEBUG: ' + now + '\n be weary\n\n'; logger.color = true; logger.onDebug('be weary'); diff --git a/test/unit/specs/stream_logger.js b/test/unit/specs/stream_logger.js index f4c3d65ce..834c044fa 100644 --- a/test/unit/specs/stream_logger.js +++ b/test/unit/specs/stream_logger.js @@ -1,14 +1,14 @@ describe('Stream Logger', function () { - var Log = require('../../../src/lib/log'); - var StreamLogger = require('../../../src/lib/loggers/stream'); - var MockWritableStream = require('../../mocks/writable_stream'); - var once = require('events').EventEmitter.prototype.once; - var stream = new MockWritableStream(); - var _ = require('../../../src/lib/utils'); - var expect = require('expect.js'); - var parentLog; + const Log = require('../../../src/lib/log'); + const StreamLogger = require('../../../src/lib/loggers/stream'); + const MockWritableStream = require('../../mocks/writable_stream'); + const once = require('events').EventEmitter.prototype.once; + const stream = new MockWritableStream(); + const _ = require('../../../src/lib/utils'); + const expect = require('expect.js'); + let parentLog; - var stub = require('../../utils/auto_release_stub').make(); + const stub = require('../../utils/auto_release_stub').make(); beforeEach(function () { stub(stream, 'write'); @@ -24,7 +24,7 @@ describe('Stream Logger', function () { function makeLogger(parent, levels) { parent = parent || parentLog; - var config = { + const config = { levels: Log.parseLevels(levels || 'trace'), stream: stream }; @@ -36,12 +36,12 @@ describe('Stream Logger', function () { describe('buffer flush', function () { if (require('stream').Writable) { it('writes everything in the buffer to console.error', function () { - var logger = makeLogger(); - var line = 'This string is written 10 times to create buffered output\n'; + const logger = makeLogger(); + const line = 'This string is written 10 times to create buffered output\n'; // get the last handler for process's "exit" event - var exitHandlers = process._events.exit; - var exitHandler = _.isArray(exitHandlers) ? _.last(exitHandlers) : exitHandlers; + const exitHandlers = process._events.exit; + const exitHandler = _.isArray(exitHandlers) ? _.last(exitHandlers) : exitHandlers; // allow the logger to acctually write to the stream stream.write.restore(); @@ -52,7 +52,7 @@ describe('Stream Logger', function () { }); // collect everything that is written to console.error - var flushedOutput = ''; + let flushedOutput = ''; stub(console, 'error', function (str) { flushedOutput += str; }); @@ -69,7 +69,7 @@ describe('Stream Logger', function () { }); } else { it('does not fall apart with non streams2 streams', function () { - var exitHandler; + let exitHandler; stub(process, 'once', function (event, handler) { if (event === 'exit') { exitHandler = handler; @@ -77,7 +77,7 @@ describe('Stream Logger', function () { once.call(process, event, handler); }); - var logger = makeLogger(); + const logger = makeLogger(); expect(function () { // call the event handler diff --git a/test/unit/specs/tracer_logger.js b/test/unit/specs/tracer_logger.js index d78269c11..4b7dee22a 100644 --- a/test/unit/specs/tracer_logger.js +++ b/test/unit/specs/tracer_logger.js @@ -1,10 +1,10 @@ describe('Tracer Logger', function () { - var Log = require('../../../src/lib/log'); - var TracerLogger = require('../../../src/lib/loggers/tracer'); - var sinon = require('sinon'); - var expect = require('expect.js'); - var parentLog; + const Log = require('../../../src/lib/log'); + const TracerLogger = require('../../../src/lib/loggers/tracer'); + const sinon = require('sinon'); + const expect = require('expect.js'); + let parentLog; beforeEach(function () { parentLog = new Log(); @@ -16,21 +16,21 @@ describe('Tracer Logger', function () { function makeLogger(parent, levels) { parent = parent || parentLog; - var config = { + const config = { levels: Log.parseLevels(levels || 'trace') }; return new TracerLogger(parent, config); } - var stub = require('../../utils/auto_release_stub').make(); + const stub = require('../../utils/auto_release_stub').make(); // require('../generic_logger_tests')(makeLogger); describe('#formatTraceMessage', function () { it('includes the original host', function () { - var logger = makeLogger(); + const logger = makeLogger(); - var formatted = logger._formatTraceMessage({ + const formatted = logger._formatTraceMessage({ method: 'DELETE', url: 'https://originalhost.com:9522/path/to/thing?qs=100', body: '{ "yes": true }', @@ -45,7 +45,7 @@ describe('Tracer Logger', function () { }); describe('#write', function () { - var logger; + let logger; beforeEach(function () { logger = makeLogger(); stub(logger.stream, 'write'); diff --git a/test/unit/specs/transport.js b/test/unit/specs/transport.js index d3a578056..11351b522 100644 --- a/test/unit/specs/transport.js +++ b/test/unit/specs/transport.js @@ -1,12 +1,12 @@ -var Transport = require('../../../src/lib/transport'); -var Host = require('../../../src/lib/host'); -var errors = require('../../../src/lib/errors'); +const Transport = require('../../../src/lib/transport'); +const Host = require('../../../src/lib/host'); +const errors = require('../../../src/lib/errors'); -var sinon = require('sinon'); -var expect = require('expect.js'); -var _ = require('lodash'); -var nodeList = require('../../fixtures/short_node_list.5.0.json'); -var stub = require('../../utils/auto_release_stub').make(); +const sinon = require('sinon'); +const expect = require('expect.js'); +const _ = require('lodash'); +const nodeList = require('../../fixtures/short_node_list.5.0.json'); +const stub = require('../../utils/auto_release_stub').make(); /** * Allows the tests call #request() without it doing anything past trying to select @@ -31,7 +31,7 @@ describe('Transport Class', function () { describe('Constructor', function () { it('Accepts a log class and intanciates it at this.log', function () { function CustomLogClass() {} - var trans = new Transport({ + const trans = new Transport({ log: CustomLogClass }); @@ -39,7 +39,7 @@ describe('Transport Class', function () { }); it('Accepts a connection pool class and intanciates it at this.connectionPool', function () { - var trans = new Transport({ + const trans = new Transport({ connectionPool: CustomConnectionPool }); @@ -49,7 +49,7 @@ describe('Transport Class', function () { it('Accepts the name of a connectionPool class that is defined on Transport.connectionPools', function () { Transport.connectionPools.custom = CustomConnectionPool; - var trans = new Transport({ + const trans = new Transport({ connectionPool: 'custom' }); @@ -59,7 +59,7 @@ describe('Transport Class', function () { it('Throws an error when connectionPool config is set wrong', function () { expect(function () { - var trans = new Transport({ + const trans = new Transport({ connectionPool: 'pasta' }); }).to.throwError(/invalid connectionpool/i); @@ -67,7 +67,7 @@ describe('Transport Class', function () { it('calls sniff immediately if sniffOnStart is true', function () { stub(Transport.prototype, 'sniff'); - var trans = new Transport({ + const trans = new Transport({ sniffOnStart: true }); @@ -75,16 +75,16 @@ describe('Transport Class', function () { }); it('schedules a sniff when sniffInterval is set', function () { - var clock = sinon.useFakeTimers('setTimeout'); + const clock = sinon.useFakeTimers('setTimeout'); stub.autoRelease(clock); stub(Transport.prototype, 'sniff'); - var trans = new Transport({ + const trans = new Transport({ sniffInterval: 25000 }); expect(_.size(clock.timers)).to.eql(1); - var id = _.keys(clock.timers).pop(); + const id = _.keys(clock.timers).pop(); clock.tick(25000); expect(trans.sniff.callCount).to.eql(1); expect(_.size(clock.timers)).to.eql(1); @@ -94,15 +94,15 @@ describe('Transport Class', function () { describe('config.sniffedNodesProtocol', function () { it('Assigns to itself', function () { - var football = {}; - var trans = new Transport({ + const football = {}; + const trans = new Transport({ sniffedNodesProtocol: football }); expect(trans).to.have.property('sniffedNodesProtocol', football); }); it('Defaults to null when no hosts given', function () { - var trans = new Transport({ + const trans = new Transport({ hosts: [] }); @@ -110,7 +110,7 @@ describe('Transport Class', function () { }); it('Defaults to "http" when a single http host given', function () { - var trans = new Transport({ + const trans = new Transport({ hosts: [ new Host({ protocol: 'http' @@ -122,7 +122,7 @@ describe('Transport Class', function () { }); it('Defaults to "http" when multiple http host given', function () { - var trans = new Transport({ + const trans = new Transport({ hosts: [ new Host(), 'http://google.com/', @@ -137,7 +137,7 @@ describe('Transport Class', function () { }); it('Defaults to "https" when a single https host given', function () { - var trans = new Transport({ + const trans = new Transport({ host: { protocol: 'https' } @@ -147,7 +147,7 @@ describe('Transport Class', function () { }); it('Defaults to "https" when every seed host uses https', function () { - var trans = new Transport({ + const trans = new Transport({ hosts: [ 'https://localhost:9200/', new Host({ @@ -166,7 +166,7 @@ describe('Transport Class', function () { describe('host config', function () { it('rejects non-strings/objects', function () { expect(function () { - var trans = new Transport({ + const trans = new Transport({ host: [ 'localhost', 9393 @@ -175,7 +175,7 @@ describe('Transport Class', function () { }).to.throwError(TypeError); expect(function () { - var trans = new Transport({ + const trans = new Transport({ host: [ [9292] ] @@ -185,7 +185,7 @@ describe('Transport Class', function () { it('accepts the config value on the host: key', function () { stub(Transport.connectionPools.main.prototype, 'setHosts'); - var trans = new Transport({ + const trans = new Transport({ host: 'localhost' }); @@ -197,7 +197,7 @@ describe('Transport Class', function () { it('accepts the config value on the hosts: key', function () { stub(Transport.connectionPools.main.prototype, 'setHosts'); - var trans = new Transport({ + const trans = new Transport({ hosts: 'localhost' }); @@ -209,8 +209,8 @@ describe('Transport Class', function () { it('accepts A host object as the config', function () { stub(Transport.connectionPools.main.prototype, 'setHosts'); - var h = new Host('localhost'); - var trans = new Transport({ + const h = new Host('localhost'); + const trans = new Transport({ host: h }); @@ -220,7 +220,7 @@ describe('Transport Class', function () { it('accepts strings as the config', function () { stub(Transport.connectionPools.main.prototype, 'setHosts'); - var trans = new Transport({ + const trans = new Transport({ hosts: [ 'localhost:8888', ] @@ -237,7 +237,7 @@ describe('Transport Class', function () { it('accepts objects as the config', function () { stub(Transport.connectionPools.main.prototype, 'setHosts'); - var trans = new Transport({ + const trans = new Transport({ hosts: [ { protocol: 'https', @@ -262,13 +262,13 @@ describe('Transport Class', function () { // check that it's getting the suggestCompression setting stub(Transport.connectionPools.main.prototype, 'setHosts'); - var trans = new Transport({ + let trans = new Transport({ suggestCompression: true, hosts: ['localhost:9200'] }); expect(trans.connectionPool.setHosts).to.have.property('callCount', 1); - var hosts = trans.connectionPool.setHosts.firstCall.args[0]; + let hosts = trans.connectionPool.setHosts.firstCall.args[0]; expect(hosts).to.have.length(1); expect(hosts[0]).to.have.property('suggestCompression', true); @@ -285,20 +285,20 @@ describe('Transport Class', function () { describe('randomizeHosts options', function () { it('calls _.shuffle be default', function () { - var _ = require('../../../src/lib/utils'); + const _ = require('../../../src/lib/utils'); stub(Transport.connectionPools.main.prototype, 'setHosts'); stub(_, 'shuffle'); - var trans = new Transport({ + const trans = new Transport({ hosts: 'localhost' }); expect(_.shuffle.callCount).to.eql(1); }); it('skips the call to _.shuffle when false', function () { - var _ = require('../../../src/lib/utils'); + const _ = require('../../../src/lib/utils'); stub(Transport.connectionPools.main.prototype, 'setHosts'); stub(_, 'shuffle'); - var trans = new Transport({ + const trans = new Transport({ hosts: 'localhost', randomizeHosts: false }); @@ -310,7 +310,7 @@ describe('Transport Class', function () { describe('#defer', function () { it('returns a custom defer object', function () { - var defer = Transport.prototype.defer(); + const defer = Transport.prototype.defer(); expect(defer).to.have.property('promise'); expect(defer).to.have.property('resolve'); expect(defer).to.have.property('reject'); @@ -319,7 +319,7 @@ describe('Transport Class', function () { describe('#sniff', function () { - var trans; + let trans; beforeEach(function () { trans = new Transport({ suggestCompression: true }); @@ -366,7 +366,7 @@ describe('Transport Class', function () { function (done) { trans.sniff(function () { expect(trans.connectionPool.setHosts.callCount).to.eql(1); - var hosts = trans.connectionPool.setHosts.lastCall.args[0]; + const hosts = trans.connectionPool.setHosts.lastCall.args[0]; expect(hosts).to.have.length(2); @@ -386,7 +386,7 @@ describe('Transport Class', function () { // check that it's getting the suggestCompression setting trans.sniff(function () { expect(trans.connectionPool.setHosts).to.have.property('callCount', 1); - var hosts = trans.connectionPool.setHosts.lastCall.args[0]; + const hosts = trans.connectionPool.setHosts.lastCall.args[0]; expect(hosts).to.have.length(2); expect(hosts[0]).to.have.property('suggestCompression', true); expect(hosts[1]).to.have.property('suggestCompression', true); @@ -423,7 +423,7 @@ describe('Transport Class', function () { describe('#request', function () { it('logs when it begins', function (done) { - var trans = new Transport(); + const trans = new Transport(); stub(trans.log, 'debug'); stub(trans.connectionPool, 'select', function (cb) { // simulate "no connections" @@ -437,7 +437,7 @@ describe('Transport Class', function () { }); it('rejects GET requests with a body (callback)', function (done) { - var trans = new Transport(); + const trans = new Transport(); stub(trans.log, 'debug'); stub(trans.connectionPool, 'select', function (cb) { // simulate "no connections" @@ -454,7 +454,7 @@ describe('Transport Class', function () { }); it('rejects GET requests with a body (promise)', function (done) { - var trans = new Transport(); + const trans = new Transport(); stub(trans.log, 'debug'); stub(trans.connectionPool, 'select', function (cb) { // simulate "no connections" @@ -475,11 +475,11 @@ describe('Transport Class', function () { describe('gets a body', function () { it('serializes it', function (done) { - var trans = new Transport({ + const trans = new Transport({ hosts: 'localhost' }); - var conn = getConnection(trans); - var body = { + const conn = getConnection(trans); + const body = { _id: 'simple body', name: 'ഢധയമബ' }; @@ -495,11 +495,11 @@ describe('Transport Class', function () { }); }); it('serializes bulk bodies', function (done) { - var trans = new Transport({ + const trans = new Transport({ hosts: 'localhost' }); - var conn = getConnection(trans); - var body = [ + const conn = getConnection(trans); + const body = [ { _id: 'simple body' }, { name: 'ഢധയമബ' } ]; @@ -522,11 +522,11 @@ describe('Transport Class', function () { describe('gets a body it cant serialize', function () { it('throws an error', function () { - var trans = new Transport({ + const trans = new Transport({ hosts: 'localhost' }); getConnection(trans); - var body = { + const body = { _id: 'circular body' }; body.body = body; @@ -541,7 +541,7 @@ describe('Transport Class', function () { describe('when selecting a connection', function () { it('logs a warning, and responds with NoConnection when it receives nothing', function (done) { - var trans = new Transport(); + const trans = new Transport(); stub(trans.log, 'warning'); trans.request({}, function (err, body, status) { expect(trans.log.warning.callCount).to.eql(1); @@ -552,7 +552,7 @@ describe('Transport Class', function () { }); }); it('quits if a sync selector throws an error', function () { - var trans = new Transport({ + const trans = new Transport({ hosts: 'localhost', selector: function () { throw new Error('I am broken'); @@ -564,7 +564,7 @@ describe('Transport Class', function () { }); }); it('quits if gets an error from an async selector', function () { - var trans = new Transport({ + const trans = new Transport({ hosts: 'localhost', selector: function (connections, cb) { process.nextTick(function () { @@ -578,10 +578,10 @@ describe('Transport Class', function () { }); }); it('calls connection#request once it gets one', function (done) { - var trans = new Transport({ + const trans = new Transport({ hosts: 'localhost' }); - var conn = getConnection(trans); + const conn = getConnection(trans); stub(conn, 'request', function () { done(); @@ -595,9 +595,9 @@ describe('Transport Class', function () { // create a test that checks N retries function testRetries(retries) { return function (done) { - var randomSelector = require('../../../src/lib/selectors/random'); - var connections; - var attempts = 0; + const randomSelector = require('../../../src/lib/selectors/random'); + let connections; + let attempts = 0; function failRequest(params, cb) { attempts++; process.nextTick(function () { @@ -605,7 +605,7 @@ describe('Transport Class', function () { }); } - var trans = new Transport({ + const trans = new Transport({ hosts: _.map(new Array(retries + 1), function (val, i) { return 'localhost/' + i; }), @@ -639,24 +639,24 @@ describe('Transport Class', function () { describe('return value', function () { it('returns an object with an abort() method when a callback is sent', function () { - var tran = new Transport(); + const tran = new Transport(); shortCircuitRequest(tran); - var ret = tran.request({}, _.noop); + const ret = tran.request({}, _.noop); expect(ret).to.be.a('object'); expect(ret.abort).to.be.a('function'); }); it('the object is a promise when a callback is not suplied', function () { - var tran = new Transport(); + const tran = new Transport(); shortCircuitRequest(tran); - var ret = tran.request({}); + const ret = tran.request({}); expect(ret.then).to.be.a('function'); expect(ret.abort).to.be.a('function'); ret.then(_.noop, _.noop); // prevent complaining from bluebird }); it('promise is always pulled from the defer created by this.defer()', function () { - var fakePromise = {}; - var origDefer = Transport.prototype.defer; - var tran = new Transport({ + const fakePromise = {}; + const origDefer = Transport.prototype.defer; + const tran = new Transport({ defer: function () { return { resolve: _.noop, @@ -666,7 +666,7 @@ describe('Transport Class', function () { } }); shortCircuitRequest(tran); - var ret = tran.request({}); + const ret = tran.request({}); Transport.prototype.defer = origDefer; expect(ret).to.be(fakePromise); expect(ret.abort).to.be.a('function'); @@ -677,7 +677,7 @@ describe('Transport Class', function () { if (process && process.hasOwnProperty('domain')) { it('works without a domain', function () { expect(process.domain).to.be(null); - var tran = new Transport(); + const tran = new Transport(); shortCircuitRequest(tran); tran.request({}, function () { expect(process.domain).to.be(null); @@ -686,12 +686,12 @@ describe('Transport Class', function () { it('binds the callback to the correct domain', function () { expect(process.domain).to.be(null); - var domain = require('domain').create(); + const domain = require('domain').create(); domain.run(function () { - var tran = new Transport(); + const tran = new Transport(); shortCircuitRequest(tran); expect(process.domain).not.to.be(null); - var startingDomain = process.domain + const startingDomain = process.domain; tran.request({}, function () { expect(process.domain).not.to.be(null); expect(process.domain).to.be(startingDomain); @@ -704,24 +704,24 @@ describe('Transport Class', function () { describe('aborting', function () { it('prevents the request from starting if called in the same tick', function () { - var tran = new Transport({ + const tran = new Transport({ host: 'localhost' }); - var con = getConnection(tran); + const con = getConnection(tran); stub(con, 'request', function () { throw new Error('Request should not have been called.'); }); - var ret = tran.request({}); + const ret = tran.request({}); ret.abort(); }); it('calls the function returned by the connector if it has been called', function (done) { - var tran = new Transport({ + const tran = new Transport({ host: 'localhost' }); - var con = getConnection(tran); + const con = getConnection(tran); stub(con, 'request', function () { process.nextTick(function () { ret.abort(); @@ -734,16 +734,16 @@ describe('Transport Class', function () { var ret = tran.request({}); }); it('ignores the response from the connection when the connector does not support aborting', function (done) { - var tran = new Transport({ + const tran = new Transport({ host: 'localhost' }); - var con = getConnection(tran); + const con = getConnection(tran); stub(con, 'request', function (params, cb) { cb(); }); - var ret = tran.request({}, function () { + const ret = tran.request({}, function () { throw new Error('Callback should not have been called.'); }); ret.abort(); @@ -753,11 +753,11 @@ describe('Transport Class', function () { describe('timeout', function () { it('uses 30 seconds for the default', function () { - var clock = sinon.useFakeTimers('setTimeout', 'clearTimeout'); + const clock = sinon.useFakeTimers('setTimeout', 'clearTimeout'); stub.autoRelease(clock); - var tran = new Transport({}); + const tran = new Transport({}); - var prom = tran.request({}); + const prom = tran.request({}); // disregard promise, prevent bluebird's warnings prom.then(_.noop, _.noop); @@ -768,13 +768,13 @@ describe('Transport Class', function () { }); }); it('inherits the requestTimeout from the transport', function () { - var clock = sinon.useFakeTimers('setTimeout', 'clearTimeout'); + const clock = sinon.useFakeTimers('setTimeout', 'clearTimeout'); stub.autoRelease(clock); - var tran = new Transport({ + const tran = new Transport({ requestTimeout: 5000 }); - var prom = tran.request({}); + const prom = tran.request({}); // disregard promise, prevent bluebird's warnings prom.then(_.noop, _.noop); @@ -788,9 +788,9 @@ describe('Transport Class', function () { _.each([false, 0, null], function (falsy) { it('skips the timeout when it is ' + falsy, function () { - var clock = sinon.useFakeTimers(); + const clock = sinon.useFakeTimers(); stub.autoRelease(clock); - var tran = new Transport({}); + const tran = new Transport({}); stub(tran.connectionPool, 'select', function () {}); tran.request({ @@ -806,7 +806,7 @@ describe('Transport Class', function () { describe('#setHosts', function () { it('accepts strings, host objects, and host configs', function () { - var trans = new Transport({ suggestCompression: true }); + const trans = new Transport({ suggestCompression: true }); stub(trans.connectionPool, 'setHosts'); trans.setHosts([ @@ -816,7 +816,7 @@ describe('Transport Class', function () { ]); sinon.assert.calledOnce(trans.connectionPool.setHosts); - var host, hosts = trans.connectionPool.setHosts.firstCall.args[0]; + let host, hosts = trans.connectionPool.setHosts.firstCall.args[0]; expect(hosts).to.have.length(3); @@ -842,7 +842,7 @@ describe('Transport Class', function () { describe('#close', function () { it('proxies the call to it\'s log and connection pool', function () { - var tran = new Transport(); + const tran = new Transport(); stub(tran.connectionPool, 'close'); stub(tran.log, 'close'); diff --git a/test/unit/specs/transport_with_server.js b/test/unit/specs/transport_with_server.js index 1f55a7599..81388fd7c 100644 --- a/test/unit/specs/transport_with_server.js +++ b/test/unit/specs/transport_with_server.js @@ -1,14 +1,14 @@ -var Transport = require('../../../src/lib/transport'); -var ConnectionPool = require('../../../src/lib/connection_pool'); -var Host = require('../../../src/lib/host'); -var errors = require('../../../src/lib/errors'); -var expect = require('expect.js'); - -var sinon = require('sinon'); -var nock = require('../../mocks/server.js'); -var through2 = require('through2'); -var _ = require('lodash'); -var stub = require('../../utils/auto_release_stub').make(); +const Transport = require('../../../src/lib/transport'); +const ConnectionPool = require('../../../src/lib/connection_pool'); +const Host = require('../../../src/lib/host'); +const errors = require('../../../src/lib/errors'); +const expect = require('expect.js'); + +const sinon = require('sinon'); +const nock = require('../../mocks/server.js'); +const through2 = require('through2'); +const _ = require('lodash'); +const stub = require('../../utils/auto_release_stub').make(); /** * Allows the tests call #request() without it doing anything past trying to select @@ -28,7 +28,7 @@ function getConnection(transport, status) { describe('Transport + Mock server', function () { describe('#request', function () { describe('server responds', function () { - var serverMock; + let serverMock; before(function () { serverMock = nock('http://localhost/') @@ -79,7 +79,7 @@ describe('Transport + Mock server', function () { describe('with a 400 status code', function () { it('passes back a 400/BadRequest error', function (done) { - var trans = new Transport({ + const trans = new Transport({ hosts: 'localhost' }); @@ -98,7 +98,7 @@ describe('Transport + Mock server', function () { describe('with a 404 status code', function () { describe('and castExists is set', function () { it('sends back false', function (done) { - var trans = new Transport({ + const trans = new Transport({ hosts: 'localhost' }); @@ -115,7 +115,7 @@ describe('Transport + Mock server', function () { }); describe('and the castExists param is not set', function () { it('sends back a 404/NotFound error', function (done) { - var trans = new Transport({ + const trans = new Transport({ hosts: 'localhost' }); @@ -134,7 +134,7 @@ describe('Transport + Mock server', function () { describe('with a 500 status code', function () { it('passes back a 500/InternalServerError error', function (done) { - var trans = new Transport({ + const trans = new Transport({ hosts: 'localhost' }); @@ -152,7 +152,7 @@ describe('Transport + Mock server', function () { describe('with a 530 status code', function () { it('passes back a Generic error', function (done) { - var trans = new Transport({ + const trans = new Transport({ hosts: 'localhost' }); @@ -170,7 +170,7 @@ describe('Transport + Mock server', function () { describe('with a 200 status code', function () { describe('and the castExists param is set', function () { it('sends back true', function (done) { - var trans = new Transport({ + const trans = new Transport({ hosts: 'localhost' }); @@ -187,7 +187,7 @@ describe('Transport + Mock server', function () { }); describe('with a partial response body', function () { it('sends back a serialization error', function (done) { - var trans = new Transport({ + const trans = new Transport({ hosts: 'localhost' }); @@ -203,7 +203,7 @@ describe('Transport + Mock server', function () { }); describe('with a valid response body', function () { it('sends back the body and status code with no error', function (done) { - var trans = new Transport({ + const trans = new Transport({ hosts: 'localhost' }); @@ -222,7 +222,7 @@ describe('Transport + Mock server', function () { describe('with plain text', function () { it('notices the content-type header and returns the text', function (done) { - var trans = new Transport({ + const trans = new Transport({ hosts: 'localhost' }); @@ -239,13 +239,13 @@ describe('Transport + Mock server', function () { describe('return value', function () { it('resolves the promise it with the response body', function (done) { - var serverMock = nock('http://esbox.1.com/') + const serverMock = nock('http://esbox.1.com/') .get('/') .reply(200, { good: 'day' }); - var tran = new Transport({ + const tran = new Transport({ hosts: 'http://esbox.1.com/' }); @@ -260,13 +260,13 @@ describe('Transport + Mock server', function () { describe('timeout', function () { it('clears the timeout when the request is complete', function () { - var clock = sinon.useFakeTimers('setTimeout', 'clearTimeout'); + const clock = sinon.useFakeTimers('setTimeout', 'clearTimeout'); stub.autoRelease(clock); - var tran = new Transport({ + const tran = new Transport({ host: 'http://localhost:9200/' }); - var server = nock('http://localhost:9200/') + const server = nock('http://localhost:9200/') .get('/') .reply(200, { i: 'am here' @@ -282,11 +282,11 @@ describe('Transport + Mock server', function () { }); it('timeout responds with a requestTimeout error', function (done) { - var tran = new Transport({ + const tran = new Transport({ host: 'http://localhost:9200/' }); - var server = nock('http://localhost:9200/') + const server = nock('http://localhost:9200/') .get('/') .delay(1000) .reply(200, { @@ -304,13 +304,13 @@ describe('Transport + Mock server', function () { describe('sniffOnConnectionFault', function () { it('schedules a sniff when sniffOnConnectionFault is set and a connection failes', function () { - var clock = sinon.useFakeTimers('setTimeout'); + const clock = sinon.useFakeTimers('setTimeout'); stub.autoRelease(clock); - var serverMock = nock('http://esbox.1.com/') + const serverMock = nock('http://esbox.1.com/') .get('/') .reply(200, function () { - var str = through2(function (chunk, enc, cb) { + const str = through2(function (chunk, enc, cb) { cb(new Error('force error')); }); @@ -324,7 +324,7 @@ describe('Transport + Mock server', function () { stub(ConnectionPool.prototype, '_onConnectionDied'); stub(Transport.prototype, 'sniff'); - var tran = new Transport({ + const tran = new Transport({ hosts: 'http://esbox.1.com/', sniffOnConnectionFault: true, maxRetries: 0 @@ -343,7 +343,7 @@ describe('Transport + Mock server', function () { expect(tran.sniff.callCount).to.eql(0); expect(_.size(clock.timers)).to.eql(1); - var timeout = _.values(clock.timers).pop(); + const timeout = _.values(clock.timers).pop(); timeout.func(); expect(tran.sniff.callCount).to.eql(1); }); diff --git a/test/unit/specs/utils.js b/test/unit/specs/utils.js index 0c6f6fcfc..9cf3fd343 100644 --- a/test/unit/specs/utils.js +++ b/test/unit/specs/utils.js @@ -1,7 +1,7 @@ -var _ = require('../../../src/lib/utils'); -var expect = require('expect.js'); +const _ = require('../../../src/lib/utils'); +const expect = require('expect.js'); -var stub = require('../../utils/auto_release_stub').make(); +const stub = require('../../utils/auto_release_stub').make(); describe('Utils', function () { @@ -238,14 +238,14 @@ describe('Utils', function () { describe('#deepMerge', function () { it('returns the same object that was passed', function () { - var obj = { + const obj = { foo: 'bar' }; expect(_.deepMerge(obj, { bar: 'baz' })).to.eql(obj); }); it('concats arrays', function () { - var obj = { + const obj = { foo: ['bax', 'boz'] }; _.deepMerge(obj, { foo: ['boop'] }); @@ -253,7 +253,7 @@ describe('Utils', function () { }); it('wont merge values of different types', function () { - var obj = { + const obj = { foo: ['stop', 'foo', 'stahp'] }; _.deepMerge(obj, { foo: 'string' }); @@ -261,7 +261,7 @@ describe('Utils', function () { }); it('works recursively', function () { - var obj = { + const obj = { foo: 'bar', bax: { foo: ['bax', 'boz'] @@ -275,8 +275,8 @@ describe('Utils', function () { describe('#createArray', function () { it('accepts an array of things and simply returns a copy of it', function () { - var inp = [{ a: 1 }, 'pizza']; - var out = _.createArray(inp); + const inp = [{ a: 1 }, 'pizza']; + const out = _.createArray(inp); expect(out).to.eql(inp); expect(out).to.not.be(inp); }); @@ -309,28 +309,28 @@ describe('Utils', function () { * _.funcEnum(object, key, opts, default); */ it('tests if the value at key in object is a function, returns it if so', function () { - var config = { + const config = { func: function () {} }; expect(_.funcEnum(config, 'func', {}, 'toString')) .to.be(config.func); }); it('tests if the value at key in object is undefined, returns the option at key default if so', function () { - var config = { + const config = { func: undefined }; expect(_.funcEnum(config, 'func', {}, 'toString')) .to.be(Object.prototype.toString); }); it('tests if the value at key in object is a string, returns the option at that key if so', function () { - var config = { + const config = { 'config key name': 'toString' }; expect(_.funcEnum(config, 'config key name', { toString: 'pizza' }, 'toJSON')) .to.be('pizza'); }); it('throws an informative error if the selection if invalid', function () { - var config = { + const config = { 'config': 'val' }; @@ -350,15 +350,15 @@ describe('Utils', function () { describe('#applyArgs', function () { _.times(10, function (i) { - var method = i > 5 ? 'apply' : 'call'; - var argCount = i + 1; - var slice = 1; + const method = i > 5 ? 'apply' : 'call'; + const argCount = i + 1; + const slice = 1; it('uses ' + method + ' with ' + i + ' args', function () { - var func = function () {}; + const func = function () {}; stub(func, method); - var args = _.map(new Array(i), function (val, i) { return i; }); + const args = _.map(new Array(i), function (val, i) { return i; }); _.applyArgs(func, null, args); expect(func[method].callCount).to.eql(1); @@ -371,11 +371,11 @@ describe('Utils', function () { it('slices the arguments properly before calling ' + method + ' with ' + argCount + ' args sliced at ' + slice, function () { - var func = function () {}; + const func = function () {}; stub(func, method); - var args = _.map(new Array(argCount), function (val, i) { return i; }); - var expected = args.slice(slice); + const args = _.map(new Array(argCount), function (val, i) { return i; }); + const expected = args.slice(slice); _.applyArgs(func, null, args, slice); expect(func[method].callCount).to.eql(1); @@ -397,14 +397,14 @@ describe('Utils', function () { }); if (require('stream').Writable) { - var MockWritableStream = require('../../mocks/writable_stream'); + const MockWritableStream = require('../../mocks/writable_stream'); it('ignores empty stream', function () { - var stream = new MockWritableStream(); + const stream = new MockWritableStream(); expect(_.getUnwrittenFromStream(stream)).to.be(''); }); it('returns only what is in the buffer', function () { - var stream = new MockWritableStream(); + const stream = new MockWritableStream(); stream.write('hot'); stream.write('dog'); expect(_.getUnwrittenFromStream(stream)).to.be('dog'); diff --git a/test/unit/specs/yaml_test_reader.js b/test/unit/specs/yaml_test_reader.js index 4e101c1df..8c0fabd48 100644 --- a/test/unit/specs/yaml_test_reader.js +++ b/test/unit/specs/yaml_test_reader.js @@ -1,7 +1,7 @@ describe('Yaml Test Reader', function () { - var YamlDoc = require('../../integration/yaml_suite/yaml_doc'); - var compare = YamlDoc.compareRangeToVersion; - var expect = require('expect.js'); + const YamlDoc = require('../../integration/yaml_suite/yaml_doc'); + const compare = YamlDoc.compareRangeToVersion; + const expect = require('expect.js'); describe('version range comparison', function () { it('supports unbounded ranges', function () { diff --git a/test/utils/auto_release_stub.js b/test/utils/auto_release_stub.js index 7ae531de7..a77d99489 100644 --- a/test/utils/auto_release_stub.js +++ b/test/utils/auto_release_stub.js @@ -1,15 +1,15 @@ -var sinon = require('sinon'); +const sinon = require('sinon'); exports.make = function () { - var log = []; + const log = []; afterEach(function () { - var stub; + let stub; while (stub = log.pop()) { stub.restore(); } }); - var stubber = function () { + const stubber = function () { log.push(sinon.stub.apply(sinon, arguments)); }; diff --git a/test/utils/expect_sub_object.js b/test/utils/expect_sub_object.js index 013be8a5b..7ef8f4976 100644 --- a/test/utils/expect_sub_object.js +++ b/test/utils/expect_sub_object.js @@ -1,5 +1,5 @@ -var _ = require('lodash'); -var expect = require('expect.js'); +const _ = require('lodash'); +const expect = require('expect.js'); module.exports = function expectSubObject(obj, subObj) { _.forOwn(subObj, function (val, prop) { if (typeof obj[prop] === 'object') { diff --git a/test/utils/jenkins-reporter.js b/test/utils/jenkins-reporter.js index 48c5de673..238325f0e 100644 --- a/test/utils/jenkins-reporter.js +++ b/test/utils/jenkins-reporter.js @@ -6,16 +6,16 @@ */ module.exports = JenkinsReporter; -var Base = require('mocha/lib/reporters/base'); -var _ = require('lodash'); -var chalk = require('chalk'); -var makeJUnitXml = require('./make_j_unit_xml'); -var fs = require('fs'); -var path = require('path'); -var inspect = require('util').inspect; - -var log = (function () { - var locked = _.bind(process.stdout.write, process.stdout); +const Base = require('mocha/lib/reporters/base'); +const _ = require('lodash'); +const chalk = require('chalk'); +const makeJUnitXml = require('./make_j_unit_xml'); +const fs = require('fs'); +const path = require('path'); +const inspect = require('util').inspect; + +const log = (function () { + const locked = _.bind(process.stdout.write, process.stdout); return function (str) { if (typeof str !== 'string') { str = inspect(str); @@ -24,9 +24,9 @@ var log = (function () { }; }()); -var integration = _.find(process.argv, function (arg) { return arg.indexOf('test/integration') > -1; }); -var unit = _.find(process.argv, function (arg) { return arg.indexOf('test/unit') > -1; }); -var output; +const integration = _.find(process.argv, function (arg) { return arg.indexOf('test/integration') > -1; }); +const unit = _.find(process.argv, function (arg) { return arg.indexOf('test/unit') > -1; }); +let output; if (unit) { output = path.join(__dirname, '../junit-node-unit.xml'); @@ -39,16 +39,16 @@ if (unit) { function JenkinsReporter(runner) { Base.call(this, runner); - var stats = this.stats; - var pass = 0; - var pending = 0; - var fail = 0; - var rootSuite = { + const stats = this.stats; + let pass = 0; + let pending = 0; + let fail = 0; + const rootSuite = { results: [], suites: [] }; - var stack = [rootSuite]; + const stack = [rootSuite]; function indt() { return (new Array(stack.length + 1)).join(' '); @@ -105,7 +105,7 @@ function JenkinsReporter(runner) { log(chalk.red('x')); } - var errMsg = void 0; + let errMsg = void 0; if (test.err) { errMsg = test.err.stack || test.err.toString(); @@ -146,7 +146,7 @@ function JenkinsReporter(runner) { runner.on('hook end', function (hook) { if (hook.title.indexOf('"after each"') > -1 && stack[0] && stack[0].results.length) { - var result = _.last(stack[0].results); + const result = _.last(stack[0].results); result.stdout += stack[0].stdout; result.stderr += stack[0].stderr; stack[0].stdout = stack[0].stderr = ''; @@ -155,10 +155,10 @@ function JenkinsReporter(runner) { runner.on('end', function () { restoreStdio(); - var xml = makeJUnitXml('node ' + process.version, { + const xml = makeJUnitXml('node ' + process.version, { stats: stats, suites: _.map(rootSuite.suites, function removeElements(suite) { - var s = { + const s = { name: suite.name, start: suite.start, time: suite.time || 0, @@ -186,8 +186,8 @@ function JenkinsReporter(runner) { // overload the write methods on stdout and stderr ['stdout', 'stderr'].forEach(function (name) { - var obj = process[name]; - var orig = obj.write; + const obj = process[name]; + const orig = obj.write; obj.write = function (chunk) { if (stack[0]) { stack[0][name] = (stack[0][name] || '') + chunk; diff --git a/test/utils/make_j_unit_xml.js b/test/utils/make_j_unit_xml.js index 6474afa12..56da1086c 100644 --- a/test/utils/make_j_unit_xml.js +++ b/test/utils/make_j_unit_xml.js @@ -24,17 +24,17 @@ */ module.exports = makeJUnitXml; -var testXml = require('xmlbuilder'); -var suites = testXml.create('testsuites'); -var suiteCount = 0; -var moment = require('moment'); -var _ = require('lodash'); -var chalk = require('chalk'); +const testXml = require('xmlbuilder'); +const suites = testXml.create('testsuites'); +let suiteCount = 0; +const moment = require('moment'); +const _ = require('lodash'); +const chalk = require('chalk'); function makeJUnitXml(runnerName, testDetails) { _.each(testDetails.suites, function serializeSuite(suiteInfo) { - var suite = suites.ele('testsuite', { + const suite = suites.ele('testsuite', { package: 'elasticsearch-js', id: suiteCount++, name: suiteInfo.name, @@ -47,8 +47,8 @@ function makeJUnitXml(runnerName, testDetails) { }); _.each(suiteInfo.results, function (testInfo) { - var section; - var integration = false; + let section; + let integration = false; if (suiteInfo.name.match(/\/.*\.yaml$/)) { section = suiteInfo.name.split('/').slice(0, -1).join('/').replace(/\./g, '/'); @@ -61,7 +61,7 @@ function makeJUnitXml(runnerName, testDetails) { integration = true; } - var testcase = suite.ele('testcase', { + const testcase = suite.ele('testcase', { name: testInfo.name, time: (testInfo.time || 0) / 1000, classname: runnerName + (integration ? ' - integration' : '') + '.' + section @@ -93,8 +93,8 @@ function makeJUnitXml(runnerName, testDetails) { } function giveOutput(el, info) { - var out = info.stdout.trim(); - var err = info.stderr.trim(); + const out = info.stdout.trim(); + const err = info.stderr.trim(); if (out) { el.ele('system-out', {}).cdata(chalk.stripColor(out)); diff --git a/test/utils/server.js b/test/utils/server.js index bb1770e04..d8a3bc5c7 100644 --- a/test/utils/server.js +++ b/test/utils/server.js @@ -1,16 +1,16 @@ /* eslint-disable import/no-unresolved */ -var express = require('express'); -var http = require('http'); -var fs = require('fs'); -var _ = require('lodash'); -var async = require('async'); -var root = require('path').join(__dirname, '../..'); -var browserify = require('browserify'); -var pkg = require(root + '/package.json'); -var unitSpecDir = root + '/test/unit/specs'; -var browserBuildsDir = root + '/test/unit/browser_builds'; - -var testFiles = {}; +const express = require('express'); +const http = require('http'); +const fs = require('fs'); +const _ = require('lodash'); +const async = require('async'); +const root = require('path').join(__dirname, '../..'); +const browserify = require('browserify'); +const pkg = require(root + '/package.json'); +const unitSpecDir = root + '/test/unit/specs'; +const browserBuildsDir = root + '/test/unit/browser_builds'; + +const testFiles = {}; testFiles.unit = _(fs.readdirSync(unitSpecDir)) .difference([ @@ -33,12 +33,12 @@ testFiles.build = fs.readdirSync(browserBuildsDir) return browserBuildsDir + '/' + file; } - return null + return null; }) .filter(Boolean); // generic aliasify instance -var aliasify = require('aliasify').configure({ +const aliasify = require('aliasify').configure({ aliases: pkg.browser, excludeExtensions: 'json', // verbose: false, @@ -46,7 +46,7 @@ var aliasify = require('aliasify').configure({ }); // queue for bundle requests, two at a time -var bundleQueue = async.queue(function (task, done) { +const bundleQueue = async.queue(function (task, done) { task(done); }, 2); @@ -54,16 +54,16 @@ var bundleQueue = async.queue(function (task, done) { function bundleTests(name) { return function (req, res, next) { bundleQueue.push(function (_cb) { - var done = function (err) { + const done = function (err) { if (err) { return next(err); } _cb(err); }; res.set('Content-Type', 'application/javascript'); - var b = browserify(testFiles[name]); + const b = browserify(testFiles[name]); b.transform(aliasify); - var str = b.bundle({ + const str = b.bundle({ insertGlobals: true }); @@ -81,7 +81,7 @@ function sendFile(file) { }; } -var app = express(); +const app = express(); app .use(app.router) diff --git a/webpack_config/angular.js b/webpack_config/angular.js index c5877d037..bd7eabc24 100644 --- a/webpack_config/angular.js +++ b/webpack_config/angular.js @@ -1,5 +1,5 @@ -const DefinePlugin = require('webpack/lib/DefinePlugin') -const { ignoreLoader, rel } = require('./lib') +const DefinePlugin = require('webpack/lib/DefinePlugin'); +const { ignoreLoader, rel } = require('./lib'); module.exports = { context: rel('src'), @@ -22,4 +22,4 @@ module.exports = { 'process.env.NODE_ENV': '"production"', }), ], -} +}; diff --git a/webpack_config/browser.js b/webpack_config/browser.js index c5a09c60f..d9fad28c1 100644 --- a/webpack_config/browser.js +++ b/webpack_config/browser.js @@ -1,5 +1,5 @@ -const DefinePlugin = require('webpack/lib/DefinePlugin') -const { ignoreLoader, rel } = require('./lib') +const DefinePlugin = require('webpack/lib/DefinePlugin'); +const { ignoreLoader, rel } = require('./lib'); module.exports = { context: rel('src'), @@ -23,4 +23,4 @@ module.exports = { 'process.env.NODE_ENV': '"production"', }), ], -} +}; diff --git a/webpack_config/jquery.js b/webpack_config/jquery.js index 93c7713fa..2b3f8f790 100644 --- a/webpack_config/jquery.js +++ b/webpack_config/jquery.js @@ -1,5 +1,5 @@ -const DefinePlugin = require('webpack/lib/DefinePlugin') -const { ignoreLoader, rel } = require('./lib') +const DefinePlugin = require('webpack/lib/DefinePlugin'); +const { ignoreLoader, rel } = require('./lib'); module.exports = { context: rel('src'), @@ -22,4 +22,4 @@ module.exports = { 'process.env.NODE_ENV': '"production"', }), ], -} +}; diff --git a/webpack_config/lib.js b/webpack_config/lib.js index b7107e631..826853659 100644 --- a/webpack_config/lib.js +++ b/webpack_config/lib.js @@ -1,13 +1,13 @@ -const rel = require('path').resolve.bind(null, __dirname, '..') +const rel = require('path').resolve.bind(null, __dirname, '..'); function ignoreLoader(ignores) { return { loader: 'null-loader', test(path) { - return ignores.some(ignore => path.includes(ignore)) + return ignores.some(ignore => path.includes(ignore)); }, - } + }; } function jsLoader() { @@ -15,7 +15,7 @@ function jsLoader() { loader: 'babel-loader', test: /\.js$/, include: rel('src'), - } + }; } -module.exports = { ignoreLoader, jsLoader, rel } +module.exports = { ignoreLoader, jsLoader, rel }; From 058569d4f814e96c31e4f28c2def8e32701d48ac Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 18:56:26 -0700 Subject: [PATCH 37/61] [eslint] remove exception for `no-var`, fix violations --- .eslintrc.yaml | 1 - grunt/utils.js | 2 +- src/lib/client_action.js | 5 +++-- src/lib/connectors/jquery.js | 2 +- src/lib/log.js | 5 +++-- src/lib/transport/sniff_on_connection_fault.js | 2 +- src/lib/utils.js | 5 +++-- test/integration/yaml_suite/yaml_doc.js | 6 +++--- test/mocks/browser_server.js | 4 ++-- test/unit/specs/http_connector.js | 3 ++- test/unit/specs/transport.js | 3 ++- 11 files changed, 21 insertions(+), 17 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 1d2b8ec67..a13d74756 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -2,7 +2,6 @@ extends: "@elastic/eslint-config-kibana" rules: - no-var: warn no-unused-vars: warn semi: warn one-var: warn diff --git a/grunt/utils.js b/grunt/utils.js index 32b4b88dc..8a05e1473 100644 --- a/grunt/utils.js +++ b/grunt/utils.js @@ -6,7 +6,7 @@ const stable = pkg.config.supported_es_branches; const unstable = pkg.config.unstable_es_branches; const branches = [].concat(stable, unstable); -var utils = { +const utils = { branchSuffix: function (branch) { return branch === utils.branches._default ? '' : '_' + _.snakeCase(branch); }, diff --git a/src/lib/client_action.js b/src/lib/client_action.js index 975d7bdfe..d54c1e3e8 100644 --- a/src/lib/client_action.js +++ b/src/lib/client_action.js @@ -327,8 +327,8 @@ function exec(transport, spec, params, cb) { case 'method': request.method = _.toUpperString(params[key]); break; - default: - var paramSpec = spec.params[key]; + default: { + const paramSpec = spec.params[key]; if (paramSpec) { // param keys don't always match the param name, in those cases it's stored in the param def as "name" paramSpec.name = paramSpec.name || key; @@ -346,6 +346,7 @@ function exec(transport, spec, params, cb) { } else { query[key] = params[key]; } + } } } } diff --git a/src/lib/connectors/jquery.js b/src/lib/connectors/jquery.js index a61da5c38..51b4f3cd3 100644 --- a/src/lib/connectors/jquery.js +++ b/src/lib/connectors/jquery.js @@ -26,7 +26,7 @@ JqueryConnector.prototype.request = function (params, cb) { done: cb }; - var jqXHR = jQuery.ajax(ajax) + const jqXHR = jQuery.ajax(ajax) .done(function (data) { cb(null, data, jqXHR.statusCode(), { 'content-type': jqXHR.getResponseHeader('content-type') diff --git a/src/lib/log.js b/src/lib/log.js index fc4f4a511..6c53c8220 100644 --- a/src/lib/log.js +++ b/src/lib/log.js @@ -150,11 +150,12 @@ Log.levels = [ */ Log.parseLevels = function (input) { switch (typeof input) { - case 'string': - var i = _.indexOf(Log.levels, input); + case 'string': { + const i = _.indexOf(Log.levels, input); if (i >= 0) { return Log.levels.slice(0, i + 1); } + } /* fall through */ case 'object': if (_.isArray(input)) { diff --git a/src/lib/transport/sniff_on_connection_fault.js b/src/lib/transport/sniff_on_connection_fault.js index 06ce3acdd..c775ce4af 100644 --- a/src/lib/transport/sniff_on_connection_fault.js +++ b/src/lib/transport/sniff_on_connection_fault.js @@ -17,7 +17,7 @@ module.exports = function setupSniffOnConnectionFault(transport) { // do the actual sniff, if the sniff is unable to // connect to a node this function will be called again by the connectionPool - var work = function () { + const work = function () { work.timerId = transport._timeout(work.timerId); transport.sniff(); }; diff --git a/src/lib/utils.js b/src/lib/utils.js index e1303a5e4..02ab41293 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -343,8 +343,8 @@ _.funcEnum = function (config, name, opts, def) { return opts[val]; } /* falls through */ - default: - var err = 'Invalid ' + name + ' "' + val + '", expected a function'; + default: { + let err = 'Invalid ' + name + ' "' + val + '", expected a function'; switch (_.size(opts)) { case 0: break; @@ -356,6 +356,7 @@ _.funcEnum = function (config, name, opts, def) { break; } throw new TypeError(err); + } } }; diff --git a/test/integration/yaml_suite/yaml_doc.js b/test/integration/yaml_suite/yaml_doc.js index 237c08f51..2a4087966 100644 --- a/test/integration/yaml_suite/yaml_doc.js +++ b/test/integration/yaml_suite/yaml_doc.js @@ -403,11 +403,11 @@ YamlDoc.prototype = { } const client = clientManager.get(); - var clientActionName = _.map(action.split('.'), _.camelCase).join('.'); + const clientActionName = _.map(action.split('.'), _.camelCase).join('.'); const clientAction = this.get(clientActionName, client); _.assign(inputParams, args[action]); - var params = _.transform(inputParams, _.bind(function (params, val, name) { + const params = _.transform(inputParams, _.bind(function (params, val, name) { const camelName = _.camelCase(name); // search through the params and url peices to find this param name @@ -426,7 +426,7 @@ YamlDoc.prototype = { } // for ercursively traversing the params to replace '$stashed' vars - var transformObject = function (vals, val, i) { + const transformObject = function (vals, val, i) { if (_.isString(val)) { val = (val[0] === '$') ? this.get(val) : val; } else if (_.isPlainObject(val) || _.isArray(val)) { diff --git a/test/mocks/browser_server.js b/test/mocks/browser_server.js index 7e9e66ded..ba8828266 100644 --- a/test/mocks/browser_server.js +++ b/test/mocks/browser_server.js @@ -30,7 +30,7 @@ const server = new XhrServer(function (request) { server.start(); -var mockNock = module.exports = function (url) { +const mockNock = module.exports = function (url) { const parsedUrl = parseUrl(url); const req = { method: 'GET', @@ -38,7 +38,7 @@ var mockNock = module.exports = function (url) { times: 1 }; - var modifyReq = { + const modifyReq = { get: function (path) { req.path = path; req.method = 'GET'; diff --git a/test/unit/specs/http_connector.js b/test/unit/specs/http_connector.js index c9b66acc3..737ed9998 100644 --- a/test/unit/specs/http_connector.js +++ b/test/unit/specs/http_connector.js @@ -481,12 +481,13 @@ describe('Http Connector', function () { const fixture = _.partial(path.join, __dirname, '../../fixtures'); let timeout; // start the timeout once we hear back from the client + let client; // eslint-disable-line prefer-const const server = cp.fork(fixture('keepalive_server.js')) .on('message', function (port) { client.send(port); }); - var client = cp.fork(fixture('keepalive.js')) + client = cp.fork(fixture('keepalive.js')) .on('message', function (output) { expect(output).to.have.property('remaining', 0); expect(output).to.have.property('timeouts', 0); diff --git a/test/unit/specs/transport.js b/test/unit/specs/transport.js index 11351b522..e75d224e9 100644 --- a/test/unit/specs/transport.js +++ b/test/unit/specs/transport.js @@ -722,6 +722,7 @@ describe('Transport Class', function () { }); const con = getConnection(tran); + let ret; // eslint-disable-line prefer-const stub(con, 'request', function () { process.nextTick(function () { ret.abort(); @@ -731,7 +732,7 @@ describe('Transport Class', function () { }; }); - var ret = tran.request({}); + ret = tran.request({}); }); it('ignores the response from the connection when the connector does not support aborting', function (done) { const tran = new Transport({ From d63a37dd42b1788902586fbddf908bfa8889aa5e Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 19:07:57 -0700 Subject: [PATCH 38/61] [eslint] remove exception for `no-unused-vars`, fix violations --- .eslintrc.yaml | 1 - test/integration/yaml_suite/run.js | 7 ++-- test/mocks/writable_stream.js | 13 ++++--- test/unit/browser_builds/angular.js | 7 ---- test/unit/browser_builds/generic.js | 1 - test/unit/browser_builds/jquery.js | 1 - test/unit/buffer_flush_tests.js | 2 +- test/unit/coverage.js | 2 +- test/unit/generic_logger_tests.js | 24 ++++++------- test/unit/specs/abstract_logger.js | 2 -- test/unit/specs/client_action.js | 46 ++++++++++++------------ test/unit/specs/connection_abstract.js | 4 +-- test/unit/specs/console_logger.js | 2 +- test/unit/specs/file_logger.js | 2 +- test/unit/specs/host.js | 1 - test/unit/specs/http_connector.js | 19 +++++----- test/unit/specs/log.js | 14 ++++---- test/unit/specs/stdio_logger.js | 1 - test/unit/specs/stream_logger.js | 2 +- test/unit/specs/tracer_logger.js | 1 - test/unit/specs/transport.js | 10 +++--- test/unit/specs/transport_with_server.js | 32 +++++------------ test/utils/jenkins-reporter.js | 6 ---- 23 files changed, 77 insertions(+), 123 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index a13d74756..9d7280390 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -2,7 +2,6 @@ extends: "@elastic/eslint-config-kibana" rules: - no-unused-vars: warn semi: warn one-var: warn new-cap: warn diff --git a/test/integration/yaml_suite/run.js b/test/integration/yaml_suite/run.js index 5fcce9e33..144ed513f 100644 --- a/test/integration/yaml_suite/run.js +++ b/test/integration/yaml_suite/run.js @@ -1,12 +1,9 @@ module.exports = function (branch) { const path = require('path'); - const jsYaml = require('js-yaml'); const YamlFile = require('./yaml_file'); const root = require('find-root')(__dirname); const rootReq = function (loc) { return require(path.join(root, loc)); }; const _ = rootReq('src/lib/utils'); - const utils = rootReq('grunt/utils'); - const es = rootReq('src/elasticsearch'); const clientManager = require('./client_manager'); const port = parseInt(process.env.ES_PORT || 9200, 10); @@ -32,8 +29,8 @@ module.exports = function (branch) { return clientManager.get().clearEs(); }); - const files = _.map(require('./yaml_tests_' + _.snakeCase(branch) + '.json'), function (docs, filename) { - return new YamlFile(filename, docs); + _.each(require('./yaml_tests_' + _.snakeCase(branch) + '.json'), function (docs, filename) { + new YamlFile(filename, docs); }); }); diff --git a/test/mocks/writable_stream.js b/test/mocks/writable_stream.js index 12f311051..7f77f2edc 100644 --- a/test/mocks/writable_stream.js +++ b/test/mocks/writable_stream.js @@ -12,20 +12,19 @@ if (Writable) { // nice and simple for streams 2 MockWritableStream = module.exports = function (opts) { Writable.call(this, opts); - - this._write = function (chunk, encoding, cb) {}; + this._write = function () {}; }; util.inherits(MockWritableStream, Writable); } else { // Node < 0.10 did not provide a usefull stream abstract const Stream = require('stream').Stream; - module.exports = MockWritableStream = function (opts) { + module.exports = MockWritableStream = function () { Stream.call(this); this.writable = true; }; util.inherits(MockWritableStream, Stream); - MockWritableStream.prototype.write = function (data) { + MockWritableStream.prototype.write = function () { if (!this.writable) { this.emit('error', new Error('stream not writable')); return false; @@ -41,15 +40,15 @@ if (Writable) { } }; - MockWritableStream.prototype.end = function (data, encoding, cb) { + MockWritableStream.prototype.end = function (data, encoding) { if (typeof (data) === 'function') { - cb = data; + // data is a cb } else if (typeof (encoding) === 'function') { - cb = encoding; this.write(data); } else if (arguments.length > 0) { this.write(data, encoding); } + this.writable = false; }; diff --git a/test/unit/browser_builds/angular.js b/test/unit/browser_builds/angular.js index 9f8e84842..135a03c7e 100644 --- a/test/unit/browser_builds/angular.js +++ b/test/unit/browser_builds/angular.js @@ -2,18 +2,14 @@ const _ = require('lodash'); const expect = require('expect.js'); const Promise = require('bluebird'); -const sinon = require('sinon'); describe('Angular esFactory', function () { before(function () { require('../../../src/elasticsearch.angular.js'); }); - const uuid = (function () { let i = 0; return function () { return ++i; }; }()); let esFactory; - let $http; let $rootScope; - let $httpBackend; function bootstrap(env) { beforeEach(function () { @@ -37,10 +33,8 @@ describe('Angular esFactory', function () { }); beforeEach(angular.mock.inject(function ($injector) { - $http = $injector.get('$http'); esFactory = $injector.get('esFactory'); $rootScope = $injector.get('$rootScope'); - $httpBackend = $injector.get('$httpBackend'); })); } @@ -70,7 +64,6 @@ describe('Angular esFactory', function () { it('returns an error created by calling a method incorrectly', function () { const client = esFactory({ hosts: null }); - let err; const prom = client.get().then(function () { throw new Error('expected request to fail'); diff --git a/test/unit/browser_builds/generic.js b/test/unit/browser_builds/generic.js index 93b82a934..69903a206 100644 --- a/test/unit/browser_builds/generic.js +++ b/test/unit/browser_builds/generic.js @@ -1,5 +1,4 @@ const expect = require('expect.js'); -const Transport = require('../../../src/lib/transport'); describe('elasticsearch namespace', function () { const es = window.elasticsearch; diff --git a/test/unit/browser_builds/jquery.js b/test/unit/browser_builds/jquery.js index 62e246277..92460e915 100644 --- a/test/unit/browser_builds/jquery.js +++ b/test/unit/browser_builds/jquery.js @@ -1,6 +1,5 @@ /* global $ */ const expect = require('expect.js'); -const Transport = require('../../../src/lib/transport'); describe('jQuery.es namespace', function () { it('is defined on the global jQuery', function () { diff --git a/test/unit/buffer_flush_tests.js b/test/unit/buffer_flush_tests.js index 285015e57..3f724bbd1 100644 --- a/test/unit/buffer_flush_tests.js +++ b/test/unit/buffer_flush_tests.js @@ -48,7 +48,7 @@ module.exports = function (makeLogger) { once.call(process, event, handler); }); - const logger = makeLogger(); + makeLogger(); expect(function () { // call the event handler diff --git a/test/unit/coverage.js b/test/unit/coverage.js index dde3445ed..c64cbd6bf 100644 --- a/test/unit/coverage.js +++ b/test/unit/coverage.js @@ -1,4 +1,4 @@ -const blanket = require('blanket')({ +require('blanket')({ pattern: require('path').join(__dirname, '../../src') }); diff --git a/test/unit/generic_logger_tests.js b/test/unit/generic_logger_tests.js index e92452bd1..8ce0aa6f4 100644 --- a/test/unit/generic_logger_tests.js +++ b/test/unit/generic_logger_tests.js @@ -1,7 +1,5 @@ const expect = require('expect.js'); const Log = require('../../src/lib/log'); -const LoggerAbstract = require('../../src/lib/logger'); -const TracerLogger = require('../../src/lib/loggers/tracer'); const now = new Date('2013-03-01T00:00:00Z'); const sinon = require('sinon'); @@ -24,7 +22,7 @@ module.exports = function (makeLogger) { }); it('listens for the loggers\' "closing" event', function () { - const logger = makeLogger(parent); + makeLogger(parent); expect(parent.listenerCount('closing')).to.eql(1); }); }); @@ -38,7 +36,7 @@ module.exports = function (makeLogger) { }); it('listens to just error when log is explicitly error', function () { - const logger = makeLogger(parent, 'error'); + makeLogger(parent, 'error'); expect(parent.listenerCount('error')).to.eql(1); expect(parent.listenerCount('warning')).to.eql(0); expect(parent.listenerCount('info')).to.eql(0); @@ -47,7 +45,7 @@ module.exports = function (makeLogger) { }); it('listens for all the events when level is "trace"', function () { - const logger = makeLogger(parent, 'trace'); + makeLogger(parent, 'trace'); expect(parent.listenerCount('error')).to.eql(1); expect(parent.listenerCount('warning')).to.eql(1); expect(parent.listenerCount('info')).to.eql(1); @@ -56,7 +54,7 @@ module.exports = function (makeLogger) { }); it('listens for specific events when level is an array', function () { - const logger = makeLogger(parent, ['error', 'trace']); + makeLogger(parent, ['error', 'trace']); expect(parent.listenerCount('error')).to.eql(1); expect(parent.listenerCount('warning')).to.eql(0); expect(parent.listenerCount('info')).to.eql(0); @@ -87,7 +85,7 @@ module.exports = function (makeLogger) { }); it('emits events because something is listening', function () { - const logger = makeLogger(parent, 'trace'); + makeLogger(parent, 'trace'); stub(parent, 'emit'); parent.error(new Error('error message')); @@ -142,7 +140,7 @@ module.exports = function (makeLogger) { describe('#onError', function () { it('uses the Error name when it is not just "Error"', function () { const logger = makeLogger(); - stub(logger, 'write', function (label, msg) { + stub(logger, 'write', function (label) { expect(label).to.eql('TypeError'); }); @@ -152,7 +150,7 @@ module.exports = function (makeLogger) { it('uses "ERROR" when the error name is "Error"', function () { const logger = makeLogger(); - stub(logger, 'write', function (label, msg) { + stub(logger, 'write', function (label) { expect(label).to.eql('ERROR'); }); @@ -164,7 +162,7 @@ module.exports = function (makeLogger) { describe('#onWarning', function () { it('uses the "WARNING" label', function () { const logger = makeLogger(); - stub(logger, 'write', function (label, msg) { + stub(logger, 'write', function (label) { expect(label).to.eql('WARNING'); }); logger.onWarning('message'); @@ -185,7 +183,7 @@ module.exports = function (makeLogger) { describe('#onInfo', function () { it('uses the "INFO" label', function () { const logger = makeLogger(); - stub(logger, 'write', function (label, msg) { + stub(logger, 'write', function (label) { expect(label).to.eql('INFO'); }); logger.onInfo('message'); @@ -206,7 +204,7 @@ module.exports = function (makeLogger) { describe('#onDebug', function () { it('uses the "DEBUG" label', function () { const logger = makeLogger(); - stub(logger, 'write', function (label, msg) { + stub(logger, 'write', function (label) { expect(label).to.eql('DEBUG'); }); logger.onDebug('message'); @@ -227,7 +225,7 @@ module.exports = function (makeLogger) { describe('#onTrace', function () { it('uses the "TRACE" label', function () { const logger = makeLogger(); - stub(logger, 'write', function (label, msg) { + stub(logger, 'write', function (label) { expect(label).to.eql('TRACE'); }); logger.onTrace(Log.normalizeTraceArgs('GET', 'http://place/thing?me=true', '{}', '{"ok": true}', 200)); diff --git a/test/unit/specs/abstract_logger.js b/test/unit/specs/abstract_logger.js index e64217d35..0ac4b993d 100644 --- a/test/unit/specs/abstract_logger.js +++ b/test/unit/specs/abstract_logger.js @@ -1,11 +1,9 @@ describe('Logger Abstract', function () { const expect = require('expect.js'); - const sinon = require('sinon'); const Log = require('../../../src/lib/log'); const LoggerAbstract = require('../../../src/lib/logger'); let parentLog; - const stub = require('../../utils/auto_release_stub').make(); function makeLogger(parent, levels) { return new LoggerAbstract(parent || parentLog, { diff --git a/test/unit/specs/client_action.js b/test/unit/specs/client_action.js index 57f7e7be1..f9f161bdf 100644 --- a/test/unit/specs/client_action.js +++ b/test/unit/specs/client_action.js @@ -92,7 +92,7 @@ describe('Client Action runner', function () { describe('clientAction::proxy', function () { it('proxies to the passed function', function () { - const action = makeClientActionProxy(function (params, cb) { + const action = makeClientActionProxy(function () { throw new Error('proxy function called'); }); @@ -110,7 +110,7 @@ describe('Client Action runner', function () { }); }); - action({}, function (err, params) { + action({}, function () { expect(client.transport.request).to.be.a('function'); done(); }); @@ -126,7 +126,7 @@ describe('Client Action runner', function () { }); it('supports a param transformation function', function () { - const action = makeClientActionProxy(function (params, cb) { + const action = makeClientActionProxy(function (params) { expect(params).to.have.property('transformed'); }, { transform: function (params) { @@ -139,7 +139,7 @@ describe('Client Action runner', function () { it('returns the proxied function\'s return value', function () { const football = {}; - const action = makeClientActionProxy(function (params, cb) { + const action = makeClientActionProxy(function () { return football; }); @@ -186,7 +186,7 @@ describe('Client Action runner', function () { it('rejects date values', function (done) { action({ one: new Date() - }, function (err, params) { + }, function (err) { expect(err).to.be.a(TypeError); done(); }); @@ -196,7 +196,7 @@ describe('Client Action runner', function () { action({ one: ['one'], two: [1304] - }, function (err, params) { + }, function (err) { expect(err).to.be.a(TypeError); done(); }); @@ -205,7 +205,7 @@ describe('Client Action runner', function () { it('rejects object', function (done) { action({ one: { but: 'duration' } - }, function (err, params) { + }, function (err) { expect(err).to.be.a(TypeError); done(); }); @@ -242,7 +242,7 @@ describe('Client Action runner', function () { it('it rejects regexp', function (done) { action({ one: /regexp!/g - }, function (err, params) { + }, function (err) { expect(err).to.be.a(TypeError); done(); }); @@ -253,7 +253,7 @@ describe('Client Action runner', function () { one: { pasta: 'sauce' } - }, function (err, params) { + }, function (err) { expect(err).to.be.a(TypeError); done(); }); @@ -302,7 +302,7 @@ describe('Client Action runner', function () { it('it rejects things not in the list', function (done) { action({ one: 'not an opt' - }, function (err, params) { + }, function (err) { expect(err).to.be.a(TypeError); done(); }); @@ -417,7 +417,7 @@ describe('Client Action runner', function () { it('rejects dates', function (done) { action({ one: new Date() - }, function (err, params) { + }, function (err) { expect(err).to.be.a(TypeError); done(); }); @@ -426,7 +426,7 @@ describe('Client Action runner', function () { it('rejects objects', function (done) { action({ one: {} - }, function (err, params) { + }, function (err) { expect(err).to.be.a(TypeError); done(); }); @@ -435,7 +435,7 @@ describe('Client Action runner', function () { it('rejects arrays', function (done) { action({ one: [] - }, function (err, params) { + }, function (err) { expect(err).to.be.a(TypeError); done(); }); @@ -444,7 +444,7 @@ describe('Client Action runner', function () { it('rejects regexp', function (done) { action({ one: /pasta/g - }, function (err, params) { + }, function (err) { expect(err).to.be.a(TypeError); done(); }); @@ -488,7 +488,7 @@ describe('Client Action runner', function () { it('rejects dates', function (done) { action({ one: new Date() - }, function (err, params) { + }, function (err) { expect(err).to.be.a(TypeError); done(); }); @@ -497,7 +497,7 @@ describe('Client Action runner', function () { it('rejects objects', function (done) { action({ one: {} - }, function (err, params) { + }, function (err) { expect(err).to.be.a(TypeError); done(); }); @@ -506,7 +506,7 @@ describe('Client Action runner', function () { it('rejects arrays', function (done) { action({ one: [] - }, function (err, params) { + }, function (err) { expect(err).to.be.a(TypeError); done(); }); @@ -515,7 +515,7 @@ describe('Client Action runner', function () { it('rejects regexp', function (done) { action({ one: /pasta/g - }, function (err, params) { + }, function (err) { expect(err).to.be.a(TypeError); done(); }); @@ -559,7 +559,7 @@ describe('Client Action runner', function () { it('rejects objects', function (done) { action({ one: {} - }, function (err, params) { + }, function (err) { expect(err).to.be.a(TypeError); done(); }); @@ -568,7 +568,7 @@ describe('Client Action runner', function () { it('rejects arrays', function (done) { action({ one: [] - }, function (err, params) { + }, function (err) { expect(err).to.be.a(TypeError); done(); }); @@ -577,7 +577,7 @@ describe('Client Action runner', function () { it('rejects regexp', function (done) { action({ one: /pasta/g - }, function (err, params) { + }, function (err) { expect(err).to.be.a(TypeError); done(); }); @@ -732,7 +732,7 @@ describe('Client Action runner', function () { it('rejects a url if it required params that are not present', function (done) { action(params({ type: ['type1', 'type2'] - }), function (err, resp) { + }), function (err) { expect(err).to.be.a(TypeError); params.check(); done(); @@ -845,7 +845,7 @@ describe('Client Action runner', function () { it('enforces required params', function (done) { action(params({ b: '3w' - }), function (err, resp) { + }), function (err) { expect(err).to.be.a(TypeError); params.check(); done(); diff --git a/test/unit/specs/connection_abstract.js b/test/unit/specs/connection_abstract.js index 87dfe3801..9805a186a 100644 --- a/test/unit/specs/connection_abstract.js +++ b/test/unit/specs/connection_abstract.js @@ -17,11 +17,11 @@ describe('Connection Abstract', function () { it('requires a valid host', function () { expect(function () { - const conn = new ConnectionAbstract(); + new ConnectionAbstract(); }).to.throwError(TypeError); expect(function () { - const conn = new ConnectionAbstract({}); + new ConnectionAbstract({}); }).to.throwError(TypeError); }); diff --git a/test/unit/specs/console_logger.js b/test/unit/specs/console_logger.js index 2e38e6954..4767a58b7 100644 --- a/test/unit/specs/console_logger.js +++ b/test/unit/specs/console_logger.js @@ -20,7 +20,7 @@ function makeLogger(parent, levels) { return new ConsoleLogger(parent, config); } -const stub = require('../../utils/auto_release_stub').make(); +require('../../utils/auto_release_stub').make(); describe('Console Logger', function () { diff --git a/test/unit/specs/file_logger.js b/test/unit/specs/file_logger.js index a4d6835ee..c9454ff31 100644 --- a/test/unit/specs/file_logger.js +++ b/test/unit/specs/file_logger.js @@ -76,7 +76,7 @@ describe('File Logger', function () { once.call(process, event, handler); }); - const logger = makeLogger(); + makeLogger(); expect(function () { // call the event handler diff --git a/test/unit/specs/host.js b/test/unit/specs/host.js index a56669f0f..5de586a13 100644 --- a/test/unit/specs/host.js +++ b/test/unit/specs/host.js @@ -1,5 +1,4 @@ const Host = require('../../../src/lib/host'); -const _ = require('lodash'); const expect = require('expect.js'); const url = require('url'); const expectSubObject = require('../../utils/expect_sub_object'); diff --git a/test/unit/specs/http_connector.js b/test/unit/specs/http_connector.js index 737ed9998..6eab94de4 100644 --- a/test/unit/specs/http_connector.js +++ b/test/unit/specs/http_connector.js @@ -3,15 +3,12 @@ describe('Http Connector', function () { const _ = require('lodash'); const expect = require('expect.js'); const nock = require('nock'); - const sinon = require('sinon'); - const util = require('util'); const parseUrl = require('url').parse; const http = require('http'); const https = require('https'); const AgentKeepAlive = require('agentkeepalive'); const Host = require('../../../src/lib/host'); - const errors = require('../../../src/lib/errors'); const HttpConnection = require('../../../src/lib/connectors/http'); const ConnectionAbstract = require('../../../src/lib/connection'); @@ -62,7 +59,7 @@ describe('Http Connector', function () { it('expects the host to have a protocol of http or https', function () { expect(function () { - const con = new HttpConnection(new Host('thrifty://es.com/stuff')); + new HttpConnection(new Host('thrifty://es.com/stuff')); }).to.throwError(/invalid protocol/i); }); @@ -254,7 +251,7 @@ describe('Http Connector', function () { stub(con.log, 'error'); stub(https, 'request', makeStubReqWithMsgWhichErrorsMidBody()); - con.request({}, function (err, resp, status) { + con.request({}, function () { expect(con.log.error.callCount).to.eql(0); done(); }); @@ -264,7 +261,7 @@ describe('Http Connector', function () { const con = new HttpConnection(new Host('https://google.com/')); stub(https, 'request', makeStubReqWithMsgWhichErrorsMidBody(new Error('no more message :('))); - con.request({}, function (err, resp, status) { + con.request({}, function (err) { expect(err).to.be.an(Error); expect(err.message).to.eql('no more message :('); done(); @@ -275,7 +272,7 @@ describe('Http Connector', function () { const con = new HttpConnection(new Host('https://google.com/')); stub(https, 'request', makeStubReqWithMsgWhichErrorsMidBody()); - con.request({}, function (err, resp, status) { + con.request({}, function (err, resp) { expect(resp).to.be(undefined); done(); }); @@ -414,7 +411,7 @@ describe('Http Connector', function () { stub(http.ClientRequest.prototype, 'setNoDelay'); const server = nock('http://localhost/').get('/').reply(200); - con.request({}, function (err, resp, status) { + con.request({}, function () { expect(http.ClientRequest.prototype.setNoDelay.callCount).to.eql(1); expect(http.ClientRequest.prototype.setNoDelay.lastCall.args[0]).to.eql(true); server.done(); @@ -433,7 +430,7 @@ describe('Http Connector', function () { con.request({ body: body - }, function (err, resp, status) { + }, function () { expect(http.ClientRequest.prototype.setHeader.lastCall.args).to.eql(['Content-Length', 14]); server.done(); done(); @@ -449,7 +446,7 @@ describe('Http Connector', function () { .once() .reply(200, respBody); - con.request({}, function (err, resp, status) { + con.request({}, function (err, resp) { expect(resp).to.be(respBody); server.done(); done(); @@ -465,7 +462,7 @@ describe('Http Connector', function () { .once() .reply(200, respBody); - con.request({}, function (err, resp, status) { + con.request({}, function (err, resp) { expect(resp).to.be(respBody); server.done(); done(); diff --git a/test/unit/specs/log.js b/test/unit/specs/log.js index 562ecfffd..17410da15 100644 --- a/test/unit/specs/log.js +++ b/test/unit/specs/log.js @@ -134,7 +134,7 @@ describe('Log class', function () { log = new Log({ log: [ { - type: function (log, config) { + type: function (log) { log.on('error', _.noop); log.on('warning', _.noop); log.on('info', _.noop); @@ -237,22 +237,22 @@ describe('Log class', function () { it('rejects numbers and other truthy data-types', function () { expect(function () { - const log = new Log({ log: 1515 }); + new Log({ log: 1515 }); }).to.throwError(/invalid logging output config/i); expect(function () { - const log = new Log({ log: /regexp/ }); + new Log({ log: /regexp/ }); }).to.throwError(/invalid logging output config/i); expect(function () { - const log = new Log({ log: new Date() }); + new Log({ log: new Date() }); }).to.throwError(/invalid logging output config/i); expect(function () { - const log = new Log({ log: [1515] }); + new Log({ log: [1515] }); }).to.throwError(/invalid logging output config/i); expect(function () { - const log = new Log({ log: [/regexp/] }); + new Log({ log: [/regexp/] }); }).to.throwError(/invalid logging output config/i); expect(function () { - const log = new Log({ log: [new Date()] }); + new Log({ log: [new Date()] }); }).to.throwError(/invalid logging output config/i); }); }); diff --git a/test/unit/specs/stdio_logger.js b/test/unit/specs/stdio_logger.js index fc8356bf6..71b5bc8f6 100644 --- a/test/unit/specs/stdio_logger.js +++ b/test/unit/specs/stdio_logger.js @@ -31,7 +31,6 @@ describe('Stdio Logger', function () { const now = '2013-01-01T00:00:00Z'; const nowDate = new Date(now); const nowTime = nowDate.getTime(); - let clock; beforeEach(function () { stub.autoRelease(sinon.useFakeTimers(nowTime)); diff --git a/test/unit/specs/stream_logger.js b/test/unit/specs/stream_logger.js index 834c044fa..4ad55b782 100644 --- a/test/unit/specs/stream_logger.js +++ b/test/unit/specs/stream_logger.js @@ -77,7 +77,7 @@ describe('Stream Logger', function () { once.call(process, event, handler); }); - const logger = makeLogger(); + makeLogger(); expect(function () { // call the event handler diff --git a/test/unit/specs/tracer_logger.js b/test/unit/specs/tracer_logger.js index 4b7dee22a..9feaa1383 100644 --- a/test/unit/specs/tracer_logger.js +++ b/test/unit/specs/tracer_logger.js @@ -2,7 +2,6 @@ describe('Tracer Logger', function () { const Log = require('../../../src/lib/log'); const TracerLogger = require('../../../src/lib/loggers/tracer'); - const sinon = require('sinon'); const expect = require('expect.js'); let parentLog; diff --git a/test/unit/specs/transport.js b/test/unit/specs/transport.js index e75d224e9..5ceeaa43f 100644 --- a/test/unit/specs/transport.js +++ b/test/unit/specs/transport.js @@ -59,7 +59,7 @@ describe('Transport Class', function () { it('Throws an error when connectionPool config is set wrong', function () { expect(function () { - const trans = new Transport({ + new Transport({ connectionPool: 'pasta' }); }).to.throwError(/invalid connectionpool/i); @@ -166,7 +166,7 @@ describe('Transport Class', function () { describe('host config', function () { it('rejects non-strings/objects', function () { expect(function () { - const trans = new Transport({ + new Transport({ host: [ 'localhost', 9393 @@ -175,7 +175,7 @@ describe('Transport Class', function () { }).to.throwError(TypeError); expect(function () { - const trans = new Transport({ + new Transport({ host: [ [9292] ] @@ -288,7 +288,7 @@ describe('Transport Class', function () { const _ = require('../../../src/lib/utils'); stub(Transport.connectionPools.main.prototype, 'setHosts'); stub(_, 'shuffle'); - const trans = new Transport({ + new Transport({ hosts: 'localhost' }); @@ -298,7 +298,7 @@ describe('Transport Class', function () { const _ = require('../../../src/lib/utils'); stub(Transport.connectionPools.main.prototype, 'setHosts'); stub(_, 'shuffle'); - const trans = new Transport({ + new Transport({ hosts: 'localhost', randomizeHosts: false }); diff --git a/test/unit/specs/transport_with_server.js b/test/unit/specs/transport_with_server.js index 81388fd7c..69f56da08 100644 --- a/test/unit/specs/transport_with_server.js +++ b/test/unit/specs/transport_with_server.js @@ -1,6 +1,5 @@ const Transport = require('../../../src/lib/transport'); const ConnectionPool = require('../../../src/lib/connection_pool'); -const Host = require('../../../src/lib/host'); const errors = require('../../../src/lib/errors'); const expect = require('expect.js'); @@ -10,21 +9,6 @@ const through2 = require('through2'); const _ = require('lodash'); const stub = require('../../utils/auto_release_stub').make(); -/** - * Allows the tests call #request() without it doing anything past trying to select - * a connection. - * @param {Transport} tran - the transport to neuter - */ -function shortCircuitRequest(tran, delay) { - stub(tran.connectionPool, 'select', function (cb) { - setTimeout(cb, delay); - }); -} - -function getConnection(transport, status) { - return transport.connectionPool.getConnections(status || 'alive', 1).pop(); -} - describe('Transport + Mock server', function () { describe('#request', function () { describe('server responds', function () { @@ -209,7 +193,7 @@ describe('Transport + Mock server', function () { trans.request({ path: '/', - }, function (err, body, status) { + }, function (err, body) { expect(err).to.be(undefined); expect(body).to.eql({ 'the answer': 42 @@ -228,7 +212,7 @@ describe('Transport + Mock server', function () { trans.request({ path: '/hottie-threads', - }, function (err, body, status) { + }, function (err, body) { expect(err).to.be(undefined); expect(body).to.match(/s?he said/g); done(); @@ -239,7 +223,7 @@ describe('Transport + Mock server', function () { describe('return value', function () { it('resolves the promise it with the response body', function (done) { - const serverMock = nock('http://esbox.1.com/') + nock('http://esbox.1.com/') .get('/') .reply(200, { good: 'day' @@ -266,7 +250,7 @@ describe('Transport + Mock server', function () { host: 'http://localhost:9200/' }); - const server = nock('http://localhost:9200/') + nock('http://localhost:9200/') .get('/') .reply(200, { i: 'am here' @@ -286,7 +270,7 @@ describe('Transport + Mock server', function () { host: 'http://localhost:9200/' }); - const server = nock('http://localhost:9200/') + nock('http://localhost:9200/') .get('/') .delay(1000) .reply(200, { @@ -295,7 +279,7 @@ describe('Transport + Mock server', function () { tran.request({ requestTimeout: 25 - }, function (err, resp, status) { + }, function (err) { expect(err).to.be.a(errors.RequestTimeout); done(); }); @@ -307,7 +291,7 @@ describe('Transport + Mock server', function () { const clock = sinon.useFakeTimers('setTimeout'); stub.autoRelease(clock); - const serverMock = nock('http://esbox.1.com/') + nock('http://esbox.1.com/') .get('/') .reply(200, function () { const str = through2(function (chunk, enc, cb) { @@ -338,7 +322,7 @@ describe('Transport + Mock server', function () { .then(function () { throw new Error('expected the request to fail'); }) - .catch(function (err) { + .catch(function () { expect(ConnectionPool.prototype._onConnectionDied.callCount).to.eql(1); expect(tran.sniff.callCount).to.eql(0); expect(_.size(clock.timers)).to.eql(1); diff --git a/test/utils/jenkins-reporter.js b/test/utils/jenkins-reporter.js index 238325f0e..911fa6d3e 100644 --- a/test/utils/jenkins-reporter.js +++ b/test/utils/jenkins-reporter.js @@ -40,9 +40,6 @@ function JenkinsReporter(runner) { Base.call(this, runner); const stats = this.stats; - let pass = 0; - let pending = 0; - let fail = 0; const rootSuite = { results: [], suites: [] @@ -94,14 +91,11 @@ function JenkinsReporter(runner) { runner.on('test end', function (test) { if (test.state === 'passed') { - pass++; log(chalk.green('.')); } else if (test.pending) { - pending++; log(chalk.grey('.')); return; } else { - fail++; log(chalk.red('x')); } From ccf333ad9f0653f7feb35f6f24970a4b42d82d37 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 19:08:41 -0700 Subject: [PATCH 39/61] [eslint] remove exception for `semi` --- .eslintrc.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 9d7280390..81d40e278 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -2,7 +2,6 @@ extends: "@elastic/eslint-config-kibana" rules: - semi: warn one-var: warn new-cap: warn space-unary-ops: warn From d50eea6d6f66d3fe5392a9561e06d84b17bb1afa Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 19:10:40 -0700 Subject: [PATCH 40/61] [eslint] remove exception for `one-var`, fix violations --- .eslintrc.yaml | 1 - src/lib/client_action.js | 4 +++- src/lib/connectors/http.js | 3 ++- src/lib/serializers/json.js | 3 ++- src/lib/utils.js | 5 ++++- test/unit/specs/connection_pool.js | 16 +++++++++++++--- test/unit/specs/log.js | 3 ++- test/unit/specs/transport.js | 3 ++- 8 files changed, 28 insertions(+), 10 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 81d40e278..ed2e46d65 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -2,7 +2,6 @@ extends: "@elastic/eslint-config-kibana" rules: - one-var: warn new-cap: warn space-unary-ops: warn dot-notation: warn diff --git a/src/lib/client_action.js b/src/lib/client_action.js index d54c1e3e8..20488ee04 100644 --- a/src/lib/client_action.js +++ b/src/lib/client_action.js @@ -183,7 +183,9 @@ const castType = { }; function resolveUrl(url, params) { - let vars = {}, i, key; + const vars = {}; + let i; + let key; if (url.req) { // url has required params diff --git a/src/lib/connectors/http.js b/src/lib/connectors/http.js index c8ea501c0..671206594 100644 --- a/src/lib/connectors/http.js +++ b/src/lib/connectors/http.js @@ -65,7 +65,8 @@ HttpConnector.prototype.onStatusSet = _.handler(function (status) { _.each(agent.sockets, collectSockets); _.each(agent.freeSockets, collectSockets); _.each(toRemove, function (args) { - let host = args[0], socket = args[1]; + const host = args[0]; + const socket = args[1]; agent.removeSocket(socket, parseUrl(host)); socket.destroy(); }); diff --git a/src/lib/serializers/json.js b/src/lib/serializers/json.js index 15d4cbcd8..0bc9b4a10 100755 --- a/src/lib/serializers/json.js +++ b/src/lib/serializers/json.js @@ -44,7 +44,8 @@ Json.prototype.deserialize = function (str) { }; Json.prototype.bulkBody = function (val) { - let body = '', i; + let body = ''; + let i; if (_.isArray(val)) { for (i = 0; i < val.length; i++) { diff --git a/src/lib/utils.js b/src/lib/utils.js index 02ab41293..711dad613 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -97,7 +97,10 @@ function adjustWordCase(firstWordCap, otherWordsCap, sep) { let i = 0; const words = []; let word = ''; - let code, c, upper, lower; + let code; + let c; + let upper; + let lower; for (; i < string.length; i++) { code = string.charCodeAt(i); diff --git a/test/unit/specs/connection_pool.js b/test/unit/specs/connection_pool.js index fe8e6f4f9..7e815e68f 100644 --- a/test/unit/specs/connection_pool.js +++ b/test/unit/specs/connection_pool.js @@ -19,7 +19,11 @@ function listenerCount(emitter, event) { describe('Connection Pool', function () { describe('Adding/Removing/Syncing Connections', function () { - let pool, host, connection, host2, connection2; + let pool; + let host; + let connection; + let host2; + let connection2; beforeEach(function () { pool = new ConnectionPool({}); @@ -93,7 +97,9 @@ describe('Connection Pool', function () { }); describe('Connection selection', function () { - let pool, host, host2; + let pool; + let host; + let host2; beforeEach(function () { pool = new ConnectionPool({}); @@ -211,7 +217,11 @@ describe('Connection Pool', function () { }); describe('Connection state management', function () { - let pool, host, host2, connection, connection2; + let pool; + let host; + let host2; + let connection; + let connection2; beforeEach(function () { pool = new ConnectionPool({}); diff --git a/test/unit/specs/log.js b/test/unit/specs/log.js index 17410da15..2acd67f24 100644 --- a/test/unit/specs/log.js +++ b/test/unit/specs/log.js @@ -128,7 +128,8 @@ describe('Log class', function () { }); describe('instance without one output listening to all events', function () { - let log, call; + let log; + let call; beforeEach(function () { call = void 0; log = new Log({ diff --git a/test/unit/specs/transport.js b/test/unit/specs/transport.js index 5ceeaa43f..905d2cc1b 100644 --- a/test/unit/specs/transport.js +++ b/test/unit/specs/transport.js @@ -817,7 +817,8 @@ describe('Transport Class', function () { ]); sinon.assert.calledOnce(trans.connectionPool.setHosts); - let host, hosts = trans.connectionPool.setHosts.firstCall.args[0]; + let host; + const hosts = trans.connectionPool.setHosts.firstCall.args[0]; expect(hosts).to.have.length(3); From f4e4cf73586a80b07ae4af029a5f68c7fa0be014 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 19:11:39 -0700 Subject: [PATCH 41/61] [eslint] remove exception for `new-cap`, fix violations --- .eslintrc.yaml | 1 - grunt/config/esvm.js | 2 +- src/elasticsearch.jquery.js | 2 +- test/unit/specs/client.js | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index ed2e46d65..bfd3e298f 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -2,7 +2,6 @@ extends: "@elastic/eslint-config-kibana" rules: - new-cap: warn space-unary-ops: warn dot-notation: warn quotes: warn diff --git a/grunt/config/esvm.js b/grunt/config/esvm.js index 130383e69..aa0526314 100644 --- a/grunt/config/esvm.js +++ b/grunt/config/esvm.js @@ -102,7 +102,7 @@ utils.branches.forEach(function (branch) { opts.version = v.version; } else if (ref) { - v = new Version.fromBranch(String(ref).replace(/v?(\d+\.\d+)\..+/, '$1')); + v = Version.fromBranch(String(ref).replace(/v?(\d+\.\d+)\..+/, '$1')); opts.branch = ref; opts.fresh = true; } diff --git a/src/elasticsearch.jquery.js b/src/elasticsearch.jquery.js index a05f8c442..8618a7baf 100644 --- a/src/elasticsearch.jquery.js +++ b/src/elasticsearch.jquery.js @@ -4,7 +4,7 @@ const es = require('./elasticsearch'); function defer() { - const def = $.Deferred(); + const def = new $.Deferred(); // def.promise is usually a property (in normal implementations) // we override the promise to keep things working def.promise = def.promise(); diff --git a/test/unit/specs/client.js b/test/unit/specs/client.js index 6d42b48cc..73fc32c7a 100644 --- a/test/unit/specs/client.js +++ b/test/unit/specs/client.js @@ -36,7 +36,7 @@ describe('Client instances creation', function () { it('inherits the ' + prev + ' API when specified', function () { client.close(); - client = es.Client({ + client = new es.Client({ apiVersion: prev }); expect(client.bulk).to.be(apis[prev].bulk); From cd8c9aa7ffa54067709dbed0fc723b06ee8e918b Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 19:12:31 -0700 Subject: [PATCH 42/61] [eslint] remove exception for `space-unary-ops` --- .eslintrc.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index bfd3e298f..fb75b87bb 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -2,7 +2,6 @@ extends: "@elastic/eslint-config-kibana" rules: - space-unary-ops: warn dot-notation: warn quotes: warn no-use-before-define: warn From 886c9aa20b3ba15226017e7a117fbc217469d4fe Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 19:12:47 -0700 Subject: [PATCH 43/61] [eslint] remove exception for `dot-notation` --- .eslintrc.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index fb75b87bb..fb75db366 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -2,7 +2,6 @@ extends: "@elastic/eslint-config-kibana" rules: - dot-notation: warn quotes: warn no-use-before-define: warn no-empty: warn From acdde5a86b1da6b8c7583b1c54aea14a22aa84c7 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 19:13:05 -0700 Subject: [PATCH 44/61] [eslint] remove exception for `quotes` --- .eslintrc.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index fb75db366..e8d2e0a14 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -2,7 +2,6 @@ extends: "@elastic/eslint-config-kibana" rules: - quotes: warn no-use-before-define: warn no-empty: warn space-before-function-paren: warn From 499b51dfb334dfc2175f9dcfabc01ca69daa05a6 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 19:14:07 -0700 Subject: [PATCH 45/61] [eslint] remove exception for `no-use-before-define`, and fix violations --- .eslintrc.yaml | 1 - test/integration/yaml_suite/yaml_doc.js | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index e8d2e0a14..fa147f4ab 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -2,7 +2,6 @@ extends: "@elastic/eslint-config-kibana" rules: - no-use-before-define: warn no-empty: warn space-before-function-paren: warn no-restricted-globals: warn diff --git a/test/integration/yaml_suite/yaml_doc.js b/test/integration/yaml_suite/yaml_doc.js index 2a4087966..c0909e0b2 100644 --- a/test/integration/yaml_suite/yaml_doc.js +++ b/test/integration/yaml_suite/yaml_doc.js @@ -344,6 +344,8 @@ YamlDoc.prototype = { */ do_do: function (args, done) { let catcher; + let clientActionName; //eslint-disable-line prefer-const + let params; //eslint-disable-line prefer-const if (process.env.LOG_DO) { const __done = done; @@ -403,11 +405,11 @@ YamlDoc.prototype = { } const client = clientManager.get(); - const clientActionName = _.map(action.split('.'), _.camelCase).join('.'); + clientActionName = _.map(action.split('.'), _.camelCase).join('.'); const clientAction = this.get(clientActionName, client); _.assign(inputParams, args[action]); - const params = _.transform(inputParams, _.bind(function (params, val, name) { + params = _.transform(inputParams, _.bind(function (params, val, name) { const camelName = _.camelCase(name); // search through the params and url peices to find this param name From c9dc6906982ac30f42acace652ef1e711e03a2da Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 19:17:03 -0700 Subject: [PATCH 46/61] [eslint] remove exception for `no-empty`, and fix violations --- .eslintrc.yaml | 1 - grunt/config/s3.js | 6 +++++- scripts/generate/index.js | 13 ++++++++++--- src/lib/serializers/json.js | 4 +++- test/integration/yaml_suite/client_manager.js | 6 +++++- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index fa147f4ab..e8a59d935 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -2,7 +2,6 @@ extends: "@elastic/eslint-config-kibana" rules: - no-empty: warn space-before-function-paren: warn no-restricted-globals: warn prefer-const: warn \ No newline at end of file diff --git a/grunt/config/s3.js b/grunt/config/s3.js index 5fa220f50..514897d63 100644 --- a/grunt/config/s3.js +++ b/grunt/config/s3.js @@ -1,7 +1,11 @@ let config = {}; try { config = require('../../.aws-config.json'); -} catch (e) {} +} catch (error) { + if (error.code !== 'ENOENT') { + throw error; + } +} module.exports = { upload_archives: { diff --git a/scripts/generate/index.js b/scripts/generate/index.js index 9df5077f6..5eb4c31a1 100644 --- a/scripts/generate/index.js +++ b/scripts/generate/index.js @@ -70,9 +70,16 @@ const paths = { }; function isDirectory(dir) { - let stat; - try { stat = fs.statSync(dir); } catch (e) {} - return (stat && stat.isDirectory()); + try { + const stat = fs.statSync(dir); + return stat.isDirectory(); + } catch (error) { + if (error.code === 'ENOENT') { + return false; + } + + throw error; + } } function dirFilter(dir, fn) { diff --git a/src/lib/serializers/json.js b/src/lib/serializers/json.js index 0bc9b4a10..56efc80a8 100755 --- a/src/lib/serializers/json.js +++ b/src/lib/serializers/json.js @@ -39,7 +39,9 @@ Json.prototype.deserialize = function (str) { if (typeof str === 'string') { try { return JSON.parse(str); - } catch (e) {} + } catch (e) { + return undefined; + } } }; diff --git a/test/integration/yaml_suite/client_manager.js b/test/integration/yaml_suite/client_manager.js index 02eb7e72e..3458aaa55 100644 --- a/test/integration/yaml_suite/client_manager.js +++ b/test/integration/yaml_suite/client_manager.js @@ -77,7 +77,11 @@ module.exports = { if (logConfig && logConfig.type === 'tracer') { try { fs.unlinkSync(fromRoot('elasticsearch-tracer.log')); - } catch (e) {} + } catch (error) { + if (error.code !== 'ENOENT') { + throw error; + } + } } // close existing client From 5ba151ef430f0f5a78ea8d2409419081a0b7f314 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 19:17:29 -0700 Subject: [PATCH 47/61] [eslint] remove exception for `space-before-function-paren` --- .eslintrc.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index e8a59d935..46b463ad6 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -2,6 +2,5 @@ extends: "@elastic/eslint-config-kibana" rules: - space-before-function-paren: warn no-restricted-globals: warn prefer-const: warn \ No newline at end of file From 40078d6965f84070241988b74da7ca3aaef0b829 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 19:18:14 -0700 Subject: [PATCH 48/61] [eslint] remove exception for `no-restricted-globals`, and fix violations --- .eslintrc.yaml | 1 - test/unit/specs/nodes_to_host_callback.js | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 46b463ad6..a340c735d 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -2,5 +2,4 @@ extends: "@elastic/eslint-config-kibana" rules: - no-restricted-globals: warn prefer-const: warn \ No newline at end of file diff --git a/test/unit/specs/nodes_to_host_callback.js b/test/unit/specs/nodes_to_host_callback.js index 10bfa79e5..cf4c1d200 100644 --- a/test/unit/specs/nodes_to_host_callback.js +++ b/test/unit/specs/nodes_to_host_callback.js @@ -7,7 +7,7 @@ describe('Nodes to host callback', function () { const nodes20 = require('../../fixtures/short_node_list.2.0.json'); const nodes50 = require('../../fixtures/short_node_list.5.0.json'); - context('0.x style', function () { + describe('0.x style', function () { it('properly creates host objects', function () { expect(callback(nodes90)).to.eql([ { @@ -32,7 +32,7 @@ describe('Nodes to host callback', function () { }); }); - context('1.0 nodes style', function () { + describe('1.0 nodes style', function () { it('properly creates host objects', function () { expect(callback(nodes10)).to.eql([ { @@ -57,7 +57,7 @@ describe('Nodes to host callback', function () { }); }); - context('2.0 nodes style', function () { + describe('2.0 nodes style', function () { it('properly creates host objects', function () { expect(callback(nodes20)).to.eql([ { @@ -82,7 +82,7 @@ describe('Nodes to host callback', function () { }); }); - context('5.0 nodes style', function () { + describe('5.0 nodes style', function () { it('properly creates host objects', function () { expect(callback(nodes50)).to.eql([ { From 24454c27a8ce68c1002718a2295b1527451f3bb4 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 19:19:43 -0700 Subject: [PATCH 49/61] [eslint] remove exception for `prefer-const`, and fix violations --- .eslintrc.yaml | 5 +---- src/lib/connection.js | 3 +-- src/lib/connectors/http.js | 2 +- test/integration/yaml_suite/yaml_doc.js | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index a340c735d..461653ed5 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -1,5 +1,2 @@ --- -extends: "@elastic/eslint-config-kibana" - -rules: - prefer-const: warn \ No newline at end of file +extends: "@elastic/eslint-config-kibana" \ No newline at end of file diff --git a/src/lib/connection.js b/src/lib/connection.js index df3b2cd14..8eb6a69c8 100644 --- a/src/lib/connection.js +++ b/src/lib/connection.js @@ -55,13 +55,12 @@ ConnectionAbstract.prototype.ping = function (params, cb) { let requestTimeout = this.pingTimeout; let requestTimeoutId; let aborted; - let abort; if (params && params.hasOwnProperty('requestTimeout')) { requestTimeout = params.requestTimeout; } - abort = this.request(_.defaults(params || {}, { + const abort = this.request(_.defaults(params || {}, { path: '/', method: 'HEAD' }), function (err) { diff --git a/src/lib/connectors/http.js b/src/lib/connectors/http.js index 671206594..2d7e41ecf 100644 --- a/src/lib/connectors/http.js +++ b/src/lib/connectors/http.js @@ -133,11 +133,11 @@ HttpConnector.prototype.makeReqParams = function (params) { HttpConnector.prototype.request = function (params, cb) { let incoming; let timeoutId; - let request; let status = 0; let headers = {}; const log = this.log; let response; + let request; // eslint-disable-line prefer-const const reqParams = this.makeReqParams(params); diff --git a/test/integration/yaml_suite/yaml_doc.js b/test/integration/yaml_suite/yaml_doc.js index c0909e0b2..06250e171 100644 --- a/test/integration/yaml_suite/yaml_doc.js +++ b/test/integration/yaml_suite/yaml_doc.js @@ -449,7 +449,7 @@ YamlDoc.prototype = { catcher = null; } - let timeoutId; + let timeoutId; // eslint-disable-line prefer-const const cb = _.bind(function (error, body) { this._last_requests_response = body; clearTimeout(timeoutId); From 7c014b3efdccc2d8a79043d0db2b2c0a12995fda Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 20:36:33 -0700 Subject: [PATCH 50/61] move elasticsearch repo/archives to tmp dir --- .eslintignore | 1 - .gitignore | 2 +- scripts/generate/index.js | 31 ++++++++++++++++++------------- scripts/generate/js_api.js | 2 +- scripts/generate/yaml_tests.js | 4 ++-- 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/.eslintignore b/.eslintignore index 8b4271e3c..3a814ec07 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,3 @@ -/src/_* /src/bower_es_js /src/lib/apis /node_modules diff --git a/.gitignore b/.gitignore index 24aafb2e4..1c06e6a0d 100644 --- a/.gitignore +++ b/.gitignore @@ -8,11 +8,11 @@ test/integration/yaml_suite/log .idea esvm .es-snapshot-repos +/tmp ## generated files test/integration/yaml_suite/yaml_tests*.json test/integration/yaml_suite/index*.js -src/_elasticsearch* src/bower*/ junit-*.xml elasticsearch*.log diff --git a/scripts/generate/index.js b/scripts/generate/index.js index 5eb4c31a1..c56f3f0d1 100644 --- a/scripts/generate/index.js +++ b/scripts/generate/index.js @@ -51,18 +51,21 @@ if (argv.branch) { branches = utils.branches; } +const TMP_DIR = fromRoot('tmp'); +const ES_REPO_DIR = path.join(TMP_DIR, 'es/repo'); +const ES_BRANCHES_DIR = path.join(TMP_DIR, 'es/branches'); + const paths = { root: fromRoot('.'), src: fromRoot('src'), - esSrc: fromRoot('src/_elasticsearch_'), docs: fromRoot('docs'), docsIndex: fromRoot('docs/index.asciidoc'), apiSrc: 'src/lib/apis', getArchiveDir: function (branch) { - return fromRoot('src/_elasticsearch_' + _.snakeCase(branch)); + return path.join(ES_BRANCHES_DIR, _.snakeCase(branch)); }, getArchiveTarball: function (branch) { - return fromRoot('src/_elasticsearch_' + _.snakeCase(branch) + '.tar'); + return path.join(ES_BRANCHES_DIR, _.snakeCase(branch) + '.tar'); }, getSpecPathInRepo: function (branch) { return /^v?(master|[2-9]\.)/.test(branch) ? 'rest-api-spec/src/main/resources/rest-api-spec' : 'rest-api-spec'; @@ -122,14 +125,15 @@ function spawnStep(cmd, args, cwd) { function initStep() { return function (done) { - if (isDirectory(paths.esSrc)) { + if (isDirectory(ES_REPO_DIR)) { async.series([ - spawnStep('git', ['remote', 'set-url', 'origin', esUrl], paths.esSrc) + spawnStep('git', ['remote', 'set-url', 'origin', esUrl], ES_REPO_DIR) ], done); } else { async.series([ - spawnStep('git', ['init', '--bare', paths.esSrc], paths.root), - spawnStep('git', ['remote', 'add', 'origin', esUrl], paths.esSrc) + spawnStep('mkdir', ['-p', path.dirname(ES_REPO_DIR)], paths.root), + spawnStep('git', ['init', '--bare', ES_REPO_DIR], paths.root), + spawnStep('git', ['remote', 'add', 'origin', esUrl], ES_REPO_DIR) ], done); } }; @@ -137,7 +141,7 @@ function initStep() { function fetchBranchesStep() { const branchArgs = branches.map(function (b) { return b + ':' + b; }); - return spawnStep('git', ['fetch', '--no-tags', '--force', 'origin'].concat(branchArgs), paths.esSrc); + return spawnStep('git', ['fetch', '--depth=1', '--no-tags', '--force', 'origin'].concat(branchArgs), ES_REPO_DIR); } @@ -171,8 +175,9 @@ function findGeneratedApiFiles() { function clearGeneratedFiles() { - const esArchives = /^_elasticsearch_(master|[\dx_]+|\.tar)$/; - const generatedFiles = []; + const generatedFiles = [ + ES_BRANCHES_DIR, + ]; if (argv.api) { generatedFiles.push(findGeneratedApiFiles()); @@ -217,8 +222,8 @@ function createArchive(branch) { } async.series([ - spawnStep('mkdir', [dir], paths.root), - spawnStep('git', ['archive', '--format', 'tar', '--output', tarball, branch, specPathInRepo], paths.esSrc), + spawnStep('mkdir', ['-p', dir], paths.root), + spawnStep('git', ['archive', '--format', 'tar', '--output', tarball, branch, specPathInRepo], ES_REPO_DIR), spawnStep('tar', ['-x', '-f', tarball, '-C', dir, '--strip-components', subDirCount]), spawnStep('rm', [tarball]) ], done); @@ -229,7 +234,7 @@ function generateStep(branch) { return function (done) { async.parallel([ argv.api && async.apply(require('./js_api'), branch), - argv.tests && async.apply(require('./yaml_tests'), branch) + argv.tests && async.apply(require('./yaml_tests'), branch, ES_BRANCHES_DIR) ].filter(Boolean), done); }; } diff --git a/scripts/generate/js_api.js b/scripts/generate/js_api.js index d14b33397..ecb933485 100644 --- a/scripts/generate/js_api.js +++ b/scripts/generate/js_api.js @@ -19,7 +19,7 @@ module.exports = function (branch, done) { let docVars; // slightly modified clone of apiSpec for the docs const branchSuffix = utils.branchSuffix(branch); - const esDir = fromRoot('src/_elasticsearch_' + _.snakeCase(branch)); + const esDir = fromRoot('tmp/es/branches', _.snakeCase(branch)); const version = Version.fromBranch(branch); const overrides = version.mergeOpts(require('./overrides'), { diff --git a/scripts/generate/yaml_tests.js b/scripts/generate/yaml_tests.js index de4f4ba76..924a225a8 100644 --- a/scripts/generate/yaml_tests.js +++ b/scripts/generate/yaml_tests.js @@ -1,4 +1,4 @@ -module.exports = function (branch, done) { +module.exports = function (branch, ES_BRANCHES_DIR, done) { /** * Creates a JSON version of the YAML test suite that can be simply bundled for use in the browser. */ @@ -11,7 +11,7 @@ module.exports = function (branch, done) { const _ = require(fromRoot('src/lib/utils')); const tests = {}; // populated in readYamlTests - const esDir = fromRoot('src/_elasticsearch_' + _.snakeCase(branch)); + const esDir = path.join(ES_BRANCHES_DIR, _.snakeCase(branch)); // generate the yaml tests async.series([ From f49e61c45495adc6ae8cc3633c5000907e702ff6 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 20:37:26 -0700 Subject: [PATCH 51/61] move yaml test files to tmp dir --- .gitignore | 2 -- .npmignore | 2 -- grunt/config/mochacov.js | 4 ++-- package.json | 1 + scripts/generate/index.js | 7 +++++-- scripts/generate/yaml_tests.js | 16 ++++++++++++---- yarn.lock | 16 ++++++---------- 7 files changed, 26 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index 1c06e6a0d..e936a311d 100644 --- a/.gitignore +++ b/.gitignore @@ -11,8 +11,6 @@ esvm /tmp ## generated files -test/integration/yaml_suite/yaml_tests*.json -test/integration/yaml_suite/index*.js src/bower*/ junit-*.xml elasticsearch*.log diff --git a/.npmignore b/.npmignore index 37383064b..10a544824 100644 --- a/.npmignore +++ b/.npmignore @@ -9,8 +9,6 @@ test/integration/yaml_suite/log esvm ## generated files -test/integration/yaml_suite/yaml_tests*.json -test/integration/yaml_suite/index*.js src/_elasticsearch*/ src/bower*/ junit-*.xml diff --git a/grunt/config/mochacov.js b/grunt/config/mochacov.js index 052ee45f4..78a693a12 100644 --- a/grunt/config/mochacov.js +++ b/grunt/config/mochacov.js @@ -65,7 +65,7 @@ const config = { grunt.registerTask('mocha_integration', function (branch) { grunt.config.set( 'mochacov.integration.src', - 'test/integration/yaml_suite/index_' + _.snakeCase(branch) + '.js' + 'tmp/yaml_tests/' + _.snakeCase(branch) + '/index.js' ); grunt.task.run('mochacov:integration'); }); @@ -73,7 +73,7 @@ grunt.registerTask('mocha_integration', function (branch) { grunt.registerTask('mocha_jenkins_integration', function (branch) { grunt.config.set( 'mochacov.jenkins_integration.src', - 'test/integration/yaml_suite/index_' + _.snakeCase(branch) + '.js' + 'tmp/yaml_tests/' + _.snakeCase(branch) + '/index.js' ); grunt.task.run('mochacov:jenkins_integration'); }); diff --git a/package.json b/package.json index b5d0039c3..70fe24532 100644 --- a/package.json +++ b/package.json @@ -76,6 +76,7 @@ "js-yaml": "^3.6.0", "load-grunt-config": "^0.19.2", "load-grunt-tasks": "^3.5.0", + "mkdirp": "^0.5.1", "mocha": "^2.2.5", "mocha-lcov-reporter": "0.0.1", "mocha-screencast-reporter": "~0.1.4", diff --git a/scripts/generate/index.js b/scripts/generate/index.js index c56f3f0d1..11cd10d0f 100644 --- a/scripts/generate/index.js +++ b/scripts/generate/index.js @@ -54,6 +54,7 @@ if (argv.branch) { const TMP_DIR = fromRoot('tmp'); const ES_REPO_DIR = path.join(TMP_DIR, 'es/repo'); const ES_BRANCHES_DIR = path.join(TMP_DIR, 'es/branches'); +const YAML_TESTS_DIR = path.join(TMP_DIR, 'yaml_tests'); const paths = { root: fromRoot('.'), @@ -183,7 +184,9 @@ function clearGeneratedFiles() { generatedFiles.push(findGeneratedApiFiles()); } - generatedFiles.push(dirRegex(paths.src, esArchives)); + if (argv.api) { + generatedFiles.push(YAML_TESTS_DIR); + } const rmSteps = _.chain(generatedFiles) .flatten() @@ -234,7 +237,7 @@ function generateStep(branch) { return function (done) { async.parallel([ argv.api && async.apply(require('./js_api'), branch), - argv.tests && async.apply(require('./yaml_tests'), branch, ES_BRANCHES_DIR) + argv.tests && async.apply(require('./yaml_tests'), branch, ES_BRANCHES_DIR, YAML_TESTS_DIR) ].filter(Boolean), done); }; } diff --git a/scripts/generate/yaml_tests.js b/scripts/generate/yaml_tests.js index 924a225a8..6e81cdd2c 100644 --- a/scripts/generate/yaml_tests.js +++ b/scripts/generate/yaml_tests.js @@ -1,4 +1,4 @@ -module.exports = function (branch, ES_BRANCHES_DIR, done) { +module.exports = function (branch, ES_BRANCHES_DIR, YAML_TESTS_DIR, done) { /** * Creates a JSON version of the YAML test suite that can be simply bundled for use in the browser. */ @@ -7,10 +7,12 @@ module.exports = function (branch, ES_BRANCHES_DIR, done) { const async = require('async'); const chalk = require('chalk'); const path = require('path'); + const mkdirp = require('mkdirp'); const fromRoot = path.join.bind(path, require('find-root')(__dirname)); const _ = require(fromRoot('src/lib/utils')); const tests = {}; // populated in readYamlTests + const RUN_SCRIPT_PATH = fromRoot('test/integration/yaml_suite/run'); const esDir = path.join(ES_BRANCHES_DIR, _.snakeCase(branch)); // generate the yaml tests @@ -43,15 +45,21 @@ module.exports = function (branch, ES_BRANCHES_DIR, done) { } function writeYamlTests(done) { - const testFile = fromRoot('test/integration/yaml_suite/yaml_tests_' + _.snakeCase(branch) + '.json'); + const testFile = path.join(YAML_TESTS_DIR, _.snakeCase(branch), 'spec.json'); + + mkdirp.sync(path.dirname(testFile)); fs.writeFileSync(testFile, JSON.stringify(tests, null, ' '), 'utf8'); console.log(chalk.white.bold('wrote') + ' YAML tests as JSON to', testFile); done(); } function writeTestIndex(done) { - const file = fromRoot('test/integration/yaml_suite/index_' + _.snakeCase(branch) + '.js'); - fs.writeFileSync(file, 'require(\'./run\')(\'' + branch + '\');\n', 'utf8'); + const file = path.join(YAML_TESTS_DIR, _.snakeCase(branch), 'index.js'); + const fileDir = path.dirname(file); + const relativeRunFile = path.relative(fileDir, RUN_SCRIPT_PATH); + + mkdirp.sync(fileDir); + fs.writeFileSync(file, 'require(\'' + relativeRunFile + '\')(\'' + branch + '\');\n', 'utf8'); console.log(chalk.white.bold('wrote') + ' YAML index to', file); done(); } diff --git a/yarn.lock b/yarn.lock index 8129200a0..2c0573b52 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2997,14 +2997,14 @@ mime-types@~2.0.1, mime-types@~2.0.3: dependencies: mime-db "~1.12.0" -mime@*, mime@1.3.4, mime@^1.3.4: - version "1.3.4" - resolved "https://registry.yarnpkg.com/mime/-/mime-1.3.4.tgz#115f9e3b6b3daf2959983cb38f149a2d40eb5d53" - -mime@~1.2.11, mime@~1.2.5, mime@~1.2.9: +mime@*, mime@~1.2.11, mime@~1.2.5, mime@~1.2.9: version "1.2.11" resolved "https://registry.yarnpkg.com/mime/-/mime-1.2.11.tgz#58203eed86e3a5ef17aed2b7d9ebd47f0a60dd10" +mime@1.3.4, mime@^1.3.4: + version "1.3.4" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.3.4.tgz#115f9e3b6b3daf2959983cb38f149a2d40eb5d53" + minimatch@0.3: version "0.3.0" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-0.3.0.tgz#275d8edaac4f1bb3326472089e7949c8394699dd" @@ -3544,7 +3544,7 @@ qs@0.6.6: version "0.6.6" resolved "https://registry.yarnpkg.com/qs/-/qs-0.6.6.tgz#6e015098ff51968b8a3c819001d5f2c89bc4b107" -qs@5.2.0: +qs@5.2.0, qs@~5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/qs/-/qs-5.2.0.tgz#a9f31142af468cb72b25b30136ba2456834916be" @@ -3564,10 +3564,6 @@ qs@~5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/qs/-/qs-5.1.0.tgz#4d932e5c7ea411cca76a312d39a606200fd50cd9" -qs@~5.2.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/qs/-/qs-5.2.1.tgz#801fee030e0b9450d6385adc48a4cc55b44aedfc" - querystring-es3@^0.2.0: version "0.2.1" resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73" From 01137f9e5d9e13e4385509c9887b71aa896dbdd4 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 20:38:38 -0700 Subject: [PATCH 52/61] update .npmignore file to match .gitignore --- .npmignore | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.npmignore b/.npmignore index 10a544824..8d383be98 100644 --- a/.npmignore +++ b/.npmignore @@ -1,5 +1,5 @@ +.DS_Store dist -bower_components npm-debug.log node_modules scripts/scratch* @@ -7,9 +7,10 @@ test/integration/yaml_suite/log .aws-config.json .idea esvm +.es-snapshot-repos +/tmp ## generated files -src/_elasticsearch*/ src/bower*/ junit-*.xml elasticsearch*.log @@ -19,6 +20,7 @@ coverage.html html_docs ## just in .npmignore +/bower_components .eslintrc .travis.yml CHANGELOG.md From a6f4d549bd1057872b7f0c9ef148fefdb7e94179 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 20:40:00 -0700 Subject: [PATCH 53/61] move esvm directories to tmp dir --- .gitignore | 1 - .npmignore | 1 - grunt/config/esvm.js | 6 +++--- scripts/jenkins.sh | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index e936a311d..5a054b0ce 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,6 @@ test/integration/yaml_suite/log .aws-config.json .idea esvm -.es-snapshot-repos /tmp ## generated files diff --git a/.npmignore b/.npmignore index 8d383be98..042437606 100644 --- a/.npmignore +++ b/.npmignore @@ -7,7 +7,6 @@ test/integration/yaml_suite/log .aws-config.json .idea esvm -.es-snapshot-repos /tmp ## generated files diff --git a/grunt/config/esvm.js b/grunt/config/esvm.js index aa0526314..54c28189b 100644 --- a/grunt/config/esvm.js +++ b/grunt/config/esvm.js @@ -11,12 +11,12 @@ const Version = require('../../scripts/Version'); const versionedOpts = [ { version: '*', - directory: fromRoot('esvm'), + directory: fromRoot('tmp/esvm'), nodes: 1, quiet: false, logLevel: 'ERROR', config: { - 'path.data': fromRoot('esvm/data_dir'), + 'path.data': fromRoot('tmp/esvm/data_dir'), 'node.name': 'elasticsearch_js_test_runner', 'cluster.name': 'elasticsearch_js_test_runners', 'http.port': port, @@ -71,7 +71,7 @@ const versionedOpts = [ version: '>=1.6', config: { 'script.inline': true, - 'path.repo': process.env.ES_PATH_REPO || fromRoot('.es-snapshot-repos'), + 'path.repo': process.env.ES_PATH_REPO || fromRoot('tmp/.es-snapshot-repos'), 'repositories.url.allowed_urls': 'http://snapshot.*/' } } diff --git a/scripts/jenkins.sh b/scripts/jenkins.sh index 4193a50c2..d58ab6f3f 100644 --- a/scripts/jenkins.sh +++ b/scripts/jenkins.sh @@ -57,4 +57,4 @@ install_node "$(cat ./.node-version)" yarn release_lock -ES_PATH_REPO="./.es-snapshot-repos/$EXECUTOR_NUMBER/" ES_PORT=$((9400 + EXECUTOR_NUMBER)) RUN=NODE_UNIT,NODE_INTEGRATION VERBOSE=true node ./scripts/ci.js +ES_PATH_REPO="./tmp/.es-snapshot-repos/$EXECUTOR_NUMBER/" ES_PORT=$((9400 + EXECUTOR_NUMBER)) RUN=NODE_UNIT,NODE_INTEGRATION VERBOSE=true node ./scripts/ci.js From a9aa612f75e80337d324a009a066568f6801f740 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 20:44:46 -0700 Subject: [PATCH 54/61] move tracer log into tmp dir --- .gitignore | 1 - .npmignore | 1 - src/lib/loggers/tracer.js | 2 +- test/integration/yaml_suite/client_manager.js | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 5a054b0ce..bf1d5074c 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,6 @@ esvm ## generated files src/bower*/ junit-*.xml -elasticsearch*.log sauce_connect.lo* coverage.html .snapshots diff --git a/.npmignore b/.npmignore index 042437606..0d659b03f 100644 --- a/.npmignore +++ b/.npmignore @@ -12,7 +12,6 @@ esvm ## generated files src/bower*/ junit-*.xml -elasticsearch*.log sauce_connect.lo* coverage.html .snapshots diff --git a/src/lib/loggers/tracer.js b/src/lib/loggers/tracer.js index 96bf28ea7..1c73452a1 100755 --- a/src/lib/loggers/tracer.js +++ b/src/lib/loggers/tracer.js @@ -21,7 +21,7 @@ function Tracer(log, config) { if (config.path === false) { config.stream = process.stderr; } else { - config.stream = fs.createWriteStream(config.path || 'elasticsearch-tracer.log'); + config.stream = fs.createWriteStream(config.path || 'tmp/tracer.log'); } this.curlHost = config.curlHost || 'localhost'; diff --git a/test/integration/yaml_suite/client_manager.js b/test/integration/yaml_suite/client_manager.js index 3458aaa55..0e8d78c2f 100644 --- a/test/integration/yaml_suite/client_manager.js +++ b/test/integration/yaml_suite/client_manager.js @@ -76,7 +76,7 @@ module.exports = { if (logConfig && logConfig.type === 'tracer') { try { - fs.unlinkSync(fromRoot('elasticsearch-tracer.log')); + fs.unlinkSync(fromRoot('tmp/tracer.log')); } catch (error) { if (error.code !== 'ENOENT') { throw error; From 7b1a546b4ed8ed10f0182ba124bab8800769faa1 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 20:48:18 -0700 Subject: [PATCH 55/61] move angular/angular-mocks deps to npm --- .npmignore | 1 - bower_components/angular-mocks/.bower.json | 19 - bower_components/angular-mocks/README.md | 42 - .../angular-mocks/angular-mocks.js | 2177 -- bower_components/angular-mocks/bower.json | 8 - bower_components/angular/.bower.json | 16 - bower_components/angular/README.md | 48 - bower_components/angular/angular-csp.css | 24 - bower_components/angular/angular.js | 22024 ---------------- bower_components/angular/angular.min.js | 216 - bower_components/angular/angular.min.js.gzip | Bin 39789 -> 0 bytes bower_components/angular/angular.min.js.map | 8 - bower_components/angular/bower.json | 7 - package.json | 2 + test/utils/server.js | 4 +- yarn.lock | 14 +- 16 files changed, 13 insertions(+), 24597 deletions(-) delete mode 100644 bower_components/angular-mocks/.bower.json delete mode 100644 bower_components/angular-mocks/README.md delete mode 100644 bower_components/angular-mocks/angular-mocks.js delete mode 100644 bower_components/angular-mocks/bower.json delete mode 100644 bower_components/angular/.bower.json delete mode 100644 bower_components/angular/README.md delete mode 100644 bower_components/angular/angular-csp.css delete mode 100644 bower_components/angular/angular.js delete mode 100644 bower_components/angular/angular.min.js delete mode 100644 bower_components/angular/angular.min.js.gzip delete mode 100644 bower_components/angular/angular.min.js.map delete mode 100644 bower_components/angular/bower.json diff --git a/.npmignore b/.npmignore index 0d659b03f..26ee2d9ac 100644 --- a/.npmignore +++ b/.npmignore @@ -18,7 +18,6 @@ coverage.html html_docs ## just in .npmignore -/bower_components .eslintrc .travis.yml CHANGELOG.md diff --git a/bower_components/angular-mocks/.bower.json b/bower_components/angular-mocks/.bower.json deleted file mode 100644 index e15011874..000000000 --- a/bower_components/angular-mocks/.bower.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "angular-mocks", - "version": "1.2.25", - "main": "./angular-mocks.js", - "dependencies": { - "angular": "1.2.25" - }, - "homepage": "https://github.com/angular/bower-angular-mocks", - "_release": "1.2.25", - "_resolution": { - "type": "version", - "tag": "v1.2.25", - "commit": "e3351b37d02cfc1a9302f3eb57febc3acb77d0c8" - }, - "_source": "git://github.com/angular/bower-angular-mocks.git", - "_target": "~1.2.25", - "_originalSource": "angular-mocks", - "_direct": true -} \ No newline at end of file diff --git a/bower_components/angular-mocks/README.md b/bower_components/angular-mocks/README.md deleted file mode 100644 index 3448d2849..000000000 --- a/bower_components/angular-mocks/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# bower-angular-mocks - -This repo is for distribution on `bower`. The source for this module is in the -[main AngularJS repo](https://github.com/angular/angular.js/tree/master/src/ngMock). -Please file issues and pull requests against that repo. - -## Install - -Install with `bower`: - -```shell -bower install angular-mocks -``` - -## Documentation - -Documentation is available on the -[AngularJS docs site](http://docs.angularjs.org/guide/dev_guide.unit-testing). - -## License - -The MIT License - -Copyright (c) 2010-2012 Google, Inc. http://angularjs.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/bower_components/angular-mocks/angular-mocks.js b/bower_components/angular-mocks/angular-mocks.js deleted file mode 100644 index 054bb0b9b..000000000 --- a/bower_components/angular-mocks/angular-mocks.js +++ /dev/null @@ -1,2177 +0,0 @@ -/** - * @license AngularJS v1.2.25 - * (c) 2010-2014 Google, Inc. http://angularjs.org - * License: MIT - */ -(function(window, angular, undefined) { - -'use strict'; - -/** - * @ngdoc object - * @name angular.mock - * @description - * - * Namespace from 'angular-mocks.js' which contains testing related code. - */ -angular.mock = {}; - -/** - * ! This is a private undocumented service ! - * - * @name $browser - * - * @description - * This service is a mock implementation of {@link ng.$browser}. It provides fake - * implementation for commonly used browser apis that are hard to test, e.g. setTimeout, xhr, - * cookies, etc... - * - * The api of this service is the same as that of the real {@link ng.$browser $browser}, except - * that there are several helper methods available which can be used in tests. - */ -angular.mock.$BrowserProvider = function() { - this.$get = function() { - return new angular.mock.$Browser(); - }; -}; - -angular.mock.$Browser = function() { - var self = this; - - this.isMock = true; - self.$$url = "http://server/"; - self.$$lastUrl = self.$$url; // used by url polling fn - self.pollFns = []; - - // TODO(vojta): remove this temporary api - self.$$completeOutstandingRequest = angular.noop; - self.$$incOutstandingRequestCount = angular.noop; - - - // register url polling fn - - self.onUrlChange = function(listener) { - self.pollFns.push( - function() { - if (self.$$lastUrl != self.$$url) { - self.$$lastUrl = self.$$url; - listener(self.$$url); - } - } - ); - - return listener; - }; - - self.$$checkUrlChange = angular.noop; - - self.cookieHash = {}; - self.lastCookieHash = {}; - self.deferredFns = []; - self.deferredNextId = 0; - - self.defer = function(fn, delay) { - delay = delay || 0; - self.deferredFns.push({time:(self.defer.now + delay), fn:fn, id: self.deferredNextId}); - self.deferredFns.sort(function(a,b){ return a.time - b.time;}); - return self.deferredNextId++; - }; - - - /** - * @name $browser#defer.now - * - * @description - * Current milliseconds mock time. - */ - self.defer.now = 0; - - - self.defer.cancel = function(deferId) { - var fnIndex; - - angular.forEach(self.deferredFns, function(fn, index) { - if (fn.id === deferId) fnIndex = index; - }); - - if (fnIndex !== undefined) { - self.deferredFns.splice(fnIndex, 1); - return true; - } - - return false; - }; - - - /** - * @name $browser#defer.flush - * - * @description - * Flushes all pending requests and executes the defer callbacks. - * - * @param {number=} number of milliseconds to flush. See {@link #defer.now} - */ - self.defer.flush = function(delay) { - if (angular.isDefined(delay)) { - self.defer.now += delay; - } else { - if (self.deferredFns.length) { - self.defer.now = self.deferredFns[self.deferredFns.length-1].time; - } else { - throw new Error('No deferred tasks to be flushed'); - } - } - - while (self.deferredFns.length && self.deferredFns[0].time <= self.defer.now) { - self.deferredFns.shift().fn(); - } - }; - - self.$$baseHref = ''; - self.baseHref = function() { - return this.$$baseHref; - }; -}; -angular.mock.$Browser.prototype = { - -/** - * @name $browser#poll - * - * @description - * run all fns in pollFns - */ - poll: function poll() { - angular.forEach(this.pollFns, function(pollFn){ - pollFn(); - }); - }, - - addPollFn: function(pollFn) { - this.pollFns.push(pollFn); - return pollFn; - }, - - url: function(url, replace) { - if (url) { - this.$$url = url; - return this; - } - - return this.$$url; - }, - - cookies: function(name, value) { - if (name) { - if (angular.isUndefined(value)) { - delete this.cookieHash[name]; - } else { - if (angular.isString(value) && //strings only - value.length <= 4096) { //strict cookie storage limits - this.cookieHash[name] = value; - } - } - } else { - if (!angular.equals(this.cookieHash, this.lastCookieHash)) { - this.lastCookieHash = angular.copy(this.cookieHash); - this.cookieHash = angular.copy(this.cookieHash); - } - return this.cookieHash; - } - }, - - notifyWhenNoOutstandingRequests: function(fn) { - fn(); - } -}; - - -/** - * @ngdoc provider - * @name $exceptionHandlerProvider - * - * @description - * Configures the mock implementation of {@link ng.$exceptionHandler} to rethrow or to log errors - * passed into the `$exceptionHandler`. - */ - -/** - * @ngdoc service - * @name $exceptionHandler - * - * @description - * Mock implementation of {@link ng.$exceptionHandler} that rethrows or logs errors passed - * into it. See {@link ngMock.$exceptionHandlerProvider $exceptionHandlerProvider} for configuration - * information. - * - * - * ```js - * describe('$exceptionHandlerProvider', function() { - * - * it('should capture log messages and exceptions', function() { - * - * module(function($exceptionHandlerProvider) { - * $exceptionHandlerProvider.mode('log'); - * }); - * - * inject(function($log, $exceptionHandler, $timeout) { - * $timeout(function() { $log.log(1); }); - * $timeout(function() { $log.log(2); throw 'banana peel'; }); - * $timeout(function() { $log.log(3); }); - * expect($exceptionHandler.errors).toEqual([]); - * expect($log.assertEmpty()); - * $timeout.flush(); - * expect($exceptionHandler.errors).toEqual(['banana peel']); - * expect($log.log.logs).toEqual([[1], [2], [3]]); - * }); - * }); - * }); - * ``` - */ - -angular.mock.$ExceptionHandlerProvider = function() { - var handler; - - /** - * @ngdoc method - * @name $exceptionHandlerProvider#mode - * - * @description - * Sets the logging mode. - * - * @param {string} mode Mode of operation, defaults to `rethrow`. - * - * - `rethrow`: If any errors are passed into the handler in tests, it typically - * means that there is a bug in the application or test, so this mock will - * make these tests fail. - * - `log`: Sometimes it is desirable to test that an error is thrown, for this case the `log` - * mode stores an array of errors in `$exceptionHandler.errors`, to allow later - * assertion of them. See {@link ngMock.$log#assertEmpty assertEmpty()} and - * {@link ngMock.$log#reset reset()} - */ - this.mode = function(mode) { - switch(mode) { - case 'rethrow': - handler = function(e) { - throw e; - }; - break; - case 'log': - var errors = []; - - handler = function(e) { - if (arguments.length == 1) { - errors.push(e); - } else { - errors.push([].slice.call(arguments, 0)); - } - }; - - handler.errors = errors; - break; - default: - throw new Error("Unknown mode '" + mode + "', only 'log'/'rethrow' modes are allowed!"); - } - }; - - this.$get = function() { - return handler; - }; - - this.mode('rethrow'); -}; - - -/** - * @ngdoc service - * @name $log - * - * @description - * Mock implementation of {@link ng.$log} that gathers all logged messages in arrays - * (one array per logging level). These arrays are exposed as `logs` property of each of the - * level-specific log function, e.g. for level `error` the array is exposed as `$log.error.logs`. - * - */ -angular.mock.$LogProvider = function() { - var debug = true; - - function concat(array1, array2, index) { - return array1.concat(Array.prototype.slice.call(array2, index)); - } - - this.debugEnabled = function(flag) { - if (angular.isDefined(flag)) { - debug = flag; - return this; - } else { - return debug; - } - }; - - this.$get = function () { - var $log = { - log: function() { $log.log.logs.push(concat([], arguments, 0)); }, - warn: function() { $log.warn.logs.push(concat([], arguments, 0)); }, - info: function() { $log.info.logs.push(concat([], arguments, 0)); }, - error: function() { $log.error.logs.push(concat([], arguments, 0)); }, - debug: function() { - if (debug) { - $log.debug.logs.push(concat([], arguments, 0)); - } - } - }; - - /** - * @ngdoc method - * @name $log#reset - * - * @description - * Reset all of the logging arrays to empty. - */ - $log.reset = function () { - /** - * @ngdoc property - * @name $log#log.logs - * - * @description - * Array of messages logged using {@link ngMock.$log#log}. - * - * @example - * ```js - * $log.log('Some Log'); - * var first = $log.log.logs.unshift(); - * ``` - */ - $log.log.logs = []; - /** - * @ngdoc property - * @name $log#info.logs - * - * @description - * Array of messages logged using {@link ngMock.$log#info}. - * - * @example - * ```js - * $log.info('Some Info'); - * var first = $log.info.logs.unshift(); - * ``` - */ - $log.info.logs = []; - /** - * @ngdoc property - * @name $log#warn.logs - * - * @description - * Array of messages logged using {@link ngMock.$log#warn}. - * - * @example - * ```js - * $log.warn('Some Warning'); - * var first = $log.warn.logs.unshift(); - * ``` - */ - $log.warn.logs = []; - /** - * @ngdoc property - * @name $log#error.logs - * - * @description - * Array of messages logged using {@link ngMock.$log#error}. - * - * @example - * ```js - * $log.error('Some Error'); - * var first = $log.error.logs.unshift(); - * ``` - */ - $log.error.logs = []; - /** - * @ngdoc property - * @name $log#debug.logs - * - * @description - * Array of messages logged using {@link ngMock.$log#debug}. - * - * @example - * ```js - * $log.debug('Some Error'); - * var first = $log.debug.logs.unshift(); - * ``` - */ - $log.debug.logs = []; - }; - - /** - * @ngdoc method - * @name $log#assertEmpty - * - * @description - * Assert that the all of the logging methods have no logged messages. If messages present, an - * exception is thrown. - */ - $log.assertEmpty = function() { - var errors = []; - angular.forEach(['error', 'warn', 'info', 'log', 'debug'], function(logLevel) { - angular.forEach($log[logLevel].logs, function(log) { - angular.forEach(log, function (logItem) { - errors.push('MOCK $log (' + logLevel + '): ' + String(logItem) + '\n' + - (logItem.stack || '')); - }); - }); - }); - if (errors.length) { - errors.unshift("Expected $log to be empty! Either a message was logged unexpectedly, or "+ - "an expected log message was not checked and removed:"); - errors.push(''); - throw new Error(errors.join('\n---------\n')); - } - }; - - $log.reset(); - return $log; - }; -}; - - -/** - * @ngdoc service - * @name $interval - * - * @description - * Mock implementation of the $interval service. - * - * Use {@link ngMock.$interval#flush `$interval.flush(millis)`} to - * move forward by `millis` milliseconds and trigger any functions scheduled to run in that - * time. - * - * @param {function()} fn A function that should be called repeatedly. - * @param {number} delay Number of milliseconds between each function call. - * @param {number=} [count=0] Number of times to repeat. If not set, or 0, will repeat - * indefinitely. - * @param {boolean=} [invokeApply=true] If set to `false` skips model dirty checking, otherwise - * will invoke `fn` within the {@link ng.$rootScope.Scope#$apply $apply} block. - * @returns {promise} A promise which will be notified on each iteration. - */ -angular.mock.$IntervalProvider = function() { - this.$get = ['$rootScope', '$q', - function($rootScope, $q) { - var repeatFns = [], - nextRepeatId = 0, - now = 0; - - var $interval = function(fn, delay, count, invokeApply) { - var deferred = $q.defer(), - promise = deferred.promise, - iteration = 0, - skipApply = (angular.isDefined(invokeApply) && !invokeApply); - - count = (angular.isDefined(count)) ? count : 0; - promise.then(null, null, fn); - - promise.$$intervalId = nextRepeatId; - - function tick() { - deferred.notify(iteration++); - - if (count > 0 && iteration >= count) { - var fnIndex; - deferred.resolve(iteration); - - angular.forEach(repeatFns, function(fn, index) { - if (fn.id === promise.$$intervalId) fnIndex = index; - }); - - if (fnIndex !== undefined) { - repeatFns.splice(fnIndex, 1); - } - } - - if (!skipApply) $rootScope.$apply(); - } - - repeatFns.push({ - nextTime:(now + delay), - delay: delay, - fn: tick, - id: nextRepeatId, - deferred: deferred - }); - repeatFns.sort(function(a,b){ return a.nextTime - b.nextTime;}); - - nextRepeatId++; - return promise; - }; - /** - * @ngdoc method - * @name $interval#cancel - * - * @description - * Cancels a task associated with the `promise`. - * - * @param {promise} promise A promise from calling the `$interval` function. - * @returns {boolean} Returns `true` if the task was successfully cancelled. - */ - $interval.cancel = function(promise) { - if(!promise) return false; - var fnIndex; - - angular.forEach(repeatFns, function(fn, index) { - if (fn.id === promise.$$intervalId) fnIndex = index; - }); - - if (fnIndex !== undefined) { - repeatFns[fnIndex].deferred.reject('canceled'); - repeatFns.splice(fnIndex, 1); - return true; - } - - return false; - }; - - /** - * @ngdoc method - * @name $interval#flush - * @description - * - * Runs interval tasks scheduled to be run in the next `millis` milliseconds. - * - * @param {number=} millis maximum timeout amount to flush up until. - * - * @return {number} The amount of time moved forward. - */ - $interval.flush = function(millis) { - now += millis; - while (repeatFns.length && repeatFns[0].nextTime <= now) { - var task = repeatFns[0]; - task.fn(); - task.nextTime += task.delay; - repeatFns.sort(function(a,b){ return a.nextTime - b.nextTime;}); - } - return millis; - }; - - return $interval; - }]; -}; - - -/* jshint -W101 */ -/* The R_ISO8061_STR regex is never going to fit into the 100 char limit! - * This directive should go inside the anonymous function but a bug in JSHint means that it would - * not be enacted early enough to prevent the warning. - */ -var R_ISO8061_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?:\:?(\d\d)(?:\:?(\d\d)(?:\.(\d{3}))?)?)?(Z|([+-])(\d\d):?(\d\d)))?$/; - -function jsonStringToDate(string) { - var match; - if (match = string.match(R_ISO8061_STR)) { - var date = new Date(0), - tzHour = 0, - tzMin = 0; - if (match[9]) { - tzHour = int(match[9] + match[10]); - tzMin = int(match[9] + match[11]); - } - date.setUTCFullYear(int(match[1]), int(match[2]) - 1, int(match[3])); - date.setUTCHours(int(match[4]||0) - tzHour, - int(match[5]||0) - tzMin, - int(match[6]||0), - int(match[7]||0)); - return date; - } - return string; -} - -function int(str) { - return parseInt(str, 10); -} - -function padNumber(num, digits, trim) { - var neg = ''; - if (num < 0) { - neg = '-'; - num = -num; - } - num = '' + num; - while(num.length < digits) num = '0' + num; - if (trim) - num = num.substr(num.length - digits); - return neg + num; -} - - -/** - * @ngdoc type - * @name angular.mock.TzDate - * @description - * - * *NOTE*: this is not an injectable instance, just a globally available mock class of `Date`. - * - * Mock of the Date type which has its timezone specified via constructor arg. - * - * The main purpose is to create Date-like instances with timezone fixed to the specified timezone - * offset, so that we can test code that depends on local timezone settings without dependency on - * the time zone settings of the machine where the code is running. - * - * @param {number} offset Offset of the *desired* timezone in hours (fractions will be honored) - * @param {(number|string)} timestamp Timestamp representing the desired time in *UTC* - * - * @example - * !!!! WARNING !!!!! - * This is not a complete Date object so only methods that were implemented can be called safely. - * To make matters worse, TzDate instances inherit stuff from Date via a prototype. - * - * We do our best to intercept calls to "unimplemented" methods, but since the list of methods is - * incomplete we might be missing some non-standard methods. This can result in errors like: - * "Date.prototype.foo called on incompatible Object". - * - * ```js - * var newYearInBratislava = new TzDate(-1, '2009-12-31T23:00:00Z'); - * newYearInBratislava.getTimezoneOffset() => -60; - * newYearInBratislava.getFullYear() => 2010; - * newYearInBratislava.getMonth() => 0; - * newYearInBratislava.getDate() => 1; - * newYearInBratislava.getHours() => 0; - * newYearInBratislava.getMinutes() => 0; - * newYearInBratislava.getSeconds() => 0; - * ``` - * - */ -angular.mock.TzDate = function (offset, timestamp) { - var self = new Date(0); - if (angular.isString(timestamp)) { - var tsStr = timestamp; - - self.origDate = jsonStringToDate(timestamp); - - timestamp = self.origDate.getTime(); - if (isNaN(timestamp)) - throw { - name: "Illegal Argument", - message: "Arg '" + tsStr + "' passed into TzDate constructor is not a valid date string" - }; - } else { - self.origDate = new Date(timestamp); - } - - var localOffset = new Date(timestamp).getTimezoneOffset(); - self.offsetDiff = localOffset*60*1000 - offset*1000*60*60; - self.date = new Date(timestamp + self.offsetDiff); - - self.getTime = function() { - return self.date.getTime() - self.offsetDiff; - }; - - self.toLocaleDateString = function() { - return self.date.toLocaleDateString(); - }; - - self.getFullYear = function() { - return self.date.getFullYear(); - }; - - self.getMonth = function() { - return self.date.getMonth(); - }; - - self.getDate = function() { - return self.date.getDate(); - }; - - self.getHours = function() { - return self.date.getHours(); - }; - - self.getMinutes = function() { - return self.date.getMinutes(); - }; - - self.getSeconds = function() { - return self.date.getSeconds(); - }; - - self.getMilliseconds = function() { - return self.date.getMilliseconds(); - }; - - self.getTimezoneOffset = function() { - return offset * 60; - }; - - self.getUTCFullYear = function() { - return self.origDate.getUTCFullYear(); - }; - - self.getUTCMonth = function() { - return self.origDate.getUTCMonth(); - }; - - self.getUTCDate = function() { - return self.origDate.getUTCDate(); - }; - - self.getUTCHours = function() { - return self.origDate.getUTCHours(); - }; - - self.getUTCMinutes = function() { - return self.origDate.getUTCMinutes(); - }; - - self.getUTCSeconds = function() { - return self.origDate.getUTCSeconds(); - }; - - self.getUTCMilliseconds = function() { - return self.origDate.getUTCMilliseconds(); - }; - - self.getDay = function() { - return self.date.getDay(); - }; - - // provide this method only on browsers that already have it - if (self.toISOString) { - self.toISOString = function() { - return padNumber(self.origDate.getUTCFullYear(), 4) + '-' + - padNumber(self.origDate.getUTCMonth() + 1, 2) + '-' + - padNumber(self.origDate.getUTCDate(), 2) + 'T' + - padNumber(self.origDate.getUTCHours(), 2) + ':' + - padNumber(self.origDate.getUTCMinutes(), 2) + ':' + - padNumber(self.origDate.getUTCSeconds(), 2) + '.' + - padNumber(self.origDate.getUTCMilliseconds(), 3) + 'Z'; - }; - } - - //hide all methods not implemented in this mock that the Date prototype exposes - var unimplementedMethods = ['getUTCDay', - 'getYear', 'setDate', 'setFullYear', 'setHours', 'setMilliseconds', - 'setMinutes', 'setMonth', 'setSeconds', 'setTime', 'setUTCDate', 'setUTCFullYear', - 'setUTCHours', 'setUTCMilliseconds', 'setUTCMinutes', 'setUTCMonth', 'setUTCSeconds', - 'setYear', 'toDateString', 'toGMTString', 'toJSON', 'toLocaleFormat', 'toLocaleString', - 'toLocaleTimeString', 'toSource', 'toString', 'toTimeString', 'toUTCString', 'valueOf']; - - angular.forEach(unimplementedMethods, function(methodName) { - self[methodName] = function() { - throw new Error("Method '" + methodName + "' is not implemented in the TzDate mock"); - }; - }); - - return self; -}; - -//make "tzDateInstance instanceof Date" return true -angular.mock.TzDate.prototype = Date.prototype; -/* jshint +W101 */ - -angular.mock.animate = angular.module('ngAnimateMock', ['ng']) - - .config(['$provide', function($provide) { - - var reflowQueue = []; - $provide.value('$$animateReflow', function(fn) { - var index = reflowQueue.length; - reflowQueue.push(fn); - return function cancel() { - reflowQueue.splice(index, 1); - }; - }); - - $provide.decorator('$animate', function($delegate, $$asyncCallback) { - var animate = { - queue : [], - enabled : $delegate.enabled, - triggerCallbacks : function() { - $$asyncCallback.flush(); - }, - triggerReflow : function() { - angular.forEach(reflowQueue, function(fn) { - fn(); - }); - reflowQueue = []; - } - }; - - angular.forEach( - ['enter','leave','move','addClass','removeClass','setClass'], function(method) { - animate[method] = function() { - animate.queue.push({ - event : method, - element : arguments[0], - args : arguments - }); - $delegate[method].apply($delegate, arguments); - }; - }); - - return animate; - }); - - }]); - - -/** - * @ngdoc function - * @name angular.mock.dump - * @description - * - * *NOTE*: this is not an injectable instance, just a globally available function. - * - * Method for serializing common angular objects (scope, elements, etc..) into strings, useful for - * debugging. - * - * This method is also available on window, where it can be used to display objects on debug - * console. - * - * @param {*} object - any object to turn into string. - * @return {string} a serialized string of the argument - */ -angular.mock.dump = function(object) { - return serialize(object); - - function serialize(object) { - var out; - - if (angular.isElement(object)) { - object = angular.element(object); - out = angular.element('
'); - angular.forEach(object, function(element) { - out.append(angular.element(element).clone()); - }); - out = out.html(); - } else if (angular.isArray(object)) { - out = []; - angular.forEach(object, function(o) { - out.push(serialize(o)); - }); - out = '[ ' + out.join(', ') + ' ]'; - } else if (angular.isObject(object)) { - if (angular.isFunction(object.$eval) && angular.isFunction(object.$apply)) { - out = serializeScope(object); - } else if (object instanceof Error) { - out = object.stack || ('' + object.name + ': ' + object.message); - } else { - // TODO(i): this prevents methods being logged, - // we should have a better way to serialize objects - out = angular.toJson(object, true); - } - } else { - out = String(object); - } - - return out; - } - - function serializeScope(scope, offset) { - offset = offset || ' '; - var log = [offset + 'Scope(' + scope.$id + '): {']; - for ( var key in scope ) { - if (Object.prototype.hasOwnProperty.call(scope, key) && !key.match(/^(\$|this)/)) { - log.push(' ' + key + ': ' + angular.toJson(scope[key])); - } - } - var child = scope.$$childHead; - while(child) { - log.push(serializeScope(child, offset + ' ')); - child = child.$$nextSibling; - } - log.push('}'); - return log.join('\n' + offset); - } -}; - -/** - * @ngdoc service - * @name $httpBackend - * @description - * Fake HTTP backend implementation suitable for unit testing applications that use the - * {@link ng.$http $http service}. - * - * *Note*: For fake HTTP backend implementation suitable for end-to-end testing or backend-less - * development please see {@link ngMockE2E.$httpBackend e2e $httpBackend mock}. - * - * During unit testing, we want our unit tests to run quickly and have no external dependencies so - * we don’t want to send [XHR](https://developer.mozilla.org/en/xmlhttprequest) or - * [JSONP](http://en.wikipedia.org/wiki/JSONP) requests to a real server. All we really need is - * to verify whether a certain request has been sent or not, or alternatively just let the - * application make requests, respond with pre-trained responses and assert that the end result is - * what we expect it to be. - * - * This mock implementation can be used to respond with static or dynamic responses via the - * `expect` and `when` apis and their shortcuts (`expectGET`, `whenPOST`, etc). - * - * When an Angular application needs some data from a server, it calls the $http service, which - * sends the request to a real server using $httpBackend service. With dependency injection, it is - * easy to inject $httpBackend mock (which has the same API as $httpBackend) and use it to verify - * the requests and respond with some testing data without sending a request to a real server. - * - * There are two ways to specify what test data should be returned as http responses by the mock - * backend when the code under test makes http requests: - * - * - `$httpBackend.expect` - specifies a request expectation - * - `$httpBackend.when` - specifies a backend definition - * - * - * # Request Expectations vs Backend Definitions - * - * Request expectations provide a way to make assertions about requests made by the application and - * to define responses for those requests. The test will fail if the expected requests are not made - * or they are made in the wrong order. - * - * Backend definitions allow you to define a fake backend for your application which doesn't assert - * if a particular request was made or not, it just returns a trained response if a request is made. - * The test will pass whether or not the request gets made during testing. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Request expectationsBackend definitions
Syntax.expect(...).respond(...).when(...).respond(...)
Typical usagestrict unit testsloose (black-box) unit testing
Fulfills multiple requestsNOYES
Order of requests mattersYESNO
Request requiredYESNO
Response requiredoptional (see below)YES
- * - * In cases where both backend definitions and request expectations are specified during unit - * testing, the request expectations are evaluated first. - * - * If a request expectation has no response specified, the algorithm will search your backend - * definitions for an appropriate response. - * - * If a request didn't match any expectation or if the expectation doesn't have the response - * defined, the backend definitions are evaluated in sequential order to see if any of them match - * the request. The response from the first matched definition is returned. - * - * - * # Flushing HTTP requests - * - * The $httpBackend used in production always responds to requests asynchronously. If we preserved - * this behavior in unit testing, we'd have to create async unit tests, which are hard to write, - * to follow and to maintain. But neither can the testing mock respond synchronously; that would - * change the execution of the code under test. For this reason, the mock $httpBackend has a - * `flush()` method, which allows the test to explicitly flush pending requests. This preserves - * the async api of the backend, while allowing the test to execute synchronously. - * - * - * # Unit testing with mock $httpBackend - * The following code shows how to setup and use the mock backend when unit testing a controller. - * First we create the controller under test: - * - ```js - // The controller code - function MyController($scope, $http) { - var authToken; - - $http.get('/auth.py').success(function(data, status, headers) { - authToken = headers('A-Token'); - $scope.user = data; - }); - - $scope.saveMessage = function(message) { - var headers = { 'Authorization': authToken }; - $scope.status = 'Saving...'; - - $http.post('/add-msg.py', message, { headers: headers } ).success(function(response) { - $scope.status = ''; - }).error(function() { - $scope.status = 'ERROR!'; - }); - }; - } - ``` - * - * Now we setup the mock backend and create the test specs: - * - ```js - // testing controller - describe('MyController', function() { - var $httpBackend, $rootScope, createController; - - beforeEach(inject(function($injector) { - // Set up the mock http service responses - $httpBackend = $injector.get('$httpBackend'); - // backend definition common for all tests - $httpBackend.when('GET', '/auth.py').respond({userId: 'userX'}, {'A-Token': 'xxx'}); - - // Get hold of a scope (i.e. the root scope) - $rootScope = $injector.get('$rootScope'); - // The $controller service is used to create instances of controllers - var $controller = $injector.get('$controller'); - - createController = function() { - return $controller('MyController', {'$scope' : $rootScope }); - }; - })); - - - afterEach(function() { - $httpBackend.verifyNoOutstandingExpectation(); - $httpBackend.verifyNoOutstandingRequest(); - }); - - - it('should fetch authentication token', function() { - $httpBackend.expectGET('/auth.py'); - var controller = createController(); - $httpBackend.flush(); - }); - - - it('should send msg to server', function() { - var controller = createController(); - $httpBackend.flush(); - - // now you don’t care about the authentication, but - // the controller will still send the request and - // $httpBackend will respond without you having to - // specify the expectation and response for this request - - $httpBackend.expectPOST('/add-msg.py', 'message content').respond(201, ''); - $rootScope.saveMessage('message content'); - expect($rootScope.status).toBe('Saving...'); - $httpBackend.flush(); - expect($rootScope.status).toBe(''); - }); - - - it('should send auth header', function() { - var controller = createController(); - $httpBackend.flush(); - - $httpBackend.expectPOST('/add-msg.py', undefined, function(headers) { - // check if the header was send, if it wasn't the expectation won't - // match the request and the test will fail - return headers['Authorization'] == 'xxx'; - }).respond(201, ''); - - $rootScope.saveMessage('whatever'); - $httpBackend.flush(); - }); - }); - ``` - */ -angular.mock.$HttpBackendProvider = function() { - this.$get = ['$rootScope', createHttpBackendMock]; -}; - -/** - * General factory function for $httpBackend mock. - * Returns instance for unit testing (when no arguments specified): - * - passing through is disabled - * - auto flushing is disabled - * - * Returns instance for e2e testing (when `$delegate` and `$browser` specified): - * - passing through (delegating request to real backend) is enabled - * - auto flushing is enabled - * - * @param {Object=} $delegate Real $httpBackend instance (allow passing through if specified) - * @param {Object=} $browser Auto-flushing enabled if specified - * @return {Object} Instance of $httpBackend mock - */ -function createHttpBackendMock($rootScope, $delegate, $browser) { - var definitions = [], - expectations = [], - responses = [], - responsesPush = angular.bind(responses, responses.push), - copy = angular.copy; - - function createResponse(status, data, headers, statusText) { - if (angular.isFunction(status)) return status; - - return function() { - return angular.isNumber(status) - ? [status, data, headers, statusText] - : [200, status, data]; - }; - } - - // TODO(vojta): change params to: method, url, data, headers, callback - function $httpBackend(method, url, data, callback, headers, timeout, withCredentials) { - var xhr = new MockXhr(), - expectation = expectations[0], - wasExpected = false; - - function prettyPrint(data) { - return (angular.isString(data) || angular.isFunction(data) || data instanceof RegExp) - ? data - : angular.toJson(data); - } - - function wrapResponse(wrapped) { - if (!$browser && timeout && timeout.then) timeout.then(handleTimeout); - - return handleResponse; - - function handleResponse() { - var response = wrapped.response(method, url, data, headers); - xhr.$$respHeaders = response[2]; - callback(copy(response[0]), copy(response[1]), xhr.getAllResponseHeaders(), - copy(response[3] || '')); - } - - function handleTimeout() { - for (var i = 0, ii = responses.length; i < ii; i++) { - if (responses[i] === handleResponse) { - responses.splice(i, 1); - callback(-1, undefined, ''); - break; - } - } - } - } - - if (expectation && expectation.match(method, url)) { - if (!expectation.matchData(data)) - throw new Error('Expected ' + expectation + ' with different data\n' + - 'EXPECTED: ' + prettyPrint(expectation.data) + '\nGOT: ' + data); - - if (!expectation.matchHeaders(headers)) - throw new Error('Expected ' + expectation + ' with different headers\n' + - 'EXPECTED: ' + prettyPrint(expectation.headers) + '\nGOT: ' + - prettyPrint(headers)); - - expectations.shift(); - - if (expectation.response) { - responses.push(wrapResponse(expectation)); - return; - } - wasExpected = true; - } - - var i = -1, definition; - while ((definition = definitions[++i])) { - if (definition.match(method, url, data, headers || {})) { - if (definition.response) { - // if $browser specified, we do auto flush all requests - ($browser ? $browser.defer : responsesPush)(wrapResponse(definition)); - } else if (definition.passThrough) { - $delegate(method, url, data, callback, headers, timeout, withCredentials); - } else throw new Error('No response defined !'); - return; - } - } - throw wasExpected ? - new Error('No response defined !') : - new Error('Unexpected request: ' + method + ' ' + url + '\n' + - (expectation ? 'Expected ' + expectation : 'No more request expected')); - } - - /** - * @ngdoc method - * @name $httpBackend#when - * @description - * Creates a new backend definition. - * - * @param {string} method HTTP method. - * @param {string|RegExp} url HTTP url. - * @param {(string|RegExp|function(string))=} data HTTP request body or function that receives - * data string and returns true if the data is as expected. - * @param {(Object|function(Object))=} headers HTTP headers or function that receives http header - * object and returns true if the headers match the current definition. - * @returns {requestHandler} Returns an object with `respond` method that controls how a matched - * request is handled. - * - * - respond – - * `{function([status,] data[, headers, statusText]) - * | function(function(method, url, data, headers)}` - * – The respond method takes a set of static data to be returned or a function that can - * return an array containing response status (number), response data (string), response - * headers (Object), and the text for the status (string). - */ - $httpBackend.when = function(method, url, data, headers) { - var definition = new MockHttpExpectation(method, url, data, headers), - chain = { - respond: function(status, data, headers, statusText) { - definition.response = createResponse(status, data, headers, statusText); - } - }; - - if ($browser) { - chain.passThrough = function() { - definition.passThrough = true; - }; - } - - definitions.push(definition); - return chain; - }; - - /** - * @ngdoc method - * @name $httpBackend#whenGET - * @description - * Creates a new backend definition for GET requests. For more info see `when()`. - * - * @param {string|RegExp} url HTTP url. - * @param {(Object|function(Object))=} headers HTTP headers. - * @returns {requestHandler} Returns an object with `respond` method that control how a matched - * request is handled. - */ - - /** - * @ngdoc method - * @name $httpBackend#whenHEAD - * @description - * Creates a new backend definition for HEAD requests. For more info see `when()`. - * - * @param {string|RegExp} url HTTP url. - * @param {(Object|function(Object))=} headers HTTP headers. - * @returns {requestHandler} Returns an object with `respond` method that control how a matched - * request is handled. - */ - - /** - * @ngdoc method - * @name $httpBackend#whenDELETE - * @description - * Creates a new backend definition for DELETE requests. For more info see `when()`. - * - * @param {string|RegExp} url HTTP url. - * @param {(Object|function(Object))=} headers HTTP headers. - * @returns {requestHandler} Returns an object with `respond` method that control how a matched - * request is handled. - */ - - /** - * @ngdoc method - * @name $httpBackend#whenPOST - * @description - * Creates a new backend definition for POST requests. For more info see `when()`. - * - * @param {string|RegExp} url HTTP url. - * @param {(string|RegExp|function(string))=} data HTTP request body or function that receives - * data string and returns true if the data is as expected. - * @param {(Object|function(Object))=} headers HTTP headers. - * @returns {requestHandler} Returns an object with `respond` method that control how a matched - * request is handled. - */ - - /** - * @ngdoc method - * @name $httpBackend#whenPUT - * @description - * Creates a new backend definition for PUT requests. For more info see `when()`. - * - * @param {string|RegExp} url HTTP url. - * @param {(string|RegExp|function(string))=} data HTTP request body or function that receives - * data string and returns true if the data is as expected. - * @param {(Object|function(Object))=} headers HTTP headers. - * @returns {requestHandler} Returns an object with `respond` method that control how a matched - * request is handled. - */ - - /** - * @ngdoc method - * @name $httpBackend#whenJSONP - * @description - * Creates a new backend definition for JSONP requests. For more info see `when()`. - * - * @param {string|RegExp} url HTTP url. - * @returns {requestHandler} Returns an object with `respond` method that control how a matched - * request is handled. - */ - createShortMethods('when'); - - - /** - * @ngdoc method - * @name $httpBackend#expect - * @description - * Creates a new request expectation. - * - * @param {string} method HTTP method. - * @param {string|RegExp} url HTTP url. - * @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that - * receives data string and returns true if the data is as expected, or Object if request body - * is in JSON format. - * @param {(Object|function(Object))=} headers HTTP headers or function that receives http header - * object and returns true if the headers match the current expectation. - * @returns {requestHandler} Returns an object with `respond` method that control how a matched - * request is handled. - * - * - respond – - * `{function([status,] data[, headers, statusText]) - * | function(function(method, url, data, headers)}` - * – The respond method takes a set of static data to be returned or a function that can - * return an array containing response status (number), response data (string), response - * headers (Object), and the text for the status (string). - */ - $httpBackend.expect = function(method, url, data, headers) { - var expectation = new MockHttpExpectation(method, url, data, headers); - expectations.push(expectation); - return { - respond: function (status, data, headers, statusText) { - expectation.response = createResponse(status, data, headers, statusText); - } - }; - }; - - - /** - * @ngdoc method - * @name $httpBackend#expectGET - * @description - * Creates a new request expectation for GET requests. For more info see `expect()`. - * - * @param {string|RegExp} url HTTP url. - * @param {Object=} headers HTTP headers. - * @returns {requestHandler} Returns an object with `respond` method that control how a matched - * request is handled. See #expect for more info. - */ - - /** - * @ngdoc method - * @name $httpBackend#expectHEAD - * @description - * Creates a new request expectation for HEAD requests. For more info see `expect()`. - * - * @param {string|RegExp} url HTTP url. - * @param {Object=} headers HTTP headers. - * @returns {requestHandler} Returns an object with `respond` method that control how a matched - * request is handled. - */ - - /** - * @ngdoc method - * @name $httpBackend#expectDELETE - * @description - * Creates a new request expectation for DELETE requests. For more info see `expect()`. - * - * @param {string|RegExp} url HTTP url. - * @param {Object=} headers HTTP headers. - * @returns {requestHandler} Returns an object with `respond` method that control how a matched - * request is handled. - */ - - /** - * @ngdoc method - * @name $httpBackend#expectPOST - * @description - * Creates a new request expectation for POST requests. For more info see `expect()`. - * - * @param {string|RegExp} url HTTP url. - * @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that - * receives data string and returns true if the data is as expected, or Object if request body - * is in JSON format. - * @param {Object=} headers HTTP headers. - * @returns {requestHandler} Returns an object with `respond` method that control how a matched - * request is handled. - */ - - /** - * @ngdoc method - * @name $httpBackend#expectPUT - * @description - * Creates a new request expectation for PUT requests. For more info see `expect()`. - * - * @param {string|RegExp} url HTTP url. - * @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that - * receives data string and returns true if the data is as expected, or Object if request body - * is in JSON format. - * @param {Object=} headers HTTP headers. - * @returns {requestHandler} Returns an object with `respond` method that control how a matched - * request is handled. - */ - - /** - * @ngdoc method - * @name $httpBackend#expectPATCH - * @description - * Creates a new request expectation for PATCH requests. For more info see `expect()`. - * - * @param {string|RegExp} url HTTP url. - * @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that - * receives data string and returns true if the data is as expected, or Object if request body - * is in JSON format. - * @param {Object=} headers HTTP headers. - * @returns {requestHandler} Returns an object with `respond` method that control how a matched - * request is handled. - */ - - /** - * @ngdoc method - * @name $httpBackend#expectJSONP - * @description - * Creates a new request expectation for JSONP requests. For more info see `expect()`. - * - * @param {string|RegExp} url HTTP url. - * @returns {requestHandler} Returns an object with `respond` method that control how a matched - * request is handled. - */ - createShortMethods('expect'); - - - /** - * @ngdoc method - * @name $httpBackend#flush - * @description - * Flushes all pending requests using the trained responses. - * - * @param {number=} count Number of responses to flush (in the order they arrived). If undefined, - * all pending requests will be flushed. If there are no pending requests when the flush method - * is called an exception is thrown (as this typically a sign of programming error). - */ - $httpBackend.flush = function(count) { - $rootScope.$digest(); - if (!responses.length) throw new Error('No pending request to flush !'); - - if (angular.isDefined(count)) { - while (count--) { - if (!responses.length) throw new Error('No more pending request to flush !'); - responses.shift()(); - } - } else { - while (responses.length) { - responses.shift()(); - } - } - $httpBackend.verifyNoOutstandingExpectation(); - }; - - - /** - * @ngdoc method - * @name $httpBackend#verifyNoOutstandingExpectation - * @description - * Verifies that all of the requests defined via the `expect` api were made. If any of the - * requests were not made, verifyNoOutstandingExpectation throws an exception. - * - * Typically, you would call this method following each test case that asserts requests using an - * "afterEach" clause. - * - * ```js - * afterEach($httpBackend.verifyNoOutstandingExpectation); - * ``` - */ - $httpBackend.verifyNoOutstandingExpectation = function() { - $rootScope.$digest(); - if (expectations.length) { - throw new Error('Unsatisfied requests: ' + expectations.join(', ')); - } - }; - - - /** - * @ngdoc method - * @name $httpBackend#verifyNoOutstandingRequest - * @description - * Verifies that there are no outstanding requests that need to be flushed. - * - * Typically, you would call this method following each test case that asserts requests using an - * "afterEach" clause. - * - * ```js - * afterEach($httpBackend.verifyNoOutstandingRequest); - * ``` - */ - $httpBackend.verifyNoOutstandingRequest = function() { - if (responses.length) { - throw new Error('Unflushed requests: ' + responses.length); - } - }; - - - /** - * @ngdoc method - * @name $httpBackend#resetExpectations - * @description - * Resets all request expectations, but preserves all backend definitions. Typically, you would - * call resetExpectations during a multiple-phase test when you want to reuse the same instance of - * $httpBackend mock. - */ - $httpBackend.resetExpectations = function() { - expectations.length = 0; - responses.length = 0; - }; - - return $httpBackend; - - - function createShortMethods(prefix) { - angular.forEach(['GET', 'DELETE', 'JSONP'], function(method) { - $httpBackend[prefix + method] = function(url, headers) { - return $httpBackend[prefix](method, url, undefined, headers); - }; - }); - - angular.forEach(['PUT', 'POST', 'PATCH'], function(method) { - $httpBackend[prefix + method] = function(url, data, headers) { - return $httpBackend[prefix](method, url, data, headers); - }; - }); - } -} - -function MockHttpExpectation(method, url, data, headers) { - - this.data = data; - this.headers = headers; - - this.match = function(m, u, d, h) { - if (method != m) return false; - if (!this.matchUrl(u)) return false; - if (angular.isDefined(d) && !this.matchData(d)) return false; - if (angular.isDefined(h) && !this.matchHeaders(h)) return false; - return true; - }; - - this.matchUrl = function(u) { - if (!url) return true; - if (angular.isFunction(url.test)) return url.test(u); - return url == u; - }; - - this.matchHeaders = function(h) { - if (angular.isUndefined(headers)) return true; - if (angular.isFunction(headers)) return headers(h); - return angular.equals(headers, h); - }; - - this.matchData = function(d) { - if (angular.isUndefined(data)) return true; - if (data && angular.isFunction(data.test)) return data.test(d); - if (data && angular.isFunction(data)) return data(d); - if (data && !angular.isString(data)) return angular.equals(data, angular.fromJson(d)); - return data == d; - }; - - this.toString = function() { - return method + ' ' + url; - }; -} - -function createMockXhr() { - return new MockXhr(); -} - -function MockXhr() { - - // hack for testing $http, $httpBackend - MockXhr.$$lastInstance = this; - - this.open = function(method, url, async) { - this.$$method = method; - this.$$url = url; - this.$$async = async; - this.$$reqHeaders = {}; - this.$$respHeaders = {}; - }; - - this.send = function(data) { - this.$$data = data; - }; - - this.setRequestHeader = function(key, value) { - this.$$reqHeaders[key] = value; - }; - - this.getResponseHeader = function(name) { - // the lookup must be case insensitive, - // that's why we try two quick lookups first and full scan last - var header = this.$$respHeaders[name]; - if (header) return header; - - name = angular.lowercase(name); - header = this.$$respHeaders[name]; - if (header) return header; - - header = undefined; - angular.forEach(this.$$respHeaders, function(headerVal, headerName) { - if (!header && angular.lowercase(headerName) == name) header = headerVal; - }); - return header; - }; - - this.getAllResponseHeaders = function() { - var lines = []; - - angular.forEach(this.$$respHeaders, function(value, key) { - lines.push(key + ': ' + value); - }); - return lines.join('\n'); - }; - - this.abort = angular.noop; -} - - -/** - * @ngdoc service - * @name $timeout - * @description - * - * This service is just a simple decorator for {@link ng.$timeout $timeout} service - * that adds a "flush" and "verifyNoPendingTasks" methods. - */ - -angular.mock.$TimeoutDecorator = function($delegate, $browser) { - - /** - * @ngdoc method - * @name $timeout#flush - * @description - * - * Flushes the queue of pending tasks. - * - * @param {number=} delay maximum timeout amount to flush up until - */ - $delegate.flush = function(delay) { - $browser.defer.flush(delay); - }; - - /** - * @ngdoc method - * @name $timeout#verifyNoPendingTasks - * @description - * - * Verifies that there are no pending tasks that need to be flushed. - */ - $delegate.verifyNoPendingTasks = function() { - if ($browser.deferredFns.length) { - throw new Error('Deferred tasks to flush (' + $browser.deferredFns.length + '): ' + - formatPendingTasksAsString($browser.deferredFns)); - } - }; - - function formatPendingTasksAsString(tasks) { - var result = []; - angular.forEach(tasks, function(task) { - result.push('{id: ' + task.id + ', ' + 'time: ' + task.time + '}'); - }); - - return result.join(', '); - } - - return $delegate; -}; - -angular.mock.$RAFDecorator = function($delegate) { - var queue = []; - var rafFn = function(fn) { - var index = queue.length; - queue.push(fn); - return function() { - queue.splice(index, 1); - }; - }; - - rafFn.supported = $delegate.supported; - - rafFn.flush = function() { - if(queue.length === 0) { - throw new Error('No rAF callbacks present'); - } - - var length = queue.length; - for(var i=0;i'); - }; -}; - -/** - * @ngdoc module - * @name ngMock - * @packageName angular-mocks - * @description - * - * # ngMock - * - * The `ngMock` module provides support to inject and mock Angular services into unit tests. - * In addition, ngMock also extends various core ng services such that they can be - * inspected and controlled in a synchronous manner within test code. - * - * - *
- * - */ -angular.module('ngMock', ['ng']).provider({ - $browser: angular.mock.$BrowserProvider, - $exceptionHandler: angular.mock.$ExceptionHandlerProvider, - $log: angular.mock.$LogProvider, - $interval: angular.mock.$IntervalProvider, - $httpBackend: angular.mock.$HttpBackendProvider, - $rootElement: angular.mock.$RootElementProvider -}).config(['$provide', function($provide) { - $provide.decorator('$timeout', angular.mock.$TimeoutDecorator); - $provide.decorator('$$rAF', angular.mock.$RAFDecorator); - $provide.decorator('$$asyncCallback', angular.mock.$AsyncCallbackDecorator); -}]); - -/** - * @ngdoc module - * @name ngMockE2E - * @module ngMockE2E - * @packageName angular-mocks - * @description - * - * The `ngMockE2E` is an angular module which contains mocks suitable for end-to-end testing. - * Currently there is only one mock present in this module - - * the {@link ngMockE2E.$httpBackend e2e $httpBackend} mock. - */ -angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) { - $provide.decorator('$httpBackend', angular.mock.e2e.$httpBackendDecorator); -}]); - -/** - * @ngdoc service - * @name $httpBackend - * @module ngMockE2E - * @description - * Fake HTTP backend implementation suitable for end-to-end testing or backend-less development of - * applications that use the {@link ng.$http $http service}. - * - * *Note*: For fake http backend implementation suitable for unit testing please see - * {@link ngMock.$httpBackend unit-testing $httpBackend mock}. - * - * This implementation can be used to respond with static or dynamic responses via the `when` api - * and its shortcuts (`whenGET`, `whenPOST`, etc) and optionally pass through requests to the - * real $httpBackend for specific requests (e.g. to interact with certain remote apis or to fetch - * templates from a webserver). - * - * As opposed to unit-testing, in an end-to-end testing scenario or in scenario when an application - * is being developed with the real backend api replaced with a mock, it is often desirable for - * certain category of requests to bypass the mock and issue a real http request (e.g. to fetch - * templates or static files from the webserver). To configure the backend with this behavior - * use the `passThrough` request handler of `when` instead of `respond`. - * - * Additionally, we don't want to manually have to flush mocked out requests like we do during unit - * testing. For this reason the e2e $httpBackend flushes mocked out requests - * automatically, closely simulating the behavior of the XMLHttpRequest object. - * - * To setup the application to run with this http backend, you have to create a module that depends - * on the `ngMockE2E` and your application modules and defines the fake backend: - * - * ```js - * myAppDev = angular.module('myAppDev', ['myApp', 'ngMockE2E']); - * myAppDev.run(function($httpBackend) { - * phones = [{name: 'phone1'}, {name: 'phone2'}]; - * - * // returns the current list of phones - * $httpBackend.whenGET('/phones').respond(phones); - * - * // adds a new phone to the phones array - * $httpBackend.whenPOST('/phones').respond(function(method, url, data) { - * var phone = angular.fromJson(data); - * phones.push(phone); - * return [200, phone, {}]; - * }); - * $httpBackend.whenGET(/^\/templates\//).passThrough(); - * //... - * }); - * ``` - * - * Afterwards, bootstrap your app with this new module. - */ - -/** - * @ngdoc method - * @name $httpBackend#when - * @module ngMockE2E - * @description - * Creates a new backend definition. - * - * @param {string} method HTTP method. - * @param {string|RegExp} url HTTP url. - * @param {(string|RegExp)=} data HTTP request body. - * @param {(Object|function(Object))=} headers HTTP headers or function that receives http header - * object and returns true if the headers match the current definition. - * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that - * control how a matched request is handled. - * - * - respond – - * `{function([status,] data[, headers, statusText]) - * | function(function(method, url, data, headers)}` - * – The respond method takes a set of static data to be returned or a function that can return - * an array containing response status (number), response data (string), response headers - * (Object), and the text for the status (string). - * - passThrough – `{function()}` – Any request matching a backend definition with - * `passThrough` handler will be passed through to the real backend (an XHR request will be made - * to the server.) - */ - -/** - * @ngdoc method - * @name $httpBackend#whenGET - * @module ngMockE2E - * @description - * Creates a new backend definition for GET requests. For more info see `when()`. - * - * @param {string|RegExp} url HTTP url. - * @param {(Object|function(Object))=} headers HTTP headers. - * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that - * control how a matched request is handled. - */ - -/** - * @ngdoc method - * @name $httpBackend#whenHEAD - * @module ngMockE2E - * @description - * Creates a new backend definition for HEAD requests. For more info see `when()`. - * - * @param {string|RegExp} url HTTP url. - * @param {(Object|function(Object))=} headers HTTP headers. - * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that - * control how a matched request is handled. - */ - -/** - * @ngdoc method - * @name $httpBackend#whenDELETE - * @module ngMockE2E - * @description - * Creates a new backend definition for DELETE requests. For more info see `when()`. - * - * @param {string|RegExp} url HTTP url. - * @param {(Object|function(Object))=} headers HTTP headers. - * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that - * control how a matched request is handled. - */ - -/** - * @ngdoc method - * @name $httpBackend#whenPOST - * @module ngMockE2E - * @description - * Creates a new backend definition for POST requests. For more info see `when()`. - * - * @param {string|RegExp} url HTTP url. - * @param {(string|RegExp)=} data HTTP request body. - * @param {(Object|function(Object))=} headers HTTP headers. - * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that - * control how a matched request is handled. - */ - -/** - * @ngdoc method - * @name $httpBackend#whenPUT - * @module ngMockE2E - * @description - * Creates a new backend definition for PUT requests. For more info see `when()`. - * - * @param {string|RegExp} url HTTP url. - * @param {(string|RegExp)=} data HTTP request body. - * @param {(Object|function(Object))=} headers HTTP headers. - * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that - * control how a matched request is handled. - */ - -/** - * @ngdoc method - * @name $httpBackend#whenPATCH - * @module ngMockE2E - * @description - * Creates a new backend definition for PATCH requests. For more info see `when()`. - * - * @param {string|RegExp} url HTTP url. - * @param {(string|RegExp)=} data HTTP request body. - * @param {(Object|function(Object))=} headers HTTP headers. - * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that - * control how a matched request is handled. - */ - -/** - * @ngdoc method - * @name $httpBackend#whenJSONP - * @module ngMockE2E - * @description - * Creates a new backend definition for JSONP requests. For more info see `when()`. - * - * @param {string|RegExp} url HTTP url. - * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that - * control how a matched request is handled. - */ -angular.mock.e2e = {}; -angular.mock.e2e.$httpBackendDecorator = - ['$rootScope', '$delegate', '$browser', createHttpBackendMock]; - - -angular.mock.clearDataCache = function() { - var key, - cache = angular.element.cache; - - for(key in cache) { - if (Object.prototype.hasOwnProperty.call(cache,key)) { - var handle = cache[key].handle; - - handle && angular.element(handle.elem).off(); - delete cache[key]; - } - } -}; - - -if(window.jasmine || window.mocha) { - - var currentSpec = null, - isSpecRunning = function() { - return !!currentSpec; - }; - - - (window.beforeEach || window.setup)(function() { - currentSpec = this; - }); - - (window.afterEach || window.teardown)(function() { - var injector = currentSpec.$injector; - - angular.forEach(currentSpec.$modules, function(module) { - if (module && module.$$hashKey) { - module.$$hashKey = undefined; - } - }); - - currentSpec.$injector = null; - currentSpec.$modules = null; - currentSpec = null; - - if (injector) { - injector.get('$rootElement').off(); - injector.get('$browser').pollFns.length = 0; - } - - angular.mock.clearDataCache(); - - // clean up jquery's fragment cache - angular.forEach(angular.element.fragments, function(val, key) { - delete angular.element.fragments[key]; - }); - - MockXhr.$$lastInstance = null; - - angular.forEach(angular.callbacks, function(val, key) { - delete angular.callbacks[key]; - }); - angular.callbacks.counter = 0; - }); - - /** - * @ngdoc function - * @name angular.mock.module - * @description - * - * *NOTE*: This function is also published on window for easy access.
- * *NOTE*: This function is declared ONLY WHEN running tests with jasmine or mocha - * - * This function registers a module configuration code. It collects the configuration information - * which will be used when the injector is created by {@link angular.mock.inject inject}. - * - * See {@link angular.mock.inject inject} for usage example - * - * @param {...(string|Function|Object)} fns any number of modules which are represented as string - * aliases or as anonymous module initialization functions. The modules are used to - * configure the injector. The 'ng' and 'ngMock' modules are automatically loaded. If an - * object literal is passed they will be registered as values in the module, the key being - * the module name and the value being what is returned. - */ - window.module = angular.mock.module = function() { - var moduleFns = Array.prototype.slice.call(arguments, 0); - return isSpecRunning() ? workFn() : workFn; - ///////////////////// - function workFn() { - if (currentSpec.$injector) { - throw new Error('Injector already created, can not register a module!'); - } else { - var modules = currentSpec.$modules || (currentSpec.$modules = []); - angular.forEach(moduleFns, function(module) { - if (angular.isObject(module) && !angular.isArray(module)) { - modules.push(function($provide) { - angular.forEach(module, function(value, key) { - $provide.value(key, value); - }); - }); - } else { - modules.push(module); - } - }); - } - } - }; - - /** - * @ngdoc function - * @name angular.mock.inject - * @description - * - * *NOTE*: This function is also published on window for easy access.
- * *NOTE*: This function is declared ONLY WHEN running tests with jasmine or mocha - * - * The inject function wraps a function into an injectable function. The inject() creates new - * instance of {@link auto.$injector $injector} per test, which is then used for - * resolving references. - * - * - * ## Resolving References (Underscore Wrapping) - * Often, we would like to inject a reference once, in a `beforeEach()` block and reuse this - * in multiple `it()` clauses. To be able to do this we must assign the reference to a variable - * that is declared in the scope of the `describe()` block. Since we would, most likely, want - * the variable to have the same name of the reference we have a problem, since the parameter - * to the `inject()` function would hide the outer variable. - * - * To help with this, the injected parameters can, optionally, be enclosed with underscores. - * These are ignored by the injector when the reference name is resolved. - * - * For example, the parameter `_myService_` would be resolved as the reference `myService`. - * Since it is available in the function body as _myService_, we can then assign it to a variable - * defined in an outer scope. - * - * ``` - * // Defined out reference variable outside - * var myService; - * - * // Wrap the parameter in underscores - * beforeEach( inject( function(_myService_){ - * myService = _myService_; - * })); - * - * // Use myService in a series of tests. - * it('makes use of myService', function() { - * myService.doStuff(); - * }); - * - * ``` - * - * See also {@link angular.mock.module angular.mock.module} - * - * ## Example - * Example of what a typical jasmine tests looks like with the inject method. - * ```js - * - * angular.module('myApplicationModule', []) - * .value('mode', 'app') - * .value('version', 'v1.0.1'); - * - * - * describe('MyApp', function() { - * - * // You need to load modules that you want to test, - * // it loads only the "ng" module by default. - * beforeEach(module('myApplicationModule')); - * - * - * // inject() is used to inject arguments of all given functions - * it('should provide a version', inject(function(mode, version) { - * expect(version).toEqual('v1.0.1'); - * expect(mode).toEqual('app'); - * })); - * - * - * // The inject and module method can also be used inside of the it or beforeEach - * it('should override a version and test the new version is injected', function() { - * // module() takes functions or strings (module aliases) - * module(function($provide) { - * $provide.value('version', 'overridden'); // override version here - * }); - * - * inject(function(version) { - * expect(version).toEqual('overridden'); - * }); - * }); - * }); - * - * ``` - * - * @param {...Function} fns any number of functions which will be injected using the injector. - */ - - - - var ErrorAddingDeclarationLocationStack = function(e, errorForStack) { - this.message = e.message; - this.name = e.name; - if (e.line) this.line = e.line; - if (e.sourceId) this.sourceId = e.sourceId; - if (e.stack && errorForStack) - this.stack = e.stack + '\n' + errorForStack.stack; - if (e.stackArray) this.stackArray = e.stackArray; - }; - ErrorAddingDeclarationLocationStack.prototype.toString = Error.prototype.toString; - - window.inject = angular.mock.inject = function() { - var blockFns = Array.prototype.slice.call(arguments, 0); - var errorForStack = new Error('Declaration Location'); - return isSpecRunning() ? workFn.call(currentSpec) : workFn; - ///////////////////// - function workFn() { - var modules = currentSpec.$modules || []; - - modules.unshift('ngMock'); - modules.unshift('ng'); - var injector = currentSpec.$injector; - if (!injector) { - injector = currentSpec.$injector = angular.injector(modules); - } - for(var i = 0, ii = blockFns.length; i < ii; i++) { - try { - /* jshint -W040 *//* Jasmine explicitly provides a `this` object when calling functions */ - injector.invoke(blockFns[i] || angular.noop, this); - /* jshint +W040 */ - } catch (e) { - if (e.stack && errorForStack) { - throw new ErrorAddingDeclarationLocationStack(e, errorForStack); - } - throw e; - } finally { - errorForStack = null; - } - } - } - }; -} - - -})(window, window.angular); diff --git a/bower_components/angular-mocks/bower.json b/bower_components/angular-mocks/bower.json deleted file mode 100644 index 2fd96eb8c..000000000 --- a/bower_components/angular-mocks/bower.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "angular-mocks", - "version": "1.2.25", - "main": "./angular-mocks.js", - "dependencies": { - "angular": "1.2.25" - } -} diff --git a/bower_components/angular/.bower.json b/bower_components/angular/.bower.json deleted file mode 100644 index a312cd450..000000000 --- a/bower_components/angular/.bower.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "angular", - "version": "1.2.25", - "main": "./angular.js", - "dependencies": {}, - "homepage": "https://github.com/angular/bower-angular", - "_release": "1.2.25", - "_resolution": { - "type": "version", - "tag": "v1.2.25", - "commit": "0d956316b0472031ac895e57c14b8b2100eea9fb" - }, - "_source": "git://github.com/angular/bower-angular.git", - "_target": "1.2.25", - "_originalSource": "angular" -} \ No newline at end of file diff --git a/bower_components/angular/README.md b/bower_components/angular/README.md deleted file mode 100644 index fc0c09987..000000000 --- a/bower_components/angular/README.md +++ /dev/null @@ -1,48 +0,0 @@ -# bower-angular - -This repo is for distribution on `bower`. The source for this module is in the -[main AngularJS repo](https://github.com/angular/angular.js). -Please file issues and pull requests against that repo. - -## Install - -Install with `bower`: - -```shell -bower install angular -``` - -Add a ` -``` - -## Documentation - -Documentation is available on the -[AngularJS docs site](http://docs.angularjs.org/). - -## License - -The MIT License - -Copyright (c) 2010-2012 Google, Inc. http://angularjs.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/bower_components/angular/angular-csp.css b/bower_components/angular/angular-csp.css deleted file mode 100644 index 3abb3a0e6..000000000 --- a/bower_components/angular/angular-csp.css +++ /dev/null @@ -1,24 +0,0 @@ -/* Include this file in your html if you are using the CSP mode. */ - -@charset "UTF-8"; - -[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], -.ng-cloak, .x-ng-cloak, -.ng-hide { - display: none !important; -} - -ng\:form { - display: block; -} - -.ng-animate-block-transitions { - transition:0s all!important; - -webkit-transition:0s all!important; -} - -/* show the element during a show/hide animation when the - * animation is ongoing, but the .ng-hide class is active */ -.ng-hide-add-active, .ng-hide-remove { - display: block!important; -} diff --git a/bower_components/angular/angular.js b/bower_components/angular/angular.js deleted file mode 100644 index 132234b62..000000000 --- a/bower_components/angular/angular.js +++ /dev/null @@ -1,22024 +0,0 @@ -/** - * @license AngularJS v1.2.25 - * (c) 2010-2014 Google, Inc. http://angularjs.org - * License: MIT - */ -(function(window, document, undefined) {'use strict'; - -/** - * @description - * - * This object provides a utility for producing rich Error messages within - * Angular. It can be called as follows: - * - * var exampleMinErr = minErr('example'); - * throw exampleMinErr('one', 'This {0} is {1}', foo, bar); - * - * The above creates an instance of minErr in the example namespace. The - * resulting error will have a namespaced error code of example.one. The - * resulting error will replace {0} with the value of foo, and {1} with the - * value of bar. The object is not restricted in the number of arguments it can - * take. - * - * If fewer arguments are specified than necessary for interpolation, the extra - * interpolation markers will be preserved in the final string. - * - * Since data will be parsed statically during a build step, some restrictions - * are applied with respect to how minErr instances are created and called. - * Instances should have names of the form namespaceMinErr for a minErr created - * using minErr('namespace') . Error codes, namespaces and template strings - * should all be static strings, not variables or general expressions. - * - * @param {string} module The namespace to use for the new minErr instance. - * @returns {function(code:string, template:string, ...templateArgs): Error} minErr instance - */ - -function minErr(module) { - return function () { - var code = arguments[0], - prefix = '[' + (module ? module + ':' : '') + code + '] ', - template = arguments[1], - templateArgs = arguments, - stringify = function (obj) { - if (typeof obj === 'function') { - return obj.toString().replace(/ \{[\s\S]*$/, ''); - } else if (typeof obj === 'undefined') { - return 'undefined'; - } else if (typeof obj !== 'string') { - return JSON.stringify(obj); - } - return obj; - }, - message, i; - - message = prefix + template.replace(/\{\d+\}/g, function (match) { - var index = +match.slice(1, -1), arg; - - if (index + 2 < templateArgs.length) { - arg = templateArgs[index + 2]; - if (typeof arg === 'function') { - return arg.toString().replace(/ ?\{[\s\S]*$/, ''); - } else if (typeof arg === 'undefined') { - return 'undefined'; - } else if (typeof arg !== 'string') { - return toJson(arg); - } - return arg; - } - return match; - }); - - message = message + '\nhttp://errors.angularjs.org/1.2.25/' + - (module ? module + '/' : '') + code; - for (i = 2; i < arguments.length; i++) { - message = message + (i == 2 ? '?' : '&') + 'p' + (i-2) + '=' + - encodeURIComponent(stringify(arguments[i])); - } - - return new Error(message); - }; -} - -/* We need to tell jshint what variables are being exported */ -/* global angular: true, - msie: true, - jqLite: true, - jQuery: true, - slice: true, - push: true, - toString: true, - ngMinErr: true, - angularModule: true, - nodeName_: true, - uid: true, - VALIDITY_STATE_PROPERTY: true, - - lowercase: true, - uppercase: true, - manualLowercase: true, - manualUppercase: true, - nodeName_: true, - isArrayLike: true, - forEach: true, - sortedKeys: true, - forEachSorted: true, - reverseParams: true, - nextUid: true, - setHashKey: true, - extend: true, - int: true, - inherit: true, - noop: true, - identity: true, - valueFn: true, - isUndefined: true, - isDefined: true, - isObject: true, - isString: true, - isNumber: true, - isDate: true, - isArray: true, - isFunction: true, - isRegExp: true, - isWindow: true, - isScope: true, - isFile: true, - isBlob: true, - isBoolean: true, - isPromiseLike: true, - trim: true, - isElement: true, - makeMap: true, - map: true, - size: true, - includes: true, - indexOf: true, - arrayRemove: true, - isLeafNode: true, - copy: true, - shallowCopy: true, - equals: true, - csp: true, - concat: true, - sliceArgs: true, - bind: true, - toJsonReplacer: true, - toJson: true, - fromJson: true, - toBoolean: true, - startingTag: true, - tryDecodeURIComponent: true, - parseKeyValue: true, - toKeyValue: true, - encodeUriSegment: true, - encodeUriQuery: true, - angularInit: true, - bootstrap: true, - snake_case: true, - bindJQuery: true, - assertArg: true, - assertArgFn: true, - assertNotHasOwnProperty: true, - getter: true, - getBlockElements: true, - hasOwnProperty: true, -*/ - -//////////////////////////////////// - -/** - * @ngdoc module - * @name ng - * @module ng - * @description - * - * # ng (core module) - * The ng module is loaded by default when an AngularJS application is started. The module itself - * contains the essential components for an AngularJS application to function. The table below - * lists a high level breakdown of each of the services/factories, filters, directives and testing - * components available within this core module. - * - *
- */ - -// The name of a form control's ValidityState property. -// This is used so that it's possible for internal tests to create mock ValidityStates. -var VALIDITY_STATE_PROPERTY = 'validity'; - -/** - * @ngdoc function - * @name angular.lowercase - * @module ng - * @kind function - * - * @description Converts the specified string to lowercase. - * @param {string} string String to be converted to lowercase. - * @returns {string} Lowercased string. - */ -var lowercase = function(string){return isString(string) ? string.toLowerCase() : string;}; -var hasOwnProperty = Object.prototype.hasOwnProperty; - -/** - * @ngdoc function - * @name angular.uppercase - * @module ng - * @kind function - * - * @description Converts the specified string to uppercase. - * @param {string} string String to be converted to uppercase. - * @returns {string} Uppercased string. - */ -var uppercase = function(string){return isString(string) ? string.toUpperCase() : string;}; - - -var manualLowercase = function(s) { - /* jshint bitwise: false */ - return isString(s) - ? s.replace(/[A-Z]/g, function(ch) {return String.fromCharCode(ch.charCodeAt(0) | 32);}) - : s; -}; -var manualUppercase = function(s) { - /* jshint bitwise: false */ - return isString(s) - ? s.replace(/[a-z]/g, function(ch) {return String.fromCharCode(ch.charCodeAt(0) & ~32);}) - : s; -}; - - -// String#toLowerCase and String#toUpperCase don't produce correct results in browsers with Turkish -// locale, for this reason we need to detect this case and redefine lowercase/uppercase methods -// with correct but slower alternatives. -if ('i' !== 'I'.toLowerCase()) { - lowercase = manualLowercase; - uppercase = manualUppercase; -} - - -var /** holds major version number for IE or NaN for real browsers */ - msie, - jqLite, // delay binding since jQuery could be loaded after us. - jQuery, // delay binding - slice = [].slice, - push = [].push, - toString = Object.prototype.toString, - ngMinErr = minErr('ng'), - - /** @name angular */ - angular = window.angular || (window.angular = {}), - angularModule, - nodeName_, - uid = ['0', '0', '0']; - -/** - * IE 11 changed the format of the UserAgent string. - * See http://msdn.microsoft.com/en-us/library/ms537503.aspx - */ -msie = int((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]); -if (isNaN(msie)) { - msie = int((/trident\/.*; rv:(\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]); -} - - -/** - * @private - * @param {*} obj - * @return {boolean} Returns true if `obj` is an array or array-like object (NodeList, Arguments, - * String ...) - */ -function isArrayLike(obj) { - if (obj == null || isWindow(obj)) { - return false; - } - - var length = obj.length; - - if (obj.nodeType === 1 && length) { - return true; - } - - return isString(obj) || isArray(obj) || length === 0 || - typeof length === 'number' && length > 0 && (length - 1) in obj; -} - -/** - * @ngdoc function - * @name angular.forEach - * @module ng - * @kind function - * - * @description - * Invokes the `iterator` function once for each item in `obj` collection, which can be either an - * object or an array. The `iterator` function is invoked with `iterator(value, key)`, where `value` - * is the value of an object property or an array element and `key` is the object property key or - * array element index. Specifying a `context` for the function is optional. - * - * It is worth noting that `.forEach` does not iterate over inherited properties because it filters - * using the `hasOwnProperty` method. - * - ```js - var values = {name: 'misko', gender: 'male'}; - var log = []; - angular.forEach(values, function(value, key) { - this.push(key + ': ' + value); - }, log); - expect(log).toEqual(['name: misko', 'gender: male']); - ``` - * - * @param {Object|Array} obj Object to iterate over. - * @param {Function} iterator Iterator function. - * @param {Object=} context Object to become context (`this`) for the iterator function. - * @returns {Object|Array} Reference to `obj`. - */ -function forEach(obj, iterator, context) { - var key; - if (obj) { - if (isFunction(obj)) { - for (key in obj) { - // Need to check if hasOwnProperty exists, - // as on IE8 the result of querySelectorAll is an object without a hasOwnProperty function - if (key != 'prototype' && key != 'length' && key != 'name' && (!obj.hasOwnProperty || obj.hasOwnProperty(key))) { - iterator.call(context, obj[key], key); - } - } - } else if (isArray(obj) || isArrayLike(obj)) { - for (key = 0; key < obj.length; key++) { - iterator.call(context, obj[key], key); - } - } else if (obj.forEach && obj.forEach !== forEach) { - obj.forEach(iterator, context); - } else { - for (key in obj) { - if (obj.hasOwnProperty(key)) { - iterator.call(context, obj[key], key); - } - } - } - } - return obj; -} - -function sortedKeys(obj) { - var keys = []; - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - keys.push(key); - } - } - return keys.sort(); -} - -function forEachSorted(obj, iterator, context) { - var keys = sortedKeys(obj); - for ( var i = 0; i < keys.length; i++) { - iterator.call(context, obj[keys[i]], keys[i]); - } - return keys; -} - - -/** - * when using forEach the params are value, key, but it is often useful to have key, value. - * @param {function(string, *)} iteratorFn - * @returns {function(*, string)} - */ -function reverseParams(iteratorFn) { - return function(value, key) { iteratorFn(key, value); }; -} - -/** - * A consistent way of creating unique IDs in angular. The ID is a sequence of alpha numeric - * characters such as '012ABC'. The reason why we are not using simply a number counter is that - * the number string gets longer over time, and it can also overflow, where as the nextId - * will grow much slower, it is a string, and it will never overflow. - * - * @returns {string} an unique alpha-numeric string - */ -function nextUid() { - var index = uid.length; - var digit; - - while(index) { - index--; - digit = uid[index].charCodeAt(0); - if (digit == 57 /*'9'*/) { - uid[index] = 'A'; - return uid.join(''); - } - if (digit == 90 /*'Z'*/) { - uid[index] = '0'; - } else { - uid[index] = String.fromCharCode(digit + 1); - return uid.join(''); - } - } - uid.unshift('0'); - return uid.join(''); -} - - -/** - * Set or clear the hashkey for an object. - * @param obj object - * @param h the hashkey (!truthy to delete the hashkey) - */ -function setHashKey(obj, h) { - if (h) { - obj.$$hashKey = h; - } - else { - delete obj.$$hashKey; - } -} - -/** - * @ngdoc function - * @name angular.extend - * @module ng - * @kind function - * - * @description - * Extends the destination object `dst` by copying all of the properties from the `src` object(s) - * to `dst`. You can specify multiple `src` objects. - * - * @param {Object} dst Destination object. - * @param {...Object} src Source object(s). - * @returns {Object} Reference to `dst`. - */ -function extend(dst) { - var h = dst.$$hashKey; - forEach(arguments, function(obj) { - if (obj !== dst) { - forEach(obj, function(value, key) { - dst[key] = value; - }); - } - }); - - setHashKey(dst,h); - return dst; -} - -function int(str) { - return parseInt(str, 10); -} - - -function inherit(parent, extra) { - return extend(new (extend(function() {}, {prototype:parent}))(), extra); -} - -/** - * @ngdoc function - * @name angular.noop - * @module ng - * @kind function - * - * @description - * A function that performs no operations. This function can be useful when writing code in the - * functional style. - ```js - function foo(callback) { - var result = calculateResult(); - (callback || angular.noop)(result); - } - ``` - */ -function noop() {} -noop.$inject = []; - - -/** - * @ngdoc function - * @name angular.identity - * @module ng - * @kind function - * - * @description - * A function that returns its first argument. This function is useful when writing code in the - * functional style. - * - ```js - function transformer(transformationFn, value) { - return (transformationFn || angular.identity)(value); - }; - ``` - */ -function identity($) {return $;} -identity.$inject = []; - - -function valueFn(value) {return function() {return value;};} - -/** - * @ngdoc function - * @name angular.isUndefined - * @module ng - * @kind function - * - * @description - * Determines if a reference is undefined. - * - * @param {*} value Reference to check. - * @returns {boolean} True if `value` is undefined. - */ -function isUndefined(value){return typeof value === 'undefined';} - - -/** - * @ngdoc function - * @name angular.isDefined - * @module ng - * @kind function - * - * @description - * Determines if a reference is defined. - * - * @param {*} value Reference to check. - * @returns {boolean} True if `value` is defined. - */ -function isDefined(value){return typeof value !== 'undefined';} - - -/** - * @ngdoc function - * @name angular.isObject - * @module ng - * @kind function - * - * @description - * Determines if a reference is an `Object`. Unlike `typeof` in JavaScript, `null`s are not - * considered to be objects. Note that JavaScript arrays are objects. - * - * @param {*} value Reference to check. - * @returns {boolean} True if `value` is an `Object` but not `null`. - */ -function isObject(value){return value != null && typeof value === 'object';} - - -/** - * @ngdoc function - * @name angular.isString - * @module ng - * @kind function - * - * @description - * Determines if a reference is a `String`. - * - * @param {*} value Reference to check. - * @returns {boolean} True if `value` is a `String`. - */ -function isString(value){return typeof value === 'string';} - - -/** - * @ngdoc function - * @name angular.isNumber - * @module ng - * @kind function - * - * @description - * Determines if a reference is a `Number`. - * - * @param {*} value Reference to check. - * @returns {boolean} True if `value` is a `Number`. - */ -function isNumber(value){return typeof value === 'number';} - - -/** - * @ngdoc function - * @name angular.isDate - * @module ng - * @kind function - * - * @description - * Determines if a value is a date. - * - * @param {*} value Reference to check. - * @returns {boolean} True if `value` is a `Date`. - */ -function isDate(value) { - return toString.call(value) === '[object Date]'; -} - - -/** - * @ngdoc function - * @name angular.isArray - * @module ng - * @kind function - * - * @description - * Determines if a reference is an `Array`. - * - * @param {*} value Reference to check. - * @returns {boolean} True if `value` is an `Array`. - */ -var isArray = (function() { - if (!isFunction(Array.isArray)) { - return function(value) { - return toString.call(value) === '[object Array]'; - }; - } - return Array.isArray; -})(); - -/** - * @ngdoc function - * @name angular.isFunction - * @module ng - * @kind function - * - * @description - * Determines if a reference is a `Function`. - * - * @param {*} value Reference to check. - * @returns {boolean} True if `value` is a `Function`. - */ -function isFunction(value){return typeof value === 'function';} - - -/** - * Determines if a value is a regular expression object. - * - * @private - * @param {*} value Reference to check. - * @returns {boolean} True if `value` is a `RegExp`. - */ -function isRegExp(value) { - return toString.call(value) === '[object RegExp]'; -} - - -/** - * Checks if `obj` is a window object. - * - * @private - * @param {*} obj Object to check - * @returns {boolean} True if `obj` is a window obj. - */ -function isWindow(obj) { - return obj && obj.document && obj.location && obj.alert && obj.setInterval; -} - - -function isScope(obj) { - return obj && obj.$evalAsync && obj.$watch; -} - - -function isFile(obj) { - return toString.call(obj) === '[object File]'; -} - - -function isBlob(obj) { - return toString.call(obj) === '[object Blob]'; -} - - -function isBoolean(value) { - return typeof value === 'boolean'; -} - - -function isPromiseLike(obj) { - return obj && isFunction(obj.then); -} - - -var trim = (function() { - // native trim is way faster: http://jsperf.com/angular-trim-test - // but IE doesn't have it... :-( - // TODO: we should move this into IE/ES5 polyfill - if (!String.prototype.trim) { - return function(value) { - return isString(value) ? value.replace(/^\s\s*/, '').replace(/\s\s*$/, '') : value; - }; - } - return function(value) { - return isString(value) ? value.trim() : value; - }; -})(); - - -/** - * @ngdoc function - * @name angular.isElement - * @module ng - * @kind function - * - * @description - * Determines if a reference is a DOM element (or wrapped jQuery element). - * - * @param {*} value Reference to check. - * @returns {boolean} True if `value` is a DOM element (or wrapped jQuery element). - */ -function isElement(node) { - return !!(node && - (node.nodeName // we are a direct element - || (node.prop && node.attr && node.find))); // we have an on and find method part of jQuery API -} - -/** - * @param str 'key1,key2,...' - * @returns {object} in the form of {key1:true, key2:true, ...} - */ -function makeMap(str) { - var obj = {}, items = str.split(","), i; - for ( i = 0; i < items.length; i++ ) - obj[ items[i] ] = true; - return obj; -} - - -if (msie < 9) { - nodeName_ = function(element) { - element = element.nodeName ? element : element[0]; - return (element.scopeName && element.scopeName != 'HTML') - ? uppercase(element.scopeName + ':' + element.nodeName) : element.nodeName; - }; -} else { - nodeName_ = function(element) { - return element.nodeName ? element.nodeName : element[0].nodeName; - }; -} - - -function map(obj, iterator, context) { - var results = []; - forEach(obj, function(value, index, list) { - results.push(iterator.call(context, value, index, list)); - }); - return results; -} - - -/** - * @description - * Determines the number of elements in an array, the number of properties an object has, or - * the length of a string. - * - * Note: This function is used to augment the Object type in Angular expressions. See - * {@link angular.Object} for more information about Angular arrays. - * - * @param {Object|Array|string} obj Object, array, or string to inspect. - * @param {boolean} [ownPropsOnly=false] Count only "own" properties in an object - * @returns {number} The size of `obj` or `0` if `obj` is neither an object nor an array. - */ -function size(obj, ownPropsOnly) { - var count = 0, key; - - if (isArray(obj) || isString(obj)) { - return obj.length; - } else if (isObject(obj)) { - for (key in obj) - if (!ownPropsOnly || obj.hasOwnProperty(key)) - count++; - } - - return count; -} - - -function includes(array, obj) { - return indexOf(array, obj) != -1; -} - -function indexOf(array, obj) { - if (array.indexOf) return array.indexOf(obj); - - for (var i = 0; i < array.length; i++) { - if (obj === array[i]) return i; - } - return -1; -} - -function arrayRemove(array, value) { - var index = indexOf(array, value); - if (index >=0) - array.splice(index, 1); - return value; -} - -function isLeafNode (node) { - if (node) { - switch (node.nodeName) { - case "OPTION": - case "PRE": - case "TITLE": - return true; - } - } - return false; -} - -/** - * @ngdoc function - * @name angular.copy - * @module ng - * @kind function - * - * @description - * Creates a deep copy of `source`, which should be an object or an array. - * - * * If no destination is supplied, a copy of the object or array is created. - * * If a destination is provided, all of its elements (for array) or properties (for objects) - * are deleted and then all elements/properties from the source are copied to it. - * * If `source` is not an object or array (inc. `null` and `undefined`), `source` is returned. - * * If `source` is identical to 'destination' an exception will be thrown. - * - * @param {*} source The source that will be used to make a copy. - * Can be any type, including primitives, `null`, and `undefined`. - * @param {(Object|Array)=} destination Destination into which the source is copied. If - * provided, must be of the same type as `source`. - * @returns {*} The copy or updated `destination`, if `destination` was specified. - * - * @example - - -
-
- Name:
- E-mail:
- Gender: male - female
- - -
-
form = {{user | json}}
-
master = {{master | json}}
-
- - -
-
- */ -function copy(source, destination, stackSource, stackDest) { - if (isWindow(source) || isScope(source)) { - throw ngMinErr('cpws', - "Can't copy! Making copies of Window or Scope instances is not supported."); - } - - if (!destination) { - destination = source; - if (source) { - if (isArray(source)) { - destination = copy(source, [], stackSource, stackDest); - } else if (isDate(source)) { - destination = new Date(source.getTime()); - } else if (isRegExp(source)) { - destination = new RegExp(source.source, source.toString().match(/[^\/]*$/)[0]); - destination.lastIndex = source.lastIndex; - } else if (isObject(source)) { - destination = copy(source, {}, stackSource, stackDest); - } - } - } else { - if (source === destination) throw ngMinErr('cpi', - "Can't copy! Source and destination are identical."); - - stackSource = stackSource || []; - stackDest = stackDest || []; - - if (isObject(source)) { - var index = indexOf(stackSource, source); - if (index !== -1) return stackDest[index]; - - stackSource.push(source); - stackDest.push(destination); - } - - var result; - if (isArray(source)) { - destination.length = 0; - for ( var i = 0; i < source.length; i++) { - result = copy(source[i], null, stackSource, stackDest); - if (isObject(source[i])) { - stackSource.push(source[i]); - stackDest.push(result); - } - destination.push(result); - } - } else { - var h = destination.$$hashKey; - if (isArray(destination)) { - destination.length = 0; - } else { - forEach(destination, function(value, key) { - delete destination[key]; - }); - } - for ( var key in source) { - result = copy(source[key], null, stackSource, stackDest); - if (isObject(source[key])) { - stackSource.push(source[key]); - stackDest.push(result); - } - destination[key] = result; - } - setHashKey(destination,h); - } - - } - return destination; -} - -/** - * Creates a shallow copy of an object, an array or a primitive - */ -function shallowCopy(src, dst) { - if (isArray(src)) { - dst = dst || []; - - for ( var i = 0; i < src.length; i++) { - dst[i] = src[i]; - } - } else if (isObject(src)) { - dst = dst || {}; - - for (var key in src) { - if (hasOwnProperty.call(src, key) && !(key.charAt(0) === '$' && key.charAt(1) === '$')) { - dst[key] = src[key]; - } - } - } - - return dst || src; -} - - -/** - * @ngdoc function - * @name angular.equals - * @module ng - * @kind function - * - * @description - * Determines if two objects or two values are equivalent. Supports value types, regular - * expressions, arrays and objects. - * - * Two objects or values are considered equivalent if at least one of the following is true: - * - * * Both objects or values pass `===` comparison. - * * Both objects or values are of the same type and all of their properties are equal by - * comparing them with `angular.equals`. - * * Both values are NaN. (In JavaScript, NaN == NaN => false. But we consider two NaN as equal) - * * Both values represent the same regular expression (In JavaScript, - * /abc/ == /abc/ => false. But we consider two regular expressions as equal when their textual - * representation matches). - * - * During a property comparison, properties of `function` type and properties with names - * that begin with `$` are ignored. - * - * Scope and DOMWindow objects are being compared only by identify (`===`). - * - * @param {*} o1 Object or value to compare. - * @param {*} o2 Object or value to compare. - * @returns {boolean} True if arguments are equal. - */ -function equals(o1, o2) { - if (o1 === o2) return true; - if (o1 === null || o2 === null) return false; - if (o1 !== o1 && o2 !== o2) return true; // NaN === NaN - var t1 = typeof o1, t2 = typeof o2, length, key, keySet; - if (t1 == t2) { - if (t1 == 'object') { - if (isArray(o1)) { - if (!isArray(o2)) return false; - if ((length = o1.length) == o2.length) { - for(key=0; key 2 ? sliceArgs(arguments, 2) : []; - if (isFunction(fn) && !(fn instanceof RegExp)) { - return curryArgs.length - ? function() { - return arguments.length - ? fn.apply(self, curryArgs.concat(slice.call(arguments, 0))) - : fn.apply(self, curryArgs); - } - : function() { - return arguments.length - ? fn.apply(self, arguments) - : fn.call(self); - }; - } else { - // in IE, native methods are not functions so they cannot be bound (note: they don't need to be) - return fn; - } -} - - -function toJsonReplacer(key, value) { - var val = value; - - if (typeof key === 'string' && key.charAt(0) === '$') { - val = undefined; - } else if (isWindow(value)) { - val = '$WINDOW'; - } else if (value && document === value) { - val = '$DOCUMENT'; - } else if (isScope(value)) { - val = '$SCOPE'; - } - - return val; -} - - -/** - * @ngdoc function - * @name angular.toJson - * @module ng - * @kind function - * - * @description - * Serializes input into a JSON-formatted string. Properties with leading $ characters will be - * stripped since angular uses this notation internally. - * - * @param {Object|Array|Date|string|number} obj Input to be serialized into JSON. - * @param {boolean=} pretty If set to true, the JSON output will contain newlines and whitespace. - * @returns {string|undefined} JSON-ified string representing `obj`. - */ -function toJson(obj, pretty) { - if (typeof obj === 'undefined') return undefined; - return JSON.stringify(obj, toJsonReplacer, pretty ? ' ' : null); -} - - -/** - * @ngdoc function - * @name angular.fromJson - * @module ng - * @kind function - * - * @description - * Deserializes a JSON string. - * - * @param {string} json JSON string to deserialize. - * @returns {Object|Array|string|number} Deserialized thingy. - */ -function fromJson(json) { - return isString(json) - ? JSON.parse(json) - : json; -} - - -function toBoolean(value) { - if (typeof value === 'function') { - value = true; - } else if (value && value.length !== 0) { - var v = lowercase("" + value); - value = !(v == 'f' || v == '0' || v == 'false' || v == 'no' || v == 'n' || v == '[]'); - } else { - value = false; - } - return value; -} - -/** - * @returns {string} Returns the string representation of the element. - */ -function startingTag(element) { - element = jqLite(element).clone(); - try { - // turns out IE does not let you set .html() on elements which - // are not allowed to have children. So we just ignore it. - element.empty(); - } catch(e) {} - // As Per DOM Standards - var TEXT_NODE = 3; - var elemHtml = jqLite('
').append(element).html(); - try { - return element[0].nodeType === TEXT_NODE ? lowercase(elemHtml) : - elemHtml. - match(/^(<[^>]+>)/)[1]. - replace(/^<([\w\-]+)/, function(match, nodeName) { return '<' + lowercase(nodeName); }); - } catch(e) { - return lowercase(elemHtml); - } - -} - - -///////////////////////////////////////////////// - -/** - * Tries to decode the URI component without throwing an exception. - * - * @private - * @param str value potential URI component to check. - * @returns {boolean} True if `value` can be decoded - * with the decodeURIComponent function. - */ -function tryDecodeURIComponent(value) { - try { - return decodeURIComponent(value); - } catch(e) { - // Ignore any invalid uri component - } -} - - -/** - * Parses an escaped url query string into key-value pairs. - * @returns {Object.} - */ -function parseKeyValue(/**string*/keyValue) { - var obj = {}, key_value, key; - forEach((keyValue || "").split('&'), function(keyValue) { - if ( keyValue ) { - key_value = keyValue.replace(/\+/g,'%20').split('='); - key = tryDecodeURIComponent(key_value[0]); - if ( isDefined(key) ) { - var val = isDefined(key_value[1]) ? tryDecodeURIComponent(key_value[1]) : true; - if (!hasOwnProperty.call(obj, key)) { - obj[key] = val; - } else if(isArray(obj[key])) { - obj[key].push(val); - } else { - obj[key] = [obj[key],val]; - } - } - } - }); - return obj; -} - -function toKeyValue(obj) { - var parts = []; - forEach(obj, function(value, key) { - if (isArray(value)) { - forEach(value, function(arrayValue) { - parts.push(encodeUriQuery(key, true) + - (arrayValue === true ? '' : '=' + encodeUriQuery(arrayValue, true))); - }); - } else { - parts.push(encodeUriQuery(key, true) + - (value === true ? '' : '=' + encodeUriQuery(value, true))); - } - }); - return parts.length ? parts.join('&') : ''; -} - - -/** - * We need our custom method because encodeURIComponent is too aggressive and doesn't follow - * http://www.ietf.org/rfc/rfc3986.txt with regards to the character set (pchar) allowed in path - * segments: - * segment = *pchar - * pchar = unreserved / pct-encoded / sub-delims / ":" / "@" - * pct-encoded = "%" HEXDIG HEXDIG - * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" - * sub-delims = "!" / "$" / "&" / "'" / "(" / ")" - * / "*" / "+" / "," / ";" / "=" - */ -function encodeUriSegment(val) { - return encodeUriQuery(val, true). - replace(/%26/gi, '&'). - replace(/%3D/gi, '='). - replace(/%2B/gi, '+'); -} - - -/** - * This method is intended for encoding *key* or *value* parts of query component. We need a custom - * method because encodeURIComponent is too aggressive and encodes stuff that doesn't have to be - * encoded per http://tools.ietf.org/html/rfc3986: - * query = *( pchar / "/" / "?" ) - * pchar = unreserved / pct-encoded / sub-delims / ":" / "@" - * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" - * pct-encoded = "%" HEXDIG HEXDIG - * sub-delims = "!" / "$" / "&" / "'" / "(" / ")" - * / "*" / "+" / "," / ";" / "=" - */ -function encodeUriQuery(val, pctEncodeSpaces) { - return encodeURIComponent(val). - replace(/%40/gi, '@'). - replace(/%3A/gi, ':'). - replace(/%24/g, '$'). - replace(/%2C/gi, ','). - replace(/%20/g, (pctEncodeSpaces ? '%20' : '+')); -} - - -/** - * @ngdoc directive - * @name ngApp - * @module ng - * - * @element ANY - * @param {angular.Module} ngApp an optional application - * {@link angular.module module} name to load. - * - * @description - * - * Use this directive to **auto-bootstrap** an AngularJS application. The `ngApp` directive - * designates the **root element** of the application and is typically placed near the root element - * of the page - e.g. on the `` or `` tags. - * - * Only one AngularJS application can be auto-bootstrapped per HTML document. The first `ngApp` - * found in the document will be used to define the root element to auto-bootstrap as an - * application. To run multiple applications in an HTML document you must manually bootstrap them using - * {@link angular.bootstrap} instead. AngularJS applications cannot be nested within each other. - * - * You can specify an **AngularJS module** to be used as the root module for the application. This - * module will be loaded into the {@link auto.$injector} when the application is bootstrapped and - * should contain the application code needed or have dependencies on other modules that will - * contain the code. See {@link angular.module} for more information. - * - * In the example below if the `ngApp` directive were not placed on the `html` element then the - * document would not be compiled, the `AppController` would not be instantiated and the `{{ a+b }}` - * would not be resolved to `3`. - * - * `ngApp` is the easiest, and most common, way to bootstrap an application. - * - - -
- I can add: {{a}} + {{b}} = {{ a+b }} -
-
- - angular.module('ngAppDemo', []).controller('ngAppDemoController', function($scope) { - $scope.a = 1; - $scope.b = 2; - }); - -
- * - */ -function angularInit(element, bootstrap) { - var elements = [element], - appElement, - module, - names = ['ng:app', 'ng-app', 'x-ng-app', 'data-ng-app'], - NG_APP_CLASS_REGEXP = /\sng[:\-]app(:\s*([\w\d_]+);?)?\s/; - - function append(element) { - element && elements.push(element); - } - - forEach(names, function(name) { - names[name] = true; - append(document.getElementById(name)); - name = name.replace(':', '\\:'); - if (element.querySelectorAll) { - forEach(element.querySelectorAll('.' + name), append); - forEach(element.querySelectorAll('.' + name + '\\:'), append); - forEach(element.querySelectorAll('[' + name + ']'), append); - } - }); - - forEach(elements, function(element) { - if (!appElement) { - var className = ' ' + element.className + ' '; - var match = NG_APP_CLASS_REGEXP.exec(className); - if (match) { - appElement = element; - module = (match[2] || '').replace(/\s+/g, ','); - } else { - forEach(element.attributes, function(attr) { - if (!appElement && names[attr.name]) { - appElement = element; - module = attr.value; - } - }); - } - } - }); - if (appElement) { - bootstrap(appElement, module ? [module] : []); - } -} - -/** - * @ngdoc function - * @name angular.bootstrap - * @module ng - * @description - * Use this function to manually start up angular application. - * - * See: {@link guide/bootstrap Bootstrap} - * - * Note that ngScenario-based end-to-end tests cannot use this function to bootstrap manually. - * They must use {@link ng.directive:ngApp ngApp}. - * - * Angular will detect if it has been loaded into the browser more than once and only allow the - * first loaded script to be bootstrapped and will report a warning to the browser console for - * each of the subsequent scripts. This prevents strange results in applications, where otherwise - * multiple instances of Angular try to work on the DOM. - * - * - * - * - *
- * - * - * - * - * - * - * - *
{{heading}}
{{fill}}
- *
- *
- * - * var app = angular.module('multi-bootstrap', []) - * - * .controller('BrokenTable', function($scope) { - * $scope.headings = ['One', 'Two', 'Three']; - * $scope.fillings = [[1, 2, 3], ['A', 'B', 'C'], [7, 8, 9]]; - * }); - * - * - * it('should only insert one table cell for each item in $scope.fillings', function() { - * expect(element.all(by.css('td')).count()) - * .toBe(9); - * }); - * - *
- * - * @param {DOMElement} element DOM element which is the root of angular application. - * @param {Array=} modules an array of modules to load into the application. - * Each item in the array should be the name of a predefined module or a (DI annotated) - * function that will be invoked by the injector as a run block. - * See: {@link angular.module modules} - * @returns {auto.$injector} Returns the newly created injector for this app. - */ -function bootstrap(element, modules) { - var doBootstrap = function() { - element = jqLite(element); - - if (element.injector()) { - var tag = (element[0] === document) ? 'document' : startingTag(element); - //Encode angle brackets to prevent input from being sanitized to empty string #8683 - throw ngMinErr( - 'btstrpd', - "App Already Bootstrapped with this Element '{0}'", - tag.replace(//,'>')); - } - - modules = modules || []; - modules.unshift(['$provide', function($provide) { - $provide.value('$rootElement', element); - }]); - modules.unshift('ng'); - var injector = createInjector(modules); - injector.invoke(['$rootScope', '$rootElement', '$compile', '$injector', '$animate', - function(scope, element, compile, injector, animate) { - scope.$apply(function() { - element.data('$injector', injector); - compile(element)(scope); - }); - }] - ); - return injector; - }; - - var NG_DEFER_BOOTSTRAP = /^NG_DEFER_BOOTSTRAP!/; - - if (window && !NG_DEFER_BOOTSTRAP.test(window.name)) { - return doBootstrap(); - } - - window.name = window.name.replace(NG_DEFER_BOOTSTRAP, ''); - angular.resumeBootstrap = function(extraModules) { - forEach(extraModules, function(module) { - modules.push(module); - }); - doBootstrap(); - }; -} - -var SNAKE_CASE_REGEXP = /[A-Z]/g; -function snake_case(name, separator) { - separator = separator || '_'; - return name.replace(SNAKE_CASE_REGEXP, function(letter, pos) { - return (pos ? separator : '') + letter.toLowerCase(); - }); -} - -function bindJQuery() { - // bind to jQuery if present; - jQuery = window.jQuery; - // Use jQuery if it exists with proper functionality, otherwise default to us. - // Angular 1.2+ requires jQuery 1.7.1+ for on()/off() support. - if (jQuery && jQuery.fn.on) { - jqLite = jQuery; - extend(jQuery.fn, { - scope: JQLitePrototype.scope, - isolateScope: JQLitePrototype.isolateScope, - controller: JQLitePrototype.controller, - injector: JQLitePrototype.injector, - inheritedData: JQLitePrototype.inheritedData - }); - // Method signature: - // jqLitePatchJQueryRemove(name, dispatchThis, filterElems, getterIfNoArguments) - jqLitePatchJQueryRemove('remove', true, true, false); - jqLitePatchJQueryRemove('empty', false, false, false); - jqLitePatchJQueryRemove('html', false, false, true); - } else { - jqLite = JQLite; - } - angular.element = jqLite; -} - -/** - * throw error if the argument is falsy. - */ -function assertArg(arg, name, reason) { - if (!arg) { - throw ngMinErr('areq', "Argument '{0}' is {1}", (name || '?'), (reason || "required")); - } - return arg; -} - -function assertArgFn(arg, name, acceptArrayAnnotation) { - if (acceptArrayAnnotation && isArray(arg)) { - arg = arg[arg.length - 1]; - } - - assertArg(isFunction(arg), name, 'not a function, got ' + - (arg && typeof arg === 'object' ? arg.constructor.name || 'Object' : typeof arg)); - return arg; -} - -/** - * throw error if the name given is hasOwnProperty - * @param {String} name the name to test - * @param {String} context the context in which the name is used, such as module or directive - */ -function assertNotHasOwnProperty(name, context) { - if (name === 'hasOwnProperty') { - throw ngMinErr('badname', "hasOwnProperty is not a valid {0} name", context); - } -} - -/** - * Return the value accessible from the object by path. Any undefined traversals are ignored - * @param {Object} obj starting object - * @param {String} path path to traverse - * @param {boolean} [bindFnToScope=true] - * @returns {Object} value as accessible by path - */ -//TODO(misko): this function needs to be removed -function getter(obj, path, bindFnToScope) { - if (!path) return obj; - var keys = path.split('.'); - var key; - var lastInstance = obj; - var len = keys.length; - - for (var i = 0; i < len; i++) { - key = keys[i]; - if (obj) { - obj = (lastInstance = obj)[key]; - } - } - if (!bindFnToScope && isFunction(obj)) { - return bind(lastInstance, obj); - } - return obj; -} - -/** - * Return the DOM siblings between the first and last node in the given array. - * @param {Array} array like object - * @returns {DOMElement} object containing the elements - */ -function getBlockElements(nodes) { - var startNode = nodes[0], - endNode = nodes[nodes.length - 1]; - if (startNode === endNode) { - return jqLite(startNode); - } - - var element = startNode; - var elements = [element]; - - do { - element = element.nextSibling; - if (!element) break; - elements.push(element); - } while (element !== endNode); - - return jqLite(elements); -} - -/** - * @ngdoc type - * @name angular.Module - * @module ng - * @description - * - * Interface for configuring angular {@link angular.module modules}. - */ - -function setupModuleLoader(window) { - - var $injectorMinErr = minErr('$injector'); - var ngMinErr = minErr('ng'); - - function ensure(obj, name, factory) { - return obj[name] || (obj[name] = factory()); - } - - var angular = ensure(window, 'angular', Object); - - // We need to expose `angular.$$minErr` to modules such as `ngResource` that reference it during bootstrap - angular.$$minErr = angular.$$minErr || minErr; - - return ensure(angular, 'module', function() { - /** @type {Object.} */ - var modules = {}; - - /** - * @ngdoc function - * @name angular.module - * @module ng - * @description - * - * The `angular.module` is a global place for creating, registering and retrieving Angular - * modules. - * All modules (angular core or 3rd party) that should be available to an application must be - * registered using this mechanism. - * - * When passed two or more arguments, a new module is created. If passed only one argument, an - * existing module (the name passed as the first argument to `module`) is retrieved. - * - * - * # Module - * - * A module is a collection of services, directives, controllers, filters, and configuration information. - * `angular.module` is used to configure the {@link auto.$injector $injector}. - * - * ```js - * // Create a new module - * var myModule = angular.module('myModule', []); - * - * // register a new service - * myModule.value('appName', 'MyCoolApp'); - * - * // configure existing services inside initialization blocks. - * myModule.config(['$locationProvider', function($locationProvider) { - * // Configure existing providers - * $locationProvider.hashPrefix('!'); - * }]); - * ``` - * - * Then you can create an injector and load your modules like this: - * - * ```js - * var injector = angular.injector(['ng', 'myModule']) - * ``` - * - * However it's more likely that you'll just use - * {@link ng.directive:ngApp ngApp} or - * {@link angular.bootstrap} to simplify this process for you. - * - * @param {!string} name The name of the module to create or retrieve. - * @param {!Array.=} requires If specified then new module is being created. If - * unspecified then the module is being retrieved for further configuration. - * @param {Function=} configFn Optional configuration function for the module. Same as - * {@link angular.Module#config Module#config()}. - * @returns {module} new module with the {@link angular.Module} api. - */ - return function module(name, requires, configFn) { - var assertNotHasOwnProperty = function(name, context) { - if (name === 'hasOwnProperty') { - throw ngMinErr('badname', 'hasOwnProperty is not a valid {0} name', context); - } - }; - - assertNotHasOwnProperty(name, 'module'); - if (requires && modules.hasOwnProperty(name)) { - modules[name] = null; - } - return ensure(modules, name, function() { - if (!requires) { - throw $injectorMinErr('nomod', "Module '{0}' is not available! You either misspelled " + - "the module name or forgot to load it. If registering a module ensure that you " + - "specify the dependencies as the second argument.", name); - } - - /** @type {!Array.>} */ - var invokeQueue = []; - - /** @type {!Array.} */ - var runBlocks = []; - - var config = invokeLater('$injector', 'invoke'); - - /** @type {angular.Module} */ - var moduleInstance = { - // Private state - _invokeQueue: invokeQueue, - _runBlocks: runBlocks, - - /** - * @ngdoc property - * @name angular.Module#requires - * @module ng - * - * @description - * Holds the list of modules which the injector will load before the current module is - * loaded. - */ - requires: requires, - - /** - * @ngdoc property - * @name angular.Module#name - * @module ng - * - * @description - * Name of the module. - */ - name: name, - - - /** - * @ngdoc method - * @name angular.Module#provider - * @module ng - * @param {string} name service name - * @param {Function} providerType Construction function for creating new instance of the - * service. - * @description - * See {@link auto.$provide#provider $provide.provider()}. - */ - provider: invokeLater('$provide', 'provider'), - - /** - * @ngdoc method - * @name angular.Module#factory - * @module ng - * @param {string} name service name - * @param {Function} providerFunction Function for creating new instance of the service. - * @description - * See {@link auto.$provide#factory $provide.factory()}. - */ - factory: invokeLater('$provide', 'factory'), - - /** - * @ngdoc method - * @name angular.Module#service - * @module ng - * @param {string} name service name - * @param {Function} constructor A constructor function that will be instantiated. - * @description - * See {@link auto.$provide#service $provide.service()}. - */ - service: invokeLater('$provide', 'service'), - - /** - * @ngdoc method - * @name angular.Module#value - * @module ng - * @param {string} name service name - * @param {*} object Service instance object. - * @description - * See {@link auto.$provide#value $provide.value()}. - */ - value: invokeLater('$provide', 'value'), - - /** - * @ngdoc method - * @name angular.Module#constant - * @module ng - * @param {string} name constant name - * @param {*} object Constant value. - * @description - * Because the constant are fixed, they get applied before other provide methods. - * See {@link auto.$provide#constant $provide.constant()}. - */ - constant: invokeLater('$provide', 'constant', 'unshift'), - - /** - * @ngdoc method - * @name angular.Module#animation - * @module ng - * @param {string} name animation name - * @param {Function} animationFactory Factory function for creating new instance of an - * animation. - * @description - * - * **NOTE**: animations take effect only if the **ngAnimate** module is loaded. - * - * - * Defines an animation hook that can be later used with - * {@link ngAnimate.$animate $animate} service and directives that use this service. - * - * ```js - * module.animation('.animation-name', function($inject1, $inject2) { - * return { - * eventName : function(element, done) { - * //code to run the animation - * //once complete, then run done() - * return function cancellationFunction(element) { - * //code to cancel the animation - * } - * } - * } - * }) - * ``` - * - * See {@link ngAnimate.$animateProvider#register $animateProvider.register()} and - * {@link ngAnimate ngAnimate module} for more information. - */ - animation: invokeLater('$animateProvider', 'register'), - - /** - * @ngdoc method - * @name angular.Module#filter - * @module ng - * @param {string} name Filter name. - * @param {Function} filterFactory Factory function for creating new instance of filter. - * @description - * See {@link ng.$filterProvider#register $filterProvider.register()}. - */ - filter: invokeLater('$filterProvider', 'register'), - - /** - * @ngdoc method - * @name angular.Module#controller - * @module ng - * @param {string|Object} name Controller name, or an object map of controllers where the - * keys are the names and the values are the constructors. - * @param {Function} constructor Controller constructor function. - * @description - * See {@link ng.$controllerProvider#register $controllerProvider.register()}. - */ - controller: invokeLater('$controllerProvider', 'register'), - - /** - * @ngdoc method - * @name angular.Module#directive - * @module ng - * @param {string|Object} name Directive name, or an object map of directives where the - * keys are the names and the values are the factories. - * @param {Function} directiveFactory Factory function for creating new instance of - * directives. - * @description - * See {@link ng.$compileProvider#directive $compileProvider.directive()}. - */ - directive: invokeLater('$compileProvider', 'directive'), - - /** - * @ngdoc method - * @name angular.Module#config - * @module ng - * @param {Function} configFn Execute this function on module load. Useful for service - * configuration. - * @description - * Use this method to register work which needs to be performed on module loading. - * For more about how to configure services, see - * {@link providers#providers_provider-recipe Provider Recipe}. - */ - config: config, - - /** - * @ngdoc method - * @name angular.Module#run - * @module ng - * @param {Function} initializationFn Execute this function after injector creation. - * Useful for application initialization. - * @description - * Use this method to register work which should be performed when the injector is done - * loading all modules. - */ - run: function(block) { - runBlocks.push(block); - return this; - } - }; - - if (configFn) { - config(configFn); - } - - return moduleInstance; - - /** - * @param {string} provider - * @param {string} method - * @param {String=} insertMethod - * @returns {angular.Module} - */ - function invokeLater(provider, method, insertMethod) { - return function() { - invokeQueue[insertMethod || 'push']([provider, method, arguments]); - return moduleInstance; - }; - } - }); - }; - }); - -} - -/* global angularModule: true, - version: true, - - $LocaleProvider, - $CompileProvider, - - htmlAnchorDirective, - inputDirective, - inputDirective, - formDirective, - scriptDirective, - selectDirective, - styleDirective, - optionDirective, - ngBindDirective, - ngBindHtmlDirective, - ngBindTemplateDirective, - ngClassDirective, - ngClassEvenDirective, - ngClassOddDirective, - ngCspDirective, - ngCloakDirective, - ngControllerDirective, - ngFormDirective, - ngHideDirective, - ngIfDirective, - ngIncludeDirective, - ngIncludeFillContentDirective, - ngInitDirective, - ngNonBindableDirective, - ngPluralizeDirective, - ngRepeatDirective, - ngShowDirective, - ngStyleDirective, - ngSwitchDirective, - ngSwitchWhenDirective, - ngSwitchDefaultDirective, - ngOptionsDirective, - ngTranscludeDirective, - ngModelDirective, - ngListDirective, - ngChangeDirective, - requiredDirective, - requiredDirective, - ngValueDirective, - ngAttributeAliasDirectives, - ngEventDirectives, - - $AnchorScrollProvider, - $AnimateProvider, - $BrowserProvider, - $CacheFactoryProvider, - $ControllerProvider, - $DocumentProvider, - $ExceptionHandlerProvider, - $FilterProvider, - $InterpolateProvider, - $IntervalProvider, - $HttpProvider, - $HttpBackendProvider, - $LocationProvider, - $LogProvider, - $ParseProvider, - $RootScopeProvider, - $QProvider, - $$SanitizeUriProvider, - $SceProvider, - $SceDelegateProvider, - $SnifferProvider, - $TemplateCacheProvider, - $TimeoutProvider, - $$RAFProvider, - $$AsyncCallbackProvider, - $WindowProvider -*/ - - -/** - * @ngdoc object - * @name angular.version - * @module ng - * @description - * An object that contains information about the current AngularJS version. This object has the - * following properties: - * - * - `full` – `{string}` – Full version string, such as "0.9.18". - * - `major` – `{number}` – Major version number, such as "0". - * - `minor` – `{number}` – Minor version number, such as "9". - * - `dot` – `{number}` – Dot version number, such as "18". - * - `codeName` – `{string}` – Code name of the release, such as "jiggling-armfat". - */ -var version = { - full: '1.2.25', // all of these placeholder strings will be replaced by grunt's - major: 1, // package task - minor: 2, - dot: 25, - codeName: 'hypnotic-gesticulation' -}; - - -function publishExternalAPI(angular){ - extend(angular, { - 'bootstrap': bootstrap, - 'copy': copy, - 'extend': extend, - 'equals': equals, - 'element': jqLite, - 'forEach': forEach, - 'injector': createInjector, - 'noop': noop, - 'bind': bind, - 'toJson': toJson, - 'fromJson': fromJson, - 'identity': identity, - 'isUndefined': isUndefined, - 'isDefined': isDefined, - 'isString': isString, - 'isFunction': isFunction, - 'isObject': isObject, - 'isNumber': isNumber, - 'isElement': isElement, - 'isArray': isArray, - 'version': version, - 'isDate': isDate, - 'lowercase': lowercase, - 'uppercase': uppercase, - 'callbacks': {counter: 0}, - '$$minErr': minErr, - '$$csp': csp - }); - - angularModule = setupModuleLoader(window); - try { - angularModule('ngLocale'); - } catch (e) { - angularModule('ngLocale', []).provider('$locale', $LocaleProvider); - } - - angularModule('ng', ['ngLocale'], ['$provide', - function ngModule($provide) { - // $$sanitizeUriProvider needs to be before $compileProvider as it is used by it. - $provide.provider({ - $$sanitizeUri: $$SanitizeUriProvider - }); - $provide.provider('$compile', $CompileProvider). - directive({ - a: htmlAnchorDirective, - input: inputDirective, - textarea: inputDirective, - form: formDirective, - script: scriptDirective, - select: selectDirective, - style: styleDirective, - option: optionDirective, - ngBind: ngBindDirective, - ngBindHtml: ngBindHtmlDirective, - ngBindTemplate: ngBindTemplateDirective, - ngClass: ngClassDirective, - ngClassEven: ngClassEvenDirective, - ngClassOdd: ngClassOddDirective, - ngCloak: ngCloakDirective, - ngController: ngControllerDirective, - ngForm: ngFormDirective, - ngHide: ngHideDirective, - ngIf: ngIfDirective, - ngInclude: ngIncludeDirective, - ngInit: ngInitDirective, - ngNonBindable: ngNonBindableDirective, - ngPluralize: ngPluralizeDirective, - ngRepeat: ngRepeatDirective, - ngShow: ngShowDirective, - ngStyle: ngStyleDirective, - ngSwitch: ngSwitchDirective, - ngSwitchWhen: ngSwitchWhenDirective, - ngSwitchDefault: ngSwitchDefaultDirective, - ngOptions: ngOptionsDirective, - ngTransclude: ngTranscludeDirective, - ngModel: ngModelDirective, - ngList: ngListDirective, - ngChange: ngChangeDirective, - required: requiredDirective, - ngRequired: requiredDirective, - ngValue: ngValueDirective - }). - directive({ - ngInclude: ngIncludeFillContentDirective - }). - directive(ngAttributeAliasDirectives). - directive(ngEventDirectives); - $provide.provider({ - $anchorScroll: $AnchorScrollProvider, - $animate: $AnimateProvider, - $browser: $BrowserProvider, - $cacheFactory: $CacheFactoryProvider, - $controller: $ControllerProvider, - $document: $DocumentProvider, - $exceptionHandler: $ExceptionHandlerProvider, - $filter: $FilterProvider, - $interpolate: $InterpolateProvider, - $interval: $IntervalProvider, - $http: $HttpProvider, - $httpBackend: $HttpBackendProvider, - $location: $LocationProvider, - $log: $LogProvider, - $parse: $ParseProvider, - $rootScope: $RootScopeProvider, - $q: $QProvider, - $sce: $SceProvider, - $sceDelegate: $SceDelegateProvider, - $sniffer: $SnifferProvider, - $templateCache: $TemplateCacheProvider, - $timeout: $TimeoutProvider, - $window: $WindowProvider, - $$rAF: $$RAFProvider, - $$asyncCallback : $$AsyncCallbackProvider - }); - } - ]); -} - -/* global JQLitePrototype: true, - addEventListenerFn: true, - removeEventListenerFn: true, - BOOLEAN_ATTR: true -*/ - -////////////////////////////////// -//JQLite -////////////////////////////////// - -/** - * @ngdoc function - * @name angular.element - * @module ng - * @kind function - * - * @description - * Wraps a raw DOM element or HTML string as a [jQuery](http://jquery.com) element. - * - * If jQuery is available, `angular.element` is an alias for the - * [jQuery](http://api.jquery.com/jQuery/) function. If jQuery is not available, `angular.element` - * delegates to Angular's built-in subset of jQuery, called "jQuery lite" or "jqLite." - * - *
jqLite is a tiny, API-compatible subset of jQuery that allows - * Angular to manipulate the DOM in a cross-browser compatible way. **jqLite** implements only the most - * commonly needed functionality with the goal of having a very small footprint.
- * - * To use jQuery, simply load it before `DOMContentLoaded` event fired. - * - *
**Note:** all element references in Angular are always wrapped with jQuery or - * jqLite; they are never raw DOM references.
- * - * ## Angular's jqLite - * jqLite provides only the following jQuery methods: - * - * - [`addClass()`](http://api.jquery.com/addClass/) - * - [`after()`](http://api.jquery.com/after/) - * - [`append()`](http://api.jquery.com/append/) - * - [`attr()`](http://api.jquery.com/attr/) - * - [`bind()`](http://api.jquery.com/bind/) - Does not support namespaces, selectors or eventData - * - [`children()`](http://api.jquery.com/children/) - Does not support selectors - * - [`clone()`](http://api.jquery.com/clone/) - * - [`contents()`](http://api.jquery.com/contents/) - * - [`css()`](http://api.jquery.com/css/) - * - [`data()`](http://api.jquery.com/data/) - * - [`empty()`](http://api.jquery.com/empty/) - * - [`eq()`](http://api.jquery.com/eq/) - * - [`find()`](http://api.jquery.com/find/) - Limited to lookups by tag name - * - [`hasClass()`](http://api.jquery.com/hasClass/) - * - [`html()`](http://api.jquery.com/html/) - * - [`next()`](http://api.jquery.com/next/) - Does not support selectors - * - [`on()`](http://api.jquery.com/on/) - Does not support namespaces, selectors or eventData - * - [`off()`](http://api.jquery.com/off/) - Does not support namespaces or selectors - * - [`one()`](http://api.jquery.com/one/) - Does not support namespaces or selectors - * - [`parent()`](http://api.jquery.com/parent/) - Does not support selectors - * - [`prepend()`](http://api.jquery.com/prepend/) - * - [`prop()`](http://api.jquery.com/prop/) - * - [`ready()`](http://api.jquery.com/ready/) - * - [`remove()`](http://api.jquery.com/remove/) - * - [`removeAttr()`](http://api.jquery.com/removeAttr/) - * - [`removeClass()`](http://api.jquery.com/removeClass/) - * - [`removeData()`](http://api.jquery.com/removeData/) - * - [`replaceWith()`](http://api.jquery.com/replaceWith/) - * - [`text()`](http://api.jquery.com/text/) - * - [`toggleClass()`](http://api.jquery.com/toggleClass/) - * - [`triggerHandler()`](http://api.jquery.com/triggerHandler/) - Passes a dummy event object to handlers. - * - [`unbind()`](http://api.jquery.com/unbind/) - Does not support namespaces - * - [`val()`](http://api.jquery.com/val/) - * - [`wrap()`](http://api.jquery.com/wrap/) - * - * ## jQuery/jqLite Extras - * Angular also provides the following additional methods and events to both jQuery and jqLite: - * - * ### Events - * - `$destroy` - AngularJS intercepts all jqLite/jQuery's DOM destruction apis and fires this event - * on all DOM nodes being removed. This can be used to clean up any 3rd party bindings to the DOM - * element before it is removed. - * - * ### Methods - * - `controller(name)` - retrieves the controller of the current element or its parent. By default - * retrieves controller associated with the `ngController` directive. If `name` is provided as - * camelCase directive name, then the controller for this directive will be retrieved (e.g. - * `'ngModel'`). - * - `injector()` - retrieves the injector of the current element or its parent. - * - `scope()` - retrieves the {@link ng.$rootScope.Scope scope} of the current - * element or its parent. - * - `isolateScope()` - retrieves an isolate {@link ng.$rootScope.Scope scope} if one is attached directly to the - * current element. This getter should be used only on elements that contain a directive which starts a new isolate - * scope. Calling `scope()` on this element always returns the original non-isolate scope. - * - `inheritedData()` - same as `data()`, but walks up the DOM until a value is found or the top - * parent element is reached. - * - * @param {string|DOMElement} element HTML string or DOMElement to be wrapped into jQuery. - * @returns {Object} jQuery object. - */ - -JQLite.expando = 'ng339'; - -var jqCache = JQLite.cache = {}, - jqId = 1, - addEventListenerFn = (window.document.addEventListener - ? function(element, type, fn) {element.addEventListener(type, fn, false);} - : function(element, type, fn) {element.attachEvent('on' + type, fn);}), - removeEventListenerFn = (window.document.removeEventListener - ? function(element, type, fn) {element.removeEventListener(type, fn, false); } - : function(element, type, fn) {element.detachEvent('on' + type, fn); }); - -/* - * !!! This is an undocumented "private" function !!! - */ -var jqData = JQLite._data = function(node) { - //jQuery always returns an object on cache miss - return this.cache[node[this.expando]] || {}; -}; - -function jqNextId() { return ++jqId; } - - -var SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g; -var MOZ_HACK_REGEXP = /^moz([A-Z])/; -var jqLiteMinErr = minErr('jqLite'); - -/** - * Converts snake_case to camelCase. - * Also there is special case for Moz prefix starting with upper case letter. - * @param name Name to normalize - */ -function camelCase(name) { - return name. - replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) { - return offset ? letter.toUpperCase() : letter; - }). - replace(MOZ_HACK_REGEXP, 'Moz$1'); -} - -///////////////////////////////////////////// -// jQuery mutation patch -// -// In conjunction with bindJQuery intercepts all jQuery's DOM destruction apis and fires a -// $destroy event on all DOM nodes being removed. -// -///////////////////////////////////////////// - -function jqLitePatchJQueryRemove(name, dispatchThis, filterElems, getterIfNoArguments) { - var originalJqFn = jQuery.fn[name]; - originalJqFn = originalJqFn.$original || originalJqFn; - removePatch.$original = originalJqFn; - jQuery.fn[name] = removePatch; - - function removePatch(param) { - // jshint -W040 - var list = filterElems && param ? [this.filter(param)] : [this], - fireEvent = dispatchThis, - set, setIndex, setLength, - element, childIndex, childLength, children; - - if (!getterIfNoArguments || param != null) { - while(list.length) { - set = list.shift(); - for(setIndex = 0, setLength = set.length; setIndex < setLength; setIndex++) { - element = jqLite(set[setIndex]); - if (fireEvent) { - element.triggerHandler('$destroy'); - } else { - fireEvent = !fireEvent; - } - for(childIndex = 0, childLength = (children = element.children()).length; - childIndex < childLength; - childIndex++) { - list.push(jQuery(children[childIndex])); - } - } - } - } - return originalJqFn.apply(this, arguments); - } -} - -var SINGLE_TAG_REGEXP = /^<(\w+)\s*\/?>(?:<\/\1>|)$/; -var HTML_REGEXP = /<|&#?\w+;/; -var TAG_NAME_REGEXP = /<([\w:]+)/; -var XHTML_TAG_REGEXP = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi; - -var wrapMap = { - 'option': [1, ''], - - 'thead': [1, '', '
'], - 'col': [2, '', '
'], - 'tr': [2, '', '
'], - 'td': [3, '', '
'], - '_default': [0, "", ""] -}; - -wrapMap.optgroup = wrapMap.option; -wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; -wrapMap.th = wrapMap.td; - -function jqLiteIsTextNode(html) { - return !HTML_REGEXP.test(html); -} - -function jqLiteBuildFragment(html, context) { - var elem, tmp, tag, wrap, - fragment = context.createDocumentFragment(), - nodes = [], i, j, jj; - - if (jqLiteIsTextNode(html)) { - // Convert non-html into a text node - nodes.push(context.createTextNode(html)); - } else { - tmp = fragment.appendChild(context.createElement('div')); - // Convert html into DOM nodes - tag = (TAG_NAME_REGEXP.exec(html) || ["", ""])[1].toLowerCase(); - wrap = wrapMap[tag] || wrapMap._default; - tmp.innerHTML = '
 
' + - wrap[1] + html.replace(XHTML_TAG_REGEXP, "<$1>") + wrap[2]; - tmp.removeChild(tmp.firstChild); - - // Descend through wrappers to the right content - i = wrap[0]; - while (i--) { - tmp = tmp.lastChild; - } - - for (j=0, jj=tmp.childNodes.length; j -1); -} - -function jqLiteRemoveClass(element, cssClasses) { - if (cssClasses && element.setAttribute) { - forEach(cssClasses.split(' '), function(cssClass) { - element.setAttribute('class', trim( - (" " + (element.getAttribute('class') || '') + " ") - .replace(/[\n\t]/g, " ") - .replace(" " + trim(cssClass) + " ", " ")) - ); - }); - } -} - -function jqLiteAddClass(element, cssClasses) { - if (cssClasses && element.setAttribute) { - var existingClasses = (' ' + (element.getAttribute('class') || '') + ' ') - .replace(/[\n\t]/g, " "); - - forEach(cssClasses.split(' '), function(cssClass) { - cssClass = trim(cssClass); - if (existingClasses.indexOf(' ' + cssClass + ' ') === -1) { - existingClasses += cssClass + ' '; - } - }); - - element.setAttribute('class', trim(existingClasses)); - } -} - -function jqLiteAddNodes(root, elements) { - if (elements) { - elements = (!elements.nodeName && isDefined(elements.length) && !isWindow(elements)) - ? elements - : [ elements ]; - for(var i=0; i < elements.length; i++) { - root.push(elements[i]); - } - } -} - -function jqLiteController(element, name) { - return jqLiteInheritedData(element, '$' + (name || 'ngController' ) + 'Controller'); -} - -function jqLiteInheritedData(element, name, value) { - // if element is the document object work with the html element instead - // this makes $(document).scope() possible - if(element.nodeType == 9) { - element = element.documentElement; - } - var names = isArray(name) ? name : [name]; - - while (element) { - for (var i = 0, ii = names.length; i < ii; i++) { - if ((value = jqLite.data(element, names[i])) !== undefined) return value; - } - - // If dealing with a document fragment node with a host element, and no parent, use the host - // element as the parent. This enables directives within a Shadow DOM or polyfilled Shadow DOM - // to lookup parent controllers. - element = element.parentNode || (element.nodeType === 11 && element.host); - } -} - -function jqLiteEmpty(element) { - for (var i = 0, childNodes = element.childNodes; i < childNodes.length; i++) { - jqLiteDealoc(childNodes[i]); - } - while (element.firstChild) { - element.removeChild(element.firstChild); - } -} - -////////////////////////////////////////// -// Functions which are declared directly. -////////////////////////////////////////// -var JQLitePrototype = JQLite.prototype = { - ready: function(fn) { - var fired = false; - - function trigger() { - if (fired) return; - fired = true; - fn(); - } - - // check if document already is loaded - if (document.readyState === 'complete'){ - setTimeout(trigger); - } else { - this.on('DOMContentLoaded', trigger); // works for modern browsers and IE9 - // we can not use jqLite since we are not done loading and jQuery could be loaded later. - // jshint -W064 - JQLite(window).on('load', trigger); // fallback to window.onload for others - // jshint +W064 - } - }, - toString: function() { - var value = []; - forEach(this, function(e){ value.push('' + e);}); - return '[' + value.join(', ') + ']'; - }, - - eq: function(index) { - return (index >= 0) ? jqLite(this[index]) : jqLite(this[this.length + index]); - }, - - length: 0, - push: push, - sort: [].sort, - splice: [].splice -}; - -////////////////////////////////////////// -// Functions iterating getter/setters. -// these functions return self on setter and -// value on get. -////////////////////////////////////////// -var BOOLEAN_ATTR = {}; -forEach('multiple,selected,checked,disabled,readOnly,required,open'.split(','), function(value) { - BOOLEAN_ATTR[lowercase(value)] = value; -}); -var BOOLEAN_ELEMENTS = {}; -forEach('input,select,option,textarea,button,form,details'.split(','), function(value) { - BOOLEAN_ELEMENTS[uppercase(value)] = true; -}); - -function getBooleanAttrName(element, name) { - // check dom last since we will most likely fail on name - var booleanAttr = BOOLEAN_ATTR[name.toLowerCase()]; - - // booleanAttr is here twice to minimize DOM access - return booleanAttr && BOOLEAN_ELEMENTS[element.nodeName] && booleanAttr; -} - -forEach({ - data: jqLiteData, - removeData: jqLiteRemoveData -}, function(fn, name) { - JQLite[name] = fn; -}); - -forEach({ - data: jqLiteData, - inheritedData: jqLiteInheritedData, - - scope: function(element) { - // Can't use jqLiteData here directly so we stay compatible with jQuery! - return jqLite.data(element, '$scope') || jqLiteInheritedData(element.parentNode || element, ['$isolateScope', '$scope']); - }, - - isolateScope: function(element) { - // Can't use jqLiteData here directly so we stay compatible with jQuery! - return jqLite.data(element, '$isolateScope') || jqLite.data(element, '$isolateScopeNoTemplate'); - }, - - controller: jqLiteController, - - injector: function(element) { - return jqLiteInheritedData(element, '$injector'); - }, - - removeAttr: function(element,name) { - element.removeAttribute(name); - }, - - hasClass: jqLiteHasClass, - - css: function(element, name, value) { - name = camelCase(name); - - if (isDefined(value)) { - element.style[name] = value; - } else { - var val; - - if (msie <= 8) { - // this is some IE specific weirdness that jQuery 1.6.4 does not sure why - val = element.currentStyle && element.currentStyle[name]; - if (val === '') val = 'auto'; - } - - val = val || element.style[name]; - - if (msie <= 8) { - // jquery weirdness :-/ - val = (val === '') ? undefined : val; - } - - return val; - } - }, - - attr: function(element, name, value){ - var lowercasedName = lowercase(name); - if (BOOLEAN_ATTR[lowercasedName]) { - if (isDefined(value)) { - if (!!value) { - element[name] = true; - element.setAttribute(name, lowercasedName); - } else { - element[name] = false; - element.removeAttribute(lowercasedName); - } - } else { - return (element[name] || - (element.attributes.getNamedItem(name)|| noop).specified) - ? lowercasedName - : undefined; - } - } else if (isDefined(value)) { - element.setAttribute(name, value); - } else if (element.getAttribute) { - // the extra argument "2" is to get the right thing for a.href in IE, see jQuery code - // some elements (e.g. Document) don't have get attribute, so return undefined - var ret = element.getAttribute(name, 2); - // normalize non-existing attributes to undefined (as jQuery) - return ret === null ? undefined : ret; - } - }, - - prop: function(element, name, value) { - if (isDefined(value)) { - element[name] = value; - } else { - return element[name]; - } - }, - - text: (function() { - var NODE_TYPE_TEXT_PROPERTY = []; - if (msie < 9) { - NODE_TYPE_TEXT_PROPERTY[1] = 'innerText'; /** Element **/ - NODE_TYPE_TEXT_PROPERTY[3] = 'nodeValue'; /** Text **/ - } else { - NODE_TYPE_TEXT_PROPERTY[1] = /** Element **/ - NODE_TYPE_TEXT_PROPERTY[3] = 'textContent'; /** Text **/ - } - getText.$dv = ''; - return getText; - - function getText(element, value) { - var textProp = NODE_TYPE_TEXT_PROPERTY[element.nodeType]; - if (isUndefined(value)) { - return textProp ? element[textProp] : ''; - } - element[textProp] = value; - } - })(), - - val: function(element, value) { - if (isUndefined(value)) { - if (nodeName_(element) === 'SELECT' && element.multiple) { - var result = []; - forEach(element.options, function (option) { - if (option.selected) { - result.push(option.value || option.text); - } - }); - return result.length === 0 ? null : result; - } - return element.value; - } - element.value = value; - }, - - html: function(element, value) { - if (isUndefined(value)) { - return element.innerHTML; - } - for (var i = 0, childNodes = element.childNodes; i < childNodes.length; i++) { - jqLiteDealoc(childNodes[i]); - } - element.innerHTML = value; - }, - - empty: jqLiteEmpty -}, function(fn, name){ - /** - * Properties: writes return selection, reads return first value - */ - JQLite.prototype[name] = function(arg1, arg2) { - var i, key; - var nodeCount = this.length; - - // jqLiteHasClass has only two arguments, but is a getter-only fn, so we need to special-case it - // in a way that survives minification. - // jqLiteEmpty takes no arguments but is a setter. - if (fn !== jqLiteEmpty && - (((fn.length == 2 && (fn !== jqLiteHasClass && fn !== jqLiteController)) ? arg1 : arg2) === undefined)) { - if (isObject(arg1)) { - - // we are a write, but the object properties are the key/values - for (i = 0; i < nodeCount; i++) { - if (fn === jqLiteData) { - // data() takes the whole object in jQuery - fn(this[i], arg1); - } else { - for (key in arg1) { - fn(this[i], key, arg1[key]); - } - } - } - // return self for chaining - return this; - } else { - // we are a read, so read the first child. - // TODO: do we still need this? - var value = fn.$dv; - // Only if we have $dv do we iterate over all, otherwise it is just the first element. - var jj = (value === undefined) ? Math.min(nodeCount, 1) : nodeCount; - for (var j = 0; j < jj; j++) { - var nodeValue = fn(this[j], arg1, arg2); - value = value ? value + nodeValue : nodeValue; - } - return value; - } - } else { - // we are a write, so apply to all children - for (i = 0; i < nodeCount; i++) { - fn(this[i], arg1, arg2); - } - // return self for chaining - return this; - } - }; -}); - -function createEventHandler(element, events) { - var eventHandler = function (event, type) { - if (!event.preventDefault) { - event.preventDefault = function() { - event.returnValue = false; //ie - }; - } - - if (!event.stopPropagation) { - event.stopPropagation = function() { - event.cancelBubble = true; //ie - }; - } - - if (!event.target) { - event.target = event.srcElement || document; - } - - if (isUndefined(event.defaultPrevented)) { - var prevent = event.preventDefault; - event.preventDefault = function() { - event.defaultPrevented = true; - prevent.call(event); - }; - event.defaultPrevented = false; - } - - event.isDefaultPrevented = function() { - return event.defaultPrevented || event.returnValue === false; - }; - - // Copy event handlers in case event handlers array is modified during execution. - var eventHandlersCopy = shallowCopy(events[type || event.type] || []); - - forEach(eventHandlersCopy, function(fn) { - fn.call(element, event); - }); - - // Remove monkey-patched methods (IE), - // as they would cause memory leaks in IE8. - if (msie <= 8) { - // IE7/8 does not allow to delete property on native object - event.preventDefault = null; - event.stopPropagation = null; - event.isDefaultPrevented = null; - } else { - // It shouldn't affect normal browsers (native methods are defined on prototype). - delete event.preventDefault; - delete event.stopPropagation; - delete event.isDefaultPrevented; - } - }; - eventHandler.elem = element; - return eventHandler; -} - -////////////////////////////////////////// -// Functions iterating traversal. -// These functions chain results into a single -// selector. -////////////////////////////////////////// -forEach({ - removeData: jqLiteRemoveData, - - dealoc: jqLiteDealoc, - - on: function onFn(element, type, fn, unsupported){ - if (isDefined(unsupported)) throw jqLiteMinErr('onargs', 'jqLite#on() does not support the `selector` or `eventData` parameters'); - - var events = jqLiteExpandoStore(element, 'events'), - handle = jqLiteExpandoStore(element, 'handle'); - - if (!events) jqLiteExpandoStore(element, 'events', events = {}); - if (!handle) jqLiteExpandoStore(element, 'handle', handle = createEventHandler(element, events)); - - forEach(type.split(' '), function(type){ - var eventFns = events[type]; - - if (!eventFns) { - if (type == 'mouseenter' || type == 'mouseleave') { - var contains = document.body.contains || document.body.compareDocumentPosition ? - function( a, b ) { - // jshint bitwise: false - var adown = a.nodeType === 9 ? a.documentElement : a, - bup = b && b.parentNode; - return a === bup || !!( bup && bup.nodeType === 1 && ( - adown.contains ? - adown.contains( bup ) : - a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 - )); - } : - function( a, b ) { - if ( b ) { - while ( (b = b.parentNode) ) { - if ( b === a ) { - return true; - } - } - } - return false; - }; - - events[type] = []; - - // Refer to jQuery's implementation of mouseenter & mouseleave - // Read about mouseenter and mouseleave: - // http://www.quirksmode.org/js/events_mouse.html#link8 - var eventmap = { mouseleave : "mouseout", mouseenter : "mouseover"}; - - onFn(element, eventmap[type], function(event) { - var target = this, related = event.relatedTarget; - // For mousenter/leave call the handler if related is outside the target. - // NB: No relatedTarget if the mouse left/entered the browser window - if ( !related || (related !== target && !contains(target, related)) ){ - handle(event, type); - } - }); - - } else { - addEventListenerFn(element, type, handle); - events[type] = []; - } - eventFns = events[type]; - } - eventFns.push(fn); - }); - }, - - off: jqLiteOff, - - one: function(element, type, fn) { - element = jqLite(element); - - //add the listener twice so that when it is called - //you can remove the original function and still be - //able to call element.off(ev, fn) normally - element.on(type, function onFn() { - element.off(type, fn); - element.off(type, onFn); - }); - element.on(type, fn); - }, - - replaceWith: function(element, replaceNode) { - var index, parent = element.parentNode; - jqLiteDealoc(element); - forEach(new JQLite(replaceNode), function(node){ - if (index) { - parent.insertBefore(node, index.nextSibling); - } else { - parent.replaceChild(node, element); - } - index = node; - }); - }, - - children: function(element) { - var children = []; - forEach(element.childNodes, function(element){ - if (element.nodeType === 1) - children.push(element); - }); - return children; - }, - - contents: function(element) { - return element.contentDocument || element.childNodes || []; - }, - - append: function(element, node) { - forEach(new JQLite(node), function(child){ - if (element.nodeType === 1 || element.nodeType === 11) { - element.appendChild(child); - } - }); - }, - - prepend: function(element, node) { - if (element.nodeType === 1) { - var index = element.firstChild; - forEach(new JQLite(node), function(child){ - element.insertBefore(child, index); - }); - } - }, - - wrap: function(element, wrapNode) { - wrapNode = jqLite(wrapNode)[0]; - var parent = element.parentNode; - if (parent) { - parent.replaceChild(wrapNode, element); - } - wrapNode.appendChild(element); - }, - - remove: function(element) { - jqLiteDealoc(element); - var parent = element.parentNode; - if (parent) parent.removeChild(element); - }, - - after: function(element, newElement) { - var index = element, parent = element.parentNode; - forEach(new JQLite(newElement), function(node){ - parent.insertBefore(node, index.nextSibling); - index = node; - }); - }, - - addClass: jqLiteAddClass, - removeClass: jqLiteRemoveClass, - - toggleClass: function(element, selector, condition) { - if (selector) { - forEach(selector.split(' '), function(className){ - var classCondition = condition; - if (isUndefined(classCondition)) { - classCondition = !jqLiteHasClass(element, className); - } - (classCondition ? jqLiteAddClass : jqLiteRemoveClass)(element, className); - }); - } - }, - - parent: function(element) { - var parent = element.parentNode; - return parent && parent.nodeType !== 11 ? parent : null; - }, - - next: function(element) { - if (element.nextElementSibling) { - return element.nextElementSibling; - } - - // IE8 doesn't have nextElementSibling - var elm = element.nextSibling; - while (elm != null && elm.nodeType !== 1) { - elm = elm.nextSibling; - } - return elm; - }, - - find: function(element, selector) { - if (element.getElementsByTagName) { - return element.getElementsByTagName(selector); - } else { - return []; - } - }, - - clone: jqLiteClone, - - triggerHandler: function(element, event, extraParameters) { - - var dummyEvent, eventFnsCopy, handlerArgs; - var eventName = event.type || event; - var eventFns = (jqLiteExpandoStore(element, 'events') || {})[eventName]; - - if (eventFns) { - - // Create a dummy event to pass to the handlers - dummyEvent = { - preventDefault: function() { this.defaultPrevented = true; }, - isDefaultPrevented: function() { return this.defaultPrevented === true; }, - stopPropagation: noop, - type: eventName, - target: element - }; - - // If a custom event was provided then extend our dummy event with it - if (event.type) { - dummyEvent = extend(dummyEvent, event); - } - - // Copy event handlers in case event handlers array is modified during execution. - eventFnsCopy = shallowCopy(eventFns); - handlerArgs = extraParameters ? [dummyEvent].concat(extraParameters) : [dummyEvent]; - - forEach(eventFnsCopy, function(fn) { - fn.apply(element, handlerArgs); - }); - - } - } -}, function(fn, name){ - /** - * chaining functions - */ - JQLite.prototype[name] = function(arg1, arg2, arg3) { - var value; - for(var i=0; i < this.length; i++) { - if (isUndefined(value)) { - value = fn(this[i], arg1, arg2, arg3); - if (isDefined(value)) { - // any function which returns a value needs to be wrapped - value = jqLite(value); - } - } else { - jqLiteAddNodes(value, fn(this[i], arg1, arg2, arg3)); - } - } - return isDefined(value) ? value : this; - }; - - // bind legacy bind/unbind to on/off - JQLite.prototype.bind = JQLite.prototype.on; - JQLite.prototype.unbind = JQLite.prototype.off; -}); - -/** - * Computes a hash of an 'obj'. - * Hash of a: - * string is string - * number is number as string - * object is either result of calling $$hashKey function on the object or uniquely generated id, - * that is also assigned to the $$hashKey property of the object. - * - * @param obj - * @returns {string} hash string such that the same input will have the same hash string. - * The resulting string key is in 'type:hashKey' format. - */ -function hashKey(obj, nextUidFn) { - var objType = typeof obj, - key; - - if (objType == 'function' || (objType == 'object' && obj !== null)) { - if (typeof (key = obj.$$hashKey) == 'function') { - // must invoke on object to keep the right this - key = obj.$$hashKey(); - } else if (key === undefined) { - key = obj.$$hashKey = (nextUidFn || nextUid)(); - } - } else { - key = obj; - } - - return objType + ':' + key; -} - -/** - * HashMap which can use objects as keys - */ -function HashMap(array, isolatedUid) { - if (isolatedUid) { - var uid = 0; - this.nextUid = function() { - return ++uid; - }; - } - forEach(array, this.put, this); -} -HashMap.prototype = { - /** - * Store key value pair - * @param key key to store can be any type - * @param value value to store can be any type - */ - put: function(key, value) { - this[hashKey(key, this.nextUid)] = value; - }, - - /** - * @param key - * @returns {Object} the value for the key - */ - get: function(key) { - return this[hashKey(key, this.nextUid)]; - }, - - /** - * Remove the key/value pair - * @param key - */ - remove: function(key) { - var value = this[key = hashKey(key, this.nextUid)]; - delete this[key]; - return value; - } -}; - -/** - * @ngdoc function - * @module ng - * @name angular.injector - * @kind function - * - * @description - * Creates an injector function that can be used for retrieving services as well as for - * dependency injection (see {@link guide/di dependency injection}). - * - - * @param {Array.} modules A list of module functions or their aliases. See - * {@link angular.module}. The `ng` module must be explicitly added. - * @returns {function()} Injector function. See {@link auto.$injector $injector}. - * - * @example - * Typical usage - * ```js - * // create an injector - * var $injector = angular.injector(['ng']); - * - * // use the injector to kick off your application - * // use the type inference to auto inject arguments, or use implicit injection - * $injector.invoke(function($rootScope, $compile, $document){ - * $compile($document)($rootScope); - * $rootScope.$digest(); - * }); - * ``` - * - * Sometimes you want to get access to the injector of a currently running Angular app - * from outside Angular. Perhaps, you want to inject and compile some markup after the - * application has been bootstrapped. You can do this using the extra `injector()` added - * to JQuery/jqLite elements. See {@link angular.element}. - * - * *This is fairly rare but could be the case if a third party library is injecting the - * markup.* - * - * In the following example a new block of HTML containing a `ng-controller` - * directive is added to the end of the document body by JQuery. We then compile and link - * it into the current AngularJS scope. - * - * ```js - * var $div = $('
{{content.label}}
'); - * $(document.body).append($div); - * - * angular.element(document).injector().invoke(function($compile) { - * var scope = angular.element($div).scope(); - * $compile($div)(scope); - * }); - * ``` - */ - - -/** - * @ngdoc module - * @name auto - * @description - * - * Implicit module which gets automatically added to each {@link auto.$injector $injector}. - */ - -var FN_ARGS = /^function\s*[^\(]*\(\s*([^\)]*)\)/m; -var FN_ARG_SPLIT = /,/; -var FN_ARG = /^\s*(_?)(\S+?)\1\s*$/; -var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg; -var $injectorMinErr = minErr('$injector'); -function annotate(fn) { - var $inject, - fnText, - argDecl, - last; - - if (typeof fn === 'function') { - if (!($inject = fn.$inject)) { - $inject = []; - if (fn.length) { - fnText = fn.toString().replace(STRIP_COMMENTS, ''); - argDecl = fnText.match(FN_ARGS); - forEach(argDecl[1].split(FN_ARG_SPLIT), function(arg){ - arg.replace(FN_ARG, function(all, underscore, name){ - $inject.push(name); - }); - }); - } - fn.$inject = $inject; - } - } else if (isArray(fn)) { - last = fn.length - 1; - assertArgFn(fn[last], 'fn'); - $inject = fn.slice(0, last); - } else { - assertArgFn(fn, 'fn', true); - } - return $inject; -} - -/////////////////////////////////////// - -/** - * @ngdoc service - * @name $injector - * @kind function - * - * @description - * - * `$injector` is used to retrieve object instances as defined by - * {@link auto.$provide provider}, instantiate types, invoke methods, - * and load modules. - * - * The following always holds true: - * - * ```js - * var $injector = angular.injector(); - * expect($injector.get('$injector')).toBe($injector); - * expect($injector.invoke(function($injector){ - * return $injector; - * }).toBe($injector); - * ``` - * - * # Injection Function Annotation - * - * JavaScript does not have annotations, and annotations are needed for dependency injection. The - * following are all valid ways of annotating function with injection arguments and are equivalent. - * - * ```js - * // inferred (only works if code not minified/obfuscated) - * $injector.invoke(function(serviceA){}); - * - * // annotated - * function explicit(serviceA) {}; - * explicit.$inject = ['serviceA']; - * $injector.invoke(explicit); - * - * // inline - * $injector.invoke(['serviceA', function(serviceA){}]); - * ``` - * - * ## Inference - * - * In JavaScript calling `toString()` on a function returns the function definition. The definition - * can then be parsed and the function arguments can be extracted. *NOTE:* This does not work with - * minification, and obfuscation tools since these tools change the argument names. - * - * ## `$inject` Annotation - * By adding an `$inject` property onto a function the injection parameters can be specified. - * - * ## Inline - * As an array of injection names, where the last item in the array is the function to call. - */ - -/** - * @ngdoc method - * @name $injector#get - * - * @description - * Return an instance of the service. - * - * @param {string} name The name of the instance to retrieve. - * @return {*} The instance. - */ - -/** - * @ngdoc method - * @name $injector#invoke - * - * @description - * Invoke the method and supply the method arguments from the `$injector`. - * - * @param {!Function} fn The function to invoke. Function parameters are injected according to the - * {@link guide/di $inject Annotation} rules. - * @param {Object=} self The `this` for the invoked method. - * @param {Object=} locals Optional object. If preset then any argument names are read from this - * object first, before the `$injector` is consulted. - * @returns {*} the value returned by the invoked `fn` function. - */ - -/** - * @ngdoc method - * @name $injector#has - * - * @description - * Allows the user to query if the particular service exists. - * - * @param {string} Name of the service to query. - * @returns {boolean} returns true if injector has given service. - */ - -/** - * @ngdoc method - * @name $injector#instantiate - * @description - * Create a new instance of JS type. The method takes a constructor function, invokes the new - * operator, and supplies all of the arguments to the constructor function as specified by the - * constructor annotation. - * - * @param {Function} Type Annotated constructor function. - * @param {Object=} locals Optional object. If preset then any argument names are read from this - * object first, before the `$injector` is consulted. - * @returns {Object} new instance of `Type`. - */ - -/** - * @ngdoc method - * @name $injector#annotate - * - * @description - * Returns an array of service names which the function is requesting for injection. This API is - * used by the injector to determine which services need to be injected into the function when the - * function is invoked. There are three ways in which the function can be annotated with the needed - * dependencies. - * - * # Argument names - * - * The simplest form is to extract the dependencies from the arguments of the function. This is done - * by converting the function into a string using `toString()` method and extracting the argument - * names. - * ```js - * // Given - * function MyController($scope, $route) { - * // ... - * } - * - * // Then - * expect(injector.annotate(MyController)).toEqual(['$scope', '$route']); - * ``` - * - * This method does not work with code minification / obfuscation. For this reason the following - * annotation strategies are supported. - * - * # The `$inject` property - * - * If a function has an `$inject` property and its value is an array of strings, then the strings - * represent names of services to be injected into the function. - * ```js - * // Given - * var MyController = function(obfuscatedScope, obfuscatedRoute) { - * // ... - * } - * // Define function dependencies - * MyController['$inject'] = ['$scope', '$route']; - * - * // Then - * expect(injector.annotate(MyController)).toEqual(['$scope', '$route']); - * ``` - * - * # The array notation - * - * It is often desirable to inline Injected functions and that's when setting the `$inject` property - * is very inconvenient. In these situations using the array notation to specify the dependencies in - * a way that survives minification is a better choice: - * - * ```js - * // We wish to write this (not minification / obfuscation safe) - * injector.invoke(function($compile, $rootScope) { - * // ... - * }); - * - * // We are forced to write break inlining - * var tmpFn = function(obfuscatedCompile, obfuscatedRootScope) { - * // ... - * }; - * tmpFn.$inject = ['$compile', '$rootScope']; - * injector.invoke(tmpFn); - * - * // To better support inline function the inline annotation is supported - * injector.invoke(['$compile', '$rootScope', function(obfCompile, obfRootScope) { - * // ... - * }]); - * - * // Therefore - * expect(injector.annotate( - * ['$compile', '$rootScope', function(obfus_$compile, obfus_$rootScope) {}]) - * ).toEqual(['$compile', '$rootScope']); - * ``` - * - * @param {Function|Array.} fn Function for which dependent service names need to - * be retrieved as described above. - * - * @returns {Array.} The names of the services which the function requires. - */ - - - - -/** - * @ngdoc service - * @name $provide - * - * @description - * - * The {@link auto.$provide $provide} service has a number of methods for registering components - * with the {@link auto.$injector $injector}. Many of these functions are also exposed on - * {@link angular.Module}. - * - * An Angular **service** is a singleton object created by a **service factory**. These **service - * factories** are functions which, in turn, are created by a **service provider**. - * The **service providers** are constructor functions. When instantiated they must contain a - * property called `$get`, which holds the **service factory** function. - * - * When you request a service, the {@link auto.$injector $injector} is responsible for finding the - * correct **service provider**, instantiating it and then calling its `$get` **service factory** - * function to get the instance of the **service**. - * - * Often services have no configuration options and there is no need to add methods to the service - * provider. The provider will be no more than a constructor function with a `$get` property. For - * these cases the {@link auto.$provide $provide} service has additional helper methods to register - * services without specifying a provider. - * - * * {@link auto.$provide#provider provider(provider)} - registers a **service provider** with the - * {@link auto.$injector $injector} - * * {@link auto.$provide#constant constant(obj)} - registers a value/object that can be accessed by - * providers and services. - * * {@link auto.$provide#value value(obj)} - registers a value/object that can only be accessed by - * services, not providers. - * * {@link auto.$provide#factory factory(fn)} - registers a service **factory function**, `fn`, - * that will be wrapped in a **service provider** object, whose `$get` property will contain the - * given factory function. - * * {@link auto.$provide#service service(class)} - registers a **constructor function**, `class` - * that will be wrapped in a **service provider** object, whose `$get` property will instantiate - * a new object using the given constructor function. - * - * See the individual methods for more information and examples. - */ - -/** - * @ngdoc method - * @name $provide#provider - * @description - * - * Register a **provider function** with the {@link auto.$injector $injector}. Provider functions - * are constructor functions, whose instances are responsible for "providing" a factory for a - * service. - * - * Service provider names start with the name of the service they provide followed by `Provider`. - * For example, the {@link ng.$log $log} service has a provider called - * {@link ng.$logProvider $logProvider}. - * - * Service provider objects can have additional methods which allow configuration of the provider - * and its service. Importantly, you can configure what kind of service is created by the `$get` - * method, or how that service will act. For example, the {@link ng.$logProvider $logProvider} has a - * method {@link ng.$logProvider#debugEnabled debugEnabled} - * which lets you specify whether the {@link ng.$log $log} service will log debug messages to the - * console or not. - * - * @param {string} name The name of the instance. NOTE: the provider will be available under `name + - 'Provider'` key. - * @param {(Object|function())} provider If the provider is: - * - * - `Object`: then it should have a `$get` method. The `$get` method will be invoked using - * {@link auto.$injector#invoke $injector.invoke()} when an instance needs to be created. - * - `Constructor`: a new instance of the provider will be created using - * {@link auto.$injector#instantiate $injector.instantiate()}, then treated as `object`. - * - * @returns {Object} registered provider instance - - * @example - * - * The following example shows how to create a simple event tracking service and register it using - * {@link auto.$provide#provider $provide.provider()}. - * - * ```js - * // Define the eventTracker provider - * function EventTrackerProvider() { - * var trackingUrl = '/track'; - * - * // A provider method for configuring where the tracked events should been saved - * this.setTrackingUrl = function(url) { - * trackingUrl = url; - * }; - * - * // The service factory function - * this.$get = ['$http', function($http) { - * var trackedEvents = {}; - * return { - * // Call this to track an event - * event: function(event) { - * var count = trackedEvents[event] || 0; - * count += 1; - * trackedEvents[event] = count; - * return count; - * }, - * // Call this to save the tracked events to the trackingUrl - * save: function() { - * $http.post(trackingUrl, trackedEvents); - * } - * }; - * }]; - * } - * - * describe('eventTracker', function() { - * var postSpy; - * - * beforeEach(module(function($provide) { - * // Register the eventTracker provider - * $provide.provider('eventTracker', EventTrackerProvider); - * })); - * - * beforeEach(module(function(eventTrackerProvider) { - * // Configure eventTracker provider - * eventTrackerProvider.setTrackingUrl('/custom-track'); - * })); - * - * it('tracks events', inject(function(eventTracker) { - * expect(eventTracker.event('login')).toEqual(1); - * expect(eventTracker.event('login')).toEqual(2); - * })); - * - * it('saves to the tracking url', inject(function(eventTracker, $http) { - * postSpy = spyOn($http, 'post'); - * eventTracker.event('login'); - * eventTracker.save(); - * expect(postSpy).toHaveBeenCalled(); - * expect(postSpy.mostRecentCall.args[0]).not.toEqual('/track'); - * expect(postSpy.mostRecentCall.args[0]).toEqual('/custom-track'); - * expect(postSpy.mostRecentCall.args[1]).toEqual({ 'login': 1 }); - * })); - * }); - * ``` - */ - -/** - * @ngdoc method - * @name $provide#factory - * @description - * - * Register a **service factory**, which will be called to return the service instance. - * This is short for registering a service where its provider consists of only a `$get` property, - * which is the given service factory function. - * You should use {@link auto.$provide#factory $provide.factory(getFn)} if you do not need to - * configure your service in a provider. - * - * @param {string} name The name of the instance. - * @param {function()} $getFn The $getFn for the instance creation. Internally this is a short hand - * for `$provide.provider(name, {$get: $getFn})`. - * @returns {Object} registered provider instance - * - * @example - * Here is an example of registering a service - * ```js - * $provide.factory('ping', ['$http', function($http) { - * return function ping() { - * return $http.send('/ping'); - * }; - * }]); - * ``` - * You would then inject and use this service like this: - * ```js - * someModule.controller('Ctrl', ['ping', function(ping) { - * ping(); - * }]); - * ``` - */ - - -/** - * @ngdoc method - * @name $provide#service - * @description - * - * Register a **service constructor**, which will be invoked with `new` to create the service - * instance. - * This is short for registering a service where its provider's `$get` property is the service - * constructor function that will be used to instantiate the service instance. - * - * You should use {@link auto.$provide#service $provide.service(class)} if you define your service - * as a type/class. - * - * @param {string} name The name of the instance. - * @param {Function} constructor A class (constructor function) that will be instantiated. - * @returns {Object} registered provider instance - * - * @example - * Here is an example of registering a service using - * {@link auto.$provide#service $provide.service(class)}. - * ```js - * var Ping = function($http) { - * this.$http = $http; - * }; - * - * Ping.$inject = ['$http']; - * - * Ping.prototype.send = function() { - * return this.$http.get('/ping'); - * }; - * $provide.service('ping', Ping); - * ``` - * You would then inject and use this service like this: - * ```js - * someModule.controller('Ctrl', ['ping', function(ping) { - * ping.send(); - * }]); - * ``` - */ - - -/** - * @ngdoc method - * @name $provide#value - * @description - * - * Register a **value service** with the {@link auto.$injector $injector}, such as a string, a - * number, an array, an object or a function. This is short for registering a service where its - * provider's `$get` property is a factory function that takes no arguments and returns the **value - * service**. - * - * Value services are similar to constant services, except that they cannot be injected into a - * module configuration function (see {@link angular.Module#config}) but they can be overridden by - * an Angular - * {@link auto.$provide#decorator decorator}. - * - * @param {string} name The name of the instance. - * @param {*} value The value. - * @returns {Object} registered provider instance - * - * @example - * Here are some examples of creating value services. - * ```js - * $provide.value('ADMIN_USER', 'admin'); - * - * $provide.value('RoleLookup', { admin: 0, writer: 1, reader: 2 }); - * - * $provide.value('halfOf', function(value) { - * return value / 2; - * }); - * ``` - */ - - -/** - * @ngdoc method - * @name $provide#constant - * @description - * - * Register a **constant service**, such as a string, a number, an array, an object or a function, - * with the {@link auto.$injector $injector}. Unlike {@link auto.$provide#value value} it can be - * injected into a module configuration function (see {@link angular.Module#config}) and it cannot - * be overridden by an Angular {@link auto.$provide#decorator decorator}. - * - * @param {string} name The name of the constant. - * @param {*} value The constant value. - * @returns {Object} registered instance - * - * @example - * Here a some examples of creating constants: - * ```js - * $provide.constant('SHARD_HEIGHT', 306); - * - * $provide.constant('MY_COLOURS', ['red', 'blue', 'grey']); - * - * $provide.constant('double', function(value) { - * return value * 2; - * }); - * ``` - */ - - -/** - * @ngdoc method - * @name $provide#decorator - * @description - * - * Register a **service decorator** with the {@link auto.$injector $injector}. A service decorator - * intercepts the creation of a service, allowing it to override or modify the behaviour of the - * service. The object returned by the decorator may be the original service, or a new service - * object which replaces or wraps and delegates to the original service. - * - * @param {string} name The name of the service to decorate. - * @param {function()} decorator This function will be invoked when the service needs to be - * instantiated and should return the decorated service instance. The function is called using - * the {@link auto.$injector#invoke injector.invoke} method and is therefore fully injectable. - * Local injection arguments: - * - * * `$delegate` - The original service instance, which can be monkey patched, configured, - * decorated or delegated to. - * - * @example - * Here we decorate the {@link ng.$log $log} service to convert warnings to errors by intercepting - * calls to {@link ng.$log#error $log.warn()}. - * ```js - * $provide.decorator('$log', ['$delegate', function($delegate) { - * $delegate.warn = $delegate.error; - * return $delegate; - * }]); - * ``` - */ - - -function createInjector(modulesToLoad) { - var INSTANTIATING = {}, - providerSuffix = 'Provider', - path = [], - loadedModules = new HashMap([], true), - providerCache = { - $provide: { - provider: supportObject(provider), - factory: supportObject(factory), - service: supportObject(service), - value: supportObject(value), - constant: supportObject(constant), - decorator: decorator - } - }, - providerInjector = (providerCache.$injector = - createInternalInjector(providerCache, function() { - throw $injectorMinErr('unpr', "Unknown provider: {0}", path.join(' <- ')); - })), - instanceCache = {}, - instanceInjector = (instanceCache.$injector = - createInternalInjector(instanceCache, function(servicename) { - var provider = providerInjector.get(servicename + providerSuffix); - return instanceInjector.invoke(provider.$get, provider); - })); - - - forEach(loadModules(modulesToLoad), function(fn) { instanceInjector.invoke(fn || noop); }); - - return instanceInjector; - - //////////////////////////////////// - // $provider - //////////////////////////////////// - - function supportObject(delegate) { - return function(key, value) { - if (isObject(key)) { - forEach(key, reverseParams(delegate)); - } else { - return delegate(key, value); - } - }; - } - - function provider(name, provider_) { - assertNotHasOwnProperty(name, 'service'); - if (isFunction(provider_) || isArray(provider_)) { - provider_ = providerInjector.instantiate(provider_); - } - if (!provider_.$get) { - throw $injectorMinErr('pget', "Provider '{0}' must define $get factory method.", name); - } - return providerCache[name + providerSuffix] = provider_; - } - - function factory(name, factoryFn) { return provider(name, { $get: factoryFn }); } - - function service(name, constructor) { - return factory(name, ['$injector', function($injector) { - return $injector.instantiate(constructor); - }]); - } - - function value(name, val) { return factory(name, valueFn(val)); } - - function constant(name, value) { - assertNotHasOwnProperty(name, 'constant'); - providerCache[name] = value; - instanceCache[name] = value; - } - - function decorator(serviceName, decorFn) { - var origProvider = providerInjector.get(serviceName + providerSuffix), - orig$get = origProvider.$get; - - origProvider.$get = function() { - var origInstance = instanceInjector.invoke(orig$get, origProvider); - return instanceInjector.invoke(decorFn, null, {$delegate: origInstance}); - }; - } - - //////////////////////////////////// - // Module Loading - //////////////////////////////////// - function loadModules(modulesToLoad){ - var runBlocks = [], moduleFn, invokeQueue, i, ii; - forEach(modulesToLoad, function(module) { - if (loadedModules.get(module)) return; - loadedModules.put(module, true); - - try { - if (isString(module)) { - moduleFn = angularModule(module); - runBlocks = runBlocks.concat(loadModules(moduleFn.requires)).concat(moduleFn._runBlocks); - - for(invokeQueue = moduleFn._invokeQueue, i = 0, ii = invokeQueue.length; i < ii; i++) { - var invokeArgs = invokeQueue[i], - provider = providerInjector.get(invokeArgs[0]); - - provider[invokeArgs[1]].apply(provider, invokeArgs[2]); - } - } else if (isFunction(module)) { - runBlocks.push(providerInjector.invoke(module)); - } else if (isArray(module)) { - runBlocks.push(providerInjector.invoke(module)); - } else { - assertArgFn(module, 'module'); - } - } catch (e) { - if (isArray(module)) { - module = module[module.length - 1]; - } - if (e.message && e.stack && e.stack.indexOf(e.message) == -1) { - // Safari & FF's stack traces don't contain error.message content - // unlike those of Chrome and IE - // So if stack doesn't contain message, we create a new string that contains both. - // Since error.stack is read-only in Safari, I'm overriding e and not e.stack here. - /* jshint -W022 */ - e = e.message + '\n' + e.stack; - } - throw $injectorMinErr('modulerr', "Failed to instantiate module {0} due to:\n{1}", - module, e.stack || e.message || e); - } - }); - return runBlocks; - } - - //////////////////////////////////// - // internal Injector - //////////////////////////////////// - - function createInternalInjector(cache, factory) { - - function getService(serviceName) { - if (cache.hasOwnProperty(serviceName)) { - if (cache[serviceName] === INSTANTIATING) { - throw $injectorMinErr('cdep', 'Circular dependency found: {0}', - serviceName + ' <- ' + path.join(' <- ')); - } - return cache[serviceName]; - } else { - try { - path.unshift(serviceName); - cache[serviceName] = INSTANTIATING; - return cache[serviceName] = factory(serviceName); - } catch (err) { - if (cache[serviceName] === INSTANTIATING) { - delete cache[serviceName]; - } - throw err; - } finally { - path.shift(); - } - } - } - - function invoke(fn, self, locals){ - var args = [], - $inject = annotate(fn), - length, i, - key; - - for(i = 0, length = $inject.length; i < length; i++) { - key = $inject[i]; - if (typeof key !== 'string') { - throw $injectorMinErr('itkn', - 'Incorrect injection token! Expected service name as string, got {0}', key); - } - args.push( - locals && locals.hasOwnProperty(key) - ? locals[key] - : getService(key) - ); - } - if (isArray(fn)) { - fn = fn[length]; - } - - // http://jsperf.com/angularjs-invoke-apply-vs-switch - // #5388 - return fn.apply(self, args); - } - - function instantiate(Type, locals) { - var Constructor = function() {}, - instance, returnedValue; - - // Check if Type is annotated and use just the given function at n-1 as parameter - // e.g. someModule.factory('greeter', ['$window', function(renamed$window) {}]); - Constructor.prototype = (isArray(Type) ? Type[Type.length - 1] : Type).prototype; - instance = new Constructor(); - returnedValue = invoke(Type, instance, locals); - - return isObject(returnedValue) || isFunction(returnedValue) ? returnedValue : instance; - } - - return { - invoke: invoke, - instantiate: instantiate, - get: getService, - annotate: annotate, - has: function(name) { - return providerCache.hasOwnProperty(name + providerSuffix) || cache.hasOwnProperty(name); - } - }; - } -} - -/** - * @ngdoc service - * @name $anchorScroll - * @kind function - * @requires $window - * @requires $location - * @requires $rootScope - * - * @description - * When called, it checks current value of `$location.hash()` and scrolls to the related element, - * according to rules specified in - * [Html5 spec](http://dev.w3.org/html5/spec/Overview.html#the-indicated-part-of-the-document). - * - * It also watches the `$location.hash()` and scrolls whenever it changes to match any anchor. - * This can be disabled by calling `$anchorScrollProvider.disableAutoScrolling()`. - * - * @example - - -
- Go to bottom - You're at the bottom! -
-
- - function ScrollCtrl($scope, $location, $anchorScroll) { - $scope.gotoBottom = function (){ - // set the location.hash to the id of - // the element you wish to scroll to. - $location.hash('bottom'); - - // call $anchorScroll() - $anchorScroll(); - }; - } - - - #scrollArea { - height: 350px; - overflow: auto; - } - - #bottom { - display: block; - margin-top: 2000px; - } - -
- */ -function $AnchorScrollProvider() { - - var autoScrollingEnabled = true; - - this.disableAutoScrolling = function() { - autoScrollingEnabled = false; - }; - - this.$get = ['$window', '$location', '$rootScope', function($window, $location, $rootScope) { - var document = $window.document; - - // helper function to get first anchor from a NodeList - // can't use filter.filter, as it accepts only instances of Array - // and IE can't convert NodeList to an array using [].slice - // TODO(vojta): use filter if we change it to accept lists as well - function getFirstAnchor(list) { - var result = null; - forEach(list, function(element) { - if (!result && lowercase(element.nodeName) === 'a') result = element; - }); - return result; - } - - function scroll() { - var hash = $location.hash(), elm; - - // empty hash, scroll to the top of the page - if (!hash) $window.scrollTo(0, 0); - - // element with given id - else if ((elm = document.getElementById(hash))) elm.scrollIntoView(); - - // first anchor with given name :-D - else if ((elm = getFirstAnchor(document.getElementsByName(hash)))) elm.scrollIntoView(); - - // no element and hash == 'top', scroll to the top of the page - else if (hash === 'top') $window.scrollTo(0, 0); - } - - // does not scroll when user clicks on anchor link that is currently on - // (no url change, no $location.hash() change), browser native does scroll - if (autoScrollingEnabled) { - $rootScope.$watch(function autoScrollWatch() {return $location.hash();}, - function autoScrollWatchAction() { - $rootScope.$evalAsync(scroll); - }); - } - - return scroll; - }]; -} - -var $animateMinErr = minErr('$animate'); - -/** - * @ngdoc provider - * @name $animateProvider - * - * @description - * Default implementation of $animate that doesn't perform any animations, instead just - * synchronously performs DOM - * updates and calls done() callbacks. - * - * In order to enable animations the ngAnimate module has to be loaded. - * - * To see the functional implementation check out src/ngAnimate/animate.js - */ -var $AnimateProvider = ['$provide', function($provide) { - - - this.$$selectors = {}; - - - /** - * @ngdoc method - * @name $animateProvider#register - * - * @description - * Registers a new injectable animation factory function. The factory function produces the - * animation object which contains callback functions for each event that is expected to be - * animated. - * - * * `eventFn`: `function(Element, doneFunction)` The element to animate, the `doneFunction` - * must be called once the element animation is complete. If a function is returned then the - * animation service will use this function to cancel the animation whenever a cancel event is - * triggered. - * - * - * ```js - * return { - * eventFn : function(element, done) { - * //code to run the animation - * //once complete, then run done() - * return function cancellationFunction() { - * //code to cancel the animation - * } - * } - * } - * ``` - * - * @param {string} name The name of the animation. - * @param {Function} factory The factory function that will be executed to return the animation - * object. - */ - this.register = function(name, factory) { - var key = name + '-animation'; - if (name && name.charAt(0) != '.') throw $animateMinErr('notcsel', - "Expecting class selector starting with '.' got '{0}'.", name); - this.$$selectors[name.substr(1)] = key; - $provide.factory(key, factory); - }; - - /** - * @ngdoc method - * @name $animateProvider#classNameFilter - * - * @description - * Sets and/or returns the CSS class regular expression that is checked when performing - * an animation. Upon bootstrap the classNameFilter value is not set at all and will - * therefore enable $animate to attempt to perform an animation on any element. - * When setting the classNameFilter value, animations will only be performed on elements - * that successfully match the filter expression. This in turn can boost performance - * for low-powered devices as well as applications containing a lot of structural operations. - * @param {RegExp=} expression The className expression which will be checked against all animations - * @return {RegExp} The current CSS className expression value. If null then there is no expression value - */ - this.classNameFilter = function(expression) { - if(arguments.length === 1) { - this.$$classNameFilter = (expression instanceof RegExp) ? expression : null; - } - return this.$$classNameFilter; - }; - - this.$get = ['$timeout', '$$asyncCallback', function($timeout, $$asyncCallback) { - - function async(fn) { - fn && $$asyncCallback(fn); - } - - /** - * - * @ngdoc service - * @name $animate - * @description The $animate service provides rudimentary DOM manipulation functions to - * insert, remove and move elements within the DOM, as well as adding and removing classes. - * This service is the core service used by the ngAnimate $animator service which provides - * high-level animation hooks for CSS and JavaScript. - * - * $animate is available in the AngularJS core, however, the ngAnimate module must be included - * to enable full out animation support. Otherwise, $animate will only perform simple DOM - * manipulation operations. - * - * To learn more about enabling animation support, click here to visit the {@link ngAnimate - * ngAnimate module page} as well as the {@link ngAnimate.$animate ngAnimate $animate service - * page}. - */ - return { - - /** - * - * @ngdoc method - * @name $animate#enter - * @kind function - * @description Inserts the element into the DOM either after the `after` element or within - * the `parent` element. Once complete, the done() callback will be fired (if provided). - * @param {DOMElement} element the element which will be inserted into the DOM - * @param {DOMElement} parent the parent element which will append the element as - * a child (if the after element is not present) - * @param {DOMElement} after the sibling element which will append the element - * after itself - * @param {Function=} done callback function that will be called after the element has been - * inserted into the DOM - */ - enter : function(element, parent, after, done) { - if (after) { - after.after(element); - } else { - if (!parent || !parent[0]) { - parent = after.parent(); - } - parent.append(element); - } - async(done); - }, - - /** - * - * @ngdoc method - * @name $animate#leave - * @kind function - * @description Removes the element from the DOM. Once complete, the done() callback will be - * fired (if provided). - * @param {DOMElement} element the element which will be removed from the DOM - * @param {Function=} done callback function that will be called after the element has been - * removed from the DOM - */ - leave : function(element, done) { - element.remove(); - async(done); - }, - - /** - * - * @ngdoc method - * @name $animate#move - * @kind function - * @description Moves the position of the provided element within the DOM to be placed - * either after the `after` element or inside of the `parent` element. Once complete, the - * done() callback will be fired (if provided). - * - * @param {DOMElement} element the element which will be moved around within the - * DOM - * @param {DOMElement} parent the parent element where the element will be - * inserted into (if the after element is not present) - * @param {DOMElement} after the sibling element where the element will be - * positioned next to - * @param {Function=} done the callback function (if provided) that will be fired after the - * element has been moved to its new position - */ - move : function(element, parent, after, done) { - // Do not remove element before insert. Removing will cause data associated with the - // element to be dropped. Insert will implicitly do the remove. - this.enter(element, parent, after, done); - }, - - /** - * - * @ngdoc method - * @name $animate#addClass - * @kind function - * @description Adds the provided className CSS class value to the provided element. Once - * complete, the done() callback will be fired (if provided). - * @param {DOMElement} element the element which will have the className value - * added to it - * @param {string} className the CSS class which will be added to the element - * @param {Function=} done the callback function (if provided) that will be fired after the - * className value has been added to the element - */ - addClass : function(element, className, done) { - className = isString(className) ? - className : - isArray(className) ? className.join(' ') : ''; - forEach(element, function (element) { - jqLiteAddClass(element, className); - }); - async(done); - }, - - /** - * - * @ngdoc method - * @name $animate#removeClass - * @kind function - * @description Removes the provided className CSS class value from the provided element. - * Once complete, the done() callback will be fired (if provided). - * @param {DOMElement} element the element which will have the className value - * removed from it - * @param {string} className the CSS class which will be removed from the element - * @param {Function=} done the callback function (if provided) that will be fired after the - * className value has been removed from the element - */ - removeClass : function(element, className, done) { - className = isString(className) ? - className : - isArray(className) ? className.join(' ') : ''; - forEach(element, function (element) { - jqLiteRemoveClass(element, className); - }); - async(done); - }, - - /** - * - * @ngdoc method - * @name $animate#setClass - * @kind function - * @description Adds and/or removes the given CSS classes to and from the element. - * Once complete, the done() callback will be fired (if provided). - * @param {DOMElement} element the element which will have its CSS classes changed - * removed from it - * @param {string} add the CSS classes which will be added to the element - * @param {string} remove the CSS class which will be removed from the element - * @param {Function=} done the callback function (if provided) that will be fired after the - * CSS classes have been set on the element - */ - setClass : function(element, add, remove, done) { - forEach(element, function (element) { - jqLiteAddClass(element, add); - jqLiteRemoveClass(element, remove); - }); - async(done); - }, - - enabled : noop - }; - }]; -}]; - -function $$AsyncCallbackProvider(){ - this.$get = ['$$rAF', '$timeout', function($$rAF, $timeout) { - return $$rAF.supported - ? function(fn) { return $$rAF(fn); } - : function(fn) { - return $timeout(fn, 0, false); - }; - }]; -} - -/** - * ! This is a private undocumented service ! - * - * @name $browser - * @requires $log - * @description - * This object has two goals: - * - * - hide all the global state in the browser caused by the window object - * - abstract away all the browser specific features and inconsistencies - * - * For tests we provide {@link ngMock.$browser mock implementation} of the `$browser` - * service, which can be used for convenient testing of the application without the interaction with - * the real browser apis. - */ -/** - * @param {object} window The global window object. - * @param {object} document jQuery wrapped document. - * @param {function()} XHR XMLHttpRequest constructor. - * @param {object} $log console.log or an object with the same interface. - * @param {object} $sniffer $sniffer service - */ -function Browser(window, document, $log, $sniffer) { - var self = this, - rawDocument = document[0], - location = window.location, - history = window.history, - setTimeout = window.setTimeout, - clearTimeout = window.clearTimeout, - pendingDeferIds = {}; - - self.isMock = false; - - var outstandingRequestCount = 0; - var outstandingRequestCallbacks = []; - - // TODO(vojta): remove this temporary api - self.$$completeOutstandingRequest = completeOutstandingRequest; - self.$$incOutstandingRequestCount = function() { outstandingRequestCount++; }; - - /** - * Executes the `fn` function(supports currying) and decrements the `outstandingRequestCallbacks` - * counter. If the counter reaches 0, all the `outstandingRequestCallbacks` are executed. - */ - function completeOutstandingRequest(fn) { - try { - fn.apply(null, sliceArgs(arguments, 1)); - } finally { - outstandingRequestCount--; - if (outstandingRequestCount === 0) { - while(outstandingRequestCallbacks.length) { - try { - outstandingRequestCallbacks.pop()(); - } catch (e) { - $log.error(e); - } - } - } - } - } - - /** - * @private - * Note: this method is used only by scenario runner - * TODO(vojta): prefix this method with $$ ? - * @param {function()} callback Function that will be called when no outstanding request - */ - self.notifyWhenNoOutstandingRequests = function(callback) { - // force browser to execute all pollFns - this is needed so that cookies and other pollers fire - // at some deterministic time in respect to the test runner's actions. Leaving things up to the - // regular poller would result in flaky tests. - forEach(pollFns, function(pollFn){ pollFn(); }); - - if (outstandingRequestCount === 0) { - callback(); - } else { - outstandingRequestCallbacks.push(callback); - } - }; - - ////////////////////////////////////////////////////////////// - // Poll Watcher API - ////////////////////////////////////////////////////////////// - var pollFns = [], - pollTimeout; - - /** - * @name $browser#addPollFn - * - * @param {function()} fn Poll function to add - * - * @description - * Adds a function to the list of functions that poller periodically executes, - * and starts polling if not started yet. - * - * @returns {function()} the added function - */ - self.addPollFn = function(fn) { - if (isUndefined(pollTimeout)) startPoller(100, setTimeout); - pollFns.push(fn); - return fn; - }; - - /** - * @param {number} interval How often should browser call poll functions (ms) - * @param {function()} setTimeout Reference to a real or fake `setTimeout` function. - * - * @description - * Configures the poller to run in the specified intervals, using the specified - * setTimeout fn and kicks it off. - */ - function startPoller(interval, setTimeout) { - (function check() { - forEach(pollFns, function(pollFn){ pollFn(); }); - pollTimeout = setTimeout(check, interval); - })(); - } - - ////////////////////////////////////////////////////////////// - // URL API - ////////////////////////////////////////////////////////////// - - var lastBrowserUrl = location.href, - baseElement = document.find('base'), - newLocation = null; - - /** - * @name $browser#url - * - * @description - * GETTER: - * Without any argument, this method just returns current value of location.href. - * - * SETTER: - * With at least one argument, this method sets url to new value. - * If html5 history api supported, pushState/replaceState is used, otherwise - * location.href/location.replace is used. - * Returns its own instance to allow chaining - * - * NOTE: this api is intended for use only by the $location service. Please use the - * {@link ng.$location $location service} to change url. - * - * @param {string} url New url (when used as setter) - * @param {boolean=} replace Should new url replace current history record ? - */ - self.url = function(url, replace) { - // Android Browser BFCache causes location, history reference to become stale. - if (location !== window.location) location = window.location; - if (history !== window.history) history = window.history; - - // setter - if (url) { - if (lastBrowserUrl == url) return; - lastBrowserUrl = url; - if ($sniffer.history) { - if (replace) history.replaceState(null, '', url); - else { - history.pushState(null, '', url); - // Crazy Opera Bug: http://my.opera.com/community/forums/topic.dml?id=1185462 - baseElement.attr('href', baseElement.attr('href')); - } - } else { - newLocation = url; - if (replace) { - location.replace(url); - } else { - location.href = url; - } - } - return self; - // getter - } else { - // - newLocation is a workaround for an IE7-9 issue with location.replace and location.href - // methods not updating location.href synchronously. - // - the replacement is a workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=407172 - return newLocation || location.href.replace(/%27/g,"'"); - } - }; - - var urlChangeListeners = [], - urlChangeInit = false; - - function fireUrlChange() { - newLocation = null; - if (lastBrowserUrl == self.url()) return; - - lastBrowserUrl = self.url(); - forEach(urlChangeListeners, function(listener) { - listener(self.url()); - }); - } - - /** - * @name $browser#onUrlChange - * - * @description - * Register callback function that will be called, when url changes. - * - * It's only called when the url is changed from outside of angular: - * - user types different url into address bar - * - user clicks on history (forward/back) button - * - user clicks on a link - * - * It's not called when url is changed by $browser.url() method - * - * The listener gets called with new url as parameter. - * - * NOTE: this api is intended for use only by the $location service. Please use the - * {@link ng.$location $location service} to monitor url changes in angular apps. - * - * @param {function(string)} listener Listener function to be called when url changes. - * @return {function(string)} Returns the registered listener fn - handy if the fn is anonymous. - */ - self.onUrlChange = function(callback) { - // TODO(vojta): refactor to use node's syntax for events - if (!urlChangeInit) { - // We listen on both (hashchange/popstate) when available, as some browsers (e.g. Opera) - // don't fire popstate when user change the address bar and don't fire hashchange when url - // changed by push/replaceState - - // html5 history api - popstate event - if ($sniffer.history) jqLite(window).on('popstate', fireUrlChange); - // hashchange event - if ($sniffer.hashchange) jqLite(window).on('hashchange', fireUrlChange); - // polling - else self.addPollFn(fireUrlChange); - - urlChangeInit = true; - } - - urlChangeListeners.push(callback); - return callback; - }; - - /** - * Checks whether the url has changed outside of Angular. - * Needs to be exported to be able to check for changes that have been done in sync, - * as hashchange/popstate events fire in async. - */ - self.$$checkUrlChange = fireUrlChange; - - ////////////////////////////////////////////////////////////// - // Misc API - ////////////////////////////////////////////////////////////// - - /** - * @name $browser#baseHref - * - * @description - * Returns current - * (always relative - without domain) - * - * @returns {string} The current base href - */ - self.baseHref = function() { - var href = baseElement.attr('href'); - return href ? href.replace(/^(https?\:)?\/\/[^\/]*/, '') : ''; - }; - - ////////////////////////////////////////////////////////////// - // Cookies API - ////////////////////////////////////////////////////////////// - var lastCookies = {}; - var lastCookieString = ''; - var cookiePath = self.baseHref(); - - /** - * @name $browser#cookies - * - * @param {string=} name Cookie name - * @param {string=} value Cookie value - * - * @description - * The cookies method provides a 'private' low level access to browser cookies. - * It is not meant to be used directly, use the $cookie service instead. - * - * The return values vary depending on the arguments that the method was called with as follows: - * - * - cookies() -> hash of all cookies, this is NOT a copy of the internal state, so do not modify - * it - * - cookies(name, value) -> set name to value, if value is undefined delete the cookie - * - cookies(name) -> the same as (name, undefined) == DELETES (no one calls it right now that - * way) - * - * @returns {Object} Hash of all cookies (if called without any parameter) - */ - self.cookies = function(name, value) { - /* global escape: false, unescape: false */ - var cookieLength, cookieArray, cookie, i, index; - - if (name) { - if (value === undefined) { - rawDocument.cookie = escape(name) + "=;path=" + cookiePath + - ";expires=Thu, 01 Jan 1970 00:00:00 GMT"; - } else { - if (isString(value)) { - cookieLength = (rawDocument.cookie = escape(name) + '=' + escape(value) + - ';path=' + cookiePath).length + 1; - - // per http://www.ietf.org/rfc/rfc2109.txt browser must allow at minimum: - // - 300 cookies - // - 20 cookies per unique domain - // - 4096 bytes per cookie - if (cookieLength > 4096) { - $log.warn("Cookie '"+ name + - "' possibly not set or overflowed because it was too large ("+ - cookieLength + " > 4096 bytes)!"); - } - } - } - } else { - if (rawDocument.cookie !== lastCookieString) { - lastCookieString = rawDocument.cookie; - cookieArray = lastCookieString.split("; "); - lastCookies = {}; - - for (i = 0; i < cookieArray.length; i++) { - cookie = cookieArray[i]; - index = cookie.indexOf('='); - if (index > 0) { //ignore nameless cookies - name = unescape(cookie.substring(0, index)); - // the first value that is seen for a cookie is the most - // specific one. values for the same cookie name that - // follow are for less specific paths. - if (lastCookies[name] === undefined) { - lastCookies[name] = unescape(cookie.substring(index + 1)); - } - } - } - } - return lastCookies; - } - }; - - - /** - * @name $browser#defer - * @param {function()} fn A function, who's execution should be deferred. - * @param {number=} [delay=0] of milliseconds to defer the function execution. - * @returns {*} DeferId that can be used to cancel the task via `$browser.defer.cancel()`. - * - * @description - * Executes a fn asynchronously via `setTimeout(fn, delay)`. - * - * Unlike when calling `setTimeout` directly, in test this function is mocked and instead of using - * `setTimeout` in tests, the fns are queued in an array, which can be programmatically flushed - * via `$browser.defer.flush()`. - * - */ - self.defer = function(fn, delay) { - var timeoutId; - outstandingRequestCount++; - timeoutId = setTimeout(function() { - delete pendingDeferIds[timeoutId]; - completeOutstandingRequest(fn); - }, delay || 0); - pendingDeferIds[timeoutId] = true; - return timeoutId; - }; - - - /** - * @name $browser#defer.cancel - * - * @description - * Cancels a deferred task identified with `deferId`. - * - * @param {*} deferId Token returned by the `$browser.defer` function. - * @returns {boolean} Returns `true` if the task hasn't executed yet and was successfully - * canceled. - */ - self.defer.cancel = function(deferId) { - if (pendingDeferIds[deferId]) { - delete pendingDeferIds[deferId]; - clearTimeout(deferId); - completeOutstandingRequest(noop); - return true; - } - return false; - }; - -} - -function $BrowserProvider(){ - this.$get = ['$window', '$log', '$sniffer', '$document', - function( $window, $log, $sniffer, $document){ - return new Browser($window, $document, $log, $sniffer); - }]; -} - -/** - * @ngdoc service - * @name $cacheFactory - * - * @description - * Factory that constructs {@link $cacheFactory.Cache Cache} objects and gives access to - * them. - * - * ```js - * - * var cache = $cacheFactory('cacheId'); - * expect($cacheFactory.get('cacheId')).toBe(cache); - * expect($cacheFactory.get('noSuchCacheId')).not.toBeDefined(); - * - * cache.put("key", "value"); - * cache.put("another key", "another value"); - * - * // We've specified no options on creation - * expect(cache.info()).toEqual({id: 'cacheId', size: 2}); - * - * ``` - * - * - * @param {string} cacheId Name or id of the newly created cache. - * @param {object=} options Options object that specifies the cache behavior. Properties: - * - * - `{number=}` `capacity` — turns the cache into LRU cache. - * - * @returns {object} Newly created cache object with the following set of methods: - * - * - `{object}` `info()` — Returns id, size, and options of cache. - * - `{{*}}` `put({string} key, {*} value)` — Puts a new key-value pair into the cache and returns - * it. - * - `{{*}}` `get({string} key)` — Returns cached value for `key` or undefined for cache miss. - * - `{void}` `remove({string} key)` — Removes a key-value pair from the cache. - * - `{void}` `removeAll()` — Removes all cached values. - * - `{void}` `destroy()` — Removes references to this cache from $cacheFactory. - * - * @example - - -
- - - - -

Cached Values

-
- - : - -
- -

Cache Info

-
- - : - -
-
-
- - angular.module('cacheExampleApp', []). - controller('CacheController', ['$scope', '$cacheFactory', function($scope, $cacheFactory) { - $scope.keys = []; - $scope.cache = $cacheFactory('cacheId'); - $scope.put = function(key, value) { - if ($scope.cache.get(key) === undefined) { - $scope.keys.push(key); - } - $scope.cache.put(key, value === undefined ? null : value); - }; - }]); - - - p { - margin: 10px 0 3px; - } - -
- */ -function $CacheFactoryProvider() { - - this.$get = function() { - var caches = {}; - - function cacheFactory(cacheId, options) { - if (cacheId in caches) { - throw minErr('$cacheFactory')('iid', "CacheId '{0}' is already taken!", cacheId); - } - - var size = 0, - stats = extend({}, options, {id: cacheId}), - data = {}, - capacity = (options && options.capacity) || Number.MAX_VALUE, - lruHash = {}, - freshEnd = null, - staleEnd = null; - - /** - * @ngdoc type - * @name $cacheFactory.Cache - * - * @description - * A cache object used to store and retrieve data, primarily used by - * {@link $http $http} and the {@link ng.directive:script script} directive to cache - * templates and other data. - * - * ```js - * angular.module('superCache') - * .factory('superCache', ['$cacheFactory', function($cacheFactory) { - * return $cacheFactory('super-cache'); - * }]); - * ``` - * - * Example test: - * - * ```js - * it('should behave like a cache', inject(function(superCache) { - * superCache.put('key', 'value'); - * superCache.put('another key', 'another value'); - * - * expect(superCache.info()).toEqual({ - * id: 'super-cache', - * size: 2 - * }); - * - * superCache.remove('another key'); - * expect(superCache.get('another key')).toBeUndefined(); - * - * superCache.removeAll(); - * expect(superCache.info()).toEqual({ - * id: 'super-cache', - * size: 0 - * }); - * })); - * ``` - */ - return caches[cacheId] = { - - /** - * @ngdoc method - * @name $cacheFactory.Cache#put - * @kind function - * - * @description - * Inserts a named entry into the {@link $cacheFactory.Cache Cache} object to be - * retrieved later, and incrementing the size of the cache if the key was not already - * present in the cache. If behaving like an LRU cache, it will also remove stale - * entries from the set. - * - * It will not insert undefined values into the cache. - * - * @param {string} key the key under which the cached data is stored. - * @param {*} value the value to store alongside the key. If it is undefined, the key - * will not be stored. - * @returns {*} the value stored. - */ - put: function(key, value) { - if (capacity < Number.MAX_VALUE) { - var lruEntry = lruHash[key] || (lruHash[key] = {key: key}); - - refresh(lruEntry); - } - - if (isUndefined(value)) return; - if (!(key in data)) size++; - data[key] = value; - - if (size > capacity) { - this.remove(staleEnd.key); - } - - return value; - }, - - /** - * @ngdoc method - * @name $cacheFactory.Cache#get - * @kind function - * - * @description - * Retrieves named data stored in the {@link $cacheFactory.Cache Cache} object. - * - * @param {string} key the key of the data to be retrieved - * @returns {*} the value stored. - */ - get: function(key) { - if (capacity < Number.MAX_VALUE) { - var lruEntry = lruHash[key]; - - if (!lruEntry) return; - - refresh(lruEntry); - } - - return data[key]; - }, - - - /** - * @ngdoc method - * @name $cacheFactory.Cache#remove - * @kind function - * - * @description - * Removes an entry from the {@link $cacheFactory.Cache Cache} object. - * - * @param {string} key the key of the entry to be removed - */ - remove: function(key) { - if (capacity < Number.MAX_VALUE) { - var lruEntry = lruHash[key]; - - if (!lruEntry) return; - - if (lruEntry == freshEnd) freshEnd = lruEntry.p; - if (lruEntry == staleEnd) staleEnd = lruEntry.n; - link(lruEntry.n,lruEntry.p); - - delete lruHash[key]; - } - - delete data[key]; - size--; - }, - - - /** - * @ngdoc method - * @name $cacheFactory.Cache#removeAll - * @kind function - * - * @description - * Clears the cache object of any entries. - */ - removeAll: function() { - data = {}; - size = 0; - lruHash = {}; - freshEnd = staleEnd = null; - }, - - - /** - * @ngdoc method - * @name $cacheFactory.Cache#destroy - * @kind function - * - * @description - * Destroys the {@link $cacheFactory.Cache Cache} object entirely, - * removing it from the {@link $cacheFactory $cacheFactory} set. - */ - destroy: function() { - data = null; - stats = null; - lruHash = null; - delete caches[cacheId]; - }, - - - /** - * @ngdoc method - * @name $cacheFactory.Cache#info - * @kind function - * - * @description - * Retrieve information regarding a particular {@link $cacheFactory.Cache Cache}. - * - * @returns {object} an object with the following properties: - *
    - *
  • **id**: the id of the cache instance
  • - *
  • **size**: the number of entries kept in the cache instance
  • - *
  • **...**: any additional properties from the options object when creating the - * cache.
  • - *
- */ - info: function() { - return extend({}, stats, {size: size}); - } - }; - - - /** - * makes the `entry` the freshEnd of the LRU linked list - */ - function refresh(entry) { - if (entry != freshEnd) { - if (!staleEnd) { - staleEnd = entry; - } else if (staleEnd == entry) { - staleEnd = entry.n; - } - - link(entry.n, entry.p); - link(entry, freshEnd); - freshEnd = entry; - freshEnd.n = null; - } - } - - - /** - * bidirectionally links two entries of the LRU linked list - */ - function link(nextEntry, prevEntry) { - if (nextEntry != prevEntry) { - if (nextEntry) nextEntry.p = prevEntry; //p stands for previous, 'prev' didn't minify - if (prevEntry) prevEntry.n = nextEntry; //n stands for next, 'next' didn't minify - } - } - } - - - /** - * @ngdoc method - * @name $cacheFactory#info - * - * @description - * Get information about all the caches that have been created - * - * @returns {Object} - key-value map of `cacheId` to the result of calling `cache#info` - */ - cacheFactory.info = function() { - var info = {}; - forEach(caches, function(cache, cacheId) { - info[cacheId] = cache.info(); - }); - return info; - }; - - - /** - * @ngdoc method - * @name $cacheFactory#get - * - * @description - * Get access to a cache object by the `cacheId` used when it was created. - * - * @param {string} cacheId Name or id of a cache to access. - * @returns {object} Cache object identified by the cacheId or undefined if no such cache. - */ - cacheFactory.get = function(cacheId) { - return caches[cacheId]; - }; - - - return cacheFactory; - }; -} - -/** - * @ngdoc service - * @name $templateCache - * - * @description - * The first time a template is used, it is loaded in the template cache for quick retrieval. You - * can load templates directly into the cache in a `script` tag, or by consuming the - * `$templateCache` service directly. - * - * Adding via the `script` tag: - * - * ```html - * - * ``` - * - * **Note:** the `script` tag containing the template does not need to be included in the `head` of - * the document, but it must be below the `ng-app` definition. - * - * Adding via the $templateCache service: - * - * ```js - * var myApp = angular.module('myApp', []); - * myApp.run(function($templateCache) { - * $templateCache.put('templateId.html', 'This is the content of the template'); - * }); - * ``` - * - * To retrieve the template later, simply use it in your HTML: - * ```html - *
- * ``` - * - * or get it via Javascript: - * ```js - * $templateCache.get('templateId.html') - * ``` - * - * See {@link ng.$cacheFactory $cacheFactory}. - * - */ -function $TemplateCacheProvider() { - this.$get = ['$cacheFactory', function($cacheFactory) { - return $cacheFactory('templates'); - }]; -} - -/* ! VARIABLE/FUNCTION NAMING CONVENTIONS THAT APPLY TO THIS FILE! - * - * DOM-related variables: - * - * - "node" - DOM Node - * - "element" - DOM Element or Node - * - "$node" or "$element" - jqLite-wrapped node or element - * - * - * Compiler related stuff: - * - * - "linkFn" - linking fn of a single directive - * - "nodeLinkFn" - function that aggregates all linking fns for a particular node - * - "childLinkFn" - function that aggregates all linking fns for child nodes of a particular node - * - "compositeLinkFn" - function that aggregates all linking fns for a compilation root (nodeList) - */ - - -/** - * @ngdoc service - * @name $compile - * @kind function - * - * @description - * Compiles an HTML string or DOM into a template and produces a template function, which - * can then be used to link {@link ng.$rootScope.Scope `scope`} and the template together. - * - * The compilation is a process of walking the DOM tree and matching DOM elements to - * {@link ng.$compileProvider#directive directives}. - * - *
- * **Note:** This document is an in-depth reference of all directive options. - * For a gentle introduction to directives with examples of common use cases, - * see the {@link guide/directive directive guide}. - *
- * - * ## Comprehensive Directive API - * - * There are many different options for a directive. - * - * The difference resides in the return value of the factory function. - * You can either return a "Directive Definition Object" (see below) that defines the directive properties, - * or just the `postLink` function (all other properties will have the default values). - * - *
- * **Best Practice:** It's recommended to use the "directive definition object" form. - *
- * - * Here's an example directive declared with a Directive Definition Object: - * - * ```js - * var myModule = angular.module(...); - * - * myModule.directive('directiveName', function factory(injectables) { - * var directiveDefinitionObject = { - * priority: 0, - * template: '
', // or // function(tElement, tAttrs) { ... }, - * // or - * // templateUrl: 'directive.html', // or // function(tElement, tAttrs) { ... }, - * transclude: false, - * restrict: 'A', - * scope: false, - * controller: function($scope, $element, $attrs, $transclude, otherInjectables) { ... }, - * controllerAs: 'stringAlias', - * require: 'siblingDirectiveName', // or // ['^parentDirectiveName', '?optionalDirectiveName', '?^optionalParent'], - * compile: function compile(tElement, tAttrs, transclude) { - * return { - * pre: function preLink(scope, iElement, iAttrs, controller) { ... }, - * post: function postLink(scope, iElement, iAttrs, controller) { ... } - * } - * // or - * // return function postLink( ... ) { ... } - * }, - * // or - * // link: { - * // pre: function preLink(scope, iElement, iAttrs, controller) { ... }, - * // post: function postLink(scope, iElement, iAttrs, controller) { ... } - * // } - * // or - * // link: function postLink( ... ) { ... } - * }; - * return directiveDefinitionObject; - * }); - * ``` - * - *
- * **Note:** Any unspecified options will use the default value. You can see the default values below. - *
- * - * Therefore the above can be simplified as: - * - * ```js - * var myModule = angular.module(...); - * - * myModule.directive('directiveName', function factory(injectables) { - * var directiveDefinitionObject = { - * link: function postLink(scope, iElement, iAttrs) { ... } - * }; - * return directiveDefinitionObject; - * // or - * // return function postLink(scope, iElement, iAttrs) { ... } - * }); - * ``` - * - * - * - * ### Directive Definition Object - * - * The directive definition object provides instructions to the {@link ng.$compile - * compiler}. The attributes are: - * - * #### `priority` - * When there are multiple directives defined on a single DOM element, sometimes it - * is necessary to specify the order in which the directives are applied. The `priority` is used - * to sort the directives before their `compile` functions get called. Priority is defined as a - * number. Directives with greater numerical `priority` are compiled first. Pre-link functions - * are also run in priority order, but post-link functions are run in reverse order. The order - * of directives with the same priority is undefined. The default priority is `0`. - * - * #### `terminal` - * If set to true then the current `priority` will be the last set of directives - * which will execute (any directives at the current priority will still execute - * as the order of execution on same `priority` is undefined). - * - * #### `scope` - * **If set to `true`,** then a new scope will be created for this directive. If multiple directives on the - * same element request a new scope, only one new scope is created. The new scope rule does not - * apply for the root of the template since the root of the template always gets a new scope. - * - * **If set to `{}` (object hash),** then a new "isolate" scope is created. The 'isolate' scope differs from - * normal scope in that it does not prototypically inherit from the parent scope. This is useful - * when creating reusable components, which should not accidentally read or modify data in the - * parent scope. - * - * The 'isolate' scope takes an object hash which defines a set of local scope properties - * derived from the parent scope. These local properties are useful for aliasing values for - * templates. Locals definition is a hash of local scope property to its source: - * - * * `@` or `@attr` - bind a local scope property to the value of DOM attribute. The result is - * always a string since DOM attributes are strings. If no `attr` name is specified then the - * attribute name is assumed to be the same as the local name. - * Given `` and widget definition - * of `scope: { localName:'@myAttr' }`, then widget scope property `localName` will reflect - * the interpolated value of `hello {{name}}`. As the `name` attribute changes so will the - * `localName` property on the widget scope. The `name` is read from the parent scope (not - * component scope). - * - * * `=` or `=attr` - set up bi-directional binding between a local scope property and the - * parent scope property of name defined via the value of the `attr` attribute. If no `attr` - * name is specified then the attribute name is assumed to be the same as the local name. - * Given `` and widget definition of - * `scope: { localModel:'=myAttr' }`, then widget scope property `localModel` will reflect the - * value of `parentModel` on the parent scope. Any changes to `parentModel` will be reflected - * in `localModel` and any changes in `localModel` will reflect in `parentModel`. If the parent - * scope property doesn't exist, it will throw a NON_ASSIGNABLE_MODEL_EXPRESSION exception. You - * can avoid this behavior using `=?` or `=?attr` in order to flag the property as optional. - * - * * `&` or `&attr` - provides a way to execute an expression in the context of the parent scope. - * If no `attr` name is specified then the attribute name is assumed to be the same as the - * local name. Given `` and widget definition of - * `scope: { localFn:'&myAttr' }`, then isolate scope property `localFn` will point to - * a function wrapper for the `count = count + value` expression. Often it's desirable to - * pass data from the isolated scope via an expression to the parent scope, this can be - * done by passing a map of local variable names and values into the expression wrapper fn. - * For example, if the expression is `increment(amount)` then we can specify the amount value - * by calling the `localFn` as `localFn({amount: 22})`. - * - * - * - * #### `controller` - * Controller constructor function. The controller is instantiated before the - * pre-linking phase and it is shared with other directives (see - * `require` attribute). This allows the directives to communicate with each other and augment - * each other's behavior. The controller is injectable (and supports bracket notation) with the following locals: - * - * * `$scope` - Current scope associated with the element - * * `$element` - Current element - * * `$attrs` - Current attributes object for the element - * * `$transclude` - A transclude linking function pre-bound to the correct transclusion scope. - * The scope can be overridden by an optional first argument. - * `function([scope], cloneLinkingFn)`. - * - * - * #### `require` - * Require another directive and inject its controller as the fourth argument to the linking function. The - * `require` takes a string name (or array of strings) of the directive(s) to pass in. If an array is used, the - * injected argument will be an array in corresponding order. If no such directive can be - * found, or if the directive does not have a controller, then an error is raised. The name can be prefixed with: - * - * * (no prefix) - Locate the required controller on the current element. Throw an error if not found. - * * `?` - Attempt to locate the required controller or pass `null` to the `link` fn if not found. - * * `^` - Locate the required controller by searching the element and its parents. Throw an error if not found. - * * `?^` - Attempt to locate the required controller by searching the element and its parents or pass - * `null` to the `link` fn if not found. - * - * - * #### `controllerAs` - * Controller alias at the directive scope. An alias for the controller so it - * can be referenced at the directive template. The directive needs to define a scope for this - * configuration to be used. Useful in the case when directive is used as component. - * - * - * #### `restrict` - * String of subset of `EACM` which restricts the directive to a specific directive - * declaration style. If omitted, the default (attributes only) is used. - * - * * `E` - Element name: `` - * * `A` - Attribute (default): `
` - * * `C` - Class: `
` - * * `M` - Comment: `` - * - * - * #### `template` - * HTML markup that may: - * * Replace the contents of the directive's element (default). - * * Replace the directive's element itself (if `replace` is true - DEPRECATED). - * * Wrap the contents of the directive's element (if `transclude` is true). - * - * Value may be: - * - * * A string. For example `
{{delete_str}}
`. - * * A function which takes two arguments `tElement` and `tAttrs` (described in the `compile` - * function api below) and returns a string value. - * - * - * #### `templateUrl` - * Same as `template` but the template is loaded from the specified URL. Because - * the template loading is asynchronous the compilation/linking is suspended until the template - * is loaded. - * - * You can specify `templateUrl` as a string representing the URL or as a function which takes two - * arguments `tElement` and `tAttrs` (described in the `compile` function api below) and returns - * a string value representing the url. In either case, the template URL is passed through {@link - * api/ng.$sce#getTrustedResourceUrl $sce.getTrustedResourceUrl}. - * - * - * #### `replace` ([*DEPRECATED*!], will be removed in next major release) - * specify what the template should replace. Defaults to `false`. - * - * * `true` - the template will replace the directive's element. - * * `false` - the template will replace the contents of the directive's element. - * - * The replacement process migrates all of the attributes / classes from the old element to the new - * one. See the {@link guide/directive#creating-custom-directives_creating-directives_template-expanding-directive - * Directives Guide} for an example. - * - * #### `transclude` - * compile the content of the element and make it available to the directive. - * Typically used with {@link ng.directive:ngTransclude - * ngTransclude}. The advantage of transclusion is that the linking function receives a - * transclusion function which is pre-bound to the correct scope. In a typical setup the widget - * creates an `isolate` scope, but the transclusion is not a child, but a sibling of the `isolate` - * scope. This makes it possible for the widget to have private state, and the transclusion to - * be bound to the parent (pre-`isolate`) scope. - * - * * `true` - transclude the content of the directive. - * * `'element'` - transclude the whole element including any directives defined at lower priority. - * - *
- * **Note:** When testing an element transclude directive you must not place the directive at the root of the - * DOM fragment that is being compiled. See {@link guide/unit-testing#testing-transclusion-directives - * Testing Transclusion Directives}. - *
- * - * #### `compile` - * - * ```js - * function compile(tElement, tAttrs, transclude) { ... } - * ``` - * - * The compile function deals with transforming the template DOM. Since most directives do not do - * template transformation, it is not used often. The compile function takes the following arguments: - * - * * `tElement` - template element - The element where the directive has been declared. It is - * safe to do template transformation on the element and child elements only. - * - * * `tAttrs` - template attributes - Normalized list of attributes declared on this element shared - * between all directive compile functions. - * - * * `transclude` - [*DEPRECATED*!] A transclude linking function: `function(scope, cloneLinkingFn)` - * - *
- * **Note:** The template instance and the link instance may be different objects if the template has - * been cloned. For this reason it is **not** safe to do anything other than DOM transformations that - * apply to all cloned DOM nodes within the compile function. Specifically, DOM listener registration - * should be done in a linking function rather than in a compile function. - *
- - *
- * **Note:** The compile function cannot handle directives that recursively use themselves in their - * own templates or compile functions. Compiling these directives results in an infinite loop and a - * stack overflow errors. - * - * This can be avoided by manually using $compile in the postLink function to imperatively compile - * a directive's template instead of relying on automatic template compilation via `template` or - * `templateUrl` declaration or manual compilation inside the compile function. - *
- * - *
- * **Note:** The `transclude` function that is passed to the compile function is deprecated, as it - * e.g. does not know about the right outer scope. Please use the transclude function that is passed - * to the link function instead. - *
- - * A compile function can have a return value which can be either a function or an object. - * - * * returning a (post-link) function - is equivalent to registering the linking function via the - * `link` property of the config object when the compile function is empty. - * - * * returning an object with function(s) registered via `pre` and `post` properties - allows you to - * control when a linking function should be called during the linking phase. See info about - * pre-linking and post-linking functions below. - * - * - * #### `link` - * This property is used only if the `compile` property is not defined. - * - * ```js - * function link(scope, iElement, iAttrs, controller, transcludeFn) { ... } - * ``` - * - * The link function is responsible for registering DOM listeners as well as updating the DOM. It is - * executed after the template has been cloned. This is where most of the directive logic will be - * put. - * - * * `scope` - {@link ng.$rootScope.Scope Scope} - The scope to be used by the - * directive for registering {@link ng.$rootScope.Scope#$watch watches}. - * - * * `iElement` - instance element - The element where the directive is to be used. It is safe to - * manipulate the children of the element only in `postLink` function since the children have - * already been linked. - * - * * `iAttrs` - instance attributes - Normalized list of attributes declared on this element shared - * between all directive linking functions. - * - * * `controller` - a controller instance - A controller instance if at least one directive on the - * element defines a controller. The controller is shared among all the directives, which allows - * the directives to use the controllers as a communication channel. - * - * * `transcludeFn` - A transclude linking function pre-bound to the correct transclusion scope. - * The scope can be overridden by an optional first argument. This is the same as the `$transclude` - * parameter of directive controllers. - * `function([scope], cloneLinkingFn)`. - * - * - * #### Pre-linking function - * - * Executed before the child elements are linked. Not safe to do DOM transformation since the - * compiler linking function will fail to locate the correct elements for linking. - * - * #### Post-linking function - * - * Executed after the child elements are linked. It is safe to do DOM transformation in the post-linking function. - * - * - * ### Attributes - * - * The {@link ng.$compile.directive.Attributes Attributes} object - passed as a parameter in the - * `link()` or `compile()` functions. It has a variety of uses. - * - * accessing *Normalized attribute names:* - * Directives like 'ngBind' can be expressed in many ways: 'ng:bind', `data-ng-bind`, or 'x-ng-bind'. - * the attributes object allows for normalized access to - * the attributes. - * - * * *Directive inter-communication:* All directives share the same instance of the attributes - * object which allows the directives to use the attributes object as inter directive - * communication. - * - * * *Supports interpolation:* Interpolation attributes are assigned to the attribute object - * allowing other directives to read the interpolated value. - * - * * *Observing interpolated attributes:* Use `$observe` to observe the value changes of attributes - * that contain interpolation (e.g. `src="http://github.com/%7B%7Bbar%7D%7D"`). Not only is this very efficient but it's also - * the only way to easily get the actual value because during the linking phase the interpolation - * hasn't been evaluated yet and so the value is at this time set to `undefined`. - * - * ```js - * function linkingFn(scope, elm, attrs, ctrl) { - * // get the attribute value - * console.log(attrs.ngModel); - * - * // change the attribute - * attrs.$set('ngModel', 'new value'); - * - * // observe changes to interpolated attribute - * attrs.$observe('ngModel', function(value) { - * console.log('ngModel has changed value to ' + value); - * }); - * } - * ``` - * - * Below is an example using `$compileProvider`. - * - *
- * **Note**: Typically directives are registered with `module.directive`. The example below is - * to illustrate how `$compile` works. - *
- * - - - -
-
-
-
-
-
- - it('should auto compile', function() { - var textarea = $('textarea'); - var output = $('div[compile]'); - // The initial state reads 'Hello Angular'. - expect(output.getText()).toBe('Hello Angular'); - textarea.clear(); - textarea.sendKeys('{{name}}!'); - expect(output.getText()).toBe('Angular!'); - }); - -
- - * - * - * @param {string|DOMElement} element Element or HTML string to compile into a template function. - * @param {function(angular.Scope, cloneAttachFn=)} transclude function available to directives. - * @param {number} maxPriority only apply directives lower than given priority (Only effects the - * root element(s), not their children) - * @returns {function(scope, cloneAttachFn=)} a link function which is used to bind template - * (a DOM element/tree) to a scope. Where: - * - * * `scope` - A {@link ng.$rootScope.Scope Scope} to bind to. - * * `cloneAttachFn` - If `cloneAttachFn` is provided, then the link function will clone the - * `template` and call the `cloneAttachFn` function allowing the caller to attach the - * cloned elements to the DOM document at the appropriate place. The `cloneAttachFn` is - * called as:
`cloneAttachFn(clonedElement, scope)` where: - * - * * `clonedElement` - is a clone of the original `element` passed into the compiler. - * * `scope` - is the current scope with which the linking function is working with. - * - * Calling the linking function returns the element of the template. It is either the original - * element passed in, or the clone of the element if the `cloneAttachFn` is provided. - * - * After linking the view is not updated until after a call to $digest which typically is done by - * Angular automatically. - * - * If you need access to the bound view, there are two ways to do it: - * - * - If you are not asking the linking function to clone the template, create the DOM element(s) - * before you send them to the compiler and keep this reference around. - * ```js - * var element = $compile('

{{total}}

')(scope); - * ``` - * - * - if on the other hand, you need the element to be cloned, the view reference from the original - * example would not point to the clone, but rather to the original template that was cloned. In - * this case, you can access the clone via the cloneAttachFn: - * ```js - * var templateElement = angular.element('

{{total}}

'), - * scope = ....; - * - * var clonedElement = $compile(templateElement)(scope, function(clonedElement, scope) { - * //attach the clone to DOM document at the right place - * }); - * - * //now we have reference to the cloned DOM via `clonedElement` - * ``` - * - * - * For information on how the compiler works, see the - * {@link guide/compiler Angular HTML Compiler} section of the Developer Guide. - */ - -var $compileMinErr = minErr('$compile'); - -/** - * @ngdoc provider - * @name $compileProvider - * @kind function - * - * @description - */ -$CompileProvider.$inject = ['$provide', '$$sanitizeUriProvider']; -function $CompileProvider($provide, $$sanitizeUriProvider) { - var hasDirectives = {}, - Suffix = 'Directive', - COMMENT_DIRECTIVE_REGEXP = /^\s*directive\:\s*([\d\w_\-]+)\s+(.*)$/, - CLASS_DIRECTIVE_REGEXP = /(([\d\w_\-]+)(?:\:([^;]+))?;?)/; - - // Ref: http://developers.whatwg.org/webappapis.html#event-handler-idl-attributes - // The assumption is that future DOM event attribute names will begin with - // 'on' and be composed of only English letters. - var EVENT_HANDLER_ATTR_REGEXP = /^(on[a-z]+|formaction)$/; - - /** - * @ngdoc method - * @name $compileProvider#directive - * @kind function - * - * @description - * Register a new directive with the compiler. - * - * @param {string|Object} name Name of the directive in camel-case (i.e. ngBind which - * will match as ng-bind), or an object map of directives where the keys are the - * names and the values are the factories. - * @param {Function|Array} directiveFactory An injectable directive factory function. See - * {@link guide/directive} for more info. - * @returns {ng.$compileProvider} Self for chaining. - */ - this.directive = function registerDirective(name, directiveFactory) { - assertNotHasOwnProperty(name, 'directive'); - if (isString(name)) { - assertArg(directiveFactory, 'directiveFactory'); - if (!hasDirectives.hasOwnProperty(name)) { - hasDirectives[name] = []; - $provide.factory(name + Suffix, ['$injector', '$exceptionHandler', - function($injector, $exceptionHandler) { - var directives = []; - forEach(hasDirectives[name], function(directiveFactory, index) { - try { - var directive = $injector.invoke(directiveFactory); - if (isFunction(directive)) { - directive = { compile: valueFn(directive) }; - } else if (!directive.compile && directive.link) { - directive.compile = valueFn(directive.link); - } - directive.priority = directive.priority || 0; - directive.index = index; - directive.name = directive.name || name; - directive.require = directive.require || (directive.controller && directive.name); - directive.restrict = directive.restrict || 'A'; - directives.push(directive); - } catch (e) { - $exceptionHandler(e); - } - }); - return directives; - }]); - } - hasDirectives[name].push(directiveFactory); - } else { - forEach(name, reverseParams(registerDirective)); - } - return this; - }; - - - /** - * @ngdoc method - * @name $compileProvider#aHrefSanitizationWhitelist - * @kind function - * - * @description - * Retrieves or overrides the default regular expression that is used for whitelisting of safe - * urls during a[href] sanitization. - * - * The sanitization is a security measure aimed at prevent XSS attacks via html links. - * - * Any url about to be assigned to a[href] via data-binding is first normalized and turned into - * an absolute url. Afterwards, the url is matched against the `aHrefSanitizationWhitelist` - * regular expression. If a match is found, the original url is written into the dom. Otherwise, - * the absolute url is prefixed with `'unsafe:'` string and only then is it written into the DOM. - * - * @param {RegExp=} regexp New regexp to whitelist urls with. - * @returns {RegExp|ng.$compileProvider} Current RegExp if called without value or self for - * chaining otherwise. - */ - this.aHrefSanitizationWhitelist = function(regexp) { - if (isDefined(regexp)) { - $$sanitizeUriProvider.aHrefSanitizationWhitelist(regexp); - return this; - } else { - return $$sanitizeUriProvider.aHrefSanitizationWhitelist(); - } - }; - - - /** - * @ngdoc method - * @name $compileProvider#imgSrcSanitizationWhitelist - * @kind function - * - * @description - * Retrieves or overrides the default regular expression that is used for whitelisting of safe - * urls during img[src] sanitization. - * - * The sanitization is a security measure aimed at prevent XSS attacks via html links. - * - * Any url about to be assigned to img[src] via data-binding is first normalized and turned into - * an absolute url. Afterwards, the url is matched against the `imgSrcSanitizationWhitelist` - * regular expression. If a match is found, the original url is written into the dom. Otherwise, - * the absolute url is prefixed with `'unsafe:'` string and only then is it written into the DOM. - * - * @param {RegExp=} regexp New regexp to whitelist urls with. - * @returns {RegExp|ng.$compileProvider} Current RegExp if called without value or self for - * chaining otherwise. - */ - this.imgSrcSanitizationWhitelist = function(regexp) { - if (isDefined(regexp)) { - $$sanitizeUriProvider.imgSrcSanitizationWhitelist(regexp); - return this; - } else { - return $$sanitizeUriProvider.imgSrcSanitizationWhitelist(); - } - }; - - this.$get = [ - '$injector', '$interpolate', '$exceptionHandler', '$http', '$templateCache', '$parse', - '$controller', '$rootScope', '$document', '$sce', '$animate', '$$sanitizeUri', - function($injector, $interpolate, $exceptionHandler, $http, $templateCache, $parse, - $controller, $rootScope, $document, $sce, $animate, $$sanitizeUri) { - - var Attributes = function(element, attr) { - this.$$element = element; - this.$attr = attr || {}; - }; - - Attributes.prototype = { - $normalize: directiveNormalize, - - - /** - * @ngdoc method - * @name $compile.directive.Attributes#$addClass - * @kind function - * - * @description - * Adds the CSS class value specified by the classVal parameter to the element. If animations - * are enabled then an animation will be triggered for the class addition. - * - * @param {string} classVal The className value that will be added to the element - */ - $addClass : function(classVal) { - if(classVal && classVal.length > 0) { - $animate.addClass(this.$$element, classVal); - } - }, - - /** - * @ngdoc method - * @name $compile.directive.Attributes#$removeClass - * @kind function - * - * @description - * Removes the CSS class value specified by the classVal parameter from the element. If - * animations are enabled then an animation will be triggered for the class removal. - * - * @param {string} classVal The className value that will be removed from the element - */ - $removeClass : function(classVal) { - if(classVal && classVal.length > 0) { - $animate.removeClass(this.$$element, classVal); - } - }, - - /** - * @ngdoc method - * @name $compile.directive.Attributes#$updateClass - * @kind function - * - * @description - * Adds and removes the appropriate CSS class values to the element based on the difference - * between the new and old CSS class values (specified as newClasses and oldClasses). - * - * @param {string} newClasses The current CSS className value - * @param {string} oldClasses The former CSS className value - */ - $updateClass : function(newClasses, oldClasses) { - var toAdd = tokenDifference(newClasses, oldClasses); - var toRemove = tokenDifference(oldClasses, newClasses); - - if(toAdd.length === 0) { - $animate.removeClass(this.$$element, toRemove); - } else if(toRemove.length === 0) { - $animate.addClass(this.$$element, toAdd); - } else { - $animate.setClass(this.$$element, toAdd, toRemove); - } - }, - - /** - * Set a normalized attribute on the element in a way such that all directives - * can share the attribute. This function properly handles boolean attributes. - * @param {string} key Normalized key. (ie ngAttribute) - * @param {string|boolean} value The value to set. If `null` attribute will be deleted. - * @param {boolean=} writeAttr If false, does not write the value to DOM element attribute. - * Defaults to true. - * @param {string=} attrName Optional none normalized name. Defaults to key. - */ - $set: function(key, value, writeAttr, attrName) { - // TODO: decide whether or not to throw an error if "class" - //is set through this function since it may cause $updateClass to - //become unstable. - - var booleanKey = getBooleanAttrName(this.$$element[0], key), - normalizedVal, - nodeName; - - if (booleanKey) { - this.$$element.prop(key, value); - attrName = booleanKey; - } - - this[key] = value; - - // translate normalized key to actual key - if (attrName) { - this.$attr[key] = attrName; - } else { - attrName = this.$attr[key]; - if (!attrName) { - this.$attr[key] = attrName = snake_case(key, '-'); - } - } - - nodeName = nodeName_(this.$$element); - - // sanitize a[href] and img[src] values - if ((nodeName === 'A' && key === 'href') || - (nodeName === 'IMG' && key === 'src')) { - this[key] = value = $$sanitizeUri(value, key === 'src'); - } - - if (writeAttr !== false) { - if (value === null || value === undefined) { - this.$$element.removeAttr(attrName); - } else { - this.$$element.attr(attrName, value); - } - } - - // fire observers - var $$observers = this.$$observers; - $$observers && forEach($$observers[key], function(fn) { - try { - fn(value); - } catch (e) { - $exceptionHandler(e); - } - }); - }, - - - /** - * @ngdoc method - * @name $compile.directive.Attributes#$observe - * @kind function - * - * @description - * Observes an interpolated attribute. - * - * The observer function will be invoked once during the next `$digest` following - * compilation. The observer is then invoked whenever the interpolated value - * changes. - * - * @param {string} key Normalized key. (ie ngAttribute) . - * @param {function(interpolatedValue)} fn Function that will be called whenever - the interpolated value of the attribute changes. - * See the {@link guide/directive#Attributes Directives} guide for more info. - * @returns {function()} the `fn` parameter. - */ - $observe: function(key, fn) { - var attrs = this, - $$observers = (attrs.$$observers || (attrs.$$observers = {})), - listeners = ($$observers[key] || ($$observers[key] = [])); - - listeners.push(fn); - $rootScope.$evalAsync(function() { - if (!listeners.$$inter) { - // no one registered attribute interpolation function, so lets call it manually - fn(attrs[key]); - } - }); - return fn; - } - }; - - var startSymbol = $interpolate.startSymbol(), - endSymbol = $interpolate.endSymbol(), - denormalizeTemplate = (startSymbol == '{{' || endSymbol == '}}') - ? identity - : function denormalizeTemplate(template) { - return template.replace(/\{\{/g, startSymbol).replace(/}}/g, endSymbol); - }, - NG_ATTR_BINDING = /^ngAttr[A-Z]/; - - - return compile; - - //================================ - - function compile($compileNodes, transcludeFn, maxPriority, ignoreDirective, - previousCompileContext) { - if (!($compileNodes instanceof jqLite)) { - // jquery always rewraps, whereas we need to preserve the original selector so that we can - // modify it. - $compileNodes = jqLite($compileNodes); - } - // We can not compile top level text elements since text nodes can be merged and we will - // not be able to attach scope data to them, so we will wrap them in - forEach($compileNodes, function(node, index){ - if (node.nodeType == 3 /* text node */ && node.nodeValue.match(/\S+/) /* non-empty */ ) { - $compileNodes[index] = node = jqLite(node).wrap('').parent()[0]; - } - }); - var compositeLinkFn = - compileNodes($compileNodes, transcludeFn, $compileNodes, - maxPriority, ignoreDirective, previousCompileContext); - safeAddClass($compileNodes, 'ng-scope'); - return function publicLinkFn(scope, cloneConnectFn, transcludeControllers, parentBoundTranscludeFn){ - assertArg(scope, 'scope'); - // important!!: we must call our jqLite.clone() since the jQuery one is trying to be smart - // and sometimes changes the structure of the DOM. - var $linkNode = cloneConnectFn - ? JQLitePrototype.clone.call($compileNodes) // IMPORTANT!!! - : $compileNodes; - - forEach(transcludeControllers, function(instance, name) { - $linkNode.data('$' + name + 'Controller', instance); - }); - - // Attach scope only to non-text nodes. - for(var i = 0, ii = $linkNode.length; i - addDirective(directives, - directiveNormalize(nodeName_(node).toLowerCase()), 'E', maxPriority, ignoreDirective); - - // iterate over the attributes - for (var attr, name, nName, ngAttrName, value, isNgAttr, nAttrs = node.attributes, - j = 0, jj = nAttrs && nAttrs.length; j < jj; j++) { - var attrStartName = false; - var attrEndName = false; - - attr = nAttrs[j]; - if (!msie || msie >= 8 || attr.specified) { - name = attr.name; - value = trim(attr.value); - - // support ngAttr attribute binding - ngAttrName = directiveNormalize(name); - if (isNgAttr = NG_ATTR_BINDING.test(ngAttrName)) { - name = snake_case(ngAttrName.substr(6), '-'); - } - - var directiveNName = ngAttrName.replace(/(Start|End)$/, ''); - if (ngAttrName === directiveNName + 'Start') { - attrStartName = name; - attrEndName = name.substr(0, name.length - 5) + 'end'; - name = name.substr(0, name.length - 6); - } - - nName = directiveNormalize(name.toLowerCase()); - attrsMap[nName] = name; - if (isNgAttr || !attrs.hasOwnProperty(nName)) { - attrs[nName] = value; - if (getBooleanAttrName(node, nName)) { - attrs[nName] = true; // presence means true - } - } - addAttrInterpolateDirective(node, directives, value, nName); - addDirective(directives, nName, 'A', maxPriority, ignoreDirective, attrStartName, - attrEndName); - } - } - - // use class as directive - className = node.className; - if (isString(className) && className !== '') { - while (match = CLASS_DIRECTIVE_REGEXP.exec(className)) { - nName = directiveNormalize(match[2]); - if (addDirective(directives, nName, 'C', maxPriority, ignoreDirective)) { - attrs[nName] = trim(match[3]); - } - className = className.substr(match.index + match[0].length); - } - } - break; - case 3: /* Text Node */ - addTextInterpolateDirective(directives, node.nodeValue); - break; - case 8: /* Comment */ - try { - match = COMMENT_DIRECTIVE_REGEXP.exec(node.nodeValue); - if (match) { - nName = directiveNormalize(match[1]); - if (addDirective(directives, nName, 'M', maxPriority, ignoreDirective)) { - attrs[nName] = trim(match[2]); - } - } - } catch (e) { - // turns out that under some circumstances IE9 throws errors when one attempts to read - // comment's node value. - // Just ignore it and continue. (Can't seem to reproduce in test case.) - } - break; - } - - directives.sort(byPriority); - return directives; - } - - /** - * Given a node with an directive-start it collects all of the siblings until it finds - * directive-end. - * @param node - * @param attrStart - * @param attrEnd - * @returns {*} - */ - function groupScan(node, attrStart, attrEnd) { - var nodes = []; - var depth = 0; - if (attrStart && node.hasAttribute && node.hasAttribute(attrStart)) { - var startNode = node; - do { - if (!node) { - throw $compileMinErr('uterdir', - "Unterminated attribute, found '{0}' but no matching '{1}' found.", - attrStart, attrEnd); - } - if (node.nodeType == 1 /** Element **/) { - if (node.hasAttribute(attrStart)) depth++; - if (node.hasAttribute(attrEnd)) depth--; - } - nodes.push(node); - node = node.nextSibling; - } while (depth > 0); - } else { - nodes.push(node); - } - - return jqLite(nodes); - } - - /** - * Wrapper for linking function which converts normal linking function into a grouped - * linking function. - * @param linkFn - * @param attrStart - * @param attrEnd - * @returns {Function} - */ - function groupElementsLinkFnWrapper(linkFn, attrStart, attrEnd) { - return function(scope, element, attrs, controllers, transcludeFn) { - element = groupScan(element[0], attrStart, attrEnd); - return linkFn(scope, element, attrs, controllers, transcludeFn); - }; - } - - /** - * Once the directives have been collected, their compile functions are executed. This method - * is responsible for inlining directive templates as well as terminating the application - * of the directives if the terminal directive has been reached. - * - * @param {Array} directives Array of collected directives to execute their compile function. - * this needs to be pre-sorted by priority order. - * @param {Node} compileNode The raw DOM node to apply the compile functions to - * @param {Object} templateAttrs The shared attribute function - * @param {function(angular.Scope, cloneAttachFn=)} transcludeFn A linking function, where the - * scope argument is auto-generated to the new - * child of the transcluded parent scope. - * @param {JQLite} jqCollection If we are working on the root of the compile tree then this - * argument has the root jqLite array so that we can replace nodes - * on it. - * @param {Object=} originalReplaceDirective An optional directive that will be ignored when - * compiling the transclusion. - * @param {Array.} preLinkFns - * @param {Array.} postLinkFns - * @param {Object} previousCompileContext Context used for previous compilation of the current - * node - * @returns {Function} linkFn - */ - function applyDirectivesToNode(directives, compileNode, templateAttrs, transcludeFn, - jqCollection, originalReplaceDirective, preLinkFns, postLinkFns, - previousCompileContext) { - previousCompileContext = previousCompileContext || {}; - - var terminalPriority = -Number.MAX_VALUE, - newScopeDirective, - controllerDirectives = previousCompileContext.controllerDirectives, - newIsolateScopeDirective = previousCompileContext.newIsolateScopeDirective, - templateDirective = previousCompileContext.templateDirective, - nonTlbTranscludeDirective = previousCompileContext.nonTlbTranscludeDirective, - hasTranscludeDirective = false, - hasTemplate = false, - hasElementTranscludeDirective = previousCompileContext.hasElementTranscludeDirective, - $compileNode = templateAttrs.$$element = jqLite(compileNode), - directive, - directiveName, - $template, - replaceDirective = originalReplaceDirective, - childTranscludeFn = transcludeFn, - linkFn, - directiveValue; - - // executes all directives on the current element - for(var i = 0, ii = directives.length; i < ii; i++) { - directive = directives[i]; - var attrStart = directive.$$start; - var attrEnd = directive.$$end; - - // collect multiblock sections - if (attrStart) { - $compileNode = groupScan(compileNode, attrStart, attrEnd); - } - $template = undefined; - - if (terminalPriority > directive.priority) { - break; // prevent further processing of directives - } - - if (directiveValue = directive.scope) { - newScopeDirective = newScopeDirective || directive; - - // skip the check for directives with async templates, we'll check the derived sync - // directive when the template arrives - if (!directive.templateUrl) { - assertNoDuplicate('new/isolated scope', newIsolateScopeDirective, directive, - $compileNode); - if (isObject(directiveValue)) { - newIsolateScopeDirective = directive; - } - } - } - - directiveName = directive.name; - - if (!directive.templateUrl && directive.controller) { - directiveValue = directive.controller; - controllerDirectives = controllerDirectives || {}; - assertNoDuplicate("'" + directiveName + "' controller", - controllerDirectives[directiveName], directive, $compileNode); - controllerDirectives[directiveName] = directive; - } - - if (directiveValue = directive.transclude) { - hasTranscludeDirective = true; - - // Special case ngIf and ngRepeat so that we don't complain about duplicate transclusion. - // This option should only be used by directives that know how to safely handle element transclusion, - // where the transcluded nodes are added or replaced after linking. - if (!directive.$$tlb) { - assertNoDuplicate('transclusion', nonTlbTranscludeDirective, directive, $compileNode); - nonTlbTranscludeDirective = directive; - } - - if (directiveValue == 'element') { - hasElementTranscludeDirective = true; - terminalPriority = directive.priority; - $template = $compileNode; - $compileNode = templateAttrs.$$element = - jqLite(document.createComment(' ' + directiveName + ': ' + - templateAttrs[directiveName] + ' ')); - compileNode = $compileNode[0]; - replaceWith(jqCollection, sliceArgs($template), compileNode); - - childTranscludeFn = compile($template, transcludeFn, terminalPriority, - replaceDirective && replaceDirective.name, { - // Don't pass in: - // - controllerDirectives - otherwise we'll create duplicates controllers - // - newIsolateScopeDirective or templateDirective - combining templates with - // element transclusion doesn't make sense. - // - // We need only nonTlbTranscludeDirective so that we prevent putting transclusion - // on the same element more than once. - nonTlbTranscludeDirective: nonTlbTranscludeDirective - }); - } else { - $template = jqLite(jqLiteClone(compileNode)).contents(); - $compileNode.empty(); // clear contents - childTranscludeFn = compile($template, transcludeFn); - } - } - - if (directive.template) { - hasTemplate = true; - assertNoDuplicate('template', templateDirective, directive, $compileNode); - templateDirective = directive; - - directiveValue = (isFunction(directive.template)) - ? directive.template($compileNode, templateAttrs) - : directive.template; - - directiveValue = denormalizeTemplate(directiveValue); - - if (directive.replace) { - replaceDirective = directive; - if (jqLiteIsTextNode(directiveValue)) { - $template = []; - } else { - $template = jqLite(trim(directiveValue)); - } - compileNode = $template[0]; - - if ($template.length != 1 || compileNode.nodeType !== 1) { - throw $compileMinErr('tplrt', - "Template for directive '{0}' must have exactly one root element. {1}", - directiveName, ''); - } - - replaceWith(jqCollection, $compileNode, compileNode); - - var newTemplateAttrs = {$attr: {}}; - - // combine directives from the original node and from the template: - // - take the array of directives for this element - // - split it into two parts, those that already applied (processed) and those that weren't (unprocessed) - // - collect directives from the template and sort them by priority - // - combine directives as: processed + template + unprocessed - var templateDirectives = collectDirectives(compileNode, [], newTemplateAttrs); - var unprocessedDirectives = directives.splice(i + 1, directives.length - (i + 1)); - - if (newIsolateScopeDirective) { - markDirectivesAsIsolate(templateDirectives); - } - directives = directives.concat(templateDirectives).concat(unprocessedDirectives); - mergeTemplateAttributes(templateAttrs, newTemplateAttrs); - - ii = directives.length; - } else { - $compileNode.html(directiveValue); - } - } - - if (directive.templateUrl) { - hasTemplate = true; - assertNoDuplicate('template', templateDirective, directive, $compileNode); - templateDirective = directive; - - if (directive.replace) { - replaceDirective = directive; - } - - nodeLinkFn = compileTemplateUrl(directives.splice(i, directives.length - i), $compileNode, - templateAttrs, jqCollection, hasTranscludeDirective && childTranscludeFn, preLinkFns, postLinkFns, { - controllerDirectives: controllerDirectives, - newIsolateScopeDirective: newIsolateScopeDirective, - templateDirective: templateDirective, - nonTlbTranscludeDirective: nonTlbTranscludeDirective - }); - ii = directives.length; - } else if (directive.compile) { - try { - linkFn = directive.compile($compileNode, templateAttrs, childTranscludeFn); - if (isFunction(linkFn)) { - addLinkFns(null, linkFn, attrStart, attrEnd); - } else if (linkFn) { - addLinkFns(linkFn.pre, linkFn.post, attrStart, attrEnd); - } - } catch (e) { - $exceptionHandler(e, startingTag($compileNode)); - } - } - - if (directive.terminal) { - nodeLinkFn.terminal = true; - terminalPriority = Math.max(terminalPriority, directive.priority); - } - - } - - nodeLinkFn.scope = newScopeDirective && newScopeDirective.scope === true; - nodeLinkFn.transcludeOnThisElement = hasTranscludeDirective; - nodeLinkFn.templateOnThisElement = hasTemplate; - nodeLinkFn.transclude = childTranscludeFn; - - previousCompileContext.hasElementTranscludeDirective = hasElementTranscludeDirective; - - // might be normal or delayed nodeLinkFn depending on if templateUrl is present - return nodeLinkFn; - - //////////////////// - - function addLinkFns(pre, post, attrStart, attrEnd) { - if (pre) { - if (attrStart) pre = groupElementsLinkFnWrapper(pre, attrStart, attrEnd); - pre.require = directive.require; - pre.directiveName = directiveName; - if (newIsolateScopeDirective === directive || directive.$$isolateScope) { - pre = cloneAndAnnotateFn(pre, {isolateScope: true}); - } - preLinkFns.push(pre); - } - if (post) { - if (attrStart) post = groupElementsLinkFnWrapper(post, attrStart, attrEnd); - post.require = directive.require; - post.directiveName = directiveName; - if (newIsolateScopeDirective === directive || directive.$$isolateScope) { - post = cloneAndAnnotateFn(post, {isolateScope: true}); - } - postLinkFns.push(post); - } - } - - - function getControllers(directiveName, require, $element, elementControllers) { - var value, retrievalMethod = 'data', optional = false; - if (isString(require)) { - while((value = require.charAt(0)) == '^' || value == '?') { - require = require.substr(1); - if (value == '^') { - retrievalMethod = 'inheritedData'; - } - optional = optional || value == '?'; - } - value = null; - - if (elementControllers && retrievalMethod === 'data') { - value = elementControllers[require]; - } - value = value || $element[retrievalMethod]('$' + require + 'Controller'); - - if (!value && !optional) { - throw $compileMinErr('ctreq', - "Controller '{0}', required by directive '{1}', can't be found!", - require, directiveName); - } - return value; - } else if (isArray(require)) { - value = []; - forEach(require, function(require) { - value.push(getControllers(directiveName, require, $element, elementControllers)); - }); - } - return value; - } - - - function nodeLinkFn(childLinkFn, scope, linkNode, $rootElement, boundTranscludeFn) { - var attrs, $element, i, ii, linkFn, controller, isolateScope, elementControllers = {}, transcludeFn; - - attrs = (compileNode === linkNode) - ? templateAttrs - : shallowCopy(templateAttrs, new Attributes(jqLite(linkNode), templateAttrs.$attr)); - $element = attrs.$$element; - - if (newIsolateScopeDirective) { - var LOCAL_REGEXP = /^\s*([@=&])(\??)\s*(\w*)\s*$/; - - isolateScope = scope.$new(true); - - if (templateDirective && (templateDirective === newIsolateScopeDirective || - templateDirective === newIsolateScopeDirective.$$originalDirective)) { - $element.data('$isolateScope', isolateScope); - } else { - $element.data('$isolateScopeNoTemplate', isolateScope); - } - - - - safeAddClass($element, 'ng-isolate-scope'); - - forEach(newIsolateScopeDirective.scope, function(definition, scopeName) { - var match = definition.match(LOCAL_REGEXP) || [], - attrName = match[3] || scopeName, - optional = (match[2] == '?'), - mode = match[1], // @, =, or & - lastValue, - parentGet, parentSet, compare; - - isolateScope.$$isolateBindings[scopeName] = mode + attrName; - - switch (mode) { - - case '@': - attrs.$observe(attrName, function(value) { - isolateScope[scopeName] = value; - }); - attrs.$$observers[attrName].$$scope = scope; - if( attrs[attrName] ) { - // If the attribute has been provided then we trigger an interpolation to ensure - // the value is there for use in the link fn - isolateScope[scopeName] = $interpolate(attrs[attrName])(scope); - } - break; - - case '=': - if (optional && !attrs[attrName]) { - return; - } - parentGet = $parse(attrs[attrName]); - if (parentGet.literal) { - compare = equals; - } else { - compare = function(a,b) { return a === b || (a !== a && b !== b); }; - } - parentSet = parentGet.assign || function() { - // reset the change, or we will throw this exception on every $digest - lastValue = isolateScope[scopeName] = parentGet(scope); - throw $compileMinErr('nonassign', - "Expression '{0}' used with directive '{1}' is non-assignable!", - attrs[attrName], newIsolateScopeDirective.name); - }; - lastValue = isolateScope[scopeName] = parentGet(scope); - isolateScope.$watch(function parentValueWatch() { - var parentValue = parentGet(scope); - if (!compare(parentValue, isolateScope[scopeName])) { - // we are out of sync and need to copy - if (!compare(parentValue, lastValue)) { - // parent changed and it has precedence - isolateScope[scopeName] = parentValue; - } else { - // if the parent can be assigned then do so - parentSet(scope, parentValue = isolateScope[scopeName]); - } - } - return lastValue = parentValue; - }, null, parentGet.literal); - break; - - case '&': - parentGet = $parse(attrs[attrName]); - isolateScope[scopeName] = function(locals) { - return parentGet(scope, locals); - }; - break; - - default: - throw $compileMinErr('iscp', - "Invalid isolate scope definition for directive '{0}'." + - " Definition: {... {1}: '{2}' ...}", - newIsolateScopeDirective.name, scopeName, definition); - } - }); - } - transcludeFn = boundTranscludeFn && controllersBoundTransclude; - if (controllerDirectives) { - forEach(controllerDirectives, function(directive) { - var locals = { - $scope: directive === newIsolateScopeDirective || directive.$$isolateScope ? isolateScope : scope, - $element: $element, - $attrs: attrs, - $transclude: transcludeFn - }, controllerInstance; - - controller = directive.controller; - if (controller == '@') { - controller = attrs[directive.name]; - } - - controllerInstance = $controller(controller, locals); - // For directives with element transclusion the element is a comment, - // but jQuery .data doesn't support attaching data to comment nodes as it's hard to - // clean up (http://bugs.jquery.com/ticket/8335). - // Instead, we save the controllers for the element in a local hash and attach to .data - // later, once we have the actual element. - elementControllers[directive.name] = controllerInstance; - if (!hasElementTranscludeDirective) { - $element.data('$' + directive.name + 'Controller', controllerInstance); - } - - if (directive.controllerAs) { - locals.$scope[directive.controllerAs] = controllerInstance; - } - }); - } - - // PRELINKING - for(i = 0, ii = preLinkFns.length; i < ii; i++) { - try { - linkFn = preLinkFns[i]; - linkFn(linkFn.isolateScope ? isolateScope : scope, $element, attrs, - linkFn.require && getControllers(linkFn.directiveName, linkFn.require, $element, elementControllers), transcludeFn); - } catch (e) { - $exceptionHandler(e, startingTag($element)); - } - } - - // RECURSION - // We only pass the isolate scope, if the isolate directive has a template, - // otherwise the child elements do not belong to the isolate directive. - var scopeToChild = scope; - if (newIsolateScopeDirective && (newIsolateScopeDirective.template || newIsolateScopeDirective.templateUrl === null)) { - scopeToChild = isolateScope; - } - childLinkFn && childLinkFn(scopeToChild, linkNode.childNodes, undefined, boundTranscludeFn); - - // POSTLINKING - for(i = postLinkFns.length - 1; i >= 0; i--) { - try { - linkFn = postLinkFns[i]; - linkFn(linkFn.isolateScope ? isolateScope : scope, $element, attrs, - linkFn.require && getControllers(linkFn.directiveName, linkFn.require, $element, elementControllers), transcludeFn); - } catch (e) { - $exceptionHandler(e, startingTag($element)); - } - } - - // This is the function that is injected as `$transclude`. - function controllersBoundTransclude(scope, cloneAttachFn) { - var transcludeControllers; - - // no scope passed - if (arguments.length < 2) { - cloneAttachFn = scope; - scope = undefined; - } - - if (hasElementTranscludeDirective) { - transcludeControllers = elementControllers; - } - - return boundTranscludeFn(scope, cloneAttachFn, transcludeControllers); - } - } - } - - function markDirectivesAsIsolate(directives) { - // mark all directives as needing isolate scope. - for (var j = 0, jj = directives.length; j < jj; j++) { - directives[j] = inherit(directives[j], {$$isolateScope: true}); - } - } - - /** - * looks up the directive and decorates it with exception handling and proper parameters. We - * call this the boundDirective. - * - * @param {string} name name of the directive to look up. - * @param {string} location The directive must be found in specific format. - * String containing any of theses characters: - * - * * `E`: element name - * * `A': attribute - * * `C`: class - * * `M`: comment - * @returns {boolean} true if directive was added. - */ - function addDirective(tDirectives, name, location, maxPriority, ignoreDirective, startAttrName, - endAttrName) { - if (name === ignoreDirective) return null; - var match = null; - if (hasDirectives.hasOwnProperty(name)) { - for(var directive, directives = $injector.get(name + Suffix), - i = 0, ii = directives.length; i directive.priority) && - directive.restrict.indexOf(location) != -1) { - if (startAttrName) { - directive = inherit(directive, {$$start: startAttrName, $$end: endAttrName}); - } - tDirectives.push(directive); - match = directive; - } - } catch(e) { $exceptionHandler(e); } - } - } - return match; - } - - - /** - * When the element is replaced with HTML template then the new attributes - * on the template need to be merged with the existing attributes in the DOM. - * The desired effect is to have both of the attributes present. - * - * @param {object} dst destination attributes (original DOM) - * @param {object} src source attributes (from the directive template) - */ - function mergeTemplateAttributes(dst, src) { - var srcAttr = src.$attr, - dstAttr = dst.$attr, - $element = dst.$$element; - - // reapply the old attributes to the new element - forEach(dst, function(value, key) { - if (key.charAt(0) != '$') { - if (src[key] && src[key] !== value) { - value += (key === 'style' ? ';' : ' ') + src[key]; - } - dst.$set(key, value, true, srcAttr[key]); - } - }); - - // copy the new attributes on the old attrs object - forEach(src, function(value, key) { - if (key == 'class') { - safeAddClass($element, value); - dst['class'] = (dst['class'] ? dst['class'] + ' ' : '') + value; - } else if (key == 'style') { - $element.attr('style', $element.attr('style') + ';' + value); - dst['style'] = (dst['style'] ? dst['style'] + ';' : '') + value; - // `dst` will never contain hasOwnProperty as DOM parser won't let it. - // You will get an "InvalidCharacterError: DOM Exception 5" error if you - // have an attribute like "has-own-property" or "data-has-own-property", etc. - } else if (key.charAt(0) != '$' && !dst.hasOwnProperty(key)) { - dst[key] = value; - dstAttr[key] = srcAttr[key]; - } - }); - } - - - function compileTemplateUrl(directives, $compileNode, tAttrs, - $rootElement, childTranscludeFn, preLinkFns, postLinkFns, previousCompileContext) { - var linkQueue = [], - afterTemplateNodeLinkFn, - afterTemplateChildLinkFn, - beforeTemplateCompileNode = $compileNode[0], - origAsyncDirective = directives.shift(), - // The fact that we have to copy and patch the directive seems wrong! - derivedSyncDirective = extend({}, origAsyncDirective, { - templateUrl: null, transclude: null, replace: null, $$originalDirective: origAsyncDirective - }), - templateUrl = (isFunction(origAsyncDirective.templateUrl)) - ? origAsyncDirective.templateUrl($compileNode, tAttrs) - : origAsyncDirective.templateUrl; - - $compileNode.empty(); - - $http.get($sce.getTrustedResourceUrl(templateUrl), {cache: $templateCache}). - success(function(content) { - var compileNode, tempTemplateAttrs, $template, childBoundTranscludeFn; - - content = denormalizeTemplate(content); - - if (origAsyncDirective.replace) { - if (jqLiteIsTextNode(content)) { - $template = []; - } else { - $template = jqLite(trim(content)); - } - compileNode = $template[0]; - - if ($template.length != 1 || compileNode.nodeType !== 1) { - throw $compileMinErr('tplrt', - "Template for directive '{0}' must have exactly one root element. {1}", - origAsyncDirective.name, templateUrl); - } - - tempTemplateAttrs = {$attr: {}}; - replaceWith($rootElement, $compileNode, compileNode); - var templateDirectives = collectDirectives(compileNode, [], tempTemplateAttrs); - - if (isObject(origAsyncDirective.scope)) { - markDirectivesAsIsolate(templateDirectives); - } - directives = templateDirectives.concat(directives); - mergeTemplateAttributes(tAttrs, tempTemplateAttrs); - } else { - compileNode = beforeTemplateCompileNode; - $compileNode.html(content); - } - - directives.unshift(derivedSyncDirective); - - afterTemplateNodeLinkFn = applyDirectivesToNode(directives, compileNode, tAttrs, - childTranscludeFn, $compileNode, origAsyncDirective, preLinkFns, postLinkFns, - previousCompileContext); - forEach($rootElement, function(node, i) { - if (node == compileNode) { - $rootElement[i] = $compileNode[0]; - } - }); - afterTemplateChildLinkFn = compileNodes($compileNode[0].childNodes, childTranscludeFn); - - while(linkQueue.length) { - var scope = linkQueue.shift(), - beforeTemplateLinkNode = linkQueue.shift(), - linkRootElement = linkQueue.shift(), - boundTranscludeFn = linkQueue.shift(), - linkNode = $compileNode[0]; - - if (beforeTemplateLinkNode !== beforeTemplateCompileNode) { - var oldClasses = beforeTemplateLinkNode.className; - - if (!(previousCompileContext.hasElementTranscludeDirective && - origAsyncDirective.replace)) { - // it was cloned therefore we have to clone as well. - linkNode = jqLiteClone(compileNode); - } - - replaceWith(linkRootElement, jqLite(beforeTemplateLinkNode), linkNode); - - // Copy in CSS classes from original node - safeAddClass(jqLite(linkNode), oldClasses); - } - if (afterTemplateNodeLinkFn.transcludeOnThisElement) { - childBoundTranscludeFn = createBoundTranscludeFn(scope, afterTemplateNodeLinkFn.transclude, boundTranscludeFn); - } else { - childBoundTranscludeFn = boundTranscludeFn; - } - afterTemplateNodeLinkFn(afterTemplateChildLinkFn, scope, linkNode, $rootElement, - childBoundTranscludeFn); - } - linkQueue = null; - }). - error(function(response, code, headers, config) { - throw $compileMinErr('tpload', 'Failed to load template: {0}', config.url); - }); - - return function delayedNodeLinkFn(ignoreChildLinkFn, scope, node, rootElement, boundTranscludeFn) { - var childBoundTranscludeFn = boundTranscludeFn; - if (linkQueue) { - linkQueue.push(scope); - linkQueue.push(node); - linkQueue.push(rootElement); - linkQueue.push(childBoundTranscludeFn); - } else { - if (afterTemplateNodeLinkFn.transcludeOnThisElement) { - childBoundTranscludeFn = createBoundTranscludeFn(scope, afterTemplateNodeLinkFn.transclude, boundTranscludeFn); - } - afterTemplateNodeLinkFn(afterTemplateChildLinkFn, scope, node, rootElement, childBoundTranscludeFn); - } - }; - } - - - /** - * Sorting function for bound directives. - */ - function byPriority(a, b) { - var diff = b.priority - a.priority; - if (diff !== 0) return diff; - if (a.name !== b.name) return (a.name < b.name) ? -1 : 1; - return a.index - b.index; - } - - - function assertNoDuplicate(what, previousDirective, directive, element) { - if (previousDirective) { - throw $compileMinErr('multidir', 'Multiple directives [{0}, {1}] asking for {2} on: {3}', - previousDirective.name, directive.name, what, startingTag(element)); - } - } - - - function addTextInterpolateDirective(directives, text) { - var interpolateFn = $interpolate(text, true); - if (interpolateFn) { - directives.push({ - priority: 0, - compile: function textInterpolateCompileFn(templateNode) { - // when transcluding a template that has bindings in the root - // then we don't have a parent and should do this in the linkFn - var parent = templateNode.parent(), hasCompileParent = parent.length; - if (hasCompileParent) safeAddClass(templateNode.parent(), 'ng-binding'); - - return function textInterpolateLinkFn(scope, node) { - var parent = node.parent(), - bindings = parent.data('$binding') || []; - bindings.push(interpolateFn); - parent.data('$binding', bindings); - if (!hasCompileParent) safeAddClass(parent, 'ng-binding'); - scope.$watch(interpolateFn, function interpolateFnWatchAction(value) { - node[0].nodeValue = value; - }); - }; - } - }); - } - } - - - function getTrustedContext(node, attrNormalizedName) { - if (attrNormalizedName == "srcdoc") { - return $sce.HTML; - } - var tag = nodeName_(node); - // maction[xlink:href] can source SVG. It's not limited to . - if (attrNormalizedName == "xlinkHref" || - (tag == "FORM" && attrNormalizedName == "action") || - (tag != "IMG" && (attrNormalizedName == "src" || - attrNormalizedName == "ngSrc"))) { - return $sce.RESOURCE_URL; - } - } - - - function addAttrInterpolateDirective(node, directives, value, name) { - var interpolateFn = $interpolate(value, true); - - // no interpolation found -> ignore - if (!interpolateFn) return; - - - if (name === "multiple" && nodeName_(node) === "SELECT") { - throw $compileMinErr("selmulti", - "Binding to the 'multiple' attribute is not supported. Element: {0}", - startingTag(node)); - } - - directives.push({ - priority: 100, - compile: function() { - return { - pre: function attrInterpolatePreLinkFn(scope, element, attr) { - var $$observers = (attr.$$observers || (attr.$$observers = {})); - - if (EVENT_HANDLER_ATTR_REGEXP.test(name)) { - throw $compileMinErr('nodomevents', - "Interpolations for HTML DOM event attributes are disallowed. Please use the " + - "ng- versions (such as ng-click instead of onclick) instead."); - } - - // we need to interpolate again, in case the attribute value has been updated - // (e.g. by another directive's compile function) - interpolateFn = $interpolate(attr[name], true, getTrustedContext(node, name)); - - // if attribute was updated so that there is no interpolation going on we don't want to - // register any observers - if (!interpolateFn) return; - - // TODO(i): this should likely be attr.$set(name, iterpolateFn(scope) so that we reset the - // actual attr value - attr[name] = interpolateFn(scope); - ($$observers[name] || ($$observers[name] = [])).$$inter = true; - (attr.$$observers && attr.$$observers[name].$$scope || scope). - $watch(interpolateFn, function interpolateFnWatchAction(newValue, oldValue) { - //special case for class attribute addition + removal - //so that class changes can tap into the animation - //hooks provided by the $animate service. Be sure to - //skip animations when the first digest occurs (when - //both the new and the old values are the same) since - //the CSS classes are the non-interpolated values - if(name === 'class' && newValue != oldValue) { - attr.$updateClass(newValue, oldValue); - } else { - attr.$set(name, newValue); - } - }); - } - }; - } - }); - } - - - /** - * This is a special jqLite.replaceWith, which can replace items which - * have no parents, provided that the containing jqLite collection is provided. - * - * @param {JqLite=} $rootElement The root of the compile tree. Used so that we can replace nodes - * in the root of the tree. - * @param {JqLite} elementsToRemove The jqLite element which we are going to replace. We keep - * the shell, but replace its DOM node reference. - * @param {Node} newNode The new DOM node. - */ - function replaceWith($rootElement, elementsToRemove, newNode) { - var firstElementToRemove = elementsToRemove[0], - removeCount = elementsToRemove.length, - parent = firstElementToRemove.parentNode, - i, ii; - - if ($rootElement) { - for(i = 0, ii = $rootElement.length; i < ii; i++) { - if ($rootElement[i] == firstElementToRemove) { - $rootElement[i++] = newNode; - for (var j = i, j2 = j + removeCount - 1, - jj = $rootElement.length; - j < jj; j++, j2++) { - if (j2 < jj) { - $rootElement[j] = $rootElement[j2]; - } else { - delete $rootElement[j]; - } - } - $rootElement.length -= removeCount - 1; - break; - } - } - } - - if (parent) { - parent.replaceChild(newNode, firstElementToRemove); - } - var fragment = document.createDocumentFragment(); - fragment.appendChild(firstElementToRemove); - newNode[jqLite.expando] = firstElementToRemove[jqLite.expando]; - for (var k = 1, kk = elementsToRemove.length; k < kk; k++) { - var element = elementsToRemove[k]; - jqLite(element).remove(); // must do this way to clean up expando - fragment.appendChild(element); - delete elementsToRemove[k]; - } - - elementsToRemove[0] = newNode; - elementsToRemove.length = 1; - } - - - function cloneAndAnnotateFn(fn, annotation) { - return extend(function() { return fn.apply(null, arguments); }, fn, annotation); - } - }]; -} - -var PREFIX_REGEXP = /^(x[\:\-_]|data[\:\-_])/i; -/** - * Converts all accepted directives format into proper directive name. - * All of these will become 'myDirective': - * my:Directive - * my-directive - * x-my-directive - * data-my:directive - * - * Also there is special case for Moz prefix starting with upper case letter. - * @param name Name to normalize - */ -function directiveNormalize(name) { - return camelCase(name.replace(PREFIX_REGEXP, '')); -} - -/** - * @ngdoc type - * @name $compile.directive.Attributes - * - * @description - * A shared object between directive compile / linking functions which contains normalized DOM - * element attributes. The values reflect current binding state `{{ }}`. The normalization is - * needed since all of these are treated as equivalent in Angular: - * - * ``` - * - * ``` - */ - -/** - * @ngdoc property - * @name $compile.directive.Attributes#$attr - * - * @description - * A map of DOM element attribute names to the normalized name. This is - * needed to do reverse lookup from normalized name back to actual name. - */ - - -/** - * @ngdoc method - * @name $compile.directive.Attributes#$set - * @kind function - * - * @description - * Set DOM element attribute value. - * - * - * @param {string} name Normalized element attribute name of the property to modify. The name is - * reverse-translated using the {@link ng.$compile.directive.Attributes#$attr $attr} - * property to the original name. - * @param {string} value Value to set the attribute to. The value can be an interpolated string. - */ - - - -/** - * Closure compiler type information - */ - -function nodesetLinkingFn( - /* angular.Scope */ scope, - /* NodeList */ nodeList, - /* Element */ rootElement, - /* function(Function) */ boundTranscludeFn -){} - -function directiveLinkingFn( - /* nodesetLinkingFn */ nodesetLinkingFn, - /* angular.Scope */ scope, - /* Node */ node, - /* Element */ rootElement, - /* function(Function) */ boundTranscludeFn -){} - -function tokenDifference(str1, str2) { - var values = '', - tokens1 = str1.split(/\s+/), - tokens2 = str2.split(/\s+/); - - outer: - for(var i = 0; i < tokens1.length; i++) { - var token = tokens1[i]; - for(var j = 0; j < tokens2.length; j++) { - if(token == tokens2[j]) continue outer; - } - values += (values.length > 0 ? ' ' : '') + token; - } - return values; -} - -/** - * @ngdoc provider - * @name $controllerProvider - * @description - * The {@link ng.$controller $controller service} is used by Angular to create new - * controllers. - * - * This provider allows controller registration via the - * {@link ng.$controllerProvider#register register} method. - */ -function $ControllerProvider() { - var controllers = {}, - CNTRL_REG = /^(\S+)(\s+as\s+(\w+))?$/; - - - /** - * @ngdoc method - * @name $controllerProvider#register - * @param {string|Object} name Controller name, or an object map of controllers where the keys are - * the names and the values are the constructors. - * @param {Function|Array} constructor Controller constructor fn (optionally decorated with DI - * annotations in the array notation). - */ - this.register = function(name, constructor) { - assertNotHasOwnProperty(name, 'controller'); - if (isObject(name)) { - extend(controllers, name); - } else { - controllers[name] = constructor; - } - }; - - - this.$get = ['$injector', '$window', function($injector, $window) { - - /** - * @ngdoc service - * @name $controller - * @requires $injector - * - * @param {Function|string} constructor If called with a function then it's considered to be the - * controller constructor function. Otherwise it's considered to be a string which is used - * to retrieve the controller constructor using the following steps: - * - * * check if a controller with given name is registered via `$controllerProvider` - * * check if evaluating the string on the current scope returns a constructor - * * check `window[constructor]` on the global `window` object - * - * @param {Object} locals Injection locals for Controller. - * @return {Object} Instance of given controller. - * - * @description - * `$controller` service is responsible for instantiating controllers. - * - * It's just a simple call to {@link auto.$injector $injector}, but extracted into - * a service, so that one can override this service with [BC version](https://gist.github.com/1649788). - */ - return function(expression, locals) { - var instance, match, constructor, identifier; - - if(isString(expression)) { - match = expression.match(CNTRL_REG), - constructor = match[1], - identifier = match[3]; - expression = controllers.hasOwnProperty(constructor) - ? controllers[constructor] - : getter(locals.$scope, constructor, true) || getter($window, constructor, true); - - assertArgFn(expression, constructor, true); - } - - instance = $injector.instantiate(expression, locals); - - if (identifier) { - if (!(locals && typeof locals.$scope === 'object')) { - throw minErr('$controller')('noscp', - "Cannot export controller '{0}' as '{1}'! No $scope object provided via `locals`.", - constructor || expression.name, identifier); - } - - locals.$scope[identifier] = instance; - } - - return instance; - }; - }]; -} - -/** - * @ngdoc service - * @name $document - * @requires $window - * - * @description - * A {@link angular.element jQuery or jqLite} wrapper for the browser's `window.document` object. - * - * @example - - -
-

$document title:

-

window.document title:

-
-
- - angular.module('documentExample', []) - .controller('ExampleController', ['$scope', '$document', function($scope, $document) { - $scope.title = $document[0].title; - $scope.windowTitle = angular.element(window.document)[0].title; - }]); - -
- */ -function $DocumentProvider(){ - this.$get = ['$window', function(window){ - return jqLite(window.document); - }]; -} - -/** - * @ngdoc service - * @name $exceptionHandler - * @requires ng.$log - * - * @description - * Any uncaught exception in angular expressions is delegated to this service. - * The default implementation simply delegates to `$log.error` which logs it into - * the browser console. - * - * In unit tests, if `angular-mocks.js` is loaded, this service is overridden by - * {@link ngMock.$exceptionHandler mock $exceptionHandler} which aids in testing. - * - * ## Example: - * - * ```js - * angular.module('exceptionOverride', []).factory('$exceptionHandler', function () { - * return function (exception, cause) { - * exception.message += ' (caused by "' + cause + '")'; - * throw exception; - * }; - * }); - * ``` - * - * This example will override the normal action of `$exceptionHandler`, to make angular - * exceptions fail hard when they happen, instead of just logging to the console. - * - * @param {Error} exception Exception associated with the error. - * @param {string=} cause optional information about the context in which - * the error was thrown. - * - */ -function $ExceptionHandlerProvider() { - this.$get = ['$log', function($log) { - return function(exception, cause) { - $log.error.apply($log, arguments); - }; - }]; -} - -/** - * Parse headers into key value object - * - * @param {string} headers Raw headers as a string - * @returns {Object} Parsed headers as key value object - */ -function parseHeaders(headers) { - var parsed = {}, key, val, i; - - if (!headers) return parsed; - - forEach(headers.split('\n'), function(line) { - i = line.indexOf(':'); - key = lowercase(trim(line.substr(0, i))); - val = trim(line.substr(i + 1)); - - if (key) { - parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; - } - }); - - return parsed; -} - - -/** - * Returns a function that provides access to parsed headers. - * - * Headers are lazy parsed when first requested. - * @see parseHeaders - * - * @param {(string|Object)} headers Headers to provide access to. - * @returns {function(string=)} Returns a getter function which if called with: - * - * - if called with single an argument returns a single header value or null - * - if called with no arguments returns an object containing all headers. - */ -function headersGetter(headers) { - var headersObj = isObject(headers) ? headers : undefined; - - return function(name) { - if (!headersObj) headersObj = parseHeaders(headers); - - if (name) { - return headersObj[lowercase(name)] || null; - } - - return headersObj; - }; -} - - -/** - * Chain all given functions - * - * This function is used for both request and response transforming - * - * @param {*} data Data to transform. - * @param {function(string=)} headers Http headers getter fn. - * @param {(Function|Array.)} fns Function or an array of functions. - * @returns {*} Transformed data. - */ -function transformData(data, headers, fns) { - if (isFunction(fns)) - return fns(data, headers); - - forEach(fns, function(fn) { - data = fn(data, headers); - }); - - return data; -} - - -function isSuccess(status) { - return 200 <= status && status < 300; -} - - -/** - * @ngdoc provider - * @name $httpProvider - * @description - * Use `$httpProvider` to change the default behavior of the {@link ng.$http $http} service. - * */ -function $HttpProvider() { - var JSON_START = /^\s*(\[|\{[^\{])/, - JSON_END = /[\}\]]\s*$/, - PROTECTION_PREFIX = /^\)\]\}',?\n/, - CONTENT_TYPE_APPLICATION_JSON = {'Content-Type': 'application/json;charset=utf-8'}; - - /** - * @ngdoc property - * @name $httpProvider#defaults - * @description - * - * Object containing default values for all {@link ng.$http $http} requests. - * - * - **`defaults.xsrfCookieName`** - {string} - Name of cookie containing the XSRF token. - * Defaults value is `'XSRF-TOKEN'`. - * - * - **`defaults.xsrfHeaderName`** - {string} - Name of HTTP header to populate with the - * XSRF token. Defaults value is `'X-XSRF-TOKEN'`. - * - * - **`defaults.headers`** - {Object} - Default headers for all $http requests. - * Refer to {@link ng.$http#setting-http-headers $http} for documentation on - * setting default headers. - * - **`defaults.headers.common`** - * - **`defaults.headers.post`** - * - **`defaults.headers.put`** - * - **`defaults.headers.patch`** - **/ - var defaults = this.defaults = { - // transform incoming response data - transformResponse: [function(data) { - if (isString(data)) { - // strip json vulnerability protection prefix - data = data.replace(PROTECTION_PREFIX, ''); - if (JSON_START.test(data) && JSON_END.test(data)) - data = fromJson(data); - } - return data; - }], - - // transform outgoing request data - transformRequest: [function(d) { - return isObject(d) && !isFile(d) && !isBlob(d) ? toJson(d) : d; - }], - - // default headers - headers: { - common: { - 'Accept': 'application/json, text/plain, */*' - }, - post: shallowCopy(CONTENT_TYPE_APPLICATION_JSON), - put: shallowCopy(CONTENT_TYPE_APPLICATION_JSON), - patch: shallowCopy(CONTENT_TYPE_APPLICATION_JSON) - }, - - xsrfCookieName: 'XSRF-TOKEN', - xsrfHeaderName: 'X-XSRF-TOKEN' - }; - - /** - * Are ordered by request, i.e. they are applied in the same order as the - * array, on request, but reverse order, on response. - */ - var interceptorFactories = this.interceptors = []; - - /** - * For historical reasons, response interceptors are ordered by the order in which - * they are applied to the response. (This is the opposite of interceptorFactories) - */ - var responseInterceptorFactories = this.responseInterceptors = []; - - this.$get = ['$httpBackend', '$browser', '$cacheFactory', '$rootScope', '$q', '$injector', - function($httpBackend, $browser, $cacheFactory, $rootScope, $q, $injector) { - - var defaultCache = $cacheFactory('$http'); - - /** - * Interceptors stored in reverse order. Inner interceptors before outer interceptors. - * The reversal is needed so that we can build up the interception chain around the - * server request. - */ - var reversedInterceptors = []; - - forEach(interceptorFactories, function(interceptorFactory) { - reversedInterceptors.unshift(isString(interceptorFactory) - ? $injector.get(interceptorFactory) : $injector.invoke(interceptorFactory)); - }); - - forEach(responseInterceptorFactories, function(interceptorFactory, index) { - var responseFn = isString(interceptorFactory) - ? $injector.get(interceptorFactory) - : $injector.invoke(interceptorFactory); - - /** - * Response interceptors go before "around" interceptors (no real reason, just - * had to pick one.) But they are already reversed, so we can't use unshift, hence - * the splice. - */ - reversedInterceptors.splice(index, 0, { - response: function(response) { - return responseFn($q.when(response)); - }, - responseError: function(response) { - return responseFn($q.reject(response)); - } - }); - }); - - - /** - * @ngdoc service - * @kind function - * @name $http - * @requires ng.$httpBackend - * @requires $cacheFactory - * @requires $rootScope - * @requires $q - * @requires $injector - * - * @description - * The `$http` service is a core Angular service that facilitates communication with the remote - * HTTP servers via the browser's [XMLHttpRequest](https://developer.mozilla.org/en/xmlhttprequest) - * object or via [JSONP](http://en.wikipedia.org/wiki/JSONP). - * - * For unit testing applications that use `$http` service, see - * {@link ngMock.$httpBackend $httpBackend mock}. - * - * For a higher level of abstraction, please check out the {@link ngResource.$resource - * $resource} service. - * - * The $http API is based on the {@link ng.$q deferred/promise APIs} exposed by - * the $q service. While for simple usage patterns this doesn't matter much, for advanced usage - * it is important to familiarize yourself with these APIs and the guarantees they provide. - * - * - * # General usage - * The `$http` service is a function which takes a single argument — a configuration object — - * that is used to generate an HTTP request and returns a {@link ng.$q promise} - * with two $http specific methods: `success` and `error`. - * - * ```js - * $http({method: 'GET', url: '/someUrl'}). - * success(function(data, status, headers, config) { - * // this callback will be called asynchronously - * // when the response is available - * }). - * error(function(data, status, headers, config) { - * // called asynchronously if an error occurs - * // or server returns response with an error status. - * }); - * ``` - * - * Since the returned value of calling the $http function is a `promise`, you can also use - * the `then` method to register callbacks, and these callbacks will receive a single argument – - * an object representing the response. See the API signature and type info below for more - * details. - * - * A response status code between 200 and 299 is considered a success status and - * will result in the success callback being called. Note that if the response is a redirect, - * XMLHttpRequest will transparently follow it, meaning that the error callback will not be - * called for such responses. - * - * # Writing Unit Tests that use $http - * When unit testing (using {@link ngMock ngMock}), it is necessary to call - * {@link ngMock.$httpBackend#flush $httpBackend.flush()} to flush each pending - * request using trained responses. - * - * ``` - * $httpBackend.expectGET(...); - * $http.get(...); - * $httpBackend.flush(); - * ``` - * - * # Shortcut methods - * - * Shortcut methods are also available. All shortcut methods require passing in the URL, and - * request data must be passed in for POST/PUT requests. - * - * ```js - * $http.get('/someUrl').success(successCallback); - * $http.post('/someUrl', data).success(successCallback); - * ``` - * - * Complete list of shortcut methods: - * - * - {@link ng.$http#get $http.get} - * - {@link ng.$http#head $http.head} - * - {@link ng.$http#post $http.post} - * - {@link ng.$http#put $http.put} - * - {@link ng.$http#delete $http.delete} - * - {@link ng.$http#jsonp $http.jsonp} - * - {@link ng.$http#patch $http.patch} - * - * - * # Setting HTTP Headers - * - * The $http service will automatically add certain HTTP headers to all requests. These defaults - * can be fully configured by accessing the `$httpProvider.defaults.headers` configuration - * object, which currently contains this default configuration: - * - * - `$httpProvider.defaults.headers.common` (headers that are common for all requests): - * - `Accept: application/json, text/plain, * / *` - * - `$httpProvider.defaults.headers.post`: (header defaults for POST requests) - * - `Content-Type: application/json` - * - `$httpProvider.defaults.headers.put` (header defaults for PUT requests) - * - `Content-Type: application/json` - * - * To add or overwrite these defaults, simply add or remove a property from these configuration - * objects. To add headers for an HTTP method other than POST or PUT, simply add a new object - * with the lowercased HTTP method name as the key, e.g. - * `$httpProvider.defaults.headers.get = { 'My-Header' : 'value' }. - * - * The defaults can also be set at runtime via the `$http.defaults` object in the same - * fashion. For example: - * - * ``` - * module.run(function($http) { - * $http.defaults.headers.common.Authorization = 'Basic YmVlcDpib29w' - * }); - * ``` - * - * In addition, you can supply a `headers` property in the config object passed when - * calling `$http(config)`, which overrides the defaults without changing them globally. - * - * - * # Transforming Requests and Responses - * - * Both requests and responses can be transformed using transform functions. By default, Angular - * applies these transformations: - * - * Request transformations: - * - * - If the `data` property of the request configuration object contains an object, serialize it - * into JSON format. - * - * Response transformations: - * - * - If XSRF prefix is detected, strip it (see Security Considerations section below). - * - If JSON response is detected, deserialize it using a JSON parser. - * - * To globally augment or override the default transforms, modify the - * `$httpProvider.defaults.transformRequest` and `$httpProvider.defaults.transformResponse` - * properties. These properties are by default an array of transform functions, which allows you - * to `push` or `unshift` a new transformation function into the transformation chain. You can - * also decide to completely override any default transformations by assigning your - * transformation functions to these properties directly without the array wrapper. These defaults - * are again available on the $http factory at run-time, which may be useful if you have run-time - * services you wish to be involved in your transformations. - * - * Similarly, to locally override the request/response transforms, augment the - * `transformRequest` and/or `transformResponse` properties of the configuration object passed - * into `$http`. - * - * - * # Caching - * - * To enable caching, set the request configuration `cache` property to `true` (to use default - * cache) or to a custom cache object (built with {@link ng.$cacheFactory `$cacheFactory`}). - * When the cache is enabled, `$http` stores the response from the server in the specified - * cache. The next time the same request is made, the response is served from the cache without - * sending a request to the server. - * - * Note that even if the response is served from cache, delivery of the data is asynchronous in - * the same way that real requests are. - * - * If there are multiple GET requests for the same URL that should be cached using the same - * cache, but the cache is not populated yet, only one request to the server will be made and - * the remaining requests will be fulfilled using the response from the first request. - * - * You can change the default cache to a new object (built with - * {@link ng.$cacheFactory `$cacheFactory`}) by updating the - * {@link ng.$http#properties_defaults `$http.defaults.cache`} property. All requests who set - * their `cache` property to `true` will now use this cache object. - * - * If you set the default cache to `false` then only requests that specify their own custom - * cache object will be cached. - * - * # Interceptors - * - * Before you start creating interceptors, be sure to understand the - * {@link ng.$q $q and deferred/promise APIs}. - * - * For purposes of global error handling, authentication, or any kind of synchronous or - * asynchronous pre-processing of request or postprocessing of responses, it is desirable to be - * able to intercept requests before they are handed to the server and - * responses before they are handed over to the application code that - * initiated these requests. The interceptors leverage the {@link ng.$q - * promise APIs} to fulfill this need for both synchronous and asynchronous pre-processing. - * - * The interceptors are service factories that are registered with the `$httpProvider` by - * adding them to the `$httpProvider.interceptors` array. The factory is called and - * injected with dependencies (if specified) and returns the interceptor. - * - * There are two kinds of interceptors (and two kinds of rejection interceptors): - * - * * `request`: interceptors get called with a http `config` object. The function is free to - * modify the `config` object or create a new one. The function needs to return the `config` - * object directly, or a promise containing the `config` or a new `config` object. - * * `requestError`: interceptor gets called when a previous interceptor threw an error or - * resolved with a rejection. - * * `response`: interceptors get called with http `response` object. The function is free to - * modify the `response` object or create a new one. The function needs to return the `response` - * object directly, or as a promise containing the `response` or a new `response` object. - * * `responseError`: interceptor gets called when a previous interceptor threw an error or - * resolved with a rejection. - * - * - * ```js - * // register the interceptor as a service - * $provide.factory('myHttpInterceptor', function($q, dependency1, dependency2) { - * return { - * // optional method - * 'request': function(config) { - * // do something on success - * return config; - * }, - * - * // optional method - * 'requestError': function(rejection) { - * // do something on error - * if (canRecover(rejection)) { - * return responseOrNewPromise - * } - * return $q.reject(rejection); - * }, - * - * - * - * // optional method - * 'response': function(response) { - * // do something on success - * return response; - * }, - * - * // optional method - * 'responseError': function(rejection) { - * // do something on error - * if (canRecover(rejection)) { - * return responseOrNewPromise - * } - * return $q.reject(rejection); - * } - * }; - * }); - * - * $httpProvider.interceptors.push('myHttpInterceptor'); - * - * - * // alternatively, register the interceptor via an anonymous factory - * $httpProvider.interceptors.push(function($q, dependency1, dependency2) { - * return { - * 'request': function(config) { - * // same as above - * }, - * - * 'response': function(response) { - * // same as above - * } - * }; - * }); - * ``` - * - * # Response interceptors (DEPRECATED) - * - * Before you start creating interceptors, be sure to understand the - * {@link ng.$q $q and deferred/promise APIs}. - * - * For purposes of global error handling, authentication or any kind of synchronous or - * asynchronous preprocessing of received responses, it is desirable to be able to intercept - * responses for http requests before they are handed over to the application code that - * initiated these requests. The response interceptors leverage the {@link ng.$q - * promise apis} to fulfil this need for both synchronous and asynchronous preprocessing. - * - * The interceptors are service factories that are registered with the $httpProvider by - * adding them to the `$httpProvider.responseInterceptors` array. The factory is called and - * injected with dependencies (if specified) and returns the interceptor — a function that - * takes a {@link ng.$q promise} and returns the original or a new promise. - * - * ```js - * // register the interceptor as a service - * $provide.factory('myHttpInterceptor', function($q, dependency1, dependency2) { - * return function(promise) { - * return promise.then(function(response) { - * // do something on success - * return response; - * }, function(response) { - * // do something on error - * if (canRecover(response)) { - * return responseOrNewPromise - * } - * return $q.reject(response); - * }); - * } - * }); - * - * $httpProvider.responseInterceptors.push('myHttpInterceptor'); - * - * - * // register the interceptor via an anonymous factory - * $httpProvider.responseInterceptors.push(function($q, dependency1, dependency2) { - * return function(promise) { - * // same as above - * } - * }); - * ``` - * - * - * # Security Considerations - * - * When designing web applications, consider security threats from: - * - * - [JSON vulnerability](http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx) - * - [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery) - * - * Both server and the client must cooperate in order to eliminate these threats. Angular comes - * pre-configured with strategies that address these issues, but for this to work backend server - * cooperation is required. - * - * ## JSON Vulnerability Protection - * - * A [JSON vulnerability](http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx) - * allows third party website to turn your JSON resource URL into - * [JSONP](http://en.wikipedia.org/wiki/JSONP) request under some conditions. To - * counter this your server can prefix all JSON requests with following string `")]}',\n"`. - * Angular will automatically strip the prefix before processing it as JSON. - * - * For example if your server needs to return: - * ```js - * ['one','two'] - * ``` - * - * which is vulnerable to attack, your server can return: - * ```js - * )]}', - * ['one','two'] - * ``` - * - * Angular will strip the prefix, before processing the JSON. - * - * - * ## Cross Site Request Forgery (XSRF) Protection - * - * [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery) is a technique by which - * an unauthorized site can gain your user's private data. Angular provides a mechanism - * to counter XSRF. When performing XHR requests, the $http service reads a token from a cookie - * (by default, `XSRF-TOKEN`) and sets it as an HTTP header (`X-XSRF-TOKEN`). Since only - * JavaScript that runs on your domain could read the cookie, your server can be assured that - * the XHR came from JavaScript running on your domain. The header will not be set for - * cross-domain requests. - * - * To take advantage of this, your server needs to set a token in a JavaScript readable session - * cookie called `XSRF-TOKEN` on the first HTTP GET request. On subsequent XHR requests the - * server can verify that the cookie matches `X-XSRF-TOKEN` HTTP header, and therefore be sure - * that only JavaScript running on your domain could have sent the request. The token must be - * unique for each user and must be verifiable by the server (to prevent the JavaScript from - * making up its own tokens). We recommend that the token is a digest of your site's - * authentication cookie with a [salt](https://en.wikipedia.org/wiki/Salt_(cryptography)) - * for added security. - * - * The name of the headers can be specified using the xsrfHeaderName and xsrfCookieName - * properties of either $httpProvider.defaults at config-time, $http.defaults at run-time, - * or the per-request config object. - * - * - * @param {object} config Object describing the request to be made and how it should be - * processed. The object has following properties: - * - * - **method** – `{string}` – HTTP method (e.g. 'GET', 'POST', etc) - * - **url** – `{string}` – Absolute or relative URL of the resource that is being requested. - * - **params** – `{Object.}` – Map of strings or objects which will be turned - * to `?key1=value1&key2=value2` after the url. If the value is not a string, it will be - * JSONified. - * - **data** – `{string|Object}` – Data to be sent as the request message data. - * - **headers** – `{Object}` – Map of strings or functions which return strings representing - * HTTP headers to send to the server. If the return value of a function is null, the - * header will not be sent. - * - **xsrfHeaderName** – `{string}` – Name of HTTP header to populate with the XSRF token. - * - **xsrfCookieName** – `{string}` – Name of cookie containing the XSRF token. - * - **transformRequest** – - * `{function(data, headersGetter)|Array.}` – - * transform function or an array of such functions. The transform function takes the http - * request body and headers and returns its transformed (typically serialized) version. - * - **transformResponse** – - * `{function(data, headersGetter)|Array.}` – - * transform function or an array of such functions. The transform function takes the http - * response body and headers and returns its transformed (typically deserialized) version. - * - **cache** – `{boolean|Cache}` – If true, a default $http cache will be used to cache the - * GET request, otherwise if a cache instance built with - * {@link ng.$cacheFactory $cacheFactory}, this cache will be used for - * caching. - * - **timeout** – `{number|Promise}` – timeout in milliseconds, or {@link ng.$q promise} - * that should abort the request when resolved. - * - **withCredentials** - `{boolean}` - whether to set the `withCredentials` flag on the - * XHR object. See [requests with credentials](https://developer.mozilla.org/docs/Web/HTTP/Access_control_CORS#Requests_with_credentials) - * for more information. - * - **responseType** - `{string}` - see - * [requestType](https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#responseType). - * - * @returns {HttpPromise} Returns a {@link ng.$q promise} object with the - * standard `then` method and two http specific methods: `success` and `error`. The `then` - * method takes two arguments a success and an error callback which will be called with a - * response object. The `success` and `error` methods take a single argument - a function that - * will be called when the request succeeds or fails respectively. The arguments passed into - * these functions are destructured representation of the response object passed into the - * `then` method. The response object has these properties: - * - * - **data** – `{string|Object}` – The response body transformed with the transform - * functions. - * - **status** – `{number}` – HTTP status code of the response. - * - **headers** – `{function([headerName])}` – Header getter function. - * - **config** – `{Object}` – The configuration object that was used to generate the request. - * - **statusText** – `{string}` – HTTP status text of the response. - * - * @property {Array.} pendingRequests Array of config objects for currently pending - * requests. This is primarily meant to be used for debugging purposes. - * - * - * @example - - -
- - -
- - - -
http status code: {{status}}
-
http response data: {{data}}
-
-
- - angular.module('httpExample', []) - .controller('FetchController', ['$scope', '$http', '$templateCache', - function($scope, $http, $templateCache) { - $scope.method = 'GET'; - $scope.url = 'http-hello.html'; - - $scope.fetch = function() { - $scope.code = null; - $scope.response = null; - - $http({method: $scope.method, url: $scope.url, cache: $templateCache}). - success(function(data, status) { - $scope.status = status; - $scope.data = data; - }). - error(function(data, status) { - $scope.data = data || "Request failed"; - $scope.status = status; - }); - }; - - $scope.updateModel = function(method, url) { - $scope.method = method; - $scope.url = url; - }; - }]); - - - Hello, $http! - - - var status = element(by.binding('status')); - var data = element(by.binding('data')); - var fetchBtn = element(by.id('fetchbtn')); - var sampleGetBtn = element(by.id('samplegetbtn')); - var sampleJsonpBtn = element(by.id('samplejsonpbtn')); - var invalidJsonpBtn = element(by.id('invalidjsonpbtn')); - - it('should make an xhr GET request', function() { - sampleGetBtn.click(); - fetchBtn.click(); - expect(status.getText()).toMatch('200'); - expect(data.getText()).toMatch(/Hello, \$http!/); - }); - - it('should make a JSONP request to angularjs.org', function() { - sampleJsonpBtn.click(); - fetchBtn.click(); - expect(status.getText()).toMatch('200'); - expect(data.getText()).toMatch(/Super Hero!/); - }); - - it('should make JSONP request to invalid URL and invoke the error handler', - function() { - invalidJsonpBtn.click(); - fetchBtn.click(); - expect(status.getText()).toMatch('0'); - expect(data.getText()).toMatch('Request failed'); - }); - -
- */ - function $http(requestConfig) { - var config = { - method: 'get', - transformRequest: defaults.transformRequest, - transformResponse: defaults.transformResponse - }; - var headers = mergeHeaders(requestConfig); - - extend(config, requestConfig); - config.headers = headers; - config.method = uppercase(config.method); - - var serverRequest = function(config) { - headers = config.headers; - var reqData = transformData(config.data, headersGetter(headers), config.transformRequest); - - // strip content-type if data is undefined - if (isUndefined(reqData)) { - forEach(headers, function(value, header) { - if (lowercase(header) === 'content-type') { - delete headers[header]; - } - }); - } - - if (isUndefined(config.withCredentials) && !isUndefined(defaults.withCredentials)) { - config.withCredentials = defaults.withCredentials; - } - - // send request - return sendReq(config, reqData, headers).then(transformResponse, transformResponse); - }; - - var chain = [serverRequest, undefined]; - var promise = $q.when(config); - - // apply interceptors - forEach(reversedInterceptors, function(interceptor) { - if (interceptor.request || interceptor.requestError) { - chain.unshift(interceptor.request, interceptor.requestError); - } - if (interceptor.response || interceptor.responseError) { - chain.push(interceptor.response, interceptor.responseError); - } - }); - - while(chain.length) { - var thenFn = chain.shift(); - var rejectFn = chain.shift(); - - promise = promise.then(thenFn, rejectFn); - } - - promise.success = function(fn) { - promise.then(function(response) { - fn(response.data, response.status, response.headers, config); - }); - return promise; - }; - - promise.error = function(fn) { - promise.then(null, function(response) { - fn(response.data, response.status, response.headers, config); - }); - return promise; - }; - - return promise; - - function transformResponse(response) { - // make a copy since the response must be cacheable - var resp = extend({}, response, { - data: transformData(response.data, response.headers, config.transformResponse) - }); - return (isSuccess(response.status)) - ? resp - : $q.reject(resp); - } - - function mergeHeaders(config) { - var defHeaders = defaults.headers, - reqHeaders = extend({}, config.headers), - defHeaderName, lowercaseDefHeaderName, reqHeaderName; - - defHeaders = extend({}, defHeaders.common, defHeaders[lowercase(config.method)]); - - // using for-in instead of forEach to avoid unecessary iteration after header has been found - defaultHeadersIteration: - for (defHeaderName in defHeaders) { - lowercaseDefHeaderName = lowercase(defHeaderName); - - for (reqHeaderName in reqHeaders) { - if (lowercase(reqHeaderName) === lowercaseDefHeaderName) { - continue defaultHeadersIteration; - } - } - - reqHeaders[defHeaderName] = defHeaders[defHeaderName]; - } - - // execute if header value is a function for merged headers - execHeaders(reqHeaders); - return reqHeaders; - - function execHeaders(headers) { - var headerContent; - - forEach(headers, function(headerFn, header) { - if (isFunction(headerFn)) { - headerContent = headerFn(); - if (headerContent != null) { - headers[header] = headerContent; - } else { - delete headers[header]; - } - } - }); - } - } - } - - $http.pendingRequests = []; - - /** - * @ngdoc method - * @name $http#get - * - * @description - * Shortcut method to perform `GET` request. - * - * @param {string} url Relative or absolute URL specifying the destination of the request - * @param {Object=} config Optional configuration object - * @returns {HttpPromise} Future object - */ - - /** - * @ngdoc method - * @name $http#delete - * - * @description - * Shortcut method to perform `DELETE` request. - * - * @param {string} url Relative or absolute URL specifying the destination of the request - * @param {Object=} config Optional configuration object - * @returns {HttpPromise} Future object - */ - - /** - * @ngdoc method - * @name $http#head - * - * @description - * Shortcut method to perform `HEAD` request. - * - * @param {string} url Relative or absolute URL specifying the destination of the request - * @param {Object=} config Optional configuration object - * @returns {HttpPromise} Future object - */ - - /** - * @ngdoc method - * @name $http#jsonp - * - * @description - * Shortcut method to perform `JSONP` request. - * - * @param {string} url Relative or absolute URL specifying the destination of the request. - * The name of the callback should be the string `JSON_CALLBACK`. - * @param {Object=} config Optional configuration object - * @returns {HttpPromise} Future object - */ - createShortMethods('get', 'delete', 'head', 'jsonp'); - - /** - * @ngdoc method - * @name $http#post - * - * @description - * Shortcut method to perform `POST` request. - * - * @param {string} url Relative or absolute URL specifying the destination of the request - * @param {*} data Request content - * @param {Object=} config Optional configuration object - * @returns {HttpPromise} Future object - */ - - /** - * @ngdoc method - * @name $http#put - * - * @description - * Shortcut method to perform `PUT` request. - * - * @param {string} url Relative or absolute URL specifying the destination of the request - * @param {*} data Request content - * @param {Object=} config Optional configuration object - * @returns {HttpPromise} Future object - */ - createShortMethodsWithData('post', 'put'); - - /** - * @ngdoc property - * @name $http#defaults - * - * @description - * Runtime equivalent of the `$httpProvider.defaults` property. Allows configuration of - * default headers, withCredentials as well as request and response transformations. - * - * See "Setting HTTP Headers" and "Transforming Requests and Responses" sections above. - */ - $http.defaults = defaults; - - - return $http; - - - function createShortMethods(names) { - forEach(arguments, function(name) { - $http[name] = function(url, config) { - return $http(extend(config || {}, { - method: name, - url: url - })); - }; - }); - } - - - function createShortMethodsWithData(name) { - forEach(arguments, function(name) { - $http[name] = function(url, data, config) { - return $http(extend(config || {}, { - method: name, - url: url, - data: data - })); - }; - }); - } - - - /** - * Makes the request. - * - * !!! ACCESSES CLOSURE VARS: - * $httpBackend, defaults, $log, $rootScope, defaultCache, $http.pendingRequests - */ - function sendReq(config, reqData, reqHeaders) { - var deferred = $q.defer(), - promise = deferred.promise, - cache, - cachedResp, - url = buildUrl(config.url, config.params); - - $http.pendingRequests.push(config); - promise.then(removePendingReq, removePendingReq); - - - if ((config.cache || defaults.cache) && config.cache !== false && - (config.method === 'GET' || config.method === 'JSONP')) { - cache = isObject(config.cache) ? config.cache - : isObject(defaults.cache) ? defaults.cache - : defaultCache; - } - - if (cache) { - cachedResp = cache.get(url); - if (isDefined(cachedResp)) { - if (isPromiseLike(cachedResp)) { - // cached request has already been sent, but there is no response yet - cachedResp.then(removePendingReq, removePendingReq); - return cachedResp; - } else { - // serving from cache - if (isArray(cachedResp)) { - resolvePromise(cachedResp[1], cachedResp[0], shallowCopy(cachedResp[2]), cachedResp[3]); - } else { - resolvePromise(cachedResp, 200, {}, 'OK'); - } - } - } else { - // put the promise for the non-transformed response into cache as a placeholder - cache.put(url, promise); - } - } - - - // if we won't have the response in cache, set the xsrf headers and - // send the request to the backend - if (isUndefined(cachedResp)) { - var xsrfValue = urlIsSameOrigin(config.url) - ? $browser.cookies()[config.xsrfCookieName || defaults.xsrfCookieName] - : undefined; - if (xsrfValue) { - reqHeaders[(config.xsrfHeaderName || defaults.xsrfHeaderName)] = xsrfValue; - } - - $httpBackend(config.method, url, reqData, done, reqHeaders, config.timeout, - config.withCredentials, config.responseType); - } - - return promise; - - - /** - * Callback registered to $httpBackend(): - * - caches the response if desired - * - resolves the raw $http promise - * - calls $apply - */ - function done(status, response, headersString, statusText) { - if (cache) { - if (isSuccess(status)) { - cache.put(url, [status, response, parseHeaders(headersString), statusText]); - } else { - // remove promise from the cache - cache.remove(url); - } - } - - resolvePromise(response, status, headersString, statusText); - if (!$rootScope.$$phase) $rootScope.$apply(); - } - - - /** - * Resolves the raw $http promise. - */ - function resolvePromise(response, status, headers, statusText) { - // normalize internal statuses to 0 - status = Math.max(status, 0); - - (isSuccess(status) ? deferred.resolve : deferred.reject)({ - data: response, - status: status, - headers: headersGetter(headers), - config: config, - statusText : statusText - }); - } - - - function removePendingReq() { - var idx = indexOf($http.pendingRequests, config); - if (idx !== -1) $http.pendingRequests.splice(idx, 1); - } - } - - - function buildUrl(url, params) { - if (!params) return url; - var parts = []; - forEachSorted(params, function(value, key) { - if (value === null || isUndefined(value)) return; - if (!isArray(value)) value = [value]; - - forEach(value, function(v) { - if (isObject(v)) { - if (isDate(v)){ - v = v.toISOString(); - } else { - v = toJson(v); - } - } - parts.push(encodeUriQuery(key) + '=' + - encodeUriQuery(v)); - }); - }); - if(parts.length > 0) { - url += ((url.indexOf('?') == -1) ? '?' : '&') + parts.join('&'); - } - return url; - } - }]; -} - -function createXhr(method) { - //if IE and the method is not RFC2616 compliant, or if XMLHttpRequest - //is not available, try getting an ActiveXObject. Otherwise, use XMLHttpRequest - //if it is available - if (msie <= 8 && (!method.match(/^(get|post|head|put|delete|options)$/i) || - !window.XMLHttpRequest)) { - return new window.ActiveXObject("Microsoft.XMLHTTP"); - } else if (window.XMLHttpRequest) { - return new window.XMLHttpRequest(); - } - - throw minErr('$httpBackend')('noxhr', "This browser does not support XMLHttpRequest."); -} - -/** - * @ngdoc service - * @name $httpBackend - * @requires $window - * @requires $document - * - * @description - * HTTP backend used by the {@link ng.$http service} that delegates to - * XMLHttpRequest object or JSONP and deals with browser incompatibilities. - * - * You should never need to use this service directly, instead use the higher-level abstractions: - * {@link ng.$http $http} or {@link ngResource.$resource $resource}. - * - * During testing this implementation is swapped with {@link ngMock.$httpBackend mock - * $httpBackend} which can be trained with responses. - */ -function $HttpBackendProvider() { - this.$get = ['$browser', '$window', '$document', function($browser, $window, $document) { - return createHttpBackend($browser, createXhr, $browser.defer, $window.angular.callbacks, $document[0]); - }]; -} - -function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDocument) { - var ABORTED = -1; - - // TODO(vojta): fix the signature - return function(method, url, post, callback, headers, timeout, withCredentials, responseType) { - var status; - $browser.$$incOutstandingRequestCount(); - url = url || $browser.url(); - - if (lowercase(method) == 'jsonp') { - var callbackId = '_' + (callbacks.counter++).toString(36); - callbacks[callbackId] = function(data) { - callbacks[callbackId].data = data; - callbacks[callbackId].called = true; - }; - - var jsonpDone = jsonpReq(url.replace('JSON_CALLBACK', 'angular.callbacks.' + callbackId), - callbackId, function(status, text) { - completeRequest(callback, status, callbacks[callbackId].data, "", text); - callbacks[callbackId] = noop; - }); - } else { - - var xhr = createXhr(method); - - xhr.open(method, url, true); - forEach(headers, function(value, key) { - if (isDefined(value)) { - xhr.setRequestHeader(key, value); - } - }); - - // In IE6 and 7, this might be called synchronously when xhr.send below is called and the - // response is in the cache. the promise api will ensure that to the app code the api is - // always async - xhr.onreadystatechange = function() { - // onreadystatechange might get called multiple times with readyState === 4 on mobile webkit caused by - // xhrs that are resolved while the app is in the background (see #5426). - // since calling completeRequest sets the `xhr` variable to null, we just check if it's not null before - // continuing - // - // we can't set xhr.onreadystatechange to undefined or delete it because that breaks IE8 (method=PATCH) and - // Safari respectively. - if (xhr && xhr.readyState == 4) { - var responseHeaders = null, - response = null, - statusText = ''; - - if(status !== ABORTED) { - responseHeaders = xhr.getAllResponseHeaders(); - - // responseText is the old-school way of retrieving response (supported by IE8 & 9) - // response/responseType properties were introduced in XHR Level2 spec (supported by IE10) - response = ('response' in xhr) ? xhr.response : xhr.responseText; - } - - // Accessing statusText on an aborted xhr object will - // throw an 'c00c023f error' in IE9 and lower, don't touch it. - if (!(status === ABORTED && msie < 10)) { - statusText = xhr.statusText; - } - - completeRequest(callback, - status || xhr.status, - response, - responseHeaders, - statusText); - } - }; - - if (withCredentials) { - xhr.withCredentials = true; - } - - if (responseType) { - try { - xhr.responseType = responseType; - } catch (e) { - // WebKit added support for the json responseType value on 09/03/2013 - // https://bugs.webkit.org/show_bug.cgi?id=73648. Versions of Safari prior to 7 are - // known to throw when setting the value "json" as the response type. Other older - // browsers implementing the responseType - // - // The json response type can be ignored if not supported, because JSON payloads are - // parsed on the client-side regardless. - if (responseType !== 'json') { - throw e; - } - } - } - - xhr.send(post || null); - } - - if (timeout > 0) { - var timeoutId = $browserDefer(timeoutRequest, timeout); - } else if (isPromiseLike(timeout)) { - timeout.then(timeoutRequest); - } - - - function timeoutRequest() { - status = ABORTED; - jsonpDone && jsonpDone(); - xhr && xhr.abort(); - } - - function completeRequest(callback, status, response, headersString, statusText) { - // cancel timeout and subsequent timeout promise resolution - timeoutId && $browserDefer.cancel(timeoutId); - jsonpDone = xhr = null; - - // fix status code when it is 0 (0 status is undocumented). - // Occurs when accessing file resources or on Android 4.1 stock browser - // while retrieving files from application cache. - if (status === 0) { - status = response ? 200 : urlResolve(url).protocol == 'file' ? 404 : 0; - } - - // normalize IE bug (http://bugs.jquery.com/ticket/1450) - status = status === 1223 ? 204 : status; - statusText = statusText || ''; - - callback(status, response, headersString, statusText); - $browser.$$completeOutstandingRequest(noop); - } - }; - - function jsonpReq(url, callbackId, done) { - // we can't use jQuery/jqLite here because jQuery does crazy shit with script elements, e.g.: - // - fetches local scripts via XHR and evals them - // - adds and immediately removes script elements from the document - var script = rawDocument.createElement('script'), callback = null; - script.type = "text/javascript"; - script.src = url; - script.async = true; - - callback = function(event) { - removeEventListenerFn(script, "load", callback); - removeEventListenerFn(script, "error", callback); - rawDocument.body.removeChild(script); - script = null; - var status = -1; - var text = "unknown"; - - if (event) { - if (event.type === "load" && !callbacks[callbackId].called) { - event = { type: "error" }; - } - text = event.type; - status = event.type === "error" ? 404 : 200; - } - - if (done) { - done(status, text); - } - }; - - addEventListenerFn(script, "load", callback); - addEventListenerFn(script, "error", callback); - - if (msie <= 8) { - script.onreadystatechange = function() { - if (isString(script.readyState) && /loaded|complete/.test(script.readyState)) { - script.onreadystatechange = null; - callback({ - type: 'load' - }); - } - }; - } - - rawDocument.body.appendChild(script); - return callback; - } -} - -var $interpolateMinErr = minErr('$interpolate'); - -/** - * @ngdoc provider - * @name $interpolateProvider - * @kind function - * - * @description - * - * Used for configuring the interpolation markup. Defaults to `{{` and `}}`. - * - * @example - - - -
- //demo.label// -
-
- - it('should interpolate binding with custom symbols', function() { - expect(element(by.binding('demo.label')).getText()).toBe('This binding is brought you by // interpolation symbols.'); - }); - -
- */ -function $InterpolateProvider() { - var startSymbol = '{{'; - var endSymbol = '}}'; - - /** - * @ngdoc method - * @name $interpolateProvider#startSymbol - * @description - * Symbol to denote start of expression in the interpolated string. Defaults to `{{`. - * - * @param {string=} value new value to set the starting symbol to. - * @returns {string|self} Returns the symbol when used as getter and self if used as setter. - */ - this.startSymbol = function(value){ - if (value) { - startSymbol = value; - return this; - } else { - return startSymbol; - } - }; - - /** - * @ngdoc method - * @name $interpolateProvider#endSymbol - * @description - * Symbol to denote the end of expression in the interpolated string. Defaults to `}}`. - * - * @param {string=} value new value to set the ending symbol to. - * @returns {string|self} Returns the symbol when used as getter and self if used as setter. - */ - this.endSymbol = function(value){ - if (value) { - endSymbol = value; - return this; - } else { - return endSymbol; - } - }; - - - this.$get = ['$parse', '$exceptionHandler', '$sce', function($parse, $exceptionHandler, $sce) { - var startSymbolLength = startSymbol.length, - endSymbolLength = endSymbol.length; - - /** - * @ngdoc service - * @name $interpolate - * @kind function - * - * @requires $parse - * @requires $sce - * - * @description - * - * Compiles a string with markup into an interpolation function. This service is used by the - * HTML {@link ng.$compile $compile} service for data binding. See - * {@link ng.$interpolateProvider $interpolateProvider} for configuring the - * interpolation markup. - * - * - * ```js - * var $interpolate = ...; // injected - * var exp = $interpolate('Hello {{name | uppercase}}!'); - * expect(exp({name:'Angular'}).toEqual('Hello ANGULAR!'); - * ``` - * - * - * @param {string} text The text with markup to interpolate. - * @param {boolean=} mustHaveExpression if set to true then the interpolation string must have - * embedded expression in order to return an interpolation function. Strings with no - * embedded expression will return null for the interpolation function. - * @param {string=} trustedContext when provided, the returned function passes the interpolated - * result through {@link ng.$sce#getTrusted $sce.getTrusted(interpolatedResult, - * trustedContext)} before returning it. Refer to the {@link ng.$sce $sce} service that - * provides Strict Contextual Escaping for details. - * @returns {function(context)} an interpolation function which is used to compute the - * interpolated string. The function has these parameters: - * - * * `context`: an object against which any expressions embedded in the strings are evaluated - * against. - * - */ - function $interpolate(text, mustHaveExpression, trustedContext) { - var startIndex, - endIndex, - index = 0, - parts = [], - length = text.length, - hasInterpolation = false, - fn, - exp, - concat = []; - - while(index < length) { - if ( ((startIndex = text.indexOf(startSymbol, index)) != -1) && - ((endIndex = text.indexOf(endSymbol, startIndex + startSymbolLength)) != -1) ) { - (index != startIndex) && parts.push(text.substring(index, startIndex)); - parts.push(fn = $parse(exp = text.substring(startIndex + startSymbolLength, endIndex))); - fn.exp = exp; - index = endIndex + endSymbolLength; - hasInterpolation = true; - } else { - // we did not find anything, so we have to add the remainder to the parts array - (index != length) && parts.push(text.substring(index)); - index = length; - } - } - - if (!(length = parts.length)) { - // we added, nothing, must have been an empty string. - parts.push(''); - length = 1; - } - - // Concatenating expressions makes it hard to reason about whether some combination of - // concatenated values are unsafe to use and could easily lead to XSS. By requiring that a - // single expression be used for iframe[src], object[src], etc., we ensure that the value - // that's used is assigned or constructed by some JS code somewhere that is more testable or - // make it obvious that you bound the value to some user controlled value. This helps reduce - // the load when auditing for XSS issues. - if (trustedContext && parts.length > 1) { - throw $interpolateMinErr('noconcat', - "Error while interpolating: {0}\nStrict Contextual Escaping disallows " + - "interpolations that concatenate multiple expressions when a trusted value is " + - "required. See http://docs.angularjs.org/api/ng.$sce", text); - } - - if (!mustHaveExpression || hasInterpolation) { - concat.length = length; - fn = function(context) { - try { - for(var i = 0, ii = length, part; i - * **Note**: Intervals created by this service must be explicitly destroyed when you are finished - * with them. In particular they are not automatically destroyed when a controller's scope or a - * directive's element are destroyed. - * You should take this into consideration and make sure to always cancel the interval at the - * appropriate moment. See the example below for more details on how and when to do this. - * - * - * @param {function()} fn A function that should be called repeatedly. - * @param {number} delay Number of milliseconds between each function call. - * @param {number=} [count=0] Number of times to repeat. If not set, or 0, will repeat - * indefinitely. - * @param {boolean=} [invokeApply=true] If set to `false` skips model dirty checking, otherwise - * will invoke `fn` within the {@link ng.$rootScope.Scope#$apply $apply} block. - * @returns {promise} A promise which will be notified on each iteration. - * - * @example - * - * - * - * - *
- *
- * Date format:
- * Current time is: - *
- * Blood 1 : {{blood_1}} - * Blood 2 : {{blood_2}} - * - * - * - *
- *
- * - *
- *
- */ - function interval(fn, delay, count, invokeApply) { - var setInterval = $window.setInterval, - clearInterval = $window.clearInterval, - deferred = $q.defer(), - promise = deferred.promise, - iteration = 0, - skipApply = (isDefined(invokeApply) && !invokeApply); - - count = isDefined(count) ? count : 0; - - promise.then(null, null, fn); - - promise.$$intervalId = setInterval(function tick() { - deferred.notify(iteration++); - - if (count > 0 && iteration >= count) { - deferred.resolve(iteration); - clearInterval(promise.$$intervalId); - delete intervals[promise.$$intervalId]; - } - - if (!skipApply) $rootScope.$apply(); - - }, delay); - - intervals[promise.$$intervalId] = deferred; - - return promise; - } - - - /** - * @ngdoc method - * @name $interval#cancel - * - * @description - * Cancels a task associated with the `promise`. - * - * @param {promise} promise returned by the `$interval` function. - * @returns {boolean} Returns `true` if the task was successfully canceled. - */ - interval.cancel = function(promise) { - if (promise && promise.$$intervalId in intervals) { - intervals[promise.$$intervalId].reject('canceled'); - $window.clearInterval(promise.$$intervalId); - delete intervals[promise.$$intervalId]; - return true; - } - return false; - }; - - return interval; - }]; -} - -/** - * @ngdoc service - * @name $locale - * - * @description - * $locale service provides localization rules for various Angular components. As of right now the - * only public api is: - * - * * `id` – `{string}` – locale id formatted as `languageId-countryId` (e.g. `en-us`) - */ -function $LocaleProvider(){ - this.$get = function() { - return { - id: 'en-us', - - NUMBER_FORMATS: { - DECIMAL_SEP: '.', - GROUP_SEP: ',', - PATTERNS: [ - { // Decimal Pattern - minInt: 1, - minFrac: 0, - maxFrac: 3, - posPre: '', - posSuf: '', - negPre: '-', - negSuf: '', - gSize: 3, - lgSize: 3 - },{ //Currency Pattern - minInt: 1, - minFrac: 2, - maxFrac: 2, - posPre: '\u00A4', - posSuf: '', - negPre: '(\u00A4', - negSuf: ')', - gSize: 3, - lgSize: 3 - } - ], - CURRENCY_SYM: '$' - }, - - DATETIME_FORMATS: { - MONTH: - 'January,February,March,April,May,June,July,August,September,October,November,December' - .split(','), - SHORTMONTH: 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'.split(','), - DAY: 'Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday'.split(','), - SHORTDAY: 'Sun,Mon,Tue,Wed,Thu,Fri,Sat'.split(','), - AMPMS: ['AM','PM'], - medium: 'MMM d, y h:mm:ss a', - short: 'M/d/yy h:mm a', - fullDate: 'EEEE, MMMM d, y', - longDate: 'MMMM d, y', - mediumDate: 'MMM d, y', - shortDate: 'M/d/yy', - mediumTime: 'h:mm:ss a', - shortTime: 'h:mm a' - }, - - pluralCat: function(num) { - if (num === 1) { - return 'one'; - } - return 'other'; - } - }; - }; -} - -var PATH_MATCH = /^([^\?#]*)(\?([^#]*))?(#(.*))?$/, - DEFAULT_PORTS = {'http': 80, 'https': 443, 'ftp': 21}; -var $locationMinErr = minErr('$location'); - - -/** - * Encode path using encodeUriSegment, ignoring forward slashes - * - * @param {string} path Path to encode - * @returns {string} - */ -function encodePath(path) { - var segments = path.split('/'), - i = segments.length; - - while (i--) { - segments[i] = encodeUriSegment(segments[i]); - } - - return segments.join('/'); -} - -function parseAbsoluteUrl(absoluteUrl, locationObj, appBase) { - var parsedUrl = urlResolve(absoluteUrl, appBase); - - locationObj.$$protocol = parsedUrl.protocol; - locationObj.$$host = parsedUrl.hostname; - locationObj.$$port = int(parsedUrl.port) || DEFAULT_PORTS[parsedUrl.protocol] || null; -} - - -function parseAppUrl(relativeUrl, locationObj, appBase) { - var prefixed = (relativeUrl.charAt(0) !== '/'); - if (prefixed) { - relativeUrl = '/' + relativeUrl; - } - var match = urlResolve(relativeUrl, appBase); - locationObj.$$path = decodeURIComponent(prefixed && match.pathname.charAt(0) === '/' ? - match.pathname.substring(1) : match.pathname); - locationObj.$$search = parseKeyValue(match.search); - locationObj.$$hash = decodeURIComponent(match.hash); - - // make sure path starts with '/'; - if (locationObj.$$path && locationObj.$$path.charAt(0) != '/') { - locationObj.$$path = '/' + locationObj.$$path; - } -} - - -/** - * - * @param {string} begin - * @param {string} whole - * @returns {string} returns text from whole after begin or undefined if it does not begin with - * expected string. - */ -function beginsWith(begin, whole) { - if (whole.indexOf(begin) === 0) { - return whole.substr(begin.length); - } -} - - -function stripHash(url) { - var index = url.indexOf('#'); - return index == -1 ? url : url.substr(0, index); -} - - -function stripFile(url) { - return url.substr(0, stripHash(url).lastIndexOf('/') + 1); -} - -/* return the server only (scheme://host:port) */ -function serverBase(url) { - return url.substring(0, url.indexOf('/', url.indexOf('//') + 2)); -} - - -/** - * LocationHtml5Url represents an url - * This object is exposed as $location service when HTML5 mode is enabled and supported - * - * @constructor - * @param {string} appBase application base URL - * @param {string} basePrefix url path prefix - */ -function LocationHtml5Url(appBase, basePrefix) { - this.$$html5 = true; - basePrefix = basePrefix || ''; - var appBaseNoFile = stripFile(appBase); - parseAbsoluteUrl(appBase, this, appBase); - - - /** - * Parse given html5 (regular) url string into properties - * @param {string} newAbsoluteUrl HTML5 url - * @private - */ - this.$$parse = function(url) { - var pathUrl = beginsWith(appBaseNoFile, url); - if (!isString(pathUrl)) { - throw $locationMinErr('ipthprfx', 'Invalid url "{0}", missing path prefix "{1}".', url, - appBaseNoFile); - } - - parseAppUrl(pathUrl, this, appBase); - - if (!this.$$path) { - this.$$path = '/'; - } - - this.$$compose(); - }; - - /** - * Compose url and update `absUrl` property - * @private - */ - this.$$compose = function() { - var search = toKeyValue(this.$$search), - hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : ''; - - this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash; - this.$$absUrl = appBaseNoFile + this.$$url.substr(1); // first char is always '/' - }; - - this.$$rewrite = function(url) { - var appUrl, prevAppUrl; - - if ( (appUrl = beginsWith(appBase, url)) !== undefined ) { - prevAppUrl = appUrl; - if ( (appUrl = beginsWith(basePrefix, appUrl)) !== undefined ) { - return appBaseNoFile + (beginsWith('/', appUrl) || appUrl); - } else { - return appBase + prevAppUrl; - } - } else if ( (appUrl = beginsWith(appBaseNoFile, url)) !== undefined ) { - return appBaseNoFile + appUrl; - } else if (appBaseNoFile == url + '/') { - return appBaseNoFile; - } - }; -} - - -/** - * LocationHashbangUrl represents url - * This object is exposed as $location service when developer doesn't opt into html5 mode. - * It also serves as the base class for html5 mode fallback on legacy browsers. - * - * @constructor - * @param {string} appBase application base URL - * @param {string} hashPrefix hashbang prefix - */ -function LocationHashbangUrl(appBase, hashPrefix) { - var appBaseNoFile = stripFile(appBase); - - parseAbsoluteUrl(appBase, this, appBase); - - - /** - * Parse given hashbang url into properties - * @param {string} url Hashbang url - * @private - */ - this.$$parse = function(url) { - var withoutBaseUrl = beginsWith(appBase, url) || beginsWith(appBaseNoFile, url); - var withoutHashUrl = withoutBaseUrl.charAt(0) == '#' - ? beginsWith(hashPrefix, withoutBaseUrl) - : (this.$$html5) - ? withoutBaseUrl - : ''; - - if (!isString(withoutHashUrl)) { - throw $locationMinErr('ihshprfx', 'Invalid url "{0}", missing hash prefix "{1}".', url, - hashPrefix); - } - parseAppUrl(withoutHashUrl, this, appBase); - - this.$$path = removeWindowsDriveName(this.$$path, withoutHashUrl, appBase); - - this.$$compose(); - - /* - * In Windows, on an anchor node on documents loaded from - * the filesystem, the browser will return a pathname - * prefixed with the drive name ('/C:/path') when a - * pathname without a drive is set: - * * a.setAttribute('href', '/foo') - * * a.pathname === '/C:/foo' //true - * - * Inside of Angular, we're always using pathnames that - * do not include drive names for routing. - */ - function removeWindowsDriveName (path, url, base) { - /* - Matches paths for file protocol on windows, - such as /C:/foo/bar, and captures only /foo/bar. - */ - var windowsFilePathExp = /^\/[A-Z]:(\/.*)/; - - var firstPathSegmentMatch; - - //Get the relative path from the input URL. - if (url.indexOf(base) === 0) { - url = url.replace(base, ''); - } - - // The input URL intentionally contains a first path segment that ends with a colon. - if (windowsFilePathExp.exec(url)) { - return path; - } - - firstPathSegmentMatch = windowsFilePathExp.exec(path); - return firstPathSegmentMatch ? firstPathSegmentMatch[1] : path; - } - }; - - /** - * Compose hashbang url and update `absUrl` property - * @private - */ - this.$$compose = function() { - var search = toKeyValue(this.$$search), - hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : ''; - - this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash; - this.$$absUrl = appBase + (this.$$url ? hashPrefix + this.$$url : ''); - }; - - this.$$rewrite = function(url) { - if(stripHash(appBase) == stripHash(url)) { - return url; - } - }; -} - - -/** - * LocationHashbangUrl represents url - * This object is exposed as $location service when html5 history api is enabled but the browser - * does not support it. - * - * @constructor - * @param {string} appBase application base URL - * @param {string} hashPrefix hashbang prefix - */ -function LocationHashbangInHtml5Url(appBase, hashPrefix) { - this.$$html5 = true; - LocationHashbangUrl.apply(this, arguments); - - var appBaseNoFile = stripFile(appBase); - - this.$$rewrite = function(url) { - var appUrl; - - if ( appBase == stripHash(url) ) { - return url; - } else if ( (appUrl = beginsWith(appBaseNoFile, url)) ) { - return appBase + hashPrefix + appUrl; - } else if ( appBaseNoFile === url + '/') { - return appBaseNoFile; - } - }; - - this.$$compose = function() { - var search = toKeyValue(this.$$search), - hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : ''; - - this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash; - // include hashPrefix in $$absUrl when $$url is empty so IE8 & 9 do not reload page because of removal of '#' - this.$$absUrl = appBase + hashPrefix + this.$$url; - }; - -} - - -LocationHashbangInHtml5Url.prototype = - LocationHashbangUrl.prototype = - LocationHtml5Url.prototype = { - - /** - * Are we in html5 mode? - * @private - */ - $$html5: false, - - /** - * Has any change been replacing ? - * @private - */ - $$replace: false, - - /** - * @ngdoc method - * @name $location#absUrl - * - * @description - * This method is getter only. - * - * Return full url representation with all segments encoded according to rules specified in - * [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). - * - * @return {string} full url - */ - absUrl: locationGetter('$$absUrl'), - - /** - * @ngdoc method - * @name $location#url - * - * @description - * This method is getter / setter. - * - * Return url (e.g. `/path?a=b#hash`) when called without any parameter. - * - * Change path, search and hash, when called with parameter and return `$location`. - * - * @param {string=} url New url without base prefix (e.g. `/path?a=b#hash`) - * @return {string} url - */ - url: function(url) { - if (isUndefined(url)) - return this.$$url; - - var match = PATH_MATCH.exec(url); - if (match[1]) this.path(decodeURIComponent(match[1])); - if (match[2] || match[1]) this.search(match[3] || ''); - this.hash(match[5] || ''); - - return this; - }, - - /** - * @ngdoc method - * @name $location#protocol - * - * @description - * This method is getter only. - * - * Return protocol of current url. - * - * @return {string} protocol of current url - */ - protocol: locationGetter('$$protocol'), - - /** - * @ngdoc method - * @name $location#host - * - * @description - * This method is getter only. - * - * Return host of current url. - * - * @return {string} host of current url. - */ - host: locationGetter('$$host'), - - /** - * @ngdoc method - * @name $location#port - * - * @description - * This method is getter only. - * - * Return port of current url. - * - * @return {Number} port - */ - port: locationGetter('$$port'), - - /** - * @ngdoc method - * @name $location#path - * - * @description - * This method is getter / setter. - * - * Return path of current url when called without any parameter. - * - * Change path when called with parameter and return `$location`. - * - * Note: Path should always begin with forward slash (/), this method will add the forward slash - * if it is missing. - * - * @param {(string|number)=} path New path - * @return {string} path - */ - path: locationGetterSetter('$$path', function(path) { - path = path ? path.toString() : ''; - return path.charAt(0) == '/' ? path : '/' + path; - }), - - /** - * @ngdoc method - * @name $location#search - * - * @description - * This method is getter / setter. - * - * Return search part (as object) of current url when called without any parameter. - * - * Change search part when called with parameter and return `$location`. - * - * - * ```js - * // given url http://example.com/#/some/path?foo=bar&baz=xoxo - * var searchObject = $location.search(); - * // => {foo: 'bar', baz: 'xoxo'} - * - * - * // set foo to 'yipee' - * $location.search('foo', 'yipee'); - * // => $location - * ``` - * - * @param {string|Object.|Object.>} search New search params - string or - * hash object. - * - * When called with a single argument the method acts as a setter, setting the `search` component - * of `$location` to the specified value. - * - * If the argument is a hash object containing an array of values, these values will be encoded - * as duplicate search parameters in the url. - * - * @param {(string|Number|Array|boolean)=} paramValue If `search` is a string or number, then `paramValue` - * will override only a single search property. - * - * If `paramValue` is an array, it will override the property of the `search` component of - * `$location` specified via the first argument. - * - * If `paramValue` is `null`, the property specified via the first argument will be deleted. - * - * If `paramValue` is `true`, the property specified via the first argument will be added with no - * value nor trailing equal sign. - * - * @return {Object} If called with no arguments returns the parsed `search` object. If called with - * one or more arguments returns `$location` object itself. - */ - search: function(search, paramValue) { - switch (arguments.length) { - case 0: - return this.$$search; - case 1: - if (isString(search) || isNumber(search)) { - search = search.toString(); - this.$$search = parseKeyValue(search); - } else if (isObject(search)) { - // remove object undefined or null properties - forEach(search, function(value, key) { - if (value == null) delete search[key]; - }); - - this.$$search = search; - } else { - throw $locationMinErr('isrcharg', - 'The first argument of the `$location#search()` call must be a string or an object.'); - } - break; - default: - if (isUndefined(paramValue) || paramValue === null) { - delete this.$$search[search]; - } else { - this.$$search[search] = paramValue; - } - } - - this.$$compose(); - return this; - }, - - /** - * @ngdoc method - * @name $location#hash - * - * @description - * This method is getter / setter. - * - * Return hash fragment when called without any parameter. - * - * Change hash fragment when called with parameter and return `$location`. - * - * @param {(string|number)=} hash New hash fragment - * @return {string} hash - */ - hash: locationGetterSetter('$$hash', function(hash) { - return hash ? hash.toString() : ''; - }), - - /** - * @ngdoc method - * @name $location#replace - * - * @description - * If called, all changes to $location during current `$digest` will be replacing current history - * record, instead of adding new one. - */ - replace: function() { - this.$$replace = true; - return this; - } -}; - -function locationGetter(property) { - return function() { - return this[property]; - }; -} - - -function locationGetterSetter(property, preprocess) { - return function(value) { - if (isUndefined(value)) - return this[property]; - - this[property] = preprocess(value); - this.$$compose(); - - return this; - }; -} - - -/** - * @ngdoc service - * @name $location - * - * @requires $rootElement - * - * @description - * The $location service parses the URL in the browser address bar (based on the - * [window.location](https://developer.mozilla.org/en/window.location)) and makes the URL - * available to your application. Changes to the URL in the address bar are reflected into - * $location service and changes to $location are reflected into the browser address bar. - * - * **The $location service:** - * - * - Exposes the current URL in the browser address bar, so you can - * - Watch and observe the URL. - * - Change the URL. - * - Synchronizes the URL with the browser when the user - * - Changes the address bar. - * - Clicks the back or forward button (or clicks a History link). - * - Clicks on a link. - * - Represents the URL object as a set of methods (protocol, host, port, path, search, hash). - * - * For more information see {@link guide/$location Developer Guide: Using $location} - */ - -/** - * @ngdoc provider - * @name $locationProvider - * @description - * Use the `$locationProvider` to configure how the application deep linking paths are stored. - */ -function $LocationProvider(){ - var hashPrefix = '', - html5Mode = false; - - /** - * @ngdoc method - * @name $locationProvider#hashPrefix - * @description - * @param {string=} prefix Prefix for hash part (containing path and search) - * @returns {*} current value if used as getter or itself (chaining) if used as setter - */ - this.hashPrefix = function(prefix) { - if (isDefined(prefix)) { - hashPrefix = prefix; - return this; - } else { - return hashPrefix; - } - }; - - /** - * @ngdoc method - * @name $locationProvider#html5Mode - * @description - * @param {boolean=} mode Use HTML5 strategy if available. - * @returns {*} current value if used as getter or itself (chaining) if used as setter - */ - this.html5Mode = function(mode) { - if (isDefined(mode)) { - html5Mode = mode; - return this; - } else { - return html5Mode; - } - }; - - /** - * @ngdoc event - * @name $location#$locationChangeStart - * @eventType broadcast on root scope - * @description - * Broadcasted before a URL will change. This change can be prevented by calling - * `preventDefault` method of the event. See {@link ng.$rootScope.Scope#$on} for more - * details about event object. Upon successful change - * {@link ng.$location#events_$locationChangeSuccess $locationChangeSuccess} is fired. - * - * @param {Object} angularEvent Synthetic event object. - * @param {string} newUrl New URL - * @param {string=} oldUrl URL that was before it was changed. - */ - - /** - * @ngdoc event - * @name $location#$locationChangeSuccess - * @eventType broadcast on root scope - * @description - * Broadcasted after a URL was changed. - * - * @param {Object} angularEvent Synthetic event object. - * @param {string} newUrl New URL - * @param {string=} oldUrl URL that was before it was changed. - */ - - this.$get = ['$rootScope', '$browser', '$sniffer', '$rootElement', - function( $rootScope, $browser, $sniffer, $rootElement) { - var $location, - LocationMode, - baseHref = $browser.baseHref(), // if base[href] is undefined, it defaults to '' - initialUrl = $browser.url(), - appBase; - - if (html5Mode) { - appBase = serverBase(initialUrl) + (baseHref || '/'); - LocationMode = $sniffer.history ? LocationHtml5Url : LocationHashbangInHtml5Url; - } else { - appBase = stripHash(initialUrl); - LocationMode = LocationHashbangUrl; - } - $location = new LocationMode(appBase, '#' + hashPrefix); - $location.$$parse($location.$$rewrite(initialUrl)); - - var IGNORE_URI_REGEXP = /^\s*(javascript|mailto):/i; - - $rootElement.on('click', function(event) { - // TODO(vojta): rewrite link when opening in new tab/window (in legacy browser) - // currently we open nice url link and redirect then - - if (event.ctrlKey || event.metaKey || event.which == 2) return; - - var elm = jqLite(event.target); - - // traverse the DOM up to find first A tag - while (lowercase(elm[0].nodeName) !== 'a') { - // ignore rewriting if no A tag (reached root element, or no parent - removed from document) - if (elm[0] === $rootElement[0] || !(elm = elm.parent())[0]) return; - } - - var absHref = elm.prop('href'); - - if (isObject(absHref) && absHref.toString() === '[object SVGAnimatedString]') { - // SVGAnimatedString.animVal should be identical to SVGAnimatedString.baseVal, unless during - // an animation. - absHref = urlResolve(absHref.animVal).href; - } - - // Ignore when url is started with javascript: or mailto: - if (IGNORE_URI_REGEXP.test(absHref)) return; - - // Make relative links work in HTML5 mode for legacy browsers (or at least IE8 & 9) - // The href should be a regular url e.g. /link/somewhere or link/somewhere or ../somewhere or - // somewhere#anchor or http://example.com/somewhere - if (LocationMode === LocationHashbangInHtml5Url) { - // get the actual href attribute - see - // http://msdn.microsoft.com/en-us/library/ie/dd347148(v=vs.85).aspx - var href = elm.attr('href') || elm.attr('xlink:href'); - - if (href && href.indexOf('://') < 0) { // Ignore absolute URLs - var prefix = '#' + hashPrefix; - if (href[0] == '/') { - // absolute path - replace old path - absHref = appBase + prefix + href; - } else if (href[0] == '#') { - // local anchor - absHref = appBase + prefix + ($location.path() || '/') + href; - } else { - // relative path - join with current path - var stack = $location.path().split("/"), - parts = href.split("/"); - if (stack.length === 2 && !stack[1]) stack.length = 1; - for (var i=0; i html5 url - if ($location.absUrl() != initialUrl) { - $browser.url(http://github.com/$location.absUrl(), true); - } - - // update $location when $browser url changes - $browser.onUrlChange(function(newUrl) { - if ($location.absUrl() != newUrl) { - $rootScope.$evalAsync(function() { - var oldUrl = $location.absUrl(); - - $location.$$parse(newUrl); - if ($rootScope.$broadcast('$locationChangeStart', newUrl, - oldUrl).defaultPrevented) { - $location.$$parse(oldUrl); - $browser.url(http://github.com/oldUrl); - } else { - afterLocationChange(oldUrl); - } - }); - if (!$rootScope.$$phase) $rootScope.$digest(); - } - }); - - // update browser - var changeCounter = 0; - $rootScope.$watch(function $locationWatch() { - var oldUrl = $browser.url(); - var currentReplace = $location.$$replace; - - if (!changeCounter || oldUrl != $location.absUrl()) { - changeCounter++; - $rootScope.$evalAsync(function() { - if ($rootScope.$broadcast('$locationChangeStart', $location.absUrl(), oldUrl). - defaultPrevented) { - $location.$$parse(oldUrl); - } else { - $browser.url(http://github.com/$location.absUrl(), currentReplace); - afterLocationChange(oldUrl); - } - }); - } - $location.$$replace = false; - - return changeCounter; - }); - - return $location; - - function afterLocationChange(oldUrl) { - $rootScope.$broadcast('$locationChangeSuccess', $location.absUrl(), oldUrl); - } -}]; -} - -/** - * @ngdoc service - * @name $log - * @requires $window - * - * @description - * Simple service for logging. Default implementation safely writes the message - * into the browser's console (if present). - * - * The main purpose of this service is to simplify debugging and troubleshooting. - * - * The default is to log `debug` messages. You can use - * {@link ng.$logProvider ng.$logProvider#debugEnabled} to change this. - * - * @example - - - angular.module('logExample', []) - .controller('LogController', ['$scope', '$log', function($scope, $log) { - $scope.$log = $log; - $scope.message = 'Hello World!'; - }]); - - -
-

Reload this page with open console, enter text and hit the log button...

- Message: - - - - - -
-
-
- */ - -/** - * @ngdoc provider - * @name $logProvider - * @description - * Use the `$logProvider` to configure how the application logs messages - */ -function $LogProvider(){ - var debug = true, - self = this; - - /** - * @ngdoc method - * @name $logProvider#debugEnabled - * @description - * @param {boolean=} flag enable or disable debug level messages - * @returns {*} current value if used as getter or itself (chaining) if used as setter - */ - this.debugEnabled = function(flag) { - if (isDefined(flag)) { - debug = flag; - return this; - } else { - return debug; - } - }; - - this.$get = ['$window', function($window){ - return { - /** - * @ngdoc method - * @name $log#log - * - * @description - * Write a log message - */ - log: consoleLog('log'), - - /** - * @ngdoc method - * @name $log#info - * - * @description - * Write an information message - */ - info: consoleLog('info'), - - /** - * @ngdoc method - * @name $log#warn - * - * @description - * Write a warning message - */ - warn: consoleLog('warn'), - - /** - * @ngdoc method - * @name $log#error - * - * @description - * Write an error message - */ - error: consoleLog('error'), - - /** - * @ngdoc method - * @name $log#debug - * - * @description - * Write a debug message - */ - debug: (function () { - var fn = consoleLog('debug'); - - return function() { - if (debug) { - fn.apply(self, arguments); - } - }; - }()) - }; - - function formatError(arg) { - if (arg instanceof Error) { - if (arg.stack) { - arg = (arg.message && arg.stack.indexOf(arg.message) === -1) - ? 'Error: ' + arg.message + '\n' + arg.stack - : arg.stack; - } else if (arg.sourceURL) { - arg = arg.message + '\n' + arg.sourceURL + ':' + arg.line; - } - } - return arg; - } - - function consoleLog(type) { - var console = $window.console || {}, - logFn = console[type] || console.log || noop, - hasApply = false; - - // Note: reading logFn.apply throws an error in IE11 in IE8 document mode. - // The reason behind this is that console.log has type "object" in IE8... - try { - hasApply = !!logFn.apply; - } catch (e) {} - - if (hasApply) { - return function() { - var args = []; - forEach(arguments, function(arg) { - args.push(formatError(arg)); - }); - return logFn.apply(console, args); - }; - } - - // we are IE which either doesn't have window.console => this is noop and we do nothing, - // or we are IE where console.log doesn't have apply so we log at least first 2 args - return function(arg1, arg2) { - logFn(arg1, arg2 == null ? '' : arg2); - }; - } - }]; -} - -var $parseMinErr = minErr('$parse'); -var promiseWarningCache = {}; -var promiseWarning; - -// Sandboxing Angular Expressions -// ------------------------------ -// Angular expressions are generally considered safe because these expressions only have direct -// access to $scope and locals. However, one can obtain the ability to execute arbitrary JS code by -// obtaining a reference to native JS functions such as the Function constructor. -// -// As an example, consider the following Angular expression: -// -// {}.toString.constructor('alert("evil JS code")') -// -// This sandboxing technique is not perfect and doesn't aim to be. The goal is to prevent exploits -// against the expression language, but not to prevent exploits that were enabled by exposing -// sensitive JavaScript or browser apis on Scope. Exposing such objects on a Scope is never a good -// practice and therefore we are not even trying to protect against interaction with an object -// explicitly exposed in this way. -// -// In general, it is not possible to access a Window object from an angular expression unless a -// window or some DOM object that has a reference to window is published onto a Scope. -// Similarly we prevent invocations of function known to be dangerous, as well as assignments to -// native objects. - - -function ensureSafeMemberName(name, fullExpression) { - if (name === "__defineGetter__" || name === "__defineSetter__" - || name === "__lookupGetter__" || name === "__lookupSetter__" - || name === "__proto__") { - throw $parseMinErr('isecfld', - 'Attempting to access a disallowed field in Angular expressions! ' - +'Expression: {0}', fullExpression); - } - return name; -} - -function ensureSafeObject(obj, fullExpression) { - // nifty check if obj is Function that is fast and works across iframes and other contexts - if (obj) { - if (obj.constructor === obj) { - throw $parseMinErr('isecfn', - 'Referencing Function in Angular expressions is disallowed! Expression: {0}', - fullExpression); - } else if (// isWindow(obj) - obj.document && obj.location && obj.alert && obj.setInterval) { - throw $parseMinErr('isecwindow', - 'Referencing the Window in Angular expressions is disallowed! Expression: {0}', - fullExpression); - } else if (// isElement(obj) - obj.children && (obj.nodeName || (obj.prop && obj.attr && obj.find))) { - throw $parseMinErr('isecdom', - 'Referencing DOM nodes in Angular expressions is disallowed! Expression: {0}', - fullExpression); - } else if (// block Object so that we can't get hold of dangerous Object.* methods - obj === Object) { - throw $parseMinErr('isecobj', - 'Referencing Object in Angular expressions is disallowed! Expression: {0}', - fullExpression); - } - } - return obj; -} - -var CALL = Function.prototype.call; -var APPLY = Function.prototype.apply; -var BIND = Function.prototype.bind; - -function ensureSafeFunction(obj, fullExpression) { - if (obj) { - if (obj.constructor === obj) { - throw $parseMinErr('isecfn', - 'Referencing Function in Angular expressions is disallowed! Expression: {0}', - fullExpression); - } else if (obj === CALL || obj === APPLY || (BIND && obj === BIND)) { - throw $parseMinErr('isecff', - 'Referencing call, apply or bind in Angular expressions is disallowed! Expression: {0}', - fullExpression); - } - } -} - -var OPERATORS = { - /* jshint bitwise : false */ - 'null':function(){return null;}, - 'true':function(){return true;}, - 'false':function(){return false;}, - undefined:noop, - '+':function(self, locals, a,b){ - a=a(self, locals); b=b(self, locals); - if (isDefined(a)) { - if (isDefined(b)) { - return a + b; - } - return a; - } - return isDefined(b)?b:undefined;}, - '-':function(self, locals, a,b){ - a=a(self, locals); b=b(self, locals); - return (isDefined(a)?a:0)-(isDefined(b)?b:0); - }, - '*':function(self, locals, a,b){return a(self, locals)*b(self, locals);}, - '/':function(self, locals, a,b){return a(self, locals)/b(self, locals);}, - '%':function(self, locals, a,b){return a(self, locals)%b(self, locals);}, - '^':function(self, locals, a,b){return a(self, locals)^b(self, locals);}, - '=':noop, - '===':function(self, locals, a, b){return a(self, locals)===b(self, locals);}, - '!==':function(self, locals, a, b){return a(self, locals)!==b(self, locals);}, - '==':function(self, locals, a,b){return a(self, locals)==b(self, locals);}, - '!=':function(self, locals, a,b){return a(self, locals)!=b(self, locals);}, - '<':function(self, locals, a,b){return a(self, locals)':function(self, locals, a,b){return a(self, locals)>b(self, locals);}, - '<=':function(self, locals, a,b){return a(self, locals)<=b(self, locals);}, - '>=':function(self, locals, a,b){return a(self, locals)>=b(self, locals);}, - '&&':function(self, locals, a,b){return a(self, locals)&&b(self, locals);}, - '||':function(self, locals, a,b){return a(self, locals)||b(self, locals);}, - '&':function(self, locals, a,b){return a(self, locals)&b(self, locals);}, -// '|':function(self, locals, a,b){return a|b;}, - '|':function(self, locals, a,b){return b(self, locals)(self, locals, a(self, locals));}, - '!':function(self, locals, a){return !a(self, locals);} -}; -/* jshint bitwise: true */ -var ESCAPE = {"n":"\n", "f":"\f", "r":"\r", "t":"\t", "v":"\v", "'":"'", '"':'"'}; - - -///////////////////////////////////////// - - -/** - * @constructor - */ -var Lexer = function (options) { - this.options = options; -}; - -Lexer.prototype = { - constructor: Lexer, - - lex: function (text) { - this.text = text; - - this.index = 0; - this.ch = undefined; - this.lastCh = ':'; // can start regexp - - this.tokens = []; - - while (this.index < this.text.length) { - this.ch = this.text.charAt(this.index); - if (this.is('"\'')) { - this.readString(this.ch); - } else if (this.isNumber(this.ch) || this.is('.') && this.isNumber(this.peek())) { - this.readNumber(); - } else if (this.isIdent(this.ch)) { - this.readIdent(); - } else if (this.is('(){}[].,;:?')) { - this.tokens.push({ - index: this.index, - text: this.ch - }); - this.index++; - } else if (this.isWhitespace(this.ch)) { - this.index++; - continue; - } else { - var ch2 = this.ch + this.peek(); - var ch3 = ch2 + this.peek(2); - var fn = OPERATORS[this.ch]; - var fn2 = OPERATORS[ch2]; - var fn3 = OPERATORS[ch3]; - if (fn3) { - this.tokens.push({index: this.index, text: ch3, fn: fn3}); - this.index += 3; - } else if (fn2) { - this.tokens.push({index: this.index, text: ch2, fn: fn2}); - this.index += 2; - } else if (fn) { - this.tokens.push({ - index: this.index, - text: this.ch, - fn: fn - }); - this.index += 1; - } else { - this.throwError('Unexpected next character ', this.index, this.index + 1); - } - } - this.lastCh = this.ch; - } - return this.tokens; - }, - - is: function(chars) { - return chars.indexOf(this.ch) !== -1; - }, - - was: function(chars) { - return chars.indexOf(this.lastCh) !== -1; - }, - - peek: function(i) { - var num = i || 1; - return (this.index + num < this.text.length) ? this.text.charAt(this.index + num) : false; - }, - - isNumber: function(ch) { - return ('0' <= ch && ch <= '9'); - }, - - isWhitespace: function(ch) { - // IE treats non-breaking space as \u00A0 - return (ch === ' ' || ch === '\r' || ch === '\t' || - ch === '\n' || ch === '\v' || ch === '\u00A0'); - }, - - isIdent: function(ch) { - return ('a' <= ch && ch <= 'z' || - 'A' <= ch && ch <= 'Z' || - '_' === ch || ch === '$'); - }, - - isExpOperator: function(ch) { - return (ch === '-' || ch === '+' || this.isNumber(ch)); - }, - - throwError: function(error, start, end) { - end = end || this.index; - var colStr = (isDefined(start) - ? 's ' + start + '-' + this.index + ' [' + this.text.substring(start, end) + ']' - : ' ' + end); - throw $parseMinErr('lexerr', 'Lexer Error: {0} at column{1} in expression [{2}].', - error, colStr, this.text); - }, - - readNumber: function() { - var number = ''; - var start = this.index; - while (this.index < this.text.length) { - var ch = lowercase(this.text.charAt(this.index)); - if (ch == '.' || this.isNumber(ch)) { - number += ch; - } else { - var peekCh = this.peek(); - if (ch == 'e' && this.isExpOperator(peekCh)) { - number += ch; - } else if (this.isExpOperator(ch) && - peekCh && this.isNumber(peekCh) && - number.charAt(number.length - 1) == 'e') { - number += ch; - } else if (this.isExpOperator(ch) && - (!peekCh || !this.isNumber(peekCh)) && - number.charAt(number.length - 1) == 'e') { - this.throwError('Invalid exponent'); - } else { - break; - } - } - this.index++; - } - number = 1 * number; - this.tokens.push({ - index: start, - text: number, - literal: true, - constant: true, - fn: function() { return number; } - }); - }, - - readIdent: function() { - var parser = this; - - var ident = ''; - var start = this.index; - - var lastDot, peekIndex, methodName, ch; - - while (this.index < this.text.length) { - ch = this.text.charAt(this.index); - if (ch === '.' || this.isIdent(ch) || this.isNumber(ch)) { - if (ch === '.') lastDot = this.index; - ident += ch; - } else { - break; - } - this.index++; - } - - //check if this is not a method invocation and if it is back out to last dot - if (lastDot) { - peekIndex = this.index; - while (peekIndex < this.text.length) { - ch = this.text.charAt(peekIndex); - if (ch === '(') { - methodName = ident.substr(lastDot - start + 1); - ident = ident.substr(0, lastDot - start); - this.index = peekIndex; - break; - } - if (this.isWhitespace(ch)) { - peekIndex++; - } else { - break; - } - } - } - - - var token = { - index: start, - text: ident - }; - - // OPERATORS is our own object so we don't need to use special hasOwnPropertyFn - if (OPERATORS.hasOwnProperty(ident)) { - token.fn = OPERATORS[ident]; - token.literal = true; - token.constant = true; - } else { - var getter = getterFn(ident, this.options, this.text); - token.fn = extend(function(self, locals) { - return (getter(self, locals)); - }, { - assign: function(self, value) { - return setter(self, ident, value, parser.text, parser.options); - } - }); - } - - this.tokens.push(token); - - if (methodName) { - this.tokens.push({ - index:lastDot, - text: '.' - }); - this.tokens.push({ - index: lastDot + 1, - text: methodName - }); - } - }, - - readString: function(quote) { - var start = this.index; - this.index++; - var string = ''; - var rawString = quote; - var escape = false; - while (this.index < this.text.length) { - var ch = this.text.charAt(this.index); - rawString += ch; - if (escape) { - if (ch === 'u') { - var hex = this.text.substring(this.index + 1, this.index + 5); - if (!hex.match(/[\da-f]{4}/i)) - this.throwError('Invalid unicode escape [\\u' + hex + ']'); - this.index += 4; - string += String.fromCharCode(parseInt(hex, 16)); - } else { - var rep = ESCAPE[ch]; - string = string + (rep || ch); - } - escape = false; - } else if (ch === '\\') { - escape = true; - } else if (ch === quote) { - this.index++; - this.tokens.push({ - index: start, - text: rawString, - string: string, - literal: true, - constant: true, - fn: function() { return string; } - }); - return; - } else { - string += ch; - } - this.index++; - } - this.throwError('Unterminated quote', start); - } -}; - - -/** - * @constructor - */ -var Parser = function (lexer, $filter, options) { - this.lexer = lexer; - this.$filter = $filter; - this.options = options; -}; - -Parser.ZERO = extend(function () { - return 0; -}, { - constant: true -}); - -Parser.prototype = { - constructor: Parser, - - parse: function (text) { - this.text = text; - - this.tokens = this.lexer.lex(text); - - var value = this.statements(); - - if (this.tokens.length !== 0) { - this.throwError('is an unexpected token', this.tokens[0]); - } - - value.literal = !!value.literal; - value.constant = !!value.constant; - - return value; - }, - - primary: function () { - var primary; - if (this.expect('(')) { - primary = this.filterChain(); - this.consume(')'); - } else if (this.expect('[')) { - primary = this.arrayDeclaration(); - } else if (this.expect('{')) { - primary = this.object(); - } else { - var token = this.expect(); - primary = token.fn; - if (!primary) { - this.throwError('not a primary expression', token); - } - primary.literal = !!token.literal; - primary.constant = !!token.constant; - } - - var next, context; - while ((next = this.expect('(', '[', '.'))) { - if (next.text === '(') { - primary = this.functionCall(primary, context); - context = null; - } else if (next.text === '[') { - context = primary; - primary = this.objectIndex(primary); - } else if (next.text === '.') { - context = primary; - primary = this.fieldAccess(primary); - } else { - this.throwError('IMPOSSIBLE'); - } - } - return primary; - }, - - throwError: function(msg, token) { - throw $parseMinErr('syntax', - 'Syntax Error: Token \'{0}\' {1} at column {2} of the expression [{3}] starting at [{4}].', - token.text, msg, (token.index + 1), this.text, this.text.substring(token.index)); - }, - - peekToken: function() { - if (this.tokens.length === 0) - throw $parseMinErr('ueoe', 'Unexpected end of expression: {0}', this.text); - return this.tokens[0]; - }, - - peek: function(e1, e2, e3, e4) { - if (this.tokens.length > 0) { - var token = this.tokens[0]; - var t = token.text; - if (t === e1 || t === e2 || t === e3 || t === e4 || - (!e1 && !e2 && !e3 && !e4)) { - return token; - } - } - return false; - }, - - expect: function(e1, e2, e3, e4){ - var token = this.peek(e1, e2, e3, e4); - if (token) { - this.tokens.shift(); - return token; - } - return false; - }, - - consume: function(e1){ - if (!this.expect(e1)) { - this.throwError('is unexpected, expecting [' + e1 + ']', this.peek()); - } - }, - - unaryFn: function(fn, right) { - return extend(function(self, locals) { - return fn(self, locals, right); - }, { - constant:right.constant - }); - }, - - ternaryFn: function(left, middle, right){ - return extend(function(self, locals){ - return left(self, locals) ? middle(self, locals) : right(self, locals); - }, { - constant: left.constant && middle.constant && right.constant - }); - }, - - binaryFn: function(left, fn, right) { - return extend(function(self, locals) { - return fn(self, locals, left, right); - }, { - constant:left.constant && right.constant - }); - }, - - statements: function() { - var statements = []; - while (true) { - if (this.tokens.length > 0 && !this.peek('}', ')', ';', ']')) - statements.push(this.filterChain()); - if (!this.expect(';')) { - // optimize for the common case where there is only one statement. - // TODO(size): maybe we should not support multiple statements? - return (statements.length === 1) - ? statements[0] - : function(self, locals) { - var value; - for (var i = 0; i < statements.length; i++) { - var statement = statements[i]; - if (statement) { - value = statement(self, locals); - } - } - return value; - }; - } - } - }, - - filterChain: function() { - var left = this.expression(); - var token; - while (true) { - if ((token = this.expect('|'))) { - left = this.binaryFn(left, token.fn, this.filter()); - } else { - return left; - } - } - }, - - filter: function() { - var token = this.expect(); - var fn = this.$filter(token.text); - var argsFn = []; - while (true) { - if ((token = this.expect(':'))) { - argsFn.push(this.expression()); - } else { - var fnInvoke = function(self, locals, input) { - var args = [input]; - for (var i = 0; i < argsFn.length; i++) { - args.push(argsFn[i](self, locals)); - } - return fn.apply(self, args); - }; - return function() { - return fnInvoke; - }; - } - } - }, - - expression: function() { - return this.assignment(); - }, - - assignment: function() { - var left = this.ternary(); - var right; - var token; - if ((token = this.expect('='))) { - if (!left.assign) { - this.throwError('implies assignment but [' + - this.text.substring(0, token.index) + '] can not be assigned to', token); - } - right = this.ternary(); - return function(scope, locals) { - return left.assign(scope, right(scope, locals), locals); - }; - } - return left; - }, - - ternary: function() { - var left = this.logicalOR(); - var middle; - var token; - if ((token = this.expect('?'))) { - middle = this.assignment(); - if ((token = this.expect(':'))) { - return this.ternaryFn(left, middle, this.assignment()); - } else { - this.throwError('expected :', token); - } - } else { - return left; - } - }, - - logicalOR: function() { - var left = this.logicalAND(); - var token; - while (true) { - if ((token = this.expect('||'))) { - left = this.binaryFn(left, token.fn, this.logicalAND()); - } else { - return left; - } - } - }, - - logicalAND: function() { - var left = this.equality(); - var token; - if ((token = this.expect('&&'))) { - left = this.binaryFn(left, token.fn, this.logicalAND()); - } - return left; - }, - - equality: function() { - var left = this.relational(); - var token; - if ((token = this.expect('==','!=','===','!=='))) { - left = this.binaryFn(left, token.fn, this.equality()); - } - return left; - }, - - relational: function() { - var left = this.additive(); - var token; - if ((token = this.expect('<', '>', '<=', '>='))) { - left = this.binaryFn(left, token.fn, this.relational()); - } - return left; - }, - - additive: function() { - var left = this.multiplicative(); - var token; - while ((token = this.expect('+','-'))) { - left = this.binaryFn(left, token.fn, this.multiplicative()); - } - return left; - }, - - multiplicative: function() { - var left = this.unary(); - var token; - while ((token = this.expect('*','/','%'))) { - left = this.binaryFn(left, token.fn, this.unary()); - } - return left; - }, - - unary: function() { - var token; - if (this.expect('+')) { - return this.primary(); - } else if ((token = this.expect('-'))) { - return this.binaryFn(Parser.ZERO, token.fn, this.unary()); - } else if ((token = this.expect('!'))) { - return this.unaryFn(token.fn, this.unary()); - } else { - return this.primary(); - } - }, - - fieldAccess: function(object) { - var parser = this; - var field = this.expect().text; - var getter = getterFn(field, this.options, this.text); - - return extend(function(scope, locals, self) { - return getter(self || object(scope, locals)); - }, { - assign: function(scope, value, locals) { - var o = object(scope, locals); - if (!o) object.assign(scope, o = {}); - return setter(o, field, value, parser.text, parser.options); - } - }); - }, - - objectIndex: function(obj) { - var parser = this; - - var indexFn = this.expression(); - this.consume(']'); - - return extend(function(self, locals) { - var o = obj(self, locals), - i = indexFn(self, locals), - v, p; - - ensureSafeMemberName(i, parser.text); - if (!o) return undefined; - v = ensureSafeObject(o[i], parser.text); - if (v && v.then && parser.options.unwrapPromises) { - p = v; - if (!('$$v' in v)) { - p.$$v = undefined; - p.then(function(val) { p.$$v = val; }); - } - v = v.$$v; - } - return v; - }, { - assign: function(self, value, locals) { - var key = ensureSafeMemberName(indexFn(self, locals), parser.text); - // prevent overwriting of Function.constructor which would break ensureSafeObject check - var o = ensureSafeObject(obj(self, locals), parser.text); - if (!o) obj.assign(self, o = {}); - return o[key] = value; - } - }); - }, - - functionCall: function(fn, contextGetter) { - var argsFn = []; - if (this.peekToken().text !== ')') { - do { - argsFn.push(this.expression()); - } while (this.expect(',')); - } - this.consume(')'); - - var parser = this; - - return function(scope, locals) { - var args = []; - var context = contextGetter ? contextGetter(scope, locals) : scope; - - for (var i = 0; i < argsFn.length; i++) { - args.push(ensureSafeObject(argsFn[i](scope, locals), parser.text)); - } - var fnPtr = fn(scope, locals, context) || noop; - - ensureSafeObject(context, parser.text); - ensureSafeFunction(fnPtr, parser.text); - - // IE stupidity! (IE doesn't have apply for some native functions) - var v = fnPtr.apply - ? fnPtr.apply(context, args) - : fnPtr(args[0], args[1], args[2], args[3], args[4]); - - return ensureSafeObject(v, parser.text); - }; - }, - - // This is used with json array declaration - arrayDeclaration: function () { - var elementFns = []; - var allConstant = true; - if (this.peekToken().text !== ']') { - do { - if (this.peek(']')) { - // Support trailing commas per ES5.1. - break; - } - var elementFn = this.expression(); - elementFns.push(elementFn); - if (!elementFn.constant) { - allConstant = false; - } - } while (this.expect(',')); - } - this.consume(']'); - - return extend(function(self, locals) { - var array = []; - for (var i = 0; i < elementFns.length; i++) { - array.push(elementFns[i](self, locals)); - } - return array; - }, { - literal: true, - constant: allConstant - }); - }, - - object: function () { - var keyValues = []; - var allConstant = true; - if (this.peekToken().text !== '}') { - do { - if (this.peek('}')) { - // Support trailing commas per ES5.1. - break; - } - var token = this.expect(), - key = token.string || token.text; - this.consume(':'); - var value = this.expression(); - keyValues.push({key: key, value: value}); - if (!value.constant) { - allConstant = false; - } - } while (this.expect(',')); - } - this.consume('}'); - - return extend(function(self, locals) { - var object = {}; - for (var i = 0; i < keyValues.length; i++) { - var keyValue = keyValues[i]; - object[keyValue.key] = keyValue.value(self, locals); - } - return object; - }, { - literal: true, - constant: allConstant - }); - } -}; - - -////////////////////////////////////////////////// -// Parser helper functions -////////////////////////////////////////////////// - -function setter(obj, path, setValue, fullExp, options) { - ensureSafeObject(obj, fullExp); - - //needed? - options = options || {}; - - var element = path.split('.'), key; - for (var i = 0; element.length > 1; i++) { - key = ensureSafeMemberName(element.shift(), fullExp); - var propertyObj = ensureSafeObject(obj[key], fullExp); - if (!propertyObj) { - propertyObj = {}; - obj[key] = propertyObj; - } - obj = propertyObj; - if (obj.then && options.unwrapPromises) { - promiseWarning(fullExp); - if (!("$$v" in obj)) { - (function(promise) { - promise.then(function(val) { promise.$$v = val; }); } - )(obj); - } - if (obj.$$v === undefined) { - obj.$$v = {}; - } - obj = obj.$$v; - } - } - key = ensureSafeMemberName(element.shift(), fullExp); - ensureSafeObject(obj[key], fullExp); - obj[key] = setValue; - return setValue; -} - -var getterFnCache = {}; - -/** - * Implementation of the "Black Hole" variant from: - * - http://jsperf.com/angularjs-parse-getter/4 - * - http://jsperf.com/path-evaluation-simplified/7 - */ -function cspSafeGetterFn(key0, key1, key2, key3, key4, fullExp, options) { - ensureSafeMemberName(key0, fullExp); - ensureSafeMemberName(key1, fullExp); - ensureSafeMemberName(key2, fullExp); - ensureSafeMemberName(key3, fullExp); - ensureSafeMemberName(key4, fullExp); - - return !options.unwrapPromises - ? function cspSafeGetter(scope, locals) { - var pathVal = (locals && locals.hasOwnProperty(key0)) ? locals : scope; - - if (pathVal == null) return pathVal; - pathVal = pathVal[key0]; - - if (!key1) return pathVal; - if (pathVal == null) return undefined; - pathVal = pathVal[key1]; - - if (!key2) return pathVal; - if (pathVal == null) return undefined; - pathVal = pathVal[key2]; - - if (!key3) return pathVal; - if (pathVal == null) return undefined; - pathVal = pathVal[key3]; - - if (!key4) return pathVal; - if (pathVal == null) return undefined; - pathVal = pathVal[key4]; - - return pathVal; - } - : function cspSafePromiseEnabledGetter(scope, locals) { - var pathVal = (locals && locals.hasOwnProperty(key0)) ? locals : scope, - promise; - - if (pathVal == null) return pathVal; - - pathVal = pathVal[key0]; - if (pathVal && pathVal.then) { - promiseWarning(fullExp); - if (!("$$v" in pathVal)) { - promise = pathVal; - promise.$$v = undefined; - promise.then(function(val) { promise.$$v = val; }); - } - pathVal = pathVal.$$v; - } - - if (!key1) return pathVal; - if (pathVal == null) return undefined; - pathVal = pathVal[key1]; - if (pathVal && pathVal.then) { - promiseWarning(fullExp); - if (!("$$v" in pathVal)) { - promise = pathVal; - promise.$$v = undefined; - promise.then(function(val) { promise.$$v = val; }); - } - pathVal = pathVal.$$v; - } - - if (!key2) return pathVal; - if (pathVal == null) return undefined; - pathVal = pathVal[key2]; - if (pathVal && pathVal.then) { - promiseWarning(fullExp); - if (!("$$v" in pathVal)) { - promise = pathVal; - promise.$$v = undefined; - promise.then(function(val) { promise.$$v = val; }); - } - pathVal = pathVal.$$v; - } - - if (!key3) return pathVal; - if (pathVal == null) return undefined; - pathVal = pathVal[key3]; - if (pathVal && pathVal.then) { - promiseWarning(fullExp); - if (!("$$v" in pathVal)) { - promise = pathVal; - promise.$$v = undefined; - promise.then(function(val) { promise.$$v = val; }); - } - pathVal = pathVal.$$v; - } - - if (!key4) return pathVal; - if (pathVal == null) return undefined; - pathVal = pathVal[key4]; - if (pathVal && pathVal.then) { - promiseWarning(fullExp); - if (!("$$v" in pathVal)) { - promise = pathVal; - promise.$$v = undefined; - promise.then(function(val) { promise.$$v = val; }); - } - pathVal = pathVal.$$v; - } - return pathVal; - }; -} - -function getterFn(path, options, fullExp) { - // Check whether the cache has this getter already. - // We can use hasOwnProperty directly on the cache because we ensure, - // see below, that the cache never stores a path called 'hasOwnProperty' - if (getterFnCache.hasOwnProperty(path)) { - return getterFnCache[path]; - } - - var pathKeys = path.split('.'), - pathKeysLength = pathKeys.length, - fn; - - // http://jsperf.com/angularjs-parse-getter/6 - if (options.csp) { - if (pathKeysLength < 6) { - fn = cspSafeGetterFn(pathKeys[0], pathKeys[1], pathKeys[2], pathKeys[3], pathKeys[4], fullExp, - options); - } else { - fn = function(scope, locals) { - var i = 0, val; - do { - val = cspSafeGetterFn(pathKeys[i++], pathKeys[i++], pathKeys[i++], pathKeys[i++], - pathKeys[i++], fullExp, options)(scope, locals); - - locals = undefined; // clear after first iteration - scope = val; - } while (i < pathKeysLength); - return val; - }; - } - } else { - var code = 'var p;\n'; - forEach(pathKeys, function(key, index) { - ensureSafeMemberName(key, fullExp); - code += 'if(s == null) return undefined;\n' + - 's='+ (index - // we simply dereference 's' on any .dot notation - ? 's' - // but if we are first then we check locals first, and if so read it first - : '((k&&k.hasOwnProperty("' + key + '"))?k:s)') + '["' + key + '"]' + ';\n' + - (options.unwrapPromises - ? 'if (s && s.then) {\n' + - ' pw("' + fullExp.replace(/(["\r\n])/g, '\\$1') + '");\n' + - ' if (!("$$v" in s)) {\n' + - ' p=s;\n' + - ' p.$$v = undefined;\n' + - ' p.then(function(v) {p.$$v=v;});\n' + - '}\n' + - ' s=s.$$v\n' + - '}\n' - : ''); - }); - code += 'return s;'; - - /* jshint -W054 */ - var evaledFnGetter = new Function('s', 'k', 'pw', code); // s=scope, k=locals, pw=promiseWarning - /* jshint +W054 */ - evaledFnGetter.toString = valueFn(code); - fn = options.unwrapPromises ? function(scope, locals) { - return evaledFnGetter(scope, locals, promiseWarning); - } : evaledFnGetter; - } - - // Only cache the value if it's not going to mess up the cache object - // This is more performant that using Object.prototype.hasOwnProperty.call - if (path !== 'hasOwnProperty') { - getterFnCache[path] = fn; - } - return fn; -} - -/////////////////////////////////// - -/** - * @ngdoc service - * @name $parse - * @kind function - * - * @description - * - * Converts Angular {@link guide/expression expression} into a function. - * - * ```js - * var getter = $parse('user.name'); - * var setter = getter.assign; - * var context = {user:{name:'angular'}}; - * var locals = {user:{name:'local'}}; - * - * expect(getter(context)).toEqual('angular'); - * setter(context, 'newValue'); - * expect(context.user.name).toEqual('newValue'); - * expect(getter(context, locals)).toEqual('local'); - * ``` - * - * - * @param {string} expression String expression to compile. - * @returns {function(context, locals)} a function which represents the compiled expression: - * - * * `context` – `{object}` – an object against which any expressions embedded in the strings - * are evaluated against (typically a scope object). - * * `locals` – `{object=}` – local variables context object, useful for overriding values in - * `context`. - * - * The returned function also has the following properties: - * * `literal` – `{boolean}` – whether the expression's top-level node is a JavaScript - * literal. - * * `constant` – `{boolean}` – whether the expression is made entirely of JavaScript - * constant literals. - * * `assign` – `{?function(context, value)}` – if the expression is assignable, this will be - * set to a function to change its value on the given context. - * - */ - - -/** - * @ngdoc provider - * @name $parseProvider - * @kind function - * - * @description - * `$parseProvider` can be used for configuring the default behavior of the {@link ng.$parse $parse} - * service. - */ -function $ParseProvider() { - var cache = {}; - - var $parseOptions = { - csp: false, - unwrapPromises: false, - logPromiseWarnings: true - }; - - - /** - * @deprecated Promise unwrapping via $parse is deprecated and will be removed in the future. - * - * @ngdoc method - * @name $parseProvider#unwrapPromises - * @description - * - * **This feature is deprecated, see deprecation notes below for more info** - * - * If set to true (default is false), $parse will unwrap promises automatically when a promise is - * found at any part of the expression. In other words, if set to true, the expression will always - * result in a non-promise value. - * - * While the promise is unresolved, it's treated as undefined, but once resolved and fulfilled, - * the fulfillment value is used in place of the promise while evaluating the expression. - * - * **Deprecation notice** - * - * This is a feature that didn't prove to be wildly useful or popular, primarily because of the - * dichotomy between data access in templates (accessed as raw values) and controller code - * (accessed as promises). - * - * In most code we ended up resolving promises manually in controllers anyway and thus unifying - * the model access there. - * - * Other downsides of automatic promise unwrapping: - * - * - when building components it's often desirable to receive the raw promises - * - adds complexity and slows down expression evaluation - * - makes expression code pre-generation unattractive due to the amount of code that needs to be - * generated - * - makes IDE auto-completion and tool support hard - * - * **Warning Logs** - * - * If the unwrapping is enabled, Angular will log a warning about each expression that unwraps a - * promise (to reduce the noise, each expression is logged only once). To disable this logging use - * `$parseProvider.logPromiseWarnings(false)` api. - * - * - * @param {boolean=} value New value. - * @returns {boolean|self} Returns the current setting when used as getter and self if used as - * setter. - */ - this.unwrapPromises = function(value) { - if (isDefined(value)) { - $parseOptions.unwrapPromises = !!value; - return this; - } else { - return $parseOptions.unwrapPromises; - } - }; - - - /** - * @deprecated Promise unwrapping via $parse is deprecated and will be removed in the future. - * - * @ngdoc method - * @name $parseProvider#logPromiseWarnings - * @description - * - * Controls whether Angular should log a warning on any encounter of a promise in an expression. - * - * The default is set to `true`. - * - * This setting applies only if `$parseProvider.unwrapPromises` setting is set to true as well. - * - * @param {boolean=} value New value. - * @returns {boolean|self} Returns the current setting when used as getter and self if used as - * setter. - */ - this.logPromiseWarnings = function(value) { - if (isDefined(value)) { - $parseOptions.logPromiseWarnings = value; - return this; - } else { - return $parseOptions.logPromiseWarnings; - } - }; - - - this.$get = ['$filter', '$sniffer', '$log', function($filter, $sniffer, $log) { - $parseOptions.csp = $sniffer.csp; - - promiseWarning = function promiseWarningFn(fullExp) { - if (!$parseOptions.logPromiseWarnings || promiseWarningCache.hasOwnProperty(fullExp)) return; - promiseWarningCache[fullExp] = true; - $log.warn('[$parse] Promise found in the expression `' + fullExp + '`. ' + - 'Automatic unwrapping of promises in Angular expressions is deprecated.'); - }; - - return function(exp) { - var parsedExpression; - - switch (typeof exp) { - case 'string': - - if (cache.hasOwnProperty(exp)) { - return cache[exp]; - } - - var lexer = new Lexer($parseOptions); - var parser = new Parser(lexer, $filter, $parseOptions); - parsedExpression = parser.parse(exp); - - if (exp !== 'hasOwnProperty') { - // Only cache the value if it's not going to mess up the cache object - // This is more performant that using Object.prototype.hasOwnProperty.call - cache[exp] = parsedExpression; - } - - return parsedExpression; - - case 'function': - return exp; - - default: - return noop; - } - }; - }]; -} - -/** - * @ngdoc service - * @name $q - * @requires $rootScope - * - * @description - * A promise/deferred implementation inspired by [Kris Kowal's Q](https://github.com/kriskowal/q). - * - * [The CommonJS Promise proposal](http://wiki.commonjs.org/wiki/Promises) describes a promise as an - * interface for interacting with an object that represents the result of an action that is - * performed asynchronously, and may or may not be finished at any given point in time. - * - * From the perspective of dealing with error handling, deferred and promise APIs are to - * asynchronous programming what `try`, `catch` and `throw` keywords are to synchronous programming. - * - * ```js - * // for the purpose of this example let's assume that variables `$q`, `scope` and `okToGreet` - * // are available in the current lexical scope (they could have been injected or passed in). - * - * function asyncGreet(name) { - * var deferred = $q.defer(); - * - * setTimeout(function() { - * deferred.notify('About to greet ' + name + '.'); - * - * if (okToGreet(name)) { - * deferred.resolve('Hello, ' + name + '!'); - * } else { - * deferred.reject('Greeting ' + name + ' is not allowed.'); - * } - * }, 1000); - * - * return deferred.promise; - * } - * - * var promise = asyncGreet('Robin Hood'); - * promise.then(function(greeting) { - * alert('Success: ' + greeting); - * }, function(reason) { - * alert('Failed: ' + reason); - * }, function(update) { - * alert('Got notification: ' + update); - * }); - * ``` - * - * At first it might not be obvious why this extra complexity is worth the trouble. The payoff - * comes in the way of guarantees that promise and deferred APIs make, see - * https://github.com/kriskowal/uncommonjs/blob/master/promises/specification.md. - * - * Additionally the promise api allows for composition that is very hard to do with the - * traditional callback ([CPS](http://en.wikipedia.org/wiki/Continuation-passing_style)) approach. - * For more on this please see the [Q documentation](https://github.com/kriskowal/q) especially the - * section on serial or parallel joining of promises. - * - * - * # The Deferred API - * - * A new instance of deferred is constructed by calling `$q.defer()`. - * - * The purpose of the deferred object is to expose the associated Promise instance as well as APIs - * that can be used for signaling the successful or unsuccessful completion, as well as the status - * of the task. - * - * **Methods** - * - * - `resolve(value)` – resolves the derived promise with the `value`. If the value is a rejection - * constructed via `$q.reject`, the promise will be rejected instead. - * - `reject(reason)` – rejects the derived promise with the `reason`. This is equivalent to - * resolving it with a rejection constructed via `$q.reject`. - * - `notify(value)` - provides updates on the status of the promise's execution. This may be called - * multiple times before the promise is either resolved or rejected. - * - * **Properties** - * - * - promise – `{Promise}` – promise object associated with this deferred. - * - * - * # The Promise API - * - * A new promise instance is created when a deferred instance is created and can be retrieved by - * calling `deferred.promise`. - * - * The purpose of the promise object is to allow for interested parties to get access to the result - * of the deferred task when it completes. - * - * **Methods** - * - * - `then(successCallback, errorCallback, notifyCallback)` – regardless of when the promise was or - * will be resolved or rejected, `then` calls one of the success or error callbacks asynchronously - * as soon as the result is available. The callbacks are called with a single argument: the result - * or rejection reason. Additionally, the notify callback may be called zero or more times to - * provide a progress indication, before the promise is resolved or rejected. - * - * This method *returns a new promise* which is resolved or rejected via the return value of the - * `successCallback`, `errorCallback`. It also notifies via the return value of the - * `notifyCallback` method. The promise can not be resolved or rejected from the notifyCallback - * method. - * - * - `catch(errorCallback)` – shorthand for `promise.then(null, errorCallback)` - * - * - `finally(callback)` – allows you to observe either the fulfillment or rejection of a promise, - * but to do so without modifying the final value. This is useful to release resources or do some - * clean-up that needs to be done whether the promise was rejected or resolved. See the [full - * specification](https://github.com/kriskowal/q/wiki/API-Reference#promisefinallycallback) for - * more information. - * - * Because `finally` is a reserved word in JavaScript and reserved keywords are not supported as - * property names by ES3, you'll need to invoke the method like `promise['finally'](callback)` to - * make your code IE8 and Android 2.x compatible. - * - * # Chaining promises - * - * Because calling the `then` method of a promise returns a new derived promise, it is easily - * possible to create a chain of promises: - * - * ```js - * promiseB = promiseA.then(function(result) { - * return result + 1; - * }); - * - * // promiseB will be resolved immediately after promiseA is resolved and its value - * // will be the result of promiseA incremented by 1 - * ``` - * - * It is possible to create chains of any length and since a promise can be resolved with another - * promise (which will defer its resolution further), it is possible to pause/defer resolution of - * the promises at any point in the chain. This makes it possible to implement powerful APIs like - * $http's response interceptors. - * - * - * # Differences between Kris Kowal's Q and $q - * - * There are two main differences: - * - * - $q is integrated with the {@link ng.$rootScope.Scope} Scope model observation - * mechanism in angular, which means faster propagation of resolution or rejection into your - * models and avoiding unnecessary browser repaints, which would result in flickering UI. - * - Q has many more features than $q, but that comes at a cost of bytes. $q is tiny, but contains - * all the important functionality needed for common async tasks. - * - * # Testing - * - * ```js - * it('should simulate promise', inject(function($q, $rootScope) { - * var deferred = $q.defer(); - * var promise = deferred.promise; - * var resolvedValue; - * - * promise.then(function(value) { resolvedValue = value; }); - * expect(resolvedValue).toBeUndefined(); - * - * // Simulate resolving of promise - * deferred.resolve(123); - * // Note that the 'then' function does not get called synchronously. - * // This is because we want the promise API to always be async, whether or not - * // it got called synchronously or asynchronously. - * expect(resolvedValue).toBeUndefined(); - * - * // Propagate promise resolution to 'then' functions using $apply(). - * $rootScope.$apply(); - * expect(resolvedValue).toEqual(123); - * })); - * ``` - */ -function $QProvider() { - - this.$get = ['$rootScope', '$exceptionHandler', function($rootScope, $exceptionHandler) { - return qFactory(function(callback) { - $rootScope.$evalAsync(callback); - }, $exceptionHandler); - }]; -} - - -/** - * Constructs a promise manager. - * - * @param {function(Function)} nextTick Function for executing functions in the next turn. - * @param {function(...*)} exceptionHandler Function into which unexpected exceptions are passed for - * debugging purposes. - * @returns {object} Promise manager. - */ -function qFactory(nextTick, exceptionHandler) { - - /** - * @ngdoc method - * @name $q#defer - * @kind function - * - * @description - * Creates a `Deferred` object which represents a task which will finish in the future. - * - * @returns {Deferred} Returns a new instance of deferred. - */ - var defer = function() { - var pending = [], - value, deferred; - - deferred = { - - resolve: function(val) { - if (pending) { - var callbacks = pending; - pending = undefined; - value = ref(val); - - if (callbacks.length) { - nextTick(function() { - var callback; - for (var i = 0, ii = callbacks.length; i < ii; i++) { - callback = callbacks[i]; - value.then(callback[0], callback[1], callback[2]); - } - }); - } - } - }, - - - reject: function(reason) { - deferred.resolve(createInternalRejectedPromise(reason)); - }, - - - notify: function(progress) { - if (pending) { - var callbacks = pending; - - if (pending.length) { - nextTick(function() { - var callback; - for (var i = 0, ii = callbacks.length; i < ii; i++) { - callback = callbacks[i]; - callback[2](progress); - } - }); - } - } - }, - - - promise: { - then: function(callback, errback, progressback) { - var result = defer(); - - var wrappedCallback = function(value) { - try { - result.resolve((isFunction(callback) ? callback : defaultCallback)(value)); - } catch(e) { - result.reject(e); - exceptionHandler(e); - } - }; - - var wrappedErrback = function(reason) { - try { - result.resolve((isFunction(errback) ? errback : defaultErrback)(reason)); - } catch(e) { - result.reject(e); - exceptionHandler(e); - } - }; - - var wrappedProgressback = function(progress) { - try { - result.notify((isFunction(progressback) ? progressback : defaultCallback)(progress)); - } catch(e) { - exceptionHandler(e); - } - }; - - if (pending) { - pending.push([wrappedCallback, wrappedErrback, wrappedProgressback]); - } else { - value.then(wrappedCallback, wrappedErrback, wrappedProgressback); - } - - return result.promise; - }, - - "catch": function(callback) { - return this.then(null, callback); - }, - - "finally": function(callback) { - - function makePromise(value, resolved) { - var result = defer(); - if (resolved) { - result.resolve(value); - } else { - result.reject(value); - } - return result.promise; - } - - function handleCallback(value, isResolved) { - var callbackOutput = null; - try { - callbackOutput = (callback ||defaultCallback)(); - } catch(e) { - return makePromise(e, false); - } - if (isPromiseLike(callbackOutput)) { - return callbackOutput.then(function() { - return makePromise(value, isResolved); - }, function(error) { - return makePromise(error, false); - }); - } else { - return makePromise(value, isResolved); - } - } - - return this.then(function(value) { - return handleCallback(value, true); - }, function(error) { - return handleCallback(error, false); - }); - } - } - }; - - return deferred; - }; - - - var ref = function(value) { - if (isPromiseLike(value)) return value; - return { - then: function(callback) { - var result = defer(); - nextTick(function() { - result.resolve(callback(value)); - }); - return result.promise; - } - }; - }; - - - /** - * @ngdoc method - * @name $q#reject - * @kind function - * - * @description - * Creates a promise that is resolved as rejected with the specified `reason`. This api should be - * used to forward rejection in a chain of promises. If you are dealing with the last promise in - * a promise chain, you don't need to worry about it. - * - * When comparing deferreds/promises to the familiar behavior of try/catch/throw, think of - * `reject` as the `throw` keyword in JavaScript. This also means that if you "catch" an error via - * a promise error callback and you want to forward the error to the promise derived from the - * current promise, you have to "rethrow" the error by returning a rejection constructed via - * `reject`. - * - * ```js - * promiseB = promiseA.then(function(result) { - * // success: do something and resolve promiseB - * // with the old or a new result - * return result; - * }, function(reason) { - * // error: handle the error if possible and - * // resolve promiseB with newPromiseOrValue, - * // otherwise forward the rejection to promiseB - * if (canHandle(reason)) { - * // handle the error and recover - * return newPromiseOrValue; - * } - * return $q.reject(reason); - * }); - * ``` - * - * @param {*} reason Constant, message, exception or an object representing the rejection reason. - * @returns {Promise} Returns a promise that was already resolved as rejected with the `reason`. - */ - var reject = function(reason) { - var result = defer(); - result.reject(reason); - return result.promise; - }; - - var createInternalRejectedPromise = function(reason) { - return { - then: function(callback, errback) { - var result = defer(); - nextTick(function() { - try { - result.resolve((isFunction(errback) ? errback : defaultErrback)(reason)); - } catch(e) { - result.reject(e); - exceptionHandler(e); - } - }); - return result.promise; - } - }; - }; - - - /** - * @ngdoc method - * @name $q#when - * @kind function - * - * @description - * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. - * This is useful when you are dealing with an object that might or might not be a promise, or if - * the promise comes from a source that can't be trusted. - * - * @param {*} value Value or a promise - * @returns {Promise} Returns a promise of the passed value or promise - */ - var when = function(value, callback, errback, progressback) { - var result = defer(), - done; - - var wrappedCallback = function(value) { - try { - return (isFunction(callback) ? callback : defaultCallback)(value); - } catch (e) { - exceptionHandler(e); - return reject(e); - } - }; - - var wrappedErrback = function(reason) { - try { - return (isFunction(errback) ? errback : defaultErrback)(reason); - } catch (e) { - exceptionHandler(e); - return reject(e); - } - }; - - var wrappedProgressback = function(progress) { - try { - return (isFunction(progressback) ? progressback : defaultCallback)(progress); - } catch (e) { - exceptionHandler(e); - } - }; - - nextTick(function() { - ref(value).then(function(value) { - if (done) return; - done = true; - result.resolve(ref(value).then(wrappedCallback, wrappedErrback, wrappedProgressback)); - }, function(reason) { - if (done) return; - done = true; - result.resolve(wrappedErrback(reason)); - }, function(progress) { - if (done) return; - result.notify(wrappedProgressback(progress)); - }); - }); - - return result.promise; - }; - - - function defaultCallback(value) { - return value; - } - - - function defaultErrback(reason) { - return reject(reason); - } - - - /** - * @ngdoc method - * @name $q#all - * @kind function - * - * @description - * Combines multiple promises into a single promise that is resolved when all of the input - * promises are resolved. - * - * @param {Array.|Object.} promises An array or hash of promises. - * @returns {Promise} Returns a single promise that will be resolved with an array/hash of values, - * each value corresponding to the promise at the same index/key in the `promises` array/hash. - * If any of the promises is resolved with a rejection, this resulting promise will be rejected - * with the same rejection value. - */ - function all(promises) { - var deferred = defer(), - counter = 0, - results = isArray(promises) ? [] : {}; - - forEach(promises, function(promise, key) { - counter++; - ref(promise).then(function(value) { - if (results.hasOwnProperty(key)) return; - results[key] = value; - if (!(--counter)) deferred.resolve(results); - }, function(reason) { - if (results.hasOwnProperty(key)) return; - deferred.reject(reason); - }); - }); - - if (counter === 0) { - deferred.resolve(results); - } - - return deferred.promise; - } - - return { - defer: defer, - reject: reject, - when: when, - all: all - }; -} - -function $$RAFProvider(){ //rAF - this.$get = ['$window', '$timeout', function($window, $timeout) { - var requestAnimationFrame = $window.requestAnimationFrame || - $window.webkitRequestAnimationFrame || - $window.mozRequestAnimationFrame; - - var cancelAnimationFrame = $window.cancelAnimationFrame || - $window.webkitCancelAnimationFrame || - $window.mozCancelAnimationFrame || - $window.webkitCancelRequestAnimationFrame; - - var rafSupported = !!requestAnimationFrame; - var raf = rafSupported - ? function(fn) { - var id = requestAnimationFrame(fn); - return function() { - cancelAnimationFrame(id); - }; - } - : function(fn) { - var timer = $timeout(fn, 16.66, false); // 1000 / 60 = 16.666 - return function() { - $timeout.cancel(timer); - }; - }; - - raf.supported = rafSupported; - - return raf; - }]; -} - -/** - * DESIGN NOTES - * - * The design decisions behind the scope are heavily favored for speed and memory consumption. - * - * The typical use of scope is to watch the expressions, which most of the time return the same - * value as last time so we optimize the operation. - * - * Closures construction is expensive in terms of speed as well as memory: - * - No closures, instead use prototypical inheritance for API - * - Internal state needs to be stored on scope directly, which means that private state is - * exposed as $$____ properties - * - * Loop operations are optimized by using while(count--) { ... } - * - this means that in order to keep the same order of execution as addition we have to add - * items to the array at the beginning (unshift) instead of at the end (push) - * - * Child scopes are created and removed often - * - Using an array would be slow since inserts in middle are expensive so we use linked list - * - * There are few watches then a lot of observers. This is why you don't want the observer to be - * implemented in the same way as watch. Watch requires return of initialization function which - * are expensive to construct. - */ - - -/** - * @ngdoc provider - * @name $rootScopeProvider - * @description - * - * Provider for the $rootScope service. - */ - -/** - * @ngdoc method - * @name $rootScopeProvider#digestTtl - * @description - * - * Sets the number of `$digest` iterations the scope should attempt to execute before giving up and - * assuming that the model is unstable. - * - * The current default is 10 iterations. - * - * In complex applications it's possible that the dependencies between `$watch`s will result in - * several digest iterations. However if an application needs more than the default 10 digest - * iterations for its model to stabilize then you should investigate what is causing the model to - * continuously change during the digest. - * - * Increasing the TTL could have performance implications, so you should not change it without - * proper justification. - * - * @param {number} limit The number of digest iterations. - */ - - -/** - * @ngdoc service - * @name $rootScope - * @description - * - * Every application has a single root {@link ng.$rootScope.Scope scope}. - * All other scopes are descendant scopes of the root scope. Scopes provide separation - * between the model and the view, via a mechanism for watching the model for changes. - * They also provide an event emission/broadcast and subscription facility. See the - * {@link guide/scope developer guide on scopes}. - */ -function $RootScopeProvider(){ - var TTL = 10; - var $rootScopeMinErr = minErr('$rootScope'); - var lastDirtyWatch = null; - - this.digestTtl = function(value) { - if (arguments.length) { - TTL = value; - } - return TTL; - }; - - this.$get = ['$injector', '$exceptionHandler', '$parse', '$browser', - function( $injector, $exceptionHandler, $parse, $browser) { - - /** - * @ngdoc type - * @name $rootScope.Scope - * - * @description - * A root scope can be retrieved using the {@link ng.$rootScope $rootScope} key from the - * {@link auto.$injector $injector}. Child scopes are created using the - * {@link ng.$rootScope.Scope#$new $new()} method. (Most scopes are created automatically when - * compiled HTML template is executed.) - * - * Here is a simple scope snippet to show how you can interact with the scope. - * ```html - * - * ``` - * - * # Inheritance - * A scope can inherit from a parent scope, as in this example: - * ```js - var parent = $rootScope; - var child = parent.$new(); - - parent.salutation = "Hello"; - child.name = "World"; - expect(child.salutation).toEqual('Hello'); - - child.salutation = "Welcome"; - expect(child.salutation).toEqual('Welcome'); - expect(parent.salutation).toEqual('Hello'); - * ``` - * - * - * @param {Object.=} providers Map of service factory which need to be - * provided for the current scope. Defaults to {@link ng}. - * @param {Object.=} instanceCache Provides pre-instantiated services which should - * append/override services provided by `providers`. This is handy - * when unit-testing and having the need to override a default - * service. - * @returns {Object} Newly created scope. - * - */ - function Scope() { - this.$id = nextUid(); - this.$$phase = this.$parent = this.$$watchers = - this.$$nextSibling = this.$$prevSibling = - this.$$childHead = this.$$childTail = null; - this['this'] = this.$root = this; - this.$$destroyed = false; - this.$$asyncQueue = []; - this.$$postDigestQueue = []; - this.$$listeners = {}; - this.$$listenerCount = {}; - this.$$isolateBindings = {}; - } - - /** - * @ngdoc property - * @name $rootScope.Scope#$id - * - * @description - * Unique scope ID (monotonically increasing) useful for debugging. - */ - - /** - * @ngdoc property - * @name $rootScope.Scope#$parent - * - * @description - * Reference to the parent scope. - */ - - /** - * @ngdoc property - * @name $rootScope.Scope#$root - * - * @description - * Reference to the root scope. - */ - - Scope.prototype = { - constructor: Scope, - /** - * @ngdoc method - * @name $rootScope.Scope#$new - * @kind function - * - * @description - * Creates a new child {@link ng.$rootScope.Scope scope}. - * - * The parent scope will propagate the {@link ng.$rootScope.Scope#$digest $digest()} event. - * The scope can be removed from the scope hierarchy using {@link ng.$rootScope.Scope#$destroy $destroy()}. - * - * {@link ng.$rootScope.Scope#$destroy $destroy()} must be called on a scope when it is - * desired for the scope and its child scopes to be permanently detached from the parent and - * thus stop participating in model change detection and listener notification by invoking. - * - * @param {boolean} isolate If true, then the scope does not prototypically inherit from the - * parent scope. The scope is isolated, as it can not see parent scope properties. - * When creating widgets, it is useful for the widget to not accidentally read parent - * state. - * - * @returns {Object} The newly created child scope. - * - */ - $new: function(isolate) { - var ChildScope, - child; - - if (isolate) { - child = new Scope(); - child.$root = this.$root; - // ensure that there is just one async queue per $rootScope and its children - child.$$asyncQueue = this.$$asyncQueue; - child.$$postDigestQueue = this.$$postDigestQueue; - } else { - // Only create a child scope class if somebody asks for one, - // but cache it to allow the VM to optimize lookups. - if (!this.$$childScopeClass) { - this.$$childScopeClass = function() { - this.$$watchers = this.$$nextSibling = - this.$$childHead = this.$$childTail = null; - this.$$listeners = {}; - this.$$listenerCount = {}; - this.$id = nextUid(); - this.$$childScopeClass = null; - }; - this.$$childScopeClass.prototype = this; - } - child = new this.$$childScopeClass(); - } - child['this'] = child; - child.$parent = this; - child.$$prevSibling = this.$$childTail; - if (this.$$childHead) { - this.$$childTail.$$nextSibling = child; - this.$$childTail = child; - } else { - this.$$childHead = this.$$childTail = child; - } - return child; - }, - - /** - * @ngdoc method - * @name $rootScope.Scope#$watch - * @kind function - * - * @description - * Registers a `listener` callback to be executed whenever the `watchExpression` changes. - * - * - The `watchExpression` is called on every call to {@link ng.$rootScope.Scope#$digest - * $digest()} and should return the value that will be watched. (Since - * {@link ng.$rootScope.Scope#$digest $digest()} reruns when it detects changes the - * `watchExpression` can execute multiple times per - * {@link ng.$rootScope.Scope#$digest $digest()} and should be idempotent.) - * - The `listener` is called only when the value from the current `watchExpression` and the - * previous call to `watchExpression` are not equal (with the exception of the initial run, - * see below). Inequality is determined according to reference inequality, - * [strict comparison](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators) - * via the `!==` Javascript operator, unless `objectEquality == true` - * (see next point) - * - When `objectEquality == true`, inequality of the `watchExpression` is determined - * according to the {@link angular.equals} function. To save the value of the object for - * later comparison, the {@link angular.copy} function is used. This therefore means that - * watching complex objects will have adverse memory and performance implications. - * - The watch `listener` may change the model, which may trigger other `listener`s to fire. - * This is achieved by rerunning the watchers until no changes are detected. The rerun - * iteration limit is 10 to prevent an infinite loop deadlock. - * - * - * If you want to be notified whenever {@link ng.$rootScope.Scope#$digest $digest} is called, - * you can register a `watchExpression` function with no `listener`. (Since `watchExpression` - * can execute multiple times per {@link ng.$rootScope.Scope#$digest $digest} cycle when a - * change is detected, be prepared for multiple calls to your listener.) - * - * After a watcher is registered with the scope, the `listener` fn is called asynchronously - * (via {@link ng.$rootScope.Scope#$evalAsync $evalAsync}) to initialize the - * watcher. In rare cases, this is undesirable because the listener is called when the result - * of `watchExpression` didn't change. To detect this scenario within the `listener` fn, you - * can compare the `newVal` and `oldVal`. If these two values are identical (`===`) then the - * listener was called due to initialization. - * - * The example below contains an illustration of using a function as your $watch listener - * - * - * # Example - * ```js - // let's assume that scope was dependency injected as the $rootScope - var scope = $rootScope; - scope.name = 'misko'; - scope.counter = 0; - - expect(scope.counter).toEqual(0); - scope.$watch('name', function(newValue, oldValue) { - scope.counter = scope.counter + 1; - }); - expect(scope.counter).toEqual(0); - - scope.$digest(); - // the listener is always called during the first $digest loop after it was registered - expect(scope.counter).toEqual(1); - - scope.$digest(); - // but now it will not be called unless the value changes - expect(scope.counter).toEqual(1); - - scope.name = 'adam'; - scope.$digest(); - expect(scope.counter).toEqual(2); - - - - // Using a listener function - var food; - scope.foodCounter = 0; - expect(scope.foodCounter).toEqual(0); - scope.$watch( - // This is the listener function - function() { return food; }, - // This is the change handler - function(newValue, oldValue) { - if ( newValue !== oldValue ) { - // Only increment the counter if the value changed - scope.foodCounter = scope.foodCounter + 1; - } - } - ); - // No digest has been run so the counter will be zero - expect(scope.foodCounter).toEqual(0); - - // Run the digest but since food has not changed count will still be zero - scope.$digest(); - expect(scope.foodCounter).toEqual(0); - - // Update food and run digest. Now the counter will increment - food = 'cheeseburger'; - scope.$digest(); - expect(scope.foodCounter).toEqual(1); - - * ``` - * - * - * - * @param {(function()|string)} watchExpression Expression that is evaluated on each - * {@link ng.$rootScope.Scope#$digest $digest} cycle. A change in the return value triggers - * a call to the `listener`. - * - * - `string`: Evaluated as {@link guide/expression expression} - * - `function(scope)`: called with current `scope` as a parameter. - * @param {(function()|string)=} listener Callback called whenever the return value of - * the `watchExpression` changes. - * - * - `string`: Evaluated as {@link guide/expression expression} - * - `function(newValue, oldValue, scope)`: called with current and previous values as - * parameters. - * - * @param {boolean=} objectEquality Compare for object equality using {@link angular.equals} instead of - * comparing for reference equality. - * @returns {function()} Returns a deregistration function for this listener. - */ - $watch: function(watchExp, listener, objectEquality) { - var scope = this, - get = compileToFn(watchExp, 'watch'), - array = scope.$$watchers, - watcher = { - fn: listener, - last: initWatchVal, - get: get, - exp: watchExp, - eq: !!objectEquality - }; - - lastDirtyWatch = null; - - // in the case user pass string, we need to compile it, do we really need this ? - if (!isFunction(listener)) { - var listenFn = compileToFn(listener || noop, 'listener'); - watcher.fn = function(newVal, oldVal, scope) {listenFn(scope);}; - } - - if (typeof watchExp == 'string' && get.constant) { - var originalFn = watcher.fn; - watcher.fn = function(newVal, oldVal, scope) { - originalFn.call(this, newVal, oldVal, scope); - arrayRemove(array, watcher); - }; - } - - if (!array) { - array = scope.$$watchers = []; - } - // we use unshift since we use a while loop in $digest for speed. - // the while loop reads in reverse order. - array.unshift(watcher); - - return function deregisterWatch() { - arrayRemove(array, watcher); - lastDirtyWatch = null; - }; - }, - - - /** - * @ngdoc method - * @name $rootScope.Scope#$watchCollection - * @kind function - * - * @description - * Shallow watches the properties of an object and fires whenever any of the properties change - * (for arrays, this implies watching the array items; for object maps, this implies watching - * the properties). If a change is detected, the `listener` callback is fired. - * - * - The `obj` collection is observed via standard $watch operation and is examined on every - * call to $digest() to see if any items have been added, removed, or moved. - * - The `listener` is called whenever anything within the `obj` has changed. Examples include - * adding, removing, and moving items belonging to an object or array. - * - * - * # Example - * ```js - $scope.names = ['igor', 'matias', 'misko', 'james']; - $scope.dataCount = 4; - - $scope.$watchCollection('names', function(newNames, oldNames) { - $scope.dataCount = newNames.length; - }); - - expect($scope.dataCount).toEqual(4); - $scope.$digest(); - - //still at 4 ... no changes - expect($scope.dataCount).toEqual(4); - - $scope.names.pop(); - $scope.$digest(); - - //now there's been a change - expect($scope.dataCount).toEqual(3); - * ``` - * - * - * @param {string|function(scope)} obj Evaluated as {@link guide/expression expression}. The - * expression value should evaluate to an object or an array which is observed on each - * {@link ng.$rootScope.Scope#$digest $digest} cycle. Any shallow change within the - * collection will trigger a call to the `listener`. - * - * @param {function(newCollection, oldCollection, scope)} listener a callback function called - * when a change is detected. - * - The `newCollection` object is the newly modified data obtained from the `obj` expression - * - The `oldCollection` object is a copy of the former collection data. - * Due to performance considerations, the`oldCollection` value is computed only if the - * `listener` function declares two or more arguments. - * - The `scope` argument refers to the current scope. - * - * @returns {function()} Returns a de-registration function for this listener. When the - * de-registration function is executed, the internal watch operation is terminated. - */ - $watchCollection: function(obj, listener) { - var self = this; - // the current value, updated on each dirty-check run - var newValue; - // a shallow copy of the newValue from the last dirty-check run, - // updated to match newValue during dirty-check run - var oldValue; - // a shallow copy of the newValue from when the last change happened - var veryOldValue; - // only track veryOldValue if the listener is asking for it - var trackVeryOldValue = (listener.length > 1); - var changeDetected = 0; - var objGetter = $parse(obj); - var internalArray = []; - var internalObject = {}; - var initRun = true; - var oldLength = 0; - - function $watchCollectionWatch() { - newValue = objGetter(self); - var newLength, key, bothNaN; - - if (!isObject(newValue)) { // if primitive - if (oldValue !== newValue) { - oldValue = newValue; - changeDetected++; - } - } else if (isArrayLike(newValue)) { - if (oldValue !== internalArray) { - // we are transitioning from something which was not an array into array. - oldValue = internalArray; - oldLength = oldValue.length = 0; - changeDetected++; - } - - newLength = newValue.length; - - if (oldLength !== newLength) { - // if lengths do not match we need to trigger change notification - changeDetected++; - oldValue.length = oldLength = newLength; - } - // copy the items to oldValue and look for changes. - for (var i = 0; i < newLength; i++) { - bothNaN = (oldValue[i] !== oldValue[i]) && - (newValue[i] !== newValue[i]); - if (!bothNaN && (oldValue[i] !== newValue[i])) { - changeDetected++; - oldValue[i] = newValue[i]; - } - } - } else { - if (oldValue !== internalObject) { - // we are transitioning from something which was not an object into object. - oldValue = internalObject = {}; - oldLength = 0; - changeDetected++; - } - // copy the items to oldValue and look for changes. - newLength = 0; - for (key in newValue) { - if (newValue.hasOwnProperty(key)) { - newLength++; - if (oldValue.hasOwnProperty(key)) { - bothNaN = (oldValue[key] !== oldValue[key]) && - (newValue[key] !== newValue[key]); - if (!bothNaN && (oldValue[key] !== newValue[key])) { - changeDetected++; - oldValue[key] = newValue[key]; - } - } else { - oldLength++; - oldValue[key] = newValue[key]; - changeDetected++; - } - } - } - if (oldLength > newLength) { - // we used to have more keys, need to find them and destroy them. - changeDetected++; - for(key in oldValue) { - if (oldValue.hasOwnProperty(key) && !newValue.hasOwnProperty(key)) { - oldLength--; - delete oldValue[key]; - } - } - } - } - return changeDetected; - } - - function $watchCollectionAction() { - if (initRun) { - initRun = false; - listener(newValue, newValue, self); - } else { - listener(newValue, veryOldValue, self); - } - - // make a copy for the next time a collection is changed - if (trackVeryOldValue) { - if (!isObject(newValue)) { - //primitive - veryOldValue = newValue; - } else if (isArrayLike(newValue)) { - veryOldValue = new Array(newValue.length); - for (var i = 0; i < newValue.length; i++) { - veryOldValue[i] = newValue[i]; - } - } else { // if object - veryOldValue = {}; - for (var key in newValue) { - if (hasOwnProperty.call(newValue, key)) { - veryOldValue[key] = newValue[key]; - } - } - } - } - } - - return this.$watch($watchCollectionWatch, $watchCollectionAction); - }, - - /** - * @ngdoc method - * @name $rootScope.Scope#$digest - * @kind function - * - * @description - * Processes all of the {@link ng.$rootScope.Scope#$watch watchers} of the current scope and - * its children. Because a {@link ng.$rootScope.Scope#$watch watcher}'s listener can change - * the model, the `$digest()` keeps calling the {@link ng.$rootScope.Scope#$watch watchers} - * until no more listeners are firing. This means that it is possible to get into an infinite - * loop. This function will throw `'Maximum iteration limit exceeded.'` if the number of - * iterations exceeds 10. - * - * Usually, you don't call `$digest()` directly in - * {@link ng.directive:ngController controllers} or in - * {@link ng.$compileProvider#directive directives}. - * Instead, you should call {@link ng.$rootScope.Scope#$apply $apply()} (typically from within - * a {@link ng.$compileProvider#directive directives}), which will force a `$digest()`. - * - * If you want to be notified whenever `$digest()` is called, - * you can register a `watchExpression` function with - * {@link ng.$rootScope.Scope#$watch $watch()} with no `listener`. - * - * In unit tests, you may need to call `$digest()` to simulate the scope life cycle. - * - * # Example - * ```js - var scope = ...; - scope.name = 'misko'; - scope.counter = 0; - - expect(scope.counter).toEqual(0); - scope.$watch('name', function(newValue, oldValue) { - scope.counter = scope.counter + 1; - }); - expect(scope.counter).toEqual(0); - - scope.$digest(); - // the listener is always called during the first $digest loop after it was registered - expect(scope.counter).toEqual(1); - - scope.$digest(); - // but now it will not be called unless the value changes - expect(scope.counter).toEqual(1); - - scope.name = 'adam'; - scope.$digest(); - expect(scope.counter).toEqual(2); - * ``` - * - */ - $digest: function() { - var watch, value, last, - watchers, - asyncQueue = this.$$asyncQueue, - postDigestQueue = this.$$postDigestQueue, - length, - dirty, ttl = TTL, - next, current, target = this, - watchLog = [], - logIdx, logMsg, asyncTask; - - beginPhase('$digest'); - // Check for changes to browser url that happened in sync before the call to $digest - $browser.$$checkUrlChange(); - - lastDirtyWatch = null; - - do { // "while dirty" loop - dirty = false; - current = target; - - while(asyncQueue.length) { - try { - asyncTask = asyncQueue.shift(); - asyncTask.scope.$eval(asyncTask.expression); - } catch (e) { - clearPhase(); - $exceptionHandler(e); - } - lastDirtyWatch = null; - } - - traverseScopesLoop: - do { // "traverse the scopes" loop - if ((watchers = current.$$watchers)) { - // process our watches - length = watchers.length; - while (length--) { - try { - watch = watchers[length]; - // Most common watches are on primitives, in which case we can short - // circuit it with === operator, only when === fails do we use .equals - if (watch) { - if ((value = watch.get(current)) !== (last = watch.last) && - !(watch.eq - ? equals(value, last) - : (typeof value === 'number' && typeof last === 'number' - && isNaN(value) && isNaN(last)))) { - dirty = true; - lastDirtyWatch = watch; - watch.last = watch.eq ? copy(value, null) : value; - watch.fn(value, ((last === initWatchVal) ? value : last), current); - if (ttl < 5) { - logIdx = 4 - ttl; - if (!watchLog[logIdx]) watchLog[logIdx] = []; - logMsg = (isFunction(watch.exp)) - ? 'fn: ' + (watch.exp.name || watch.exp.toString()) - : watch.exp; - logMsg += '; newVal: ' + toJson(value) + '; oldVal: ' + toJson(last); - watchLog[logIdx].push(logMsg); - } - } else if (watch === lastDirtyWatch) { - // If the most recently dirty watcher is now clean, short circuit since the remaining watchers - // have already been tested. - dirty = false; - break traverseScopesLoop; - } - } - } catch (e) { - clearPhase(); - $exceptionHandler(e); - } - } - } - - // Insanity Warning: scope depth-first traversal - // yes, this code is a bit crazy, but it works and we have tests to prove it! - // this piece should be kept in sync with the traversal in $broadcast - if (!(next = (current.$$childHead || - (current !== target && current.$$nextSibling)))) { - while(current !== target && !(next = current.$$nextSibling)) { - current = current.$parent; - } - } - } while ((current = next)); - - // `break traverseScopesLoop;` takes us to here - - if((dirty || asyncQueue.length) && !(ttl--)) { - clearPhase(); - throw $rootScopeMinErr('infdig', - '{0} $digest() iterations reached. Aborting!\n' + - 'Watchers fired in the last 5 iterations: {1}', - TTL, toJson(watchLog)); - } - - } while (dirty || asyncQueue.length); - - clearPhase(); - - while(postDigestQueue.length) { - try { - postDigestQueue.shift()(); - } catch (e) { - $exceptionHandler(e); - } - } - }, - - - /** - * @ngdoc event - * @name $rootScope.Scope#$destroy - * @eventType broadcast on scope being destroyed - * - * @description - * Broadcasted when a scope and its children are being destroyed. - * - * Note that, in AngularJS, there is also a `$destroy` jQuery event, which can be used to - * clean up DOM bindings before an element is removed from the DOM. - */ - - /** - * @ngdoc method - * @name $rootScope.Scope#$destroy - * @kind function - * - * @description - * Removes the current scope (and all of its children) from the parent scope. Removal implies - * that calls to {@link ng.$rootScope.Scope#$digest $digest()} will no longer - * propagate to the current scope and its children. Removal also implies that the current - * scope is eligible for garbage collection. - * - * The `$destroy()` is usually used by directives such as - * {@link ng.directive:ngRepeat ngRepeat} for managing the - * unrolling of the loop. - * - * Just before a scope is destroyed, a `$destroy` event is broadcasted on this scope. - * Application code can register a `$destroy` event handler that will give it a chance to - * perform any necessary cleanup. - * - * Note that, in AngularJS, there is also a `$destroy` jQuery event, which can be used to - * clean up DOM bindings before an element is removed from the DOM. - */ - $destroy: function() { - // we can't destroy the root scope or a scope that has been already destroyed - if (this.$$destroyed) return; - var parent = this.$parent; - - this.$broadcast('$destroy'); - this.$$destroyed = true; - if (this === $rootScope) return; - - forEach(this.$$listenerCount, bind(null, decrementListenerCount, this)); - - // sever all the references to parent scopes (after this cleanup, the current scope should - // not be retained by any of our references and should be eligible for garbage collection) - if (parent.$$childHead == this) parent.$$childHead = this.$$nextSibling; - if (parent.$$childTail == this) parent.$$childTail = this.$$prevSibling; - if (this.$$prevSibling) this.$$prevSibling.$$nextSibling = this.$$nextSibling; - if (this.$$nextSibling) this.$$nextSibling.$$prevSibling = this.$$prevSibling; - - - // All of the code below is bogus code that works around V8's memory leak via optimized code - // and inline caches. - // - // see: - // - https://code.google.com/p/v8/issues/detail?id=2073#c26 - // - https://github.com/angular/angular.js/issues/6794#issuecomment-38648909 - // - https://github.com/angular/angular.js/issues/1313#issuecomment-10378451 - - this.$parent = this.$$nextSibling = this.$$prevSibling = this.$$childHead = - this.$$childTail = this.$root = null; - - // don't reset these to null in case some async task tries to register a listener/watch/task - this.$$listeners = {}; - this.$$watchers = this.$$asyncQueue = this.$$postDigestQueue = []; - - // prevent NPEs since these methods have references to properties we nulled out - this.$destroy = this.$digest = this.$apply = noop; - this.$on = this.$watch = function() { return noop; }; - }, - - /** - * @ngdoc method - * @name $rootScope.Scope#$eval - * @kind function - * - * @description - * Executes the `expression` on the current scope and returns the result. Any exceptions in - * the expression are propagated (uncaught). This is useful when evaluating Angular - * expressions. - * - * # Example - * ```js - var scope = ng.$rootScope.Scope(); - scope.a = 1; - scope.b = 2; - - expect(scope.$eval('a+b')).toEqual(3); - expect(scope.$eval(function(scope){ return scope.a + scope.b; })).toEqual(3); - * ``` - * - * @param {(string|function())=} expression An angular expression to be executed. - * - * - `string`: execute using the rules as defined in {@link guide/expression expression}. - * - `function(scope)`: execute the function with the current `scope` parameter. - * - * @param {(object)=} locals Local variables object, useful for overriding values in scope. - * @returns {*} The result of evaluating the expression. - */ - $eval: function(expr, locals) { - return $parse(expr)(this, locals); - }, - - /** - * @ngdoc method - * @name $rootScope.Scope#$evalAsync - * @kind function - * - * @description - * Executes the expression on the current scope at a later point in time. - * - * The `$evalAsync` makes no guarantees as to when the `expression` will be executed, only - * that: - * - * - it will execute after the function that scheduled the evaluation (preferably before DOM - * rendering). - * - at least one {@link ng.$rootScope.Scope#$digest $digest cycle} will be performed after - * `expression` execution. - * - * Any exceptions from the execution of the expression are forwarded to the - * {@link ng.$exceptionHandler $exceptionHandler} service. - * - * __Note:__ if this function is called outside of a `$digest` cycle, a new `$digest` cycle - * will be scheduled. However, it is encouraged to always call code that changes the model - * from within an `$apply` call. That includes code evaluated via `$evalAsync`. - * - * @param {(string|function())=} expression An angular expression to be executed. - * - * - `string`: execute using the rules as defined in {@link guide/expression expression}. - * - `function(scope)`: execute the function with the current `scope` parameter. - * - */ - $evalAsync: function(expr) { - // if we are outside of an $digest loop and this is the first time we are scheduling async - // task also schedule async auto-flush - if (!$rootScope.$$phase && !$rootScope.$$asyncQueue.length) { - $browser.defer(function() { - if ($rootScope.$$asyncQueue.length) { - $rootScope.$digest(); - } - }); - } - - this.$$asyncQueue.push({scope: this, expression: expr}); - }, - - $$postDigest : function(fn) { - this.$$postDigestQueue.push(fn); - }, - - /** - * @ngdoc method - * @name $rootScope.Scope#$apply - * @kind function - * - * @description - * `$apply()` is used to execute an expression in angular from outside of the angular - * framework. (For example from browser DOM events, setTimeout, XHR or third party libraries). - * Because we are calling into the angular framework we need to perform proper scope life - * cycle of {@link ng.$exceptionHandler exception handling}, - * {@link ng.$rootScope.Scope#$digest executing watches}. - * - * ## Life cycle - * - * # Pseudo-Code of `$apply()` - * ```js - function $apply(expr) { - try { - return $eval(expr); - } catch (e) { - $exceptionHandler(e); - } finally { - $root.$digest(); - } - } - * ``` - * - * - * Scope's `$apply()` method transitions through the following stages: - * - * 1. The {@link guide/expression expression} is executed using the - * {@link ng.$rootScope.Scope#$eval $eval()} method. - * 2. Any exceptions from the execution of the expression are forwarded to the - * {@link ng.$exceptionHandler $exceptionHandler} service. - * 3. The {@link ng.$rootScope.Scope#$watch watch} listeners are fired immediately after the - * expression was executed using the {@link ng.$rootScope.Scope#$digest $digest()} method. - * - * - * @param {(string|function())=} exp An angular expression to be executed. - * - * - `string`: execute using the rules as defined in {@link guide/expression expression}. - * - `function(scope)`: execute the function with current `scope` parameter. - * - * @returns {*} The result of evaluating the expression. - */ - $apply: function(expr) { - try { - beginPhase('$apply'); - return this.$eval(expr); - } catch (e) { - $exceptionHandler(e); - } finally { - clearPhase(); - try { - $rootScope.$digest(); - } catch (e) { - $exceptionHandler(e); - throw e; - } - } - }, - - /** - * @ngdoc method - * @name $rootScope.Scope#$on - * @kind function - * - * @description - * Listens on events of a given type. See {@link ng.$rootScope.Scope#$emit $emit} for - * discussion of event life cycle. - * - * The event listener function format is: `function(event, args...)`. The `event` object - * passed into the listener has the following attributes: - * - * - `targetScope` - `{Scope}`: the scope on which the event was `$emit`-ed or - * `$broadcast`-ed. - * - `currentScope` - `{Scope}`: the current scope which is handling the event. - * - `name` - `{string}`: name of the event. - * - `stopPropagation` - `{function=}`: calling `stopPropagation` function will cancel - * further event propagation (available only for events that were `$emit`-ed). - * - `preventDefault` - `{function}`: calling `preventDefault` sets `defaultPrevented` flag - * to true. - * - `defaultPrevented` - `{boolean}`: true if `preventDefault` was called. - * - * @param {string} name Event name to listen on. - * @param {function(event, ...args)} listener Function to call when the event is emitted. - * @returns {function()} Returns a deregistration function for this listener. - */ - $on: function(name, listener) { - var namedListeners = this.$$listeners[name]; - if (!namedListeners) { - this.$$listeners[name] = namedListeners = []; - } - namedListeners.push(listener); - - var current = this; - do { - if (!current.$$listenerCount[name]) { - current.$$listenerCount[name] = 0; - } - current.$$listenerCount[name]++; - } while ((current = current.$parent)); - - var self = this; - return function() { - namedListeners[indexOf(namedListeners, listener)] = null; - decrementListenerCount(self, 1, name); - }; - }, - - - /** - * @ngdoc method - * @name $rootScope.Scope#$emit - * @kind function - * - * @description - * Dispatches an event `name` upwards through the scope hierarchy notifying the - * registered {@link ng.$rootScope.Scope#$on} listeners. - * - * The event life cycle starts at the scope on which `$emit` was called. All - * {@link ng.$rootScope.Scope#$on listeners} listening for `name` event on this scope get - * notified. Afterwards, the event traverses upwards toward the root scope and calls all - * registered listeners along the way. The event will stop propagating if one of the listeners - * cancels it. - * - * Any exception emitted from the {@link ng.$rootScope.Scope#$on listeners} will be passed - * onto the {@link ng.$exceptionHandler $exceptionHandler} service. - * - * @param {string} name Event name to emit. - * @param {...*} args Optional one or more arguments which will be passed onto the event listeners. - * @return {Object} Event object (see {@link ng.$rootScope.Scope#$on}). - */ - $emit: function(name, args) { - var empty = [], - namedListeners, - scope = this, - stopPropagation = false, - event = { - name: name, - targetScope: scope, - stopPropagation: function() {stopPropagation = true;}, - preventDefault: function() { - event.defaultPrevented = true; - }, - defaultPrevented: false - }, - listenerArgs = concat([event], arguments, 1), - i, length; - - do { - namedListeners = scope.$$listeners[name] || empty; - event.currentScope = scope; - for (i=0, length=namedListeners.length; i= 8 ) { - normalizedVal = urlResolve(uri).href; - if (normalizedVal !== '' && !normalizedVal.match(regex)) { - return 'unsafe:'+normalizedVal; - } - } - return uri; - }; - }; -} - -var $sceMinErr = minErr('$sce'); - -var SCE_CONTEXTS = { - HTML: 'html', - CSS: 'css', - URL: 'url', - // RESOURCE_URL is a subtype of URL used in contexts where a privileged resource is sourced from a - // url. (e.g. ng-include, script src, templateUrl) - RESOURCE_URL: 'resourceUrl', - JS: 'js' -}; - -// Helper functions follow. - -// Copied from: -// http://docs.closure-library.googlecode.com/git/closure_goog_string_string.js.source.html#line962 -// Prereq: s is a string. -function escapeForRegexp(s) { - return s.replace(/([-()\[\]{}+?*.$\^|,:# -1) { - throw $sceMinErr('iwcard', - 'Illegal sequence *** in string matcher. String: {0}', matcher); - } - matcher = escapeForRegexp(matcher). - replace('\\*\\*', '.*'). - replace('\\*', '[^:/.?&;]*'); - return new RegExp('^' + matcher + '$'); - } else if (isRegExp(matcher)) { - // The only other type of matcher allowed is a Regexp. - // Match entire URL / disallow partial matches. - // Flags are reset (i.e. no global, ignoreCase or multiline) - return new RegExp('^' + matcher.source + '$'); - } else { - throw $sceMinErr('imatcher', - 'Matchers may only be "self", string patterns or RegExp objects'); - } -} - - -function adjustMatchers(matchers) { - var adjustedMatchers = []; - if (isDefined(matchers)) { - forEach(matchers, function(matcher) { - adjustedMatchers.push(adjustMatcher(matcher)); - }); - } - return adjustedMatchers; -} - - -/** - * @ngdoc service - * @name $sceDelegate - * @kind function - * - * @description - * - * `$sceDelegate` is a service that is used by the `$sce` service to provide {@link ng.$sce Strict - * Contextual Escaping (SCE)} services to AngularJS. - * - * Typically, you would configure or override the {@link ng.$sceDelegate $sceDelegate} instead of - * the `$sce` service to customize the way Strict Contextual Escaping works in AngularJS. This is - * because, while the `$sce` provides numerous shorthand methods, etc., you really only need to - * override 3 core functions (`trustAs`, `getTrusted` and `valueOf`) to replace the way things - * work because `$sce` delegates to `$sceDelegate` for these operations. - * - * Refer {@link ng.$sceDelegateProvider $sceDelegateProvider} to configure this service. - * - * The default instance of `$sceDelegate` should work out of the box with little pain. While you - * can override it completely to change the behavior of `$sce`, the common case would - * involve configuring the {@link ng.$sceDelegateProvider $sceDelegateProvider} instead by setting - * your own whitelists and blacklists for trusting URLs used for loading AngularJS resources such as - * templates. Refer {@link ng.$sceDelegateProvider#resourceUrlWhitelist - * $sceDelegateProvider.resourceUrlWhitelist} and {@link - * ng.$sceDelegateProvider#resourceUrlBlacklist $sceDelegateProvider.resourceUrlBlacklist} - */ - -/** - * @ngdoc provider - * @name $sceDelegateProvider - * @description - * - * The `$sceDelegateProvider` provider allows developers to configure the {@link ng.$sceDelegate - * $sceDelegate} service. This allows one to get/set the whitelists and blacklists used to ensure - * that the URLs used for sourcing Angular templates are safe. Refer {@link - * ng.$sceDelegateProvider#resourceUrlWhitelist $sceDelegateProvider.resourceUrlWhitelist} and - * {@link ng.$sceDelegateProvider#resourceUrlBlacklist $sceDelegateProvider.resourceUrlBlacklist} - * - * For the general details about this service in Angular, read the main page for {@link ng.$sce - * Strict Contextual Escaping (SCE)}. - * - * **Example**: Consider the following case. - * - * - your app is hosted at url `http://myapp.example.com/` - * - but some of your templates are hosted on other domains you control such as - * `http://srv01.assets.example.com/`,  `http://srv02.assets.example.com/`, etc. - * - and you have an open redirect at `http://myapp.example.com/clickThru?...`. - * - * Here is what a secure configuration for this scenario might look like: - * - * ``` - * angular.module('myApp', []).config(function($sceDelegateProvider) { - * $sceDelegateProvider.resourceUrlWhitelist([ - * // Allow same origin resource loads. - * 'self', - * // Allow loading from our assets domain. Notice the difference between * and **. - * 'http://srv*.assets.example.com/**' - * ]); - * - * // The blacklist overrides the whitelist so the open redirect here is blocked. - * $sceDelegateProvider.resourceUrlBlacklist([ - * 'http://myapp.example.com/clickThru**' - * ]); - * }); - * ``` - */ - -function $SceDelegateProvider() { - this.SCE_CONTEXTS = SCE_CONTEXTS; - - // Resource URLs can also be trusted by policy. - var resourceUrlWhitelist = ['self'], - resourceUrlBlacklist = []; - - /** - * @ngdoc method - * @name $sceDelegateProvider#resourceUrlWhitelist - * @kind function - * - * @param {Array=} whitelist When provided, replaces the resourceUrlWhitelist with the value - * provided. This must be an array or null. A snapshot of this array is used so further - * changes to the array are ignored. - * - * Follow {@link ng.$sce#resourceUrlPatternItem this link} for a description of the items - * allowed in this array. - * - * Note: **an empty whitelist array will block all URLs**! - * - * @return {Array} the currently set whitelist array. - * - * The **default value** when no whitelist has been explicitly set is `['self']` allowing only - * same origin resource requests. - * - * @description - * Sets/Gets the whitelist of trusted resource URLs. - */ - this.resourceUrlWhitelist = function (value) { - if (arguments.length) { - resourceUrlWhitelist = adjustMatchers(value); - } - return resourceUrlWhitelist; - }; - - /** - * @ngdoc method - * @name $sceDelegateProvider#resourceUrlBlacklist - * @kind function - * - * @param {Array=} blacklist When provided, replaces the resourceUrlBlacklist with the value - * provided. This must be an array or null. A snapshot of this array is used so further - * changes to the array are ignored. - * - * Follow {@link ng.$sce#resourceUrlPatternItem this link} for a description of the items - * allowed in this array. - * - * The typical usage for the blacklist is to **block - * [open redirects](http://cwe.mitre.org/data/definitions/601.html)** served by your domain as - * these would otherwise be trusted but actually return content from the redirected domain. - * - * Finally, **the blacklist overrides the whitelist** and has the final say. - * - * @return {Array} the currently set blacklist array. - * - * The **default value** when no whitelist has been explicitly set is the empty array (i.e. there - * is no blacklist.) - * - * @description - * Sets/Gets the blacklist of trusted resource URLs. - */ - - this.resourceUrlBlacklist = function (value) { - if (arguments.length) { - resourceUrlBlacklist = adjustMatchers(value); - } - return resourceUrlBlacklist; - }; - - this.$get = ['$injector', function($injector) { - - var htmlSanitizer = function htmlSanitizer(html) { - throw $sceMinErr('unsafe', 'Attempting to use an unsafe value in a safe context.'); - }; - - if ($injector.has('$sanitize')) { - htmlSanitizer = $injector.get('$sanitize'); - } - - - function matchUrl(matcher, parsedUrl) { - if (matcher === 'self') { - return urlIsSameOrigin(parsedUrl); - } else { - // definitely a regex. See adjustMatchers() - return !!matcher.exec(parsedUrl.href); - } - } - - function isResourceUrlAllowedByPolicy(url) { - var parsedUrl = urlResolve(url.toString()); - var i, n, allowed = false; - // Ensure that at least one item from the whitelist allows this url. - for (i = 0, n = resourceUrlWhitelist.length; i < n; i++) { - if (matchUrl(resourceUrlWhitelist[i], parsedUrl)) { - allowed = true; - break; - } - } - if (allowed) { - // Ensure that no item from the blacklist blocked this url. - for (i = 0, n = resourceUrlBlacklist.length; i < n; i++) { - if (matchUrl(resourceUrlBlacklist[i], parsedUrl)) { - allowed = false; - break; - } - } - } - return allowed; - } - - function generateHolderType(Base) { - var holderType = function TrustedValueHolderType(trustedValue) { - this.$$unwrapTrustedValue = function() { - return trustedValue; - }; - }; - if (Base) { - holderType.prototype = new Base(); - } - holderType.prototype.valueOf = function sceValueOf() { - return this.$$unwrapTrustedValue(); - }; - holderType.prototype.toString = function sceToString() { - return this.$$unwrapTrustedValue().toString(); - }; - return holderType; - } - - var trustedValueHolderBase = generateHolderType(), - byType = {}; - - byType[SCE_CONTEXTS.HTML] = generateHolderType(trustedValueHolderBase); - byType[SCE_CONTEXTS.CSS] = generateHolderType(trustedValueHolderBase); - byType[SCE_CONTEXTS.URL] = generateHolderType(trustedValueHolderBase); - byType[SCE_CONTEXTS.JS] = generateHolderType(trustedValueHolderBase); - byType[SCE_CONTEXTS.RESOURCE_URL] = generateHolderType(byType[SCE_CONTEXTS.URL]); - - /** - * @ngdoc method - * @name $sceDelegate#trustAs - * - * @description - * Returns an object that is trusted by angular for use in specified strict - * contextual escaping contexts (such as ng-bind-html, ng-include, any src - * attribute interpolation, any dom event binding attribute interpolation - * such as for onclick, etc.) that uses the provided value. - * See {@link ng.$sce $sce} for enabling strict contextual escaping. - * - * @param {string} type The kind of context in which this value is safe for use. e.g. url, - * resourceUrl, html, js and css. - * @param {*} value The value that that should be considered trusted/safe. - * @returns {*} A value that can be used to stand in for the provided `value` in places - * where Angular expects a $sce.trustAs() return value. - */ - function trustAs(type, trustedValue) { - var Constructor = (byType.hasOwnProperty(type) ? byType[type] : null); - if (!Constructor) { - throw $sceMinErr('icontext', - 'Attempted to trust a value in invalid context. Context: {0}; Value: {1}', - type, trustedValue); - } - if (trustedValue === null || trustedValue === undefined || trustedValue === '') { - return trustedValue; - } - // All the current contexts in SCE_CONTEXTS happen to be strings. In order to avoid trusting - // mutable objects, we ensure here that the value passed in is actually a string. - if (typeof trustedValue !== 'string') { - throw $sceMinErr('itype', - 'Attempted to trust a non-string value in a content requiring a string: Context: {0}', - type); - } - return new Constructor(trustedValue); - } - - /** - * @ngdoc method - * @name $sceDelegate#valueOf - * - * @description - * If the passed parameter had been returned by a prior call to {@link ng.$sceDelegate#trustAs - * `$sceDelegate.trustAs`}, returns the value that had been passed to {@link - * ng.$sceDelegate#trustAs `$sceDelegate.trustAs`}. - * - * If the passed parameter is not a value that had been returned by {@link - * ng.$sceDelegate#trustAs `$sceDelegate.trustAs`}, returns it as-is. - * - * @param {*} value The result of a prior {@link ng.$sceDelegate#trustAs `$sceDelegate.trustAs`} - * call or anything else. - * @returns {*} The `value` that was originally provided to {@link ng.$sceDelegate#trustAs - * `$sceDelegate.trustAs`} if `value` is the result of such a call. Otherwise, returns - * `value` unchanged. - */ - function valueOf(maybeTrusted) { - if (maybeTrusted instanceof trustedValueHolderBase) { - return maybeTrusted.$$unwrapTrustedValue(); - } else { - return maybeTrusted; - } - } - - /** - * @ngdoc method - * @name $sceDelegate#getTrusted - * - * @description - * Takes the result of a {@link ng.$sceDelegate#trustAs `$sceDelegate.trustAs`} call and - * returns the originally supplied value if the queried context type is a supertype of the - * created type. If this condition isn't satisfied, throws an exception. - * - * @param {string} type The kind of context in which this value is to be used. - * @param {*} maybeTrusted The result of a prior {@link ng.$sceDelegate#trustAs - * `$sceDelegate.trustAs`} call. - * @returns {*} The value the was originally provided to {@link ng.$sceDelegate#trustAs - * `$sceDelegate.trustAs`} if valid in this context. Otherwise, throws an exception. - */ - function getTrusted(type, maybeTrusted) { - if (maybeTrusted === null || maybeTrusted === undefined || maybeTrusted === '') { - return maybeTrusted; - } - var constructor = (byType.hasOwnProperty(type) ? byType[type] : null); - if (constructor && maybeTrusted instanceof constructor) { - return maybeTrusted.$$unwrapTrustedValue(); - } - // If we get here, then we may only take one of two actions. - // 1. sanitize the value for the requested type, or - // 2. throw an exception. - if (type === SCE_CONTEXTS.RESOURCE_URL) { - if (isResourceUrlAllowedByPolicy(maybeTrusted)) { - return maybeTrusted; - } else { - throw $sceMinErr('insecurl', - 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: {0}', - maybeTrusted.toString()); - } - } else if (type === SCE_CONTEXTS.HTML) { - return htmlSanitizer(maybeTrusted); - } - throw $sceMinErr('unsafe', 'Attempting to use an unsafe value in a safe context.'); - } - - return { trustAs: trustAs, - getTrusted: getTrusted, - valueOf: valueOf }; - }]; -} - - -/** - * @ngdoc provider - * @name $sceProvider - * @description - * - * The $sceProvider provider allows developers to configure the {@link ng.$sce $sce} service. - * - enable/disable Strict Contextual Escaping (SCE) in a module - * - override the default implementation with a custom delegate - * - * Read more about {@link ng.$sce Strict Contextual Escaping (SCE)}. - */ - -/* jshint maxlen: false*/ - -/** - * @ngdoc service - * @name $sce - * @kind function - * - * @description - * - * `$sce` is a service that provides Strict Contextual Escaping services to AngularJS. - * - * # Strict Contextual Escaping - * - * Strict Contextual Escaping (SCE) is a mode in which AngularJS requires bindings in certain - * contexts to result in a value that is marked as safe to use for that context. One example of - * such a context is binding arbitrary html controlled by the user via `ng-bind-html`. We refer - * to these contexts as privileged or SCE contexts. - * - * As of version 1.2, Angular ships with SCE enabled by default. - * - * Note: When enabled (the default), IE8 in quirks mode is not supported. In this mode, IE8 allows - * one to execute arbitrary javascript by the use of the expression() syntax. Refer - * to learn more about them. - * You can ensure your document is in standards mode and not quirks mode by adding `` - * to the top of your HTML document. - * - * SCE assists in writing code in way that (a) is secure by default and (b) makes auditing for - * security vulnerabilities such as XSS, clickjacking, etc. a lot easier. - * - * Here's an example of a binding in a privileged context: - * - * ``` - * - *
- * ``` - * - * Notice that `ng-bind-html` is bound to `userHtml` controlled by the user. With SCE - * disabled, this application allows the user to render arbitrary HTML into the DIV. - * In a more realistic example, one may be rendering user comments, blog articles, etc. via - * bindings. (HTML is just one example of a context where rendering user controlled input creates - * security vulnerabilities.) - * - * For the case of HTML, you might use a library, either on the client side, or on the server side, - * to sanitize unsafe HTML before binding to the value and rendering it in the document. - * - * How would you ensure that every place that used these types of bindings was bound to a value that - * was sanitized by your library (or returned as safe for rendering by your server?) How can you - * ensure that you didn't accidentally delete the line that sanitized the value, or renamed some - * properties/fields and forgot to update the binding to the sanitized value? - * - * To be secure by default, you want to ensure that any such bindings are disallowed unless you can - * determine that something explicitly says it's safe to use a value for binding in that - * context. You can then audit your code (a simple grep would do) to ensure that this is only done - * for those values that you can easily tell are safe - because they were received from your server, - * sanitized by your library, etc. You can organize your codebase to help with this - perhaps - * allowing only the files in a specific directory to do this. Ensuring that the internal API - * exposed by that code doesn't markup arbitrary values as safe then becomes a more manageable task. - * - * In the case of AngularJS' SCE service, one uses {@link ng.$sce#trustAs $sce.trustAs} - * (and shorthand methods such as {@link ng.$sce#trustAsHtml $sce.trustAsHtml}, etc.) to - * obtain values that will be accepted by SCE / privileged contexts. - * - * - * ## How does it work? - * - * In privileged contexts, directives and code will bind to the result of {@link ng.$sce#getTrusted - * $sce.getTrusted(context, value)} rather than to the value directly. Directives use {@link - * ng.$sce#parse $sce.parseAs} rather than `$parse` to watch attribute bindings, which performs the - * {@link ng.$sce#getTrusted $sce.getTrusted} behind the scenes on non-constant literals. - * - * As an example, {@link ng.directive:ngBindHtml ngBindHtml} uses {@link - * ng.$sce#parseAsHtml $sce.parseAsHtml(binding expression)}. Here's the actual code (slightly - * simplified): - * - * ``` - * var ngBindHtmlDirective = ['$sce', function($sce) { - * return function(scope, element, attr) { - * scope.$watch($sce.parseAsHtml(attr.ngBindHtml), function(value) { - * element.html(value || ''); - * }); - * }; - * }]; - * ``` - * - * ## Impact on loading templates - * - * This applies both to the {@link ng.directive:ngInclude `ng-include`} directive as well as - * `templateUrl`'s specified by {@link guide/directive directives}. - * - * By default, Angular only loads templates from the same domain and protocol as the application - * document. This is done by calling {@link ng.$sce#getTrustedResourceUrl - * $sce.getTrustedResourceUrl} on the template URL. To load templates from other domains and/or - * protocols, you may either either {@link ng.$sceDelegateProvider#resourceUrlWhitelist whitelist - * them} or {@link ng.$sce#trustAsResourceUrl wrap it} into a trusted value. - * - * *Please note*: - * The browser's - * [Same Origin Policy](https://code.google.com/p/browsersec/wiki/Part2#Same-origin_policy_for_XMLHttpRequest) - * and [Cross-Origin Resource Sharing (CORS)](http://www.w3.org/TR/cors/) - * policy apply in addition to this and may further restrict whether the template is successfully - * loaded. This means that without the right CORS policy, loading templates from a different domain - * won't work on all browsers. Also, loading templates from `file://` URL does not work on some - * browsers. - * - * ## This feels like too much overhead for the developer? - * - * It's important to remember that SCE only applies to interpolation expressions. - * - * If your expressions are constant literals, they're automatically trusted and you don't need to - * call `$sce.trustAs` on them (remember to include the `ngSanitize` module) (e.g. - * `
`) just works. - * - * Additionally, `a[href]` and `img[src]` automatically sanitize their URLs and do not pass them - * through {@link ng.$sce#getTrusted $sce.getTrusted}. SCE doesn't play a role here. - * - * The included {@link ng.$sceDelegate $sceDelegate} comes with sane defaults to allow you to load - * templates in `ng-include` from your application's domain without having to even know about SCE. - * It blocks loading templates from other domains or loading templates over http from an https - * served document. You can change these by setting your own custom {@link - * ng.$sceDelegateProvider#resourceUrlWhitelist whitelists} and {@link - * ng.$sceDelegateProvider#resourceUrlBlacklist blacklists} for matching such URLs. - * - * This significantly reduces the overhead. It is far easier to pay the small overhead and have an - * application that's secure and can be audited to verify that with much more ease than bolting - * security onto an application later. - * - * - * ## What trusted context types are supported? - * - * | Context | Notes | - * |---------------------|----------------| - * | `$sce.HTML` | For HTML that's safe to source into the application. The {@link ng.directive:ngBindHtml ngBindHtml} directive uses this context for bindings. If an unsafe value is encountered and the {@link ngSanitize $sanitize} module is present this will sanitize the value instead of throwing an error. | - * | `$sce.CSS` | For CSS that's safe to source into the application. Currently unused. Feel free to use it in your own directives. | - * | `$sce.URL` | For URLs that are safe to follow as links. Currently unused (`
Note that `$sce.RESOURCE_URL` makes a stronger statement about the URL than `$sce.URL` does and therefore contexts requiring values trusted for `$sce.RESOURCE_URL` can be used anywhere that values trusted for `$sce.URL` are required. | - * | `$sce.JS` | For JavaScript that is safe to execute in your application's context. Currently unused. Feel free to use it in your own directives. | - * - * ## Format of items in {@link ng.$sceDelegateProvider#resourceUrlWhitelist resourceUrlWhitelist}/{@link ng.$sceDelegateProvider#resourceUrlBlacklist Blacklist}
- * - * Each element in these arrays must be one of the following: - * - * - **'self'** - * - The special **string**, `'self'`, can be used to match against all URLs of the **same - * domain** as the application document using the **same protocol**. - * - **String** (except the special value `'self'`) - * - The string is matched against the full *normalized / absolute URL* of the resource - * being tested (substring matches are not good enough.) - * - There are exactly **two wildcard sequences** - `*` and `**`. All other characters - * match themselves. - * - `*`: matches zero or more occurrences of any character other than one of the following 6 - * characters: '`:`', '`/`', '`.`', '`?`', '`&`' and ';'. It's a useful wildcard for use - * in a whitelist. - * - `**`: matches zero or more occurrences of *any* character. As such, it's not - * not appropriate to use in for a scheme, domain, etc. as it would match too much. (e.g. - * http://**.example.com/ would match http://evil.com/?ignore=.example.com/ and that might - * not have been the intention.) Its usage at the very end of the path is ok. (e.g. - * http://foo.example.com/templates/**). - * - **RegExp** (*see caveat below*) - * - *Caveat*: While regular expressions are powerful and offer great flexibility, their syntax - * (and all the inevitable escaping) makes them *harder to maintain*. It's easy to - * accidentally introduce a bug when one updates a complex expression (imho, all regexes should - * have good test coverage.). For instance, the use of `.` in the regex is correct only in a - * small number of cases. A `.` character in the regex used when matching the scheme or a - * subdomain could be matched against a `:` or literal `.` that was likely not intended. It - * is highly recommended to use the string patterns and only fall back to regular expressions - * if they as a last resort. - * - The regular expression must be an instance of RegExp (i.e. not a string.) It is - * matched against the **entire** *normalized / absolute URL* of the resource being tested - * (even when the RegExp did not have the `^` and `$` codes.) In addition, any flags - * present on the RegExp (such as multiline, global, ignoreCase) are ignored. - * - If you are generating your JavaScript from some other templating engine (not - * recommended, e.g. in issue [#4006](https://github.com/angular/angular.js/issues/4006)), - * remember to escape your regular expression (and be aware that you might need more than - * one level of escaping depending on your templating engine and the way you interpolated - * the value.) Do make use of your platform's escaping mechanism as it might be good - * enough before coding your own. e.g. Ruby has - * [Regexp.escape(str)](http://www.ruby-doc.org/core-2.0.0/Regexp.html#method-c-escape) - * and Python has [re.escape](http://docs.python.org/library/re.html#re.escape). - * Javascript lacks a similar built in function for escaping. Take a look at Google - * Closure library's [goog.string.regExpEscape(s)]( - * http://docs.closure-library.googlecode.com/git/closure_goog_string_string.js.source.html#line962). - * - * Refer {@link ng.$sceDelegateProvider $sceDelegateProvider} for an example. - * - * ## Show me an example using SCE. - * - * - * - *
- *

- * User comments
- * By default, HTML that isn't explicitly trusted (e.g. Alice's comment) is sanitized when - * $sanitize is available. If $sanitize isn't available, this results in an error instead of an - * exploit. - *
- *
- * {{userComment.name}}: - * - *
- *
- *
- *
- *
- * - * - * var mySceApp = angular.module('mySceApp', ['ngSanitize']); - * - * mySceApp.controller("myAppController", function myAppController($http, $templateCache, $sce) { - * var self = this; - * $http.get("test_data.json", {cache: $templateCache}).success(function(userComments) { - * self.userComments = userComments; - * }); - * self.explicitlyTrustedHtml = $sce.trustAsHtml( - * 'Hover over this text.'); - * }); - * - * - * - * [ - * { "name": "Alice", - * "htmlComment": - * "Is anyone reading this?" - * }, - * { "name": "Bob", - * "htmlComment": "Yes! Am I the only other one?" - * } - * ] - * - * - * - * describe('SCE doc demo', function() { - * it('should sanitize untrusted values', function() { - * expect(element.all(by.css('.htmlComment')).first().getInnerHtml()) - * .toBe('Is anyone reading this?'); - * }); - * - * it('should NOT sanitize explicitly trusted values', function() { - * expect(element(by.id('explicitlyTrustedHtml')).getInnerHtml()).toBe( - * 'Hover over this text.'); - * }); - * }); - * - *
- * - * - * - * ## Can I disable SCE completely? - * - * Yes, you can. However, this is strongly discouraged. SCE gives you a lot of security benefits - * for little coding overhead. It will be much harder to take an SCE disabled application and - * either secure it on your own or enable SCE at a later stage. It might make sense to disable SCE - * for cases where you have a lot of existing code that was written before SCE was introduced and - * you're migrating them a module at a time. - * - * That said, here's how you can completely disable SCE: - * - * ``` - * angular.module('myAppWithSceDisabledmyApp', []).config(function($sceProvider) { - * // Completely disable SCE. For demonstration purposes only! - * // Do not use in new projects. - * $sceProvider.enabled(false); - * }); - * ``` - * - */ -/* jshint maxlen: 100 */ - -function $SceProvider() { - var enabled = true; - - /** - * @ngdoc method - * @name $sceProvider#enabled - * @kind function - * - * @param {boolean=} value If provided, then enables/disables SCE. - * @return {boolean} true if SCE is enabled, false otherwise. - * - * @description - * Enables/disables SCE and returns the current value. - */ - this.enabled = function (value) { - if (arguments.length) { - enabled = !!value; - } - return enabled; - }; - - - /* Design notes on the default implementation for SCE. - * - * The API contract for the SCE delegate - * ------------------------------------- - * The SCE delegate object must provide the following 3 methods: - * - * - trustAs(contextEnum, value) - * This method is used to tell the SCE service that the provided value is OK to use in the - * contexts specified by contextEnum. It must return an object that will be accepted by - * getTrusted() for a compatible contextEnum and return this value. - * - * - valueOf(value) - * For values that were not produced by trustAs(), return them as is. For values that were - * produced by trustAs(), return the corresponding input value to trustAs. Basically, if - * trustAs is wrapping the given values into some type, this operation unwraps it when given - * such a value. - * - * - getTrusted(contextEnum, value) - * This function should return the a value that is safe to use in the context specified by - * contextEnum or throw and exception otherwise. - * - * NOTE: This contract deliberately does NOT state that values returned by trustAs() must be - * opaque or wrapped in some holder object. That happens to be an implementation detail. For - * instance, an implementation could maintain a registry of all trusted objects by context. In - * such a case, trustAs() would return the same object that was passed in. getTrusted() would - * return the same object passed in if it was found in the registry under a compatible context or - * throw an exception otherwise. An implementation might only wrap values some of the time based - * on some criteria. getTrusted() might return a value and not throw an exception for special - * constants or objects even if not wrapped. All such implementations fulfill this contract. - * - * - * A note on the inheritance model for SCE contexts - * ------------------------------------------------ - * I've used inheritance and made RESOURCE_URL wrapped types a subtype of URL wrapped types. This - * is purely an implementation details. - * - * The contract is simply this: - * - * getTrusted($sce.RESOURCE_URL, value) succeeding implies that getTrusted($sce.URL, value) - * will also succeed. - * - * Inheritance happens to capture this in a natural way. In some future, we - * may not use inheritance anymore. That is OK because no code outside of - * sce.js and sceSpecs.js would need to be aware of this detail. - */ - - this.$get = ['$parse', '$sniffer', '$sceDelegate', function( - $parse, $sniffer, $sceDelegate) { - // Prereq: Ensure that we're not running in IE8 quirks mode. In that mode, IE allows - // the "expression(javascript expression)" syntax which is insecure. - if (enabled && $sniffer.msie && $sniffer.msieDocumentMode < 8) { - throw $sceMinErr('iequirks', - 'Strict Contextual Escaping does not support Internet Explorer version < 9 in quirks ' + - 'mode. You can fix this by adding the text to the top of your HTML ' + - 'document. See http://docs.angularjs.org/api/ng.$sce for more information.'); - } - - var sce = shallowCopy(SCE_CONTEXTS); - - /** - * @ngdoc method - * @name $sce#isEnabled - * @kind function - * - * @return {Boolean} true if SCE is enabled, false otherwise. If you want to set the value, you - * have to do it at module config time on {@link ng.$sceProvider $sceProvider}. - * - * @description - * Returns a boolean indicating if SCE is enabled. - */ - sce.isEnabled = function () { - return enabled; - }; - sce.trustAs = $sceDelegate.trustAs; - sce.getTrusted = $sceDelegate.getTrusted; - sce.valueOf = $sceDelegate.valueOf; - - if (!enabled) { - sce.trustAs = sce.getTrusted = function(type, value) { return value; }; - sce.valueOf = identity; - } - - /** - * @ngdoc method - * @name $sce#parseAs - * - * @description - * Converts Angular {@link guide/expression expression} into a function. This is like {@link - * ng.$parse $parse} and is identical when the expression is a literal constant. Otherwise, it - * wraps the expression in a call to {@link ng.$sce#getTrusted $sce.getTrusted(*type*, - * *result*)} - * - * @param {string} type The kind of SCE context in which this result will be used. - * @param {string} expression String expression to compile. - * @returns {function(context, locals)} a function which represents the compiled expression: - * - * * `context` – `{object}` – an object against which any expressions embedded in the strings - * are evaluated against (typically a scope object). - * * `locals` – `{object=}` – local variables context object, useful for overriding values in - * `context`. - */ - sce.parseAs = function sceParseAs(type, expr) { - var parsed = $parse(expr); - if (parsed.literal && parsed.constant) { - return parsed; - } else { - return function sceParseAsTrusted(self, locals) { - return sce.getTrusted(type, parsed(self, locals)); - }; - } - }; - - /** - * @ngdoc method - * @name $sce#trustAs - * - * @description - * Delegates to {@link ng.$sceDelegate#trustAs `$sceDelegate.trustAs`}. As such, - * returns an object that is trusted by angular for use in specified strict contextual - * escaping contexts (such as ng-bind-html, ng-include, any src attribute - * interpolation, any dom event binding attribute interpolation such as for onclick, etc.) - * that uses the provided value. See * {@link ng.$sce $sce} for enabling strict contextual - * escaping. - * - * @param {string} type The kind of context in which this value is safe for use. e.g. url, - * resource_url, html, js and css. - * @param {*} value The value that that should be considered trusted/safe. - * @returns {*} A value that can be used to stand in for the provided `value` in places - * where Angular expects a $sce.trustAs() return value. - */ - - /** - * @ngdoc method - * @name $sce#trustAsHtml - * - * @description - * Shorthand method. `$sce.trustAsHtml(value)` → - * {@link ng.$sceDelegate#trustAs `$sceDelegate.trustAs($sce.HTML, value)`} - * - * @param {*} value The value to trustAs. - * @returns {*} An object that can be passed to {@link ng.$sce#getTrustedHtml - * $sce.getTrustedHtml(value)} to obtain the original value. (privileged directives - * only accept expressions that are either literal constants or are the - * return value of {@link ng.$sce#trustAs $sce.trustAs}.) - */ - - /** - * @ngdoc method - * @name $sce#trustAsUrl - * - * @description - * Shorthand method. `$sce.trustAsUrl(value)` → - * {@link ng.$sceDelegate#trustAs `$sceDelegate.trustAs($sce.URL, value)`} - * - * @param {*} value The value to trustAs. - * @returns {*} An object that can be passed to {@link ng.$sce#getTrustedUrl - * $sce.getTrustedUrl(value)} to obtain the original value. (privileged directives - * only accept expressions that are either literal constants or are the - * return value of {@link ng.$sce#trustAs $sce.trustAs}.) - */ - - /** - * @ngdoc method - * @name $sce#trustAsResourceUrl - * - * @description - * Shorthand method. `$sce.trustAsResourceUrl(value)` → - * {@link ng.$sceDelegate#trustAs `$sceDelegate.trustAs($sce.RESOURCE_URL, value)`} - * - * @param {*} value The value to trustAs. - * @returns {*} An object that can be passed to {@link ng.$sce#getTrustedResourceUrl - * $sce.getTrustedResourceUrl(value)} to obtain the original value. (privileged directives - * only accept expressions that are either literal constants or are the return - * value of {@link ng.$sce#trustAs $sce.trustAs}.) - */ - - /** - * @ngdoc method - * @name $sce#trustAsJs - * - * @description - * Shorthand method. `$sce.trustAsJs(value)` → - * {@link ng.$sceDelegate#trustAs `$sceDelegate.trustAs($sce.JS, value)`} - * - * @param {*} value The value to trustAs. - * @returns {*} An object that can be passed to {@link ng.$sce#getTrustedJs - * $sce.getTrustedJs(value)} to obtain the original value. (privileged directives - * only accept expressions that are either literal constants or are the - * return value of {@link ng.$sce#trustAs $sce.trustAs}.) - */ - - /** - * @ngdoc method - * @name $sce#getTrusted - * - * @description - * Delegates to {@link ng.$sceDelegate#getTrusted `$sceDelegate.getTrusted`}. As such, - * takes the result of a {@link ng.$sce#trustAs `$sce.trustAs`}() call and returns the - * originally supplied value if the queried context type is a supertype of the created type. - * If this condition isn't satisfied, throws an exception. - * - * @param {string} type The kind of context in which this value is to be used. - * @param {*} maybeTrusted The result of a prior {@link ng.$sce#trustAs `$sce.trustAs`} - * call. - * @returns {*} The value the was originally provided to - * {@link ng.$sce#trustAs `$sce.trustAs`} if valid in this context. - * Otherwise, throws an exception. - */ - - /** - * @ngdoc method - * @name $sce#getTrustedHtml - * - * @description - * Shorthand method. `$sce.getTrustedHtml(value)` → - * {@link ng.$sceDelegate#getTrusted `$sceDelegate.getTrusted($sce.HTML, value)`} - * - * @param {*} value The value to pass to `$sce.getTrusted`. - * @returns {*} The return value of `$sce.getTrusted($sce.HTML, value)` - */ - - /** - * @ngdoc method - * @name $sce#getTrustedCss - * - * @description - * Shorthand method. `$sce.getTrustedCss(value)` → - * {@link ng.$sceDelegate#getTrusted `$sceDelegate.getTrusted($sce.CSS, value)`} - * - * @param {*} value The value to pass to `$sce.getTrusted`. - * @returns {*} The return value of `$sce.getTrusted($sce.CSS, value)` - */ - - /** - * @ngdoc method - * @name $sce#getTrustedUrl - * - * @description - * Shorthand method. `$sce.getTrustedUrl(value)` → - * {@link ng.$sceDelegate#getTrusted `$sceDelegate.getTrusted($sce.URL, value)`} - * - * @param {*} value The value to pass to `$sce.getTrusted`. - * @returns {*} The return value of `$sce.getTrusted($sce.URL, value)` - */ - - /** - * @ngdoc method - * @name $sce#getTrustedResourceUrl - * - * @description - * Shorthand method. `$sce.getTrustedResourceUrl(value)` → - * {@link ng.$sceDelegate#getTrusted `$sceDelegate.getTrusted($sce.RESOURCE_URL, value)`} - * - * @param {*} value The value to pass to `$sceDelegate.getTrusted`. - * @returns {*} The return value of `$sce.getTrusted($sce.RESOURCE_URL, value)` - */ - - /** - * @ngdoc method - * @name $sce#getTrustedJs - * - * @description - * Shorthand method. `$sce.getTrustedJs(value)` → - * {@link ng.$sceDelegate#getTrusted `$sceDelegate.getTrusted($sce.JS, value)`} - * - * @param {*} value The value to pass to `$sce.getTrusted`. - * @returns {*} The return value of `$sce.getTrusted($sce.JS, value)` - */ - - /** - * @ngdoc method - * @name $sce#parseAsHtml - * - * @description - * Shorthand method. `$sce.parseAsHtml(expression string)` → - * {@link ng.$sce#parse `$sce.parseAs($sce.HTML, value)`} - * - * @param {string} expression String expression to compile. - * @returns {function(context, locals)} a function which represents the compiled expression: - * - * * `context` – `{object}` – an object against which any expressions embedded in the strings - * are evaluated against (typically a scope object). - * * `locals` – `{object=}` – local variables context object, useful for overriding values in - * `context`. - */ - - /** - * @ngdoc method - * @name $sce#parseAsCss - * - * @description - * Shorthand method. `$sce.parseAsCss(value)` → - * {@link ng.$sce#parse `$sce.parseAs($sce.CSS, value)`} - * - * @param {string} expression String expression to compile. - * @returns {function(context, locals)} a function which represents the compiled expression: - * - * * `context` – `{object}` – an object against which any expressions embedded in the strings - * are evaluated against (typically a scope object). - * * `locals` – `{object=}` – local variables context object, useful for overriding values in - * `context`. - */ - - /** - * @ngdoc method - * @name $sce#parseAsUrl - * - * @description - * Shorthand method. `$sce.parseAsUrl(value)` → - * {@link ng.$sce#parse `$sce.parseAs($sce.URL, value)`} - * - * @param {string} expression String expression to compile. - * @returns {function(context, locals)} a function which represents the compiled expression: - * - * * `context` – `{object}` – an object against which any expressions embedded in the strings - * are evaluated against (typically a scope object). - * * `locals` – `{object=}` – local variables context object, useful for overriding values in - * `context`. - */ - - /** - * @ngdoc method - * @name $sce#parseAsResourceUrl - * - * @description - * Shorthand method. `$sce.parseAsResourceUrl(value)` → - * {@link ng.$sce#parse `$sce.parseAs($sce.RESOURCE_URL, value)`} - * - * @param {string} expression String expression to compile. - * @returns {function(context, locals)} a function which represents the compiled expression: - * - * * `context` – `{object}` – an object against which any expressions embedded in the strings - * are evaluated against (typically a scope object). - * * `locals` – `{object=}` – local variables context object, useful for overriding values in - * `context`. - */ - - /** - * @ngdoc method - * @name $sce#parseAsJs - * - * @description - * Shorthand method. `$sce.parseAsJs(value)` → - * {@link ng.$sce#parse `$sce.parseAs($sce.JS, value)`} - * - * @param {string} expression String expression to compile. - * @returns {function(context, locals)} a function which represents the compiled expression: - * - * * `context` – `{object}` – an object against which any expressions embedded in the strings - * are evaluated against (typically a scope object). - * * `locals` – `{object=}` – local variables context object, useful for overriding values in - * `context`. - */ - - // Shorthand delegations. - var parse = sce.parseAs, - getTrusted = sce.getTrusted, - trustAs = sce.trustAs; - - forEach(SCE_CONTEXTS, function (enumValue, name) { - var lName = lowercase(name); - sce[camelCase("parse_as_" + lName)] = function (expr) { - return parse(enumValue, expr); - }; - sce[camelCase("get_trusted_" + lName)] = function (value) { - return getTrusted(enumValue, value); - }; - sce[camelCase("trust_as_" + lName)] = function (value) { - return trustAs(enumValue, value); - }; - }); - - return sce; - }]; -} - -/** - * !!! This is an undocumented "private" service !!! - * - * @name $sniffer - * @requires $window - * @requires $document - * - * @property {boolean} history Does the browser support html5 history api ? - * @property {boolean} hashchange Does the browser support hashchange event ? - * @property {boolean} transitions Does the browser support CSS transition events ? - * @property {boolean} animations Does the browser support CSS animation events ? - * - * @description - * This is very simple implementation of testing browser's features. - */ -function $SnifferProvider() { - this.$get = ['$window', '$document', function($window, $document) { - var eventSupport = {}, - android = - int((/android (\d+)/.exec(lowercase(($window.navigator || {}).userAgent)) || [])[1]), - boxee = /Boxee/i.test(($window.navigator || {}).userAgent), - document = $document[0] || {}, - documentMode = document.documentMode, - vendorPrefix, - vendorRegex = /^(Moz|webkit|O|ms)(?=[A-Z])/, - bodyStyle = document.body && document.body.style, - transitions = false, - animations = false, - match; - - if (bodyStyle) { - for(var prop in bodyStyle) { - if(match = vendorRegex.exec(prop)) { - vendorPrefix = match[0]; - vendorPrefix = vendorPrefix.substr(0, 1).toUpperCase() + vendorPrefix.substr(1); - break; - } - } - - if(!vendorPrefix) { - vendorPrefix = ('WebkitOpacity' in bodyStyle) && 'webkit'; - } - - transitions = !!(('transition' in bodyStyle) || (vendorPrefix + 'Transition' in bodyStyle)); - animations = !!(('animation' in bodyStyle) || (vendorPrefix + 'Animation' in bodyStyle)); - - if (android && (!transitions||!animations)) { - transitions = isString(document.body.style.webkitTransition); - animations = isString(document.body.style.webkitAnimation); - } - } - - - return { - // Android has history.pushState, but it does not update location correctly - // so let's not use the history API at all. - // http://code.google.com/p/android/issues/detail?id=17471 - // https://github.com/angular/angular.js/issues/904 - - // older webkit browser (533.9) on Boxee box has exactly the same problem as Android has - // so let's not use the history API also - // We are purposefully using `!(android < 4)` to cover the case when `android` is undefined - // jshint -W018 - history: !!($window.history && $window.history.pushState && !(android < 4) && !boxee), - // jshint +W018 - hashchange: 'onhashchange' in $window && - // IE8 compatible mode lies - (!documentMode || documentMode > 7), - hasEvent: function(event) { - // IE9 implements 'input' event it's so fubared that we rather pretend that it doesn't have - // it. In particular the event is not fired when backspace or delete key are pressed or - // when cut operation is performed. - if (event == 'input' && msie == 9) return false; - - if (isUndefined(eventSupport[event])) { - var divElm = document.createElement('div'); - eventSupport[event] = 'on' + event in divElm; - } - - return eventSupport[event]; - }, - csp: csp(), - vendorPrefix: vendorPrefix, - transitions : transitions, - animations : animations, - android: android, - msie : msie, - msieDocumentMode: documentMode - }; - }]; -} - -function $TimeoutProvider() { - this.$get = ['$rootScope', '$browser', '$q', '$exceptionHandler', - function($rootScope, $browser, $q, $exceptionHandler) { - var deferreds = {}; - - - /** - * @ngdoc service - * @name $timeout - * - * @description - * Angular's wrapper for `window.setTimeout`. The `fn` function is wrapped into a try/catch - * block and delegates any exceptions to - * {@link ng.$exceptionHandler $exceptionHandler} service. - * - * The return value of registering a timeout function is a promise, which will be resolved when - * the timeout is reached and the timeout function is executed. - * - * To cancel a timeout request, call `$timeout.cancel(promise)`. - * - * In tests you can use {@link ngMock.$timeout `$timeout.flush()`} to - * synchronously flush the queue of deferred functions. - * - * @param {function()} fn A function, whose execution should be delayed. - * @param {number=} [delay=0] Delay in milliseconds. - * @param {boolean=} [invokeApply=true] If set to `false` skips model dirty checking, otherwise - * will invoke `fn` within the {@link ng.$rootScope.Scope#$apply $apply} block. - * @returns {Promise} Promise that will be resolved when the timeout is reached. The value this - * promise will be resolved with is the return value of the `fn` function. - * - */ - function timeout(fn, delay, invokeApply) { - var deferred = $q.defer(), - promise = deferred.promise, - skipApply = (isDefined(invokeApply) && !invokeApply), - timeoutId; - - timeoutId = $browser.defer(function() { - try { - deferred.resolve(fn()); - } catch(e) { - deferred.reject(e); - $exceptionHandler(e); - } - finally { - delete deferreds[promise.$$timeoutId]; - } - - if (!skipApply) $rootScope.$apply(); - }, delay); - - promise.$$timeoutId = timeoutId; - deferreds[timeoutId] = deferred; - - return promise; - } - - - /** - * @ngdoc method - * @name $timeout#cancel - * - * @description - * Cancels a task associated with the `promise`. As a result of this, the promise will be - * resolved with a rejection. - * - * @param {Promise=} promise Promise returned by the `$timeout` function. - * @returns {boolean} Returns `true` if the task hasn't executed yet and was successfully - * canceled. - */ - timeout.cancel = function(promise) { - if (promise && promise.$$timeoutId in deferreds) { - deferreds[promise.$$timeoutId].reject('canceled'); - delete deferreds[promise.$$timeoutId]; - return $browser.defer.cancel(promise.$$timeoutId); - } - return false; - }; - - return timeout; - }]; -} - -// NOTE: The usage of window and document instead of $window and $document here is -// deliberate. This service depends on the specific behavior of anchor nodes created by the -// browser (resolving and parsing URLs) that is unlikely to be provided by mock objects and -// cause us to break tests. In addition, when the browser resolves a URL for XHR, it -// doesn't know about mocked locations and resolves URLs to the real document - which is -// exactly the behavior needed here. There is little value is mocking these out for this -// service. -var urlParsingNode = document.createElement("a"); -var originUrl = urlResolve(window.location.href, true); - - -/** - * - * Implementation Notes for non-IE browsers - * ---------------------------------------- - * Assigning a URL to the href property of an anchor DOM node, even one attached to the DOM, - * results both in the normalizing and parsing of the URL. Normalizing means that a relative - * URL will be resolved into an absolute URL in the context of the application document. - * Parsing means that the anchor node's host, hostname, protocol, port, pathname and related - * properties are all populated to reflect the normalized URL. This approach has wide - * compatibility - Safari 1+, Mozilla 1+, Opera 7+,e etc. See - * http://www.aptana.com/reference/html/api/HTMLAnchorElement.html - * - * Implementation Notes for IE - * --------------------------- - * IE >= 8 and <= 10 normalizes the URL when assigned to the anchor node similar to the other - * browsers. However, the parsed components will not be set if the URL assigned did not specify - * them. (e.g. if you assign a.href = "foo", then a.protocol, a.host, etc. will be empty.) We - * work around that by performing the parsing in a 2nd step by taking a previously normalized - * URL (e.g. by assigning to a.href) and assigning it a.href again. This correctly populates the - * properties such as protocol, hostname, port, etc. - * - * IE7 does not normalize the URL when assigned to an anchor node. (Apparently, it does, if one - * uses the inner HTML approach to assign the URL as part of an HTML snippet - - * http://stackoverflow.com/a/472729) However, setting img[src] does normalize the URL. - * Unfortunately, setting img[src] to something like "javascript:foo" on IE throws an exception. - * Since the primary usage for normalizing URLs is to sanitize such URLs, we can't use that - * method and IE < 8 is unsupported. - * - * References: - * http://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement - * http://www.aptana.com/reference/html/api/HTMLAnchorElement.html - * http://url.spec.whatwg.org/#urlutils - * https://github.com/angular/angular.js/pull/2902 - * http://james.padolsey.com/javascript/parsing-urls-with-the-dom/ - * - * @kind function - * @param {string} url The URL to be parsed. - * @description Normalizes and parses a URL. - * @returns {object} Returns the normalized URL as a dictionary. - * - * | member name | Description | - * |---------------|----------------| - * | href | A normalized version of the provided URL if it was not an absolute URL | - * | protocol | The protocol including the trailing colon | - * | host | The host and port (if the port is non-default) of the normalizedUrl | - * | search | The search params, minus the question mark | - * | hash | The hash string, minus the hash symbol - * | hostname | The hostname - * | port | The port, without ":" - * | pathname | The pathname, beginning with "/" - * - */ -function urlResolve(url, base) { - var href = url; - - if (msie) { - // Normalize before parse. Refer Implementation Notes on why this is - // done in two steps on IE. - urlParsingNode.setAttribute("href", href); - href = urlParsingNode.href; - } - - urlParsingNode.setAttribute('href', href); - - // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils - return { - href: urlParsingNode.href, - protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', - host: urlParsingNode.host, - search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', - hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', - hostname: urlParsingNode.hostname, - port: urlParsingNode.port, - pathname: (urlParsingNode.pathname.charAt(0) === '/') - ? urlParsingNode.pathname - : '/' + urlParsingNode.pathname - }; -} - -/** - * Parse a request URL and determine whether this is a same-origin request as the application document. - * - * @param {string|object} requestUrl The url of the request as a string that will be resolved - * or a parsed URL object. - * @returns {boolean} Whether the request is for the same origin as the application document. - */ -function urlIsSameOrigin(requestUrl) { - var parsed = (isString(requestUrl)) ? urlResolve(requestUrl) : requestUrl; - return (parsed.protocol === originUrl.protocol && - parsed.host === originUrl.host); -} - -/** - * @ngdoc service - * @name $window - * - * @description - * A reference to the browser's `window` object. While `window` - * is globally available in JavaScript, it causes testability problems, because - * it is a global variable. In angular we always refer to it through the - * `$window` service, so it may be overridden, removed or mocked for testing. - * - * Expressions, like the one defined for the `ngClick` directive in the example - * below, are evaluated with respect to the current scope. Therefore, there is - * no risk of inadvertently coding in a dependency on a global value in such an - * expression. - * - * @example - - - -
- - -
-
- - it('should display the greeting in the input box', function() { - element(by.model('greeting')).sendKeys('Hello, E2E Tests'); - // If we click the button it will block the test runner - // element(':button').click(); - }); - -
- */ -function $WindowProvider(){ - this.$get = valueFn(window); -} - -/* global currencyFilter: true, - dateFilter: true, - filterFilter: true, - jsonFilter: true, - limitToFilter: true, - lowercaseFilter: true, - numberFilter: true, - orderByFilter: true, - uppercaseFilter: true, - */ - -/** - * @ngdoc provider - * @name $filterProvider - * @description - * - * Filters are just functions which transform input to an output. However filters need to be - * Dependency Injected. To achieve this a filter definition consists of a factory function which is - * annotated with dependencies and is responsible for creating a filter function. - * - * ```js - * // Filter registration - * function MyModule($provide, $filterProvider) { - * // create a service to demonstrate injection (not always needed) - * $provide.value('greet', function(name){ - * return 'Hello ' + name + '!'; - * }); - * - * // register a filter factory which uses the - * // greet service to demonstrate DI. - * $filterProvider.register('greet', function(greet){ - * // return the filter function which uses the greet service - * // to generate salutation - * return function(text) { - * // filters need to be forgiving so check input validity - * return text && greet(text) || text; - * }; - * }); - * } - * ``` - * - * The filter function is registered with the `$injector` under the filter name suffix with - * `Filter`. - * - * ```js - * it('should be the same instance', inject( - * function($filterProvider) { - * $filterProvider.register('reverse', function(){ - * return ...; - * }); - * }, - * function($filter, reverseFilter) { - * expect($filter('reverse')).toBe(reverseFilter); - * }); - * ``` - * - * - * For more information about how angular filters work, and how to create your own filters, see - * {@link guide/filter Filters} in the Angular Developer Guide. - */ - -/** - * @ngdoc service - * @name $filter - * @kind function - * @description - * Filters are used for formatting data displayed to the user. - * - * The general syntax in templates is as follows: - * - * {{ expression [| filter_name[:parameter_value] ... ] }} - * - * @param {String} name Name of the filter function to retrieve - * @return {Function} the filter function - * @example - - -
-

{{ originalText }}

-

{{ filteredText }}

-
-
- - - angular.module('filterExample', []) - .controller('MainCtrl', function($scope, $filter) { - $scope.originalText = 'hello'; - $scope.filteredText = $filter('uppercase')($scope.originalText); - }); - -
- */ -$FilterProvider.$inject = ['$provide']; -function $FilterProvider($provide) { - var suffix = 'Filter'; - - /** - * @ngdoc method - * @name $filterProvider#register - * @param {string|Object} name Name of the filter function, or an object map of filters where - * the keys are the filter names and the values are the filter factories. - * @returns {Object} Registered filter instance, or if a map of filters was provided then a map - * of the registered filter instances. - */ - function register(name, factory) { - if(isObject(name)) { - var filters = {}; - forEach(name, function(filter, key) { - filters[key] = register(key, filter); - }); - return filters; - } else { - return $provide.factory(name + suffix, factory); - } - } - this.register = register; - - this.$get = ['$injector', function($injector) { - return function(name) { - return $injector.get(name + suffix); - }; - }]; - - //////////////////////////////////////// - - /* global - currencyFilter: false, - dateFilter: false, - filterFilter: false, - jsonFilter: false, - limitToFilter: false, - lowercaseFilter: false, - numberFilter: false, - orderByFilter: false, - uppercaseFilter: false, - */ - - register('currency', currencyFilter); - register('date', dateFilter); - register('filter', filterFilter); - register('json', jsonFilter); - register('limitTo', limitToFilter); - register('lowercase', lowercaseFilter); - register('number', numberFilter); - register('orderBy', orderByFilter); - register('uppercase', uppercaseFilter); -} - -/** - * @ngdoc filter - * @name filter - * @kind function - * - * @description - * Selects a subset of items from `array` and returns it as a new array. - * - * @param {Array} array The source array. - * @param {string|Object|function()} expression The predicate to be used for selecting items from - * `array`. - * - * Can be one of: - * - * - `string`: The string is evaluated as an expression and the resulting value is used for substring match against - * the contents of the `array`. All strings or objects with string properties in `array` that contain this string - * will be returned. The predicate can be negated by prefixing the string with `!`. - * - * - `Object`: A pattern object can be used to filter specific properties on objects contained - * by `array`. For example `{name:"M", phone:"1"}` predicate will return an array of items - * which have property `name` containing "M" and property `phone` containing "1". A special - * property name `$` can be used (as in `{$:"text"}`) to accept a match against any - * property of the object. That's equivalent to the simple substring match with a `string` - * as described above. The predicate can be negated by prefixing the string with `!`. - * For Example `{name: "!M"}` predicate will return an array of items which have property `name` - * not containing "M". - * - * - `function(value)`: A predicate function can be used to write arbitrary filters. The function is - * called for each element of `array`. The final result is an array of those elements that - * the predicate returned true for. - * - * @param {function(actual, expected)|true|undefined} comparator Comparator which is used in - * determining if the expected value (from the filter expression) and actual value (from - * the object in the array) should be considered a match. - * - * Can be one of: - * - * - `function(actual, expected)`: - * The function will be given the object value and the predicate value to compare and - * should return true if the item should be included in filtered result. - * - * - `true`: A shorthand for `function(actual, expected) { return angular.equals(expected, actual)}`. - * this is essentially strict comparison of expected and actual. - * - * - `false|undefined`: A short hand for a function which will look for a substring match in case - * insensitive way. - * - * @example - - -
- - Search: - - - - - - -
NamePhone
{{friend.name}}{{friend.phone}}
-
- Any:
- Name only
- Phone only
- Equality
- - - - - - -
NamePhone
{{friendObj.name}}{{friendObj.phone}}
-
- - var expectFriendNames = function(expectedNames, key) { - element.all(by.repeater(key + ' in friends').column(key + '.name')).then(function(arr) { - arr.forEach(function(wd, i) { - expect(wd.getText()).toMatch(expectedNames[i]); - }); - }); - }; - - it('should search across all fields when filtering with a string', function() { - var searchText = element(by.model('searchText')); - searchText.clear(); - searchText.sendKeys('m'); - expectFriendNames(['Mary', 'Mike', 'Adam'], 'friend'); - - searchText.clear(); - searchText.sendKeys('76'); - expectFriendNames(['John', 'Julie'], 'friend'); - }); - - it('should search in specific fields when filtering with a predicate object', function() { - var searchAny = element(by.model('search.$')); - searchAny.clear(); - searchAny.sendKeys('i'); - expectFriendNames(['Mary', 'Mike', 'Julie', 'Juliette'], 'friendObj'); - }); - it('should use a equal comparison when comparator is true', function() { - var searchName = element(by.model('search.name')); - var strict = element(by.model('strict')); - searchName.clear(); - searchName.sendKeys('Julie'); - strict.click(); - expectFriendNames(['Julie'], 'friendObj'); - }); - -
- */ -function filterFilter() { - return function(array, expression, comparator) { - if (!isArray(array)) return array; - - var comparatorType = typeof(comparator), - predicates = []; - - predicates.check = function(value) { - for (var j = 0; j < predicates.length; j++) { - if(!predicates[j](value)) { - return false; - } - } - return true; - }; - - if (comparatorType !== 'function') { - if (comparatorType === 'boolean' && comparator) { - comparator = function(obj, text) { - return angular.equals(obj, text); - }; - } else { - comparator = function(obj, text) { - if (obj && text && typeof obj === 'object' && typeof text === 'object') { - for (var objKey in obj) { - if (objKey.charAt(0) !== '$' && hasOwnProperty.call(obj, objKey) && - comparator(obj[objKey], text[objKey])) { - return true; - } - } - return false; - } - text = (''+text).toLowerCase(); - return (''+obj).toLowerCase().indexOf(text) > -1; - }; - } - } - - var search = function(obj, text){ - if (typeof text == 'string' && text.charAt(0) === '!') { - return !search(obj, text.substr(1)); - } - switch (typeof obj) { - case "boolean": - case "number": - case "string": - return comparator(obj, text); - case "object": - switch (typeof text) { - case "object": - return comparator(obj, text); - default: - for ( var objKey in obj) { - if (objKey.charAt(0) !== '$' && search(obj[objKey], text)) { - return true; - } - } - break; - } - return false; - case "array": - for ( var i = 0; i < obj.length; i++) { - if (search(obj[i], text)) { - return true; - } - } - return false; - default: - return false; - } - }; - switch (typeof expression) { - case "boolean": - case "number": - case "string": - // Set up expression object and fall through - expression = {$:expression}; - // jshint -W086 - case "object": - // jshint +W086 - for (var key in expression) { - (function(path) { - if (typeof expression[path] === 'undefined') return; - predicates.push(function(value) { - return search(path == '$' ? value : (value && value[path]), expression[path]); - }); - })(key); - } - break; - case 'function': - predicates.push(expression); - break; - default: - return array; - } - var filtered = []; - for ( var j = 0; j < array.length; j++) { - var value = array[j]; - if (predicates.check(value)) { - filtered.push(value); - } - } - return filtered; - }; -} - -/** - * @ngdoc filter - * @name currency - * @kind function - * - * @description - * Formats a number as a currency (ie $1,234.56). When no currency symbol is provided, default - * symbol for current locale is used. - * - * @param {number} amount Input to filter. - * @param {string=} symbol Currency symbol or identifier to be displayed. - * @returns {string} Formatted number. - * - * - * @example - - - -
-
- default currency symbol ($): {{amount | currency}}
- custom currency identifier (USD$): {{amount | currency:"USD$"}} -
-
- - it('should init with 1234.56', function() { - expect(element(by.id('currency-default')).getText()).toBe('$1,234.56'); - expect(element(by.binding('amount | currency:"USD$"')).getText()).toBe('USD$1,234.56'); - }); - it('should update', function() { - if (browser.params.browser == 'safari') { - // Safari does not understand the minus key. See - // https://github.com/angular/protractor/issues/481 - return; - } - element(by.model('amount')).clear(); - element(by.model('amount')).sendKeys('-1234'); - expect(element(by.id('currency-default')).getText()).toBe('($1,234.00)'); - expect(element(by.binding('amount | currency:"USD$"')).getText()).toBe('(USD$1,234.00)'); - }); - -
- */ -currencyFilter.$inject = ['$locale']; -function currencyFilter($locale) { - var formats = $locale.NUMBER_FORMATS; - return function(amount, currencySymbol){ - if (isUndefined(currencySymbol)) currencySymbol = formats.CURRENCY_SYM; - return formatNumber(amount, formats.PATTERNS[1], formats.GROUP_SEP, formats.DECIMAL_SEP, 2). - replace(/\u00A4/g, currencySymbol); - }; -} - -/** - * @ngdoc filter - * @name number - * @kind function - * - * @description - * Formats a number as text. - * - * If the input is not a number an empty string is returned. - * - * @param {number|string} number Number to format. - * @param {(number|string)=} fractionSize Number of decimal places to round the number to. - * If this is not provided then the fraction size is computed from the current locale's number - * formatting pattern. In the case of the default locale, it will be 3. - * @returns {string} Number rounded to decimalPlaces and places a “,” after each third digit. - * - * @example - - - -
- Enter number:
- Default formatting: {{val | number}}
- No fractions: {{val | number:0}}
- Negative number: {{-val | number:4}} -
-
- - it('should format numbers', function() { - expect(element(by.id('number-default')).getText()).toBe('1,234.568'); - expect(element(by.binding('val | number:0')).getText()).toBe('1,235'); - expect(element(by.binding('-val | number:4')).getText()).toBe('-1,234.5679'); - }); - - it('should update', function() { - element(by.model('val')).clear(); - element(by.model('val')).sendKeys('3374.333'); - expect(element(by.id('number-default')).getText()).toBe('3,374.333'); - expect(element(by.binding('val | number:0')).getText()).toBe('3,374'); - expect(element(by.binding('-val | number:4')).getText()).toBe('-3,374.3330'); - }); - -
- */ - - -numberFilter.$inject = ['$locale']; -function numberFilter($locale) { - var formats = $locale.NUMBER_FORMATS; - return function(number, fractionSize) { - return formatNumber(number, formats.PATTERNS[0], formats.GROUP_SEP, formats.DECIMAL_SEP, - fractionSize); - }; -} - -var DECIMAL_SEP = '.'; -function formatNumber(number, pattern, groupSep, decimalSep, fractionSize) { - if (number == null || !isFinite(number) || isObject(number)) return ''; - - var isNegative = number < 0; - number = Math.abs(number); - var numStr = number + '', - formatedText = '', - parts = []; - - var hasExponent = false; - if (numStr.indexOf('e') !== -1) { - var match = numStr.match(/([\d\.]+)e(-?)(\d+)/); - if (match && match[2] == '-' && match[3] > fractionSize + 1) { - numStr = '0'; - number = 0; - } else { - formatedText = numStr; - hasExponent = true; - } - } - - if (!hasExponent) { - var fractionLen = (numStr.split(DECIMAL_SEP)[1] || '').length; - - // determine fractionSize if it is not specified - if (isUndefined(fractionSize)) { - fractionSize = Math.min(Math.max(pattern.minFrac, fractionLen), pattern.maxFrac); - } - - // safely round numbers in JS without hitting imprecisions of floating-point arithmetics - // inspired by: - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round - number = +(Math.round(+(number.toString() + 'e' + fractionSize)).toString() + 'e' + -fractionSize); - - if (number === 0) { - isNegative = false; - } - - var fraction = ('' + number).split(DECIMAL_SEP); - var whole = fraction[0]; - fraction = fraction[1] || ''; - - var i, pos = 0, - lgroup = pattern.lgSize, - group = pattern.gSize; - - if (whole.length >= (lgroup + group)) { - pos = whole.length - lgroup; - for (i = 0; i < pos; i++) { - if ((pos - i)%group === 0 && i !== 0) { - formatedText += groupSep; - } - formatedText += whole.charAt(i); - } - } - - for (i = pos; i < whole.length; i++) { - if ((whole.length - i)%lgroup === 0 && i !== 0) { - formatedText += groupSep; - } - formatedText += whole.charAt(i); - } - - // format fraction part. - while(fraction.length < fractionSize) { - fraction += '0'; - } - - if (fractionSize && fractionSize !== "0") formatedText += decimalSep + fraction.substr(0, fractionSize); - } else { - - if (fractionSize > 0 && number > -1 && number < 1) { - formatedText = number.toFixed(fractionSize); - } - } - - parts.push(isNegative ? pattern.negPre : pattern.posPre); - parts.push(formatedText); - parts.push(isNegative ? pattern.negSuf : pattern.posSuf); - return parts.join(''); -} - -function padNumber(num, digits, trim) { - var neg = ''; - if (num < 0) { - neg = '-'; - num = -num; - } - num = '' + num; - while(num.length < digits) num = '0' + num; - if (trim) - num = num.substr(num.length - digits); - return neg + num; -} - - -function dateGetter(name, size, offset, trim) { - offset = offset || 0; - return function(date) { - var value = date['get' + name](); - if (offset > 0 || value > -offset) - value += offset; - if (value === 0 && offset == -12 ) value = 12; - return padNumber(value, size, trim); - }; -} - -function dateStrGetter(name, shortForm) { - return function(date, formats) { - var value = date['get' + name](); - var get = uppercase(shortForm ? ('SHORT' + name) : name); - - return formats[get][value]; - }; -} - -function timeZoneGetter(date) { - var zone = -1 * date.getTimezoneOffset(); - var paddedZone = (zone >= 0) ? "+" : ""; - - paddedZone += padNumber(Math[zone > 0 ? 'floor' : 'ceil'](zone / 60), 2) + - padNumber(Math.abs(zone % 60), 2); - - return paddedZone; -} - -function ampmGetter(date, formats) { - return date.getHours() < 12 ? formats.AMPMS[0] : formats.AMPMS[1]; -} - -var DATE_FORMATS = { - yyyy: dateGetter('FullYear', 4), - yy: dateGetter('FullYear', 2, 0, true), - y: dateGetter('FullYear', 1), - MMMM: dateStrGetter('Month'), - MMM: dateStrGetter('Month', true), - MM: dateGetter('Month', 2, 1), - M: dateGetter('Month', 1, 1), - dd: dateGetter('Date', 2), - d: dateGetter('Date', 1), - HH: dateGetter('Hours', 2), - H: dateGetter('Hours', 1), - hh: dateGetter('Hours', 2, -12), - h: dateGetter('Hours', 1, -12), - mm: dateGetter('Minutes', 2), - m: dateGetter('Minutes', 1), - ss: dateGetter('Seconds', 2), - s: dateGetter('Seconds', 1), - // while ISO 8601 requires fractions to be prefixed with `.` or `,` - // we can be just safely rely on using `sss` since we currently don't support single or two digit fractions - sss: dateGetter('Milliseconds', 3), - EEEE: dateStrGetter('Day'), - EEE: dateStrGetter('Day', true), - a: ampmGetter, - Z: timeZoneGetter -}; - -var DATE_FORMATS_SPLIT = /((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z))(.*)/, - NUMBER_STRING = /^\-?\d+$/; - -/** - * @ngdoc filter - * @name date - * @kind function - * - * @description - * Formats `date` to a string based on the requested `format`. - * - * `format` string can be composed of the following elements: - * - * * `'yyyy'`: 4 digit representation of year (e.g. AD 1 => 0001, AD 2010 => 2010) - * * `'yy'`: 2 digit representation of year, padded (00-99). (e.g. AD 2001 => 01, AD 2010 => 10) - * * `'y'`: 1 digit representation of year, e.g. (AD 1 => 1, AD 199 => 199) - * * `'MMMM'`: Month in year (January-December) - * * `'MMM'`: Month in year (Jan-Dec) - * * `'MM'`: Month in year, padded (01-12) - * * `'M'`: Month in year (1-12) - * * `'dd'`: Day in month, padded (01-31) - * * `'d'`: Day in month (1-31) - * * `'EEEE'`: Day in Week,(Sunday-Saturday) - * * `'EEE'`: Day in Week, (Sun-Sat) - * * `'HH'`: Hour in day, padded (00-23) - * * `'H'`: Hour in day (0-23) - * * `'hh'`: Hour in am/pm, padded (01-12) - * * `'h'`: Hour in am/pm, (1-12) - * * `'mm'`: Minute in hour, padded (00-59) - * * `'m'`: Minute in hour (0-59) - * * `'ss'`: Second in minute, padded (00-59) - * * `'s'`: Second in minute (0-59) - * * `'.sss' or ',sss'`: Millisecond in second, padded (000-999) - * * `'a'`: am/pm marker - * * `'Z'`: 4 digit (+sign) representation of the timezone offset (-1200-+1200) - * - * `format` string can also be one of the following predefined - * {@link guide/i18n localizable formats}: - * - * * `'medium'`: equivalent to `'MMM d, y h:mm:ss a'` for en_US locale - * (e.g. Sep 3, 2010 12:05:08 pm) - * * `'short'`: equivalent to `'M/d/yy h:mm a'` for en_US locale (e.g. 9/3/10 12:05 pm) - * * `'fullDate'`: equivalent to `'EEEE, MMMM d,y'` for en_US locale - * (e.g. Friday, September 3, 2010) - * * `'longDate'`: equivalent to `'MMMM d, y'` for en_US locale (e.g. September 3, 2010) - * * `'mediumDate'`: equivalent to `'MMM d, y'` for en_US locale (e.g. Sep 3, 2010) - * * `'shortDate'`: equivalent to `'M/d/yy'` for en_US locale (e.g. 9/3/10) - * * `'mediumTime'`: equivalent to `'h:mm:ss a'` for en_US locale (e.g. 12:05:08 pm) - * * `'shortTime'`: equivalent to `'h:mm a'` for en_US locale (e.g. 12:05 pm) - * - * `format` string can contain literal values. These need to be escaped by surrounding with single quotes (e.g. - * `"h 'in the morning'"`). In order to output a single quote, escape it - i.e., two single quotes in a sequence - * (e.g. `"h 'o''clock'"`). - * - * @param {(Date|number|string)} date Date to format either as Date object, milliseconds (string or - * number) or various ISO 8601 datetime string formats (e.g. yyyy-MM-ddTHH:mm:ss.sssZ and its - * shorter versions like yyyy-MM-ddTHH:mmZ, yyyy-MM-dd or yyyyMMddTHHmmssZ). If no timezone is - * specified in the string input, the time is considered to be in the local timezone. - * @param {string=} format Formatting rules (see Description). If not specified, - * `mediumDate` is used. - * @returns {string} Formatted string or the input if input is not recognized as date/millis. - * - * @example - - - {{1288323623006 | date:'medium'}}: - {{1288323623006 | date:'medium'}}
- {{1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'}}: - {{1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'}}
- {{1288323623006 | date:'MM/dd/yyyy @ h:mma'}}: - {{'1288323623006' | date:'MM/dd/yyyy @ h:mma'}}
- {{1288323623006 | date:"MM/dd/yyyy 'at' h:mma"}}: - {{'1288323623006' | date:"MM/dd/yyyy 'at' h:mma"}}
-
- - it('should format date', function() { - expect(element(by.binding("1288323623006 | date:'medium'")).getText()). - toMatch(/Oct 2\d, 2010 \d{1,2}:\d{2}:\d{2} (AM|PM)/); - expect(element(by.binding("1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'")).getText()). - toMatch(/2010\-10\-2\d \d{2}:\d{2}:\d{2} (\-|\+)?\d{4}/); - expect(element(by.binding("'1288323623006' | date:'MM/dd/yyyy @ h:mma'")).getText()). - toMatch(/10\/2\d\/2010 @ \d{1,2}:\d{2}(AM|PM)/); - expect(element(by.binding("'1288323623006' | date:\"MM/dd/yyyy 'at' h:mma\"")).getText()). - toMatch(/10\/2\d\/2010 at \d{1,2}:\d{2}(AM|PM)/); - }); - -
- */ -dateFilter.$inject = ['$locale']; -function dateFilter($locale) { - - - var R_ISO8601_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/; - // 1 2 3 4 5 6 7 8 9 10 11 - function jsonStringToDate(string) { - var match; - if (match = string.match(R_ISO8601_STR)) { - var date = new Date(0), - tzHour = 0, - tzMin = 0, - dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear, - timeSetter = match[8] ? date.setUTCHours : date.setHours; - - if (match[9]) { - tzHour = int(match[9] + match[10]); - tzMin = int(match[9] + match[11]); - } - dateSetter.call(date, int(match[1]), int(match[2]) - 1, int(match[3])); - var h = int(match[4]||0) - tzHour; - var m = int(match[5]||0) - tzMin; - var s = int(match[6]||0); - var ms = Math.round(parseFloat('0.' + (match[7]||0)) * 1000); - timeSetter.call(date, h, m, s, ms); - return date; - } - return string; - } - - - return function(date, format) { - var text = '', - parts = [], - fn, match; - - format = format || 'mediumDate'; - format = $locale.DATETIME_FORMATS[format] || format; - if (isString(date)) { - date = NUMBER_STRING.test(date) ? int(date) : jsonStringToDate(date); - } - - if (isNumber(date)) { - date = new Date(date); - } - - if (!isDate(date)) { - return date; - } - - while(format) { - match = DATE_FORMATS_SPLIT.exec(format); - if (match) { - parts = concat(parts, match, 1); - format = parts.pop(); - } else { - parts.push(format); - format = null; - } - } - - forEach(parts, function(value){ - fn = DATE_FORMATS[value]; - text += fn ? fn(date, $locale.DATETIME_FORMATS) - : value.replace(/(^'|'$)/g, '').replace(/''/g, "'"); - }); - - return text; - }; -} - - -/** - * @ngdoc filter - * @name json - * @kind function - * - * @description - * Allows you to convert a JavaScript object into JSON string. - * - * This filter is mostly useful for debugging. When using the double curly {{value}} notation - * the binding is automatically converted to JSON. - * - * @param {*} object Any JavaScript object (including arrays and primitive types) to filter. - * @returns {string} JSON string. - * - * - * @example - - -
{{ {'name':'value'} | json }}
-
- - it('should jsonify filtered objects', function() { - expect(element(by.binding("{'name':'value'}")).getText()).toMatch(/\{\n "name": ?"value"\n}/); - }); - -
- * - */ -function jsonFilter() { - return function(object) { - return toJson(object, true); - }; -} - - -/** - * @ngdoc filter - * @name lowercase - * @kind function - * @description - * Converts string to lowercase. - * @see angular.lowercase - */ -var lowercaseFilter = valueFn(lowercase); - - -/** - * @ngdoc filter - * @name uppercase - * @kind function - * @description - * Converts string to uppercase. - * @see angular.uppercase - */ -var uppercaseFilter = valueFn(uppercase); - -/** - * @ngdoc filter - * @name limitTo - * @kind function - * - * @description - * Creates a new array or string containing only a specified number of elements. The elements - * are taken from either the beginning or the end of the source array or string, as specified by - * the value and sign (positive or negative) of `limit`. - * - * @param {Array|string} input Source array or string to be limited. - * @param {string|number} limit The length of the returned array or string. If the `limit` number - * is positive, `limit` number of items from the beginning of the source array/string are copied. - * If the number is negative, `limit` number of items from the end of the source array/string - * are copied. The `limit` will be trimmed if it exceeds `array.length` - * @returns {Array|string} A new sub-array or substring of length `limit` or less if input array - * had less than `limit` elements. - * - * @example - - - -
- Limit {{numbers}} to: -

Output numbers: {{ numbers | limitTo:numLimit }}

- Limit {{letters}} to: -

Output letters: {{ letters | limitTo:letterLimit }}

-
-
- - var numLimitInput = element(by.model('numLimit')); - var letterLimitInput = element(by.model('letterLimit')); - var limitedNumbers = element(by.binding('numbers | limitTo:numLimit')); - var limitedLetters = element(by.binding('letters | limitTo:letterLimit')); - - it('should limit the number array to first three items', function() { - expect(numLimitInput.getAttribute('value')).toBe('3'); - expect(letterLimitInput.getAttribute('value')).toBe('3'); - expect(limitedNumbers.getText()).toEqual('Output numbers: [1,2,3]'); - expect(limitedLetters.getText()).toEqual('Output letters: abc'); - }); - - it('should update the output when -3 is entered', function() { - numLimitInput.clear(); - numLimitInput.sendKeys('-3'); - letterLimitInput.clear(); - letterLimitInput.sendKeys('-3'); - expect(limitedNumbers.getText()).toEqual('Output numbers: [7,8,9]'); - expect(limitedLetters.getText()).toEqual('Output letters: ghi'); - }); - - it('should not exceed the maximum size of input array', function() { - numLimitInput.clear(); - numLimitInput.sendKeys('100'); - letterLimitInput.clear(); - letterLimitInput.sendKeys('100'); - expect(limitedNumbers.getText()).toEqual('Output numbers: [1,2,3,4,5,6,7,8,9]'); - expect(limitedLetters.getText()).toEqual('Output letters: abcdefghi'); - }); - -
- */ -function limitToFilter(){ - return function(input, limit) { - if (!isArray(input) && !isString(input)) return input; - - if (Math.abs(Number(limit)) === Infinity) { - limit = Number(limit); - } else { - limit = int(limit); - } - - if (isString(input)) { - //NaN check on limit - if (limit) { - return limit >= 0 ? input.slice(0, limit) : input.slice(limit, input.length); - } else { - return ""; - } - } - - var out = [], - i, n; - - // if abs(limit) exceeds maximum length, trim it - if (limit > input.length) - limit = input.length; - else if (limit < -input.length) - limit = -input.length; - - if (limit > 0) { - i = 0; - n = limit; - } else { - i = input.length + limit; - n = input.length; - } - - for (; i} expression A predicate to be - * used by the comparator to determine the order of elements. - * - * Can be one of: - * - * - `function`: Getter function. The result of this function will be sorted using the - * `<`, `=`, `>` operator. - * - `string`: An Angular expression. The result of this expression is used to compare elements - * (for example `name` to sort by a property called `name` or `name.substr(0, 3)` to sort by - * 3 first characters of a property called `name`). The result of a constant expression - * is interpreted as a property name to be used in comparisons (for example `"special name"` - * to sort object by the value of their `special name` property). An expression can be - * optionally prefixed with `+` or `-` to control ascending or descending sort order - * (for example, `+name` or `-name`). - * - `Array`: An array of function or string predicates. The first predicate in the array - * is used for sorting, but when two items are equivalent, the next predicate is used. - * - * @param {boolean=} reverse Reverse the order of the array. - * @returns {Array} Sorted copy of the source array. - * - * @example - - - -
-
Sorting predicate = {{predicate}}; reverse = {{reverse}}
-
- [ unsorted ] - - - - - - - - - - - -
Name - (^)Phone NumberAge
{{friend.name}}{{friend.phone}}{{friend.age}}
-
-
-
- * - * It's also possible to call the orderBy filter manually, by injecting `$filter`, retrieving the - * filter routine with `$filter('orderBy')`, and calling the returned filter routine with the - * desired parameters. - * - * Example: - * - * @example - - -
- - - - - - - - - - - -
Name - (^)Phone NumberAge
{{friend.name}}{{friend.phone}}{{friend.age}}
-
-
- - - angular.module('orderByExample', []) - .controller('ExampleController', ['$scope', '$filter', function($scope, $filter) { - var orderBy = $filter('orderBy'); - $scope.friends = [ - { name: 'John', phone: '555-1212', age: 10 }, - { name: 'Mary', phone: '555-9876', age: 19 }, - { name: 'Mike', phone: '555-4321', age: 21 }, - { name: 'Adam', phone: '555-5678', age: 35 }, - { name: 'Julie', phone: '555-8765', age: 29 } - ]; - $scope.order = function(predicate, reverse) { - $scope.friends = orderBy($scope.friends, predicate, reverse); - }; - $scope.order('-age',false); - }]); - -
- */ -orderByFilter.$inject = ['$parse']; -function orderByFilter($parse){ - return function(array, sortPredicate, reverseOrder) { - if (!(isArrayLike(array))) return array; - if (!sortPredicate) return array; - sortPredicate = isArray(sortPredicate) ? sortPredicate: [sortPredicate]; - sortPredicate = map(sortPredicate, function(predicate){ - var descending = false, get = predicate || identity; - if (isString(predicate)) { - if ((predicate.charAt(0) == '+' || predicate.charAt(0) == '-')) { - descending = predicate.charAt(0) == '-'; - predicate = predicate.substring(1); - } - get = $parse(predicate); - if (get.constant) { - var key = get(); - return reverseComparator(function(a,b) { - return compare(a[key], b[key]); - }, descending); - } - } - return reverseComparator(function(a,b){ - return compare(get(a),get(b)); - }, descending); - }); - var arrayCopy = []; - for ( var i = 0; i < array.length; i++) { arrayCopy.push(array[i]); } - return arrayCopy.sort(reverseComparator(comparator, reverseOrder)); - - function comparator(o1, o2){ - for ( var i = 0; i < sortPredicate.length; i++) { - var comp = sortPredicate[i](o1, o2); - if (comp !== 0) return comp; - } - return 0; - } - function reverseComparator(comp, descending) { - return toBoolean(descending) - ? function(a,b){return comp(b,a);} - : comp; - } - function compare(v1, v2){ - var t1 = typeof v1; - var t2 = typeof v2; - if (t1 == t2) { - if (isDate(v1) && isDate(v2)) { - v1 = v1.valueOf(); - v2 = v2.valueOf(); - } - if (t1 == "string") { - v1 = v1.toLowerCase(); - v2 = v2.toLowerCase(); - } - if (v1 === v2) return 0; - return v1 < v2 ? -1 : 1; - } else { - return t1 < t2 ? -1 : 1; - } - } - }; -} - -function ngDirective(directive) { - if (isFunction(directive)) { - directive = { - link: directive - }; - } - directive.restrict = directive.restrict || 'AC'; - return valueFn(directive); -} - -/** - * @ngdoc directive - * @name a - * @restrict E - * - * @description - * Modifies the default behavior of the html A tag so that the default action is prevented when - * the href attribute is empty. - * - * This change permits the easy creation of action links with the `ngClick` directive - * without changing the location or causing page reloads, e.g.: - * `Add Item` - */ -var htmlAnchorDirective = valueFn({ - restrict: 'E', - compile: function(element, attr) { - - if (msie <= 8) { - - // turn link into a stylable link in IE - // but only if it doesn't have name attribute, in which case it's an anchor - if (!attr.href && !attr.name) { - attr.$set('href', ''); - } - - // add a comment node to anchors to workaround IE bug that causes element content to be reset - // to new attribute content if attribute is updated with value containing @ and element also - // contains value with @ - // see issue #1949 - element.append(document.createComment('IE fix')); - } - - if (!attr.href && !attr.xlinkHref && !attr.name) { - return function(scope, element) { - // SVGAElement does not use the href attribute, but rather the 'xlinkHref' attribute. - var href = toString.call(element.prop('href')) === '[object SVGAnimatedString]' ? - 'xlink:href' : 'href'; - element.on('click', function(event){ - // if we have no href url, then don't navigate anywhere. - if (!element.attr(href)) { - event.preventDefault(); - } - }); - }; - } - } -}); - -/** - * @ngdoc directive - * @name ngHref - * @restrict A - * @priority 99 - * - * @description - * Using Angular markup like `{{hash}}` in an href attribute will - * make the link go to the wrong URL if the user clicks it before - * Angular has a chance to replace the `{{hash}}` markup with its - * value. Until Angular replaces the markup the link will be broken - * and will most likely return a 404 error. - * - * The `ngHref` directive solves this problem. - * - * The wrong way to write it: - * ```html - * - * ``` - * - * The correct way to write it: - * ```html - * - * ``` - * - * @element A - * @param {template} ngHref any string which can contain `{{}}` markup. - * - * @example - * This example shows various combinations of `href`, `ng-href` and `ng-click` attributes - * in links and their different behaviors: - - -
-
link 1 (link, don't reload)
- link 2 (link, don't reload)
- link 3 (link, reload!)
- anchor (link, don't reload)
- anchor (no link)
- link (link, change location) -
- - it('should execute ng-click but not reload when href without value', function() { - element(by.id('link-1')).click(); - expect(element(by.model('value')).getAttribute('value')).toEqual('1'); - expect(element(by.id('link-1')).getAttribute('href')).toBe(''); - }); - - it('should execute ng-click but not reload when href empty string', function() { - element(by.id('link-2')).click(); - expect(element(by.model('value')).getAttribute('value')).toEqual('2'); - expect(element(by.id('link-2')).getAttribute('href')).toBe(''); - }); - - it('should execute ng-click and change url when ng-href specified', function() { - expect(element(by.id('link-3')).getAttribute('href')).toMatch(/\/123$/); - - element(by.id('link-3')).click(); - - // At this point, we navigate away from an Angular page, so we need - // to use browser.driver to get the base webdriver. - - browser.wait(function() { - return browser.driver.getCurrentUrl().then(function(url) { - return url.match(/\/123$/); - }); - }, 5000, 'page should navigate to /123'); - }); - - xit('should execute ng-click but not reload when href empty string and name specified', function() { - element(by.id('link-4')).click(); - expect(element(by.model('value')).getAttribute('value')).toEqual('4'); - expect(element(by.id('link-4')).getAttribute('href')).toBe(''); - }); - - it('should execute ng-click but not reload when no href but name specified', function() { - element(by.id('link-5')).click(); - expect(element(by.model('value')).getAttribute('value')).toEqual('5'); - expect(element(by.id('link-5')).getAttribute('href')).toBe(null); - }); - - it('should only change url when only ng-href', function() { - element(by.model('value')).clear(); - element(by.model('value')).sendKeys('6'); - expect(element(by.id('link-6')).getAttribute('href')).toMatch(/\/6$/); - - element(by.id('link-6')).click(); - - // At this point, we navigate away from an Angular page, so we need - // to use browser.driver to get the base webdriver. - browser.wait(function() { - return browser.driver.getCurrentUrl().then(function(url) { - return url.match(/\/6$/); - }); - }, 5000, 'page should navigate to /6'); - }); - - - */ - -/** - * @ngdoc directive - * @name ngSrc - * @restrict A - * @priority 99 - * - * @description - * Using Angular markup like `{{hash}}` in a `src` attribute doesn't - * work right: The browser will fetch from the URL with the literal - * text `{{hash}}` until Angular replaces the expression inside - * `{{hash}}`. The `ngSrc` directive solves this problem. - * - * The buggy way to write it: - * ```html - * - * ``` - * - * The correct way to write it: - * ```html - * - * ``` - * - * @element IMG - * @param {template} ngSrc any string which can contain `{{}}` markup. - */ - -/** - * @ngdoc directive - * @name ngSrcset - * @restrict A - * @priority 99 - * - * @description - * Using Angular markup like `{{hash}}` in a `srcset` attribute doesn't - * work right: The browser will fetch from the URL with the literal - * text `{{hash}}` until Angular replaces the expression inside - * `{{hash}}`. The `ngSrcset` directive solves this problem. - * - * The buggy way to write it: - * ```html - * - * ``` - * - * The correct way to write it: - * ```html - * - * ``` - * - * @element IMG - * @param {template} ngSrcset any string which can contain `{{}}` markup. - */ - -/** - * @ngdoc directive - * @name ngDisabled - * @restrict A - * @priority 100 - * - * @description - * - * We shouldn't do this, because it will make the button enabled on Chrome/Firefox but not on IE8 and older IEs: - * ```html - *
- * - *
- * ``` - * - * The HTML specification does not require browsers to preserve the values of boolean attributes - * such as disabled. (Their presence means true and their absence means false.) - * If we put an Angular interpolation expression into such an attribute then the - * binding information would be lost when the browser removes the attribute. - * The `ngDisabled` directive solves this problem for the `disabled` attribute. - * This complementary directive is not removed by the browser and so provides - * a permanent reliable place to store the binding information. - * - * @example - - - Click me to toggle:
- -
- - it('should toggle button', function() { - expect(element(by.css('button')).getAttribute('disabled')).toBeFalsy(); - element(by.model('checked')).click(); - expect(element(by.css('button')).getAttribute('disabled')).toBeTruthy(); - }); - -
- * - * @element INPUT - * @param {expression} ngDisabled If the {@link guide/expression expression} is truthy, - * then special attribute "disabled" will be set on the element - */ - - -/** - * @ngdoc directive - * @name ngChecked - * @restrict A - * @priority 100 - * - * @description - * The HTML specification does not require browsers to preserve the values of boolean attributes - * such as checked. (Their presence means true and their absence means false.) - * If we put an Angular interpolation expression into such an attribute then the - * binding information would be lost when the browser removes the attribute. - * The `ngChecked` directive solves this problem for the `checked` attribute. - * This complementary directive is not removed by the browser and so provides - * a permanent reliable place to store the binding information. - * @example - - - Check me to check both:
- -
- - it('should check both checkBoxes', function() { - expect(element(by.id('checkSlave')).getAttribute('checked')).toBeFalsy(); - element(by.model('master')).click(); - expect(element(by.id('checkSlave')).getAttribute('checked')).toBeTruthy(); - }); - -
- * - * @element INPUT - * @param {expression} ngChecked If the {@link guide/expression expression} is truthy, - * then special attribute "checked" will be set on the element - */ - - -/** - * @ngdoc directive - * @name ngReadonly - * @restrict A - * @priority 100 - * - * @description - * The HTML specification does not require browsers to preserve the values of boolean attributes - * such as readonly. (Their presence means true and their absence means false.) - * If we put an Angular interpolation expression into such an attribute then the - * binding information would be lost when the browser removes the attribute. - * The `ngReadonly` directive solves this problem for the `readonly` attribute. - * This complementary directive is not removed by the browser and so provides - * a permanent reliable place to store the binding information. - * @example - - - Check me to make text readonly:
- -
- - it('should toggle readonly attr', function() { - expect(element(by.css('[type="text"]')).getAttribute('readonly')).toBeFalsy(); - element(by.model('checked')).click(); - expect(element(by.css('[type="text"]')).getAttribute('readonly')).toBeTruthy(); - }); - -
- * - * @element INPUT - * @param {expression} ngReadonly If the {@link guide/expression expression} is truthy, - * then special attribute "readonly" will be set on the element - */ - - -/** - * @ngdoc directive - * @name ngSelected - * @restrict A - * @priority 100 - * - * @description - * The HTML specification does not require browsers to preserve the values of boolean attributes - * such as selected. (Their presence means true and their absence means false.) - * If we put an Angular interpolation expression into such an attribute then the - * binding information would be lost when the browser removes the attribute. - * The `ngSelected` directive solves this problem for the `selected` attribute. - * This complementary directive is not removed by the browser and so provides - * a permanent reliable place to store the binding information. - * - * @example - - - Check me to select:
- -
- - it('should select Greetings!', function() { - expect(element(by.id('greet')).getAttribute('selected')).toBeFalsy(); - element(by.model('selected')).click(); - expect(element(by.id('greet')).getAttribute('selected')).toBeTruthy(); - }); - -
- * - * @element OPTION - * @param {expression} ngSelected If the {@link guide/expression expression} is truthy, - * then special attribute "selected" will be set on the element - */ - -/** - * @ngdoc directive - * @name ngOpen - * @restrict A - * @priority 100 - * - * @description - * The HTML specification does not require browsers to preserve the values of boolean attributes - * such as open. (Their presence means true and their absence means false.) - * If we put an Angular interpolation expression into such an attribute then the - * binding information would be lost when the browser removes the attribute. - * The `ngOpen` directive solves this problem for the `open` attribute. - * This complementary directive is not removed by the browser and so provides - * a permanent reliable place to store the binding information. - * @example - - - Check me check multiple:
-
- Show/Hide me -
-
- - it('should toggle open', function() { - expect(element(by.id('details')).getAttribute('open')).toBeFalsy(); - element(by.model('open')).click(); - expect(element(by.id('details')).getAttribute('open')).toBeTruthy(); - }); - -
- * - * @element DETAILS - * @param {expression} ngOpen If the {@link guide/expression expression} is truthy, - * then special attribute "open" will be set on the element - */ - -var ngAttributeAliasDirectives = {}; - - -// boolean attrs are evaluated -forEach(BOOLEAN_ATTR, function(propName, attrName) { - // binding to multiple is not supported - if (propName == "multiple") return; - - var normalized = directiveNormalize('ng-' + attrName); - ngAttributeAliasDirectives[normalized] = function() { - return { - priority: 100, - link: function(scope, element, attr) { - scope.$watch(attr[normalized], function ngBooleanAttrWatchAction(value) { - attr.$set(attrName, !!value); - }); - } - }; - }; -}); - - -// ng-src, ng-srcset, ng-href are interpolated -forEach(['src', 'srcset', 'href'], function(attrName) { - var normalized = directiveNormalize('ng-' + attrName); - ngAttributeAliasDirectives[normalized] = function() { - return { - priority: 99, // it needs to run after the attributes are interpolated - link: function(scope, element, attr) { - var propName = attrName, - name = attrName; - - if (attrName === 'href' && - toString.call(element.prop('href')) === '[object SVGAnimatedString]') { - name = 'xlinkHref'; - attr.$attr[name] = 'xlink:href'; - propName = null; - } - - attr.$observe(normalized, function(value) { - if (!value) { - if (attrName === 'href') { - attr.$set(name, null); - } - return; - } - - attr.$set(name, value); - - // on IE, if "ng:src" directive declaration is used and "src" attribute doesn't exist - // then calling element.setAttribute('src', 'foo') doesn't do anything, so we need - // to set the property as well to achieve the desired effect. - // we use attr[attrName] value since $set can sanitize the url. - if (msie && propName) element.prop(propName, attr[name]); - }); - } - }; - }; -}); - -/* global -nullFormCtrl */ -var nullFormCtrl = { - $addControl: noop, - $removeControl: noop, - $setValidity: noop, - $setDirty: noop, - $setPristine: noop -}; - -/** - * @ngdoc type - * @name form.FormController - * - * @property {boolean} $pristine True if user has not interacted with the form yet. - * @property {boolean} $dirty True if user has already interacted with the form. - * @property {boolean} $valid True if all of the containing forms and controls are valid. - * @property {boolean} $invalid True if at least one containing control or form is invalid. - * - * @property {Object} $error Is an object hash, containing references to all invalid controls or - * forms, where: - * - * - keys are validation tokens (error names), - * - values are arrays of controls or forms that are invalid for given error name. - * - * - * Built-in validation tokens: - * - * - `email` - * - `max` - * - `maxlength` - * - `min` - * - `minlength` - * - `number` - * - `pattern` - * - `required` - * - `url` - * - * @description - * `FormController` keeps track of all its controls and nested forms as well as the state of them, - * such as being valid/invalid or dirty/pristine. - * - * Each {@link ng.directive:form form} directive creates an instance - * of `FormController`. - * - */ -//asks for $scope to fool the BC controller module -FormController.$inject = ['$element', '$attrs', '$scope', '$animate']; -function FormController(element, attrs, $scope, $animate) { - var form = this, - parentForm = element.parent().controller('form') || nullFormCtrl, - invalidCount = 0, // used to easily determine if we are valid - errors = form.$error = {}, - controls = []; - - // init state - form.$name = attrs.name || attrs.ngForm; - form.$dirty = false; - form.$pristine = true; - form.$valid = true; - form.$invalid = false; - - parentForm.$addControl(form); - - // Setup initial state of the control - element.addClass(PRISTINE_CLASS); - toggleValidCss(true); - - // convenience method for easy toggling of classes - function toggleValidCss(isValid, validationErrorKey) { - validationErrorKey = validationErrorKey ? '-' + snake_case(validationErrorKey, '-') : ''; - $animate.setClass(element, - (isValid ? VALID_CLASS : INVALID_CLASS) + validationErrorKey, - (isValid ? INVALID_CLASS : VALID_CLASS) + validationErrorKey); - } - - /** - * @ngdoc method - * @name form.FormController#$addControl - * - * @description - * Register a control with the form. - * - * Input elements using ngModelController do this automatically when they are linked. - */ - form.$addControl = function(control) { - // Breaking change - before, inputs whose name was "hasOwnProperty" were quietly ignored - // and not added to the scope. Now we throw an error. - assertNotHasOwnProperty(control.$name, 'input'); - controls.push(control); - - if (control.$name) { - form[control.$name] = control; - } - }; - - /** - * @ngdoc method - * @name form.FormController#$removeControl - * - * @description - * Deregister a control from the form. - * - * Input elements using ngModelController do this automatically when they are destroyed. - */ - form.$removeControl = function(control) { - if (control.$name && form[control.$name] === control) { - delete form[control.$name]; - } - forEach(errors, function(queue, validationToken) { - form.$setValidity(validationToken, true, control); - }); - - arrayRemove(controls, control); - }; - - /** - * @ngdoc method - * @name form.FormController#$setValidity - * - * @description - * Sets the validity of a form control. - * - * This method will also propagate to parent forms. - */ - form.$setValidity = function(validationToken, isValid, control) { - var queue = errors[validationToken]; - - if (isValid) { - if (queue) { - arrayRemove(queue, control); - if (!queue.length) { - invalidCount--; - if (!invalidCount) { - toggleValidCss(isValid); - form.$valid = true; - form.$invalid = false; - } - errors[validationToken] = false; - toggleValidCss(true, validationToken); - parentForm.$setValidity(validationToken, true, form); - } - } - - } else { - if (!invalidCount) { - toggleValidCss(isValid); - } - if (queue) { - if (includes(queue, control)) return; - } else { - errors[validationToken] = queue = []; - invalidCount++; - toggleValidCss(false, validationToken); - parentForm.$setValidity(validationToken, false, form); - } - queue.push(control); - - form.$valid = false; - form.$invalid = true; - } - }; - - /** - * @ngdoc method - * @name form.FormController#$setDirty - * - * @description - * Sets the form to a dirty state. - * - * This method can be called to add the 'ng-dirty' class and set the form to a dirty - * state (ng-dirty class). This method will also propagate to parent forms. - */ - form.$setDirty = function() { - $animate.removeClass(element, PRISTINE_CLASS); - $animate.addClass(element, DIRTY_CLASS); - form.$dirty = true; - form.$pristine = false; - parentForm.$setDirty(); - }; - - /** - * @ngdoc method - * @name form.FormController#$setPristine - * - * @description - * Sets the form to its pristine state. - * - * This method can be called to remove the 'ng-dirty' class and set the form to its pristine - * state (ng-pristine class). This method will also propagate to all the controls contained - * in this form. - * - * Setting a form back to a pristine state is often useful when we want to 'reuse' a form after - * saving or resetting it. - */ - form.$setPristine = function () { - $animate.removeClass(element, DIRTY_CLASS); - $animate.addClass(element, PRISTINE_CLASS); - form.$dirty = false; - form.$pristine = true; - forEach(controls, function(control) { - control.$setPristine(); - }); - }; -} - - -/** - * @ngdoc directive - * @name ngForm - * @restrict EAC - * - * @description - * Nestable alias of {@link ng.directive:form `form`} directive. HTML - * does not allow nesting of form elements. It is useful to nest forms, for example if the validity of a - * sub-group of controls needs to be determined. - * - * Note: the purpose of `ngForm` is to group controls, - * but not to be a replacement for the `
` tag with all of its capabilities - * (e.g. posting to the server, ...). - * - * @param {string=} ngForm|name Name of the form. If specified, the form controller will be published into - * related scope, under this name. - * - */ - - /** - * @ngdoc directive - * @name form - * @restrict E - * - * @description - * Directive that instantiates - * {@link form.FormController FormController}. - * - * If the `name` attribute is specified, the form controller is published onto the current scope under - * this name. - * - * # Alias: {@link ng.directive:ngForm `ngForm`} - * - * In Angular forms can be nested. This means that the outer form is valid when all of the child - * forms are valid as well. However, browsers do not allow nesting of `` elements, so - * Angular provides the {@link ng.directive:ngForm `ngForm`} directive which behaves identically to - * `` but can be nested. This allows you to have nested forms, which is very useful when - * using Angular validation directives in forms that are dynamically generated using the - * {@link ng.directive:ngRepeat `ngRepeat`} directive. Since you cannot dynamically generate the `name` - * attribute of input elements using interpolation, you have to wrap each set of repeated inputs in an - * `ngForm` directive and nest these in an outer `form` element. - * - * - * # CSS classes - * - `ng-valid` is set if the form is valid. - * - `ng-invalid` is set if the form is invalid. - * - `ng-pristine` is set if the form is pristine. - * - `ng-dirty` is set if the form is dirty. - * - * Keep in mind that ngAnimate can detect each of these classes when added and removed. - * - * - * # Submitting a form and preventing the default action - * - * Since the role of forms in client-side Angular applications is different than in classical - * roundtrip apps, it is desirable for the browser not to translate the form submission into a full - * page reload that sends the data to the server. Instead some javascript logic should be triggered - * to handle the form submission in an application-specific way. - * - * For this reason, Angular prevents the default action (form submission to the server) unless the - * `` element has an `action` attribute specified. - * - * You can use one of the following two ways to specify what javascript method should be called when - * a form is submitted: - * - * - {@link ng.directive:ngSubmit ngSubmit} directive on the form element - * - {@link ng.directive:ngClick ngClick} directive on the first - * button or input field of type submit (input[type=submit]) - * - * To prevent double execution of the handler, use only one of the {@link ng.directive:ngSubmit ngSubmit} - * or {@link ng.directive:ngClick ngClick} directives. - * This is because of the following form submission rules in the HTML specification: - * - * - If a form has only one input field then hitting enter in this field triggers form submit - * (`ngSubmit`) - * - if a form has 2+ input fields and no buttons or input[type=submit] then hitting enter - * doesn't trigger submit - * - if a form has one or more input fields and one or more buttons or input[type=submit] then - * hitting enter in any of the input fields will trigger the click handler on the *first* button or - * input[type=submit] (`ngClick`) *and* a submit handler on the enclosing form (`ngSubmit`) - * - * - * ## Animation Hooks - * - * Animations in ngForm are triggered when any of the associated CSS classes are added and removed. - * These classes are: `.ng-pristine`, `.ng-dirty`, `.ng-invalid` and `.ng-valid` as well as any - * other validations that are performed within the form. Animations in ngForm are similar to how - * they work in ngClass and animations can be hooked into using CSS transitions, keyframes as well - * as JS animations. - * - * The following example shows a simple way to utilize CSS transitions to style a form element - * that has been rendered as invalid after it has been validated: - * - *
- * //be sure to include ngAnimate as a module to hook into more
- * //advanced animations
- * .my-form {
- *   transition:0.5s linear all;
- *   background: white;
- * }
- * .my-form.ng-invalid {
- *   background: red;
- *   color:white;
- * }
- * 
- * - * @example - - - - - - userType: - Required!
- userType = {{userType}}
- myForm.input.$valid = {{myForm.input.$valid}}
- myForm.input.$error = {{myForm.input.$error}}
- myForm.$valid = {{myForm.$valid}}
- myForm.$error.required = {{!!myForm.$error.required}}
- -
- - it('should initialize to model', function() { - var userType = element(by.binding('userType')); - var valid = element(by.binding('myForm.input.$valid')); - - expect(userType.getText()).toContain('guest'); - expect(valid.getText()).toContain('true'); - }); - - it('should be invalid if empty', function() { - var userType = element(by.binding('userType')); - var valid = element(by.binding('myForm.input.$valid')); - var userInput = element(by.model('userType')); - - userInput.clear(); - userInput.sendKeys(''); - - expect(userType.getText()).toEqual('userType ='); - expect(valid.getText()).toContain('false'); - }); - -
- * - * @param {string=} name Name of the form. If specified, the form controller will be published into - * related scope, under this name. - */ -var formDirectiveFactory = function(isNgForm) { - return ['$timeout', function($timeout) { - var formDirective = { - name: 'form', - restrict: isNgForm ? 'EAC' : 'E', - controller: FormController, - compile: function() { - return { - pre: function(scope, formElement, attr, controller) { - if (!attr.action) { - // we can't use jq events because if a form is destroyed during submission the default - // action is not prevented. see #1238 - // - // IE 9 is not affected because it doesn't fire a submit event and try to do a full - // page reload if the form was destroyed by submission of the form via a click handler - // on a button in the form. Looks like an IE9 specific bug. - var preventDefaultListener = function(event) { - event.preventDefault - ? event.preventDefault() - : event.returnValue = false; // IE - }; - - addEventListenerFn(formElement[0], 'submit', preventDefaultListener); - - // unregister the preventDefault listener so that we don't not leak memory but in a - // way that will achieve the prevention of the default action. - formElement.on('$destroy', function() { - $timeout(function() { - removeEventListenerFn(formElement[0], 'submit', preventDefaultListener); - }, 0, false); - }); - } - - var parentFormCtrl = formElement.parent().controller('form'), - alias = attr.name || attr.ngForm; - - if (alias) { - setter(scope, alias, controller, alias); - } - if (parentFormCtrl) { - formElement.on('$destroy', function() { - parentFormCtrl.$removeControl(controller); - if (alias) { - setter(scope, alias, undefined, alias); - } - extend(controller, nullFormCtrl); //stop propagating child destruction handlers upwards - }); - } - } - }; - } - }; - - return formDirective; - }]; -}; - -var formDirective = formDirectiveFactory(); -var ngFormDirective = formDirectiveFactory(true); - -/* global VALID_CLASS: true, - INVALID_CLASS: true, - PRISTINE_CLASS: true, - DIRTY_CLASS: true -*/ - -var URL_REGEXP = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/; -var EMAIL_REGEXP = /^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i; -var NUMBER_REGEXP = /^\s*(\-|\+)?(\d+|(\d*(\.\d*)))\s*$/; - -var inputType = { - - /** - * @ngdoc input - * @name input[text] - * - * @description - * Standard HTML text input with angular data binding, inherited by most of the `input` elements. - * - * *NOTE* Not every feature offered is available for all input types. - * - * @param {string} ngModel Assignable angular expression to data-bind to. - * @param {string=} name Property name of the form under which the control is published. - * @param {string=} required Adds `required` validation error key if the value is not entered. - * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to - * the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of - * `required` when you want to data-bind to the `required` attribute. - * @param {number=} ngMinlength Sets `minlength` validation error key if the value is shorter than - * minlength. - * @param {number=} ngMaxlength Sets `maxlength` validation error key if the value is longer than - * maxlength. - * @param {string=} ngPattern Sets `pattern` validation error key if the value does not match the - * RegExp pattern expression. Expected value is `/regexp/` for inline patterns or `regexp` for - * patterns defined as scope expressions. - * @param {string=} ngChange Angular expression to be executed when input changes due to user - * interaction with the input element. - * @param {boolean=} [ngTrim=true] If set to false Angular will not automatically trim the input. - * This parameter is ignored for input[type=password] controls, which will never trim the - * input. - * - * @example - - - -
- Single word: - - Required! - - Single word only! - - text = {{text}}
- myForm.input.$valid = {{myForm.input.$valid}}
- myForm.input.$error = {{myForm.input.$error}}
- myForm.$valid = {{myForm.$valid}}
- myForm.$error.required = {{!!myForm.$error.required}}
-
-
- - var text = element(by.binding('text')); - var valid = element(by.binding('myForm.input.$valid')); - var input = element(by.model('text')); - - it('should initialize to model', function() { - expect(text.getText()).toContain('guest'); - expect(valid.getText()).toContain('true'); - }); - - it('should be invalid if empty', function() { - input.clear(); - input.sendKeys(''); - - expect(text.getText()).toEqual('text ='); - expect(valid.getText()).toContain('false'); - }); - - it('should be invalid if multi word', function() { - input.clear(); - input.sendKeys('hello world'); - - expect(valid.getText()).toContain('false'); - }); - -
- */ - 'text': textInputType, - - - /** - * @ngdoc input - * @name input[number] - * - * @description - * Text input with number validation and transformation. Sets the `number` validation - * error if not a valid number. - * - * @param {string} ngModel Assignable angular expression to data-bind to. - * @param {string=} name Property name of the form under which the control is published. - * @param {string=} min Sets the `min` validation error key if the value entered is less than `min`. - * @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`. - * @param {string=} required Sets `required` validation error key if the value is not entered. - * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to - * the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of - * `required` when you want to data-bind to the `required` attribute. - * @param {number=} ngMinlength Sets `minlength` validation error key if the value is shorter than - * minlength. - * @param {number=} ngMaxlength Sets `maxlength` validation error key if the value is longer than - * maxlength. - * @param {string=} ngPattern Sets `pattern` validation error key if the value does not match the - * RegExp pattern expression. Expected value is `/regexp/` for inline patterns or `regexp` for - * patterns defined as scope expressions. - * @param {string=} ngChange Angular expression to be executed when input changes due to user - * interaction with the input element. - * - * @example - - - -
- Number: - - Required! - - Not valid number! - value = {{value}}
- myForm.input.$valid = {{myForm.input.$valid}}
- myForm.input.$error = {{myForm.input.$error}}
- myForm.$valid = {{myForm.$valid}}
- myForm.$error.required = {{!!myForm.$error.required}}
-
-
- - var value = element(by.binding('value')); - var valid = element(by.binding('myForm.input.$valid')); - var input = element(by.model('value')); - - it('should initialize to model', function() { - expect(value.getText()).toContain('12'); - expect(valid.getText()).toContain('true'); - }); - - it('should be invalid if empty', function() { - input.clear(); - input.sendKeys(''); - expect(value.getText()).toEqual('value ='); - expect(valid.getText()).toContain('false'); - }); - - it('should be invalid if over max', function() { - input.clear(); - input.sendKeys('123'); - expect(value.getText()).toEqual('value ='); - expect(valid.getText()).toContain('false'); - }); - -
- */ - 'number': numberInputType, - - - /** - * @ngdoc input - * @name input[url] - * - * @description - * Text input with URL validation. Sets the `url` validation error key if the content is not a - * valid URL. - * - * @param {string} ngModel Assignable angular expression to data-bind to. - * @param {string=} name Property name of the form under which the control is published. - * @param {string=} required Sets `required` validation error key if the value is not entered. - * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to - * the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of - * `required` when you want to data-bind to the `required` attribute. - * @param {number=} ngMinlength Sets `minlength` validation error key if the value is shorter than - * minlength. - * @param {number=} ngMaxlength Sets `maxlength` validation error key if the value is longer than - * maxlength. - * @param {string=} ngPattern Sets `pattern` validation error key if the value does not match the - * RegExp pattern expression. Expected value is `/regexp/` for inline patterns or `regexp` for - * patterns defined as scope expressions. - * @param {string=} ngChange Angular expression to be executed when input changes due to user - * interaction with the input element. - * - * @example - - - -
- URL: - - Required! - - Not valid url! - text = {{text}}
- myForm.input.$valid = {{myForm.input.$valid}}
- myForm.input.$error = {{myForm.input.$error}}
- myForm.$valid = {{myForm.$valid}}
- myForm.$error.required = {{!!myForm.$error.required}}
- myForm.$error.url = {{!!myForm.$error.url}}
-
-
- - var text = element(by.binding('text')); - var valid = element(by.binding('myForm.input.$valid')); - var input = element(by.model('text')); - - it('should initialize to model', function() { - expect(text.getText()).toContain('http://google.com/'); - expect(valid.getText()).toContain('true'); - }); - - it('should be invalid if empty', function() { - input.clear(); - input.sendKeys(''); - - expect(text.getText()).toEqual('text ='); - expect(valid.getText()).toContain('false'); - }); - - it('should be invalid if not url', function() { - input.clear(); - input.sendKeys('box'); - - expect(valid.getText()).toContain('false'); - }); - -
- */ - 'url': urlInputType, - - - /** - * @ngdoc input - * @name input[email] - * - * @description - * Text input with email validation. Sets the `email` validation error key if not a valid email - * address. - * - * @param {string} ngModel Assignable angular expression to data-bind to. - * @param {string=} name Property name of the form under which the control is published. - * @param {string=} required Sets `required` validation error key if the value is not entered. - * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to - * the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of - * `required` when you want to data-bind to the `required` attribute. - * @param {number=} ngMinlength Sets `minlength` validation error key if the value is shorter than - * minlength. - * @param {number=} ngMaxlength Sets `maxlength` validation error key if the value is longer than - * maxlength. - * @param {string=} ngPattern Sets `pattern` validation error key if the value does not match the - * RegExp pattern expression. Expected value is `/regexp/` for inline patterns or `regexp` for - * patterns defined as scope expressions. - * @param {string=} ngChange Angular expression to be executed when input changes due to user - * interaction with the input element. - * - * @example - - - -
- Email: - - Required! - - Not valid email! - text = {{text}}
- myForm.input.$valid = {{myForm.input.$valid}}
- myForm.input.$error = {{myForm.input.$error}}
- myForm.$valid = {{myForm.$valid}}
- myForm.$error.required = {{!!myForm.$error.required}}
- myForm.$error.email = {{!!myForm.$error.email}}
-
-
- - var text = element(by.binding('text')); - var valid = element(by.binding('myForm.input.$valid')); - var input = element(by.model('text')); - - it('should initialize to model', function() { - expect(text.getText()).toContain('me@example.com'); - expect(valid.getText()).toContain('true'); - }); - - it('should be invalid if empty', function() { - input.clear(); - input.sendKeys(''); - expect(text.getText()).toEqual('text ='); - expect(valid.getText()).toContain('false'); - }); - - it('should be invalid if not email', function() { - input.clear(); - input.sendKeys('xxx'); - - expect(valid.getText()).toContain('false'); - }); - -
- */ - 'email': emailInputType, - - - /** - * @ngdoc input - * @name input[radio] - * - * @description - * HTML radio button. - * - * @param {string} ngModel Assignable angular expression to data-bind to. - * @param {string} value The value to which the expression should be set when selected. - * @param {string=} name Property name of the form under which the control is published. - * @param {string=} ngChange Angular expression to be executed when input changes due to user - * interaction with the input element. - * @param {string} ngValue Angular expression which sets the value to which the expression should - * be set when selected. - * - * @example - - - -
- Red
- Green
- Blue
- color = {{color | json}}
-
- Note that `ng-value="specialValue"` sets radio item's value to be the value of `$scope.specialValue`. -
- - it('should change state', function() { - var color = element(by.binding('color')); - - expect(color.getText()).toContain('blue'); - - element.all(by.model('color')).get(0).click(); - - expect(color.getText()).toContain('red'); - }); - -
- */ - 'radio': radioInputType, - - - /** - * @ngdoc input - * @name input[checkbox] - * - * @description - * HTML checkbox. - * - * @param {string} ngModel Assignable angular expression to data-bind to. - * @param {string=} name Property name of the form under which the control is published. - * @param {string=} ngTrueValue The value to which the expression should be set when selected. - * @param {string=} ngFalseValue The value to which the expression should be set when not selected. - * @param {string=} ngChange Angular expression to be executed when input changes due to user - * interaction with the input element. - * - * @example - - - -
- Value1:
- Value2:
- value1 = {{value1}}
- value2 = {{value2}}
-
-
- - it('should change state', function() { - var value1 = element(by.binding('value1')); - var value2 = element(by.binding('value2')); - - expect(value1.getText()).toContain('true'); - expect(value2.getText()).toContain('YES'); - - element(by.model('value1')).click(); - element(by.model('value2')).click(); - - expect(value1.getText()).toContain('false'); - expect(value2.getText()).toContain('NO'); - }); - -
- */ - 'checkbox': checkboxInputType, - - 'hidden': noop, - 'button': noop, - 'submit': noop, - 'reset': noop, - 'file': noop -}; - -// A helper function to call $setValidity and return the value / undefined, -// a pattern that is repeated a lot in the input validation logic. -function validate(ctrl, validatorName, validity, value){ - ctrl.$setValidity(validatorName, validity); - return validity ? value : undefined; -} - -function testFlags(validity, flags) { - var i, flag; - if (flags) { - for (i=0; i= minlength, value); - }; - - ctrl.$parsers.push(minLengthValidator); - ctrl.$formatters.push(minLengthValidator); - } - - // max length validator - if (attr.ngMaxlength) { - var maxlength = int(attr.ngMaxlength); - var maxLengthValidator = function(value) { - return validate(ctrl, 'maxlength', ctrl.$isEmpty(value) || value.length <= maxlength, value); - }; - - ctrl.$parsers.push(maxLengthValidator); - ctrl.$formatters.push(maxLengthValidator); - } -} - -var numberBadFlags = ['badInput']; - -function numberInputType(scope, element, attr, ctrl, $sniffer, $browser) { - textInputType(scope, element, attr, ctrl, $sniffer, $browser); - - ctrl.$parsers.push(function(value) { - var empty = ctrl.$isEmpty(value); - if (empty || NUMBER_REGEXP.test(value)) { - ctrl.$setValidity('number', true); - return value === '' ? null : (empty ? value : parseFloat(value)); - } else { - ctrl.$setValidity('number', false); - return undefined; - } - }); - - addNativeHtml5Validators(ctrl, 'number', numberBadFlags, null, ctrl.$$validityState); - - ctrl.$formatters.push(function(value) { - return ctrl.$isEmpty(value) ? '' : '' + value; - }); - - if (attr.min) { - var minValidator = function(value) { - var min = parseFloat(attr.min); - return validate(ctrl, 'min', ctrl.$isEmpty(value) || value >= min, value); - }; - - ctrl.$parsers.push(minValidator); - ctrl.$formatters.push(minValidator); - } - - if (attr.max) { - var maxValidator = function(value) { - var max = parseFloat(attr.max); - return validate(ctrl, 'max', ctrl.$isEmpty(value) || value <= max, value); - }; - - ctrl.$parsers.push(maxValidator); - ctrl.$formatters.push(maxValidator); - } - - ctrl.$formatters.push(function(value) { - return validate(ctrl, 'number', ctrl.$isEmpty(value) || isNumber(value), value); - }); -} - -function urlInputType(scope, element, attr, ctrl, $sniffer, $browser) { - textInputType(scope, element, attr, ctrl, $sniffer, $browser); - - var urlValidator = function(value) { - return validate(ctrl, 'url', ctrl.$isEmpty(value) || URL_REGEXP.test(value), value); - }; - - ctrl.$formatters.push(urlValidator); - ctrl.$parsers.push(urlValidator); -} - -function emailInputType(scope, element, attr, ctrl, $sniffer, $browser) { - textInputType(scope, element, attr, ctrl, $sniffer, $browser); - - var emailValidator = function(value) { - return validate(ctrl, 'email', ctrl.$isEmpty(value) || EMAIL_REGEXP.test(value), value); - }; - - ctrl.$formatters.push(emailValidator); - ctrl.$parsers.push(emailValidator); -} - -function radioInputType(scope, element, attr, ctrl) { - // make the name unique, if not defined - if (isUndefined(attr.name)) { - element.attr('name', nextUid()); - } - - element.on('click', function() { - if (element[0].checked) { - scope.$apply(function() { - ctrl.$setViewValue(attr.value); - }); - } - }); - - ctrl.$render = function() { - var value = attr.value; - element[0].checked = (value == ctrl.$viewValue); - }; - - attr.$observe('value', ctrl.$render); -} - -function checkboxInputType(scope, element, attr, ctrl) { - var trueValue = attr.ngTrueValue, - falseValue = attr.ngFalseValue; - - if (!isString(trueValue)) trueValue = true; - if (!isString(falseValue)) falseValue = false; - - element.on('click', function() { - scope.$apply(function() { - ctrl.$setViewValue(element[0].checked); - }); - }); - - ctrl.$render = function() { - element[0].checked = ctrl.$viewValue; - }; - - // Override the standard `$isEmpty` because a value of `false` means empty in a checkbox. - ctrl.$isEmpty = function(value) { - return value !== trueValue; - }; - - ctrl.$formatters.push(function(value) { - return value === trueValue; - }); - - ctrl.$parsers.push(function(value) { - return value ? trueValue : falseValue; - }); -} - - -/** - * @ngdoc directive - * @name textarea - * @restrict E - * - * @description - * HTML textarea element control with angular data-binding. The data-binding and validation - * properties of this element are exactly the same as those of the - * {@link ng.directive:input input element}. - * - * @param {string} ngModel Assignable angular expression to data-bind to. - * @param {string=} name Property name of the form under which the control is published. - * @param {string=} required Sets `required` validation error key if the value is not entered. - * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to - * the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of - * `required` when you want to data-bind to the `required` attribute. - * @param {number=} ngMinlength Sets `minlength` validation error key if the value is shorter than - * minlength. - * @param {number=} ngMaxlength Sets `maxlength` validation error key if the value is longer than - * maxlength. - * @param {string=} ngPattern Sets `pattern` validation error key if the value does not match the - * RegExp pattern expression. Expected value is `/regexp/` for inline patterns or `regexp` for - * patterns defined as scope expressions. - * @param {string=} ngChange Angular expression to be executed when input changes due to user - * interaction with the input element. - * @param {boolean=} [ngTrim=true] If set to false Angular will not automatically trim the input. - */ - - -/** - * @ngdoc directive - * @name input - * @restrict E - * - * @description - * HTML input element control with angular data-binding. Input control follows HTML5 input types - * and polyfills the HTML5 validation behavior for older browsers. - * - * *NOTE* Not every feature offered is available for all input types. - * - * @param {string} ngModel Assignable angular expression to data-bind to. - * @param {string=} name Property name of the form under which the control is published. - * @param {string=} required Sets `required` validation error key if the value is not entered. - * @param {boolean=} ngRequired Sets `required` attribute if set to true - * @param {number=} ngMinlength Sets `minlength` validation error key if the value is shorter than - * minlength. - * @param {number=} ngMaxlength Sets `maxlength` validation error key if the value is longer than - * maxlength. - * @param {string=} ngPattern Sets `pattern` validation error key if the value does not match the - * RegExp pattern expression. Expected value is `/regexp/` for inline patterns or `regexp` for - * patterns defined as scope expressions. - * @param {string=} ngChange Angular expression to be executed when input changes due to user - * interaction with the input element. - * @param {boolean=} [ngTrim=true] If set to false Angular will not automatically trim the input. - * This parameter is ignored for input[type=password] controls, which will never trim the - * input. - * - * @example - - - -
-
- User name: - - Required!
- Last name: - - Too short! - - Too long!
-
-
- user = {{user}}
- myForm.userName.$valid = {{myForm.userName.$valid}}
- myForm.userName.$error = {{myForm.userName.$error}}
- myForm.lastName.$valid = {{myForm.lastName.$valid}}
- myForm.lastName.$error = {{myForm.lastName.$error}}
- myForm.$valid = {{myForm.$valid}}
- myForm.$error.required = {{!!myForm.$error.required}}
- myForm.$error.minlength = {{!!myForm.$error.minlength}}
- myForm.$error.maxlength = {{!!myForm.$error.maxlength}}
-
-
- - var user = element(by.binding('{{user}}')); - var userNameValid = element(by.binding('myForm.userName.$valid')); - var lastNameValid = element(by.binding('myForm.lastName.$valid')); - var lastNameError = element(by.binding('myForm.lastName.$error')); - var formValid = element(by.binding('myForm.$valid')); - var userNameInput = element(by.model('user.name')); - var userLastInput = element(by.model('user.last')); - - it('should initialize to model', function() { - expect(user.getText()).toContain('{"name":"guest","last":"visitor"}'); - expect(userNameValid.getText()).toContain('true'); - expect(formValid.getText()).toContain('true'); - }); - - it('should be invalid if empty when required', function() { - userNameInput.clear(); - userNameInput.sendKeys(''); - - expect(user.getText()).toContain('{"last":"visitor"}'); - expect(userNameValid.getText()).toContain('false'); - expect(formValid.getText()).toContain('false'); - }); - - it('should be valid if empty when min length is set', function() { - userLastInput.clear(); - userLastInput.sendKeys(''); - - expect(user.getText()).toContain('{"name":"guest","last":""}'); - expect(lastNameValid.getText()).toContain('true'); - expect(formValid.getText()).toContain('true'); - }); - - it('should be invalid if less than required min length', function() { - userLastInput.clear(); - userLastInput.sendKeys('xx'); - - expect(user.getText()).toContain('{"name":"guest"}'); - expect(lastNameValid.getText()).toContain('false'); - expect(lastNameError.getText()).toContain('minlength'); - expect(formValid.getText()).toContain('false'); - }); - - it('should be invalid if longer than max length', function() { - userLastInput.clear(); - userLastInput.sendKeys('some ridiculously long name'); - - expect(user.getText()).toContain('{"name":"guest"}'); - expect(lastNameValid.getText()).toContain('false'); - expect(lastNameError.getText()).toContain('maxlength'); - expect(formValid.getText()).toContain('false'); - }); - -
- */ -var inputDirective = ['$browser', '$sniffer', function($browser, $sniffer) { - return { - restrict: 'E', - require: '?ngModel', - link: function(scope, element, attr, ctrl) { - if (ctrl) { - (inputType[lowercase(attr.type)] || inputType.text)(scope, element, attr, ctrl, $sniffer, - $browser); - } - } - }; -}]; - -var VALID_CLASS = 'ng-valid', - INVALID_CLASS = 'ng-invalid', - PRISTINE_CLASS = 'ng-pristine', - DIRTY_CLASS = 'ng-dirty'; - -/** - * @ngdoc type - * @name ngModel.NgModelController - * - * @property {string} $viewValue Actual string value in the view. - * @property {*} $modelValue The value in the model, that the control is bound to. - * @property {Array.} $parsers Array of functions to execute, as a pipeline, whenever - the control reads value from the DOM. Each function is called, in turn, passing the value - through to the next. The last return value is used to populate the model. - Used to sanitize / convert the value as well as validation. For validation, - the parsers should update the validity state using - {@link ngModel.NgModelController#$setValidity $setValidity()}, - and return `undefined` for invalid values. - - * - * @property {Array.} $formatters Array of functions to execute, as a pipeline, whenever - the model value changes. Each function is called, in turn, passing the value through to the - next. Used to format / convert values for display in the control and validation. - * ```js - * function formatter(value) { - * if (value) { - * return value.toUpperCase(); - * } - * } - * ngModel.$formatters.push(formatter); - * ``` - * - * @property {Array.} $viewChangeListeners Array of functions to execute whenever the - * view value has changed. It is called with no arguments, and its return value is ignored. - * This can be used in place of additional $watches against the model value. - * - * @property {Object} $error An object hash with all errors as keys. - * - * @property {boolean} $pristine True if user has not interacted with the control yet. - * @property {boolean} $dirty True if user has already interacted with the control. - * @property {boolean} $valid True if there is no error. - * @property {boolean} $invalid True if at least one error on the control. - * - * @description - * - * `NgModelController` provides API for the `ng-model` directive. The controller contains - * services for data-binding, validation, CSS updates, and value formatting and parsing. It - * purposefully does not contain any logic which deals with DOM rendering or listening to - * DOM events. Such DOM related logic should be provided by other directives which make use of - * `NgModelController` for data-binding. - * - * ## Custom Control Example - * This example shows how to use `NgModelController` with a custom control to achieve - * data-binding. Notice how different directives (`contenteditable`, `ng-model`, and `required`) - * collaborate together to achieve the desired result. - * - * Note that `contenteditable` is an HTML5 attribute, which tells the browser to let the element - * contents be edited in place by the user. This will not work on older browsers. - * - * We are using the {@link ng.service:$sce $sce} service here and include the {@link ngSanitize $sanitize} - * module to automatically remove "bad" content like inline event listener (e.g. ``). - * However, as we are using `$sce` the model can still decide to to provide unsafe content if it marks - * that content using the `$sce` service. - * - * - - [contenteditable] { - border: 1px solid black; - background-color: white; - min-height: 20px; - } - - .ng-invalid { - border: 1px solid red; - } - - - - angular.module('customControl', ['ngSanitize']). - directive('contenteditable', ['$sce', function($sce) { - return { - restrict: 'A', // only activate on element attribute - require: '?ngModel', // get a hold of NgModelController - link: function(scope, element, attrs, ngModel) { - if(!ngModel) return; // do nothing if no ng-model - - // Specify how UI should be updated - ngModel.$render = function() { - element.html($sce.getTrustedHtml(ngModel.$viewValue || '')); - }; - - // Listen for change events to enable binding - element.on('blur keyup change', function() { - scope.$apply(read); - }); - read(); // initialize - - // Write data to the model - function read() { - var html = element.html(); - // When we clear the content editable the browser leaves a
behind - // If strip-br attribute is provided then we strip this out - if( attrs.stripBr && html == '
' ) { - html = ''; - } - ngModel.$setViewValue(html); - } - } - }; - }]); -
- -
-
Change me!
- Required! -
- -
-
- - it('should data-bind and become invalid', function() { - if (browser.params.browser == 'safari' || browser.params.browser == 'firefox') { - // SafariDriver can't handle contenteditable - // and Firefox driver can't clear contenteditables very well - return; - } - var contentEditable = element(by.css('[contenteditable]')); - var content = 'Change me!'; - - expect(contentEditable.getText()).toEqual(content); - - contentEditable.clear(); - contentEditable.sendKeys(protractor.Key.BACK_SPACE); - expect(contentEditable.getText()).toEqual(''); - expect(contentEditable.getAttribute('class')).toMatch(/ng-invalid-required/); - }); - - *
- * - * - */ -var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$parse', '$animate', - function($scope, $exceptionHandler, $attr, $element, $parse, $animate) { - this.$viewValue = Number.NaN; - this.$modelValue = Number.NaN; - this.$parsers = []; - this.$formatters = []; - this.$viewChangeListeners = []; - this.$pristine = true; - this.$dirty = false; - this.$valid = true; - this.$invalid = false; - this.$name = $attr.name; - - var ngModelGet = $parse($attr.ngModel), - ngModelSet = ngModelGet.assign; - - if (!ngModelSet) { - throw minErr('ngModel')('nonassign', "Expression '{0}' is non-assignable. Element: {1}", - $attr.ngModel, startingTag($element)); - } - - /** - * @ngdoc method - * @name ngModel.NgModelController#$render - * - * @description - * Called when the view needs to be updated. It is expected that the user of the ng-model - * directive will implement this method. - */ - this.$render = noop; - - /** - * @ngdoc method - * @name ngModel.NgModelController#$isEmpty - * - * @description - * This is called when we need to determine if the value of the input is empty. - * - * For instance, the required directive does this to work out if the input has data or not. - * The default `$isEmpty` function checks whether the value is `undefined`, `''`, `null` or `NaN`. - * - * You can override this for input directives whose concept of being empty is different to the - * default. The `checkboxInputType` directive does this because in its case a value of `false` - * implies empty. - * - * @param {*} value Reference to check. - * @returns {boolean} True if `value` is empty. - */ - this.$isEmpty = function(value) { - return isUndefined(value) || value === '' || value === null || value !== value; - }; - - var parentForm = $element.inheritedData('$formController') || nullFormCtrl, - invalidCount = 0, // used to easily determine if we are valid - $error = this.$error = {}; // keep invalid keys here - - - // Setup initial state of the control - $element.addClass(PRISTINE_CLASS); - toggleValidCss(true); - - // convenience method for easy toggling of classes - function toggleValidCss(isValid, validationErrorKey) { - validationErrorKey = validationErrorKey ? '-' + snake_case(validationErrorKey, '-') : ''; - $animate.removeClass($element, (isValid ? INVALID_CLASS : VALID_CLASS) + validationErrorKey); - $animate.addClass($element, (isValid ? VALID_CLASS : INVALID_CLASS) + validationErrorKey); - } - - /** - * @ngdoc method - * @name ngModel.NgModelController#$setValidity - * - * @description - * Change the validity state, and notifies the form when the control changes validity. (i.e. it - * does not notify form if given validator is already marked as invalid). - * - * This method should be called by validators - i.e. the parser or formatter functions. - * - * @param {string} validationErrorKey Name of the validator. the `validationErrorKey` will assign - * to `$error[validationErrorKey]=!isValid` so that it is available for data-binding. - * The `validationErrorKey` should be in camelCase and will get converted into dash-case - * for class name. Example: `myError` will result in `ng-valid-my-error` and `ng-invalid-my-error` - * class and can be bound to as `{{someForm.someControl.$error.myError}}` . - * @param {boolean} isValid Whether the current state is valid (true) or invalid (false). - */ - this.$setValidity = function(validationErrorKey, isValid) { - // Purposeful use of ! here to cast isValid to boolean in case it is undefined - // jshint -W018 - if ($error[validationErrorKey] === !isValid) return; - // jshint +W018 - - if (isValid) { - if ($error[validationErrorKey]) invalidCount--; - if (!invalidCount) { - toggleValidCss(true); - this.$valid = true; - this.$invalid = false; - } - } else { - toggleValidCss(false); - this.$invalid = true; - this.$valid = false; - invalidCount++; - } - - $error[validationErrorKey] = !isValid; - toggleValidCss(isValid, validationErrorKey); - - parentForm.$setValidity(validationErrorKey, isValid, this); - }; - - /** - * @ngdoc method - * @name ngModel.NgModelController#$setPristine - * - * @description - * Sets the control to its pristine state. - * - * This method can be called to remove the 'ng-dirty' class and set the control to its pristine - * state (ng-pristine class). - */ - this.$setPristine = function () { - this.$dirty = false; - this.$pristine = true; - $animate.removeClass($element, DIRTY_CLASS); - $animate.addClass($element, PRISTINE_CLASS); - }; - - /** - * @ngdoc method - * @name ngModel.NgModelController#$setViewValue - * - * @description - * Update the view value. - * - * This method should be called when the view value changes, typically from within a DOM event handler. - * For example {@link ng.directive:input input} and - * {@link ng.directive:select select} directives call it. - * - * It will update the $viewValue, then pass this value through each of the functions in `$parsers`, - * which includes any validators. The value that comes out of this `$parsers` pipeline, be applied to - * `$modelValue` and the **expression** specified in the `ng-model` attribute. - * - * Lastly, all the registered change listeners, in the `$viewChangeListeners` list, are called. - * - * Note that calling this function does not trigger a `$digest`. - * - * @param {string} value Value from the view. - */ - this.$setViewValue = function(value) { - this.$viewValue = value; - - // change to dirty - if (this.$pristine) { - this.$dirty = true; - this.$pristine = false; - $animate.removeClass($element, PRISTINE_CLASS); - $animate.addClass($element, DIRTY_CLASS); - parentForm.$setDirty(); - } - - forEach(this.$parsers, function(fn) { - value = fn(value); - }); - - if (this.$modelValue !== value) { - this.$modelValue = value; - ngModelSet($scope, value); - forEach(this.$viewChangeListeners, function(listener) { - try { - listener(); - } catch(e) { - $exceptionHandler(e); - } - }); - } - }; - - // model -> value - var ctrl = this; - - $scope.$watch(function ngModelWatch() { - var value = ngModelGet($scope); - - // if scope model value and ngModel value are out of sync - if (ctrl.$modelValue !== value) { - - var formatters = ctrl.$formatters, - idx = formatters.length; - - ctrl.$modelValue = value; - while(idx--) { - value = formatters[idx](value); - } - - if (ctrl.$viewValue !== value) { - ctrl.$viewValue = value; - ctrl.$render(); - } - } - - return value; - }); -}]; - - -/** - * @ngdoc directive - * @name ngModel - * - * @element input - * - * @description - * The `ngModel` directive binds an `input`,`select`, `textarea` (or custom form control) to a - * property on the scope using {@link ngModel.NgModelController NgModelController}, - * which is created and exposed by this directive. - * - * `ngModel` is responsible for: - * - * - Binding the view into the model, which other directives such as `input`, `textarea` or `select` - * require. - * - Providing validation behavior (i.e. required, number, email, url). - * - Keeping the state of the control (valid/invalid, dirty/pristine, validation errors). - * - Setting related css classes on the element (`ng-valid`, `ng-invalid`, `ng-dirty`, `ng-pristine`) including animations. - * - Registering the control with its parent {@link ng.directive:form form}. - * - * Note: `ngModel` will try to bind to the property given by evaluating the expression on the - * current scope. If the property doesn't already exist on this scope, it will be created - * implicitly and added to the scope. - * - * For best practices on using `ngModel`, see: - * - * - [https://github.com/angular/angular.js/wiki/Understanding-Scopes] - * - * For basic examples, how to use `ngModel`, see: - * - * - {@link ng.directive:input input} - * - {@link input[text] text} - * - {@link input[checkbox] checkbox} - * - {@link input[radio] radio} - * - {@link input[number] number} - * - {@link input[email] email} - * - {@link input[url] url} - * - {@link ng.directive:select select} - * - {@link ng.directive:textarea textarea} - * - * # CSS classes - * The following CSS classes are added and removed on the associated input/select/textarea element - * depending on the validity of the model. - * - * - `ng-valid` is set if the model is valid. - * - `ng-invalid` is set if the model is invalid. - * - `ng-pristine` is set if the model is pristine. - * - `ng-dirty` is set if the model is dirty. - * - * Keep in mind that ngAnimate can detect each of these classes when added and removed. - * - * ## Animation Hooks - * - * Animations within models are triggered when any of the associated CSS classes are added and removed - * on the input element which is attached to the model. These classes are: `.ng-pristine`, `.ng-dirty`, - * `.ng-invalid` and `.ng-valid` as well as any other validations that are performed on the model itself. - * The animations that are triggered within ngModel are similar to how they work in ngClass and - * animations can be hooked into using CSS transitions, keyframes as well as JS animations. - * - * The following example shows a simple way to utilize CSS transitions to style an input element - * that has been rendered as invalid after it has been validated: - * - *
- * //be sure to include ngAnimate as a module to hook into more
- * //advanced animations
- * .my-input {
- *   transition:0.5s linear all;
- *   background: white;
- * }
- * .my-input.ng-invalid {
- *   background: red;
- *   color:white;
- * }
- * 
- * - * @example - * - - - - Update input to see transitions when valid/invalid. - Integer is a valid value. -
- -
-
- *
- */ -var ngModelDirective = function() { - return { - require: ['ngModel', '^?form'], - controller: NgModelController, - link: function(scope, element, attr, ctrls) { - // notify others, especially parent forms - - var modelCtrl = ctrls[0], - formCtrl = ctrls[1] || nullFormCtrl; - - formCtrl.$addControl(modelCtrl); - - scope.$on('$destroy', function() { - formCtrl.$removeControl(modelCtrl); - }); - } - }; -}; - - -/** - * @ngdoc directive - * @name ngChange - * - * @description - * Evaluate the given expression when the user changes the input. - * The expression is evaluated immediately, unlike the JavaScript onchange event - * which only triggers at the end of a change (usually, when the user leaves the - * form element or presses the return key). - * The expression is not evaluated when the value change is coming from the model. - * - * Note, this directive requires `ngModel` to be present. - * - * @element input - * @param {expression} ngChange {@link guide/expression Expression} to evaluate upon change - * in input value. - * - * @example - * - * - * - *
- * - * - *
- * debug = {{confirmed}}
- * counter = {{counter}}
- *
- *
- * - * var counter = element(by.binding('counter')); - * var debug = element(by.binding('confirmed')); - * - * it('should evaluate the expression if changing from view', function() { - * expect(counter.getText()).toContain('0'); - * - * element(by.id('ng-change-example1')).click(); - * - * expect(counter.getText()).toContain('1'); - * expect(debug.getText()).toContain('true'); - * }); - * - * it('should not evaluate the expression if changing from model', function() { - * element(by.id('ng-change-example2')).click(); - - * expect(counter.getText()).toContain('0'); - * expect(debug.getText()).toContain('true'); - * }); - * - *
- */ -var ngChangeDirective = valueFn({ - require: 'ngModel', - link: function(scope, element, attr, ctrl) { - ctrl.$viewChangeListeners.push(function() { - scope.$eval(attr.ngChange); - }); - } -}); - - -var requiredDirective = function() { - return { - require: '?ngModel', - link: function(scope, elm, attr, ctrl) { - if (!ctrl) return; - attr.required = true; // force truthy in case we are on non input element - - var validator = function(value) { - if (attr.required && ctrl.$isEmpty(value)) { - ctrl.$setValidity('required', false); - return; - } else { - ctrl.$setValidity('required', true); - return value; - } - }; - - ctrl.$formatters.push(validator); - ctrl.$parsers.unshift(validator); - - attr.$observe('required', function() { - validator(ctrl.$viewValue); - }); - } - }; -}; - - -/** - * @ngdoc directive - * @name ngList - * - * @description - * Text input that converts between a delimited string and an array of strings. The delimiter - * can be a fixed string (by default a comma) or a regular expression. - * - * @element input - * @param {string=} ngList optional delimiter that should be used to split the value. If - * specified in form `/something/` then the value will be converted into a regular expression. - * - * @example - - - -
- List: - - Required! -
- names = {{names}}
- myForm.namesInput.$valid = {{myForm.namesInput.$valid}}
- myForm.namesInput.$error = {{myForm.namesInput.$error}}
- myForm.$valid = {{myForm.$valid}}
- myForm.$error.required = {{!!myForm.$error.required}}
-
-
- - var listInput = element(by.model('names')); - var names = element(by.binding('{{names}}')); - var valid = element(by.binding('myForm.namesInput.$valid')); - var error = element(by.css('span.error')); - - it('should initialize to model', function() { - expect(names.getText()).toContain('["igor","misko","vojta"]'); - expect(valid.getText()).toContain('true'); - expect(error.getCssValue('display')).toBe('none'); - }); - - it('should be invalid if empty', function() { - listInput.clear(); - listInput.sendKeys(''); - - expect(names.getText()).toContain(''); - expect(valid.getText()).toContain('false'); - expect(error.getCssValue('display')).not.toBe('none'); }); - -
- */ -var ngListDirective = function() { - return { - require: 'ngModel', - link: function(scope, element, attr, ctrl) { - var match = /\/(.*)\//.exec(attr.ngList), - separator = match && new RegExp(match[1]) || attr.ngList || ','; - - var parse = function(viewValue) { - // If the viewValue is invalid (say required but empty) it will be `undefined` - if (isUndefined(viewValue)) return; - - var list = []; - - if (viewValue) { - forEach(viewValue.split(separator), function(value) { - if (value) list.push(trim(value)); - }); - } - - return list; - }; - - ctrl.$parsers.push(parse); - ctrl.$formatters.push(function(value) { - if (isArray(value)) { - return value.join(', '); - } - - return undefined; - }); - - // Override the standard $isEmpty because an empty array means the input is empty. - ctrl.$isEmpty = function(value) { - return !value || !value.length; - }; - } - }; -}; - - -var CONSTANT_VALUE_REGEXP = /^(true|false|\d+)$/; -/** - * @ngdoc directive - * @name ngValue - * - * @description - * Binds the given expression to the value of `input[select]` or `input[radio]`, so - * that when the element is selected, the `ngModel` of that element is set to the - * bound value. - * - * `ngValue` is useful when dynamically generating lists of radio buttons using `ng-repeat`, as - * shown below. - * - * @element input - * @param {string=} ngValue angular expression, whose value will be bound to the `value` attribute - * of the `input` element - * - * @example - - - -
-

Which is your favorite?

- -
You chose {{my.favorite}}
-
-
- - var favorite = element(by.binding('my.favorite')); - - it('should initialize to model', function() { - expect(favorite.getText()).toContain('unicorns'); - }); - it('should bind the values to the inputs', function() { - element.all(by.model('my.favorite')).get(0).click(); - expect(favorite.getText()).toContain('pizza'); - }); - -
- */ -var ngValueDirective = function() { - return { - priority: 100, - compile: function(tpl, tplAttr) { - if (CONSTANT_VALUE_REGEXP.test(tplAttr.ngValue)) { - return function ngValueConstantLink(scope, elm, attr) { - attr.$set('value', scope.$eval(attr.ngValue)); - }; - } else { - return function ngValueLink(scope, elm, attr) { - scope.$watch(attr.ngValue, function valueWatchAction(value) { - attr.$set('value', value); - }); - }; - } - } - }; -}; - -/** - * @ngdoc directive - * @name ngBind - * @restrict AC - * - * @description - * The `ngBind` attribute tells Angular to replace the text content of the specified HTML element - * with the value of a given expression, and to update the text content when the value of that - * expression changes. - * - * Typically, you don't use `ngBind` directly, but instead you use the double curly markup like - * `{{ expression }}` which is similar but less verbose. - * - * It is preferable to use `ngBind` instead of `{{ expression }}` if a template is momentarily - * displayed by the browser in its raw state before Angular compiles it. Since `ngBind` is an - * element attribute, it makes the bindings invisible to the user while the page is loading. - * - * An alternative solution to this problem would be using the - * {@link ng.directive:ngCloak ngCloak} directive. - * - * - * @element ANY - * @param {expression} ngBind {@link guide/expression Expression} to evaluate. - * - * @example - * Enter a name in the Live Preview text box; the greeting below the text box changes instantly. - - - -
- Enter name:
- Hello ! -
-
- - it('should check ng-bind', function() { - var nameInput = element(by.model('name')); - - expect(element(by.binding('name')).getText()).toBe('Whirled'); - nameInput.clear(); - nameInput.sendKeys('world'); - expect(element(by.binding('name')).getText()).toBe('world'); - }); - -
- */ -var ngBindDirective = ngDirective({ - compile: function(templateElement) { - templateElement.addClass('ng-binding'); - return function (scope, element, attr) { - element.data('$binding', attr.ngBind); - scope.$watch(attr.ngBind, function ngBindWatchAction(value) { - // We are purposefully using == here rather than === because we want to - // catch when value is "null or undefined" - // jshint -W041 - element.text(value == undefined ? '' : value); - }); - }; - } -}); - - -/** - * @ngdoc directive - * @name ngBindTemplate - * - * @description - * The `ngBindTemplate` directive specifies that the element - * text content should be replaced with the interpolation of the template - * in the `ngBindTemplate` attribute. - * Unlike `ngBind`, the `ngBindTemplate` can contain multiple `{{` `}}` - * expressions. This directive is needed since some HTML elements - * (such as TITLE and OPTION) cannot contain SPAN elements. - * - * @element ANY - * @param {string} ngBindTemplate template of form - * {{ expression }} to eval. - * - * @example - * Try it here: enter text in text box and watch the greeting change. - - - -
- Salutation:
- Name:
-

-       
-
- - it('should check ng-bind', function() { - var salutationElem = element(by.binding('salutation')); - var salutationInput = element(by.model('salutation')); - var nameInput = element(by.model('name')); - - expect(salutationElem.getText()).toBe('Hello World!'); - - salutationInput.clear(); - salutationInput.sendKeys('Greetings'); - nameInput.clear(); - nameInput.sendKeys('user'); - - expect(salutationElem.getText()).toBe('Greetings user!'); - }); - -
- */ -var ngBindTemplateDirective = ['$interpolate', function($interpolate) { - return function(scope, element, attr) { - // TODO: move this to scenario runner - var interpolateFn = $interpolate(element.attr(attr.$attr.ngBindTemplate)); - element.addClass('ng-binding').data('$binding', interpolateFn); - attr.$observe('ngBindTemplate', function(value) { - element.text(value); - }); - }; -}]; - - -/** - * @ngdoc directive - * @name ngBindHtml - * - * @description - * Creates a binding that will innerHTML the result of evaluating the `expression` into the current - * element in a secure way. By default, the innerHTML-ed content will be sanitized using the {@link - * ngSanitize.$sanitize $sanitize} service. To utilize this functionality, ensure that `$sanitize` - * is available, for example, by including {@link ngSanitize} in your module's dependencies (not in - * core Angular.) You may also bypass sanitization for values you know are safe. To do so, bind to - * an explicitly trusted value via {@link ng.$sce#trustAsHtml $sce.trustAsHtml}. See the example - * under {@link ng.$sce#Example Strict Contextual Escaping (SCE)}. - * - * Note: If a `$sanitize` service is unavailable and the bound value isn't explicitly trusted, you - * will have an exception (instead of an exploit.) - * - * @element ANY - * @param {expression} ngBindHtml {@link guide/expression Expression} to evaluate. - * - * @example - - - -
-

-
-
- - - angular.module('bindHtmlExample', ['ngSanitize']) - .controller('ExampleController', ['$scope', function($scope) { - $scope.myHTML = - 'I am an HTMLstring with ' + - 'links! and other stuff'; - }]); - - - - it('should check ng-bind-html', function() { - expect(element(by.binding('myHTML')).getText()).toBe( - 'I am an HTMLstring with links! and other stuff'); - }); - -
- */ -var ngBindHtmlDirective = ['$sce', '$parse', function($sce, $parse) { - return { - compile: function (tElement) { - tElement.addClass('ng-binding'); - - return function (scope, element, attr) { - element.data('$binding', attr.ngBindHtml); - - var parsed = $parse(attr.ngBindHtml); - - function getStringValue() { - return (parsed(scope) || '').toString(); - } - - scope.$watch(getStringValue, function ngBindHtmlWatchAction(value) { - element.html($sce.getTrustedHtml(parsed(scope)) || ''); - }); - }; - } - }; -}]; - -function classDirective(name, selector) { - name = 'ngClass' + name; - return ['$animate', function($animate) { - return { - restrict: 'AC', - link: function(scope, element, attr) { - var oldVal; - - scope.$watch(attr[name], ngClassWatchAction, true); - - attr.$observe('class', function(value) { - ngClassWatchAction(scope.$eval(attr[name])); - }); - - - if (name !== 'ngClass') { - scope.$watch('$index', function($index, old$index) { - // jshint bitwise: false - var mod = $index & 1; - if (mod !== (old$index & 1)) { - var classes = arrayClasses(scope.$eval(attr[name])); - mod === selector ? - addClasses(classes) : - removeClasses(classes); - } - }); - } - - function addClasses(classes) { - var newClasses = digestClassCounts(classes, 1); - attr.$addClass(newClasses); - } - - function removeClasses(classes) { - var newClasses = digestClassCounts(classes, -1); - attr.$removeClass(newClasses); - } - - function digestClassCounts (classes, count) { - var classCounts = element.data('$classCounts') || {}; - var classesToUpdate = []; - forEach(classes, function (className) { - if (count > 0 || classCounts[className]) { - classCounts[className] = (classCounts[className] || 0) + count; - if (classCounts[className] === +(count > 0)) { - classesToUpdate.push(className); - } - } - }); - element.data('$classCounts', classCounts); - return classesToUpdate.join(' '); - } - - function updateClasses (oldClasses, newClasses) { - var toAdd = arrayDifference(newClasses, oldClasses); - var toRemove = arrayDifference(oldClasses, newClasses); - toRemove = digestClassCounts(toRemove, -1); - toAdd = digestClassCounts(toAdd, 1); - - if (toAdd.length === 0) { - $animate.removeClass(element, toRemove); - } else if (toRemove.length === 0) { - $animate.addClass(element, toAdd); - } else { - $animate.setClass(element, toAdd, toRemove); - } - } - - function ngClassWatchAction(newVal) { - if (selector === true || scope.$index % 2 === selector) { - var newClasses = arrayClasses(newVal || []); - if (!oldVal) { - addClasses(newClasses); - } else if (!equals(newVal,oldVal)) { - var oldClasses = arrayClasses(oldVal); - updateClasses(oldClasses, newClasses); - } - } - oldVal = shallowCopy(newVal); - } - } - }; - - function arrayDifference(tokens1, tokens2) { - var values = []; - - outer: - for(var i = 0; i < tokens1.length; i++) { - var token = tokens1[i]; - for(var j = 0; j < tokens2.length; j++) { - if(token == tokens2[j]) continue outer; - } - values.push(token); - } - return values; - } - - function arrayClasses (classVal) { - if (isArray(classVal)) { - return classVal; - } else if (isString(classVal)) { - return classVal.split(' '); - } else if (isObject(classVal)) { - var classes = [], i = 0; - forEach(classVal, function(v, k) { - if (v) { - classes = classes.concat(k.split(' ')); - } - }); - return classes; - } - return classVal; - } - }]; -} - -/** - * @ngdoc directive - * @name ngClass - * @restrict AC - * - * @description - * The `ngClass` directive allows you to dynamically set CSS classes on an HTML element by databinding - * an expression that represents all classes to be added. - * - * The directive operates in three different ways, depending on which of three types the expression - * evaluates to: - * - * 1. If the expression evaluates to a string, the string should be one or more space-delimited class - * names. - * - * 2. If the expression evaluates to an array, each element of the array should be a string that is - * one or more space-delimited class names. - * - * 3. If the expression evaluates to an object, then for each key-value pair of the - * object with a truthy value the corresponding key is used as a class name. - * - * The directive won't add duplicate classes if a particular class was already set. - * - * When the expression changes, the previously added classes are removed and only then the - * new classes are added. - * - * @animations - * add - happens just before the class is applied to the element - * remove - happens just before the class is removed from the element - * - * @element ANY - * @param {expression} ngClass {@link guide/expression Expression} to eval. The result - * of the evaluation can be a string representing space delimited class - * names, an array, or a map of class names to boolean values. In the case of a map, the - * names of the properties whose values are truthy will be added as css classes to the - * element. - * - * @example Example that demonstrates basic bindings via ngClass directive. - - -

Map Syntax Example

- deleted (apply "strike" class)
- important (apply "bold" class)
- error (apply "red" class) -
-

Using String Syntax

- -
-

Using Array Syntax

-
-
-
-
- - .strike { - text-decoration: line-through; - } - .bold { - font-weight: bold; - } - .red { - color: red; - } - - - var ps = element.all(by.css('p')); - - it('should let you toggle the class', function() { - - expect(ps.first().getAttribute('class')).not.toMatch(/bold/); - expect(ps.first().getAttribute('class')).not.toMatch(/red/); - - element(by.model('important')).click(); - expect(ps.first().getAttribute('class')).toMatch(/bold/); - - element(by.model('error')).click(); - expect(ps.first().getAttribute('class')).toMatch(/red/); - }); - - it('should let you toggle string example', function() { - expect(ps.get(1).getAttribute('class')).toBe(''); - element(by.model('style')).clear(); - element(by.model('style')).sendKeys('red'); - expect(ps.get(1).getAttribute('class')).toBe('red'); - }); - - it('array example should have 3 classes', function() { - expect(ps.last().getAttribute('class')).toBe(''); - element(by.model('style1')).sendKeys('bold'); - element(by.model('style2')).sendKeys('strike'); - element(by.model('style3')).sendKeys('red'); - expect(ps.last().getAttribute('class')).toBe('bold strike red'); - }); - -
- - ## Animations - - The example below demonstrates how to perform animations using ngClass. - - - - - -
- Sample Text -
- - .base-class { - -webkit-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.5s; - transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.5s; - } - - .base-class.my-class { - color: red; - font-size:3em; - } - - - it('should check ng-class', function() { - expect(element(by.css('.base-class')).getAttribute('class')).not. - toMatch(/my-class/); - - element(by.id('setbtn')).click(); - - expect(element(by.css('.base-class')).getAttribute('class')). - toMatch(/my-class/); - - element(by.id('clearbtn')).click(); - - expect(element(by.css('.base-class')).getAttribute('class')).not. - toMatch(/my-class/); - }); - -
- - - ## ngClass and pre-existing CSS3 Transitions/Animations - The ngClass directive still supports CSS3 Transitions/Animations even if they do not follow the ngAnimate CSS naming structure. - Upon animation ngAnimate will apply supplementary CSS classes to track the start and end of an animation, but this will not hinder - any pre-existing CSS transitions already on the element. To get an idea of what happens during a class-based animation, be sure - to view the step by step details of {@link ngAnimate.$animate#addclass $animate.addClass} and - {@link ngAnimate.$animate#removeclass $animate.removeClass}. - */ -var ngClassDirective = classDirective('', true); - -/** - * @ngdoc directive - * @name ngClassOdd - * @restrict AC - * - * @description - * The `ngClassOdd` and `ngClassEven` directives work exactly as - * {@link ng.directive:ngClass ngClass}, except they work in - * conjunction with `ngRepeat` and take effect only on odd (even) rows. - * - * This directive can be applied only within the scope of an - * {@link ng.directive:ngRepeat ngRepeat}. - * - * @element ANY - * @param {expression} ngClassOdd {@link guide/expression Expression} to eval. The result - * of the evaluation can be a string representing space delimited class names or an array. - * - * @example - - -
    -
  1. - - {{name}} - -
  2. -
-
- - .odd { - color: red; - } - .even { - color: blue; - } - - - it('should check ng-class-odd and ng-class-even', function() { - expect(element(by.repeater('name in names').row(0).column('name')).getAttribute('class')). - toMatch(/odd/); - expect(element(by.repeater('name in names').row(1).column('name')).getAttribute('class')). - toMatch(/even/); - }); - -
- */ -var ngClassOddDirective = classDirective('Odd', 0); - -/** - * @ngdoc directive - * @name ngClassEven - * @restrict AC - * - * @description - * The `ngClassOdd` and `ngClassEven` directives work exactly as - * {@link ng.directive:ngClass ngClass}, except they work in - * conjunction with `ngRepeat` and take effect only on odd (even) rows. - * - * This directive can be applied only within the scope of an - * {@link ng.directive:ngRepeat ngRepeat}. - * - * @element ANY - * @param {expression} ngClassEven {@link guide/expression Expression} to eval. The - * result of the evaluation can be a string representing space delimited class names or an array. - * - * @example - - -
    -
  1. - - {{name}}       - -
  2. -
-
- - .odd { - color: red; - } - .even { - color: blue; - } - - - it('should check ng-class-odd and ng-class-even', function() { - expect(element(by.repeater('name in names').row(0).column('name')).getAttribute('class')). - toMatch(/odd/); - expect(element(by.repeater('name in names').row(1).column('name')).getAttribute('class')). - toMatch(/even/); - }); - -
- */ -var ngClassEvenDirective = classDirective('Even', 1); - -/** - * @ngdoc directive - * @name ngCloak - * @restrict AC - * - * @description - * The `ngCloak` directive is used to prevent the Angular html template from being briefly - * displayed by the browser in its raw (uncompiled) form while your application is loading. Use this - * directive to avoid the undesirable flicker effect caused by the html template display. - * - * The directive can be applied to the `` element, but the preferred usage is to apply - * multiple `ngCloak` directives to small portions of the page to permit progressive rendering - * of the browser view. - * - * `ngCloak` works in cooperation with the following css rule embedded within `angular.js` and - * `angular.min.js`. - * For CSP mode please add `angular-csp.css` to your html file (see {@link ng.directive:ngCsp ngCsp}). - * - * ```css - * [ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak { - * display: none !important; - * } - * ``` - * - * When this css rule is loaded by the browser, all html elements (including their children) that - * are tagged with the `ngCloak` directive are hidden. When Angular encounters this directive - * during the compilation of the template it deletes the `ngCloak` element attribute, making - * the compiled element visible. - * - * For the best result, the `angular.js` script must be loaded in the head section of the html - * document; alternatively, the css rule above must be included in the external stylesheet of the - * application. - * - * Legacy browsers, like IE7, do not provide attribute selector support (added in CSS 2.1) so they - * cannot match the `[ng\:cloak]` selector. To work around this limitation, you must add the css - * class `ng-cloak` in addition to the `ngCloak` directive as shown in the example below. - * - * @element ANY - * - * @example - - -
{{ 'hello' }}
-
{{ 'hello IE7' }}
-
- - it('should remove the template directive and css class', function() { - expect($('#template1').getAttribute('ng-cloak')). - toBeNull(); - expect($('#template2').getAttribute('ng-cloak')). - toBeNull(); - }); - -
- * - */ -var ngCloakDirective = ngDirective({ - compile: function(element, attr) { - attr.$set('ngCloak', undefined); - element.removeClass('ng-cloak'); - } -}); - -/** - * @ngdoc directive - * @name ngController - * - * @description - * The `ngController` directive attaches a controller class to the view. This is a key aspect of how angular - * supports the principles behind the Model-View-Controller design pattern. - * - * MVC components in angular: - * - * * Model — Models are the properties of a scope; scopes are attached to the DOM where scope properties - * are accessed through bindings. - * * View — The template (HTML with data bindings) that is rendered into the View. - * * Controller — The `ngController` directive specifies a Controller class; the class contains business - * logic behind the application to decorate the scope with functions and values - * - * Note that you can also attach controllers to the DOM by declaring it in a route definition - * via the {@link ngRoute.$route $route} service. A common mistake is to declare the controller - * again using `ng-controller` in the template itself. This will cause the controller to be attached - * and executed twice. - * - * @element ANY - * @scope - * @param {expression} ngController Name of a globally accessible constructor function or an - * {@link guide/expression expression} that on the current scope evaluates to a - * constructor function. The controller instance can be published into a scope property - * by specifying `as propertyName`. - * - * @example - * Here is a simple form for editing user contact information. Adding, removing, clearing, and - * greeting are methods declared on the controller (see source tab). These methods can - * easily be called from the angular markup. Any changes to the data are automatically reflected - * in the View without the need for a manual update. - * - * Two different declaration styles are included below: - * - * * one binds methods and properties directly onto the controller using `this`: - * `ng-controller="SettingsController1 as settings"` - * * one injects `$scope` into the controller: - * `ng-controller="SettingsController2"` - * - * The second option is more common in the Angular community, and is generally used in boilerplates - * and in this guide. However, there are advantages to binding properties directly to the controller - * and avoiding scope. - * - * * Using `controller as` makes it obvious which controller you are accessing in the template when - * multiple controllers apply to an element. - * * If you are writing your controllers as classes you have easier access to the properties and - * methods, which will appear on the scope, from inside the controller code. - * * Since there is always a `.` in the bindings, you don't have to worry about prototypal - * inheritance masking primitives. - * - * This example demonstrates the `controller as` syntax. - * - * - * - *
- * Name: - * [ greet ]
- * Contact: - *
    - *
  • - * - * - * [ clear - * | X ] - *
  • - *
  • [ add ]
  • - *
- *
- *
- * - * angular.module('controllerAsExample', []) - * .controller('SettingsController1', SettingsController1); - * - * function SettingsController1() { - * this.name = "John Smith"; - * this.contacts = [ - * {type: 'phone', value: '408 555 1212'}, - * {type: 'email', value: 'john.smith@example.org'} ]; - * } - * - * SettingsController1.prototype.greet = function() { - * alert(this.name); - * }; - * - * SettingsController1.prototype.addContact = function() { - * this.contacts.push({type: 'email', value: 'yourname@example.org'}); - * }; - * - * SettingsController1.prototype.removeContact = function(contactToRemove) { - * var index = this.contacts.indexOf(contactToRemove); - * this.contacts.splice(index, 1); - * }; - * - * SettingsController1.prototype.clearContact = function(contact) { - * contact.type = 'phone'; - * contact.value = ''; - * }; - * - * - * it('should check controller as', function() { - * var container = element(by.id('ctrl-as-exmpl')); - * expect(container.element(by.model('settings.name')) - * .getAttribute('value')).toBe('John Smith'); - * - * var firstRepeat = - * container.element(by.repeater('contact in settings.contacts').row(0)); - * var secondRepeat = - * container.element(by.repeater('contact in settings.contacts').row(1)); - * - * expect(firstRepeat.element(by.model('contact.value')).getAttribute('value')) - * .toBe('408 555 1212'); - * - * expect(secondRepeat.element(by.model('contact.value')).getAttribute('value')) - * .toBe('john.smith@example.org'); - * - * firstRepeat.element(by.linkText('clear')).click(); - * - * expect(firstRepeat.element(by.model('contact.value')).getAttribute('value')) - * .toBe(''); - * - * container.element(by.linkText('add')).click(); - * - * expect(container.element(by.repeater('contact in settings.contacts').row(2)) - * .element(by.model('contact.value')) - * .getAttribute('value')) - * .toBe('yourname@example.org'); - * }); - * - *
- * - * This example demonstrates the "attach to `$scope`" style of controller. - * - * - * - *
- * Name: - * [ greet ]
- * Contact: - *
    - *
  • - * - * - * [ clear - * | X ] - *
  • - *
  • [ add ]
  • - *
- *
- *
- * - * angular.module('controllerExample', []) - * .controller('SettingsController2', ['$scope', SettingsController2]); - * - * function SettingsController2($scope) { - * $scope.name = "John Smith"; - * $scope.contacts = [ - * {type:'phone', value:'408 555 1212'}, - * {type:'email', value:'john.smith@example.org'} ]; - * - * $scope.greet = function() { - * alert($scope.name); - * }; - * - * $scope.addContact = function() { - * $scope.contacts.push({type:'email', value:'yourname@example.org'}); - * }; - * - * $scope.removeContact = function(contactToRemove) { - * var index = $scope.contacts.indexOf(contactToRemove); - * $scope.contacts.splice(index, 1); - * }; - * - * $scope.clearContact = function(contact) { - * contact.type = 'phone'; - * contact.value = ''; - * }; - * } - * - * - * it('should check controller', function() { - * var container = element(by.id('ctrl-exmpl')); - * - * expect(container.element(by.model('name')) - * .getAttribute('value')).toBe('John Smith'); - * - * var firstRepeat = - * container.element(by.repeater('contact in contacts').row(0)); - * var secondRepeat = - * container.element(by.repeater('contact in contacts').row(1)); - * - * expect(firstRepeat.element(by.model('contact.value')).getAttribute('value')) - * .toBe('408 555 1212'); - * expect(secondRepeat.element(by.model('contact.value')).getAttribute('value')) - * .toBe('john.smith@example.org'); - * - * firstRepeat.element(by.linkText('clear')).click(); - * - * expect(firstRepeat.element(by.model('contact.value')).getAttribute('value')) - * .toBe(''); - * - * container.element(by.linkText('add')).click(); - * - * expect(container.element(by.repeater('contact in contacts').row(2)) - * .element(by.model('contact.value')) - * .getAttribute('value')) - * .toBe('yourname@example.org'); - * }); - * - *
- - */ -var ngControllerDirective = [function() { - return { - scope: true, - controller: '@', - priority: 500 - }; -}]; - -/** - * @ngdoc directive - * @name ngCsp - * - * @element html - * @description - * Enables [CSP (Content Security Policy)](https://developer.mozilla.org/en/Security/CSP) support. - * - * This is necessary when developing things like Google Chrome Extensions. - * - * CSP forbids apps to use `eval` or `Function(string)` generated functions (among other things). - * For Angular to be CSP compatible there are only two things that we need to do differently: - * - * - don't use `Function` constructor to generate optimized value getters - * - don't inject custom stylesheet into the document - * - * AngularJS uses `Function(string)` generated functions as a speed optimization. Applying the `ngCsp` - * directive will cause Angular to use CSP compatibility mode. When this mode is on AngularJS will - * evaluate all expressions up to 30% slower than in non-CSP mode, but no security violations will - * be raised. - * - * CSP forbids JavaScript to inline stylesheet rules. In non CSP mode Angular automatically - * includes some CSS rules (e.g. {@link ng.directive:ngCloak ngCloak}). - * To make those directives work in CSP mode, include the `angular-csp.css` manually. - * - * Angular tries to autodetect if CSP is active and automatically turn on the CSP-safe mode. This - * autodetection however triggers a CSP error to be logged in the console: - * - * ``` - * Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of - * script in the following Content Security Policy directive: "default-src 'self'". Note that - * 'script-src' was not explicitly set, so 'default-src' is used as a fallback. - * ``` - * - * This error is harmless but annoying. To prevent the error from showing up, put the `ngCsp` - * directive on the root element of the application or on the `angular.js` script tag, whichever - * appears first in the html document. - * - * *Note: This directive is only available in the `ng-csp` and `data-ng-csp` attribute form.* - * - * @example - * This example shows how to apply the `ngCsp` directive to the `html` tag. - ```html - - - ... - ... - - ``` - */ - -// ngCsp is not implemented as a proper directive any more, because we need it be processed while we -// bootstrap the system (before $parse is instantiated), for this reason we just have -// the csp.isActive() fn that looks for ng-csp attribute anywhere in the current doc - -/** - * @ngdoc directive - * @name ngClick - * - * @description - * The ngClick directive allows you to specify custom behavior when - * an element is clicked. - * - * @element ANY - * @priority 0 - * @param {expression} ngClick {@link guide/expression Expression} to evaluate upon - * click. ({@link guide/expression#-event- Event object is available as `$event`}) - * - * @example - - - - - count: {{count}} - - - - it('should check ng-click', function() { - expect(element(by.binding('count')).getText()).toMatch('0'); - element(by.css('button')).click(); - expect(element(by.binding('count')).getText()).toMatch('1'); - }); - - - */ -/* - * A directive that allows creation of custom onclick handlers that are defined as angular - * expressions and are compiled and executed within the current scope. - * - * Events that are handled via these handler are always configured not to propagate further. - */ -var ngEventDirectives = {}; - -// For events that might fire synchronously during DOM manipulation -// we need to execute their event handlers asynchronously using $evalAsync, -// so that they are not executed in an inconsistent state. -var forceAsyncEvents = { - 'blur': true, - 'focus': true -}; -forEach( - 'click dblclick mousedown mouseup mouseover mouseout mousemove mouseenter mouseleave keydown keyup keypress submit focus blur copy cut paste'.split(' '), - function(eventName) { - var directiveName = directiveNormalize('ng-' + eventName); - ngEventDirectives[directiveName] = ['$parse', '$rootScope', function($parse, $rootScope) { - return { - compile: function($element, attr) { - var fn = $parse(attr[directiveName]); - return function ngEventHandler(scope, element) { - element.on(eventName, function(event) { - var callback = function() { - fn(scope, {$event:event}); - }; - if (forceAsyncEvents[eventName] && $rootScope.$$phase) { - scope.$evalAsync(callback); - } else { - scope.$apply(callback); - } - }); - }; - } - }; - }]; - } -); - -/** - * @ngdoc directive - * @name ngDblclick - * - * @description - * The `ngDblclick` directive allows you to specify custom behavior on a dblclick event. - * - * @element ANY - * @priority 0 - * @param {expression} ngDblclick {@link guide/expression Expression} to evaluate upon - * a dblclick. (The Event object is available as `$event`) - * - * @example - - - - count: {{count}} - - - */ - - -/** - * @ngdoc directive - * @name ngMousedown - * - * @description - * The ngMousedown directive allows you to specify custom behavior on mousedown event. - * - * @element ANY - * @priority 0 - * @param {expression} ngMousedown {@link guide/expression Expression} to evaluate upon - * mousedown. ({@link guide/expression#-event- Event object is available as `$event`}) - * - * @example - - - - count: {{count}} - - - */ - - -/** - * @ngdoc directive - * @name ngMouseup - * - * @description - * Specify custom behavior on mouseup event. - * - * @element ANY - * @priority 0 - * @param {expression} ngMouseup {@link guide/expression Expression} to evaluate upon - * mouseup. ({@link guide/expression#-event- Event object is available as `$event`}) - * - * @example - - - - count: {{count}} - - - */ - -/** - * @ngdoc directive - * @name ngMouseover - * - * @description - * Specify custom behavior on mouseover event. - * - * @element ANY - * @priority 0 - * @param {expression} ngMouseover {@link guide/expression Expression} to evaluate upon - * mouseover. ({@link guide/expression#-event- Event object is available as `$event`}) - * - * @example - - - - count: {{count}} - - - */ - - -/** - * @ngdoc directive - * @name ngMouseenter - * - * @description - * Specify custom behavior on mouseenter event. - * - * @element ANY - * @priority 0 - * @param {expression} ngMouseenter {@link guide/expression Expression} to evaluate upon - * mouseenter. ({@link guide/expression#-event- Event object is available as `$event`}) - * - * @example - - - - count: {{count}} - - - */ - - -/** - * @ngdoc directive - * @name ngMouseleave - * - * @description - * Specify custom behavior on mouseleave event. - * - * @element ANY - * @priority 0 - * @param {expression} ngMouseleave {@link guide/expression Expression} to evaluate upon - * mouseleave. ({@link guide/expression#-event- Event object is available as `$event`}) - * - * @example - - - - count: {{count}} - - - */ - - -/** - * @ngdoc directive - * @name ngMousemove - * - * @description - * Specify custom behavior on mousemove event. - * - * @element ANY - * @priority 0 - * @param {expression} ngMousemove {@link guide/expression Expression} to evaluate upon - * mousemove. ({@link guide/expression#-event- Event object is available as `$event`}) - * - * @example - - - - count: {{count}} - - - */ - - -/** - * @ngdoc directive - * @name ngKeydown - * - * @description - * Specify custom behavior on keydown event. - * - * @element ANY - * @priority 0 - * @param {expression} ngKeydown {@link guide/expression Expression} to evaluate upon - * keydown. (Event object is available as `$event` and can be interrogated for keyCode, altKey, etc.) - * - * @example - - - - key down count: {{count}} - - - */ - - -/** - * @ngdoc directive - * @name ngKeyup - * - * @description - * Specify custom behavior on keyup event. - * - * @element ANY - * @priority 0 - * @param {expression} ngKeyup {@link guide/expression Expression} to evaluate upon - * keyup. (Event object is available as `$event` and can be interrogated for keyCode, altKey, etc.) - * - * @example - - -

Typing in the input box below updates the key count

- key up count: {{count}} - -

Typing in the input box below updates the keycode

- -

event keyCode: {{ event.keyCode }}

-

event altKey: {{ event.altKey }}

-
-
- */ - - -/** - * @ngdoc directive - * @name ngKeypress - * - * @description - * Specify custom behavior on keypress event. - * - * @element ANY - * @param {expression} ngKeypress {@link guide/expression Expression} to evaluate upon - * keypress. ({@link guide/expression#-event- Event object is available as `$event`} - * and can be interrogated for keyCode, altKey, etc.) - * - * @example - - - - key press count: {{count}} - - - */ - - -/** - * @ngdoc directive - * @name ngSubmit - * - * @description - * Enables binding angular expressions to onsubmit events. - * - * Additionally it prevents the default action (which for form means sending the request to the - * server and reloading the current page), but only if the form does not contain `action`, - * `data-action`, or `x-action` attributes. - * - *
- * **Warning:** Be careful not to cause "double-submission" by using both the `ngClick` and - * `ngSubmit` handlers together. See the - * {@link form#submitting-a-form-and-preventing-the-default-action `form` directive documentation} - * for a detailed discussion of when `ngSubmit` may be triggered. - *
- * - * @element form - * @priority 0 - * @param {expression} ngSubmit {@link guide/expression Expression} to eval. - * ({@link guide/expression#-event- Event object is available as `$event`}) - * - * @example - - - -
- Enter text and hit enter: - - -
list={{list}}
-
-
- - it('should check ng-submit', function() { - expect(element(by.binding('list')).getText()).toBe('list=[]'); - element(by.css('#submit')).click(); - expect(element(by.binding('list')).getText()).toContain('hello'); - expect(element(by.model('text')).getAttribute('value')).toBe(''); - }); - it('should ignore empty strings', function() { - expect(element(by.binding('list')).getText()).toBe('list=[]'); - element(by.css('#submit')).click(); - element(by.css('#submit')).click(); - expect(element(by.binding('list')).getText()).toContain('hello'); - }); - -
- */ - -/** - * @ngdoc directive - * @name ngFocus - * - * @description - * Specify custom behavior on focus event. - * - * Note: As the `focus` event is executed synchronously when calling `input.focus()` - * AngularJS executes the expression using `scope.$evalAsync` if the event is fired - * during an `$apply` to ensure a consistent state. - * - * @element window, input, select, textarea, a - * @priority 0 - * @param {expression} ngFocus {@link guide/expression Expression} to evaluate upon - * focus. ({@link guide/expression#-event- Event object is available as `$event`}) - * - * @example - * See {@link ng.directive:ngClick ngClick} - */ - -/** - * @ngdoc directive - * @name ngBlur - * - * @description - * Specify custom behavior on blur event. - * - * A [blur event](https://developer.mozilla.org/en-US/docs/Web/Events/blur) fires when - * an element has lost focus. - * - * Note: As the `blur` event is executed synchronously also during DOM manipulations - * (e.g. removing a focussed input), - * AngularJS executes the expression using `scope.$evalAsync` if the event is fired - * during an `$apply` to ensure a consistent state. - * - * @element window, input, select, textarea, a - * @priority 0 - * @param {expression} ngBlur {@link guide/expression Expression} to evaluate upon - * blur. ({@link guide/expression#-event- Event object is available as `$event`}) - * - * @example - * See {@link ng.directive:ngClick ngClick} - */ - -/** - * @ngdoc directive - * @name ngCopy - * - * @description - * Specify custom behavior on copy event. - * - * @element window, input, select, textarea, a - * @priority 0 - * @param {expression} ngCopy {@link guide/expression Expression} to evaluate upon - * copy. ({@link guide/expression#-event- Event object is available as `$event`}) - * - * @example - - - - copied: {{copied}} - - - */ - -/** - * @ngdoc directive - * @name ngCut - * - * @description - * Specify custom behavior on cut event. - * - * @element window, input, select, textarea, a - * @priority 0 - * @param {expression} ngCut {@link guide/expression Expression} to evaluate upon - * cut. ({@link guide/expression#-event- Event object is available as `$event`}) - * - * @example - - - - cut: {{cut}} - - - */ - -/** - * @ngdoc directive - * @name ngPaste - * - * @description - * Specify custom behavior on paste event. - * - * @element window, input, select, textarea, a - * @priority 0 - * @param {expression} ngPaste {@link guide/expression Expression} to evaluate upon - * paste. ({@link guide/expression#-event- Event object is available as `$event`}) - * - * @example - - - - pasted: {{paste}} - - - */ - -/** - * @ngdoc directive - * @name ngIf - * @restrict A - * - * @description - * The `ngIf` directive removes or recreates a portion of the DOM tree based on an - * {expression}. If the expression assigned to `ngIf` evaluates to a false - * value then the element is removed from the DOM, otherwise a clone of the - * element is reinserted into the DOM. - * - * `ngIf` differs from `ngShow` and `ngHide` in that `ngIf` completely removes and recreates the - * element in the DOM rather than changing its visibility via the `display` css property. A common - * case when this difference is significant is when using css selectors that rely on an element's - * position within the DOM, such as the `:first-child` or `:last-child` pseudo-classes. - * - * Note that when an element is removed using `ngIf` its scope is destroyed and a new scope - * is created when the element is restored. The scope created within `ngIf` inherits from - * its parent scope using - * [prototypal inheritance](https://github.com/angular/angular.js/wiki/The-Nuances-of-Scope-Prototypal-Inheritance). - * An important implication of this is if `ngModel` is used within `ngIf` to bind to - * a javascript primitive defined in the parent scope. In this case any modifications made to the - * variable within the child scope will override (hide) the value in the parent scope. - * - * Also, `ngIf` recreates elements using their compiled state. An example of this behavior - * is if an element's class attribute is directly modified after it's compiled, using something like - * jQuery's `.addClass()` method, and the element is later removed. When `ngIf` recreates the element - * the added class will be lost because the original compiled state is used to regenerate the element. - * - * Additionally, you can provide animations via the `ngAnimate` module to animate the `enter` - * and `leave` effects. - * - * @animations - * enter - happens just after the ngIf contents change and a new DOM element is created and injected into the ngIf container - * leave - happens just before the ngIf contents are removed from the DOM - * - * @element ANY - * @scope - * @priority 600 - * @param {expression} ngIf If the {@link guide/expression expression} is falsy then - * the element is removed from the DOM tree. If it is truthy a copy of the compiled - * element is added to the DOM tree. - * - * @example - - - Click me:
- Show when checked: - - I'm removed when the checkbox is unchecked. - -
- - .animate-if { - background:white; - border:1px solid black; - padding:10px; - } - - .animate-if.ng-enter, .animate-if.ng-leave { - -webkit-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.5s; - transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.5s; - } - - .animate-if.ng-enter, - .animate-if.ng-leave.ng-leave-active { - opacity:0; - } - - .animate-if.ng-leave, - .animate-if.ng-enter.ng-enter-active { - opacity:1; - } - -
- */ -var ngIfDirective = ['$animate', function($animate) { - return { - transclude: 'element', - priority: 600, - terminal: true, - restrict: 'A', - $$tlb: true, - link: function ($scope, $element, $attr, ctrl, $transclude) { - var block, childScope, previousElements; - $scope.$watch($attr.ngIf, function ngIfWatchAction(value) { - - if (toBoolean(value)) { - if (!childScope) { - childScope = $scope.$new(); - $transclude(childScope, function (clone) { - clone[clone.length++] = document.createComment(' end ngIf: ' + $attr.ngIf + ' '); - // Note: We only need the first/last node of the cloned nodes. - // However, we need to keep the reference to the jqlite wrapper as it might be changed later - // by a directive with templateUrl when its template arrives. - block = { - clone: clone - }; - $animate.enter(clone, $element.parent(), $element); - }); - } - } else { - if(previousElements) { - previousElements.remove(); - previousElements = null; - } - if(childScope) { - childScope.$destroy(); - childScope = null; - } - if(block) { - previousElements = getBlockElements(block.clone); - $animate.leave(previousElements, function() { - previousElements = null; - }); - block = null; - } - } - }); - } - }; -}]; - -/** - * @ngdoc directive - * @name ngInclude - * @restrict ECA - * - * @description - * Fetches, compiles and includes an external HTML fragment. - * - * By default, the template URL is restricted to the same domain and protocol as the - * application document. This is done by calling {@link ng.$sce#getTrustedResourceUrl - * $sce.getTrustedResourceUrl} on it. To load templates from other domains or protocols - * you may either {@link ng.$sceDelegateProvider#resourceUrlWhitelist whitelist them} or - * [wrap them](ng.$sce#trustAsResourceUrl) as trusted values. Refer to Angular's {@link - * ng.$sce Strict Contextual Escaping}. - * - * In addition, the browser's - * [Same Origin Policy](https://code.google.com/p/browsersec/wiki/Part2#Same-origin_policy_for_XMLHttpRequest) - * and [Cross-Origin Resource Sharing (CORS)](http://www.w3.org/TR/cors/) - * policy may further restrict whether the template is successfully loaded. - * For example, `ngInclude` won't work for cross-domain requests on all browsers and for `file://` - * access on some browsers. - * - * @animations - * enter - animation is used to bring new content into the browser. - * leave - animation is used to animate existing content away. - * - * The enter and leave animation occur concurrently. - * - * @scope - * @priority 400 - * - * @param {string} ngInclude|src angular expression evaluating to URL. If the source is a string constant, - * make sure you wrap it in **single** quotes, e.g. `src="'myPartialTemplate.html'"`. - * @param {string=} onload Expression to evaluate when a new partial is loaded. - * - * @param {string=} autoscroll Whether `ngInclude` should call {@link ng.$anchorScroll - * $anchorScroll} to scroll the viewport after the content is loaded. - * - * - If the attribute is not set, disable scrolling. - * - If the attribute is set without value, enable scrolling. - * - Otherwise enable scrolling only if the expression evaluates to truthy value. - * - * @example - - -
- - url of the template: {{template.url}} -
-
-
-
-
-
- - angular.module('includeExample', ['ngAnimate']) - .controller('ExampleController', ['$scope', function($scope) { - $scope.templates = - [ { name: 'template1.html', url: 'template1.html'}, - { name: 'template2.html', url: 'template2.html'} ]; - $scope.template = $scope.templates[0]; - }]); - - - Content of template1.html - - - Content of template2.html - - - .slide-animate-container { - position:relative; - background:white; - border:1px solid black; - height:40px; - overflow:hidden; - } - - .slide-animate { - padding:10px; - } - - .slide-animate.ng-enter, .slide-animate.ng-leave { - -webkit-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.5s; - transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.5s; - - position:absolute; - top:0; - left:0; - right:0; - bottom:0; - display:block; - padding:10px; - } - - .slide-animate.ng-enter { - top:-50px; - } - .slide-animate.ng-enter.ng-enter-active { - top:0; - } - - .slide-animate.ng-leave { - top:0; - } - .slide-animate.ng-leave.ng-leave-active { - top:50px; - } - - - var templateSelect = element(by.model('template')); - var includeElem = element(by.css('[ng-include]')); - - it('should load template1.html', function() { - expect(includeElem.getText()).toMatch(/Content of template1.html/); - }); - - it('should load template2.html', function() { - if (browser.params.browser == 'firefox') { - // Firefox can't handle using selects - // See https://github.com/angular/protractor/issues/480 - return; - } - templateSelect.click(); - templateSelect.all(by.css('option')).get(2).click(); - expect(includeElem.getText()).toMatch(/Content of template2.html/); - }); - - it('should change to blank', function() { - if (browser.params.browser == 'firefox') { - // Firefox can't handle using selects - return; - } - templateSelect.click(); - templateSelect.all(by.css('option')).get(0).click(); - expect(includeElem.isPresent()).toBe(false); - }); - -
- */ - - -/** - * @ngdoc event - * @name ngInclude#$includeContentRequested - * @eventType emit on the scope ngInclude was declared in - * @description - * Emitted every time the ngInclude content is requested. - */ - - -/** - * @ngdoc event - * @name ngInclude#$includeContentLoaded - * @eventType emit on the current ngInclude scope - * @description - * Emitted every time the ngInclude content is reloaded. - */ -var ngIncludeDirective = ['$http', '$templateCache', '$anchorScroll', '$animate', '$sce', - function($http, $templateCache, $anchorScroll, $animate, $sce) { - return { - restrict: 'ECA', - priority: 400, - terminal: true, - transclude: 'element', - controller: angular.noop, - compile: function(element, attr) { - var srcExp = attr.ngInclude || attr.src, - onloadExp = attr.onload || '', - autoScrollExp = attr.autoscroll; - - return function(scope, $element, $attr, ctrl, $transclude) { - var changeCounter = 0, - currentScope, - previousElement, - currentElement; - - var cleanupLastIncludeContent = function() { - if(previousElement) { - previousElement.remove(); - previousElement = null; - } - if(currentScope) { - currentScope.$destroy(); - currentScope = null; - } - if(currentElement) { - $animate.leave(currentElement, function() { - previousElement = null; - }); - previousElement = currentElement; - currentElement = null; - } - }; - - scope.$watch($sce.parseAsResourceUrl(srcExp), function ngIncludeWatchAction(src) { - var afterAnimation = function() { - if (isDefined(autoScrollExp) && (!autoScrollExp || scope.$eval(autoScrollExp))) { - $anchorScroll(); - } - }; - var thisChangeId = ++changeCounter; - - if (src) { - $http.get(src, {cache: $templateCache}).success(function(response) { - if (thisChangeId !== changeCounter) return; - var newScope = scope.$new(); - ctrl.template = response; - - // Note: This will also link all children of ng-include that were contained in the original - // html. If that content contains controllers, ... they could pollute/change the scope. - // However, using ng-include on an element with additional content does not make sense... - // Note: We can't remove them in the cloneAttchFn of $transclude as that - // function is called before linking the content, which would apply child - // directives to non existing elements. - var clone = $transclude(newScope, function(clone) { - cleanupLastIncludeContent(); - $animate.enter(clone, null, $element, afterAnimation); - }); - - currentScope = newScope; - currentElement = clone; - - currentScope.$emit('$includeContentLoaded'); - scope.$eval(onloadExp); - }).error(function() { - if (thisChangeId === changeCounter) cleanupLastIncludeContent(); - }); - scope.$emit('$includeContentRequested'); - } else { - cleanupLastIncludeContent(); - ctrl.template = null; - } - }); - }; - } - }; -}]; - -// This directive is called during the $transclude call of the first `ngInclude` directive. -// It will replace and compile the content of the element with the loaded template. -// We need this directive so that the element content is already filled when -// the link function of another directive on the same element as ngInclude -// is called. -var ngIncludeFillContentDirective = ['$compile', - function($compile) { - return { - restrict: 'ECA', - priority: -400, - require: 'ngInclude', - link: function(scope, $element, $attr, ctrl) { - $element.html(ctrl.template); - $compile($element.contents())(scope); - } - }; - }]; - -/** - * @ngdoc directive - * @name ngInit - * @restrict AC - * - * @description - * The `ngInit` directive allows you to evaluate an expression in the - * current scope. - * - *
- * The only appropriate use of `ngInit` is for aliasing special properties of - * {@link ng.directive:ngRepeat `ngRepeat`}, as seen in the demo below. Besides this case, you - * should use {@link guide/controller controllers} rather than `ngInit` - * to initialize values on a scope. - *
- *
- * **Note**: If you have assignment in `ngInit` along with {@link ng.$filter `$filter`}, make - * sure you have parenthesis for correct precedence: - *
- *   
- *
- *
- * - * @priority 450 - * - * @element ANY - * @param {expression} ngInit {@link guide/expression Expression} to eval. - * - * @example - - - -
-
-
- list[ {{outerIndex}} ][ {{innerIndex}} ] = {{value}}; -
-
-
-
- - it('should alias index positions', function() { - var elements = element.all(by.css('.example-init')); - expect(elements.get(0).getText()).toBe('list[ 0 ][ 0 ] = a;'); - expect(elements.get(1).getText()).toBe('list[ 0 ][ 1 ] = b;'); - expect(elements.get(2).getText()).toBe('list[ 1 ][ 0 ] = c;'); - expect(elements.get(3).getText()).toBe('list[ 1 ][ 1 ] = d;'); - }); - -
- */ -var ngInitDirective = ngDirective({ - priority: 450, - compile: function() { - return { - pre: function(scope, element, attrs) { - scope.$eval(attrs.ngInit); - } - }; - } -}); - -/** - * @ngdoc directive - * @name ngNonBindable - * @restrict AC - * @priority 1000 - * - * @description - * The `ngNonBindable` directive tells Angular not to compile or bind the contents of the current - * DOM element. This is useful if the element contains what appears to be Angular directives and - * bindings but which should be ignored by Angular. This could be the case if you have a site that - * displays snippets of code, for instance. - * - * @element ANY - * - * @example - * In this example there are two locations where a simple interpolation binding (`{{}}`) is present, - * but the one wrapped in `ngNonBindable` is left alone. - * - * @example - - -
Normal: {{1 + 2}}
-
Ignored: {{1 + 2}}
-
- - it('should check ng-non-bindable', function() { - expect(element(by.binding('1 + 2')).getText()).toContain('3'); - expect(element.all(by.css('div')).last().getText()).toMatch(/1 \+ 2/); - }); - -
- */ -var ngNonBindableDirective = ngDirective({ terminal: true, priority: 1000 }); - -/** - * @ngdoc directive - * @name ngPluralize - * @restrict EA - * - * @description - * `ngPluralize` is a directive that displays messages according to en-US localization rules. - * These rules are bundled with angular.js, but can be overridden - * (see {@link guide/i18n Angular i18n} dev guide). You configure ngPluralize directive - * by specifying the mappings between - * [plural categories](http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html) - * and the strings to be displayed. - * - * # Plural categories and explicit number rules - * There are two - * [plural categories](http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html) - * in Angular's default en-US locale: "one" and "other". - * - * While a plural category may match many numbers (for example, in en-US locale, "other" can match - * any number that is not 1), an explicit number rule can only match one number. For example, the - * explicit number rule for "3" matches the number 3. There are examples of plural categories - * and explicit number rules throughout the rest of this documentation. - * - * # Configuring ngPluralize - * You configure ngPluralize by providing 2 attributes: `count` and `when`. - * You can also provide an optional attribute, `offset`. - * - * The value of the `count` attribute can be either a string or an {@link guide/expression - * Angular expression}; these are evaluated on the current scope for its bound value. - * - * The `when` attribute specifies the mappings between plural categories and the actual - * string to be displayed. The value of the attribute should be a JSON object. - * - * The following example shows how to configure ngPluralize: - * - * ```html - * - * - *``` - * - * In the example, `"0: Nobody is viewing."` is an explicit number rule. If you did not - * specify this rule, 0 would be matched to the "other" category and "0 people are viewing" - * would be shown instead of "Nobody is viewing". You can specify an explicit number rule for - * other numbers, for example 12, so that instead of showing "12 people are viewing", you can - * show "a dozen people are viewing". - * - * You can use a set of closed braces (`{}`) as a placeholder for the number that you want substituted - * into pluralized strings. In the previous example, Angular will replace `{}` with - * `{{personCount}}`. The closed braces `{}` is a placeholder - * for {{numberExpression}}. - * - * # Configuring ngPluralize with offset - * The `offset` attribute allows further customization of pluralized text, which can result in - * a better user experience. For example, instead of the message "4 people are viewing this document", - * you might display "John, Kate and 2 others are viewing this document". - * The offset attribute allows you to offset a number by any desired value. - * Let's take a look at an example: - * - * ```html - * - * - * ``` - * - * Notice that we are still using two plural categories(one, other), but we added - * three explicit number rules 0, 1 and 2. - * When one person, perhaps John, views the document, "John is viewing" will be shown. - * When three people view the document, no explicit number rule is found, so - * an offset of 2 is taken off 3, and Angular uses 1 to decide the plural category. - * In this case, plural category 'one' is matched and "John, Mary and one other person are viewing" - * is shown. - * - * Note that when you specify offsets, you must provide explicit number rules for - * numbers from 0 up to and including the offset. If you use an offset of 3, for example, - * you must provide explicit number rules for 0, 1, 2 and 3. You must also provide plural strings for - * plural categories "one" and "other". - * - * @param {string|expression} count The variable to be bound to. - * @param {string} when The mapping between plural category to its corresponding strings. - * @param {number=} offset Offset to deduct from the total number. - * - * @example - - - -
- Person 1:
- Person 2:
- Number of People:
- - - Without Offset: - -
- - - With Offset(2): - - -
-
- - it('should show correct pluralized string', function() { - var withoutOffset = element.all(by.css('ng-pluralize')).get(0); - var withOffset = element.all(by.css('ng-pluralize')).get(1); - var countInput = element(by.model('personCount')); - - expect(withoutOffset.getText()).toEqual('1 person is viewing.'); - expect(withOffset.getText()).toEqual('Igor is viewing.'); - - countInput.clear(); - countInput.sendKeys('0'); - - expect(withoutOffset.getText()).toEqual('Nobody is viewing.'); - expect(withOffset.getText()).toEqual('Nobody is viewing.'); - - countInput.clear(); - countInput.sendKeys('2'); - - expect(withoutOffset.getText()).toEqual('2 people are viewing.'); - expect(withOffset.getText()).toEqual('Igor and Misko are viewing.'); - - countInput.clear(); - countInput.sendKeys('3'); - - expect(withoutOffset.getText()).toEqual('3 people are viewing.'); - expect(withOffset.getText()).toEqual('Igor, Misko and one other person are viewing.'); - - countInput.clear(); - countInput.sendKeys('4'); - - expect(withoutOffset.getText()).toEqual('4 people are viewing.'); - expect(withOffset.getText()).toEqual('Igor, Misko and 2 other people are viewing.'); - }); - it('should show data-bound names', function() { - var withOffset = element.all(by.css('ng-pluralize')).get(1); - var personCount = element(by.model('personCount')); - var person1 = element(by.model('person1')); - var person2 = element(by.model('person2')); - personCount.clear(); - personCount.sendKeys('4'); - person1.clear(); - person1.sendKeys('Di'); - person2.clear(); - person2.sendKeys('Vojta'); - expect(withOffset.getText()).toEqual('Di, Vojta and 2 other people are viewing.'); - }); - -
- */ -var ngPluralizeDirective = ['$locale', '$interpolate', function($locale, $interpolate) { - var BRACE = /{}/g; - return { - restrict: 'EA', - link: function(scope, element, attr) { - var numberExp = attr.count, - whenExp = attr.$attr.when && element.attr(attr.$attr.when), // we have {{}} in attrs - offset = attr.offset || 0, - whens = scope.$eval(whenExp) || {}, - whensExpFns = {}, - startSymbol = $interpolate.startSymbol(), - endSymbol = $interpolate.endSymbol(), - isWhen = /^when(Minus)?(.+)$/; - - forEach(attr, function(expression, attributeName) { - if (isWhen.test(attributeName)) { - whens[lowercase(attributeName.replace('when', '').replace('Minus', '-'))] = - element.attr(attr.$attr[attributeName]); - } - }); - forEach(whens, function(expression, key) { - whensExpFns[key] = - $interpolate(expression.replace(BRACE, startSymbol + numberExp + '-' + - offset + endSymbol)); - }); - - scope.$watch(function ngPluralizeWatch() { - var value = parseFloat(scope.$eval(numberExp)); - - if (!isNaN(value)) { - //if explicit number rule such as 1, 2, 3... is defined, just use it. Otherwise, - //check it against pluralization rules in $locale service - if (!(value in whens)) value = $locale.pluralCat(value - offset); - return whensExpFns[value](scope, element, true); - } else { - return ''; - } - }, function ngPluralizeWatchAction(newVal) { - element.text(newVal); - }); - } - }; -}]; - -/** - * @ngdoc directive - * @name ngRepeat - * - * @description - * The `ngRepeat` directive instantiates a template once per item from a collection. Each template - * instance gets its own scope, where the given loop variable is set to the current collection item, - * and `$index` is set to the item index or key. - * - * Special properties are exposed on the local scope of each template instance, including: - * - * | Variable | Type | Details | - * |-----------|-----------------|-----------------------------------------------------------------------------| - * | `$index` | {@type number} | iterator offset of the repeated element (0..length-1) | - * | `$first` | {@type boolean} | true if the repeated element is first in the iterator. | - * | `$middle` | {@type boolean} | true if the repeated element is between the first and last in the iterator. | - * | `$last` | {@type boolean} | true if the repeated element is last in the iterator. | - * | `$even` | {@type boolean} | true if the iterator position `$index` is even (otherwise false). | - * | `$odd` | {@type boolean} | true if the iterator position `$index` is odd (otherwise false). | - * - * Creating aliases for these properties is possible with {@link ng.directive:ngInit `ngInit`}. - * This may be useful when, for instance, nesting ngRepeats. - * - * # Special repeat start and end points - * To repeat a series of elements instead of just one parent element, ngRepeat (as well as other ng directives) supports extending - * the range of the repeater by defining explicit start and end points by using **ng-repeat-start** and **ng-repeat-end** respectively. - * The **ng-repeat-start** directive works the same as **ng-repeat**, but will repeat all the HTML code (including the tag it's defined on) - * up to and including the ending HTML tag where **ng-repeat-end** is placed. - * - * The example below makes use of this feature: - * ```html - *
- * Header {{ item }} - *
- *
- * Body {{ item }} - *
- *
- * Footer {{ item }} - *
- * ``` - * - * And with an input of {@type ['A','B']} for the items variable in the example above, the output will evaluate to: - * ```html - *
- * Header A - *
- *
- * Body A - *
- *
- * Footer A - *
- *
- * Header B - *
- *
- * Body B - *
- *
- * Footer B - *
- * ``` - * - * The custom start and end points for ngRepeat also support all other HTML directive syntax flavors provided in AngularJS (such - * as **data-ng-repeat-start**, **x-ng-repeat-start** and **ng:repeat-start**). - * - * @animations - * **.enter** - when a new item is added to the list or when an item is revealed after a filter - * - * **.leave** - when an item is removed from the list or when an item is filtered out - * - * **.move** - when an adjacent item is filtered out causing a reorder or when the item contents are reordered - * - * @element ANY - * @scope - * @priority 1000 - * @param {repeat_expression} ngRepeat The expression indicating how to enumerate a collection. These - * formats are currently supported: - * - * * `variable in expression` – where variable is the user defined loop variable and `expression` - * is a scope expression giving the collection to enumerate. - * - * For example: `album in artist.albums`. - * - * * `(key, value) in expression` – where `key` and `value` can be any user defined identifiers, - * and `expression` is the scope expression giving the collection to enumerate. - * - * For example: `(name, age) in {'adam':10, 'amalie':12}`. - * - * * `variable in expression track by tracking_expression` – You can also provide an optional tracking function - * which can be used to associate the objects in the collection with the DOM elements. If no tracking function - * is specified the ng-repeat associates elements by identity in the collection. It is an error to have - * more than one tracking function to resolve to the same key. (This would mean that two distinct objects are - * mapped to the same DOM element, which is not possible.) Filters should be applied to the expression, - * before specifying a tracking expression. - * - * For example: `item in items` is equivalent to `item in items track by $id(item)`. This implies that the DOM elements - * will be associated by item identity in the array. - * - * For example: `item in items track by $id(item)`. A built in `$id()` function can be used to assign a unique - * `$$hashKey` property to each item in the array. This property is then used as a key to associated DOM elements - * with the corresponding item in the array by identity. Moving the same object in array would move the DOM - * element in the same way in the DOM. - * - * For example: `item in items track by item.id` is a typical pattern when the items come from the database. In this - * case the object identity does not matter. Two objects are considered equivalent as long as their `id` - * property is same. - * - * For example: `item in items | filter:searchText track by item.id` is a pattern that might be used to apply a filter - * to items in conjunction with a tracking expression. - * - * @example - * This example initializes the scope to a list of names and - * then uses `ngRepeat` to display every person: - - -
- I have {{friends.length}} friends. They are: - -
    -
  • - [{{$index + 1}}] {{friend.name}} who is {{friend.age}} years old. -
  • -
-
-
- - .example-animate-container { - background:white; - border:1px solid black; - list-style:none; - margin:0; - padding:0 10px; - } - - .animate-repeat { - line-height:40px; - list-style:none; - box-sizing:border-box; - } - - .animate-repeat.ng-move, - .animate-repeat.ng-enter, - .animate-repeat.ng-leave { - -webkit-transition:all linear 0.5s; - transition:all linear 0.5s; - } - - .animate-repeat.ng-leave.ng-leave-active, - .animate-repeat.ng-move, - .animate-repeat.ng-enter { - opacity:0; - max-height:0; - } - - .animate-repeat.ng-leave, - .animate-repeat.ng-move.ng-move-active, - .animate-repeat.ng-enter.ng-enter-active { - opacity:1; - max-height:40px; - } - - - var friends = element.all(by.repeater('friend in friends')); - - it('should render initial data set', function() { - expect(friends.count()).toBe(10); - expect(friends.get(0).getText()).toEqual('[1] John who is 25 years old.'); - expect(friends.get(1).getText()).toEqual('[2] Jessie who is 30 years old.'); - expect(friends.last().getText()).toEqual('[10] Samantha who is 60 years old.'); - expect(element(by.binding('friends.length')).getText()) - .toMatch("I have 10 friends. They are:"); - }); - - it('should update repeater when filter predicate changes', function() { - expect(friends.count()).toBe(10); - - element(by.model('q')).sendKeys('ma'); - - expect(friends.count()).toBe(2); - expect(friends.get(0).getText()).toEqual('[1] Mary who is 28 years old.'); - expect(friends.last().getText()).toEqual('[2] Samantha who is 60 years old.'); - }); - -
- */ -var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) { - var NG_REMOVED = '$$NG_REMOVED'; - var ngRepeatMinErr = minErr('ngRepeat'); - return { - transclude: 'element', - priority: 1000, - terminal: true, - $$tlb: true, - link: function($scope, $element, $attr, ctrl, $transclude){ - var expression = $attr.ngRepeat; - var match = expression.match(/^\s*([\s\S]+?)\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?\s*$/), - trackByExp, trackByExpGetter, trackByIdExpFn, trackByIdArrayFn, trackByIdObjFn, - lhs, rhs, valueIdentifier, keyIdentifier, - hashFnLocals = {$id: hashKey}; - - if (!match) { - throw ngRepeatMinErr('iexp', "Expected expression in form of '_item_ in _collection_[ track by _id_]' but got '{0}'.", - expression); - } - - lhs = match[1]; - rhs = match[2]; - trackByExp = match[3]; - - if (trackByExp) { - trackByExpGetter = $parse(trackByExp); - trackByIdExpFn = function(key, value, index) { - // assign key, value, and $index to the locals so that they can be used in hash functions - if (keyIdentifier) hashFnLocals[keyIdentifier] = key; - hashFnLocals[valueIdentifier] = value; - hashFnLocals.$index = index; - return trackByExpGetter($scope, hashFnLocals); - }; - } else { - trackByIdArrayFn = function(key, value) { - return hashKey(value); - }; - trackByIdObjFn = function(key) { - return key; - }; - } - - match = lhs.match(/^(?:([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\))$/); - if (!match) { - throw ngRepeatMinErr('iidexp', "'_item_' in '_item_ in _collection_' should be an identifier or '(_key_, _value_)' expression, but got '{0}'.", - lhs); - } - valueIdentifier = match[3] || match[1]; - keyIdentifier = match[2]; - - // Store a list of elements from previous run. This is a hash where key is the item from the - // iterator, and the value is objects with following properties. - // - scope: bound scope - // - element: previous element. - // - index: position - var lastBlockMap = {}; - - //watch props - $scope.$watchCollection(rhs, function ngRepeatAction(collection){ - var index, length, - previousNode = $element[0], // current position of the node - nextNode, - // Same as lastBlockMap but it has the current state. It will become the - // lastBlockMap on the next iteration. - nextBlockMap = {}, - arrayLength, - childScope, - key, value, // key/value of iteration - trackById, - trackByIdFn, - collectionKeys, - block, // last object information {scope, element, id} - nextBlockOrder = [], - elementsToRemove; - - - if (isArrayLike(collection)) { - collectionKeys = collection; - trackByIdFn = trackByIdExpFn || trackByIdArrayFn; - } else { - trackByIdFn = trackByIdExpFn || trackByIdObjFn; - // if object, extract keys, sort them and use to determine order of iteration over obj props - collectionKeys = []; - for (key in collection) { - if (collection.hasOwnProperty(key) && key.charAt(0) != '$') { - collectionKeys.push(key); - } - } - collectionKeys.sort(); - } - - arrayLength = collectionKeys.length; - - // locate existing items - length = nextBlockOrder.length = collectionKeys.length; - for(index = 0; index < length; index++) { - key = (collection === collectionKeys) ? index : collectionKeys[index]; - value = collection[key]; - trackById = trackByIdFn(key, value, index); - assertNotHasOwnProperty(trackById, '`track by` id'); - if(lastBlockMap.hasOwnProperty(trackById)) { - block = lastBlockMap[trackById]; - delete lastBlockMap[trackById]; - nextBlockMap[trackById] = block; - nextBlockOrder[index] = block; - } else if (nextBlockMap.hasOwnProperty(trackById)) { - // restore lastBlockMap - forEach(nextBlockOrder, function(block) { - if (block && block.scope) lastBlockMap[block.id] = block; - }); - // This is a duplicate and we need to throw an error - throw ngRepeatMinErr('dupes', - "Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: {0}, Duplicate key: {1}, Duplicate value: {2}", - expression, trackById, toJson(value)); - } else { - // new never before seen block - nextBlockOrder[index] = { id: trackById }; - nextBlockMap[trackById] = false; - } - } - - // remove existing items - for (key in lastBlockMap) { - // lastBlockMap is our own object so we don't need to use special hasOwnPropertyFn - if (lastBlockMap.hasOwnProperty(key)) { - block = lastBlockMap[key]; - elementsToRemove = getBlockElements(block.clone); - $animate.leave(elementsToRemove); - forEach(elementsToRemove, function(element) { element[NG_REMOVED] = true; }); - block.scope.$destroy(); - } - } - - // we are not using forEach for perf reasons (trying to avoid #call) - for (index = 0, length = collectionKeys.length; index < length; index++) { - key = (collection === collectionKeys) ? index : collectionKeys[index]; - value = collection[key]; - block = nextBlockOrder[index]; - if (nextBlockOrder[index - 1]) previousNode = getBlockEnd(nextBlockOrder[index - 1]); - - if (block.scope) { - // if we have already seen this object, then we need to reuse the - // associated scope/element - childScope = block.scope; - - nextNode = previousNode; - do { - nextNode = nextNode.nextSibling; - } while(nextNode && nextNode[NG_REMOVED]); - - if (getBlockStart(block) != nextNode) { - // existing item which got moved - $animate.move(getBlockElements(block.clone), null, jqLite(previousNode)); - } - previousNode = getBlockEnd(block); - } else { - // new item which we don't know about - childScope = $scope.$new(); - } - - childScope[valueIdentifier] = value; - if (keyIdentifier) childScope[keyIdentifier] = key; - childScope.$index = index; - childScope.$first = (index === 0); - childScope.$last = (index === (arrayLength - 1)); - childScope.$middle = !(childScope.$first || childScope.$last); - // jshint bitwise: false - childScope.$odd = !(childScope.$even = (index&1) === 0); - // jshint bitwise: true - - if (!block.scope) { - $transclude(childScope, function(clone) { - clone[clone.length++] = document.createComment(' end ngRepeat: ' + expression + ' '); - $animate.enter(clone, null, jqLite(previousNode)); - previousNode = clone; - block.scope = childScope; - // Note: We only need the first/last node of the cloned nodes. - // However, we need to keep the reference to the jqlite wrapper as it might be changed later - // by a directive with templateUrl when its template arrives. - block.clone = clone; - nextBlockMap[block.id] = block; - }); - } - } - lastBlockMap = nextBlockMap; - }); - } - }; - - function getBlockStart(block) { - return block.clone[0]; - } - - function getBlockEnd(block) { - return block.clone[block.clone.length - 1]; - } -}]; - -/** - * @ngdoc directive - * @name ngShow - * - * @description - * The `ngShow` directive shows or hides the given HTML element based on the expression - * provided to the `ngShow` attribute. The element is shown or hidden by removing or adding - * the `.ng-hide` CSS class onto the element. The `.ng-hide` CSS class is predefined - * in AngularJS and sets the display style to none (using an !important flag). - * For CSP mode please add `angular-csp.css` to your html file (see {@link ng.directive:ngCsp ngCsp}). - * - * ```html - * - *
- * - * - *
- * ``` - * - * When the `ngShow` expression evaluates to false then the `.ng-hide` CSS class is added to the class attribute - * on the element causing it to become hidden. When true, the `.ng-hide` CSS class is removed - * from the element causing the element not to appear hidden. - * - *
- * **Note:** Here is a list of values that ngShow will consider as a falsy value (case insensitive):
- * "f" / "0" / "false" / "no" / "n" / "[]" - *
- * - * ## Why is !important used? - * - * You may be wondering why !important is used for the `.ng-hide` CSS class. This is because the `.ng-hide` selector - * can be easily overridden by heavier selectors. For example, something as simple - * as changing the display style on a HTML list item would make hidden elements appear visible. - * This also becomes a bigger issue when dealing with CSS frameworks. - * - * By using !important, the show and hide behavior will work as expected despite any clash between CSS selector - * specificity (when !important isn't used with any conflicting styles). If a developer chooses to override the - * styling to change how to hide an element then it is just a matter of using !important in their own CSS code. - * - * ### Overriding `.ng-hide` - * - * By default, the `.ng-hide` class will style the element with `display:none!important`. If you wish to change - * the hide behavior with ngShow/ngHide then this can be achieved by restating the styles for the `.ng-hide` - * class in CSS: - * - * ```css - * .ng-hide { - * //this is just another form of hiding an element - * display:block!important; - * position:absolute; - * top:-9999px; - * left:-9999px; - * } - * ``` - * - * By default you don't need to override in CSS anything and the animations will work around the display style. - * - * ## A note about animations with `ngShow` - * - * Animations in ngShow/ngHide work with the show and hide events that are triggered when the directive expression - * is true and false. This system works like the animation system present with ngClass except that - * you must also include the !important flag to override the display property - * so that you can perform an animation when the element is hidden during the time of the animation. - * - * ```css - * // - * //a working example can be found at the bottom of this page - * // - * .my-element.ng-hide-add, .my-element.ng-hide-remove { - * transition:0.5s linear all; - * } - * - * .my-element.ng-hide-add { ... } - * .my-element.ng-hide-add.ng-hide-add-active { ... } - * .my-element.ng-hide-remove { ... } - * .my-element.ng-hide-remove.ng-hide-remove-active { ... } - * ``` - * - * Keep in mind that, as of AngularJS version 1.2.17 (and 1.3.0-beta.11), there is no need to change the display - * property to block during animation states--ngAnimate will handle the style toggling automatically for you. - * - * @animations - * addClass: `.ng-hide` - happens after the `ngShow` expression evaluates to a truthy value and the just before contents are set to visible - * removeClass: `.ng-hide` - happens after the `ngShow` expression evaluates to a non truthy value and just before the contents are set to hidden - * - * @element ANY - * @param {expression} ngShow If the {@link guide/expression expression} is truthy - * then the element is shown or hidden respectively. - * - * @example - - - Click me:
-
- Show: -
- I show up when your checkbox is checked. -
-
-
- Hide: -
- I hide when your checkbox is checked. -
-
-
- - @import url(http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css); - - - .animate-show { - -webkit-transition:all linear 0.5s; - transition:all linear 0.5s; - line-height:20px; - opacity:1; - padding:10px; - border:1px solid black; - background:white; - } - - .animate-show.ng-hide { - line-height:0; - opacity:0; - padding:0 10px; - } - - .check-element { - padding:10px; - border:1px solid black; - background:white; - } - - - var thumbsUp = element(by.css('span.glyphicon-thumbs-up')); - var thumbsDown = element(by.css('span.glyphicon-thumbs-down')); - - it('should check ng-show / ng-hide', function() { - expect(thumbsUp.isDisplayed()).toBeFalsy(); - expect(thumbsDown.isDisplayed()).toBeTruthy(); - - element(by.model('checked')).click(); - - expect(thumbsUp.isDisplayed()).toBeTruthy(); - expect(thumbsDown.isDisplayed()).toBeFalsy(); - }); - -
- */ -var ngShowDirective = ['$animate', function($animate) { - return function(scope, element, attr) { - scope.$watch(attr.ngShow, function ngShowWatchAction(value){ - $animate[toBoolean(value) ? 'removeClass' : 'addClass'](element, 'ng-hide'); - }); - }; -}]; - - -/** - * @ngdoc directive - * @name ngHide - * - * @description - * The `ngHide` directive shows or hides the given HTML element based on the expression - * provided to the `ngHide` attribute. The element is shown or hidden by removing or adding - * the `ng-hide` CSS class onto the element. The `.ng-hide` CSS class is predefined - * in AngularJS and sets the display style to none (using an !important flag). - * For CSP mode please add `angular-csp.css` to your html file (see {@link ng.directive:ngCsp ngCsp}). - * - * ```html - * - *
- * - * - *
- * ``` - * - * When the `.ngHide` expression evaluates to true then the `.ng-hide` CSS class is added to the class attribute - * on the element causing it to become hidden. When false, the `.ng-hide` CSS class is removed - * from the element causing the element not to appear hidden. - * - *
- * **Note:** Here is a list of values that ngHide will consider as a falsy value (case insensitive):
- * "f" / "0" / "false" / "no" / "n" / "[]" - *
- * - * ## Why is !important used? - * - * You may be wondering why !important is used for the `.ng-hide` CSS class. This is because the `.ng-hide` selector - * can be easily overridden by heavier selectors. For example, something as simple - * as changing the display style on a HTML list item would make hidden elements appear visible. - * This also becomes a bigger issue when dealing with CSS frameworks. - * - * By using !important, the show and hide behavior will work as expected despite any clash between CSS selector - * specificity (when !important isn't used with any conflicting styles). If a developer chooses to override the - * styling to change how to hide an element then it is just a matter of using !important in their own CSS code. - * - * ### Overriding `.ng-hide` - * - * By default, the `.ng-hide` class will style the element with `display:none!important`. If you wish to change - * the hide behavior with ngShow/ngHide then this can be achieved by restating the styles for the `.ng-hide` - * class in CSS: - * - * ```css - * .ng-hide { - * //this is just another form of hiding an element - * display:block!important; - * position:absolute; - * top:-9999px; - * left:-9999px; - * } - * ``` - * - * By default you don't need to override in CSS anything and the animations will work around the display style. - * - * ## A note about animations with `ngHide` - * - * Animations in ngShow/ngHide work with the show and hide events that are triggered when the directive expression - * is true and false. This system works like the animation system present with ngClass, except that the `.ng-hide` - * CSS class is added and removed for you instead of your own CSS class. - * - * ```css - * // - * //a working example can be found at the bottom of this page - * // - * .my-element.ng-hide-add, .my-element.ng-hide-remove { - * transition:0.5s linear all; - * } - * - * .my-element.ng-hide-add { ... } - * .my-element.ng-hide-add.ng-hide-add-active { ... } - * .my-element.ng-hide-remove { ... } - * .my-element.ng-hide-remove.ng-hide-remove-active { ... } - * ``` - * - * Keep in mind that, as of AngularJS version 1.2.17 (and 1.3.0-beta.11), there is no need to change the display - * property to block during animation states--ngAnimate will handle the style toggling automatically for you. - * - * @animations - * removeClass: `.ng-hide` - happens after the `ngHide` expression evaluates to a truthy value and just before the contents are set to hidden - * addClass: `.ng-hide` - happens after the `ngHide` expression evaluates to a non truthy value and just before the contents are set to visible - * - * @element ANY - * @param {expression} ngHide If the {@link guide/expression expression} is truthy then - * the element is shown or hidden respectively. - * - * @example - - - Click me:
-
- Show: -
- I show up when your checkbox is checked. -
-
-
- Hide: -
- I hide when your checkbox is checked. -
-
-
- - @import url(http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css); - - - .animate-hide { - -webkit-transition:all linear 0.5s; - transition:all linear 0.5s; - line-height:20px; - opacity:1; - padding:10px; - border:1px solid black; - background:white; - } - - .animate-hide.ng-hide { - line-height:0; - opacity:0; - padding:0 10px; - } - - .check-element { - padding:10px; - border:1px solid black; - background:white; - } - - - var thumbsUp = element(by.css('span.glyphicon-thumbs-up')); - var thumbsDown = element(by.css('span.glyphicon-thumbs-down')); - - it('should check ng-show / ng-hide', function() { - expect(thumbsUp.isDisplayed()).toBeFalsy(); - expect(thumbsDown.isDisplayed()).toBeTruthy(); - - element(by.model('checked')).click(); - - expect(thumbsUp.isDisplayed()).toBeTruthy(); - expect(thumbsDown.isDisplayed()).toBeFalsy(); - }); - -
- */ -var ngHideDirective = ['$animate', function($animate) { - return function(scope, element, attr) { - scope.$watch(attr.ngHide, function ngHideWatchAction(value){ - $animate[toBoolean(value) ? 'addClass' : 'removeClass'](element, 'ng-hide'); - }); - }; -}]; - -/** - * @ngdoc directive - * @name ngStyle - * @restrict AC - * - * @description - * The `ngStyle` directive allows you to set CSS style on an HTML element conditionally. - * - * @element ANY - * @param {expression} ngStyle - * - * {@link guide/expression Expression} which evals to an - * object whose keys are CSS style names and values are corresponding values for those CSS - * keys. - * - * Since some CSS style names are not valid keys for an object, they must be quoted. - * See the 'background-color' style in the example below. - * - * @example - - - - - -
- Sample Text -
myStyle={{myStyle}}
-
- - span { - color: black; - } - - - var colorSpan = element(by.css('span')); - - it('should check ng-style', function() { - expect(colorSpan.getCssValue('color')).toBe('rgba(0, 0, 0, 1)'); - element(by.css('input[value=\'set color\']')).click(); - expect(colorSpan.getCssValue('color')).toBe('rgba(255, 0, 0, 1)'); - element(by.css('input[value=clear]')).click(); - expect(colorSpan.getCssValue('color')).toBe('rgba(0, 0, 0, 1)'); - }); - -
- */ -var ngStyleDirective = ngDirective(function(scope, element, attr) { - scope.$watch(attr.ngStyle, function ngStyleWatchAction(newStyles, oldStyles) { - if (oldStyles && (newStyles !== oldStyles)) { - forEach(oldStyles, function(val, style) { element.css(style, '');}); - } - if (newStyles) element.css(newStyles); - }, true); -}); - -/** - * @ngdoc directive - * @name ngSwitch - * @restrict EA - * - * @description - * The `ngSwitch` directive is used to conditionally swap DOM structure on your template based on a scope expression. - * Elements within `ngSwitch` but without `ngSwitchWhen` or `ngSwitchDefault` directives will be preserved at the location - * as specified in the template. - * - * The directive itself works similar to ngInclude, however, instead of downloading template code (or loading it - * from the template cache), `ngSwitch` simply chooses one of the nested elements and makes it visible based on which element - * matches the value obtained from the evaluated expression. In other words, you define a container element - * (where you place the directive), place an expression on the **`on="..."` attribute** - * (or the **`ng-switch="..."` attribute**), define any inner elements inside of the directive and place - * a when attribute per element. The when attribute is used to inform ngSwitch which element to display when the on - * expression is evaluated. If a matching expression is not found via a when attribute then an element with the default - * attribute is displayed. - * - *
- * Be aware that the attribute values to match against cannot be expressions. They are interpreted - * as literal string values to match against. - * For example, **`ng-switch-when="someVal"`** will match against the string `"someVal"` not against the - * value of the expression `$scope.someVal`. - *
- - * @animations - * enter - happens after the ngSwitch contents change and the matched child element is placed inside the container - * leave - happens just after the ngSwitch contents change and just before the former contents are removed from the DOM - * - * @usage - * - * ``` - * - * ... - * ... - * ... - * - * ``` - * - * - * @scope - * @priority 800 - * @param {*} ngSwitch|on expression to match against ng-switch-when. - * On child elements add: - * - * * `ngSwitchWhen`: the case statement to match against. If match then this - * case will be displayed. If the same match appears multiple times, all the - * elements will be displayed. - * * `ngSwitchDefault`: the default case when no other case match. If there - * are multiple default cases, all of them will be displayed when no other - * case match. - * - * - * @example - - -
- - selection={{selection}} -
-
-
Settings Div
-
Home Span
-
default
-
-
-
- - angular.module('switchExample', ['ngAnimate']) - .controller('ExampleController', ['$scope', function($scope) { - $scope.items = ['settings', 'home', 'other']; - $scope.selection = $scope.items[0]; - }]); - - - .animate-switch-container { - position:relative; - background:white; - border:1px solid black; - height:40px; - overflow:hidden; - } - - .animate-switch { - padding:10px; - } - - .animate-switch.ng-animate { - -webkit-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.5s; - transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.5s; - - position:absolute; - top:0; - left:0; - right:0; - bottom:0; - } - - .animate-switch.ng-leave.ng-leave-active, - .animate-switch.ng-enter { - top:-50px; - } - .animate-switch.ng-leave, - .animate-switch.ng-enter.ng-enter-active { - top:0; - } - - - var switchElem = element(by.css('[ng-switch]')); - var select = element(by.model('selection')); - - it('should start in settings', function() { - expect(switchElem.getText()).toMatch(/Settings Div/); - }); - it('should change to home', function() { - select.all(by.css('option')).get(1).click(); - expect(switchElem.getText()).toMatch(/Home Span/); - }); - it('should select default', function() { - select.all(by.css('option')).get(2).click(); - expect(switchElem.getText()).toMatch(/default/); - }); - -
- */ -var ngSwitchDirective = ['$animate', function($animate) { - return { - restrict: 'EA', - require: 'ngSwitch', - - // asks for $scope to fool the BC controller module - controller: ['$scope', function ngSwitchController() { - this.cases = {}; - }], - link: function(scope, element, attr, ngSwitchController) { - var watchExpr = attr.ngSwitch || attr.on, - selectedTranscludes = [], - selectedElements = [], - previousElements = [], - selectedScopes = []; - - scope.$watch(watchExpr, function ngSwitchWatchAction(value) { - var i, ii; - for (i = 0, ii = previousElements.length; i < ii; ++i) { - previousElements[i].remove(); - } - previousElements.length = 0; - - for (i = 0, ii = selectedScopes.length; i < ii; ++i) { - var selected = selectedElements[i]; - selectedScopes[i].$destroy(); - previousElements[i] = selected; - $animate.leave(selected, function() { - previousElements.splice(i, 1); - }); - } - - selectedElements.length = 0; - selectedScopes.length = 0; - - if ((selectedTranscludes = ngSwitchController.cases['!' + value] || ngSwitchController.cases['?'])) { - scope.$eval(attr.change); - forEach(selectedTranscludes, function(selectedTransclude) { - var selectedScope = scope.$new(); - selectedScopes.push(selectedScope); - selectedTransclude.transclude(selectedScope, function(caseElement) { - var anchor = selectedTransclude.element; - - selectedElements.push(caseElement); - $animate.enter(caseElement, anchor.parent(), anchor); - }); - }); - } - }); - } - }; -}]; - -var ngSwitchWhenDirective = ngDirective({ - transclude: 'element', - priority: 800, - require: '^ngSwitch', - link: function(scope, element, attrs, ctrl, $transclude) { - ctrl.cases['!' + attrs.ngSwitchWhen] = (ctrl.cases['!' + attrs.ngSwitchWhen] || []); - ctrl.cases['!' + attrs.ngSwitchWhen].push({ transclude: $transclude, element: element }); - } -}); - -var ngSwitchDefaultDirective = ngDirective({ - transclude: 'element', - priority: 800, - require: '^ngSwitch', - link: function(scope, element, attr, ctrl, $transclude) { - ctrl.cases['?'] = (ctrl.cases['?'] || []); - ctrl.cases['?'].push({ transclude: $transclude, element: element }); - } -}); - -/** - * @ngdoc directive - * @name ngTransclude - * @restrict AC - * - * @description - * Directive that marks the insertion point for the transcluded DOM of the nearest parent directive that uses transclusion. - * - * Any existing content of the element that this directive is placed on will be removed before the transcluded content is inserted. - * - * @element ANY - * - * @example - - - -
-
-
- {{text}} -
-
- - it('should have transcluded', function() { - var titleElement = element(by.model('title')); - titleElement.clear(); - titleElement.sendKeys('TITLE'); - var textElement = element(by.model('text')); - textElement.clear(); - textElement.sendKeys('TEXT'); - expect(element(by.binding('title')).getText()).toEqual('TITLE'); - expect(element(by.binding('text')).getText()).toEqual('TEXT'); - }); - -
- * - */ -var ngTranscludeDirective = ngDirective({ - link: function($scope, $element, $attrs, controller, $transclude) { - if (!$transclude) { - throw minErr('ngTransclude')('orphan', - 'Illegal use of ngTransclude directive in the template! ' + - 'No parent directive that requires a transclusion found. ' + - 'Element: {0}', - startingTag($element)); - } - - $transclude(function(clone) { - $element.empty(); - $element.append(clone); - }); - } -}); - -/** - * @ngdoc directive - * @name script - * @restrict E - * - * @description - * Load the content of a ` - - Load inlined template -
- - - it('should load template defined inside script tag', function() { - element(by.css('#tpl-link')).click(); - expect(element(by.css('#tpl-content')).getText()).toMatch(/Content of the template/); - }); - - - */ -var scriptDirective = ['$templateCache', function($templateCache) { - return { - restrict: 'E', - terminal: true, - compile: function(element, attr) { - if (attr.type == 'text/ng-template') { - var templateUrl = attr.id, - // IE is not consistent, in scripts we have to read .text but in other nodes we have to read .textContent - text = element[0].text; - - $templateCache.put(templateUrl, text); - } - } - }; -}]; - -var ngOptionsMinErr = minErr('ngOptions'); -/** - * @ngdoc directive - * @name select - * @restrict E - * - * @description - * HTML `SELECT` element with angular data-binding. - * - * # `ngOptions` - * - * The `ngOptions` attribute can be used to dynamically generate a list of `` - * DOM element. - * * `trackexpr`: Used when working with an array of objects. The result of this expression will be - * used to identify the objects in the array. The `trackexpr` will most likely refer to the - * `value` variable (e.g. `value.propertyName`). - * - * @example - - - -
-
    -
  • - Name: - [X] -
  • -
  • - [add] -
  • -
-
- Color (null not allowed): -
- - Color (null allowed): - - -
- - Color grouped by shade: -
- - - Select bogus.
-
- Currently selected: {{ {selected_color:myColor} }} -
-
-
-
- - it('should check ng-options', function() { - expect(element(by.binding('{selected_color:myColor}')).getText()).toMatch('red'); - element.all(by.model('myColor')).first().click(); - element.all(by.css('select[ng-model="myColor"] option')).first().click(); - expect(element(by.binding('{selected_color:myColor}')).getText()).toMatch('black'); - element(by.css('.nullable select[ng-model="myColor"]')).click(); - element.all(by.css('.nullable select[ng-model="myColor"] option')).first().click(); - expect(element(by.binding('{selected_color:myColor}')).getText()).toMatch('null'); - }); - -
- */ - -var ngOptionsDirective = valueFn({ terminal: true }); -// jshint maxlen: false -var selectDirective = ['$compile', '$parse', function($compile, $parse) { - //000011111111110000000000022222222220000000000000000000003333333333000000000000004444444444444440000000005555555555555550000000666666666666666000000000000000777777777700000000000000000008888888888 - var NG_OPTIONS_REGEXP = /^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?(?:\s+group\s+by\s+([\s\S]+?))?\s+for\s+(?:([\$\w][\$\w]*)|(?:\(\s*([\$\w][\$\w]*)\s*,\s*([\$\w][\$\w]*)\s*\)))\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?$/, - nullModelCtrl = {$setViewValue: noop}; -// jshint maxlen: 100 - - return { - restrict: 'E', - require: ['select', '?ngModel'], - controller: ['$element', '$scope', '$attrs', function($element, $scope, $attrs) { - var self = this, - optionsMap = {}, - ngModelCtrl = nullModelCtrl, - nullOption, - unknownOption; - - - self.databound = $attrs.ngModel; - - - self.init = function(ngModelCtrl_, nullOption_, unknownOption_) { - ngModelCtrl = ngModelCtrl_; - nullOption = nullOption_; - unknownOption = unknownOption_; - }; - - - self.addOption = function(value) { - assertNotHasOwnProperty(value, '"option value"'); - optionsMap[value] = true; - - if (ngModelCtrl.$viewValue == value) { - $element.val(value); - if (unknownOption.parent()) unknownOption.remove(); - } - }; - - - self.removeOption = function(value) { - if (this.hasOption(value)) { - delete optionsMap[value]; - if (ngModelCtrl.$viewValue == value) { - this.renderUnknownOption(value); - } - } - }; - - - self.renderUnknownOption = function(val) { - var unknownVal = '? ' + hashKey(val) + ' ?'; - unknownOption.val(unknownVal); - $element.prepend(unknownOption); - $element.val(unknownVal); - unknownOption.prop('selected', true); // needed for IE - }; - - - self.hasOption = function(value) { - return optionsMap.hasOwnProperty(value); - }; - - $scope.$on('$destroy', function() { - // disable unknown option so that we don't do work when the whole select is being destroyed - self.renderUnknownOption = noop; - }); - }], - - link: function(scope, element, attr, ctrls) { - // if ngModel is not defined, we don't need to do anything - if (!ctrls[1]) return; - - var selectCtrl = ctrls[0], - ngModelCtrl = ctrls[1], - multiple = attr.multiple, - optionsExp = attr.ngOptions, - nullOption = false, // if false, user will not be able to select it (used by ngOptions) - emptyOption, - // we can't just jqLite('