From 4354f6e848d9f592ec1b40402950823df3c85a72 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Fri, 18 Mar 2016 01:03:37 -0700 Subject: [PATCH 01/60] chore(package.json): remove unused `watchpack` dependency --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 251f6b4..989c09d 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,6 @@ "json-loader": "^0.5.2", "merge-stream": "0.1.8", "uglify-js": "2.4.23", - "watchpack": "^0.2.8", "webpack": "1.10.0", "webpack-core": "^0.6.5" } From e6b47b52c6e82332891f69b317c7d0edfdb19239 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Fri, 18 Mar 2016 01:04:06 -0700 Subject: [PATCH 02/60] chore(package.json): update webpack to version 1.12.14 --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 989c09d..c07d979 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,6 @@ "json-loader": "^0.5.2", "merge-stream": "0.1.8", "uglify-js": "2.4.23", - "webpack": "1.10.0", - "webpack-core": "^0.6.5" + "webpack": "^1.12.14" } } From 59d328ae0d94cb4e74b6bf1a185fe142153e5d66 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Fri, 18 Mar 2016 01:34:54 -0700 Subject: [PATCH 03/60] chore(build): update babel to v6.x --- package.json | 11 ++++++----- webpack.config.js | 8 ++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index c07d979..72d0555 100644 --- a/package.json +++ b/package.json @@ -14,18 +14,19 @@ "lib": "./src" }, "dependencies": { - "babel-runtime": "5.6.15", + "babel-runtime": "^6.6.1", "isomorphic-fetch": "^2.1.0", "lodash": "3.10.0" }, "devDependencies": { - "babel": "5.6.14", - "babel-core": "5.6.15", - "babel-loader": "5.2.2", + "babel-core": "^6.7.2", + "babel-loader": "^6.2.4", + "babel-plugin-transform-runtime": "^6.6.0", + "babel-preset-es2015": "^6.6.0", "expect.js": "~0.3.1", "form-data": "^1.0.0-rc3", "gulp": "3.9.0", - "gulp-babel": "5.1.0", + "gulp-babel": "^6.1.2", "gulp-mocha": "2.2.0", "gulp-webpack": "1.5.0", "json-loader": "^0.5.2", diff --git a/webpack.config.js b/webpack.config.js index 62a938a..ed0cf4b 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -11,8 +11,12 @@ module.exports = { module: { loaders: [{ test: /\.js$/, - loader: 'babel-loader?stage=0&optional=runtime', - exclude: /(bower_components|node_modules)/ + loader: 'babel-loader', + exclude: /(bower_components|node_modules)/, + query: { + plugins: ['transform-runtime'], + presets: ['es2015'] + } }, ] }, From 37c3301f3503ddf0ab8fa9d01839c2361a7194c2 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Fri, 18 Mar 2016 01:35:39 -0700 Subject: [PATCH 04/60] chore(webpack): use tabs instead of spaces for indentation --- webpack.config.js | 52 +++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index ed0cf4b..2f335a6 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,30 +1,30 @@ var webpack = require("webpack"); module.exports = { - context: __dirname, - entry: './src/index.js', - output: { - libraryTarget: "umd", - library: "Montage", - filename: './dist/montage.js' - }, - module: { - loaders: [{ - test: /\.js$/, - loader: 'babel-loader', - exclude: /(bower_components|node_modules)/, - query: { - plugins: ['transform-runtime'], - presets: ['es2015'] - } - }, - ] - }, - resolve: { - extensions: ['', '.js', '.jsx'] - }, - plugins: [ - new webpack.optimize.DedupePlugin(), - new webpack.optimize.UglifyJsPlugin({minimize: true}) - ] + context: __dirname, + entry: './src/index.js', + output: { + libraryTarget: "umd", + library: "Montage", + filename: './dist/montage.js' + }, + module: { + loaders: [{ + test: /\.js$/, + loader: 'babel-loader', + exclude: /(bower_components|node_modules)/, + query: { + plugins: ['transform-runtime'], + presets: ['es2015'] + } + }, + ] + }, + resolve: { + extensions: ['', '.js', '.jsx'] + }, + plugins: [ + new webpack.optimize.DedupePlugin(), + new webpack.optimize.UglifyJsPlugin({minimize: true}) + ] } From ad47a0137a38dbc9b7762f31d89206ce8a39591a Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Fri, 18 Mar 2016 01:37:22 -0700 Subject: [PATCH 05/60] chore(webpack): correct closing bracket style --- webpack.config.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 2f335a6..59cbd04 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -17,8 +17,7 @@ module.exports = { plugins: ['transform-runtime'], presets: ['es2015'] } - }, - ] + }] }, resolve: { extensions: ['', '.js', '.jsx'] From 72e366cd07a7e7d23db0462e712d6fb218afe741 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Fri, 18 Mar 2016 01:37:45 -0700 Subject: [PATCH 06/60] chore(webpack): remove `.jsx` extension --- webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webpack.config.js b/webpack.config.js index 59cbd04..3d898ff 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -20,7 +20,7 @@ module.exports = { }] }, resolve: { - extensions: ['', '.js', '.jsx'] + extensions: ['', '.js'] }, plugins: [ new webpack.optimize.DedupePlugin(), From c21c8307cc271eab4e60e6a8178b473fc69303f7 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Fri, 18 Mar 2016 01:38:59 -0700 Subject: [PATCH 07/60] chore(webpack): use `include` property instead of `exclude` --- webpack.config.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/webpack.config.js b/webpack.config.js index 3d898ff..40f6d60 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,4 +1,5 @@ var webpack = require("webpack"); +var path = require('path'); module.exports = { context: __dirname, @@ -12,7 +13,9 @@ module.exports = { loaders: [{ test: /\.js$/, loader: 'babel-loader', - exclude: /(bower_components|node_modules)/, + include: [ + path.resolve(__dirname, 'src') + ], query: { plugins: ['transform-runtime'], presets: ['es2015'] From d58ef264d6db51ab980eea1b92434f4ab23564f1 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Fri, 18 Mar 2016 01:39:21 -0700 Subject: [PATCH 08/60] chore(webpack): use single quotes --- webpack.config.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 40f6d60..9e63069 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,12 +1,12 @@ -var webpack = require("webpack"); +var webpack = require('webpack'); var path = require('path'); module.exports = { context: __dirname, entry: './src/index.js', output: { - libraryTarget: "umd", - library: "Montage", + libraryTarget: 'umd', + library: 'Montage', filename: './dist/montage.js' }, module: { From caed1870d2e1c2a8572a3528ab7ed3c1c3739a63 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Fri, 18 Mar 2016 01:52:20 -0700 Subject: [PATCH 09/60] style(index): use tabs instead of spaces for indentation --- src/index.js | 489 +++++++++++++++++++++++++++------------------------ 1 file changed, 258 insertions(+), 231 deletions(-) diff --git a/src/index.js b/src/index.js index 169cbe6..27d5d92 100644 --- a/src/index.js +++ b/src/index.js @@ -10,241 +10,268 @@ import _ from 'lodash'; * @return int */ export function getByteLen(normal_val) { - // Force string type - normal_val = String(normal_val); - - var byteLen = 0; - for (var i = 0; i < normal_val.length; i++) { - var c = normal_val.charCodeAt(i); - byteLen += c < (1 << 7) ? 1 : - c < (1 << 11) ? 2 : - c < (1 << 16) ? 3 : - c < (1 << 21) ? 4 : - c < (1 << 26) ? 5 : - c < (1 << 31) ? 6 : Number.NaN; - } - return byteLen; + // Force string type + normal_val = String(normal_val); + + var byteLen = 0; + for (var i = 0; i < normal_val.length; i++) { + var c = normal_val.charCodeAt(i); + byteLen += c < (1 << 7) ? 1 : + c < (1 << 11) ? 2 : + c < (1 << 16) ? 3 : + c < (1 << 21) ? 4 : + c < (1 << 26) ? 5 : + c < (1 << 31) ? 6 : Number.NaN; + } + return byteLen; } export class Client { - constructor(params = {}) { - params.api_version = params.api_version || 1; - this.params = params; - if (this.params.url) { - this.url_prefix = this.params.url; - } else if (this.params.dev) { - this.url_prefix = `http://${params.domain}.dev.montagehot.club/api/v${params.api_version}/`; - } else { - this.url_prefix = `https://${params.domain}.mntge.com/api/v${params.api_version}/`; - } - } - schemas() { - return this.request(`schemas/`); - } - schema(name) { - return this.request(`schemas/${name}/`); - } - files(formData) { - return this.request(`files/`,'POST', formData, true); - } - documents(queries) { - return this.request(`query/`, 'POST', queries) - } - document(schema, document_uuid) { - var documentQuery = { - '$schema': schema, - '$query': [['$get', document_uuid]] - }; - - return this.request(`query/`, 'POST', { query: documentQuery }); - } - document_cursor(schema, cursor) { - var params = {cursor}; - return this.request(`schemas/${schema}/`, "GET", params); - } - //*paginated_documents(schema, query) { - // //yields promises - - // var cursor; - - // function onResponse(response) { - // cursor = response.cursors ? response.cursors.next : null; - // return response.data; - // } - - // yield this.documents(schema, query).then(onResponse); - - // while (cursor) { - // yield this.document_cursor(schema, cursor).then(onResponse); - // } - //} - create_document(schema, document) { - return this.create_documents(schema, [document]); - } - create_documents(schema, documents) { - return this.request(`schemas/${schema}/save/`, "POST", documents); - } - update_document(schema, document_uuid, document) { - return this.request(`schemas/${schema}/${document_uuid}/`, "POST", document); - } - delete_document(schema, document_uuid) { - return this.request(`schemas/${schema}/${document_uuid}/`, "DELETE"); - } - auth() { - return this.request("auth/", "POST", { - username: this.params.username, - password: this.params.password, - }).then(response => { - this.params.token = response.data.token; - return response; - }); - } - request(url, method, data, file) { - var options = { - method: method && method.toUpperCase() || "GET", - headers: { - accept: 'application/json', - 'X-Requested-With': 'XMLHttpRequest', - } - } - if (!file) { - options.headers['Content-Type'] = 'application/json'; - } - if (data) { - if (options.method === "GET") { - url += '?' + querystring.stringify(data); - } else { - if(file) options.body = data - else options.body = JSON.stringify(data); - } - } - if (this.params.token) { - options.headers.Authorization = `Token ${this.params.token}`; - } - if (options.body) { - //Varnish and heroku require a content length! - options.headers['Content-Length'] = getByteLen(options.body); - } - var reqUrl = `${this.url_prefix}${url}` - return this._agent(reqUrl, options).then(function(response) { - if (!response.ok) { - response.request = _.merge({ - url: reqUrl, - }, options); - return Promise.reject(response); - } - if (response.status >= 400) { - return response.text().then(body => { - var errorMessage = body || response.statusText; - try { - errorMessage = JSON.parse(body); - } catch (e) {} - return Promise.reject(errorMessage); - }); - } - return response.json(); - }).then(function(payload) { - if (payload && payload.errors) { - return Promise.reject(payload.errors); - } - return payload; - }); - } - _agent(...args) { - return fetch(...args); - } - // TODO files api + constructor(params = {}) { + params.api_version = params.api_version || 1; + this.params = params; + if (this.params.url) { + this.url_prefix = this.params.url; + } else if (this.params.dev) { + this.url_prefix = `http://${params.domain}.dev.montagehot.club/api/v${params.api_version}/`; + } else { + this.url_prefix = `https://${params.domain}.mntge.com/api/v${params.api_version}/`; + } + } + + schemas() { + return this.request(`schemas/`); + } + + schema(name) { + return this.request(`schemas/${name}/`); + } + + files(formData) { + return this.request(`files/`,'POST', formData, true); + } + + documents(queries) { + return this.request(`query/`, 'POST', queries) + } + + document(schema, document_uuid) { + var documentQuery = { + '$schema': schema, + '$query': [['$get', document_uuid]] + }; + + return this.request(`query/`, 'POST', { query: documentQuery }); + } + + document_cursor(schema, cursor) { + var params = {cursor}; + return this.request(`schemas/${schema}/`, "GET", params); + } + + //*paginated_documents(schema, query) { + // //yields promises + + // var cursor; + + // function onResponse(response) { + // cursor = response.cursors ? response.cursors.next : null; + // return response.data; + // } + + // yield this.documents(schema, query).then(onResponse); + + // while (cursor) { + // yield this.document_cursor(schema, cursor).then(onResponse); + // } + //} + create_document(schema, document) { + return this.create_documents(schema, [document]); + } + + create_documents(schema, documents) { + return this.request(`schemas/${schema}/save/`, "POST", documents); + } + + update_document(schema, document_uuid, document) { + return this.request(`schemas/${schema}/${document_uuid}/`, "POST", document); + } + + delete_document(schema, document_uuid) { + return this.request(`schemas/${schema}/${document_uuid}/`, "DELETE"); + } + + auth() { + return this.request("auth/", "POST", { + username: this.params.username, + password: this.params.password, + }).then(response => { + this.params.token = response.data.token; + return response; + }); + } + + request(url, method, data, file) { + var options = { + method: method && method.toUpperCase() || "GET", + headers: { + accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + } + } + if (!file) { + options.headers['Content-Type'] = 'application/json'; + } + if (data) { + if (options.method === "GET") { + url += '?' + querystring.stringify(data); + } else { + if(file) options.body = data + else options.body = JSON.stringify(data); + } + } + if (this.params.token) { + options.headers.Authorization = `Token ${this.params.token}`; + } + if (options.body) { + //Varnish and heroku require a content length! + options.headers['Content-Length'] = getByteLen(options.body); + } + var reqUrl = `${this.url_prefix}${url}` + return this._agent(reqUrl, options).then(function(response) { + if (!response.ok) { + response.request = _.merge({ + url: reqUrl, + }, options); + return Promise.reject(response); + } + if (response.status >= 400) { + return response.text().then(body => { + var errorMessage = body || response.statusText; + try { + errorMessage = JSON.parse(body); + } catch (e) {} + return Promise.reject(errorMessage); + }); + } + return response.json(); + }).then(function(payload) { + if (payload && payload.errors) { + return Promise.reject(payload.errors); + } + return payload; + }); + } + + _agent(...args) { + return fetch(...args); + } + + // TODO files api } export class Query { - constructor(schemaName, state) { - if (!schemaName) throw "Schema name is required"; - - this.schemaName = schemaName; - - state = state || { - '$schema': schemaName, - '$query': [ - ['$filter', []] - ] - } - this._state = state; - } - _merge(delta) { - var state = _.merge({}, this._state, delta); - return new Query(this.schemaName, state); - } - _mergeArray(delta, prepend = false) { - var index = _.findIndex(this._state['$query'], (item) => { - return item[0] === delta[0]; - }); - - if (index !== -1) { - this._state['$query'][index] = delta; - } else { - if (prepend) { - this._state['$query'].unshift(delta); - } else { - this._state['$query'].push(delta); - } - } - - return new Query(this.schemaName, this._state); - } - limit(num) { - return this._mergeArray(['$limit', num]); - } - offset(num) { - return this._mergeArray(['$offset', num]); - } - order(order_by, ordering) { - var parsedOrder; - if(_.isString(ordering)) { - parsedOrder = `$${ordering}`; - } else { - parsedOrder = ordering < 0 ? "$desc" : "$asc"; - } - - return this._mergeArray(['$order_by', [parsedOrder, order_by]]); - } - pluck(fields) { - return this._mergeArray(['$pluck', fields]); - } - without(fields) { - return this._mergeArray(['$without', fields]); - } - pageSize(size) { - return this._mergeArray(['$limit', size]); - } - index(indexName) { - return this._mergeArray(['$index', indexName]); - } - filter(params) { - var filterIndex = _.findIndex(this._state['$query'], (item) => { - return item[0] === '$filter'; - }); - var filters = this._state['$query'][filterIndex]; - - Object.keys(params).forEach((key) => { - var [field, operator] = key.split("__"); - var queryField = operator ? [`$${operator}`, params[key]] : params[key]; - - filters[1].push([field, queryField]); - }) - - return this._mergeArray(filters); - } - where(params) { - //alias - return this.filter(params); - } - between(params) { - if (params && params.from && params.to) { - return this._mergeArray(['$between', [params.from, params.to, params.index]], true) - } - return this; - } - toJS() { - return this._state; - } + constructor(schemaName, state) { + if (!schemaName) throw "Schema name is required"; + + this.schemaName = schemaName; + + state = state || { + '$schema': schemaName, + '$query': [ + ['$filter', []] + ] + } + this._state = state; + } + + _merge(delta) { + var state = _.merge({}, this._state, delta); + return new Query(this.schemaName, state); + } + + _mergeArray(delta, prepend = false) { + var index = _.findIndex(this._state['$query'], (item) => { + return item[0] === delta[0]; + }); + + if (index !== -1) { + this._state['$query'][index] = delta; + } else { + if (prepend) { + this._state['$query'].unshift(delta); + } else { + this._state['$query'].push(delta); + } + } + + return new Query(this.schemaName, this._state); + } + + limit(num) { + return this._mergeArray(['$limit', num]); + } + + offset(num) { + return this._mergeArray(['$offset', num]); + } + + order(order_by, ordering) { + var parsedOrder; + if(_.isString(ordering)) { + parsedOrder = `$${ordering}`; + } else { + parsedOrder = ordering < 0 ? "$desc" : "$asc"; + } + + return this._mergeArray(['$order_by', [parsedOrder, order_by]]); + } + + pluck(fields) { + return this._mergeArray(['$pluck', fields]); + } + + without(fields) { + return this._mergeArray(['$without', fields]); + } + + pageSize(size) { + return this._mergeArray(['$limit', size]); + } + + index(indexName) { + return this._mergeArray(['$index', indexName]); + } + + filter(params) { + var filterIndex = _.findIndex(this._state['$query'], (item) => { + return item[0] === '$filter'; + }); + var filters = this._state['$query'][filterIndex]; + + Object.keys(params).forEach((key) => { + var [field, operator] = key.split("__"); + var queryField = operator ? [`$${operator}`, params[key]] : params[key]; + + filters[1].push([field, queryField]); + }) + + return this._mergeArray(filters); + } + + where(params) { + //alias + return this.filter(params); + } + + between(params) { + if (params && params.from && params.to) { + return this._mergeArray(['$between', [params.from, params.to, params.index]], true) + } + return this; + } + + toJS() { + return this._state; + } } From f521a8f2e35e88fd4339c2f0a416afbf3ca3b344 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Fri, 18 Mar 2016 01:56:30 -0700 Subject: [PATCH 10/60] docs(index): add reference link to `getByteLen()` --- src/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/index.js b/src/index.js index 27d5d92..9140861 100644 --- a/src/index.js +++ b/src/index.js @@ -6,6 +6,8 @@ import _ from 'lodash'; /** * Count bytes in a string's UTF-8 representation. * + * [Reference]{@link http://codereview.stackexchange.com/a/37552} + * * @param string * @return int */ From 263fae6cf8be468a367da9177f2f9016959c45fe Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Fri, 18 Mar 2016 01:57:35 -0700 Subject: [PATCH 11/60] docs(index): correct jsdoc for `getByteLen()` --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 9140861..7338e83 100644 --- a/src/index.js +++ b/src/index.js @@ -8,8 +8,8 @@ import _ from 'lodash'; * * [Reference]{@link http://codereview.stackexchange.com/a/37552} * - * @param string - * @return int + * @param {string} normal_val + * @return {int} */ export function getByteLen(normal_val) { // Force string type From de1afb473ed6893a746d4e13d2561c2749bc9d34 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Fri, 18 Mar 2016 02:08:37 -0700 Subject: [PATCH 12/60] feat(api): add `DocumentsAPI` --- src/api.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/api.js diff --git a/src/api.js b/src/api.js new file mode 100644 index 0000000..03eb201 --- /dev/null +++ b/src/api.js @@ -0,0 +1,35 @@ +export class DocumentsAPI { + constructor(client) { + this.client = client; + } + + list(schema) { + const endpoint = `schemas/${schema}/documents/`; + return this.client.request(endpoint); + } + + save(schema, documents) { + const endpoint = `schemas/${schema}/documents/`; + return this.client.request(endpoint, 'POST', documents); + } + + get(schema, document_id) { + const endpoint = `schemas/${schema}/documents/${document_id}/`; + return this.client.request(endpoint); + } + + replace(schema, document) { + const endpoint = `schemas/${schema}/documents/${document.id}/`; + return this.client.request(endpoint, 'PUT', document); + } + + update(schema, document) { + const endpoint = `schemas/${schema}/documents/${document.id}/`; + return this.client.request(endpoint, 'PATCH', document); + } + + remove(schema, document_id) { + const endpoint = `schemas/${schema}/documents/${document_id}/`; + return this.client.request(endpoint, 'DELETE'); + } +} From abd93205254af28049691e4e3f4cc7e94a8412fc Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Fri, 18 Mar 2016 02:13:38 -0700 Subject: [PATCH 13/60] feat(Client): replace document methods with an instance of `DocumentsAPI` --- src/index.js | 53 +++------------------------------------------------- 1 file changed, 3 insertions(+), 50 deletions(-) diff --git a/src/index.js b/src/index.js index 7338e83..055ac68 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,7 @@ import fetch from 'isomorphic-fetch'; import querystring from 'querystring'; import _ from 'lodash'; +import { DocumentsAPI } from './api'; /** @@ -39,6 +40,8 @@ export class Client { } else { this.url_prefix = `https://${params.domain}.mntge.com/api/v${params.api_version}/`; } + + this.documents = new DocumentsAPI(this); } schemas() { @@ -53,56 +56,6 @@ export class Client { return this.request(`files/`,'POST', formData, true); } - documents(queries) { - return this.request(`query/`, 'POST', queries) - } - - document(schema, document_uuid) { - var documentQuery = { - '$schema': schema, - '$query': [['$get', document_uuid]] - }; - - return this.request(`query/`, 'POST', { query: documentQuery }); - } - - document_cursor(schema, cursor) { - var params = {cursor}; - return this.request(`schemas/${schema}/`, "GET", params); - } - - //*paginated_documents(schema, query) { - // //yields promises - - // var cursor; - - // function onResponse(response) { - // cursor = response.cursors ? response.cursors.next : null; - // return response.data; - // } - - // yield this.documents(schema, query).then(onResponse); - - // while (cursor) { - // yield this.document_cursor(schema, cursor).then(onResponse); - // } - //} - create_document(schema, document) { - return this.create_documents(schema, [document]); - } - - create_documents(schema, documents) { - return this.request(`schemas/${schema}/save/`, "POST", documents); - } - - update_document(schema, document_uuid, document) { - return this.request(`schemas/${schema}/${document_uuid}/`, "POST", document); - } - - delete_document(schema, document_uuid) { - return this.request(`schemas/${schema}/${document_uuid}/`, "DELETE"); - } - auth() { return this.request("auth/", "POST", { username: this.params.username, From ea045a724652372cdcdf74274d41713381c669e7 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Fri, 18 Mar 2016 02:36:08 -0700 Subject: [PATCH 14/60] feat(SchemaAPI): add `SchemaAPI` --- src/api.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/api.js b/src/api.js index 03eb201..1da56c0 100644 --- a/src/api.js +++ b/src/api.js @@ -33,3 +33,42 @@ export class DocumentsAPI { return this.client.request(endpoint, 'DELETE'); } } + +export class SchemaAPI { + constructor(client) { + this.client = client; + } + + create(name, fields = []) { + const payload = { name, fields }; + return this.client.request('schemas/', 'POST', payload); + } + + list() { + return this.client.request('schemas/'); + } + + get(schema) { + return this.client.request(`schemas/${schema}/`); + } + + update(schema, name, fields) { + var payload = {}; + + if (name) { + payload.name = name; + } + + if (fields) { + payload.fields = fields; + } + + if (Object.keys(payload).length) { + return this.client.request(`schemas/${schema}/`, 'PATCH', payload); + } + } + + remove(schema) { + return this.client.request(`schemas/${schema}/`, 'DELETE'); + } +} From ec23afe31a7e2acc0ad72bb080a46568afe279af Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Fri, 18 Mar 2016 02:39:11 -0700 Subject: [PATCH 15/60] feat(Client): replace schema methods with an instance of `SchemaAPI` --- src/index.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/index.js b/src/index.js index 055ac68..f96ed58 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,7 @@ import fetch from 'isomorphic-fetch'; import querystring from 'querystring'; import _ from 'lodash'; -import { DocumentsAPI } from './api'; +import { DocumentsAPI, SchemaAPI } from './api'; /** @@ -42,14 +42,7 @@ export class Client { } this.documents = new DocumentsAPI(this); - } - - schemas() { - return this.request(`schemas/`); - } - - schema(name) { - return this.request(`schemas/${name}/`); + this.schemas = new SchemaAPI(this); } files(formData) { From fc2b1c7c7ed6d6d8ee6390455788a525d65c5a77 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Fri, 18 Mar 2016 02:54:51 -0700 Subject: [PATCH 16/60] feat(UserAPI): add `UserAPI` --- src/api.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/api.js b/src/api.js index 1da56c0..76002dc 100644 --- a/src/api.js +++ b/src/api.js @@ -72,3 +72,46 @@ export class SchemaAPI { return this.client.request(`schemas/${schema}/`, 'DELETE'); } } + +export class UserAPI { + constructor(client) { + this.client = client + } + + list() { + return this.client.request('users/'); + } + + create(full_name, email, password) { + const payload = { full_name, email, password }; + return this.client.request('users/', 'POST', payload) + } + + get(user_id) { + return this.client.request(`users/${user_id}/`); + } + + update(user_id, full_name, email, password) { + var payload = {}; + + if (full_name) { + payload.full_name = full_name; + } + + if (email) { + payload.email = email; + } + + if (password) { + payload.password = password; + } + + if (Object.keys(payload).length) { + return this.client.request(`users/${user_id}/`, 'PATCH', payload); + } + } + + remove(user_id) { + return this.client.request(`users/${user_id}/`, 'DELETE'); + } +} From bf9dcfdaf64796035753b596dcf622b261c1462c Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Fri, 18 Mar 2016 02:56:32 -0700 Subject: [PATCH 17/60] feat(Client): add an instance of the `UserAPI` as a property of `Client` --- src/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index f96ed58..a1708bb 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,7 @@ import fetch from 'isomorphic-fetch'; import querystring from 'querystring'; import _ from 'lodash'; -import { DocumentsAPI, SchemaAPI } from './api'; +import { DocumentsAPI, SchemaAPI, UserAPI } from './api'; /** @@ -43,6 +43,7 @@ export class Client { this.documents = new DocumentsAPI(this); this.schemas = new SchemaAPI(this); + this.users = new UserAPI(this); } files(formData) { From 5374f0748b672a15c64e20ca04acb9fdabd71002 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Fri, 18 Mar 2016 03:03:27 -0700 Subject: [PATCH 18/60] feat(RoleAPI): add `RoleAPI` --- src/api.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/api.js b/src/api.js index 76002dc..cb1f79f 100644 --- a/src/api.js +++ b/src/api.js @@ -115,3 +115,46 @@ export class UserAPI { return this.client.request(`users/${user_id}/`, 'DELETE'); } } + +export class RoleAPI { + constructor(client) { + this.client = client; + } + + create(name, add_users = []) { + const payload = { name, add_users }; + return this.client.request(`roles/`, 'POST', payload); + } + + list() { + return this.client.request(`roles/`); + } + + get(role) { + return this.client.request(`roles/${role}/`); + } + + update(role, name, add_users, remove_users) { + var payload = {}; + + if (name) { + payload.name = name; + } + + if (add_users) { + payload.add_users = add_users; + } + + if (remove_users) { + payload.remove_users = remove_users; + } + + if (Object.keys(payload).length) { + return this.client.request(`roles/${role}/`, 'PATCH', payload); + } + } + + remove(role) { + return this.client.request(`roles/${role}/`, 'DELETE'); + } +} From f3f9eabb3b26e662086cd23f5b9b3dddd2324698 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Fri, 18 Mar 2016 03:04:15 -0700 Subject: [PATCH 19/60] feat(Client): add an instance of the `RoleAPI` as a property of `Client` --- src/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index a1708bb..56b2ce1 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,7 @@ import fetch from 'isomorphic-fetch'; import querystring from 'querystring'; import _ from 'lodash'; -import { DocumentsAPI, SchemaAPI, UserAPI } from './api'; +import { DocumentsAPI, SchemaAPI, UserAPI, RoleAPI } from './api'; /** @@ -44,6 +44,7 @@ export class Client { this.documents = new DocumentsAPI(this); this.schemas = new SchemaAPI(this); this.users = new UserAPI(this); + this.roles = new RoleAPI(this); } files(formData) { From 80029f979b60d1a89da010e33a5c5bda07bd0a63 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Fri, 18 Mar 2016 03:44:26 -0700 Subject: [PATCH 20/60] feat(FileAPI): add `FileAPI` --- src/api.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/api.js b/src/api.js index cb1f79f..79f1996 100644 --- a/src/api.js +++ b/src/api.js @@ -34,6 +34,29 @@ export class DocumentsAPI { } } +export class FileAPI { + constructor(client) { + this.client = client; + } + + list() { + return this.client.request('files/'); + } + + get(file_id) { + return this.client.request(`files/${file_id}/`); + } + + remove(file_id) { + const endpoint = `files/${file_id}/`; + return this.client.request(endpoint, 'DELETE'); + } + + save(formData) { + return this.client.request('files/', 'POST', formData, true); + } +} + export class SchemaAPI { constructor(client) { this.client = client; From d167c6ec8f9695d45fdd0490d579656114d9e3ab Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sat, 2 Apr 2016 14:21:44 -0700 Subject: [PATCH 21/60] refactor(getByteLen): don't export `getByteLen` --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 56b2ce1..a494df0 100644 --- a/src/index.js +++ b/src/index.js @@ -12,7 +12,7 @@ import { DocumentsAPI, SchemaAPI, UserAPI, RoleAPI } from './api'; * @param {string} normal_val * @return {int} */ -export function getByteLen(normal_val) { +function getByteLen(normal_val) { // Force string type normal_val = String(normal_val); From a210d5e252e9ea3d23af82a7348de64c87da7c4e Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sat, 2 Apr 2016 14:27:22 -0700 Subject: [PATCH 22/60] feat(Client): don't attempt to parse JSON when the HTTP status is 204 (No Content) --- src/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/index.js b/src/index.js index a494df0..6c67283 100644 --- a/src/index.js +++ b/src/index.js @@ -89,6 +89,9 @@ export class Client { } var reqUrl = `${this.url_prefix}${url}` return this._agent(reqUrl, options).then(function(response) { + if(response.status === 204) { + return; + } if (!response.ok) { response.request = _.merge({ url: reqUrl, From 4e8185bf57e88e4c71456a73878cd7d13dd64fad Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sat, 2 Apr 2016 14:47:10 -0700 Subject: [PATCH 23/60] feat(Client): add an instance of the `FileAPI` to `Client` --- src/index.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/index.js b/src/index.js index 6c67283..2e12860 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,7 @@ import fetch from 'isomorphic-fetch'; import querystring from 'querystring'; import _ from 'lodash'; -import { DocumentsAPI, SchemaAPI, UserAPI, RoleAPI } from './api'; +import { DocumentsAPI, SchemaAPI, UserAPI, RoleAPI, FileAPI } from './api'; /** @@ -45,10 +45,7 @@ export class Client { this.schemas = new SchemaAPI(this); this.users = new UserAPI(this); this.roles = new RoleAPI(this); - } - - files(formData) { - return this.request(`files/`,'POST', formData, true); + this.files = new FileAPI(this); } auth() { @@ -119,8 +116,6 @@ export class Client { _agent(...args) { return fetch(...args); } - - // TODO files api } export class Query { From ed7e3377ed699625b3685a10a39c8c32e8a70f52 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sat, 2 Apr 2016 14:54:59 -0700 Subject: [PATCH 24/60] refactor(DocumentsAPI): move `DocumentsAPI` into its own file --- src/api.js | 36 ------------------------------------ src/api/documents.js | 35 +++++++++++++++++++++++++++++++++++ src/index.js | 4 ++-- 3 files changed, 37 insertions(+), 38 deletions(-) create mode 100644 src/api/documents.js diff --git a/src/api.js b/src/api.js index 79f1996..bf1e597 100644 --- a/src/api.js +++ b/src/api.js @@ -1,39 +1,3 @@ -export class DocumentsAPI { - constructor(client) { - this.client = client; - } - - list(schema) { - const endpoint = `schemas/${schema}/documents/`; - return this.client.request(endpoint); - } - - save(schema, documents) { - const endpoint = `schemas/${schema}/documents/`; - return this.client.request(endpoint, 'POST', documents); - } - - get(schema, document_id) { - const endpoint = `schemas/${schema}/documents/${document_id}/`; - return this.client.request(endpoint); - } - - replace(schema, document) { - const endpoint = `schemas/${schema}/documents/${document.id}/`; - return this.client.request(endpoint, 'PUT', document); - } - - update(schema, document) { - const endpoint = `schemas/${schema}/documents/${document.id}/`; - return this.client.request(endpoint, 'PATCH', document); - } - - remove(schema, document_id) { - const endpoint = `schemas/${schema}/documents/${document_id}/`; - return this.client.request(endpoint, 'DELETE'); - } -} - export class FileAPI { constructor(client) { this.client = client; diff --git a/src/api/documents.js b/src/api/documents.js new file mode 100644 index 0000000..8fbb5c3 --- /dev/null +++ b/src/api/documents.js @@ -0,0 +1,35 @@ +export default class DocumentsAPI { + constructor(client) { + this.client = client; + } + + list(schema) { + const endpoint = `schemas/${schema}/documents/`; + return this.client.request(endpoint); + } + + save(schema, documents) { + const endpoint = `schemas/${schema}/documents/`; + return this.client.request(endpoint, 'POST', documents); + } + + get(schema, document_id) { + const endpoint = `schemas/${schema}/documents/${document_id}/`; + return this.client.request(endpoint); + } + + replace(schema, document) { + const endpoint = `schemas/${schema}/documents/${document.id}/`; + return this.client.request(endpoint, 'PUT', document); + } + + update(schema, document) { + const endpoint = `schemas/${schema}/documents/${document.id}/`; + return this.client.request(endpoint, 'PATCH', document); + } + + remove(schema, document_id) { + const endpoint = `schemas/${schema}/documents/${document_id}/`; + return this.client.request(endpoint, 'DELETE'); + } +} diff --git a/src/index.js b/src/index.js index 2e12860..cd067a4 100644 --- a/src/index.js +++ b/src/index.js @@ -1,8 +1,8 @@ import fetch from 'isomorphic-fetch'; import querystring from 'querystring'; import _ from 'lodash'; -import { DocumentsAPI, SchemaAPI, UserAPI, RoleAPI, FileAPI } from './api'; - +import { SchemaAPI, UserAPI, RoleAPI, FileAPI } from './api'; +import DocumentsAPI from './api/documents'; /** * Count bytes in a string's UTF-8 representation. From e54176f10e4c05bec24df6f593904158bb490b7b Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sat, 2 Apr 2016 14:56:54 -0700 Subject: [PATCH 25/60] refactor(FileAPI): move `FileAPI` into its own file --- src/api.js | 23 ----------------------- src/api/file.js | 22 ++++++++++++++++++++++ src/index.js | 3 ++- 3 files changed, 24 insertions(+), 24 deletions(-) create mode 100644 src/api/file.js diff --git a/src/api.js b/src/api.js index bf1e597..7ecc4b6 100644 --- a/src/api.js +++ b/src/api.js @@ -1,26 +1,3 @@ -export class FileAPI { - constructor(client) { - this.client = client; - } - - list() { - return this.client.request('files/'); - } - - get(file_id) { - return this.client.request(`files/${file_id}/`); - } - - remove(file_id) { - const endpoint = `files/${file_id}/`; - return this.client.request(endpoint, 'DELETE'); - } - - save(formData) { - return this.client.request('files/', 'POST', formData, true); - } -} - export class SchemaAPI { constructor(client) { this.client = client; diff --git a/src/api/file.js b/src/api/file.js new file mode 100644 index 0000000..08645d1 --- /dev/null +++ b/src/api/file.js @@ -0,0 +1,22 @@ +export default class FileAPI { + constructor(client) { + this.client = client; + } + + list() { + return this.client.request('files/'); + } + + get(file_id) { + return this.client.request(`files/${file_id}/`); + } + + remove(file_id) { + const endpoint = `files/${file_id}/`; + return this.client.request(endpoint, 'DELETE'); + } + + save(formData) { + return this.client.request('files/', 'POST', formData, true); + } +} diff --git a/src/index.js b/src/index.js index cd067a4..83f2002 100644 --- a/src/index.js +++ b/src/index.js @@ -1,8 +1,9 @@ import fetch from 'isomorphic-fetch'; import querystring from 'querystring'; import _ from 'lodash'; -import { SchemaAPI, UserAPI, RoleAPI, FileAPI } from './api'; +import { SchemaAPI, UserAPI, RoleAPI } from './api'; import DocumentsAPI from './api/documents'; +import FileAPI from './api/file'; /** * Count bytes in a string's UTF-8 representation. From a141b0188306ffd8e4f07a3f0e9aa220aeaa124e Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sat, 2 Apr 2016 14:58:32 -0700 Subject: [PATCH 26/60] refactor(SchemaAPI): move `SchemaAPI` into its own file --- src/api.js | 39 --------------------------------------- src/api/schema.js | 38 ++++++++++++++++++++++++++++++++++++++ src/index.js | 3 ++- 3 files changed, 40 insertions(+), 40 deletions(-) create mode 100644 src/api/schema.js diff --git a/src/api.js b/src/api.js index 7ecc4b6..ca5616d 100644 --- a/src/api.js +++ b/src/api.js @@ -1,42 +1,3 @@ -export class SchemaAPI { - constructor(client) { - this.client = client; - } - - create(name, fields = []) { - const payload = { name, fields }; - return this.client.request('schemas/', 'POST', payload); - } - - list() { - return this.client.request('schemas/'); - } - - get(schema) { - return this.client.request(`schemas/${schema}/`); - } - - update(schema, name, fields) { - var payload = {}; - - if (name) { - payload.name = name; - } - - if (fields) { - payload.fields = fields; - } - - if (Object.keys(payload).length) { - return this.client.request(`schemas/${schema}/`, 'PATCH', payload); - } - } - - remove(schema) { - return this.client.request(`schemas/${schema}/`, 'DELETE'); - } -} - export class UserAPI { constructor(client) { this.client = client diff --git a/src/api/schema.js b/src/api/schema.js new file mode 100644 index 0000000..be0f80e --- /dev/null +++ b/src/api/schema.js @@ -0,0 +1,38 @@ +export default class SchemaAPI { + constructor(client) { + this.client = client; + } + + create(name, fields = []) { + const payload = { name, fields }; + return this.client.request('schemas/', 'POST', payload); + } + + list() { + return this.client.request('schemas/'); + } + + get(schema) { + return this.client.request(`schemas/${schema}/`); + } + + update(schema, name, fields) { + var payload = {}; + + if (name) { + payload.name = name; + } + + if (fields) { + payload.fields = fields; + } + + if (Object.keys(payload).length) { + return this.client.request(`schemas/${schema}/`, 'PATCH', payload); + } + } + + remove(schema) { + return this.client.request(`schemas/${schema}/`, 'DELETE'); + } +} diff --git a/src/index.js b/src/index.js index 83f2002..f8d0429 100644 --- a/src/index.js +++ b/src/index.js @@ -1,9 +1,10 @@ import fetch from 'isomorphic-fetch'; import querystring from 'querystring'; import _ from 'lodash'; -import { SchemaAPI, UserAPI, RoleAPI } from './api'; +import { UserAPI, RoleAPI } from './api'; import DocumentsAPI from './api/documents'; import FileAPI from './api/file'; +import SchemaAPI from './api/schema'; /** * Count bytes in a string's UTF-8 representation. From 975100b36d0e1bb977f8d176e232b88b65712f43 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sat, 2 Apr 2016 14:59:43 -0700 Subject: [PATCH 27/60] refactor(UserAPI): move `UserAPI` into its own file --- src/api.js | 43 ------------------------------------------- src/api/user.js | 42 ++++++++++++++++++++++++++++++++++++++++++ src/index.js | 3 ++- 3 files changed, 44 insertions(+), 44 deletions(-) create mode 100644 src/api/user.js diff --git a/src/api.js b/src/api.js index ca5616d..14adf73 100644 --- a/src/api.js +++ b/src/api.js @@ -1,46 +1,3 @@ -export class UserAPI { - constructor(client) { - this.client = client - } - - list() { - return this.client.request('users/'); - } - - create(full_name, email, password) { - const payload = { full_name, email, password }; - return this.client.request('users/', 'POST', payload) - } - - get(user_id) { - return this.client.request(`users/${user_id}/`); - } - - update(user_id, full_name, email, password) { - var payload = {}; - - if (full_name) { - payload.full_name = full_name; - } - - if (email) { - payload.email = email; - } - - if (password) { - payload.password = password; - } - - if (Object.keys(payload).length) { - return this.client.request(`users/${user_id}/`, 'PATCH', payload); - } - } - - remove(user_id) { - return this.client.request(`users/${user_id}/`, 'DELETE'); - } -} - export class RoleAPI { constructor(client) { this.client = client; diff --git a/src/api/user.js b/src/api/user.js new file mode 100644 index 0000000..bd58f6c --- /dev/null +++ b/src/api/user.js @@ -0,0 +1,42 @@ +export default class UserAPI { + constructor(client) { + this.client = client + } + + list() { + return this.client.request('users/'); + } + + create(full_name, email, password) { + const payload = { full_name, email, password }; + return this.client.request('users/', 'POST', payload) + } + + get(user_id) { + return this.client.request(`users/${user_id}/`); + } + + update(user_id, full_name, email, password) { + var payload = {}; + + if (full_name) { + payload.full_name = full_name; + } + + if (email) { + payload.email = email; + } + + if (password) { + payload.password = password; + } + + if (Object.keys(payload).length) { + return this.client.request(`users/${user_id}/`, 'PATCH', payload); + } + } + + remove(user_id) { + return this.client.request(`users/${user_id}/`, 'DELETE'); + } +} diff --git a/src/index.js b/src/index.js index f8d0429..53b5e36 100644 --- a/src/index.js +++ b/src/index.js @@ -1,10 +1,11 @@ import fetch from 'isomorphic-fetch'; import querystring from 'querystring'; import _ from 'lodash'; -import { UserAPI, RoleAPI } from './api'; +import { RoleAPI } from './api'; import DocumentsAPI from './api/documents'; import FileAPI from './api/file'; import SchemaAPI from './api/schema'; +import UserAPI from './api/user'; /** * Count bytes in a string's UTF-8 representation. From 90cf5d4562e9b957159370647a63bf94a216f27e Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sat, 2 Apr 2016 15:01:35 -0700 Subject: [PATCH 28/60] refactor(RoleAPI): move `RoleAPI` into the `api` directory --- src/{api.js => api/role.js} | 2 +- src/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/{api.js => api/role.js} (95%) diff --git a/src/api.js b/src/api/role.js similarity index 95% rename from src/api.js rename to src/api/role.js index 14adf73..95bc1c2 100644 --- a/src/api.js +++ b/src/api/role.js @@ -1,4 +1,4 @@ -export class RoleAPI { +export default class RoleAPI { constructor(client) { this.client = client; } diff --git a/src/index.js b/src/index.js index 53b5e36..30f3827 100644 --- a/src/index.js +++ b/src/index.js @@ -1,9 +1,9 @@ import fetch from 'isomorphic-fetch'; import querystring from 'querystring'; import _ from 'lodash'; -import { RoleAPI } from './api'; import DocumentsAPI from './api/documents'; import FileAPI from './api/file'; +import RoleAPI from './api/role'; import SchemaAPI from './api/schema'; import UserAPI from './api/user'; From bb480f7c819c53d6bda57ebde4f04421b96d3043 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sat, 2 Apr 2016 15:09:55 -0700 Subject: [PATCH 29/60] refactor(index): export an object with `Client` and `Query` as properties instead of exporting the classes directly --- src/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 30f3827..2ae8129 100644 --- a/src/index.js +++ b/src/index.js @@ -32,7 +32,7 @@ function getByteLen(normal_val) { return byteLen; } -export class Client { +class Client { constructor(params = {}) { params.api_version = params.api_version || 1; this.params = params; @@ -121,7 +121,7 @@ export class Client { } } -export class Query { +class Query { constructor(schemaName, state) { if (!schemaName) throw "Schema name is required"; @@ -226,3 +226,8 @@ export class Query { return this._state; } } + +export { + Client, + Query +}; From 16a985b7ec2589d47165d83c1867b5dd2e451e0f Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sat, 2 Apr 2016 15:13:02 -0700 Subject: [PATCH 30/60] refactor(Query): move `Query` into its own file --- src/index.js | 107 +-------------------------------------------------- src/query.js | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 106 deletions(-) create mode 100644 src/query.js diff --git a/src/index.js b/src/index.js index 2ae8129..287cbca 100644 --- a/src/index.js +++ b/src/index.js @@ -6,6 +6,7 @@ import FileAPI from './api/file'; import RoleAPI from './api/role'; import SchemaAPI from './api/schema'; import UserAPI from './api/user'; +import Query from './query'; /** * Count bytes in a string's UTF-8 representation. @@ -121,112 +122,6 @@ class Client { } } -class Query { - constructor(schemaName, state) { - if (!schemaName) throw "Schema name is required"; - - this.schemaName = schemaName; - - state = state || { - '$schema': schemaName, - '$query': [ - ['$filter', []] - ] - } - this._state = state; - } - - _merge(delta) { - var state = _.merge({}, this._state, delta); - return new Query(this.schemaName, state); - } - - _mergeArray(delta, prepend = false) { - var index = _.findIndex(this._state['$query'], (item) => { - return item[0] === delta[0]; - }); - - if (index !== -1) { - this._state['$query'][index] = delta; - } else { - if (prepend) { - this._state['$query'].unshift(delta); - } else { - this._state['$query'].push(delta); - } - } - - return new Query(this.schemaName, this._state); - } - - limit(num) { - return this._mergeArray(['$limit', num]); - } - - offset(num) { - return this._mergeArray(['$offset', num]); - } - - order(order_by, ordering) { - var parsedOrder; - if(_.isString(ordering)) { - parsedOrder = `$${ordering}`; - } else { - parsedOrder = ordering < 0 ? "$desc" : "$asc"; - } - - return this._mergeArray(['$order_by', [parsedOrder, order_by]]); - } - - pluck(fields) { - return this._mergeArray(['$pluck', fields]); - } - - without(fields) { - return this._mergeArray(['$without', fields]); - } - - pageSize(size) { - return this._mergeArray(['$limit', size]); - } - - index(indexName) { - return this._mergeArray(['$index', indexName]); - } - - filter(params) { - var filterIndex = _.findIndex(this._state['$query'], (item) => { - return item[0] === '$filter'; - }); - var filters = this._state['$query'][filterIndex]; - - Object.keys(params).forEach((key) => { - var [field, operator] = key.split("__"); - var queryField = operator ? [`$${operator}`, params[key]] : params[key]; - - filters[1].push([field, queryField]); - }) - - return this._mergeArray(filters); - } - - where(params) { - //alias - return this.filter(params); - } - - between(params) { - if (params && params.from && params.to) { - return this._mergeArray(['$between', [params.from, params.to, params.index]], true) - } - return this; - } - - toJS() { - return this._state; - } -} - export { Client, Query diff --git a/src/query.js b/src/query.js new file mode 100644 index 0000000..638f69f --- /dev/null +++ b/src/query.js @@ -0,0 +1,107 @@ +import _ from 'lodash'; + +export default class Query { + constructor(schemaName, state) { + if (!schemaName) throw "Schema name is required"; + + this.schemaName = schemaName; + + state = state || { + '$schema': schemaName, + '$query': [ + ['$filter', []] + ] + } + this._state = state; + } + + _merge(delta) { + var state = _.merge({}, this._state, delta); + return new Query(this.schemaName, state); + } + + _mergeArray(delta, prepend = false) { + var index = _.findIndex(this._state['$query'], (item) => { + return item[0] === delta[0]; + }); + + if (index !== -1) { + this._state['$query'][index] = delta; + } else { + if (prepend) { + this._state['$query'].unshift(delta); + } else { + this._state['$query'].push(delta); + } + } + + return new Query(this.schemaName, this._state); + } + + limit(num) { + return this._mergeArray(['$limit', num]); + } + + offset(num) { + return this._mergeArray(['$offset', num]); + } + + order(order_by, ordering) { + var parsedOrder; + if(_.isString(ordering)) { + parsedOrder = `$${ordering}`; + } else { + parsedOrder = ordering < 0 ? "$desc" : "$asc"; + } + + return this._mergeArray(['$order_by', [parsedOrder, order_by]]); + } + + pluck(fields) { + return this._mergeArray(['$pluck', fields]); + } + + without(fields) { + return this._mergeArray(['$without', fields]); + } + + pageSize(size) { + return this._mergeArray(['$limit', size]); + } + + index(indexName) { + return this._mergeArray(['$index', indexName]); + } + + filter(params) { + var filterIndex = _.findIndex(this._state['$query'], (item) => { + return item[0] === '$filter'; + }); + var filters = this._state['$query'][filterIndex]; + + Object.keys(params).forEach((key) => { + var [field, operator] = key.split("__"); + var queryField = operator ? [`$${operator}`, params[key]] : params[key]; + + filters[1].push([field, queryField]); + }) + + return this._mergeArray(filters); + } + + where(params) { + //alias + return this.filter(params); + } + + between(params) { + if (params && params.from && params.to) { + return this._mergeArray(['$between', [params.from, params.to, params.index]], true) + } + return this; + } + + toJS() { + return this._state; + } +} From ccca71787c1577753a0b4f08ea44fecc807a1b5f Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sat, 2 Apr 2016 15:14:54 -0700 Subject: [PATCH 31/60] refactor(Client): move `Client` into its own file --- src/client.js | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/index.js | 123 +------------------------------------------------- 2 files changed, 124 insertions(+), 122 deletions(-) create mode 100644 src/client.js diff --git a/src/client.js b/src/client.js new file mode 100644 index 0000000..63927ff --- /dev/null +++ b/src/client.js @@ -0,0 +1,123 @@ +import fetch from 'isomorphic-fetch'; +import querystring from 'querystring'; +import _ from 'lodash'; + +import DocumentsAPI from './api/documents'; +import FileAPI from './api/file'; +import RoleAPI from './api/role'; +import SchemaAPI from './api/schema'; +import UserAPI from './api/user'; + +export default class Client { + constructor(params = {}) { + params.api_version = params.api_version || 1; + this.params = params; + if (this.params.url) { + this.url_prefix = this.params.url; + } else if (this.params.dev) { + this.url_prefix = `http://${params.domain}.dev.montagehot.club/api/v${params.api_version}/`; + } else { + this.url_prefix = `https://${params.domain}.mntge.com/api/v${params.api_version}/`; + } + + this.documents = new DocumentsAPI(this); + this.schemas = new SchemaAPI(this); + this.users = new UserAPI(this); + this.roles = new RoleAPI(this); + this.files = new FileAPI(this); + } + + auth() { + return this.request("auth/", "POST", { + username: this.params.username, + password: this.params.password, + }).then(response => { + this.params.token = response.data.token; + return response; + }); + } + + request(url, method, data, file) { + var options = { + method: method && method.toUpperCase() || "GET", + headers: { + accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + } + } + if (!file) { + options.headers['Content-Type'] = 'application/json'; + } + if (data) { + if (options.method === "GET") { + url += '?' + querystring.stringify(data); + } else { + if(file) options.body = data + else options.body = JSON.stringify(data); + } + } + if (this.params.token) { + options.headers.Authorization = `Token ${this.params.token}`; + } + if (options.body) { + //Varnish and heroku require a content length! + options.headers['Content-Length'] = getByteLen(options.body); + } + var reqUrl = `${this.url_prefix}${url}` + return this._agent(reqUrl, options).then(function(response) { + if(response.status === 204) { + return; + } + if (!response.ok) { + response.request = _.merge({ + url: reqUrl, + }, options); + return Promise.reject(response); + } + if (response.status >= 400) { + return response.text().then(body => { + var errorMessage = body || response.statusText; + try { + errorMessage = JSON.parse(body); + } catch (e) {} + return Promise.reject(errorMessage); + }); + } + return response.json(); + }).then(function(payload) { + if (payload && payload.errors) { + return Promise.reject(payload.errors); + } + return payload; + }); + } + + _agent(...args) { + return fetch(...args); + } +} + +/** + * Count bytes in a string's UTF-8 representation. + * + * [Reference]{@link http://codereview.stackexchange.com/a/37552} + * + * @param {string} normal_val + * @return {int} + */ +function getByteLen(normal_val) { + // Force string type + normal_val = String(normal_val); + + var byteLen = 0; + for (var i = 0; i < normal_val.length; i++) { + var c = normal_val.charCodeAt(i); + byteLen += c < (1 << 7) ? 1 : + c < (1 << 11) ? 2 : + c < (1 << 16) ? 3 : + c < (1 << 21) ? 4 : + c < (1 << 26) ? 5 : + c < (1 << 31) ? 6 : Number.NaN; + } + return byteLen; +} diff --git a/src/index.js b/src/index.js index 287cbca..006e538 100644 --- a/src/index.js +++ b/src/index.js @@ -1,127 +1,6 @@ -import fetch from 'isomorphic-fetch'; -import querystring from 'querystring'; -import _ from 'lodash'; -import DocumentsAPI from './api/documents'; -import FileAPI from './api/file'; -import RoleAPI from './api/role'; -import SchemaAPI from './api/schema'; -import UserAPI from './api/user'; +import Client from './client'; import Query from './query'; -/** - * Count bytes in a string's UTF-8 representation. - * - * [Reference]{@link http://codereview.stackexchange.com/a/37552} - * - * @param {string} normal_val - * @return {int} - */ -function getByteLen(normal_val) { - // Force string type - normal_val = String(normal_val); - - var byteLen = 0; - for (var i = 0; i < normal_val.length; i++) { - var c = normal_val.charCodeAt(i); - byteLen += c < (1 << 7) ? 1 : - c < (1 << 11) ? 2 : - c < (1 << 16) ? 3 : - c < (1 << 21) ? 4 : - c < (1 << 26) ? 5 : - c < (1 << 31) ? 6 : Number.NaN; - } - return byteLen; -} - -class Client { - constructor(params = {}) { - params.api_version = params.api_version || 1; - this.params = params; - if (this.params.url) { - this.url_prefix = this.params.url; - } else if (this.params.dev) { - this.url_prefix = `http://${params.domain}.dev.montagehot.club/api/v${params.api_version}/`; - } else { - this.url_prefix = `https://${params.domain}.mntge.com/api/v${params.api_version}/`; - } - - this.documents = new DocumentsAPI(this); - this.schemas = new SchemaAPI(this); - this.users = new UserAPI(this); - this.roles = new RoleAPI(this); - this.files = new FileAPI(this); - } - - auth() { - return this.request("auth/", "POST", { - username: this.params.username, - password: this.params.password, - }).then(response => { - this.params.token = response.data.token; - return response; - }); - } - - request(url, method, data, file) { - var options = { - method: method && method.toUpperCase() || "GET", - headers: { - accept: 'application/json', - 'X-Requested-With': 'XMLHttpRequest', - } - } - if (!file) { - options.headers['Content-Type'] = 'application/json'; - } - if (data) { - if (options.method === "GET") { - url += '?' + querystring.stringify(data); - } else { - if(file) options.body = data - else options.body = JSON.stringify(data); - } - } - if (this.params.token) { - options.headers.Authorization = `Token ${this.params.token}`; - } - if (options.body) { - //Varnish and heroku require a content length! - options.headers['Content-Length'] = getByteLen(options.body); - } - var reqUrl = `${this.url_prefix}${url}` - return this._agent(reqUrl, options).then(function(response) { - if(response.status === 204) { - return; - } - if (!response.ok) { - response.request = _.merge({ - url: reqUrl, - }, options); - return Promise.reject(response); - } - if (response.status >= 400) { - return response.text().then(body => { - var errorMessage = body || response.statusText; - try { - errorMessage = JSON.parse(body); - } catch (e) {} - return Promise.reject(errorMessage); - }); - } - return response.json(); - }).then(function(payload) { - if (payload && payload.errors) { - return Promise.reject(payload.errors); - } - return payload; - }); - } - - _agent(...args) { - return fetch(...args); - } -} - export { Client, Query From 19e977c6ad1da91bcefa558d290135d1328f7073 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sat, 2 Apr 2016 15:28:28 -0700 Subject: [PATCH 32/60] chore(build): use tabs instead of spaces --- gulpfile.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index d9e2c8c..b629393 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,25 +4,25 @@ var mocha = require('gulp-mocha'); var webpack = require('gulp-webpack'); -gulp.task('build', function() { - return gulp.src('src/**/*.js') - .pipe(to5({stage: 1, optional: 'runtime'})) - .pipe(gulp.dest('dist')); +gulp.task('build', function () { + return gulp.src('src/**/*.js') + .pipe(to5({stage: 1, optional: 'runtime'})) + .pipe(gulp.dest('dist')); }); -gulp.task('test', function() { - require("babel/register")({ - stage: 1, optional: 'runtime' - }); +gulp.task('test', function () { + require("babel/register")({ + stage: 1, optional: 'runtime' + }); - return gulp.src('tests/**/*test.js') - .pipe(mocha({reporter: 'nyan'})); + return gulp.src('tests/**/*test.js') + .pipe(mocha({reporter: 'nyan'})); }); -gulp.task('webpack', function() { - var myConfig = Object.create(require('./webpack.config')); +gulp.task('webpack', function () { + var myConfig = Object.create(require('./webpack.config')); - return gulp.src('src/') - .pipe(webpack(myConfig)) - .pipe(gulp.dest('./')); + return gulp.src('src/') + .pipe(webpack(myConfig)) + .pipe(gulp.dest('./')); }); From 96b6b5a62441934944cbc1791c678e71eb8eee0d Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sat, 2 Apr 2016 15:29:00 -0700 Subject: [PATCH 33/60] chore(build): rename `myConfig` to `webpackConfig` --- gulpfile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index b629393..e1d6e1e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -20,9 +20,9 @@ gulp.task('test', function () { }); gulp.task('webpack', function () { - var myConfig = Object.create(require('./webpack.config')); + var webpackConfig = Object.create(require('./webpack.config')); return gulp.src('src/') - .pipe(webpack(myConfig)) + .pipe(webpack(webpackConfig)) .pipe(gulp.dest('./')); }); From 790bca145beea978cf6b4aca24ed4501f5daeee4 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sat, 2 Apr 2016 15:29:29 -0700 Subject: [PATCH 34/60] chore(build): rename `to5` to `babel` --- gulpfile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index e1d6e1e..5d453e5 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,12 +1,12 @@ var gulp = require('gulp'); -var to5 = require('gulp-babel'); +var babel = require('gulp-babel'); var mocha = require('gulp-mocha'); var webpack = require('gulp-webpack'); gulp.task('build', function () { return gulp.src('src/**/*.js') - .pipe(to5({stage: 1, optional: 'runtime'})) + .pipe(babel({stage: 1, optional: 'runtime'})) .pipe(gulp.dest('dist')); }); From f8512e1e1ee562d45538342b23d11ac8b132bf4a Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sat, 2 Apr 2016 16:32:36 -0700 Subject: [PATCH 35/60] refactor(DocumentAPI): use the singular form for `DocumentAPI` to match the convention used for the other APIs --- src/api/{documents.js => document.js} | 2 +- src/client.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename src/api/{documents.js => document.js} (96%) diff --git a/src/api/documents.js b/src/api/document.js similarity index 96% rename from src/api/documents.js rename to src/api/document.js index 8fbb5c3..c7426df 100644 --- a/src/api/documents.js +++ b/src/api/document.js @@ -1,4 +1,4 @@ -export default class DocumentsAPI { +export default class DocumentAPI { constructor(client) { this.client = client; } diff --git a/src/client.js b/src/client.js index 63927ff..f932776 100644 --- a/src/client.js +++ b/src/client.js @@ -2,7 +2,7 @@ import fetch from 'isomorphic-fetch'; import querystring from 'querystring'; import _ from 'lodash'; -import DocumentsAPI from './api/documents'; +import DocumentAPI from './api/document'; import FileAPI from './api/file'; import RoleAPI from './api/role'; import SchemaAPI from './api/schema'; @@ -20,7 +20,7 @@ export default class Client { this.url_prefix = `https://${params.domain}.mntge.com/api/v${params.api_version}/`; } - this.documents = new DocumentsAPI(this); + this.documents = new DocumentAPI(this); this.schemas = new SchemaAPI(this); this.users = new UserAPI(this); this.roles = new RoleAPI(this); From 58e1542931533d74db5b5003acbcbe9bacd0ce1b Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sat, 2 Apr 2016 17:53:32 -0700 Subject: [PATCH 36/60] chore(build): create `.babelrc` --- .babelrc | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .babelrc diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..9402126 --- /dev/null +++ b/.babelrc @@ -0,0 +1,4 @@ +{ + "plugins": ["transform-runtime"], + "presets": ["es2015"] +} From 050bc1eaad75dcc322add6bb6d054d45b10ed384 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sat, 2 Apr 2016 17:54:44 -0700 Subject: [PATCH 37/60] chore(build): use babel config in `.babelrc` --- webpack.config.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 9e63069..aa45e59 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -15,11 +15,7 @@ module.exports = { loader: 'babel-loader', include: [ path.resolve(__dirname, 'src') - ], - query: { - plugins: ['transform-runtime'], - presets: ['es2015'] - } + ] }] }, resolve: { From 4f3365ddef807e4d3757ca3f10246743baa850a2 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sat, 2 Apr 2016 17:58:02 -0700 Subject: [PATCH 38/60] chore(gulpfile): update to use babel 6 --- gulpfile.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 5d453e5..46b927f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -6,14 +6,12 @@ var webpack = require('gulp-webpack'); gulp.task('build', function () { return gulp.src('src/**/*.js') - .pipe(babel({stage: 1, optional: 'runtime'})) + .pipe(babel()) .pipe(gulp.dest('dist')); }); gulp.task('test', function () { - require("babel/register")({ - stage: 1, optional: 'runtime' - }); + require('babel-core/register'); return gulp.src('tests/**/*test.js') .pipe(mocha({reporter: 'nyan'})); From d03d49f479e765576623bfbd96d50436ce56c759 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sat, 2 Apr 2016 17:58:45 -0700 Subject: [PATCH 39/60] chore(gulpfile): use default mocha reporter --- gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 46b927f..bfc6872 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -14,7 +14,7 @@ gulp.task('test', function () { require('babel-core/register'); return gulp.src('tests/**/*test.js') - .pipe(mocha({reporter: 'nyan'})); + .pipe(mocha()); }); gulp.task('webpack', function () { From 9ee5be89aa9075e147ffda3f7a732eb48946b15d Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sat, 2 Apr 2016 17:59:40 -0700 Subject: [PATCH 40/60] chore(gulpfile): don't read the contents of source files before passing the paths along to mocha --- gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index bfc6872..bc383b7 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -13,7 +13,7 @@ gulp.task('build', function () { gulp.task('test', function () { require('babel-core/register'); - return gulp.src('tests/**/*test.js') + return gulp.src('tests/**/*test.js', { read: false }) .pipe(mocha()); }); From 4f35e9cc425cd17d0ae79ea1d6e28f6f4c055582 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sat, 2 Apr 2016 18:00:13 -0700 Subject: [PATCH 41/60] chore(gulpfile): require an underscore before "test.js" --- gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index bc383b7..1780ea6 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -13,7 +13,7 @@ gulp.task('build', function () { gulp.task('test', function () { require('babel-core/register'); - return gulp.src('tests/**/*test.js', { read: false }) + return gulp.src('tests/**/*_test.js', { read: false }) .pipe(mocha()); }); From 4928a1fb5660b2878a576101bfffe8221d16328e Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sat, 2 Apr 2016 18:09:52 -0700 Subject: [PATCH 42/60] tests(*): use tabs instead of spaces --- tests/client_test.js | 746 +++++++++++++++++++++---------------------- tests/query_test.js | 380 +++++++++++----------- 2 files changed, 563 insertions(+), 563 deletions(-) diff --git a/tests/client_test.js b/tests/client_test.js index e1f2b56..17a4c8f 100644 --- a/tests/client_test.js +++ b/tests/client_test.js @@ -9,383 +9,383 @@ var emitter = new EventEmitter(); function mockedRequest(url, options) { - var self = {}; - self.method = options.method; - self.headers = options.headers; - self.body = options.body; - self.url = url; - self.getParams = null; - if (_.indexOf(url, '?') !== -1) { - self.getParams = querystring.parse(url.split('?')[1]); - self.url = url.split('?')[0]; - } - self.callback = null; - - var promise = new Promise(function(resolve, reject) { - self.callback = function(err, success) { - if (err) { - reject(err); - } else { - resolve({ - ok: success.ok, - status: success.status || 200, - json: function() { - return Promise.resolve(success.body); - }, - text: function() { - return Promise.resolve(success.body); - } - }); - } - } - }); - - emitter.emit('request', self); - return promise; + var self = {}; + self.method = options.method; + self.headers = options.headers; + self.body = options.body; + self.url = url; + self.getParams = null; + if (_.indexOf(url, '?') !== -1) { + self.getParams = querystring.parse(url.split('?')[1]); + self.url = url.split('?')[0]; + } + self.callback = null; + + var promise = new Promise(function (resolve, reject) { + self.callback = function (err, success) { + if (err) { + reject(err); + } else { + resolve({ + ok: success.ok, + status: success.status || 200, + json: function () { + return Promise.resolve(success.body); + }, + text: function () { + return Promise.resolve(success.body); + } + }); + } + } + }); + + emitter.emit('request', self); + return promise; } class MockedClient extends Client { - _agent(...args) { - return mockedRequest(...args); - } + _agent(...args) { + return mockedRequest(...args); + } } describe('Client', () => { - let client; - - beforeEach(() => { - client = new MockedClient(); - }); - - describe('initialize', () => { - context('when the api version is not specified', () => { - it('should set a default api version of 1', () => { - var client = new Client(); - expect(client.params.api_version).to.be(1); - }); - }); - - context('when the api version is specified', () => { - it('should set the version', () => { - var client = new Client({api_version: 4}); - expect(client.params.api_version).to.be(4); - }); - }); - - context('when a url param is passed in', () => { - it('should set the url prefix to the url', () => { - var client = new Client({url: 'https://www.foo.com'}); - expect(client.url_prefix).to.be('https://www.foo.com'); - }); - }); - - context('when a url param is not passed in', () => { - it('should set the url to the montage production site', () => { - var client = new Client({domain: 'foo'}); - expect(client.url_prefix).to.be('https://foo.mntge.com/api/v1/'); - }); - }); - - context('when the dev param is set to true', () => { - it('should use the dev montage domain', () => { - var client = new Client({dev: true, domain: 'foo'}); - expect(client.url_prefix).to.be('http://foo.dev.montagehot.club/api/v1/'); - }); - }); - }); - - describe('request', () => { - it('rejects validation errors and attempts to return JSON', () => { - emitter.once('request', (request) => { - request.callback(null, { - ok: true, - status: 403, - body: JSON.stringify({errors: ['something went wrong']}), - }); - - }); - return client.request('#').then(response => { - expect.fail(); - }, error => { - //console.log(error); - expect(error).to.be.eql({errors: ['something went wrong']}); - }); - }); - - it('rejects validation errors from status 200 and attempts to return JSON', () => { - emitter.once('request', (request) => { - request.callback(null, { - ok: true, - status: 200, - body: {errors: ['something went wrong']}, - }); - - }); - return client.request('#').then(response => { - expect.fail(); - }, error => { - //console.log(error); - expect(error).to.be.eql(['something went wrong']); - }); - }); - - it('rejects bad responses with body text', () => { - emitter.once('request', (request) => { - request.callback(null, { - ok: false, - body: 'something went wrong', - }); - - }); - return client.request('#').then(response => { - expect.fail(); - }, error => { - //console.log(error); - return error.text().then(text => { - expect(text).to.be.eql('something went wrong'); - }); - }); - }); - }); - - describe('schemas', () => { - it('returns promise from schemas endpoint', () => { - emitter.once('request', (request) => { - expect(_.last(request.url.split('/v1/'))).to.be('schemas/'); - expect(request.method).to.be('GET'); - request.callback(null, { - ok: true, - body: 'schemas FTW', - }); - - }); - return client.schemas().then((response) => { - expect(response).to.be('schemas FTW') - }); - }); - }); - - describe('schema', () => { - it('returns promise from schema endpoint', () => { - emitter.once('request', (request) => { - expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/'); - expect(request.method).to.be('GET'); - request.callback(null, { - ok: true, - body: 'movies FTW', - }); - }); - return client.schema('movies').then((response) => { - expect(response).to.be('movies FTW') - }); - }); - }); - - describe('documents', () => { - it('returns promise from documents endpoint', () => { - emitter.once('request', (request) => { - expect(_.last(request.url.split('/v1/'))).to.be('query/'); - expect(request.method).to.be('POST'); - request.callback(null, { - ok: true, - body: 'movie instances FTW', - }); - }); - return client.documents('movies').then((response) => { - expect(response).to.be('movie instances FTW') - }); - }); - - //it('sends query params as get params', () => { - // emitter.once('request', (request) => { - // expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/query/'); - // //ow nested JSON serializeation - // expect(JSON.parse(request.body).filter).to.eql({ - // rating__gt: 5 - // }); - // expect(request.method).to.be('POST'); - // request.callback(null, { - // ok: true, - // body: 'movie instances FTW', - // }); - // }); - // var query = new Query('foo').filter({rating__gt: 5}) - // return client.documents('movies', query).then((response) => { - // expect(response).to.be('movie instances FTW') - // }); - //}); - }); - - describe('document', () => { - it('returns promise from document endpoint', () => { - emitter.once('request', (request) => { - expect(_.last(request.url.split('/v1/'))).to.be('query/'); - expect(request.method).to.be('POST'); - request.callback(null, { - ok: true, - body: 'foobar movie', - }); - }); - return client.document('movies', 'foobar').then((response) => { - expect(response).to.be('foobar movie') - }); - }); - }); - - describe('document cursor', () => { - it('returns promise from documents endpoint with a cursor param', () => { - emitter.once('request', (request) => { - expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/'); - expect(request.method).to.be('GET'); - expect(request.getParams).to.be.eql({cursor: 'DEADBEAF'}); - request.callback(null, { - ok: true, - body: 'yeilding movies', - }); - }); - return client.document_cursor('movies', 'DEADBEAF').then((response) => { - expect(response).to.be('yeilding movies') - }); - }); - }); - - describe('create document', () => { - it('returns promise from create document endpoint with post data', () => { - emitter.once('request', (request) => { - expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/save/'); - expect(request.method).to.be('POST'); - expect(request.body).to.be.eql(JSON.stringify([{title: 'Star Wars'}])); - request.callback(null, { - ok: true, - body: {id: 'aww yeah'}, - }); - }); - return client.create_document('movies', {title: 'Star Wars'}).then((response) => { - expect(response).to.be.eql({id: 'aww yeah'}) - }); - }); - }); - - describe('update document', () => { - it('returns promise from update document endpoint with post data', () => { - emitter.once('request', (request) => { - expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/foobar/'); - expect(request.method).to.be('POST'); - expect(request.body).to.be.eql(JSON.stringify({title: 'Star Wars'})); - request.callback(null, { - ok: true, - body: {id: 'aww yeah'}, - }); - }); - return client.update_document('movies', 'foobar', {title: 'Star Wars'}).then((response) => { - expect(response).to.be.eql({id: 'aww yeah'}) - }); - }); - }); - - describe('delete document', () => { - it('returns promise from delete document endpoint', () => { - emitter.once('request', (request) => { - expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/foobar/'); - expect(request.method).to.be('DELETE'); - request.callback(null, { - ok: true, - body: null, - }); - }); - return client.delete_document('movies', 'foobar').then((response) => { - expect(response).to.be.eql(null) - }); - }); - }); - - describe('auth', () => { - it('returns promise from auth endpoint and sends login info', () => { - emitter.once('request', (request) => { - expect(_.last(request.url.split('/v1/'))).to.be('auth/'); - expect(request.method).to.be('POST'); - expect(request.body).to.be.eql(JSON.stringify({ - username: 'johnsmith', - password: 'secret', - })); - request.callback(null, { - ok: true, - body: {data: { token: 'FOO'}}, - }); - }); - client.params.username = 'johnsmith'; - client.params.password = 'secret'; - return client.auth().then((response) => { - expect(response).to.be.eql({data: {token: 'FOO'}}) - }); - expect(client.params.token).to.be.eql('FOO'); - }); - }); - - describe('files', () => { - it('returns promise from create file endpoint with post data', () => { - emitter.once('request', (request) => { - expect(_.last(request.url.split('/v1/'))).to.be('files/'); - expect(request.method).to.be('POST'); - //expect(request.body).to.be.eql(JSON.stringify([{title: 'Star Wars'}])); - request.callback(null, { - ok: true, - body: {id: 'aww yeah'}, - }); - }); - var formData = new FormData(); - formData.append('my_buffer', new Buffer(10)); - return client.files(formData).then((response) => { - expect(response).to.be.eql({id: 'aww yeah'}) - }); - }); - }); - - //describe('paginated documents', () => { - // it('returns a generator that yields response promises', () => { - // function firstPage(request) { - // expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/query/'); - // expect(request.method).to.be('POST'); - // request.callback(null, { - // ok: true, - // body: { - // data: ['aww yeah'], - // cursors: { - // next: 'DEADBEAF', - // } - // }, - // }); - // } - - // function lastPage(request) { - // expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/'); - // expect(request.method).to.be('GET'); - // expect(request.getParams['cursor']).to.be('DEADBEAF'); - // request.callback(null, { - // ok: true, - // body: { - // data: ['last one alive lock the door'], - // }, - // }); - // } - - // emitter.once('request', firstPage); - // var generator = client.paginated_documents('movies'); - // var g1 = generator.next() - // expect(g1.done).to.be(false); - // var response = g1.value; - // return response.then(objects => { - // emitter.once('request', lastPage); - // expect(objects).to.be.eql(['aww yeah']); - // var g2 = generator.next(); - // expect(g2.done).to.be(false); - // expect(g2.value).to.be.ok(); - // return g2.value.then(objects => { - // expect(objects).to.be.eql(['last one alive lock the door']); - // var g3 = generator.next(); - // expect(g3.done).to.be(true); - // }); - // }); - // }); - //}); + let client; + + beforeEach(() => { + client = new MockedClient(); + }); + + describe('initialize', () => { + context('when the api version is not specified', () => { + it('should set a default api version of 1', () => { + var client = new Client(); + expect(client.params.api_version).to.be(1); + }); + }); + + context('when the api version is specified', () => { + it('should set the version', () => { + var client = new Client({api_version: 4}); + expect(client.params.api_version).to.be(4); + }); + }); + + context('when a url param is passed in', () => { + it('should set the url prefix to the url', () => { + var client = new Client({url: 'https://www.foo.com'}); + expect(client.url_prefix).to.be('https://www.foo.com'); + }); + }); + + context('when a url param is not passed in', () => { + it('should set the url to the montage production site', () => { + var client = new Client({domain: 'foo'}); + expect(client.url_prefix).to.be('https://foo.mntge.com/api/v1/'); + }); + }); + + context('when the dev param is set to true', () => { + it('should use the dev montage domain', () => { + var client = new Client({dev: true, domain: 'foo'}); + expect(client.url_prefix).to.be('http://foo.dev.montagehot.club/api/v1/'); + }); + }); + }); + + describe('request', () => { + it('rejects validation errors and attempts to return JSON', () => { + emitter.once('request', (request) => { + request.callback(null, { + ok: true, + status: 403, + body: JSON.stringify({errors: ['something went wrong']}), + }); + + }); + return client.request('#').then(response => { + expect.fail(); + }, error => { + //console.log(error); + expect(error).to.be.eql({errors: ['something went wrong']}); + }); + }); + + it('rejects validation errors from status 200 and attempts to return JSON', () => { + emitter.once('request', (request) => { + request.callback(null, { + ok: true, + status: 200, + body: {errors: ['something went wrong']}, + }); + + }); + return client.request('#').then(response => { + expect.fail(); + }, error => { + //console.log(error); + expect(error).to.be.eql(['something went wrong']); + }); + }); + + it('rejects bad responses with body text', () => { + emitter.once('request', (request) => { + request.callback(null, { + ok: false, + body: 'something went wrong', + }); + + }); + return client.request('#').then(response => { + expect.fail(); + }, error => { + //console.log(error); + return error.text().then(text => { + expect(text).to.be.eql('something went wrong'); + }); + }); + }); + }); + + describe('schemas', () => { + it('returns promise from schemas endpoint', () => { + emitter.once('request', (request) => { + expect(_.last(request.url.split('/v1/'))).to.be('schemas/'); + expect(request.method).to.be('GET'); + request.callback(null, { + ok: true, + body: 'schemas FTW', + }); + + }); + return client.schemas().then((response) => { + expect(response).to.be('schemas FTW') + }); + }); + }); + + describe('schema', () => { + it('returns promise from schema endpoint', () => { + emitter.once('request', (request) => { + expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/'); + expect(request.method).to.be('GET'); + request.callback(null, { + ok: true, + body: 'movies FTW', + }); + }); + return client.schema('movies').then((response) => { + expect(response).to.be('movies FTW') + }); + }); + }); + + describe('documents', () => { + it('returns promise from documents endpoint', () => { + emitter.once('request', (request) => { + expect(_.last(request.url.split('/v1/'))).to.be('query/'); + expect(request.method).to.be('POST'); + request.callback(null, { + ok: true, + body: 'movie instances FTW', + }); + }); + return client.documents('movies').then((response) => { + expect(response).to.be('movie instances FTW') + }); + }); + + //it('sends query params as get params', () => { + // emitter.once('request', (request) => { + // expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/query/'); + // //ow nested JSON serializeation + // expect(JSON.parse(request.body).filter).to.eql({ + // rating__gt: 5 + // }); + // expect(request.method).to.be('POST'); + // request.callback(null, { + // ok: true, + // body: 'movie instances FTW', + // }); + // }); + // var query = new Query('foo').filter({rating__gt: 5}) + // return client.documents('movies', query).then((response) => { + // expect(response).to.be('movie instances FTW') + // }); + //}); + }); + + describe('document', () => { + it('returns promise from document endpoint', () => { + emitter.once('request', (request) => { + expect(_.last(request.url.split('/v1/'))).to.be('query/'); + expect(request.method).to.be('POST'); + request.callback(null, { + ok: true, + body: 'foobar movie', + }); + }); + return client.document('movies', 'foobar').then((response) => { + expect(response).to.be('foobar movie') + }); + }); + }); + + describe('document cursor', () => { + it('returns promise from documents endpoint with a cursor param', () => { + emitter.once('request', (request) => { + expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/'); + expect(request.method).to.be('GET'); + expect(request.getParams).to.be.eql({cursor: 'DEADBEAF'}); + request.callback(null, { + ok: true, + body: 'yeilding movies', + }); + }); + return client.document_cursor('movies', 'DEADBEAF').then((response) => { + expect(response).to.be('yeilding movies') + }); + }); + }); + + describe('create document', () => { + it('returns promise from create document endpoint with post data', () => { + emitter.once('request', (request) => { + expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/save/'); + expect(request.method).to.be('POST'); + expect(request.body).to.be.eql(JSON.stringify([{title: 'Star Wars'}])); + request.callback(null, { + ok: true, + body: {id: 'aww yeah'}, + }); + }); + return client.create_document('movies', {title: 'Star Wars'}).then((response) => { + expect(response).to.be.eql({id: 'aww yeah'}) + }); + }); + }); + + describe('update document', () => { + it('returns promise from update document endpoint with post data', () => { + emitter.once('request', (request) => { + expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/foobar/'); + expect(request.method).to.be('POST'); + expect(request.body).to.be.eql(JSON.stringify({title: 'Star Wars'})); + request.callback(null, { + ok: true, + body: {id: 'aww yeah'}, + }); + }); + return client.update_document('movies', 'foobar', {title: 'Star Wars'}).then((response) => { + expect(response).to.be.eql({id: 'aww yeah'}) + }); + }); + }); + + describe('delete document', () => { + it('returns promise from delete document endpoint', () => { + emitter.once('request', (request) => { + expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/foobar/'); + expect(request.method).to.be('DELETE'); + request.callback(null, { + ok: true, + body: null, + }); + }); + return client.delete_document('movies', 'foobar').then((response) => { + expect(response).to.be.eql(null) + }); + }); + }); + + describe('auth', () => { + it('returns promise from auth endpoint and sends login info', () => { + emitter.once('request', (request) => { + expect(_.last(request.url.split('/v1/'))).to.be('auth/'); + expect(request.method).to.be('POST'); + expect(request.body).to.be.eql(JSON.stringify({ + username: 'johnsmith', + password: 'secret', + })); + request.callback(null, { + ok: true, + body: {data: {token: 'FOO'}}, + }); + }); + client.params.username = 'johnsmith'; + client.params.password = 'secret'; + return client.auth().then((response) => { + expect(response).to.be.eql({data: {token: 'FOO'}}) + }); + expect(client.params.token).to.be.eql('FOO'); + }); + }); + + describe('files', () => { + it('returns promise from create file endpoint with post data', () => { + emitter.once('request', (request) => { + expect(_.last(request.url.split('/v1/'))).to.be('files/'); + expect(request.method).to.be('POST'); + //expect(request.body).to.be.eql(JSON.stringify([{title: 'Star Wars'}])); + request.callback(null, { + ok: true, + body: {id: 'aww yeah'}, + }); + }); + var formData = new FormData(); + formData.append('my_buffer', new Buffer(10)); + return client.files(formData).then((response) => { + expect(response).to.be.eql({id: 'aww yeah'}) + }); + }); + }); + + //describe('paginated documents', () => { + // it('returns a generator that yields response promises', () => { + // function firstPage(request) { + // expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/query/'); + // expect(request.method).to.be('POST'); + // request.callback(null, { + // ok: true, + // body: { + // data: ['aww yeah'], + // cursors: { + // next: 'DEADBEAF', + // } + // }, + // }); + // } + + // function lastPage(request) { + // expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/'); + // expect(request.method).to.be('GET'); + // expect(request.getParams['cursor']).to.be('DEADBEAF'); + // request.callback(null, { + // ok: true, + // body: { + // data: ['last one alive lock the door'], + // }, + // }); + // } + + // emitter.once('request', firstPage); + // var generator = client.paginated_documents('movies'); + // var g1 = generator.next() + // expect(g1.done).to.be(false); + // var response = g1.value; + // return response.then(objects => { + // emitter.once('request', lastPage); + // expect(objects).to.be.eql(['aww yeah']); + // var g2 = generator.next(); + // expect(g2.done).to.be(false); + // expect(g2.value).to.be.ok(); + // return g2.value.then(objects => { + // expect(objects).to.be.eql(['last one alive lock the door']); + // var g3 = generator.next(); + // expect(g3.done).to.be(true); + // }); + // }); + // }); + //}); }); diff --git a/tests/query_test.js b/tests/query_test.js index d474324..3035022 100644 --- a/tests/query_test.js +++ b/tests/query_test.js @@ -4,194 +4,194 @@ import _ from 'lodash'; describe('Query', () => { - describe('initialize', () => { - it('should require a schema name', () => { - var query = new Query("foo"); - expect(query.schemaName).to.be("foo"); - }); - - it('should setup the default query object', () => { - var query = new Query("foo"); - var expected = { - '$schema': 'foo', - '$query': [['$filter', []]] - }; - - expect(query.toJS()).to.eql(expected); - }); - - it('should not overwrite default state', () => { - var query = new Query("foo", { bar: "baz" }) - expect(query.toJS()).to.eql({ bar: "baz" }) - }) - }); - - describe('_mergeArray', () => { - context('when the item exists already', () => { - it('should overwrite it with the new item', () => { - var state = { - '$schema': 'foo', - '$query': [ - ['$filter', []], - ['$limit', 5] - ] - }; - var expected = { - '$schema': 'foo', - '$query': [ - ['$filter', []], - ['$limit', 6] - ] - }; - var query = new Query('foo', state); - expect(query._mergeArray(['$limit', 6]).toJS()).to.eql(expected); - }) - }) - - context('when the item does not exist already', () => { - it('should add the new item', () => { - var state = { - '$schema': 'foo', - '$query': [ - ['$filter', []], - ['$limit', 6] - ] - }; - var query = new Query('foo'); - expect(query._mergeArray(['$limit', 6]).toJS()).to.eql(state); - }) - }) - - context('when the prepend option is true', () => { - it('should prepend the query', () => { - var state = { - '$schema': 'foo', - '$query': [ - ['$between', 'foo'], - ['$filter', []] - ] - }; - var query = new Query('foo'); - expect(query._mergeArray(['$between', 'foo'], true).toJS()).to.eql(state); - }) - }) - }) - - describe('limit', () => { - it('sets limit', () => { - var query = new Query('foo'); - var params = query.limit(5).toJS(); - var expected = [['$filter', []],['$limit', 5]]; - - expect(params['$query']).to.eql(expected); - }); - }); - - describe('offset', () => { - it('sets offset', () => { - var query = new Query('foo'); - var params = query.offset(5).toJS(); - var expected = [['$filter', []],['$offset', 5]]; - expect(params['$query']).to.eql(expected); - }); - }); - - describe('order', () => { - it('sets order_by and direction', () => { - var query = new Query('foo'); - var params = query.order('rating', -1).toJS(); - var expected = [['$filter', []],['$order_by', ['$desc', 'rating']]]; - expect(params['$query']).to.eql(expected); - - expected = [['$filter', []],['$order_by', ['$asc', 'rating']]]; - params = query.order('rating', 1).toJS(); - expect(params['$query']).to.eql(expected); - }); - - it('sets order_by and direction by string', () => { - var query = new Query('foo'); - var params = query.order('rating', 'desc').toJS(); - var expected = [['$filter', []],['$order_by', ['$desc', 'rating']]]; - expect(params['$query']).to.eql(expected); - - expected = [['$filter', []],['$order_by', ['$asc', 'rating']]]; - params = query.order('rating', 'asc').toJS(); - expect(params['$query']).to.eql(expected); - }); - }); - - describe('filter', () => { - it('sets filter params', () => { - var query = new Query('foo'); - var params = query.filter({rating__gt: 5}).toJS(); - var expected = [['$filter', [['rating', ['$gt', 5]]]]]; - expect(params['$query']).to.eql(expected); - }); - - it('merges filter params', () => { - var query = new Query('foo'); - var params = query.filter({rating__gt: 5}) - .filter({author: 'speilberg'}) - .toJS(); - var expected = [ - ['$filter', [ - ['rating', ['$gt', 5]], - ['author', 'speilberg'] - ]] - ]; - expect(params['$query']).to.eql(expected); - }); - }); - - describe('pluck', () => { - it('sets pluck params', () => { - var query = new Query('foo'); - var params = query.pluck(['rating', 'id']).toJS(); - var expected = [['$filter', []], ['$pluck', ['rating', 'id']]]; - expect(params['$query']).to.be.eql(expected); - }); - }); - - describe('without', () => { - it('sets without params', () => { - var query = new Query('foo'); - var params = query.without(['blob']).toJS(); - var expected = [['$filter', []], ['$without', ['blob']]]; - expect(params['$query']).to.be.eql(expected); - }); - }); - - describe('pageSize', () => { - it('sets batch_size params', () => { - var query = new Query('foo'); - var params = query.pageSize(20).toJS(); - var expected = [['$filter', []], ['$limit', 20]]; - expect(params['$query']).to.be.eql(expected); - }); - }); - - describe('index', () => { - it('sets index params', () => { - var query = new Query('foo'); - var params = query.index('fullText').toJS(); - var expected = [['$filter', []], ['$index', 'fullText']]; - expect(params['$query']).to.be.eql(expected); - }); - }); - - describe('between', () => { - it('should require a from and a to', () => { - var query = new Query('foo'); - var params = query.between().toJS(); - var expected = [['$filter', []]]; - expect(params['$query']).to.be.eql(expected); - }); - - it('should prepend the between operator', () => { - var query = new Query('foo'); - var params = query.between({ from: 1, to: 10, index: 'rank' }).toJS(); - var expected = [['$between', [1, 10, 'rank']], ['$filter', []]]; - expect(params['$query']).to.be.eql(expected); - }); - }); + describe('initialize', () => { + it('should require a schema name', () => { + var query = new Query("foo"); + expect(query.schemaName).to.be("foo"); + }); + + it('should setup the default query object', () => { + var query = new Query("foo"); + var expected = { + '$schema': 'foo', + '$query': [['$filter', []]] + }; + + expect(query.toJS()).to.eql(expected); + }); + + it('should not overwrite default state', () => { + var query = new Query("foo", {bar: "baz"}) + expect(query.toJS()).to.eql({bar: "baz"}) + }) + }); + + describe('_mergeArray', () => { + context('when the item exists already', () => { + it('should overwrite it with the new item', () => { + var state = { + '$schema': 'foo', + '$query': [ + ['$filter', []], + ['$limit', 5] + ] + }; + var expected = { + '$schema': 'foo', + '$query': [ + ['$filter', []], + ['$limit', 6] + ] + }; + var query = new Query('foo', state); + expect(query._mergeArray(['$limit', 6]).toJS()).to.eql(expected); + }) + }) + + context('when the item does not exist already', () => { + it('should add the new item', () => { + var state = { + '$schema': 'foo', + '$query': [ + ['$filter', []], + ['$limit', 6] + ] + }; + var query = new Query('foo'); + expect(query._mergeArray(['$limit', 6]).toJS()).to.eql(state); + }) + }) + + context('when the prepend option is true', () => { + it('should prepend the query', () => { + var state = { + '$schema': 'foo', + '$query': [ + ['$between', 'foo'], + ['$filter', []] + ] + }; + var query = new Query('foo'); + expect(query._mergeArray(['$between', 'foo'], true).toJS()).to.eql(state); + }) + }) + }) + + describe('limit', () => { + it('sets limit', () => { + var query = new Query('foo'); + var params = query.limit(5).toJS(); + var expected = [['$filter', []], ['$limit', 5]]; + + expect(params['$query']).to.eql(expected); + }); + }); + + describe('offset', () => { + it('sets offset', () => { + var query = new Query('foo'); + var params = query.offset(5).toJS(); + var expected = [['$filter', []], ['$offset', 5]]; + expect(params['$query']).to.eql(expected); + }); + }); + + describe('order', () => { + it('sets order_by and direction', () => { + var query = new Query('foo'); + var params = query.order('rating', -1).toJS(); + var expected = [['$filter', []], ['$order_by', ['$desc', 'rating']]]; + expect(params['$query']).to.eql(expected); + + expected = [['$filter', []], ['$order_by', ['$asc', 'rating']]]; + params = query.order('rating', 1).toJS(); + expect(params['$query']).to.eql(expected); + }); + + it('sets order_by and direction by string', () => { + var query = new Query('foo'); + var params = query.order('rating', 'desc').toJS(); + var expected = [['$filter', []], ['$order_by', ['$desc', 'rating']]]; + expect(params['$query']).to.eql(expected); + + expected = [['$filter', []], ['$order_by', ['$asc', 'rating']]]; + params = query.order('rating', 'asc').toJS(); + expect(params['$query']).to.eql(expected); + }); + }); + + describe('filter', () => { + it('sets filter params', () => { + var query = new Query('foo'); + var params = query.filter({rating__gt: 5}).toJS(); + var expected = [['$filter', [['rating', ['$gt', 5]]]]]; + expect(params['$query']).to.eql(expected); + }); + + it('merges filter params', () => { + var query = new Query('foo'); + var params = query.filter({rating__gt: 5}) + .filter({author: 'speilberg'}) + .toJS(); + var expected = [ + ['$filter', [ + ['rating', ['$gt', 5]], + ['author', 'speilberg'] + ]] + ]; + expect(params['$query']).to.eql(expected); + }); + }); + + describe('pluck', () => { + it('sets pluck params', () => { + var query = new Query('foo'); + var params = query.pluck(['rating', 'id']).toJS(); + var expected = [['$filter', []], ['$pluck', ['rating', 'id']]]; + expect(params['$query']).to.be.eql(expected); + }); + }); + + describe('without', () => { + it('sets without params', () => { + var query = new Query('foo'); + var params = query.without(['blob']).toJS(); + var expected = [['$filter', []], ['$without', ['blob']]]; + expect(params['$query']).to.be.eql(expected); + }); + }); + + describe('pageSize', () => { + it('sets batch_size params', () => { + var query = new Query('foo'); + var params = query.pageSize(20).toJS(); + var expected = [['$filter', []], ['$limit', 20]]; + expect(params['$query']).to.be.eql(expected); + }); + }); + + describe('index', () => { + it('sets index params', () => { + var query = new Query('foo'); + var params = query.index('fullText').toJS(); + var expected = [['$filter', []], ['$index', 'fullText']]; + expect(params['$query']).to.be.eql(expected); + }); + }); + + describe('between', () => { + it('should require a from and a to', () => { + var query = new Query('foo'); + var params = query.between().toJS(); + var expected = [['$filter', []]]; + expect(params['$query']).to.be.eql(expected); + }); + + it('should prepend the between operator', () => { + var query = new Query('foo'); + var params = query.between({from: 1, to: 10, index: 'rank'}).toJS(); + var expected = [['$between', [1, 10, 'rank']], ['$filter', []]]; + expect(params['$query']).to.be.eql(expected); + }); + }); }); From 45306781eef877263ff3da99f509354bf96135e2 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sun, 3 Apr 2016 21:34:14 -0700 Subject: [PATCH 43/60] tests(client): remove tests for methods that have been moved to their own classes --- tests/client_test.js | 218 ------------------------------------------- 1 file changed, 218 deletions(-) diff --git a/tests/client_test.js b/tests/client_test.js index 17a4c8f..e922372 100644 --- a/tests/client_test.js +++ b/tests/client_test.js @@ -148,157 +148,6 @@ describe('Client', () => { }); }); - describe('schemas', () => { - it('returns promise from schemas endpoint', () => { - emitter.once('request', (request) => { - expect(_.last(request.url.split('/v1/'))).to.be('schemas/'); - expect(request.method).to.be('GET'); - request.callback(null, { - ok: true, - body: 'schemas FTW', - }); - - }); - return client.schemas().then((response) => { - expect(response).to.be('schemas FTW') - }); - }); - }); - - describe('schema', () => { - it('returns promise from schema endpoint', () => { - emitter.once('request', (request) => { - expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/'); - expect(request.method).to.be('GET'); - request.callback(null, { - ok: true, - body: 'movies FTW', - }); - }); - return client.schema('movies').then((response) => { - expect(response).to.be('movies FTW') - }); - }); - }); - - describe('documents', () => { - it('returns promise from documents endpoint', () => { - emitter.once('request', (request) => { - expect(_.last(request.url.split('/v1/'))).to.be('query/'); - expect(request.method).to.be('POST'); - request.callback(null, { - ok: true, - body: 'movie instances FTW', - }); - }); - return client.documents('movies').then((response) => { - expect(response).to.be('movie instances FTW') - }); - }); - - //it('sends query params as get params', () => { - // emitter.once('request', (request) => { - // expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/query/'); - // //ow nested JSON serializeation - // expect(JSON.parse(request.body).filter).to.eql({ - // rating__gt: 5 - // }); - // expect(request.method).to.be('POST'); - // request.callback(null, { - // ok: true, - // body: 'movie instances FTW', - // }); - // }); - // var query = new Query('foo').filter({rating__gt: 5}) - // return client.documents('movies', query).then((response) => { - // expect(response).to.be('movie instances FTW') - // }); - //}); - }); - - describe('document', () => { - it('returns promise from document endpoint', () => { - emitter.once('request', (request) => { - expect(_.last(request.url.split('/v1/'))).to.be('query/'); - expect(request.method).to.be('POST'); - request.callback(null, { - ok: true, - body: 'foobar movie', - }); - }); - return client.document('movies', 'foobar').then((response) => { - expect(response).to.be('foobar movie') - }); - }); - }); - - describe('document cursor', () => { - it('returns promise from documents endpoint with a cursor param', () => { - emitter.once('request', (request) => { - expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/'); - expect(request.method).to.be('GET'); - expect(request.getParams).to.be.eql({cursor: 'DEADBEAF'}); - request.callback(null, { - ok: true, - body: 'yeilding movies', - }); - }); - return client.document_cursor('movies', 'DEADBEAF').then((response) => { - expect(response).to.be('yeilding movies') - }); - }); - }); - - describe('create document', () => { - it('returns promise from create document endpoint with post data', () => { - emitter.once('request', (request) => { - expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/save/'); - expect(request.method).to.be('POST'); - expect(request.body).to.be.eql(JSON.stringify([{title: 'Star Wars'}])); - request.callback(null, { - ok: true, - body: {id: 'aww yeah'}, - }); - }); - return client.create_document('movies', {title: 'Star Wars'}).then((response) => { - expect(response).to.be.eql({id: 'aww yeah'}) - }); - }); - }); - - describe('update document', () => { - it('returns promise from update document endpoint with post data', () => { - emitter.once('request', (request) => { - expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/foobar/'); - expect(request.method).to.be('POST'); - expect(request.body).to.be.eql(JSON.stringify({title: 'Star Wars'})); - request.callback(null, { - ok: true, - body: {id: 'aww yeah'}, - }); - }); - return client.update_document('movies', 'foobar', {title: 'Star Wars'}).then((response) => { - expect(response).to.be.eql({id: 'aww yeah'}) - }); - }); - }); - - describe('delete document', () => { - it('returns promise from delete document endpoint', () => { - emitter.once('request', (request) => { - expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/foobar/'); - expect(request.method).to.be('DELETE'); - request.callback(null, { - ok: true, - body: null, - }); - }); - return client.delete_document('movies', 'foobar').then((response) => { - expect(response).to.be.eql(null) - }); - }); - }); - describe('auth', () => { it('returns promise from auth endpoint and sends login info', () => { emitter.once('request', (request) => { @@ -321,71 +170,4 @@ describe('Client', () => { expect(client.params.token).to.be.eql('FOO'); }); }); - - describe('files', () => { - it('returns promise from create file endpoint with post data', () => { - emitter.once('request', (request) => { - expect(_.last(request.url.split('/v1/'))).to.be('files/'); - expect(request.method).to.be('POST'); - //expect(request.body).to.be.eql(JSON.stringify([{title: 'Star Wars'}])); - request.callback(null, { - ok: true, - body: {id: 'aww yeah'}, - }); - }); - var formData = new FormData(); - formData.append('my_buffer', new Buffer(10)); - return client.files(formData).then((response) => { - expect(response).to.be.eql({id: 'aww yeah'}) - }); - }); - }); - - //describe('paginated documents', () => { - // it('returns a generator that yields response promises', () => { - // function firstPage(request) { - // expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/query/'); - // expect(request.method).to.be('POST'); - // request.callback(null, { - // ok: true, - // body: { - // data: ['aww yeah'], - // cursors: { - // next: 'DEADBEAF', - // } - // }, - // }); - // } - - // function lastPage(request) { - // expect(_.last(request.url.split('/v1/'))).to.be('schemas/movies/'); - // expect(request.method).to.be('GET'); - // expect(request.getParams['cursor']).to.be('DEADBEAF'); - // request.callback(null, { - // ok: true, - // body: { - // data: ['last one alive lock the door'], - // }, - // }); - // } - - // emitter.once('request', firstPage); - // var generator = client.paginated_documents('movies'); - // var g1 = generator.next() - // expect(g1.done).to.be(false); - // var response = g1.value; - // return response.then(objects => { - // emitter.once('request', lastPage); - // expect(objects).to.be.eql(['aww yeah']); - // var g2 = generator.next(); - // expect(g2.done).to.be(false); - // expect(g2.value).to.be.ok(); - // return g2.value.then(objects => { - // expect(objects).to.be.eql(['last one alive lock the door']); - // var g3 = generator.next(); - // expect(g3.done).to.be(true); - // }); - // }); - // }); - //}); }); From b0f84798592bf024214be385b257664c4abec50f Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Sun, 3 Apr 2016 22:21:13 -0700 Subject: [PATCH 44/60] tests(mocha): use the `min` reporter --- gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 1780ea6..ebe8769 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -14,7 +14,7 @@ gulp.task('test', function () { require('babel-core/register'); return gulp.src('tests/**/*_test.js', { read: false }) - .pipe(mocha()); + .pipe(mocha({ reporter: 'min'})); }); gulp.task('webpack', function () { From 716c686b600bb5cc368a451643189b8a07827550 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Mon, 4 Apr 2016 10:17:36 -0700 Subject: [PATCH 45/60] feat(client): mirror the `python-montage` wrapper's implemenation of Client --- src/client.js | 71 +++++++++++++------- tests/client_test.js | 154 +++++++++++++++++++++++++++---------------- 2 files changed, 143 insertions(+), 82 deletions(-) diff --git a/src/client.js b/src/client.js index f932776..71529b3 100644 --- a/src/client.js +++ b/src/client.js @@ -8,17 +8,12 @@ import RoleAPI from './api/role'; import SchemaAPI from './api/schema'; import UserAPI from './api/user'; +const BASE_URL = 'mntge.com'; + export default class Client { - constructor(params = {}) { - params.api_version = params.api_version || 1; - this.params = params; - if (this.params.url) { - this.url_prefix = this.params.url; - } else if (this.params.dev) { - this.url_prefix = `http://${params.domain}.dev.montagehot.club/api/v${params.api_version}/`; - } else { - this.url_prefix = `https://${params.domain}.mntge.com/api/v${params.api_version}/`; - } + constructor(subdomain, token, url = BASE_URL) { + this.hostname = `${subdomain}.${url}`; + this.token = token; this.documents = new DocumentAPI(this); this.schemas = new SchemaAPI(this); @@ -27,50 +22,76 @@ export default class Client { this.files = new FileAPI(this); } - auth() { - return this.request("auth/", "POST", { - username: this.params.username, - password: this.params.password, + url(endpoint) { + return `https://${this.hostname}/api/v1/${endpoint}`; + } + + authenticate(email, password) { + return this.request('user/', 'POST', { + username: email, + password: password }).then(response => { - this.params.token = response.data.token; + this.token = response.data.token; return response; }); } - request(url, method, data, file) { + user() { + if(this.token) { + return this.request('user/'); + } + + return Promise.reject('The current user is not authenticated.') + } + + execute(queries) { + var querySet = {}; + + for(var key in queries) { + if(queries.hasOwnProperty(key)) { + querySet[key] = queries[key].toJS(); + } + } + + return this.request('execute/', 'POST', querySet); + } + + request(endpoint, method, data, file) { + var requestUrl = this.url(endpoint); + var options = { method: method && method.toUpperCase() || "GET", headers: { accept: 'application/json', - 'X-Requested-With': 'XMLHttpRequest', + 'X-Requested-With': 'XMLHttpRequest' } - } + }; if (!file) { options.headers['Content-Type'] = 'application/json'; } if (data) { if (options.method === "GET") { - url += '?' + querystring.stringify(data); + requestUrl += '?' + querystring.stringify(data); } else { - if(file) options.body = data + if(file) options.body = data; else options.body = JSON.stringify(data); } } - if (this.params.token) { - options.headers.Authorization = `Token ${this.params.token}`; + if (this.token) { + options.headers.Authorization = `Token ${this.token}`; } if (options.body) { //Varnish and heroku require a content length! options.headers['Content-Length'] = getByteLen(options.body); } - var reqUrl = `${this.url_prefix}${url}` - return this._agent(reqUrl, options).then(function(response) { + + return this._agent(requestUrl, options).then(function(response) { if(response.status === 204) { return; } if (!response.ok) { response.request = _.merge({ - url: reqUrl, + url: requestUrl }, options); return Promise.reject(response); } diff --git a/tests/client_test.js b/tests/client_test.js index e922372..b6fdc87 100644 --- a/tests/client_test.js +++ b/tests/client_test.js @@ -1,13 +1,10 @@ import expect from 'expect.js'; import querystring from 'querystring'; import {Client, Query} from '../src/index'; -import _ from 'lodash'; -import FormData from 'form-data'; import {EventEmitter} from 'events'; var emitter = new EventEmitter(); - function mockedRequest(url, options) { var self = {}; self.method = options.method; @@ -15,7 +12,7 @@ function mockedRequest(url, options) { self.body = options.body; self.url = url; self.getParams = null; - if (_.indexOf(url, '?') !== -1) { + if (url.indexOf('?') !== -1) { self.getParams = querystring.parse(url.split('?')[1]); self.url = url.split('?')[0]; } @@ -54,61 +51,129 @@ describe('Client', () => { let client; beforeEach(() => { - client = new MockedClient(); + client = new MockedClient('testco'); }); - describe('initialize', () => { - context('when the api version is not specified', () => { - it('should set a default api version of 1', () => { - var client = new Client(); - expect(client.params.api_version).to.be(1); + describe('initialization', () => { + context('when a url argument is not supplied', () => { + it('should set the hostname to the Montage production site', () => { + var client = new MockedClient('testco'); + expect(client.hostname).to.be('testco.mntge.com'); }); }); - context('when the api version is specified', () => { - it('should set the version', () => { - var client = new Client({api_version: 4}); - expect(client.params.api_version).to.be(4); + context('when a url argument is supplied', () => { + it('should set the hostname to the supplied url', () => { + var client = new MockedClient('testco', null, 'not-mntge.com'); + expect(client.hostname).to.be('testco.not-mntge.com'); }); }); + }); + + describe('#url()', () => { + it('should return a url to the specified endpoint', () => { + expect(client.url('user/')).to.be('https://testco.mntge.com/api/v1/user/'); + }); + }); + + describe('#authenticate()', (done) => { + it('should set the user token when the credentials are valid', () => { + var endpoint = 'https://testco.mntge.com/api/v1/user/'; + + expect(client.token).to.be(undefined); + + emitter.once('request', (request) => { + expect(request.url).to.be(endpoint); + expect(request.method).to.be('POST'); + expect(request.body).to.eql(JSON.stringify({ + username: 'test@example.com', + password: 'letmein' + })); + request.callback(null, { + ok: true, + body: {data: {token: 'USER_TOKEN'}}, + }); + }); - context('when a url param is passed in', () => { - it('should set the url prefix to the url', () => { - var client = new Client({url: 'https://www.foo.com'}); - expect(client.url_prefix).to.be('https://www.foo.com'); + client.authenticate('test@example.com', 'letmein').then((response) => { + expect(response).to.be.eql({data: {token: 'USER_TOKEN'}}); + expect(client.token).to.eql('USER_TOKEN'); + done(); }); }); - context('when a url param is not passed in', () => { - it('should set the url to the montage production site', () => { - var client = new Client({domain: 'foo'}); - expect(client.url_prefix).to.be('https://foo.mntge.com/api/v1/'); + it('should not set a token when the credentials are invalid', (done) => { + var endpoint = 'https://testco.mntge.com/api/v1/user/'; + expect(client.token).to.be(undefined); + + emitter.once('request', (request) => { + expect(request.url).to.be(endpoint); + expect(request.method).to.be('POST'); + expect(request.body).to.be('{"username":"fake@example.com","password":"invalid"}'); + request.callback(null, { + ok: true, + status: 401, + body: JSON.stringify([{'detail': 'Incorrect authentication credentials.'}]), + }); + }); + + client.authenticate('fake@example.com', 'invalid').then(response => { + expect().fail(); + }, error => { + expect(error).to.eql([{'detail': 'Incorrect authentication credentials.'}]) + expect(client.token).to.be(undefined); + done(); }); }); + }); + + describe('#user()', (done) => { + it('should reject the promise when the user is unauthenticated', () => { + client.user().then( + function resolved() { + expect().fail(); + }, + function rejected() { + done(); + } + ); + }); + + it('should resolve the promise when the user is authenticated', (done) => { + var client = new MockedClient('testco', 'USER_TOKEN'); + var endpoint = 'https://testco.mntge.com/api/v1/user/'; + + emitter.once('request', (request) => { + expect(request.url).to.be(endpoint); + expect(request.method).to.be('GET'); + expect(request.body).to.be(undefined); + request.callback(null, { + ok: true, + body: 'resolved promise', + }); + }); - context('when the dev param is set to true', () => { - it('should use the dev montage domain', () => { - var client = new Client({dev: true, domain: 'foo'}); - expect(client.url_prefix).to.be('http://foo.dev.montagehot.club/api/v1/'); + client.user().then(response => { + expect(response).to.be('resolved promise'); + done(); }); }); }); - describe('request', () => { - it('rejects validation errors and attempts to return JSON', () => { + describe('#request()', () => { + it('rejects validation errors and attempts to return JSON', (done) => { emitter.once('request', (request) => { request.callback(null, { ok: true, status: 403, - body: JSON.stringify({errors: ['something went wrong']}), + body: JSON.stringify({errors: ['something went wrong']}) }); - }); return client.request('#').then(response => { - expect.fail(); + expect().fail(); }, error => { - //console.log(error); expect(error).to.be.eql({errors: ['something went wrong']}); + done(); }); }); @@ -124,7 +189,6 @@ describe('Client', () => { return client.request('#').then(response => { expect.fail(); }, error => { - //console.log(error); expect(error).to.be.eql(['something went wrong']); }); }); @@ -140,34 +204,10 @@ describe('Client', () => { return client.request('#').then(response => { expect.fail(); }, error => { - //console.log(error); return error.text().then(text => { expect(text).to.be.eql('something went wrong'); }); }); }); }); - - describe('auth', () => { - it('returns promise from auth endpoint and sends login info', () => { - emitter.once('request', (request) => { - expect(_.last(request.url.split('/v1/'))).to.be('auth/'); - expect(request.method).to.be('POST'); - expect(request.body).to.be.eql(JSON.stringify({ - username: 'johnsmith', - password: 'secret', - })); - request.callback(null, { - ok: true, - body: {data: {token: 'FOO'}}, - }); - }); - client.params.username = 'johnsmith'; - client.params.password = 'secret'; - return client.auth().then((response) => { - expect(response).to.be.eql({data: {token: 'FOO'}}) - }); - expect(client.params.token).to.be.eql('FOO'); - }); - }); }); From b1a616a54556f8a71453034d77853cd9e1f56231 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Mon, 4 Apr 2016 11:05:32 -0700 Subject: [PATCH 46/60] feat(query): mirror `python-montage` wrapper's implementation of Query --- src/query.js | 166 ++++++++++++++----------- tests/query_test.js | 286 ++++++++++++++++++++------------------------ 2 files changed, 224 insertions(+), 228 deletions(-) diff --git a/src/query.js b/src/query.js index 638f69f..97f72e7 100644 --- a/src/query.js +++ b/src/query.js @@ -1,107 +1,127 @@ import _ from 'lodash'; export default class Query { - constructor(schemaName, state) { - if (!schemaName) throw "Schema name is required"; - - this.schemaName = schemaName; - - state = state || { - '$schema': schemaName, - '$query': [ - ['$filter', []] - ] - } - this._state = state; - } - - _merge(delta) { - var state = _.merge({}, this._state, delta); - return new Query(this.schemaName, state); - } - - _mergeArray(delta, prepend = false) { - var index = _.findIndex(this._state['$query'], (item) => { - return item[0] === delta[0]; - }); - - if (index !== -1) { - this._state['$query'][index] = delta; - } else { - if (prepend) { - this._state['$query'].unshift(delta); - } else { - this._state['$query'].push(delta); - } - } + constructor(schema) { + if (!schema) throw 'A schema name is required'; - return new Query(this.schemaName, this._state); + this.schema = schema; + this.terms = []; } - limit(num) { - return this._mergeArray(['$limit', num]); + toJS() { + return { + $schema: this.schema, + $query: this.terms + }; + } + + get(id) { + this.terms.push(['$get', id]); + return this; + } + + getAll(ids, index = 'id') { + this.terms.push(['$get_all', [index, ids]]); + return this; + } + + filter(...filters) { + var filterSet = filters.reduce((filterSet, currentFilter) => { + return filterSet.concat(currentFilter.toJS()); + }, []); + + this.terms.push(['$filter', filterSet]); + return this; + } + + hasFields(...fields) { + this.terms.push(['$has_fields', fields]) + return this; } - offset(num) { - return this._mergeArray(['$offset', num]); + withFields(...fields) { + this.terms.push(['$with_fields', fields]) + return this; } - order(order_by, ordering) { - var parsedOrder; - if(_.isString(ordering)) { - parsedOrder = `$${ordering}`; - } else { - parsedOrder = ordering < 0 ? "$desc" : "$asc"; + orderBy(field, ordering = 'asc') { + if(ordering !== 'asc' && ordering !== 'desc') { + throw new Error('ordering must be desc or asc'); } - return this._mergeArray(['$order_by', [parsedOrder, order_by]]); + ordering = '$' + ordering; + this.terms.push(['$order_by', field, ordering]) + return this; } - pluck(fields) { - return this._mergeArray(['$pluck', fields]); + skip(num) { + this.terms.push(['$skip', num]); + return this; } - without(fields) { - return this._mergeArray(['$without', fields]); + limit(num) { + this.terms.push(['$limit', num]); + return this; } - pageSize(size) { - return this._mergeArray(['$limit', size]); + slice(start, end) { + this.terms.push(['$slice', [start, end]]); + return this; } - index(indexName) { - return this._mergeArray(['$index', indexName]); + nth(num) { + this.terms.push(['$nth', num]); + return this; } - filter(params) { - var filterIndex = _.findIndex(this._state['$query'], (item) => { - return item[0] === '$filter'; - }); - var filters = this._state['$query'][filterIndex]; + sample(num) { + this.terms.push(['$sample', num]); + return this; + } - Object.keys(params).forEach((key) => { - var [field, operator] = key.split("__"); - var queryField = operator ? [`$${operator}`, params[key]] : params[key]; + pluck(...fields) { + this.terms.push(['$pluck', fields]); + return this; + } - filters[1].push([field, queryField]); - }) + without(...fields) { + this.terms.push(['$without', fields]); + return this; + } - return this._mergeArray(filters); + group(field) { + this.terms.push(['$group', field]); + return this; } - where(params) { - //alias - return this.filter(params); + count() { + this.terms.push(['$count']); + return this; } - between(params) { - if (params && params.from && params.to) { - return this._mergeArray(['$between', [params.from, params.to, params.index]], true) - } + sum(field) { + this.terms.push(['$sum', field]); return this; } - toJS() { - return this._state; + avg(field) { + this.terms.push(['$avg', field]); + return this; + } + + min(field) { + this.terms.push(['$min', field]); + return this; + } + + max(field) { + this.terms.push(['$max', field]); + return this; + } + + between(start, end, index) { + var value = index ? [start, end, index] : [start, end]; + this.terms.push(['$between', value]); + return this; } } diff --git a/tests/query_test.js b/tests/query_test.js index 3035022..bd6ce82 100644 --- a/tests/query_test.js +++ b/tests/query_test.js @@ -1,197 +1,173 @@ import expect from 'expect.js'; import {Query} from '../src/index'; -import _ from 'lodash'; +var query; describe('Query', () => { - describe('initialize', () => { + beforeEach(function() { + query = new Query('testSchema'); + }); + + describe('initialization', () => { it('should require a schema name', () => { - var query = new Query("foo"); - expect(query.schemaName).to.be("foo"); - }); - - it('should setup the default query object', () => { - var query = new Query("foo"); - var expected = { - '$schema': 'foo', - '$query': [['$filter', []]] - }; - - expect(query.toJS()).to.eql(expected); - }); - - it('should not overwrite default state', () => { - var query = new Query("foo", {bar: "baz"}) - expect(query.toJS()).to.eql({bar: "baz"}) - }) - }); - - describe('_mergeArray', () => { - context('when the item exists already', () => { - it('should overwrite it with the new item', () => { - var state = { - '$schema': 'foo', - '$query': [ - ['$filter', []], - ['$limit', 5] - ] - }; - var expected = { - '$schema': 'foo', - '$query': [ - ['$filter', []], - ['$limit', 6] - ] - }; - var query = new Query('foo', state); - expect(query._mergeArray(['$limit', 6]).toJS()).to.eql(expected); - }) - }) - - context('when the item does not exist already', () => { - it('should add the new item', () => { - var state = { - '$schema': 'foo', - '$query': [ - ['$filter', []], - ['$limit', 6] - ] - }; - var query = new Query('foo'); - expect(query._mergeArray(['$limit', 6]).toJS()).to.eql(state); - }) - }) - - context('when the prepend option is true', () => { - it('should prepend the query', () => { - var state = { - '$schema': 'foo', - '$query': [ - ['$between', 'foo'], - ['$filter', []] - ] - }; - var query = new Query('foo'); - expect(query._mergeArray(['$between', 'foo'], true).toJS()).to.eql(state); - }) - }) - }) - - describe('limit', () => { - it('sets limit', () => { - var query = new Query('foo'); - var params = query.limit(5).toJS(); - var expected = [['$filter', []], ['$limit', 5]]; + expect(query.schema).to.be('testSchema'); + }); + }); + + describe('#toJS()', () => { + it('should return a query object', () => { + expect(query.toJS()).to.eql({ + $schema: 'testSchema', + $query: [] + }); + }); + }); + + describe('#get()', () => { + it('sets get', () => { + query.get('1234'); + expect(query.terms).to.eql([['$get', '1234']]); + }); + }); + + describe('#getAll()', () => { + it('sets getAll', () => { + query.getAll(['1234', 'abcd']); + expect(query.terms).to.eql([['$get_all', ['id', ['1234', 'abcd']]]]); + }); + }); + + describe('#hasFields()', () => { + it('sets hasFields', () => { + query.hasFields('title', 'rating'); + expect(query.terms).to.eql([['$has_fields', ['title', 'rating']]]); + }); + }); - expect(params['$query']).to.eql(expected); + describe('#withFields()', () => { + it('sets withFields', () => { + query.withFields('title', 'rating'); + expect(query.terms).to.eql([['$with_fields', ['title', 'rating']]]); }); }); - describe('offset', () => { - it('sets offset', () => { - var query = new Query('foo'); - var params = query.offset(5).toJS(); - var expected = [['$filter', []], ['$offset', 5]]; - expect(params['$query']).to.eql(expected); + describe('#orderBy()', () => { + context('when no direction supplied', () => { + it('sets order_by and default direction', () => { + query.orderBy('rating'); + expect(query.terms).to.eql([['$order_by', 'rating', '$asc']]); + }); + }); + + context('when direction is ascending', () => { + it('sets order_by and ascending direction', () => { + query.orderBy('rating', 'asc'); + expect(query.terms).to.eql([['$order_by', 'rating', '$asc']]); + }); + }); + + context('when direction is descending', () => { + it('sets order_by and descending direction', () => { + query.orderBy('rating', 'desc'); + expect(query.terms).to.eql([['$order_by', 'rating', '$desc']]); + }); + }); + + context('when direction is invalid', () => { + it('should throw an exception', () => { + expect(query.orderBy).withArgs('rating', -1).to.throwException(); + }); }); }); - describe('order', () => { - it('sets order_by and direction', () => { - var query = new Query('foo'); - var params = query.order('rating', -1).toJS(); - var expected = [['$filter', []], ['$order_by', ['$desc', 'rating']]]; - expect(params['$query']).to.eql(expected); + describe('#skip()', () => { + it('sets skip', () => { + query.skip(10); + expect(query.terms).to.eql([['$skip', 10]]); + }); + }); - expected = [['$filter', []], ['$order_by', ['$asc', 'rating']]]; - params = query.order('rating', 1).toJS(); - expect(params['$query']).to.eql(expected); + describe('#limit()', () => { + it('sets limit', () => { + query.limit(10); + expect(query.terms).to.eql([['$limit', 10]]); }); + }); + + describe('#slice()', () => { + it('sets slice', () => { + query.slice(10, 20); + expect(query.terms).to.eql([['$slice', [10, 20]]]); + }); + }); - it('sets order_by and direction by string', () => { - var query = new Query('foo'); - var params = query.order('rating', 'desc').toJS(); - var expected = [['$filter', []], ['$order_by', ['$desc', 'rating']]]; - expect(params['$query']).to.eql(expected); + describe('#nth()', () => { + it('sets nth', () => { + query.nth(5); + expect(query.terms).to.eql([['$nth', 5]]); + }); + }); - expected = [['$filter', []], ['$order_by', ['$asc', 'rating']]]; - params = query.order('rating', 'asc').toJS(); - expect(params['$query']).to.eql(expected); + describe('#sample()', () => { + it('sets sample', () => { + query.sample(20); + expect(query.terms).to.eql([['$sample', 20]]); }); }); - describe('filter', () => { - it('sets filter params', () => { - var query = new Query('foo'); - var params = query.filter({rating__gt: 5}).toJS(); - var expected = [['$filter', [['rating', ['$gt', 5]]]]]; - expect(params['$query']).to.eql(expected); + describe('#pluck()', () => { + it('sets pluck', () => { + query.pluck('name', 'rank', 'rating'); + expect(query.terms).to.eql([['$pluck', ['name', 'rank', 'rating']]]); }); + }); - it('merges filter params', () => { - var query = new Query('foo'); - var params = query.filter({rating__gt: 5}) - .filter({author: 'speilberg'}) - .toJS(); - var expected = [ - ['$filter', [ - ['rating', ['$gt', 5]], - ['author', 'speilberg'] - ]] - ]; - expect(params['$query']).to.eql(expected); + describe('#without()', () => { + it('sets without', () => { + query.without('votes', 'rank'); + expect(query.terms).to.eql([['$without', ['votes', 'rank']]]); }); }); - describe('pluck', () => { - it('sets pluck params', () => { - var query = new Query('foo'); - var params = query.pluck(['rating', 'id']).toJS(); - var expected = [['$filter', []], ['$pluck', ['rating', 'id']]]; - expect(params['$query']).to.be.eql(expected); + describe('#count()', () => { + it('sets count', () => { + query.count(); + expect(query.terms).to.eql([['$count']]); }); }); - describe('without', () => { - it('sets without params', () => { - var query = new Query('foo'); - var params = query.without(['blob']).toJS(); - var expected = [['$filter', []], ['$without', ['blob']]]; - expect(params['$query']).to.be.eql(expected); + describe('#sum()', () => { + it('sets sum', () => { + query.sum('rank'); + expect(query.terms).to.eql([['$sum', 'rank']]); }); }); - describe('pageSize', () => { - it('sets batch_size params', () => { - var query = new Query('foo'); - var params = query.pageSize(20).toJS(); - var expected = [['$filter', []], ['$limit', 20]]; - expect(params['$query']).to.be.eql(expected); + describe('#avg()', () => { + it('sets avg', () => { + query.avg('rank'); + expect(query.terms).to.eql([['$avg', 'rank']]); }); }); - describe('index', () => { - it('sets index params', () => { - var query = new Query('foo'); - var params = query.index('fullText').toJS(); - var expected = [['$filter', []], ['$index', 'fullText']]; - expect(params['$query']).to.be.eql(expected); + describe('#min()', () => { + it('sets min', () => { + query.min('rating'); + expect(query.terms).to.eql([['$min', 'rating']]); }); }); - describe('between', () => { - it('should require a from and a to', () => { - var query = new Query('foo'); - var params = query.between().toJS(); - var expected = [['$filter', []]]; - expect(params['$query']).to.be.eql(expected); + describe('#max()', () => { + it('sets max', () => { + query.max('rating'); + expect(query.terms).to.eql([['$max', 'rating']]); }); + }); - it('should prepend the between operator', () => { - var query = new Query('foo'); - var params = query.between({from: 1, to: 10, index: 'rank'}).toJS(); - var expected = [['$between', [1, 10, 'rank']], ['$filter', []]]; - expect(params['$query']).to.be.eql(expected); + describe('#between()', () => { + it('sets between', () => { + query.between(0, 10, 'rank'); + expect(query.terms).to.eql([['$between', [0, 10, 'rank']]]); }); }); }); From fe14bf9a16e737a0ffc12e2cf95037abff2ad7a8 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Tue, 5 Apr 2016 12:43:28 -0700 Subject: [PATCH 47/60] feat(field): create a `Field` class that allows users to apply filters to their queries --- src/field.js | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/index.js | 2 ++ 2 files changed, 94 insertions(+) create mode 100644 src/field.js diff --git a/src/field.js b/src/field.js new file mode 100644 index 0000000..7be6420 --- /dev/null +++ b/src/field.js @@ -0,0 +1,92 @@ +export default class Field { + constructor(field) { + this.field = field; + this.filters = []; + } + + toJS() { + return this.filters.map(filter => { + return [this.field, filter]; + }); + } + + eq(value) { + this.filters.push(["$eq", value]); + return this; + } + + ieq(value) { + this.filters.push(["$ieq", value]); + return this; + } + + ne(value) { + this.filters.push(["$ne", value]); + return this; + } + + lt(value) { + this.filters.push(["$lt", value]); + return this; + } + + le(value) { + this.filters.push(["$le", value]); + return this; + } + + gt(value) { + this.filters.push(["$gt", value]); + return this; + } + + ge(value) { + this.filters.push(["$ge", value]); + return this; + } + + inSet(...values) { + this.filters.push(["$in", values]); + return this; + } + + contains(value) { + this.filters.push(["$contains", value]); + return this; + } + + regex(expression) { + this.filters.push(["$regex", expression]); + return this; + } + + starts(value) { + this.filters.push(["$starts", value]); + return this; + } + + istarts(value) { + this.filters.push(["$istarts", value]); + return this; + } + + ends(value) { + this.filters.push(["$ends", value]); + return this; + } + + iends(value) { + this.filters.push(["$iends", value]); + return this; + } + + intersects(value) { + this.filters.push(["$intersects", value]); + return this; + } + + includes(value) { + this.filters.push(["$includes", value]); + return this; + } +} diff --git a/src/index.js b/src/index.js index 006e538..34590b9 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,9 @@ import Client from './client'; import Query from './query'; +import Field from './field'; export { Client, + Field, Query }; From 824a86dcd765a26a54518abc2c6416e50b883521 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Tue, 5 Apr 2016 12:45:02 -0700 Subject: [PATCH 48/60] feat(PolicyAPI): create `PolicyAPI` --- src/api/policy.js | 55 +++++++++++++++++++++++++++++++++++++++++++++++ src/client.js | 2 ++ 2 files changed, 57 insertions(+) create mode 100644 src/api/policy.js diff --git a/src/api/policy.js b/src/api/policy.js new file mode 100644 index 0000000..baed3cd --- /dev/null +++ b/src/api/policy.js @@ -0,0 +1,55 @@ +export default class PolicyAPI { + constructor(client) { + this.client = client; + } + + create(description, policy) { + var payload = { + description, + policy + }; + + return this.client.request('policy/', 'POST', payload); + } + + list() { + return this.client.request('policy/'); + } + + get(policy_id) { + return this.client.request(`policy/${policy_id}/`); + } + + update(policy_id, description, policy) { + if(!description && !policy) { + throw new Error('Must provide a `description` or `policy`'); + } + + var payload = {}; + + if(description) { + payload.description = description; + } + + if(policy) { + payload.policy = policy; + } + + if(payload) { + return this.client.request(`policy/${policy_id}/`, 'PATCH', payload); + } + } + + remove(policy_id) { + return this.client.request(`policy/${policy_id}/`, 'DELETE'); + } + + checkPermission(action, resource) { + var payload = { + action, + resource + }; + + return this.client.request('policy/check/', 'GET', payload); + } +} diff --git a/src/client.js b/src/client.js index 71529b3..1da2b14 100644 --- a/src/client.js +++ b/src/client.js @@ -7,6 +7,7 @@ import FileAPI from './api/file'; import RoleAPI from './api/role'; import SchemaAPI from './api/schema'; import UserAPI from './api/user'; +import PolicyAPI from './api/policy'; const BASE_URL = 'mntge.com'; @@ -20,6 +21,7 @@ export default class Client { this.users = new UserAPI(this); this.roles = new RoleAPI(this); this.files = new FileAPI(this); + this.policy = new PolicyAPI(this); } url(endpoint) { From 574f4cf4ffa587943f2f656bab4b58b0b108233d Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Tue, 5 Apr 2016 12:45:56 -0700 Subject: [PATCH 49/60] feat(scripting): create `Script` and `RunLua` classes --- src/scripting.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/scripting.js diff --git a/src/scripting.js b/src/scripting.js new file mode 100644 index 0000000..e500d6d --- /dev/null +++ b/src/scripting.js @@ -0,0 +1,27 @@ +class Script { + constructor(name) { + this.name = name + } + + toJS() { + return { + $type: 'script', + $name: this.name + }; + } + +} + +class RunLua { + constructor(code) { + this.code = code; + } + + toJS() { + return { + $type: 'lua', + $code: this.code + }; + } +} + From 3a2ec6f416b32a761202dd8242cfdd8212d56d29 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Fri, 15 Apr 2016 17:13:09 -0700 Subject: [PATCH 50/60] chore(package.js): use `dist/montage.js` as the `main` file --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 72d0555..60b1068 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "montagedata", "version": "2.1.0", - "main": "dist/index.js", + "main": "dist/montage.js", "description": "Client library for Montage Data", "scripts": { "test": "gulp test" From 80493319745d9175e0126754db153a61e5b0bf4a Mon Sep 17 00:00:00 2001 From: dmpayton Date: Tue, 19 Apr 2016 19:20:14 -0700 Subject: [PATCH 51/60] feat(query): Implement get_nearest and get_intersecting. --- src/query.js | 10 ++++++++++ tests/query_test.js | 22 ++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/query.js b/src/query.js index 97f72e7..c74db16 100644 --- a/src/query.js +++ b/src/query.js @@ -124,4 +124,14 @@ export default class Query { this.terms.push(['$between', value]); return this; } + + get_intersecting(geometry, index) { + this.terms.push(['$get_intersecting', [index, geometry]]); + return this; + } + + get_nearest(geometry, index) { + this.terms.push(['$get_nearest', [index, geometry]]); + return this; + } } diff --git a/tests/query_test.js b/tests/query_test.js index bd6ce82..b4a6e37 100644 --- a/tests/query_test.js +++ b/tests/query_test.js @@ -170,4 +170,26 @@ describe('Query', () => { expect(query.terms).to.eql([['$between', [0, 10, 'rank']]]); }); }); + + describe('#get_intersecting()', () => { + it('sets get_intersecting', () => { + var point = { + 'type': 'Point', + 'coordinates': [-120.34589052200315, 36.12704320788633] + }; + query.get_intersecting(point, 'location'); + expect(query.terms).to.eql([['$get_intersecting', ['location', point]]]); + }); + }); + + describe('#get_nearest()', () => { + it('sets get_nearest', () => { + var point = { + 'type': 'Point', + 'coordinates': [-120.34589052200315, 36.12704320788633] + }; + query.get_nearest(point, 'location'); + expect(query.terms).to.eql([['$get_nearest', ['location', point]]]); + }); + }); }); From cd394c7343be05846d9d9c3ad4e30ca937a43ad0 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Tue, 19 Apr 2016 20:47:05 -0700 Subject: [PATCH 52/60] style(query): change snake_case to camelCase --- src/query.js | 4 ++-- tests/query_test.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/query.js b/src/query.js index c74db16..a41cf78 100644 --- a/src/query.js +++ b/src/query.js @@ -125,12 +125,12 @@ export default class Query { return this; } - get_intersecting(geometry, index) { + getIntersecting(geometry, index) { this.terms.push(['$get_intersecting', [index, geometry]]); return this; } - get_nearest(geometry, index) { + getNearest(geometry, index) { this.terms.push(['$get_nearest', [index, geometry]]); return this; } diff --git a/tests/query_test.js b/tests/query_test.js index b4a6e37..bf09671 100644 --- a/tests/query_test.js +++ b/tests/query_test.js @@ -171,24 +171,24 @@ describe('Query', () => { }); }); - describe('#get_intersecting()', () => { + describe('#getIntersecting()', () => { it('sets get_intersecting', () => { var point = { 'type': 'Point', 'coordinates': [-120.34589052200315, 36.12704320788633] }; - query.get_intersecting(point, 'location'); + query.getIntersecting(point, 'location'); expect(query.terms).to.eql([['$get_intersecting', ['location', point]]]); }); }); - describe('#get_nearest()', () => { + describe('#getNearest()', () => { it('sets get_nearest', () => { var point = { 'type': 'Point', 'coordinates': [-120.34589052200315, 36.12704320788633] }; - query.get_nearest(point, 'location'); + query.getNearest(point, 'location'); expect(query.terms).to.eql([['$get_nearest', ['location', point]]]); }); }); From 727ed6ac7f78892fc67c6799292c6c773a139e3a Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Tue, 3 May 2016 13:54:09 -0700 Subject: [PATCH 53/60] refactor(client): remove the `url` parameter. use `this.host` instead --- src/client.js | 9 ++++----- tests/client_test.js | 23 +++++++---------------- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/src/client.js b/src/client.js index 1da2b14..6c5dd1d 100644 --- a/src/client.js +++ b/src/client.js @@ -9,11 +9,10 @@ import SchemaAPI from './api/schema'; import UserAPI from './api/user'; import PolicyAPI from './api/policy'; -const BASE_URL = 'mntge.com'; - export default class Client { - constructor(subdomain, token, url = BASE_URL) { - this.hostname = `${subdomain}.${url}`; + constructor(subdomain, token) { + this.host = 'mntge.com'; + this.subdomain = subdomain; this.token = token; this.documents = new DocumentAPI(this); @@ -25,7 +24,7 @@ export default class Client { } url(endpoint) { - return `https://${this.hostname}/api/v1/${endpoint}`; + return `https://${this.subdomain}.${this.host}/api/v1/${endpoint}`; } authenticate(email, password) { diff --git a/tests/client_test.js b/tests/client_test.js index b6fdc87..7f572c2 100644 --- a/tests/client_test.js +++ b/tests/client_test.js @@ -54,26 +54,17 @@ describe('Client', () => { client = new MockedClient('testco'); }); - describe('initialization', () => { - context('when a url argument is not supplied', () => { - it('should set the hostname to the Montage production site', () => { - var client = new MockedClient('testco'); - expect(client.hostname).to.be('testco.mntge.com'); - }); - }); - - context('when a url argument is supplied', () => { - it('should set the hostname to the supplied url', () => { - var client = new MockedClient('testco', null, 'not-mntge.com'); - expect(client.hostname).to.be('testco.not-mntge.com'); - }); - }); - }); - describe('#url()', () => { it('should return a url to the specified endpoint', () => { expect(client.url('user/')).to.be('https://testco.mntge.com/api/v1/user/'); }); + + context('when a custom host is supplied', () => { + it('should use the supplied host', () => { + client.host = 'not-mntge.com'; + expect(client.url('')).to.be('https://testco.not-mntge.com/api/v1/'); + }); + }); }); describe('#authenticate()', (done) => { From 163e4fe8523eb863a5422d789b3697192aefec89 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Tue, 3 May 2016 13:54:43 -0700 Subject: [PATCH 54/60] feat(client): allow users to specify a protocol --- src/client.js | 3 ++- tests/client_test.js | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/client.js b/src/client.js index 6c5dd1d..25ad426 100644 --- a/src/client.js +++ b/src/client.js @@ -11,6 +11,7 @@ import PolicyAPI from './api/policy'; export default class Client { constructor(subdomain, token) { + this.protocol = 'https'; this.host = 'mntge.com'; this.subdomain = subdomain; this.token = token; @@ -24,7 +25,7 @@ export default class Client { } url(endpoint) { - return `https://${this.subdomain}.${this.host}/api/v1/${endpoint}`; + return `${this.protocol}://${this.subdomain}.${this.host}/api/v1/${endpoint}`; } authenticate(email, password) { diff --git a/tests/client_test.js b/tests/client_test.js index 7f572c2..bbd13a8 100644 --- a/tests/client_test.js +++ b/tests/client_test.js @@ -65,6 +65,13 @@ describe('Client', () => { expect(client.url('')).to.be('https://testco.not-mntge.com/api/v1/'); }); }); + + context('when a custom protocol is supplied', () => { + it('should use the supplied protocol', () => { + client.protocol = 'test'; + expect(client.url('')).to.be('test://testco.mntge.com/api/v1/'); + }); + }); }); describe('#authenticate()', (done) => { From 44d72788624c21f2c6cf4510e2393632cb22dd3f Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Tue, 3 May 2016 13:55:37 -0700 Subject: [PATCH 55/60] refactor(client): rename `subdomain` to `project` --- src/client.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client.js b/src/client.js index 25ad426..e1940eb 100644 --- a/src/client.js +++ b/src/client.js @@ -10,10 +10,10 @@ import UserAPI from './api/user'; import PolicyAPI from './api/policy'; export default class Client { - constructor(subdomain, token) { + constructor(project, token) { this.protocol = 'https'; this.host = 'mntge.com'; - this.subdomain = subdomain; + this.project = project; this.token = token; this.documents = new DocumentAPI(this); @@ -25,7 +25,7 @@ export default class Client { } url(endpoint) { - return `${this.protocol}://${this.subdomain}.${this.host}/api/v1/${endpoint}`; + return `${this.protocol}://${this.project}.${this.host}/api/v1/${endpoint}`; } authenticate(email, password) { From e06b7d2c36d3a7b7accb00ca19dae4fe74f6cc35 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Tue, 19 Jul 2016 14:07:34 -0700 Subject: [PATCH 56/60] fix(client): add `babel-polyfill` to fix an issue with undefined `Promise` in IE fixes #13 --- package.json | 1 + src/client.js | 1 + 2 files changed, 2 insertions(+) diff --git a/package.json b/package.json index 60b1068..b3f1505 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "babel-core": "^6.7.2", "babel-loader": "^6.2.4", "babel-plugin-transform-runtime": "^6.6.0", + "babel-polyfill": "^6.9.1", "babel-preset-es2015": "^6.6.0", "expect.js": "~0.3.1", "form-data": "^1.0.0-rc3", diff --git a/src/client.js b/src/client.js index e1940eb..1e8a15c 100644 --- a/src/client.js +++ b/src/client.js @@ -1,6 +1,7 @@ import fetch from 'isomorphic-fetch'; import querystring from 'querystring'; import _ from 'lodash'; +import 'babel-polyfill'; import DocumentAPI from './api/document'; import FileAPI from './api/file'; From f0a0a6253554f1ffbeb2106a5c8425cca733155e Mon Sep 17 00:00:00 2001 From: Jason Kraus Date: Wed, 3 Aug 2016 17:18:12 -0700 Subject: [PATCH 57/60] emergency fix to pass query along --- src/query.js | 1 + tests/query_test.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/query.js b/src/query.js index a41cf78..6dac071 100644 --- a/src/query.js +++ b/src/query.js @@ -10,6 +10,7 @@ export default class Query { toJS() { return { + $type: 'query', $schema: this.schema, $query: this.terms }; diff --git a/tests/query_test.js b/tests/query_test.js index bf09671..5aaa1f6 100644 --- a/tests/query_test.js +++ b/tests/query_test.js @@ -17,6 +17,7 @@ describe('Query', () => { describe('#toJS()', () => { it('should return a query object', () => { expect(query.toJS()).to.eql({ + $type: 'query', $schema: 'testSchema', $query: [] }); From 3c974ef9af8760c34e745d6ae2816ac205f33f2e Mon Sep 17 00:00:00 2001 From: Jason Kraus Date: Tue, 13 Sep 2016 12:13:49 -0700 Subject: [PATCH 58/60] nodejs loads a non-minified version of montage [dist/index.js], bower loads a minified version of montage [dist/montage.js] --- bower.json | 17 +++ dist/api/document.js | 64 ++++++++ dist/api/file.js | 49 +++++++ dist/api/policy.js | 84 +++++++++++ dist/api/role.js | 76 ++++++++++ dist/api/schema.js | 72 +++++++++ dist/api/user.js | 74 ++++++++++ dist/client.js | 207 ++++++++++++++++++++++++++ dist/field.js | 138 ++++++++++++++++++ dist/index.js | 339 ++----------------------------------------- dist/montage.js | 9 +- dist/query.js | 210 +++++++++++++++++++++++++++ dist/scripting.js | 49 +++++++ package.json | 2 +- 14 files changed, 1060 insertions(+), 330 deletions(-) create mode 100644 bower.json create mode 100644 dist/api/document.js create mode 100644 dist/api/file.js create mode 100644 dist/api/policy.js create mode 100644 dist/api/role.js create mode 100644 dist/api/schema.js create mode 100644 dist/api/user.js create mode 100644 dist/client.js create mode 100644 dist/field.js create mode 100644 dist/query.js create mode 100644 dist/scripting.js diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..3c9c6ad --- /dev/null +++ b/bower.json @@ -0,0 +1,17 @@ +{ + "name": "montagedata", + "description": "Client library for Montage Data", + "main": "dist/montage.js", + "authors": [ + "Jason Kraus " + ], + "license": "MIT", + "homepage": "https://github.com/Montage-Inc/javascript-montage", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ] +} diff --git a/dist/api/document.js b/dist/api/document.js new file mode 100644 index 0000000..e100192 --- /dev/null +++ b/dist/api/document.js @@ -0,0 +1,64 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); + +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + +var _createClass2 = require('babel-runtime/helpers/createClass'); + +var _createClass3 = _interopRequireDefault(_createClass2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var DocumentAPI = function () { + function DocumentAPI(client) { + (0, _classCallCheck3.default)(this, DocumentAPI); + + this.client = client; + } + + (0, _createClass3.default)(DocumentAPI, [{ + key: 'list', + value: function list(schema) { + var endpoint = 'schemas/' + schema + '/documents/'; + return this.client.request(endpoint); + } + }, { + key: 'save', + value: function save(schema, documents) { + var endpoint = 'schemas/' + schema + '/documents/'; + return this.client.request(endpoint, 'POST', documents); + } + }, { + key: 'get', + value: function get(schema, document_id) { + var endpoint = 'schemas/' + schema + '/documents/' + document_id + '/'; + return this.client.request(endpoint); + } + }, { + key: 'replace', + value: function replace(schema, document) { + var endpoint = 'schemas/' + schema + '/documents/' + document.id + '/'; + return this.client.request(endpoint, 'PUT', document); + } + }, { + key: 'update', + value: function update(schema, document) { + var endpoint = 'schemas/' + schema + '/documents/' + document.id + '/'; + return this.client.request(endpoint, 'PATCH', document); + } + }, { + key: 'remove', + value: function remove(schema, document_id) { + var endpoint = 'schemas/' + schema + '/documents/' + document_id + '/'; + return this.client.request(endpoint, 'DELETE'); + } + }]); + return DocumentAPI; +}(); + +exports.default = DocumentAPI; \ No newline at end of file diff --git a/dist/api/file.js b/dist/api/file.js new file mode 100644 index 0000000..be2980c --- /dev/null +++ b/dist/api/file.js @@ -0,0 +1,49 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); + +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + +var _createClass2 = require('babel-runtime/helpers/createClass'); + +var _createClass3 = _interopRequireDefault(_createClass2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var FileAPI = function () { + function FileAPI(client) { + (0, _classCallCheck3.default)(this, FileAPI); + + this.client = client; + } + + (0, _createClass3.default)(FileAPI, [{ + key: 'list', + value: function list() { + return this.client.request('files/'); + } + }, { + key: 'get', + value: function get(file_id) { + return this.client.request('files/' + file_id + '/'); + } + }, { + key: 'remove', + value: function remove(file_id) { + var endpoint = 'files/' + file_id + '/'; + return this.client.request(endpoint, 'DELETE'); + } + }, { + key: 'save', + value: function save(formData) { + return this.client.request('files/', 'POST', formData, true); + } + }]); + return FileAPI; +}(); + +exports.default = FileAPI; \ No newline at end of file diff --git a/dist/api/policy.js b/dist/api/policy.js new file mode 100644 index 0000000..ec046bf --- /dev/null +++ b/dist/api/policy.js @@ -0,0 +1,84 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); + +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + +var _createClass2 = require('babel-runtime/helpers/createClass'); + +var _createClass3 = _interopRequireDefault(_createClass2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var PolicyAPI = function () { + function PolicyAPI(client) { + (0, _classCallCheck3.default)(this, PolicyAPI); + + this.client = client; + } + + (0, _createClass3.default)(PolicyAPI, [{ + key: 'create', + value: function create(description, policy) { + var payload = { + description: description, + policy: policy + }; + + return this.client.request('policy/', 'POST', payload); + } + }, { + key: 'list', + value: function list() { + return this.client.request('policy/'); + } + }, { + key: 'get', + value: function get(policy_id) { + return this.client.request('policy/' + policy_id + '/'); + } + }, { + key: 'update', + value: function update(policy_id, description, policy) { + if (!description && !policy) { + throw new Error('Must provide a `description` or `policy`'); + } + + var payload = {}; + + if (description) { + payload.description = description; + } + + if (policy) { + payload.policy = policy; + } + + if (payload) { + return this.client.request('policy/' + policy_id + '/', 'PATCH', payload); + } + } + }, { + key: 'remove', + value: function remove(policy_id) { + return this.client.request('policy/' + policy_id + '/', 'DELETE'); + } + }, { + key: 'checkPermission', + value: function checkPermission(action, resource) { + var payload = { + action: action, + resource: resource + }; + + return this.client.request('policy/check/', 'GET', payload); + } + }]); + return PolicyAPI; +}(); + +exports.default = PolicyAPI; \ No newline at end of file diff --git a/dist/api/role.js b/dist/api/role.js new file mode 100644 index 0000000..b0dd2f5 --- /dev/null +++ b/dist/api/role.js @@ -0,0 +1,76 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _keys = require('babel-runtime/core-js/object/keys'); + +var _keys2 = _interopRequireDefault(_keys); + +var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); + +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + +var _createClass2 = require('babel-runtime/helpers/createClass'); + +var _createClass3 = _interopRequireDefault(_createClass2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var RoleAPI = function () { + function RoleAPI(client) { + (0, _classCallCheck3.default)(this, RoleAPI); + + this.client = client; + } + + (0, _createClass3.default)(RoleAPI, [{ + key: 'create', + value: function create(name) { + var add_users = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; + + var payload = { name: name, add_users: add_users }; + return this.client.request('roles/', 'POST', payload); + } + }, { + key: 'list', + value: function list() { + return this.client.request('roles/'); + } + }, { + key: 'get', + value: function get(role) { + return this.client.request('roles/' + role + '/'); + } + }, { + key: 'update', + value: function update(role, name, add_users, remove_users) { + var payload = {}; + + if (name) { + payload.name = name; + } + + if (add_users) { + payload.add_users = add_users; + } + + if (remove_users) { + payload.remove_users = remove_users; + } + + if ((0, _keys2.default)(payload).length) { + return this.client.request('roles/' + role + '/', 'PATCH', payload); + } + } + }, { + key: 'remove', + value: function remove(role) { + return this.client.request('roles/' + role + '/', 'DELETE'); + } + }]); + return RoleAPI; +}(); + +exports.default = RoleAPI; \ No newline at end of file diff --git a/dist/api/schema.js b/dist/api/schema.js new file mode 100644 index 0000000..f2a9245 --- /dev/null +++ b/dist/api/schema.js @@ -0,0 +1,72 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _keys = require('babel-runtime/core-js/object/keys'); + +var _keys2 = _interopRequireDefault(_keys); + +var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); + +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + +var _createClass2 = require('babel-runtime/helpers/createClass'); + +var _createClass3 = _interopRequireDefault(_createClass2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var SchemaAPI = function () { + function SchemaAPI(client) { + (0, _classCallCheck3.default)(this, SchemaAPI); + + this.client = client; + } + + (0, _createClass3.default)(SchemaAPI, [{ + key: 'create', + value: function create(name) { + var fields = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; + + var payload = { name: name, fields: fields }; + return this.client.request('schemas/', 'POST', payload); + } + }, { + key: 'list', + value: function list() { + return this.client.request('schemas/'); + } + }, { + key: 'get', + value: function get(schema) { + return this.client.request('schemas/' + schema + '/'); + } + }, { + key: 'update', + value: function update(schema, name, fields) { + var payload = {}; + + if (name) { + payload.name = name; + } + + if (fields) { + payload.fields = fields; + } + + if ((0, _keys2.default)(payload).length) { + return this.client.request('schemas/' + schema + '/', 'PATCH', payload); + } + } + }, { + key: 'remove', + value: function remove(schema) { + return this.client.request('schemas/' + schema + '/', 'DELETE'); + } + }]); + return SchemaAPI; +}(); + +exports.default = SchemaAPI; \ No newline at end of file diff --git a/dist/api/user.js b/dist/api/user.js new file mode 100644 index 0000000..964178b --- /dev/null +++ b/dist/api/user.js @@ -0,0 +1,74 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _keys = require('babel-runtime/core-js/object/keys'); + +var _keys2 = _interopRequireDefault(_keys); + +var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); + +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + +var _createClass2 = require('babel-runtime/helpers/createClass'); + +var _createClass3 = _interopRequireDefault(_createClass2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var UserAPI = function () { + function UserAPI(client) { + (0, _classCallCheck3.default)(this, UserAPI); + + this.client = client; + } + + (0, _createClass3.default)(UserAPI, [{ + key: 'list', + value: function list() { + return this.client.request('users/'); + } + }, { + key: 'create', + value: function create(full_name, email, password) { + var payload = { full_name: full_name, email: email, password: password }; + return this.client.request('users/', 'POST', payload); + } + }, { + key: 'get', + value: function get(user_id) { + return this.client.request('users/' + user_id + '/'); + } + }, { + key: 'update', + value: function update(user_id, full_name, email, password) { + var payload = {}; + + if (full_name) { + payload.full_name = full_name; + } + + if (email) { + payload.email = email; + } + + if (password) { + payload.password = password; + } + + if ((0, _keys2.default)(payload).length) { + return this.client.request('users/' + user_id + '/', 'PATCH', payload); + } + } + }, { + key: 'remove', + value: function remove(user_id) { + return this.client.request('users/' + user_id + '/', 'DELETE'); + } + }]); + return UserAPI; +}(); + +exports.default = UserAPI; \ No newline at end of file diff --git a/dist/client.js b/dist/client.js new file mode 100644 index 0000000..02c7df4 --- /dev/null +++ b/dist/client.js @@ -0,0 +1,207 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _stringify = require('babel-runtime/core-js/json/stringify'); + +var _stringify2 = _interopRequireDefault(_stringify); + +var _promise = require('babel-runtime/core-js/promise'); + +var _promise2 = _interopRequireDefault(_promise); + +var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); + +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + +var _createClass2 = require('babel-runtime/helpers/createClass'); + +var _createClass3 = _interopRequireDefault(_createClass2); + +var _isomorphicFetch = require('isomorphic-fetch'); + +var _isomorphicFetch2 = _interopRequireDefault(_isomorphicFetch); + +var _querystring = require('querystring'); + +var _querystring2 = _interopRequireDefault(_querystring); + +var _lodash = require('lodash'); + +var _lodash2 = _interopRequireDefault(_lodash); + +require('babel-polyfill'); + +var _document = require('./api/document'); + +var _document2 = _interopRequireDefault(_document); + +var _file = require('./api/file'); + +var _file2 = _interopRequireDefault(_file); + +var _role = require('./api/role'); + +var _role2 = _interopRequireDefault(_role); + +var _schema = require('./api/schema'); + +var _schema2 = _interopRequireDefault(_schema); + +var _user = require('./api/user'); + +var _user2 = _interopRequireDefault(_user); + +var _policy = require('./api/policy'); + +var _policy2 = _interopRequireDefault(_policy); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var Client = function () { + function Client(project, token) { + (0, _classCallCheck3.default)(this, Client); + + this.protocol = 'https'; + this.host = 'mntge.com'; + this.project = project; + this.token = token; + + this.documents = new _document2.default(this); + this.schemas = new _schema2.default(this); + this.users = new _user2.default(this); + this.roles = new _role2.default(this); + this.files = new _file2.default(this); + this.policy = new _policy2.default(this); + } + + (0, _createClass3.default)(Client, [{ + key: 'url', + value: function url(endpoint) { + return this.protocol + '://' + this.project + '.' + this.host + '/api/v1/' + endpoint; + } + }, { + key: 'authenticate', + value: function authenticate(email, password) { + var _this = this; + + return this.request('user/', 'POST', { + username: email, + password: password + }).then(function (response) { + _this.token = response.data.token; + return response; + }); + } + }, { + key: 'user', + value: function user() { + if (this.token) { + return this.request('user/'); + } + + return _promise2.default.reject('The current user is not authenticated.'); + } + }, { + key: 'execute', + value: function execute(queries) { + var querySet = {}; + + for (var key in queries) { + if (queries.hasOwnProperty(key)) { + querySet[key] = queries[key].toJS(); + } + } + + return this.request('execute/', 'POST', querySet); + } + }, { + key: 'request', + value: function request(endpoint, method, data, file) { + var requestUrl = this.url(endpoint); + + var options = { + method: method && method.toUpperCase() || "GET", + headers: { + accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest' + } + }; + if (!file) { + options.headers['Content-Type'] = 'application/json'; + } + if (data) { + if (options.method === "GET") { + requestUrl += '?' + _querystring2.default.stringify(data); + } else { + if (file) options.body = data;else options.body = (0, _stringify2.default)(data); + } + } + if (this.token) { + options.headers.Authorization = 'Token ' + this.token; + } + if (options.body) { + //Varnish and heroku require a content length! + options.headers['Content-Length'] = getByteLen(options.body); + } + + return this._agent(requestUrl, options).then(function (response) { + if (response.status === 204) { + return; + } + if (!response.ok) { + response.request = _lodash2.default.merge({ + url: requestUrl + }, options); + return _promise2.default.reject(response); + } + if (response.status >= 400) { + return response.text().then(function (body) { + var errorMessage = body || response.statusText; + try { + errorMessage = JSON.parse(body); + } catch (e) {} + return _promise2.default.reject(errorMessage); + }); + } + return response.json(); + }).then(function (payload) { + if (payload && payload.errors) { + return _promise2.default.reject(payload.errors); + } + return payload; + }); + } + }, { + key: '_agent', + value: function _agent() { + return _isomorphicFetch2.default.apply(undefined, arguments); + } + }]); + return Client; +}(); + +/** + * Count bytes in a string's UTF-8 representation. + * + * [Reference]{@link http://codereview.stackexchange.com/a/37552} + * + * @param {string} normal_val + * @return {int} + */ + + +exports.default = Client; +function getByteLen(normal_val) { + // Force string type + normal_val = String(normal_val); + + var byteLen = 0; + for (var i = 0; i < normal_val.length; i++) { + var c = normal_val.charCodeAt(i); + byteLen += c < 1 << 7 ? 1 : c < 1 << 11 ? 2 : c < 1 << 16 ? 3 : c < 1 << 21 ? 4 : c < 1 << 26 ? 5 : c < 1 << 31 ? 6 : Number.NaN; + } + return byteLen; +} \ No newline at end of file diff --git a/dist/field.js b/dist/field.js new file mode 100644 index 0000000..79b7e6e --- /dev/null +++ b/dist/field.js @@ -0,0 +1,138 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck"); + +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + +var _createClass2 = require("babel-runtime/helpers/createClass"); + +var _createClass3 = _interopRequireDefault(_createClass2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var Field = function () { + function Field(field) { + (0, _classCallCheck3.default)(this, Field); + + this.field = field; + this.filters = []; + } + + (0, _createClass3.default)(Field, [{ + key: "toJS", + value: function toJS() { + var _this = this; + + return this.filters.map(function (filter) { + return [_this.field, filter]; + }); + } + }, { + key: "eq", + value: function eq(value) { + this.filters.push(["$eq", value]); + return this; + } + }, { + key: "ieq", + value: function ieq(value) { + this.filters.push(["$ieq", value]); + return this; + } + }, { + key: "ne", + value: function ne(value) { + this.filters.push(["$ne", value]); + return this; + } + }, { + key: "lt", + value: function lt(value) { + this.filters.push(["$lt", value]); + return this; + } + }, { + key: "le", + value: function le(value) { + this.filters.push(["$le", value]); + return this; + } + }, { + key: "gt", + value: function gt(value) { + this.filters.push(["$gt", value]); + return this; + } + }, { + key: "ge", + value: function ge(value) { + this.filters.push(["$ge", value]); + return this; + } + }, { + key: "inSet", + value: function inSet() { + for (var _len = arguments.length, values = Array(_len), _key = 0; _key < _len; _key++) { + values[_key] = arguments[_key]; + } + + this.filters.push(["$in", values]); + return this; + } + }, { + key: "contains", + value: function contains(value) { + this.filters.push(["$contains", value]); + return this; + } + }, { + key: "regex", + value: function regex(expression) { + this.filters.push(["$regex", expression]); + return this; + } + }, { + key: "starts", + value: function starts(value) { + this.filters.push(["$starts", value]); + return this; + } + }, { + key: "istarts", + value: function istarts(value) { + this.filters.push(["$istarts", value]); + return this; + } + }, { + key: "ends", + value: function ends(value) { + this.filters.push(["$ends", value]); + return this; + } + }, { + key: "iends", + value: function iends(value) { + this.filters.push(["$iends", value]); + return this; + } + }, { + key: "intersects", + value: function intersects(value) { + this.filters.push(["$intersects", value]); + return this; + } + }, { + key: "includes", + value: function includes(value) { + this.filters.push(["$includes", value]); + return this; + } + }]); + return Field; +}(); + +exports.default = Field; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 042401f..2320490 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,337 +1,24 @@ 'use strict'; -var _createClass = require('babel-runtime/helpers/create-class')['default']; - -var _classCallCheck = require('babel-runtime/helpers/class-call-check')['default']; - -var _slicedToArray = require('babel-runtime/helpers/sliced-to-array')['default']; - -var _Promise = require('babel-runtime/core-js/promise')['default']; - -var _Object$keys = require('babel-runtime/core-js/object/keys')['default']; - -var _interopRequireDefault = require('babel-runtime/helpers/interop-require-default')['default']; - -Object.defineProperty(exports, '__esModule', { - value: true +Object.defineProperty(exports, "__esModule", { + value: true }); -exports.getByteLen = getByteLen; - -var _isomorphicFetch = require('isomorphic-fetch'); - -var _isomorphicFetch2 = _interopRequireDefault(_isomorphicFetch); - -var _querystring = require('querystring'); - -var _querystring2 = _interopRequireDefault(_querystring); - -var _lodash = require('lodash'); - -var _lodash2 = _interopRequireDefault(_lodash); - -/** - * Count bytes in a string's UTF-8 representation. - * - * @param string - * @return int - */ - -function getByteLen(normal_val) { - // Force string type - normal_val = String(normal_val); - - var byteLen = 0; - for (var i = 0; i < normal_val.length; i++) { - var c = normal_val.charCodeAt(i); - byteLen += c < 1 << 7 ? 1 : c < 1 << 11 ? 2 : c < 1 << 16 ? 3 : c < 1 << 21 ? 4 : c < 1 << 26 ? 5 : c < 1 << 31 ? 6 : Number.NaN; - } - return byteLen; -} - -var Client = (function () { - function Client() { - var params = arguments[0] === undefined ? {} : arguments[0]; - - _classCallCheck(this, Client); - - params.api_version = params.api_version || 1; - this.params = params; - if (this.params.url) { - this.url_prefix = this.params.url; - } else if (this.params.dev) { - this.url_prefix = 'http://' + params.domain + '.dev.montagehot.club/api/v' + params.api_version + '/'; - } else { - this.url_prefix = 'https://' + params.domain + '.mntge.com/api/v' + params.api_version + '/'; - } - } - - _createClass(Client, [{ - key: 'schemas', - value: function schemas() { - return this.request('schemas/'); - } - }, { - key: 'schema', - value: function schema(name) { - return this.request('schemas/' + name + '/'); - } - }, { - key: 'files', - value: function files(formData) { - return this.request('files/', 'POST', formData, true); - } - }, { - key: 'documents', - value: function documents(queries) { - return this.request('query/', 'POST', queries); - } - }, { - key: 'document', - value: function document(schema, document_uuid) { - var documentQuery = { - '$schema': schema, - '$query': [['$get', document_uuid]] - }; - - return this.request('query/', 'POST', { query: documentQuery }); - } - }, { - key: 'document_cursor', - value: function document_cursor(schema, cursor) { - var params = { cursor: cursor }; - return this.request('schemas/' + schema + '/', 'GET', params); - } - }, { - key: 'create_document', - - //*paginated_documents(schema, query) { - // //yields promises - - // var cursor; - - // function onResponse(response) { - // cursor = response.cursors ? response.cursors.next : null; - // return response.data; - // } - - // yield this.documents(schema, query).then(onResponse); - - // while (cursor) { - // yield this.document_cursor(schema, cursor).then(onResponse); - // } - //} - value: function create_document(schema, document) { - return this.create_documents(schema, [document]); - } - }, { - key: 'create_documents', - value: function create_documents(schema, documents) { - return this.request('schemas/' + schema + '/save/', 'POST', documents); - } - }, { - key: 'update_document', - value: function update_document(schema, document_uuid, document) { - return this.request('schemas/' + schema + '/' + document_uuid + '/', 'POST', document); - } - }, { - key: 'delete_document', - value: function delete_document(schema, document_uuid) { - return this.request('schemas/' + schema + '/' + document_uuid + '/', 'DELETE'); - } - }, { - key: 'auth', - value: function auth() { - var _this = this; - - return this.request('auth/', 'POST', { - username: this.params.username, - password: this.params.password - }).then(function (response) { - _this.params.token = response.data.token; - return response; - }); - } - }, { - key: 'request', - value: function request(url, method, data, file) { - var options = { - method: method && method.toUpperCase() || 'GET', - headers: { - accept: 'application/json', - 'X-Requested-With': 'XMLHttpRequest' - } - }; - if (!file) { - options.headers['Content-Type'] = 'application/json'; - } - if (data) { - if (options.method === 'GET') { - url += '?' + _querystring2['default'].stringify(data); - } else { - if (file) options.body = data;else options.body = JSON.stringify(data); - } - } - if (this.params.token) { - options.headers.Authorization = 'Token ' + this.params.token; - } - if (options.body) { - //Varnish and heroku require a content length! - options.headers['Content-Length'] = getByteLen(options.body); - } - var reqUrl = '' + this.url_prefix + url; - return this._agent(reqUrl, options).then(function (response) { - if (!response.ok) { - response.request = _lodash2['default'].merge({ - url: reqUrl - }, options); - return _Promise.reject(response); - } - if (response.status >= 400) { - return response.text().then(function (body) { - var errorMessage = body || response.statusText; - try { - errorMessage = JSON.parse(body); - } catch (e) {} - return _Promise.reject(errorMessage); - }); - } - return response.json(); - }).then(function (payload) { - if (payload && payload.errors) { - return _Promise.reject(payload.errors); - } - return payload; - }); - } - }, { - key: '_agent', - value: function _agent() { - return _isomorphicFetch2['default'].apply(undefined, arguments); - } - // TODO files api - - }]); - - return Client; -})(); - -exports.Client = Client; - -var Query = (function () { - function Query(schemaName, state) { - _classCallCheck(this, Query); - - if (!schemaName) throw 'Schema name is required'; - - this.schemaName = schemaName; - - state = state || { - '$schema': schemaName, - '$query': [['$filter', []]] - }; - this._state = state; - } - - _createClass(Query, [{ - key: '_merge', - value: function _merge(delta) { - var state = _lodash2['default'].merge({}, this._state, delta); - return new Query(this.schemaName, state); - } - }, { - key: '_mergeArray', - value: function _mergeArray(delta) { - var index = _lodash2['default'].findIndex(this._state['$query'], function (item) { - return item[0] === delta[0]; - }); - - if (index !== -1) { - this._state['$query'][index] = delta; - } else { - this._state['$query'].push(delta); - } - - return new Query(this.schemaName, this._state); - } - }, { - key: 'limit', - value: function limit(num) { - return this._mergeArray(['$limit', num]); - } - }, { - key: 'offset', - value: function offset(num) { - return this._mergeArray(['$offset', num]); - } - }, { - key: 'order', - value: function order(order_by, ordering) { - var parsedOrder; - if (_lodash2['default'].isString(ordering)) { - parsedOrder = '$' + ordering; - } else { - parsedOrder = ordering < 0 ? '$desc' : '$asc'; - } - - return this._mergeArray(['$order_by', [parsedOrder, order_by]]); - } - }, { - key: 'pluck', - value: function pluck(fields) { - return this._mergeArray(['$pluck', fields]); - } - }, { - key: 'without', - value: function without(fields) { - return this._mergeArray(['$without', fields]); - } - }, { - key: 'pageSize', - value: function pageSize(size) { - return this._mergeArray(['$limit', size]); - } - }, { - key: 'index', - value: function index(indexName) { - return this._mergeArray(['$index', indexName]); - } - }, { - key: 'filter', - value: function filter(params) { - var filterIndex = _lodash2['default'].findIndex(this._state['$query'], function (item) { - return item[0] === '$filter'; - }); - var filters = this._state['$query'][filterIndex]; +exports.Query = exports.Field = exports.Client = undefined; - _Object$keys(params).forEach(function (key) { - var _key$split = key.split('__'); +var _client = require('./client'); - var _key$split2 = _slicedToArray(_key$split, 2); +var _client2 = _interopRequireDefault(_client); - var field = _key$split2[0]; - var operator = _key$split2[1]; +var _query = require('./query'); - var queryField = operator ? ['$' + operator, params[key]] : params[key]; +var _query2 = _interopRequireDefault(_query); - filters[1].push([field, queryField]); - }); +var _field = require('./field'); - return this._mergeArray(filters); - } - }, { - key: 'where', - value: function where(params) { - //alias - return this.filter(params); - } - }, { - key: 'toJS', - value: function toJS() { - return this._state; - } - }]); +var _field2 = _interopRequireDefault(_field); - return Query; -})(); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -exports.Query = Query; \ No newline at end of file +exports.Client = _client2.default; +exports.Field = _field2.default; +exports.Query = _query2.default; \ No newline at end of file diff --git a/dist/montage.js b/dist/montage.js index 6bf0dcc..2e938a1 100644 --- a/dist/montage.js +++ b/dist/montage.js @@ -1,3 +1,6 @@ -!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):"object"==typeof exports?exports.Montage=n():t.Montage=n()}(this,function(){return function(t){function n(e){if(r[e])return r[e].exports;var o=r[e]={exports:{},id:e,loaded:!1};return t[e].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var r={};return n.m=t,n.c=r,n.p="",n(0)}([function(t,n,r){"use strict";function e(t){t=String(t);for(var n=0,r=0;re?1:2048>e?2:65536>e?3:1<<21>e?4:1<<26>e?5:1<<31>e?6:Number.NaN}return n}var o=r(1)["default"],u=r(6)["default"],i=r(7)["default"],a=r(27)["default"],c=r(42)["default"],f=r(46)["default"];Object.defineProperty(n,"__esModule",{value:!0}),n.getByteLen=e;var s=r(47),l=f(s),p=r(49),h=f(p),v=r(52),d=f(v),y=function(){function t(){var n=void 0===arguments[0]?{}:arguments[0];u(this,t),n.api_version=n.api_version||1,this.params=n,this.params.url?this.url_prefix=this.params.url:this.params.dev?this.url_prefix="http://"+n.domain+".dev.montagehot.club/api/v"+n.api_version+"/":this.url_prefix="https://"+n.domain+".mntge.com/api/v"+n.api_version+"/"}return o(t,[{key:"schemas",value:function(){return this.request("schemas/")}},{key:"schema",value:function(t){return this.request("schemas/"+t+"/")}},{key:"files",value:function(t){return this.request("files/","POST",t,!0)}},{key:"documents",value:function(t){return this.request("query/","POST",t)}},{key:"document",value:function(t,n){var r={$schema:t,$query:[["$get",n]]};return this.request("query/","POST",{query:r})}},{key:"document_cursor",value:function(t,n){var r={cursor:n};return this.request("schemas/"+t+"/","GET",r)}},{key:"create_document",value:function(t,n){return this.create_documents(t,[n])}},{key:"create_documents",value:function(t,n){return this.request("schemas/"+t+"/save/","POST",n)}},{key:"update_document",value:function(t,n,r){return this.request("schemas/"+t+"/"+n+"/","POST",r)}},{key:"delete_document",value:function(t,n){return this.request("schemas/"+t+"/"+n+"/","DELETE")}},{key:"auth",value:function(){var t=this;return this.request("auth/","POST",{username:this.params.username,password:this.params.password}).then(function(n){return t.params.token=n.data.token,n})}},{key:"request",value:function(t,n,r,o){var u={method:n&&n.toUpperCase()||"GET",headers:{accept:"application/json","X-Requested-With":"XMLHttpRequest"}};o||(u.headers["Content-Type"]="application/json"),r&&("GET"===u.method?t+="?"+h["default"].stringify(r):o?u.body=r:u.body=JSON.stringify(r)),this.params.token&&(u.headers.Authorization="Token "+this.params.token),u.body&&(u.headers["Content-Length"]=e(u.body));var i=""+this.url_prefix+t;return this._agent(i,u).then(function(t){return t.ok?t.status>=400?t.text().then(function(n){var r=n||t.statusText;try{r=JSON.parse(n)}catch(e){}return a.reject(r)}):t.json():(t.request=d["default"].merge({url:i},u),a.reject(t))}).then(function(t){return t&&t.errors?a.reject(t.errors):t})}},{key:"_agent",value:function(){return l["default"].apply(void 0,arguments)}}]),t}();n.Client=y;var _=function(){function t(n,r){if(u(this,t),!n)throw"Schema name is required";this.schemaName=n,r=r||{$schema:n,$query:[["$filter",[]]]},this._state=r}return o(t,[{key:"_merge",value:function(n){var r=d["default"].merge({},this._state,n);return new t(this.schemaName,r)}},{key:"_mergeArray",value:function(n){var r=d["default"].findIndex(this._state.$query,function(t){return t[0]===n[0]});return-1!==r?this._state.$query[r]=n:this._state.$query.push(n),new t(this.schemaName,this._state)}},{key:"limit",value:function(t){return this._mergeArray(["$limit",t])}},{key:"offset",value:function(t){return this._mergeArray(["$offset",t])}},{key:"order",value:function(t,n){var r;return r=d["default"].isString(n)?"$"+n:0>n?"$desc":"$asc",this._mergeArray(["$order_by",[r,t]])}},{key:"pluck",value:function(t){return this._mergeArray(["$pluck",t])}},{key:"without",value:function(t){return this._mergeArray(["$without",t])}},{key:"pageSize",value:function(t){return this._mergeArray(["$limit",t])}},{key:"index",value:function(t){return this._mergeArray(["$index",t])}},{key:"filter",value:function(t){var n=d["default"].findIndex(this._state.$query,function(t){return"$filter"===t[0]}),r=this._state.$query[n];return c(t).forEach(function(n){var e=n.split("__"),o=i(e,2),u=o[0],a=o[1],c=a?["$"+a,t[n]]:t[n];r[1].push([u,c])}),this._mergeArray(r)}},{key:"where",value:function(t){return this.filter(t)}},{key:"toJS",value:function(){return this._state}}]),t}();n.Query=_},function(t,n,r){"use strict";var e=r(2)["default"];n["default"]=function(){function t(t,n){for(var r=0;r0?d:v)(t)}function o(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}}function u(t,n,r){return t[n]=r,t}function i(t){return g?function(n,r,e){return b.setDesc(n,r,o(t,e))}:u}function a(t){return null!==t&&("object"==typeof t||"function"==typeof t)}function c(t){return"function"==typeof t}function f(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}var s="undefined"!=typeof self?self:Function("return this")(),l={},p=Object.defineProperty,h={}.hasOwnProperty,v=Math.ceil,d=Math.floor,y=Math.max,_=Math.min,g=!!function(){try{return 2==p({},"a",{get:function(){return 2}}).a}catch(t){}}(),m=i(1),b=t.exports=r(5)({g:s,core:l,html:s.document&&document.documentElement,isObject:a,isFunction:c,that:function(){return this},toInteger:e,toLength:function(t){return t>0?_(e(t),9007199254740991):0},toIndex:function(t,n){return t=e(t),0>t?y(t+n,0):_(t,n)},has:function(t,n){return h.call(t,n)},create:Object.create,getProto:Object.getPrototypeOf,DESC:g,desc:o,getDesc:Object.getOwnPropertyDescriptor,setDesc:p,setDescs:Object.defineProperties,getKeys:Object.keys,getNames:Object.getOwnPropertyNames,getSymbols:Object.getOwnPropertySymbols,assertDefined:f,ES5Object:Object,toObject:function(t){return b.ES5Object(f(t))},hide:m,def:i(0),set:s.Symbol?u:m,each:[].forEach});"undefined"!=typeof __e&&(__e=l),"undefined"!=typeof __g&&(__g=s)},function(t,n){t.exports=function(t){return t.FW=!1,t.path=t.core,t}},function(t,n){"use strict";n["default"]=function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")},n.__esModule=!0},function(t,n,r){"use strict";var e=r(8)["default"],o=r(25)["default"];n["default"]=function(){function t(t,n){var r=[],o=!0,u=!1,i=void 0;try{for(var a,c=e(t);!(o=(a=c.next()).done)&&(r.push(a.value),!n||r.length!==n);o=!0);}catch(f){u=!0,i=f}finally{try{!o&&c["return"]&&c["return"]()}finally{if(u)throw i}}return r}return function(n,r){if(Array.isArray(n))return n;if(o(Object(n)))return t(n,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),n.__esModule=!0},function(t,n,r){t.exports={"default":r(9),__esModule:!0}},function(t,n,r){r(10),r(22),r(24),t.exports=r(4).core.getIterator},function(t,n,r){r(11);var e=r(4),o=r(14).Iterators,u=r(16)("iterator"),i=o.Array,a=e.g.NodeList,c=e.g.HTMLCollection,f=a&&a.prototype,s=c&&c.prototype;e.FW&&(!a||u in f||e.hide(f,u,i),!c||u in s||e.hide(s,u,i)),o.NodeList=o.HTMLCollection=i},function(t,n,r){var e=r(4),o=r(12),u=r(13).safe("iter"),i=r(14),a=i.step,c=i.Iterators;r(19)(Array,"Array",function(t,n){e.set(this,u,{o:e.toObject(t),i:0,k:n})},function(){var t=this[u],n=t.o,r=t.k,e=t.i++;return!n||e>=n.length?(t.o=void 0,a(1)):"keys"==r?a(0,e):"values"==r?a(0,n[e]):a(0,[e,n[e]])},"values"),c.Arguments=c.Array,o("keys"),o("values"),o("entries")},function(t,n){t.exports=function(){}},function(t,n,r){function e(t){return"Symbol(".concat(void 0===t?"":t,")_",(++o+Math.random()).toString(36))}var o=0;e.safe=r(4).g.Symbol||e,t.exports=e},function(t,n,r){"use strict";function e(t,n){o.hide(t,f,n),s in[]&&o.hide(t,s,n)}var o=r(4),u=r(15),i=u.classof,a=r(18),c=a.obj,f=r(16)("iterator"),s="@@iterator",l=r(17)("iterators"),p={};e(p,o.that),t.exports={BUGGY:"keys"in[]&&!("next"in[].keys()),Iterators:l,step:function(t,n){return{value:n,done:!!t}},is:function(t){var n=Object(t),r=o.g.Symbol;return(r&&r.iterator||s)in n||f in n||o.has(l,i(n))},get:function(t){var n,r=o.g.Symbol;return void 0!=t&&(n=t[r&&r.iterator||s]||t[f]||l[i(t)]),a(o.isFunction(n),t," is not iterable!"),c(n.call(t))},set:e,create:function(t,n,r,e){t.prototype=o.create(e||p,{next:o.desc(1,r)}),u.set(t,n+" Iterator")}}},function(t,n,r){function e(t){return i.call(t).slice(8,-1)}var o=r(4),u=r(16)("toStringTag"),i={}.toString;e.classof=function(t){var n,r;return void 0==t?void 0===t?"Undefined":"Null":"string"==typeof(r=(n=Object(t))[u])?r:e(n)},e.set=function(t,n,r){t&&!o.has(t=r?t:t.prototype,u)&&o.hide(t,u,n)},t.exports=e},function(t,n,r){var e=r(4).g,o=r(17)("wks");t.exports=function(t){return o[t]||(o[t]=e.Symbol&&e.Symbol[t]||r(13).safe("Symbol."+t))}},function(t,n,r){var e=r(4),o="__core-js_shared__",u=e.g[o]||(e.g[o]={});t.exports=function(t){return u[t]||(u[t]={})}},function(t,n,r){function e(t,n,r){if(!t)throw TypeError(r?n+r:n)}var o=r(4);e.def=o.assertDefined,e.fn=function(t){if(!o.isFunction(t))throw TypeError(t+" is not a function!");return t},e.obj=function(t){if(!o.isObject(t))throw TypeError(t+" is not an object!");return t},e.inst=function(t,n,r){if(!(t instanceof n))throw TypeError(r+": use the 'new' operator!");return t},t.exports=e},function(t,n,r){var e=r(20),o=r(21),u=r(4),i=r(15),a=r(14),c=r(16)("iterator"),f="@@iterator",s="keys",l="values",p=a.Iterators;t.exports=function(t,n,r,h,v,d,y){function _(t){function n(n){return new r(n,t)}switch(t){case s:return function(){return n(this)};case l:return function(){return n(this)}}return function(){return n(this)}}a.create(r,n,h);var g,m,b=n+" Iterator",w=t.prototype,x=w[c]||w[f]||v&&w[v],j=x||_(v);if(x){var O=u.getProto(j.call(new t));i.set(O,b,!0),u.FW&&u.has(w,f)&&a.set(O,u.that)}if((u.FW||y)&&a.set(w,j),p[n]=j,p[b]=u.that,v)if(g={keys:d?j:_(s),values:v==l?j:_(l),entries:v!=l?j:_("entries")},y)for(m in g)m in w||o(w,m,g[m]);else e(e.P+e.F*a.BUGGY,n,g)}},function(t,n,r){function e(t,n){return function(){return t.apply(n,arguments)}}function o(t,n,r){var u,f,s,l,p=t&o.G,h=t&o.P,v=p?i:t&o.S?i[n]:(i[n]||{}).prototype,d=p?a:a[n]||(a[n]={});p&&(r=n);for(u in r)f=!(t&o.F)&&v&&u in v,f&&u in d||(s=f?v[u]:r[u],p&&!c(v[u])?l=r[u]:t&o.B&&f?l=e(s,i):t&o.W&&v[u]==s?!function(t){l=function(n){return this instanceof t?new t(n):t(n)},l.prototype=t.prototype}(s):l=h&&c(s)?e(Function.call,s):s,d[u]=l,h&&((d.prototype||(d.prototype={}))[u]=s))}var u=r(4),i=u.g,a=u.core,c=u.isFunction;o.F=1,o.G=2,o.S=4,o.P=8,o.B=16,o.W=32,t.exports=o},function(t,n,r){t.exports=r(4).hide},function(t,n,r){var e=r(4).set,o=r(23)(!0),u=r(13).safe("iter"),i=r(14),a=i.step;r(19)(String,"String",function(t){e(this,u,{o:String(t),i:0})},function(){var t,n=this[u],r=n.o,e=n.i;return e>=r.length?a(1):(t=o(r,e),n.i+=t.length,a(0,t))})},function(t,n,r){var e=r(4);t.exports=function(t){return function(n,r){var o,u,i=String(e.assertDefined(n)),a=e.toInteger(r),c=i.length;return 0>a||a>=c?t?"":void 0:(o=i.charCodeAt(a),55296>o||o>56319||a+1===c||(u=i.charCodeAt(a+1))<56320||u>57343?t?i.charAt(a):o:t?i.slice(a,a+2):(o-55296<<10)+(u-56320)+65536)}}},function(t,n,r){var e=r(4).core,o=r(14);e.isIterable=o.is,e.getIterator=o.get},function(t,n,r){t.exports={"default":r(26),__esModule:!0}},function(t,n,r){r(10),r(22),r(24),t.exports=r(4).core.isIterable},function(t,n,r){t.exports={"default":r(28),__esModule:!0}},function(t,n,r){r(29),r(22),r(10),r(30),t.exports=r(4).core.Promise},function(t,n,r){"use strict";var e=r(15),o={};o[r(16)("toStringTag")]="z",r(4).FW&&"z"!=e(o)&&r(21)(Object.prototype,"toString",function(){return"[object "+e.classof(this)+"]"},!0)},function(t,n,r){"use strict";function e(t){var n=new T(function(){});return t&&(n.constructor=Object),T.resolve(n)===n}function o(t){return R(t)&&(F?"Promise"==d.classof(t):j in t)}function u(t,n){return h.FW||t!==T||n!==p?b(t,n):!0}function i(t){var n=C(t)[x];return void 0!=n?n:t}function a(t){var n;return R(t)&&(n=t.then),S(n)?n:!1}function c(t){var n=t.c;n.length&&I.call(k,function(){function r(n){var r,u,i=o?n.ok:n.fail;try{i?(o||(t.h=!0),r=i===!0?e:i(e),r===n.P?n.rej(TypeError("Promise-chain cycle")):(u=a(r))?u.call(r,n.res,n.rej):n.res(r)):n.rej(e)}catch(c){n.rej(c)}}for(var e=t.v,o=1==t.s,u=0;n.length>u;)r(n[u++]);n.length=0})}function f(t){var n,r=t[j],e=r.a||r.c,o=0;if(r.h)return!1;for(;e.length>o;)if(n=e[o++],n.fail||!f(n.P))return!1;return!0}function s(t){var n,r=this;r.d||(r.d=!0,r=r.r||r,r.v=t,r.s=2,r.a=r.c.slice(),setTimeout(function(){I.call(k,function(){f(n=r.p)&&(E?A.emit("unhandledRejection",t,n):k.console&&console.error&&console.error("Unhandled promise rejection",t)),r.a=void 0})},1),c(r))}function l(t){var n,r=this;if(!r.d){r.d=!0,r=r.r||r;try{(n=a(t))?I.call(k,function(){var e={r:r,d:!1};try{n.call(t,v(l,e,1),v(s,e,1))}catch(o){s.call(e,o)}}):(r.v=t,r.s=1,c(r))}catch(e){s.call({r:r,d:!1},e)}}}var p,h=r(4),v=r(32),d=r(15),y=r(20),_=r(18),g=r(33),m=r(35).set,b=r(31),w=r(36),x=r(16)("species"),j=r(13).safe("record"),O="Promise",k=h.g,A=k.process,E="process"==d(A),I=A&&A.nextTick||r(37).set,T=k[O],S=h.isFunction,R=h.isObject,P=_.fn,C=_.obj,F=function(){function t(n){var r=new T(n);return m(r,t.prototype),r}var n=!1;try{if(n=S(T)&&S(T.resolve)&&e(),m(t,T),t.prototype=h.create(T.prototype,{constructor:{value:t}}),t.resolve(5).then(function(){})instanceof t||(n=!1),n&&h.DESC){var r=!1;T.resolve(h.setDesc({},"then",{get:function(){r=!0}})),n=r}}catch(o){n=!1}return n}();F||(T=function(t){P(t);var n={p:_.inst(this,T,O),c:[],a:void 0,s:0,d:!1,v:void 0,h:!1};h.hide(this,j,n);try{t(v(l,n,1),v(s,n,1))}catch(r){s.call(n,r)}},r(40)(T.prototype,{then:function(t,n){var r=C(C(this).constructor)[x],e={ok:S(t)?t:!0,fail:S(n)?n:!1},o=e.P=new(void 0!=r?r:T)(function(t,n){e.res=P(t),e.rej=P(n)}),u=this[j];return u.c.push(e),u.a&&u.a.push(e),u.s&&c(u),o},"catch":function(t){return this.then(void 0,t)}})),y(y.G+y.W+y.F*!F,{Promise:T}),d.set(T,O),w(T),w(p=h.core[O]),y(y.S+y.F*!F,O,{reject:function(t){return new(i(this))(function(n,r){r(t)})}}),y(y.S+y.F*(!F||e(!0)),O,{resolve:function(t){return o(t)&&u(t.constructor,this)?t:new this(function(n){n(t)})}}),y(y.S+y.F*!(F&&r(41)(function(t){T.all(t)["catch"](function(){})})),O,{all:function(t){var n=i(this),r=[];return new n(function(e,o){g(t,!1,r.push,r);var u=r.length,i=Array(u);u?h.each.call(r,function(t,r){n.resolve(t).then(function(t){i[r]=t,--u||e(i)},o)}):e(i)})},race:function(t){var n=i(this);return new n(function(r,e){g(t,!1,function(t){n.resolve(t).then(r,e)})})}})},function(t,n){t.exports=Object.is||function(t,n){return t===n?0!==t||1/t===1/n:t!=t&&n!=n}},function(t,n,r){var e=r(18).fn;t.exports=function(t,n,r){if(e(t),~r&&void 0===n)return t;switch(r){case 1:return function(r){return t.call(n,r)};case 2:return function(r,e){return t.call(n,r,e)};case 3:return function(r,e,o){return t.call(n,r,e,o)}}return function(){return t.apply(n,arguments)}}},function(t,n,r){var e=r(32),o=r(14).get,u=r(34);t.exports=function(t,n,r,i){for(var a,c=o(t),f=e(r,i,n?2:1);!(a=c.next()).done;)if(u(c,f,a.value,n)===!1)return u.close(c)}},function(t,n,r){function e(t){var n=t["return"];void 0!==n&&u(n.call(t))}function o(t,n,r,o){try{return o?n(u(r)[0],r[1]):n(r)}catch(i){throw e(t),i}}var u=r(18).obj;o.close=e,t.exports=o},function(t,n,r){function e(t,n){u.obj(t),u(null===n||o.isObject(n),n,": can't set as prototype!")}var o=r(4),u=r(18);t.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(t,n){try{n=r(32)(Function.call,o.getDesc(Object.prototype,"__proto__").set,2),n({},[])}catch(u){t=!0}return function(r,o){return e(r,o),t?r.__proto__=o:n(r,o),r}}():void 0),check:e}},function(t,n,r){var e=r(4),o=r(16)("species");t.exports=function(t){!e.DESC||o in t||e.setDesc(t,o,{configurable:!0,get:e.that})}},function(t,n,r){"use strict";function e(){var t=+this;if(c.has(w,t)){var n=w[t];delete w[t],n()}}function o(t){e.call(t.data)}var u,i,a,c=r(4),f=r(32),s=r(15),l=r(38),p=r(39),h=c.g,v=c.isFunction,d=c.html,y=h.process,_=h.setImmediate,g=h.clearImmediate,m=h.MessageChannel,b=0,w={},x="onreadystatechange";v(_)&&v(g)||(_=function(t){for(var n=[],r=1;arguments.length>r;)n.push(arguments[r++]);return w[++b]=function(){l(v(t)?t:Function(t),n)},u(b),b},g=function(t){delete w[t]},"process"==s(y)?u=function(t){y.nextTick(f(e,t,1))}:h.addEventListener&&v(h.postMessage)&&!h.importScripts?(u=function(t){h.postMessage(t,"*")},h.addEventListener("message",o,!1)):v(m)?(i=new m,a=i.port2,i.port1.onmessage=o,u=f(a.postMessage,a,1)):u=x in p("script")?function(t){d.appendChild(p("script"))[x]=function(){d.removeChild(this),e.call(t)}}:function(t){setTimeout(f(e,t,1),0)}),t.exports={set:_,clear:g}},function(t,n){t.exports=function(t,n,r){var e=void 0===r;switch(n.length){case 0:return e?t():t.call(r);case 1:return e?t(n[0]):t.call(r,n[0]);case 2:return e?t(n[0],n[1]):t.call(r,n[0],n[1]);case 3:return e?t(n[0],n[1],n[2]):t.call(r,n[0],n[1],n[2]);case 4:return e?t(n[0],n[1],n[2],n[3]):t.call(r,n[0],n[1],n[2],n[3]);case 5:return e?t(n[0],n[1],n[2],n[3],n[4]):t.call(r,n[0],n[1],n[2],n[3],n[4])}return t.apply(r,n)}},function(t,n,r){var e=r(4),o=e.g.document,u=e.isObject,i=u(o)&&u(o.createElement);t.exports=function(t){return i?o.createElement(t):{}}},function(t,n,r){var e=r(21);t.exports=function(t,n){for(var r in n)e(t,r,n[r]);return t}},function(t,n,r){var e=r(16)("iterator"),o=!1;try{var u=[7][e]();u["return"]=function(){o=!0},Array.from(u,function(){throw 2})}catch(i){}t.exports=function(t){if(!o)return!1;var n=!1;try{var r=[7],u=r[e]();u.next=function(){n=!0},r[e]=function(){return u},t(r)}catch(i){}return n}},function(t,n,r){t.exports={"default":r(43),__esModule:!0}},function(t,n,r){r(44),t.exports=r(4).core.Object.keys},function(t,n,r){var e=r(4),o=r(20),u=e.isObject,i=e.toObject;e.each.call("freeze,seal,preventExtensions,isFrozen,isSealed,isExtensible,getOwnPropertyDescriptor,getPrototypeOf,keys,getOwnPropertyNames".split(","),function(t,n){var a=(e.core.Object||{})[t]||Object[t],c=0,f={};f[t]=0==n?function(t){return u(t)?a(t):t}:1==n?function(t){return u(t)?a(t):t}:2==n?function(t){return u(t)?a(t):t}:3==n?function(t){return u(t)?a(t):!0}:4==n?function(t){return u(t)?a(t):!0}:5==n?function(t){return u(t)?a(t):!1}:6==n?function(t,n){return a(i(t),n)}:7==n?function(t){return a(Object(e.assertDefined(t)))}:8==n?function(t){return a(i(t))}:r(45).get;try{a("z")}catch(s){c=1}o(o.S+o.F*c,"Object",f)})},function(t,n,r){function e(t){try{return i(t)}catch(n){return a.slice()}}var o=r(4),u={}.toString,i=o.getNames,a="object"==typeof window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];t.exports.get=function(t){return a&&"[object Window]"==u.call(t)?e(t):i(o.toObject(t))}},function(t,n){"use strict";n["default"]=function(t){return t&&t.__esModule?t:{"default":t}},n.__esModule=!0},function(t,n,r){r(48),t.exports=self.fetch.bind(self)},function(t,n){!function(){"use strict";function t(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function n(t){return"string"!=typeof t&&(t=String(t)),t}function r(t){this.map={},t instanceof r?t.forEach(function(t,n){this.append(n,t)},this):t&&Object.getOwnPropertyNames(t).forEach(function(n){this.append(n,t[n])},this)}function e(t){return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function o(t){return new Promise(function(n,r){t.onload=function(){n(t.result)},t.onerror=function(){r(t.error)}})}function u(t){var n=new FileReader;return n.readAsArrayBuffer(t),o(n)}function i(t){var n=new FileReader;return n.readAsText(t),o(n)}function a(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,"string"==typeof t)this._bodyText=t;else if(h.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(h.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(t){if(!h.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(t))throw new Error("unsupported BodyInit type")}else this._bodyText=""},h.blob?(this.blob=function(){var t=e(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this.blob().then(u)},this.text=function(){var t=e(this);if(t)return t;if(this._bodyBlob)return i(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)}):this.text=function(){var t=e(this);return t?t:Promise.resolve(this._bodyText)},h.formData&&(this.formData=function(){return this.text().then(s)}),this.json=function(){return this.text().then(JSON.parse)},this}function c(t){var n=t.toUpperCase();return v.indexOf(n)>-1?n:t}function f(t,n){n=n||{};var e=n.body;if(f.prototype.isPrototypeOf(t)){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,n.headers||(this.headers=new r(t.headers)),this.method=t.method,this.mode=t.mode,e||(e=t._bodyInit,t.bodyUsed=!0)}else this.url=t;if(this.credentials=n.credentials||this.credentials||"omit",(n.headers||!this.headers)&&(this.headers=new r(n.headers)),this.method=c(n.method||this.method||"GET"),this.mode=n.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&e)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(e)}function s(t){var n=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),e=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");n.append(decodeURIComponent(e),decodeURIComponent(o))}}),n}function l(t){var n=new r,e=t.getAllResponseHeaders().trim().split("\n");return e.forEach(function(t){var r=t.trim().split(":"),e=r.shift().trim(),o=r.join(":").trim();n.append(e,o)}),n}function p(t,n){n||(n={}),this._initBody(t),this.type="default",this.status=n.status,this.ok=this.status>=200&&this.status<300,this.statusText=n.statusText,this.headers=n.headers instanceof r?n.headers:new r(n.headers),this.url=n.url||""}if(!self.fetch){r.prototype.append=function(r,e){r=t(r),e=n(e);var o=this.map[r];o||(o=[],this.map[r]=o),o.push(e)},r.prototype["delete"]=function(n){delete this.map[t(n)]},r.prototype.get=function(n){var r=this.map[t(n)];return r?r[0]:null},r.prototype.getAll=function(n){return this.map[t(n)]||[]},r.prototype.has=function(n){return this.map.hasOwnProperty(t(n))},r.prototype.set=function(r,e){this.map[t(r)]=[n(e)]},r.prototype.forEach=function(t,n){Object.getOwnPropertyNames(this.map).forEach(function(r){this.map[r].forEach(function(e){t.call(n,e,r,this)},this)},this)};var h={blob:"FileReader"in self&&"Blob"in self&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in self,arrayBuffer:"ArrayBuffer"in self},v=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];f.prototype.clone=function(){return new f(this)},a.call(f.prototype),a.call(p.prototype),p.prototype.clone=function(){return new p(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new r(this.headers),url:this.url})},p.error=function(){var t=new p(null,{status:0,statusText:""});return t.type="error",t};var d=[301,302,303,307,308];p.redirect=function(t,n){if(-1===d.indexOf(n))throw new RangeError("Invalid status code");return new p(null,{status:n,headers:{location:t}})},self.Headers=r,self.Request=f,self.Response=p,self.fetch=function(t,n){return new Promise(function(r,e){function o(){return"responseURL"in i?i.responseURL:/^X-Request-URL:/m.test(i.getAllResponseHeaders())?i.getResponseHeader("X-Request-URL"):void 0}var u;u=f.prototype.isPrototypeOf(t)&&!n?t:new f(t,n);var i=new XMLHttpRequest;i.onload=function(){var t=1223===i.status?204:i.status;if(100>t||t>599)return void e(new TypeError("Network request failed"));var n={status:t,statusText:i.statusText,headers:l(i),url:o()},u="response"in i?i.response:i.responseText;r(new p(u,n))},i.onerror=function(){e(new TypeError("Network request failed"))},i.open(u.method,u.url,!0),"include"===u.credentials&&(i.withCredentials=!0),"responseType"in i&&h.blob&&(i.responseType="blob"),u.headers.forEach(function(t,n){i.setRequestHeader(n,t)}),i.send("undefined"==typeof u._bodyInit?null:u._bodyInit)})},self.fetch.polyfill=!0}}()},function(t,n,r){"use strict";n.decode=n.parse=r(50),n.encode=n.stringify=r(51)},function(t,n){"use strict";function r(t,n){return Object.prototype.hasOwnProperty.call(t,n)}t.exports=function(t,n,e,o){n=n||"&",e=e||"=";var u={};if("string"!=typeof t||0===t.length)return u;var i=/\+/g;t=t.split(n);var a=1e3;o&&"number"==typeof o.maxKeys&&(a=o.maxKeys);var c=t.length;a>0&&c>a&&(c=a);for(var f=0;c>f;++f){var s,l,p,h,v=t[f].replace(i,"%20"),d=v.indexOf(e);d>=0?(s=v.substr(0,d),l=v.substr(d+1)):(s=v,l=""),p=decodeURIComponent(s),h=decodeURIComponent(l),r(u,p)?Array.isArray(u[p])?u[p].push(h):u[p]=[u[p],h]:u[p]=h}return u}},function(t,n){"use strict";var r=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,n,e,o){return n=n||"&",e=e||"=",null===t&&(t=void 0),"object"==typeof t?Object.keys(t).map(function(o){var u=encodeURIComponent(r(o))+e;return Array.isArray(t[o])?t[o].map(function(t){return u+encodeURIComponent(r(t))}).join(n):u+encodeURIComponent(r(t[o]))}).join(n):o?encodeURIComponent(r(o))+e+encodeURIComponent(r(t)):""}},function(t,n,r){var e;(function(t,o){(function(){function u(t,n){if(t!==n){var r=null===t,e=t===E,o=t===t,u=null===n,i=n===E,a=n===n;if(t>n&&!u||!o||r&&!i&&a||e&&a)return 1;if(n>t&&!r||!a||u&&!e&&o||i&&o)return-1}return 0}function i(t,n,r){for(var e=t.length,o=r?e:-1;r?o--:++o-1;);return r}function l(t,n){for(var r=t.length;r--&&n.indexOf(t.charAt(r))>-1;);return r}function p(t,n){return u(t.criteria,n.criteria)||t.index-n.index}function h(t,n,r){for(var e=-1,o=t.criteria,i=n.criteria,a=o.length,c=r.length;++e=c)return f;var s=r[e];return f*("asc"===s||s===!0?1:-1)}}return t.index-n.index}function v(t){return Ht[t]}function d(t){return Kt[t]}function y(t,n,r){return n?t=Yt[t]:r&&(t=Vt[t]),"\\"+t}function _(t){return"\\"+Vt[t]}function g(t,n,r){for(var e=t.length,o=n+(r?0:-1);r?o--:++o=t&&t>=9&&13>=t||32==t||160==t||5760==t||6158==t||t>=8192&&(8202>=t||8232==t||8233==t||8239==t||8287==t||12288==t||65279==t)}function w(t,n){for(var r=-1,e=t.length,o=-1,u=[];++rn,o=r?t.length:0,u=Hr(0,o,this.__views__),i=u.start,a=u.end,c=a-i,f=e?a:i-1,s=this.__iteratees__,l=s.length,p=0,h=ji(c,this.__takeCount__);if(!r||L>o||o==c&&h==c)return er(e&&r?t.reverse():t,this.__actions__);var v=[];t:for(;c--&&h>p;){f+=n;for(var d=-1,y=t[f];++d=L?dr(n):null,f=n.length;c&&(u=Vt,i=!1,n=c);t:for(;++or&&(r=-r>o?0:o+r),e=e===E||e>o?o:+e||0,0>e&&(e+=o),o=r>e?0:e>>>0,r>>>=0;o>r;)t[r++]=n;return t}function In(t,n){var r=[];return $i(t,function(t,e,o){n(t,e,o)&&r.push(t)}),r}function Tn(t,n,r,e){var o;return r(t,function(t,r,u){return n(t,r,u)?(o=e?r:t,!1):void 0}),o}function Sn(t,n,r,e){e||(e=[]);for(var o=-1,u=t.length;++oe;)t=t[n[e++]];return e&&e==o?t:E}}function $n(t,n,r,e,o,u){return t===n?!0:null==t||null==n||!Uo(t)&&!m(n)?t!==t&&n!==n:Dn(t,n,$n,r,e,o,u)}function Dn(t,n,r,e,o,u,i){var a=Ta(t),c=Ta(n),f=X,s=X;a||(f=ei.call(t),f==K?f=nt:f!=nt&&(a=zo(t))),c||(s=ei.call(n),s==K?s=nt:s!=nt&&(c=zo(n)));var l=f==nt,p=s==nt,h=f==s;if(h&&!a&&!l)return Nr(t,n,f);if(!o){var v=l&&ni.call(t,"__wrapped__"),d=p&&ni.call(n,"__wrapped__");if(v||d)return r(v?t.value():t,d?n.value():n,e,o,u,i)}if(!h)return!1;u||(u=[]),i||(i=[]);for(var y=u.length;y--;)if(u[y]==t)return i[y]==n;u.push(t),i.push(n);var _=(a?qr:Br)(t,n,r,e,o,u,i);return u.pop(),i.pop(),_}function qn(t,n,r){var e=n.length,o=e,u=!r;if(null==t)return!o;for(t=le(t);e--;){var i=n[e];if(u&&i[2]?i[1]!==t[i[0]]:!(i[0]in t))return!1}for(;++en&&(n=-n>o?0:o+n),r=r===E||r>o?o:+r||0,0>r&&(r+=o),o=n>r?0:r-n>>>0,n>>>=0;for(var u=Mu(o);++e=L,c=i?dr():null,f=[];c?(e=Vt,u=!1):(i=!1,c=n?[]:f);t:for(;++r=o){for(;o>e;){var u=e+o>>>1,i=t[u];(r?n>=i:n>i)&&null!==i?e=u+1:o=u}return o}return ur(t,n,Iu,r)}function ur(t,n,r,e){n=r(n);for(var o=0,u=t?t.length:0,i=n!==n,a=null===n,c=n===E;u>o;){var f=gi((o+u)/2),s=r(t[f]),l=s!==E,p=s===s;if(i)var h=p||e;else h=a?p&&l&&(e||null!=s):c?p&&(e||l):null==s?!1:e?n>=s:n>s;h?o=f+1:u=f}return ji(u,Si)}function ir(t,n,r){if("function"!=typeof t)return Iu;if(n===E)return t;switch(r){case 1:return function(r){return t.call(n,r)};case 3:return function(r,e,o){return t.call(n,r,e,o)};case 4:return function(r,e,o,u){return t.call(n,r,e,o,u)};case 5:return function(r,e,o,u,i){return t.call(n,r,e,o,u,i)}}return function(){return t.apply(n,arguments)}}function ar(t){var n=new ii(t.byteLength),r=new vi(n);return r.set(new vi(t)),n}function cr(t,n,r){for(var e=r.length,o=-1,u=xi(t.length-e,0),i=-1,a=n.length,c=Mu(a+u);++i2?r[o-2]:E,i=o>2?r[2]:E,a=o>1?r[o-1]:E;for("function"==typeof u?(u=ir(u,a,5),o-=2):(u="function"==typeof a?a:E,o-=u?1:0),i&&Zr(r[0],r[1],i)&&(u=3>o?E:u,o=1);++e-1?r[u]:E}return Tn(r,e,t)}}function xr(t){return function(n,r,e){return n&&n.length?(r=Mr(r,e,3),i(n,r,t)):-1}}function jr(t){return function(n,r,e){return r=Mr(r,e,3),Tn(n,r,t,!0)}}function Or(t){return function(){for(var n,r=arguments.length,o=t?r:-1,u=0,i=Mu(r);t?o--:++o=L)return n.plant(e).value();for(var o=0,u=r?i[o].apply(this,t):e;++og){var O=a?tn(a):E,k=xi(f-g,0),A=v?j:E,I=v?E:j,R=v?b:E,P=v?E:b;n|=v?F:U,n&=~(v?U:F),d||(n&=~(T|S));var C=[t,n,r,R,A,P,I,O,c,k],$=Pr.apply(E,C);return ne(t)&&Wi($,C),$.placeholder=x,$}}var D=p?r:this,q=h?D[t]:t;return a&&(b=ce(b,a)),l&&c=n||!bi(n))return"";var o=n-e;return r=null==r?" ":r+"",_u(r,yi(o/r.length)).slice(0,o)}function Fr(t,n,r,e){function o(){for(var n=-1,a=arguments.length,c=-1,f=e.length,s=Mu(f+a);++cc))return!1;for(;++a-1&&t%1==0&&n>t}function Zr(t,n,r){if(!Uo(r))return!1;var e=typeof n;if("number"==e?Vr(r)&&Qr(n,r.length):"string"==e&&n in r){var o=r[n];return t===t?t===o:o!==o}return!1}function te(t,n){var r=typeof t;if("string"==r&&Et.test(t)||"number"==r)return!0;if(Ta(t))return!1;var e=!At.test(t);return e||null!=n&&t in le(n)}function ne(t){var r=Lr(t);if(!(r in o.prototype))return!1;var e=n[r];if(t===e)return!0;var u=Mi(e);return!!u&&t===u[0]}function re(t){return"number"==typeof t&&t>-1&&t%1==0&&Pi>=t}function ee(t){return t===t&&!Uo(t)}function oe(t,n){var r=t[1],e=n[1],o=r|e,u=$>o,i=e==$&&r==P||e==$&&r==D&&t[7].length<=n[8]||e==($|D)&&r==P;if(!u&&!i)return t;e&T&&(t[2]=n[2],o|=r&T?0:R);var a=n[3];if(a){var c=t[3];t[3]=c?cr(c,a,n[4]):tn(a),t[4]=c?w(t[3],H):tn(n[4])}return a=n[5],a&&(c=t[5],t[5]=c?fr(c,a,n[6]):tn(a),t[6]=c?w(t[5],H):tn(n[6])),a=n[7],a&&(t[7]=tn(a)),e&$&&(t[8]=null==t[8]?n[8]:ji(t[8],n[8])),null==t[9]&&(t[9]=n[9]),t[0]=n[0],t[1]=o,t}function ue(t,n){return t===E?n:Sa(t,n,ue)}function ie(t,n){t=le(t);for(var r=-1,e=n.length,o={};++re;)i[++u]=Jn(t,e,e+=n);return i}function de(t){for(var n=-1,r=t?t.length:0,e=-1,o=[];++nn?0:n)):[]}function _e(t,n,r){var e=t?t.length:0;return e?((r?Zr(t,n,r):null==n)&&(n=1),n=e-(+n||0),Jn(t,0,0>n?0:n)):[]}function ge(t,n,r){return t&&t.length?rr(t,Mr(n,r,3),!0,!0):[]}function me(t,n,r){return t&&t.length?rr(t,Mr(n,r,3),!0):[]}function be(t,n,r,e){var o=t?t.length:0;return o?(r&&"number"!=typeof r&&Zr(t,n,r)&&(r=0,e=o),En(t,n,r,e)):[]}function we(t){return t?t[0]:E}function xe(t,n,r){var e=t?t.length:0;return r&&Zr(t,n,r)&&(n=!1),e?Sn(t,n):[]}function je(t){var n=t?t.length:0;return n?Sn(t,!0):[]}function Oe(t,n,r){var e=t?t.length:0;if(!e)return-1;if("number"==typeof r)r=0>r?xi(e+r,0):r;else if(r){var o=or(t,n);return e>o&&(n===n?n===t[o]:t[o]!==t[o])?o:-1}return a(t,n,r||0)}function ke(t){return _e(t,1)}function Ae(t){var n=t?t.length:0;return n?t[n-1]:E}function Ee(t,n,r){var e=t?t.length:0;if(!e)return-1;var o=e;if("number"==typeof r)o=(0>r?xi(e+r,0):ji(r||0,e-1))+1;else if(r){o=or(t,n,!0)-1;var u=t[o];return(n===n?n===u:u!==u)?o:-1}if(n!==n)return g(t,o,!0);for(;o--;)if(t[o]===n)return o;return-1}function Ie(){var t=arguments,n=t[0];if(!n||!n.length)return n;for(var r=0,e=Wr(),o=t.length;++r-1;)hi.call(n,u,1);return n}function Te(t,n,r){var e=[];if(!t||!t.length)return e;var o=-1,u=[],i=t.length;for(n=Mr(n,r,3);++on?0:n)):[]}function Ce(t,n,r){var e=t?t.length:0;return e?((r?Zr(t,n,r):null==n)&&(n=1),n=e-(+n||0),Jn(t,0>n?0:n)):[]}function Fe(t,n,r){return t&&t.length?rr(t,Mr(n,r,3),!1,!0):[]}function Ue(t,n,r){return t&&t.length?rr(t,Mr(n,r,3)):[]}function $e(t,n,r,e){var o=t?t.length:0;if(!o)return[];null!=n&&"boolean"!=typeof n&&(e=r,r=Zr(t,n,e)?E:n,n=!1);var u=Mr();return(null!=r||u!==wn)&&(r=u(r,e,3)),n&&Wr()==a?x(t,r):tr(t,r)}function De(t){if(!t||!t.length)return[];var n=-1,r=0;t=cn(t,function(t){return Vr(t)?(r=xi(t.length,r),!0):void 0});for(var e=Mu(r);++nr?xi(o+r,0):r||0,"string"==typeof t||!Ta(t)&&Wo(t)?o>=r&&t.indexOf(n,r)>-1:!!o&&Wr(t,n,r)>-1}function to(t,n,r){var e=Ta(t)?fn:Nn;return n=Mr(n,r,3),e(t,n)}function no(t,n){return to(t,Fu(n))}function ro(t,n,r){var e=Ta(t)?cn:In;return n=Mr(n,r,3),e(t,function(t,r,e){return!n(t,r,e)})}function eo(t,n,r){if(r?Zr(t,n,r):null==n){t=se(t);var e=t.length;return e>0?t[Kn(0,e-1)]:E}var o=-1,u=Xo(t),e=u.length,i=e-1;for(n=ji(0>n?0:+n||0,e);++o0&&(r=n.apply(this,arguments)),1>=t&&(n=E),r}}function ho(t,n,r){function e(){h&&ai(h),f&&ai(f),d=0,f=h=v=E}function o(n,r){r&&ai(r),f=h=v=E,n&&(d=da(),s=t.apply(p,c),h||f||(c=p=E))}function u(){var t=n-(da()-l);0>=t||t>n?o(v,f):h=pi(u,t)}function i(){o(_,h)}function a(){if(c=arguments,l=da(),p=this,v=_&&(h||!g),y===!1)var r=g&&!h;else{f||g||(d=l);var e=y-(l-d),o=0>=e||e>y;o?(f&&(f=ai(f)),d=l,s=t.apply(p,c)):f||(f=pi(i,e))}return o&&h?h=ai(h):h||n===y||(h=pi(u,n)),r&&(o=!0,s=t.apply(p,c)),!o||h||f||(c=p=E),s}var c,f,s,l,p,h,v,d=0,y=!1,_=!0;if("function"!=typeof t)throw new Yu(G);if(n=0>n?0:+n||0,r===!0){var g=!0;_=!1}else Uo(r)&&(g=!!r.leading,y="maxWait"in r&&xi(+r.maxWait||0,n),_="trailing"in r?!!r.trailing:_);return a.cancel=e,a}function vo(t,n){if("function"!=typeof t||n&&"function"!=typeof n)throw new Yu(G);var r=function(){var e=arguments,o=n?n.apply(this,e):e[0],u=r.cache;if(u.has(o))return u.get(o);var i=t.apply(this,e);return r.cache=u.set(o,i),i};return r.cache=new vo.Cache,r}function yo(t){if("function"!=typeof t)throw new Yu(G);return function(){return!t.apply(this,arguments)}}function _o(t){return po(2,t)}function go(t,n){if("function"!=typeof t)throw new Yu(G);return n=xi(n===E?t.length-1:+n||0,0),function(){for(var r=arguments,e=-1,o=xi(r.length-n,0),u=Mu(o);++en}function ko(t,n){return t>=n}function Ao(t){return m(t)&&Vr(t)&&ni.call(t,"callee")&&!si.call(t,"callee")}function Eo(t){return t===!0||t===!1||m(t)&&ei.call(t)==J}function Io(t){return m(t)&&ei.call(t)==Y}function To(t){return!!t&&1===t.nodeType&&m(t)&&!Mo(t)}function So(t){return null==t?!0:Vr(t)&&(Ta(t)||Wo(t)||Ao(t)||m(t)&&Fo(t.splice))?!t.length:!Ba(t).length}function Ro(t,n,r,e){r="function"==typeof r?ir(r,e,3):E;var o=r?r(t,n):E;return o===E?$n(t,n,r):!!o}function Po(t){return m(t)&&"string"==typeof t.message&&ei.call(t)==V}function Co(t){return"number"==typeof t&&bi(t)}function Fo(t){return Uo(t)&&ei.call(t)==Q}function Uo(t){var n=typeof t;return!!t&&("object"==n||"function"==n)}function $o(t,n,r,e){return r="function"==typeof r?ir(r,e,3):E,qn(t,zr(n),r)}function Do(t){return Bo(t)&&t!=+t}function qo(t){return null==t?!1:Fo(t)?ui.test(ti.call(t)):m(t)&&$t.test(t)}function No(t){return null===t}function Bo(t){return"number"==typeof t||m(t)&&ei.call(t)==tt}function Mo(t){var n;if(!m(t)||ei.call(t)!=nt||Ao(t)||!ni.call(t,"constructor")&&(n=t.constructor,"function"==typeof n&&!(n instanceof n)))return!1;var r;return Rn(t,function(t,n){r=n}),r===E||ni.call(t,r)}function Lo(t){return Uo(t)&&ei.call(t)==rt}function Wo(t){return"string"==typeof t||m(t)&&ei.call(t)==ot}function zo(t){return m(t)&&re(t.length)&&!!zt[ei.call(t)]}function Go(t){return t===E}function Ho(t,n){return n>t}function Ko(t,n){return n>=t}function Xo(t){var n=t?Li(t):0;return re(n)?n?tn(t):[]:iu(t)}function Jo(t){return bn(t,nu(t))}function Yo(t,n,r){var e=Ui(t);return r&&Zr(t,n,r)&&(n=E),n?gn(e,n):e}function Vo(t){return Fn(t,nu(t))}function Qo(t,n,r){var e=null==t?E:Un(t,pe(n),n+"");return e===E?r:e}function Zo(t,n){if(null==t)return!1;var r=ni.call(t,n);if(!r&&!te(n)){if(n=pe(n),t=1==n.length?t:Un(t,Jn(n,0,-1)),null==t)return!1;n=Ae(n),r=ni.call(t,n)}return r||re(t.length)&&Qr(n,t.length)&&(Ta(t)||Ao(t))}function tu(t,n,r){r&&Zr(t,n,r)&&(n=E);for(var e=-1,o=Ba(t),u=o.length,i={};++e0;++e=ji(n,r)&&tr?0:+r||0,e),r-=n.length,r>=0&&t.indexOf(n,r)==r}function hu(t){return t=f(t),t&&xt.test(t)?t.replace(bt,d):t}function vu(t){return t=f(t),t&&St.test(t)?t.replace(Tt,y):t||"(?:)"}function du(t,n,r){t=f(t),n=+n;var e=t.length;if(e>=n||!bi(n))return t;var o=(n-e)/2,u=gi(o),i=yi(o);return r=Cr("",i,r),r.slice(0,u)+t+r}function yu(t,n,r){return(r?Zr(t,n,r):null==n)?n=0:n&&(n=+n),t=bu(t),ki(t,n||(Ut.test(t)?16:10))}function _u(t,n){var r="";if(t=f(t),n=+n,1>n||!t||!bi(n))return r;do n%2&&(r+=t),n=gi(n/2),t+=t;while(n);return r}function gu(t,n,r){return t=f(t),r=null==r?0:ji(0>r?0:+r||0,t.length),t.lastIndexOf(n,r)==r}function mu(t,r,e){var o=n.templateSettings;e&&Zr(t,r,e)&&(r=e=E),t=f(t),r=_n(gn({},e||r),o,yn);var u,i,a=_n(gn({},r.imports),o.imports,yn),c=Ba(a),s=nr(a,c),l=0,p=r.interpolate||Nt,h="__p += '",v=Xu((r.escape||Nt).source+"|"+p.source+"|"+(p===kt?Ct:Nt).source+"|"+(r.evaluate||Nt).source+"|$","g"),d="//# sourceURL="+("sourceURL"in r?r.sourceURL:"lodash.templateSources["+ ++Wt+"]")+"\n";t.replace(v,function(n,r,e,o,a,c){return e||(e=o),h+=t.slice(l,c).replace(Bt,_),r&&(u=!0,h+="' +\n__e("+r+") +\n'"),a&&(i=!0,h+="';\n"+a+";\n__p += '"),e&&(h+="' +\n((__t = ("+e+")) == null ? '' : __t) +\n'"),l=c+n.length,n}),h+="';\n";var y=r.variable;y||(h="with (obj) {\n"+h+"\n}\n"),h=(i?h.replace(yt,""):h).replace(_t,"$1").replace(gt,"$1;"),h="function("+(y||"obj")+") {\n"+(y?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(u?", __e = _.escape":"")+(i?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+h+"return __p\n}";var g=Va(function(){return zu(c,d+"return "+h).apply(E,s)});if(g.source=h,Po(g))throw g;return g}function bu(t,n,r){var e=t;return(t=f(t))?(r?Zr(e,n,r):null==n)?t.slice(j(t),O(t)+1):(n+="",t.slice(s(t,n),l(t,n)+1)):t}function wu(t,n,r){var e=t;return t=f(t),t?(r?Zr(e,n,r):null==n)?t.slice(j(t)):t.slice(s(t,n+"")):t}function xu(t,n,r){var e=t;return t=f(t),t?(r?Zr(e,n,r):null==n)?t.slice(0,O(t)+1):t.slice(0,l(t,n+"")+1):t}function ju(t,n,r){r&&Zr(t,n,r)&&(n=E);var e=q,o=N;if(null!=n)if(Uo(n)){var u="separator"in n?n.separator:u;e="length"in n?+n.length||0:e,o="omission"in n?f(n.omission):o}else e=+n||0;if(t=f(t),e>=t.length)return t;var i=e-o.length;if(1>i)return o;var a=t.slice(0,i);if(null==u)return a+o;if(Lo(u)){if(t.slice(i).search(u)){var c,s,l=t.slice(0,i);for(u.global||(u=Xu(u.source,(Ft.exec(u)||"")+"g")),u.lastIndex=0;c=u.exec(l);)s=c.index;a=a.slice(0,null==s?i:s)}}else if(t.indexOf(u,i)!=i){var p=a.lastIndexOf(u);p>-1&&(a=a.slice(0,p))}return a+o}function Ou(t){return t=f(t),t&&wt.test(t)?t.replace(mt,k):t}function ku(t,n,r){return r&&Zr(t,n,r)&&(n=E),t=f(t),t.match(n||Mt)||[]}function Au(t,n,r){return r&&Zr(t,n,r)&&(n=E),m(t)?Tu(t):wn(t,n)}function Eu(t){return function(){return t}}function Iu(t){return t}function Tu(t){return Bn(xn(t,!0))}function Su(t,n){return Mn(t,xn(n,!0))}function Ru(t,n,r){if(null==r){var e=Uo(n),o=e?Ba(n):E,u=o&&o.length?Fn(n,o):E;(u?u.length:e)||(u=!1,r=n,n=t,t=this)}u||(u=Fn(n,Ba(n)));var i=!0,a=-1,c=Fo(t),f=u.length;r===!1?i=!1:Uo(r)&&"chain"in r&&(i=r.chain);for(;++at||!bi(t))return[];var e=-1,o=Mu(ji(t,Ti));for(n=ir(n,r,1);++ee?o[e]=n(e):n(e);return o}function qu(t){var n=++ri;return f(t)+n}function Nu(t,n){return(+t||0)+(+n||0)}function Bu(t,n,r){return r&&Zr(t,n,r)&&(n=E),n=Mr(n,r,3),1==n.length?vn(Ta(t)?t:se(t),n):Zn(t,n)}t=t?on.defaults(en.Object(),t,on.pick(en,Lt)):en;var Mu=t.Array,Lu=t.Date,Wu=t.Error,zu=t.Function,Gu=t.Math,Hu=t.Number,Ku=t.Object,Xu=t.RegExp,Ju=t.String,Yu=t.TypeError,Vu=Mu.prototype,Qu=Ku.prototype,Zu=Ju.prototype,ti=zu.prototype.toString,ni=Qu.hasOwnProperty,ri=0,ei=Qu.toString,oi=en._,ui=Xu("^"+ti.call(ni).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ii=t.ArrayBuffer,ai=t.clearTimeout,ci=t.parseFloat,fi=Gu.pow,si=Qu.propertyIsEnumerable,li=Gr(t,"Set"),pi=t.setTimeout,hi=Vu.splice,vi=t.Uint8Array,di=Gr(t,"WeakMap"),yi=Gu.ceil,_i=Gr(Ku,"create"),gi=Gu.floor,mi=Gr(Mu,"isArray"),bi=t.isFinite,wi=Gr(Ku,"keys"),xi=Gu.max,ji=Gu.min,Oi=Gr(Lu,"now"),ki=t.parseInt,Ai=Gu.random,Ei=Hu.NEGATIVE_INFINITY,Ii=Hu.POSITIVE_INFINITY,Ti=4294967295,Si=Ti-1,Ri=Ti>>>1,Pi=9007199254740991,Ci=di&&new di,Fi={};n.support={};n.templateSettings={escape:jt,evaluate:Ot,interpolate:kt,variable:"",imports:{_:n}};var Ui=function(){function t(){}return function(n){if(Uo(n)){t.prototype=n;var r=new t;t.prototype=E}return r||{}}}(),$i=pr(Pn),Di=pr(Cn,!0),qi=hr(),Ni=hr(!0),Bi=Ci?function(t,n){return Ci.set(t,n),t}:Iu,Mi=Ci?function(t){return Ci.get(t)}:Cu,Li=zn("length"),Wi=function(){var t=0,n=0;return function(r,e){var o=da(),u=M-(o-n);if(n=o,u>0){if(++t>=B)return r}else t=0;return Bi(r,e)}}(),zi=go(function(t,n){return m(t)&&Vr(t)?On(t,Sn(n,!1,!0)):[]}),Gi=xr(),Hi=xr(!0),Ki=go(function(t){for(var n=t.length,r=n,e=Mu(l),o=Wr(),u=o==a,i=[];r--;){var c=t[r]=Vr(c=t[r])?c:[];e[r]=u&&c.length>=120?dr(r&&c):null}var f=t[0],s=-1,l=f?f.length:0,p=e[0];t:for(;++s2?t[n-2]:E,e=n>1?t[n-1]:E;return n>2&&"function"==typeof r?n-=2:(r=n>1&&"function"==typeof e?(--n,e):E,e=E),t.length=n,qe(t,r,e)}),na=go(function(t){return t=Sn(t),this.thru(function(n){return Zt(Ta(n)?n:[le(n)],t)})}),ra=go(function(t,n){return mn(t,Sn(n))}),ea=sr(function(t,n,r){ni.call(t,r)?++t[r]:t[r]=1}),oa=wr($i),ua=wr(Di,!0),ia=kr(nn,$i),aa=kr(rn,Di),ca=sr(function(t,n,r){ni.call(t,r)?t[r].push(n):t[r]=[n]}),fa=sr(function(t,n,r){t[r]=n}),sa=go(function(t,n,r){var e=-1,o="function"==typeof n,u=te(n),i=Vr(t)?Mu(t.length):[];return $i(t,function(t){var a=o?n:u&&null!=t?t[n]:E;i[++e]=a?a.apply(t,r):Yr(t,n,r)}),i}),la=sr(function(t,n,r){t[r?0:1].push(n)},function(){return[[],[]]}),pa=Rr(ln,$i),ha=Rr(pn,Di),va=go(function(t,n){if(null==t)return[];var r=n[2];return r&&Zr(n[0],n[1],r)&&(n.length=1),Qn(t,Sn(n),[])}),da=Oi||function(){return(new Lu).getTime()},ya=go(function(t,n,r){var e=T;if(r.length){var o=w(r,ya.placeholder);e|=F}return Dr(t,e,n,r,o)}),_a=go(function(t,n){n=n.length?Sn(n):Vo(t);for(var r=-1,e=n.length;++r0||0>n)?new o(r):(0>t?r=r.takeRight(-t):t&&(r=r.drop(t)),n!==E&&(n=+n||0,r=0>n?r.dropRight(-n):r.take(n-t)),r)},o.prototype.takeRightWhile=function(t,n){return this.reverse().takeWhile(t,n).reverse()},o.prototype.toArray=function(){return this.take(Ii)},Pn(o.prototype,function(t,r){var u=/^(?:filter|map|reject)|While$/.test(r),i=/^(?:first|last)$/.test(r),a=n[i?"take"+("last"==r?"Right":""):r];a&&(n.prototype[r]=function(){var n=i?[1]:arguments,r=this.__chain__,c=this.__wrapped__,f=!!this.__actions__.length,s=c instanceof o,l=n[0],p=s||Ta(c);p&&u&&"function"==typeof l&&1!=l.length&&(s=p=!1);var h=function(t){return i&&r?a(t,1)[0]:a.apply(E,sn([t],n))},v={func:We,args:[h],thisArg:E},d=s&&!f;if(i&&!r)return d?(c=c.clone(),c.__actions__.push(v),t.call(c)):a.call(E,this.value())[0];if(!i&&p){c=d?c:new o(this);var y=t.apply(c,n);return y.__actions__.push(v),new e(y,r)}return this.thru(h)})}),nn(["join","pop","push","replace","shift","sort","splice","split","unshift"],function(t){var r=(/^(?:replace|split)$/.test(t)?Zu:Vu)[t],e=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",o=/^(?:join|pop|replace|shift)$/.test(t);n.prototype[t]=function(){var t=arguments;return o&&!this.__chain__?r.apply(this.value(),t):this[e](function(n){return r.apply(n,t)})}}),Pn(o.prototype,function(t,r){var e=n[r];if(e){var o=e.name,u=Fi[o]||(Fi[o]=[]);u.push({name:r,func:e})}}),Fi[Pr(E,S).name]=[{name:"wrapper",func:E}],o.prototype.clone=b,o.prototype.reverse=Z,o.prototype.value=et,n.prototype.chain=ze,n.prototype.commit=Ge,n.prototype.concat=na,n.prototype.plant=He,n.prototype.reverse=Ke,n.prototype.toString=Xe,n.prototype.run=n.prototype.toJSON=n.prototype.valueOf=n.prototype.value=Je,n.prototype.collect=n.prototype.map,n.prototype.head=n.prototype.first,n.prototype.select=n.prototype.filter,n.prototype.tail=n.prototype.rest,n}var E,I="3.10.0",T=1,S=2,R=4,P=8,C=16,F=32,U=64,$=128,D=256,q=30,N="...",B=150,M=16,L=200,W=1,z=2,G="Expected a function",H="__lodash_placeholder__",K="[object Arguments]",X="[object Array]",J="[object Boolean]",Y="[object Date]",V="[object Error]",Q="[object Function]",Z="[object Map]",tt="[object Number]",nt="[object Object]",rt="[object RegExp]",et="[object Set]",ot="[object String]",ut="[object WeakMap]",it="[object ArrayBuffer]",at="[object Float32Array]",ct="[object Float64Array]",ft="[object Int8Array]",st="[object Int16Array]",lt="[object Int32Array]",pt="[object Uint8Array]",ht="[object Uint8ClampedArray]",vt="[object Uint16Array]",dt="[object Uint32Array]",yt=/\b__p \+= '';/g,_t=/\b(__p \+=) '' \+/g,gt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,mt=/&(?:amp|lt|gt|quot|#39|#96);/g,bt=/[&<>"'`]/g,wt=RegExp(mt.source),xt=RegExp(bt.source),jt=/<%-([\s\S]+?)%>/g,Ot=/<%([\s\S]+?)%>/g,kt=/<%=([\s\S]+?)%>/g,At=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,Et=/^\w*$/,It=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g,Tt=/^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g,St=RegExp(Tt.source),Rt=/[\u0300-\u036f\ufe20-\ufe23]/g,Pt=/\\(\\)?/g,Ct=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Ft=/\w*$/,Ut=/^0[xX]/,$t=/^\[object .+?Constructor\]$/,Dt=/^\d+$/,qt=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,Nt=/($^)/,Bt=/['\n\r\u2028\u2029\\]/g,Mt=function(){var t="[A-Z\\xc0-\\xd6\\xd8-\\xde]",n="[a-z\\xdf-\\xf6\\xf8-\\xff]+";return RegExp(t+"+(?="+t+n+")|"+t+"?"+n+"|"+t+"+|[0-9]+","g")}(),Lt=["Array","ArrayBuffer","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Math","Number","Object","RegExp","Set","String","_","clearTimeout","isFinite","parseFloat","parseInt","setTimeout","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap"],Wt=-1,zt={};zt[at]=zt[ct]=zt[ft]=zt[st]=zt[lt]=zt[pt]=zt[ht]=zt[vt]=zt[dt]=!0,zt[K]=zt[X]=zt[it]=zt[J]=zt[Y]=zt[V]=zt[Q]=zt[Z]=zt[tt]=zt[nt]=zt[rt]=zt[et]=zt[ot]=zt[ut]=!1;var Gt={};Gt[K]=Gt[X]=Gt[it]=Gt[J]=Gt[Y]=Gt[at]=Gt[ct]=Gt[ft]=Gt[st]=Gt[lt]=Gt[tt]=Gt[nt]=Gt[rt]=Gt[ot]=Gt[pt]=Gt[ht]=Gt[vt]=Gt[dt]=!0,Gt[V]=Gt[Q]=Gt[Z]=Gt[et]=Gt[ut]=!1;var Ht={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},Kt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Xt={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Jt={"function":!0,object:!0},Yt={0:"x30",1:"x31",2:"x32",3:"x33",4:"x34",5:"x35",6:"x36",7:"x37",8:"x38",9:"x39",A:"x41",B:"x42",C:"x43",D:"x44",E:"x45",F:"x46",a:"x61",b:"x62",c:"x63",d:"x64",e:"x65",f:"x66",n:"x6e",r:"x72",t:"x74",u:"x75",v:"x76",x:"x78"},Vt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Qt=Jt[typeof n]&&n&&!n.nodeType&&n,Zt=Jt[typeof t]&&t&&!t.nodeType&&t,tn=Qt&&Zt&&"object"==typeof o&&o&&o.Object&&o,nn=Jt[typeof self]&&self&&self.Object&&self,rn=Jt[typeof window]&&window&&window.Object&&window,en=(Zt&&Zt.exports===Qt&&Qt,tn||rn!==(this&&this.window)&&rn||nn||this),on=A();en._=on,e=function(){return on}.call(n,r,n,t),!(e!==E&&(t.exports=e))}).call(this)}).call(n,r(53)(t),function(){return this}())},function(t,n){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children=[],t.webpackPolyfill=1),t}}])}); \ No newline at end of file +!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.Montage=n():t.Montage=n()}(this,function(){return function(t){function n(e){if(r[e])return r[e].exports;var i=r[e]={exports:{},id:e,loaded:!1};return t[e].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}var r={};return n.m=t,n.c=r,n.p="",n(0)}(function(t){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n))switch(typeof t[n]){case"function":break;case"object":t[n]=function(n){var r=n.slice(1),e=t[n[0]];return function(t,n,i){e.apply(this,[t,n,i].concat(r))}}(t[n]);break;default:t[n]=t[t[n]]}return t}([function(t,n,r){"use strict";function e(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(n,"__esModule",{value:!0}),n.Query=n.Field=n.Client=void 0;var i=r(1),o=e(i),u=r(388),c=e(u),f=r(389),a=e(f);n.Client=o["default"],n.Field=a["default"],n.Query=c["default"]},function(t,n,r){"use strict";function e(t){return t&&t.__esModule?t:{"default":t}}function i(t){t=String(t);for(var n=0,r=0;r=400?t.text().then(function(n){var r=n||t.statusText;try{r=JSON.parse(n)}catch(e){}return f["default"].reject(r)}):t.json():(t.request=_["default"].merge({url:o},c),f["default"].reject(t))}).then(function(t){return t&&t.errors?f["default"].reject(t.errors):t})}},{key:"_agent",value:function(){return v["default"].apply(void 0,arguments)}}]),t}();n["default"]=M},function(t,n,r){t.exports={"default":r(3),__esModule:!0}},function(t,n,r){var e=r(4),i=e.JSON||(e.JSON={stringify:JSON.stringify});t.exports=function(t){return i.stringify.apply(i,arguments)}},function(t,n){var r=t.exports={version:"2.4.0"};"number"==typeof __e&&(__e=r)},function(t,n,r){t.exports={"default":r(6),__esModule:!0}},function(t,n,r){r(7),r(8),r(51),r(55),t.exports=r(4).Promise},function(t,n){},[390,9,12],[391,10,11],function(t,n){var r=Math.ceil,e=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?e:r)(t)}},function(t,n){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},[392,13,14,28,18,29,30,31,47,49,48],function(t,n){t.exports=!0},function(t,n,r){var e=r(15),i=r(4),o=r(16),u=r(18),c="prototype",f=function(t,n,r){var a,s,l,h=t&f.F,p=t&f.G,v=t&f.S,d=t&f.P,y=t&f.B,g=t&f.W,_=p?i:i[n]||(i[n]={}),m=_[c],b=p?e:v?e[n]:(e[n]||{})[c];p&&(r=n);for(a in r)s=!h&&b&&void 0!==b[a],s&&a in _||(l=s?b[a]:r[a],_[a]=p&&"function"!=typeof b[a]?r[a]:y&&s?o(l,e):g&&b[a]==l?function(t){var n=function(n,r,e){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(n);case 2:return new t(n,r)}return new t(n,r,e)}return t.apply(this,arguments)};return n[c]=t[c],n}(l):d&&"function"==typeof l?o(Function.call,l):l,d&&((_.virtual||(_.virtual={}))[a]=l,t&f.R&&m&&!m[a]&&u(m,a,l)))};f.F=1,f.G=2,f.S=4,f.P=8,f.B=16,f.W=32,f.U=64,f.R=128,t.exports=f},function(t,n){var r=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},[393,17],function(t,n){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},[394,19,27,23],[395,20,22,26,23],[396,21],function(t,n){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},[397,23,24,25],[398,24],function(t,n){t.exports=function(t){try{return!!t()}catch(n){return!0}}},[399,21,15],[400,21],function(t,n){t.exports=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}}},function(t,n,r){t.exports=r(18)},function(t,n){var r={}.hasOwnProperty;t.exports=function(t,n){return r.call(t,n)}},function(t,n){t.exports={}},[401,32,27,47,18,48],[402,20,33,45,42,25,46],[403,19,20,34,23],[404,35,45],[405,29,36,39,42],[406,37,11],[407,38],function(t,n){var r={}.toString;t.exports=function(t){return r.call(t).slice(8,-1)}},[408,36,40,41],[409,10],[410,10],[411,43,44],[412,15],function(t,n){var r=0,e=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++r+e).toString(36))}},function(t,n){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},[413,15],[414,19,29,48],[415,43,44,15],[416,29,50,42],[417,11],function(t,n,r){r(52);for(var e=r(15),i=r(18),o=r(30),u=r(48)("toStringTag"),c=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],f=0;f<5;f++){var a=c[f],s=e[a],l=s&&s.prototype;l&&!l[u]&&i(l,u,a),o[a]=o.Array}},[418,53,54,30,36,12],function(t,n){t.exports=function(){}},function(t,n){t.exports=function(t,n){return{value:n,done:!!t}}},[419,13,15,16,56,14,21,17,57,58,62,63,65,48,66,47,67,4,68],[420,38,48],function(t,n){t.exports=function(t,n,r,e){if(!(t instanceof n)||void 0!==e&&e in t)throw TypeError(r+": incorrect invocation!");return t}},[421,16,59,60,20,40,61],[422,20],[423,30,48],[424,56,48,30,4],[425,20,17,48],[426,16,64,46,25,15,38],function(t,n){t.exports=function(t,n,r){var e=void 0===r;switch(n.length){case 0:return e?t():t.call(r);case 1:return e?t(n[0]):t.call(r,n[0]);case 2:return e?t(n[0],n[1]):t.call(r,n[0],n[1]);case 3:return e?t(n[0],n[1],n[2]):t.call(r,n[0],n[1],n[2]);case 4:return e?t(n[0],n[1],n[2],n[3]):t.call(r,n[0],n[1],n[2],n[3])}return t.apply(r,n)}},[427,15,63,38],function(t,n,r){var e=r(18);t.exports=function(t,n,r){for(var i in n)r&&t[i]?t[i]=n[i]:e(t,i,n[i]);return t}},function(t,n,r){"use strict";var e=r(15),i=r(4),o=r(19),u=r(23),c=r(48)("species");t.exports=function(t){var n="function"==typeof i[t]?i[t]:e[t];u&&n&&!n[c]&&o.f(n,c,{configurable:!0,get:function(){return this}})}},[428,48],function(t,n){"use strict";n.__esModule=!0,n["default"]=function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}},function(t,n,r){"use strict";function e(t){return t&&t.__esModule?t:{"default":t}}n.__esModule=!0;var i=r(71),o=e(i);n["default"]=function(){function t(t,n){for(var r=0;r-1?n:t}function l(t,n){n=n||{};var r=n.body;if(l.prototype.isPrototypeOf(t)){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,n.headers||(this.headers=new i(t.headers)),this.method=t.method,this.mode=t.mode,r||(r=t._bodyInit,t.bodyUsed=!0)}else this.url=t;if(this.credentials=n.credentials||this.credentials||"omit",!n.headers&&this.headers||(this.headers=new i(n.headers)),this.method=s(n.method||this.method||"GET"),this.mode=n.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function h(t){var n=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),e=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");n.append(decodeURIComponent(e),decodeURIComponent(i))}}),n}function p(t){var n=new i,r=(t.getAllResponseHeaders()||"").trim().split("\n");return r.forEach(function(t){var r=t.trim().split(":"),e=r.shift().trim(),i=r.join(":").trim();n.append(e,i)}),n}function v(t,n){n||(n={}),this.type="default",this.status=n.status,this.ok=this.status>=200&&this.status<300,this.statusText=n.statusText,this.headers=n.headers instanceof i?n.headers:new i(n.headers),this.url=n.url||"",this._initBody(t)}if(!t.fetch){var d={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};i.prototype.append=function(t,e){t=n(t),e=r(e);var i=this.map[t];i||(i=[],this.map[t]=i),i.push(e)},i.prototype["delete"]=function(t){delete this.map[n(t)]},i.prototype.get=function(t){var r=this.map[n(t)];return r?r[0]:null},i.prototype.getAll=function(t){return this.map[n(t)]||[]},i.prototype.has=function(t){return this.map.hasOwnProperty(n(t))},i.prototype.set=function(t,e){this.map[n(t)]=[r(e)]},i.prototype.forEach=function(t,n){Object.getOwnPropertyNames(this.map).forEach(function(r){this.map[r].forEach(function(e){t.call(n,e,r,this)},this)},this)},i.prototype.keys=function(){var t=[];return this.forEach(function(n,r){t.push(r)}),e(t)},i.prototype.values=function(){var t=[];return this.forEach(function(n){t.push(n)}),e(t)},i.prototype.entries=function(){var t=[];return this.forEach(function(n,r){t.push([r,n])}),e(t)},d.iterable&&(i.prototype[Symbol.iterator]=i.prototype.entries);var y=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];l.prototype.clone=function(){return new l(this)},a.call(l.prototype),a.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new i(this.headers),url:this.url})},v.error=function(){var t=new v(null,{status:0,statusText:""});return t.type="error",t};var g=[301,302,303,307,308];v.redirect=function(t,n){if(g.indexOf(n)===-1)throw new RangeError("Invalid status code");return new v(null,{status:n,headers:{location:t}})},t.Headers=i,t.Request=l,t.Response=v,t.fetch=function(t,n){return new Promise(function(r,e){function i(){return"responseURL"in u?u.responseURL:/^X-Request-URL:/m.test(u.getAllResponseHeaders())?u.getResponseHeader("X-Request-URL"):void 0}var o;o=l.prototype.isPrototypeOf(t)&&!n?t:new l(t,n);var u=new XMLHttpRequest;u.onload=function(){var t={status:u.status,statusText:u.statusText,headers:p(u),url:i()},n="response"in u?u.response:u.responseText;r(new v(n,t))},u.onerror=function(){e(new TypeError("Network request failed"))},u.ontimeout=function(){e(new TypeError("Network request failed"))},u.open(o.method,o.url,!0),"include"===o.credentials&&(u.withCredentials=!0),"responseType"in u&&d.blob&&(u.responseType="blob"),o.headers.forEach(function(t,n){u.setRequestHeader(n,t)}),u.send("undefined"==typeof o._bodyInit?null:o._bodyInit)})},t.fetch.polyfill=!0}}("undefined"!=typeof self?self:this)},function(t,n,r){"use strict";n.decode=n.parse=r(77),n.encode=n.stringify=r(78)},function(t,n){"use strict";function r(t,n){return Object.prototype.hasOwnProperty.call(t,n)}t.exports=function(t,n,e,i){n=n||"&",e=e||"=";var o={};if("string"!=typeof t||0===t.length)return o;var u=/\+/g;t=t.split(n);var c=1e3;i&&"number"==typeof i.maxKeys&&(c=i.maxKeys);var f=t.length;c>0&&f>c&&(f=c);for(var a=0;a=0?(s=v.substr(0,d),l=v.substr(d+1)):(s=v,l=""),h=decodeURIComponent(s),p=decodeURIComponent(l),r(o,h)?Array.isArray(o[h])?o[h].push(p):o[h]=[o[h],p]:o[h]=p}return o}},function(t,n){"use strict";var r=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,n,e,i){return n=n||"&",e=e||"=",null===t&&(t=void 0),"object"==typeof t?Object.keys(t).map(function(i){var o=encodeURIComponent(r(i))+e;return Array.isArray(t[i])?t[i].map(function(t){return o+encodeURIComponent(r(t))}).join(n):o+encodeURIComponent(r(t[i]))}).join(n):i?encodeURIComponent(r(i))+e+encodeURIComponent(r(t)):""}},function(t,n,r){var e;(function(t,i){(function(){function o(t,n){if(t!==n){var r=null===t,e=t===A,i=t===t,o=null===n,u=n===A,c=n===n;if(t>n&&!o||!i||r&&!u&&c||e&&c)return 1;if(t-1;);return r}function l(t,n){for(var r=t.length;r--&&n.indexOf(t.charAt(r))>-1;);return r}function h(t,n){return o(t.criteria,n.criteria)||t.index-n.index}function p(t,n,r){for(var e=-1,i=t.criteria,u=n.criteria,c=i.length,f=r.length;++e=f)return a;var s=r[e];return a*("asc"===s||s===!0?1:-1)}}return t.index-n.index}function v(t){return Vt[t]}function d(t){return Jt[t]}function y(t,n,r){return n?t=Yt[t]:r&&(t=Xt[t]),"\\"+t}function g(t){return"\\"+Xt[t]}function _(t,n,r){for(var e=t.length,i=n+(r?0:-1);r?i--:++i=9&&t<=13||32==t||160==t||5760==t||6158==t||t>=8192&&(t<=8202||8232==t||8233==t||8239==t||8287==t||12288==t||65279==t)}function w(t,n){for(var r=-1,e=t.length,i=-1,o=[];++r=B?dr(n):null,a=n.length;f&&(o=Xt,u=!1,n=f);t:for(;++ii?0:i+r),e=e===A||e>i?i:+e||0,e<0&&(e+=i),i=r>e?0:e>>>0,r>>>=0;ri?0:i+n),r=r===A||r>i?i:+r||0,r<0&&(r+=i),i=n>r?0:r-n>>>0,n>>>=0;for(var o=Do(i);++e=B,f=u?dr():null,a=[];f?(e=Xt,o=!1):(u=!1,f=n?[]:a);t:for(;++r>>1,u=t[o];(r?u<=n:u2?r[i-2]:A,u=i>2?r[2]:A,c=i>1?r[i-1]:A;for("function"==typeof o?(o=ur(o,c,5),i-=2):(o="function"==typeof c?c:A,i-=o?1:0),u&&Zr(r[0],r[1],u)&&(o=i<3?A:o,i=1);++e-1?r[o]:A}return Pn(r,e,t)}}function xr(t){return function(n,r,e){return n&&n.length?(r=Dr(r,e,3),u(n,r,t)):-1}}function Sr(t){return function(n,r,e){return r=Dr(r,e,3),Pn(n,r,t,!0)}}function Er(t){return function(){for(var n,r=arguments.length,i=t?r:-1,o=0,u=Do(r);t?i--:++i=B)return n.plant(e).value();for(var i=0,o=r?u[i].apply(this,t):e;++i=n||!bu(n))return"";var i=n-e;return r=null==r?" ":r+"",go(r,yu(i/r.length)).slice(0,i)}function Rr(t,n,r,e){function i(){for(var n=-1,c=arguments.length,f=-1,a=e.length,s=Do(a+c);++ff))return!1;for(;++c-1&&t%1==0&&t-1&&t%1==0&&t<=Tu}function ee(t){return t===t&&!Ri(t)}function ie(t,n){var r=t[1],e=n[1],i=r|e,o=i-1;)pu.call(n,o,1);return n}function Pe(t,n,r){var e=[];if(!t||!t.length)return e;var i=-1,o=[],u=t.length;for(n=Dr(n,r,3);++i-1:!!i&&Wr(t,n,r)>-1}function ti(t,n,r){var e=Pc(t)?an:$n;return n=Dr(n,r,3),e(t,n)}function ni(t,n){return ti(t,Ro(n))}function ri(t,n,r){var e=Pc(t)?fn:jn;return n=Dr(n,r,3),e(t,function(t,r,e){return!n(t,r,e)})}function ei(t,n,r){if(r?Zr(t,n,r):null==n){t=se(t);var e=t.length;return e>0?t[Jn(0,e-1)]:A}var i=-1,o=Ji(t),e=o.length,u=e-1;for(n=Su(n<0?0:+n||0,e);++i0&&(r=n.apply(this,arguments)),t<=1&&(n=A),r}}function pi(t,n,r){function e(){p&&cu(p),a&&cu(a),d=0,a=p=v=A}function i(n,r){r&&cu(r),a=p=v=A,n&&(d=dc(),s=t.apply(h,f),p||a||(f=h=A))}function o(){var t=n-(dc()-l);t<=0||t>n?i(v,a):p=hu(o,t)}function u(){i(g,p)}function c(){if(f=arguments,l=dc(),h=this,v=g&&(p||!_),y===!1)var r=_&&!p;else{a||_||(d=l);var e=y-(l-d),i=e<=0||e>y;i?(a&&(a=cu(a)),d=l,s=t.apply(h,f)):a||(a=hu(u,e))}return i&&p?p=cu(p):p||n===y||(p=hu(o,n)),r&&(i=!0,s=t.apply(h,f)),!i||p||a||(f=h=A),s}var f,a,s,l,h,p,v,d=0,y=!1,g=!0;if("function"!=typeof t)throw new Yo(z);if(n=n<0?0:+n||0,r===!0){var _=!0;g=!1}else Ri(r)&&(_=!!r.leading,y="maxWait"in r&&xu(+r.maxWait||0,n),g="trailing"in r?!!r.trailing:g);return c.cancel=e,c}function vi(t,n){if("function"!=typeof t||n&&"function"!=typeof n)throw new Yo(z);var r=function(){var e=arguments,i=n?n.apply(this,e):e[0],o=r.cache;if(o.has(i))return o.get(i);var u=t.apply(this,e);return r.cache=o.set(i,u),u};return r.cache=new vi.Cache,r}function di(t){if("function"!=typeof t)throw new Yo(z);return function(){return!t.apply(this,arguments)}}function yi(t){return hi(2,t)}function gi(t,n){if("function"!=typeof t)throw new Yo(z);return n=xu(n===A?t.length-1:+n||0,0),function(){for(var r=arguments,e=-1,i=xu(r.length-n,0),o=Do(i);++en}function Ei(t,n){return t>=n}function Oi(t){return m(t)&&Xr(t)&&nu.call(t,"callee")&&!su.call(t,"callee")}function ki(t){return t===!0||t===!1||m(t)&&eu.call(t)==K}function Ai(t){return m(t)&&eu.call(t)==Y}function ji(t){return!!t&&1===t.nodeType&&m(t)&&!qi(t)}function Pi(t){return null==t||(Xr(t)&&(Pc(t)||Bi(t)||Oi(t)||m(t)&&Ii(t.splice))?!t.length:!qc(t).length)}function Fi(t,n,r,e){r="function"==typeof r?ur(r,e,3):A;var i=r?r(t,n):A;return i===A?Ln(t,n,r):!!i}function Mi(t){return m(t)&&"string"==typeof t.message&&eu.call(t)==X}function Ti(t){return"number"==typeof t&&bu(t)}function Ii(t){return Ri(t)&&eu.call(t)==Q}function Ri(t){var n=typeof t;return!!t&&("object"==n||"function"==n)}function Ni(t,n,r,e){return r="function"==typeof r?ur(r,e,3):A,Un(t,Gr(n),r)}function Li(t){return $i(t)&&t!=+t}function Ci(t){return null!=t&&(Ii(t)?ou.test(tu.call(t)):m(t)&&Lt.test(t))}function Ui(t){return null===t}function $i(t){return"number"==typeof t||m(t)&&eu.call(t)==tt}function qi(t){var n;if(!m(t)||eu.call(t)!=nt||Oi(t)||!nu.call(t,"constructor")&&(n=t.constructor,"function"==typeof n&&!(n instanceof n)))return!1;var r;return Mn(t,function(t,n){r=n}),r===A||nu.call(t,r)}function Di(t){return Ri(t)&&eu.call(t)==rt}function Bi(t){return"string"==typeof t||m(t)&&eu.call(t)==it}function Wi(t){return m(t)&&re(t.length)&&!!Gt[eu.call(t)]}function Gi(t){return t===A}function zi(t,n){return t0;++e=Su(n,r)&&t=0&&t.indexOf(n,r)==r}function ho(t){return t=a(t),t&&xt.test(t)?t.replace(bt,d):t}function po(t){return t=a(t),t&&Ft.test(t)?t.replace(Pt,y):t||"(?:)"}function vo(t,n,r){t=a(t),n=+n;var e=t.length;if(e>=n||!bu(n))return t;var i=(n-e)/2,o=_u(i),u=yu(i);return r=Ir("",u,r),r.slice(0,o)+t+r}function yo(t,n,r){return(r?Zr(t,n,r):null==n)?n=0:n&&(n=+n),t=bo(t),Ou(t,n||(Nt.test(t)?16:10))}function go(t,n){var r="";if(t=a(t),n=+n,n<1||!t||!bu(n))return r;do n%2&&(r+=t),n=_u(n/2),t+=t;while(n);return r}function _o(t,n,r){return t=a(t),r=null==r?0:Su(r<0?0:+r||0,t.length),t.lastIndexOf(n,r)==r}function mo(t,r,e){var i=n.templateSettings;e&&Zr(t,r,e)&&(r=e=A),t=a(t),r=gn(_n({},e||r),i,yn);var o,u,c=gn(_n({},r.imports),i.imports,yn),f=qc(c),s=nr(c,f),l=0,h=r.interpolate||$t,p="__p += '",v=Ho((r.escape||$t).source+"|"+h.source+"|"+(h===Ot?It:$t).source+"|"+(r.evaluate||$t).source+"|$","g"),d="//# sourceURL="+("sourceURL"in r?r.sourceURL:"lodash.templateSources["+ ++Wt+"]")+"\n";t.replace(v,function(n,r,e,i,c,f){return e||(e=i),p+=t.slice(l,f).replace(qt,g),r&&(o=!0,p+="' +\n__e("+r+") +\n'"),c&&(u=!0,p+="';\n"+c+";\n__p += '"),e&&(p+="' +\n((__t = ("+e+")) == null ? '' : __t) +\n'"),l=f+n.length,n}),p+="';\n";var y=r.variable;y||(p="with (obj) {\n"+p+"\n}\n"),p=(u?p.replace(yt,""):p).replace(gt,"$1").replace(_t,"$1;"),p="function("+(y||"obj")+") {\n"+(y?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(o?", __e = _.escape":"")+(u?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+p+"return __p\n}";var _=Xc(function(){return Go(f,d+"return "+p).apply(A,s)});if(_.source=p,Mi(_))throw _;return _}function bo(t,n,r){var e=t;return(t=a(t))?(r?Zr(e,n,r):null==n)?t.slice(S(t),E(t)+1):(n+="",t.slice(s(t,n),l(t,n)+1)):t}function wo(t,n,r){var e=t;return t=a(t),t?(r?Zr(e,n,r):null==n)?t.slice(S(t)):t.slice(s(t,n+"")):t}function xo(t,n,r){var e=t;return t=a(t),t?(r?Zr(e,n,r):null==n)?t.slice(0,E(t)+1):t.slice(0,l(t,n+"")+1):t}function So(t,n,r){r&&Zr(t,n,r)&&(n=A);var e=U,i=$;if(null!=n)if(Ri(n)){var o="separator"in n?n.separator:o;e="length"in n?+n.length||0:e,i="omission"in n?a(n.omission):i}else e=+n||0;if(t=a(t),e>=t.length)return t;var u=e-i.length;if(u<1)return i;var c=t.slice(0,u);if(null==o)return c+i;if(Di(o)){if(t.slice(u).search(o)){var f,s,l=t.slice(0,u);for(o.global||(o=Ho(o.source,(Rt.exec(o)||"")+"g")),o.lastIndex=0;f=o.exec(l);)s=f.index;c=c.slice(0,null==s?u:s)}}else if(t.indexOf(o,u)!=u){var h=c.lastIndexOf(o);h>-1&&(c=c.slice(0,h))}return c+i}function Eo(t){return t=a(t),t&&wt.test(t)?t.replace(mt,O):t}function Oo(t,n,r){return r&&Zr(t,n,r)&&(n=A),t=a(t),t.match(n||Dt)||[]}function ko(t,n,r){return r&&Zr(t,n,r)&&(n=A),m(t)?Po(t):wn(t,n)}function Ao(t){return function(){return t}}function jo(t){return t}function Po(t){return qn(xn(t,!0))}function Fo(t,n){return Dn(t,xn(n,!0))}function Mo(t,n,r){if(null==r){var e=Ri(n),i=e?qc(n):A,o=i&&i.length?Rn(n,i):A;(o?o.length:e)||(o=!1,r=n,n=t,t=this)}o||(o=Rn(n,qc(n)));var u=!0,c=-1,f=Ii(t),a=o.length;r===!1?u=!1:Ri(r)&&"chain"in r&&(u=r.chain);for(;++c>>1,Tu=9007199254740991,Iu=du&&new du,Ru={};n.support={};n.templateSettings={escape:St,evaluate:Et,interpolate:Ot,variable:"",imports:{_:n}};var Nu=function(){function t(){}return function(n){if(Ri(n)){t.prototype=n;var r=new t;t.prototype=A}return r||{}}}(),Lu=hr(Tn),Cu=hr(In,!0),Uu=pr(),$u=pr(!0),qu=Iu?function(t,n){return Iu.set(t,n),t}:jo,Du=Iu?function(t){return Iu.get(t)}:Io,Bu=Gn("length"),Wu=function(){var t=0,n=0;return function(r,e){var i=dc(),o=D-(i-n);if(n=i,o>0){if(++t>=q)return r}else t=0;return qu(r,e)}}(),Gu=gi(function(t,n){return m(t)&&Xr(t)?En(t,Fn(n,!1,!0)):[]}),zu=xr(),Vu=xr(!0),Ju=gi(function(t){for(var n=t.length,r=n,e=Do(l),i=Wr(),o=i==c,u=[];r--;){var f=t[r]=Xr(f=t[r])?f:[];e[r]=o&&f.length>=120?dr(r&&f):null}var a=t[0],s=-1,l=a?a.length:0,h=e[0];t:for(;++s2?t[n-2]:A,e=n>1?t[n-1]:A;return n>2&&"function"==typeof r?n-=2:(r=n>1&&"function"==typeof e?(--n,e):A,e=A),t.length=n,Ue(t,r,e)}),nc=gi(function(t){return t=Fn(t),this.thru(function(n){return Zt(Pc(n)?n:[le(n)],t)})}),rc=gi(function(t,n){return mn(t,Fn(n))}),ec=sr(function(t,n,r){nu.call(t,r)?++t[r]:t[r]=1}),ic=wr(Lu),oc=wr(Cu,!0),uc=Or(nn,Lu),cc=Or(rn,Cu),fc=sr(function(t,n,r){nu.call(t,r)?t[r].push(n):t[r]=[n]}),ac=sr(function(t,n,r){t[r]=n}),sc=gi(function(t,n,r){var e=-1,i="function"==typeof n,o=te(n),u=Xr(t)?Do(t.length):[];return Lu(t,function(t){var c=i?n:o&&null!=t?t[n]:A;u[++e]=c?c.apply(t,r):Yr(t,n,r)}),u}),lc=sr(function(t,n,r){t[r?0:1].push(n)},function(){return[[],[]]}),hc=Mr(ln,Lu),pc=Mr(hn,Cu),vc=gi(function(t,n){if(null==t)return[];var r=n[2];return r&&Zr(n[0],n[1],r)&&(n.length=1),Qn(t,Fn(n),[])}),dc=Eu||function(){return(new Bo).getTime()},yc=gi(function(t,n,r){var e=P;if(r.length){var i=w(r,yc.placeholder);e|=R}return Cr(t,e,n,r,i)}),gc=gi(function(t,n){n=n.length?Fn(n):Yi(t);for(var r=-1,e=n.length;++r0||n<0)?new i(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),n!==A&&(n=+n||0,r=n<0?r.dropRight(-n):r.take(n-t)),r)},i.prototype.takeRightWhile=function(t,n){return this.reverse().takeWhile(t,n).reverse()},i.prototype.toArray=function(){return this.take(ju)},Tn(i.prototype,function(t,r){var o=/^(?:filter|map|reject)|While$/.test(r),u=/^(?:first|last)$/.test(r),c=n[u?"take"+("last"==r?"Right":""):r];c&&(n.prototype[r]=function(){var n=u?[1]:arguments,r=this.__chain__,f=this.__wrapped__,a=!!this.__actions__.length,s=f instanceof i,l=n[0],h=s||Pc(f);h&&o&&"function"==typeof l&&1!=l.length&&(s=h=!1);var p=function(t){return u&&r?c(t,1)[0]:c.apply(A,sn([t],n))},v={func:We,args:[p],thisArg:A},d=s&&!a;if(u&&!r)return d?(f=f.clone(),f.__actions__.push(v),t.call(f)):c.call(A,this.value())[0];if(!u&&h){f=d?f:new i(this);var y=t.apply(f,n);return y.__actions__.push(v),new e(y,r)}return this.thru(p)})}),nn(["join","pop","push","replace","shift","sort","splice","split","unshift"],function(t){var r=(/^(?:replace|split)$/.test(t)?Zo:Xo)[t],e=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",i=/^(?:join|pop|replace|shift)$/.test(t);n.prototype[t]=function(){var t=arguments;return i&&!this.__chain__?r.apply(this.value(),t):this[e](function(n){return r.apply(n,t)})}}),Tn(i.prototype,function(t,r){var e=n[r];if(e){var i=e.name,o=Ru[i]||(Ru[i]=[]);o.push({name:r,func:e})}}),Ru[Tr(A,F).name]=[{name:"wrapper",func:A}],i.prototype.clone=b,i.prototype.reverse=Z,i.prototype.value=et,n.prototype.chain=Ge,n.prototype.commit=ze,n.prototype.concat=nc,n.prototype.plant=Ve,n.prototype.reverse=Je,n.prototype.toString=He,n.prototype.run=n.prototype.toJSON=n.prototype.valueOf=n.prototype.value=Ke,n.prototype.collect=n.prototype.map,n.prototype.head=n.prototype.first,n.prototype.select=n.prototype.filter,n.prototype.tail=n.prototype.rest,n}var A,j="3.10.0",P=1,F=2,M=4,T=8,I=16,R=32,N=64,L=128,C=256,U=30,$="...",q=150,D=16,B=200,W=1,G=2,z="Expected a function",V="__lodash_placeholder__",J="[object Arguments]",H="[object Array]",K="[object Boolean]",Y="[object Date]",X="[object Error]",Q="[object Function]",Z="[object Map]",tt="[object Number]",nt="[object Object]",rt="[object RegExp]",et="[object Set]",it="[object String]",ot="[object WeakMap]",ut="[object ArrayBuffer]",ct="[object Float32Array]",ft="[object Float64Array]",at="[object Int8Array]",st="[object Int16Array]",lt="[object Int32Array]",ht="[object Uint8Array]",pt="[object Uint8ClampedArray]",vt="[object Uint16Array]",dt="[object Uint32Array]",yt=/\b__p \+= '';/g,gt=/\b(__p \+=) '' \+/g,_t=/(__e\(.*?\)|\b__t\)) \+\n'';/g,mt=/&(?:amp|lt|gt|quot|#39|#96);/g,bt=/[&<>"'`]/g,wt=RegExp(mt.source),xt=RegExp(bt.source),St=/<%-([\s\S]+?)%>/g,Et=/<%([\s\S]+?)%>/g,Ot=/<%=([\s\S]+?)%>/g,kt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,At=/^\w*$/,jt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g,Pt=/^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g,Ft=RegExp(Pt.source),Mt=/[\u0300-\u036f\ufe20-\ufe23]/g,Tt=/\\(\\)?/g,It=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Rt=/\w*$/,Nt=/^0[xX]/,Lt=/^\[object .+?Constructor\]$/,Ct=/^\d+$/,Ut=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,$t=/($^)/,qt=/['\n\r\u2028\u2029\\]/g,Dt=function(){ +var t="[A-Z\\xc0-\\xd6\\xd8-\\xde]",n="[a-z\\xdf-\\xf6\\xf8-\\xff]+";return RegExp(t+"+(?="+t+n+")|"+t+"?"+n+"|"+t+"+|[0-9]+","g")}(),Bt=["Array","ArrayBuffer","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Math","Number","Object","RegExp","Set","String","_","clearTimeout","isFinite","parseFloat","parseInt","setTimeout","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap"],Wt=-1,Gt={};Gt[ct]=Gt[ft]=Gt[at]=Gt[st]=Gt[lt]=Gt[ht]=Gt[pt]=Gt[vt]=Gt[dt]=!0,Gt[J]=Gt[H]=Gt[ut]=Gt[K]=Gt[Y]=Gt[X]=Gt[Q]=Gt[Z]=Gt[tt]=Gt[nt]=Gt[rt]=Gt[et]=Gt[it]=Gt[ot]=!1;var zt={};zt[J]=zt[H]=zt[ut]=zt[K]=zt[Y]=zt[ct]=zt[ft]=zt[at]=zt[st]=zt[lt]=zt[tt]=zt[nt]=zt[rt]=zt[it]=zt[ht]=zt[pt]=zt[vt]=zt[dt]=!0,zt[X]=zt[Q]=zt[Z]=zt[et]=zt[ot]=!1;var Vt={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},Jt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Ht={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Kt={"function":!0,object:!0},Yt={0:"x30",1:"x31",2:"x32",3:"x33",4:"x34",5:"x35",6:"x36",7:"x37",8:"x38",9:"x39",A:"x41",B:"x42",C:"x43",D:"x44",E:"x45",F:"x46",a:"x61",b:"x62",c:"x63",d:"x64",e:"x65",f:"x66",n:"x6e",r:"x72",t:"x74",u:"x75",v:"x76",x:"x78"},Xt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Qt=Kt[typeof n]&&n&&!n.nodeType&&n,Zt=Kt[typeof t]&&t&&!t.nodeType&&t,tn=Qt&&Zt&&"object"==typeof i&&i&&i.Object&&i,nn=Kt[typeof self]&&self&&self.Object&&self,rn=Kt[typeof window]&&window&&window.Object&&window,en=(Zt&&Zt.exports===Qt&&Qt,tn||rn!==(this&&this.window)&&rn||nn||this),on=k();en._=on,e=function(){return on}.call(n,r,n,t),!(e!==A&&(t.exports=e))}).call(this)}).call(n,r(80)(t),function(){return this}())},function(t,n){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children=[],t.webpackPolyfill=1),t}},function(t,n,r){(function(t){"use strict";function n(t,n,r){t[n]||Object[e](t,n,{writable:!0,configurable:!0,value:r})}if(r(82),r(373),r(375),t._babelPolyfill)throw new Error("only one instance of babel-polyfill is allowed");t._babelPolyfill=!0;var e="defineProperty";n(String.prototype,"padLeft","".padStart),n(String.prototype,"padRight","".padEnd),"pop,reverse,shift,keys,values,entries,indexOf,every,some,forEach,map,filter,find,findIndex,includes,join,slice,concat,push,splice,unshift,sort,lastIndexOf,reduce,reduceRight,copyWithin,fill".split(",").forEach(function(t){[][t]&&n(Array,t,Function.call.bind([][t]))})}).call(n,function(){return this}())},function(t,n,r){r(83),r(132),r(133),r(134),r(135),r(137),r(140),r(141),r(142),r(143),r(144),r(145),r(146),r(147),r(148),r(150),r(152),r(154),r(156),r(159),r(160),r(161),r(165),r(167),r(169),r(172),r(173),r(174),r(175),r(177),r(178),r(179),r(180),r(181),r(182),r(183),r(185),r(186),r(187),r(189),r(190),r(191),r(193),r(194),r(195),r(196),r(197),r(198),r(199),r(200),r(201),r(202),r(203),r(204),r(205),r(206),r(211),r(212),r(216),r(217),r(218),r(219),r(221),r(222),r(223),r(224),r(225),r(226),r(227),r(228),r(229),r(230),r(231),r(232),r(233),r(234),r(235),r(236),r(237),r(239),r(240),r(246),r(247),r(249),r(250),r(251),r(255),r(256),r(257),r(258),r(259),r(261),r(262),r(263),r(264),r(267),r(269),r(270),r(271),r(273),r(275),r(277),r(278),r(279),r(281),r(282),r(283),r(284),r(291),r(294),r(295),r(297),r(298),r(301),r(302),r(304),r(305),r(306),r(307),r(308),r(309),r(310),r(311),r(312),r(313),r(314),r(315),r(316),r(317),r(318),r(319),r(320),r(321),r(322),r(324),r(325),r(326),r(327),r(328),r(329),r(331),r(332),r(333),r(334),r(335),r(336),r(337),r(338),r(340),r(341),r(343),r(344),r(345),r(346),r(349),r(350),r(351),r(352),r(353),r(354),r(355),r(356),r(358),r(359),r(360),r(361),r(362),r(363),r(364),r(365),r(366),r(367),r(368),r(371),r(372),t.exports=r(89)},function(t,n,r){"use strict";var e=r(84),i=r(85),o=r(86),u=r(88),c=r(98),f=r(102).KEY,a=r(87),s=r(103),l=r(104),h=r(99),p=r(105),v=r(106),d=r(107),y=r(109),g=r(122),_=r(125),m=r(92),b=r(112),w=r(96),x=r(97),S=r(126),E=r(129),O=r(131),k=r(91),A=r(110),j=O.f,P=k.f,F=E.f,M=e.Symbol,T=e.JSON,I=T&&T.stringify,R="prototype",N=p("_hidden"),L=p("toPrimitive"),C={}.propertyIsEnumerable,U=s("symbol-registry"),$=s("symbols"),q=s("op-symbols"),D=Object[R],B="function"==typeof M,W=e.QObject,G=!W||!W[R]||!W[R].findChild,z=o&&a(function(){return 7!=S(P({},"a",{get:function(){return P(this,"a",{value:7}).a}})).a})?function(t,n,r){var e=j(D,n);e&&delete D[n],P(t,n,r),e&&t!==D&&P(D,n,e)}:P,V=function(t){var n=$[t]=S(M[R]);return n._k=t,n},J=B&&"symbol"==typeof M.iterator?function(t){return"symbol"==typeof t}:function(t){return t instanceof M},H=function(t,n,r){return t===D&&H(q,n,r),m(t),n=w(n,!0),m(r),i($,n)?(r.enumerable?(i(t,N)&&t[N][n]&&(t[N][n]=!1),r=S(r,{enumerable:x(0,!1)})):(i(t,N)||P(t,N,x(1,{})),t[N][n]=!0),z(t,n,r)):P(t,n,r)},K=function(t,n){m(t);for(var r,e=g(n=b(n)),i=0,o=e.length;o>i;)H(t,r=e[i++],n[r]);return t},Y=function(t,n){return void 0===n?S(t):K(S(t),n)},X=function(t){var n=C.call(this,t=w(t,!0));return!(this===D&&i($,t)&&!i(q,t))&&(!(n||!i(this,t)||!i($,t)||i(this,N)&&this[N][t])||n)},Q=function(t,n){if(t=b(t),n=w(n,!0),t!==D||!i($,n)||i(q,n)){var r=j(t,n);return!r||!i($,n)||i(t,N)&&t[N][n]||(r.enumerable=!0),r}},Z=function(t){for(var n,r=F(b(t)),e=[],o=0;r.length>o;)i($,n=r[o++])||n==N||n==f||e.push(n);return e},tt=function(t){for(var n,r=t===D,e=F(r?q:b(t)),o=[],u=0;e.length>u;)!i($,n=e[u++])||r&&!i(D,n)||o.push($[n]);return o};B||(M=function(){if(this instanceof M)throw TypeError("Symbol is not a constructor!");var t=h(arguments.length>0?arguments[0]:void 0),n=function(r){this===D&&n.call(q,r),i(this,N)&&i(this[N],t)&&(this[N][t]=!1),z(this,t,x(1,r))};return o&&G&&z(D,t,{configurable:!0,set:n}),V(t)},c(M[R],"toString",function(){return this._k}),O.f=Q,k.f=H,r(130).f=E.f=Z,r(124).f=X,r(123).f=tt,o&&!r(108)&&c(D,"propertyIsEnumerable",X,!0),v.f=function(t){return V(p(t))}),u(u.G+u.W+u.F*!B,{Symbol:M});for(var nt="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),rt=0;nt.length>rt;)p(nt[rt++]);for(var nt=A(p.store),rt=0;nt.length>rt;)d(nt[rt++]);u(u.S+u.F*!B,"Symbol",{"for":function(t){return i(U,t+="")?U[t]:U[t]=M(t)},keyFor:function(t){if(J(t))return y(U,t);throw TypeError(t+" is not a symbol!")},useSetter:function(){G=!0},useSimple:function(){G=!1}}),u(u.S+u.F*!B,"Object",{create:Y,defineProperty:H,defineProperties:K,getOwnPropertyDescriptor:Q,getOwnPropertyNames:Z,getOwnPropertySymbols:tt}),T&&u(u.S+u.F*(!B||a(function(){var t=M();return"[null]"!=I([t])||"{}"!=I({a:t})||"{}"!=I(Object(t))})),"JSON",{stringify:function(t){if(void 0!==t&&!J(t)){for(var n,r,e=[t],i=1;arguments.length>i;)e.push(arguments[i++]);return n=e[1],"function"==typeof n&&(r=n),!r&&_(n)||(n=function(t,n){if(r&&(n=r.call(this,t,n)),!J(n))return n}),e[1]=n,I.apply(T,e)}}}),M[R][L]||r(90)(M[R],L,M[R].valueOf),l(M,"Symbol"),l(Math,"Math",!0),l(e.JSON,"JSON",!0)},15,29,[398,87],24,function(t,n,r){var e=r(84),i=r(89),o=r(90),u=r(98),c=r(100),f="prototype",a=function(t,n,r){var s,l,h,p,v=t&a.F,d=t&a.G,y=t&a.S,g=t&a.P,_=t&a.B,m=d?e:y?e[n]||(e[n]={}):(e[n]||{})[f],b=d?i:i[n]||(i[n]={}),w=b[f]||(b[f]={});d&&(r=n);for(s in r)l=!v&&m&&void 0!==m[s],h=(l?m:r)[s],p=_&&l?c(h,e):g&&"function"==typeof h?c(Function.call,h):h,m&&u(m,s,h,t&a.U),b[s]!=h&&o(b,s,p),g&&w[s]!=h&&(w[s]=h)};e.core=i,a.F=1,a.G=2,a.S=4,a.P=8,a.B=16,a.W=32,a.U=64,a.R=128,t.exports=a},4,[394,91,97,86],[395,92,94,96,86],[396,93],21,[397,86,87,95],[399,93,84],[400,93],27,function(t,n,r){var e=r(84),i=r(90),o=r(85),u=r(99)("src"),c="toString",f=Function[c],a=(""+f).split(c);r(89).inspectSource=function(t){return f.call(t)},(t.exports=function(t,n,r,c){var f="function"==typeof r;f&&(o(r,"name")||i(r,"name",n)),t[n]!==r&&(f&&(o(r,u)||i(r,u,t[n]?""+t[n]:a.join(String(n)))),t===e?t[n]=r:c?t[n]?t[n]=r:i(t,n,r):(delete t[n],i(t,n,r)))})(Function.prototype,c,function(){return"function"==typeof this&&this[u]||f.call(this)})},44,[393,101],17,function(t,n,r){var e=r(99)("meta"),i=r(93),o=r(85),u=r(91).f,c=0,f=Object.isExtensible||function(){return!0},a=!r(87)(function(){return f(Object.preventExtensions({}))}),s=function(t){u(t,e,{value:{i:"O"+ ++c,w:{}}})},l=function(t,n){if(!i(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!o(t,e)){if(!f(t))return"F";if(!n)return"E";s(t)}return t[e].i},h=function(t,n){if(!o(t,e)){if(!f(t))return!0;if(!n)return!1;s(t)}return t[e].w},p=function(t){return a&&v.NEED&&f(t)&&!o(t,e)&&s(t),t},v=t.exports={KEY:e,NEED:!1,fastKey:l,getWeak:h,onFreeze:p}},[412,84],[414,91,85,105],[415,103,99,84],function(t,n,r){n.f=r(105)},function(t,n,r){var e=r(84),i=r(89),o=r(108),u=r(106),c=r(91).f;t.exports=function(t){var n=i.Symbol||(i.Symbol=o?{}:e.Symbol||{});"_"==t.charAt(0)||t in n||c(n,t,{value:u.f(t)})}},function(t,n){t.exports=!1},function(t,n,r){var e=r(110),i=r(112);t.exports=function(t,n){for(var r,o=i(t),u=e(o),c=u.length,f=0;c>f;)if(o[r=u[f++]]===n)return r}},[404,111,121],[405,85,112,116,120],[406,113,115],[407,114],38,11,[408,112,117,119],[409,118],10,[410,118],[411,103,99],45,function(t,n,r){var e=r(110),i=r(123),o=r(124);t.exports=function(t){var n=e(t),r=i.f;if(r)for(var u,c=r(t),f=o.f,a=0;c.length>a;)f.call(t,u=c[a++])&&n.push(u);return n}},function(t,n){n.f=Object.getOwnPropertySymbols},function(t,n){n.f={}.propertyIsEnumerable},function(t,n,r){var e=r(114);t.exports=Array.isArray||function(t){return"Array"==e(t)}},[402,92,127,121,120,95,128],[403,91,92,110,86],[413,84],function(t,n,r){var e=r(112),i=r(130).f,o={}.toString,u="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],c=function(t){try{return i(t)}catch(n){return u.slice()}};t.exports.f=function(t){return u&&"[object Window]"==o.call(t)?c(t):i(e(t))}},function(t,n,r){var e=r(111),i=r(121).concat("length","prototype");n.f=Object.getOwnPropertyNames||function(t){return e(t,i)}},function(t,n,r){var e=r(124),i=r(97),o=r(112),u=r(96),c=r(85),f=r(94),a=Object.getOwnPropertyDescriptor;n.f=r(86)?a:function(t,n){if(t=o(t),n=u(n,!0),f)try{return a(t,n)}catch(r){}if(c(t,n))return i(!e.f.call(t,n),t[n])}},function(t,n,r){var e=r(88);e(e.S,"Object",{create:r(126)})},[429,88,86,91],function(t,n,r){var e=r(88);e(e.S+e.F*!r(86),"Object",{defineProperties:r(127)})},function(t,n,r){var e=r(112),i=r(131).f;r(136)("getOwnPropertyDescriptor",function(){return function(t,n){return i(e(t),n)}})},[430,88,89,87],function(t,n,r){var e=r(138),i=r(139);r(136)("getPrototypeOf",function(){return function(t){return i(e(t))}})},[417,115],[416,85,138,120],[431,138,110,136],function(t,n,r){r(136)("getOwnPropertyNames",function(){return r(129).f})},function(t,n,r){var e=r(93),i=r(102).onFreeze;r(136)("freeze",function(t){return function(n){return t&&e(n)?t(i(n)):n}})},function(t,n,r){var e=r(93),i=r(102).onFreeze;r(136)("seal",function(t){return function(n){return t&&e(n)?t(i(n)):n}})},function(t,n,r){var e=r(93),i=r(102).onFreeze;r(136)("preventExtensions",function(t){return function(n){return t&&e(n)?t(i(n)):n}})},function(t,n,r){var e=r(93);r(136)("isFrozen",function(t){return function(n){return!e(n)||!!t&&t(n)}})},function(t,n,r){var e=r(93);r(136)("isSealed",function(t){return function(n){return!e(n)||!!t&&t(n)}})},function(t,n,r){var e=r(93);r(136)("isExtensible",function(t){return function(n){return!!e(n)&&(!t||t(n))}})},function(t,n,r){var e=r(88);e(e.S+e.F,"Object",{assign:r(149)})},function(t,n,r){"use strict";var e=r(110),i=r(123),o=r(124),u=r(138),c=r(113),f=Object.assign;t.exports=!f||r(87)(function(){var t={},n={},r=Symbol(),e="abcdefghijklmnopqrst";return t[r]=7,e.split("").forEach(function(t){n[t]=t}),7!=f({},t)[r]||Object.keys(f({},n)).join("")!=e})?function(t,n){for(var r=u(t),f=arguments.length,a=1,s=i.f,l=o.f;f>a;)for(var h,p=c(arguments[a++]),v=s?e(p).concat(s(p)):e(p),d=v.length,y=0;d>y;)l.call(p,h=v[y++])&&(r[h]=p[h]);return r}:f},function(t,n,r){var e=r(88);e(e.S,"Object",{is:r(151)})},function(t,n){t.exports=Object.is||function(t,n){return t===n?0!==t||1/t===1/n:t!=t&&n!=n}},function(t,n,r){var e=r(88);e(e.S,"Object",{setPrototypeOf:r(153).set})},function(t,n,r){var e=r(93),i=r(92),o=function(t,n){if(i(t),!e(n)&&null!==n)throw TypeError(n+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(t,n,e){try{e=r(100)(Function.call,r(131).f(Object.prototype,"__proto__").set,2),e(t,[]),n=!(t instanceof Array)}catch(i){n=!0}return function(t,r){return o(t,r),n?t.__proto__=r:e(t,r),t}}({},!1):void 0),check:o}},function(t,n,r){"use strict";var e=r(155),i={};i[r(105)("toStringTag")]="z",i+""!="[object z]"&&r(98)(Object.prototype,"toString",function(){return"[object "+e(this)+"]"},!0)},[420,114,105],function(t,n,r){var e=r(88);e(e.P,"Function",{bind:r(157)})},function(t,n,r){"use strict";var e=r(101),i=r(93),o=r(158),u=[].slice,c={},f=function(t,n,r){if(!(n in c)){for(var e=[],i=0;i>>0||(u.test(r)?16:10))}:e},function(t,n,r){var e=r(88),i=r(115),o=r(87),u=r(164),c="["+u+"]",f="​…",a=RegExp("^"+c+c+"*"),s=RegExp(c+c+"*$"),l=function(t,n,r){var i={},c=o(function(){return!!u[t]()||f[t]()!=f}),a=i[t]=c?n(h):u[t];r&&(i[r]=a),e(e.P+e.F*c,"String",i)},h=l.trim=function(t,n){return t=String(i(t)),1&n&&(t=t.replace(a,"")),2&n&&(t=t.replace(s,"")),t};t.exports=l},function(t,n){t.exports="\t\n\x0B\f\r   ᠎              \u2028\u2029\ufeff"},function(t,n,r){var e=r(88),i=r(166);e(e.G+e.F*(parseFloat!=i),{parseFloat:i})},function(t,n,r){var e=r(84).parseFloat,i=r(163).trim;t.exports=1/e(r(164)+"-0")!==-(1/0)?function(t){var n=i(String(t),3),r=e(n);return 0===r&&"-"==n.charAt(0)?-0:r}:e},function(t,n,r){"use strict";var e=r(84),i=r(85),o=r(114),u=r(168),c=r(96),f=r(87),a=r(130).f,s=r(131).f,l=r(91).f,h=r(163).trim,p="Number",v=e[p],d=v,y=v.prototype,g=o(r(126)(y))==p,_="trim"in String.prototype,m=function(t){var n=c(t,!1);if("string"==typeof n&&n.length>2){n=_?n.trim():h(n,3);var r,e,i,o=n.charCodeAt(0);if(43===o||45===o){if(r=n.charCodeAt(2),88===r||120===r)return NaN}else if(48===o){switch(n.charCodeAt(1)){case 66:case 98:e=2,i=49;break;case 79:case 111:e=8,i=55;break;default:return+n}for(var u,f=n.slice(2),a=0,s=f.length;ai)return NaN;return parseInt(f,e)}}return+n};if(!v(" 0o1")||!v("0b1")||v("+0x1")){v=function(t){var n=arguments.length<1?0:t,r=this;return r instanceof v&&(g?f(function(){y.valueOf.call(r)}):o(r)!=p)?u(new d(m(n)),r,v):m(n)};for(var b,w=r(86)?a(d):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger".split(","),x=0;w.length>x;x++)i(d,b=w[x])&&!i(v,b)&&l(v,b,s(d,b));v.prototype=y,y.constructor=v,r(98)(e,p,v)}},function(t,n,r){var e=r(93),i=r(153).set;t.exports=function(t,n,r){var o,u=n.constructor;return u!==r&&"function"==typeof u&&(o=u.prototype)!==r.prototype&&e(o)&&i&&i(t,o),t}},function(t,n,r){"use strict";var e=r(88),i=r(118),o=r(170),u=r(171),c=1..toFixed,f=Math.floor,a=[0,0,0,0,0,0],s="Number.toFixed: incorrect invocation!",l="0",h=function(t,n){for(var r=-1,e=n;++r<6;)e+=t*a[r],a[r]=e%1e7,e=f(e/1e7)},p=function(t){for(var n=6,r=0;--n>=0;)r+=a[n],a[n]=f(r/t),r=r%t*1e7},v=function(){for(var t=6,n="";--t>=0;)if(""!==n||0===t||0!==a[t]){var r=String(a[t]);n=""===n?r:n+u.call(l,7-r.length)+r}return n},d=function(t,n,r){return 0===n?r:n%2===1?d(t,n-1,r*t):d(t*t,n/2,r)},y=function(t){for(var n=0,r=t;r>=4096;)n+=12,r/=4096;for(;r>=2;)n+=1,r/=2;return n};e(e.P+e.F*(!!c&&("0.000"!==8e-5.toFixed(3)||"1"!==.9.toFixed(0)||"1.25"!==1.255.toFixed(2)||"1000000000000000128"!==(0xde0b6b3a7640080).toFixed(0))||!r(87)(function(){c.call({})})),"Number",{toFixed:function(t){var n,r,e,c,f=o(this,s),a=i(t),g="",_=l;if(a<0||a>20)throw RangeError(s);if(f!=f)return"NaN";if(f<=-1e21||f>=1e21)return String(f);if(f<0&&(g="-",f=-f),f>1e-21)if(n=y(f*d(2,69,1))-69,r=n<0?f*d(2,-n,1):f/d(2,n,1),r*=4503599627370496,n=52-n,n>0){for(h(0,r),e=a;e>=7;)h(1e7,0),e-=7;for(h(d(10,e,1),0),e=n-1;e>=23;)p(1<<23),e-=23;p(1<0?(c=_.length,_=g+(c<=a?"0."+u.call(l,a-c)+_:_.slice(0,c-a)+"."+_.slice(c-a))):_=g+_,_}})},function(t,n,r){var e=r(114);t.exports=function(t,n){if("number"!=typeof t&&"Number"!=e(t))throw TypeError(n);return+t}},function(t,n,r){"use strict";var e=r(118),i=r(115);t.exports=function(t){var n=String(i(this)),r="",o=e(t);if(o<0||o==1/0)throw RangeError("Count can't be negative");for(;o>0;(o>>>=1)&&(n+=n))1&o&&(r+=n);return r}},function(t,n,r){"use strict";var e=r(88),i=r(87),o=r(170),u=1..toPrecision;e(e.P+e.F*(i(function(){return"1"!==u.call(1,void 0)})||!i(function(){u.call({})})),"Number",{toPrecision:function(t){var n=o(this,"Number#toPrecision: incorrect invocation!");return void 0===t?u.call(n):u.call(n,t)}})},function(t,n,r){var e=r(88);e(e.S,"Number",{EPSILON:Math.pow(2,-52)})},function(t,n,r){var e=r(88),i=r(84).isFinite;e(e.S,"Number",{isFinite:function(t){return"number"==typeof t&&i(t)}})},function(t,n,r){var e=r(88);e(e.S,"Number",{isInteger:r(176)})},function(t,n,r){var e=r(93),i=Math.floor;t.exports=function(t){return!e(t)&&isFinite(t)&&i(t)===t}},function(t,n,r){var e=r(88);e(e.S,"Number",{isNaN:function(t){return t!=t}})},function(t,n,r){var e=r(88),i=r(176),o=Math.abs;e(e.S,"Number",{isSafeInteger:function(t){return i(t)&&o(t)<=9007199254740991}})},function(t,n,r){var e=r(88);e(e.S,"Number",{MAX_SAFE_INTEGER:9007199254740991})},function(t,n,r){var e=r(88);e(e.S,"Number",{MIN_SAFE_INTEGER:-9007199254740991})},function(t,n,r){var e=r(88),i=r(166);e(e.S+e.F*(Number.parseFloat!=i),"Number",{parseFloat:i})},function(t,n,r){var e=r(88),i=r(162);e(e.S+e.F*(Number.parseInt!=i),"Number",{parseInt:i})},function(t,n,r){var e=r(88),i=r(184),o=Math.sqrt,u=Math.acosh;e(e.S+e.F*!(u&&710==Math.floor(u(Number.MAX_VALUE))&&u(1/0)==1/0),"Math",{acosh:function(t){return(t=+t)<1?NaN:t>94906265.62425156?Math.log(t)+Math.LN2:i(t-1+o(t-1)*o(t+1))}})},function(t,n){t.exports=Math.log1p||function(t){return(t=+t)>-1e-8&&t<1e-8?t-t*t/2:Math.log(1+t)}},function(t,n,r){function e(t){return isFinite(t=+t)&&0!=t?t<0?-e(-t):Math.log(t+Math.sqrt(t*t+1)):t}var i=r(88),o=Math.asinh;i(i.S+i.F*!(o&&1/o(0)>0),"Math",{asinh:e})},function(t,n,r){var e=r(88),i=Math.atanh;e(e.S+e.F*!(i&&1/i(-0)<0),"Math",{atanh:function(t){return 0==(t=+t)?t:Math.log((1+t)/(1-t))/2}})},function(t,n,r){var e=r(88),i=r(188);e(e.S,"Math",{cbrt:function(t){return i(t=+t)*Math.pow(Math.abs(t),1/3)}})},function(t,n){t.exports=Math.sign||function(t){return 0==(t=+t)||t!=t?t:t<0?-1:1}},function(t,n,r){var e=r(88);e(e.S,"Math",{clz32:function(t){return(t>>>=0)?31-Math.floor(Math.log(t+.5)*Math.LOG2E):32}})},function(t,n,r){var e=r(88),i=Math.exp;e(e.S,"Math",{cosh:function(t){return(i(t=+t)+i(-t))/2}})},function(t,n,r){var e=r(88),i=r(192);e(e.S+e.F*(i!=Math.expm1),"Math",{expm1:i})},function(t,n){var r=Math.expm1;t.exports=!r||r(10)>22025.465794806718||r(10)<22025.465794806718||r(-2e-17)!=-2e-17?function(t){return 0==(t=+t)?t:t>-1e-6&&t<1e-6?t+t*t/2:Math.exp(t)-1}:r},function(t,n,r){var e=r(88),i=r(188),o=Math.pow,u=o(2,-52),c=o(2,-23),f=o(2,127)*(2-c),a=o(2,-126),s=function(t){return t+1/u-1/u};e(e.S,"Math",{fround:function(t){var n,r,e=Math.abs(t),o=i(t);return ef||r!=r?o*(1/0):o*r)}})},function(t,n,r){var e=r(88),i=Math.abs;e(e.S,"Math",{hypot:function(t,n){for(var r,e,o=0,u=0,c=arguments.length,f=0;u0?(e=r/f,o+=e*e):o+=r;return f===1/0?1/0:f*Math.sqrt(o)}})},function(t,n,r){var e=r(88),i=Math.imul;e(e.S+e.F*r(87)(function(){return i(4294967295,5)!=-5||2!=i.length}),"Math",{imul:function(t,n){var r=65535,e=+t,i=+n,o=r&e,u=r&i;return 0|o*u+((r&e>>>16)*u+o*(r&i>>>16)<<16>>>0)}})},function(t,n,r){var e=r(88);e(e.S,"Math",{log10:function(t){return Math.log(t)/Math.LN10}})},function(t,n,r){var e=r(88);e(e.S,"Math",{log1p:r(184)})},function(t,n,r){var e=r(88);e(e.S,"Math",{log2:function(t){return Math.log(t)/Math.LN2}})},function(t,n,r){var e=r(88);e(e.S,"Math",{sign:r(188)})},function(t,n,r){var e=r(88),i=r(192),o=Math.exp;e(e.S+e.F*r(87)(function(){return!Math.sinh(-2e-17)!=-2e-17}),"Math",{sinh:function(t){return Math.abs(t=+t)<1?(i(t)-i(-t))/2:(o(t-1)-o(-t-1))*(Math.E/2)}})},function(t,n,r){var e=r(88),i=r(192),o=Math.exp;e(e.S,"Math",{tanh:function(t){var n=i(t=+t),r=i(-t);return n==1/0?1:r==1/0?-1:(n-r)/(o(t)+o(-t))}})},function(t,n,r){var e=r(88);e(e.S,"Math",{trunc:function(t){return(t>0?Math.floor:Math.ceil)(t)}})},function(t,n,r){var e=r(88),i=r(119),o=String.fromCharCode,u=String.fromCodePoint;e(e.S+e.F*(!!u&&1!=u.length),"String",{fromCodePoint:function(t){for(var n,r=[],e=arguments.length,u=0;e>u;){if(n=+arguments[u++],i(n,1114111)!==n)throw RangeError(n+" is not a valid code point");r.push(n<65536?o(n):o(((n-=65536)>>10)+55296,n%1024+56320))}return r.join("")}})},function(t,n,r){var e=r(88),i=r(112),o=r(117);e(e.S,"String",{raw:function(t){for(var n=i(t.raw),r=o(n.length),e=arguments.length,u=[],c=0;r>c;)u.push(String(n[c++])),c1?arguments[1]:void 0,e=i(n.length),f=void 0===r?e:Math.min(i(r),e),a=String(t);return c?c.call(n,a,f):n.slice(f-a.length,f)===a}})},function(t,n,r){var e=r(214),i=r(115);t.exports=function(t,n,r){if(e(n))throw TypeError("String#"+r+" doesn't accept regex!");return String(i(t))}},function(t,n,r){var e=r(93),i=r(114),o=r(105)("match");t.exports=function(t){var n;return e(t)&&(void 0!==(n=t[o])?!!n:"RegExp"==i(t))}},function(t,n,r){var e=r(105)("match");t.exports=function(t){var n=/./;try{"/./"[t](n)}catch(r){try{return n[e]=!1,!"/./"[t](n)}catch(i){}}return!0}},function(t,n,r){"use strict";var e=r(88),i=r(213),o="includes";e(e.P+e.F*r(215)(o),"String",{includes:function(t){return!!~i(this,t,o).indexOf(t,arguments.length>1?arguments[1]:void 0)}})},function(t,n,r){var e=r(88);e(e.P,"String",{repeat:r(171)})},function(t,n,r){"use strict";var e=r(88),i=r(117),o=r(213),u="startsWith",c=""[u];e(e.P+e.F*r(215)(u),"String",{startsWith:function(t){var n=o(this,t,u),r=i(Math.min(arguments.length>1?arguments[1]:void 0,n.length)),e=String(t);return c?c.call(n,e,r):n.slice(r,r+e.length)===e}})},function(t,n,r){"use strict";r(220)("anchor",function(t){return function(n){return t(this,"a","name",n)}})},function(t,n,r){var e=r(88),i=r(87),o=r(115),u=/"/g,c=function(t,n,r,e){var i=String(o(t)),c="<"+n;return""!==r&&(c+=" "+r+'="'+String(e).replace(u,""")+'"'),c+">"+i+""};t.exports=function(t,n){var r={};r[t]=n(c),e(e.P+e.F*i(function(){var n=""[t]('"');return n!==n.toLowerCase()||n.split('"').length>3}),"String",r)}},function(t,n,r){"use strict";r(220)("big",function(t){return function(){return t(this,"big","","")}})},function(t,n,r){"use strict";r(220)("blink",function(t){return function(){return t(this,"blink","","")}})},function(t,n,r){"use strict";r(220)("bold",function(t){return function(){return t(this,"b","","")}})},function(t,n,r){"use strict";r(220)("fixed",function(t){return function(){return t(this,"tt","","")}})},function(t,n,r){"use strict";r(220)("fontcolor",function(t){return function(n){return t(this,"font","color",n)}})},function(t,n,r){"use strict";r(220)("fontsize",function(t){return function(n){return t(this,"font","size",n)}})},function(t,n,r){"use strict";r(220)("italics",function(t){return function(){return t(this,"i","","")}})},function(t,n,r){"use strict";r(220)("link",function(t){return function(n){return t(this,"a","href",n)}})},function(t,n,r){"use strict";r(220)("small",function(t){return function(){return t(this,"small","","")}})},function(t,n,r){"use strict";r(220)("strike",function(t){return function(){return t(this,"strike","","")}})},function(t,n,r){"use strict";r(220)("sub",function(t){return function(){return t(this,"sub","","")}})},function(t,n,r){"use strict";r(220)("sup",function(t){return function(){return t(this,"sup","","")}})},function(t,n,r){var e=r(88);e(e.S,"Date",{now:function(){return(new Date).getTime()}})},function(t,n,r){"use strict";var e=r(88),i=r(138),o=r(96);e(e.P+e.F*r(87)(function(){return null!==new Date(NaN).toJSON()||1!==Date.prototype.toJSON.call({toISOString:function(){return 1}})}),"Date",{toJSON:function(t){var n=i(this),r=o(n);return"number"!=typeof r||isFinite(r)?n.toISOString():null}})},function(t,n,r){"use strict";var e=r(88),i=r(87),o=Date.prototype.getTime,u=function(t){return t>9?t:"0"+t};e(e.P+e.F*(i(function(){return"0385-07-25T07:06:39.999Z"!=new Date(-5e13-1).toISOString()})||!i(function(){new Date(NaN).toISOString()})),"Date",{toISOString:function(){if(!isFinite(o.call(this)))throw RangeError("Invalid time value");var t=this,n=t.getUTCFullYear(),r=t.getUTCMilliseconds(),e=n<0?"-":n>9999?"+":"";return e+("00000"+Math.abs(n)).slice(e?-6:-4)+"-"+u(t.getUTCMonth()+1)+"-"+u(t.getUTCDate())+"T"+u(t.getUTCHours())+":"+u(t.getUTCMinutes())+":"+u(t.getUTCSeconds())+"."+(r>99?r:"0"+u(r))+"Z"}})},function(t,n,r){var e=Date.prototype,i="Invalid Date",o="toString",u=e[o],c=e.getTime;new Date(NaN)+""!=i&&r(98)(e,o,function(){var t=c.call(this);return t===t?u.call(this):i})},function(t,n,r){var e=r(105)("toPrimitive"),i=Date.prototype;e in i||r(90)(i,e,r(238))},function(t,n,r){"use strict";var e=r(92),i=r(96),o="number";t.exports=function(t){if("string"!==t&&t!==o&&"default"!==t)throw TypeError("Incorrect hint");return i(e(this),t!=o)}},function(t,n,r){var e=r(88);e(e.S,"Array",{isArray:r(125)})},function(t,n,r){"use strict";var e=r(100),i=r(88),o=r(138),u=r(241),c=r(242),f=r(117),a=r(243),s=r(244);i(i.S+i.F*!r(245)(function(t){Array.from(t)}),"Array",{from:function(t){var n,r,i,l,h=o(t),p="function"==typeof this?this:Array,v=arguments.length,d=v>1?arguments[1]:void 0,y=void 0!==d,g=0,_=s(h);if(y&&(d=e(d,v>2?arguments[2]:void 0,2)),void 0==_||p==Array&&c(_))for(n=f(h.length),r=new p(n);n>g;g++)a(r,g,y?d(h[g],g):h[g]);else for(l=_.call(h),r=new p;!(i=l.next()).done;g++)a(r,g,y?u(l,d,[i.value,g],!0):i.value);return r.length=g,r}})},[422,92],[423,209,105],function(t,n,r){"use strict";var e=r(91),i=r(97);t.exports=function(t,n,r){n in t?e.f(t,n,i(0,r)):t[n]=r}},[424,155,105,209,89],[428,105],function(t,n,r){"use strict";var e=r(88),i=r(243);e(e.S+e.F*r(87)(function(){function t(){}return!(Array.of.call(t)instanceof t)}),"Array",{of:function(){for(var t=0,n=arguments.length,r=new("function"==typeof this?this:Array)(n);n>t;)i(r,t,arguments[t++]);return r.length=n,r}})},function(t,n,r){"use strict";var e=r(88),i=r(112),o=[].join;e(e.P+e.F*(r(113)!=Object||!r(248)(o)),"Array",{join:function(t){return o.call(i(this),void 0===t?",":t)}})},function(t,n,r){var e=r(87);t.exports=function(t,n){return!!t&&e(function(){n?t.call(null,function(){},1):t.call(null)})}},function(t,n,r){"use strict";var e=r(88),i=r(128),o=r(114),u=r(119),c=r(117),f=[].slice;e(e.P+e.F*r(87)(function(){i&&f.call(i)}),"Array",{slice:function(t,n){var r=c(this.length),e=o(this);if(n=void 0===n?r:n,"Array"==e)return f.call(this,t,n);for(var i=u(t,r),a=u(n,r),s=c(a-i),l=Array(s),h=0;hw;w++)if((h||w in _)&&(d=_[w],y=m(d,w,g),t))if(r)x[w]=y;else if(y)switch(t){case 3:return!0;case 5:return d;case 6:return w;case 2:x.push(d)}else if(s)return!1;return l?-1:a||s?s:x}}},function(t,n,r){var e=r(254);t.exports=function(t,n){return new(e(t))(n)}},function(t,n,r){var e=r(93),i=r(125),o=r(105)("species");t.exports=function(t){var n;return i(t)&&(n=t.constructor,"function"!=typeof n||n!==Array&&!i(n.prototype)||(n=void 0),e(n)&&(n=n[o],null===n&&(n=void 0))),void 0===n?Array:n}},function(t,n,r){"use strict";var e=r(88),i=r(252)(1);e(e.P+e.F*!r(248)([].map,!0),"Array",{map:function(t){return i(this,t,arguments[1])}})},function(t,n,r){"use strict";var e=r(88),i=r(252)(2);e(e.P+e.F*!r(248)([].filter,!0),"Array",{filter:function(t){return i(this,t,arguments[1])}})},function(t,n,r){"use strict";var e=r(88),i=r(252)(3);e(e.P+e.F*!r(248)([].some,!0),"Array",{some:function(t){return i(this,t,arguments[1])}})},function(t,n,r){"use strict";var e=r(88),i=r(252)(4);e(e.P+e.F*!r(248)([].every,!0),"Array",{every:function(t){return i(this,t,arguments[1])}})},function(t,n,r){"use strict";var e=r(88),i=r(260);e(e.P+e.F*!r(248)([].reduce,!0),"Array",{reduce:function(t){return i(this,t,arguments.length,arguments[1],!1)}})},function(t,n,r){var e=r(101),i=r(138),o=r(113),u=r(117);t.exports=function(t,n,r,c,f){e(n);var a=i(t),s=o(a),l=u(a.length),h=f?l-1:0,p=f?-1:1;if(r<2)for(;;){if(h in s){c=s[h],h+=p;break}if(h+=p,f?h<0:l<=h)throw TypeError("Reduce of empty array with no initial value")}for(;f?h>=0:l>h;h+=p)h in s&&(c=n(c,s[h],h,a));return c}},function(t,n,r){"use strict";var e=r(88),i=r(260);e(e.P+e.F*!r(248)([].reduceRight,!0),"Array",{reduceRight:function(t){return i(this,t,arguments.length,arguments[1],!0)}})},function(t,n,r){"use strict";var e=r(88),i=r(116)(!1),o=[].indexOf,u=!!o&&1/[1].indexOf(1,-0)<0;e(e.P+e.F*(u||!r(248)(o)),"Array",{indexOf:function(t){return u?o.apply(this,arguments)||0:i(this,t,arguments[1])}})},function(t,n,r){"use strict";var e=r(88),i=r(112),o=r(118),u=r(117),c=[].lastIndexOf,f=!!c&&1/[1].lastIndexOf(1,-0)<0;e(e.P+e.F*(f||!r(248)(c)),"Array",{lastIndexOf:function(t){if(f)return c.apply(this,arguments)||0; +var n=i(this),r=u(n.length),e=r-1;for(arguments.length>1&&(e=Math.min(e,o(arguments[1]))),e<0&&(e=r+e);e>=0;e--)if(e in n&&n[e]===t)return e||0;return-1}})},function(t,n,r){var e=r(88);e(e.P,"Array",{copyWithin:r(265)}),r(266)("copyWithin")},function(t,n,r){"use strict";var e=r(138),i=r(119),o=r(117);t.exports=[].copyWithin||function(t,n){var r=e(this),u=o(r.length),c=i(t,u),f=i(n,u),a=arguments.length>2?arguments[2]:void 0,s=Math.min((void 0===a?u:i(a,u))-f,u-c),l=1;for(f0;)f in r?r[c]=r[f]:delete r[c],c+=l,f+=l;return r}},function(t,n,r){var e=r(105)("unscopables"),i=Array.prototype;void 0==i[e]&&r(90)(i,e,{}),t.exports=function(t){i[e][t]=!0}},function(t,n,r){var e=r(88);e(e.P,"Array",{fill:r(268)}),r(266)("fill")},function(t,n,r){"use strict";var e=r(138),i=r(119),o=r(117);t.exports=function(t){for(var n=e(this),r=o(n.length),u=arguments.length,c=i(u>1?arguments[1]:void 0,r),f=u>2?arguments[2]:void 0,a=void 0===f?r:i(f,r);a>c;)n[c++]=t;return n}},function(t,n,r){"use strict";var e=r(88),i=r(252)(5),o="find",u=!0;o in[]&&Array(1)[o](function(){u=!1}),e(e.P+e.F*u,"Array",{find:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}}),r(266)(o)},function(t,n,r){"use strict";var e=r(88),i=r(252)(6),o="findIndex",u=!0;o in[]&&Array(1)[o](function(){u=!1}),e(e.P+e.F*u,"Array",{findIndex:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}}),r(266)(o)},function(t,n,r){r(272)("Array")},function(t,n,r){"use strict";var e=r(84),i=r(91),o=r(86),u=r(105)("species");t.exports=function(t){var n=e[t];o&&n&&!n[u]&&i.f(n,u,{configurable:!0,get:function(){return this}})}},[418,266,274,209,112,208],54,function(t,n,r){var e=r(84),i=r(168),o=r(91).f,u=r(130).f,c=r(214),f=r(276),a=e.RegExp,s=a,l=a.prototype,h=/a/g,p=/a/g,v=new a(h)!==h;if(r(86)&&(!v||r(87)(function(){return p[r(105)("match")]=!1,a(h)!=h||a(p)==p||"/a/i"!=a(h,"i")}))){a=function(t,n){var r=this instanceof a,e=c(t),o=void 0===n;return!r&&e&&t.constructor===a&&o?t:i(v?new s(e&&!o?t.source:t,n):s((e=t instanceof a)?t.source:t,e&&o?f.call(t):n),r?this:l,a)};for(var d=(function(t){t in a||o(a,t,{configurable:!0,get:function(){return s[t]},set:function(n){s[t]=n}})}),y=u(s),g=0;y.length>g;)d(y[g++]);l.constructor=a,a.prototype=l,r(98)(e,"RegExp",a)}r(272)("RegExp")},function(t,n,r){"use strict";var e=r(92);t.exports=function(){var t=e(this),n="";return t.global&&(n+="g"),t.ignoreCase&&(n+="i"),t.multiline&&(n+="m"),t.unicode&&(n+="u"),t.sticky&&(n+="y"),n}},function(t,n,r){"use strict";r(278);var e=r(92),i=r(276),o=r(86),u="toString",c=/./[u],f=function(t){r(98)(RegExp.prototype,u,t,!0)};r(87)(function(){return"/a/b"!=c.call({source:"a",flags:"b"})})?f(function(){var t=e(this);return"/".concat(t.source,"/","flags"in t?t.flags:!o&&t instanceof RegExp?i.call(t):void 0)}):c.name!=u&&f(function(){return c.call(this)})},function(t,n,r){r(86)&&"g"!=/./g.flags&&r(91).f(RegExp.prototype,"flags",{configurable:!0,get:r(276)})},function(t,n,r){r(280)("match",1,function(t,n,r){return[function(r){"use strict";var e=t(this),i=void 0==r?void 0:r[n];return void 0!==i?i.call(r,e):new RegExp(r)[n](String(e))},r]})},function(t,n,r){"use strict";var e=r(90),i=r(98),o=r(87),u=r(115),c=r(105);t.exports=function(t,n,r){var f=c(t),a=r(u,f,""[t]),s=a[0],l=a[1];o(function(){var n={};return n[f]=function(){return 7},7!=""[t](n)})&&(i(String.prototype,t,s),e(RegExp.prototype,f,2==n?function(t,n){return l.call(t,this,n)}:function(t){return l.call(t,this)}))}},function(t,n,r){r(280)("replace",2,function(t,n,r){return[function(e,i){"use strict";var o=t(this),u=void 0==e?void 0:e[n];return void 0!==u?u.call(e,o,i):r.call(String(o),e,i)},r]})},function(t,n,r){r(280)("search",1,function(t,n,r){return[function(r){"use strict";var e=t(this),i=void 0==r?void 0:r[n];return void 0!==i?i.call(r,e):new RegExp(r)[n](String(e))},r]})},function(t,n,r){r(280)("split",2,function(t,n,e){"use strict";var i=r(214),o=e,u=[].push,c="split",f="length",a="lastIndex";if("c"=="abbc"[c](/(b)*/)[1]||4!="test"[c](/(?:)/,-1)[f]||2!="ab"[c](/(?:ab)*/)[f]||4!="."[c](/(.?)(.?)/)[f]||"."[c](/()()/)[f]>1||""[c](/.?/)[f]){var s=void 0===/()??/.exec("")[1];e=function(t,n){var r=String(this);if(void 0===t&&0===n)return[];if(!i(t))return o.call(r,t,n);var e,c,l,h,p,v=[],d=(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.unicode?"u":"")+(t.sticky?"y":""),y=0,g=void 0===n?4294967295:n>>>0,_=new RegExp(t.source,d+"g");for(s||(e=new RegExp("^"+_.source+"$(?!\\s)",d));(c=_.exec(r))&&(l=c.index+c[0][f],!(l>y&&(v.push(r.slice(y,c.index)),!s&&c[f]>1&&c[0].replace(e,function(){for(p=1;p1&&c.index=g)));)_[a]===c.index&&_[a]++;return y===r[f]?!h&&_.test("")||v.push(""):v.push(r.slice(y)),v[f]>g?v.slice(0,g):v}}else"0"[c](void 0,0)[f]&&(e=function(t,n){return void 0===t&&0===n?[]:o.call(this,t,n)});return[function(r,i){var o=t(this),u=void 0==r?void 0:r[n];return void 0!==u?u.call(r,o,i):e.call(String(o),r,i)},e]})},[419,108,84,100,155,88,93,101,285,286,287,288,289,105,290,104,272,89,245],57,[421,100,241,242,92,117,244],[425,92,101,105],[426,100,158,128,95,84,114],[427,84,288,114],function(t,n,r){var e=r(98);t.exports=function(t,n,r){for(var i in n)e(t,i,n[i],r);return t}},function(t,n,r){"use strict";var e=r(292);t.exports=r(293)("Map",function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},{get:function(t){var n=e.getEntry(this,t);return n&&n.v},set:function(t,n){return e.def(this,0===t?0:t,n)}},e,!0)},function(t,n,r){"use strict";var e=r(91).f,i=r(126),o=r(290),u=r(100),c=r(285),f=r(115),a=r(286),s=r(208),l=r(274),h=r(272),p=r(86),v=r(102).fastKey,d=p?"_s":"size",y=function(t,n){var r,e=v(n);if("F"!==e)return t._i[e];for(r=t._f;r;r=r.n)if(r.k==n)return r};t.exports={getConstructor:function(t,n,r,s){var l=t(function(t,e){c(t,l,n,"_i"),t._i=i(null),t._f=void 0,t._l=void 0,t[d]=0,void 0!=e&&a(e,r,t[s],t)});return o(l.prototype,{clear:function(){for(var t=this,n=t._i,r=t._f;r;r=r.n)r.r=!0,r.p&&(r.p=r.p.n=void 0),delete n[r.i];t._f=t._l=void 0,t[d]=0},"delete":function(t){var n=this,r=y(n,t);if(r){var e=r.n,i=r.p;delete n._i[r.i],r.r=!0,i&&(i.n=e),e&&(e.p=i),n._f==r&&(n._f=e),n._l==r&&(n._l=i),n[d]--}return!!r},forEach:function(t){c(this,l,"forEach");for(var n,r=u(t,arguments.length>1?arguments[1]:void 0,3);n=n?n.n:this._f;)for(r(n.v,n.k,this);n&&n.r;)n=n.p},has:function(t){return!!y(this,t)}}),p&&e(l.prototype,"size",{get:function(){return f(this[d])}}),l},def:function(t,n,r){var e,i,o=y(t,n);return o?o.v=r:(t._l=o={i:i=v(n,!0),k:n,v:r,p:e=t._l,n:void 0,r:!1},t._f||(t._f=o),e&&(e.n=o),t[d]++,"F"!==i&&(t._i[i]=o)),t},getEntry:y,setStrong:function(t,n,r){s(t,n,function(t,n){this._t=t,this._k=n,this._l=void 0},function(){for(var t=this,n=t._k,r=t._l;r&&r.r;)r=r.p;return t._t&&(t._l=r=r?r.n:t._t._f)?"keys"==n?l(0,r.k):"values"==n?l(0,r.v):l(0,[r.k,r.v]):(t._t=void 0,l(1))},r?"entries":"values",!r,!0),h(n)}}},function(t,n,r){"use strict";var e=r(84),i=r(88),o=r(98),u=r(290),c=r(102),f=r(286),a=r(285),s=r(93),l=r(87),h=r(245),p=r(104),v=r(168);t.exports=function(t,n,r,d,y,g){var _=e[t],m=_,b=y?"set":"add",w=m&&m.prototype,x={},S=function(t){var n=w[t];o(w,t,"delete"==t?function(t){return!(g&&!s(t))&&n.call(this,0===t?0:t)}:"has"==t?function(t){return!(g&&!s(t))&&n.call(this,0===t?0:t)}:"get"==t?function(t){return g&&!s(t)?void 0:n.call(this,0===t?0:t)}:"add"==t?function(t){return n.call(this,0===t?0:t),this}:function(t,r){return n.call(this,0===t?0:t,r),this})};if("function"==typeof m&&(g||w.forEach&&!l(function(){(new m).entries().next()}))){var E=new m,O=E[b](g?{}:-0,1)!=E,k=l(function(){E.has(1)}),A=h(function(t){new m(t)}),j=!g&&l(function(){for(var t=new m,n=5;n--;)t[b](n,n);return!t.has(-0)});A||(m=n(function(n,r){a(n,m,t);var e=v(new _,n,m);return void 0!=r&&f(r,y,e[b],e),e}),m.prototype=w,w.constructor=m),(k||j)&&(S("delete"),S("has"),y&&S("get")),(j||O)&&S(b),g&&w.clear&&delete w.clear}else m=d.getConstructor(n,t,y,b),u(m.prototype,r),c.NEED=!0;return p(m,t),x[t]=m,i(i.G+i.W+i.F*(m!=_),x),g||d.setStrong(m,t,y),m}},function(t,n,r){"use strict";var e=r(292);t.exports=r(293)("Set",function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},{add:function(t){return e.def(this,t=0===t?0:t,t)}},e)},function(t,n,r){"use strict";var e,i=r(252)(0),o=r(98),u=r(102),c=r(149),f=r(296),a=r(93),s=u.getWeak,l=Object.isExtensible,h=f.ufstore,p={},v=function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},d={get:function(t){if(a(t)){var n=s(t);return n===!0?h(this).get(t):n?n[this._i]:void 0}},set:function(t,n){return f.def(this,t,n)}},y=t.exports=r(293)("WeakMap",v,d,f,!0,!0);7!=(new y).set((Object.freeze||Object)(p),7).get(p)&&(e=f.getConstructor(v),c(e.prototype,d),u.NEED=!0,i(["delete","has","get","set"],function(t){var n=y.prototype,r=n[t];o(n,t,function(n,i){if(a(n)&&!l(n)){this._f||(this._f=new e);var o=this._f[t](n,i);return"set"==t?this:o}return r.call(this,n,i)})}))},function(t,n,r){"use strict";var e=r(290),i=r(102).getWeak,o=r(92),u=r(93),c=r(285),f=r(286),a=r(252),s=r(85),l=a(5),h=a(6),p=0,v=function(t){return t._l||(t._l=new d)},d=function(){this.a=[]},y=function(t,n){return l(t.a,function(t){return t[0]===n})};d.prototype={get:function(t){var n=y(this,t);if(n)return n[1]},has:function(t){return!!y(this,t)},set:function(t,n){var r=y(this,t);r?r[1]=n:this.a.push([t,n])},"delete":function(t){var n=h(this.a,function(n){return n[0]===t});return~n&&this.a.splice(n,1),!!~n}},t.exports={getConstructor:function(t,n,r,o){var a=t(function(t,e){c(t,a,n,"_i"),t._i=p++,t._l=void 0,void 0!=e&&f(e,r,t[o],t)});return e(a.prototype,{"delete":function(t){if(!u(t))return!1;var n=i(t);return n===!0?v(this)["delete"](t):n&&s(n,this._i)&&delete n[this._i]},has:function(t){if(!u(t))return!1;var n=i(t);return n===!0?v(this).has(t):n&&s(n,this._i)}}),a},def:function(t,n,r){var e=i(o(n),!0);return e===!0?v(t).set(n,r):e[t._i]=r,t},ufstore:v}},function(t,n,r){"use strict";var e=r(296);r(293)("WeakSet",function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},{add:function(t){return e.def(this,t,!0)}},e,!1,!0)},function(t,n,r){"use strict";var e=r(88),i=r(299),o=r(300),u=r(92),c=r(119),f=r(117),a=r(93),s=r(84).ArrayBuffer,l=r(287),h=o.ArrayBuffer,p=o.DataView,v=i.ABV&&s.isView,d=h.prototype.slice,y=i.VIEW,g="ArrayBuffer";e(e.G+e.W+e.F*(s!==h),{ArrayBuffer:h}),e(e.S+e.F*!i.CONSTR,g,{isView:function(t){return v&&v(t)||a(t)&&y in t}}),e(e.P+e.U+e.F*r(87)(function(){return!new h(2).slice(1,void 0).byteLength}),g,{slice:function(t,n){if(void 0!==d&&void 0===n)return d.call(u(this),t);for(var r=u(this).byteLength,e=c(t,r),i=c(void 0===n?r:n,r),o=new(l(this,h))(f(i-e)),a=new p(this),s=new p(o),v=0;e>1,s=23===n?P(2,-24)-P(2,-77):0,l=0,h=t<0||0===t&&1/t<0?1:0;for(t=j(t),t!=t||t===k?(i=t!=t?1:0,e=f):(e=F(M(t)/T),t*(o=P(2,-e))<1&&(e--,o*=2),t+=e+a>=1?s/o:s*P(2,1-a),t*o>=2&&(e++,o/=2),e+a>=f?(i=0,e=f):e+a>=1?(i=(t*o-1)*P(2,n),e+=a):(i=t*P(2,a-1)*P(2,n),e=0));n>=8;u[l++]=255&i,i/=256,n-=8);for(e=e<0;u[l++]=255&e,e/=256,c-=8);return u[--l]|=128*h,u},q=function(t,n,r){var e,i=8*r-n-1,o=(1<>1,c=i-7,f=r-1,a=t[f--],s=127&a;for(a>>=7;c>0;s=256*s+t[f],f--,c-=8);for(e=s&(1<<-c)-1,s>>=-c,c+=n;c>0;e=256*e+t[f],f--,c-=8);if(0===s)s=1-u;else{if(s===o)return e?NaN:a?-k:k;e+=P(2,n),s-=u}return(a?-1:1)*e*P(2,s-n)},D=function(t){return t[3]<<24|t[2]<<16|t[1]<<8|t[0]},B=function(t){return[255&t]},W=function(t){return[255&t,t>>8&255]},G=function(t){return[255&t,t>>8&255,t>>16&255,t>>24&255]},z=function(t){return $(t,52,8)},V=function(t){return $(t,23,4)},J=function(t,n,r){v(t[m],n,{get:function(){return this[r]}})},H=function(t,n,r,e){var i=+r,o=l(i);if(i!=o||o<0||o+n>t[C])throw O(w);var u=t[L]._b,c=o+t[U],f=u.slice(c,c+n);return e?f:f.reverse()},K=function(t,n,r,e,i,o){var u=+r,c=l(u);if(u!=c||c<0||c+n>t[C])throw O(w);for(var f=t[L]._b,a=c+t[U],s=e(+i),h=0;htt;)(X=Z[tt++])in x||c(x,X,A[X]);o||(Q.constructor=x)}var nt=new S(new x(2)),rt=S[m].setInt8;nt.setInt8(0,2147483648),nt.setInt8(1,2147483649),!nt.getInt8(0)&&nt.getInt8(1)||f(S[m],{setInt8:function(t,n){rt.call(this,t,n<<24>>24)},setUint8:function(t,n){rt.call(this,t,n<<24>>24)}},!0)}else x=function(t){var n=Y(this,t);this._b=d.call(Array(n),0),this[C]=n},S=function(t,n,r){s(this,S,_),s(t,x,_);var e=t[C],i=l(n);if(i<0||i>e)throw O("Wrong offset!");if(r=void 0===r?e-i:h(r),i+r>e)throw O(b);this[L]=t,this[U]=i,this[C]=r},i&&(J(x,R,"_l"),J(S,I,"_b"),J(S,R,"_l"),J(S,N,"_o")),f(S[m],{getInt8:function(t){return H(this,1,t)[0]<<24>>24},getUint8:function(t){return H(this,1,t)[0]},getInt16:function(t){var n=H(this,2,t,arguments[1]);return(n[1]<<8|n[0])<<16>>16},getUint16:function(t){var n=H(this,2,t,arguments[1]);return n[1]<<8|n[0]},getInt32:function(t){return D(H(this,4,t,arguments[1]))},getUint32:function(t){return D(H(this,4,t,arguments[1]))>>>0},getFloat32:function(t){return q(H(this,4,t,arguments[1]),23,4)},getFloat64:function(t){return q(H(this,8,t,arguments[1]),52,8)},setInt8:function(t,n){K(this,1,t,B,n)},setUint8:function(t,n){K(this,1,t,B,n)},setInt16:function(t,n){K(this,2,t,W,n,arguments[2])},setUint16:function(t,n){K(this,2,t,W,n,arguments[2])},setInt32:function(t,n){K(this,4,t,G,n,arguments[2])},setUint32:function(t,n){K(this,4,t,G,n,arguments[2])},setFloat32:function(t,n){K(this,4,t,V,n,arguments[2])},setFloat64:function(t,n){K(this,8,t,z,n,arguments[2])}});y(x,g),y(S,_),c(S[m],u.VIEW,!0),n[g]=x,n[_]=S},function(t,n,r){var e=r(88);e(e.G+e.W+e.F*!r(299).ABV,{DataView:r(300).DataView})},function(t,n,r){r(303)("Int8",1,function(t){return function(n,r,e){return t(this,n,r,e)}})},function(t,n,r){"use strict";if(r(86)){var e=r(108),i=r(84),o=r(87),u=r(88),c=r(299),f=r(300),a=r(100),s=r(285),l=r(97),h=r(90),p=r(290),v=r(118),d=r(117),y=r(119),g=r(96),_=r(85),m=r(151),b=r(155),w=r(93),x=r(138),S=r(242),E=r(126),O=r(139),k=r(130).f,A=r(244),j=r(99),P=r(105),F=r(252),M=r(116),T=r(287),I=r(273),R=r(209),N=r(245),L=r(272),C=r(268),U=r(265),$=r(91),q=r(131),D=$.f,B=q.f,W=i.RangeError,G=i.TypeError,z=i.Uint8Array,V="ArrayBuffer",J="Shared"+V,H="BYTES_PER_ELEMENT",K="prototype",Y=Array[K],X=f.ArrayBuffer,Q=f.DataView,Z=F(0),tt=F(2),nt=F(3),rt=F(4),et=F(5),it=F(6),ot=M(!0),ut=M(!1),ct=I.values,ft=I.keys,at=I.entries,st=Y.lastIndexOf,lt=Y.reduce,ht=Y.reduceRight,pt=Y.join,vt=Y.sort,dt=Y.slice,yt=Y.toString,gt=Y.toLocaleString,_t=P("iterator"),mt=P("toStringTag"),bt=j("typed_constructor"),wt=j("def_constructor"),xt=c.CONSTR,St=c.TYPED,Et=c.VIEW,Ot="Wrong length!",kt=F(1,function(t,n){return Tt(T(t,t[wt]),n)}),At=o(function(){return 1===new z(new Uint16Array([1]).buffer)[0]}),jt=!!z&&!!z[K].set&&o(function(){new z(1).set({})}),Pt=function(t,n){if(void 0===t)throw G(Ot);var r=+t,e=d(t);if(n&&!m(r,e))throw W(Ot);return e},Ft=function(t,n){var r=v(t);if(r<0||r%n)throw W("Wrong offset!");return r},Mt=function(t){if(w(t)&&St in t)return t;throw G(t+" is not a typed array!")},Tt=function(t,n){if(!(w(t)&&bt in t))throw G("It is not a typed array constructor!");return new t(n)},It=function(t,n){return Rt(T(t,t[wt]),n)},Rt=function(t,n){for(var r=0,e=n.length,i=Tt(t,e);e>r;)i[r]=n[r++];return i},Nt=function(t,n,r){D(t,n,{get:function(){return this._d[r]}})},Lt=function(t){var n,r,e,i,o,u,c=x(t),f=arguments.length,s=f>1?arguments[1]:void 0,l=void 0!==s,h=A(c);if(void 0!=h&&!S(h)){for(u=h.call(c),e=[],n=0;!(o=u.next()).done;n++)e.push(o.value);c=e}for(l&&f>2&&(s=a(s,arguments[2],2)),n=0,r=d(c.length),i=Tt(this,r);r>n;n++)i[n]=l?s(c[n],n):c[n];return i},Ct=function(){for(var t=0,n=arguments.length,r=Tt(this,n);n>t;)r[t]=arguments[t++];return r},Ut=!!z&&o(function(){gt.call(new z(1))}),$t=function(){return gt.apply(Ut?dt.call(Mt(this)):Mt(this),arguments)},qt={copyWithin:function(t,n){return U.call(Mt(this),t,n,arguments.length>2?arguments[2]:void 0)},every:function(t){return rt(Mt(this),t,arguments.length>1?arguments[1]:void 0)},fill:function(t){return C.apply(Mt(this),arguments)},filter:function(t){return It(this,tt(Mt(this),t,arguments.length>1?arguments[1]:void 0))},find:function(t){return et(Mt(this),t,arguments.length>1?arguments[1]:void 0)},findIndex:function(t){return it(Mt(this),t,arguments.length>1?arguments[1]:void 0)},forEach:function(t){Z(Mt(this),t,arguments.length>1?arguments[1]:void 0)},indexOf:function(t){return ut(Mt(this),t,arguments.length>1?arguments[1]:void 0)},includes:function(t){return ot(Mt(this),t,arguments.length>1?arguments[1]:void 0)},join:function(t){return pt.apply(Mt(this),arguments)},lastIndexOf:function(t){return st.apply(Mt(this),arguments)},map:function(t){return kt(Mt(this),t,arguments.length>1?arguments[1]:void 0)},reduce:function(t){return lt.apply(Mt(this),arguments)},reduceRight:function(t){return ht.apply(Mt(this),arguments)},reverse:function(){for(var t,n=this,r=Mt(n).length,e=Math.floor(r/2),i=0;i1?arguments[1]:void 0)},sort:function(t){return vt.call(Mt(this),t)},subarray:function(t,n){var r=Mt(this),e=r.length,i=y(t,e);return new(T(r,r[wt]))(r.buffer,r.byteOffset+i*r.BYTES_PER_ELEMENT,d((void 0===n?e:y(n,e))-i))}},Dt=function(t,n){return It(this,dt.call(Mt(this),t,n))},Bt=function(t){Mt(this);var n=Ft(arguments[1],1),r=this.length,e=x(t),i=d(e.length),o=0;if(i+n>r)throw W(Ot);for(;o255?255:255&e),i.v[v](r*n+i.o,e,At)},P=function(t,n){D(t,n,{get:function(){return A(this,n)},set:function(t){return j(this,n,t)},enumerable:!0})};m?(y=r(function(t,r,e,i){s(t,y,a,"_d");var o,u,c,f,l=0,p=0;if(w(r)){if(!(r instanceof X||(f=b(r))==V||f==J))return St in r?Rt(y,r):Lt.call(y,r);o=r,p=Ft(e,n);var v=r.byteLength;if(void 0===i){if(v%n)throw W(Ot);if(u=v-p,u<0)throw W(Ot)}else if(u=d(i)*n,u+p>v)throw W(Ot);c=u/n}else c=Pt(r,!0),u=c*n,o=new X(u);for(h(t,"_d",{b:o,o:p,l:u,e:c,v:new Q(o)});l=r.length)return{value:void 0,done:!0};while(!((t=r[n._i++])in n._t));return{value:t,done:!1}}),e(e.S,"Reflect",{enumerate:function(t){return new o(t)}})},function(t,n,r){function e(t,n){var r,c,s=arguments.length<3?t:arguments[2];return a(t)===s?t[n]:(r=i.f(t,n))?u(r,"value")?r.value:void 0!==r.get?r.get.call(s):void 0:f(c=o(t))?e(c,n,s):void 0}var i=r(131),o=r(139),u=r(85),c=r(88),f=r(93),a=r(92);c(c.S,"Reflect",{get:e})},function(t,n,r){var e=r(131),i=r(88),o=r(92);i(i.S,"Reflect",{getOwnPropertyDescriptor:function(t,n){return e.f(o(t),n)}})},function(t,n,r){var e=r(88),i=r(139),o=r(92);e(e.S,"Reflect",{getPrototypeOf:function(t){return i(o(t))}})},function(t,n,r){var e=r(88);e(e.S,"Reflect",{has:function(t,n){return n in t}})},function(t,n,r){var e=r(88),i=r(92),o=Object.isExtensible;e(e.S,"Reflect",{isExtensible:function(t){return i(t),!o||o(t)}})},function(t,n,r){var e=r(88);e(e.S,"Reflect",{ownKeys:r(323)})},function(t,n,r){var e=r(130),i=r(123),o=r(92),u=r(84).Reflect;t.exports=u&&u.ownKeys||function(t){var n=e.f(o(t)),r=i.f;return r?n.concat(r(t)):n}},function(t,n,r){var e=r(88),i=r(92),o=Object.preventExtensions;e(e.S,"Reflect",{preventExtensions:function(t){i(t);try{return o&&o(t),!0}catch(n){return!1}}})},function(t,n,r){function e(t,n,r){var f,h,p=arguments.length<4?t:arguments[3],v=o.f(s(t),n);if(!v){if(l(h=u(t)))return e(h,n,r,p);v=a(0)}return c(v,"value")?!(v.writable===!1||!l(p))&&(f=o.f(p,n)||a(0),f.value=r,i.f(p,n,f),!0):void 0!==v.set&&(v.set.call(p,r),!0)}var i=r(91),o=r(131),u=r(139),c=r(85),f=r(88),a=r(97),s=r(92),l=r(93);f(f.S,"Reflect",{set:e})},function(t,n,r){var e=r(88),i=r(153);i&&e(e.S,"Reflect",{setPrototypeOf:function(t,n){i.check(t,n);try{return i.set(t,n),!0}catch(r){return!1}}})},function(t,n,r){"use strict";var e=r(88),i=r(116)(!0);e(e.P,"Array",{includes:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}}),r(266)("includes")},function(t,n,r){"use strict";var e=r(88),i=r(207)(!0);e(e.P,"String",{at:function(t){return i(this,t)}})},function(t,n,r){"use strict";var e=r(88),i=r(330);e(e.P,"String",{padStart:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0,!0)}})},function(t,n,r){var e=r(117),i=r(171),o=r(115);t.exports=function(t,n,r,u){var c=String(o(t)),f=c.length,a=void 0===r?" ":String(r),s=e(n);if(s<=f||""==a)return c;var l=s-f,h=i.call(a,Math.ceil(l/a.length));return h.length>l&&(h=h.slice(0,l)),u?h+c:c+h}},function(t,n,r){"use strict";var e=r(88),i=r(330);e(e.P,"String",{padEnd:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0,!1)}})},function(t,n,r){"use strict";r(163)("trimLeft",function(t){return function(){return t(this,1)}},"trimStart")},function(t,n,r){"use strict";r(163)("trimRight",function(t){return function(){return t(this,2)}},"trimEnd")},function(t,n,r){"use strict";var e=r(88),i=r(115),o=r(117),u=r(214),c=r(276),f=RegExp.prototype,a=function(t,n){this._r=t,this._s=n};r(210)(a,"RegExp String",function(){var t=this._r.exec(this._s);return{value:t,done:null===t}}),e(e.P,"String",{matchAll:function(t){if(i(this),!u(t))throw TypeError(t+" is not a regexp!");var n=String(this),r="flags"in f?String(t.flags):c.call(t),e=new RegExp(t.source,~r.indexOf("g")?r:"g"+r);return e.lastIndex=o(t.lastIndex),new a(e,n)}})},function(t,n,r){r(107)("asyncIterator")},function(t,n,r){r(107)("observable")},function(t,n,r){var e=r(88),i=r(323),o=r(112),u=r(131),c=r(243);e(e.S,"Object",{getOwnPropertyDescriptors:function(t){for(var n,r=o(t),e=u.f,f=i(r),a={},s=0;f.length>s;)c(a,n=f[s++],e(r,n));return a}})},function(t,n,r){var e=r(88),i=r(339)(!1);e(e.S,"Object",{values:function(t){return i(t)}})},function(t,n,r){var e=r(110),i=r(112),o=r(124).f;t.exports=function(t){return function(n){for(var r,u=i(n),c=e(u),f=c.length,a=0,s=[];f>a;)o.call(u,r=c[a++])&&s.push(t?[r,u[r]]:u[r]);return s}}},function(t,n,r){var e=r(88),i=r(339)(!0);e(e.S,"Object",{entries:function(t){return i(t)}})},function(t,n,r){"use strict";var e=r(88),i=r(138),o=r(101),u=r(91);r(86)&&e(e.P+r(342),"Object",{__defineGetter__:function(t,n){u.f(i(this),t,{get:o(n),enumerable:!0,configurable:!0})}})},function(t,n,r){t.exports=r(108)||!r(87)(function(){var t=Math.random();__defineSetter__.call(null,t,function(){}),delete r(84)[t]})},function(t,n,r){"use strict";var e=r(88),i=r(138),o=r(101),u=r(91);r(86)&&e(e.P+r(342),"Object",{__defineSetter__:function(t,n){u.f(i(this),t,{set:o(n),enumerable:!0,configurable:!0})}})},function(t,n,r){"use strict";var e=r(88),i=r(138),o=r(96),u=r(139),c=r(131).f;r(86)&&e(e.P+r(342),"Object",{__lookupGetter__:function(t){var n,r=i(this),e=o(t,!0);do if(n=c(r,e))return n.get;while(r=u(r))}})},function(t,n,r){"use strict";var e=r(88),i=r(138),o=r(96),u=r(139),c=r(131).f;r(86)&&e(e.P+r(342),"Object",{__lookupSetter__:function(t){var n,r=i(this),e=o(t,!0);do if(n=c(r,e))return n.set;while(r=u(r))}})},function(t,n,r){var e=r(88);e(e.P+e.R,"Map",{toJSON:r(347)("Map")})},function(t,n,r){var e=r(155),i=r(348);t.exports=function(t){return function(){if(e(this)!=t)throw TypeError(t+"#toJSON isn't generic");return i(this)}}},function(t,n,r){var e=r(286);t.exports=function(t,n){var r=[];return e(t,!1,r.push,r,n),r}},function(t,n,r){var e=r(88);e(e.P+e.R,"Set",{toJSON:r(347)("Set")})},function(t,n,r){var e=r(88);e(e.S,"System",{global:r(84)})},function(t,n,r){var e=r(88),i=r(114);e(e.S,"Error",{isError:function(t){return"Error"===i(t)}})},function(t,n,r){var e=r(88);e(e.S,"Math",{iaddh:function(t,n,r,e){var i=t>>>0,o=n>>>0,u=r>>>0;return o+(e>>>0)+((i&u|(i|u)&~(i+u>>>0))>>>31)|0}})},function(t,n,r){var e=r(88);e(e.S,"Math",{isubh:function(t,n,r,e){var i=t>>>0,o=n>>>0,u=r>>>0;return o-(e>>>0)-((~i&u|~(i^u)&i-u>>>0)>>>31)|0}})},function(t,n,r){var e=r(88);e(e.S,"Math",{imulh:function(t,n){var r=65535,e=+t,i=+n,o=e&r,u=i&r,c=e>>16,f=i>>16,a=(c*u>>>0)+(o*u>>>16);return c*f+(a>>16)+((o*f>>>0)+(a&r)>>16)}})},function(t,n,r){var e=r(88);e(e.S,"Math",{umulh:function(t,n){var r=65535,e=+t,i=+n,o=e&r,u=i&r,c=e>>>16,f=i>>>16,a=(c*u>>>0)+(o*u>>>16);return c*f+(a>>>16)+((o*f>>>0)+(a&r)>>>16)}})},function(t,n,r){var e=r(357),i=r(92),o=e.key,u=e.set;e.exp({defineMetadata:function(t,n,r,e){u(t,n,i(r),o(e))}})},function(t,n,r){var e=r(291),i=r(88),o=r(103)("metadata"),u=o.store||(o.store=new(r(295))),c=function(t,n,r){var i=u.get(t);if(!i){if(!r)return;u.set(t,i=new e)}var o=i.get(n);if(!o){if(!r)return;i.set(n,o=new e)}return o},f=function(t,n,r){var e=c(n,r,!1);return void 0!==e&&e.has(t)},a=function(t,n,r){var e=c(n,r,!1);return void 0===e?void 0:e.get(t)},s=function(t,n,r,e){c(r,e,!0).set(t,n)},l=function(t,n){var r=c(t,n,!1),e=[];return r&&r.forEach(function(t,n){e.push(n)}),e},h=function(t){return void 0===t||"symbol"==typeof t?t:String(t)},p=function(t){i(i.S,"Reflect",t)};t.exports={store:u,map:c,has:f,get:a,set:s,keys:l,key:h,exp:p}},function(t,n,r){var e=r(357),i=r(92),o=e.key,u=e.map,c=e.store;e.exp({deleteMetadata:function(t,n){var r=arguments.length<3?void 0:o(arguments[2]),e=u(i(n),r,!1);if(void 0===e||!e["delete"](t))return!1;if(e.size)return!0;var f=c.get(n);return f["delete"](r),!!f.size||c["delete"](n)}})},function(t,n,r){var e=r(357),i=r(92),o=r(139),u=e.has,c=e.get,f=e.key,a=function(t,n,r){var e=u(t,n,r);if(e)return c(t,n,r);var i=o(n);return null!==i?a(t,i,r):void 0};e.exp({getMetadata:function(t,n){return a(t,i(n),arguments.length<3?void 0:f(arguments[2]))}})},function(t,n,r){var e=r(294),i=r(348),o=r(357),u=r(92),c=r(139),f=o.keys,a=o.key,s=function(t,n){var r=f(t,n),o=c(t);if(null===o)return r;var u=s(o,n);return u.length?r.length?i(new e(r.concat(u))):u:r};o.exp({getMetadataKeys:function(t){return s(u(t),arguments.length<2?void 0:a(arguments[1]))}})},function(t,n,r){var e=r(357),i=r(92),o=e.get,u=e.key;e.exp({getOwnMetadata:function(t,n){return o(t,i(n),arguments.length<3?void 0:u(arguments[2]))}})},function(t,n,r){var e=r(357),i=r(92),o=e.keys,u=e.key;e.exp({getOwnMetadataKeys:function(t){return o(i(t),arguments.length<2?void 0:u(arguments[1]))}})},function(t,n,r){var e=r(357),i=r(92),o=r(139),u=e.has,c=e.key,f=function(t,n,r){var e=u(t,n,r);if(e)return!0;var i=o(n);return null!==i&&f(t,i,r)};e.exp({hasMetadata:function(t,n){return f(t,i(n),arguments.length<3?void 0:c(arguments[2]))}})},function(t,n,r){var e=r(357),i=r(92),o=e.has,u=e.key;e.exp({hasOwnMetadata:function(t,n){return o(t,i(n),arguments.length<3?void 0:u(arguments[2]))}})},function(t,n,r){var e=r(357),i=r(92),o=r(101),u=e.key,c=e.set;e.exp({metadata:function(t,n){return function(r,e){c(t,n,(void 0!==e?i:o)(r),u(e)); +}}})},function(t,n,r){var e=r(88),i=r(289)(),o=r(84).process,u="process"==r(114)(o);e(e.G,{asap:function(t){var n=u&&o.domain;i(n?n.bind(t):t)}})},function(t,n,r){"use strict";var e=r(88),i=r(84),o=r(89),u=r(289)(),c=r(105)("observable"),f=r(101),a=r(92),s=r(285),l=r(290),h=r(90),p=r(286),v=p.RETURN,d=function(t){return null==t?void 0:f(t)},y=function(t){var n=t._c;n&&(t._c=void 0,n())},g=function(t){return void 0===t._o},_=function(t){g(t)||(t._o=void 0,y(t))},m=function(t,n){a(t),this._c=void 0,this._o=t,t=new b(this);try{var r=n(t),e=r;null!=r&&("function"==typeof r.unsubscribe?r=function(){e.unsubscribe()}:f(r),this._c=r)}catch(i){return void t.error(i)}g(this)&&y(this)};m.prototype=l({},{unsubscribe:function(){_(this)}});var b=function(t){this._s=t};b.prototype=l({},{next:function(t){var n=this._s;if(!g(n)){var r=n._o;try{var e=d(r.next);if(e)return e.call(r,t)}catch(i){try{_(n)}finally{throw i}}}},error:function(t){var n=this._s;if(g(n))throw t;var r=n._o;n._o=void 0;try{var e=d(r.error);if(!e)throw t;t=e.call(r,t)}catch(i){try{y(n)}finally{throw i}}return y(n),t},complete:function(t){var n=this._s;if(!g(n)){var r=n._o;n._o=void 0;try{var e=d(r.complete);t=e?e.call(r,t):void 0}catch(i){try{y(n)}finally{throw i}}return y(n),t}}});var w=function(t){s(this,w,"Observable","_f")._f=f(t)};l(w.prototype,{subscribe:function(t){return new m(t,this._f)},forEach:function(t){var n=this;return new(o.Promise||i.Promise)(function(r,e){f(t);var i=n.subscribe({next:function(n){try{return t(n)}catch(r){e(r),i.unsubscribe()}},error:e,complete:r})})}}),l(w,{from:function(t){var n="function"==typeof this?this:w,r=d(a(t)[c]);if(r){var e=a(r.call(t));return e.constructor===n?e:new n(function(t){return e.subscribe(t)})}return new n(function(n){var r=!1;return u(function(){if(!r){try{if(p(t,!1,function(t){if(n.next(t),r)return v})===v)return}catch(e){if(r)throw e;return void n.error(e)}n.complete()}}),function(){r=!0}})},of:function(){for(var t=0,n=arguments.length,r=Array(n);tu;)(r[u]=arguments[u++])===c&&(f=!0);return function(){var e,o=this,u=arguments.length,a=0,s=0;if(!f&&!u)return i(t,r,o);if(e=r.slice(),f)for(;n>a;a++)e[a]===c&&(e[a]=arguments[s++]);for(;u>s;)e.push(arguments[s++]);return i(t,e,o)}}},function(t,n,r){t.exports=r(84)},function(t,n,r){var e=r(88),i=r(288);e(e.G+e.B,{setImmediate:i.set,clearImmediate:i.clear})},function(t,n,r){for(var e=r(273),i=r(98),o=r(84),u=r(90),c=r(209),f=r(105),a=f("iterator"),s=f("toStringTag"),l=c.Array,h=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],p=0;p<5;p++){var v,d=h[p],y=o[d],g=y&&y.prototype;if(g){g[a]||u(g,a,l),g[s]||u(g,s,d),c[d]=l;for(v in e)g[v]||i(g,v,e[v],!0)}}},function(t,n,r){(function(n,r){!function(n){"use strict";function e(t,n,r,e){var i=Object.create((n||o).prototype),u=new v(e||[]);return i._invoke=l(t,r,u),i}function i(t,n,r){try{return{type:"normal",arg:t.call(n,r)}}catch(e){return{type:"throw",arg:e}}}function o(){}function u(){}function c(){}function f(t){["next","throw","return"].forEach(function(n){t[n]=function(t){return this._invoke(n,t)}})}function a(t){this.arg=t}function s(t){function n(r,e,o,u){var c=i(t[r],t,e);if("throw"!==c.type){var f=c.arg,s=f.value;return s instanceof a?Promise.resolve(s.arg).then(function(t){n("next",t,o,u)},function(t){n("throw",t,o,u)}):Promise.resolve(s).then(function(t){f.value=t,o(f)},u)}u(c.arg)}function e(t,r){function e(){return new Promise(function(e,i){n(t,r,e,i)})}return o=o?o.then(e,e):e()}"object"==typeof r&&r.domain&&(n=r.domain.bind(n));var o;this._invoke=e}function l(t,n,r){var e=E;return function(o,u){if(e===k)throw new Error("Generator is already running");if(e===A){if("throw"===o)throw u;return y()}for(;;){var c=r.delegate;if(c){if("return"===o||"throw"===o&&c.iterator[o]===g){r.delegate=null;var f=c.iterator["return"];if(f){var a=i(f,c.iterator,u);if("throw"===a.type){o="throw",u=a.arg;continue}}if("return"===o)continue}var a=i(c.iterator[o],c.iterator,u);if("throw"===a.type){r.delegate=null,o="throw",u=a.arg;continue}o="next",u=g;var s=a.arg;if(!s.done)return e=O,s;r[c.resultName]=s.value,r.next=c.nextLoc,r.delegate=null}if("next"===o)r.sent=r._sent=u;else if("throw"===o){if(e===E)throw e=A,u;r.dispatchException(u)&&(o="next",u=g)}else"return"===o&&r.abrupt("return",u);e=k;var a=i(t,n,r);if("normal"===a.type){e=r.done?A:O;var s={value:a.arg,done:r.done};if(a.arg!==j)return s;r.delegate&&"next"===o&&(u=g)}else"throw"===a.type&&(e=A,o="throw",u=a.arg)}}}function h(t){var n={tryLoc:t[0]};1 in t&&(n.catchLoc=t[1]),2 in t&&(n.finallyLoc=t[2],n.afterLoc=t[3]),this.tryEntries.push(n)}function p(t){var n=t.completion||{};n.type="normal",delete n.arg,t.completion=n}function v(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(h,this),this.reset(!0)}function d(t){if(t){var n=t[b];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,e=function i(){for(;++r=0;--e){var i=this.tryEntries[e],o=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=_.call(i,"catchLoc"),c=_.call(i,"finallyLoc");if(u&&c){if(this.prev=0;--r){var e=this.tryEntries[r];if(e.tryLoc<=this.prev&&_.call(e,"finallyLoc")&&this.prev=0;--n){var r=this.tryEntries[n];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),p(r),j}},"catch":function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc===t){var e=r.completion;if("throw"===e.type){var i=e.arg;p(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:d(t),resultName:n,nextLoc:r},j}}}("object"==typeof n?n:"object"==typeof window?window:"object"==typeof self?self:this)}).call(n,function(){return this}(),r(374))},function(t,n){function r(t){return f===setTimeout?setTimeout(t,0):f.call(null,t,0)}function e(t){a===clearTimeout?clearTimeout(t):a.call(null,t)}function i(){p&&l&&(p=!1,l.length?h=l.concat(h):v=-1,h.length&&o())}function o(){if(!p){var t=r(i);p=!0;for(var n=h.length;n;){for(l=h,h=[];++v1)for(var e=1;e=n.length?{value:void 0,done:!0}:(t=o(n,r),this._i+=t.length,{value:t,done:!1})})},function(t,n,r,e,i){var o=r(e),u=r(i);t.exports=function(t){return function(n,r){var e,i,c=String(u(n)),f=o(r),a=c.length;return f<0||f>=a?t?"":void 0:(e=c.charCodeAt(f),e<55296||e>56319||f+1===a||(i=c.charCodeAt(f+1))<56320||i>57343?t?c.charAt(f):e:t?c.slice(f,f+2):(e-55296<<10)+(i-56320)+65536)}}},function(t,n,r,e,i,o,u,c,f,a,s,l,h){"use strict";var p=r(e),v=r(i),d=r(o),y=r(u),g=r(c),_=r(f),m=r(a),b=r(s),w=r(l),x=r(h)("iterator"),S=!([].keys&&"next"in[].keys()),E="@@iterator",O="keys",k="values",A=function(){return this};t.exports=function(t,n,r,e,i,o,u){m(r,n,e);var c,f,a,s=function(t){if(!S&&t in P)return P[t];switch(t){case O:return function(){return new r(this,t)};case k:return function(){return new r(this,t)}}return function(){return new r(this,t)}},l=n+" Iterator",h=i==k,j=!1,P=t.prototype,F=P[x]||P[E]||i&&P[i],M=F||s(i),T=i?h?s("entries"):M:void 0,I="Array"==n?P.entries||F:F;if(I&&(a=w(I.call(new t)),a!==Object.prototype&&(b(a,l,!0),p||g(a,x)||y(a,x,A))),h&&F&&F.name!==k&&(j=!0,M=function(){return F.call(this)}),p&&!u||!S&&!j&&P[x]||y(P,x,M),_[n]=M,_[l]=A,i)if(c={values:h?M:s(k),keys:o?M:s(O),entries:T},u)for(f in c)f in P||d(P,f,c[f]);else v(v.P+v.F*(S||j),n,c);return c}},function(t,n,r,e){var i=r(e);t.exports=function(t,n,r){if(i(t),void 0===n)return t;switch(r){case 1:return function(r){return t.call(n,r)};case 2:return function(r,e){return t.call(n,r,e)};case 3:return function(r,e,i){return t.call(n,r,e,i)}}return function(){return t.apply(n,arguments)}}},function(t,n,r,e,i,o){var u=r(e),c=r(i);t.exports=r(o)?function(t,n,r){return u.f(t,n,c(1,r))}:function(t,n,r){return t[n]=r,t}},function(t,n,r,e,i,o,u){var c=r(e),f=r(i),a=r(o),s=Object.defineProperty;n.f=r(u)?Object.defineProperty:function(t,n,r){if(c(t),n=a(n,!0),c(r),f)try{return s(t,n,r)}catch(e){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(t[n]=r.value),t}},function(t,n,r,e){var i=r(e);t.exports=function(t){if(!i(t))throw TypeError(t+" is not an object!");return t}},function(t,n,r,e,i,o){t.exports=!r(e)&&!r(i)(function(){return 7!=Object.defineProperty(r(o)("div"),"a",{get:function(){return 7}}).a})},function(t,n,r,e){t.exports=!r(e)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,n,r,e,i){var o=r(e),u=r(i).document,c=o(u)&&o(u.createElement);t.exports=function(t){return c?u.createElement(t):{}}},function(t,n,r,e){var i=r(e);t.exports=function(t,n){if(!i(t))return t;var r,e;if(n&&"function"==typeof(r=t.toString)&&!i(e=r.call(t)))return e;if("function"==typeof(r=t.valueOf)&&!i(e=r.call(t)))return e;if(!n&&"function"==typeof(r=t.toString)&&!i(e=r.call(t)))return e;throw TypeError("Can't convert object to primitive value")}},function(t,n,r,e,i,o,u,c){"use strict";var f=r(e),a=r(i),s=r(o),l={};r(u)(l,r(c)("iterator"),function(){return this}),t.exports=function(t,n,r){t.prototype=f(l,{next:a(1,r)}),s(t,n+" Iterator")}},function(t,n,r,e,i,o,u,c,f){var a=r(e),s=r(i),l=r(o),h=r(u)("IE_PROTO"),p=function(){},v="prototype",d=function(){var t,n=r(c)("iframe"),e=l.length,i="<",o=">";for(n.style.display="none",r(f).appendChild(n),n.src="javascript:",t=n.contentWindow.document,t.open(),t.write(i+"script"+o+"document.F=Object"+i+"/script"+o),t.close(),d=t.F;e--;)delete d[v][l[e]];return d()};t.exports=Object.create||function(t,n){var r;return null!==t?(p[v]=a(t),r=new p,p[v]=null,r[h]=t):r=d(),void 0===n?r:s(r,n)}},function(t,n,r,e,i,o,u){var c=r(e),f=r(i),a=r(o);t.exports=r(u)?Object.defineProperties:function(t,n){f(t);for(var r,e=a(n),i=e.length,o=0;i>o;)c.f(t,r=e[o++],n[r]);return t}},function(t,n,r,e,i){var o=r(e),u=r(i);t.exports=Object.keys||function(t){return o(t,u)}},function(t,n,r,e,i,o,u){var c=r(e),f=r(i),a=r(o)(!1),s=r(u)("IE_PROTO");t.exports=function(t,n){var r,e=f(t),i=0,o=[];for(r in e)r!=s&&c(e,r)&&o.push(r);for(;n.length>i;)c(e,r=n[i++])&&(~a(o,r)||o.push(r));return o}},function(t,n,r,e,i){var o=r(e),u=r(i);t.exports=function(t){return o(u(t))}},function(t,n,r,e){var i=r(e);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==i(t)?t.split(""):Object(t)}},function(t,n,r,e,i,o){var u=r(e),c=r(i),f=r(o);t.exports=function(t){return function(n,r,e){var i,o=u(n),a=c(o.length),s=f(e,a);if(t&&r!=r){for(;a>s;)if(i=o[s++],i!=i)return!0}else for(;a>s;s++)if((t||s in o)&&o[s]===r)return t||s||0;return!t&&-1}}},function(t,n,r,e){var i=r(e),o=Math.min;t.exports=function(t){return t>0?o(i(t),9007199254740991):0}},function(t,n,r,e){var i=r(e),o=Math.max,u=Math.min;t.exports=function(t,n){return t=i(t),t<0?o(t+n,0):u(t,n)}},function(t,n,r,e,i){var o=r(e)("keys"),u=r(i);t.exports=function(t){return o[t]||(o[t]=u(t))}},function(t,n,r,e){var i=r(e),o="__core-js_shared__",u=i[o]||(i[o]={});t.exports=function(t){return u[t]||(u[t]={})}},function(t,n,r,e){t.exports=r(e).document&&document.documentElement},function(t,n,r,e,i,o){var u=r(e).f,c=r(i),f=r(o)("toStringTag");t.exports=function(t,n,r){t&&!c(t=r?t:t.prototype,f)&&u(t,f,{configurable:!0,value:n})}},function(t,n,r,e,i,o){var u=r(e)("wks"),c=r(i),f=r(o).Symbol,a="function"==typeof f,s=t.exports=function(t){return u[t]||(u[t]=a&&f[t]||(a?f:c)("Symbol."+t))};s.store=u},function(t,n,r,e,i,o){var u=r(e),c=r(i),f=r(o)("IE_PROTO"),a=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=c(t),u(t,f)?t[f]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?a:null}},function(t,n,r,e){var i=r(e);t.exports=function(t){return Object(i(t))}},function(t,n,r,e,i,o,u,c){"use strict";var f=r(e),a=r(i),s=r(o),l=r(u);t.exports=r(c)(Array,"Array",function(t,n){this._t=l(t),this._i=0,this._k=n},function(){var t=this._t,n=this._k,r=this._i++;return!t||r>=t.length?(this._t=void 0,a(1)):"keys"==n?a(0,r):"values"==n?a(0,t[r]):a(0,[r,t[r]])},"values"),s.Arguments=s.Array,f("keys"),f("values"),f("entries")},function(t,n,r,e,i,o,u,c,f,a,s,l,h,p,v,d,y,g,_,m,b){"use strict";var w,x,S,E=r(e),O=r(i),k=r(o),A=r(u),j=r(c),P=r(f),F=r(a),M=r(s),T=r(l),I=r(h),R=r(p).set,N=r(v)(),L="Promise",C=O.TypeError,U=O.process,$=O[L],U=O.process,q="process"==A(U),D=function(){},B=!!function(){try{var t=$.resolve(1),n=(t.constructor={})[r(d)("species")]=function(t){t(D,D)};return(q||"function"==typeof PromiseRejectionEvent)&&t.then(D)instanceof n}catch(e){}}(),W=function(t,n){return t===n||t===$&&n===S},G=function(t){var n;return!(!P(t)||"function"!=typeof(n=t.then))&&n},z=function(t){return W($,t)?new V(t):new x(t)},V=x=function(t){var n,r;this.promise=new t(function(t,e){if(void 0!==n||void 0!==r)throw C("Bad Promise constructor");n=t,r=e}),this.resolve=F(n),this.reject=F(r)},J=function(t){try{t()}catch(n){return{error:n}}},H=function(t,n){if(!t._n){t._n=!0;var r=t._c;N(function(){for(var e=t._v,i=1==t._s,o=0,u=function(n){var r,o,u=i?n.ok:n.fail,c=n.resolve,f=n.reject,a=n.domain;try{u?(i||(2==t._h&&X(t),t._h=1),u===!0?r=e:(a&&a.enter(),r=u(e),a&&a.exit()),r===n.promise?f(C("Promise-chain cycle")):(o=G(r))?o.call(r,c,f):c(r)):f(e)}catch(s){f(s)}};r.length>o;)u(r[o++]);t._c=[],t._n=!1,n&&!t._h&&K(t)})}},K=function(t){R.call(O,function(){var n,r,e,i=t._v;if(Y(t)&&(n=J(function(){q?U.emit("unhandledRejection",i,t):(r=O.onunhandledrejection)?r({promise:t,reason:i}):(e=O.console)&&e.error&&e.error("Unhandled promise rejection",i)}),t._h=q||Y(t)?2:1),t._a=void 0,n)throw n.error})},Y=function(t){if(1==t._h)return!1;for(var n,r=t._a||t._c,e=0;r.length>e;)if(n=r[e++],n.fail||!Y(n.promise))return!1;return!0},X=function(t){R.call(O,function(){var n;q?U.emit("rejectionHandled",t):(n=O.onrejectionhandled)&&n({promise:t,reason:t._v})})},Q=function(t){var n=this;n._d||(n._d=!0,n=n._w||n,n._v=t,n._s=2,n._a||(n._a=n._c.slice()),H(n,!0))},Z=function(t){var n,r=this;if(!r._d){r._d=!0,r=r._w||r;try{if(r===t)throw C("Promise can't be resolved itself");(n=G(t))?N(function(){var e={_w:r,_d:!1};try{n.call(t,k(Z,e,1),k(Q,e,1))}catch(i){Q.call(e,i)}}):(r._v=t,r._s=1,H(r,!1))}catch(e){Q.call({_w:r,_d:!1},e)}}};B||($=function(t){M(this,$,L,"_h"),F(t),w.call(this);try{t(k(Z,this,1),k(Q,this,1))}catch(n){Q.call(this,n)}},w=function(t){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},w.prototype=r(y)($.prototype,{then:function(t,n){var r=z(I(this,$));return r.ok="function"!=typeof t||t,r.fail="function"==typeof n&&n,r.domain=q?U.domain:void 0,this._c.push(r),this._a&&this._a.push(r),this._s&&H(this,!1),r.promise},"catch":function(t){return this.then(void 0,t)}}),V=function(){var t=new w;this.promise=t,this.resolve=k(Z,t,1),this.reject=k(Q,t,1)}),j(j.G+j.W+j.F*!B,{Promise:$}),r(g)($,L),r(_)(L),S=r(m)[L],j(j.S+j.F*!B,L,{reject:function(t){var n=z(this),r=n.reject;return r(t),n.promise}}),j(j.S+j.F*(E||!B),L,{resolve:function(t){if(t instanceof $&&W(t.constructor,this))return t;var n=z(this),r=n.resolve;return r(t),n.promise}}),j(j.S+j.F*!(B&&r(b)(function(t){$.all(t)["catch"](D)})),L,{all:function(t){var n=this,r=z(n),e=r.resolve,i=r.reject,o=J(function(){var r=[],o=0,u=1;T(t,!1,function(t){var c=o++,f=!1;r.push(void 0),u++,n.resolve(t).then(function(t){f||(f=!0,r[c]=t,--u||e(r))},i)}),--u||e(r)});return o&&i(o.error),r.promise},race:function(t){var n=this,r=z(n),e=r.reject,i=J(function(){T(t,!1,function(t){n.resolve(t).then(r.resolve,e)})});return i&&e(i.error),r.promise}})},function(t,n,r,e,i){var o=r(e),u=r(i)("toStringTag"),c="Arguments"==o(function(){return arguments}()),f=function(t,n){try{return t[n]}catch(r){}};t.exports=function(t){var n,r,e;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(r=f(n=Object(t),u))?r:c?o(n):"Object"==(e=o(n))&&"function"==typeof n.callee?"Arguments":e}},function(t,n,r,e,i,o,u,c,f){var a=r(e),s=r(i),l=r(o),h=r(u),p=r(c),v=r(f),d={},y={},n=t.exports=function(t,n,r,e,i){var o,u,c,f,g=i?function(){return t}:v(t),_=a(r,e,n?2:1),m=0;if("function"!=typeof g)throw TypeError(t+" is not iterable!");if(l(g)){for(o=p(t.length);o>m;m++)if(f=n?_(h(u=t[m])[0],u[1]):_(t[m]),f===d||f===y)return f}else for(c=g.call(t);!(u=c.next()).done;)if(f=s(c,_,u.value,n),f===d||f===y)return f};n.BREAK=d,n.RETURN=y},function(t,n,r,e){var i=r(e);t.exports=function(t,n,r,e){try{return e?n(i(r)[0],r[1]):n(r)}catch(o){var u=t["return"];throw void 0!==u&&i(u.call(t)),o}}},function(t,n,r,e,i){var o=r(e),u=r(i)("iterator"),c=Array.prototype;t.exports=function(t){return void 0!==t&&(o.Array===t||c[u]===t)}},function(t,n,r,e,i,o,u){var c=r(e),f=r(i)("iterator"),a=r(o);t.exports=r(u).getIteratorMethod=function(t){if(void 0!=t)return t[f]||t["@@iterator"]||a[c(t)]}},function(t,n,r,e,i,o){var u=r(e),c=r(i),f=r(o)("species");t.exports=function(t,n){var r,e=u(t).constructor;return void 0===e||void 0==(r=u(e)[f])?n:c(r)}},function(t,n,r,e,i,o,u,c,f){var a,s,l,h=r(e),p=r(i),v=r(o),d=r(u),y=r(c),g=y.process,_=y.setImmediate,m=y.clearImmediate,b=y.MessageChannel,w=0,x={},S="onreadystatechange",E=function(){var t=+this;if(x.hasOwnProperty(t)){var n=x[t];delete x[t],n()}},O=function(t){E.call(t.data)};_&&m||(_=function(t){for(var n=[],r=1;arguments.length>r;)n.push(arguments[r++]);return x[++w]=function(){p("function"==typeof t?t:Function(t),n)},a(w),w},m=function(t){delete x[t]},"process"==r(f)(g)?a=function(t){g.nextTick(h(E,t,1))}:b?(s=new b,l=s.port2,s.port1.onmessage=O,a=h(l.postMessage,l,1)):y.addEventListener&&"function"==typeof postMessage&&!y.importScripts?(a=function(t){y.postMessage(t+"","*")},y.addEventListener("message",O,!1)):a=S in d("script")?function(t){ +v.appendChild(d("script"))[S]=function(){v.removeChild(this),E.call(t)}}:function(t){setTimeout(h(E,t,1),0)}),t.exports={set:_,clear:m}},function(t,n,r,e,i,o){var u=r(e),c=r(i).set,f=u.MutationObserver||u.WebKitMutationObserver,a=u.process,s=u.Promise,l="process"==r(o)(a);t.exports=function(){var t,n,r,e=function(){var e,i;for(l&&(e=a.domain)&&e.exit();t;){i=t.fn,t=t.next;try{i()}catch(o){throw t?r():n=void 0,o}}n=void 0,e&&e.enter()};if(l)r=function(){a.nextTick(e)};else if(f){var i=!0,o=document.createTextNode("");new f(e).observe(o,{characterData:!0}),r=function(){o.data=i=!i}}else if(s&&s.resolve){var h=s.resolve();r=function(){h.then(e)}}else r=function(){c.call(u,e)};return function(e){var i={fn:e,next:void 0};n&&(n.next=i),t||(t=i,r()),n=i}}},function(t,n,r,e){var i=r(e)("iterator"),o=!1;try{var u=[7][i]();u["return"]=function(){o=!0},Array.from(u,function(){throw 2})}catch(c){}t.exports=function(t,n){if(!n&&!o)return!1;var r=!1;try{var e=[7],u=e[i]();u.next=function(){return{done:r=!0}},e[i]=function(){return u},t(e)}catch(c){}return r}},function(t,n,r,e,i,o){var u=r(e);u(u.S+u.F*!r(i),"Object",{defineProperty:r(o).f})},function(t,n,r,e,i,o){var u=r(e),c=r(i),f=r(o);t.exports=function(t,n){var r=(c.Object||{})[t]||Object[t],e={};e[t]=n(r),u(u.S+u.F*f(function(){r(1)}),"Object",e)}},function(t,n,r,e,i,o){var u=r(e),c=r(i);r(o)("keys",function(){return function(t){return c(u(t))}})}]))}); \ No newline at end of file diff --git a/dist/query.js b/dist/query.js new file mode 100644 index 0000000..779756b --- /dev/null +++ b/dist/query.js @@ -0,0 +1,210 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); + +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + +var _createClass2 = require('babel-runtime/helpers/createClass'); + +var _createClass3 = _interopRequireDefault(_createClass2); + +var _lodash = require('lodash'); + +var _lodash2 = _interopRequireDefault(_lodash); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var Query = function () { + function Query(schema) { + (0, _classCallCheck3.default)(this, Query); + + if (!schema) throw 'A schema name is required'; + + this.schema = schema; + this.terms = []; + } + + (0, _createClass3.default)(Query, [{ + key: 'toJS', + value: function toJS() { + return { + $type: 'query', + $schema: this.schema, + $query: this.terms + }; + } + }, { + key: 'get', + value: function get(id) { + this.terms.push(['$get', id]); + return this; + } + }, { + key: 'getAll', + value: function getAll(ids) { + var index = arguments.length <= 1 || arguments[1] === undefined ? 'id' : arguments[1]; + + this.terms.push(['$get_all', [index, ids]]); + return this; + } + }, { + key: 'filter', + value: function filter() { + for (var _len = arguments.length, filters = Array(_len), _key = 0; _key < _len; _key++) { + filters[_key] = arguments[_key]; + } + + var filterSet = filters.reduce(function (filterSet, currentFilter) { + return filterSet.concat(currentFilter.toJS()); + }, []); + + this.terms.push(['$filter', filterSet]); + return this; + } + }, { + key: 'hasFields', + value: function hasFields() { + for (var _len2 = arguments.length, fields = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + fields[_key2] = arguments[_key2]; + } + + this.terms.push(['$has_fields', fields]); + return this; + } + }, { + key: 'withFields', + value: function withFields() { + for (var _len3 = arguments.length, fields = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + fields[_key3] = arguments[_key3]; + } + + this.terms.push(['$with_fields', fields]); + return this; + } + }, { + key: 'orderBy', + value: function orderBy(field) { + var ordering = arguments.length <= 1 || arguments[1] === undefined ? 'asc' : arguments[1]; + + if (ordering !== 'asc' && ordering !== 'desc') { + throw new Error('ordering must be desc or asc'); + } + + ordering = '$' + ordering; + this.terms.push(['$order_by', field, ordering]); + return this; + } + }, { + key: 'skip', + value: function skip(num) { + this.terms.push(['$skip', num]); + return this; + } + }, { + key: 'limit', + value: function limit(num) { + this.terms.push(['$limit', num]); + return this; + } + }, { + key: 'slice', + value: function slice(start, end) { + this.terms.push(['$slice', [start, end]]); + return this; + } + }, { + key: 'nth', + value: function nth(num) { + this.terms.push(['$nth', num]); + return this; + } + }, { + key: 'sample', + value: function sample(num) { + this.terms.push(['$sample', num]); + return this; + } + }, { + key: 'pluck', + value: function pluck() { + for (var _len4 = arguments.length, fields = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { + fields[_key4] = arguments[_key4]; + } + + this.terms.push(['$pluck', fields]); + return this; + } + }, { + key: 'without', + value: function without() { + for (var _len5 = arguments.length, fields = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { + fields[_key5] = arguments[_key5]; + } + + this.terms.push(['$without', fields]); + return this; + } + }, { + key: 'group', + value: function group(field) { + this.terms.push(['$group', field]); + return this; + } + }, { + key: 'count', + value: function count() { + this.terms.push(['$count']); + return this; + } + }, { + key: 'sum', + value: function sum(field) { + this.terms.push(['$sum', field]); + return this; + } + }, { + key: 'avg', + value: function avg(field) { + this.terms.push(['$avg', field]); + return this; + } + }, { + key: 'min', + value: function min(field) { + this.terms.push(['$min', field]); + return this; + } + }, { + key: 'max', + value: function max(field) { + this.terms.push(['$max', field]); + return this; + } + }, { + key: 'between', + value: function between(start, end, index) { + var value = index ? [start, end, index] : [start, end]; + this.terms.push(['$between', value]); + return this; + } + }, { + key: 'getIntersecting', + value: function getIntersecting(geometry, index) { + this.terms.push(['$get_intersecting', [index, geometry]]); + return this; + } + }, { + key: 'getNearest', + value: function getNearest(geometry, index) { + this.terms.push(['$get_nearest', [index, geometry]]); + return this; + } + }]); + return Query; +}(); + +exports.default = Query; \ No newline at end of file diff --git a/dist/scripting.js b/dist/scripting.js new file mode 100644 index 0000000..6163117 --- /dev/null +++ b/dist/scripting.js @@ -0,0 +1,49 @@ +'use strict'; + +var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); + +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + +var _createClass2 = require('babel-runtime/helpers/createClass'); + +var _createClass3 = _interopRequireDefault(_createClass2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var Script = function () { + function Script(name) { + (0, _classCallCheck3.default)(this, Script); + + this.name = name; + } + + (0, _createClass3.default)(Script, [{ + key: 'toJS', + value: function toJS() { + return { + $type: 'script', + $name: this.name + }; + } + }]); + return Script; +}(); + +var RunLua = function () { + function RunLua(code) { + (0, _classCallCheck3.default)(this, RunLua); + + this.code = code; + } + + (0, _createClass3.default)(RunLua, [{ + key: 'toJS', + value: function toJS() { + return { + $type: 'lua', + $code: this.code + }; + } + }]); + return RunLua; +}(); \ No newline at end of file diff --git a/package.json b/package.json index b3f1505..987506f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "montagedata", "version": "2.1.0", - "main": "dist/montage.js", + "main": "dist/index.js", "description": "Client library for Montage Data", "scripts": { "test": "gulp test" From 45baa147049027e01e7652bf801b906afc87339c Mon Sep 17 00:00:00 2001 From: Jason Kraus Date: Tue, 20 Sep 2016 14:32:53 -0700 Subject: [PATCH 59/60] babel-polyfill is a runtime requirement --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 987506f..127d596 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ }, "dependencies": { "babel-runtime": "^6.6.1", + "babel-polyfill": "^6.9.1", "isomorphic-fetch": "^2.1.0", "lodash": "3.10.0" }, @@ -22,7 +23,6 @@ "babel-core": "^6.7.2", "babel-loader": "^6.2.4", "babel-plugin-transform-runtime": "^6.6.0", - "babel-polyfill": "^6.9.1", "babel-preset-es2015": "^6.6.0", "expect.js": "~0.3.1", "form-data": "^1.0.0-rc3", From 694be36341650db1895a56cba708e92761d44710 Mon Sep 17 00:00:00 2001 From: Allen Mills Date: Fri, 14 Oct 2016 14:33:01 -0700 Subject: [PATCH 60/60] feat: add index.d.ts to dist/ for ts typings --- dist/index.d.ts | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 60 insertions(+) create mode 100644 dist/index.d.ts diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..3361c95 --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,59 @@ +declare module 'montagedata' { + /** Declaration file generated by dts-gen */ + + export class Client { + constructor(project: any, token?: any); + authenticate(email: any, password: any): any; + execute(queries: any): any; + request(endpoint: any, method: any, data: any, file: any): any; + url(endpoint: any): any; + user(): any; + documents: any; + } + export class Field { + constructor(field: any); + contains(value: any): any; + ends(value: any): any; + eq(value: any): any; + ge(value: any): any; + gt(value: any): any; + iends(value: any): any; + ieq(value: any): any; + inSet(...args: any[]): any; + includes(value: any): any; + intersects(value: any): any; + istarts(value: any): any; + le(value: any): any; + lt(value: any): any; + ne(value: any): any; + regex(expression: any): any; + starts(value: any): any; + toJS(): any; + } + export class Query { + constructor(schema: any); + avg(field: any): any; + between(start: any, end: any, index: any): any; + count(): any; + filter(...args: any[]): any; + get(id: any): any; + getAll(ids: any, ...args: any[]): any; + getIntersecting(geometry: any, index: any): any; + getNearest(geometry: any, index: any): any; + group(field: any): any; + hasFields(...args: any[]): any; + limit(num: any): any; + max(field: any): any; + min(field: any): any; + nth(num: any): any; + orderBy(field: any, ordering?: any): any; + pluck(...args: any[]): any; + sample(num: any): any; + skip(num: any): any; + slice(start: any, end: any): any; + sum(field: any): any; + toJS(): any; + withFields(...args: any[]): any; + without(...args: any[]): any; + } +} diff --git a/package.json b/package.json index 127d596..1e26489 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "montagedata", "version": "2.1.0", "main": "dist/index.js", + "types": "dist/index.d.ts", "description": "Client library for Montage Data", "scripts": { "test": "gulp test"