From 23d2094234c28edb79d353bb1c9b35cecf0ac70c Mon Sep 17 00:00:00 2001 From: Matias Date: Wed, 22 May 2019 20:22:54 -0300 Subject: [PATCH 1/4] Initial version --- .dockerignore | 14 + .env.local | 6 + .gitignore | 23 + CODE_OF_CONDUCT.md | 46 + CONTRIBUTING.md | 9 + Dockerfile | 19 + Dockerfile.prod | 21 + LICENSE | 201 ++++ docker-compose.prod.yml | 24 + package-lock.json | 1850 +++++++++++++++++++++++++++++++ package.json | 29 + src/app.js | 53 + src/db.js | 10 + src/errors/index.js | 31 + src/errors/notAllowed.json | 8 + src/index.js | 2 + src/models/ecosystem.js | 101 ++ src/models/index.js | 5 + src/schema/index.js | 12 + src/schema/mutations/AddTeam.js | 68 ++ src/schema/mutations/index.js | 14 + src/schema/queries/Teams.js | 21 + src/schema/queries/index.js | 14 + src/schema/types/Bot.js | 14 + src/schema/types/Ecosystem.js | 30 + src/schema/types/EventHost.js | 31 + src/schema/types/Host.js | 15 + src/schema/types/Team.js | 35 + src/schema/types/index.js | 11 + src/schema/types/input/Bot.js | 15 + src/schema/types/input/Host.js | 16 + src/schema/types/input/Team.js | 22 + src/schema/types/input/index.js | 9 + src/storage/AzureStorage.js | 87 ++ src/utils/logger.js | 41 + 35 files changed, 2907 insertions(+) create mode 100644 .dockerignore create mode 100644 .env.local create mode 100644 .gitignore create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 Dockerfile create mode 100644 Dockerfile.prod create mode 100644 LICENSE create mode 100644 docker-compose.prod.yml create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 src/app.js create mode 100644 src/db.js create mode 100644 src/errors/index.js create mode 100644 src/errors/notAllowed.json create mode 100644 src/index.js create mode 100644 src/models/ecosystem.js create mode 100644 src/models/index.js create mode 100644 src/schema/index.js create mode 100644 src/schema/mutations/AddTeam.js create mode 100644 src/schema/mutations/index.js create mode 100644 src/schema/queries/Teams.js create mode 100644 src/schema/queries/index.js create mode 100644 src/schema/types/Bot.js create mode 100644 src/schema/types/Ecosystem.js create mode 100644 src/schema/types/EventHost.js create mode 100644 src/schema/types/Host.js create mode 100644 src/schema/types/Team.js create mode 100644 src/schema/types/index.js create mode 100644 src/schema/types/input/Bot.js create mode 100644 src/schema/types/input/Host.js create mode 100644 src/schema/types/input/Team.js create mode 100644 src/schema/types/input/index.js create mode 100644 src/storage/AzureStorage.js create mode 100644 src/utils/logger.js 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..ab3193771 --- /dev/null +++ b/.env.local @@ -0,0 +1,6 @@ +NODE_ENV=production +PORT=4011 + +MONGO_URL=mongodb://mongo/saweb + +PRESHARED_GATEWAY_KEY=saweb_key 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/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 000000000..9fd6b338c --- /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: npm start + 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..d0d1e0fde --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1850 @@ +{ + "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" + } + }, + "@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" + } + }, + "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" + } + } + } + }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, + "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=" + }, + "axios": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.18.0.tgz", + "integrity": "sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI=", + "requires": { + "follow-redirects": "^1.3.0", + "is-buffer": "^1.1.5" + } + }, + "backo2": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", + "integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc=" + }, + "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" + } + }, + "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==" + }, + "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==" + }, + "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" + } + }, + "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" + } + }, + "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" + } + }, + "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" + } + }, + "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" + } + }, + "dotenv": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-6.0.0.tgz", + "integrity": "sha512-FlWbnhgjtwD+uNLUGHbMykMOYQaTivdHEmYwAKFjn6GKe/CqY0fNae93ZHTd20snh9ZLr8mTzIL9m0APQ1pjQg==" + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "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=" + }, + "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" + } + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, + "esm": { + "version": "3.2.25", + "resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz", + "integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==" + }, + "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==" + }, + "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==" + } + } + }, + "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==" + } + } + }, + "follow-redirects": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.7.0.tgz", + "integrity": "sha512-m/pZQy4Gj287eNy94nivy5wchN3Kp+Q5WgUPNy5lJSZ3sgkVKSYV/ZChMAQVIgx1SqfZ2zBZtPA2YlXIWxxJOQ==", + "requires": { + "debug": "^3.2.6" + }, + "dependencies": { + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "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==" + } + } + }, + "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==" + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + }, + "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" + } + } + } + }, + "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-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", + "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=" + }, + "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" + } + }, + "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" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "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": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" + }, + "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-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" + } + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" + }, + "iterall": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/iterall/-/iterall-1.2.2.tgz", + "integrity": "sha512-yynBb1g+RFUPY64fTrFv7nsjRrENBQJaX2UL+2Szc9REFrSNm1rpSXHGzhmAy7a9uv3vlvgBlXnf9RqmPH1/DA==" + }, + "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" + } + }, + "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=" + }, + "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" + } + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "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" + } + }, + "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==" + }, + "node-fetch": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", + "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" + }, + "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.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" + } + }, + "one-time": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/one-time/-/one-time-0.0.4.tgz", + "integrity": "sha1-+M33eISCb+Tf+T46nMN7HkSAdC4=" + }, + "parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" + }, + "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=" + }, + "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==" + }, + "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==" + }, + "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" + } + }, + "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=" + }, + "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" + } + }, + "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" + } + }, + "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" + } + }, + "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_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" + }, + "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" + } + } + } + }, + "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==" + }, + "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==" + }, + "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" + } + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, + "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==" + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + }, + "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" + } + } + } + }, + "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" + } + }, + "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=" + }, + "yallist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" + }, + "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..1e9b23411 --- /dev/null +++ b/package.json @@ -0,0 +1,29 @@ +{ + "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" + }, + "dependencies": { + "@azure/storage-blob": "^10.3.0", + "apollo-server-express": "2.1.0", + "axios": "0.18.0", + "dotenv": "6.0.0", + "esm": "^3.2.22", + "express": "4.16.3", + "graphql": "0.13.2", + "mongoose": "5.3.4", + "winston": "3.2.1" + } +} diff --git a/src/app.js b/src/app.js new file mode 100644 index 000000000..2b29d8a1a --- /dev/null +++ b/src/app.js @@ -0,0 +1,53 @@ +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'; + +const app = express(); + +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) => { + console.log(err); +}); +db.once('open', () => { + console.log('Connected to the DB.'); +}); + +app.listen(process.env.PORT, () => { + console.log(`Listening on port ${process.env.PORT}`); +}); 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..b6c507c56 --- /dev/null +++ b/src/errors/index.js @@ -0,0 +1,31 @@ +class ClientError extends Error { + constructor(args) { + super(args); + } +} + +class ServerError extends Error { + constructor(args) { + super(args); + } +} + +export class AuthenticationError extends ClientError { + // code = 401 + // message = 'Authentication not found, you have to be authenticated to perform this action' +} + +export class DatabaseError extends ClientError { + // code = 404 + // message = `Ressource not found : ${this.message}` +} + +export class WrongArgumentsError extends ClientError { + // code = 400 + // message = `Wrong arguments : ${this.message}` +} + +export class ServiceUnavailableError extends ServerError { + // code = 503 + // 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..85384b9e8 --- /dev/null +++ b/src/models/ecosystem.js @@ -0,0 +1,101 @@ +const mongoose = require('mongoose') +const { Schema } = require('mongoose') + +const ecosystemSchema = new Schema({ + authId: { + type: String, + required: true + }, + teams: [{ + codeName: { + type: String, + required: true + }, + displayName: { + type: String, + required: true + }, + host:{ + url: { + type: String, + required: true + }, + container: { + type: String, + required: true + }, + accessKey: { + type: String, + required: true + } + }, + bots: [{ + repo: { + type: String, + required: true + }, + configFile: { + type: String, + required: true + } + }], + plotters: [{ + 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 + }, + container: { + type: String, + required: true + }, + accessKey: { + type: String, + required: true + } + }, + competitions: [{ + repo: { + type: String, + required: true + }, + configFile: { + type: String, + required: true + } + }], + plotters: [{ + 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/AddTeam.js b/src/schema/mutations/AddTeam.js new file mode 100644 index 000000000..69cdd86c2 --- /dev/null +++ b/src/schema/mutations/AddTeam.js @@ -0,0 +1,68 @@ +import { AuthenticationError } from '../../errors'; +import { TeamType } from '../types'; +import { Ecosystem } from '../../models'; +import { TeamInputType } from '../types/input'; +import logger from '../../utils/logger'; +import { createContainer } from '../../storage/AzureStorage'; + +import { + GraphQLString +} from 'graphql'; + +export const args = { + team: { type: TeamInputType }, +}; + +const resolve = async (parent, { team }, context) => { + logger.debug('addTeam -> Entering Fuction.') + + 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 + } + + let containerName = team.codeName + await createContainer(containerName) + // let accessKey = await createPrivateAccessKey() + let accessKey = "test" + + if (!team.host) { + let nodeEndpoint = { + url: process.env.SUPERALGOS_NODE_ENDPOINT, + container: containerName, + accessKey: accessKey, + } + team.host = nodeEndpoint + } + + userEcosystem.teams.push(team) + await userEcosystem.save() + + } catch (err) { + logger.error('addTeam -> Error: %s', err.stack) + // throw new ServerError('There has been an error adding the team.') + return 'There has been an error adding the team.' + } +}; + +const mutation = { + addTeam: { + type: GraphQLString, + 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..fd97d2baa --- /dev/null +++ b/src/schema/mutations/index.js @@ -0,0 +1,14 @@ +import { + GraphQLObjectType, +} from 'graphql'; + +import AddTeamMutation from './AddTeam'; + +const Mutation = new GraphQLObjectType({ + name: 'Mutation', + fields: Object.assign( + AddTeamMutation, + ), +}); + +export default Mutation; diff --git a/src/schema/queries/Teams.js b/src/schema/queries/Teams.js new file mode 100644 index 000000000..2c278e453 --- /dev/null +++ b/src/schema/queries/Teams.js @@ -0,0 +1,21 @@ +import { GraphQLList } from 'graphql'; +import { TeamType } from '../types'; +import { Ecosystem } from '../../models'; +import logger from '../../utils/logger' + +const args = {}; + +const resolve = (parent, args, context) => { + logger.debug('Listing teams.') + +} + +const query = { + teams: { + type: new GraphQLList(TeamType), + 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..5483b5df6 --- /dev/null +++ b/src/schema/queries/index.js @@ -0,0 +1,14 @@ +import { + GraphQLObjectType, +} from 'graphql'; + +import TeamsQuery from './Teams'; + +const RootQuery = new GraphQLObjectType({ + name: 'RootQueryType', + fields: Object.assign( + TeamsQuery + ), +}); + +export default RootQuery; diff --git a/src/schema/types/Bot.js b/src/schema/types/Bot.js new file mode 100644 index 000000000..7e02f2e38 --- /dev/null +++ b/src/schema/types/Bot.js @@ -0,0 +1,14 @@ +import { + GraphQLObjectType, + GraphQLString +} from 'graphql'; + +const BotType = new GraphQLObjectType({ + name: 'Bot', + fields: () => ({ + repo: { type: GraphQLString }, + configFile: { type: GraphQLString } + }), +}); + +export default BotType; diff --git a/src/schema/types/Ecosystem.js b/src/schema/types/Ecosystem.js new file mode 100644 index 000000000..828361682 --- /dev/null +++ b/src/schema/types/Ecosystem.js @@ -0,0 +1,30 @@ +import { + GraphQLObjectType, + GraphQLString, + GraphQLID +} 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 + teams: { + type: new GraphQLList(TeamType), + resolve(parent) { + return parent.teams; + } + }, + 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..91e2c7533 --- /dev/null +++ b/src/schema/types/EventHost.js @@ -0,0 +1,31 @@ +import { + GraphQLObjectType, + GraphQLString +} from 'graphql'; + +import { BotType } from './index'; + +const EventHostType = new GraphQLObjectType({ + name: 'EventHost', + fields: () => ({ + codeName: { type: GraphQLString }, + displayName: { type: GraphQLString }, + host: { type: GraphQLString }, + container: { type: GraphQLString }, + accessKey: { type: GraphQLString }, + competitions: { + type: new GraphQLList(BotType), + resolve(parent) { + return parent.bots; + } + }, + plotters: { + type: new GraphQLList(BotType), + resolve(parent) { + return parent.bots; + } + } + }), +}); + +export default EventHostType; diff --git a/src/schema/types/Host.js b/src/schema/types/Host.js new file mode 100644 index 000000000..4c31de9e7 --- /dev/null +++ b/src/schema/types/Host.js @@ -0,0 +1,15 @@ +import { + GraphQLObjectType, + GraphQLString +} from 'graphql'; + +const HostType = new GraphQLObjectType({ + name: 'Host', + fields: () => ({ + url: { type: GraphQLString }, + container: { type: GraphQLString }, + accessKey: { type: GraphQLString } + }), +}); + +export default HostType; diff --git a/src/schema/types/Team.js b/src/schema/types/Team.js new file mode 100644 index 000000000..e39d0aa5b --- /dev/null +++ b/src/schema/types/Team.js @@ -0,0 +1,35 @@ +import { + GraphQLObjectType, + GraphQLString, + GraphQLList +} from 'graphql'; + +import { BotType, 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(BotType), + resolve(parent) { + return parent.bots; + } + } + }), +}); + +export default TeamType; diff --git a/src/schema/types/index.js b/src/schema/types/index.js new file mode 100644 index 000000000..8f8f70ce1 --- /dev/null +++ b/src/schema/types/index.js @@ -0,0 +1,11 @@ +import TeamType from './Team'; +import BotType from './Bot'; +import EventHostType from './EventHost'; +import HostType from './Host'; + +export { + TeamType, + BotType, + EventHostType, + HostType +}; diff --git a/src/schema/types/input/Bot.js b/src/schema/types/input/Bot.js new file mode 100644 index 000000000..75f10ebde --- /dev/null +++ b/src/schema/types/input/Bot.js @@ -0,0 +1,15 @@ +import { + GraphQLInputObjectType, + GraphQLString +} from 'graphql'; + +const Type = new GraphQLInputObjectType({ + name: 'BotInput', + description: 'Payload for bot input.', + fields: () => ({ + repo: { type: GraphQLString }, + configFile: { 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..9574ce095 --- /dev/null +++ b/src/schema/types/input/Host.js @@ -0,0 +1,16 @@ +import { + GraphQLInputObjectType, + GraphQLString +} from 'graphql'; + +const Type = new GraphQLInputObjectType({ + name: 'HostInput', + description: 'Payload for host input.', + fields: () => ({ + url: { type: GraphQLString }, + container: { type: GraphQLString }, + accessKey: { type: GraphQLString } + }), +}); + +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..878dca112 --- /dev/null +++ b/src/schema/types/input/Team.js @@ -0,0 +1,22 @@ +import { + GraphQLString, + GraphQLInputObjectType, + GraphQLNonNull, + GraphQLList +} 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 }, + bots: { type: new GraphQLNonNull(new GraphQLList(BotInputType)) }, + plotters: { type: new GraphQLList(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..bee4b6f16 --- /dev/null +++ b/src/schema/types/input/index.js @@ -0,0 +1,9 @@ +import TeamInputType from './Team' +import BotInputType from './Bot' +import HostInputType from './Host' + +export { + TeamInputType, + BotInputType, + HostInputType +}; diff --git a/src/storage/AzureStorage.js b/src/storage/AzureStorage.js new file mode 100644 index 000000000..ea2d49c07 --- /dev/null +++ b/src/storage/AzureStorage.js @@ -0,0 +1,87 @@ +import logger from '../utils/logger' +const { + Aborter, + BlobURL, + BlockBlobURL, + ContainerURL, + ServiceURL, + StorageURL, + SharedKeyCredential +} = require("@azure/storage-blob") + +const AzureServiceURL = () => { + // Enter your storage account name and shared key + const account = process.env.STORAGE_BASE_URL; + const accountKey = process.env.STORAGE_CONNECTION_STRING; + + // Use SharedKeyCredential with storage account and account key + const sharedKeyCredential = new SharedKeyCredential(account, accountKey); + + // Use sharedKeyCredential, tokenCredential or anonymousCredential to create a pipeline + const pipeline = StorageURL.newPipeline(sharedKeyCredential); + + // List containers + const serviceURL = new ServiceURL( + // When using AnonymousCredential, following url should include a valid SAS or support public access + `https://${account}.blob.core.windows.net`, + pipeline + ); + logger.info("Connected to te file Storage.") + return serviceURL +} + +const serviceURL = AzureServiceURL() + +export const getFileContent = async (containerName, blobName) => { + const containerURL = ContainerURL.fromServiceURL(serviceURL, 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(serviceURL, 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) => { + try { + const containerURL = ContainerURL.fromServiceURL(serviceURL, containerName) + const blockBlobURL = BlockBlobURL.fromContainerURL(containerURL, blobName) + await blockBlobURL.delete(Aborter.none) + } catch (err) { + logger.warn('Error deleting the file: %s%s', containerName, blobName) + } +} + +export const deleteContainer = async (containerName) => { + const containerURL = ContainerURL.fromServiceURL(serviceURL, containerName) + await containerURL.delete(Aborter.none) + logger.debug('deleteContainer -> Successful.') +} + +export const createContainer = async (containerName) => { + const containerURL = ContainerURL.fromServiceURL(serviceURL, containerName) + await containerURL.create(Aborter.none) + logger.debug('createContainer -> Successful.') +} + +// 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/utils/logger.js b/src/utils/logger.js new file mode 100644 index 000000000..9ef06e941 --- /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: '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 From 8ef729b77f5e129d1b9bfa634a9eafa68836f775 Mon Sep 17 00:00:00 2001 From: Matias Date: Fri, 24 May 2019 20:18:11 -0300 Subject: [PATCH 2/4] saweb-api migration --- package-lock.json | 369 ++++++++++++++++++++ package.json | 2 + src/app.js | 7 +- src/models/ecosystem.js | 20 +- src/schema/mutations/AddTeam.js | 50 +-- src/schema/mutations/DeleteTeam.js | 60 ++++ src/schema/mutations/index.js | 2 + src/schema/queries/Ecosystem.js | 42 +++ src/schema/queries/FileContent.js | 33 ++ src/schema/queries/Teams.js | 21 -- src/schema/queries/index.js | 6 +- src/schema/types/Bot.js | 2 + src/schema/types/Ecosystem.js | 3 +- src/schema/types/EventHost.js | 3 +- src/schema/types/File.js | 17 + src/schema/types/Host.js | 1 + src/schema/types/index.js | 6 +- src/schema/types/input/Bot.js | 5 +- src/schema/types/input/File.js | 19 + src/schema/types/input/Host.js | 1 + src/schema/types/input/Team.js | 4 +- src/schema/types/input/index.js | 4 +- src/storage/CopyBot.js | 60 ++++ src/storage/CopySimulator.js | 83 +++++ src/storage/CreateTeam.js | 27 ++ src/storage/DeleteTeam.js | 18 + src/storage/{ => providers}/AzureStorage.js | 86 ++++- src/utils/logger.js | 4 +- 28 files changed, 876 insertions(+), 79 deletions(-) create mode 100644 src/schema/mutations/DeleteTeam.js create mode 100644 src/schema/queries/Ecosystem.js create mode 100644 src/schema/queries/FileContent.js delete mode 100644 src/schema/queries/Teams.js create mode 100644 src/schema/types/File.js create mode 100644 src/schema/types/input/File.js create mode 100644 src/storage/CopyBot.js create mode 100644 src/storage/CopySimulator.js create mode 100644 src/storage/CreateTeam.js create mode 100644 src/storage/DeleteTeam.js rename src/storage/{ => providers}/AzureStorage.js (51%) diff --git a/package-lock.json b/package-lock.json index d0d1e0fde..52d8bf200 100644 --- a/package-lock.json +++ b/package-lock.json @@ -217,6 +217,17 @@ "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" + } + }, "apollo-cache-control": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/apollo-cache-control/-/apollo-cache-control-0.6.0.tgz", @@ -440,6 +451,19 @@ "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=" + }, "async": { "version": "2.6.1", "resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz", @@ -466,6 +490,16 @@ "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.18.0", "resolved": "https://registry.npmjs.org/axios/-/axios-0.18.0.tgz", @@ -475,11 +509,75 @@ "is-buffer": "^1.1.5" } }, + "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=" }, + "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" + } + }, "bluebird": { "version": "3.5.1", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", @@ -502,6 +600,11 @@ "type-is": "~1.6.17" } }, + "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", @@ -521,6 +624,11 @@ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" + }, "color": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/color/-/color-3.0.0.tgz", @@ -618,6 +726,14 @@ "vary": "^1" } }, + "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", @@ -678,6 +794,15 @@ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-6.0.0.tgz", "integrity": "sha512-FlWbnhgjtwD+uNLUGHbMykMOYQaTivdHEmYwAKFjn6GKe/CqY0fNae93ZHTd20snh9ZLr8mTzIL9m0APQ1pjQg==" }, + "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", @@ -880,6 +1005,21 @@ } } }, + "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", @@ -939,6 +1079,11 @@ } } }, + "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", @@ -969,6 +1114,14 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, + "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" + } + }, "graphql": { "version": "0.13.2", "resolved": "https://registry.npmjs.org/graphql/-/graphql-0.13.2.tgz", @@ -1039,6 +1192,20 @@ } } }, + "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", @@ -1052,6 +1219,15 @@ "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" + } + }, "http-errors": { "version": "1.7.2", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", @@ -1064,6 +1240,16 @@ "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", @@ -1123,16 +1309,75 @@ "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=" }, + "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==" }, + "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-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", @@ -1193,6 +1438,15 @@ "yallist": "^3.0.2" } }, + "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", @@ -1326,6 +1580,11 @@ "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" }, + "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", @@ -1373,6 +1632,11 @@ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" }, + "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", @@ -1466,6 +1730,54 @@ "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_optional": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz", @@ -1604,6 +1916,22 @@ "memory-pager": "^1.0.2" } }, + "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", @@ -1688,6 +2016,19 @@ "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-is": { "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", @@ -1697,11 +2038,24 @@ "mime-types": "~2.1.24" } }, + "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", @@ -1726,11 +2080,26 @@ "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" + } + }, "winston": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/winston/-/winston-3.2.1.tgz", diff --git a/package.json b/package.json index 1e9b23411..6dab68f4f 100644 --- a/package.json +++ b/package.json @@ -19,10 +19,12 @@ "@azure/storage-blob": "^10.3.0", "apollo-server-express": "2.1.0", "axios": "0.18.0", + "azure-storage": "^2.10.3", "dotenv": "6.0.0", "esm": "^3.2.22", "express": "4.16.3", "graphql": "0.13.2", + "json-beautify": "^1.1.0", "mongoose": "5.3.4", "winston": "3.2.1" } diff --git a/src/app.js b/src/app.js index 2b29d8a1a..69f1f14ce 100644 --- a/src/app.js +++ b/src/app.js @@ -4,6 +4,7 @@ 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' const app = express(); @@ -42,12 +43,12 @@ server.applyMiddleware({ }); db.on('error', (err) => { - console.log(err); + logger.error(err); }); db.once('open', () => { - console.log('Connected to the DB.'); + logger.info('Connected to the DB.'); }); app.listen(process.env.PORT, () => { - console.log(`Listening on port ${process.env.PORT}`); + logger.info(`Listening on port ${process.env.PORT}`); }); diff --git a/src/models/ecosystem.js b/src/models/ecosystem.js index 85384b9e8..5856d8f19 100644 --- a/src/models/ecosystem.js +++ b/src/models/ecosystem.js @@ -20,6 +20,10 @@ const ecosystemSchema = new Schema({ type: String, required: true }, + storage: { + type: String, + required: true + }, container: { type: String, required: true @@ -30,13 +34,21 @@ const ecosystemSchema = new Schema({ } }, bots: [{ - repo: { + codeName: { type: String, required: true }, - configFile: { + displayName: { type: String, required: true + }, + repo: { + type: String, + required: false + }, + configFile: { + type: String, + required: false } }], plotters: [{ @@ -64,6 +76,10 @@ const ecosystemSchema = new Schema({ type: String, required: true }, + storage: { + type: String, + required: true + }, container: { type: String, required: true diff --git a/src/schema/mutations/AddTeam.js b/src/schema/mutations/AddTeam.js index 69cdd86c2..44e6402d0 100644 --- a/src/schema/mutations/AddTeam.js +++ b/src/schema/mutations/AddTeam.js @@ -1,17 +1,11 @@ -import { AuthenticationError } from '../../errors'; -import { TeamType } from '../types'; -import { Ecosystem } from '../../models'; -import { TeamInputType } from '../types/input'; -import logger from '../../utils/logger'; -import { createContainer } from '../../storage/AzureStorage'; +import logger from '../../utils/logger' +import { AuthenticationError, WrongArgumentsError } from '../../errors' +import { TeamType } from '../types' +import { Ecosystem } from '../../models' +import { TeamInputType } from '../types/input' +import { createTeam } from '../../storage/CreateTeam' -import { - GraphQLString -} from 'graphql'; - -export const args = { - team: { type: TeamInputType }, -}; +export const args = { team: { type: TeamInputType } } const resolve = async (parent, { team }, context) => { logger.debug('addTeam -> Entering Fuction.') @@ -33,36 +27,42 @@ const resolve = async (parent, { team }, context) => { userEcosystem.authId = context.userId } - let containerName = team.codeName - await createContainer(containerName) - // let accessKey = await createPrivateAccessKey() - let accessKey = "test" + for (let i = 0; i < userEcosystem.teams.length; i++) { + const auxTeam = userEcosystem.teams[i]; + if (auxTeam.codeName === team.codeName) { + throw new WrongArgumentsError("The team already exist on the user ecosystem.") + } + } + let accessKey = await createTeam(team) if (!team.host) { let nodeEndpoint = { url: process.env.SUPERALGOS_NODE_ENDPOINT, - container: containerName, + container: team.codeName, accessKey: accessKey, } team.host = nodeEndpoint } + let bots= [] + bots.push(team.bot) + team.bots = bots + userEcosystem.teams.push(team) await userEcosystem.save() - + return team } catch (err) { logger.error('addTeam -> Error: %s', err.stack) - // throw new ServerError('There has been an error adding the team.') - return 'There has been an error adding the team.' + throw err } -}; +} const mutation = { addTeam: { - type: GraphQLString, + type: TeamType, 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..85f4c403a --- /dev/null +++ b/src/schema/mutations/DeleteTeam.js @@ -0,0 +1,60 @@ +import logger from '../../utils/logger' +import { AuthenticationError, WrongArgumentsError } from '../../errors' +import { TeamType } from '../types' +import { Ecosystem } from '../../models' +import { TeamInputType } from '../types/input' +import { deleteTeam } from '../../storage/DeleteTeam' + +export const args = { team: { type: TeamInputType } } + +const resolve = async (parent, { team }, context) => { + logger.debug('deleteTeam -> Entering Fuction.') + + 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.teams.length; i++) { + const auxTeam = userEcosystem.teams[i] + if (auxTeam.codeName === team.codeName) { + logger.debug('deleteTeam -> Team found, removing.') + teamFound = true + await deleteTeam(team) + userEcosystem.teams.splice(i, 1) + 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/index.js b/src/schema/mutations/index.js index fd97d2baa..85ef11366 100644 --- a/src/schema/mutations/index.js +++ b/src/schema/mutations/index.js @@ -3,11 +3,13 @@ import { } from 'graphql'; import AddTeamMutation from './AddTeam'; +import DeleteTeamMutation from './DeleteTeam'; const Mutation = new GraphQLObjectType({ name: 'Mutation', fields: Object.assign( AddTeamMutation, + DeleteTeamMutation ), }); diff --git a/src/schema/queries/Ecosystem.js b/src/schema/queries/Ecosystem.js new file mode 100644 index 000000000..ca55b7fce --- /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 Fuction.') + + 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..910fa8df5 --- /dev/null +++ b/src/schema/queries/FileContent.js @@ -0,0 +1,33 @@ +import logger from '../../utils/logger' +import { FileInputType } from '../types/input' +import { GraphQLString } from 'graphql' + +export const args = { file: { type: FileInputType } } + +const resolve = async (parent, { file }, context) => { + logger.debug('getFileContent -> Entering Fuction: ' + file.filePath) + + try { + + let storage = require('../../storage/providers/AzureStorage') // Default value + if (process.env.STORAGE_PROVIDER === 'Minio') { + storage = require('../storage/providers/MinioStorage') + } + + return storage.getFileContentRemote(file.container, file.filePath, file.storage, file.accessKey) + + } catch (err) { + logger.error('getFileContent -> Error: %s', err.stack) + throw err + } +} + +const query = { + fileContent: { + type: GraphQLString, + args, + resolve, + } +} + +export default query diff --git a/src/schema/queries/Teams.js b/src/schema/queries/Teams.js deleted file mode 100644 index 2c278e453..000000000 --- a/src/schema/queries/Teams.js +++ /dev/null @@ -1,21 +0,0 @@ -import { GraphQLList } from 'graphql'; -import { TeamType } from '../types'; -import { Ecosystem } from '../../models'; -import logger from '../../utils/logger' - -const args = {}; - -const resolve = (parent, args, context) => { - logger.debug('Listing teams.') - -} - -const query = { - teams: { - type: new GraphQLList(TeamType), - args, - resolve, - }, -}; - -export default query; diff --git a/src/schema/queries/index.js b/src/schema/queries/index.js index 5483b5df6..1a9a0fbf6 100644 --- a/src/schema/queries/index.js +++ b/src/schema/queries/index.js @@ -2,12 +2,14 @@ import { GraphQLObjectType, } from 'graphql'; -import TeamsQuery from './Teams'; +import EcosystemQuery from './Ecosystem'; +import FileContentQuery from './FileContent'; const RootQuery = new GraphQLObjectType({ name: 'RootQueryType', fields: Object.assign( - TeamsQuery + EcosystemQuery, + FileContentQuery ), }); diff --git a/src/schema/types/Bot.js b/src/schema/types/Bot.js index 7e02f2e38..6701c467e 100644 --- a/src/schema/types/Bot.js +++ b/src/schema/types/Bot.js @@ -6,6 +6,8 @@ import { const BotType = new GraphQLObjectType({ name: 'Bot', fields: () => ({ + codeName: { type: GraphQLString }, + displayName: { type: GraphQLString }, repo: { type: GraphQLString }, configFile: { type: GraphQLString } }), diff --git a/src/schema/types/Ecosystem.js b/src/schema/types/Ecosystem.js index 828361682..d31cbbde2 100644 --- a/src/schema/types/Ecosystem.js +++ b/src/schema/types/Ecosystem.js @@ -1,7 +1,8 @@ import { GraphQLObjectType, GraphQLString, - GraphQLID + GraphQLID, + GraphQLList } from 'graphql'; import { TeamType, EventHostType } from './index'; diff --git a/src/schema/types/EventHost.js b/src/schema/types/EventHost.js index 91e2c7533..571bab36e 100644 --- a/src/schema/types/EventHost.js +++ b/src/schema/types/EventHost.js @@ -1,6 +1,7 @@ import { GraphQLObjectType, - GraphQLString + GraphQLString, + GraphQLList } from 'graphql'; import { BotType } from './index'; 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 index 4c31de9e7..fbc45bcd1 100644 --- a/src/schema/types/Host.js +++ b/src/schema/types/Host.js @@ -7,6 +7,7 @@ const HostType = new GraphQLObjectType({ name: 'Host', fields: () => ({ url: { type: GraphQLString }, + storage: { type: GraphQLString }, container: { type: GraphQLString }, accessKey: { type: GraphQLString } }), diff --git a/src/schema/types/index.js b/src/schema/types/index.js index 8f8f70ce1..17d90c59a 100644 --- a/src/schema/types/index.js +++ b/src/schema/types/index.js @@ -2,10 +2,14 @@ import TeamType from './Team'; import BotType from './Bot'; import EventHostType from './EventHost'; import HostType from './Host'; +import EcosystemType from './Ecosystem'; +import FileType from './File'; export { TeamType, BotType, EventHostType, - HostType + HostType, + EcosystemType, + FileType }; diff --git a/src/schema/types/input/Bot.js b/src/schema/types/input/Bot.js index 75f10ebde..dfbadf5fb 100644 --- a/src/schema/types/input/Bot.js +++ b/src/schema/types/input/Bot.js @@ -1,12 +1,15 @@ import { GraphQLInputObjectType, - GraphQLString + GraphQLString, + GraphQLNonNull } from 'graphql'; const Type = new GraphQLInputObjectType({ name: 'BotInput', description: 'Payload for bot input.', fields: () => ({ + codeName: { type: new GraphQLNonNull(GraphQLString) }, + displayName: { type: new GraphQLNonNull(GraphQLString) }, repo: { type: GraphQLString }, configFile: { type: GraphQLString } }), diff --git a/src/schema/types/input/File.js b/src/schema/types/input/File.js new file mode 100644 index 000000000..d92d4c6f0 --- /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: new GraphQLNonNull(GraphQLString) }, + fileContent: { type: GraphQLString } + }), +}); + +export default Type; diff --git a/src/schema/types/input/Host.js b/src/schema/types/input/Host.js index 9574ce095..6f9d4bb5f 100644 --- a/src/schema/types/input/Host.js +++ b/src/schema/types/input/Host.js @@ -8,6 +8,7 @@ const Type = new GraphQLInputObjectType({ description: 'Payload for host input.', fields: () => ({ url: { type: GraphQLString }, + storage: { type: GraphQLString }, container: { type: GraphQLString }, accessKey: { type: GraphQLString } }), diff --git a/src/schema/types/input/Team.js b/src/schema/types/input/Team.js index 878dca112..37f49a33c 100644 --- a/src/schema/types/input/Team.js +++ b/src/schema/types/input/Team.js @@ -14,8 +14,8 @@ const Type = new GraphQLInputObjectType({ codeName: { type: new GraphQLNonNull(GraphQLString) }, displayName: { type: new GraphQLNonNull(GraphQLString) }, host: { type: HostInputType }, - bots: { type: new GraphQLNonNull(new GraphQLList(BotInputType)) }, - plotters: { type: new GraphQLList(BotInputType) } + bot: { type: new GraphQLNonNull(BotInputType) }, + plotter: { type: BotInputType } }), }); diff --git a/src/schema/types/input/index.js b/src/schema/types/input/index.js index bee4b6f16..ec822c308 100644 --- a/src/schema/types/input/index.js +++ b/src/schema/types/input/index.js @@ -1,9 +1,11 @@ import TeamInputType from './Team' import BotInputType from './Bot' import HostInputType from './Host' +import FileInputType from './File' export { TeamInputType, BotInputType, - HostInputType + HostInputType, + FileInputType }; diff --git a/src/storage/CopyBot.js b/src/storage/CopyBot.js new file mode 100644 index 000000000..357f1c493 --- /dev/null +++ b/src/storage/CopyBot.js @@ -0,0 +1,60 @@ +import beautify from 'json-beautify' +import logger from '../utils/logger' + +export const copyBot = async (storage, teamCodeName, botCodeName, botDisplayName) => { + try { + logger.debug('copyBot started for bot %s', botCodeName) + + let containerName = 'aavikings' + let templatePath = 'AAVikings/bots/blumblebee-Trading-Bot' + let config = await storage.getFileContent(containerName, templatePath + '/this.bot.config.json') + let code = await storage.getFileContent(containerName, templatePath + '/Trading-Process/User.Bot.js') + + // 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 + + // Write the new files + let newBotPath = teamCodeName + '/bots/' + botCodeName + '-Trading-Bot' + await storage.writeFileContent(teamCodeName, newBotPath + '/this.bot.config.json', beautify(parsedConfig, null, 2, 80)) + await storage.writeFileContent(teamCodeName, newBotPath + '/Trading-Bot/User.Bot.js', code) + + logger.debug('copyBot completed for bot %s', botCodeName) + + } catch (err) { + logger.error('copyBot error for bot: %s. %s', botCodeName, err) + throw err + } +} + +export const removeBot = async (storage, teamCodeName, botCodeName) => { + try { + logger.debug('removeBot started for bot %s', botCodeName) + + // Delete bot code + let newBotPath = teamCodeName + '/bots/' + 'bot-' + botCodeName + await storage.deleteBlob(teamCodeName, newBotPath + '/this.bot.config.json') + await storage.deleteBlob(teamCodeName, newBotPath + '/Trading-Bot/User.Bot.js') + + logger.debug('removeBot completed for bot %s', botCodeName) + + } 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..ca2466891 --- /dev/null +++ b/src/storage/CopySimulator.js @@ -0,0 +1,83 @@ +import beautify from 'json-beautify' +import logger from '../utils/logger' + +export const copySimulator = async (storage, teamCodeName, botCodeName, botDisplayName) => { + try { + logger.debug('copySimulator started for bot %s', 'simulator-' + botCodeName) + + let containerName = 'aamasters' + let templatePath = 'AAMasters/bots/AAJason-Indicator-Bot' + let commons = await storage.getFileContent(containerName, templatePath + '/Commons.js') + let config = await storage.getFileContent(containerName, templatePath + '/this.bot.config.json') + let codeDaily = await storage.getFileContent(containerName, templatePath + '/Multi-Period-Daily/User.Bot.js') + let codeMarket = await storage.getFileContent(containerName, templatePath + '/Multi-Period-Market/User.Bot.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 = 'simulator-' + newBotCodeName + '-Indicator-Bot' + let newSimulatorPath = teamCodeName + '/bots/' + newSimulatorName + await storage.writeFileContent(teamCodeName, newSimulatorPath + '/Commons.js', commons) + await storage.writeFileContent(teamCodeName, newSimulatorPath + '/this.bot.config.json', beautify(parsedConfig, null, 2, 80)) + await storage.writeFileContent(teamCodeName, newSimulatorPath + '/Multi-Period-Daily/User.Bot.js', codeDaily) + await storage.writeFileContent(teamCodeName, newSimulatorPath + '/Multi-Period-Market/User.Bot.js', codeMarket) + + logger.debug('copySimulator completed for bot %s', newBotCodeName) + + } 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/CreateTeam.js b/src/storage/CreateTeam.js new file mode 100644 index 000000000..a2833250d --- /dev/null +++ b/src/storage/CreateTeam.js @@ -0,0 +1,27 @@ +import logger from '../utils/logger' +import { copyBot } from './CopyBot' +import { copySimulator } from './CopySimulator' + +export const createTeam = async (team) => { + try { + logger.debug('createTeam started for team %s', team.codeName) + + let storage = require ('./providers/AzureStorage') // Default value + if (process.env.STORAGE_PROVIDER === 'Minio') { + storage = require ('./providers/MinioStorage') + } + + let containerName = team.codeName + await storage.createContainer(containerName) + let accessKey = storage.createPrivateAccessKey(containerName, "WRITE", 365) + + await copyBot(storage, team.codeName, team.bot.codeName, team.bot.displayName) + await copySimulator(storage, team.codeName, team.bot.codeName, team.bot.displayName) + + return accessKey + + } catch (err) { + logger.error('createTeam error for teamCodeName: %s, error: %s', team.bot.codeName, err.stack) + throw err + } +} diff --git a/src/storage/DeleteTeam.js b/src/storage/DeleteTeam.js new file mode 100644 index 000000000..1f984d634 --- /dev/null +++ b/src/storage/DeleteTeam.js @@ -0,0 +1,18 @@ +import logger from '../utils/logger' + +export const deleteTeam = async (team) => { + try { + logger.debug('deleteTeam started for team %s', team.codeName) + + let storage = require ('./providers/AzureStorage') // Default value + if (process.env.STORAGE_PROVIDER === 'Minio') { + storage = require ('./providers/MinioStorage') + } + + await storage.deleteContainer(team.codeName) + + } catch (err) { + logger.error('deleteTeam error for teamCodeName: %s, error: %s', team.codeName, err.stack) + throw err + } +} diff --git a/src/storage/AzureStorage.js b/src/storage/providers/AzureStorage.js similarity index 51% rename from src/storage/AzureStorage.js rename to src/storage/providers/AzureStorage.js index ea2d49c07..0992f7efb 100644 --- a/src/storage/AzureStorage.js +++ b/src/storage/providers/AzureStorage.js @@ -1,37 +1,49 @@ -import logger from '../utils/logger' -const { +import logger from '../../utils/logger' +import { Aborter, BlobURL, BlockBlobURL, ContainerURL, ServiceURL, StorageURL, - SharedKeyCredential -} = require("@azure/storage-blob") + SharedKeyCredential, + AnonymousCredential +} from '@azure/storage-blob' const AzureServiceURL = () => { - // Enter your storage account name and shared key - const account = process.env.STORAGE_BASE_URL; - const accountKey = process.env.STORAGE_CONNECTION_STRING; - // Use SharedKeyCredential with storage account and account key - const sharedKeyCredential = new SharedKeyCredential(account, accountKey); + const sharedKeyCredential = new SharedKeyCredential(process.env.STORAGE_BASE_URL, process.env.STORAGE_CONNECTION_STRING); // Use sharedKeyCredential, tokenCredential or anonymousCredential to create a pipeline - const pipeline = StorageURL.newPipeline(sharedKeyCredential); + 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://${account}.blob.core.windows.net`, + `https://${process.env.STORAGE_BASE_URL}.blob.core.windows.net`, pipeline - ); - logger.info("Connected to te file Storage.") + ) return serviceURL } const serviceURL = AzureServiceURL() +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(serviceURL, containerName) const blockBlobURL = BlockBlobURL.fromContainerURL(containerURL, blobName) @@ -76,12 +88,52 @@ export const createContainer = async (containerName) => { async function streamToString(readableStream) { return new Promise((resolve, reject) => { const chunks = []; - readableStream.on("data", data => { + readableStream.on('data', data => { chunks.push(data.toString()); }); - readableStream.on("end", () => { - resolve(chunks.join("")); + readableStream.on('end', () => { + resolve(chunks.join('')); }); - readableStream.on("error", reject) + readableStream.on('error', reject) }); } + +export const createPrivateAccessKey = (container, type, days) => { + let azure = require('azure-storage'); + let blobService = azure.createBlobService(process.env.AZURE_STORAGE_CONNECTION_STRING); + + let startDate = new Date(); + startDate.setDate(startDate.getDate() - 1); + + let expiryDate = new Date(startDate); + expiryDate.setDate(startDate.getDate() + days); + + let azurePermissions; + + switch (type) { + case 'READ': { + azurePermissions = azure.BlobUtilities.SharedAccessPermissions.READ; + break; + } + case 'WRITE': { + azurePermissions = azure.BlobUtilities.SharedAccessPermissions.WRITE; + break; + } + case 'DELETE': { + azurePermissions = azure.BlobUtilities.SharedAccessPermissions.DELETE; + break; + } + } + + let blobName = undefined; + + let sharedAccessPolicy = { + AccessPolicy: { + Permissions: azurePermissions, + Start: startDate, + Expiry: expiryDate + } + }; + + return blobService.generateSharedAccessSignature(container, blobName, sharedAccessPolicy); +} diff --git a/src/utils/logger.js b/src/utils/logger.js index 9ef06e941..3932769cc 100644 --- a/src/utils/logger.js +++ b/src/utils/logger.js @@ -13,7 +13,7 @@ const options = { timestamp: true }, console: { - level: 'debug', + level: process.env.LOG_LEVEL || 'debug', handleExceptions: true, json: false, colorize: true, @@ -32,7 +32,7 @@ const logger = createLogger({ ) ), transports: [ - new transports.File(options.file), + // new transports.File(options.file), new transports.Console(options.console) ], exitOnError: false // do not exit on handled exceptions From 7f5b093de0bec372bca00206528aa2a68a848000 Mon Sep 17 00:00:00 2001 From: Matias Date: Mon, 27 May 2019 13:48:51 -0300 Subject: [PATCH 3/4] Progress pre master app --- src/models/ecosystem.js | 204 ++++++++++++++++++++++++++- src/schema/mutations/AddTeam.js | 25 +++- src/schema/mutations/DeleteTeam.js | 6 +- src/schema/types/Bot.js | 14 +- src/schema/types/Competition.js | 32 +++++ src/schema/types/DataRange.js | 14 ++ src/schema/types/DataSet.js | 21 +++ src/schema/types/Ecosystem.js | 4 +- src/schema/types/EventHost.js | 17 ++- src/schema/types/Exchange.js | 13 ++ src/schema/types/Module.js | 25 ++++ src/schema/types/Panel.js | 15 ++ src/schema/types/Plotter.js | 26 ++++ src/schema/types/PlotterReference.js | 17 +++ src/schema/types/Product.js | 31 ++++ src/schema/types/Team.js | 6 +- src/schema/types/index.js | 20 ++- 17 files changed, 464 insertions(+), 26 deletions(-) create mode 100644 src/schema/types/Competition.js create mode 100644 src/schema/types/DataRange.js create mode 100644 src/schema/types/DataSet.js create mode 100644 src/schema/types/Exchange.js create mode 100644 src/schema/types/Module.js create mode 100644 src/schema/types/Panel.js create mode 100644 src/schema/types/Plotter.js create mode 100644 src/schema/types/PlotterReference.js create mode 100644 src/schema/types/Product.js diff --git a/src/models/ecosystem.js b/src/models/ecosystem.js index 5856d8f19..36ce90642 100644 --- a/src/models/ecosystem.js +++ b/src/models/ecosystem.js @@ -6,7 +6,7 @@ const ecosystemSchema = new Schema({ type: String, required: true }, - teams: [{ + devTeams: [{ codeName: { type: String, required: true @@ -15,7 +15,7 @@ const ecosystemSchema = new Schema({ type: String, required: true }, - host:{ + host: { url: { type: String, required: true @@ -42,6 +42,10 @@ const ecosystemSchema = new Schema({ type: String, required: true }, + type: { + type: String, + required: false + }, repo: { type: String, required: false @@ -49,9 +53,115 @@ const ecosystemSchema = new Schema({ configFile: { 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 @@ -71,7 +181,7 @@ const ecosystemSchema = new Schema({ type: String, required: true }, - host:{ + host: { url: { type: String, required: true @@ -90,6 +200,52 @@ const ecosystemSchema = new Schema({ } }, 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: { + codeName: { + type: String, + required: false + }, + host: { + type: String, + required: false + }, + repo: { + type: String, + required: true + }, + moduleName: { + type: String, + required: true + }, + }, + participants: [{ + type: String, + required: false + }], repo: { type: String, required: true @@ -100,6 +256,46 @@ const ecosystemSchema = new Schema({ } }], 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 diff --git a/src/schema/mutations/AddTeam.js b/src/schema/mutations/AddTeam.js index 44e6402d0..87e339e94 100644 --- a/src/schema/mutations/AddTeam.js +++ b/src/schema/mutations/AddTeam.js @@ -27,8 +27,8 @@ const resolve = async (parent, { team }, context) => { userEcosystem.authId = context.userId } - for (let i = 0; i < userEcosystem.teams.length; i++) { - const auxTeam = userEcosystem.teams[i]; + 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.") } @@ -44,11 +44,26 @@ const resolve = async (parent, { team }, context) => { team.host = nodeEndpoint } - let bots= [] - bots.push(team.bot) + let bots = [] + let tradingBot = { + codeName: team.bot.codeName, + displayName: team.bot.displayName, + repo: team.bot.codeName + '-Trading-Bot', + configFile: 'this.bot.config.json' + } + bots.push(tradingBot) + + let simulatorBot = { + codeName: 'simulator-' + team.bot.codeName, + displayName: 'Simulator ' + team.bot.displayName, + repo: 'simulator-' + team.bot.codeName + '-Indicator-Bot', + configFile: 'this.bot.config.json' + } + bots.push(simulatorBot) + team.bots = bots - userEcosystem.teams.push(team) + userEcosystem.devTeams.push(team) await userEcosystem.save() return team } catch (err) { diff --git a/src/schema/mutations/DeleteTeam.js b/src/schema/mutations/DeleteTeam.js index 85f4c403a..dd4061919 100644 --- a/src/schema/mutations/DeleteTeam.js +++ b/src/schema/mutations/DeleteTeam.js @@ -25,13 +25,13 @@ const resolve = async (parent, { team }, context) => { } let teamFound = false - for (let i = 0; i < userEcosystem.teams.length; i++) { - const auxTeam = userEcosystem.teams[i] + 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 deleteTeam(team) - userEcosystem.teams.splice(i, 1) + userEcosystem.devTeams.splice(i, 1) await userEcosystem.save() break } diff --git a/src/schema/types/Bot.js b/src/schema/types/Bot.js index 6701c467e..f983f1129 100644 --- a/src/schema/types/Bot.js +++ b/src/schema/types/Bot.js @@ -1,15 +1,25 @@ import { GraphQLObjectType, - GraphQLString + GraphQLString, + GraphQLList } from 'graphql'; +import { ProductType } from './index' + const BotType = new GraphQLObjectType({ name: 'Bot', fields: () => ({ codeName: { type: GraphQLString }, displayName: { type: GraphQLString }, + type: { type: GraphQLString }, repo: { type: GraphQLString }, - configFile: { type: GraphQLString } + configFile: { type: GraphQLString }, + products: { + type: new GraphQLList(ProductType), + resolve(parent) { + return parent.products; + } + }, }), }); 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 index d31cbbde2..8fabc5847 100644 --- a/src/schema/types/Ecosystem.js +++ b/src/schema/types/Ecosystem.js @@ -13,10 +13,10 @@ const EcosystemType = new GraphQLObjectType({ id: { type: GraphQLID }, authId: { type: GraphQLString }, userName: { type: GraphQLString }, // TODO this field is temporary, it should be used the user module query - teams: { + devTeams: { type: new GraphQLList(TeamType), resolve(parent) { - return parent.teams; + return parent.devTeams; } }, hosts: { diff --git a/src/schema/types/EventHost.js b/src/schema/types/EventHost.js index 571bab36e..c951dabba 100644 --- a/src/schema/types/EventHost.js +++ b/src/schema/types/EventHost.js @@ -4,26 +4,31 @@ import { GraphQLList } from 'graphql'; -import { BotType } from './index'; +import { CompetitionType, PlotterType, HostType } from './index'; const EventHostType = new GraphQLObjectType({ name: 'EventHost', fields: () => ({ codeName: { type: GraphQLString }, displayName: { type: GraphQLString }, - host: { type: GraphQLString }, + host: { + type: HostType, + resolve(parent) { + return parent.host; + } + }, container: { type: GraphQLString }, accessKey: { type: GraphQLString }, competitions: { - type: new GraphQLList(BotType), + type: new GraphQLList(CompetitionType), resolve(parent) { - return parent.bots; + return parent.competitions; } }, plotters: { - type: new GraphQLList(BotType), + type: new GraphQLList(PlotterType), resolve(parent) { - return parent.bots; + return parent.plotters; } } }), 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/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..1c6007032 --- /dev/null +++ b/src/schema/types/PlotterReference.js @@ -0,0 +1,17 @@ +import { + GraphQLObjectType, + GraphQLString +} from 'graphql'; + +const PlotterReferenceType = new GraphQLObjectType({ + name: 'PlotterReference', + fields: () => ({ + codeName: { type: GraphQLString }, + host: { type: GraphQLString }, + devTeam: { type: GraphQLString }, + 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 index e39d0aa5b..00607f192 100644 --- a/src/schema/types/Team.js +++ b/src/schema/types/Team.js @@ -4,7 +4,7 @@ import { GraphQLList } from 'graphql'; -import { BotType, HostType } from './index'; +import { BotType, PlotterType, HostType } from './index'; const TeamType = new GraphQLObjectType({ name: 'Team', @@ -24,9 +24,9 @@ const TeamType = new GraphQLObjectType({ } }, plotters: { - type: new GraphQLList(BotType), + type: new GraphQLList(PlotterType), resolve(parent) { - return parent.bots; + return parent.plotters; } } }), diff --git a/src/schema/types/index.js b/src/schema/types/index.js index 17d90c59a..31708e9b2 100644 --- a/src/schema/types/index.js +++ b/src/schema/types/index.js @@ -4,6 +4,15 @@ 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, @@ -11,5 +20,14 @@ export { EventHostType, HostType, EcosystemType, - FileType + FileType, + PanelType, + ModuleType, + PlotterType, + CompetitionType, + PlotterReferenceType, + ProductType, + DataSetType, + DataRangeType, + ExchangeType }; From 2c588cba717cf5e1afbf71afea01a29fb0068d91 Mon Sep 17 00:00:00 2001 From: Matias Date: Wed, 29 May 2019 11:29:37 -0300 Subject: [PATCH 4/4] Adding stable version --- src/config/ecosystem.json | 886 +++++++++++++++++++++++++++ src/models/ecosystem.js | 30 +- src/schema/mutations/AddTeam.js | 36 +- src/schema/mutations/DeleteTeam.js | 6 +- src/schema/queries/Ecosystem.js | 2 +- src/schema/queries/FileContent.js | 20 +- src/schema/types/Bot.js | 1 + src/schema/types/PlotterReference.js | 11 +- src/schema/types/input/DeleteTeam.js | 18 + src/schema/types/input/Team.js | 3 +- src/schema/types/input/index.js | 6 +- src/storage/CopyBot.js | 2 +- src/storage/CopyBots.js | 22 + src/storage/CopySimulator.js | 2 +- src/storage/CreateTeam.js | 27 - 15 files changed, 1005 insertions(+), 67 deletions(-) create mode 100644 src/config/ecosystem.json create mode 100644 src/schema/types/input/DeleteTeam.js create mode 100644 src/storage/CopyBots.js delete mode 100644 src/storage/CreateTeam.js diff --git a/src/config/ecosystem.json b/src/config/ecosystem.json new file mode 100644 index 000000000..1c76887be --- /dev/null +++ b/src/config/ecosystem.json @@ -0,0 +1,886 @@ +{ + "authId": "", + "devTeams": [ + { + "codeName": "AAMasters", + "displayName": "Masters", + "host": { + "url": "http://localhost:4100/", + "storage": "https://aadevelop.blob.core.windows.net", + "container": "aamasters", + "accessKey": "?st=2019-05-21T12%3A00%3A00Z&se=2020-05-22T12%3A00%3A00Z&sp=rl&sv=2018-03-28&sr=c&sig=PsGM67klPfLjdfjymziEQEQcD5Wzy3SMcZWsTCQrhd8%3D" + }, + "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": [] + } + ], + "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": "http://localhost:4100/", + "container": "aavikings", + "storage": "https://aadevelop.blob.core.windows.net", + "accessKey": "?st=2019-05-20T12%3A00%3A00Z&se=2020-05-21T12%3A00%3A00Z&sp=rl&sv=2018-03-28&sr=c&sig=hJuV9aEP4KVZo5z54FEF1BQtkbksfwkTJFv1FYkHFRg%3D" + }, + "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": "http://localhost:4100/", + "storage": "https://aadevelop.blob.core.windows.net", + "container": "aaplatform", + "accessKey": "?sv=2018-03-28&ss=b&srt=co&sp=rw&se=2020-01-04T00:00:00Z&st=2019-01-08T11:25:04Z&spr=https&sig=xZU1PO%2BdtVilqlZp%2BVRWW55LYl8oGZU7x4JnP%2BhMc%2FY%3D" + }, + "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": "http://localhost:4100/", + "storage": "https://aadevelop.blob.core.windows.net", + "container": "aamasters", + "accessKey": "?st=2019-05-21T12%3A00%3A00Z&se=2020-05-22T12%3A00%3A00Z&sp=rl&sv=2018-03-28&sr=c&sig=PsGM67klPfLjdfjymziEQEQcD5Wzy3SMcZWsTCQrhd8%3D" + }, + "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/models/ecosystem.js b/src/models/ecosystem.js index 36ce90642..827a3ae42 100644 --- a/src/models/ecosystem.js +++ b/src/models/ecosystem.js @@ -44,7 +44,11 @@ const ecosystemSchema = new Schema({ }, type: { type: String, - required: false + required: true + }, + profilePicture: { + type: String, + required: true }, repo: { type: String, @@ -225,13 +229,31 @@ const ecosystemSchema = new Schema({ required: false }, plotter: { + devTeam: { + type: String, + required: true + }, codeName: { type: String, - required: false + required: true }, host: { - type: String, - required: false + url: { + type: String, + required: true + }, + storage: { + type: String, + required: true + }, + container: { + type: String, + required: true + }, + accessKey: { + type: String, + required: true + } }, repo: { type: String, diff --git a/src/schema/mutations/AddTeam.js b/src/schema/mutations/AddTeam.js index 87e339e94..81030d41f 100644 --- a/src/schema/mutations/AddTeam.js +++ b/src/schema/mutations/AddTeam.js @@ -3,12 +3,12 @@ import { AuthenticationError, WrongArgumentsError } from '../../errors' import { TeamType } from '../types' import { Ecosystem } from '../../models' import { TeamInputType } from '../types/input' -import { createTeam } from '../../storage/CreateTeam' +import { copyBots } from '../../storage/CopyBots' export const args = { team: { type: TeamInputType } } const resolve = async (parent, { team }, context) => { - logger.debug('addTeam -> Entering Fuction.') + logger.debug('addTeam -> Entering Function.') if (!context.userId) { throw new AuthenticationError() @@ -34,35 +34,27 @@ const resolve = async (parent, { team }, context) => { } } - let accessKey = await createTeam(team) + let storage = require ('../../storage/providers/AzureStorage') // Default value + if (process.env.STORAGE_PROVIDER === 'Minio') { + storage = require ('../../storage/providers/MinioStorage') + } + + let containerName = team.codeName + await storage.createContainer(containerName) + let accessKey = storage.createPrivateAccessKey(containerName, "WRITE", 365) + + let botsConfigurations = await copyBots(storage, team) + team.bots = botsConfigurations if (!team.host) { let nodeEndpoint = { url: process.env.SUPERALGOS_NODE_ENDPOINT, + storage: process.env.STORAGE_URL, container: team.codeName, accessKey: accessKey, } team.host = nodeEndpoint } - let bots = [] - let tradingBot = { - codeName: team.bot.codeName, - displayName: team.bot.displayName, - repo: team.bot.codeName + '-Trading-Bot', - configFile: 'this.bot.config.json' - } - bots.push(tradingBot) - - let simulatorBot = { - codeName: 'simulator-' + team.bot.codeName, - displayName: 'Simulator ' + team.bot.displayName, - repo: 'simulator-' + team.bot.codeName + '-Indicator-Bot', - configFile: 'this.bot.config.json' - } - bots.push(simulatorBot) - - team.bots = bots - userEcosystem.devTeams.push(team) await userEcosystem.save() return team diff --git a/src/schema/mutations/DeleteTeam.js b/src/schema/mutations/DeleteTeam.js index dd4061919..9e8ee3626 100644 --- a/src/schema/mutations/DeleteTeam.js +++ b/src/schema/mutations/DeleteTeam.js @@ -2,13 +2,13 @@ import logger from '../../utils/logger' import { AuthenticationError, WrongArgumentsError } from '../../errors' import { TeamType } from '../types' import { Ecosystem } from '../../models' -import { TeamInputType } from '../types/input' +import { DeleteTeamInputType } from '../types/input' import { deleteTeam } from '../../storage/DeleteTeam' -export const args = { team: { type: TeamInputType } } +export const args = { team: { type: DeleteTeamInputType } } const resolve = async (parent, { team }, context) => { - logger.debug('deleteTeam -> Entering Fuction.') + logger.debug('deleteTeam -> Entering Function.') if (!context.userId) { throw new AuthenticationError() diff --git a/src/schema/queries/Ecosystem.js b/src/schema/queries/Ecosystem.js index ca55b7fce..d6eeafb6f 100644 --- a/src/schema/queries/Ecosystem.js +++ b/src/schema/queries/Ecosystem.js @@ -5,7 +5,7 @@ import { EcosystemType } from '../types' const args = {} const resolve = async (parent, args, context) => { - logger.debug('getEcosystem -> Entering Fuction.') + logger.debug('getEcosystem -> Entering Function.') try { if (!context.userId) { diff --git a/src/schema/queries/FileContent.js b/src/schema/queries/FileContent.js index 910fa8df5..0c5ce7515 100644 --- a/src/schema/queries/FileContent.js +++ b/src/schema/queries/FileContent.js @@ -5,7 +5,7 @@ import { GraphQLString } from 'graphql' export const args = { file: { type: FileInputType } } const resolve = async (parent, { file }, context) => { - logger.debug('getFileContent -> Entering Fuction: ' + file.filePath) + logger.debug('getFileContent -> Entering Function: ' + file.filePath) try { @@ -14,7 +14,23 @@ const resolve = async (parent, { file }, context) => { storage = require('../storage/providers/MinioStorage') } - return storage.getFileContentRemote(file.container, file.filePath, file.storage, file.accessKey) + //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." + } + + let fileContent = await storage.getFileContentRemote(file.container, file.filePath, file.storage, file.accessKey) + return fileContent } catch (err) { logger.error('getFileContent -> Error: %s', err.stack) diff --git a/src/schema/types/Bot.js b/src/schema/types/Bot.js index f983f1129..9ce0405ab 100644 --- a/src/schema/types/Bot.js +++ b/src/schema/types/Bot.js @@ -12,6 +12,7 @@ const BotType = new GraphQLObjectType({ codeName: { type: GraphQLString }, displayName: { type: GraphQLString }, type: { type: GraphQLString }, + profilePicture: { type: GraphQLString }, repo: { type: GraphQLString }, configFile: { type: GraphQLString }, products: { diff --git a/src/schema/types/PlotterReference.js b/src/schema/types/PlotterReference.js index 1c6007032..06baa44f0 100644 --- a/src/schema/types/PlotterReference.js +++ b/src/schema/types/PlotterReference.js @@ -3,12 +3,19 @@ import { GraphQLString } from 'graphql'; +import { HostType } from './index'; + const PlotterReferenceType = new GraphQLObjectType({ name: 'PlotterReference', fields: () => ({ - codeName: { type: GraphQLString }, - host: { type: GraphQLString }, devTeam: { type: GraphQLString }, + codeName: { type: GraphQLString }, + host: { + type: HostType, + resolve(parent) { + return parent.host; + } + }, moduleName: { type: GraphQLString }, repo: { type: GraphQLString } }), 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/Team.js b/src/schema/types/input/Team.js index 37f49a33c..c4423a55a 100644 --- a/src/schema/types/input/Team.js +++ b/src/schema/types/input/Team.js @@ -1,8 +1,7 @@ import { GraphQLString, GraphQLInputObjectType, - GraphQLNonNull, - GraphQLList + GraphQLNonNull } from 'graphql'; import { BotInputType, HostInputType } from './index'; diff --git a/src/schema/types/input/index.js b/src/schema/types/input/index.js index ec822c308..2e3d3dd55 100644 --- a/src/schema/types/input/index.js +++ b/src/schema/types/input/index.js @@ -2,10 +2,12 @@ import TeamInputType from './Team' import BotInputType from './Bot' import HostInputType from './Host' import FileInputType from './File' +import DeleteTeamInputType from './DeleteTeam' export { TeamInputType, BotInputType, HostInputType, - FileInputType -}; + FileInputType, + DeleteTeamInputType +} diff --git a/src/storage/CopyBot.js b/src/storage/CopyBot.js index 357f1c493..309bb8808 100644 --- a/src/storage/CopyBot.js +++ b/src/storage/CopyBot.js @@ -35,7 +35,7 @@ export const copyBot = async (storage, teamCodeName, botCodeName, botDisplayName await storage.writeFileContent(teamCodeName, newBotPath + '/Trading-Bot/User.Bot.js', code) logger.debug('copyBot completed for bot %s', botCodeName) - + return parsedConfig } catch (err) { logger.error('copyBot error for bot: %s. %s', botCodeName, err) throw err diff --git a/src/storage/CopyBots.js b/src/storage/CopyBots.js new file mode 100644 index 000000000..ede1b352b --- /dev/null +++ b/src/storage/CopyBots.js @@ -0,0 +1,22 @@ +import logger from '../utils/logger' +import { copyBot } from './CopyBot' +import { copySimulator } from './CopySimulator' + +export const copyBots = async (storage, team) => { + try { + logger.debug('copyBots started for team %s', team.codeName) + let bots = [] + + let tradingBot = await copyBot(storage, team.codeName, team.bot.codeName, team.bot.displayName) + bots.push(tradingBot) + + let simulatorBot = await copySimulator(storage, team.codeName, team.bot.codeName, team.bot.displayName) + bots.push(simulatorBot) + + return bots + + } catch (err) { + logger.error('copyBots error for teamCodeName: %s, error: %s', team.bot.codeName, err.stack) + throw err + } +} diff --git a/src/storage/CopySimulator.js b/src/storage/CopySimulator.js index ca2466891..1931ee9df 100644 --- a/src/storage/CopySimulator.js +++ b/src/storage/CopySimulator.js @@ -55,7 +55,7 @@ export const copySimulator = async (storage, teamCodeName, botCodeName, botDispl await storage.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 diff --git a/src/storage/CreateTeam.js b/src/storage/CreateTeam.js deleted file mode 100644 index a2833250d..000000000 --- a/src/storage/CreateTeam.js +++ /dev/null @@ -1,27 +0,0 @@ -import logger from '../utils/logger' -import { copyBot } from './CopyBot' -import { copySimulator } from './CopySimulator' - -export const createTeam = async (team) => { - try { - logger.debug('createTeam started for team %s', team.codeName) - - let storage = require ('./providers/AzureStorage') // Default value - if (process.env.STORAGE_PROVIDER === 'Minio') { - storage = require ('./providers/MinioStorage') - } - - let containerName = team.codeName - await storage.createContainer(containerName) - let accessKey = storage.createPrivateAccessKey(containerName, "WRITE", 365) - - await copyBot(storage, team.codeName, team.bot.codeName, team.bot.displayName) - await copySimulator(storage, team.codeName, team.bot.codeName, team.bot.displayName) - - return accessKey - - } catch (err) { - logger.error('createTeam error for teamCodeName: %s, error: %s', team.bot.codeName, err.stack) - throw err - } -}