diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..fe24f1c90 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,14 @@ +# Ignore files to be uploaded to the image +.env +.env.dev +.env.prod +.git +.gitignore +Dockerfile +Dockerfile.prod +README.md +CODE_OF_CONDUCT.md +CONTRIBUTING.md + +/coverage +/.nyc_output diff --git a/.env.local b/.env.local new file mode 100644 index 000000000..fb69d8efa --- /dev/null +++ b/.env.local @@ -0,0 +1,21 @@ +NODE_ENV=production +PORT=4004 + +# LOG_LEVEL=info + +MONGO_URL=mongodb://mongo/saweb + +GATEWAY_ENDPOINT=http://master-app-api:4100/graphql +PRESHARED_GATEWAY_KEY=saweb_key + +# The NODE_ENDPOINT is used at team creation and is where other components will search for the team +NODE_ENDPOINT=http://docker.for.win.localhost:4100/ + +# Storage Configuration +STORAGE_PROVIDER=Minio +# Minio +MINIO_END_POINT=minio +MINIO_PORT=9000 +MINIO_USE_SSL=false +MINIO_ACCESS_KEY=minio +MINIO_SECRET_KEY=minio123 diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..d67bde39e --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +# Logs +logs +*.log +npm-debug.log* + +# Dependency directories +/node_modules + +# Optional npm cache directory +.npm + +# dotenv environment variables file +.env + +# Build folder js files +build/ +dist/ + +# Visual Studio Code +.vscode + +#Mac specific files +.DS_Store diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..4b37b0e16 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,46 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team using the online form in the contacts page of the superalgos.org website. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..1d1736260 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,9 @@ +# Contributing + +We are thrilled you are interested in contributing to this repository. Your help may be essential to the project's success and we want you in! + +Superalgos is a collective project, currently at a very early stage. We not only welcome contributions but may even choose to incentivize relevant contributions via the project's native crypto token. + +Please read the [Join the Dev Team]( https://superalgos.org/developers-join-dev-team.shtml) page in our website to learn more about how you may become a relevant member of the Community and even make a living out of contributing code to the project. + +Contributions are deemed _voluntary work_, irrespective of the incentives that may be in place, and are subject to the conditions described in the LICENSE \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..f034cb7a6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM mhart/alpine-node:12 + +# Directory where the service will be installed +ARG API_DIR=/usr/src/saweb-api + +# Prepare required directories +RUN mkdir -p ${API_DIR} + +# Use app directory as current workdir +WORKDIR ${API_DIR} + +# Copy package.json to workdir +COPY . ${API_DIR}/ + +# Install dependencies +RUN npm install --production + +# Expose Port +EXPOSE $PORT diff --git a/Dockerfile.prod b/Dockerfile.prod new file mode 100644 index 000000000..1b6cc3770 --- /dev/null +++ b/Dockerfile.prod @@ -0,0 +1,21 @@ +FROM mhart/alpine-node:8 + +ENV PORT=4004 + +RUN mkdir -p /var/www/app && \ + mkdir -p /var/www/app/node_modules + +# Use app directory as current workdir +WORKDIR /var/www/app +ENV PATH /var/www/app/node_modules/.bin:$PATH +# Copy package.json to workdir +COPY package.json /var/www/app/package.json + +# Install dependencies +RUN npm install + +# Copy application code +COPY . /var/www/app + +# Expose Port +EXPOSE $PORT diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 000000000..92be9c77b --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# saweb-api \ No newline at end of file diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 000000000..7ec7ba765 --- /dev/null +++ b/docker-compose.prod.yml @@ -0,0 +1,24 @@ +version: '3' +services: + node: + image: saweb-api:v1 + build: + context: . + dockerfile: ./Dockerfile.prod + env_file: ./.env + container_name: saweb-api + tty: true + stdin_open: true + volumes: + - ./:/var/www/app + - /var/www/app/node_modules + working_dir: /var/www/app + restart: always + command: node . + expose: + - 4004 + network_mode: webproxy +networks: + default: + external: + name: webproxy diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..689905ac4 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,3295 @@ +{ + "name": "saweb-api", + "version": "0.1.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@apollographql/apollo-tools": { + "version": "0.3.7", + "resolved": "https://registry.npmjs.org/@apollographql/apollo-tools/-/apollo-tools-0.3.7.tgz", + "integrity": "sha512-+ertvzAwzkYmuUtT8zH3Zi6jPdyxZwOgnYaZHY7iLnMVJDhQKWlkyjLMF8wyzlPiEdDImVUMm5lOIBZo7LkGlg==", + "requires": { + "apollo-env": "0.5.1" + } + }, + "@apollographql/apollo-upload-server": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/@apollographql/apollo-upload-server/-/apollo-upload-server-5.0.3.tgz", + "integrity": "sha512-tGAp3ULNyoA8b5o9LsU2Lq6SwgVPUOKAqKywu2liEtTvrFSGPrObwanhYwArq3GPeOqp2bi+JknSJCIU3oQN1Q==", + "requires": { + "@babel/runtime-corejs2": "^7.0.0-rc.1", + "busboy": "^0.2.14", + "object-path": "^0.11.4" + } + }, + "@apollographql/graphql-playground-html": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/@apollographql/graphql-playground-html/-/graphql-playground-html-1.6.18.tgz", + "integrity": "sha512-7HGC1hQ0Aj93z2kv8h4RBtYClkiccj+F2Juh1m74Pky7D9tJDsQ4eBlaNNn0jMxGAL6EuaGwBN46EA9JtBMRog==" + }, + "@azure/ms-rest-js": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@azure/ms-rest-js/-/ms-rest-js-1.2.3.tgz", + "integrity": "sha512-eROQ034b+9v0Hd3wETKi/EwF5pqS3VRAk1Lm8iKVPOP8v30f6Zfzsi420MRfBMsbNCx/mE2N0L65Px7tvcGfVg==", + "requires": { + "axios": "^0.18.0", + "form-data": "^2.3.2", + "tough-cookie": "^2.4.3", + "tslib": "^1.9.2", + "uuid": "^3.2.1", + "xml2js": "^0.4.19" + }, + "dependencies": { + "axios": { + "version": "0.18.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.18.1.tgz", + "integrity": "sha512-0BfJq4NSfQXd+SkFdrvFbG7addhYSBA2mQwISr46pD6E5iqkWg02RAs8vyTT/j0RTnoYmeXauBuSv1qKwR179g==", + "requires": { + "follow-redirects": "1.5.10", + "is-buffer": "^2.0.2" + } + } + } + }, + "@azure/storage-blob": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/@azure/storage-blob/-/storage-blob-10.3.0.tgz", + "integrity": "sha512-KZbJ3q8RpAdeIB5Em1lgXkiq7Mll9bSHHbHavOFMepkkF7HQa3Sez9FdkAVIkVVWK5YoBlshBGZ+mtiSQiS9Fw==", + "requires": { + "@azure/ms-rest-js": "1.2.3", + "events": "3.0.0", + "tslib": "^1.9.3" + } + }, + "@babel/runtime-corejs2": { + "version": "7.4.5", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs2/-/runtime-corejs2-7.4.5.tgz", + "integrity": "sha512-5yLuwzvIDecKwYMzJtiarky4Fb5643H3Ao5jwX0HrMR5oM5mn2iHH9wSZonxwNK0oAjAFUQAiOd4jT7/9Y2jMQ==", + "requires": { + "core-js": "^2.6.5", + "regenerator-runtime": "^0.13.2" + } + }, + "@protobufjs/aspromise": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", + "integrity": "sha1-m4sMxmPWaafY9vXQiToU00jzD78=" + }, + "@protobufjs/base64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz", + "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==" + }, + "@protobufjs/codegen": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz", + "integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==" + }, + "@protobufjs/eventemitter": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz", + "integrity": "sha1-NVy8mLr61ZePntCV85diHx0Ga3A=" + }, + "@protobufjs/fetch": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz", + "integrity": "sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU=", + "requires": { + "@protobufjs/aspromise": "^1.1.1", + "@protobufjs/inquire": "^1.1.0" + } + }, + "@protobufjs/float": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz", + "integrity": "sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E=" + }, + "@protobufjs/inquire": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz", + "integrity": "sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik=" + }, + "@protobufjs/path": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz", + "integrity": "sha1-bMKyDFya1q0NzP0hynZz2Nf79o0=" + }, + "@protobufjs/pool": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz", + "integrity": "sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q=" + }, + "@protobufjs/utf8": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", + "integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=" + }, + "@types/accepts": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/@types/accepts/-/accepts-1.3.5.tgz", + "integrity": "sha512-jOdnI/3qTpHABjM5cx1Hc0sKsPoYCp+DP/GJRGtDlPd7fiV9oXGGIcjW/ZOxLIvjGz8MA+uMZI9metHlgqbgwQ==", + "requires": { + "@types/node": "*" + } + }, + "@types/body-parser": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.0.tgz", + "integrity": "sha512-a2+YeUjPkztKJu5aIF2yArYFQQp8d51wZ7DavSHjFuY1mqVgidGyzEQ41JIVNy82fXj8yPgy2vJmfIywgESW6w==", + "requires": { + "@types/connect": "*", + "@types/node": "*" + } + }, + "@types/connect": { + "version": "3.4.32", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.32.tgz", + "integrity": "sha512-4r8qa0quOvh7lGD0pre62CAb1oni1OO6ecJLGCezTmhQ8Fz50Arx9RUszryR8KlgK6avuSXvviL6yWyViQABOg==", + "requires": { + "@types/node": "*" + } + }, + "@types/cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-GmK8AKu8i+s+EChK/uZ5IbrXPcPaQKWaNSGevDT/7o3gFObwSUQwqb1jMqxuo+YPvj0ckGzINI+EO7EHcmJjKg==", + "requires": { + "@types/express": "*" + } + }, + "@types/events": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz", + "integrity": "sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==" + }, + "@types/express": { + "version": "4.16.0", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.16.0.tgz", + "integrity": "sha512-TtPEYumsmSTtTetAPXlJVf3kEqb6wZK0bZojpJQrnD/djV4q1oB6QQ8aKvKqwNPACoe02GNiy5zDzcYivR5Z2w==", + "requires": { + "@types/body-parser": "*", + "@types/express-serve-static-core": "*", + "@types/serve-static": "*" + } + }, + "@types/express-serve-static-core": { + "version": "4.16.5", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.16.5.tgz", + "integrity": "sha512-T8oej2B9TVALoCK4epWXRNWaFaqDyOaEQ3ntph+tSw5QoKnZfxgCXefIm3+nGp2XCRrkX4X7U5CSTMnwKJcOjQ==", + "requires": { + "@types/node": "*", + "@types/range-parser": "*" + } + }, + "@types/long": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.0.tgz", + "integrity": "sha512-1w52Nyx4Gq47uuu0EVcsHBxZFJgurQ+rTKS3qMHxR1GY2T8c2AJYd6vZoZ9q1rupaDjU0yT+Jc2XTyXkjeMA+Q==" + }, + "@types/mime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@types/mime/-/mime-2.0.1.tgz", + "integrity": "sha512-FwI9gX75FgVBJ7ywgnq/P7tw+/o1GUbtP0KzbtusLigAOgIgNISRK0ZPl4qertvXSIE8YbsVJueQ90cDt9YYyw==" + }, + "@types/node": { + "version": "12.0.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.2.tgz", + "integrity": "sha512-5tabW/i+9mhrfEOUcLDu2xBPsHJ+X5Orqy9FKpale3SjDA17j5AEpYq5vfy3oAeAHGcvANRCO3NV3d2D6q3NiA==" + }, + "@types/range-parser": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.3.tgz", + "integrity": "sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA==" + }, + "@types/serve-static": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.2.tgz", + "integrity": "sha512-/BZ4QRLpH/bNYgZgwhKEh+5AsboDBcUdlBYgzoLX0fpj3Y2gp6EApyOlM3bK53wQS/OE1SrdSYBAbux2D1528Q==", + "requires": { + "@types/express-serve-static-core": "*", + "@types/mime": "*" + } + }, + "@types/ws": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-6.0.1.tgz", + "integrity": "sha512-EzH8k1gyZ4xih/MaZTXwT2xOkPiIMSrhQ9b8wrlX88L0T02eYsddatQlwVFlEPyEqV0ChpdpNnE51QPH6NVT4Q==", + "requires": { + "@types/events": "*", + "@types/node": "*" + } + }, + "accepts": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", + "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", + "requires": { + "mime-types": "~2.1.24", + "negotiator": "0.6.2" + } + }, + "ajv": { + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", + "integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==", + "requires": { + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ansi-colors": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.3.tgz", + "integrity": "sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw==", + "dev": true + }, + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "apollo-cache-control": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/apollo-cache-control/-/apollo-cache-control-0.6.0.tgz", + "integrity": "sha512-66aCF6MHe0/FdD3knphwTv6CCIdb1ZxrMsiRpxP474qqyYVe2jAwBu6aJBn4emffZHZ7i6gp9dY6cPHThjnbKA==", + "requires": { + "apollo-server-env": "2.3.0", + "graphql-extensions": "0.6.0" + } + }, + "apollo-datasource": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/apollo-datasource/-/apollo-datasource-0.4.0.tgz", + "integrity": "sha512-6QkgnLYwQrW0qv+yXIf617DojJbGmza2XJXUlgnzrGGhxzfAynzEjaLyYkc8rYS1m82vjrl9EOmLHTcnVkvZAQ==", + "requires": { + "apollo-server-caching": "0.4.0", + "apollo-server-env": "2.3.0" + } + }, + "apollo-engine-reporting": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/apollo-engine-reporting/-/apollo-engine-reporting-1.1.0.tgz", + "integrity": "sha512-Dj0BwgcluHL0QVUaquhAoYoLX9Z4DRP/n2REcIwO8d2iy52r+1wN5QqZLx97dEFh7CjhNjTWeysJzc8XMWKa1Q==", + "requires": { + "apollo-engine-reporting-protobuf": "0.3.0", + "apollo-graphql": "^0.2.1-alpha.1", + "apollo-server-core": "2.5.0", + "apollo-server-env": "2.3.0", + "async-retry": "^1.2.1", + "graphql-extensions": "0.6.0" + } + }, + "apollo-engine-reporting-protobuf": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/apollo-engine-reporting-protobuf/-/apollo-engine-reporting-protobuf-0.3.0.tgz", + "integrity": "sha512-PYowpx/E+TJT/8nKpp3JmJuKh3x1SZcxDF6Cquj0soV205TUpFFCZQMi91i5ACiEp2AkYvM/GDBIrw+rfIwzTg==", + "requires": { + "protobufjs": "^6.8.6" + } + }, + "apollo-env": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/apollo-env/-/apollo-env-0.5.1.tgz", + "integrity": "sha512-fndST2xojgSdH02k5hxk1cbqA9Ti8RX4YzzBoAB4oIe1Puhq7+YlhXGXfXB5Y4XN0al8dLg+5nAkyjNAR2qZTw==", + "requires": { + "core-js": "^3.0.1", + "node-fetch": "^2.2.0", + "sha.js": "^2.4.11" + }, + "dependencies": { + "core-js": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.1.2.tgz", + "integrity": "sha512-3poRGjbu56leCtZCZCzCgQ7GcKOflDFnjWIepaPFUsM0IXUBrne10sl3aa2Bkcz3+FjRdIxBe9dAMhIJmEnQNA==" + } + } + }, + "apollo-graphql": { + "version": "0.2.1-register.1", + "resolved": "https://registry.npmjs.org/apollo-graphql/-/apollo-graphql-0.2.1-register.1.tgz", + "integrity": "sha512-Z2LOuvYomC9CN9K+mpFVcVQu6Ml5PIJlV+YOkGzFq73xeqWg1InxHqI3eEdCEhxTJq6H8rlWT8ATrMS+4sIhqw==", + "requires": { + "apollo-env": "0.4.1-register.1", + "lodash.sortby": "^4.7.0" + }, + "dependencies": { + "apollo-env": { + "version": "0.4.1-register.1", + "resolved": "https://registry.npmjs.org/apollo-env/-/apollo-env-0.4.1-register.1.tgz", + "integrity": "sha512-fg1US7YZ6yW1N0tFq8g4HpCR3eJZmI+rIiHDiknYN9D1MTjvwYdmXYhi7VaPvQ21hV5nMRvfBUMqYXjP+6FsGQ==", + "requires": { + "core-js": "3.0.0-beta.13", + "node-fetch": "^2.2.0", + "sha.js": "^2.4.11" + } + }, + "core-js": { + "version": "3.0.0-beta.13", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.0.0-beta.13.tgz", + "integrity": "sha512-16Q43c/3LT9NyePUJKL8nRIQgYWjcBhjJSMWg96PVSxoS0PeE0NHitPI3opBrs9MGGHjte1KoEVr9W63YKlTXQ==" + } + } + }, + "apollo-link": { + "version": "1.2.11", + "resolved": "https://registry.npmjs.org/apollo-link/-/apollo-link-1.2.11.tgz", + "integrity": "sha512-PQvRCg13VduLy3X/0L79M6uOpTh5iHdxnxYuo8yL7sJlWybKRJwsv4IcRBJpMFbChOOaHY7Og9wgPo6DLKDKDA==", + "requires": { + "apollo-utilities": "^1.2.1", + "ts-invariant": "^0.3.2", + "tslib": "^1.9.3", + "zen-observable-ts": "^0.8.18" + } + }, + "apollo-server-caching": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/apollo-server-caching/-/apollo-server-caching-0.4.0.tgz", + "integrity": "sha512-GTOZdbLhrSOKYNWMYgaqX5cVNSMT0bGUTZKV8/tYlyYmsB6ey7l6iId3Q7UpHS6F6OR2lstz5XaKZ+T3fDfPzQ==", + "requires": { + "lru-cache": "^5.0.0" + } + }, + "apollo-server-core": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/apollo-server-core/-/apollo-server-core-2.5.0.tgz", + "integrity": "sha512-7hyQ/Rt0hC38bUfxMQmLNHDBIGEBykFWo9EO0W+3o/cno/SqBKd1KKichrABVv+v+SCvZAUutX6gYS5l3G+ULQ==", + "requires": { + "@apollographql/apollo-tools": "^0.3.6-alpha.1", + "@apollographql/graphql-playground-html": "^1.6.6", + "@types/ws": "^6.0.0", + "apollo-cache-control": "0.6.0", + "apollo-datasource": "0.4.0", + "apollo-engine-reporting": "1.1.0", + "apollo-server-caching": "0.4.0", + "apollo-server-env": "2.3.0", + "apollo-server-errors": "2.3.0", + "apollo-server-plugin-base": "0.4.0", + "apollo-tracing": "0.6.0", + "fast-json-stable-stringify": "^2.0.0", + "graphql-extensions": "0.6.0", + "graphql-subscriptions": "^1.0.0", + "graphql-tag": "^2.9.2", + "graphql-tools": "^4.0.0", + "graphql-upload": "^8.0.2", + "sha.js": "^2.4.11", + "subscriptions-transport-ws": "^0.9.11", + "ws": "^6.0.0" + }, + "dependencies": { + "graphql-subscriptions": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/graphql-subscriptions/-/graphql-subscriptions-1.1.0.tgz", + "integrity": "sha512-6WzlBFC0lWmXJbIVE8OgFgXIP4RJi3OQgTPa0DVMsDXdpRDjTsM1K9wfl5HSYX7R87QAGlvcv2Y4BIZa/ItonA==", + "requires": { + "iterall": "^1.2.1" + } + }, + "graphql-tools": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/graphql-tools/-/graphql-tools-4.0.4.tgz", + "integrity": "sha512-chF12etTIGVVGy3fCTJ1ivJX2KB7OSG4c6UOJQuqOHCmBQwTyNgCDuejZKvpYxNZiEx7bwIjrodDgDe9RIkjlw==", + "requires": { + "apollo-link": "^1.2.3", + "apollo-utilities": "^1.0.1", + "deprecated-decorator": "^0.1.6", + "iterall": "^1.1.3", + "uuid": "^3.1.0" + } + } + } + }, + "apollo-server-env": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/apollo-server-env/-/apollo-server-env-2.3.0.tgz", + "integrity": "sha512-WIwlkCM/gir0CkoYWPMTCH8uGCCKB/aM074U1bKayvkFOBVO2VgG5x2kgsfkyF05IMQq2/GOTsKhNY7RnUEhTA==", + "requires": { + "node-fetch": "^2.1.2", + "util.promisify": "^1.0.0" + } + }, + "apollo-server-errors": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/apollo-server-errors/-/apollo-server-errors-2.3.0.tgz", + "integrity": "sha512-rUvzwMo2ZQgzzPh2kcJyfbRSfVKRMhfIlhY7BzUfM4x6ZT0aijlgsf714Ll3Mbf5Fxii32kD0A/DmKsTecpccw==" + }, + "apollo-server-express": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/apollo-server-express/-/apollo-server-express-2.1.0.tgz", + "integrity": "sha512-jLFIz1VLduMA/rme4OAy3IPeoaMEZOPoQXpio8AhfjIqCijRPPfoWJ2QMqz56C/g3vas7rZtgcVOrHpjBKudjw==", + "requires": { + "@apollographql/apollo-upload-server": "^5.0.3", + "@apollographql/graphql-playground-html": "^1.6.0", + "@types/accepts": "^1.3.5", + "@types/body-parser": "1.17.0", + "@types/cors": "^2.8.4", + "@types/express": "4.16.0", + "accepts": "^1.3.5", + "apollo-server-core": "^2.1.0", + "body-parser": "^1.18.3", + "cors": "^2.8.4", + "graphql-subscriptions": "^0.5.8", + "graphql-tools": "^3.0.4", + "type-is": "^1.6.16" + } + }, + "apollo-server-plugin-base": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/apollo-server-plugin-base/-/apollo-server-plugin-base-0.4.0.tgz", + "integrity": "sha512-iD7ARNtwnvHGd1EMPK0CuodM8d8hgDvFwTfIDzJY04QIQ6/KrBFaWhnCXJsy+HMb47GovwBbq67IK6eb2WJgBg==" + }, + "apollo-tracing": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/apollo-tracing/-/apollo-tracing-0.6.0.tgz", + "integrity": "sha512-OpYPHVBgcQ/HT2WLXJQWwhilzR1rrl01tZeMU2N7yinsp/oyKngF5aUSMtuvX1k/T3abilQo+w10oAQlBCGdPA==", + "requires": { + "apollo-server-env": "2.3.0", + "graphql-extensions": "0.6.0" + } + }, + "apollo-utilities": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/apollo-utilities/-/apollo-utilities-1.3.0.tgz", + "integrity": "sha512-wQjV+FdWcTWmWUFlChG5rS0vHKy5OsXC6XlV9STRstQq6VbXANwHy6DHnTEQAfLXWAbNcPgBu+nBUpR3dFhwrA==", + "requires": { + "fast-json-stable-stringify": "^2.0.0", + "ts-invariant": "^0.4.0", + "tslib": "^1.9.3" + }, + "dependencies": { + "ts-invariant": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/ts-invariant/-/ts-invariant-0.4.2.tgz", + "integrity": "sha512-PTAAn8lJPEdRBJJEs4ig6MVZWfO12yrFzV7YaPslmyhG7+4MA279y4BXT3f72gXeVl0mC1aAWq2rMX4eKTWU/Q==", + "requires": { + "tslib": "^1.9.3" + } + } + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, + "asn1": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "requires": { + "safer-buffer": "~2.1.0" + } + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + }, + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true + }, + "async": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz", + "integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==", + "requires": { + "lodash": "^4.17.10" + } + }, + "async-limiter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", + "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==" + }, + "async-retry": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/async-retry/-/async-retry-1.2.3.tgz", + "integrity": "sha512-tfDb02Th6CE6pJUF2gjW5ZVjsgwlucVXOEQMvEX9JgSJMs9gAX+Nz3xRuJBKuUYjTSYORqvDBORdAQ3LU59g7Q==", + "requires": { + "retry": "0.12.0" + } + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" + }, + "aws4": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", + "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" + }, + "axios": { + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz", + "integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==", + "requires": { + "follow-redirects": "1.5.10", + "is-buffer": "^2.0.2" + } + }, + "azure-storage": { + "version": "2.10.3", + "resolved": "https://registry.npmjs.org/azure-storage/-/azure-storage-2.10.3.tgz", + "integrity": "sha512-IGLs5Xj6kO8Ii90KerQrrwuJKexLgSwYC4oLWmc11mzKe7Jt2E5IVg+ZQ8K53YWZACtVTMBNO3iGuA+4ipjJxQ==", + "requires": { + "browserify-mime": "~1.2.9", + "extend": "^3.0.2", + "json-edm-parser": "0.1.2", + "md5.js": "1.3.4", + "readable-stream": "~2.0.0", + "request": "^2.86.0", + "underscore": "~1.8.3", + "uuid": "^3.0.0", + "validator": "~9.4.1", + "xml2js": "0.2.8", + "xmlbuilder": "^9.0.7" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" + }, + "readable-stream": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", + "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "~1.0.0", + "process-nextick-args": "~1.0.6", + "string_decoder": "~0.10.x", + "util-deprecate": "~1.0.1" + } + }, + "sax": { + "version": "0.5.8", + "resolved": "https://registry.npmjs.org/sax/-/sax-0.5.8.tgz", + "integrity": "sha1-1HLbIo6zMcJQaw6MFVJK25OdEsE=" + }, + "xml2js": { + "version": "0.2.8", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.2.8.tgz", + "integrity": "sha1-m4FpCTFjH/CdGVdUn69U9PmAs8I=", + "requires": { + "sax": "0.5.x" + } + } + } + }, + "backo2": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", + "integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc=" + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "requires": { + "tweetnacl": "^0.14.3" + } + }, + "block-stream2": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/block-stream2/-/block-stream2-1.1.0.tgz", + "integrity": "sha1-xzjjqRupd+u14f70MeE8oR2GOeI=", + "requires": { + "defined": "^1.0.0", + "inherits": "^2.0.1", + "readable-stream": "^2.0.4" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "bluebird": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", + "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==" + }, + "body-parser": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", + "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", + "requires": { + "bytes": "3.1.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "on-finished": "~2.3.0", + "qs": "6.7.0", + "raw-body": "2.4.0", + "type-is": "~1.6.17" + } + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "browserify-mime": { + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/browserify-mime/-/browserify-mime-1.2.9.tgz", + "integrity": "sha1-rrGvKN5sDXpqLOQK22j/GEIq8x8=" + }, + "bson": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/bson/-/bson-1.0.9.tgz", + "integrity": "sha512-IQX9/h7WdMBIW/q/++tGd+emQr0XMdeZ6icnT/74Xk9fnabWn+gZgpE+9V+gujL3hhJOoNrnDVY7tWdzc7NUTg==" + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" + }, + "busboy": { + "version": "0.2.14", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-0.2.14.tgz", + "integrity": "sha1-bCpiLvz0fFe7vh4qnDetNseSVFM=", + "requires": { + "dicer": "0.2.5", + "readable-stream": "1.1.x" + } + }, + "bytes": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", + "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" + }, + "chai": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", + "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", + "dev": true, + "requires": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", + "get-func-name": "^2.0.0", + "pathval": "^1.1.0", + "type-detect": "^4.0.5" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "dependencies": { + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "dev": true + }, + "cliui": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz", + "integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==", + "dev": true, + "requires": { + "string-width": "^2.1.1", + "strip-ansi": "^4.0.0", + "wrap-ansi": "^2.0.0" + } + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "dev": true + }, + "color": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/color/-/color-3.0.0.tgz", + "integrity": "sha512-jCpd5+s0s0t7p3pHQKpnJ0TpQKKdleP71LWcA0aqiljpiuAkOSUFN/dyH8ZwF0hRmFlrIuRhufds1QyEP9EB+w==", + "requires": { + "color-convert": "^1.9.1", + "color-string": "^1.5.2" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "color-string": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.5.3.tgz", + "integrity": "sha512-dC2C5qeWoYkxki5UAXapdjqO672AM4vZuPGRQfO8b5HKuKGBbKWpITyDYN7TOFKvRW7kOgAn3746clDBMDJyQw==", + "requires": { + "color-name": "^1.0.0", + "simple-swizzle": "^0.2.2" + } + }, + "colornames": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/colornames/-/colornames-1.1.1.tgz", + "integrity": "sha1-+IiQMGhcfE/54qVZ9Qd+t2qBb5Y=" + }, + "colors": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.3.3.tgz", + "integrity": "sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg==" + }, + "colorspace": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/colorspace/-/colorspace-1.1.2.tgz", + "integrity": "sha512-vt+OoIP2d76xLhjwbBaucYlNSpPsrJWPlBTtwCpQKIu6/CSMutyzX93O/Do0qzpH3YoHEes8YEFXyZ797rEhzQ==", + "requires": { + "color": "3.0.x", + "text-hex": "1.0.x" + } + }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "content-disposition": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + }, + "cookie": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, + "core-js": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.8.tgz", + "integrity": "sha512-RWlREFU74TEkdXzyl1bka66O3kYp8jeTXrvJZDzVVMH8AiHUSOFpL1yfhQJ+wHocAm1m+4971W1PPzfLuCv1vg==" + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "requires": { + "object-assign": "^4", + "vary": "^1" + } + }, + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "dev": true, + "requires": { + "type-detect": "^4.0.0" + } + }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "requires": { + "object-keys": "^1.0.12" + } + }, + "defined": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", + "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=" + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + }, + "deprecated-decorator": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/deprecated-decorator/-/deprecated-decorator-0.1.6.tgz", + "integrity": "sha1-AJZjF7ehL+kvPMgx91g68ym4bDc=" + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, + "diagnostics": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/diagnostics/-/diagnostics-1.1.1.tgz", + "integrity": "sha512-8wn1PmdunLJ9Tqbx+Fx/ZEuHfJf4NKSN2ZBj7SJC/OWRWha843+WsTjqMe1B5E3p28jqBlp+mJ2fPVxPyNgYKQ==", + "requires": { + "colorspace": "1.1.x", + "enabled": "1.0.x", + "kuler": "1.0.x" + } + }, + "dicer": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.2.5.tgz", + "integrity": "sha1-WZbAhrszIYyBLAkL3cCc0S+stw8=", + "requires": { + "readable-stream": "1.1.x", + "streamsearch": "0.1.2" + } + }, + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + }, + "dotenv": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.0.0.tgz", + "integrity": "sha512-30xVGqjLjiUOArT4+M5q9sYdvuR4riM6yK9wMcas9Vbp6zZa+ocC9dp6QoftuhTPhFAiLK/0C5Ni2nou/Bk8lg==" + }, + "double-ended-queue": { + "version": "2.1.0-0", + "resolved": "https://registry.npmjs.org/double-ended-queue/-/double-ended-queue-2.1.0-0.tgz", + "integrity": "sha1-ED01J/0xUo9AGIEwyEHv3XgmTlw=" + }, + "ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "requires": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "enabled": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/enabled/-/enabled-1.0.2.tgz", + "integrity": "sha1-ll9lE9LC0cX0ZStkouM5ZGf8L5M=", + "requires": { + "env-variable": "0.0.x" + } + }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" + }, + "end-of-stream": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", + "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", + "dev": true, + "requires": { + "once": "^1.4.0" + } + }, + "env-variable": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/env-variable/-/env-variable-0.0.5.tgz", + "integrity": "sha512-zoB603vQReOFvTg5xMl9I1P2PnHsHQQKTEowsKKD7nseUfJq6UWzK+4YtlWUO1nhiQUxe6XMkk+JleSZD1NZFA==" + }, + "es-abstract": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz", + "integrity": "sha512-vDZfg/ykNxQVwup/8E1BZhVzFfBxs9NqMzGcvIJrqg5k2/5Za2bWo40dK2J1pgLngZ7c+Shh8lwYtLGyrwPutg==", + "requires": { + "es-to-primitive": "^1.2.0", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "is-callable": "^1.1.4", + "is-regex": "^1.0.4", + "object-keys": "^1.0.12" + } + }, + "es-to-primitive": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", + "integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==", + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "es6-error": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-2.1.1.tgz", + "integrity": "sha1-kThDAexe0cmnJH0RKCRyFvA1R80=" + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "esm": { + "version": "3.2.25", + "resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz", + "integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==" + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + }, + "eventemitter3": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.2.tgz", + "integrity": "sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q==" + }, + "events": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.0.0.tgz", + "integrity": "sha512-Dc381HFWJzEOhQ+d8pkNon++bk9h6cdAoAj4iE6Q4y6xgTzySWXlKn05/TVNpjnfRqi/X0EpJEJohPjNI3zpVA==" + }, + "execa": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", + "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", + "dev": true, + "requires": { + "cross-spawn": "^6.0.0", + "get-stream": "^4.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + } + }, + "express": { + "version": "4.16.3", + "resolved": "https://registry.npmjs.org/express/-/express-4.16.3.tgz", + "integrity": "sha1-avilAjUNsyRuzEvs9rWjTSL37VM=", + "requires": { + "accepts": "~1.3.5", + "array-flatten": "1.1.1", + "body-parser": "1.18.2", + "content-disposition": "0.5.2", + "content-type": "~1.0.4", + "cookie": "0.3.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.1.1", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.3", + "qs": "6.5.1", + "range-parser": "~1.2.0", + "safe-buffer": "5.1.1", + "send": "0.16.2", + "serve-static": "1.13.2", + "setprototypeof": "1.1.0", + "statuses": "~1.4.0", + "type-is": "~1.6.16", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "dependencies": { + "body-parser": { + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", + "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=", + "requires": { + "bytes": "3.0.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.1", + "http-errors": "~1.6.2", + "iconv-lite": "0.4.19", + "on-finished": "~2.3.0", + "qs": "6.5.1", + "raw-body": "2.3.2", + "type-is": "~1.6.15" + } + }, + "bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" + }, + "http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": ">= 1.4.0 < 2" + } + }, + "iconv-lite": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", + "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==" + }, + "qs": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" + }, + "raw-body": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", + "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=", + "requires": { + "bytes": "3.0.0", + "http-errors": "1.6.2", + "iconv-lite": "0.4.19", + "unpipe": "1.0.0" + }, + "dependencies": { + "depd": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", + "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=" + }, + "http-errors": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", + "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", + "requires": { + "depd": "1.1.1", + "inherits": "2.0.3", + "setprototypeof": "1.0.3", + "statuses": ">= 1.3.1 < 2" + } + }, + "setprototypeof": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", + "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" + } + } + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" + }, + "setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" + }, + "statuses": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", + "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" + } + } + }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" + }, + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" + }, + "fast-safe-stringify": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.6.tgz", + "integrity": "sha512-q8BZ89jjc+mz08rSxROs8VsrBBcn1SIw1kq9NjolL509tkABRk9io01RAjSaEv1Xb2uFLt8VtRiZbGp5H8iDtg==" + }, + "fecha": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fecha/-/fecha-2.3.3.tgz", + "integrity": "sha512-lUGBnIamTAwk4znq5BcqsDaxSmZ9nDVJaij6NvRt/Tg4R69gERA+otPKbS86ROw9nxVMw2/mp1fnaiWqbs6Sdg==" + }, + "finalhandler": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", + "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", + "requires": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "statuses": "~1.4.0", + "unpipe": "~1.0.0" + }, + "dependencies": { + "statuses": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", + "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" + } + } + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "flat": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz", + "integrity": "sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw==", + "dev": true, + "requires": { + "is-buffer": "~2.0.3" + }, + "dependencies": { + "is-buffer": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", + "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==", + "dev": true + } + } + }, + "follow-redirects": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", + "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", + "requires": { + "debug": "=3.1.0" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + } + } + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" + }, + "form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" + }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + }, + "fs-capacitor": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/fs-capacitor/-/fs-capacitor-2.0.4.tgz", + "integrity": "sha512-8S4f4WsCryNw2mJJchi46YgB6CR5Ze+4L1h8ewl9tEpL4SJ3ZO+c/bS4BWhB8bK+O3TMqhuZarTitd0S0eh2pA==" + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true + }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "dev": true + }, + "get-stream": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", + "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", + "dev": true, + "requires": { + "pump": "^3.0.0" + } + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graphql": { + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-0.13.2.tgz", + "integrity": "sha512-QZ5BL8ZO/B20VA8APauGBg3GyEgZ19eduvpLWoq5x7gMmWnHoy8rlQWPLmWgFvo1yNgjSEFMesmS4R6pPr7xog==", + "requires": { + "iterall": "^1.2.1" + } + }, + "graphql-extensions": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/graphql-extensions/-/graphql-extensions-0.6.0.tgz", + "integrity": "sha512-SshzmbD68fHXRv2q3St29olMOxHDLQ5e9TOh+Tz2BYxinrfhjFaPNcEefiK/vF295wW827Y58bdO11Xmhf8J+Q==", + "requires": { + "@apollographql/apollo-tools": "^0.3.6-alpha.1" + } + }, + "graphql-subscriptions": { + "version": "0.5.8", + "resolved": "https://registry.npmjs.org/graphql-subscriptions/-/graphql-subscriptions-0.5.8.tgz", + "integrity": "sha512-0CaZnXKBw2pwnIbvmVckby5Ge5e2ecmjofhYCdyeACbCly2j3WXDP/pl+s+Dqd2GQFC7y99NB+53jrt55CKxYQ==", + "requires": { + "iterall": "^1.2.1" + } + }, + "graphql-tag": { + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/graphql-tag/-/graphql-tag-2.10.1.tgz", + "integrity": "sha512-jApXqWBzNXQ8jYa/HLkZJaVw9jgwNqZkywa2zfFn16Iv1Zb7ELNHkJaXHR7Quvd5SIGsy6Ny7SUKATgnu05uEg==" + }, + "graphql-tools": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/graphql-tools/-/graphql-tools-3.1.1.tgz", + "integrity": "sha512-yHvPkweUB0+Q/GWH5wIG60bpt8CTwBklCSzQdEHmRUgAdEQKxw+9B7zB3dG7wB3Ym7M7lfrS4Ej+jtDZfA2UXg==", + "requires": { + "apollo-link": "^1.2.2", + "apollo-utilities": "^1.0.1", + "deprecated-decorator": "^0.1.6", + "iterall": "^1.1.3", + "uuid": "^3.1.0" + } + }, + "graphql-upload": { + "version": "8.0.6", + "resolved": "https://registry.npmjs.org/graphql-upload/-/graphql-upload-8.0.6.tgz", + "integrity": "sha512-cBRALMOvGBm2AD6M61b1QbSmKfCLXvgV+Z3wXT2JS1EQwGWQ1g5/sby4J/cpwAaGnq5P2eGp+N3HQI9cSn9Jfg==", + "requires": { + "busboy": "^0.3.1", + "fs-capacitor": "^2.0.1", + "http-errors": "^1.7.2", + "object-path": "^0.11.4" + }, + "dependencies": { + "busboy": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-0.3.1.tgz", + "integrity": "sha512-y7tTxhGKXcyBxRKAni+awqx8uqaJKrSFSNFSeRG5CsWNdmy2BIK+6VGWEW7TZnIO/533mtMEA4rOevQV815YJw==", + "requires": { + "dicer": "0.3.0" + } + }, + "dicer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.3.0.tgz", + "integrity": "sha512-MdceRRWqltEG2dZqO769g27N/3PXfcKl04VhYnBlo2YhH7zPi88VebsjTKclaOyiuMaGU72hTfw3VkUitGcVCA==", + "requires": { + "streamsearch": "0.1.2" + } + } + } + }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true + }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" + }, + "har-validator": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", + "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", + "requires": { + "ajv": "^6.5.5", + "har-schema": "^2.0.0" + } + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "has-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", + "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=" + }, + "hash-base": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", + "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", + "requires": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true + }, + "http-errors": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", + "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + } + }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "invert-kv": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz", + "integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==", + "dev": true + }, + "ipaddr.js": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz", + "integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==" + }, + "is-arrayish": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", + "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==" + }, + "is-buffer": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", + "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==" + }, + "is-callable": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", + "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==" + }, + "is-date-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", + "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=" + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "is-regex": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", + "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", + "requires": { + "has": "^1.0.1" + } + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" + }, + "is-symbol": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", + "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", + "requires": { + "has-symbols": "^1.0.0" + } + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + }, + "iterall": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/iterall/-/iterall-1.2.2.tgz", + "integrity": "sha512-yynBb1g+RFUPY64fTrFv7nsjRrENBQJaX2UL+2Szc9REFrSNm1rpSXHGzhmAy7a9uv3vlvgBlXnf9RqmPH1/DA==" + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" + }, + "json-beautify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/json-beautify/-/json-beautify-1.1.0.tgz", + "integrity": "sha512-Y8lEcqhyJKRq2IhYBGtRIQO7EgOlyeSCYXnQCzAnGO5DhCBzMBEZ90PTw620NwpfQccJ/sj4+bU+r4GBI0b2Lw==" + }, + "json-edm-parser": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/json-edm-parser/-/json-edm-parser-0.1.2.tgz", + "integrity": "sha1-HmCw/vG8CvZ7wNFG393lSGzWFbQ=", + "requires": { + "jsonparse": "~1.2.0" + } + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" + }, + "json-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-stream/-/json-stream-1.0.0.tgz", + "integrity": "sha1-GjhU4o0rvuqzHMfd9oPS3cVlJwg=" + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" + }, + "jsonparse": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.2.0.tgz", + "integrity": "sha1-XAxWhRBxYOcv50ib3eoLRMK8Z70=" + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + } + }, + "kareem": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.0.tgz", + "integrity": "sha512-6hHxsp9e6zQU8nXsP+02HGWXwTkOEw6IROhF2ZA28cYbUk4eJ6QbtZvdqZOdD9YPKghG3apk5eOCvs+tLl3lRg==" + }, + "kuler": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/kuler/-/kuler-1.0.1.tgz", + "integrity": "sha512-J9nVUucG1p/skKul6DU3PUZrhs0LPulNaeUOox0IyXDi8S4CztTHs1gQphhuZmzXG7VOQSf6NJfKuzteQLv9gQ==", + "requires": { + "colornames": "^1.1.1" + } + }, + "lcid": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz", + "integrity": "sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA==", + "dev": true, + "requires": { + "invert-kv": "^2.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + }, + "lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=" + }, + "lodash.sortby": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", + "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=" + }, + "log-symbols": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", + "integrity": "sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg==", + "dev": true, + "requires": { + "chalk": "^2.0.1" + } + }, + "logform": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/logform/-/logform-2.1.2.tgz", + "integrity": "sha512-+lZh4OpERDBLqjiwDLpAWNQu6KMjnlXH2ByZwCuSqVPJletw0kTWJf5CgSNAUKn1KUkv3m2cUz/LK8zyEy7wzQ==", + "requires": { + "colors": "^1.2.1", + "fast-safe-stringify": "^2.0.4", + "fecha": "^2.3.3", + "ms": "^2.1.1", + "triple-beam": "^1.3.0" + }, + "dependencies": { + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + } + } + }, + "long": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", + "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" + }, + "lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "requires": { + "yallist": "^3.0.2" + } + }, + "map-age-cleaner": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz", + "integrity": "sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w==", + "dev": true, + "requires": { + "p-defer": "^1.0.0" + } + }, + "md5.js": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz", + "integrity": "sha1-6b296UogpawYsENA/Fdk1bCdkB0=", + "requires": { + "hash-base": "^3.0.0", + "inherits": "^2.0.1" + } + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "mem": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/mem/-/mem-4.3.0.tgz", + "integrity": "sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w==", + "dev": true, + "requires": { + "map-age-cleaner": "^0.1.1", + "mimic-fn": "^2.0.0", + "p-is-promise": "^2.0.0" + } + }, + "memory-pager": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", + "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==", + "optional": true + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + }, + "mime": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", + "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" + }, + "mime-db": { + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" + }, + "mime-types": { + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "requires": { + "mime-db": "1.40.0" + } + }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "minio": { + "version": "7.0.8", + "resolved": "https://registry.npmjs.org/minio/-/minio-7.0.8.tgz", + "integrity": "sha512-nPVmtms5cARaaqCCH3n0n0jIMaaG+y8Ka5s0/YA8X5/fvZoHmDmaIoJtvSwZc72L/gQgqEJqcIvBMrbjW7NkHQ==", + "requires": { + "async": "^1.5.2", + "block-stream2": "^1.0.0", + "concat-stream": "^1.4.8", + "es6-error": "^2.0.2", + "json-stream": "^1.0.0", + "lodash": "^4.14.2", + "mime-types": "^2.1.14", + "mkdirp": "^0.5.1", + "querystring": "0.2.0", + "through2": "^0.6.5", + "uuid": "^3.1.0", + "xml": "^1.0.0", + "xml2js": "^0.4.15" + }, + "dependencies": { + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=" + } + } + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "mocha": { + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-6.1.4.tgz", + "integrity": "sha512-PN8CIy4RXsIoxoFJzS4QNnCH4psUCPWc4/rPrst/ecSJJbLBkubMiyGCP2Kj/9YnWbotFqAoeXyXMucj7gwCFg==", + "dev": true, + "requires": { + "ansi-colors": "3.2.3", + "browser-stdout": "1.3.1", + "debug": "3.2.6", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "find-up": "3.0.0", + "glob": "7.1.3", + "growl": "1.10.5", + "he": "1.2.0", + "js-yaml": "3.13.1", + "log-symbols": "2.2.0", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "ms": "2.1.1", + "node-environment-flags": "1.0.5", + "object.assign": "4.1.0", + "strip-json-comments": "2.0.1", + "supports-color": "6.0.0", + "which": "1.3.1", + "wide-align": "1.1.3", + "yargs": "13.2.2", + "yargs-parser": "13.0.0", + "yargs-unparser": "1.5.0" + }, + "dependencies": { + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + } + } + }, + "mongodb": { + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.1.6.tgz", + "integrity": "sha512-E5QJuXQoMlT7KyCYqNNMfAkhfQD79AT4F8Xd+6x37OX+8BL17GyXyWvfm6wuyx4wnzCCPoCSLeMeUN2S7dU9yw==", + "requires": { + "mongodb-core": "3.1.5", + "safe-buffer": "^5.1.2" + } + }, + "mongodb-core": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.1.5.tgz", + "integrity": "sha512-emT/tM4ZBinqd6RZok+EzDdtN4LjYJIckv71qQVOEFmvXgT5cperZegVmTgox/1cx4XQu6LJ5ZuIwipP/eKdQg==", + "requires": { + "bson": "^1.1.0", + "require_optional": "^1.0.1", + "safe-buffer": "^5.1.2", + "saslprep": "^1.0.0" + }, + "dependencies": { + "bson": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.1.tgz", + "integrity": "sha512-jCGVYLoYMHDkOsbwJZBCqwMHyH4c+wzgI9hG7Z6SZJRXWr+x58pdIbm2i9a/jFGCkRJqRUr8eoI7lDWa0hTkxg==" + } + } + }, + "mongoose": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.3.4.tgz", + "integrity": "sha512-DIUWOyYgZv2zGi/BoFEaFiaCVuDonnzGhW3cnc3JFjBScYn6z24tS2j3VB0dtMoX8FFjxmmMVnlmHPEIbV4PKA==", + "requires": { + "async": "2.6.1", + "bson": "~1.0.5", + "kareem": "2.3.0", + "lodash.get": "4.4.2", + "mongodb": "3.1.6", + "mongodb-core": "3.1.5", + "mongoose-legacy-pluralize": "1.0.2", + "mpath": "0.5.1", + "mquery": "3.2.0", + "ms": "2.0.0", + "regexp-clone": "0.0.1", + "safe-buffer": "5.1.2", + "sliced": "1.0.1" + } + }, + "mongoose-legacy-pluralize": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/mongoose-legacy-pluralize/-/mongoose-legacy-pluralize-1.0.2.tgz", + "integrity": "sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ==" + }, + "mpath": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.5.1.tgz", + "integrity": "sha512-H8OVQ+QEz82sch4wbODFOz+3YQ61FYz/z3eJ5pIdbMEaUzDqA268Wd+Vt4Paw9TJfvDgVKaayC0gBzMIw2jhsg==" + }, + "mquery": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/mquery/-/mquery-3.2.0.tgz", + "integrity": "sha512-qPJcdK/yqcbQiKoemAt62Y0BAc0fTEKo1IThodBD+O5meQRJT/2HSe5QpBNwaa4CjskoGrYWsEyjkqgiE0qjhg==", + "requires": { + "bluebird": "3.5.1", + "debug": "3.1.0", + "regexp-clone": "0.0.1", + "safe-buffer": "5.1.2", + "sliced": "1.0.1" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + } + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "negotiator": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", + "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" + }, + "nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "dev": true + }, + "node-environment-flags": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.5.tgz", + "integrity": "sha512-VNYPRfGfmZLx0Ye20jWzHUjyTW/c+6Wq+iLhDzUI4XmhrDd9l/FozXV3F2xOaXjvp0co0+v1YSR3CMP6g+VvLQ==", + "dev": true, + "requires": { + "object.getownpropertydescriptors": "^2.0.3", + "semver": "^5.7.0" + } + }, + "node-fetch": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", + "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" + }, + "npm-run-path": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", + "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", + "dev": true, + "requires": { + "path-key": "^2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==" + }, + "object-path": { + "version": "0.11.4", + "resolved": "https://registry.npmjs.org/object-path/-/object-path-0.11.4.tgz", + "integrity": "sha1-NwrnUvvzfePqcKhhwju6iRVpGUk=" + }, + "object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + } + }, + "object.getownpropertydescriptors": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz", + "integrity": "sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY=", + "requires": { + "define-properties": "^1.1.2", + "es-abstract": "^1.5.1" + } + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "one-time": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/one-time/-/one-time-0.0.4.tgz", + "integrity": "sha1-+M33eISCb+Tf+T46nMN7HkSAdC4=" + }, + "os-locale": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-3.1.0.tgz", + "integrity": "sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==", + "dev": true, + "requires": { + "execa": "^1.0.0", + "lcid": "^2.0.0", + "mem": "^4.0.0" + } + }, + "p-defer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-1.0.0.tgz", + "integrity": "sha1-n26xgvbJqozXQwBKfU+WsZaw+ww=", + "dev": true + }, + "p-finally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", + "dev": true + }, + "p-is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.1.0.tgz", + "integrity": "sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg==", + "dev": true + }, + "p-limit": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz", + "integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "dev": true + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + }, + "pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", + "dev": true + }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" + }, + "protobufjs": { + "version": "6.8.8", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.8.8.tgz", + "integrity": "sha512-AAmHtD5pXgZfi7GMpllpO3q1Xw1OYldr+dMUlAnffGTAhqkg72WdmSY71uKBF/JuyiKs8psYbtKrhi0ASCD8qw==", + "requires": { + "@protobufjs/aspromise": "^1.1.2", + "@protobufjs/base64": "^1.1.2", + "@protobufjs/codegen": "^2.0.4", + "@protobufjs/eventemitter": "^1.1.0", + "@protobufjs/fetch": "^1.1.0", + "@protobufjs/float": "^1.0.2", + "@protobufjs/inquire": "^1.1.0", + "@protobufjs/path": "^1.1.2", + "@protobufjs/pool": "^1.1.0", + "@protobufjs/utf8": "^1.1.0", + "@types/long": "^4.0.0", + "@types/node": "^10.1.0", + "long": "^4.0.0" + }, + "dependencies": { + "@types/node": { + "version": "10.14.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.7.tgz", + "integrity": "sha512-on4MmIDgHXiuJDELPk1NFaKVUxxCFr37tm8E9yN6rAiF5Pzp/9bBfBHkoexqRiY+hk/Z04EJU9kKEb59YqJ82A==" + } + } + }, + "proxy-addr": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", + "integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==", + "requires": { + "forwarded": "~0.1.2", + "ipaddr.js": "1.9.0" + } + }, + "psl": { + "version": "1.1.31", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz", + "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==" + }, + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dev": true, + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" + }, + "qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" + }, + "querystring": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", + "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=" + }, + "range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" + }, + "raw-body": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", + "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "requires": { + "bytes": "3.1.0", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + } + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "redis": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/redis/-/redis-2.8.0.tgz", + "integrity": "sha512-M1OkonEQwtRmZv4tEWF2VgpG0JWJ8Fv1PhlgT5+B+uNq2cA3Rt1Yt/ryoR+vQNOQcIEgdCdfH0jr3bDpihAw1A==", + "requires": { + "double-ended-queue": "^2.1.0-0", + "redis-commands": "^1.2.0", + "redis-parser": "^2.6.0" + } + }, + "redis-commands": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.5.0.tgz", + "integrity": "sha512-6KxamqpZ468MeQC3bkWmCB1fp56XL64D4Kf0zJSwDZbVLLm7KFkoIcHrgRvQ+sk8dnhySs7+yBg94yIkAK7aJg==" + }, + "redis-parser": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-2.6.0.tgz", + "integrity": "sha1-Uu0J2srBCPGmMcB+m2mUHnoZUEs=" + }, + "regenerator-runtime": { + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz", + "integrity": "sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA==" + }, + "regexp-clone": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-0.0.1.tgz", + "integrity": "sha1-p8LgmJH9vzj7sQ03b7cwA+aKxYk=" + }, + "request": { + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + }, + "dependencies": { + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + }, + "tough-cookie": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "requires": { + "psl": "^1.1.24", + "punycode": "^1.4.1" + } + } + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true + }, + "require_optional": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz", + "integrity": "sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g==", + "requires": { + "resolve-from": "^2.0.0", + "semver": "^5.1.0" + } + }, + "resolve-from": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz", + "integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c=" + }, + "retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", + "integrity": "sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs=" + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "saslprep": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.3.tgz", + "integrity": "sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag==", + "optional": true, + "requires": { + "sparse-bitfield": "^3.0.3" + } + }, + "sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" + }, + "semver": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", + "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==" + }, + "send": { + "version": "0.16.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", + "integrity": "sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw==", + "requires": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.6.2", + "mime": "1.4.1", + "ms": "2.0.0", + "on-finished": "~2.3.0", + "range-parser": "~1.2.0", + "statuses": "~1.4.0" + }, + "dependencies": { + "http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": ">= 1.4.0 < 2" + } + }, + "setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" + }, + "statuses": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", + "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" + } + } + }, + "serve-static": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz", + "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", + "requires": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.2", + "send": "0.16.2" + } + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true + }, + "setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" + }, + "sha.js": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", + "requires": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "dev": true + }, + "simple-swizzle": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", + "integrity": "sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo=", + "requires": { + "is-arrayish": "^0.3.1" + } + }, + "sliced": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz", + "integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E=" + }, + "sparse-bitfield": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", + "integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=", + "optional": true, + "requires": { + "memory-pager": "^1.0.2" + } + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "sshpk": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", + "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + } + }, + "stack-trace": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", + "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=" + }, + "statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" + }, + "streamsearch": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz", + "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=" + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + }, + "strip-eof": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", + "dev": true + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, + "subscriptions-transport-ws": { + "version": "0.9.16", + "resolved": "https://registry.npmjs.org/subscriptions-transport-ws/-/subscriptions-transport-ws-0.9.16.tgz", + "integrity": "sha512-pQdoU7nC+EpStXnCfh/+ho0zE0Z+ma+i7xvj7bkXKb1dvYHSZxgRPaU6spRP+Bjzow67c/rRDoix5RT0uU9omw==", + "requires": { + "backo2": "^1.0.2", + "eventemitter3": "^3.1.0", + "iterall": "^1.2.1", + "symbol-observable": "^1.0.4", + "ws": "^5.2.0" + }, + "dependencies": { + "ws": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/ws/-/ws-5.2.2.tgz", + "integrity": "sha512-jaHFD6PFv6UgoIVda6qZllptQsMlDEJkTQcybzzXDYM1XO9Y8em691FGMPmM46WGyLU4z9KMgQN+qrux/nhlHA==", + "requires": { + "async-limiter": "~1.0.0" + } + } + } + }, + "supports-color": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.0.0.tgz", + "integrity": "sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "symbol-observable": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz", + "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==" + }, + "text-hex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz", + "integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==" + }, + "through2": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", + "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", + "requires": { + "readable-stream": ">=1.0.33-1 <1.1.0-0", + "xtend": ">=4.0.0 <4.1.0-0" + }, + "dependencies": { + "readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + } + } + }, + "toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" + }, + "tough-cookie": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", + "requires": { + "psl": "^1.1.28", + "punycode": "^2.1.1" + } + }, + "triple-beam": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz", + "integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw==" + }, + "ts-invariant": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/ts-invariant/-/ts-invariant-0.3.3.tgz", + "integrity": "sha512-UReOKsrJFGC9tUblgSRWo+BsVNbEd77Cl6WiV/XpMlkifXwNIJbknViCucHvVZkXSC/mcWeRnIGdY7uprcwvdQ==", + "requires": { + "tslib": "^1.9.3" + } + }, + "tslib": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", + "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==" + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" + }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true + }, + "type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + } + }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" + }, + "underscore": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", + "integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=" + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "requires": { + "punycode": "^2.1.0" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "util.promisify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/util.promisify/-/util.promisify-1.0.0.tgz", + "integrity": "sha512-i+6qA2MPhvoKLuxnJNpXAGhg7HphQOSUq2LKMZD0m15EiskXUkMvKdF4Uui0WYeCUGea+o2cw/ZuwehtfsrNkA==", + "requires": { + "define-properties": "^1.1.2", + "object.getownpropertydescriptors": "^2.0.3" + } + }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + }, + "validator": { + "version": "9.4.1", + "resolved": "https://registry.npmjs.org/validator/-/validator-9.4.1.tgz", + "integrity": "sha512-YV5KjzvRmSyJ1ee/Dm5UED0G+1L4GZnLN3w6/T+zZm8scVua4sOhYKWTUrKa0H/tMiJyO9QLHMPN+9mB/aMunA==" + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "requires": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "dev": true + }, + "wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "dev": true, + "requires": { + "string-width": "^1.0.2 || 2" + } + }, + "winston": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/winston/-/winston-3.2.1.tgz", + "integrity": "sha512-zU6vgnS9dAWCEKg/QYigd6cgMVVNwyTzKs81XZtTFuRwJOcDdBg7AU0mXVyNbs7O5RH2zdv+BdNZUlx7mXPuOw==", + "requires": { + "async": "^2.6.1", + "diagnostics": "^1.1.1", + "is-stream": "^1.1.0", + "logform": "^2.1.1", + "one-time": "0.0.4", + "readable-stream": "^3.1.1", + "stack-trace": "0.0.x", + "triple-beam": "^1.3.0", + "winston-transport": "^4.3.0" + }, + "dependencies": { + "readable-stream": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.3.0.tgz", + "integrity": "sha512-EsI+s3k3XsW+fU8fQACLN59ky34AZ14LoeVZpYwmZvldCFo0r0gnelwF2TcMjLor/BTL5aDJVBMkss0dthToPw==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "string_decoder": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.2.0.tgz", + "integrity": "sha512-6YqyX6ZWEYguAxgZzHGL7SsCeGx3V2TtOTqZz1xSTSWnqsbWwbptafNyvf/ACquZUXV3DANr5BDIwNYe1mN42w==", + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "winston-transport": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.3.0.tgz", + "integrity": "sha512-B2wPuwUi3vhzn/51Uukcao4dIduEiPOcOt9HJ3QeaXgkJ5Z7UwpBzxS4ZGNHtrxrUvTwemsQiSys0ihOf8Mp1A==", + "requires": { + "readable-stream": "^2.3.6", + "triple-beam": "^1.2.0" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "wrap-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "dev": true, + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + } + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "ws": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", + "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", + "requires": { + "async-limiter": "~1.0.0" + } + }, + "xml": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz", + "integrity": "sha1-eLpyAgApxbyHuKgaPPzXS0ovweU=" + }, + "xml2js": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", + "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", + "requires": { + "sax": ">=0.6.0", + "xmlbuilder": "~9.0.1" + } + }, + "xmlbuilder": { + "version": "9.0.7", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", + "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=" + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" + }, + "y18n": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", + "dev": true + }, + "yallist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" + }, + "yargs": { + "version": "13.2.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.2.2.tgz", + "integrity": "sha512-WyEoxgyTD3w5XRpAQNYUB9ycVH/PQrToaTXdYXRdOXvEy1l19br+VJsc0vcO8PTGg5ro/l/GY7F/JMEBmI0BxA==", + "dev": true, + "requires": { + "cliui": "^4.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "os-locale": "^3.1.0", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, + "yargs-parser": { + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.0.0.tgz", + "integrity": "sha512-w2LXjoL8oRdRQN+hOyppuXs+V/fVAYtpcrRxZuF7Kt/Oc+Jr2uAcVntaUTNT6w5ihoWfFDpNY8CPx1QskxZ/pw==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + }, + "yargs-unparser": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.5.0.tgz", + "integrity": "sha512-HK25qidFTCVuj/D1VfNiEndpLIeJN78aqgR23nL3y4N0U/91cOAzqfHlF8n2BvoNDcZmJKin3ddNSvOxSr8flw==", + "dev": true, + "requires": { + "flat": "^4.1.0", + "lodash": "^4.17.11", + "yargs": "^12.0.5" + }, + "dependencies": { + "get-caller-file": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", + "dev": true + }, + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", + "dev": true + }, + "yargs": { + "version": "12.0.5", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-12.0.5.tgz", + "integrity": "sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw==", + "dev": true, + "requires": { + "cliui": "^4.0.0", + "decamelize": "^1.2.0", + "find-up": "^3.0.0", + "get-caller-file": "^1.0.1", + "os-locale": "^3.0.0", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^2.0.0", + "which-module": "^2.0.0", + "y18n": "^3.2.1 || ^4.0.0", + "yargs-parser": "^11.1.1" + } + }, + "yargs-parser": { + "version": "11.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-11.1.1.tgz", + "integrity": "sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + } + } + }, + "zen-observable": { + "version": "0.8.14", + "resolved": "https://registry.npmjs.org/zen-observable/-/zen-observable-0.8.14.tgz", + "integrity": "sha512-kQz39uonEjEESwh+qCi83kcC3rZJGh4mrZW7xjkSQYXkq//JZHTtKo+6yuVloTgMtzsIWOJrjIrKvk/dqm0L5g==" + }, + "zen-observable-ts": { + "version": "0.8.18", + "resolved": "https://registry.npmjs.org/zen-observable-ts/-/zen-observable-ts-0.8.18.tgz", + "integrity": "sha512-q7d05s75Rn1j39U5Oapg3HI2wzriVwERVo4N7uFGpIYuHB9ff02P/E92P9B8T7QVC93jCMHpbXH7X0eVR5LA7A==", + "requires": { + "tslib": "^1.9.3", + "zen-observable": "^0.8.0" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 000000000..3e4f6357e --- /dev/null +++ b/package.json @@ -0,0 +1,35 @@ +{ + "name": "saweb-api", + "version": "0.1.0", + "description": "Superalgos Web backend API", + "author": "Superalgos, ltd.", + "license": "Apache-2.0", + "repository": { + "type": "git", + "url": "git+https://github.com/Superalgos/SAWebServer.git" + }, + "main": "src/index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "devDependencies": { + "express": "^4.16.4", + "chai": "^4.2.0", + "mocha": "^6.1.4" + }, + "dependencies": { + "@azure/storage-blob": "^10.3.0", + "apollo-server-express": "2.1.0", + "axios": "0.19.0", + "azure-storage": "^2.10.3", + "dotenv": "8.0.0", + "esm": "^3.2.22", + "express": "4.16.3", + "graphql": "0.13.2", + "json-beautify": "^1.1.0", + "minio": "^7.0.8", + "mongoose": "5.3.4", + "redis": "^2.8.0", + "winston": "3.2.1" + } +} diff --git a/src/app.js b/src/app.js new file mode 100644 index 000000000..74855f021 --- /dev/null +++ b/src/app.js @@ -0,0 +1,58 @@ +import 'dotenv/config'; +import express from 'express'; +import { ApolloServer } from 'apollo-server-express'; +import schema from './schema'; +import wrongPreshared from './errors/notAllowed.json'; +import db from './db'; +import logger from './utils/logger' +import bodyParser from 'body-parser' + +const app = express(); + +app.use(bodyParser.json({limit: '50mb'})); +app.use(bodyParser.urlencoded({limit: '50mb', extended: true})); + +app.post('/graphql', (req, res, next) => { + if (req.headers.preshared === process.env.PRESHARED_GATEWAY_KEY) { + next(); + } else { + res.send(wrongPreshared); + } +}); + +// Starting the graphql server +const server = new ApolloServer({ + schema, + playground: { + settings: { + 'editor.theme': 'dark', + 'editor.cursorShape': 'line', + }, + }, + context: ({ req }) => ({ + userId: req.headers.userid, + authorization: req.headers.authorization, + }), + formatError: error => ({ + code: error.extensions.exception.code, + message: error.message, + path: error.path, + }), + introspection: true, +}); + +server.applyMiddleware({ + app, + cors: true, +}); + +db.on('error', (err) => { + logger.error(err); +}); +db.once('open', () => { + logger.info('Connected to the DB.'); +}); + +app.listen(process.env.PORT, () => { + logger.info(`Listening on port ${process.env.PORT}`); +}); diff --git a/src/config/ecosystem.json b/src/config/ecosystem.json new file mode 100644 index 000000000..dfde878c0 --- /dev/null +++ b/src/config/ecosystem.json @@ -0,0 +1,892 @@ +{ + "authId": "", + "devTeams": [ + { + "codeName": "AAMasters", + "displayName": "Masters", + "host": { + "url": "https://demo-api-dev.superalgos.org/", + "storage": "localStorage", + "container": "aamasters", + "accessKey": "09e890b76767ede3e10f0526b5036600a6b8d3faac540336e12b493fdb2aa9ed46f86094c34652f99fb6322e5f09806412f17725807f85e4dc4169bd22dd59f0b23aba5251f5544478a1aabf5a2dea5260e6eb0c29af3a788208af85025a02f94950437d501b91fd55b9d97b3d6ac3af4e1161321f78b73ca0fda524dc3a5d03" + }, + "bots": [ + { + "codeName": "AAOlivia", + "displayName": "Olivia", + "type": "Indicator", + "profilePicture": "Olivia.png", + "repo": "AAOlivia-Indicator-Bot", + "configFile": "this.bot.config.json", + "products": [ + { + "codeName": "Candles", + "displayName": "Candles", + "description": "Two sets of files per period that contains candles.", + "dataSets": [ + { + "codeName": "Multi-Period-Market", + "type": "Market Files", + "validPeriods": [ + "24-hs", + "12-hs", + "08-hs", + "06-hs", + "04-hs", + "03-hs", + "02-hs", + "01-hs" + ], + "filePath": "AAMasters/AAOlivia.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Candles/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json" + }, + { + "codeName": "Multi-Period-Daily", + "type": "Daily Files", + "validPeriods": [ + "45-min", + "40-min", + "30-min", + "20-min", + "15-min", + "10-min", + "05-min", + "04-min", + "03-min", + "02-min", + "01-min" + ], + "filePath": "AAMasters/AAOlivia.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Candles/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "dataRange": { + "filePath": "AAMasters/AAOlivia.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Candles/Multi-Period-Daily", + "fileName": "Data.Range.@AssetA_@AssetB.json" + } + } + ], + "exchangeList": [ + { + "name": "Poloniex" + }, + { + "name": "Coss" + } + ], + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersCandlesVolumes", + "moduleName": "Candles" + } + }, + { + "codeName": "Volumes", + "displayName": "Buy and Sell Volumes", + "description": "Two sets of files per period that contains buy and sell volumes.", + "dataSets": [ + { + "codeName": "Multi-Period-Market", + "type": "Market Files", + "validPeriods": [ + "24-hs", + "12-hs", + "08-hs", + "06-hs", + "04-hs", + "03-hs", + "02-hs", + "01-hs" + ], + "filePath": "AAMasters/AAOlivia.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Volumes/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json" + }, + { + "codeName": "Multi-Period-Daily", + "type": "Daily Files", + "validPeriods": [ + "45-min", + "40-min", + "30-min", + "20-min", + "15-min", + "10-min", + "05-min", + "04-min", + "03-min", + "02-min", + "01-min" + ], + "filePath": "AAMasters/AAOlivia.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Volumes/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "dataRange": { + "filePath": "AAMasters/AAOlivia.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Volumes/Multi-Period-Daily", + "fileName": "Data.Range.@AssetA_@AssetB.json" + } + } + ], + "exchangeList": [ + { + "name": "Poloniex" + }, + { + "name": "Coss" + } + ], + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersCandlesVolumes", + "moduleName": "Volumes" + } + } + ] + }, + { + "codeName": "AATom", + "displayName": "Tom", + "type": "Indicator", + "profilePicture": "Tom.png", + "repo": "AATom-Indicator-Bot", + "configFile": "this.bot.config.json", + "products": [ + { + "codeName": "Candle-Stairs", + "displayName": "Candle-Stairs Patters", + "description": "Two sets of files per period that contains candle-stairs patterns.", + "dataSets": [ + { + "codeName": "Multi-Period-Market", + "type": "Market Files", + "validPeriods": [ + "24-hs", + "12-hs", + "08-hs", + "06-hs", + "04-hs", + "03-hs", + "02-hs", + "01-hs" + ], + "filePath": "AAMasters/AATom.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Candle-Stairs/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json" + }, + { + "codeName": "Multi-Period-Daily", + "type": "Daily Files", + "validPeriods": [ + "45-min", + "40-min", + "30-min", + "20-min", + "15-min", + "10-min", + "05-min", + "04-min", + "03-min", + "02-min", + "01-min" + ], + "filePath": "AAMasters/AATom.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Candle-Stairs/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "dataRange": { + "filePath": "AAMasters/AATom.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Candle-Stairs/Multi-Period-Daily", + "fileName": "Data.Range.@AssetA_@AssetB.json" + } + } + ], + "exchangeList": [ + { + "name": "Poloniex" + }, + { + "name": "Coss" + } + ], + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersStairsPatterns", + "moduleName": "CandleStairs" + } + }, + { + "codeName": "Volume-Stairs", + "displayName": "Volume-Stairs Patters", + "description": "Two sets of files per period that contains volume-stairs patterns.", + "dataSets": [ + { + "codeName": "Multi-Period-Market", + "type": "Market Files", + "validPeriods": [ + "24-hs", + "12-hs", + "08-hs", + "06-hs", + "04-hs", + "03-hs", + "02-hs", + "01-hs" + ], + "filePath": "AAMasters/AATom.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Volume-Stairs/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json" + }, + { + "codeName": "Multi-Period-Daily", + "type": "Daily Files", + "validPeriods": [ + "45-min", + "40-min", + "30-min", + "20-min", + "15-min", + "10-min", + "05-min", + "04-min", + "03-min", + "02-min", + "01-min" + ], + "filePath": "AAMasters/AATom.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Volume-Stairs/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "dataRange": { + "filePath": "AAMasters/AATom.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Volume-Stairs/Multi-Period-Daily", + "fileName": "Data.Range.@AssetA_@AssetB.json" + } + } + ], + "exchangeList": [ + { + "name": "Poloniex" + }, + { + "name": "Coss" + } + ], + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersStairsPatterns", + "moduleName": "VolumeStairs" + } + } + ] + }, + { + "codeName": "AAChris", + "displayName": "Chris", + "type": "Indicator", + "profilePicture": "Chris.png", + "repo": "AAChris-Indicator-Bot", + "configFile": "this.bot.config.json", + "products": [ + { + "codeName": "Bollinger-Bands", + "displayName": "Bollinger Bands", + "description": "Bollinger Bands", + "dataSets": [ + { + "codeName": "Multi-Period-Market", + "type": "Market Files", + "validPeriods": [ + "24-hs", + "12-hs", + "08-hs", + "06-hs", + "04-hs", + "03-hs", + "02-hs", + "01-hs" + ], + "filePath": "AAMasters/AAChris.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Bollinger-Bands/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json" + }, + { + "codeName": "Multi-Period-Daily", + "type": "Daily Files", + "validPeriods": [ + "45-min", + "40-min", + "30-min", + "20-min", + "15-min", + "10-min", + "05-min", + "04-min", + "03-min", + "02-min", + "01-min" + ], + "filePath": "AAMasters/AAChris.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Bollinger-Bands/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "dataRange": { + "filePath": "AAMasters/AAChris.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Bollinger-Bands/Multi-Period-Daily", + "fileName": "Data.Range.@AssetA_@AssetB.json" + } + } + ], + "exchangeList": [ + { + "name": "Poloniex" + }, + { + "name": "Coss" + } + ], + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersBollingerBands", + "moduleName": "BollingerBands" + } + }, + { + "codeName": "Percentage-Bandwidth", + "displayName": "Percentage Bandwidth", + "description": "Percentage Bandwidth", + "dataSets": [ + { + "codeName": "Multi-Period-Market", + "type": "Market Files", + "validPeriods": [ + "24-hs", + "12-hs", + "08-hs", + "06-hs", + "04-hs", + "03-hs", + "02-hs", + "01-hs" + ], + "filePath": "AAMasters/AAChris.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Percentage-Bandwidth/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json" + }, + { + "codeName": "Multi-Period-Daily", + "type": "Daily Files", + "validPeriods": [ + "45-min", + "40-min", + "30-min", + "20-min", + "15-min", + "10-min", + "05-min", + "04-min", + "03-min", + "02-min", + "01-min" + ], + "filePath": "AAMasters/AAChris.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Percentage-Bandwidth/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "dataRange": { + "filePath": "AAMasters/AAChris.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Percentage-Bandwidth/Multi-Period-Daily", + "fileName": "Data.Range.@AssetA_@AssetB.json" + } + } + ], + "exchangeList": [ + { + "name": "Poloniex" + }, + { + "name": "Coss" + } + ], + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersBollingerBands", + "moduleName": "PercentageBandwidth" + } + } + ] + }, + { + "codeName": "AAPaula", + "displayName": "Paula", + "type": "Indicator", + "profilePicture": "Paula.png", + "repo": "AAPaula-Indicator-Bot", + "configFile": "this.bot.config.json", + "products": [ + { + "codeName": "Bollinger-Channels", + "displayName": "Bollinger-Channels", + "description": "Two sets of files per period that contains band-channel patterns.", + "dataSets": [ + { + "codeName": "Multi-Period-Market", + "type": "Market Files", + "validPeriods": [ + "24-hs", + "12-hs", + "08-hs", + "06-hs", + "04-hs", + "03-hs", + "02-hs", + "01-hs" + ], + "filePath": "AAMasters/AAPaula.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Bollinger-Channels/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json" + }, + { + "codeName": "Multi-Period-Daily", + "type": "Daily Files", + "validPeriods": [ + "45-min", + "40-min", + "30-min", + "20-min", + "15-min", + "10-min", + "05-min", + "04-min", + "03-min", + "02-min", + "01-min" + ], + "filePath": "AAMasters/AAPaula.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Bollinger-Channels/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "dataRange": { + "filePath": "AAMasters/AAPaula.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Bollinger-Channels/Multi-Period-Daily", + "fileName": "Data.Range.@AssetA_@AssetB.json" + } + } + ], + "exchangeList": [ + { + "name": "Poloniex" + }, + { + "name": "Coss" + } + ], + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersBollingerChannels", + "moduleName": "BollingerChannels" + } + }, + { + "codeName": "Bollinger-Sub-Channels", + "displayName": "Bollinger-Sub-Channels", + "description": "Bollinger Sub Channels with slope.", + "dataSets": [ + { + "codeName": "Multi-Period-Market", + "type": "Market Files", + "validPeriods": [ + "24-hs", + "12-hs", + "08-hs", + "06-hs", + "04-hs", + "03-hs", + "02-hs", + "01-hs" + ], + "filePath": "AAMasters/AAPaula.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Bollinger-Sub-Channels/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json" + }, + { + "codeName": "Multi-Period-Daily", + "type": "Daily Files", + "validPeriods": [ + "45-min", + "40-min", + "30-min", + "20-min", + "15-min", + "10-min", + "05-min", + "04-min", + "03-min", + "02-min", + "01-min" + ], + "filePath": "AAMasters/AAPaula.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Bollinger-Sub-Channels/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "dataRange": { + "filePath": "AAMasters/AAPaula.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Bollinger-Sub-Channels/Multi-Period-Daily", + "fileName": "Data.Range.@AssetA_@AssetB.json" + } + } + ], + "exchangeList": [ + { + "name": "Poloniex" + }, + { + "name": "Coss" + } + ], + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersBollingerChannels", + "moduleName": "BollingerSubChannels" + } + } + ] + } + ], + "plotters": [ + { + "displayName": "Plotters Candles & Volumes", + "codeName": "PlottersCandlesVolumes", + "devTeam": "AAMasters", + "modules": [ + { + "codeName": "Candles", + "moduleName": "Candles", + "description": "Plots traditional red and green candles.", + "profilePicture": "Candles.png", + "panels": [ + { + "codeName": "CandlePanel", + "moduleName": "CandlePanel", + "event": "Current Candle Changed" + } + ] + }, + { + "codeName": "Volumes", + "description": "Plots volumes separated in buy and sell.", + "moduleName": "Volumes", + "profilePicture": "Volumes.png", + "panels": [ + { + "codeName": "VolumePanel", + "moduleName": "VolumePanel", + "event": "Current Volume Changed" + } + ] + } + ], + "repo": "Plotters-Candles-Volumes", + "configFile": "this.plotter.config.json" + }, + { + "displayName": "Plotters Stairs Patterns", + "codeName": "PlottersStairsPatterns", + "devTeam": "AAMasters", + "modules": [ + { + "codeName": "CandleStairs", + "moduleName": "CandleStairs", + "description": "Plots Candle Stairs patterns.", + "profilePicture": "CandleStairs.png", + "panels": [] + }, + { + "codeName": "VolumeStairs", + "description": "Plots Volume Stairs patterns.", + "moduleName": "VolumeStairs", + "profilePicture": "VolumeStairs.png", + "panels": [] + } + ], + "repo": "Plotters-Stairs-Patterns", + "configFile": "this.plotter.config.json" + }, + { + "displayName": "Plotters Trading", + "codeName": "PlottersTrading", + "devTeam": "AAMasters", + "modules": [ + { + "codeName": "Details", + "moduleName": "Details", + "description": "Plots trading decitions in an easy to understand way.", + "panels": [] + }, + { + "codeName": "History", + "moduleName": "History", + "description": "Plots trading history.", + "profilePicture": "History.png", + "panels": [] + } + ], + "repo": "Plotters-Trading", + "configFile": "this.plotter.config.json" + }, + { + "displayName": "Plotters Bollinger Bands", + "codeName": "PlottersBollingerBands", + "devTeam": "AAMasters", + "modules": [ + { + "codeName": "BollingerBands", + "moduleName": "BollingerBands", + "description": "Plots Bollinger Bands.", + "profilePicture": "BollingerBands.png", + "panels": [ + { + "codeName": "BollingerBandsPanel", + "moduleName": "BollingerBandsPanel", + "event": "Current Band Changed" + } + ] + }, + { + "codeName": "PercentageBandwidth", + "moduleName": "PercentageBandwidth", + "description": "Plots Bollinger Bands.", + "profilePicture": "PercentageBandwidth.png", + "panels": [] + } + ], + "repo": "Plotters-Bollinger-Bands", + "configFile": "this.plotter.config.json" + }, + { + "displayName": "Plotters Trading Simulation", + "codeName": "PlottersTradingSimulation", + "devTeam": "AAMasters", + "modules": [ + { + "codeName": "TradingSimulation", + "moduleName": "TradingSimulation", + "description": "Plots Bollinger Records.", + "profilePicture": "TradingSimulation.png", + "panels": [ + { + "codeName": "TradingSimulationPanel", + "moduleName": "TradingSimulationPanel", + "event": "Current Record Changed" + } + ] + }, + { + "codeName": "Conditions", + "moduleName": "Conditions", + "description": "Plots Simulation Conditions.", + "profilePicture": "Conditions.png", + "panels": [] + }, + { + "codeName": "Strategies", + "moduleName": "Strategies", + "description": "Plots Strategies.", + "profilePicture": "Strategies.png", + "panels": [] + }, + { + "codeName": "Trades", + "moduleName": "Trades", + "description": "Plots Trades.", + "profilePicture": "Trades.png", + "panels": [] + }, + { + "codeName": "SimulationExecution", + "moduleName": "SimulationExecution", + "description": "Plots Simulation Execution.", + "profilePicture": "SimulationExecution.png", + "panels": [ + { + "codeName": "SimulationExecutionPanel", + "moduleName": "SimulationExecutionPanel", + "event": "Current Record Changed" + } + ] + } + ], + "repo": "Plotters-Trading-Simulation", + "configFile": "this.plotter.config.json" + }, + { + "displayName": "Plotters Bollinger Channels", + "codeName": "PlottersBollingerChannels", + "devTeam": "AAMasters", + "modules": [ + { + "codeName": "BollingerChannels", + "moduleName": "BollingerChannels", + "description": "Plots Bollinger Channels.", + "profilePicture": "BollingerChannels.png", + "panels": [ + { + "codeName": "ChannelPanel", + "moduleName": "ChannelPanel", + "event": "Current Channel Changed" + } + ] + }, + { + "codeName": "BollingerSubChannels", + "moduleName": "BollingerSubChannels", + "description": "Plots Bollinger Sub-Channels.", + "profilePicture": "BollingerSubChannels.png", + "panels": [ + { + "codeName": "SubChannelPanel", + "moduleName": "SubChannelPanel", + "event": "Current Sub-Channel Changed" + } + ] + } + ], + "repo": "Plotters-Bollinger-Channels", + "configFile": "this.plotter.config.json" + } + ] + }, + { + "codeName": "AAVikings", + "displayName": "Vikings", + "host": { + "url": "https://demo-api-dev.superalgos.org/", + "container": "aavikings", + "storage": "localStorage", + "accessKey": "0f38fea438be5adfc5873228f503c55353fb334406128b16a958851b8e47c118a08f0105dd8985d5479758fc4cc3f56c2e2364c2d7c3d0fdffba8d7e9356056a34629e3b926b1ebb940122d973db30b04fc18fab542cbc1afdc032dccf64b0fe308ee6bbc74f82bd350aaebf723428a50d8a699fa2b4b96d58716986ed24069f" + }, + "bots": [ + { + "codeName": "AAGauss", + "displayName": "Gauss", + "type": "Indicator", + "profilePicture": "Gauss.png", + "repo": "AAGauss-Indicator-Bot", + "configFile": "this.bot.config.json", + "products": [ + { + "codeName": "LRCPoints", + "displayName": "LRCPoints", + "description": "Two sets of files per period that contains LRC points.", + "dataSets": [ + { + "codeName": "Multi-Period-Market", + "type": "Market Files", + "validPeriods": [ + "24-hs", + "12-hs", + "08-hs", + "06-hs", + "04-hs", + "03-hs", + "02-hs", + "01-hs" + ], + "filePath": "AAVikings/AAGauss.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/LRC-Points/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json" + }, + { + "codeName": "Multi-Period-Daily", + "type": "Daily Files", + "validPeriods": [ + "45-min", + "40-min", + "30-min", + "20-min", + "15-min", + "10-min", + "05-min", + "04-min", + "03-min", + "02-min", + "01-min" + ], + "filePath": "AAVikings/AAGauss.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/LRC-Points/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "dataRange": { + "filePath": "AAVikings/AAGauss.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/LRC-Points/Multi-Period-Daily", + "fileName": "Data.Range.@AssetA_@AssetB.json" + } + } + ], + "exchangeList": [ + { + "name": "Poloniex" + }, + { + "name": "Coss" + } + ], + "plotter": { + "devTeam": "AAVikings", + "codeName": "PlotterLinearRegressionCurve", + "moduleName": "LRC" + } + } + ] + } + ], + "plotters": [ + { + "displayName": "Plotter LRC", + "codeName": "PlotterLinearRegressionCurve", + "devTeam": "AAVikings", + "modules": [ + { + "codeName": "LRC", + "moduleName": "LRC", + "description": "Plots the linear regression curve.", + "profilePicture": "LRC.png", + "panels": [ + { + "codeName": "ChannelPanel", + "moduleName": "ChannelPanel", + "event": "Current LRC Changed" + } + ] + } + ], + "repo": "Plotters-Linear-Regression-Curve", + "configFile": "this.plotter.config.json" + } + ] + } + ], + "hosts": [ + { + "codeName": "AAMasters", + "displayName": "AA Arena", + "host": { + "url": "https://demo-api-dev.superalgos.org/", + "storage": "localStorage", + "container": "aamasters", + "accessKey": "09e890b76767ede3e10f0526b5036600a6b8d3faac540336e12b493fdb2aa9ed46f86094c34652f99fb6322e5f09806412f17725807f85e4dc4169bd22dd59f0b23aba5251f5544478a1aabf5a2dea5260e6eb0c29af3a788208af85025a02f94950437d501b91fd55b9d97b3d6ac3af4e1161321f78b73ca0fda524dc3a5d03" + }, + "competitions": [ + { + "codeName": "Weekend-Deathmatch", + "description": "First AA Internal Competition. Bots will be trading during 3 days at the USDT/BTC market of Poloniex to see who can make the gratest return over investment (ROI).", + "displayName": "AA Internal Challenge", + "startDatetime": "2018-01-01T16:00:00.000Z", + "finishDatetime": "2018-01-02T16:00:00.000Z", + "formula": "ROI", + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersROI", + "host": { + "url": "https://demo-api-dev.superalgos.org/", + "storage": "localStorage", + "container": "aamasters", + "accessKey": "" + }, + "moduleName": "CombinedProfits", + "repo": "Plotters-ROI" + }, + "rules": [], + "prizes": [], + "participants": [], + "repo": "Weekend-Deathmatch", + "configFile": "this.competition.config.json" + } + ], + "plotters": [ + { + "displayName": "Plotters ROI", + "codeName": "PlottersROI", + "devTeam": "AAMasters", + "modules": [ + { + "codeName": "CombinedProfits", + "moduleName": "CombinedProfits", + "description": "Plots participants of a competition by the ROI each one had over time.", + "panels": [] + } + ], + "repo": "Plotters-ROI", + "configFile": "this.plotter.config.json" + } + ] + } + ] +} diff --git a/src/db.js b/src/db.js new file mode 100644 index 000000000..8bbcd0c63 --- /dev/null +++ b/src/db.js @@ -0,0 +1,10 @@ +import mongoose from 'mongoose'; + +mongoose.connect(process.env.MONGO_URL, { useNewUrlParser: true }) +mongoose.set('useCreateIndex', true); +mongoose.set('useFindAndModify', false); +mongoose.Promise = global.Promise; + +const db = mongoose.connection; + +export default db; diff --git a/src/errors/index.js b/src/errors/index.js new file mode 100644 index 000000000..4680e2202 --- /dev/null +++ b/src/errors/index.js @@ -0,0 +1,23 @@ +export class AuthenticationError extends Error { + constructor(message) { + super(message) + this.code = 401 + this.message = 'Authentication not found, you have to be authenticated to perform this action.' + } +} + +export class WrongArgumentsError extends Error { + constructor(message) { + super(message) + this.code = 400 + this.message = `Wrong arguments : ${this.message}` + } +} + +export class ServiceUnavailableError extends Error { + constructor(message) { + super(message) + this.code = 503 + this.message = `At least one service is unresponding ${this.message}` + } +} diff --git a/src/errors/notAllowed.json b/src/errors/notAllowed.json new file mode 100644 index 000000000..b76604aa2 --- /dev/null +++ b/src/errors/notAllowed.json @@ -0,0 +1,8 @@ +{ + "errors": [ + { + "code": 401, + "message": "Wait, you're not supposed to be here, go through the gate as everyone else" + } + ] +} diff --git a/src/index.js b/src/index.js new file mode 100644 index 000000000..59744b324 --- /dev/null +++ b/src/index.js @@ -0,0 +1,2 @@ +require = require('esm')(module) +module.exports = require('./app.js') diff --git a/src/models/ecosystem.js b/src/models/ecosystem.js new file mode 100644 index 000000000..e50759767 --- /dev/null +++ b/src/models/ecosystem.js @@ -0,0 +1,343 @@ +const mongoose = require('mongoose') +const { Schema } = require('mongoose') + +const ecosystemSchema = new Schema({ + authId: { + type: String, + required: true + }, + devTeams: [{ + codeName: { + type: String, + required: true + }, + displayName: { + type: String, + required: true + }, + host: { + url: { + type: String, + required: true + }, + storage: { + type: String, + required: true + }, + container: { + type: String, + required: true + }, + accessKey: { + type: String, + required: false + }, + ownerKey: { + type: String, + required: false + } + }, + bots: [{ + codeName: { + type: String, + required: true + }, + displayName: { + type: String, + required: true + }, + type: { + type: String, + required: true + }, + profilePicture: { + type: String, + required: true + }, + repo: { + type: String, + required: false + }, + configFile: { + type: String, + required: false + }, + cloneId: { + type: String, + required: false + }, + products: [{ + codeName: { + type: String, + required: true + }, + displayName: { + type: String, + required: true + }, + description: { + type: String, + required: true + }, + dataSets: [{ + codeName: { + type: String, + required: true + }, + type: { + type: String, + required: true + }, + validPeriods: [{ + type: String, + required: true + }], + filePath: { + type: String, + required: true + }, + fileName: { + type: String, + required: true + }, + dataRange: { + filePath: { + type: String, + required: false + }, + fileName: { + type: String, + required: false + }, + }, + }], + exchangeList: [{ + name: { + type: String, + required: true + } + }], + plotter: { + codeName: { + type: String, + required: false + }, + devTeam: { + type: String, + required: false + }, + moduleName: { + type: String, + required: true + }, + } + }] + }], + plotters: [{ + codeName: { + type: String, + required: true + }, + displayName: { + type: String, + required: true + }, + modules: [{ + codeName: { + type: String, + required: true + }, + moduleName: { + type: String, + required: true + }, + description: { + type: String, + required: false + }, + profilePicture: { + type: String, + required: false + }, + panels: [{ + codeName: { + type: String, + required: true + }, + moduleName: { + type: String, + required: true + }, + event: { + type: String, + required: true + } + }], + }], + repo: { + type: String, + required: true + }, + configFile: { + type: String, + required: true + } + }] + }], + hosts: [{ + codeName: { + type: String, + required: true + }, + displayName: { + type: String, + required: true + }, + host: { + url: { + type: String, + required: true + }, + storage: { + type: String, + required: true + }, + container: { + type: String, + required: true + }, + accessKey: { + type: String, + required: false + } + }, + competitions: [{ + codeName: { + type: String, + required: true + }, + displayName: { + type: String, + required: true + }, + description: { + type: String, + required: false + }, + startDatetime: { + type: String, + required: false + }, + finishDatetime: { + type: String, + required: false + }, + formula: { + type: String, + required: false + }, + plotter: { + devTeam: { + type: String, + required: true + }, + codeName: { + type: String, + required: true + }, + host: { + url: { + type: String, + required: true + }, + storage: { + type: String, + required: true + }, + container: { + type: String, + required: true + }, + accessKey: { + type: String, + required: false + } + }, + repo: { + type: String, + required: true + }, + moduleName: { + type: String, + required: true + }, + }, + participants: [{ + type: String, + required: false + }], + repo: { + type: String, + required: true + }, + configFile: { + type: String, + required: true + } + }], + plotters: [{ + codeName: { + type: String, + required: true + }, + displayName: { + type: String, + required: true + }, + modules: [{ + codeName: { + type: String, + required: true + }, + moduleName: { + type: String, + required: true + }, + description: { + type: String, + required: false + }, + profilePicture: { + type: String, + required: false + }, + panels: [{ + codeName: { + type: String, + required: true + }, + moduleName: { + type: String, + required: true + }, + event: { + type: String, + required: true + } + }], + }], + repo: { + type: String, + required: true + }, + configFile: { + type: String, + required: true + } + }] + }] +}) + +const Ecosystem = mongoose.model('Ecosystem', ecosystemSchema); + +export default Ecosystem; diff --git a/src/models/index.js b/src/models/index.js new file mode 100644 index 000000000..7f988ec48 --- /dev/null +++ b/src/models/index.js @@ -0,0 +1,5 @@ +import Ecosystem from './ecosystem'; + +export { + Ecosystem +}; diff --git a/src/schema/index.js b/src/schema/index.js new file mode 100644 index 000000000..59088712f --- /dev/null +++ b/src/schema/index.js @@ -0,0 +1,12 @@ +import { + GraphQLSchema, +} from 'graphql'; +import RootQuery from './queries'; +import Mutation from './mutations'; + +const Schema = new GraphQLSchema({ + query: RootQuery, + mutation: Mutation, +}); + +export default Schema; diff --git a/src/schema/mutations/AddBot.js b/src/schema/mutations/AddBot.js new file mode 100644 index 000000000..86d972b68 --- /dev/null +++ b/src/schema/mutations/AddBot.js @@ -0,0 +1,71 @@ +import logger from '../../utils/logger' +import { BotInputType, } from '../types/input' +import { BotType, } from '../types' +import { Ecosystem } from '../../models' + +export const args = { bot: { type: BotInputType } } + +const resolve = async (parent, { bot }, context) => { + logger.debug('addBot -> Dev team: %s. Bot: %s', bot.devTeam, bot.codeName) + try { + + let userEcosystem = await Ecosystem.findOne({ + authId: context.userId + }) + + if (!userEcosystem) { + throw 'Ecosystem not found for the user.' + } + + let newBotClone + for (let i = 0; i < userEcosystem.devTeams.length; i++) { + const auxTeam = userEcosystem.devTeams[i] + if (auxTeam.codeName === bot.devTeam) { + for (let j = 0; j < auxTeam.bots.length; j++) { + const auxBot = auxTeam.bots[j] + if (auxBot.codeName === bot.codeName) { + for (let k = 0; k < auxBot.products.length; k++) { + const auxProduct = auxBot.products[k] + if (auxProduct.codeName === bot.productCodeName) { + newBotClone = { + displayName: auxBot.displayName, + codeName: auxBot.codeName, + type: auxBot.type, + profilePicture: auxBot.profilePicture, + cloneId: bot.cloneId, + products: [auxProduct] + } + auxTeam.bots.push(newBotClone) + userEcosystem.markModified("devTeams") + break + } + } + break + } + } + break + } + } + + if (newBotClone) { + await userEcosystem.save() + return newBotClone + } else { + throw 'Algobot not found.' + } + + } catch (err) { + logger.error('addBot -> Error: %s', err.message) + throw err + } +} + +const mutation = { + addBot: { + type: BotType, + args, + resolve, + } +} + +export default mutation; diff --git a/src/schema/mutations/AddTeam.js b/src/schema/mutations/AddTeam.js new file mode 100644 index 000000000..73c7c6918 --- /dev/null +++ b/src/schema/mutations/AddTeam.js @@ -0,0 +1,89 @@ +import logger from '../../utils/logger' +import { AuthenticationError, WrongArgumentsError } from '../../errors' +import { TeamType } from '../types' +import { Ecosystem } from '../../models' +import { TeamInputType } from '../types/input' +import { copyBot } from '../../storage/CopyBot' +import { copySimulator } from '../../storage/CopySimulator' +import { createContainer, writeFileContent } from '../../storage/providers/MinioStorage' +import crypto from 'crypto' + +export const args = { team: { type: TeamInputType } } + +const resolve = async (parent, { team }, context) => { + logger.debug('addTeam -> Entering Function.') + + if (!context.userId) { + throw new AuthenticationError() + } + + try { + let userEcosystem = await Ecosystem.findOne({ + authId: context.userId + }) + + if (!userEcosystem) { + logger.debug('addTeam -> Ecosystem not found for the user, creating a new one from default.') + + let defaultEcosystem = require('../../config/ecosystem.json') + userEcosystem = new Ecosystem(defaultEcosystem) + userEcosystem.authId = context.userId + } + + for (let i = 0; i < userEcosystem.devTeams.length; i++) { + const auxTeam = userEcosystem.devTeams[i]; + if (auxTeam.codeName === team.codeName) { + throw new WrongArgumentsError("The team already exist on the user ecosystem.") + } + } + + // Teams will be created on a local minio container + let botsConfigurations = [] + try { + await createContainer(team.codeName) + } catch (err) { + if (err.message !== 'Your previous request to create the named bucket succeeded and you already own it.') { + logger.error('addTeam -> Error: %s', err.stack) + throw err + } else { + logger.warn('addTeam -> %s', err.message) + } + } + + let tradingBot = await copyBot(team.codeName, team.bot.codeName, team.bot.displayName, writeFileContent) + botsConfigurations.push(tradingBot) + let simulatorBot = await copySimulator(team.codeName, team.bot.codeName, team.bot.displayName, writeFileContent) + botsConfigurations.push(simulatorBot) + + team.bots = botsConfigurations + + if (!team.host) { + let nodeEndpoint = { + url: process.env.NODE_ENDPOINT, + storage: 'localStorage', + container: team.codeName, + accessKey: crypto.randomBytes(128).toString('hex'), + ownerKey: crypto.randomBytes(128).toString('hex') + } + team.host = nodeEndpoint + } + + userEcosystem.devTeams.push(team) + userEcosystem.markModified("devTeams") + await userEcosystem.save() + return team + } catch (err) { + logger.error('addTeam -> Error: %s', err.stack) + throw err + } +} + +const mutation = { + addTeam: { + type: TeamType, + args, + resolve, + } +} + +export default mutation; diff --git a/src/schema/mutations/CreateFile.js b/src/schema/mutations/CreateFile.js new file mode 100644 index 000000000..b1e501e80 --- /dev/null +++ b/src/schema/mutations/CreateFile.js @@ -0,0 +1,40 @@ +import logger from '../../utils/logger' +import { FileInputType } from '../types/input' +import { GraphQLString } from 'graphql' +import { writeFileContent } from '../../storage/providers/MinioStorage' +import { AuthenticationError, WrongArgumentsError } from '../../errors' +import getDevTeamHost from '../../utils/getDevTeamHost' + +export const args = { file: { type: FileInputType } } + +const resolve = async (parent, { file }, context) => { + try { + if (file.accessKey === undefined || file.accessKey === null) { + throw new WrongArgumentsError() + } + + let host = await getDevTeamHost(file.container, undefined, file.accessKey) + + if (host === undefined || host === null) { + throw new AuthenticationError() + } + let date = new Date() + await writeFileContent(file.container, file.filePath, file.fileContent) + let dateAfter = new Date() + logger.info('createFile: ' + file.container + '/...' + file.filePath.substring(file.filePath.length -110 , file.filePath.length) + ', ' + (dateAfter - date)) + return 'File created.' + } catch (err) { + logger.error('createFile -> Error: %s', err.message) + throw err + } +} + +const mutation = { + createFile: { + type: GraphQLString, + args, + resolve, + } +} + +export default mutation; diff --git a/src/schema/mutations/DeleteTeam.js b/src/schema/mutations/DeleteTeam.js new file mode 100644 index 000000000..6c1fbc0f8 --- /dev/null +++ b/src/schema/mutations/DeleteTeam.js @@ -0,0 +1,61 @@ +import logger from '../../utils/logger' +import { AuthenticationError, WrongArgumentsError } from '../../errors' +import { TeamType } from '../types' +import { Ecosystem } from '../../models' +import { DeleteTeamInputType } from '../types/input' +import { deleteContainer } from '../../storage/providers/MinioStorage' + +export const args = { team: { type: DeleteTeamInputType } } + +const resolve = async (parent, { team }, context) => { + logger.debug('deleteTeam -> Entering Function.') + + if (!context.userId) { + throw new AuthenticationError() + } + + try { + let userEcosystem = await Ecosystem.findOne({ + authId: context.userId + }) + + if (!userEcosystem) { + logger.debug('deleteTeam -> Ecosystem not found for the user.') + throw new WrongArgumentsError('The user does not have an ecosystem configured.') + } + + let teamFound = false + for (let i = 0; i < userEcosystem.devTeams.length; i++) { + const auxTeam = userEcosystem.devTeams[i] + if (auxTeam.codeName === team.codeName) { + logger.debug('deleteTeam -> Team found, removing.') + teamFound = true + await deleteContainer(team.codeName) + userEcosystem.devTeams.splice(i, 1) + userEcosystem.markModified("devTeams") + await userEcosystem.save() + break + } + } + + if (!teamFound) { + throw new WrongArgumentsError('Team was not found on the user ecosystem.') + } else { + return team + } + + } catch (err) { + logger.error('deleteTeam -> Error: %s', err.stack) + throw err + } +} + +const mutation = { + deleteTeam: { + type: TeamType, + args, + resolve, + } +} + +export default mutation; diff --git a/src/schema/mutations/RemoveBot.js b/src/schema/mutations/RemoveBot.js new file mode 100644 index 000000000..83249f703 --- /dev/null +++ b/src/schema/mutations/RemoveBot.js @@ -0,0 +1,64 @@ +import logger from '../../utils/logger' +import { BotInputType, } from '../types/input' +import { BotType, } from '../types' +import { Ecosystem } from '../../models' + +export const args = { bot: { type: BotInputType } } + +const resolve = async (parent, { bot }, context) => { + logger.debug('removeBot -> Dev team: %s. Bot: %s', bot.devTeam, bot.codeName) + try { + + let userEcosystem = await Ecosystem.findOne({ + authId: context.userId + }) + + if (!userEcosystem) { + throw 'Ecosystem not found for the user.' + } + + let removedBotClone + for (let i = 0; i < userEcosystem.devTeams.length; i++) { + const auxTeam = userEcosystem.devTeams[i] + if (auxTeam.codeName === bot.devTeam) { + for (let j = 0; j < auxTeam.bots.length; j++) { + const auxBot = auxTeam.bots[j] + if (auxBot.codeName === bot.codeName && auxBot.cloneId === bot.cloneId) { + for (let k = 0; k < auxBot.products.length; k++) { + const auxProduct = auxBot.products[k] + if (auxProduct.codeName === bot.productCodeName) { + removedBotClone = auxBot + auxTeam.bots.splice(j, 1) + userEcosystem.markModified("devTeams") + break + } + } + break + } + } + break + } + } + + if (removedBotClone) { + await userEcosystem.save() + return removedBotClone + } else { + throw 'Algobot not found.' + } + + } catch (err) { + logger.error('removeBot -> Error: %s', err.message) + throw err + } +} + +const mutation = { + removeBot: { + type: BotType, + args, + resolve, + } +} + +export default mutation; diff --git a/src/schema/mutations/index.js b/src/schema/mutations/index.js new file mode 100644 index 000000000..be7aad941 --- /dev/null +++ b/src/schema/mutations/index.js @@ -0,0 +1,22 @@ +import { + GraphQLObjectType, +} from 'graphql' + +import AddTeamMutation from './AddTeam' +import DeleteTeamMutation from './DeleteTeam' +import CreateFileMutation from './CreateFile' +import AddBotMutation from './AddBot' +import RemoveBotMutation from './RemoveBot' + +const Mutation = new GraphQLObjectType({ + name: 'Mutation', + fields: Object.assign( + AddTeamMutation, + DeleteTeamMutation, + CreateFileMutation, + AddBotMutation, + RemoveBotMutation + ) +}) + +export default Mutation diff --git a/src/schema/queries/Ecosystem.js b/src/schema/queries/Ecosystem.js new file mode 100644 index 000000000..d6eeafb6f --- /dev/null +++ b/src/schema/queries/Ecosystem.js @@ -0,0 +1,42 @@ +import logger from '../../utils/logger' +import { Ecosystem } from '../../models' +import { EcosystemType } from '../types' + +const args = {} + +const resolve = async (parent, args, context) => { + logger.debug('getEcosystem -> Entering Function.') + + try { + if (!context.userId) { + logger.debug('getEcosystem -> User not logged in, returning default ecosystem.') + let defaultEcosystem = require('../../config/ecosystem.json') + return defaultEcosystem + } else { + let userEcosystem = await Ecosystem.findOne({ + authId: context.userId + }) + + if (!userEcosystem) { + logger.debug('addTeam -> Ecosystem not found for the user, retrieving default.') + let defaultEcosystem = require('../../config/ecosystem.json') + return defaultEcosystem + } + + return userEcosystem + } + } catch (err) { + logger.error('getEcosystem -> Error: %s', err.stack) + throw err + } +} + +const query = { + getEcosystem: { + type: EcosystemType, + args, + resolve, + } +} + +export default query diff --git a/src/schema/queries/FileContent.js b/src/schema/queries/FileContent.js new file mode 100644 index 000000000..43bf10c3d --- /dev/null +++ b/src/schema/queries/FileContent.js @@ -0,0 +1,47 @@ +import logger from '../../utils/logger' +import { FileInputType } from '../types/input' +import { GraphQLString } from 'graphql' +import { getFileContent } from '../../storage/providers/MinioStorage' +import { AuthenticationError, WrongArgumentsError } from '../../errors' +import getDevTeamHost from '../../utils/getDevTeamHost' + +export const args = { file: { type: FileInputType } } + +const resolve = async (parent, { file }, context) => { + try { + if (file.accessKey === undefined || file.accessKey === null) { + throw new WrongArgumentsError() + } + + let host = await getDevTeamHost(file.container, file.accessKey) + + if (host === undefined || host === null) { + logger.error('Error getting file:' + JSON.stringify(file)) + throw new AuthenticationError() + } + + let date = new Date() + let fileContent = await getFileContent(file.container, file.filePath) + let dateAfter = new Date() + logger.info('getFileContent: ' + file.container + '/...' + file.filePath.substring(file.filePath.length -110 , file.filePath.length) + ', ' + (dateAfter - date)) + return fileContent + + } catch (err) { + if (err.message === 'The specified key does not exist.') + logger.debug('getFileContent -> Error: %s', err.message) + else { + logger.error('getFileContent -> Error: %s', err.message) + throw err + } + } +} + +const query = { + fileContent: { + type: GraphQLString, + args, + resolve, + } +} + +export default query diff --git a/src/schema/queries/PlotterCode.js b/src/schema/queries/PlotterCode.js new file mode 100644 index 000000000..6008bd919 --- /dev/null +++ b/src/schema/queries/PlotterCode.js @@ -0,0 +1,53 @@ +import logger from '../../utils/logger' +import { FileInputType } from '../types/input' +import { GraphQLString } from 'graphql' +import { getFileContent } from '../../storage/providers/MinioStorage' +import { getFileContentRemote } from '../../storage/providers/AzureStorage' + +export const args = { file: { type: FileInputType } } + +const resolve = async (parent, { file }, context) => { + logger.debug('getPlotterCode -> Entering Function: ' + file.container + '/' + file.filePath) + + try { + + let fileContent + if (file.storage === '' || file.storage === undefined) { + //TODO Add permissions + fileContent = await getFileContent(file.container, file.filePath) + } else { + // TODO Temporary fix for plotter and plotter pannels + if (file.storage === '' && file.accessKey === '') { + let defaultEcosystem = require('../../config/ecosystem.json') + for (let index = 0; index < defaultEcosystem.devTeams.length; index++) { + const devTeam = defaultEcosystem.devTeams[index]; + if (devTeam.codeName.toLowerCase() === file.container) { + file.storage = devTeam.host.storage + file.accessKey = devTeam.host.accessKey + } + } + } + if (file.storage === '' || file.accessKey === '') { + throw "Wrong parameters." + } + fileContent = await getFileContentRemote(file.container, file.filePath, file.storage, file.accessKey) + } + + return fileContent + + } catch (err) { + logger.error('getPlotterCode -> Error: %s', err) + logger.error('getPlotterCode -> Stack: %s', err.stack) + throw err + } +} + +const query = { + plotterCode: { + type: GraphQLString, + args, + resolve, + } +} + +export default query diff --git a/src/schema/queries/index.js b/src/schema/queries/index.js new file mode 100644 index 000000000..2551f88ec --- /dev/null +++ b/src/schema/queries/index.js @@ -0,0 +1,18 @@ +import { + GraphQLObjectType, +} from 'graphql'; + +import EcosystemQuery from './Ecosystem'; +import FileContentQuery from './FileContent'; +import PlotterCodeQuery from './PlotterCode'; + +const RootQuery = new GraphQLObjectType({ + name: 'RootQueryType', + fields: Object.assign( + EcosystemQuery, + FileContentQuery, + PlotterCodeQuery + ), +}); + +export default RootQuery; diff --git a/src/schema/types/Bot.js b/src/schema/types/Bot.js new file mode 100644 index 000000000..347587f02 --- /dev/null +++ b/src/schema/types/Bot.js @@ -0,0 +1,28 @@ +import { + GraphQLObjectType, + GraphQLString, + GraphQLList +} from 'graphql'; + +import { ProductType } from './index' + +const BotType = new GraphQLObjectType({ + name: 'Bot', + fields: () => ({ + codeName: { type: GraphQLString }, + displayName: { type: GraphQLString }, + type: { type: GraphQLString }, + profilePicture: { type: GraphQLString }, + repo: { type: GraphQLString }, + configFile: { type: GraphQLString }, + cloneId: { type: GraphQLString }, + products: { + type: new GraphQLList(ProductType), + resolve(parent) { + return parent.products; + } + }, + }), +}); + +export default BotType; diff --git a/src/schema/types/Competition.js b/src/schema/types/Competition.js new file mode 100644 index 000000000..16f42cd4a --- /dev/null +++ b/src/schema/types/Competition.js @@ -0,0 +1,32 @@ +import { + GraphQLObjectType, + GraphQLString, + GraphQLList +} from 'graphql'; + +import { PlotterReferenceType } from './index'; + +const CompetitionType = new GraphQLObjectType({ + name: 'Competition', + fields: () => ({ + codeName: { type: GraphQLString }, + displayName: { type: GraphQLString }, + description: { type: GraphQLString }, + startDatetime: { type: GraphQLString }, + finishDatetime: { type: GraphQLString }, + formula: { type: GraphQLString }, + plotter: { + type: PlotterReferenceType, + resolve(parent) { + return parent.plotter; + } + }, + rules:{ type: new GraphQLList(GraphQLString) }, + prizes:{ type: new GraphQLList(GraphQLString) }, + participants:{ type: new GraphQLList(GraphQLString) }, + repo: { type: GraphQLString }, + configFile: { type: GraphQLString } + }), +}); + +export default CompetitionType; diff --git a/src/schema/types/DataRange.js b/src/schema/types/DataRange.js new file mode 100644 index 000000000..aebeb3cd7 --- /dev/null +++ b/src/schema/types/DataRange.js @@ -0,0 +1,14 @@ +import { + GraphQLObjectType, + GraphQLString +} from 'graphql'; + +const DataRangeType = new GraphQLObjectType({ + name: 'DataRange', + fields: () => ({ + filePath: { type: GraphQLString }, + fileName: { type: GraphQLString } + }), +}); + +export default DataRangeType; diff --git a/src/schema/types/DataSet.js b/src/schema/types/DataSet.js new file mode 100644 index 000000000..a96ff8ff5 --- /dev/null +++ b/src/schema/types/DataSet.js @@ -0,0 +1,21 @@ +import { + GraphQLObjectType, + GraphQLString, + GraphQLList +} from 'graphql'; + +import { DataRangeType } from './index' + +const DataSetType = new GraphQLObjectType({ + name: 'DataSet', + fields: () => ({ + codeName: { type: GraphQLString }, + type: { type: GraphQLString }, + validPeriods: { type: new GraphQLList(GraphQLString) }, + filePath: { type: GraphQLString }, + fileName: { type: GraphQLString }, + dataRange: { type: DataRangeType } + }), +}); + +export default DataSetType; diff --git a/src/schema/types/Ecosystem.js b/src/schema/types/Ecosystem.js new file mode 100644 index 000000000..8fabc5847 --- /dev/null +++ b/src/schema/types/Ecosystem.js @@ -0,0 +1,31 @@ +import { + GraphQLObjectType, + GraphQLString, + GraphQLID, + GraphQLList +} from 'graphql'; + +import { TeamType, EventHostType } from './index'; + +const EcosystemType = new GraphQLObjectType({ + name: 'Ecosystem', + fields: () => ({ + id: { type: GraphQLID }, + authId: { type: GraphQLString }, + userName: { type: GraphQLString }, // TODO this field is temporary, it should be used the user module query + devTeams: { + type: new GraphQLList(TeamType), + resolve(parent) { + return parent.devTeams; + } + }, + hosts: { + type: new GraphQLList(EventHostType), + resolve(parent) { + return parent.hosts; + } + } + }), +}); + +export default EcosystemType; diff --git a/src/schema/types/EventHost.js b/src/schema/types/EventHost.js new file mode 100644 index 000000000..c951dabba --- /dev/null +++ b/src/schema/types/EventHost.js @@ -0,0 +1,37 @@ +import { + GraphQLObjectType, + GraphQLString, + GraphQLList +} from 'graphql'; + +import { CompetitionType, PlotterType, HostType } from './index'; + +const EventHostType = new GraphQLObjectType({ + name: 'EventHost', + fields: () => ({ + codeName: { type: GraphQLString }, + displayName: { type: GraphQLString }, + host: { + type: HostType, + resolve(parent) { + return parent.host; + } + }, + container: { type: GraphQLString }, + accessKey: { type: GraphQLString }, + competitions: { + type: new GraphQLList(CompetitionType), + resolve(parent) { + return parent.competitions; + } + }, + plotters: { + type: new GraphQLList(PlotterType), + resolve(parent) { + return parent.plotters; + } + } + }), +}); + +export default EventHostType; diff --git a/src/schema/types/Exchange.js b/src/schema/types/Exchange.js new file mode 100644 index 000000000..b80b7ec03 --- /dev/null +++ b/src/schema/types/Exchange.js @@ -0,0 +1,13 @@ +import { + GraphQLObjectType, + GraphQLString +} from 'graphql'; + +const ExchangeType = new GraphQLObjectType({ + name: 'Exchange', + fields: () => ({ + name: { type: GraphQLString } + }), +}); + +export default ExchangeType; diff --git a/src/schema/types/File.js b/src/schema/types/File.js new file mode 100644 index 000000000..bf3c11136 --- /dev/null +++ b/src/schema/types/File.js @@ -0,0 +1,17 @@ +import { + GraphQLObjectType, + GraphQLString +} from 'graphql'; + +const FileType = new GraphQLObjectType({ + name: 'File', + fields: () => ({ + container: { type: GraphQLString }, + filePath: { type: GraphQLString }, + storage: { type: GraphQLString }, + accessKey: { type: GraphQLString }, + fileContent: { type: GraphQLString } + }), +}); + +export default FileType; diff --git a/src/schema/types/Host.js b/src/schema/types/Host.js new file mode 100644 index 000000000..0b36b8e00 --- /dev/null +++ b/src/schema/types/Host.js @@ -0,0 +1,17 @@ +import { + GraphQLObjectType, + GraphQLString +} from 'graphql'; + +const HostType = new GraphQLObjectType({ + name: 'Host', + fields: () => ({ + url: { type: GraphQLString }, + storage: { type: GraphQLString }, + container: { type: GraphQLString }, + accessKey: { type: GraphQLString }, + ownerKey: { type: GraphQLString } + }), +}); + +export default HostType; diff --git a/src/schema/types/Module.js b/src/schema/types/Module.js new file mode 100644 index 000000000..eb1addabb --- /dev/null +++ b/src/schema/types/Module.js @@ -0,0 +1,25 @@ +import { + GraphQLObjectType, + GraphQLString, + GraphQLList +} from 'graphql' + +import { PanelType } from './index' + +const ModuleType = new GraphQLObjectType({ + name: 'Module', + fields: () => ({ + codeName: { type: GraphQLString }, + moduleName: { type: GraphQLString }, + description: { type: GraphQLString }, + profilePicture: { type: GraphQLString }, + panels: { + type: new GraphQLList(PanelType), + resolve(parent) { + return parent.panels; + } + } + }), +}); + +export default ModuleType; diff --git a/src/schema/types/Panel.js b/src/schema/types/Panel.js new file mode 100644 index 000000000..a3e19b4aa --- /dev/null +++ b/src/schema/types/Panel.js @@ -0,0 +1,15 @@ +import { + GraphQLObjectType, + GraphQLString +} from 'graphql'; + +const PanelType = new GraphQLObjectType({ + name: 'Panel', + fields: () => ({ + codeName: { type: GraphQLString }, + moduleName: { type: GraphQLString }, + event: { type: GraphQLString } + }), +}); + +export default PanelType; diff --git a/src/schema/types/Plotter.js b/src/schema/types/Plotter.js new file mode 100644 index 000000000..b0b672625 --- /dev/null +++ b/src/schema/types/Plotter.js @@ -0,0 +1,26 @@ +import { + GraphQLObjectType, + GraphQLString, + GraphQLList +} from 'graphql'; + +import { ModuleType } from './index' + +const PlotterType = new GraphQLObjectType({ + name: 'Plotter', + fields: () => ({ + codeName: { type: GraphQLString }, + displayName: { type: GraphQLString }, + host: { type: GraphQLString }, + modules: { + type: new GraphQLList(ModuleType), + resolve(parent) { + return parent.modules; + } + }, + repo: { type: GraphQLString }, + configFile: { type: GraphQLString } + }), +}); + +export default PlotterType; diff --git a/src/schema/types/PlotterReference.js b/src/schema/types/PlotterReference.js new file mode 100644 index 000000000..06baa44f0 --- /dev/null +++ b/src/schema/types/PlotterReference.js @@ -0,0 +1,24 @@ +import { + GraphQLObjectType, + GraphQLString +} from 'graphql'; + +import { HostType } from './index'; + +const PlotterReferenceType = new GraphQLObjectType({ + name: 'PlotterReference', + fields: () => ({ + devTeam: { type: GraphQLString }, + codeName: { type: GraphQLString }, + host: { + type: HostType, + resolve(parent) { + return parent.host; + } + }, + moduleName: { type: GraphQLString }, + repo: { type: GraphQLString } + }), +}); + +export default PlotterReferenceType; diff --git a/src/schema/types/Product.js b/src/schema/types/Product.js new file mode 100644 index 000000000..1494872c3 --- /dev/null +++ b/src/schema/types/Product.js @@ -0,0 +1,31 @@ +import { + GraphQLObjectType, + GraphQLString, + GraphQLList +} from 'graphql'; + +import { ExchangeType, DataSetType, PlotterReferenceType } from './index' + +const ProductType = new GraphQLObjectType({ + name: 'Product', + fields: () => ({ + codeName: { type: GraphQLString }, + displayName: { type: GraphQLString }, + description: { type: GraphQLString }, + dataSets: { + type: new GraphQLList(DataSetType), + resolve(parent) { + return parent.dataSets; + } + }, + exchangeList: { + type: new GraphQLList(ExchangeType), + resolve(parent) { + return parent.exchangeList; + } + }, + plotter: { type: PlotterReferenceType } + }), +}); + +export default ProductType; diff --git a/src/schema/types/Team.js b/src/schema/types/Team.js new file mode 100644 index 000000000..00607f192 --- /dev/null +++ b/src/schema/types/Team.js @@ -0,0 +1,35 @@ +import { + GraphQLObjectType, + GraphQLString, + GraphQLList +} from 'graphql'; + +import { BotType, PlotterType, HostType } from './index'; + +const TeamType = new GraphQLObjectType({ + name: 'Team', + fields: () => ({ + codeName: { type: GraphQLString }, + displayName: { type: GraphQLString }, + host: { + type: HostType, + resolve(parent) { + return parent.host; + } + }, + bots: { + type: new GraphQLList(BotType), + resolve(parent) { + return parent.bots; + } + }, + plotters: { + type: new GraphQLList(PlotterType), + resolve(parent) { + return parent.plotters; + } + } + }), +}); + +export default TeamType; diff --git a/src/schema/types/index.js b/src/schema/types/index.js new file mode 100644 index 000000000..31708e9b2 --- /dev/null +++ b/src/schema/types/index.js @@ -0,0 +1,33 @@ +import TeamType from './Team'; +import BotType from './Bot'; +import EventHostType from './EventHost'; +import HostType from './Host'; +import EcosystemType from './Ecosystem'; +import FileType from './File'; +import PanelType from './Panel'; +import ModuleType from './Module'; +import PlotterType from './Plotter'; +import CompetitionType from './Competition'; +import PlotterReferenceType from './PlotterReference'; +import ProductType from './Product'; +import DataSetType from './DataSet'; +import DataRangeType from './DataRange'; +import ExchangeType from './Exchange'; + +export { + TeamType, + BotType, + EventHostType, + HostType, + EcosystemType, + FileType, + PanelType, + ModuleType, + PlotterType, + CompetitionType, + PlotterReferenceType, + ProductType, + DataSetType, + DataRangeType, + ExchangeType +}; diff --git a/src/schema/types/input/Bot.js b/src/schema/types/input/Bot.js new file mode 100644 index 000000000..1fdcd09ad --- /dev/null +++ b/src/schema/types/input/Bot.js @@ -0,0 +1,22 @@ +import { + GraphQLInputObjectType, + GraphQLString, + GraphQLNonNull +} from 'graphql'; + +const Type = new GraphQLInputObjectType({ + name: 'BotInput', + description: 'Payload for bot input.', + fields: () => ({ + codeName: { type: new GraphQLNonNull(GraphQLString) }, + productCodeName: { type: GraphQLString }, + devTeam: { type: GraphQLString}, + displayName: { type: GraphQLString }, + repo: { type: GraphQLString }, + configFile: { type: GraphQLString }, + cloneId: { type: GraphQLString }, + validPeriod: { type: GraphQLString }, + }), +}); + +export default Type; diff --git a/src/schema/types/input/DataSet.js b/src/schema/types/input/DataSet.js new file mode 100644 index 000000000..71efbf934 --- /dev/null +++ b/src/schema/types/input/DataSet.js @@ -0,0 +1,19 @@ +import { + GraphQLInputObjectType, + GraphQLString, + GraphQLList +} from 'graphql'; + +const Type = new GraphQLInputObjectType({ + name: 'DataSetInput', + description: 'Payload for data set input.', + fields: () => ({ + codeName: { type: new GraphQLNonNull(GraphQLString) }, + type: { type: new GraphQLNonNull(GraphQLString) }, + filePath: { type: new GraphQLNonNull(GraphQLString) }, + fileName: { type: new GraphQLNonNull(GraphQLString) }, + validPeriods: { type: new GraphQLList(GraphQLString) } + }), +}); + +export default Type; diff --git a/src/schema/types/input/DeleteTeam.js b/src/schema/types/input/DeleteTeam.js new file mode 100644 index 000000000..bd7ed63d2 --- /dev/null +++ b/src/schema/types/input/DeleteTeam.js @@ -0,0 +1,18 @@ +import { + GraphQLString, + GraphQLInputObjectType, + GraphQLNonNull +} from 'graphql'; + +import { HostInputType } from './index'; + +const Type = new GraphQLInputObjectType({ + name: 'DeleteTeamInput', + description: 'Payload for team input', + fields: () => ({ + codeName: { type: new GraphQLNonNull(GraphQLString) }, + host: { type: HostInputType } + }), +}); + +export default Type; diff --git a/src/schema/types/input/Exchange.js b/src/schema/types/input/Exchange.js new file mode 100644 index 000000000..738aca4ac --- /dev/null +++ b/src/schema/types/input/Exchange.js @@ -0,0 +1,15 @@ +import { + GraphQLInputObjectType, + GraphQLString, + GraphQLNonNull +} from 'graphql'; + +const Type = new GraphQLInputObjectType({ + name: 'ExchangeInput', + description: 'Payload for exchange input.', + fields: () => ({ + name: { type: new GraphQLNonNull(GraphQLString) } + }), +}); + +export default Type; diff --git a/src/schema/types/input/File.js b/src/schema/types/input/File.js new file mode 100644 index 000000000..7b69397ae --- /dev/null +++ b/src/schema/types/input/File.js @@ -0,0 +1,19 @@ +import { + GraphQLInputObjectType, + GraphQLString, + GraphQLNonNull +} from 'graphql'; + +const Type = new GraphQLInputObjectType({ + name: 'FileInput', + description: 'Payload for file input.', + fields: () => ({ + container: { type: new GraphQLNonNull(GraphQLString) }, + filePath: { type: new GraphQLNonNull(GraphQLString) }, + storage: { type: new GraphQLNonNull(GraphQLString) }, + accessKey: { type: GraphQLString }, + fileContent: { type: GraphQLString } + }), +}); + +export default Type; diff --git a/src/schema/types/input/Host.js b/src/schema/types/input/Host.js new file mode 100644 index 000000000..6f9d4bb5f --- /dev/null +++ b/src/schema/types/input/Host.js @@ -0,0 +1,17 @@ +import { + GraphQLInputObjectType, + GraphQLString +} from 'graphql'; + +const Type = new GraphQLInputObjectType({ + name: 'HostInput', + description: 'Payload for host input.', + fields: () => ({ + url: { type: GraphQLString }, + storage: { type: GraphQLString }, + container: { type: GraphQLString }, + accessKey: { type: GraphQLString } + }), +}); + +export default Type; diff --git a/src/schema/types/input/Plotter.js b/src/schema/types/input/Plotter.js new file mode 100644 index 000000000..1faa1a322 --- /dev/null +++ b/src/schema/types/input/Plotter.js @@ -0,0 +1,17 @@ +import { + GraphQLInputObjectType, + GraphQLString, + GraphQLNonNull +} from 'graphql'; + +const Type = new GraphQLInputObjectType({ + name: 'PlotterInput', + description: 'Payload for plotter input.', + fields: () => ({ + devTeam: { type: new GraphQLNonNull(GraphQLString) }, + codeName: { type: new GraphQLNonNull(GraphQLString) }, + moduleName: { type: new GraphQLNonNull(GraphQLString) } + }), +}); + +export default Type; diff --git a/src/schema/types/input/Product.js b/src/schema/types/input/Product.js new file mode 100644 index 000000000..9fb26fab2 --- /dev/null +++ b/src/schema/types/input/Product.js @@ -0,0 +1,24 @@ +import { + GraphQLInputObjectType, + GraphQLString, + GraphQLNonNull +} from 'graphql'; + +import { DataSetInputType } from './index'; +import { ExchangeInputType } from './index'; +import { PlotterInputType } from './index'; + +const Type = new GraphQLInputObjectType({ + name: 'ProductInput', + description: 'Payload for product input.', + fields: () => ({ + codeName: { type: new GraphQLNonNull(GraphQLString) }, + displayName: { type: new GraphQLNonNull(GraphQLString) }, + description: { type: GraphQLString }, + dataSets: { type: new GraphQLList(DataSetInputType) }, + exchangeList: { type: new GraphQLList(ExchangeInputType) }, + plotter: { type: PlotterInputType } + }), +}); + +export default Type; diff --git a/src/schema/types/input/Team.js b/src/schema/types/input/Team.js new file mode 100644 index 000000000..c4423a55a --- /dev/null +++ b/src/schema/types/input/Team.js @@ -0,0 +1,21 @@ +import { + GraphQLString, + GraphQLInputObjectType, + GraphQLNonNull +} from 'graphql'; + +import { BotInputType, HostInputType } from './index'; + +const Type = new GraphQLInputObjectType({ + name: 'TeamInput', + description: 'Payload for team input', + fields: () => ({ + codeName: { type: new GraphQLNonNull(GraphQLString) }, + displayName: { type: new GraphQLNonNull(GraphQLString) }, + host: { type: HostInputType }, + bot: { type: new GraphQLNonNull(BotInputType) }, + plotter: { type: BotInputType } + }), +}); + +export default Type; diff --git a/src/schema/types/input/index.js b/src/schema/types/input/index.js new file mode 100644 index 000000000..6344400c3 --- /dev/null +++ b/src/schema/types/input/index.js @@ -0,0 +1,21 @@ +import TeamInputType from './Team' +import BotInputType from './Bot' +import HostInputType from './Host' +import FileInputType from './File' +import DeleteTeamInputType from './DeleteTeam' +import DataSetInputType from './DataSet' +import ExchangeInputType from './Exchange' +import PlotterInputType from './Plotter' +import ProductInputType from './Product' + +export { + TeamInputType, + BotInputType, + HostInputType, + FileInputType, + DeleteTeamInputType, + DataSetInputType, + ExchangeInputType, + PlotterInputType, + ProductInputType +} diff --git a/src/storage/CopyBot.js b/src/storage/CopyBot.js new file mode 100644 index 000000000..76483c90f --- /dev/null +++ b/src/storage/CopyBot.js @@ -0,0 +1,41 @@ +import beautify from 'json-beautify' +import logger from '../utils/logger' +import readFile from '../utils/readFile' + +export const copyBot = async (teamCodeName, botCodeName, botDisplayName, writeFileContent) => { + try { + logger.debug('copyBot started for bot %s', botCodeName) + // File imports + const botCode = await readFile('./src/storage/templates/TradingBot/User.Bot.js') + const config = await readFile('./src/storage/templates/TradingBot/this.bot.config.json') + + // Change config to adapt the new indicator + let parsedConfig = JSON.parse(config) + parsedConfig.displayName = botDisplayName + parsedConfig.codeName = botCodeName + parsedConfig.devTeam = teamCodeName + parsedConfig.profilePicture = botCodeName + '.png' + + parsedConfig.processes[0].statusDependencies[0].devTeam = teamCodeName + parsedConfig.processes[0].statusDependencies[0].bot = botCodeName + parsedConfig.processes[0].statusDependencies[1].devTeam = teamCodeName + parsedConfig.processes[0].statusDependencies[1].bot = 'simulator-' + botCodeName + parsedConfig.processes[0].statusDependencies[2].devTeam = teamCodeName + parsedConfig.processes[0].statusDependencies[2].bot = 'simulator-' + botCodeName + + parsedConfig.processes[0].dataDependencies[1].devTeam = teamCodeName + parsedConfig.processes[0].dataDependencies[1].bot = 'simulator-' + botCodeName + parsedConfig.processes[0].dataDependencies[2].devTeam = teamCodeName + parsedConfig.processes[0].dataDependencies[2].bot = 'simulator-' + botCodeName + + // Creating a new trading bot + let newBotPath = teamCodeName + '/bots/' + botCodeName + '-Trading-Bot' + await writeFileContent(teamCodeName, newBotPath + '/Trading-Process/User.Bot.js', botCode) + await writeFileContent(teamCodeName, newBotPath + '/this.bot.config.json', beautify(parsedConfig, null, 2, 80)) + + return parsedConfig + } catch (err) { + logger.error('copyBot error for bot: %s. %s', botCodeName, err) + throw err + } +} diff --git a/src/storage/CopySimulator.js b/src/storage/CopySimulator.js new file mode 100644 index 000000000..9bcb240f2 --- /dev/null +++ b/src/storage/CopySimulator.js @@ -0,0 +1,83 @@ +import beautify from 'json-beautify' +import logger from '../utils/logger' +import readFile from '../utils/readFile' + +export const copySimulator = async (teamCodeName, botCodeName, botDisplayName, writeFileContent) => { + try { + logger.debug('copySimulator started for bot %s', 'simulator-' + botCodeName) + + // File imports + const commons = await readFile('./src/storage/templates/Simulator/Commons.js') + const config = await readFile('./src/storage/templates/Simulator/this.bot.config.json') + const codeDaily = await readFile('./src/storage/templates/Simulator/User.Bot.Daily.js') + const codeMarket = await readFile('./src/storage/templates/Simulator/User.Bot.Market.js') + + // Change config to adapt the new indicator + let newBotCodeName = 'simulator-' + botCodeName + let parsedConfig = JSON.parse(config) + parsedConfig.displayName = 'Simulator ' + botDisplayName + parsedConfig.codeName = newBotCodeName + parsedConfig.devTeam = teamCodeName + parsedConfig.profilePicture = newBotCodeName + '.png' + + parsedConfig.processes[0].statusDependencies[0].devTeam = teamCodeName + parsedConfig.processes[0].statusDependencies[0].bot = newBotCodeName + parsedConfig.processes[1].statusDependencies[2].devTeam = teamCodeName + parsedConfig.processes[1].statusDependencies[2].bot = newBotCodeName + + //Changing Indicator Output + parsedConfig.products[0].storageAccount = teamCodeName + parsedConfig.products[0].dataSets[0].filePath = teamCodeName + '/' + parsedConfig.codeName + '.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Trading-Simulation/Multi-Period-Market/@Period' + parsedConfig.products[0].dataSets[1].filePath = teamCodeName + '/' + parsedConfig.codeName + '.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Trading-Simulation/Multi-Period-Daily/@Period/@Year/@Month/@Day' + parsedConfig.products[0].dataSets[1].dataRange.filePath = teamCodeName + '/' + parsedConfig.codeName + '.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Trading-Simulation/Multi-Period-Daily' + + parsedConfig.products[1].storageAccount = teamCodeName + parsedConfig.products[1].dataSets[0].filePath = teamCodeName + '/' + parsedConfig.codeName + '.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Simulation-Conditions/Multi-Period-Market/@Period' + parsedConfig.products[1].dataSets[1].filePath = teamCodeName + '/' + parsedConfig.codeName + '.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Simulation-Conditions/Multi-Period-Daily/@Period/@Year/@Month/@Day' + parsedConfig.products[1].dataSets[1].dataRange.filePath = teamCodeName + '/' + parsedConfig.codeName + '.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Simulation-Conditions/Multi-Period-Daily' + + parsedConfig.products[2].storageAccount = teamCodeName + parsedConfig.products[2].dataSets[0].filePath = teamCodeName + '/' + parsedConfig.codeName + '.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Simulation-Strategies/Multi-Period-Market/@Period' + parsedConfig.products[2].dataSets[1].filePath = teamCodeName + '/' + parsedConfig.codeName + '.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Simulation-Strategies/Multi-Period-Daily/@Period/@Year/@Month/@Day' + parsedConfig.products[2].dataSets[1].dataRange.filePath = teamCodeName + '/' + parsedConfig.codeName + '.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Simulation-Strategies/Multi-Period-Daily' + + parsedConfig.products[3].storageAccount = teamCodeName + parsedConfig.products[3].dataSets[0].filePath = teamCodeName + '/' + parsedConfig.codeName + '.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Simulation-Trades/Multi-Period-Market/@Period' + parsedConfig.products[3].dataSets[1].filePath = teamCodeName + '/' + parsedConfig.codeName + '.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Simulation-Trades/Multi-Period-Daily/@Period/@Year/@Month/@Day' + parsedConfig.products[3].dataSets[1].dataRange.filePath = teamCodeName + '/' + parsedConfig.codeName + '.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Simulation-Trades/Multi-Period-Daily' + + // Write the new files + let newSimulatorName = newBotCodeName + '-Indicator-Bot' + let newSimulatorPath = teamCodeName + '/bots/' + newSimulatorName + await writeFileContent(teamCodeName, newSimulatorPath + '/Commons.js', commons) + await writeFileContent(teamCodeName, newSimulatorPath + '/this.bot.config.json', beautify(parsedConfig, null, 2, 80)) + await writeFileContent(teamCodeName, newSimulatorPath + '/Multi-Period-Daily/User.Bot.js', codeDaily) + await writeFileContent(teamCodeName, newSimulatorPath + '/Multi-Period-Market/User.Bot.js', codeMarket) + + logger.debug('copySimulator completed for bot %s', newBotCodeName) + return parsedConfig + } catch (err) { + logger.error('copySimulator error for bot: %s. %s', botCodeName, err) + throw err + } +} + +export const removeSimulator = async (storage, teamCodeName, botCodeName) => { + try { + logger.debug('removeSimulator started for bot %s', botCodeName) + + // Delete simulator code + let newSimulatorName = 'simulator-' + botCodeName + '-Indicator-Bot' + let newSimulatorPath = teamCodeName + '/bots/' + newSimulatorName + await storage.deleteBlob(teamCodeName, newSimulatorPath + '/Commons.js') + await storage.deleteBlob(teamCodeName, newSimulatorPath + '/this.bot.config.json') + await storage.deleteBlob(teamCodeName, newSimulatorPath + '/Multi-Period-Daily/User.Bot.js') + await storage.deleteBlob(teamCodeName, newSimulatorPath + '/Multi-Period-Market/User.Bot.js') + + logger.debug('removeSimulator completed for bot %s', botCodeName) + + } catch (err) { + logger.error('copySimulator error for bot %s: %s', botCodeName, err) + throw err + } +} diff --git a/src/storage/providers/AzureStorage.js b/src/storage/providers/AzureStorage.js new file mode 100644 index 000000000..d820fbbb7 --- /dev/null +++ b/src/storage/providers/AzureStorage.js @@ -0,0 +1,91 @@ +import { + Aborter, + BlobURL, + BlockBlobURL, + ContainerURL, + ServiceURL, + StorageURL, + SharedKeyCredential, + AnonymousCredential +} from '@azure/storage-blob' + +const getService = () => { + // Use SharedKeyCredential with storage account and account key + const sharedKeyCredential = new SharedKeyCredential(process.env.AZURE_BASE_URL, process.env.AZURE_CONNECTION_STRING); + + // Use sharedKeyCredential, tokenCredential or anonymousCredential to create a pipeline + const pipeline = StorageURL.newPipeline(sharedKeyCredential, { + retryOptions: { maxTries: 10 } + }); + + // List containers + const serviceURL = new ServiceURL( + // When using AnonymousCredential, following url should include a valid SAS or support public access + `https://${process.env.AZURE_BASE_URL}.blob.core.windows.net`, + pipeline + ) + return serviceURL +} + +export const getFileContentRemote = async (containerName, blobName, storage, accessKey) => { + const pipeline = StorageURL.newPipeline(new AnonymousCredential(), { + retryOptions: { maxTries: 10 } + }) + const serviceURLWithAccessKey = new ServiceURL( + `${storage}${accessKey}`, + pipeline + ); + const containerURL = ContainerURL.fromServiceURL(serviceURLWithAccessKey, containerName) + const blockBlobURL = BlockBlobURL.fromContainerURL(containerURL, blobName) + let downloadResponse = await blockBlobURL.download(Aborter.none, 0) + return await streamToString(downloadResponse.readableStreamBody) +} + +export const getFileContent = async (containerName, blobName) => { + const containerURL = ContainerURL.fromServiceURL(getService(), containerName) + const blockBlobURL = BlockBlobURL.fromContainerURL(containerURL, blobName) + let downloadResponse = await blockBlobURL.download(Aborter.none, 0) + return await streamToString(downloadResponse.readableStreamBody) +} + +export const writeFileContent = async (containerName, blobName, content) => { + const containerURL = ContainerURL.fromServiceURL(getService(), containerName) + const blobURL = BlobURL.fromContainerURL(containerURL, blobName) + const blockBlobURL = BlockBlobURL.fromBlobURL(blobURL) + await blockBlobURL.upload( + Aborter.none, + content, + content.length + ) +} + +export const deleteBlob = async (containerName, blobName) => { + const containerURL = ContainerURL.fromServiceURL(getService(), containerName) + const blockBlobURL = BlockBlobURL.fromContainerURL(containerURL, blobName) + await blockBlobURL.delete(Aborter.none) +} + +export const deleteContainer = async (containerName) => { + const containerURL = ContainerURL.fromServiceURL(getService(), containerName) + await containerURL.delete(Aborter.none) +} + +export const createContainer = async (containerName) => { + const containerURL = ContainerURL.fromServiceURL(getService(), containerName) + await containerURL.create(Aborter.none) +} + +// A helper method used to read a Node.js readable stream into string +async function streamToString(readableStream) { + return new Promise((resolve, reject) => { + const chunks = [] + readableStream.on('data', data => { + chunks.push(data.toString()); + }) + readableStream.on('end', () => { + resolve(chunks.join('')) + }) + readableStream.on('error', reject) + }) +} + diff --git a/src/storage/providers/MinioStorage.js b/src/storage/providers/MinioStorage.js new file mode 100644 index 000000000..1da17c11e --- /dev/null +++ b/src/storage/providers/MinioStorage.js @@ -0,0 +1,99 @@ +import { Client } from 'minio' + +const getService = () => { + let service = new Client({ + endPoint: process.env.MINIO_END_POINT, + port: JSON.parse(process.env.MINIO_PORT), + useSSL: JSON.parse(process.env.MINIO_USE_SSL), + accessKey: process.env.MINIO_ACCESS_KEY, + secretKey: process.env.MINIO_SECRET_KEY + }) + return service +} + +export const getFileContent = async (containerName, blobName) => { + let service = getService() + let chunks = [] + let fileContent = await new Promise(function (resolve, reject) { + service.getObject(containerName, blobName, function (error, dataStream) { + if (error) { + reject(error) + } + if (dataStream != undefined) { + dataStream.on('data', function (chunk) { + chunks.push(chunk.toString()) + }) + dataStream.on('end', function () { + resolve(chunks.join('')) + }) + dataStream.on('error', function (e) { + reject(e) + }) + } else { + resolve('') + } + }) + }) + return fileContent +} + +export const writeFileContent = async (containerName, blobName, content) => { + let service = getService() + await new Promise(function (resolve, reject) { + service.putObject(containerName, blobName, content, 'text/plain', function (error) { + if (error) { + reject(error) + } + resolve() + }) + }) +} + +export const createContainer = async (containerName) => { + let service = getService() + await new Promise(function (resolve, reject) { + service.makeBucket(containerName, '', function (error) { + if (error) { + reject(error) + } + resolve() + }) + }) +} + +export const deleteContainer = async (containerName) => { + let service = getService() + let objectsStream = service.listObjects(containerName, '', true) + let totalObjects = 0 + let removed = 0 + objectsStream.on('data', async function (obj) { + totalObjects++ + await new Promise(function (resolve, reject) { + service.removeObject(containerName, obj.name, function (e) { + if (e) reject(e) + removed++ + resolve() + }) + }) + }) + objectsStream.on('error', function (e) { + throw e + }) + objectsStream.on('end', async function (e) { + await removeBucket() + }) + + function removeBucket() { + if (totalObjects === removed) { + new Promise(function (resolve, reject) { + service.removeBucket(containerName, function (e) { + if (e) reject(e) + resolve() + }) + }) + } else { + setTimeout(removeBucket, 2000) + } + } +} + diff --git a/src/storage/templates/Simulator/Commons.js b/src/storage/templates/Simulator/Commons.js new file mode 100644 index 000000000..7d9509461 --- /dev/null +++ b/src/storage/templates/Simulator/Commons.js @@ -0,0 +1,1991 @@ +const strategy = require('./Integrations/Strategy') + +exports.newCommons = function newCommons(bot, logger, UTILITIES) { + + const { orderMessage } = require("@superalgos/mqservice") + + const { + MESSAGE_ENTITY, MESSAGE_TYPE, ORDER_CREATOR, ORDER_TYPE, + ORDER_OWNER, ORDER_DIRECTION, ORDER_STATUS, ORDER_EXIT_OUTCOME, + createMessage, getMessage, getExpandedMessage + } = orderMessage.newOrderMessage() + + + const FULL_LOG = true; + const LOG_FILE_CONTENT = false; + + const MODULE_NAME = "Commons"; + const ONE_DAY_IN_MILISECONDS = 24 * 60 * 60 * 1000; + const GMT_SECONDS = ':00.000 GMT+0000'; + + let thisObject = { + initializeData: initializeData, + runSimulation: runSimulation, + buildLRC: buildLRC, + buildPercentageBandwidthMap: buildPercentageBandwidthMap, + buildBollingerBandsMap: buildBollingerBandsMap, + buildBollingerChannelsArray: buildBollingerChannelsArray, + buildBollingerSubChannelsArray: buildBollingerSubChannelsArray, + buildCandles: buildCandles + }; + + let utilities = UTILITIES.newCloudUtilities(bot, logger); + + let LRCMap = new Map(); + let percentageBandwidthMap = new Map(); + let bollingerBandsMap = new Map(); + let bollingerChannelsArray = []; + let bollingerSubChannelsArray = []; + + let candles = []; + + return thisObject; + + function initializeData() { + + LRCMap = new Map(); + percentageBandwidthMap = new Map(); + bollingerBandsMap = new Map(); + bollingerChannelsArray = []; + bollingerSubChannelsArray = []; + + candles = []; + } + + async function runSimulation( + timePeriod, + currentDay, + startDate, + endDate, + interExecutionMemory, + callback, + callBackFunction) { + + try { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] runSimulation -> Entering function."); } + + let executionArray = []; + let recordsArray = []; + let conditionsArray = []; + let strategiesArray = []; + let tradesArray = []; + let lastObjectsArray = []; + + let tradingSystem = await strategy.getStrategy(); + + /* Initial Default Values */ + + let initialDate = startDate; + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] runSimulation -> initialDate = " + initialDate); } + + const DEFAULT_BASE_ASSET_BALANCE = 1 + const DEFAULT_BASE_ASSET_MINIMUN_BALANCE = 0.5 + const DEFAULT_BASE_ASSET_MAXIMUN_BALANCE = 2 + + let initialBalanceA = DEFAULT_BASE_ASSET_BALANCE + let minimumBalanceA = DEFAULT_BASE_ASSET_MINIMUN_BALANCE + let maximumBalanceA = DEFAULT_BASE_ASSET_MAXIMUN_BALANCE + let initialBalanceB = 0 + let minimumBalanceB = 0 + let maximumBalanceB = 0 + let baseAsset = 'BTC' + + /* Parameters Processing */ + + if (tradingSystem.parameters !== undefined) { + if (tradingSystem.parameters.baseAsset !== undefined) { + if (tradingSystem.parameters.baseAsset.formula !== undefined) { + let receivedParameters + try { + receivedParameters = JSON.parse(tradingSystem.parameters.baseAsset.formula.code); + + if (receivedParameters.name !== undefined) { + baseAsset = receivedParameters.name; + if (baseAsset !== 'BTC' && baseAsset !== 'USDT') { + tradingSystem.parameters.baseAsset.formula.error = baseAsset + ' is not supported. Using default: BTC.' + baseAsset = 'BTC' + } + } + + if (baseAsset === 'BTC') { + if (receivedParameters.initialBalance !== undefined) { + initialBalanceA = receivedParameters.initialBalance; + initialBalanceB = 0 + } else { + initialBalanceA = DEFAULT_BASE_ASSET_BALANCE; + initialBalanceB = 0 + } + if (receivedParameters.minimumBalance !== undefined) { + minimumBalanceA = receivedParameters.minimumBalance; + minimumBalanceB = 0 + } else { + minimumBalanceA = DEFAULT_BASE_ASSET_MINIMUN_BALANCE; + minimumBalanceB = 0 + } + if (receivedParameters.maximumBalance !== undefined) { + maximumBalanceA = receivedParameters.maximumBalance; + maximumBalanceB = 0 + } else { + maximumBalanceA = DEFAULT_BASE_ASSET_MAXIMUN_BALANCE; + maximumBalanceB = 0 + } + } else { + if (receivedParameters.initialBalance !== undefined) { + initialBalanceB = receivedParameters.initialBalance; + initialBalanceA = 0 + } else { + initialBalanceB = DEFAULT_BASE_ASSET_BALANCE; + initialBalanceA = 0 + } + if (receivedParameters.minimumBalance !== undefined) { + minimumBalanceB = receivedParameters.minimumBalance; + minimumBalanceA = 0 + } else { + minimumBalanceB = DEFAULT_BASE_ASSET_MINIMUN_BALANCE; + minimumBalanceA = 0 + } + if (receivedParameters.maximumBalance !== undefined) { + maximumBalanceB = receivedParameters.maximumBalance; + maximumBalanceA = 0 + } else { + maximumBalanceB = DEFAULT_BASE_ASSET_MAXIMUN_BALANCE; + maximumBalanceA = 0 + } + } + } catch (err) { + tradingSystem.parameters.baseAsset.formula.error = err.message + } + } + } + } + + /* Strategy and Phases */ + + let currentStrategyIndex = -1; + let strategyStage = 'No Stage'; + + /* Stop Loss Management */ + + const MIN_STOP_LOSS_VALUE = 1 // We can not let the stop be zero to avoid division by 0 error or infinity numbers as a result. + const MAX_STOP_LOSS_VALUE = Number.MAX_SAFE_INTEGER + let stopLoss = 0; + let stopLossPhase = 0; + let stopLossStage = 'No Stage'; + + /* Take Profit Management */ + + const MIN_TAKE_PROFIT_VALUE = 1 // We can not let the buy order be zero to avoid division by 0 error or infinity numbers as a result. + const MAX_TAKE_PROFIT_VALUE = Number.MAX_SAFE_INTEGER + let previousTakeProfit = 0; + let takeProfit = 0; + let takeProfitPhase = 0; + let takeProfitStage = 'No Stage'; + + /* Simulation Records */ + + let tradePositionRate = 0; + let tradePositionSize = 0; + let positionInstant; + + let previousBalanceAssetA = 0; + let previousBalanceAssetB = 0; + let hitRatio = 0; + let ROI = 0; + let days = 0; + let anualizedRateOfReturn = 0; + let type = '""'; + let marketRate = 0; + let takePositionNow = false + + /* In some cases we need to know if we are positioned at the last candle of the calendar day, for that we need thse variables. */ + + let lastInstantOfTheDay = currentDay.valueOf() + ONE_DAY_IN_MILISECONDS - 1; + let lastCandle = candles[candles.length - 1]; + + /* These 2 objects will allow us to create separate files for each one of them. */ + + let currentStrategy = { + begin: 0, + end: 0, + status: 0, + number: 0 + } + + let currentTrade = { + begin: 0, + end: 0, + status: 0, + profit: 0, + exitType: 0, + beginRate: 0, + endRate: 0 + } + + /* + The following counters need to survive multiple executions of the similator and keep themselves reliable. + This is challenging when the simulation is executed using Daily Files, since each execution means a new + day and these counters are meant to be kept along the whole market. + + To overcome this problem, we use the interExecutionMemory to record the values of the current execution + when finish. But there are a few details: + + 1. When the process is at the head of the market, it executes multple times at the same day. + 2. The same code serves execution from Market Files. + 3. In Daily Files we are receiving candles from the current day and previous day, so we need to take care of + not adding to the counters duplicate info when processing the day before candles. + + To overcome these challenges we record the values of the counters and variables on the interExecutionMemory only when + the day is complete and if we have a currentDay. That menas that for Market Files we will never use + interExecutionMemory. + */ + + let balanceAssetA = initialBalanceA; + let balanceAssetB = initialBalanceB; + + let lastTradeProfitLoss = 0; + let profit = 0; + let lastTradeROI = 0; + + let roundtrips = 0; + let fails = 0; + let hits = 0; + let periods = 0; + + /* Message to the Simulation Executor */ + + let orderId = 0; + let messageId = 0; + + let yesterday = {}; + + yesterday.balanceAssetA = balanceAssetA; + yesterday.balanceAssetB = balanceAssetB; + + yesterday.lastTradeProfitLoss = 0; + yesterday.profit = 0; + yesterday.lastTradeROI = 0; + + yesterday.Roundtrips = 0; + yesterday.fails = 0; + yesterday.hits = 0; + yesterday.Periods = 0; + + yesterday.orderId = 0; + yesterday.messageId = 0; + + yesterday.hitRatio = 0; + yesterday.ROI = 0; + yesterday.anualizedRateOfReturn = 0; + + if (interExecutionMemory.roundtrips === undefined) { + + /* Initialize the data structure we will use inter execution. */ + + interExecutionMemory.balanceAssetA = balanceAssetA; + interExecutionMemory.balanceAssetB = balanceAssetB; + + interExecutionMemory.lastTradeProfitLoss = lastTradeProfitLoss; + interExecutionMemory.profit = profit; + interExecutionMemory.lastTradeROI = lastTradeROI; + + interExecutionMemory.roundtrips = 0; + interExecutionMemory.fails = 0; + interExecutionMemory.hits = 0; + interExecutionMemory.periods = 0; + + interExecutionMemory.orderId = 0; + interExecutionMemory.messageId = 0; + + interExecutionMemory.hitRatio = 0; + interExecutionMemory.ROI = 0; + interExecutionMemory.anualizedRateOfReturn = 0; + + } else { + + /* We get the initial values from the day previous to the candles we receive at the current execution */ + + if (currentDay.valueOf() >= startDate.valueOf() + ONE_DAY_IN_MILISECONDS) { // Only after the first day we start grabbing the balance from this memory. + + balanceAssetA = interExecutionMemory.balanceAssetA; + balanceAssetB = interExecutionMemory.balanceAssetB; + + yesterday.balanceAssetA = balanceAssetA; + yesterday.balanceAssetB = balanceAssetB; + + } + + lastTradeProfitLoss = interExecutionMemory.lastTradeProfitLoss; + profit = interExecutionMemory.profit; + lastTradeROI = interExecutionMemory.lastTradeROI; + + roundtrips = interExecutionMemory.roundtrips; + fails = interExecutionMemory.fails; + hits = interExecutionMemory.hits; + periods = interExecutionMemory.periods; + + orderId = interExecutionMemory.orderId; + messageId = interExecutionMemory.messageId; + + hitRatio = interExecutionMemory.hitRatio; + ROI = interExecutionMemory.ROI; + anualizedRateOfReturn = interExecutionMemory.anualizedRateOfReturn; + + yesterday.hitRatio = hitRatio; + yesterday.ROI = ROI; + yesterday.anualizedRateOfReturn = anualizedRateOfReturn; + + } + + /* Main Simulation Loop: We go thourgh all the candles at this time period. */ + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] runSimulation -> Main Simulation Loop -> candles.length = " + candles.length); } + + for (let i = 0; i < candles.length; i++) { + + + let candle = candles[i]; + let percentageBandwidth = percentageBandwidthMap.get(candle.begin); + let bollingerBand = bollingerBandsMap.get(candle.begin); + let bollingerChannel = getElement(bollingerChannelsArray, candle.begin, candle.end); + let bollingerSubChannel = getElement(bollingerSubChannelsArray, candle.begin, candle.end); + + //let LRC = LRCMap.get(candle.begin); + + /* If any of the needed indicators is missing, then that period is not calculated */ + + if (candle.begin < initialDate.valueOf()) { continue; } + if (bollingerBand === undefined) { continue; } + if (percentageBandwidth === undefined) { continue; } // percentageBandwidth might start after the first few candles. + if (bollingerChannel === undefined) { continue; } + if (bollingerSubChannel === undefined) { continue; } + + //if (LRC === undefined) { continue; } + + periods++; + days = periods * timePeriod / ONE_DAY_IN_MILISECONDS; + + if (currentDay !== undefined) { // This means that we are processing Daily Files + if (candle.end < currentDay.valueOf()) { + yesterday.Periods++; + } + + /* We skip the candle at the head of the market because i has not closed yet. */ + let candlesPerDay = ONE_DAY_IN_MILISECONDS / timePeriod + if (i === candles.length - 1) { + if ((candles.length < candlesPerDay) || (candles.length > candlesPerDay && candles.length < candlesPerDay * 2) ) { + /*We are at the head of the market, thus we skip the last candle because it has not close yet. */ + continue; + /* Note here that in the last candle of the first day or the second day it will use an incomplete candle and partially calculated indicators. + if we skip these two periods, then there will be a hole in the file since the last period will be missing. */ + } + } + } else { // We are processing Market Files + if (i === candles.length - 1) { + continue; + } + } + + let lastObjects = { + candle: clone(candle), + //LRC: clone(LRC), + bollingerBand: clone(bollingerBand), + percentageBandwidth: clone(percentageBandwidth), + bollingerChannel: clone(bollingerChannel), + bollingerSubChannel: clone(bollingerSubChannel) + } + + function clone(obj) { + if (null == obj || "object" != typeof obj) return obj; + var copy = obj.constructor(); + for (var attr in obj) { + if (obj.hasOwnProperty(attr)) copy[attr] = obj[attr]; + } + return copy; + } + + lastObjects.candle.previous = undefined; + //lastObjects.LRC.previous = undefined; + lastObjects.bollingerBand.previous = undefined; + lastObjects.percentageBandwidth.previous = undefined; + lastObjects.bollingerChannel.previous = undefined; + lastObjects.bollingerSubChannel.previous = undefined; + + lastObjectsArray.push(lastObjects); + + if (lastObjectsArray.length > 5) { + lastObjectsArray.splice(0,1); + } + + let conditions = new Map; // Here we store the conditions values that will be use in the simulator for decision making. + let formulas = new Map; + let conditionsArrayRecord = []; // These are the records that will be saved in a file for the plotter to consume. + let conditionsArrayValues = []; // Here we store the conditions values that will be written on file for the plotter. + let formulasErrors = []; // Here we store the errors produced by all phase formulas. + let formulasValues = []; // Here we store the values produced by all phase formulas. + + /* We define and evaluate all conditions to be used later during the simulation loop. */ + + conditionsArrayRecord.push(candle.begin); + conditionsArrayRecord.push(candle.end); + + evaluateConditionsAndFormulas(tradingSystem, conditions); + + function evaluateConditionsAndFormulas(tradingSystem, conditions) { + + for (let j = 0; j < tradingSystem.strategies.length; j++) { + + let strategy = tradingSystem.strategies[j]; + + let positionSize = 0 + let positionRate = 0 + + /* Continue with the rest of the formulas and conditions */ + + let triggerStage = strategy.triggerStage + + if (triggerStage !== undefined) { + + if (triggerStage.triggerOn !== undefined) { + + for (let k = 0; k < triggerStage.triggerOn.situations.length; k++) { + + let situation = triggerStage.triggerOn.situations[k]; + + for (let m = 0; m < situation.conditions.length; m++) { + + let condition = situation.conditions[m]; + let key = j + '-' + 'triggerStage' + '-' + 'triggerOn' + '-' + k + '-' + m; + + if (condition.code !== undefined) { + newCondition(key, condition.code); + } + } + } + } + + if (triggerStage.triggerOff !== undefined) { + + for (let k = 0; k < triggerStage.triggerOff.situations.length; k++) { + + let situation = triggerStage.triggerOff.situations[k]; + + for (let m = 0; m < situation.conditions.length; m++) { + + let condition = situation.conditions[m]; + let key = j + '-' + 'triggerStage' + '-' + 'triggerOff' + '-' + k + '-' + m; + + if (condition.code !== undefined) { + newCondition(key, condition.code); + } + } + } + } + + if (triggerStage.takePosition !== undefined) { + + for (let k = 0; k < triggerStage.takePosition.situations.length; k++) { + + let situation = triggerStage.takePosition.situations[k]; + + for (let m = 0; m < situation.conditions.length; m++) { + + let condition = situation.conditions[m]; + let key = j + '-' + 'triggerStage' + '-' + 'takePosition' + '-' + k + '-' + m; + + if (condition.code !== undefined) { + newCondition(key, condition.code); + } + } + } + } + } + + let openStage = strategy.openStage + + if (openStage !== undefined) { + + /* Default Values*/ + if (baseAsset === 'BTC') { + positionSize = balanceAssetA; + positionRate = candle.close; + } else { + positionSize = balanceAssetB; + positionRate = candle.close; + } + + let initialDefinition = openStage.initialDefinition + + if (initialDefinition !== undefined) { + + if (tradePositionSize !== 0) { + positionSize = tradePositionSize + } else { + if (initialDefinition.positionSize !== undefined) { + if (initialDefinition.positionSize.formula !== undefined) { + try { + positionSize = eval(initialDefinition.positionSize.formula.code); + } catch (err) { + initialDefinition.positionSize.formula.error = err.message + } + if (isNaN(positionSize)) { + if (baseAsset === 'BTC') { + positionSize = balanceAssetA; + } else { + positionSize = balanceAssetB; + } + } else { + if (baseAsset === 'BTC') { + if (positionSize > balanceAssetA) { positionSize = balanceAssetA } + } else { + if (positionSize > balanceAssetB) { positionSize = balanceAssetB } + } + } + } + } + } + + if (tradePositionRate !== 0) { + positionRate = tradePositionRate + } else { + if (initialDefinition.positionRate !== undefined) { + if (initialDefinition.positionRate.formula !== undefined) { + try { + positionRate = eval(initialDefinition.positionRate.formula.code); + } catch (err) { + initialDefinition.positionRate.formula.error = err.message + } + if (isNaN(positionRate)) { + if (baseAsset === 'BTC') { + positionRate = candle.close; + } else { + positionRate = candle.close; + } + } + } + } + } + + if (initialDefinition.stopLoss !== undefined) { + + for (let p = 0; p < initialDefinition.stopLoss.phases.length; p++) { + + let phase = initialDefinition.stopLoss.phases[p]; + + /* Evaluate Formula */ + let formulaValue + let formulaError = '' + + if (phase.formula !== undefined) { + try { + formulaValue = eval(phase.formula.code); + if (formulaValue === Infinity) { + formulaError= "Formula evaluates to Infinity." + formulaValue = MAX_STOP_LOSS_VALUE + } + } catch (err) { + if (phase.formula.code.indexOf('previous') > 0 && err.message.indexOf('of undefined') > 0) { + /* + We are not going to set an error for the casess we are using previous and the error is that the indicator is undefined. + */ + } else { + formulaError = err.message + } + } + if (isNaN(formulaValue)) { formulaValue = 0; } + if (formulaValue < MIN_STOP_LOSS_VALUE) { + formulaValue = MIN_STOP_LOSS_VALUE + } + + formulasErrors.push('"' + formulaError + '"') + formulasValues.push(formulaValue) + let key = j + '-' + 'openStage' + '-' + 'initialDefinition' + '-' + 'stopLoss' + '-' + p; + formulas.set(key, formulaValue) + } + + /* next phase event */ + let nextPhaseEvent = phase.nextPhaseEvent; + if (nextPhaseEvent !== undefined) { + + for (let k = 0; k < nextPhaseEvent.situations.length; k++) { + + let situation = nextPhaseEvent.situations[k]; + + for (let m = 0; m < situation.conditions.length; m++) { + + let condition = situation.conditions[m]; + let key = j + '-' + 'openStage' + '-' + 'initialDefinition' + '-' + 'stopLoss' + '-' + p + '-' + k + '-' + m; + + if (condition.code !== undefined) { + newCondition(key, condition.code); + } + } + } + } + } + } + + if (initialDefinition.takeProfit !== undefined) { + + for (let p = 0; p < initialDefinition.takeProfit.phases.length; p++) { + + let phase = initialDefinition.takeProfit.phases[p]; + + /* Evaluate Formula */ + let formulaValue + let formulaError = '' + + if (phase.formula !== undefined) { + try { + formulaValue = eval(phase.formula.code); + if (formulaValue === Infinity) { + formulaError = "Formula evaluates to Infinity." + formulaValue = MAX_TAKE_PROFIT_VALUE + } + } catch (err) { + if (phase.formula.code.indexOf('previous') > 0 && err.message.indexOf('of undefined') > 0) { + /* + We are not going to set an error for the casess we are using previous and the error is that the indicator is undefined. + */ + } else { + formulaError = err.message + } + } + if (isNaN(formulaValue)) { formulaValue = 0; } + if (formulaValue < MIN_TAKE_PROFIT_VALUE) { + formulaValue = MIN_TAKE_PROFIT_VALUE + } + + formulasErrors.push('"' + formulaError + '"') + formulasValues.push(formulaValue) + let key = j + '-' + 'openStage' + '-' + 'initialDefinition' + '-' + 'takeProfit' + '-' + p; + formulas.set(key, formulaValue) + } + + /* next phase event */ + let nextPhaseEvent = phase.nextPhaseEvent; + if (nextPhaseEvent !== undefined) { + + for (let k = 0; k < nextPhaseEvent.situations.length; k++) { + + let situation = nextPhaseEvent.situations[k]; + + for (let m = 0; m < situation.conditions.length; m++) { + + let condition = situation.conditions[m]; + let key = j + '-' + 'openStage' + '-' + 'initialDefinition' + '-' + 'takeProfit' + '-' + p + '-' + k + '-' + m; + + if (condition.code !== undefined) { + newCondition(key, condition.code); + } + } + } + } + } + } + } + + strategy.positionSize = positionSize + strategy.positionRate = positionRate + } + + let manageStage = strategy.manageStage + + if (manageStage !== undefined) { + + if (manageStage.stopLoss !== undefined) { + + for (let p = 0; p < manageStage.stopLoss.phases.length; p++) { + + let phase = manageStage.stopLoss.phases[p]; + + /* Evaluate Formula */ + let formulaValue + let formulaError = '' + + if (phase.formula !== undefined) { + try { + formulaValue = eval(phase.formula.code); + if (formulaValue === Infinity) { + formulaError = "Formula evaluates to Infinity." + formulaValue = MAX_STOP_LOSS_VALUE + } + } catch (err) { + if (phase.formula.code.indexOf('previous') > 0 && err.message.indexOf('of undefined') > 0) { + /* + We are not going to set an error for the casess we are using previous and the error is that the indicator is undefined. + */ + } else { + formulaError = err.message + } + } + if (isNaN(formulaValue)) { formulaValue = 0; } + if (formulaValue < MIN_STOP_LOSS_VALUE) { + formulaValue = MIN_STOP_LOSS_VALUE + } + + formulasErrors.push('"' + formulaError + '"') + formulasValues.push(formulaValue) + let key = j + '-' + 'manageStage' + '-' + 'stopLoss' + '-' + p; + formulas.set(key, formulaValue) + } + + /* next phase event */ + let nextPhaseEvent = phase.nextPhaseEvent; + if (nextPhaseEvent !== undefined) { + + for (let k = 0; k < nextPhaseEvent.situations.length; k++) { + + let situation = nextPhaseEvent.situations[k]; + + for (let m = 0; m < situation.conditions.length; m++) { + + let condition = situation.conditions[m]; + let key = j + '-' + 'manageStage' + '-' + 'stopLoss' + '-' + p + '-' + k + '-' + m; + + if (condition.code !== undefined) { + newCondition(key, condition.code); + } + } + } + } + } + } + + if (manageStage.takeProfit !== undefined) { + + for (let p = 0; p < manageStage.takeProfit.phases.length; p++) { + + let phase = manageStage.takeProfit.phases[p]; + + /* Evaluate Formula */ + let formulaValue + let formulaError = '' + + if (phase.formula !== undefined) { + try { + formulaValue = eval(phase.formula.code); + if (formulaValue === Infinity) { + formulaError = "Formula evaluates to Infinity." + formulaValue = MAX_TAKE_PROFIT_VALUE + } + } catch (err) { + if (phase.formula.code.indexOf('previous') > 0 && err.message.indexOf('of undefined') > 0) { + /* + We are not going to set an error for the casess we are using previous and the error is that the indicator is undefined. + */ + } else { + formulaError = err.message + } + } + if (isNaN(formulaValue)) { formulaValue = 0; } + if (formulaValue < MIN_TAKE_PROFIT_VALUE) { + formulaValue = MIN_TAKE_PROFIT_VALUE + } + + formulasErrors.push('"' + formulaError + '"') + formulasValues.push(formulaValue) + let key = j + '-' + 'manageStage' + '-' + 'takeProfit' + '-' + p; + formulas.set(key, formulaValue) + } + + /* next phase event */ + let nextPhaseEvent = phase.nextPhaseEvent; + if (nextPhaseEvent !== undefined) { + + for (let k = 0; k < nextPhaseEvent.situations.length; k++) { + + let situation = nextPhaseEvent.situations[k]; + + for (let m = 0; m < situation.conditions.length; m++) { + + let condition = situation.conditions[m]; + let key = j + '-' + 'manageStage' + '-' + 'takeProfit' + '-' + p + '-' + k + '-' + m; + + if (condition.code !== undefined) { + newCondition(key, condition.code); + } + } + } + } + } + } + } + + function newCondition(key, node) { + + let condition; + let error = '' + let value + + try { + value = eval(node.code); + } catch (err) { + /* + One possible error is that the conditions references a .previous that is undefined. For this + reason and others, we will simply set the value to false. + */ + value = false + + if (node.code.indexOf('previous') > 0 && err.message.indexOf('of undefined') > 0) { + /* + We are not going to set an error for the casess we are using previous and the error is that the indicator is undefined. + */ + } else { + node.error = err.message + } + } + + condition = { + key: key, + value: value + }; + + conditions.set(condition.key, condition); + + if (condition.value) { + conditionsArrayValues.push(1); + } else { + conditionsArrayValues.push(0); + } + } + } + } + + /* Trigger On Conditions */ + if ( + strategyStage === 'No Stage' && + currentStrategyIndex === -1 + ) { + let minimumBalance + let maximumBalance + let balance + + if (baseAsset === 'BTC') { + balance = balanceAssetA + minimumBalance = minimumBalanceA + maximumBalance = maximumBalanceA + } else { + balance = balanceAssetB + minimumBalance = minimumBalanceB + maximumBalance = maximumBalanceB + } + + if (balance > minimumBalance && balance < maximumBalance) { + + /* + Here we need to pick a strategy, or if there is not suitable strategy for the current + market conditions, we pass until the next period. + + To pick a new strategy we will evaluate what we call the trigger on. Once we enter + into one strategy, we will ignore market conditions for others. However there is also + a strategy trigger off which can be hit before taking a position. If hit, we would + be outside a strategy again and looking for the condition to enter all over again. + + */ + + for (let j = 0; j < tradingSystem.strategies.length; j++) { + + let strategy = tradingSystem.strategies[j]; + + let triggerStage = strategy.triggerStage + + if (triggerStage !== undefined) { + + if (triggerStage.triggerOn !== undefined) { + + for (let k = 0; k < triggerStage.triggerOn.situations.length; k++) { + + let situation = triggerStage.triggerOn.situations[k]; + let passed = true; + + for (let m = 0; m < situation.conditions.length; m++) { + + let condition = situation.conditions[m]; + let key = j + '-' + 'triggerStage' + '-' + 'triggerOn' + '-' + k + '-' + m; + + let value = false + if (conditions.get(key) !== undefined) { + value = conditions.get(key).value; + } + + if (value === false) { passed = false; } + } + + if (passed) { + + strategyStage = 'Trigger Stage'; + currentStrategyIndex = j; + currentStrategy.begin = candle.begin; + currentStrategy.beginRate = candle.min; + currentStrategy.endRate = candle.min; // In case the strategy does not get exited + break; + } + } + } + } + } + } else { + let stopRunningDate = new Date(candle.begin) + if (balance < minimumBalance) { + tradingSystem.error = "Min Balance @ " + stopRunningDate.toUTCString() + } + if (balance > maximumBalance) { + tradingSystem.error = "Max Balance @ " + stopRunningDate.toUTCString() + } + } + } + + /* Trigger Off Condition */ + if (strategyStage === 'Trigger Stage') { + + let strategy = tradingSystem.strategies[currentStrategyIndex]; + + let triggerStage = strategy.triggerStage + + if (triggerStage !== undefined) { + + if (triggerStage.triggerOff !== undefined) { + + for (let k = 0; k < triggerStage.triggerOff.situations.length; k++) { + + let situation = triggerStage.triggerOff.situations[k]; + let passed = true; + + for (let m = 0; m < situation.conditions.length; m++) { + + let condition = situation.conditions[m]; + let key = currentStrategyIndex + '-' + 'triggerStage' + '-' + 'triggerOff' + '-' + k + '-' + m; + + let value = false + if (conditions.get(key) !== undefined) { + value = conditions.get(key).value; + } + + if (value === false) { passed = false; } + } + + if (passed) { + + currentStrategy.number = currentStrategyIndex + currentStrategy.end = candle.end; + currentStrategy.endRate = candle.min; + currentStrategy.status = 1; + strategyStage = 'No Stage'; + currentStrategyIndex = -1; + break; + } + } + } + } + } + + /* Take Position Condition */ + if (strategyStage === 'Trigger Stage') { + + let strategy = tradingSystem.strategies[currentStrategyIndex]; + + let triggerStage = strategy.triggerStage + + if (triggerStage !== undefined) { + + if (triggerStage.takePosition !== undefined) { + + for (let k = 0; k < triggerStage.takePosition.situations.length; k++) { + + let situation = triggerStage.takePosition.situations[k]; + let passed = true; + + for (let m = 0; m < situation.conditions.length; m++) { + + let condition = situation.conditions[m]; + let key = currentStrategyIndex + '-' + 'triggerStage' + '-' + 'takePosition' + '-' + k + '-' + m; + + let value = false + if (conditions.get(key) !== undefined) { + value = conditions.get(key).value; + } + + if (value === false) { passed = false; } + } + + if (passed) { + + type = '"Take Position"'; + + strategyStage = 'Open Stage'; + stopLossStage = 'Open Stage'; + takeProfitStage = 'Open Stage'; + stopLossPhase = 1; + takeProfitPhase = 1; + currentTrade.begin = candle.begin; + currentTrade.beginRate = candle.close; + takePositionNow = true + break; + } + } + } + } + } + + /* Stop Loss Management */ + if ( + (strategyStage === 'Open Stage' || strategyStage === 'Manage Stage') && + takePositionNow !== true + ) { + + checkStopPhases() + calculateStopLoss(); + + } + + function checkStopPhases() { + + let strategy = tradingSystem.strategies[currentStrategyIndex]; + + let openStage = strategy.openStage + let manageStage = strategy.manageStage + let parentNode + let j = currentStrategyIndex + let stageKey + let initialDefinitionKey = '' + let p + + if (stopLossStage === 'Open Stage' && openStage !== undefined) { + if (openStage.initialDefinition !== undefined) { + if (openStage.initialDefinition.stopLoss !== undefined) { + parentNode = openStage.initialDefinition + initialDefinitionKey = '-' + 'initialDefinition' + stageKey = 'openStage' + p = stopLossPhase - 1 + } + } + } + + if (stopLossStage === 'Manage Stage' && manageStage !== undefined) { + if (manageStage.stopLoss !== undefined) { + parentNode = manageStage + stageKey = 'manageStage' + p = stopLossPhase - 2 + } + } + + let phase = parentNode.stopLoss.phases[p]; + + let nextPhaseEvent = phase.nextPhaseEvent; + if (nextPhaseEvent !== undefined) { + + for (let k = 0; k < nextPhaseEvent.situations.length; k++) { + + let situation = nextPhaseEvent.situations[k]; + let passed = true; + + for (let m = 0; m < situation.conditions.length; m++) { + + let condition = situation.conditions[m]; + let key = j + '-' + stageKey + initialDefinitionKey + '-' + 'stopLoss' + '-' + p + '-' + k + '-' + m; + + let value = false + if (conditions.get(key) !== undefined) { + value = conditions.get(key).value; + } + + if (value === false) { passed = false; } + } + + if (passed) { + + stopLossPhase++; + stopLossStage = 'Manage Stage' + if (takeProfitPhase > 1) { strategyStage = 'Manage Stage' } + return; + } + } + } + } + + function calculateStopLoss() { + + let strategy = tradingSystem.strategies[currentStrategyIndex]; + let openStage = strategy.openStage + let manageStage = strategy.manageStage + let phase + let key + + if (stopLossStage === 'Open Stage' && openStage !== undefined) { + if (openStage.initialDefinition !== undefined) { + if (openStage.initialDefinition.stopLoss !== undefined) { + phase = openStage.initialDefinition.stopLoss.phases[stopLossPhase - 1]; + key = currentStrategyIndex + '-' + 'openStage' + '-' + 'initialDefinition' + '-' + 'stopLoss' + '-' + (stopLossPhase - 1); + } + } + } + + if (stopLossStage === 'Manage Stage' && manageStage !== undefined) { + if (manageStage.stopLoss !== undefined) { + phase = manageStage.stopLoss.phases[stopLossPhase - 2]; + key = currentStrategyIndex + '-' + 'manageStage' + '-' + 'stopLoss' + '-' + (stopLossPhase - 2); + } + } + + if (phase !== undefined) { + if (phase.formula !== undefined) { + stopLoss = formulas.get(key) + } + } + } + + /* Take Profit Management */ + if ( + (strategyStage === 'Open Stage' || strategyStage === 'Manage Stage') && + takePositionNow !== true + ) { + + checkTakeProfitPhases(); + calculateTakeProfit(); + + } + + function checkTakeProfitPhases() { + + let strategy = tradingSystem.strategies[currentStrategyIndex]; + + let openStage = strategy.openStage + let manageStage = strategy.manageStage + let parentNode + let j = currentStrategyIndex + let stageKey + let initialDefinitionKey = '' + let p + + if (takeProfitStage === 'Open Stage' && openStage !== undefined) { + if (openStage.initialDefinition !== undefined) { + if (openStage.initialDefinition.takeProfit !== undefined) { + parentNode = openStage.initialDefinition + initialDefinitionKey = '-' + 'initialDefinition' + stageKey = 'openStage' + p = takeProfitPhase - 1 + } + } + } + + if (takeProfitStage === 'Manage Stage' && manageStage !== undefined) { + if (manageStage.takeProfit !== undefined) { + parentNode = manageStage + stageKey = 'manageStage' + p = takeProfitPhase - 2 + } + } + + let phase = parentNode.takeProfit.phases[p]; + + let nextPhaseEvent = phase.nextPhaseEvent; + if (nextPhaseEvent !== undefined) { + + for (let k = 0; k < nextPhaseEvent.situations.length; k++) { + + let situation = nextPhaseEvent.situations[k]; + let passed = true; + + for (let m = 0; m < situation.conditions.length; m++) { + + let condition = situation.conditions[m]; + let key = j + '-' + stageKey + initialDefinitionKey + '-' + 'takeProfit' + '-' + p + '-' + k + '-' + m; + + let value = false + if (conditions.get(key) !== undefined) { + value = conditions.get(key).value; + } + + if (value === false) { passed = false; } + } + + if (passed) { + + takeProfitPhase++; + takeProfitStage = 'Manage Stage' + if (stopLossPhase > 1) { strategyStage = 'Manage Stage' } + return; + } + } + } + } + + function calculateTakeProfit() { + + let strategy = tradingSystem.strategies[currentStrategyIndex]; + let openStage = strategy.openStage + let manageStage = strategy.manageStage + let phase + let key + + if (takeProfitStage === 'Open Stage' && openStage !== undefined) { + if (openStage.initialDefinition !== undefined) { + if (openStage.initialDefinition.takeProfit !== undefined) { + phase = openStage.initialDefinition.takeProfit.phases[takeProfitPhase - 1]; + key = currentStrategyIndex + '-' + 'openStage' + '-' + 'initialDefinition' + '-' + 'takeProfit' + '-' + (takeProfitPhase - 1); + } + } + } + + if (takeProfitStage === 'Manage Stage' && manageStage !== undefined) { + if (manageStage.takeProfit !== undefined) { + phase = manageStage.takeProfit.phases[takeProfitPhase - 2]; + key = currentStrategyIndex + '-' + 'manageStage' + '-' + 'takeProfit' + '-' + (takeProfitPhase - 2); + } + } + + if (phase !== undefined) { + if (phase.formula !== undefined) { + takeProfit = formulas.get(key) + } + } + } + + /* Checking if Stop or Take Profit were hit */ + if ( + (strategyStage === 'Open Stage' || strategyStage === 'Manage Stage') && + takePositionNow !== true + ) { + + /* Checking what happened since the last execution. We need to know if the Stop Loss + or our Take Profit were hit. */ + + /* Stop Loss condition: Here we verify if the Stop Loss was hitted or not. */ + + if ((baseAsset === 'BTC' && candle.max >= stopLoss) || (baseAsset !== 'BTC' && candle.min <= stopLoss)) { + + if (baseAsset === 'BTC') { + balanceAssetA = balanceAssetA + balanceAssetB / stopLoss; + balanceAssetB = 0; + } else { + balanceAssetB = balanceAssetB + balanceAssetA * stopLoss; + balanceAssetA = 0; + } + + if (currentDay !== undefined) { + if (positionInstant < currentDay.valueOf()) { + yesterday.balanceAssetA = balanceAssetA; + yesterday.balanceAssetB = balanceAssetB; + } + } + + marketRate = stopLoss; + type = '"Close@StopLoss"'; + strategyStage = 'Close Stage'; + stopLossStage = 'No Stage'; + takeProfitStage = 'No Stage'; + currentTrade.end = candle.end; + currentTrade.status = 1; + currentTrade.exitType = 1; + currentTrade.endRate = stopLoss; + + currentStrategy.number = currentStrategyIndex + currentStrategy.end = candle.end; + currentStrategy.endRate = candle.min; + currentStrategy.status = 1; + } + + /* Take Profit condition: Here we verify if the Take Profit was filled or not. */ + + if ((baseAsset === 'BTC' && candle.min <= takeProfit) || (baseAsset !== 'BTC' && candle.max >= takeProfit)) { + + if (baseAsset === 'BTC') { + balanceAssetA = balanceAssetA + balanceAssetB / takeProfit; + balanceAssetB = 0; + } else { + balanceAssetB = balanceAssetB + balanceAssetA * takeProfit; + balanceAssetA = 0; + } + + if (currentDay !== undefined) { + if (positionInstant < currentDay.valueOf()) { + yesterday.balanceAssetA = balanceAssetA; + yesterday.balanceAssetB = balanceAssetB; + + } + } + + marketRate = takeProfit; + type = '"Close@TakeProfit"'; + strategyStage = 'Close Stage'; + stopLossStage = 'No Stage'; + takeProfitStage = 'No Stage'; + currentTrade.end = candle.end; + currentTrade.status = 1; + currentTrade.exitType = 2; + currentTrade.endRate = takeProfit; + + currentStrategy.number = currentStrategyIndex + currentStrategy.end = candle.end; + currentStrategy.endRate = candle.min; + currentStrategy.status = 1; + } + } + + /* Taking a Position */ + if ( + takePositionNow === true + ) { + takePositionNow = false + + /* tradePositionSize default is the whole balance if no size was defined by the user */ + if (baseAsset === 'BTC') { + tradePositionSize = balanceAssetA; + } else { + tradePositionSize = balanceAssetB; + } + tradePositionRate = candle.close + + /* Check if the user defined a position size or rate */ + let strategy = tradingSystem.strategies[currentStrategyIndex]; + + tradePositionSize = strategy.positionSize; + tradePositionRate = strategy.positionRate; + + calculateTakeProfit(); + calculateStopLoss(); + + marketRate = candle.close; + + previousBalanceAssetA = balanceAssetA; + previousBalanceAssetB = balanceAssetB; + + lastTradeProfitLoss = 0; + lastTradeROI = 0; + + if (baseAsset === 'BTC') { + balanceAssetB = balanceAssetB + tradePositionSize * tradePositionRate; + balanceAssetA = balanceAssetA - tradePositionSize; + } else { + balanceAssetA = balanceAssetA + tradePositionSize / tradePositionRate; + balanceAssetB = balanceAssetB - tradePositionSize; + } + + positionInstant = candle.end; + + if (currentDay !== undefined) { + if (positionInstant < currentDay.valueOf()) { + yesterday.balanceAssetA = balanceAssetA; + yesterday.balanceAssetB = balanceAssetB; + + yesterday.lastTradeProfitLoss = lastTradeProfitLoss; + yesterday.lastTradeROI = lastTradeROI; + } + } + + addRecord(); + continue; + } + + /* Closing a Position */ + if (strategyStage === 'Close Stage') { + + roundtrips++; + + if (currentDay !== undefined) { + if (positionInstant < currentDay.valueOf()) { + yesterday.Roundtrips++; + } + } + + if (baseAsset === 'BTC') { + lastTradeProfitLoss = balanceAssetA - previousBalanceAssetA; + lastTradeROI = lastTradeProfitLoss * 100 / tradePositionSize; + if (isNaN(lastTradeROI)) { lastTradeROI = 0; } + profit = balanceAssetA - initialBalanceA; + } else { + lastTradeProfitLoss = balanceAssetB - previousBalanceAssetB; + lastTradeROI = lastTradeProfitLoss * 100 / tradePositionSize; + if (isNaN(lastTradeROI)) { lastTradeROI = 0; } + profit = balanceAssetB - initialBalanceB; + } + + if (currentDay !== undefined) { + if (positionInstant < currentDay.valueOf()) { + yesterday.lastTradeProfitLoss = lastTradeProfitLoss; + yesterday.profit = profit; + yesterday.lastTradeROI = lastTradeROI; + } + } + + currentTrade.lastTradeROI = lastTradeROI; + currentTrade.stopRate = stopLoss; + + if (lastTradeProfitLoss > 0) { + hits++; + + if (currentDay !== undefined) { + if (positionInstant < currentDay.valueOf()) { + yesterday.hits++; + } + } + + } else { + fails++; + + if (currentDay !== undefined) { + if (positionInstant < currentDay.valueOf()) { + yesterday.fails++; + } + } + } + + if (baseAsset === 'BTC') { + ROI = (initialBalanceA + profit) / initialBalanceA - 1; + hitRatio = hits / roundtrips; + anualizedRateOfReturn = ROI / days * 365; + } else { + ROI = (initialBalanceB + profit) / initialBalanceB - 1; + hitRatio = hits / roundtrips; + anualizedRateOfReturn = ROI / days * 365; + } + + if (currentDay !== undefined) { + if (positionInstant < currentDay.valueOf()) { + yesterday.ROI = ROI; + yesterday.hitRatio = hitRatio; + yesterday.anualizedRateOfReturn = anualizedRateOfReturn; + } + } + + + addRecord(); + + currentStrategyIndex = -1; + stopLoss = 0; + tradePositionRate = 0; + tradePositionSize = 0; + positionInstant = undefined; + takeProfit = 0; + strategyStage = 'No Stage'; + stopLossStage = 'No Stage'; + takeProfitStage = 'No Stage'; + stopLossPhase = 0; + takeProfitPhase = 0; + continue; + + } + + /* Not a buy or sell condition */ + + marketRate = candle.close; + addRecord(); + + function addRecord() { + + // Since we are going to write the message to a file that the Simulation Executor is going to read, we use the abbreviations. + let messageType; + let message; + let simulationRecord; + let executionRecord; + let executionMessage; + + messageId++; + + if (strategyStage === 'Open Stage' || strategyStage === 'Manage Stage' || type === '"Close@TakeProfit"' || type === '"Close@StopLoss"') { + + if (type === '"Take Position"') { + messageType = MESSAGE_TYPE.Order; + orderId++; + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] runSimulation -> addRecord -> Taking Position Now. "); } + + } else { + if (type === '"Close@TakeProfit"' || type === '"Close@StopLoss"') { + messageType = MESSAGE_TYPE.OrderClose; + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] runSimulation -> addRecord -> Closing Position Now. "); } + + } else { + messageType = MESSAGE_TYPE.OrderUpdate; + } + } + + let exitOutcome = "" + if (messageType === MESSAGE_TYPE.OrderClose && type === '"Close@TakeProfit"') { + exitOutcome = "TP" + } + if (messageType === MESSAGE_TYPE.OrderClose && type === '"Close@StopLoss"') { + exitOutcome = "SL" + } + + executionMessage = createMessage( + messageId, + MESSAGE_ENTITY.SimulationEngine, + MESSAGE_ENTITY.SimulationExecutor, + messageType, + (new Date()).valueOf(), + orderId.toString(), + ORDER_CREATOR.SimulationEngine, + (new Date()).valueOf(), + ORDER_OWNER.User, + global.EXCHANGE_NAME, + "BTC_USDT", + 0, + ORDER_TYPE.Limit, + tradePositionRate, + stopLoss, + takeProfit, + ORDER_DIRECTION.Sell, + -1, + ORDER_STATUS.Signaled, + 0, + exitOutcome) + + } + else { + + executionMessage = createMessage( + messageId, + MESSAGE_ENTITY.SimulationEngine, + MESSAGE_ENTITY.SimulationExecutor, + MESSAGE_TYPE.HeartBeat, + (new Date()).valueOf(), + "", + "", + 0, + "", + "", + "", + 0, + "", + 0, + 0, + 0, + "", + 0, + "", + 0, + "", + "") + } + + executionRecord = { + begin: candle.begin, + end: candle.end, + executionRecord: executionMessage + } + + executionArray.push(executionRecord) + + let strategyStageNumber + switch (strategyStage) { + case 'No Stage': { + strategyStageNumber = 0 + break + } + case 'Trigger Stage': { + strategyStageNumber = 1 + break + } + case 'Open Stage': { + strategyStageNumber = 2 + break + } + case 'Manage Stage': { + strategyStageNumber = 3 + break + } + case 'Close Stage': { + strategyStageNumber = 4 + break + } + } + + if (balanceAssetA === Infinity) { + balanceAssetA = Number.MAX_SAFE_INTEGER + } + + if (balanceAssetB === Infinity) { + balanceAssetB = Number.MAX_SAFE_INTEGER + } + + let quotedBaseAsset = '"' + baseAsset + '"' + + simulationRecord = { + begin: candle.begin, + end: candle.end, + type: type, + marketRate: marketRate, + amount: 1, + balanceA: balanceAssetA, + balanceB: balanceAssetB, + profit: profit, + lastTradeProfitLoss: lastTradeProfitLoss, + stopLoss: stopLoss, + roundtrips: roundtrips, + hits: hits, + fails: fails, + hitRatio: hitRatio, + ROI: ROI, + periods: periods, + days: days, + anualizedRateOfReturn: anualizedRateOfReturn, + positionRate: tradePositionRate, + lastTradeROI: lastTradeROI, + strategy: currentStrategyIndex, + strategyStageNumber: strategyStageNumber, + takeProfit: takeProfit, + stopLossPhase: stopLossPhase, + takeProfitPhase: takeProfitPhase, + executionRecord: executionMessage, + positionSize: tradePositionSize, + initialBalanceA: initialBalanceA, + minimumBalanceA: minimumBalanceA, + maximumBalanceA: maximumBalanceA, + initialBalanceB: initialBalanceB, + minimumBalanceB: minimumBalanceB, + maximumBalanceB: maximumBalanceB, + baseAsset: quotedBaseAsset + } + + recordsArray.push(simulationRecord); + + type = '""'; + + /* Prepare the information for the Conditions File */ + + conditionsArrayRecord.push(currentStrategyIndex); + conditionsArrayRecord.push(strategyStageNumber); + conditionsArrayRecord.push(stopLossPhase); + conditionsArrayRecord.push(takeProfitPhase); + conditionsArrayRecord.push(conditionsArrayValues); + conditionsArrayRecord.push(formulasErrors); + conditionsArrayRecord.push(formulasValues); + + conditionsArray.push(conditionsArrayRecord); + + /* Prepare the information for the Strategies File*/ + + if ( + (currentStrategy.begin !== 0 && currentStrategy.end !== 0) || + (currentStrategy.begin !== 0 && i === candles.length - 1 && lastCandle.end !== lastInstantOfTheDay) + ) { + + strategiesArray.push(currentStrategy); + + currentStrategy = { + begin: 0, + end: 0, + status: 0, + number: 0, + beginRate: 0, + endRate: 0 + } + } + + /* Prepare the information for the Trades File */ + + if ( + (currentTrade.begin !== 0 && currentTrade.end !== 0) || + (currentTrade.begin !== 0 && i === candles.length - 1 && lastCandle.end !== lastInstantOfTheDay) + ) { + + currentTrade.profit = lastTradeProfitLoss; + + tradesArray.push(currentTrade); + + currentTrade = { + begin: 0, + end: 0, + status: 0, + lastTradeROI: 0, + exitType: 0, + beginRate: 0, + endRate: 0 + } + } + } + } + + /* + Before returning we need to see if we have to record some of our counters at the interExecutionMemory. + To do that, the condition to be met is that this execution must include all candles of the currentDay. + */ + + if (currentDay !== undefined) { + + if (lastCandle.end === lastInstantOfTheDay) { + + interExecutionMemory.balanceAssetA = yesterday.balanceAssetA; + interExecutionMemory.balanceAssetB = yesterday.balanceAssetB; + interExecutionMemory.lastTradeProfitLoss = yesterday.lastTradeProfitLoss; + interExecutionMemory.profit = yesterday.profit; + interExecutionMemory.lastTradeROI = yesterday.lastTradeROI; + + interExecutionMemory.roundtrips = interExecutionMemory.roundtrips + yesterday.Roundtrips; + interExecutionMemory.fails = interExecutionMemory.fails + yesterday.fails; + interExecutionMemory.hits = interExecutionMemory.hits + yesterday.hits; + interExecutionMemory.periods = interExecutionMemory.periods + yesterday.Periods; + + interExecutionMemory.messageId = interExecutionMemory.messageId + yesterday.messageId; + interExecutionMemory.orderId = interExecutionMemory.orderId + yesterday.orderId; + + interExecutionMemory.hitRatio = yesterday.hitRatio; + interExecutionMemory.ROI = yesterday.ROI; + interExecutionMemory.anualizedRateOfReturn = yesterday.anualizedRateOfReturn; + } + } + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] runSimulation -> callback -> recordsArray.length = " + recordsArray.length); } + + callback(tradingSystem, executionArray, recordsArray, conditionsArray, strategiesArray, tradesArray, lastObjectsArray); + + function getElement(pArray, begin, end) { + + let element; + + for (let i = 0; i < pArray.length; i++) { + + element = pArray[i]; + + if (begin >= element.begin && end <= element.end) { + return element + } + } + + return + } + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] runSimulation -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + + function buildLRC(dataFile, callBackFunction) { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] buildLRC -> Entering function."); } + + try { + + let previous; + + for (let i = 0; i < dataFile.length; i++) { + + let LRC = { + begin: dataFile[i][0], + end: dataFile[i][1], + _15: dataFile[i][2], + _30: dataFile[i][3], + _60: dataFile[i][4] + }; + + if (previous !== undefined) { + + if (previous._15 > LRC._15) { LRC.direction15 = 'Down'; } + if (previous._15 < LRC._15) { LRC.direction15 = 'Up'; } + if (previous._15 === LRC._15) { LRC.direction15 = 'Side'; } + + if (previous._30 > LRC._30) { LRC.direction30 = 'Down'; } + if (previous._30 < LRC._30) { LRC.direction30 = 'Up'; } + if (previous._30 === LRC._30) { LRC.direction30 = 'Side'; } + + if (previous._60 > LRC._60) { LRC.direction60 = 'Down'; } + if (previous._60 < LRC._60) { LRC.direction60 = 'Up'; } + if (previous._60 === LRC._60) { LRC.direction60 = 'Side'; } + + } + + LRC.previous = previous; + + LRCMap.set(LRC.begin, LRC); + + previous = LRC; + } + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] buildLRC -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + + function buildPercentageBandwidthMap(dataFile, callBackFunction) { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] buildPercentageBandwidthMap -> Entering function."); } + + try { + + let previous; + + for (let i = 0; i < dataFile.length; i++) { + + let percentageBandwidth = { + begin: dataFile[i][0], + end: dataFile[i][1], + value: dataFile[i][2], + movingAverage: dataFile[i][3], + bandwidth: dataFile[i][4] + }; + + if (previous !== undefined) { + + if (previous.movingAverage > percentageBandwidth.movingAverage) { percentageBandwidth.direction = 'Down'; } + if (previous.movingAverage < percentageBandwidth.movingAverage) { percentageBandwidth.direction = 'Up'; } + if (previous.movingAverage === percentageBandwidth.movingAverage) { percentageBandwidth.direction = 'Side'; } + + } + + percentageBandwidth.previous = previous; + + percentageBandwidthMap.set(percentageBandwidth.begin, percentageBandwidth); + + previous = percentageBandwidth; + } + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] buildPercentageBandwidthMap -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + + function buildBollingerBandsMap(dataFile, callBackFunction) { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] buildBollingerBandsMap -> Entering function."); } + + try { + + let previous; + + for (let i = 0; i < dataFile.length; i++) { + + let bollingerBand = { + begin: dataFile[i][0], + end: dataFile[i][1], + movingAverage: dataFile[i][2], + standardDeviation: dataFile[i][3], + deviation: dataFile[i][4] + }; + + if (previous !== undefined) { + + if (previous.movingAverage > bollingerBand.movingAverage) { bollingerBand.direction = 'Down'; } + if (previous.movingAverage < bollingerBand.movingAverage) { bollingerBand.direction = 'Up'; } + if (previous.movingAverage === bollingerBand.movingAverage) { bollingerBand.direction = 'Side'; } + + } + + bollingerBand.previous = previous; + + bollingerBandsMap.set(bollingerBand.begin, bollingerBand); + + previous = bollingerBand; + } + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] buildBollingerBandsMap -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + + function buildBollingerChannelsArray(dataFile, callBackFunction) { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] buildBollingerChannelsArray -> Entering function."); } + + try { + + let previous; + + for (let i = 0; i < dataFile.length; i++) { + + let bollingerChannel = { + begin: dataFile[i][0], + end: dataFile[i][1], + direction: dataFile[i][2], + period: dataFile[i][3] + }; + + bollingerChannel.previous = previous; + + bollingerChannelsArray.push(bollingerChannel); + + previous = bollingerChannel; + } + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] buildBollingerChannelsArray -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + + function buildBollingerSubChannelsArray(dataFile, callBackFunction) { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] buildBollingerSubChannelsArray -> Entering function."); } + + try { + + let previous; + + for (let i = 0; i < dataFile.length; i++) { + + let bollingerSubChannel = { + begin: dataFile[i][0], + end: dataFile[i][1], + direction: dataFile[i][2], + slope: dataFile[i][3], + period: dataFile[i][4], + firstMovingAverage: dataFile[i][5], + lastMovingAverage: dataFile[i][6], + firstDeviation: dataFile[i][7], + lastDeviation: dataFile[i][8] + }; + + bollingerSubChannel.previous = previous; + + bollingerSubChannelsArray.push(bollingerSubChannel); + + previous = bollingerSubChannel; + } + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] buildBollingerSubChannelsArray -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + + function buildCandles(dataFile, callBackFunction) { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] buildCandles -> Entering function."); } + + try { + + let previous; + + for (let i = 0; i < dataFile.length; i++) { + + let candle = { + open: undefined, + close: undefined, + min: 10000000000000, + max: 0, + begin: undefined, + end: undefined, + direction: undefined + }; + + candle.min = dataFile[i][0]; + candle.max = dataFile[i][1]; + + candle.open = dataFile[i][2]; + candle.close = dataFile[i][3]; + + candle.begin = dataFile[i][4]; + candle.end = dataFile[i][5]; + + if (candle.open > candle.close) { candle.direction = 'Down'; } + if (candle.open < candle.close) { candle.direction = 'Up'; } + if (candle.open === candle.close) { candle.direction = 'Side'; } + + candle.previous = previous; + + candles.push(candle); + + previous = candle; + } + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] buildCandles -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } +}; diff --git a/src/storage/templates/Simulator/User.Bot.Daily.js b/src/storage/templates/Simulator/User.Bot.Daily.js new file mode 100644 index 000000000..ef105c9a6 --- /dev/null +++ b/src/storage/templates/Simulator/User.Bot.Daily.js @@ -0,0 +1,553 @@ +exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileStorage) { + + const FULL_LOG = true; + const LOG_FILE_CONTENT = false; + + const MODULE_NAME = "User Bot"; + + const EXECUTION_FOLDER_NAME = "Trading-Execution"; + const SIMULATED_RECORDS_FOLDER_NAME = "Trading-Simulation"; + const CONDITIONS_FOLDER_NAME = "Simulation-Conditions"; + const STRATEGIES_FOLDER_NAME = "Simulation-Strategies"; + const TRADES_FOLDER_NAME = "Simulation-Trades"; + + const commons = COMMONS.newCommons(bot, logger, UTILITIES); + + thisObject = { + initialize: initialize, + start: start + }; + + let utilities = UTILITIES.newCloudUtilities(bot, logger); + + let dataDependencies; + + return thisObject; + + function initialize(pDataDependencies, callBackFunction) { + + try { + + logger.fileName = MODULE_NAME; + logger.initialize(); + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] initialize -> Entering function."); } + + dataDependencies = pDataDependencies; + + callBackFunction(global.DEFAULT_OK_RESPONSE); + + } catch (err) { + logger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + + function start(dataFiles, timePeriod, outputPeriodLabel, currentDay, startDate, endDate, interExecutionMemory, callBackFunction) { + + try { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> Entering function."); } + + let market = global.MARKET; + let dataFile; + + let recordsArray + let conditionsArray + let strategiesArray + let tradesArray + let lastObjectsArray + + let tradingSystem = {}; + + commons.initializeData(); + + for (let i = 0; i < dataDependencies.config.length; i++) { + + let dependency = dataDependencies.config[i]; + dataFile = dataFiles[i]; + + switch (i) { + + case 0: { + commons.buildLRC(dataFile, callBackFunction); + break; + } + case 1: { + commons.buildPercentageBandwidthMap(dataFile, callBackFunction); + break; + } + case 2: { + commons.buildBollingerBandsMap(dataFile, callBackFunction); + break; + } + case 3: { + commons.buildBollingerChannelsArray(dataFile, callBackFunction); + break; + } + case 4: { + commons.buildBollingerSubChannelsArray(dataFile, callBackFunction); + break; + } + case 5: { + commons.buildCandles(dataFile, callBackFunction); + break; + } + } + } + + commons.runSimulation( + timePeriod, + currentDay, + startDate, + endDate, + interExecutionMemory, + writeFiles, + callBackFunction) + + function writeFiles(pTradingSystem, pExecutionArray, pRecordsArray, pConditionsArray, pStrategiesArray, pTradesArray, pLastObjectsArray) { + + tradingSystem = pTradingSystem + executionArray = pExecutionArray + recordsArray = pRecordsArray + conditionsArray = pConditionsArray + strategiesArray = pStrategiesArray + tradesArray = pTradesArray + lastObjectsArray = pLastObjectsArray + + writeExecutionFile() + } + + function writeExecutionFile() { + + try { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeExecutionFile -> Entering function."); } + + let separator = ""; + let fileRecordCounter = 0; + + let fileContent = ""; + + for (let i = 0; i < executionArray.length; i++) { + + let record = executionArray[i]; + + /* Will only add to the file the records of the current day */ + + if (record.begin < currentDay.valueOf()) { continue; } + + fileContent = fileContent + separator + '[' + + record.begin + "," + + record.end + "," + + JSON.stringify(record.executionRecord) + "]"; + + if (separator === "") { separator = ","; } + + fileRecordCounter++; + + } + + fileContent = "[" + fileContent + "]"; + + let dateForPath = currentDay.getUTCFullYear() + '/' + utilities.pad(currentDay.getUTCMonth() + 1, 2) + '/' + utilities.pad(currentDay.getUTCDate(), 2); + let fileName = '' + market.assetA + '_' + market.assetB + '.json'; + + let filePathRoot = bot.devTeam + "/" + bot.codeName + "." + bot.version.major + "." + bot.version.minor + "/" + global.CLONE_EXECUTOR.codeName + "." + global.CLONE_EXECUTOR.version + "/" + global.EXCHANGE_NAME + "/" + bot.dataSetVersion; + let filePath = filePathRoot + "/Output/" + EXECUTION_FOLDER_NAME + "/" + "Multi-Period-Daily" + "/" + outputPeriodLabel + "/" + dateForPath; + filePath += '/' + fileName + + fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); + + function onFileCreated(err) { + + try { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeExecutionFile -> onFileCreated -> Entering function."); } + if (LOG_FILE_CONTENT === true) { logger.write(MODULE_NAME, "[INFO] start -> writeExecutionFile -> onFileCreated -> fileContent = " + fileContent); } + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + + logger.write(MODULE_NAME, "[ERROR] start -> writeExecutionFile -> onFileCreated -> err = " + err.stack); + logger.write(MODULE_NAME, "[ERROR] start -> writeExecutionFile -> onFileCreated -> filePath = " + filePath); + logger.write(MODULE_NAME, "[ERROR] start -> writeExecutionFile -> onFileCreated -> market = " + market.assetA + "_" + market.assetB); + + callBackFunction(err); + return; + + } + + writeRecordsFile(); + + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] start -> writeExecutionFile -> onFileCreated -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] start -> writeExecutionFile -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + + function writeRecordsFile() { + + try { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeRecordsFile -> Entering function."); } + + let separator = ""; + let fileRecordCounter = 0; + + let fileContent = ""; + + for (let i = 0; i < recordsArray.length; i++) { + + let record = recordsArray[i]; + + /* Will only add to the file the records of the current day */ + + if (record.begin < currentDay.valueOf()) { continue; } + + fileContent = fileContent + separator + '[' + + record.begin + "," + + record.end + "," + + record.type + "," + + record.marketRate + "," + + record.amount + "," + + record.balanceA + "," + + record.balanceB + "," + + record.profit + "," + + record.lastTradeProfitLoss + "," + + record.stopLoss + "," + + record.roundtrips + "," + + record.hits + "," + + record.fails + "," + + record.hitRatio + "," + + record.ROI + "," + + record.periods + "," + + record.days + "," + + record.anualizedRateOfReturn + "," + + record.positionRate + "," + + record.lastTradeROI + "," + + record.strategy + "," + + record.strategyStageNumber + "," + + record.takeProfit + "," + + record.stopLossPhase + "," + + record.takeProfitPhase + "," + + JSON.stringify(record.executionRecord) + "," + + record.positionSize + "," + + record.initialBalanceA + "," + + record.minimumBalanceA + "," + + record.maximumBalanceA + "," + + record.initialBalanceB + "," + + record.minimumBalanceB + "," + + record.maximumBalanceB + "," + + record.baseAsset + "]"; + + if (separator === "") { separator = ","; } + + fileRecordCounter++; + + } + + fileContent = "[" + fileContent + "]"; + + let dateForPath = currentDay.getUTCFullYear() + '/' + utilities.pad(currentDay.getUTCMonth() + 1, 2) + '/' + utilities.pad(currentDay.getUTCDate(), 2); + let fileName = '' + market.assetA + '_' + market.assetB + '.json'; + + let filePathRoot = bot.devTeam + "/" + bot.codeName + "." + bot.version.major + "." + bot.version.minor + "/" + global.CLONE_EXECUTOR.codeName + "." + global.CLONE_EXECUTOR.version + "/" + global.EXCHANGE_NAME + "/" + bot.dataSetVersion; + let filePath = filePathRoot + "/Output/" + SIMULATED_RECORDS_FOLDER_NAME + "/" + "Multi-Period-Daily" + "/" + outputPeriodLabel + "/" + dateForPath; + filePath += '/' + fileName + + fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); + + function onFileCreated(err) { + + try { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeRecordsFile -> onFileCreated -> Entering function."); } + if (LOG_FILE_CONTENT === true) { logger.write(MODULE_NAME, "[INFO] start -> writeRecordsFile -> onFileCreated -> fileContent = " + fileContent); } + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + + logger.write(MODULE_NAME, "[ERROR] start -> writeRecordsFile -> onFileCreated -> err = " + err.stack); + logger.write(MODULE_NAME, "[ERROR] start -> writeRecordsFile -> onFileCreated -> filePath = " + filePath); + logger.write(MODULE_NAME, "[ERROR] start -> writeRecordsFile -> onFileCreated -> market = " + market.assetA + "_" + market.assetB); + + callBackFunction(err); + return; + + } + + writeConditionsFile(); + + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] start -> writeRecordsFile -> onFileCreated -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] start -> writeRecordsFile -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + + function writeConditionsFile() { + + try { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeConditionsFile -> Entering function."); } + + let separator = ""; + let fileRecordCounter = 0; + + let fileContent = ""; + + for (let i = 0; i < conditionsArray.length; i++) { + + let record = conditionsArray[i]; + + /* Will only add to the file the records of the current day */ + + if (record.begin < currentDay.valueOf()) { continue; } + + let conditions = ""; + let conditionsSeparator = ""; + + /* Will only add to the file the records of the current day */ + + if (record.begin < currentDay.valueOf()) { continue; } + + for (let j = 0; j < record.length - 3; j++) { + conditions = conditions + conditionsSeparator + record[j]; + if (conditionsSeparator === "") { conditionsSeparator = ","; } + } + + conditions = conditions + conditionsSeparator + '[' + record[record.length - 3] + ']'; // The last item contains an Array of condition values. + conditions = conditions + conditionsSeparator + '[' + record[record.length - 2] + ']'; // The last item contains an Array of formulaErrors. + conditions = conditions + conditionsSeparator + '[' + record[record.length - 1] + ']'; // The last item contains an Array of formulaValues. + + fileContent = fileContent + separator + '[' + conditions + ']'; + + if (separator === "") { separator = ","; } + + fileRecordCounter++; + + } + + fileContent = "[" + fileContent + "]"; + fileContent = "[" + JSON.stringify(tradingSystem) + "," + JSON.stringify(lastObjectsArray) + "," + fileContent + "]"; + + let dateForPath = currentDay.getUTCFullYear() + '/' + utilities.pad(currentDay.getUTCMonth() + 1, 2) + '/' + utilities.pad(currentDay.getUTCDate(), 2); + let fileName = '' + market.assetA + '_' + market.assetB + '.json'; + + let filePathRoot = bot.devTeam + "/" + bot.codeName + "." + bot.version.major + "." + bot.version.minor + "/" + global.CLONE_EXECUTOR.codeName + "." + global.CLONE_EXECUTOR.version + "/" + global.EXCHANGE_NAME + "/" + bot.dataSetVersion; + let filePath = filePathRoot + "/Output/" + CONDITIONS_FOLDER_NAME + "/" + "Multi-Period-Daily" + "/" + outputPeriodLabel + "/" + dateForPath; + filePath += '/' + fileName + + fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); + + function onFileCreated(err) { + + try { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeConditionsFile -> onFileCreated -> Entering function."); } + if (LOG_FILE_CONTENT === true) { logger.write(MODULE_NAME, "[INFO] start -> writeConditionsFile -> onFileCreated -> fileContent = " + fileContent); } + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + + logger.write(MODULE_NAME, "[ERROR] start -> writeConditionsFile -> onFileCreated -> err = " + err.stack); + logger.write(MODULE_NAME, "[ERROR] start -> writeConditionsFile -> onFileCreated -> filePath = " + filePath); + logger.write(MODULE_NAME, "[ERROR] start -> writeConditionsFile -> onFileCreated -> market = " + market.assetA + "_" + market.assetB); + + callBackFunction(err); + return; + + } + + writeStrategiesFile(); + + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] start -> writeConditionsFile -> onFileCreated -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] start -> writeConditionsFile -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + + function writeStrategiesFile() { + + try { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeStrategiesFile -> Entering function."); } + + let separator = ""; + let fileRecordCounter = 0; + + let fileContent = ""; + + for (let i = 0; i < strategiesArray.length; i++) { + let record = strategiesArray[i]; + + /* Will only add to the file the records of the current day. In this case since objects can span more than one day, we add all of the objects that ends + at the current date. */ + + if (record.end < currentDay.valueOf()) { continue; } + + fileContent = fileContent + separator + '[' + + record.begin + "," + + record.end + "," + + record.status + "," + + record.number + "," + + record.beginRate + "," + + record.endRate + "]"; + + if (separator === "") { separator = ","; } + + fileRecordCounter++; + + } + + fileContent = "[" + fileContent + "]"; + + let dateForPath = currentDay.getUTCFullYear() + '/' + utilities.pad(currentDay.getUTCMonth() + 1, 2) + '/' + utilities.pad(currentDay.getUTCDate(), 2); + let fileName = '' + market.assetA + '_' + market.assetB + '.json'; + + let filePathRoot = bot.devTeam + "/" + bot.codeName + "." + bot.version.major + "." + bot.version.minor + "/" + global.CLONE_EXECUTOR.codeName + "." + global.CLONE_EXECUTOR.version + "/" + global.EXCHANGE_NAME + "/" + bot.dataSetVersion; + let filePath = filePathRoot + "/Output/" + STRATEGIES_FOLDER_NAME + "/" + "Multi-Period-Daily" + "/" + outputPeriodLabel + "/" + dateForPath; + filePath += '/' + fileName + + fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); + + function onFileCreated(err) { + + try { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeStrategiesFile -> onFileCreated -> Entering function."); } + if (LOG_FILE_CONTENT === true) { logger.write(MODULE_NAME, "[INFO] start -> writeStrategiesFile -> onFileCreated -> fileContent = " + fileContent); } + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + + logger.write(MODULE_NAME, "[ERROR] start -> writeStrategiesFile -> onFileCreated -> err = " + err.stack); + logger.write(MODULE_NAME, "[ERROR] start -> writeStrategiesFile -> onFileCreated -> filePath = " + filePath); + logger.write(MODULE_NAME, "[ERROR] start -> writeStrategiesFile -> onFileCreated -> market = " + market.assetA + "_" + market.assetB); + + callBackFunction(err); + return; + + } + + writeTradesFile(); + + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] start -> writeStrategiesFile -> onFileCreated -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] start -> writeStrategiesFile -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + + function writeTradesFile() { + + try { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeTradesFile -> Entering function."); } + + let separator = ""; + let fileRecordCounter = 0; + + let fileContent = ""; + + for (let i = 0; i < tradesArray.length; i++) { + + let record = tradesArray[i]; + + /* Will only add to the file the records of the current day. In this case since objects can span more than one day, we add all of the objects that ends + at the current date. */ + + if (record.end < currentDay.valueOf()) { continue; } + if (record.stopRate === undefined) { record.stopRate = 0} + + fileContent = fileContent + separator + '[' + + record.begin + "," + + record.end + "," + + record.status + "," + + record.lastTradeROI + "," + + record.beginRate + "," + + record.endRate + "," + + record.exitType + "," + + record.stopRate + "]"; + + if (separator === "") { separator = ","; } + + fileRecordCounter++; + + } + + fileContent = "[" + fileContent + "]"; + + let dateForPath = currentDay.getUTCFullYear() + '/' + utilities.pad(currentDay.getUTCMonth() + 1, 2) + '/' + utilities.pad(currentDay.getUTCDate(), 2); + let fileName = '' + market.assetA + '_' + market.assetB + '.json'; + + let filePathRoot = bot.devTeam + "/" + bot.codeName + "." + bot.version.major + "." + bot.version.minor + "/" + global.CLONE_EXECUTOR.codeName + "." + global.CLONE_EXECUTOR.version + "/" + global.EXCHANGE_NAME + "/" + bot.dataSetVersion; + let filePath = filePathRoot + "/Output/" + TRADES_FOLDER_NAME + "/" + "Multi-Period-Daily" + "/" + outputPeriodLabel + "/" + dateForPath; + filePath += '/' + fileName + + fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); + + function onFileCreated(err) { + + try { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeTradesFile -> onFileCreated -> Entering function."); } + if (LOG_FILE_CONTENT === true) { logger.write(MODULE_NAME, "[INFO] start -> writeTradesFile -> onFileCreated -> fileContent = " + fileContent); } + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + + logger.write(MODULE_NAME, "[ERROR] start -> writeTradesFile -> onFileCreated -> err = " + err.stack); + logger.write(MODULE_NAME, "[ERROR] start -> writeTradesFile -> onFileCreated -> filePath = " + filePath); + logger.write(MODULE_NAME, "[ERROR] start -> writeTradesFile -> onFileCreated -> market = " + market.assetA + "_" + market.assetB); + + callBackFunction(err); + return; + + } + + callBackFunction(global.DEFAULT_OK_RESPONSE); + + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] start -> writeTradesFile -> onFileCreated -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] start -> writeTradesFile -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + + + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] start -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } +}; diff --git a/src/storage/templates/Simulator/User.Bot.Market.js b/src/storage/templates/Simulator/User.Bot.Market.js new file mode 100644 index 000000000..a4dc38283 --- /dev/null +++ b/src/storage/templates/Simulator/User.Bot.Market.js @@ -0,0 +1,518 @@ +exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileStorage) { + + const FULL_LOG = true; + const LOG_FILE_CONTENT = false; + + const MODULE_NAME = "User Bot"; + + const EXECUTION_FOLDER_NAME = "Trading-Execution"; + const SIMULATED_RECORDS_FOLDER_NAME = "Trading-Simulation"; + const CONDITIONS_FOLDER_NAME = "Simulation-Conditions"; + const STRATEGIES_FOLDER_NAME = "Simulation-Strategies"; + const TRADES_FOLDER_NAME = "Simulation-Trades"; + + const commons = COMMONS.newCommons(bot, logger, UTILITIES); + + thisObject = { + initialize: initialize, + start: start + }; + + let dataDependencies; + + return thisObject; + + function initialize(pDataDependencies, callBackFunction) { + + try { + + logger.fileName = MODULE_NAME; + logger.initialize(); + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] initialize -> Entering function."); } + + dataDependencies = pDataDependencies; + + callBackFunction(global.DEFAULT_OK_RESPONSE); + + } catch (err) { + logger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + + function start(dataFiles, timePeriod, outputPeriodLabel, startDate, endDate, callBackFunction) { + + try { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> Entering function."); } + + let market = global.MARKET; + let dataFile; + + let recordsArray + let conditionsArray + let strategiesArray + let tradesArray + let lastObjectsArray + + let tradingSystem = {}; + let interExecutionMemory = {}; + let currentDay = bot.processDatetime; + + commons.initializeData(); + + for (let i = 0; i < dataDependencies.config.length; i++) { + + let dependency = dataDependencies.config[i]; + dataFile = dataFiles[i]; + + switch (i) { + + case 0: { + commons.buildLRC(dataFile, callBackFunction); + break; + } + case 1: { + commons.buildPercentageBandwidthMap(dataFile, callBackFunction); + break; + } + case 2: { + commons.buildBollingerBandsMap(dataFile, callBackFunction); + break; + } + case 3: { + commons.buildBollingerChannelsArray(dataFile, callBackFunction); + break; + } + case 4: { + commons.buildBollingerSubChannelsArray(dataFile, callBackFunction); + break; + } + case 5: { + commons.buildCandles(dataFile, callBackFunction); + break; + } + } + } + + commons.runSimulation( + timePeriod, + currentDay, + startDate, + endDate, + interExecutionMemory, + writeFiles, + callBackFunction) + + function writeFiles(pTradingSystem, pExecutionArray, pRecordsArray, pConditionsArray, pStrategiesArray, pTradesArray, pLastObjectsArray) { + + tradingSystem = pTradingSystem + executionArray = pExecutionArray + recordsArray = pRecordsArray + conditionsArray = pConditionsArray + strategiesArray = pStrategiesArray + tradesArray = pTradesArray + lastObjectsArray = pLastObjectsArray + + writeExecutionFile() + } + + function writeExecutionFile() { + + try { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeExecutionFile -> Entering function."); } + + let separator = ""; + let fileRecordCounter = 0; + + let fileContent = ""; + + for (let i = 0; i < executionArray.length; i++) { + + let record = executionArray[i]; + + fileContent = fileContent + separator + '[' + + record.begin + "," + + record.end + "," + + JSON.stringify(record.executionRecord) + "]"; + + if (separator === "") { separator = ","; } + + fileRecordCounter++; + + } + + fileContent = "[" + fileContent + "]"; + + let fileName = '' + market.assetA + '_' + market.assetB + '.json'; + + let filePathRoot = bot.devTeam + "/" + bot.codeName + "." + bot.version.major + "." + bot.version.minor + "/" + global.CLONE_EXECUTOR.codeName + "." + global.CLONE_EXECUTOR.version + "/" + global.EXCHANGE_NAME + "/" + bot.dataSetVersion; + let filePath = filePathRoot + "/Output/" + EXECUTION_FOLDER_NAME + "/" + "Multi-Period-Market" + "/" + outputPeriodLabel; + filePath += '/' + fileName + + fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); + + function onFileCreated(err) { + + try { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeExecutionFile -> onFileCreated -> Entering function."); } + if (LOG_FILE_CONTENT === true) { logger.write(MODULE_NAME, "[INFO] start -> writeExecutionFile -> onFileCreated -> fileContent = " + fileContent); } + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + + logger.write(MODULE_NAME, "[ERROR] start -> writeExecutionFile -> onFileCreated -> err = " + err.stack); + logger.write(MODULE_NAME, "[ERROR] start -> writeExecutionFile -> onFileCreated -> filePath = " + filePath); + logger.write(MODULE_NAME, "[ERROR] start -> writeExecutionFile -> onFileCreated -> market = " + market.assetA + "_" + market.assetB); + + callBackFunction(err); + return; + + } + + writeRecordsFile(); + + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] start -> writeExecutionFile -> onFileCreated -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] start -> writeExecutionFile -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + + function writeRecordsFile() { + + try { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeRecordsFile -> Entering function."); } + + let separator = ""; + let fileRecordCounter = 0; + + let fileContent = ""; + + for (let i = 0; i < recordsArray.length; i++) { + + let record = recordsArray[i]; + + fileContent = fileContent + separator + '[' + + record.begin + "," + + record.end + "," + + record.type + "," + + record.marketRate + "," + + record.amount + "," + + record.balanceA + "," + + record.balanceB + "," + + record.profit + "," + + record.lastTradeProfitLoss + "," + + record.stopLoss + "," + + record.roundtrips + "," + + record.hits + "," + + record.fails + "," + + record.hitRatio + "," + + record.ROI + "," + + record.periods + "," + + record.days + "," + + record.anualizedRateOfReturn + "," + + record.positionRate + "," + + record.lastTradeROI + "," + + record.strategy + "," + + record.strategyStageNumber + "," + + record.takeProfit + "," + + record.stopLossPhase + "," + + record.takeProfitPhase + "," + + JSON.stringify(record.executionRecord) + "," + + record.positionSize + "," + + record.initialBalanceA + "," + + record.minimumBalanceA + "," + + record.maximumBalanceA + "," + + record.initialBalanceB + "," + + record.minimumBalanceB + "," + + record.maximumBalanceB + "," + + record.baseAsset + "]"; + + if (separator === "") { separator = ","; } + + fileRecordCounter++; + + } + + fileContent = "[" + fileContent + "]"; + + let fileName = '' + market.assetA + '_' + market.assetB + '.json'; + + let filePathRoot = bot.devTeam + "/" + bot.codeName + "." + bot.version.major + "." + bot.version.minor + "/" + global.CLONE_EXECUTOR.codeName + "." + global.CLONE_EXECUTOR.version + "/" + global.EXCHANGE_NAME + "/" + bot.dataSetVersion; + let filePath = filePathRoot + "/Output/" + SIMULATED_RECORDS_FOLDER_NAME + "/" + "Multi-Period-Market" + "/" + outputPeriodLabel; + filePath += '/' + fileName + + fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); + + function onFileCreated(err) { + + try { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeRecordsFile -> onFileCreated -> Entering function."); } + if (LOG_FILE_CONTENT === true) { logger.write(MODULE_NAME, "[INFO] start -> writeRecordsFile -> onFileCreated -> fileContent = " + fileContent); } + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + + logger.write(MODULE_NAME, "[ERROR] start -> writeRecordsFile -> onFileCreated -> err = " + err.stack); + logger.write(MODULE_NAME, "[ERROR] start -> writeRecordsFile -> onFileCreated -> filePath = " + filePath); + logger.write(MODULE_NAME, "[ERROR] start -> writeRecordsFile -> onFileCreated -> market = " + market.assetA + "_" + market.assetB); + + callBackFunction(err); + return; + + } + + writeConditionsFile(); + + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] start -> writeRecordsFile -> onFileCreated -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] start -> writeRecordsFile -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + + function writeConditionsFile() { + + try { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeConditionsFile -> Entering function."); } + + let separator = ""; + let fileRecordCounter = 0; + + let fileContent = ""; + + for (let i = 0; i < conditionsArray.length; i++) { + + let record = conditionsArray[i]; + + let conditions = ""; + let conditionsSeparator = ""; + + for (let j = 0; j < record.length - 3; j++) { + conditions = conditions + conditionsSeparator + record[j]; + if (conditionsSeparator === "") { conditionsSeparator = ","; } + } + + conditions = conditions + conditionsSeparator + '[' + record[record.length - 3] + ']'; // The last item contains an Array of condition values. + conditions = conditions + conditionsSeparator + '[' + record[record.length - 2] + ']'; // The last item contains an Array of formulaErrors. + conditions = conditions + conditionsSeparator + '[' + record[record.length - 1] + ']'; // The last item contains an Array of formulaValues. + + fileContent = fileContent + separator + '[' + conditions + ']'; + + if (separator === "") { separator = ","; } + + fileRecordCounter++; + + } + + fileContent = "[" + fileContent + "]"; + fileContent = "[" + JSON.stringify(tradingSystem) + "," + JSON.stringify(lastObjectsArray) + "," + fileContent + "]"; + let fileName = '' + market.assetA + '_' + market.assetB + '.json'; + + let filePathRoot = bot.devTeam + "/" + bot.codeName + "." + bot.version.major + "." + bot.version.minor + "/" + global.CLONE_EXECUTOR.codeName + "." + global.CLONE_EXECUTOR.version + "/" + global.EXCHANGE_NAME + "/" + bot.dataSetVersion; + let filePath = filePathRoot + "/Output/" + CONDITIONS_FOLDER_NAME + "/" + "Multi-Period-Market" + "/" + outputPeriodLabel; + filePath += '/' + fileName + + fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); + + function onFileCreated(err) { + + try { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeConditionsFile -> onFileCreated -> Entering function."); } + if (LOG_FILE_CONTENT === true) { logger.write(MODULE_NAME, "[INFO] start -> writeConditionsFile -> onFileCreated -> fileContent = " + fileContent); } + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + + logger.write(MODULE_NAME, "[ERROR] start -> writeConditionsFile -> onFileCreated -> err = " + err.stack); + logger.write(MODULE_NAME, "[ERROR] start -> writeConditionsFile -> onFileCreated -> filePath = " + filePath); + logger.write(MODULE_NAME, "[ERROR] start -> writeConditionsFile -> onFileCreated -> market = " + market.assetA + "_" + market.assetB); + + callBackFunction(err); + return; + + } + + writeStrategiesFile(); + + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] start -> writeConditionsFile -> onFileCreated -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] start -> writeConditionsFile -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + + function writeStrategiesFile() { + + try { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeStrategiesFile -> Entering function."); } + + let separator = ""; + let fileRecordCounter = 0; + + let fileContent = ""; + + for (let i = 0; i < strategiesArray.length; i++) { + let record = strategiesArray[i]; + + fileContent = fileContent + separator + '[' + + record.begin + "," + + record.end + "," + + record.status + "," + + record.number + "," + + record.beginRate + "," + + record.endRate + "]"; + + if (separator === "") { separator = ","; } + + fileRecordCounter++; + + } + + fileContent = "[" + fileContent + "]"; + let fileName = '' + market.assetA + '_' + market.assetB + '.json'; + + let filePathRoot = bot.devTeam + "/" + bot.codeName + "." + bot.version.major + "." + bot.version.minor + "/" + global.CLONE_EXECUTOR.codeName + "." + global.CLONE_EXECUTOR.version + "/" + global.EXCHANGE_NAME + "/" + bot.dataSetVersion; + let filePath = filePathRoot + "/Output/" + STRATEGIES_FOLDER_NAME + "/" + "Multi-Period-Market" + "/" + outputPeriodLabel; + filePath += '/' + fileName + + fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); + + function onFileCreated(err) { + + try { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeStrategiesFile -> onFileCreated -> Entering function."); } + if (LOG_FILE_CONTENT === true) { logger.write(MODULE_NAME, "[INFO] start -> writeStrategiesFile -> onFileCreated -> fileContent = " + fileContent); } + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + + logger.write(MODULE_NAME, "[ERROR] start -> writeStrategiesFile -> onFileCreated -> err = " + err.stack); + logger.write(MODULE_NAME, "[ERROR] start -> writeStrategiesFile -> onFileCreated -> filePath = " + filePath); + logger.write(MODULE_NAME, "[ERROR] start -> writeStrategiesFile -> onFileCreated -> market = " + market.assetA + "_" + market.assetB); + + callBackFunction(err); + return; + + } + + writeTradesFile(); + + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] start -> writeStrategiesFile -> onFileCreated -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] start -> writeStrategiesFile -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + + function writeTradesFile() { + + try { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeTradesFile -> Entering function."); } + + let separator = ""; + let fileRecordCounter = 0; + + let fileContent = ""; + + for (let i = 0; i < tradesArray.length; i++) { + + let record = tradesArray[i]; + if (record.stopRate === undefined) { record.stopRate = 0 } + + fileContent = fileContent + separator + '[' + + record.begin + "," + + record.end + "," + + record.status + "," + + record.lastTradeROI + "," + + record.beginRate + "," + + record.endRate + "," + + record.exitType + "," + + record.stopRate + "]"; + + if (separator === "") { separator = ","; } + + fileRecordCounter++; + + } + + fileContent = "[" + fileContent + "]"; + let fileName = '' + market.assetA + '_' + market.assetB + '.json'; + + let filePathRoot = bot.devTeam + "/" + bot.codeName + "." + bot.version.major + "." + bot.version.minor + "/" + global.CLONE_EXECUTOR.codeName + "." + global.CLONE_EXECUTOR.version + "/" + global.EXCHANGE_NAME + "/" + bot.dataSetVersion; + let filePath = filePathRoot + "/Output/" + TRADES_FOLDER_NAME + "/" + "Multi-Period-Market" + "/" + outputPeriodLabel; + filePath += '/' + fileName + + fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); + + function onFileCreated(err) { + + try { + + if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> writeTradesFile -> onFileCreated -> Entering function."); } + if (LOG_FILE_CONTENT === true) { logger.write(MODULE_NAME, "[INFO] start -> writeTradesFile -> onFileCreated -> fileContent = " + fileContent); } + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + + logger.write(MODULE_NAME, "[ERROR] start -> writeTradesFile -> onFileCreated -> err = " + err.stack); + logger.write(MODULE_NAME, "[ERROR] start -> writeTradesFile -> onFileCreated -> filePath = " + filePath); + logger.write(MODULE_NAME, "[ERROR] start -> writeTradesFile -> onFileCreated -> market = " + market.assetA + "_" + market.assetB); + + callBackFunction(err); + return; + + } + + callBackFunction(global.DEFAULT_OK_RESPONSE); + + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] start -> writeTradesFile -> onFileCreated -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] start -> writeTradesFile -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } + + } + catch (err) { + logger.write(MODULE_NAME, "[ERROR] start -> err = " + err.stack); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } + } +}; diff --git a/src/storage/templates/Simulator/this.bot.config.json b/src/storage/templates/Simulator/this.bot.config.json new file mode 100644 index 000000000..15b52e5e1 --- /dev/null +++ b/src/storage/templates/Simulator/this.bot.config.json @@ -0,0 +1,387 @@ +{ + "displayName": "Jason", + "codeName": "AAJason", + "type": "Indicator", + "version": { + "major": 1, + "minor": 0, + "patch": 0 + }, + "devTeam": "AAMasters", + "profilePicture": "Jason.png", + "dataSetVersion": "dataSet.V1", + "processes": [ + { + "name": "Multi-Period-Market", + "description": "Produces a single file for each time period covering all the market.", + "normalWaitTime": 60000, + "retryWaitTime": 10000, + "sleepWaitTime": 3600000, + "comaWaitTime": 86400000, + "framework": { + "name": "Multi-Period-Market", + "startDate": { + "fixedDate": "2018-07-01" + }, + "endDate": { + } + }, + "statusDependencies": [ + { + "devTeam": "AAMasters", + "bot": "AAJason", + "botVersion": { + "major": 1, + "minor": 0 + }, + "process": "Multi-Period-Market", + "dataSetVersion": "dataSet.V1" + } + ], + "dataDependencies": [ + { + "devTeam": "AAVikings", + "bot": "AAGauss", + "botVersion": { + "major": 1, + "minor": 0 + }, + "product": "LRC-Points", + "dataSetVersion": "dataSet.V1", + "dataSet": "Multi-Period-Market" + }, + { + "devTeam": "AAMasters", + "bot": "AAChris", + "botVersion": { + "major": 1, + "minor": 0 + }, + "product": "Percentage-Bandwidth", + "dataSetVersion": "dataSet.V1", + "dataSet": "Multi-Period-Market" + }, + { + "devTeam": "AAMasters", + "bot": "AAChris", + "botVersion": { + "major": 1, + "minor": 0 + }, + "product": "Bollinger-Bands", + "dataSetVersion": "dataSet.V1", + "dataSet": "Multi-Period-Market" + }, + { + "devTeam": "AAMasters", + "bot": "AAPaula", + "botVersion": { + "major": 1, + "minor": 0 + }, + "product": "Bollinger-Standard-Channels", + "dataSetVersion": "dataSet.V1", + "dataSet": "Multi-Period-Market" + }, + { + "devTeam": "AAMasters", + "bot": "AAPaula", + "botVersion": { + "major": 1, + "minor": 0 + }, + "product": "Bollinger-Standard-Sub-Channels", + "dataSetVersion": "dataSet.V1", + "dataSet": "Multi-Period-Market" + }, + { + "devTeam": "AAMasters", + "bot": "AAOlivia", + "botVersion": { + "major": 1, + "minor": 0 + }, + "product": "Candles", + "dataSetVersion": "dataSet.V1", + "dataSet": "Multi-Period-Market" + } + ] + }, + { + "name": "Multi-Period-Daily", + "description": "Produces a Daily File at each time period.", + "normalWaitTime": 60000, + "retryWaitTime": 10000, + "sleepWaitTime": 3600000, + "comaWaitTime": 86400000, + "framework": { + "name": "Multi-Period-Daily", + "validPeriods": [ "15-min", "10-min", "05-min"], + "startDate": { + "fixedDate": "2018-07-01" + }, + "endDate": { + "takeItFromStatusDependency": 1 + } + }, + "statusDependencies": [ + { + "devTeam": "AAMasters", + "bot": "AACharly", + "botVersion": { + "major": 1, + "minor": 0 + }, + "process": "Historic-Trades", + "dataSetVersion": "dataSet.V1" + }, + { + "devTeam": "AAMasters", + "bot": "AAOlivia", + "botVersion": { + "major": 1, + "minor": 0 + }, + "process": "Multi-Period-Daily", + "dataSetVersion": "dataSet.V1" + }, + { + "devTeam": "AAMasters", + "bot": "AAJason", + "botVersion": { + "major": 1, + "minor": 0 + }, + "process": "Multi-Period-Daily", + "dataSetVersion": "dataSet.V1" + } + ], + "dataDependencies": [ + { + "devTeam": "AAVikings", + "bot": "AAGauss", + "botVersion": { + "major": 1, + "minor": 0 + }, + "product": "LRC-Points", + "dataSetVersion": "dataSet.V1", + "dataSet": "Multi-Period-Daily" + }, + { + "devTeam": "AAMasters", + "bot": "AAChris", + "botVersion": { + "major": 1, + "minor": 0 + }, + "product": "Percentage-Bandwidth", + "dataSetVersion": "dataSet.V1", + "dataSet": "Multi-Period-Daily" + }, + { + "devTeam": "AAMasters", + "bot": "AAChris", + "botVersion": { + "major": 1, + "minor": 0 + }, + "product": "Bollinger-Bands", + "dataSetVersion": "dataSet.V1", + "dataSet": "Multi-Period-Daily" + }, + { + "devTeam": "AAMasters", + "bot": "AAPaula", + "botVersion": { + "major": 1, + "minor": 0 + }, + "product": "Bollinger-Standard-Channels", + "dataSetVersion": "dataSet.V1", + "dataSet": "Multi-Period-Daily" + }, + { + "devTeam": "AAMasters", + "bot": "AAPaula", + "botVersion": { + "major": 1, + "minor": 0 + }, + "product": "Bollinger-Standard-Sub-Channels", + "dataSetVersion": "dataSet.V1", + "dataSet": "Multi-Period-Daily" + }, + { + "devTeam": "AAMasters", + "bot": "AAOlivia", + "botVersion": { + "major": 1, + "minor": 0 + }, + "product": "Candles", + "dataSetVersion": "dataSet.V1", + "dataSet": "Multi-Period-Daily" + } + ] + } + ], + "products": [ + { + "codeName": "Trading-Simulation", + "displayName": "Trading Simulation", + "description": "Trading Simulation", + "storageAccount": "aajason", + "dataSets": [ + { + "codeName": "Multi-Period-Market", + "type": "Market Files", + "validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs" ], + "filePath": "AAMasters/AAJason.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Trading-Simulation/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json" + }, + { + "codeName": "Multi-Period-Daily", + "type": "Daily Files", + "validPeriods": [ "15-min", "10-min", "05-min" ], + "filePath": "AAMasters/AAJason.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Trading-Simulation/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "dataRange": { + "filePath": "AAMasters/AAJason.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Trading-Simulation/Multi-Period-Daily", + "fileName": "Data.Range.@AssetA_@AssetB.json" + } + } + ], + "exchangeList": [ + { + "name": "Poloniex" + }, + { + "name": "Coss" + } + ], + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersTradingSimulation", + "moduleName": "TradingSimulation" + } + }, + { + "codeName": "Simulation-Conditions", + "displayName": "Simulation Conditions", + "description": "Simulation Conditions", + "storageAccount": "aajason", + "dataSets": [ + { + "codeName": "Multi-Period-Market", + "type": "Market Files", + "validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs" ], + "filePath": "AAMasters/AAJason.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Simulation-Conditions/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json" + }, + { + "codeName": "Multi-Period-Daily", + "type": "Daily Files", + "validPeriods": [ "15-min", "10-min", "05-min" ], + "filePath": "AAMasters/AAJason.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Simulation-Conditions/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "dataRange": { + "filePath": "AAMasters/AAJason.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Simulation-Conditions/Multi-Period-Daily", + "fileName": "Data.Range.@AssetA_@AssetB.json" + } + } + ], + "exchangeList": [ + { + "name": "Poloniex" + }, + { + "name": "Coss" + } + ], + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersTradingSimulation", + "moduleName": "Conditions" + } + }, + { + "codeName": "Simulation-Strategies", + "displayName": "Simulation Strategies", + "description": "Simulation Strategies", + "storageAccount": "aajason", + "dataSets": [ + { + "codeName": "Multi-Period-Market", + "type": "Market Files", + "validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs" ], + "filePath": "AAMasters/AAJason.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Simulation-Strategies/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json" + }, + { + "codeName": "Multi-Period-Daily", + "type": "Daily Files", + "validPeriods": [ "15-min", "10-min", "05-min" ], + "filePath": "AAMasters/AAJason.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Simulation-Strategies/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "dataRange": { + "filePath": "AAMasters/AAJason.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Simulation-Strategies/Multi-Period-Daily", + "fileName": "Data.Range.@AssetA_@AssetB.json" + } + } + ], + "exchangeList": [ + { + "name": "Poloniex" + }, + { + "name": "Coss" + } + ], + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersTradingSimulation", + "moduleName": "Strategies" + } + }, + { + "codeName": "Simulation-Trades", + "displayName": "Simulation Trades", + "description": "Simulation Trades", + "storageAccount": "aajason", + "dataSets": [ + { + "codeName": "Multi-Period-Market", + "type": "Market Files", + "validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs" ], + "filePath": "AAMasters/AAJason.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Simulation-Trades/Multi-Period-Market/@Period", + "fileName": "@AssetA_@AssetB.json" + }, + { + "codeName": "Multi-Period-Daily", + "type": "Daily Files", + "validPeriods": [ "15-min", "10-min", "05-min" ], + "filePath": "AAMasters/AAJason.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Simulation-Trades/Multi-Period-Daily/@Period/@Year/@Month/@Day", + "fileName": "@AssetA_@AssetB.json", + "dataRange": { + "filePath": "AAMasters/AAJason.1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Simulation-Trades/Multi-Period-Daily", + "fileName": "Data.Range.@AssetA_@AssetB.json" + } + } + ], + "exchangeList": [ + { + "name": "Poloniex" + }, + { + "name": "Coss" + } + ], + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersTradingSimulation", + "moduleName": "Trades" + } + } + ] +} diff --git a/src/storage/templates/TradingBot/User.Bot.js b/src/storage/templates/TradingBot/User.Bot.js new file mode 100644 index 000000000..ac5a643ea --- /dev/null +++ b/src/storage/templates/TradingBot/User.Bot.js @@ -0,0 +1,915 @@ +exports.newUserBot = function newUserBot(bot, logger) { + + // Variable used for logs, which will be passed to the logger instance + const MODULE_NAME = 'User Bot' + const LOG_INFO = true + let assistant, fileStorage + let autopilotControl = false + + const orderMessage = require("@superalgos/mqservice/orderMessage/orderMessage") + + const { + MESSAGE_ENTITY, MESSAGE_TYPE, ORDER_CREATOR, ORDER_TYPE, ORDER_OWNER, + ORDER_DIRECTION, ORDER_STATUS, ORDER_EXIT_OUTCOME, ORDER_MARGIN_ENABLED, + getMessage, createMessageFromObject + } = orderMessage.newOrderMessage() + + const axios = require('axios') + const util = require('util') + + /* + This objects returns two public functions that will be used to integrate with the platform. + */ + return { + initialize: initialize, + start: start, + setAutopilot: setAutopilot, + executorLogic: executorLogic + } + + function initialize(pAssistant, pGenes, callBackFunction) { + try { + logInfo('initialize -> Entering function.') + + // Integration with platform logger, when running on cloud + logger.fileName = MODULE_NAME + assistant = pAssistant + + if (bot.timePeriodFileStorage === undefined) { + throw new Error("Execution Parameter Time Period not defined.") + } + + if (bot.dataSet === undefined) { + throw new Error("Execution Parameter Data Set not defined.") + } + + let key = bot.devTeam + '-simulator-' + bot.codeName + '-Trading-Execution-' + bot.dataSet + '-dataSet.V1' + fileStorage = assistant.dataDependencies.dataSets.get(key) + + if (fileStorage !== undefined) { + callBackFunction(global.DEFAULT_OK_RESPONSE) + } else { + logError('initialize -> Failed to initialize storage. Key not found:' + key) + callBackFunction(global.DEFAULT_FAIL_RESPONSE) + } + } catch (error) { + logError('initialize -> onDone -> err = ' + error.message) + callBackFunction(global.DEFAULT_FAIL_RESPONSE) + } + } + + function logInfo(message) { + if (LOG_INFO === true) { logger.write(MODULE_NAME, '[INFO] ' + message) } + } + + function logWarn(message) { + if (LOG_INFO === true) { logger.write(MODULE_NAME, '[WARN] ' + message) } + } + + function logError(message) { + logger.write(MODULE_NAME, '[ERROR] ' + message) + } + + function setAutopilot(autopilot) { + autopilotControl = autopilot + } + + /* + The start function is called by the platform for executing the bot every 1 minute + */ + function start(callBackFunction) { + logInfo('start -> Entering function.') + + const callback = util.callbackify(executorLogic) + + callback((err, ret) => { + if (err) { + callBackFunction(err) + } else { + callBackFunction(global.DEFAULT_OK_RESPONSE) + } + }) + } + + function getValueFromPreviousExecution(key) { + let value = assistant.remindMeOf(key) + if (value === undefined) + value = 0 + return value + } + + async function executorLogic() { + try { + let indicatorFileContent = await getIndicatorFile() + let simulatorEngineMessage = getSimulatorEngineMessageFromFile(indicatorFileContent) + + let stopLoss = getValueFromPreviousExecution('lastStopLoss') + let takeProfit = getValueFromPreviousExecution('lastTakeProfit') + let openTradeSimulatorMessageId = getValueFromPreviousExecution('openTradeSimulatorMessageId') + + if (simulatorEngineMessage === undefined) { + if (openTradeSimulatorMessageId > 0) { + logWarn('executorLogic -> Simulator message not available. Will proceed to check if the trade needs to be closed.') + let simulatorMessajeNotFound = -1 + await closeTrade(stopLoss, takeProfit, simulatorMessajeNotFound) + } + } else { + logInfo('executorLogic -> Processing simulator record: ' + JSON.stringify(simulatorEngineMessage)) + + // Verify if there is an inconsistent state between the simulator and executor + let isMessageAnOrder = (simulatorEngineMessage.messageType === MESSAGE_TYPE.Order) + let isMessageAnOrderUpdate = (simulatorEngineMessage.messageType === MESSAGE_TYPE.OrderUpdate) + let isMessageAnOrderClose = (simulatorEngineMessage.messageType === MESSAGE_TYPE.OrderClose) + let isMessageAHeartBeat = (simulatorEngineMessage.messageType === MESSAGE_TYPE.HeartBeat) + + let existsAnOpenTrade = (openTradeSimulatorMessageId > 0) + if (existsAnOpenTrade) { + let isOrderMessage = isMessageAnOrder && simulatorEngineMessage.id === openTradeSimulatorMessageId + if (isOrderMessage || isMessageAnOrderUpdate) { + logInfo('Moving the position because it is the same message that caused the open trade or because it is an update.') + await openOrMoveTrade(simulatorEngineMessage) + } else if (isMessageAnOrderClose) { + assistant.rememberThis('closeTradeSimulatorMessageId', simulatorEngineMessage.id) + let isStopLoss = (simulatorEngineMessage.order.exitOutcome === ORDER_EXIT_OUTCOME.StopLoss) + let isTakeProfit = (simulatorEngineMessage.order.exitOutcome === ORDER_EXIT_OUTCOME.StopLoss) + if (isStopLoss) { + stopLoss = assistant.getMarketRate() + takeProfit = 0 + } else if (isTakeProfit) { + stopLoss = 0 + takeProfit = assistant.getMarketRate() + } + } else if (isMessageAHeartBeat) { + logWarn('An inconsisten state was detected: there is an open trade and a close trade was expected.') + let skippedSimulatorEngineMessage = getSkippedMessageOrderClose(indicatorFileContent) + if (skippedSimulatorEngineMessage === undefined) { + logWarn('There was not a Skipped Message Order Close. Closing the position the best possible.') + stopLoss = assistant.getMarketRate() + takeProfit = 0 + } else { + if (skippedSimulatorEngineMessage.id > openTradeSimulatorMessageId) { + logWarn('The Skipped Message Order Close was found and using it to set the SL and TP.') + stopLoss = skippedSimulatorEngineMessage.order.stop + takeProfit = skippedSimulatorEngineMessage.order.takeProfit + } else { + logWarn('One Message Order Close was found but is older than the Open Order. Closing the position the best possible.') + stopLoss = assistant.getMarketRate() + takeProfit = 0 + } + } + } else { + logError('Not managed condition.') + } + assistant.rememberThis('lastStopLoss', stopLoss) + assistant.rememberThis('lastTakeProfit', takeProfit) + await closeTrade(stopLoss, takeProfit, openTradeSimulatorMessageId) + } else { + if (isMessageAnOrder) { + await openOrMoveTrade(simulatorEngineMessage) + } else { + logInfo('Nothing to do, there is not an open order.') + } + } + assistant.addExtraData(simulatorEngineMessage) // Adding the record used for the execution + } + } catch (error) { + logError('Error on executorLogic: ' + JSON.stringify(error)) + throw error + } + } + + async function closeTrade(stopLoss, takeProfit, openTradeSimulatorMessageId) { + let currentRate = assistant.getMarketRate() + let wasExecuted = false + let tradeSize = assistant.getAvailableBalance().assetA + let tradeDirection = ORDER_DIRECTION.Buy + let closeTradeSimulatorMessageId = getValueFromPreviousExecution('closeTradeSimulatorMessageId') + + if (process.env.BASE_ASSET === 'assetA') { + wasExecuted = closeTradeSimulatorMessageId > 0 && assistant.getAvailableBalance().assetB === 0 && assistant.getAvailableBalance().assetA > 0 + tradeSize = assistant.getAvailableBalance().assetB + tradeDirection = ORDER_DIRECTION.Sell + } else { + wasExecuted = closeTradeSimulatorMessageId > 0 && assistant.getAvailableBalance().assetA === 0 && assistant.getAvailableBalance().assetB > 0 + } + + // Check completion of current positions at the exchange + let positions = assistant.getPositions() + let isPositionExecuted = false + for (let i = 0; i < positions.length; i++) { + const position = positions[i]; + if (position.id === closeTradeSimulatorMessageId && position.status === 'executed') { + isPositionExecuted = true + break + } + } + + if (isPositionExecuted || wasExecuted) { + assistant.rememberThis('openTradeSimulatorMessageId', 0) + assistant.rememberThis('closeTradeSimulatorMessageId', 0) + assistant.rememberThis('openTradePositionId', 0) + assistant.rememberThis('lastStopLoss', 0) + assistant.rememberThis('lastTakeProfit', 0) + + let simulatorExecutorMessage = buildBasicSimulatorExecutorMessage() + simulatorExecutorMessage.id = openTradeSimulatorMessageId + simulatorExecutorMessage.order.id = positions.length > 0 ? positions[0].id : 0 + simulatorExecutorMessage.order.rate = currentRate + simulatorExecutorMessage.order.stop = stopLoss + simulatorExecutorMessage.order.takeProfit = takeProfit + simulatorExecutorMessage.order.direction = tradeDirection + simulatorExecutorMessage.order.size = tradeSize + simulatorExecutorMessage.order.status = ORDER_STATUS.Placed + simulatorExecutorMessage.order.exitOutcome = ORDER_EXIT_OUTCOME.StopLoss + + let message = createMessageFromObject(simulatorExecutorMessage) + assistant.addExtraData(message) + } + + // Checking Stop Loss & Take Profit + if ((takeProfit > 0 || stopLoss > 0) && closeTradeSimulatorMessageId > 0) { + let exitOutcome + if (takeProfit > 0) { + logInfo('Closing trade with Take Profit.') + exitOutcome = ORDER_EXIT_OUTCOME.TakeProfit + } else { + logInfo('Closing trade with Stop Loss.') + exitOutcome = ORDER_EXIT_OUTCOME.StopLoss + } + + try { + let position + if (process.env.BASE_ASSET === 'assetA') { + position = await createSellPosition(currentRate) + } else { + position = await createBuyPosition(currentRate) + } + assistant.rememberThis('closeTradePositionId', position.id) + + let simulatorExecutorMessage = buildBasicSimulatorExecutorMessage() + simulatorExecutorMessage.id = openTradeSimulatorMessageId + simulatorExecutorMessage.order.id = position.id + simulatorExecutorMessage.order.rate = currentRate + simulatorExecutorMessage.order.stop = stopLoss + simulatorExecutorMessage.order.takeProfit = takeProfit + simulatorExecutorMessage.order.direction = tradeDirection + simulatorExecutorMessage.order.size = tradeSize + simulatorExecutorMessage.order.status = ORDER_STATUS.Placed + simulatorExecutorMessage.order.exitOutcome = exitOutcome + + let message = createMessageFromObject(simulatorExecutorMessage) + assistant.addExtraData(message) + + } catch (error) { + let simulatorExecutorMessage = buildBasicSimulatorExecutorMessage() + simulatorExecutorMessage.id = openTradeSimulatorMessageId + simulatorExecutorMessage.from = MESSAGE_ENTITY.TradingAssistant + simulatorExecutorMessage.to = MESSAGE_ENTITY.SimulationExecutor + simulatorExecutorMessage.order.rate = currentRate + simulatorExecutorMessage.order.stop = stopLoss + simulatorExecutorMessage.order.takeProfit = takeProfit + simulatorExecutorMessage.order.direction = tradeDirection + simulatorExecutorMessage.order.size = tradeSize + simulatorExecutorMessage.order.status = ORDER_STATUS.Rejected + simulatorExecutorMessage.order.exitOutcome = exitOutcome + simulatorExecutorMessage.order.statusDetails = error.message + + let message = createMessageFromObject(simulatorExecutorMessage) + assistant.addExtraData(message) + } finally { + return + } + } + } + + async function openOrMoveTrade(simulatorEngineMessage) { + autopilotControl = true // Force autopilot on for now + if (!autopilotControl) { + autopilotControl = await getAutopilot() + } + if (autopilotControl.autopilot || autopilotControl) { + await openTradeAutopilotOn(simulatorEngineMessage) + } else { + await openTradeAutopilotOff(simulatorEngineMessage) + } + } + + async function openTradeAutopilotOn(simulatorEngineMessage) { + let currentRate = assistant.getMarketRate() + let tradeSize = assistant.getAvailableBalance().assetB + let tradeDirection = ORDER_DIRECTION.Sell + + if (process.env.BASE_ASSET === 'assetA') { + tradeSize = assistant.getAvailableBalance().assetA + tradeDirection = ORDER_DIRECTION.Buy + } + + try { + // Create a new position or move existing position to complete the order execution + let position + if (process.env.BASE_ASSET === 'assetA') { + position = await createBuyPosition(currentRate) + } else { + position = await createSellPosition(currentRate) + } + + assistant.rememberThis('openTradePositionId', position.id) + assistant.rememberThis('openTradeSimulatorMessageId', simulatorEngineMessage.id) + assistant.rememberThis('lastStopLoss', simulatorEngineMessage.order.stop) + assistant.rememberThis('lastTakeProfit', simulatorEngineMessage.order.takeProfit) + + let simulatorExecutorMessage = buildBasicSimulatorExecutorMessage() + simulatorExecutorMessage.id = simulatorEngineMessage.id + simulatorExecutorMessage.order.id = position.id + simulatorExecutorMessage.order.rate = currentRate + simulatorExecutorMessage.order.stop = simulatorEngineMessage.order.stop + simulatorExecutorMessage.order.takeProfit = simulatorEngineMessage.order.takeProfit + simulatorExecutorMessage.order.direction = tradeDirection + simulatorExecutorMessage.order.size = tradeSize + + let message = createMessageFromObject(simulatorExecutorMessage) + assistant.addExtraData(message) + } catch (error) { + let simulatorExecutorMessage = buildBasicSimulatorExecutorMessage() + simulatorExecutorMessage.id = simulatorEngineMessage.id + simulatorExecutorMessage.from = MESSAGE_ENTITY.TradingAssistant + simulatorExecutorMessage.to = MESSAGE_ENTITY.SimulationExecutor + simulatorExecutorMessage.messageType = MESSAGE_TYPE.Order + simulatorExecutorMessage.order.rate = currentRate + simulatorExecutorMessage.order.stop = simulatorEngineMessage.order.stop + simulatorExecutorMessage.order.takeProfit = simulatorEngineMessage.order.takeProfit + simulatorExecutorMessage.order.direction = tradeDirection + simulatorExecutorMessage.order.size = tradeSize + simulatorExecutorMessage.order.status = ORDER_STATUS.Rejected + simulatorExecutorMessage.order.statusDetails = error.message + + let message = createMessageFromObject(simulatorExecutorMessage) + assistant.addExtraData(message) + } + } + + async function openTradeAutopilotOff(simulatorEngineMessage) { + /** + * If there is a ManualAuthorized order on the cockpit we will proceed to: + * 1) Save an audit containing what we received from the cockpit + * 2) Execute the order in the market as received + * 3) Save the audit of the order placed + * 4) Update the cockpit with the result + */ + let acceptedSignals = await getSignalsByCloneId(ORDER_STATUS.ManualAuthorized) + if (acceptedSignals !== undefined && acceptedSignals.length > 0) { + for (let acceptedSignal of acceptedSignals) { + try { + logInfo('openTradeAutopilotOff -> Executing manual authorized signal.') + + // 1) Save audit containing what we received from the cockpit + let simulatorExecutorMessage = buildBasicSimulatorExecutorMessage() + simulatorExecutorMessage.id = simulatorEngineMessage.id + simulatorExecutorMessage.from = MESSAGE_ENTITY.TradingCokpit + simulatorExecutorMessage.to = MESSAGE_ENTITY.SimulationExecutor + simulatorExecutorMessage.order = acceptedSignal.orderData // we save the order as received + simulatorExecutorMessage.order.status = ORDER_STATUS.ManualAuthorized + let message = createMessageFromObject(simulatorExecutorMessage) + assistant.addExtraData(message) + + // 2) Execute the order in the market as received + let position = await createSellPosition(acceptedSignal.orderData.rate, acceptedSignal.orderData.size) + assistant.rememberThis('openTradePositionId', position.id) + assistant.rememberThis('openTradeSimulatorMessageId', simulatorEngineMessage.id) + assistant.rememberThis('lastStopLoss', simulatorEngineMessage.order.stop) + assistant.rememberThis('lastTakeProfit', simulatorEngineMessage.order.takeProfit) + + // 3) Save the audit of the order placed + simulatorExecutorMessage = buildBasicSimulatorExecutorMessage() + simulatorExecutorMessage.id = simulatorEngineMessage.id + simulatorExecutorMessage.from = MESSAGE_ENTITY.SimulationExecutor + simulatorExecutorMessage.to = MESSAGE_ENTITY.TradingAssistant + simulatorExecutorMessage.dateTime = position.date + + simulatorExecutorMessage.order = acceptedSignal.orderData + simulatorExecutorMessage.order.id = position.id + simulatorExecutorMessage.order.dateTime = position.date + simulatorExecutorMessage.order.rate = position.rate + simulatorExecutorMessage.order.size = position.amountB + simulatorExecutorMessage.order.status = ORDER_STATUS.Placed + simulatorExecutorMessage.order.sizeFilled = 0 + + // 4) Update the cockpit with the result + await updateSignal(acceptedSignal.id, simulatorExecutorMessage) + + message = createMessageFromObject(simulatorExecutorMessage) + assistant.addExtraData(message) + return + } catch (error) { + // Update the cockpit with the error + let simulatorExecutorMessage = buildBasicSimulatorExecutorMessage() + simulatorExecutorMessage.id = simulatorEngineMessage.id + simulatorExecutorMessage.from = MESSAGE_ENTITY.SimulationExecutor + simulatorExecutorMessage.to = MESSAGE_ENTITY.TradingCokpit + simulatorExecutorMessage.messageType = MESSAGE_TYPE.Order + simulatorExecutorMessage.dateTime = bot.processDatetime.valueOf() + simulatorExecutorMessage.order.status = ORDER_STATUS.Rejected + simulatorExecutorMessage.order.statusDetails = error.message + + simulatorExecutorMessage.order = acceptedSignal.order + + await updateSignal(acceptedSignal.id, simulatorExecutorMessage) + + // Update the audit with the error + let message = createMessageFromObject(simulatorExecutorMessage) + assistant.addExtraData(message) + return + } + } + } + + /** + * If there is a Placed order on the cockpit we will proceed to: + * 1) Check order status on the market + * 2) Save the audit of the status + * 3) Update the cockpit with the results + */ + let inProcessSignals = await getSignalsByCloneId(ORDER_STATUS.Placed) + if (inProcessSignals !== undefined && inProcessSignals.length > 0) { + for (let inProcessSignal of inProcessSignals) { + logInfo('openTradeAutopilotOff -> Checking in process signal.') + // 1) Check order status on the market + let position = checkSignalCompletion() + if (position || position === undefined) { + // 2) Save the audit of the status + let simulatorExecutorMessage = buildBasicSimulatorExecutorMessage() + simulatorExecutorMessage.id = inProcessSignal.orderData.id + simulatorExecutorMessage.from = MESSAGE_ENTITY.SimulationExecutor + simulatorExecutorMessage.to = MESSAGE_ENTITY.TradingCokpit + simulatorExecutorMessage.messageType = MESSAGE_TYPE.OrderUpdate + + simulatorExecutorMessage.order = inProcessSignal.orderData + simulatorExecutorMessage.order.status = ORDER_STATUS.Filled + simulatorExecutorMessage.order.sizeFilled = -1 + + // 3) Update the cockpit with the results + await updateSignal(inProcessSignal.id, simulatorExecutorMessage) + + let message = createMessageFromObject(simulatorExecutorMessage) + assistant.addExtraData(message) + } else { + // Otherwise: Save the audit of the order status, wichs is currently saved by the trading process + } + return + } + } + + /** + * If there is any signal not yet authorized: + * 1) Update the signal with the new indicator value on the cockpit + * 3) Save the audit of the message sent + */ + let assetBBalance = assistant.getAvailableBalance().assetB + let currentRate = assistant.getMarketRate() + let signals = await getSignalsByCloneId(ORDER_STATUS.Signaled) + if (signals !== undefined && signals.length > 0) { + for (let inProcessSignal of signals) { + logInfo('openTradeAutopilotOff -> Signal waiting for approval found, updating it with latest market data.') + + let simulatorExecutorMessage = buildBasicSimulatorExecutorMessage() + simulatorExecutorMessage.to = MESSAGE_ENTITY.TradingCokpit + simulatorExecutorMessage.messageType = MESSAGE_TYPE.OrderUpdate + simulatorExecutorMessage.order.id = 0 + simulatorExecutorMessage.order.rate = currentRate + simulatorExecutorMessage.order.stop = simulatorEngineMessage.order.stop + simulatorExecutorMessage.order.takeProfit = simulatorEngineMessage.order.takeProfit + simulatorExecutorMessage.order.direction = simulatorEngineMessage.order.direction + simulatorExecutorMessage.order.size = assetBBalance + simulatorExecutorMessage.order.status = ORDER_STATUS.Signaled + + await updateSignal(inProcessSignal.id, simulatorExecutorMessage) + + let message = createMessageFromObject(simulatorExecutorMessage) + assistant.addExtraData(message) + return + } + } + + /** + * Finally: + * 1) Check if it's needed to create a new signal based on the indicator + * 2) Save the audit message for the received info from Trading Simulator + * 3) Create the signal on the cockpit + */ + if (simulatorEngineMessage !== undefined && simulatorEngineMessage.messageType === MESSAGE_TYPE.Order + && simulatorEngineMessage.order.direction === ORDER_DIRECTION.Sell) { + logInfo('Creating new signal.') + + // 2) Save the audit message for the received info from Trading Simulator + let simulatorExecutorMessage = buildBasicSimulatorExecutorMessage() + simulatorExecutorMessage.id = simulatorEngineMessage.id + simulatorExecutorMessage.to = MESSAGE_ENTITY.TradingCokpit + simulatorExecutorMessage.messageType = MESSAGE_TYPE.Order + simulatorExecutorMessage.order.id = 0 + simulatorExecutorMessage.order.status = ORDER_STATUS.Signaled + simulatorExecutorMessage.order.rate = currentRate + simulatorExecutorMessage.order.direction = ORDER_DIRECTION.Sell + simulatorExecutorMessage.order.takeProfit = simulatorEngineMessage.order.takeProfit + simulatorExecutorMessage.order.stop = simulatorEngineMessage.order.stop + simulatorExecutorMessage.order.size = assetBBalance + + let message = createMessageFromObject(simulatorExecutorMessage) + assistant.addExtraData(message) + + // 3) Create the signal on the cockpit + await createSignal(simulatorExecutorMessage) + } else { + logWarn("openTradeAutopilotOff -> Nothing to do, there isn't a buy or sell opportunity.") + } + } + + async function createBuyPosition(currentRate, amountToBuy) { + if (!amountToBuy) amountToBuy = assistant.getAvailableBalance().assetA + let amountB = Number((amountToBuy / currentRate).toFixed(8)) + let positions = assistant.getPositions() + let assetABalance = assistant.getAvailableBalance().assetA + + if (positions.length > 0 && positions[0].type === 'buy' && positions[0].status !== 'executed') { + logInfo('createBuyPosition -> Moving an existing BUY position to a new price: $' + Number(currentRate).toLocaleString()) + + assistant.movePosition[util.promisify.custom] = n => new Promise((resolve, reject) => { + assistant.movePosition(positions[0], currentRate, (result, position) => { + if (result !== global.DEFAULT_OK_RESPONSE) { + reject(result) + } else { + resolve(position) + } + }) + }) + + let movePosition = util.promisify(assistant.movePosition) + await movePosition(positions[0], currentRate) + return positions[0] + } else if (assetABalance > 0) { + logInfo('createBuyPosition -> Put a new BUY position at price: $' + Number(currentRate).toLocaleString()) + + assistant.putPosition[util.promisify.custom] = n => new Promise((resolve, reject) => { + assistant.putPosition('buy', currentRate, amountToBuy, amountB, (result, position) => { + if (result !== global.DEFAULT_OK_RESPONSE) { + reject(result) + } else { + resolve(position) + } + }) + }) + + let putPosition = util.promisify(assistant.putPosition) + let position = await putPosition('buy', currentRate, amountToBuy, amountB) + return position + } else { + logInfo('createBuyPosition -> Not enough available balance to buy.') + throw new Error('There is not enough available balance to buy.') + } + } + + async function createSellPosition(currentRate, amountToSell) { + if (!amountToSell) amountToSell = assistant.getAvailableBalance().assetB + let amountA = amountToSell * currentRate + let positions = assistant.getPositions() + + if (positions.length > 0 && positions[0].type === 'sell' && positions[0].status !== 'executed') { + logInfo('createSellPosition -> Moving an existing SELL position to a new price: $' + Number(currentRate).toLocaleString()) + + assistant.movePosition[util.promisify.custom] = n => new Promise((resolve, reject) => { + assistant.movePosition(positions[0], currentRate, (result, position) => { + if (result !== global.DEFAULT_OK_RESPONSE) { + reject(result) + } else { + resolve(position) + } + }) + }) + + let movePosition = util.promisify(assistant.movePosition) + await movePosition(positions[0], currentRate) + return positions[0] + } else if (assistant.getAvailableBalance().assetB > 0) { + logInfo('createSellPosition -> Put a new SELL position at price: $' + Number(currentRate).toLocaleString()) + assistant.putPosition[util.promisify.custom] = n => new Promise((resolve, reject) => { + assistant.putPosition('sell', currentRate, amountA, amountToSell, (result, position) => { + if (result !== global.DEFAULT_OK_RESPONSE) { + reject(result) + } else { + resolve(position) + } + }) + }) + + let putPosition = util.promisify(assistant.putPosition) + let position = await putPosition('sell', currentRate, amountA, amountToSell) + return position + } else { + logInfo('createSellPosition -> There is not enough available balance to sell.') + throw new Error('There is not enough available balance to sell.') + } + } + + function checkSignalCompletion() { + let positions = assistant.getPositions() + if ((positions.length === 0) || (positions.length > 0 && positions[0].status === 'executed')) { + logInfo('checkSignalCompletion -> The order was executed.') + return positions[0] + } else { + return false + } + } + + // Storage functions + async function getIndicatorFile() { + logInfo('getIndicatorFile -> Entering function. ' + bot.processDatetime.toISOString()) + + let filePath + if (bot.processes[0].timePeriod > 2700000) { + // Market Files + filePath = 'Trading-Execution/' + bot.dataSet + '/' + bot.timePeriodFileStorage + } else { + // Daily Files + let dateTime = bot.processDatetime + let datePath = dateTime.getUTCFullYear() + '/' + pad(dateTime.getUTCMonth() + 1, 2) + '/' + pad(dateTime.getUTCDate(), 2) + filePath = 'Trading-Execution/' + bot.dataSet + '/' + bot.timePeriodFileStorage + '/' + datePath + } + + /* + bot.botCache: allows us to keep a map (key value pairs) between executions, + so we don't need to go to the storage to retrieve this value. + If the value already exist on the cache we will get it from there, + otherwise it will be retrieved from the bot storage. + */ + if (bot.startMode === 'Backtest' && bot.botCache.has(filePath)) { + logInfo('getIndicatorFile -> Getting the file from local cache.') + return bot.botCache.get(filePath) + } else { + let indicatorFileContent = await getFileContent(filePath, 'USDT_BTC.json') + bot.botCache.set(filePath, JSON.parse(indicatorFileContent)) + return JSON.parse(indicatorFileContent) + } + } + + function getSimulatorEngineMessageFromFile(indicatorFileContent) { + try { + let lastIndexIndicatorFile = indicatorFileContent.length - 1 + + if (indicatorFileContent[lastIndexIndicatorFile] === undefined) { + logWarn('getSimulatorEngineMessageFromFile -> Recived file does not contain any record yet.') + return + } + let lastAvailableDateTime = indicatorFileContent[lastIndexIndicatorFile][0] + + if (bot.processDatetime.valueOf() <= lastAvailableDateTime || !isExecutionToday()) { + for (let i = 0; i < indicatorFileContent.length; i++) { + if (bot.processDatetime.valueOf() >= indicatorFileContent[i][0] && bot.processDatetime.valueOf() < indicatorFileContent[i][1]) { + return getMessage(indicatorFileContent[i][2]) + } + } + + logWarn('getSimulatorEngineMessageFromFile -> The indicator message was not found at time: ' + bot.processDatetime.valueOf()) + } else { + // Running live we will process last available Indicator Message only if it's delayed 30 minutes top + let maxTolerance = 30 * 60 * 1000 + let lastAvailableDateTimeEnd = indicatorFileContent[lastIndexIndicatorFile][1] + let minutesDelayed = (bot.processDatetime.valueOf() - lastAvailableDateTimeEnd) / 60 / 1000 + logWarn('getSimulatorEngineMessageFromFile -> Last available indicator is delayed: ' + minutesDelayed.toFixed(2) + ' minutes.') + if (bot.processDatetime.valueOf() <= (lastAvailableDateTime + maxTolerance)) { + return getMessage(indicatorFileContent[lastIndexIndicatorFile][2]) + } else { + logWarn('getSimulatorEngineMessageFromFile -> Last available indicator older than 30 minutes: ' + JSON.stringify(indicatorFileContent[lastIndexIndicatorFile])) + assistant.addExtraData(indicatorFileContent[lastIndexIndicatorFile]) // Adding the record used for the execution + } + } + } catch (error) { + logError('getSimulatorEngineMessageFromFile -> error = ' + error.message) + throw global.DEFAULT_RETRY_RESPONSE + } + } + + function getSkippedMessageOrderClose(indicatorFileContent) { + try { + let lastIndexIndicatorFile = indicatorFileContent.length - 1 + + for (let i = lastIndexIndicatorFile; i >= 0; i--) { + let simulatorMessage = getMessage(indicatorFileContent[i][2]) + if (simulatorMessage.messageType === MESSAGE_TYPE.OrderClose) { + return simulatorMessage + } + } + } catch (error) { + logError('getSkippedMessageOrderClose -> error = ' + error.message) + throw global.DEFAULT_RETRY_RESPONSE + } + } + + // Helper Functions + function isExecutionToday() { + let localDate = new Date() + let today = new Date(Date.UTC( + localDate.getUTCFullYear(), + localDate.getUTCMonth(), + localDate.getUTCDate())) + + return (today.getUTCFullYear() === bot.processDatetime.getUTCFullYear() + && today.getUTCMonth() === bot.processDatetime.getUTCMonth() + && today.getUTCDate() === bot.processDatetime.getUTCDate()) + } + + // Modules queries + async function getSignalsByCloneId(orderStatus) { + try { + const cockPit = await axios({ + url: process.env.GATEWAY_ENDPOINT_K8S, + method: 'post', + data: { + query: ` + query($cloneId: String!, $orderStatus: String){ + cockpit_SignalsByCloneId(cloneId: $cloneId, orderStatus:$orderStatus){ + id + cloneId + orderId + orderCreator + orderStatus + orderData + } + } + `, + variables: { + cloneId: process.env.CLONE_ID, + orderStatus: orderStatus + }, + }, + headers: { + authorization: process.env.AUTHORIZATION + } + }) + + logInfo("Retrieved signals in status: " + orderStatus) + return cockPit.data.data.cockpit_SignalsByCloneId + + } catch (error) { + logError('getSignalsByCloneId error: ' + error.response.data.errors[0]) + throw global.DEFAULT_RETRY_RESPONSE + } + } + + async function updateSignal(signalId, message) { + try { + const cockPit = await axios({ + url: process.env.GATEWAY_ENDPOINT_K8S, + method: 'post', + data: { + query: ` + mutation ($signalId: ID!, $message:cockpit_JSON!){ + cockpit_UpdateSignal( + id: $signalId + message: $message + ) { + id + cloneId + orderStatus + } + } + `, + variables: { + signalId: signalId, + message: message + }, + }, + headers: { + authorization: process.env.AUTHORIZATION + } + }) + + logInfo('updateSignal ok.') + return cockPit.data.data.cockpit_UpdateSignal + } catch (error) { + logError('updateSignal error: ' + error.response.data.errors[0]) + throw global.DEFAULT_RETRY_RESPONSE + } + } + + async function createSignal(message) { + try { + const cockPit = await axios({ + url: process.env.GATEWAY_ENDPOINT_K8S, + method: 'post', + data: { + query: ` + mutation ($cloneId: String!, $message: cockpit_JSON!){ + cockpit_CreateSignal( + cloneId: $cloneId + message: $message + ) { + id + cloneId + orderStatus + } + } + `, + variables: { + cloneId: process.env.CLONE_ID, + message: message + }, + }, + headers: { + authorization: process.env.AUTHORIZATION + } + }) + + logInfo('createSignal ok.') + return cockPit.data.data.cockpit_CreateSignal + } catch (error) { + logInfo("createSignal error: " + error.response.data.errors[0]) + throw global.DEFAULT_RETRY_RESPONSE + } + } + + async function getAutopilot() { + try { + const cockPit = await axios({ + url: process.env.GATEWAY_ENDPOINT_K8S, + method: 'post', + data: { + query: ` + query($cloneId: String!){ + cockpit_CloneSettingsByCloneId(cloneId: $cloneId){ + id + cloneId + autopilot + } + } + `, + variables: { + cloneId: process.env.CLONE_ID + }, + }, + headers: { + authorization: process.env.AUTHORIZATION + } + }) + + if (cockPit.data.errors) { + throw new Error(cockPit.data.errors[0].message) + } else { + logInfo('getAutopilot -> Ok.') + return cockPit.data.data.cockpit_CloneSettingsByCloneId + } + + } catch (error) { + logInfo('getAutopilot error: ' + error) + throw global.DEFAULT_RETRY_RESPONSE + } + } + + async function getFileContent(containerName, blobName) { + fileStorage.getTextFile[util.promisify.custom] = n => new Promise((resolve, reject) => { + fileStorage.getTextFile(containerName, blobName, (result, fileContent) => { + if (result !== global.DEFAULT_OK_RESPONSE) { + let errorMessage = '[WARN] getFileContent -> The indicator dependency is not ready. Will retry later.' + console.log(errorMessage) + logWarn(errorMessage) + reject(global.DEFAULT_RETRY_RESPONSE) + } else { + resolve(fileContent) + } + }) + }) + + let getTextFile = util.promisify(fileStorage.getTextFile) + let fileContent = await getTextFile(containerName, blobName) + return fileContent + } + + function pad(str, max) { + str = str.toString() + return str.length < max ? pad('0' + str, max) : str + } + + function buildBasicSimulatorExecutorMessage() { + var simulatorExecutorMessage = {} + simulatorExecutorMessage.id = 0 + simulatorExecutorMessage.from = MESSAGE_ENTITY.SimulationExecutor + simulatorExecutorMessage.to = MESSAGE_ENTITY.TradingAssistant + simulatorExecutorMessage.messageType = MESSAGE_TYPE.Order + simulatorExecutorMessage.dateTime = bot.processDatetime.valueOf() + + simulatorExecutorMessage.order = {} + simulatorExecutorMessage.order.id = 0 + simulatorExecutorMessage.order.dateTime = bot.processDatetime.valueOf() + simulatorExecutorMessage.order.creator = ORDER_CREATOR.SimulationEngine + simulatorExecutorMessage.order.owner = ORDER_OWNER.User + simulatorExecutorMessage.order.exchange = global.EXCHANGE_NAME + simulatorExecutorMessage.order.market = global.MARKET.assetA + '_' + global.MARKET.assetB + simulatorExecutorMessage.order.marginEnabled = ORDER_MARGIN_ENABLED.False + simulatorExecutorMessage.order.type = ORDER_TYPE.Limit + simulatorExecutorMessage.order.status = ORDER_STATUS.Placed + simulatorExecutorMessage.order.sizeFilled = 0 + simulatorExecutorMessage.order.exitOutcome = '' + simulatorExecutorMessage.order.statusMessage = '' + + return simulatorExecutorMessage + } + +} diff --git a/src/storage/templates/TradingBot/this.bot.config.json b/src/storage/templates/TradingBot/this.bot.config.json new file mode 100644 index 000000000..d59dba4bc --- /dev/null +++ b/src/storage/templates/TradingBot/this.bot.config.json @@ -0,0 +1,188 @@ +{ + "displayName": "Bumblebee", + "codeName": "bumblebee", + "type": "Trading", + "version": { + "major": 1, + "minor": 0, + "patch": 0 + }, + "devTeam": "vikings", + "profilePicture": "bumblebee.png", + "dataSetVersion": "dataSet.V1", + "processes": [ + { + "name": "Trading-Process", + "description": "Trading strategy to be used as a template.", + "normalWaitTime": 60000, + "retryWaitTime": 10000, + "sleepWaitTime": 3600000, + "comaWaitTime": 86400000, + "timePeriod": 3600000, + "statusDependencies": [ + { + "devTeam": "aavikings", + "bot": "bumblebee", + "botVersion": { + "major": 1, + "minor": 0 + }, + "process": "Trading-Process", + "dataSetVersion": "dataSet.V1", + "type": "Trading" + }, + { + "devTeam": "AAMasters", + "bot": "AAJason", + "botVersion": { + "major": 1, + "minor": 0 + }, + "process": "Multi-Period-Market", + "dataSetVersion": "dataSet.V1", + "type": "Indicator" + }, + { + "devTeam": "AAMasters", + "bot": "AAJason", + "botVersion": { + "major": 1, + "minor": 0 + }, + "process": "Multi-Period-Daily", + "dataSetVersion": "dataSet.V1", + "type": "Indicator" + } + ], + "dataDependencies": [ + { + "devTeam": "AAMasters", + "bot": "AABruce", + "botVersion": { + "major": 1, + "minor": 0 + }, + "product": "Candles", + "dataSetVersion": "dataSet.V1", + "dataSet": "One-Min" + }, + { + "devTeam": "AAMasters", + "bot": "AAJason", + "botVersion": { + "major": 1, + "minor": 0 + }, + "product": "Trading-Execution", + "dataSetVersion": "dataSet.V1", + "dataSet": "Multi-Period-Market" + }, + { + "devTeam": "AAMasters", + "bot": "AAJason", + "botVersion": { + "major": 1, + "minor": 0 + }, + "product": "Trading-Execution", + "dataSetVersion": "dataSet.V1", + "dataSet": "Multi-Period-Daily" + } + ] + } + ], + "products": [ + { + "codeName": "Live Trading History", + "displayName": "Live Trading History", + "shortDisplayName": "Live", + "description": "General information about trading history.", + "dataSets": [ + { + "codeName": "Oficial History", + "type": "File Sequence", + "validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs", "45-min", "40-min", "30-min", "20-min", "15-min", "10-min", "05-min", "04-min", "03-min", "02-min", "01-min" ], + "filePath": "@DevTeam/@Bot.1.0/AACloud.1.1/Poloniex/dataSet.V1/Output/Trading-Process", + "fileName": "Execution.History.Live.@Sequence.json" + } + ], + "exchangeList": [ + { + "name": "Poloniex" + } + ], + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersTradingSimulation", + "moduleName": "SimulationExecution" + } + }, + { + "codeName": "Backtest Trading History", + "displayName": "Backtest Trading History", + "shortDisplayName": "Backtest", + "description": "General information about backtest trading history.", + "dataSets": [ + { + "codeName": "Backtest History", + "type": "File Sequence", + "validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs", "45-min", "40-min", "30-min", "20-min", "15-min", "10-min", "05-min", "04-min", "03-min", "02-min", "01-min" ], + "filePath": "@DevTeam/@Bot.1.0/AACloud.1.1/Poloniex/dataSet.V1/Output/Trading-Process", + "fileName": "Execution.History.Backtest.@Sequence.json" + } + ], + "exchangeList": [ + { + "name": "Poloniex" + } + ], + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersTradingSimulation", + "moduleName": "SimulationExecution" + } + }, + { + "codeName": "Competition Trading History", + "displayName": "Competition Trading History", + "shortDisplayName": "Competition", + "description": "General information about competition trading history.", + "dataSets": [ + { + "codeName": "Competition History", + "type": "File Sequence", + "validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs", "45-min", "40-min", "30-min", "20-min", "15-min", "10-min", "05-min", "04-min", "03-min", "02-min", "01-min" ], + "filePath": "@DevTeam/@Bot.1.0/AACloud.1.1/Poloniex/dataSet.V1/Output/Trading-Process", + "fileName": "Execution.History.Competition.@Sequence.json" + } + ], + "exchangeList": [ + { + "name": "Poloniex" + } + ], + "plotter": { + "devTeam": "AAMasters", + "codeName": "PlottersTradingSimulation", + "moduleName": "SimulationExecution" + } + } + ], + "marketRateProvider": { + "devTeam": "AAMasters", + "bot": "AABruce", + "host": { + "url": "https://demo-dev.superalgos.org/", + "storage": "localStorage", + "container": "aamasters", + "accessKey": "" + }, + "botVersion": { + "major": 1, + "minor": 0 + }, + "product": "Candles", + "dataSet": "One-Min", + "dataSetVersion": "dataSet.V1" + } +} diff --git a/src/utils/getDevTeamHost.js b/src/utils/getDevTeamHost.js new file mode 100644 index 000000000..2066fc4fb --- /dev/null +++ b/src/utils/getDevTeamHost.js @@ -0,0 +1,32 @@ +import { Ecosystem } from '../models' + +let teamCache = new Map() +export default async function getDevTeamHost(devTeamName, accessKey, ownerKey) { + let host + if (accessKey) { + host = teamCache.get(devTeamName + '.accessKey') + } else { + host = teamCache.get(devTeamName + '.ownerKey') + } + if (host && (host.accessKey === accessKey || host.ownerKey === ownerKey)) { + return host + } else { + let ecosystem = await Ecosystem.find() + + for (var i = 0; i < ecosystem.length; i++) { + for (var j = 0; j < ecosystem[i].devTeams.length; j++) { + if (ecosystem[i].devTeams[j].codeName.toLowerCase() === devTeamName.toLowerCase()) { + if (ecosystem[i].devTeams[j].host.accessKey === accessKey) { + teamCache.set(devTeamName + '.accessKey', ecosystem[i].devTeams[j].host) + return ecosystem[i].devTeams[j].host + } + if (ecosystem[i].devTeams[j].host.ownerKey === ownerKey) { + teamCache.set(devTeamName + '.ownerKey', ecosystem[i].devTeams[j].host) + return ecosystem[i].devTeams[j].host + } + } + } + } + + } +} diff --git a/src/utils/logger.js b/src/utils/logger.js new file mode 100644 index 000000000..3932769cc --- /dev/null +++ b/src/utils/logger.js @@ -0,0 +1,41 @@ +import { createLogger, format, transports } from 'winston' +import { inspect } from 'util' + +const options = { + file: { + level: 'info', + filename: '../logs/app.log', + handleExceptions: true, + json: true, + maxsize: 5242880, // 5MB + maxFiles: 5, + colorize: false, + timestamp: true + }, + console: { + level: process.env.LOG_LEVEL || 'debug', + handleExceptions: true, + json: false, + colorize: true, + timestamp: true + } +} + +const logger = createLogger({ + level: 'info', + format: format.combine( + format.colorize(), + format.splat(), + format.timestamp({ format: 'YY/MM/DD HH:mm' }), + format.printf( + info => `${info.timestamp} - ${info.level}: ${JSON.parse(JSON.stringify(inspect(info.message)))}` + ) + ), + transports: [ + // new transports.File(options.file), + new transports.Console(options.console) + ], + exitOnError: false // do not exit on handled exceptions +}) + +export default logger diff --git a/src/utils/readFile.js b/src/utils/readFile.js new file mode 100644 index 000000000..1be0d4609 --- /dev/null +++ b/src/utils/readFile.js @@ -0,0 +1,14 @@ +import fs from 'fs' + +export default function readFile(fileName) { + return new Promise(function (resolve, reject) { + fs.readFile(fileName, 'utf8', (err, file) => { + if (err) { + reject(err) + } else { + resolve(file) + } + }) + + }) +} diff --git a/test/minioTest.js b/test/minioTest.js new file mode 100644 index 000000000..e7d1bd7b0 --- /dev/null +++ b/test/minioTest.js @@ -0,0 +1,46 @@ +import { assert } from 'chai' +import { + getFileContent, + createContainer, + deleteContainer, + writeFileContent +} from '../src/storage/providers/MinioStorage' + +import 'dotenv/config' + +describe('Minio Storage Tests', function () { + it('Create Container', async function () { + let containerName = 'test-container' + await createContainer(containerName) + assert.isOk('everything', 'everything is ok') + }) + it('Save File', async function () { + let containerName = 'test-container' + let blobName = 'test-folder/test_data_file.json' + let content = '[0,0,0,0]' + await writeFileContent(containerName, blobName, content) + + // for (let index = 0; index < 1000; index++) { + // let blobName = 'test-folder/test_data_file_' + index + '.json' + // await writeFileContent(containerName, blobName, content) + // } + + assert.isOk('everything', 'everything is ok') + }) + it('Retrieve File', async function () { + let containerName = 'test-container' + let blobName = 'test-folder/test_data_file_1.json' + let fileContent = await getFileContent(containerName, blobName) + + let expected = '[0,0,0,0]' + assert.equal(fileContent, expected) + }) + it('Delete Container', async function () { + let containerName = 'test-container' + console.log('start: '+ new Date().toISOString()) + await deleteContainer(containerName) + console.log('end: '+ new Date().toISOString()) + + assert.isOk('everything', 'everything is ok') + }) +})