diff --git a/.gitattributes b/.gitattributes index 642db914..5b03d703 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ *.js linguist-detectable=false +*.ts linguist-detectable=false diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..77b37102 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,4 @@ +# These are supported funding model platforms + +github: postgres-ai +patreon: Database_Lab # Replace with a single Patreon username diff --git a/.gitignore b/.gitignore index 44a297f5..8719d1d4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .DS_Store .idea/ +.env engine/bin/ /db-lab-run/ @@ -11,4 +12,7 @@ engine/bin/ /engine/configs/server.yml /engine/configs/run_ci.yaml /engine/configs/ci_checker.yml -/packer/example.com.key + +engine/meta + +ui/packages/shared/dist/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4c8aef61..da8a843d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,4 @@ variables: - SAST_EXCLUDED_ANALYZERS: "semgrep-sast,gosec-sast" DOCKER_DRIVER: overlay2 workflow: diff --git a/.gitlab/agents/k8s-cluster-1/config.yaml b/.gitlab/agents/k8s-cluster-1/config.yaml new file mode 100644 index 00000000..73481f44 --- /dev/null +++ b/.gitlab/agents/k8s-cluster-1/config.yaml @@ -0,0 +1,3 @@ +ci_access: + projects: + - id: postgres-ai/database-lab diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 00000000..a4267581 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,23 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Build/Test/Lint Commands +- Build all components: `cd engine && make build` +- Lint code: `cd engine && make lint` +- Run unit tests: `cd engine && make test` +- Run integration tests: `cd engine && make test-ci-integration` +- Run a specific test: `cd engine && GO111MODULE=on go test -v ./path/to/package -run TestName` +- Run UI: `cd ui && pnpm start:ce` (Community Edition) or `pnpm start:platform` + +## Code Style Guidelines +- Go code follows "Effective Go" and "Go Code Review Comments" guidelines +- Use present tense and imperative mood in commit messages +- Limit first commit line to 72 characters +- All Git commits must be signed +- Format Go code with `cd engine && make fmt` +- Use error handling with pkg/errors +- Follow standard Go import ordering +- Group similar functions together +- Error messages should be descriptive and actionable +- UI uses pnpm for package management \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f32b4abf..4d399f35 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,11 +23,11 @@ These are mostly guidelines, not rules. Use your best judgment, and feel free to - [Git commit messages](#git-commit-messages) - [Go styleguide](#go-styleguide) - [Documentation styleguide](#documentation-styleguide) + - [API design and testing](#api-design-and-testing) + - [UI development](#ui-development) - [Development setup](#development-setup) - [Repo overview](#repo-overview) - --- @@ -121,6 +121,45 @@ We encourage you to follow the principles described in the following documents: - [Effective Go](https://go.dev/doc/effective_go) - [Go Code Review Comments](https://github.com/golang/go/wiki/CodeReviewComments) +### Message style guide +Consistent messaging is important throughout the codebase. Follow these guidelines for errors, logs, and user-facing messages: + +#### Error messages +- Lowercase for internal errors and logs: `failed to start session` (no ending period) +- Uppercase for user-facing errors: `Requested object does not exist. Specify your request.` (with ending period) +- Omit articles ("a", "an", "the") for brevity: use `failed to update clone` not `failed to update the clone` +- Be specific and actionable whenever possible +- For variable interpolation, use consistent formatting: `failed to find clone: %s` + +#### CLI output +- Use concise, action-oriented language +- Present tense with ellipsis for in-progress actions: `Creating clone...` + - Ellipsis (`...`) indicates an ongoing process where the user should wait + - Always follow up with a completion message when the operation finishes +- Past tense with period for results: `Clone created successfully.` +- Include relevant identifiers (IDs, names) in output + +#### Progress indication +- Use ellipsis (`...`) to indicate that an operation is in progress and the user should wait +- For longer operations, consider providing percentage or step indicators: `Cloning database... (25%)` +- When an operation with ellipsis completes, always provide a completion message without ellipsis +- Example sequence: + ``` + Creating clone... + Clone "test-clone" created successfully. + ``` + +#### UI messages +- Be consistent with terminology across UI and documentation +- For confirmations, use format: `{Resource} {action} successfully.` +- For errors, provide clear next steps when possible +- Use sentence case for all messages (capitalize first word only) + +#### Commit messages +- Start with lowercase type prefix: `fix:`, `feat:`, `docs:`, etc. +- Use imperative mood: `add feature` not `added feature` +- Provide context in the body if needed + ### Documentation styleguide Documentation for Database Lab Engine and additional components is hosted at https://postgres.ai/docs and is maintained in this GitLab repo: https://gitlab.com/postgres-ai/docs. @@ -132,6 +171,94 @@ We're building documentation following the principles described at https://docum Learn more: https://documentation.divio.com/. +### API design and testing +The DBLab API follows RESTful principles with these key guidelines: +- Clear resource-based URL structure +- Consistent usage of HTTP methods (GET, POST, DELETE, etc.) +- Standardized error responses +- Authentication via API tokens +- JSON for request and response bodies +- Comprehensive documentation with examples + +#### API Documentation +We use readme.io to host the API docs: https://dblab.readme.io/ and https://api.dblab.dev. + +When updating the API specification: +1. Make changes to the OpenAPI spec file in `engine/api/swagger-spec/` +2. Upload it to readme.io as a new documentation version +3. Review and publish the new version + +#### Testing with Postman and Newman +Postman collection is generated based on the OpenAPI spec file, using [Portman](https://github.com/apideck-libraries/portman). + +##### Setup and Generation +1. Install Portman: `npm install -g @apideck/portman` +2. Generate Postman collection file: + ``` + portman --cliOptionsFile engine/api/postman/portman-cli.json + ``` + +##### Test Structure Best Practices +- Arrange tests in logical flows (create, read, update, delete) +- Use environment variables to store and pass data between requests +- For object creation tests, capture the ID in the response to use in subsequent requests +- Add validation tests for response status, body structure, and expected values +- Clean up created resources at the end of test flows + +##### CI/CD Integration +The Postman collection is automatically run in CI/CD pipelines using Newman. For local testing: +``` +newman run engine/api/postman/dblab_api.postman_collection.json -e engine/api/postman/branching.aws.postgres.ai.postman_environment.json +``` + +### UI development +The Database Lab Engine UI contains two main packages: +- `@postgres.ai/platform` - Platform version of UI +- `@postgres.ai/ce` - Community Edition version of UI +- `@postgres.ai/shared` - Common modules shared between packages + +#### Working with UI packages +At the repository root: +- `pnpm install` - Install all dependencies +- `npm run build -ws` - Build all packages +- `npm run start -w @postgres.ai/platform` - Run Platform UI in dev mode +- `npm run start -w @postgres.ai/ce` - Run Community Edition UI in dev mode + +_Note: Don't use commands for `@postgres.ai/shared` - it's a dependent package that can't be run or built directly_ + +#### Platform UI Development +1. Set up environment variables: + ```bash + cd ui/packages/platform + cp .env_example_dev .env + ``` +2. Edit `.env` to set: + - `REACT_APP_API_URL_PREFIX` to point to dev API server + - `REACT_APP_TOKEN_DEBUG` to set your JWT token +3. Start development server: `pnpm run start` + +#### CI pipelines for UI code +To deploy UI changes, tag the commit with `ui/` prefix and push it: +```shell +git tag ui/1.0.12 +git push origin ui/1.0.12 +``` + +#### Handling Vulnerabilities +When addressing vulnerabilities in UI packages: +1. Update the affected package to a newer version if available +2. For sub-package vulnerabilities, try using [npm-force-resolutions](https://www.npmjs.com/package/npm-force-resolutions) +3. As a last resort, consider forking the package locally + +For code-related issues: +1. Consider rewriting JavaScript code in TypeScript +2. Follow recommendations from security analysis tools +3. Only ignore false positives when absolutely necessary + +#### TypeScript Migration +- `@postgres.ai/shared` and `@postgres.ai/ce` are written in TypeScript +- `@postgres.ai/platform` is partially written in TypeScript with ongoing migration efforts + ### Repo overview The [postgres-ai/database-lab](https://gitlab.com/postgres-ai/database-lab) repo contains 2 components: - [Database Lab Engine](https://gitlab.com/postgres-ai/database-lab/-/tree/master/engine) @@ -140,7 +267,6 @@ The [postgres-ai/database-lab](https://gitlab.com/postgres-ai/database-lab) repo - [Database Lab CLI](https://gitlab.com/postgres-ai/database-lab/-/tree/master/engine/cmd/cli) - [Database Lab UI](https://gitlab.com/postgres-ai/database-lab/-/tree/master/ui) - [Community Edition](https://gitlab.com/postgres-ai/database-lab/-/tree/master/ui/packages/ce) - - [Platform](https://gitlab.com/postgres-ai/database-lab/-/tree/master/ui/packages/platform) - [Shared components](https://gitlab.com/postgres-ai/database-lab/-/tree/master/ui/packages/shared) Components have a separate version, denoted by either: @@ -191,10 +317,27 @@ Components have a separate version, denoted by either: ### Building from source -Use `Makefile` to build Database Lab components from source. +The Database Lab Engine provides multiple build targets in its `Makefile`: + +```bash +cd engine +make help # View all available build targets +make build # Build all components (Server, CLI, CI Checker) +make build-dle # Build Database Lab Engine binary and Docker image +make test # Run unit tests +``` + +You can also build specific components: + +```bash +# Build the CLI for all supported platforms +make build-client + +# Build the Server in debug mode +make build-debug -Run `make help` to see all available targets. +# Build and run DLE locally +make run-dle +``` - +See our [GitLab Container Registry](https://gitlab.com/postgres-ai/database-lab/container_registry) to find pre-built images for development branches. diff --git a/LICENSE b/LICENSE index fd32533a..b0cc8d52 100644 --- a/LICENSE +++ b/LICENSE @@ -1,19 +1,201 @@ -Copyright © 2018-present, Postgres.ai (https://postgres.ai), Nikolay Samokhvalov nik@postgres.ai - -Portions of this software are licensed as follows: -- UI components: - - All content that resides in the "./ui/packages/platform" directory of this repository is licensed under the - license defined in "./ui/packages/platform/LICENSE" - - All content that resides in the "./ui/packages/ce" directory of this repository is licensed under the "AGPLv3" - license defined in "./LICENSE" - - All content that resides in the "./ui/packages/shared" directory of this repository is licensed under the "AGPLv3" - license defined in "./LICENSE" -- All third party components incorporated into the Database Lab Engine software are licensed under the original license -provided by the owner of the applicable component. -- Content outside of the above mentioned directories above is licensed under the "AGPLv3" license defined -in "./LICENSE" - -In plain language: this repository contains open-source software licensed under an OSI-approved license AGPLv3 (see -https://opensource.org/) except "./ui/packages/platform" that defines user interfaces and business logic for the -"Platform" version of Database Lab, which is not open source and can be used only with commercial license obtained -from Postgres.ai (see https://postgres.ai/pricing). + 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 2023-2025 Postgres AI https://postgres.ai/ + + 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. \ No newline at end of file diff --git a/LICENSE-AGPL b/LICENSE-AGPL deleted file mode 100644 index e308d63a..00000000 --- a/LICENSE-AGPL +++ /dev/null @@ -1,661 +0,0 @@ - GNU AFFERO GENERAL PUBLIC LICENSE - Version 3, 19 November 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU Affero General Public License is a free, copyleft license for -software and other kinds of works, specifically designed to ensure -cooperation with the community in the case of network server software. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -our General Public Licenses are intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - Developers that use our General Public Licenses protect your rights -with two steps: (1) assert copyright on the software, and (2) offer -you this License which gives you legal permission to copy, distribute -and/or modify the software. - - A secondary benefit of defending all users' freedom is that -improvements made in alternate versions of the program, if they -receive widespread use, become available for other developers to -incorporate. Many developers of free software are heartened and -encouraged by the resulting cooperation. However, in the case of -software used on network servers, this result may fail to come about. -The GNU General Public License permits making a modified version and -letting the public access it on a server without ever releasing its -source code to the public. - - The GNU Affero General Public License is designed specifically to -ensure that, in such cases, the modified source code becomes available -to the community. It requires the operator of a network server to -provide the source code of the modified version running there to the -users of that server. Therefore, public use of a modified version, on -a publicly accessible server, gives the public access to the source -code of the modified version. - - An older license, called the Affero General Public License and -published by Affero, was designed to accomplish similar goals. This is -a different license, not a version of the Affero GPL, but Affero has -released a new version of the Affero GPL which permits relicensing under -this license. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU Affero General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Remote Network Interaction; Use with the GNU General Public License. - - Notwithstanding any other provision of this License, if you modify the -Program, your modified version must prominently offer all users -interacting with it remotely through a computer network (if your version -supports such interaction) an opportunity to receive the Corresponding -Source of your version by providing access to the Corresponding Source -from a network server at no charge, through some standard or customary -means of facilitating copying of software. This Corresponding Source -shall include the Corresponding Source for any work covered by version 3 -of the GNU General Public License that is incorporated pursuant to the -following paragraph. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the work with which it is combined will remain governed by version -3 of the GNU General Public License. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU Affero General Public License from time to time. Such new versions -will be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU Affero General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU Affero General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU Affero General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - Database Lab – instant database clones to boost development - Copyright © 2018-present, Postgres.ai (https://postgres.ai), Nikolay Samokhvalov - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If your software can interact with users remotely through a computer -network, you should also make sure that it provides a way for users to -get its source. For example, if your program is a web application, its -interface could display a "Source" link that leads users to an archive -of the code. There are many ways you could offer source, and different -solutions will be better for different programs; see section 13 for the -specific requirements. - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU AGPL, see -. diff --git a/README.md b/README.md index fb7f20e0..9eada025 100644 --- a/README.md +++ b/README.md @@ -5,18 +5,21 @@
-

Database Lab Engine (DLE)

+

DBLab Engine

- + twitter
- :zap: Blazing-fast cloning of PostgreSQL databases :elephant:
- Thin clones of PostgreSQL to build powerful development, test, QA, and staging environments.
- Available for any PostgreSQL, including AWS RDS*, GCP CloudSQL*, Heroku*, Digital Ocean*, and self-managed instances. + ⚡ Blazing-fast PostgreSQL cloning and branching 🐘

+ 🛠️ Build powerful dev/test environments.
+ 🔃 Cover 100% of DB migrations with CI tests.
+ 💡 Quickly verify ChatGPT ideas to get rid of hallucinations.

+ Available for any PostgreSQL, including self-managed and managed services* like AWS RDS, GCP Cloud SQL, Supabase, and Timescale.

+ It can be installed and used anywhere: across all cloud environments and on-premises.

@@ -44,25 +47,29 @@ --- - * For a managed PostgreSQL cloud service such as AWS RDS or Heroku, where physical connection and access to PGDATA are not available, DLE is supposed to be running on a separate VM in the same region, performing periodical automated full refresh of data and serving itself as a database-as-a-service solution providing thin database clones for development and testing purposes. + *For managed PostgreSQL cloud services like AWS RDS or Heroku, direct physical connection and PGDATA access aren't possible. In these cases, DBLab should run on a separate VM within the same region. It will routinely auto-refresh its data, effectively acting as a database-as-a-service solution. This setup then offers thin database branching ideal for development and testing. -## Why DLE? -- Build dev/QA/staging environments based on full-size production-like databases. +## Why DBLab? +- Build dev/QA/staging environments using full-scale, production-like databases. - Provide temporary full-size database clones for SQL query analysis and optimization (see also: [SQL optimization chatbot Joe](https://gitlab.com/postgres-ai/joe)). -- Automatically test database changes in CI/CD pipelines to avoid incidents in production. +- Automatically test database changes in CI/CD pipelines, minimizing risks of production incidents. +- Rapidly validate ChatGPT or other LLM concepts, check for hallucinations, and iterate towards effective solutions. -For example, cloning a 1 TiB PostgreSQL database takes ~10 seconds. Dozens of independent clones are up and running on a single machine, supporting lots of development and testing activities, without increasing costs for hardware. +For example, cloning a 1 TiB PostgreSQL database takes just about 10 seconds. On a single machine, you can have dozens of independent clones running simultaneously, supporting extensive development and testing activities without any added hardware costs.

Try it yourself right now: -- enter [the Database Lab Platform](https://console.postgres.ai/), join the "Demo" organization, and test cloning of ~1 TiB demo database, or -- check out another demo setup, DLE CE: https://nik-tf-test.aws.postgres.ai:446/instance, use the token `demo` to enter (this setup has self-signed certificates, so ignore browser's complaints) +- Visit [Postgres.ai Console](https://console.postgres.ai/), set up your first organization, and provision a DBLab Standard Edition (DBLab SE) to any cloud or on-premises environment. + - [Pricing](https://postgres.ai/pricing) (starting at $62/month) + - [Documentation: How to install DBLab SE](https://postgres.ai/docs/how-to-guides/administration/install-dle-from-postgres-ai) +- Demo: https://demo.dblab.dev (use the token `demo-token` to access) +- Looking for a free version? Install the DBLab Community Edition by [following this tutorial](https://postgres.ai/docs/tutorials/database-lab-tutorial). ## How it works -Thin cloning is fast because it uses [Copy-on-Write (CoW)](https://en.wikipedia.org/wiki/Copy-on-write#In_computer_storage). DLE supports two technologies to enable CoW and thin cloning: [ZFS](https://en.wikipedia.org/wiki/ZFS) (default) and [LVM](https://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)). +Thin cloning is fast because it is based on [Copy-on-Write (CoW)](https://en.wikipedia.org/wiki/Copy-on-write#In_computer_storage). DBLab employs two technologies for enabling thin cloning: [ZFS](https://en.wikipedia.org/wiki/ZFS) (default) and [LVM](https://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)). -With ZFS, Database Lab Engine periodically creates a new snapshot of the data directory and maintains a set of snapshots, cleaning up old and unused ones. When requesting a new clone, users can choose which snapshot to use. +Using ZFS, DBLab routinely takes new snapshots of the data directory, managing a collection of them and removing old or unused ones. When requesting a fresh clone, users have the option to select their preferred snapshot. Read more: - [How it works](https://postgres.ai/products/how-it-works) @@ -71,53 +78,61 @@ Read more: - [Questions and answers](https://postgres.ai/docs/questions-and-answers) ## Where to start -- [Database Lab tutorial for any PostgreSQL database](https://postgres.ai/docs/tutorials/database-lab-tutorial) -- [Database Lab tutorial for Amazon RDS](https://postgres.ai/docs/tutorials/database-lab-tutorial-amazon-rds) -- [Terraform module template (AWS)](https://postgres.ai/docs/how-to-guides/administration/install-database-lab-with-terraform) +- [DBLab tutorial for any PostgreSQL database](https://postgres.ai/docs/tutorials/database-lab-tutorial) +- [DBLab tutorial for Amazon RDS](https://postgres.ai/docs/tutorials/database-lab-tutorial-amazon-rds) +- [How to install DBLab SE using Postgres.ai Console](https://postgres.ai/docs/how-to-guides/administration/install-dle-from-postgres-ai) +- [How to install DBLab SE using AWS Marketplace](https://postgres.ai/docs/how-to-guides/administration/install-dle-from-aws-marketplace) ## Case studies -- Qiwi: [How Qiwi Controls the Data to Accelerate Development](https://postgres.ai/resources/case-studies/qiwi) - GitLab: [How GitLab iterates on SQL performance optimization workflow to reduce downtime risks](https://postgres.ai/resources/case-studies/gitlab) ## Features -- Blazing-fast cloning of Postgres databases – a few seconds to create a new clone ready to accept connections and queries, regardless of database size. -- The theoretical maximum number of snapshots and clones is 264 ([ZFS](https://en.wikipedia.org/wiki/ZFS), default). -- The theoretical maximum size of PostgreSQL data directory: 256 quadrillion zebibytes, or 2128 bytes ([ZFS](https://en.wikipedia.org/wiki/ZFS), default). -- PostgreSQL major versions supported: 9.6–14. -- Two technologies are supported to enable thin cloning ([CoW](https://en.wikipedia.org/wiki/Copy-on-write)): [ZFS](https://en.wikipedia.org/wiki/ZFS) and [LVM](https://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)). -- All components are packaged in Docker containers. -- UI to make manual work more convenient. -- API and CLI to automate the work with DLE snapshots and clones. -- By default, PostgreSQL containers include many popular extensions ([docs](https://postgres.ai/docs/database-lab/supported-databases#extensions-included-by-default)). -- PostgreSQL containers can be customized ([docs](https://postgres.ai/docs/database-lab/supported-databases#how-to-add-more-extensions)). -- Source database can be located anywhere (self-managed Postgres, AWS RDS, GCP CloudSQL, Azure, Timescale Cloud, and so on) and does NOT require any adjustments. There are NO requirements to install ZFS or Docker to the source (production) databases. -- Initial data provisioning can be done at either the physical (pg_basebackup, backup / archiving tools such as WAL-G or pgBackRest) or logical (dump/restore directly from the source or from files stored at AWS S3) level. -- For logical mode, partial data retrieval is supported (specific databases, specific tables). -- For physical mode, a continuously updated state is supported ("sync container"), making DLE a specialized version of standby Postgres. -- For logical mode, periodic full refresh is supported, automated, and controlled by DLE. It is possible to use multiple disks containing different versions of the database, so full refresh won't require downtime. -- Fast Point in Time Recovery (PITR) to the points available in DLE snapshots. -- Unused clones are automatically deleted. -- "Deletion protection" flag can be used to block automatic or manual deletion of clones. -- Snapshot retention policies supported in DLE configuration. -- Persistent clones: clones survive DLE restarts (including full VM reboots). -- The "reset" command can be used to switch to a different version of data. -- DB Migration Checker component collects various artifacts useful for DB testing in CI ([docs](https://postgres.ai/docs/db-migration-checker)). -- SSH port forwarding for API and Postgres connections. -- Docker container config parameters can be specified in the DLE config. -- Resource usage quotas for clones: CPU, RAM (container quotas, supported by Docker) -- Postgres config parameters can be specified in the DLE config (separately for clones, the "sync" container, and the "promote" container). -- Monitoring: auth-free `/healthz` API endpoint, extended `/status` (requires auth), [Netdata module](https://gitlab.com/postgres-ai/netdata_for_dle). +- Speed & scale + - Blazing-fast cloning of PostgreSQL databases – clone in seconds, irrespective of database size + - Theoretical max of snapshots/clones: 264 ([ZFS](https://en.wikipedia.org/wiki/ZFS), default) + - Maximum size of PostgreSQL data directory: 256 quadrillion zebibytes, or 2128 bytes ([ZFS](https://en.wikipedia.org/wiki/ZFS), default) +- Support & technologies + - Supported PostgreSQL versions: 9.6–17 + - Thin cloning ([CoW](https://en.wikipedia.org/wiki/Copy-on-write)) technologies: [ZFS](https://en.wikipedia.org/wiki/ZFS) and [LVM](https://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)) + - UI for manual tasks and API & CLI for automation + - Packaged in Docker containers for all components +- PostgreSQL containers + - Popular extensions including contrib modules, pgvector, HypoPG and many others ([docs](https://postgres.ai/docs/database-lab/supported-databases#extensions-included-by-default)) + - Customization capabilities for containers ([docs](https://postgres.ai/docs/database-lab/supported-databases#how-to-add-more-extensions)) + - Docker container and PostgreSQL configuration parameters in the DBLab config +- Source database requirements + - Location flexibility: self-managed PostgreSQL, AWS RDS, GCP Cloud SQL, Azure, etc.—no source adjustments needed. + - No ZFS or Docker requirements for source databases +- Data provisioning & retrieval + - Physical (pg_basebackup, WAL-G, pgBackRest) and logical (dump/restore) provisioning + - Partial data retrieval in logical mode (specific databases/tables) + - Continuous update in physical mode + - Periodic full refresh in logical mode without downtime +- Recovery & management + - Fast Point in Time Recovery (PITR) for physical mode + - Auto-deletion of unused clones + - Snapshot retention policies in DBLab configuration +- Clones + - "Deletion protection" for preventing clone deletion + - Persistent clones withstand DBLab restarts + - "Reset" command for data version switching + - Resource quotas: CPU, RAM +- Monitoring & security + - `/healthz` API endpoint (no auth), extended `/status` endpoint ([API docs](https://api.dblab.dev)) + - Netdata module for insights ## How to contribute -### Give the project a star -The easiest way to contribute is to give the project a GitHub/GitLab star: +### Support us on GitHub/GitLab +The simplest way to show your support is by giving us a star on GitHub or GitLab! ⭐ ![Add a star](./assets/star.gif) ### Spread the word -Post a tweet mentioning [@Database_Lab](https://twitter.com/Database_Lab) or share the link to this repo in your favorite social network. +- Tweet about DBLab and mention [@Database_Lab](https://twitter.com/Database_Lab). +- Share a link to this repository on your favorite social media platform. -If you are actively using DLE, tell others about your experience. You can use the logo referenced below and stored in the `./assets` folder. Feel free to put them in your documents, slide decks, application, and website interfaces to show that you use DLE. +### Share your experience +If DBLab has been a vital tool for you, tell the world about your journey. Use the logo from the `./assets` folder for a visual touch. Whether it's in documents, presentations, applications, or on your website, let everyone know you trust and use DBLab. HTML snippet for lighter backgrounds:

@@ -142,57 +157,60 @@ For darker backgrounds: ``` ### Propose an idea or report a bug -Check out our [contributing guide](./CONTRIBUTING.md) for more details. +For proposals, bug reports, and participation in development, see our [Contributing Guide](./CONTRIBUTING.md). -### Participate in development -Check out our [contributing guide](./CONTRIBUTING.md) for more details. - -### Translate the README -Making Database Lab Engine more accessible to engineers around the Globe is a great help for the project. Check details in the [translation section of contributing guide](./CONTRIBUTING.md#Translation). ### Reference guides -- [DLE components](https://postgres.ai/docs/reference-guides/database-lab-engine-components) -- [DLE configuration reference](https://postgres.ai/docs/database-lab/config-reference) -- [DLE API reference](https://postgres.ai/swagger-ui/dblab/) +- [DBLab components](https://postgres.ai/docs/reference-guides/database-lab-engine-components) - [Client CLI reference](https://postgres.ai/docs/database-lab/cli-reference) +- [DBLab API reference](https://api.dblab.dev/) +- [DBLab configuration reference](https://postgres.ai/docs/database-lab/config-reference) ### How-to guides -- [How to install Database Lab with Terraform on AWS](https://postgres.ai/docs/how-to-guides/administration/install-database-lab-with-terraform) - [How to install and initialize Database Lab CLI](https://postgres.ai/docs/how-to-guides/cli/cli-install-init) -- [How to manage DLE](https://postgres.ai/docs/how-to-guides/administration) +- [How to manage DBLab](https://postgres.ai/docs/how-to-guides/administration) - [How to work with clones](https://postgres.ai/docs/how-to-guides/cloning) +- [How to work with branches](XXXXXXX) – TBD +- [How to integrate DBLab with GitHub Actions](XXXXXXX) – TBD +- [How to integrate DBLab with GitLab CI/CD](XXXXXXX) – TBD -More you can find in [the "How-to guides" section](https://postgres.ai/docs/how-to-guides) of the docs. +You can find more in the ["How-to guides" section](https://postgres.ai/docs/how-to-guides) of the documentation. ### Miscellaneous -- [DLE Docker images](https://hub.docker.com/r/postgresai/dblab-server) +- [DBLab Docker images](https://hub.docker.com/r/postgresai/dblab-server) - [Extended Docker images for PostgreSQL (with plenty of extensions)](https://hub.docker.com/r/postgresai/extended-postgres) - [SQL Optimization chatbot (Joe Bot)](https://postgres.ai/docs/joe-bot) - [DB Migration Checker](https://postgres.ai/docs/db-migration-checker) ## License -DLE source code is licensed under the OSI-approved open source license GNU Affero General Public License version 3 (AGPLv3). +The DBLab source code is licensed under the OSI-approved open source license [Apache 2.0](https://opensource.org/license/apache-2-0/). Reach out to the Postgres.ai team if you want a trial or commercial license that does not contain the GPL clauses: [Contact page](https://postgres.ai/contact). -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fpostgres-ai%2Fdatabase-lab-engine.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fpostgres-ai%2Fdatabase-lab-engine?ref=badge_large) - ## Community & Support -- ["Database Lab Engine Community Covenant Code of Conduct"](./CODE_OF_CONDUCT.md) -- Where to get help: [Contact page](https://postgres.ai/contact) +- [Database Lab Engine Community Covenant Code of Conduct](./CODE_OF_CONDUCT.md) +- Where to get help: [Contact page](https://postgres.ai/contact). - [Community Slack](https://slack.postgres.ai) -- If you need to report a security issue, follow instructions in ["Database Lab Engine security guidelines"](./SECURITY.md). +- If you need to report a security issue, follow the instructions in [Database Lab Engine Security Guidelines](./SECURITY.md). [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg?color=blue)](./CODE_OF_CONDUCT.md) +Many thanks to our amazing contributors! + + + + + ## Translations +Making DBLab more accessible to engineers around the globe is a great help for the project. Check details in the [translation section of contributing guide](./CONTRIBUTING.md#Translation). This README is available in the following translations: - -- [German / Deutsch](translations/README.german.md) (🙏 [@ane4ka](https://github.com/ane4ka)) -- [Brazilian Portuguese / Português (BR)](translations/README.portuguese-br.md) (🙏 [@Alexand](https://gitlab.com/Alexand)) -- [Russian / Pусский](translations/README.russian.md) (🙏 [@Tanya301](https://github.com/Tanya301)) -- [Spanish / Español](translations/README.spanish.md) (🙏 [@asotolongo](https://gitlab.com/asotolongo)) -- [Ukrainian / Українська](translations/README.ukrainian.md) (🙏 [@denis-boost](https://github.com/denis-boost)) +- [German / Deutsch](translations/README.german.md) (by [@ane4ka](https://github.com/ane4ka)) +- [Brazilian Portuguese / Português (BR)](translations/README.portuguese-br.md) (by [@Alexand](https://gitlab.com/Alexand)) +- [Russian / Pусский](translations/README.russian.md) (by [@Tanya301](https://github.com/Tanya301)) +- [Spanish / Español](translations/README.spanish.md) (by [@asotolongo](https://gitlab.com/asotolongo)) +- [Ukrainian / Українська](translations/README.ukrainian.md) (by [@denis-boost](https://github.com/denis-boost)) 👉 [How to make a translation contribution](./CONTRIBUTING.md#translation) + + diff --git a/assets/database-lab-dark-mode.png b/assets/database-lab-dark-mode.png new file mode 100644 index 00000000..072f6fb3 Binary files /dev/null and b/assets/database-lab-dark-mode.png differ diff --git a/assets/database-lab-dark-mode.svg b/assets/database-lab-dark-mode.svg new file mode 100644 index 00000000..2db3bd73 --- /dev/null +++ b/assets/database-lab-dark-mode.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/database-lab-light-mode.png b/assets/database-lab-light-mode.png new file mode 100644 index 00000000..347745a2 Binary files /dev/null and b/assets/database-lab-light-mode.png differ diff --git a/assets/database-lab-light-mode.svg b/assets/database-lab-light-mode.svg new file mode 100644 index 00000000..81ad331b --- /dev/null +++ b/assets/database-lab-light-mode.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/dle-simple.png b/assets/dle-simple.png new file mode 100644 index 00000000..9727a2d9 Binary files /dev/null and b/assets/dle-simple.png differ diff --git a/assets/dle-simple.svg b/assets/dle-simple.svg new file mode 100644 index 00000000..76daec73 --- /dev/null +++ b/assets/dle-simple.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/dle.svg b/assets/dle.svg index 9d056971..ab0b2f99 100644 --- a/assets/dle.svg +++ b/assets/dle.svg @@ -3,10 +3,10 @@ - - - - - - + + + + + + diff --git a/assets/dle_button.svg b/assets/dle_button.svg index 4efa2538..a03d399d 100644 --- a/assets/dle_button.svg +++ b/assets/dle_button.svg @@ -4,12 +4,12 @@ - - - - - - + + + + + + diff --git a/cloudformation/dle_cf_template.yaml b/cloudformation/dle_cf_template.yaml deleted file mode 100644 index 6b53e154..00000000 --- a/cloudformation/dle_cf_template.yaml +++ /dev/null @@ -1,583 +0,0 @@ -AWSTemplateFormatVersion: 2010-09-09 -Description: >- - AWS CloudFormation template DLE_Instance_Host: Creates a single EC2 instance based on Database Lab Engine (DLE) AMI, - configures DLE, launches the data retrieval process, eventually making it possible to create thin clones using DLE API, CLI, or UI. - You will be billed for the AWS resources used if you create a stack from this template. -Metadata: - AWS::CloudFormation::Interface: - ParameterGroups: - - - Label: - default: "Amazon EC2 configuration" - Parameters: - - InstanceType - - ZFSVolumeSize - - SSHLocation - - VPC - - Subnet - - KeyName - - Label: - default: "TLS certificate configuration" - Parameters: - - CertificateSubdomain - - CertificateHostedZone - - CertificateEmail - - - Label: - default: "Database Lab Engine (DLE) configuration" - Parameters: - - DLERetrievalRefreshTimetable - - PostgresDumpParallelJobs - - DLEVerificationToken - - DLEDebugMode - - - Label: - default: "Source PostgreSQL parameters" - Parameters: - - SourceDatabaseSize - - SourcePostgresHost - - SourcePostgresPort - - SourcePostgresUsername - - SourcePostgresPassword - - SourcePostgresDBName - - PostgresConfigSharedPreloadLibraries - - SourcePostgresDBList - - - Label: - default: "Advanced DLE configuration" - Parameters: - - PostgresDockerImage - - DLEZFSDataSetsNumber - ParameterLabels: - KeyName: - default: "Key pair" - InstanceType: - default: "Instance type" - SSHLocation: - default: "Connection source IP range" - SourceDatabaseSize: - default: "Total source database size in GiB" - CertificateSubdomain: - default: "Certificate subdomain" - CertificateHostedZone: - default: "Hosted zone" - CertificateEmail: - default: "Certificate email" - DLEDebugMode: - default: "DLE debug mode" - DLEVerificationToken: - default: "DLE verification token" - DLERetrievalRefreshTimetable: - default: "DLE retrieval refresh timetable" - PostgresDockerImage: - default: "Postgres docker image" - DLEZFSDataSetsNumber: - default: "Number of supported snapshots." - PostgresDumpParallelJobs: - default: "Number of pg_dump jobs" - SourcePostgresDBName: - default: "Database name" - VPC: - default: "VPC security group" - Subnet: - default: "Subnet" - SourcePostgresHost: - default: "Host name or IP" - SourcePostgresPort: - default: "Port" - SourcePostgresUsername: - default: "User name" - SourcePostgresPassword: - default: "Password" - PostgresConfigSharedPreloadLibraries: - default: "shared_preload_libraries parameter" - SourcePostgresDBList: - default: "Comma separated list of databases to copy" -Parameters: - Subnet: - Description: Subnet to attach EC2 machine. - Type: AWS::EC2::Subnet::Id - VPC: - Description: VPC to attach EC2 machine. - Type: AWS::EC2::VPC::Id - ConstraintDescription: Can contain only ASCII characters and can not be empty. - KeyName: - Description: Name of an existing EC2 KeyPair to enable SSH access to the instance - Type: 'AWS::EC2::KeyPair::KeyName' - ConstraintDescription: Can contain only ASCII characters and can not be empty. - InstanceType: - Description: DLE EC2 instance type - Type: String - Default: m5.2xlarge - AllowedValues: - - r5.large - - r5.xlarge - - r5.2xlarge - - r5.4xlarge - - r5.8xlarge - - r5.12xlarge - - r5.16xlarge - - r5.24xlarge - - m5.large - - m5.xlarge - - m5.2xlarge - - m5.4xlarge - - m5.8xlarge - - m5.12xlarge - - m5.16xlarge - - m5.24xlarge - ConstraintDescription: must be a valid EC2 instance type. - SSHLocation: - Description: CIDR in format x.x.x.x/32 to allow one specific IP address access, 0.0.0.0/0 to allow all IP addresses access, or another CIDR range - Type: String - MinLength: '9' - MaxLength: '18' - AllowedPattern: '(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})' - ConstraintDescription: Must be a valid IP CIDR range of the form x.x.x.x/x - SourceDatabaseSize: - Description: The size of the source databases used to calculate the size of EBS volume, in GiB - Type: Number - Default: 40 - CertificateSubdomain: - Description: Subdomain to obtain a TLS certificate for (for example, dle). Leave it empty if you don't need SSL connection or don't have Route 53 hosted zone. - Type: String - CertificateHostedZone: - Description: Hosted zone to obtain a TLS certificate for (for example, example.com). Leave it empty if you don't need SSL connection or don't have Route 53 hosted zone. - Type: String - CertificateEmail: - Description: Email address for important account notifications about the issued TLS certificate. Leave it empty if you don't need SSL connection or don't have Route 53 hosted zone. - Type: String - AllowedPattern: '^$|[^\s@]+@[^\s@]+\.[^\s@]+' - Default: '' - ConstraintDescription: Must be a valid email of the form \'user@example.com\' - DLEDebugMode: - Description: Enables DLE debug mode - Type: String - Default: True - AllowedValues: - - True - - False - DLEVerificationToken: - Description: DLE verification token - Type: String - Default: "example-verification-token" - MinLength: '9' - MaxLength: '32' - DLERetrievalRefreshTimetable: - Description: DLE refresh schedule on cron format - Type: String - Default: '0 0 * * *' - DLEZFSDataSetsNumber: - Description: Number of database copies needed - Type: Number - Default: 2 - MinValue: 2 - MaxValue: 100 - PostgresDockerImage: - Description: Docker image to run PostgreSQL - Type: String - Default: 'postgresai/extended-postgres:14' - SourcePostgresDBName: - Description: Source database name. This parameter is used to connect to the database - Type: String - Default: 'postgres' - SourcePostgresHost: - Description: Source Postgres cluster host name or IP - Type: String - Default: '' - SourcePostgresPort: - Description: Source Postgres cluster port - Type: Number - MinValue: 1024 - MaxValue: 65535 - Default: 5432 - SourcePostgresUsername: - Description: Source Postgres cluster username - Type: String - Default: postgres - SourcePostgresPassword: - Description: Source Postgres cluster password - Type: String - Default: '' - NoEcho: true - PostgresConfigSharedPreloadLibraries: - Description: Source Postgres shared_preload_libraries value - Type: String - Default: '' - PostgresDumpParallelJobs: - Description: Number of jobs to run pg_dump against the source database - Type: String - Default: '1' - SourcePostgresDBList: - Description: List of database names on source for copy to DLE. Leave it empty to copy all accessible databases - Type: String - Default: '' -Mappings: - AWSInstanceType2Arch: - r5.large: - Arch: HVM64 - r5.xlarge: - Arch: HVM64 - r5.2xlarge: - Arch: HVM64 - r5.4xlarge: - Arch: HVM64 - r5.8xlarge: - Arch: HVM64 - r5.12xlarge: - Arch: HVM64 - r5.16xlarge: - Arch: HVM64 - r5.24xlarge: - Arch: HVM64 - m5.large: - Arch: HVM64 - m5.xlarge: - Arch: HVM64 - m5.2xlarge: - Arch: HVM64 - m5.4xlarge: - Arch: HVM64 - m5.8xlarge: - Arch: HVM64 - m5.12xlarge: - Arch: HVM64 - m5.16xlarge: - Arch: HVM64 - m5.24xlarge: - Arch: HVM64 - AWSRegionArch2AMI: - eu-north-1: - HVM64: ami-0888261a1eacb636e - ap-south-1: - HVM64: ami-00539bfa7a6926e1b - eu-west-3: - HVM64: ami-038d1f1d1ef71112b - eu-west-2: - HVM64: ami-07c2bca027887871b - eu-west-1: - HVM64: ami-0e38f0f4f0acd49c2 - ap-northeast-3: - HVM64: ami-01cd2976ef1688c25 - ap-northeast-2: - HVM64: ami-049c608703690f99e - ap-northeast-1: - HVM64: ami-0cb59515cd67fdc93 - sa-east-1: - HVM64: ami-0b3aeaa58412025de - ca-central-1: - HVM64: ami-075d0aae6fdd356b1 - ap-southeast-1: - HVM64: ami-054e735ba76985f92 - ap-southeast-2: - HVM64: ami-06558ef4fedcf3c2f - eu-central-1: - HVM64: ami-048a27a74e4c1239d - us-east-1: - HVM64: ami-0ed40b8023c788775 - us-east-2: - HVM64: ami-0d6a0bd053962b66f - us-west-1: - HVM64: ami-0ef7453c037b624ec - us-west-2: - HVM64: ami-0bdf048f8e10f02eb -Conditions: - CreateSubDomain: - !Not [!Equals [!Ref CertificateHostedZone, '']] - NotCreateSubDomain: - !Not [Condition: CreateSubDomain] - -Resources: - LambdaExecutionRole: - Type: AWS::IAM::Role - Properties: - AssumeRolePolicyDocument: - Version: '2012-10-17' - Statement: - - Effect: Allow - Principal: {Service: [lambda.amazonaws.com]} - Action: ['sts:AssumeRole'] - Path: "/" - ManagedPolicyArns: - - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole - PowerFunction: - Type: AWS::Lambda::Function - Properties: - Handler: index.handler - Role: !GetAtt LambdaExecutionRole.Arn - Code: - ZipFile: !Sub | - var response = require('cfn-response'); - exports.handler = function(event, context) { - var result = parseInt(event.ResourceProperties.Op1)*(parseInt(event.ResourceProperties.Op2)+2); - response.send(event, context, response.SUCCESS, {Value: result}); - }; - Runtime: nodejs14.x - SizeCalculate: - Type: Custom::Power - Properties: - ServiceToken: !GetAtt PowerFunction.Arn - Op1: !Ref SourceDatabaseSize - Op2: !Ref DLEZFSDataSetsNumber - - ZFSVolume: - Type: AWS::EC2::Volume - DeletionPolicy: Snapshot - Properties: - Encrypted: True - AvailabilityZone: !GetAtt DLEInstance.AvailabilityZone - Size: !GetAtt SizeCalculate.Value - Tags: - - - Key: Name - Value: dle-zfs-volume - VolumeType: gp2 - - DLEInstance: - Type: 'AWS::EC2::Instance' - Properties: - ImageId: !FindInMap - - AWSRegionArch2AMI - - !Ref 'AWS::Region' - - !FindInMap - - AWSInstanceType2Arch - - !Ref InstanceType - - Arch - InstanceType: !Ref InstanceType - SecurityGroupIds: !If - - CreateSubDomain - - - !GetAtt DLESecurityGroup.GroupId - - !GetAtt DLEUISecurityGroup.GroupId - - - !GetAtt DLESecurityGroup.GroupId - KeyName: !Ref KeyName - SubnetId: !Ref Subnet - Tags: - - - Key: Name - Value: "DLE Instance" - UserData: - Fn::Base64: !Sub | # No more Fn::Join needed - #!/bin/bash - set -ex - - sleep 30 - - # This code tested and works on Ubuntu 20.04 (current base AMI) - disk=$(lsblk -e7 --output PATH,NAME,FSTYPE --json | jq -r '.blockdevices[] | select(.children == null and .fstype == null) | .path ') - - sudo zpool create -f \ - -O compression=on \ - -O atime=off \ - -O recordsize=128k \ - -O logbias=throughput \ - -m /var/lib/dblab/dblab_pool \ - dblab_pool \ - $disk - - for i in {1..${DLEZFSDataSetsNumber}}; do - sudo zfs create dblab_pool/dataset_$i - done - - dle_config_path="/home/ubuntu/.dblab/engine/configs" - dle_meta_path="/home/ubuntu/.dblab/engine/meta" - postgres_conf_path="/home/ubuntu/.dblab/postgres_conf" - - yq e -i ' - .global.debug=${DLEDebugMode} | - .embeddedUI.host="" | - .server.verificationToken="${DLEVerificationToken}" | - .retrieval.refresh.timetable="${DLERetrievalRefreshTimetable}" | - .retrieval.spec.logicalRestore.options.forceInit=true | - .poolManager.mountDir = "/var/lib/dblab/dblab_pool" | - .retrieval.spec.logicalDump.options.dumpLocation="/var/lib/dblab/dblab_pool/dataset_1/dump/" | - .retrieval.spec.logicalRestore.options.dumpLocation="/var/lib/dblab/dblab_pool/dataset_1/dump/" | - .databaseContainer.dockerImage="${PostgresDockerImage}" | - .databaseConfigs.configs.shared_preload_libraries="${PostgresConfigSharedPreloadLibraries}" - ' $dle_config_path/server.yml - - yq e -i ' - .retrieval.spec.logicalDump.options.source.connection.host = "${SourcePostgresHost}" | - .retrieval.spec.logicalDump.options.source.connection.port = ${SourcePostgresPort} | - .retrieval.spec.logicalDump.options.source.connection.dbname="${SourcePostgresDBName}" | - .retrieval.spec.logicalDump.options.source.connection.username = "${SourcePostgresUsername}" | - .retrieval.spec.logicalDump.options.source.connection.password = "${SourcePostgresPassword}" | - .retrieval.spec.logicalDump.options.parallelJobs = ${PostgresDumpParallelJobs} | - .retrieval.spec.logicalRestore.options.configs.shared_preload_libraries = "${PostgresConfigSharedPreloadLibraries}" - ' $dle_config_path/server.yml - - for i in $(echo ${SourcePostgresDBList} | sed "s/,/ /g") - do - yq e -i " - .retrieval.spec.logicalDump.options.databases.$i = {} - " $dle_config_path/server.yml - done - - - sudo docker run \ - --detach \ - --name dblab_server \ - --label dblab_control \ - --privileged \ - --publish 2345:2345 \ - --volume /var/run/docker.sock:/var/run/docker.sock \ - --volume /var/lib/dblab:/var/lib/dblab/:rshared \ - --volume /var/lib/dblab/dblab_pool/dataset_1/dump/:/var/lib/dblab/dblab_pool/dataset_1/dump/:rshared \ - --volume $dle_config_path:/home/dblab/configs:ro \ - --volume $dle_meta_path:/home/dblab/meta \ - --volume $postgres_conf_path:/home/dblab/standard/postgres/control \ - --env DOCKER_API_VERSION=1.39 \ - --restart always \ - registry.gitlab.com/postgres-ai/database-lab/dblab-server:3.1.1 - - if [ ! -z "${CertificateHostedZone}" ]; then - export DOMAIN=${CertificateSubdomain}.${CertificateHostedZone} - export USER_EMAIL=${CertificateEmail} - export CERTIFICATE_EMAIL=${!USER_EMAIL:-'noreply@'$DOMAIN} - - sudo certbot certonly --standalone -d $DOMAIN -m $CERTIFICATE_EMAIL --agree-tos -n - sudo cp /etc/letsencrypt/live/$DOMAIN/fullchain.pem /etc/envoy/certs/fullchain1.pem - sudo cp /etc/letsencrypt/live/$DOMAIN/privkey.pem /etc/envoy/certs/privkey1.pem - - cat < /etc/letsencrypt/renewal-hooks/deploy/envoy.deploy - #!/bin/bash - umask 0177 - export DOMAIN=${CertificateSubdomain}.${CertificateHostedZone} - export DATA_DIR=/etc/envoy/certs/ - cp /etc/letsencrypt/live/$DOMAIN/fullchain.pem $DATA_DIR/fullchain1.pem - cp /etc/letsencrypt/live/$DOMAIN/privkey.pem $DATA_DIR/privkey1.pem - EOF - sudo chmod +x /etc/letsencrypt/renewal-hooks/deploy/envoy.deploy - - sudo systemctl enable envoy - sudo systemctl start envoy - fi - - while ! echo "UI started" | nc localhost 2346; do sleep 10; done - /opt/aws/bin/cfn-signal -e $? -d "DLE UI is available" -r "DLE Deploy Process Complete" '${WaitHandle}' - - WaitHandle: - Type: AWS::CloudFormation::WaitConditionHandle - WaitCondition: - Type: AWS::CloudFormation::WaitCondition - DependsOn: DLEInstance - Properties: - Handle: !Ref 'WaitHandle' - Timeout: '600' - - MountPoint: - Type: AWS::EC2::VolumeAttachment - Properties: - InstanceId: !Ref DLEInstance - VolumeId: !Ref ZFSVolume - Device: /dev/xvdh - - DLEElasticIP: - Type: AWS::EC2::EIP - Properties: - Domain: vpc - InstanceId: !Ref DLEInstance - - SubDomain: - Type: AWS::Route53::RecordSet - Condition: CreateSubDomain - Properties: - HostedZoneName: !Sub '${CertificateHostedZone}.' - Comment: DNS name for DLE instance. - Name: !Sub '${CertificateSubdomain}.${CertificateHostedZone}' - Type: CNAME - TTL: 60 - ResourceRecords: - - !GetAtt DLEInstance.PublicDnsName - DependsOn: - - DLEInstance - - DLEElasticIP - - DLESecurityGroup: - Type: 'AWS::EC2::SecurityGroup' - Properties: - GroupDescription: Enable ssh access via port 22 - SecurityGroupIngress: - - IpProtocol: tcp - FromPort: 22 - ToPort: 22 - CidrIp: !Ref SSHLocation - SecurityGroupEgress: - - IpProtocol: -1 - CidrIp: '0.0.0.0/0' - VpcId: !Ref VPC - - DLEUISecurityGroup: - Type: 'AWS::EC2::SecurityGroup' - Condition: CreateSubDomain - Properties: - GroupDescription: Enable ports to access DLE UI - SecurityGroupIngress: - - IpProtocol: tcp - FromPort: 80 - ToPort: 80 - CidrIp: !Ref SSHLocation - - - IpProtocol: tcp - FromPort: 443 - ToPort: 443 - CidrIp: !Ref SSHLocation - - - IpProtocol: tcp - FromPort: 446 - ToPort: 446 - CidrIp: !Ref SSHLocation - SecurityGroupEgress: - - IpProtocol: -1 - CidrIp: '0.0.0.0/0' - VpcId: !Ref VPC - -Outputs: - 02VerificationToken: - Description: 'DLE verification token' - Value: !Ref DLEVerificationToken - - 08DLEInstance: - Description: URL for newly created DLE instance - Value: !Sub 'https://${CertificateSubdomain}.${CertificateHostedZone}' - Condition: CreateSubDomain - - 01WebUIUrl: - Description: UI URL with a domain for newly created DLE instance - Value: !Sub 'https://${CertificateSubdomain}.${CertificateHostedZone}:446' - Condition: CreateSubDomain - 01WebUIUrl: - Description: UI URL with a domain for newly created DLE instance - Value: !Sub 'http://localhost:2346' - Condition: NotCreateSubDomain - - 07EBSVolumeSize: - Description: Size of provisioned EBS volume - Value: !GetAtt SizeCalculate.Value - - 03DNSName: - Description: Public DNS name - Value: !GetAtt DLEInstance.PublicDnsName - - 06EC2SSH: - Description: SSH connection to the EC2 instance with Database Lab Engine - Value: !Sub - - 'ssh ubuntu@${DNSName} -i YOUR_PRIVATE_KEY' - - DNSName: !GetAtt DLEInstance.PublicDnsName - - 05DLETunnel: - Description: Create an SSH-tunnel to Database Lab Engine - Value: !Sub - - 'ssh -N -L 2345:${DNSName}:2345 ubuntu@${DNSName} -i YOUR_PRIVATE_KEY' - - DNSName: !GetAtt DLEInstance.PublicDnsName - - 00UITunnel: - Description: Use SSH port forwarding to be able to access DLE UI - Value: !Sub - - 'ssh -N -L 2346:${DNSName}:2346 ubuntu@${DNSName} -i YOUR_PRIVATE_KEY' - - DNSName: !GetAtt DLEInstance.PublicDnsName - - 04CloneTunnel: - Description: Use SSH port forwarding to be able to access a database clone - Value: !Sub - - 'ssh -N -L CLONE_PORT:${DNSName}:CLONE_PORT ubuntu@${DNSName} -i YOUR_PRIVATE_KEY' - - DNSName: !GetAtt DLEInstance.PublicDnsName diff --git a/cloudformation/getAMIs.sh b/cloudformation/getAMIs.sh deleted file mode 100755 index 27a71304..00000000 --- a/cloudformation/getAMIs.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -# This script takes a a parameter which needs to be a name of an AWS AMI -# The string will have to identify the AMI uniquely in all regions. -# The script will generate an output which can be copied into json files of AWS CloudFormation -# -# The script uses the AWS command line tools. -# The AWS command line tools have to have a default profile with the permission to -# describe a region and to describe an image - -# The script can be run with normal OS user privileges. -# The script is not supposed to modify anything. -# There is no warranty. Please check the script upfront. You will use it on your own risk -# String to be used when no AMI is available in region -NOAMI="NOT_SUPPORTED" -# Change your aws prfile if needed here: -PROFILE=" --profile default" -# Check whether AWS CLI is installed and in search path -if ! aws_loc="$(type -p "aws")" || [ -z "$aws_loc" ]; then -echo "Error: Script requeres AWS CLI . Install it and retry" -exit 1 -fi -# Check whether parameter has been provided -if [ -z "$1" ] -then -NAME=DBLABserver* -echo "No parameter provided." -else -NAME=$1 -fi -echo "Will search for AMIs with name: ${NAME}" -echo "---------------------------------------" -##NAME=DBLABserver* -R=$(aws ec2 describe-regions --query "Regions[].{Name:RegionName}" --output text ${PROFILE}) -for i in $R; do -AMI=`aws ec2 describe-images --owners 005923036815 --region $i --filters "Name=name,Values=${NAME}" --output json | jq -r '.Images | sort_by(.CreationDate) | last(.[]).ImageId'` -if [ -z "$AMI" ] -then -AMI=$NOAMI -fi -echo " "${i}: $'\n' " "HVM64: ${AMI} -done - diff --git a/engine/.dockerignore b/engine/.dockerignore new file mode 100644 index 00000000..840be396 --- /dev/null +++ b/engine/.dockerignore @@ -0,0 +1 @@ +meta/ \ No newline at end of file diff --git a/engine/.gitlab-ci.yml b/engine/.gitlab-ci.yml index 0d47c139..a048e132 100644 --- a/engine/.gitlab-ci.yml +++ b/engine/.gitlab-ci.yml @@ -1,5 +1,7 @@ default: - image: golang:1.18 + image: + name: golang:1.23 + pull_policy: if-not-present stages: - test @@ -56,7 +58,9 @@ lint: ### Build binary. build-binary-alpine: <<: *only_engine - image: golang:1.18-alpine + image: + name: golang:1.23-alpine + pull_policy: if-not-present stage: build-binary artifacts: paths: @@ -136,13 +140,18 @@ build-binary-client-rc: - gsutil -m cp -r bin/cli/* gs://database-lab-cli/${CLEAN_TAG}/ .job_template: &build_image_definition - image: docker:20 + image: + name: docker:24 + pull_policy: if-not-present stage: build artifacts: paths: - engine/bin services: - - name: docker:dind + - name: docker:24-dind + alias: docker + command: [ "--tls=false" ] + pull_policy: if-not-present script: - cd engine - apk update && apk upgrade && apk add --no-cache bash # TODO(anatoly): Remove dependency. @@ -203,7 +212,7 @@ build-image-master-server: build-image-master-server-zfs08: <<: *build_image_definition <<: *only_master - variables: + variables: DOCKER_FILE: "Dockerfile.dblab-server-zfs08" DOCKER_NAME: "registry.gitlab.com/postgres-ai/database-lab/dblab-server" TAGS: "${DOCKER_NAME}:master-zfs0.8,${DOCKER_NAME}:master-${CI_COMMIT_SHORT_SHA}-zfs0.8" @@ -219,7 +228,7 @@ build-image-master-ci-checker: build-image-master-client: <<: *build_image_definition <<: *only_master - variables: + variables: DOCKER_FILE: "Dockerfile.dblab-cli" DOCKER_NAME: "registry.gitlab.com/postgres-ai/database-lab/dblab-cli" TAGS: "${DOCKER_NAME}:master,${DOCKER_NAME}:master-${CI_COMMIT_SHORT_SHA}" @@ -237,7 +246,6 @@ build-image-latest-server: - export CLEAN_TAG=$(echo ${CI_COMMIT_TAG#"v"}) - export LATEST_TAG=$(echo ${CLEAN_TAG%.*}-latest) - export TAGS="${DOCKER_NAME}:${LATEST_TAG},${DOCKER_NAME}:${CLEAN_TAG}" - build-image-latest-server-zfs08: <<: *build_image_definition <<: *only_tag_release @@ -331,7 +339,6 @@ build-image-rc-server-zfs08: REGISTRY: "${DH_CI_REGISTRY}" DOCKER_FILE: "Dockerfile.dblab-server-zfs08" DOCKER_NAME: "postgresai/dblab-server" - build-image-rc-server-dev: <<: *build_image_definition <<: *only_tag_rc @@ -344,7 +351,6 @@ build-image-rc-server-dev: REGISTRY: "${CI_REGISTRY}" DOCKER_FILE: "Dockerfile.dblab-server" DOCKER_NAME: "registry.gitlab.com/postgres-ai/database-lab/dblab-server" - build-image-rc-server-dev-zfs08: <<: *build_image_definition <<: *only_tag_rc @@ -357,7 +363,6 @@ build-image-rc-server-dev-zfs08: REGISTRY: "${CI_REGISTRY}" DOCKER_FILE: "Dockerfile.dblab-server-zfs08" DOCKER_NAME: "registry.gitlab.com/postgres-ai/database-lab/dblab-server" - build-image-rc-ci-checker: <<: *build_image_definition <<: *only_tag_rc @@ -370,7 +375,6 @@ build-image-rc-ci-checker: REGISTRY: "${DH_CI_REGISTRY}" DOCKER_FILE: "Dockerfile.ci-checker" DOCKER_NAME: "postgresai/dblab-ci-checker" - build-image-rc-ci-checker-dev: <<: *build_image_definition <<: *only_tag_rc @@ -383,7 +387,6 @@ build-image-rc-ci-checker-dev: REGISTRY: "${CI_REGISTRY}" DOCKER_FILE: "Dockerfile.ci-checker" DOCKER_NAME: "registry.gitlab.com/postgres-ai/database-lab/dblab-ci-checker" - build-image-rc-client: <<: *build_image_definition <<: *only_tag_rc @@ -396,17 +399,15 @@ build-image-rc-client: REGISTRY: "${DH_CI_REGISTRY}" DOCKER_FILE: "Dockerfile.dblab-cli" DOCKER_NAME: "postgresai/dblab" - -build-image-swagger-latest: +build-image-swagger-release: <<: *build_image_definition <<: *only_tag_release variables: DOCKER_FILE: "Dockerfile.swagger-ui" - DOCKER_NAME: "registry.gitlab.com/postgres-ai/database-lab/dblab-swagger-ui" + DOCKER_IMAGE_NAME: "registry.gitlab.com/postgres-ai/database-lab/dblab-swagger-ui" before_script: - export CLEAN_TAG=$(echo ${CI_COMMIT_TAG#"v"}) - - export LATEST_TAG=$(echo ${CLEAN_TAG%.*}-latest) - - export TAGS="${DOCKER_NAME}:${LATEST_TAG}" + - export TAGS="${DOCKER_IMAGE_NAME}:${CLEAN_TAG}" .bash-test: &bash_test stage: integration-test @@ -421,6 +422,8 @@ build-image-swagger-latest: artifacts: paths: - engine/bin + before_script: + - bash engine/test/_cleanup.sh script: - bash engine/test/1.synthetic.sh - bash engine/test/2.logical_generic.sh @@ -460,15 +463,32 @@ bash-test-14: variables: POSTGRES_VERSION: 14 +bash-test-15: + <<: *bash_test + variables: + POSTGRES_VERSION: 15 + +bash-test-16: + <<: *bash_test + variables: + POSTGRES_VERSION: 16 + +bash-test-17: + <<: *bash_test + variables: + POSTGRES_VERSION: 17 + integration-test: services: - - name: docker:dind + - name: docker:24-dind + alias: docker command: [ "--tls=false" ] + pull_policy: if-not-present <<: *only_feature stage: integration-test variables: # Instruct Testcontainers to use the daemon of DinD. - DOCKER_HOST: "tcp://docker:2375" + # DOCKER_HOST: "tcp://docker:2375" # Instruct Docker not to start over TLS. DOCKER_TLS_CERTDIR: "" # Improve performance with overlayfs. @@ -478,3 +498,26 @@ integration-test: script: - cd engine - make test-ci-integration + +## Deploy +.deploy-definition: &deploy_definition + stage: deploy + image: + name: dtzar/helm-kubectl:2.14.1 + pull_policy: if-not-present + script: + - bash ./engine/scripts/do.sh subs_envs ./engine/deploy/swagger-ui.yaml /tmp/swagger-ui.yaml + - kubectl apply --filename /tmp/swagger-ui.yaml -n $NAMESPACE + +deploy-swagger-ui-tag-release: + <<: *only_tag_release + <<: *deploy_definition + environment: + name: production + variables: + ENV: production + NAMESPACE: production + DOCKER_IMAGE_NAME: "registry.gitlab.com/postgres-ai/database-lab/dblab-swagger-ui" + before_script: + - export CLEAN_TAG=$(echo ${CI_COMMIT_TAG#"v"}) + - export TAG="${DOCKER_IMAGE_NAME}:${CLEAN_TAG}" diff --git a/engine/.golangci.yml b/engine/.golangci.yml index 2b9a46df..bad31644 100644 --- a/engine/.golangci.yml +++ b/engine/.golangci.yml @@ -2,10 +2,9 @@ run: timeout: 2m issues-exit-code: 1 tests: true - skip-dirs: - - vendor output: - format: colored-line-number + formats: + - format: colored-line-number print-issued-lines: true print-linter-name: true @@ -22,10 +21,8 @@ linters-settings: gofmt: simplify: true gofumpt: - lang-version: "1.17" extra-rules: false gosimple: - go: "1.17" checks: [ "all" ] goimports: local-prefixes: gitlab.com/postgres-ai/database-lab @@ -37,14 +34,17 @@ linters-settings: lll: line-length: 140 tab-width: 1 - gomnd: - settings: - mnd: - ignored-functions: strconv.Format*,os.*,strconv.Parse*,strings.SplitN,bytes.SplitN + mnd: + ignored-functions: + - strconv.Format* + - os.* + - strconv.Parse* + - strings.SplitN + - bytes.SplitN revive: - min-confidence: 0.8 + confidence: 0.8 unused: - check-exported: false + exported-fields-are-used: false unparam: check-exported: false nakedret: @@ -66,36 +66,31 @@ linters-settings: linters: enable: - - deadcode - - depguard - dupl - errcheck - gochecknoinits - goconst - gocritic - goimports - - gomnd - gosimple - govet - ineffassign - lll - - megacheck - misspell + - mnd - prealloc - revive - - structcheck + - staticcheck - stylecheck - unconvert - - varcheck - unused - unparam - wsl enable-all: false disable: + - depguard - gosec - - interfacer - gocyclo # currently unmaintained - presets: fast: false issues: @@ -107,7 +102,9 @@ issues: - lll - errcheck - wsl - - gomnd + - mnd + exclude-dirs: + - vendor exclude-use-default: false max-issues-per-linter: 0 diff --git a/engine/Dockerfile.ci-checker b/engine/Dockerfile.ci-checker index 966ab8c3..b509bc51 100644 --- a/engine/Dockerfile.ci-checker +++ b/engine/Dockerfile.ci-checker @@ -1,4 +1,4 @@ -FROM docker:20.10.12 +FROM docker:20.10.24 # Install dependencies. RUN apk update && apk add --no-cache bash diff --git a/engine/Dockerfile.dblab-cli b/engine/Dockerfile.dblab-cli index 16eadd1a..d14f8222 100644 --- a/engine/Dockerfile.dblab-cli +++ b/engine/Dockerfile.dblab-cli @@ -1,7 +1,7 @@ -FROM docker:20.10.12 +FROM docker:20.10.24 # Install dependencies. -RUN apk update && apk add --no-cache bash jq +RUN apk update && apk add --no-cache bash jq tzdata WORKDIR /home/dblab COPY ./bin/dblab ./bin/dblab diff --git a/engine/Dockerfile.dblab-server b/engine/Dockerfile.dblab-server index ba5a22bb..c1d2644c 100644 --- a/engine/Dockerfile.dblab-server +++ b/engine/Dockerfile.dblab-server @@ -1,18 +1,10 @@ # See Guides to learn how to start a container: https://postgres.ai/docs/how-to-guides/administration/engine-manage -FROM docker:20.10.12 +FROM docker:20.10.24 # Install dependencies RUN apk update \ - && apk add zfs=2.1.4-r0 --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/main \ - && apk add --no-cache lvm2 bash util-linux -RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.13/main' >> /etc/apk/repositories \ - && echo 'http://dl-cdn.alpinelinux.org/alpine/v3.13/community' >> /etc/apk/repositories \ - && apk add bcc-tools=0.18.0-r0 bcc-doc=0.18.0-r0 && ln -s $(which python3) /usr/bin/python \ - # TODO: remove after release the PR: https://github.com/iovisor/bcc/pull/3286 (issue: https://github.com/iovisor/bcc/issues/3099) - && wget https://raw.githubusercontent.com/iovisor/bcc/master/tools/biosnoop.py -O /usr/share/bcc/tools/biosnoop - -ENV PATH="${PATH}:/usr/share/bcc/tools" + && apk add --no-cache zfs lvm2 bash util-linux tzdata WORKDIR /home/dblab diff --git a/engine/Dockerfile.dblab-server-debug b/engine/Dockerfile.dblab-server-debug index 84d31ef4..af6b1f17 100644 --- a/engine/Dockerfile.dblab-server-debug +++ b/engine/Dockerfile.dblab-server-debug @@ -1,7 +1,7 @@ # How to start a container: https://postgres.ai/docs/how-to-guides/administration/engine-manage # Compile stage -FROM golang:1.18 AS build-env +FROM golang:1.23 AS build-env # Build Delve RUN go install github.com/go-delve/delve/cmd/dlv@latest @@ -17,14 +17,7 @@ FROM docker:20.10.12 # Install dependencies RUN apk update \ && apk add zfs=2.1.4-r0 --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/main \ - && apk add --no-cache lvm2 bash util-linux -RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.13/main' >> /etc/apk/repositories \ - && echo 'http://dl-cdn.alpinelinux.org/alpine/v3.13/community' >> /etc/apk/repositories \ - && apk add bcc-tools=0.18.0-r0 bcc-doc=0.18.0-r0 && ln -s $(which python3) /usr/bin/python \ - # TODO: remove after release the PR: https://github.com/iovisor/bcc/pull/3286 (issue: https://github.com/iovisor/bcc/issues/3099) - && wget https://raw.githubusercontent.com/iovisor/bcc/master/tools/biosnoop.py -O /usr/share/bcc/tools/biosnoop - -ENV PATH="${PATH}:/usr/share/bcc/tools" + && apk add --no-cache lvm2 bash util-linux tzdata WORKDIR /home/dblab diff --git a/engine/Dockerfile.dblab-server-zfs08 b/engine/Dockerfile.dblab-server-zfs08 index 02d55262..5ed8938c 100644 --- a/engine/Dockerfile.dblab-server-zfs08 +++ b/engine/Dockerfile.dblab-server-zfs08 @@ -1,17 +1,10 @@ # See Guides to learn how to start a container: https://postgres.ai/docs/how-to-guides/administration/engine-manage -FROM docker:20.10.12 +FROM docker:20.10.24 # Install dependencies. RUN apk update && apk add zfs=0.8.4-r0 --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/v3.12/main \ - && apk add --no-cache lvm2 bash util-linux -RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.13/main' >> /etc/apk/repositories \ - && echo 'http://dl-cdn.alpinelinux.org/alpine/v3.13/community' >> /etc/apk/repositories \ - && apk add bcc-tools=0.18.0-r0 bcc-doc=0.18.0-r0 && ln -s $(which python3) /usr/bin/python \ - # TODO: remove after release the PR: https://github.com/iovisor/bcc/pull/3286 (issue: https://github.com/iovisor/bcc/issues/3099) - && wget https://raw.githubusercontent.com/iovisor/bcc/master/tools/biosnoop.py -O /usr/share/bcc/tools/biosnoop - -ENV PATH="${PATH}:/usr/share/bcc/tools" + && apk add --no-cache lvm2 bash util-linux tzdata WORKDIR /home/dblab diff --git a/engine/Makefile b/engine/Makefile index e76f7538..84bf96de 100644 --- a/engine/Makefile +++ b/engine/Makefile @@ -5,6 +5,8 @@ RUN_CI_BINARY = run-ci CLI_BINARY = dblab GOARCH = amd64 +PWD= $(shell pwd) + COMMIT?=$(shell git rev-parse HEAD) BUILD_TIME?=$(shell date -u '+%Y%m%d-%H%M') VERSION=$(shell git describe --tags --match "v*" 2>/dev/null || echo "${COMMIT}") @@ -22,7 +24,7 @@ GOBUILD = GO111MODULE=on CGO_ENABLED=0 GOARCH=${GOARCH} go build ${LDFLAGS} GOTEST = GO111MODULE=on go test -race CLIENT_PLATFORMS=darwin linux freebsd windows -ARCHITECTURES=amd64 +ARCHITECTURES=amd64 arm64 help: ## Display the help message @echo "Please use \`make \` where is one of:" @@ -32,7 +34,7 @@ help: ## Display the help message all: clean build ## Build all binary components of the project install-lint: ## Install the linter to $GOPATH/bin which is expected to be in $PATH - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.45.0 + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.0 run-lint: ## Run linters golangci-lint run @@ -77,4 +79,20 @@ fmt: ## Format code clean: ## Remove compiled binaries from the local bin/ directory rm -f bin/* -.PHONY: help all build test run-lint install-lint lint fmt clean build-image build-dle build-ci-checker build-client build-ci-checker +run-dle: build-dle + docker run \ + --rm \ + --volume /tmp:/tmp \ + --volume /var/run/docker.sock:/var/run/docker.sock \ + --volume /var/lib/dblab:/var/lib/dblab/:rshared \ + --volume /var/lib/dblab/dblab_pool/dump:/var/lib/dblab/dblab_pool/dump \ + --volume /sys/kernel/debug:/sys/kernel/debug:rw \ + --volume /lib/modules:/lib/modules:ro \ + --volume $(PWD)/configs:/home/dblab/configs:ro \ + --volume $(PWD)/meta:/home/dblab/meta \ + --volume /proc:/host_proc:ro \ + --env DOCKER_API_VERSION=1.39 \ + -p "2345:2345" \ + dblab_server:local + +.PHONY: help all build test run-lint install-lint lint fmt clean build-image build-dle build-ci-checker build-client build-ci-checker run-dle diff --git a/engine/api/README.md b/engine/api/README.md new file mode 100644 index 00000000..37e228aa --- /dev/null +++ b/engine/api/README.md @@ -0,0 +1,24 @@ +# Database Lab Engine API + +## Directory Contents +- `swagger-spec` – OpenAPI 3.0 specification of DBLab API +- `swagger-ui` – Swagger UI to see the API specification (embedded in DBLab, available at :2345 or :2346/api) +- `postman` – [Postman](https://www.postman.com/) collection and environment files used to test the API in CI/CD pipelines via [`newman`](https://github.com/postmanlabs/newman) + +## Design principles +Work in progress: https://gitlab.com/postgres-ai/database-lab/-/merge_requests/744 + +## API docs +We use ReadMe.io to host the API documentation: https://dblab.readme.io/. Once a new API spec is ready, upload it as a new documentation version and publish. + +## Postman, newman, and CI/CD tests +The Postman collection is generated from the OpenAPI spec file using [Portman](https://github.com/apideck-libraries/portman). +1. Install and initialize `portman`. +1. Generate a new version of the Postman collection: + ``` + portman --cliOptionsFile engine/api/postman/portman-cli.json + ``` +1. Review and adjust the collection: + - Ensure object creation occurs before its deletion and pass the new object's ID between requests (TODO: provide example). + - Review and update tests as needed (TODO: details). +1. Commit, push, and ensure Newman's CI/CD testing passes. \ No newline at end of file diff --git a/engine/api/postman/branching.aws.postgres.ai.postman_environment.json b/engine/api/postman/branching.aws.postgres.ai.postman_environment.json new file mode 100644 index 00000000..407d3d88 --- /dev/null +++ b/engine/api/postman/branching.aws.postgres.ai.postman_environment.json @@ -0,0 +1,21 @@ +{ + "id": "30035c51-5e48-4d31-8676-2aac8af456ee", + "name": "branching.aws.postgres.ai", + "values": [ + { + "key": "baseUrl", + "value": "https://branching.aws.postgres.ai:446/api", + "type": "default", + "enabled": true + }, + { + "key": "verificationToken", + "value": "demo-token", + "type": "default", + "enabled": true + } + ], + "_postman_variable_scope": "environment", + "_postman_exported_at": "2023-05-18T04:01:37.154Z", + "_postman_exported_using": "Postman/10.14.2-230517-0637" +} \ No newline at end of file diff --git a/engine/api/postman/dblab.postman_collection.json b/engine/api/postman/dblab.postman_collection.json deleted file mode 100644 index 2c57013d..00000000 --- a/engine/api/postman/dblab.postman_collection.json +++ /dev/null @@ -1,431 +0,0 @@ -{ - "variables": [], - "info": { - "name": "Database Lab", - "_postman_id": "d0182a6c-79d0-877f-df91-18dbca63b734", - "description": "", - "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" - }, - "item": [ - { - "name": "status", - "event": [ - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "tests[\"Check instance status\"] = responseCode.code === 200 && jsonData && jsonData.status && jsonData.status.code && jsonData.status.code === \"OK\";" - ] - } - } - ], - "request": { - "url": "{{DBLAB_URL}}/status", - "method": "GET", - "header": [ - { - "key": "Verification-Token", - "value": "{{DBLAB_VERIFY_TOKEN}}", - "description": "" - }, - { - "key": "Content-Type", - "value": "application/json", - "description": "", - "disabled": true - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"dblab_id\": 1\n}" - }, - "description": "Select users" - }, - "response": [] - }, - { - "name": "snapshots", - "event": [ - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "tests[\"Check snapshots list\"] = responseCode.code === 200 && jsonData && Array.isArray(jsonData) && jsonData.length === 1;", - "" - ] - } - } - ], - "request": { - "url": "{{DBLAB_URL}}/snapshots", - "method": "GET", - "header": [ - { - "key": "Verification-Token", - "value": "{{DBLAB_VERIFY_TOKEN}}", - "description": "" - }, - { - "key": "Content-Type", - "value": "application/json", - "description": "" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"dblab_id\": 1\n}" - }, - "description": "Select users" - }, - "response": [] - }, - { - "name": "clone not found", - "event": [ - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "tests[\"Check for clone status\"] = responseCode.code === 404 && jsonData && jsonData.detail && jsonData.detail === \"Requested object does not exist.\";", - "" - ] - } - } - ], - "request": { - "url": "{{DBLAB_URL}}/clone/bopta26mq8oddsim86v0", - "method": "GET", - "header": [ - { - "key": "Verification-Token", - "value": "{{DBLAB_VERIFY_TOKEN}}", - "description": "" - }, - { - "key": "Content-Type", - "value": "application/json", - "description": "" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"dblab_id\": 1\n}" - }, - "description": "Select users" - }, - "response": [] - }, - { - "name": "create clone", - "event": [ - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "tests[\"Check for clone create\"] = responseCode.code === 201 && jsonData && jsonData.id && jsonData.status && ", - "(jsonData.status.code == 'OK' || jsonData.status.code == 'CREATING');", - "postman.setGlobalVariable(\"DBLAB_CLONE_ID\", jsonData.id);" - ] - } - } - ], - "request": { - "url": "{{DBLAB_URL}}/clone", - "method": "POST", - "header": [ - { - "key": "Verification-Token", - "value": "{{DBLAB_VERIFY_TOKEN}}", - "description": "" - }, - { - "key": "Content-Type", - "value": "application/json", - "description": "" - } - ], - "body": { - "mode": "raw", - "raw": "{\r\n\t\"name\": \"test-demo-clone\",\r\n\t\"protected\": false,\r\n\t\"db\": {\r\n\t\t\"username\": \"username\",\r\n\t\t\"password\": \"password\"\r\n\t}\r\n}" - }, - "description": "Select users" - }, - "response": [] - }, - { - "name": "clone status", - "event": [ - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "tests[\"Check for clone status\"] = responseCode.code === 200 && jsonData && jsonData.id && jsonData.status && ", - "(jsonData.status.code == 'OK' || jsonData.status.code == 'CREATING');", - "" - ] - } - } - ], - "request": { - "url": "{{DBLAB_URL}}/clone/{{DBLAB_CLONE_ID}}", - "method": "GET", - "header": [ - { - "key": "Verification-Token", - "value": "{{DBLAB_VERIFY_TOKEN}}", - "description": "" - }, - { - "key": "Content-Type", - "value": "application/json", - "description": "" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"dblab_id\": 1\n}" - }, - "description": "Select users" - }, - "response": [] - }, - { - "name": "clone update (name, protected)", - "event": [ - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "tests[\"Check for clone update\"] = responseCode.code === 200;", - "" - ] - } - } - ], - "request": { - "url": "{{DBLAB_URL}}/clone/{{DBLAB_CLONE_ID}}", - "method": "PATCH", - "header": [ - { - "key": "Verification-Token", - "value": "{{DBLAB_VERIFY_TOKEN}}", - "description": "" - }, - { - "key": "Content-Type", - "value": "application/json", - "description": "", - "disabled": true - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"protected\": true,\n\t\"name\": \"UPDATE_CLONE_TEST\"\n}" - }, - "description": "Select users" - }, - "response": [] - }, - { - "name": "clone/reset", - "event": [ - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "tests[\"Check for clone reset\"] = responseCode.code === 200;", - "" - ] - } - } - ], - "request": { - "url": "{{DBLAB_URL}}/clone/{{DBLAB_CLONE_ID}}/reset", - "method": "POST", - "header": [ - { - "key": "Verification-Token", - "value": "{{DBLAB_VERIFY_TOKEN}}", - "description": "" - }, - { - "key": "Content-Type", - "value": "application/json", - "description": "", - "disabled": true - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"id\": \"xxx\"\n}" - }, - "description": "Select users" - }, - "response": [] - }, - { - "name": "delete protected clone", - "event": [ - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "tests[\"Check for delete protected clone\"] = responseCode.code === 500 && jsonData && jsonData.detail && jsonData.detail === \"clone is protected\";", - "" - ] - } - } - ], - "request": { - "url": "{{DBLAB_URL}}/clone/{{DBLAB_CLONE_ID}}", - "method": "DELETE", - "header": [ - { - "key": "Verification-Token", - "value": "{{DBLAB_VERIFY_TOKEN}}", - "description": "" - }, - { - "key": "Content-Type", - "value": "application/json", - "description": "" - } - ], - "body": { - "mode": "raw", - "raw": "" - }, - "description": "Select users" - }, - "response": [] - }, - { - "name": "clone update (disable protection)", - "event": [ - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "tests[\"Check for clone update\"] = responseCode.code === 200;", - "" - ] - } - } - ], - "request": { - "url": "{{DBLAB_URL}}/clone/{{DBLAB_CLONE_ID}}", - "method": "PATCH", - "header": [ - { - "key": "Verification-Token", - "value": "{{DBLAB_VERIFY_TOKEN}}", - "description": "" - }, - { - "key": "Content-Type", - "value": "application/json", - "description": "", - "disabled": true - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"protected\": false\n}" - }, - "description": "Select users" - }, - "response": [] - }, - { - "name": "delete clone", - "event": [ - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "tests[\"Check for delete protected clone\"] = responseCode.code === 200;", - "" - ] - } - } - ], - "request": { - "url": "{{DBLAB_URL}}/clone/{{DBLAB_CLONE_ID}}", - "method": "DELETE", - "header": [ - { - "key": "Verification-Token", - "value": "{{DBLAB_VERIFY_TOKEN}}", - "description": "" - }, - { - "key": "Content-Type", - "value": "application/json", - "description": "" - } - ], - "body": { - "mode": "raw", - "raw": "" - }, - "description": "Select users" - }, - "response": [] - }, - { - "name": "removed clone status", - "event": [ - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "tests[\"Check for clone status\"] = (responseCode.code === 200 && jsonData && jsonData.id && jsonData.status && ", - "jsonData.status.code == 'DELETING') || responseCode.code == 404;", - "" - ] - } - } - ], - "request": { - "url": "{{DBLAB_URL}}/clone/{{DBLAB_CLONE_ID}}", - "method": "GET", - "header": [ - { - "key": "Verification-Token", - "value": "{{DBLAB_VERIFY_TOKEN}}", - "description": "" - }, - { - "key": "Content-Type", - "value": "application/json", - "description": "" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"dblab_id\": 1\n}" - }, - "description": "Select users" - }, - "response": [] - } - ] -} diff --git a/engine/api/postman/dblab.postman_environment.json b/engine/api/postman/dblab.postman_environment.json deleted file mode 100644 index 5f7244c9..00000000 --- a/engine/api/postman/dblab.postman_environment.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "id": "ff4200f0-7acd-eb4f-1dee-59da8c98c313", - "name": "Database Lab", - "values": [ - { - "enabled": true, - "key": "DBLAB_URL", - "value": "https://url", - "type": "text" - }, - { - "enabled": true, - "key": "DBLAB_VERIFY_TOKEN", - "value": "secret_token", - "type": "text" - } - ], - "timestamp": 1580454458304, - "_postman_variable_scope": "environment", - "_postman_exported_at": "2020-01-31T09:42:37.377Z", - "_postman_exported_using": "Postman/5.5.4" -} diff --git a/engine/api/postman/dblab_api.postman_collection.json b/engine/api/postman/dblab_api.postman_collection.json new file mode 100644 index 00000000..7995382f --- /dev/null +++ b/engine/api/postman/dblab_api.postman_collection.json @@ -0,0 +1,4057 @@ +{ + "info": { + "_postman_id": "ed8af9f0-1cde-4633-8a57-a47e10d12bfa", + "name": "DBLab API 4.0.0-beta.2", + "description": "This page provides the OpenAPI specification for the Database Lab (DBLab) API, previously recognized as the DLE API (Database Lab Engine API).\n\nContact Support:\n Name: DBLab API Support\n Email: api@postgres.ai", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "34026417" + }, + "item": [ + { + "name": "Instance", + "item": [ + { + "name": "DBLab instance status and detailed information", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Validate status 2xx ", + "pm.test(\"[GET]::/status - Status code is 2xx\", function () {", + " pm.response.to.be.success;", + "});", + "", + "// Validate if response header has matching content-type", + "pm.test(\"[GET]::/status - Content-Type is application/json\", function () {", + " pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(\"application/json\");", + "});", + "", + "// Validate if response has JSON Body ", + "pm.test(\"[GET]::/status - Response has JSON Body\", function () {", + " pm.response.to.have.jsonBody();", + "});", + "", + "// Response Validation", + "const schema = {\"type\":\"object\",\"properties\":{\"status\":{\"required\":[\"code\",\"message\"],\"type\":\"object\",\"properties\":{\"code\":{\"type\":\"string\",\"description\":\"Status code\"},\"message\":{\"type\":\"string\",\"description\":\"Status description\"}}},\"engine\":{\"type\":\"object\",\"properties\":{\"version\":{\"type\":\"string\"},\"edition\":{\"type\":\"string\"},\"billingActive\":{\"type\":\"string\"},\"instanceID\":{\"type\":\"string\"},\"startedAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"telemetry\":{\"type\":\"boolean\"},\"disableConfigModification\":{\"type\":\"boolean\"}}},\"pools\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"},\"mode\":{\"type\":\"string\"},\"dataStateAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"status\":{\"type\":\"string\"},\"cloneList\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"fileSystem\":{\"type\":\"object\",\"properties\":{\"mode\":{\"type\":\"string\"},\"free\":{\"type\":\"integer\",\"format\":\"int64\"},\"size\":{\"type\":\"integer\",\"format\":\"int64\"},\"used\":{\"type\":\"integer\",\"format\":\"int64\"},\"dataSize\":{\"type\":\"integer\",\"format\":\"int64\"},\"usedBySnapshots\":{\"type\":\"integer\",\"format\":\"int64\"},\"usedByClones\":{\"type\":\"integer\",\"format\":\"int64\"},\"compressRatio\":{\"type\":\"integer\",\"format\":\"float64\"}}}}}},\"cloning\":{\"type\":\"object\",\"properties\":{\"expectedCloningTime\":{\"type\":\"integer\",\"format\":\"float64\"},\"numClones\":{\"type\":\"integer\",\"format\":\"int64\"},\"clones\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"name\":{\"type\":\"string\"},\"snapshot\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"createdAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"dataStateAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"physicalSize\":{\"type\":\"integer\",\"format\":\"int64\"},\"logicalSize\":{\"type\":\"integer\",\"format\":\"int64\"},\"pool\":{\"type\":\"string\"},\"numClones\":{\"type\":\"integer\",\"format\":\"int\"}}},\"protected\":{\"type\":\"boolean\",\"default\":false},\"deleteAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"createdAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"status\":{\"required\":[\"code\",\"message\"],\"type\":\"object\",\"properties\":{\"code\":{\"type\":\"string\",\"description\":\"Status code\"},\"message\":{\"type\":\"string\",\"description\":\"Status description\"}}},\"db\":{\"type\":\"object\",\"properties\":{\"connStr\":{\"type\":\"string\"},\"host\":{\"type\":\"string\"},\"port\":{\"type\":\"string\"},\"username\":{\"type\":\"string\"},\"password\":{\"type\":\"string\"}}},\"metadata\":{\"type\":\"object\",\"properties\":{\"cloneDiffSize\":{\"type\":\"integer\",\"format\":\"int64\"},\"logicalSize\":{\"type\":\"integer\",\"format\":\"int64\"},\"cloningTime\":{\"type\":\"integer\",\"format\":\"float64\"},\"maxIdleMinutes\":{\"type\":\"integer\",\"format\":\"int64\"}}}}}}}},\"retrieving\":{\"type\":\"object\",\"properties\":{\"mode\":{\"type\":\"string\"},\"status\":{\"type\":\"string\"},\"lastRefresh\":{\"type\":\"string\",\"format\":\"date-time\"},\"nextRefresh\":{\"type\":\"string\",\"format\":\"date-time\"},\"alerts\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"activity\":{\"type\":\"object\",\"properties\":{\"source\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"user\":{\"type\":\"string\"},\"query\":{\"type\":\"string\"},\"duration\":{\"type\":\"number\"},\"waitEventType\":{\"type\":\"string\"},\"waitEvent\":{\"type\":\"string\"}}}},\"target\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"user\":{\"type\":\"string\"},\"query\":{\"type\":\"string\"},\"duration\":{\"type\":\"number\"},\"waitEventType\":{\"type\":\"string\"},\"waitEvent\":{\"type\":\"string\"}}}}}}}},\"provisioner\":{\"type\":\"object\",\"properties\":{\"dockerImage\":{\"type\":\"string\"},\"containerConfig\":{\"type\":\"object\",\"properties\":{}}}},\"synchronization\":{\"type\":\"object\",\"properties\":{\"status\":{\"required\":[\"code\",\"message\"],\"type\":\"object\",\"properties\":{\"code\":{\"type\":\"string\",\"description\":\"Status code\"},\"message\":{\"type\":\"string\",\"description\":\"Status description\"}}},\"startedAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"lastReplayedLsn\":{\"type\":\"string\"},\"lastReplayedLsnAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"replicationLag\":{\"type\":\"string\"},\"replicationUptime\":{\"type\":\"integer\"}}}}}", + "", + "// Validate if response matches JSON schema ", + "pm.test(\"[GET]::/status - Schema is valid\", function() {", + " pm.response.to.have.jsonSchema(schema,{unknownFormats: [\"int32\", \"int64\", \"float\", \"double\"]});", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "{{verificationToken}}", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/status", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "status" + ] + }, + "description": "Retrieves detailed information about the DBLab instance: status, version, clones, snapshots, etc." + }, + "response": [ + { + "name": "Returned detailed information about the DBLab instance", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/status", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "status" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"status\": {\n \"code\": \"OK\",\n \"message\": \"Instance is ready\"\n },\n \"engine\": {\n \"version\": \"v4.0.0-alpha.5-20230516-0224\",\n \"edition\": \"standard\",\n \"billingActive\": true,\n \"instanceID\": \"chhfqfcnvrvc73d0lij0\",\n \"startedAt\": \"2023-05-16T03:50:19Z\",\n \"telemetry\": true,\n \"disableConfigModification\": false\n },\n \"pools\": [\n {\n \"name\": \"dblab_pool/dataset_1\",\n \"mode\": \"zfs\",\n \"dataStateAt\": \"\",\n \"status\": \"empty\",\n \"cloneList\": [],\n \"fileSystem\": {\n \"mode\": \"zfs\",\n \"size\": 30685528064,\n \"free\": 30685282816,\n \"used\": 245248,\n \"dataSize\": 12288,\n \"usedBySnapshots\": 0,\n \"usedByClones\": 219648,\n \"compressRatio\": 1\n }\n },\n {\n \"name\": \"dblab_pool/dataset_2\",\n \"mode\": \"zfs\",\n \"dataStateAt\": \"\",\n \"status\": \"empty\",\n \"cloneList\": [],\n \"fileSystem\": {\n \"mode\": \"zfs\",\n \"size\": 30685528064,\n \"free\": 30685282816,\n \"used\": 245248,\n \"dataSize\": 12288,\n \"usedBySnapshots\": 0,\n \"usedByClones\": 219648,\n \"compressRatio\": 1\n }\n },\n {\n \"name\": \"dblab_pool/dataset_3\",\n \"mode\": \"zfs\",\n \"dataStateAt\": \"\",\n \"status\": \"empty\",\n \"cloneList\": [],\n \"fileSystem\": {\n \"mode\": \"zfs\",\n \"size\": 30685528064,\n \"free\": 30685282816,\n \"used\": 245248,\n \"dataSize\": 12288,\n \"usedBySnapshots\": 0,\n \"usedByClones\": 219648,\n \"compressRatio\": 1\n }\n }\n ],\n \"cloning\": {\n \"expectedCloningTime\": 0,\n \"numClones\": 0,\n \"clones\": []\n },\n \"retrieving\": {\n \"mode\": \"logical\",\n \"status\": \"pending\",\n \"lastRefresh\": null,\n \"nextRefresh\": null,\n \"alerts\": {},\n \"activity\": null\n },\n \"provisioner\": {\n \"dockerImage\": \"postgresai/extended-postgres:15\",\n \"containerConfig\": {\n \"shm-size\": \"1gb\"\n }\n },\n \"synchronization\": {\n \"status\": {\n \"code\": \"Not available\",\n \"message\": \"\"\n },\n \"lastReplayedLsn\": \"\",\n \"lastReplayedLsnAt\": \"\",\n \"replicationLag\": 0,\n \"replicationUptime\": 0\n }\n}" + }, + { + "name": "Unauthorized access", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/status", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "status" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"UNAUTHORIZED\",\n \"message\": \"Check your verification token.\"\n}" + } + ] + }, + { + "name": "Data refresh status", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Validate status 2xx ", + "pm.test(\"[GET]::/instance/retrieval - Status code is 2xx\", function () {", + " pm.response.to.be.success;", + "});", + "", + "// Validate if response header has matching content-type", + "pm.test(\"[GET]::/instance/retrieval - Content-Type is application/json\", function () {", + " pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(\"application/json\");", + "});", + "", + "// Validate if response has JSON Body ", + "pm.test(\"[GET]::/instance/retrieval - Response has JSON Body\", function () {", + " pm.response.to.have.jsonBody();", + "});", + "", + "// Response Validation", + "const schema = {\"type\":\"object\",\"properties\":{\"mode\":{\"type\":\"string\"},\"status\":{\"type\":\"string\"},\"lastRefresh\":{\"type\":\"string\",\"format\":\"date-time\"},\"nextRefresh\":{\"type\":\"string\",\"format\":\"date-time\"},\"alerts\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"activity\":{\"type\":\"object\",\"properties\":{\"source\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"user\":{\"type\":\"string\"},\"query\":{\"type\":\"string\"},\"duration\":{\"type\":\"number\"},\"waitEventType\":{\"type\":\"string\"},\"waitEvent\":{\"type\":\"string\"}}}},\"target\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"user\":{\"type\":\"string\"},\"query\":{\"type\":\"string\"},\"duration\":{\"type\":\"number\"},\"waitEventType\":{\"type\":\"string\"},\"waitEvent\":{\"type\":\"string\"}}}}}}}}", + "", + "// Validate if response matches JSON schema ", + "pm.test(\"[GET]::/instance/retrieval - Schema is valid\", function() {", + " pm.response.to.have.jsonSchema(schema,{unknownFormats: [\"int32\", \"int64\", \"float\", \"double\"]});", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "{{verificationToken}}", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/instance/retrieval", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "instance", + "retrieval" + ] + }, + "description": "Report a status of the data refresh subsystem (also known as \"data retrieval\"): timestamps of the previous and next refresh runs, status, messages." + }, + "response": [ + { + "name": "Reported a status of the data retrieval subsystem", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/instance/retrieval", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "instance", + "retrieval" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"mode\": \"logical\",\n \"status\": \"pending\",\n \"lastRefresh\": null,\n \"nextRefresh\": null,\n \"alerts\": {},\n \"activity\": null\n}" + }, + { + "name": "Unauthorized access", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/instance/retrieval", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "instance", + "retrieval" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"UNAUTHORIZED\",\n \"message\": \"Check your verification token.\"\n}" + } + ] + }, + { + "name": "Service health check", + "event": [ + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "// Validate status 2xx \npm.test(\"[GET]::/healthz - Status code is 2xx\", function () {\n pm.response.to.be.success;\n});\n", + "// Validate if response header has matching content-type\npm.test(\"[GET]::/healthz - Content-Type is application/json\", function () {\n pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(\"application/json\");\n});\n", + "// Validate if response has JSON Body \npm.test(\"[GET]::/healthz - Response has JSON Body\", function () {\n pm.response.to.have.jsonBody();\n});\n", + "// Response Validation\nconst schema = {\"type\":\"object\",\"properties\":{\"version\":{\"type\":\"string\"},\"edition\":{\"type\":\"string\"},\"billingActive\":{\"type\":\"string\"},\"instanceID\":{\"type\":\"string\"},\"startedAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"telemetry\":{\"type\":\"boolean\"},\"disableConfigModification\":{\"type\":\"boolean\"}}}\n\n// Validate if response matches JSON schema \npm.test(\"[GET]::/healthz - Schema is valid\", function() {\n pm.response.to.have.jsonSchema(schema,{unknownFormats: [\"int32\", \"int64\", \"float\", \"double\"]});\n});\n" + ] + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/healthz", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "healthz" + ] + }, + "description": "Check the overall health and availability of the API system. This endpoint does not require the 'Verification-Token' header." + }, + "response": [ + { + "name": "Successful operation", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/healthz", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "healthz" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"version\": \"v4.0.0-alpha.5-20230516-0224\",\n \"edition\": \"standard\",\n \"instanceID\": \"chhfqfcnvrvc73d0lij0\"\n}" + } + ] + } + ] + }, + { + "name": "Snapshots", + "item": [ + { + "name": "List all snapshots", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Validate status 2xx ", + "pm.test(\"[GET]::/snapshots - Status code is 2xx\", function () {", + " pm.response.to.be.success;", + "});", + "", + "// Validate if response header has matching content-type", + "pm.test(\"[GET]::/snapshots - Content-Type is application/json\", function () {", + " pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(\"application/json\");", + "});", + "", + "// Validate if response has JSON Body ", + "pm.test(\"[GET]::/snapshots - Response has JSON Body\", function () {", + " pm.response.to.have.jsonBody();", + "});", + "", + "// Response Validation", + "const schema = {\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"createdAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"dataStateAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"physicalSize\":{\"type\":\"integer\",\"format\":\"int64\"},\"logicalSize\":{\"type\":\"integer\",\"format\":\"int64\"},\"pool\":{\"type\":\"string\"},\"numClones\":{\"type\":\"integer\",\"format\":\"int\"}}}}", + "", + "// Validate if response matches JSON schema ", + "pm.test(\"[GET]::/snapshots - Schema is valid\", function() {", + " pm.response.to.have.jsonSchema(schema,{unknownFormats: [\"int32\", \"int64\", \"float\", \"double\"]});", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "{{verificationToken}}", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/snapshots", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "snapshots" + ] + }, + "description": "Return a list of all available snapshots." + }, + "response": [ + { + "name": "Returned a list of snapshots", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/snapshots", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "snapshots" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "[\n {\n \"id\": \"dblab_pool/dataset_2/nik-test-branch/20230509212711@20230509212711\",\n \"createdAt\": \"2023-05-09T21:27:11Z\",\n \"dataStateAt\": \"2023-05-09T21:27:11Z\",\n \"physicalSize\": 0,\n \"logicalSize\": 11518021632,\n \"pool\": \"dblab_pool/dataset_2\",\n \"numClones\": 1\n },\n {\n \"id\": \"dblab_pool/dataset_2/nik-test-branch/20230307171959@20230307171959\",\n \"createdAt\": \"2023-03-07T17:19:59Z\",\n \"dataStateAt\": \"2023-03-07T17:19:59Z\",\n \"physicalSize\": 151552,\n \"logicalSize\": 11518015488,\n \"pool\": \"dblab_pool/dataset_2\",\n \"numClones\": 1\n }\n]" + }, + { + "name": "Unauthorized access", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/snapshots", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "snapshots" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"UNAUTHORIZED\",\n \"message\": \"Check your verification token.\"\n}" + } + ] + }, + { + "name": "Create a snapshot", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Validate status 2xx ", + "pm.test(\"[POST]::/branch/snapshot - Status code is 2xx\", function () {", + " pm.response.to.be.success;", + "});", + "", + "// Validate if response header has matching content-type", + "pm.test(\"[POST]::/branch/snapshot - Content-Type is */*\", function () {", + " pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(\"*/*\");", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "{{verificationToken}}", + "description": "(Required) " + }, + { + "key": "Content-Type", + "value": "*/*" + }, + { + "key": "Accept", + "value": "*/*" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"cloneID\": \"test3\",\n \"message\": \"do\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/branch/snapshot", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "branch", + "snapshot" + ] + }, + "description": "Create a new snapshot using the specified clone. After a snapshot has been created, the original clone can be deleted in order to free up compute resources, if necessary. The snapshot created by this endpoint can be used later to create one or more new clones." + }, + "response": [ + { + "name": "OK", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "*/*" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"cloneID\": \"aliquip sit nisi\",\n \"message\": \"do\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/branch/snapshot", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "branch", + "snapshot" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "*/*" + } + ], + "cookie": [], + "body": "{\n \"snapshotID\": \"voluptate\"\n}" + }, + { + "name": "Bad request", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "*/*" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"cloneID\": \"aliquip sit nisi\",\n \"message\": \"do\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/branch/snapshot", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "branch", + "snapshot" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "*/*" + } + ], + "cookie": [], + "body": "{\n \"code\": \"incididunt minim nulla\",\n \"message\": \"qui fugiat\",\n \"detail\": \"occaecat\",\n \"hint\": \"anim\"\n}" + } + ] + }, + { + "name": "Retrieve a snapshot", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Validate status 2xx ", + "pm.test(\"[GET]::/branch/snapshot/:id - Status code is 2xx\", function () {", + " pm.response.to.be.success;", + "});", + "", + "// Validate if response header has matching content-type", + "pm.test(\"[GET]::/branch/snapshot/:id - Content-Type is */*\", function () {", + " pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(\"*/*\");", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "{{verificationToken}}", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "*/*" + } + ], + "url": { + "raw": "{{baseUrl}}/branch/snapshot/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "branch", + "snapshot", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "" + } + ] + }, + "description": "Retrieves the information for the specified snapshot." + }, + "response": [ + { + "name": "OK", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "*/*" + } + ], + "url": { + "raw": "{{baseUrl}}/branch/snapshot/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "branch", + "snapshot", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "Ut magna qui deserunt", + "description": "(Required) ID of the branch snapshot" + } + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "*/*" + } + ], + "cookie": [], + "body": "{\n \"id\": \"nostrud exercitation id velit\",\n \"parent\": \"exercitation sunt do anim\",\n \"child\": \"cillum incididunt voluptate veniam\",\n \"branch\": [\n \"cillum\",\n \"Excepteur ut ut occaecat eu\"\n ],\n \"root\": \"mollit culpa enim nostrud\",\n \"dataStateAt\": \"2008-01-19T00:42:22.510Z\",\n \"message\": \"irure qui \"\n}" + }, + { + "name": "Bad request", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "*/*" + } + ], + "url": { + "raw": "{{baseUrl}}/branch/snapshot/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "branch", + "snapshot", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "Ut magna qui deserunt", + "description": "(Required) ID of the branch snapshot" + } + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "*/*" + } + ], + "cookie": [], + "body": "{\n \"code\": \"incididunt minim nulla\",\n \"message\": \"qui fugiat\",\n \"detail\": \"occaecat\",\n \"hint\": \"anim\"\n}" + } + ] + }, + { + "name": "Delete a snapshot", + "request": { + "method": "DELETE", + "header": [ + { + "key": "Verification-Token", + "value": "{{verificationToken}}", + "description": "(Required) ", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/snapshot/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "snapshot", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "lorem" + } + ] + } + }, + "response": [ + { + "name": "OK", + "originalRequest": { + "method": "DELETE", + "header": [ + { + "key": "Verification-Token", + "value": "{{verificationToken}}", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/snapshot/dblab_pool/dataset_3@snapshot_20250324084404", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "snapshot", + "dblab_pool", + "dataset_3@snapshot_20250324084404" + ] + } + }, + "_postman_previewlanguage": null, + "header": null, + "cookie": [], + "body": null + }, + { + "name": "Bad request", + "originalRequest": { + "method": "DELETE", + "header": [ + { + "key": "Verification-Token", + "value": "{{verificationToken}}", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/snapshot/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "snapshot", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "" + } + ] + } + }, + "_postman_previewlanguage": null, + "header": null, + "cookie": [], + "body": "{\n \"code\": \"incididunt minim nulla\",\n \"message\": \"qui fugiat\"\n}" + } + ] + } + ] + }, + { + "name": "Clones", + "item": [ + { + "name": "List all clones", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Validate status 2xx ", + "pm.test(\"[GET]::/clones - Status code is 2xx\", function () {", + " pm.response.to.be.success;", + "});", + "", + "// Validate if response header has matching content-type", + "pm.test(\"[GET]::/clones - Content-Type is application/json\", function () {", + " pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(\"application/json\");", + "});", + "", + "// Validate if response has JSON Body ", + "pm.test(\"[GET]::/clones - Response has JSON Body\", function () {", + " pm.response.to.have.jsonBody();", + "});", + "", + "// Response Validation", + "const schema = {\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"name\":{\"type\":\"string\"},\"snapshot\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"createdAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"dataStateAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"physicalSize\":{\"type\":\"integer\",\"format\":\"int64\"},\"logicalSize\":{\"type\":\"integer\",\"format\":\"int64\"},\"pool\":{\"type\":\"string\"},\"numClones\":{\"type\":\"integer\",\"format\":\"int\"}}},\"protected\":{\"type\":\"boolean\",\"default\":false},\"deleteAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"createdAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"status\":{\"required\":[\"code\",\"message\"],\"type\":\"object\",\"properties\":{\"code\":{\"type\":\"string\",\"description\":\"Status code\"},\"message\":{\"type\":\"string\",\"description\":\"Status description\"}}},\"db\":{\"type\":\"object\",\"properties\":{\"connStr\":{\"type\":\"string\"},\"host\":{\"type\":\"string\"},\"port\":{\"type\":\"string\"},\"username\":{\"type\":\"string\"},\"password\":{\"type\":\"string\"}}},\"metadata\":{\"type\":\"object\",\"properties\":{\"cloneDiffSize\":{\"type\":\"integer\",\"format\":\"int64\"},\"logicalSize\":{\"type\":\"integer\",\"format\":\"int64\"},\"cloningTime\":{\"type\":\"integer\",\"format\":\"float64\"},\"maxIdleMinutes\":{\"type\":\"integer\",\"format\":\"int64\"}}}}}}", + "", + "// Validate if response matches JSON schema ", + "pm.test(\"[GET]::/clones - Schema is valid\", function() {", + " pm.response.to.have.jsonSchema(schema,{unknownFormats: [\"int32\", \"int64\", \"float\", \"double\"]});", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "{{verificationToken}}", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/clones", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "clones" + ] + }, + "description": "Return a list of all available clones (database endpoints)." + }, + "response": [ + { + "name": "Returned a list of all available clones", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/clones", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "clones" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "[\n {\n \"id\": \"test-clone-2\",\n \"snapshot\": {\n \"id\": \"dblab_pool/dataset_2/nik-test-branch/20230509212711@20230509212711\",\n \"createdAt\": \"2023-05-09T21:27:11Z\",\n \"dataStateAt\": \"2023-05-09T21:27:11Z\",\n \"physicalSize\": 120832,\n \"logicalSize\": 11518021632,\n \"pool\": \"dblab_pool/dataset_2\",\n \"numClones\": 3\n },\n \"branch\": \"\",\n \"protected\": false,\n \"deleteAt\": null,\n \"createdAt\": \"2023-05-16T06:12:52Z\",\n \"status\": {\n \"code\": \"OK\",\n \"message\": \"Clone is ready to accept Postgres connections.\"\n },\n \"db\": {\n \"connStr\": \"host=branching.aws.postgres.ai port=6005 user=tester dbname=postgres\",\n \"host\": \"branching.aws.postgres.ai\",\n \"port\": \"6005\",\n \"username\": \"tester\",\n \"password\": \"\",\n \"dbName\": \"postgres\"\n },\n \"metadata\": {\n \"cloneDiffSize\": 484352,\n \"logicalSize\": 11518029312,\n \"cloningTime\": 1.5250661829999999,\n \"maxIdleMinutes\": 120\n }\n },\n {\n \"id\": \"test-clone\",\n \"snapshot\": {\n \"id\": \"dblab_pool/dataset_2/nik-test-branch/20230509212711@20230509212711\",\n \"createdAt\": \"2023-05-09T21:27:11Z\",\n \"dataStateAt\": \"2023-05-09T21:27:11Z\",\n \"physicalSize\": 120832,\n \"logicalSize\": 11518021632,\n \"pool\": \"dblab_pool/dataset_2\",\n \"numClones\": 3\n },\n \"branch\": \"\",\n \"protected\": false,\n \"deleteAt\": null,\n \"createdAt\": \"2023-05-16T06:12:30Z\",\n \"status\": {\n \"code\": \"OK\",\n \"message\": \"Clone is ready to accept Postgres connections.\"\n },\n \"db\": {\n \"connStr\": \"host=branching.aws.postgres.ai port=6004 user=tester dbname=postgres\",\n \"host\": \"branching.aws.postgres.ai\",\n \"port\": \"6004\",\n \"username\": \"tester\",\n \"password\": \"\",\n \"dbName\": \"postgres\"\n },\n \"metadata\": {\n \"cloneDiffSize\": 486400,\n \"logicalSize\": 11518030336,\n \"cloningTime\": 1.57552338,\n \"maxIdleMinutes\": 120\n }\n }\n]" + }, + { + "name": "Unauthorized access", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/clones", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "clones" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"UNAUTHORIZED\",\n \"message\": \"Check your verification token.\"\n}" + } + ] + }, + { + "name": "Create a clone", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Validate status 2xx ", + "pm.test(\"[POST]::/clone - Status code is 2xx\", function () {", + " pm.response.to.be.success;", + "});", + "", + "// Validate if response header has matching content-type", + "pm.test(\"[POST]::/clone - Content-Type is application/json\", function () {", + " pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(\"application/json\");", + "});", + "", + "// Validate if response has JSON Body ", + "pm.test(\"[POST]::/clone - Response has JSON Body\", function () {", + " pm.response.to.have.jsonBody();", + "});", + "", + "// Response Validation", + "const schema = {\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"name\":{\"type\":\"string\"},\"snapshot\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"createdAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"dataStateAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"physicalSize\":{\"type\":\"integer\",\"format\":\"int64\"},\"logicalSize\":{\"type\":\"integer\",\"format\":\"int64\"},\"pool\":{\"type\":\"string\"},\"numClones\":{\"type\":\"integer\",\"format\":\"int\"}}},\"protected\":{\"type\":\"boolean\",\"default\":false},\"deleteAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"createdAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"status\":{\"required\":[\"code\",\"message\"],\"type\":\"object\",\"properties\":{\"code\":{\"type\":\"string\",\"description\":\"Status code\"},\"message\":{\"type\":\"string\",\"description\":\"Status description\"}}},\"db\":{\"type\":\"object\",\"properties\":{\"connStr\":{\"type\":\"string\"},\"host\":{\"type\":\"string\"},\"port\":{\"type\":\"string\"},\"username\":{\"type\":\"string\"},\"password\":{\"type\":\"string\"}}},\"metadata\":{\"type\":\"object\",\"properties\":{\"cloneDiffSize\":{\"type\":\"integer\",\"format\":\"int64\"},\"logicalSize\":{\"type\":\"integer\",\"format\":\"int64\"},\"cloningTime\":{\"type\":\"integer\",\"format\":\"float64\"},\"maxIdleMinutes\":{\"type\":\"integer\",\"format\":\"int64\"}}}}}", + "", + "// Validate if response matches JSON schema ", + "pm.test(\"[POST]::/clone - Schema is valid\", function() {", + " pm.response.to.have.jsonSchema(schema,{unknownFormats: [\"int32\", \"int64\", \"float\", \"double\"]});", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "{{verificationToken}}", + "description": "(Required) " + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"magna cupidatat\",\n \"snapshot\": {\n \"id\": \"veniam\"\n },\n \"branch\": \"incididunt aliquip\",\n \"protected\": null,\n \"db\": {\n \"username\": \"Duis Lorem\",\n \"password\": \"culpa non velit ut\",\n \"restricted\": null,\n \"db_name\": \"dolore qui ut\"\n }\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/clone", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "clone" + ] + } + }, + "response": [ + { + "name": "Created a new clone", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"magna cupidatat\",\n \"snapshot\": {\n \"id\": \"veniam\"\n },\n \"branch\": \"incididunt aliquip\",\n \"protected\": null,\n \"db\": {\n \"username\": \"Duis Lorem\",\n \"password\": \"culpa non velit ut\",\n \"restricted\": null,\n \"db_name\": \"dolore qui ut\"\n }\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/clone", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "clone" + ] + } + }, + "status": "Created", + "code": 201, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"id\": \"test-clone-2\",\n \"snapshot\": {\n \"id\": \"dblab_pool/dataset_2/nik-test-branch/20230509212711@20230509212711\",\n \"createdAt\": \"2023-05-09T21:27:11Z\",\n \"dataStateAt\": \"2023-05-09T21:27:11Z\",\n \"physicalSize\": 120832,\n \"logicalSize\": 11518021632,\n \"pool\": \"dblab_pool/dataset_2\",\n \"numClones\": 3\n },\n \"branch\": \"\",\n \"protected\": false,\n \"deleteAt\": null,\n \"createdAt\": \"2023-05-16T06:12:52Z\",\n \"status\": {\n \"code\": \"CREATING\",\n \"message\": \"Clone is being created.\"\n },\n \"db\": {\n \"connStr\": \"\",\n \"host\": \"\",\n \"port\": \"\",\n \"username\": \"tester\",\n \"password\": \"\",\n \"dbName\": \"postgres\"\n },\n \"metadata\": {\n \"cloneDiffSize\": 0,\n \"logicalSize\": 0,\n \"cloningTime\": 0,\n \"maxIdleMinutes\": 0\n }\n}" + }, + { + "name": "Returned an error caused by invalid request", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"magna cupidatat\",\n \"snapshot\": {\n \"id\": \"veniam\"\n },\n \"branch\": \"incididunt aliquip\",\n \"protected\": null,\n \"db\": {\n \"username\": \"Duis Lorem\",\n \"password\": \"culpa non velit ut\",\n \"restricted\": null,\n \"db_name\": \"dolore qui ut\"\n }\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/clone", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "clone" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"BAD_REQUEST\",\n \"message\": \"clone with such ID already exists\"\n}" + }, + { + "name": "Unauthorized access", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"magna cupidatat\",\n \"snapshot\": {\n \"id\": \"veniam\"\n },\n \"branch\": \"incididunt aliquip\",\n \"protected\": null,\n \"db\": {\n \"username\": \"Duis Lorem\",\n \"password\": \"culpa non velit ut\",\n \"restricted\": null,\n \"db_name\": \"dolore qui ut\"\n }\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/clone", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "clone" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"UNAUTHORIZED\",\n \"message\": \"Check your verification token.\"\n}" + } + ] + }, + { + "name": "Retrieve a clone", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Validate status 2xx ", + "pm.test(\"[GET]::/clone/:id - Status code is 2xx\", function () {", + " pm.response.to.be.success;", + "});", + "", + "// Validate if response header has matching content-type", + "pm.test(\"[GET]::/clone/:id - Content-Type is application/json\", function () {", + " pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(\"application/json\");", + "});", + "", + "// Validate if response has JSON Body ", + "pm.test(\"[GET]::/clone/:id - Response has JSON Body\", function () {", + " pm.response.to.have.jsonBody();", + "});", + "", + "// Response Validation", + "const schema = {\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"name\":{\"type\":\"string\"},\"snapshot\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"createdAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"dataStateAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"physicalSize\":{\"type\":\"integer\",\"format\":\"int64\"},\"logicalSize\":{\"type\":\"integer\",\"format\":\"int64\"},\"pool\":{\"type\":\"string\"},\"numClones\":{\"type\":\"integer\",\"format\":\"int\"}}},\"protected\":{\"type\":\"boolean\",\"default\":false},\"deleteAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"createdAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"status\":{\"required\":[\"code\",\"message\"],\"type\":\"object\",\"properties\":{\"code\":{\"type\":\"string\",\"description\":\"Status code\"},\"message\":{\"type\":\"string\",\"description\":\"Status description\"}}},\"db\":{\"type\":\"object\",\"properties\":{\"connStr\":{\"type\":\"string\"},\"host\":{\"type\":\"string\"},\"port\":{\"type\":\"string\"},\"username\":{\"type\":\"string\"},\"password\":{\"type\":\"string\"}}},\"metadata\":{\"type\":\"object\",\"properties\":{\"cloneDiffSize\":{\"type\":\"integer\",\"format\":\"int64\"},\"logicalSize\":{\"type\":\"integer\",\"format\":\"int64\"},\"cloningTime\":{\"type\":\"integer\",\"format\":\"float64\"},\"maxIdleMinutes\":{\"type\":\"integer\",\"format\":\"int64\"}}}}}", + "", + "// Validate if response matches JSON schema ", + "pm.test(\"[GET]::/clone/:id - Schema is valid\", function() {", + " pm.response.to.have.jsonSchema(schema,{unknownFormats: [\"int32\", \"int64\", \"float\", \"double\"]});", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "{{verificationToken}}", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/clone/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "clone", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "Ut magna qui deserunt", + "description": "(Required) Clone ID" + } + ] + }, + "description": "Retrieves the information for the specified clone." + }, + "response": [ + { + "name": "Returned detailed information for the specified clone", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/clone/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "clone", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "Ut magna qui deserunt", + "description": "(Required) Clone ID" + } + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"id\": \"test-clone\",\n \"snapshot\": {\n \"id\": \"dblab_pool/dataset_2/nik-test-branch/20230509212711@20230509212711\",\n \"createdAt\": \"2023-05-09T21:27:11Z\",\n \"dataStateAt\": \"2023-05-09T21:27:11Z\",\n \"physicalSize\": 120832,\n \"logicalSize\": 11518021632,\n \"pool\": \"dblab_pool/dataset_2\",\n \"numClones\": 3\n },\n \"branch\": \"\",\n \"protected\": false,\n \"deleteAt\": null,\n \"createdAt\": \"2023-05-16T06:12:30Z\",\n \"status\": {\n \"code\": \"OK\",\n \"message\": \"Clone is ready to accept Postgres connections.\"\n },\n \"db\": {\n \"connStr\": \"host=branching.aws.postgres.ai port=6004 user=tester dbname=postgres\",\n \"host\": \"branching.aws.postgres.ai\",\n \"port\": \"6004\",\n \"username\": \"tester\",\n \"password\": \"\",\n \"dbName\": \"postgres\"\n },\n \"metadata\": {\n \"cloneDiffSize\": 486400,\n \"logicalSize\": 11518030336,\n \"cloningTime\": 1.57552338,\n \"maxIdleMinutes\": 120\n }\n}" + }, + { + "name": "Unauthorized access", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/clone/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "clone", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "Ut magna qui deserunt", + "description": "(Required) Clone ID" + } + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"UNAUTHORIZED\",\n \"message\": \"Check your verification token.\"\n}" + }, + { + "name": "Not found", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/clone/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "clone", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "Ut magna qui deserunt", + "description": "(Required) Clone ID" + } + ] + } + }, + "status": "Not Found", + "code": 404, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"NOT_FOUND\",\n \"message\": \"Requested object does not exist. Specify your request.\"\n}" + } + ] + }, + { + "name": "Delete a clone", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Validate status 2xx ", + "pm.test(\"[DELETE]::/clone/:id - Status code is 2xx\", function () {", + " pm.response.to.be.success;", + "});", + "", + "// Validate if response header has matching content-type", + "pm.test(\"[DELETE]::/clone/:id - Content-Type is application/json\", function () {", + " pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(\"application/json\");", + "});", + "", + "// Validate if response has JSON Body ", + "pm.test(\"[DELETE]::/clone/:id - Response has JSON Body\", function () {", + " pm.response.to.have.jsonBody();", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "DELETE", + "header": [ + { + "key": "Verification-Token", + "value": "{{verificationToken}}", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/clone/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "clone", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "Ut magna qui deserunt", + "description": "(Required) Clone ID" + } + ] + }, + "description": "Permanently delete the specified clone. It cannot be undone." + }, + "response": [ + { + "name": "Successfully deleted the specified clone", + "originalRequest": { + "method": "DELETE", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/clone/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "clone", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "Ut magna qui deserunt", + "description": "(Required) Clone ID" + } + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "\"OK\"" + }, + { + "name": "Unauthorized access", + "originalRequest": { + "method": "DELETE", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/clone/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "clone", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "Ut magna qui deserunt", + "description": "(Required) Clone ID" + } + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"UNAUTHORIZED\",\n \"message\": \"Check your verification token.\"\n}" + }, + { + "name": "Not found", + "originalRequest": { + "method": "DELETE", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/clone/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "clone", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "Ut magna qui deserunt", + "description": "(Required) Clone ID" + } + ] + } + }, + "status": "Not Found", + "code": 404, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"NOT_FOUND\",\n \"message\": \"Requested object does not exist. Specify your request.\"\n}" + } + ] + }, + { + "name": "Update a clone", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Validate status 2xx ", + "pm.test(\"[PATCH]::/clone/:id - Status code is 2xx\", function () {", + " pm.response.to.be.success;", + "});", + "", + "// Validate if response header has matching content-type", + "pm.test(\"[PATCH]::/clone/:id - Content-Type is application/json\", function () {", + " pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(\"application/json\");", + "});", + "", + "// Validate if response has JSON Body ", + "pm.test(\"[PATCH]::/clone/:id - Response has JSON Body\", function () {", + " pm.response.to.have.jsonBody();", + "});", + "", + "// Response Validation", + "const schema = {\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"name\":{\"type\":\"string\"},\"snapshot\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"createdAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"dataStateAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"physicalSize\":{\"type\":\"integer\",\"format\":\"int64\"},\"logicalSize\":{\"type\":\"integer\",\"format\":\"int64\"},\"pool\":{\"type\":\"string\"},\"numClones\":{\"type\":\"integer\",\"format\":\"int\"}}},\"protected\":{\"type\":\"boolean\",\"default\":false},\"deleteAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"createdAt\":{\"type\":\"string\",\"format\":\"date-time\"},\"status\":{\"required\":[\"code\",\"message\"],\"type\":\"object\",\"properties\":{\"code\":{\"type\":\"string\",\"description\":\"Status code\"},\"message\":{\"type\":\"string\",\"description\":\"Status description\"}}},\"db\":{\"type\":\"object\",\"properties\":{\"connStr\":{\"type\":\"string\"},\"host\":{\"type\":\"string\"},\"port\":{\"type\":\"string\"},\"username\":{\"type\":\"string\"},\"password\":{\"type\":\"string\"}}},\"metadata\":{\"type\":\"object\",\"properties\":{\"cloneDiffSize\":{\"type\":\"integer\",\"format\":\"int64\"},\"logicalSize\":{\"type\":\"integer\",\"format\":\"int64\"},\"cloningTime\":{\"type\":\"integer\",\"format\":\"float64\"},\"maxIdleMinutes\":{\"type\":\"integer\",\"format\":\"int64\"}}}}}", + "", + "// Validate if response matches JSON schema ", + "pm.test(\"[PATCH]::/clone/:id - Schema is valid\", function() {", + " pm.response.to.have.jsonSchema(schema,{unknownFormats: [\"int32\", \"int64\", \"float\", \"double\"]});", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "Verification-Token", + "value": "{{verificationToken}}", + "description": "(Required) " + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"protected\": false\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/clone/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "clone", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "Ut magna qui deserunt", + "description": "(Required) Clone ID" + } + ] + }, + "description": "Updates the specified clone by setting the values of the parameters passed. Currently, only one paramater is supported: 'protected'." + }, + "response": [ + { + "name": "Successfully updated the specified clone", + "originalRequest": { + "method": "PATCH", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"protected\": false\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/clone/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "clone", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "Ut magna qui deserunt", + "description": "(Required) Clone ID" + } + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"id\": \"test-clone-2\",\n \"snapshot\": {\n \"id\": \"dblab_pool/dataset_2/nik-test-branch/20230509212711@20230509212711\",\n \"createdAt\": \"2023-05-09T21:27:11Z\",\n \"dataStateAt\": \"2023-05-09T21:27:11Z\",\n \"physicalSize\": 120832,\n \"logicalSize\": 11518021632,\n \"pool\": \"dblab_pool/dataset_2\",\n \"numClones\": 2\n },\n \"branch\": \"\",\n \"protected\": true,\n \"deleteAt\": null,\n \"createdAt\": \"2023-05-16T06:12:52Z\",\n \"status\": {\n \"code\": \"OK\",\n \"message\": \"Clone is ready to accept Postgres connections.\"\n },\n \"db\": {\n \"connStr\": \"host=branching.aws.postgres.ai port=6005 user=tester dbname=postgres\",\n \"host\": \"branching.aws.postgres.ai\",\n \"port\": \"6005\",\n \"username\": \"tester\",\n \"password\": \"\",\n \"dbName\": \"postgres\"\n },\n \"metadata\": {\n \"cloneDiffSize\": 561664,\n \"logicalSize\": 11518030336,\n \"cloningTime\": 1.5250661829999999,\n \"maxIdleMinutes\": 120\n }\n}" + }, + { + "name": "Unauthorized access", + "originalRequest": { + "method": "PATCH", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"protected\": false\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/clone/:id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "clone", + ":id" + ], + "variable": [ + { + "key": "id", + "value": "Ut magna qui deserunt", + "description": "(Required) Clone ID" + } + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"UNAUTHORIZED\",\n \"message\": \"Check your verification token.\"\n}" + } + ] + }, + { + "name": "Reset a clone", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Validate status 2xx ", + "pm.test(\"[POST]::/clone/:id/reset - Status code is 2xx\", function () {", + " pm.response.to.be.success;", + "});", + "", + "// Validate if response header has matching content-type", + "pm.test(\"[POST]::/clone/:id/reset - Content-Type is application/json\", function () {", + " pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(\"application/json\");", + "});", + "", + "// Validate if response has JSON Body ", + "pm.test(\"[POST]::/clone/:id/reset - Response has JSON Body\", function () {", + " pm.response.to.have.jsonBody();", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "{{verificationToken}}", + "description": "(Required) " + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"snapshotID\": \"ut nulla Duis in in\",\n \"latest\": false\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/clone/:id/reset", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "clone", + ":id", + "reset" + ], + "variable": [ + { + "key": "id", + "value": "Ut magna qui deserunt", + "description": "(Required) Clone ID" + } + ] + }, + "description": "Reset the specified clone to a previously stored state. This can be done by specifying a particular snapshot ID or using the 'latest' flag. All changes made after the snapshot are discarded during the reset, unless those changes were preserved in a snapshot. All database connections will be reset, requiring users and applications to reconnect. The duration of the reset operation is comparable to the creation of a new clone. However, unlike creating a new clone, the reset operation retains the database credentials and does not change the port. Consequently, users and applications can continue to use the same database credentials post-reset, though reconnection will be necessary. Please note that any unsaved changes will be irretrievably lost during this operation, so ensure necessary data is backed up in a snapshot prior to resetting the clone." + }, + "response": [ + { + "name": "Successfully reset the state of the specified clone", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"snapshotID\": \"ut nulla Duis in in\",\n \"latest\": false\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/clone/:id/reset", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "clone", + ":id", + "reset" + ], + "variable": [ + { + "key": "id", + "value": "Ut magna qui deserunt", + "description": "(Required) Clone ID" + } + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "\"OK\"" + }, + { + "name": "Unauthorized access", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"snapshotID\": \"ut nulla Duis in in\",\n \"latest\": false\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/clone/:id/reset", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "clone", + ":id", + "reset" + ], + "variable": [ + { + "key": "id", + "value": "Ut magna qui deserunt", + "description": "(Required) Clone ID" + } + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"UNAUTHORIZED\",\n \"message\": \"Check your verification token.\"\n}" + } + ] + } + ] + }, + { + "name": "Branches", + "item": [ + { + "name": "List all branches", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Validate status 2xx ", + "pm.test(\"[GET]::/branches - Status code is 2xx\", function () {", + " pm.response.to.be.success;", + "});", + "", + "// Validate if response header has matching content-type", + "pm.test(\"[GET]::/branches - Content-Type is */*\", function () {", + " pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(\"*/*\");", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "{{verificationToken}}", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "*/*" + } + ], + "url": { + "raw": "{{baseUrl}}/branches", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "branches" + ] + }, + "description": "Return a list of all available branches (named pointers to snapshots)." + }, + "response": [ + { + "name": "Returned a list of all available branches", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "*/*" + } + ], + "url": { + "raw": "{{baseUrl}}/branches", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "branches" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "*/*" + } + ], + "cookie": [], + "body": "[\n {\n \"name\": \"my-1\",\n \"parent\": \"main\",\n \"dataStateAt\": \"20230224202652\",\n \"snapshotID\": \"dblab_pool/dataset_2/main/20230224202652@20230224202652\"\n },\n {\n \"name\": \"nik-test-branch\",\n \"parent\": \"-\",\n \"dataStateAt\": \"20230509212711\",\n \"snapshotID\": \"dblab_pool/dataset_2/nik-test-branch/20230509212711@20230509212711\"\n },\n {\n \"name\": \"main\",\n \"parent\": \"-\",\n \"dataStateAt\": \"20230224202652\",\n \"snapshotID\": \"dblab_pool/dataset_2/main/20230224202652@20230224202652\"\n }\n]" + }, + { + "name": "Unauthorized access", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/branches", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "branches" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"UNAUTHORIZED\",\n \"message\": \"Check your verification token.\"\n}" + } + ] + }, + { + "name": "Create a branch", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Validate status 2xx ", + "pm.test(\"[POST]::/branch/create - Status code is 2xx\", function () {", + " pm.response.to.be.success;", + "});", + "", + "// Validate if response header has matching content-type", + "pm.test(\"[POST]::/branch/create - Content-Type is */*\", function () {", + " pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(\"*/*\");", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "{{verificationToken}}", + "description": "(Required) " + }, + { + "key": "Content-Type", + "value": "*/*" + }, + { + "key": "Accept", + "value": "*/*" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"branchName\": \"aute do laborum\",\n \"baseBranch\": \"tempor aliqua consectetur\",\n \"snapshotID\": \"mollit velit\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/branch", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "branch" + ] + } + }, + "response": [ + { + "name": "OK", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "*/*" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"branchName\": \"aute do laborum\",\n \"baseBranch\": \"tempor aliqua consectetur\",\n \"snapshotID\": \"mollit velit\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/branch/create", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "branch", + "create" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "*/*" + } + ], + "cookie": [], + "body": "{\n \"name\": \"cillum in laborum\"\n}" + }, + { + "name": "Bad request", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "*/*" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"branchName\": \"aute do laborum\",\n \"baseBranch\": \"tempor aliqua consectetur\",\n \"snapshotID\": \"mollit velit\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/branch/create", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "branch", + "create" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "*/*" + } + ], + "cookie": [], + "body": "{\n \"code\": \"incididunt minim nulla\",\n \"message\": \"qui fugiat\",\n \"detail\": \"occaecat\",\n \"hint\": \"anim\"\n}" + } + ] + }, + { + "name": "Delete a branch", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Validate status 2xx ", + "pm.test(\"[POST]::/branch/delete - Status code is 2xx\", function () {", + " pm.response.to.be.success;", + "});", + "", + "// Validate if response header has matching content-type", + "pm.test(\"[POST]::/branch/delete - Content-Type is */*\", function () {", + " pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(\"*/*\");", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "DELETE", + "header": [ + { + "key": "Verification-Token", + "value": "{{verificationToken}}", + "description": "(Required) " + }, + { + "key": "Content-Type", + "value": "*/*" + }, + { + "key": "Accept", + "value": "*/*" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{baseUrl}}/branch/:branchName", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "branch", + ":branchName" + ], + "variable": [ + { + "key": "branchName", + "value": "" + } + ] + }, + "description": "Permanently delete the specified branch. It cannot be undone." + }, + "response": [ + { + "name": "OK", + "originalRequest": { + "method": "DELETE", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "*/*" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"branchName\": \"dolore aliqua laboris offi\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/branch/delete", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "branch", + "delete" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "*/*" + } + ], + "cookie": [], + "body": "{\n \"status\": \"irure pariatur Excepteur occaecat ullamco\",\n \"message\": \"in enim tempor\"\n}" + }, + { + "name": "Bad request", + "originalRequest": { + "method": "DELETE", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "*/*" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"branchName\": \"dolore aliqua laboris offi\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/branch/delete", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "branch", + "delete" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "*/*" + } + ], + "cookie": [], + "body": "{\n \"code\": \"incididunt minim nulla\",\n \"message\": \"qui fugiat\",\n \"detail\": \"occaecat\",\n \"hint\": \"anim\"\n}" + } + ] + }, + { + "name": "Retrieve a branch log", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Validate status 2xx ", + "pm.test(\"[POST]::/branch/log - Status code is 2xx\", function () {", + " pm.response.to.be.success;", + "});", + "", + "// Validate if response header has matching content-type", + "pm.test(\"[POST]::/branch/log - Content-Type is */*\", function () {", + " pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(\"*/*\");", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "{{verificationToken}}", + "description": "(Required) " + }, + { + "key": "Content-Type", + "value": "*/*" + }, + { + "key": "Accept", + "value": "*/*" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"branchName\": \"in exercitation eiusmod voluptate eu\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/branch/:branchName/log", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "branch", + ":branchName", + "log" + ], + "variable": [ + { + "key": "branchName", + "value": "" + } + ] + }, + "description": "Retrieve a log of the specified branch (history of snapshots)." + }, + "response": [ + { + "name": "OK", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "*/*" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"branchName\": \"in exercitation eiusmod voluptate eu\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/branch/log", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "branch", + "log" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "*/*" + } + ], + "cookie": [], + "body": "[\n {\n \"id\": \"commodo enim\",\n \"parent\": \"laboris anim labore adipisi\",\n \"child\": \"consequat\",\n \"branch\": [\n \"ullamco ad cillum proident\",\n \"ea elit tempor nostrud\"\n ],\n \"root\": \"sunt\",\n \"dataStateAt\": \"2013-09-01T22:20:46.803Z\",\n \"message\": \"et sit\"\n },\n {\n \"id\": \"nisi cillum est deserunt\",\n \"parent\": \"pariatur Lorem\",\n \"child\": \"eu labore do deserunt\",\n \"branch\": [\n \"officia dolor\",\n \"dolor cillum eu culpa ut\"\n ],\n \"root\": \"exercitation aute\",\n \"dataStateAt\": \"1963-05-08T18:09:20.040Z\",\n \"message\": \"est Excepteur mollit nostrud\"\n }\n]" + } + ] + } + ] + }, + { + "name": "Admin", + "item": [ + { + "name": "Get config", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Validate status 2xx ", + "pm.test(\"[GET]::/admin/config - Status code is 2xx\", function () {", + " pm.response.to.be.success;", + "});", + "", + "// Validate if response header has matching content-type", + "pm.test(\"[GET]::/admin/config - Content-Type is application/json\", function () {", + " pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(\"application/json\");", + "});", + "", + "// Validate if response has JSON Body ", + "pm.test(\"[GET]::/admin/config - Response has JSON Body\", function () {", + " pm.response.to.have.jsonBody();", + "});", + "", + "// Response Validation", + "const schema = {\"type\":\"object\"}", + "", + "// Validate if response matches JSON schema ", + "pm.test(\"[GET]::/admin/config - Schema is valid\", function() {", + " pm.response.to.have.jsonSchema(schema,{unknownFormats: [\"int32\", \"int64\", \"float\", \"double\"]});", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "{{verificationToken}}", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/admin/config", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "admin", + "config" + ] + }, + "description": "Retrieve the DBLab configuration. All sensitive values are masked. Only limited set of configuration parameters is returned – only those that can be changed via API (unless reconfiguration via API is disabled by admin). The result is provided in JSON format." + }, + "response": [ + { + "name": "Returned configuration", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/admin/config", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "admin", + "config" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"databaseConfigs\": {\n \"configs\": {\n \"shared_buffers\": \"1GB\",\n \"shared_preload_libraries\": \"pg_stat_statements, pg_stat_kcache, auto_explain, logerrors\"\n }\n },\n \"databaseContainer\": {\n \"dockerImage\": \"registry.gitlab.com/postgres-ai/se-images/supabase:15\"\n },\n \"global\": {\n \"debug\": true\n },\n \"retrieval\": {\n \"refresh\": {\n \"timetable\": \"0 1 * * 0\"\n },\n \"spec\": {\n \"logicalDump\": {\n \"options\": {\n \"customOptions\": [],\n \"databases\": {\n \"test_small\": {}\n },\n \"parallelJobs\": 4,\n \"source\": {\n \"connection\": {\n \"dbname\": \"test_small\",\n \"host\": \"dev1.postgres.ai\",\n \"port\": 6666,\n \"username\": \"john\"\n }\n }\n }\n },\n \"logicalRestore\": {\n \"options\": {\n \"customOptions\": [\n \"--no-tablespaces\",\n \"--no-privileges\",\n \"--no-owner\",\n \"--exit-on-error\"\n ],\n \"parallelJobs\": 4\n }\n }\n }\n }\n}" + }, + { + "name": "Unauthorized access", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/admin/config", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "admin", + "config" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"UNAUTHORIZED\",\n \"message\": \"Check your verification token.\"\n}" + } + ] + }, + { + "name": "Set config", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Validate status 2xx ", + "pm.test(\"[POST]::/admin/config - Status code is 2xx\", function () {", + " pm.response.to.be.success;", + "});", + "", + "// Validate if response header has matching content-type", + "pm.test(\"[POST]::/admin/config - Content-Type is application/json\", function () {", + " pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(\"application/json\");", + "});", + "", + "// Validate if response has JSON Body ", + "pm.test(\"[POST]::/admin/config - Response has JSON Body\", function () {", + " pm.response.to.have.jsonBody();", + "});", + "", + "// Response Validation", + "const schema = {\"type\":\"object\"}", + "", + "// Validate if response matches JSON schema ", + "pm.test(\"[POST]::/admin/config - Schema is valid\", function() {", + " pm.response.to.have.jsonSchema(schema,{unknownFormats: [\"int32\", \"int64\", \"float\", \"double\"]});", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "{{verificationToken}}", + "description": "(Required) " + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/admin/config", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "admin", + "config" + ] + }, + "description": "Set specific configurations for the DBLab instance using this endpoint. The returned configuration parameters are limited to those that can be modified via the API (unless the API-based reconfiguration has been disabled by an administrator). The result will be provided in JSON format." + }, + "response": [ + { + "name": "Successfully saved configuration parameters", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/admin/config", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "admin", + "config" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{}" + }, + { + "name": "Bad request", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/admin/config", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "admin", + "config" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"BAD_REQUEST\",\n \"message\": \"configuration management via UI/API disabled by admin\"\n}" + }, + { + "name": "Unauthorized access", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/admin/config", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "admin", + "config" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"UNAUTHORIZED\",\n \"message\": \"Check your verification token.\"\n}" + } + ] + }, + { + "name": "Get full config (YAML)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Validate status 2xx ", + "pm.test(\"[GET]::/admin/config.yaml - Status code is 2xx\", function () {", + " pm.response.to.be.success;", + "});", + "", + "// Validate if response header has matching content-type", + "pm.test(\"[GET]::/admin/config.yaml - Content-Type is application/yaml\", function () {", + " pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(\"application/yaml\");", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "{{verificationToken}}", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/yaml" + } + ], + "url": { + "raw": "{{baseUrl}}/admin/config.yaml", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "admin", + "config.yaml" + ] + }, + "description": "Retrieve the DBLab configuration in YAML format. All sensitive values are masked. This method allows seeing the entire configuration file and can be helpful for reviewing configuration and setting up workflows to automate DBLab provisioning and configuration." + }, + "response": [ + { + "name": "Returned configuration (YAML)", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/yaml" + } + ], + "url": { + "raw": "{{baseUrl}}/admin/config.yaml", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "admin", + "config.yaml" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "text", + "header": [ + { + "key": "Content-Type", + "value": "application/yaml" + } + ], + "cookie": [], + "body": "" + }, + { + "name": "Unauthorized access", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/admin/config.yaml", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "admin", + "config.yaml" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"UNAUTHORIZED\",\n \"message\": \"Check your verification token.\"\n}" + } + ] + }, + { + "name": "Test source database", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Validate status 2xx ", + "pm.test(\"[POST]::/admin/test-db-source - Status code is 2xx\", function () {", + " pm.response.to.be.success;", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "{{verificationToken}}", + "description": "(Required) " + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"host\": \"veniam\",\n \"port\": \"tempor\",\n \"dbname\": \"et tempor in\",\n \"username\": \"minim ir\",\n \"password\": \"nisi ut incididunt in mollit\",\n \"db_list\": [\n \"veniam exercitation dolore\",\n \"do nisi in occaecat\"\n ]\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/admin/test-db-source", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "admin", + "test-db-source" + ] + } + }, + "response": [ + { + "name": "Successful operation", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"host\": \"adipisicing dolor\",\n \"port\": \"elit\",\n \"dbname\": \"cupidatat in veniam laborum dolore\",\n \"username\": \"sint\",\n \"password\": \"cillum nisi consectetur\",\n \"db_list\": [\n \"ad quis\",\n \"aliqua nisi\"\n ]\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/admin/test-db-source", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "admin", + "test-db-source" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "text", + "header": [ + { + "key": "Content-Type", + "value": "text/plain" + } + ], + "cookie": [], + "body": "" + }, + { + "name": "Bad request", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"host\": \"adipisicing dolor\",\n \"port\": \"elit\",\n \"dbname\": \"cupidatat in veniam laborum dolore\",\n \"username\": \"sint\",\n \"password\": \"cillum nisi consectetur\",\n \"db_list\": [\n \"ad quis\",\n \"aliqua nisi\"\n ]\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/admin/test-db-source", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "admin", + "test-db-source" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"BAD_REQUEST\",\n \"message\": \"configuration management via UI/API disabled by admin\"\n}" + }, + { + "name": "Unauthorized access", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"host\": \"adipisicing dolor\",\n \"port\": \"elit\",\n \"dbname\": \"cupidatat in veniam laborum dolore\",\n \"username\": \"sint\",\n \"password\": \"cillum nisi consectetur\",\n \"db_list\": [\n \"ad quis\",\n \"aliqua nisi\"\n ]\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/admin/test-db-source", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "admin", + "test-db-source" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"UNAUTHORIZED\",\n \"message\": \"Check your verification token.\"\n}" + } + ] + }, + { + "name": "Test source database", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "// Validate status 2xx ", + "pm.test(\"[POST]::/admin/ws-auth - Status code is 2xx\", function () {", + " pm.response.to.be.success;", + "});", + "", + "// Validate if response header has matching content-type", + "pm.test(\"[POST]::/admin/ws-auth - Content-Type is */*\", function () {", + " pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(\"*/*\");", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "{{verificationToken}}", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "*/*" + } + ], + "url": { + "raw": "{{baseUrl}}/admin/ws-auth", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "admin", + "ws-auth" + ] + } + }, + "response": [ + { + "name": "Successful operation", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "*/*" + } + ], + "url": { + "raw": "{{baseUrl}}/admin/ws-auth", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "admin", + "ws-auth" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "*/*" + } + ], + "cookie": [], + "body": "{\n \"token\": \"velit ut minim\"\n}" + }, + { + "name": "Bad request", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/admin/ws-auth", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "admin", + "ws-auth" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"BAD_REQUEST\",\n \"message\": \"configuration management via UI/API disabled by admin\"\n}" + }, + { + "name": "Unauthorized access", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/admin/ws-auth", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "admin", + "ws-auth" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"UNAUTHORIZED\",\n \"message\": \"Check your verification token.\"\n}" + } + ] + } + ] + }, + { + "name": "Observation", + "item": [ + { + "name": "Start observing", + "event": [ + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "// Validate status 2xx \npm.test(\"[POST]::/observation/start - Status code is 2xx\", function () {\n pm.response.to.be.success;\n});\n", + "// Validate if response header has matching content-type\npm.test(\"[POST]::/observation/start - Content-Type is application/json\", function () {\n pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(\"application/json\");\n});\n", + "// Validate if response has JSON Body \npm.test(\"[POST]::/observation/start - Response has JSON Body\", function () {\n pm.response.to.have.jsonBody();\n});\n", + "// Response Validation\nconst schema = {\"type\":\"object\",\"properties\":{\"session_id\":{\"type\":\"integer\",\"format\":\"int64\"},\"started_at\":{\"type\":\"string\",\"format\":\"date-time\"},\"finished_at\":{\"type\":\"string\",\"format\":\"date-time\"},\"config\":{\"type\":\"object\",\"properties\":{\"observation_interval\":{\"type\":\"integer\",\"format\":\"int64\"},\"max_lock_duration\":{\"type\":\"integer\",\"format\":\"int64\"},\"max_duration\":{\"type\":\"integer\",\"format\":\"int64\"}}},\"tags\":{\"type\":\"object\",\"properties\":{}},\"artifacts\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"result\":{\"type\":\"object\",\"properties\":{\"status\":{\"type\":\"string\"},\"intervals\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"started_at\":{\"type\":\"string\",\"format\":\"date-time\"},\"duration\":{\"type\":\"integer\",\"format\":\"int64\"},\"warning\":{\"type\":\"string\"}}}},\"summary\":{\"type\":\"object\",\"properties\":{\"total_duration\":{\"type\":\"integer\",\"format\":\"float64\"},\"total_intervals\":{\"type\":\"integer\",\"format\":\"int\"},\"warning_intervals\":{\"type\":\"integer\",\"format\":\"int\"},\"checklist\":{\"type\":\"object\",\"properties\":{\"overall_success\":{\"type\":\"boolean\"},\"session_duration_acceptable\":{\"type\":\"boolean\"},\"no_long_dangerous_locks\":{\"type\":\"boolean\"}}}}}}}}}\n\n// Validate if response matches JSON schema \npm.test(\"[POST]::/observation/start - Schema is valid\", function() {\n pm.response.to.have.jsonSchema(schema,{unknownFormats: [\"int32\", \"int64\", \"float\", \"double\"]});\n});\n" + ] + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"clone_id\": \"ut sit irure\",\n \"config\": {\n \"observation_interval\": 33950905,\n \"max_lock_duration\": 82462220,\n \"max_duration\": 54143470\n },\n \"tags\": {},\n \"db_name\": \"magna esse dolore\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/observation/start", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "observation", + "start" + ] + }, + "description": "[EXPERIMENTAL] Start an observation session for the specified clone. Observation sessions help detect dangerous (long-lasting, exclusive) locks in CI/CD pipelines. One of common scenarios is using observation sessions to test schema changes (DB migrations)." + }, + "response": [ + { + "name": "Successful operation", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"clone_id\": \"ut sit irure\",\n \"config\": {\n \"observation_interval\": 33950905,\n \"max_lock_duration\": 82462220,\n \"max_duration\": 54143470\n },\n \"tags\": {},\n \"db_name\": \"magna esse dolore\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/observation/start", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "observation", + "start" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"session_id\": -41566390,\n \"started_at\": \"1991-02-14T03:01:06.417Z\",\n \"finished_at\": \"2018-05-30T06:18:09.119Z\",\n \"config\": {\n \"observation_interval\": 76803835,\n \"max_lock_duration\": -6633155,\n \"max_duration\": -968293\n },\n \"tags\": {},\n \"artifacts\": [\n \"aliqua do\",\n \"consectetur amet tempor eiusmod\"\n ],\n \"result\": {\n \"status\": \"qui adipisicing velit aute\",\n \"intervals\": [\n {\n \"started_at\": \"2008-06-20T07:35:49.463Z\",\n \"duration\": 34650553,\n \"warning\": \"velit nulla ex\"\n },\n {\n \"started_at\": \"1994-03-12T02:59:52.189Z\",\n \"duration\": 10020998,\n \"warning\": \"ipsum laborum\"\n }\n ],\n \"summary\": {\n \"total_duration\": -51894451,\n \"total_intervals\": -93757197,\n \"warning_intervals\": 95087393,\n \"checklist\": {\n \"overall_success\": false,\n \"session_duration_acceptable\": true,\n \"no_long_dangerous_locks\": false\n }\n }\n }\n}" + }, + { + "name": "Not found", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"clone_id\": \"ut sit irure\",\n \"config\": {\n \"observation_interval\": 33950905,\n \"max_lock_duration\": 82462220,\n \"max_duration\": 54143470\n },\n \"tags\": {},\n \"db_name\": \"magna esse dolore\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/observation/start", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "observation", + "start" + ] + } + }, + "status": "Not Found", + "code": 404, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"NOT_FOUND\",\n \"message\": \"Requested object does not exist. Specify your request.\"\n}" + } + ] + }, + { + "name": "Stop observing", + "event": [ + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "// Validate status 2xx \npm.test(\"[POST]::/observation/stop - Status code is 2xx\", function () {\n pm.response.to.be.success;\n});\n", + "// Validate if response header has matching content-type\npm.test(\"[POST]::/observation/stop - Content-Type is application/json\", function () {\n pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(\"application/json\");\n});\n", + "// Validate if response has JSON Body \npm.test(\"[POST]::/observation/stop - Response has JSON Body\", function () {\n pm.response.to.have.jsonBody();\n});\n", + "// Response Validation\nconst schema = {\"type\":\"object\",\"properties\":{\"session_id\":{\"type\":\"integer\",\"format\":\"int64\"},\"started_at\":{\"type\":\"string\",\"format\":\"date-time\"},\"finished_at\":{\"type\":\"string\",\"format\":\"date-time\"},\"config\":{\"type\":\"object\",\"properties\":{\"observation_interval\":{\"type\":\"integer\",\"format\":\"int64\"},\"max_lock_duration\":{\"type\":\"integer\",\"format\":\"int64\"},\"max_duration\":{\"type\":\"integer\",\"format\":\"int64\"}}},\"tags\":{\"type\":\"object\",\"properties\":{}},\"artifacts\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"result\":{\"type\":\"object\",\"properties\":{\"status\":{\"type\":\"string\"},\"intervals\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"started_at\":{\"type\":\"string\",\"format\":\"date-time\"},\"duration\":{\"type\":\"integer\",\"format\":\"int64\"},\"warning\":{\"type\":\"string\"}}}},\"summary\":{\"type\":\"object\",\"properties\":{\"total_duration\":{\"type\":\"integer\",\"format\":\"float64\"},\"total_intervals\":{\"type\":\"integer\",\"format\":\"int\"},\"warning_intervals\":{\"type\":\"integer\",\"format\":\"int\"},\"checklist\":{\"type\":\"object\",\"properties\":{\"overall_success\":{\"type\":\"boolean\"},\"session_duration_acceptable\":{\"type\":\"boolean\"},\"no_long_dangerous_locks\":{\"type\":\"boolean\"}}}}}}}}}\n\n// Validate if response matches JSON schema \npm.test(\"[POST]::/observation/stop - Schema is valid\", function() {\n pm.response.to.have.jsonSchema(schema,{unknownFormats: [\"int32\", \"int64\", \"float\", \"double\"]});\n});\n" + ] + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"clone_id\": \"proident cillum nostrud officia\",\n \"overall_error\": false\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/observation/stop", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "observation", + "stop" + ] + }, + "description": "[EXPERIMENTAL] Stop the previously started observation session." + }, + "response": [ + { + "name": "Successful operation", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"clone_id\": \"proident cillum nostrud officia\",\n \"overall_error\": false\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/observation/stop", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "observation", + "stop" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"session_id\": 9614128,\n \"started_at\": \"1993-11-12T01:24:57.933Z\",\n \"finished_at\": \"1953-01-01T04:06:59.652Z\",\n \"config\": {\n \"observation_interval\": -46635741,\n \"max_lock_duration\": -53938384,\n \"max_duration\": 85779944\n },\n \"tags\": {},\n \"artifacts\": [\n \"deseru\",\n \"in ullamco veniam\"\n ],\n \"result\": {\n \"status\": \"ut ea l\",\n \"intervals\": [\n {\n \"started_at\": \"1943-07-24T05:03:49.697Z\",\n \"duration\": -45788381,\n \"warning\": \"Ut qui occaecat\"\n },\n {\n \"started_at\": \"1973-02-08T19:49:36.906Z\",\n \"duration\": 78310177,\n \"warning\": \"dolore amet mollit velit\"\n }\n ],\n \"summary\": {\n \"total_duration\": 89098265,\n \"total_intervals\": -25796081,\n \"warning_intervals\": -74609996,\n \"checklist\": {\n \"overall_success\": false,\n \"session_duration_acceptable\": true,\n \"no_long_dangerous_locks\": false\n }\n }\n }\n}" + }, + { + "name": "Bad request", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"clone_id\": \"proident cillum nostrud officia\",\n \"overall_error\": false\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/observation/stop", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "observation", + "stop" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"incididunt minim nulla\",\n \"message\": \"qui fugiat\",\n \"detail\": \"occaecat\",\n \"hint\": \"anim\"\n}" + } + ] + }, + { + "name": "Get observation summary", + "event": [ + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "// Validate status 2xx \npm.test(\"[GET]::/observation/summary/:clone_id/:session_id - Status code is 2xx\", function () {\n pm.response.to.be.success;\n});\n", + "// Validate if response header has matching content-type\npm.test(\"[GET]::/observation/summary/:clone_id/:session_id - Content-Type is application/json\", function () {\n pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(\"application/json\");\n});\n", + "// Validate if response has JSON Body \npm.test(\"[GET]::/observation/summary/:clone_id/:session_id - Response has JSON Body\", function () {\n pm.response.to.have.jsonBody();\n});\n", + "// Response Validation\nconst schema = {\"type\":\"object\",\"properties\":{\"session_id\":{\"type\":\"integer\",\"format\":\"int64\"},\"clone_id\":{\"type\":\"string\"},\"duration\":{\"type\":\"object\",\"properties\":{}},\"db_size\":{\"type\":\"object\",\"properties\":{}},\"locks\":{\"type\":\"object\",\"properties\":{}},\"log_errors\":{\"type\":\"object\",\"properties\":{}},\"artifact_types\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}}}\n\n// Validate if response matches JSON schema \npm.test(\"[GET]::/observation/summary/:clone_id/:session_id - Schema is valid\", function() {\n pm.response.to.have.jsonSchema(schema,{unknownFormats: [\"int32\", \"int64\", \"float\", \"double\"]});\n});\n" + ] + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/observation/summary/:clone_id/:session_id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "observation", + "summary", + ":clone_id", + ":session_id" + ], + "variable": [ + { + "key": "clone_id", + "value": "Ut magna qui deserunt", + "description": "(Required) Clone ID" + }, + { + "key": "session_id", + "value": "Ut magna qui deserunt", + "description": "(Required) Session ID" + } + ] + }, + "description": "[EXPERIMENTAL] Collect the observation summary info." + }, + "response": [ + { + "name": "Successful operation", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/observation/summary/:clone_id/:session_id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "observation", + "summary", + ":clone_id", + ":session_id" + ], + "variable": [ + { + "key": "clone_id", + "value": "Ut magna qui deserunt", + "description": "(Required) Clone ID" + }, + { + "key": "session_id", + "value": "Ut magna qui deserunt", + "description": "(Required) Session ID" + } + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"session_id\": 55155718,\n \"clone_id\": \"cupidatat laborum consequat Lorem officia\",\n \"duration\": {},\n \"db_size\": {},\n \"locks\": {},\n \"log_errors\": {},\n \"artifact_types\": [\n \"laboris anim Ut enim\",\n \"ullamco in esse nostrud Exc\"\n ]\n}" + }, + { + "name": "Bad request", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/observation/summary/:clone_id/:session_id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "observation", + "summary", + ":clone_id", + ":session_id" + ], + "variable": [ + { + "key": "clone_id", + "value": "Ut magna qui deserunt", + "description": "(Required) Clone ID" + }, + { + "key": "session_id", + "value": "Ut magna qui deserunt", + "description": "(Required) Session ID" + } + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"incididunt minim nulla\",\n \"message\": \"qui fugiat\",\n \"detail\": \"occaecat\",\n \"hint\": \"anim\"\n}" + } + ] + }, + { + "name": "Download an observation artifact", + "event": [ + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "// Validate status 2xx \npm.test(\"[GET]::/observation/download/:artifact_type/:clone_id/:session_id - Status code is 2xx\", function () {\n pm.response.to.be.success;\n});\n" + ] + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/observation/download/:artifact_type/:clone_id/:session_id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "observation", + "download", + ":artifact_type", + ":clone_id", + ":session_id" + ], + "variable": [ + { + "key": "artifact_type", + "value": "Ut magna qui deserunt", + "description": "(Required) Type of the requested artifact" + }, + { + "key": "clone_id", + "value": "Ut magna qui deserunt", + "description": "(Required) Clone ID" + }, + { + "key": "session_id", + "value": "Ut magna qui deserunt", + "description": "(Required) Session ID" + } + ] + }, + "description": "[EXPERIMENTAL] Download an artifact for the specified clone and observation session." + }, + "response": [ + { + "name": "Successful operation", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + } + ], + "url": { + "raw": "{{baseUrl}}/observation/download/:artifact_type/:clone_id/:session_id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "observation", + "download", + ":artifact_type", + ":clone_id", + ":session_id" + ], + "variable": [ + { + "key": "artifact_type", + "value": "Ut magna qui deserunt", + "description": "(Required) Type of the requested artifact" + }, + { + "key": "clone_id", + "value": "Ut magna qui deserunt", + "description": "(Required) Clone ID" + }, + { + "key": "session_id", + "value": "Ut magna qui deserunt", + "description": "(Required) Session ID" + } + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "text", + "header": [ + { + "key": "Content-Type", + "value": "text/plain" + } + ], + "cookie": [], + "body": "" + }, + { + "name": "Bad request", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Verification-Token", + "value": "Ut magna qui deserunt", + "description": "(Required) " + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/observation/download/:artifact_type/:clone_id/:session_id", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "observation", + "download", + ":artifact_type", + ":clone_id", + ":session_id" + ], + "variable": [ + { + "key": "artifact_type", + "value": "Ut magna qui deserunt", + "description": "(Required) Type of the requested artifact" + }, + { + "key": "clone_id", + "value": "Ut magna qui deserunt", + "description": "(Required) Clone ID" + }, + { + "key": "session_id", + "value": "Ut magna qui deserunt", + "description": "(Required) Session ID" + } + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"code\": \"incididunt minim nulla\",\n \"message\": \"qui fugiat\",\n \"detail\": \"occaecat\",\n \"hint\": \"anim\"\n}" + } + ] + } + ] + } + ], + "variable": [ + { + "key": "baseUrl", + "value": "https://branching.aws.postgres.ai:446/api", + "type": "string" + } + ] +} \ No newline at end of file diff --git a/engine/api/postman/portman-cli.json b/engine/api/postman/portman-cli.json new file mode 100644 index 00000000..89b27ed2 --- /dev/null +++ b/engine/api/postman/portman-cli.json @@ -0,0 +1,10 @@ +{ + "baseUrL": "http://branching.aws.postgres.ai:446/api", + "verificationToken": "demo-token", + "local": "engine/api/swagger-spec/dblab_openapi.yaml", + "output": "engine/api/postman/output.json", + "envFile": "engine/api/postman/portman.env", + "includeTests": true, + "syncPostman": true, + "runNewman": false +} diff --git a/engine/api/swagger-spec/dblab_openapi.yaml b/engine/api/swagger-spec/dblab_openapi.yaml new file mode 100644 index 00000000..a1d7b208 --- /dev/null +++ b/engine/api/swagger-spec/dblab_openapi.yaml @@ -0,0 +1,1919 @@ +# OpenAPI spec for DBLab API +# Useful links: +# - validate and test: https://editor.swagger.io/ +# - official reference location for this API: https://dblab.readme.io/ +# - GitHub (give us a ⭐️): https://github.com/postgres-ai/database-lab-engine + +openapi: 3.0.1 +info: + title: DBLab API + description: This page provides the OpenAPI specification for the Database Lab (DBLab) + API, previously recognized as the DLE API (Database Lab Engine API). + contact: + name: DBLab API Support + url: https://postgres.ai/contact + email: api@postgres.ai + license: + name: Apache 2.0 + url: https://github.com/postgres-ai/database-lab-engine/blob/dle-4-0/LICENSE + version: 4.0.0 +externalDocs: + description: DBLab Docs + url: https://gitlab.com/postgres-ai/docs/tree/master/docs/database-lab + +servers: + - url: "https://demo.dblab.dev/api" + description: "DBLab 4.0 demo server (with DB branching support); token: 'demo-token'" + x-examples: + Verification-Token: "demo-token" + - url: "https://demo.aws.postgres.ai:446/api" + description: "DBLab 3.x demo server; token: 'demo-token'" + x-examples: + Verification-Token: "demo-token" + - url: "{scheme}://{host}:{port}/{basePath}" + description: "Any DBLab accessed locally / through SSH port forwarding" + variables: + scheme: + enum: + - "https" + - "http" + default: "http" + description: "'http' for local connections and SSH port forwarding; + 'https' for everything else." + host: + default: "localhost" + description: "where DBLab server is installed. Use 'localhost' to work locally + or when SSH port forwarding is used." + port: + default: "2346" + description: "Port to access DBLab UI or API. Originally, '2345' is used for + direct work with API and '2346' – with UI. However, with UI, API is also available, + at ':2346/api'." + basePath: + default: "api" + description: "basePath value to access API. Use empty when working with API port + (2345 by default), or '/api' when working with UI port ('2346' by default)." + x-examples: + Verification-Token: "custom_example_token" + +tags: +- name: DBLab + description: "DBLab API Reference – database branching, instant cloning, and more. + DBLab CLI and UI rely on DBLab API." + externalDocs: + description: "DBLab Docs - tutorials, howtos, references." + url: https://postgres.ai/docs/reference-guides/database-lab-engine-api-reference + +paths: + /status: + get: + tags: + - Instance + summary: DBLab instance status and detailed information + description: "Retrieves detailed information about the DBLab instance: status, version, + clones, snapshots, etc." + operationId: status + parameters: + - name: Verification-Token + in: header + required: true + schema: + type: string + responses: + 200: + description: Returned detailed information about the DBLab instance + content: + application/json: + schema: + $ref: '#/components/schemas/Instance' + example: + status: + code: OK + message: Instance is ready + engine: + version: v4.0.0-alpha.5-20230516-0224 + edition: standard + billingActive: true + instanceID: chhfqfcnvrvc73d0lij0 + startedAt: '2023-05-16T03:50:19Z' + telemetry: true + disableConfigModification: false + pools: + - name: dblab_pool/dataset_1 + mode: zfs + dataStateAt: '' + status: empty + cloneList: [] + fileSystem: + mode: zfs + size: 30685528064 + free: 30685282816 + used: 245248 + dataSize: 12288 + usedBySnapshots: 0 + usedByClones: 219648 + compressRatio: 1 + - name: dblab_pool/dataset_2 + mode: zfs + dataStateAt: '' + status: empty + cloneList: [] + fileSystem: + mode: zfs + size: 30685528064 + free: 30685282816 + used: 245248 + dataSize: 12288 + usedBySnapshots: 0 + usedByClones: 219648 + compressRatio: 1 + - name: dblab_pool/dataset_3 + mode: zfs + dataStateAt: '' + status: empty + cloneList: [] + fileSystem: + mode: zfs + size: 30685528064 + free: 30685282816 + used: 245248 + dataSize: 12288 + usedBySnapshots: 0 + usedByClones: 219648 + compressRatio: 1 + cloning: + expectedCloningTime: 0 + numClones: 0 + clones: [] + retrieving: + mode: logical + status: pending + lastRefresh: + nextRefresh: + alerts: {} + activity: + provisioner: + dockerImage: postgresai/extended-postgres:15 + containerConfig: + shm-size: 1gb + synchronization: + status: + code: Not available + message: '' + lastReplayedLsn: '' + lastReplayedLsnAt: '' + replicationLag: 0 + replicationUptime: 0 + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: "UNAUTHORIZED" + message: "Check your verification token." + /snapshots: + get: + tags: + - Snapshots + summary: List all snapshots + description: Return a list of all available snapshots. + operationId: snapshots + parameters: + - name: Verification-Token + in: header + required: true + schema: + type: string + - name: branch + in: query + required: false + schema: + type: string + responses: + 200: + description: Returned a list of snapshots + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Snapshot' + example: + - id: dblab_pool/dataset_2/nik-test-branch/20230509212711@20230509212711 + createdAt: '2023-05-09T21:27:11Z' + dataStateAt: '2023-05-09T21:27:11Z' + physicalSize: 0 + logicalSize: 11518021632 + pool: dblab_pool/dataset_2 + numClones: 1 + - id: dblab_pool/dataset_2/nik-test-branch/20230307171959@20230307171959 + createdAt: '2023-03-07T17:19:59Z' + dataStateAt: '2023-03-07T17:19:59Z' + physicalSize: 151552 + logicalSize: 11518015488 + pool: dblab_pool/dataset_2 + numClones: 1 + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: "UNAUTHORIZED" + message: "Check your verification token." + /full-refresh: + post: + tags: + - Instance + summary: Trigger full data refresh + description: "Initiates a full data refresh." + operationId: refresh + parameters: + - name: Verification-Token + in: header + required: true + schema: + type: string + responses: + 200: + description: Full refresh has been initiated + content: + application/json: + schema: + $ref: '#/components/schemas/FullRefresh' + example: + status: OK + message: Full refresh started + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: "UNAUTHORIZED" + message: "Check your verification token." + /snapshot: + post: + tags: + - Snapshots + summary: Create a snapshot + description: "Create a new snapshot from the current state of the selected pool. + This snapshot can later be used to create clones or new branches." + parameters: + - name: Verification-Token + in: header + required: true + schema: + type: string + requestBody: + description: "Optional parameters for snapshot creation. + If no pool name is provided, the first available pool is used." + content: + '*/*': + schema: + type: object + properties: + poolName: + type: string + description: Name of the pool to create snapshot in. + required: false + responses: + 200: + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/Snapshot' + 400: + description: Bad request + content: + '*/*': + schema: + $ref: '#/components/schemas/Error' + x-codegen-request-body-name: body + /snapshot/{id}: + delete: + tags: + - Snapshots + summary: Delete a snapshot + description: "Permanently delete the specified snapshot. + If the snapshot has dependent clones or datasets, `force=true` can be provided as a query parameter." + parameters: + - name: id + in: path + required: true + description: The ID of the snapshot to delete. + schema: + type: string + pattern: '.*' + - name: force + in: query + required: false + description: Force deletion even if dependent clones or datasets exist. + schema: + type: boolean + - name: Verification-Token + in: header + required: true + schema: + type: string + responses: + 200: + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/ResponseStatus' + 400: + description: Bad request + content: + '*/*': + schema: + $ref: '#/components/schemas/Error' + /clones: + get: + tags: + - Clones + summary: List all clones + description: Return a list of all available clones (database endpoints). + parameters: + - name: Verification-Token + in: header + required: true + schema: + type: string + responses: + 200: + description: Returned a list of all available clones + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Clone' + example: + - id: test-clone-2 + snapshot: + id: dblab_pool/dataset_2/nik-test-branch/20230509212711@20230509212711 + createdAt: '2023-05-09T21:27:11Z' + dataStateAt: '2023-05-09T21:27:11Z' + physicalSize: 120832 + logicalSize: 11518021632 + pool: dblab_pool/dataset_2 + numClones: 3 + branch: '' + protected: false + deleteAt: + createdAt: '2023-05-16T06:12:52Z' + status: + code: OK + message: Clone is ready to accept Postgres connections. + db: + connStr: host=branching.aws.postgres.ai port=6005 user=tester dbname=postgres + host: branching.aws.postgres.ai + port: '6005' + username: tester + password: '' + dbName: postgres + metadata: + cloneDiffSize: 484352 + logicalSize: 11518029312 + cloningTime: 1.5250661829999999 + maxIdleMinutes: 120 + - id: test-clone + snapshot: + id: dblab_pool/dataset_2/nik-test-branch/20230509212711@20230509212711 + createdAt: '2023-05-09T21:27:11Z' + dataStateAt: '2023-05-09T21:27:11Z' + physicalSize: 120832 + logicalSize: 11518021632 + pool: dblab_pool/dataset_2 + numClones: 3 + branch: '' + protected: false + deleteAt: + createdAt: '2023-05-16T06:12:30Z' + status: + code: OK + message: Clone is ready to accept Postgres connections. + db: + connStr: host=branching.aws.postgres.ai port=6004 user=tester dbname=postgres + host: branching.aws.postgres.ai + port: '6004' + username: tester + password: '' + dbName: postgres + metadata: + cloneDiffSize: 486400 + logicalSize: 11518030336 + cloningTime: 1.57552338 + maxIdleMinutes: 120 + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: "UNAUTHORIZED" + message: "Check your verification token." + /clone: + post: + tags: + - Clones + summary: Create a clone + operationId: createClone + parameters: + - name: Verification-Token + in: header + required: true + schema: + type: string + requestBody: + description: Clone object + content: + application/json: + schema: + $ref: '#/components/schemas/CreateClone' + required: true + responses: + 201: + description: Created a new clone + content: + application/json: + schema: + $ref: '#/components/schemas/Clone' + example: + id: test-clone-2 + snapshot: + id: dblab_pool/dataset_2/nik-test-branch/20230509212711@20230509212711 + createdAt: '2023-05-09T21:27:11Z' + dataStateAt: '2023-05-09T21:27:11Z' + physicalSize: 120832 + logicalSize: 11518021632 + pool: dblab_pool/dataset_2 + numClones: 3 + branch: '' + protected: false + deleteAt: + createdAt: '2023-05-16T06:12:52Z' + status: + code: CREATING + message: Clone is being created. + db: + connStr: '' + host: '' + port: '' + username: tester + password: '' + dbName: postgres + metadata: + cloneDiffSize: 0 + logicalSize: 0 + cloningTime: 0 + maxIdleMinutes: 0 + 400: + description: Returned an error caused by invalid request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: "BAD_REQUEST" + message: "clone with such ID already exists" + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: "UNAUTHORIZED" + message: "Check your verification token." + x-codegen-request-body-name: body + /clone/{id}: + get: + tags: + - Clones + summary: Retrieve a clone + description: Retrieves the information for the specified clone. + operationId: getClone + parameters: + - name: Verification-Token + in: header + required: true + schema: + type: string + - name: id + in: path + description: Clone ID + required: true + schema: + type: string + responses: + 200: + description: Returned detailed information for the specified clone + content: + application/json: + schema: + $ref: '#/components/schemas/Clone' + example: + id: test-clone + snapshot: + id: dblab_pool/dataset_2/nik-test-branch/20230509212711@20230509212711 + createdAt: '2023-05-09T21:27:11Z' + dataStateAt: '2023-05-09T21:27:11Z' + physicalSize: 120832 + logicalSize: 11518021632 + pool: dblab_pool/dataset_2 + numClones: 3 + branch: '' + protected: false + deleteAt: + createdAt: '2023-05-16T06:12:30Z' + status: + code: OK + message: Clone is ready to accept Postgres connections. + db: + connStr: host=branching.aws.postgres.ai port=6004 user=tester dbname=postgres + host: branching.aws.postgres.ai + port: '6004' + username: tester + password: '' + dbName: postgres + metadata: + cloneDiffSize: 486400 + logicalSize: 11518030336 + cloningTime: 1.57552338 + maxIdleMinutes: 120 + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: "UNAUTHORIZED" + message: "Check your verification token." + 404: + description: Not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: NOT_FOUND + message: Requested object does not exist. Specify your request. + delete: + tags: + - Clones + summary: Delete a clone + description: Permanently delete the specified clone. It cannot be undone. + operationId: deleteClone + parameters: + - name: Verification-Token + in: header + required: true + schema: + type: string + - name: id + in: path + description: Clone ID + required: true + schema: + type: string + responses: + 200: + description: Successfully deleted the specified clone + content: + application/json: + example: + "OK" + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: "UNAUTHORIZED" + message: "Check your verification token." + 404: + description: Not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: NOT_FOUND + message: Requested object does not exist. Specify your request. + patch: + tags: + - Clones + summary: Update a clone + description: "Updates the specified clone by setting the values of the parameters passed. + Currently, only one paramater is supported: 'protected'." + operationId: updateClone + parameters: + - name: Verification-Token + in: header + required: true + schema: + type: string + - name: id + in: path + description: Clone ID + required: true + schema: + type: string + requestBody: + description: Clone object + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateClone' + required: true + responses: + 200: + description: Successfully updated the specified clone + content: + application/json: + schema: + $ref: '#/components/schemas/Clone' + example: + id: test-clone-2 + snapshot: + id: dblab_pool/dataset_2/nik-test-branch/20230509212711@20230509212711 + createdAt: '2023-05-09T21:27:11Z' + dataStateAt: '2023-05-09T21:27:11Z' + physicalSize: 120832 + logicalSize: 11518021632 + pool: dblab_pool/dataset_2 + numClones: 2 + branch: '' + protected: true + deleteAt: + createdAt: '2023-05-16T06:12:52Z' + status: + code: OK + message: Clone is ready to accept Postgres connections. + db: + connStr: host=branching.aws.postgres.ai port=6005 user=tester dbname=postgres + host: branching.aws.postgres.ai + port: '6005' + username: tester + password: '' + dbName: postgres + metadata: + cloneDiffSize: 561664 + logicalSize: 11518030336 + cloningTime: 1.5250661829999999 + maxIdleMinutes: 120 + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: "UNAUTHORIZED" + message: "Check your verification token." + #404: # TODO: fix it in engine (currently returns 500) + # description: Not found + # content: + # application/json: + # schema: + # $ref: '#/components/schemas/Error' + # example: + # code: NOT_FOUND + # message: Requested object does not exist. Specify your request. + x-codegen-request-body-name: body + /clone/{id}/reset: + post: + tags: + - Clones + summary: Reset a clone + description: "Reset the specified clone to a previously stored state. + This can be done by specifying a particular snapshot ID or using the 'latest' flag. + All changes made after the snapshot are discarded during the reset, unless those + changes were preserved in a snapshot. All database connections will be reset, + requiring users and applications to reconnect. The duration of the reset operation + is comparable to the creation of a new clone. However, unlike creating a new clone, + the reset operation retains the database credentials and does not change the port. + Consequently, users and applications can continue to use the same database credentials + post-reset, though reconnection will be necessary. Please note that any unsaved changes + will be irretrievably lost during this operation, so ensure necessary data is backed up + in a snapshot prior to resetting the clone." + operationId: resetClone + parameters: + - name: Verification-Token + in: header + required: true + schema: + type: string + - name: id + in: path + description: Clone ID + required: true + schema: + type: string + requestBody: + description: Reset object + content: + application/json: + schema: + $ref: '#/components/schemas/ResetClone' + required: false + responses: + 200: + description: Successfully reset the state of the specified clone + content: + application/json: + example: + "OK" + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: "UNAUTHORIZED" + message: "Check your verification token." + #404: # TODO: fix it in engine (currently returns 500) + # description: Not found + # content: + # application/json: + # schema: + # $ref: '#/components/schemas/Error' + x-codegen-request-body-name: body + /branches: + get: + tags: + - Branches + summary: List all branches + description: Return a list of all available branches (named pointers to snapshots). + parameters: + - name: Verification-Token + in: header + required: true + schema: + type: string + responses: + 200: + description: Returned a list of all available branches + content: + '*/*': + schema: + type: array + items: + $ref: '#/components/schemas/Branch' + example: + - name: my-1 + parent: main + dataStateAt: '20230224202652' + snapshotID: dblab_pool/dataset_2/main/20230224202652@20230224202652 + - name: nik-test-branch + parent: "-" + dataStateAt: '20230509212711' + snapshotID: dblab_pool/dataset_2/nik-test-branch/20230509212711@20230509212711 + - name: main + parent: "-" + dataStateAt: '20230224202652' + snapshotID: dblab_pool/dataset_2/main/20230224202652@20230224202652 + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: "UNAUTHORIZED" + message: "Check your verification token." + /branch/snapshot/{id}: + get: + tags: + - Snapshots + summary: Retrieve a snapshot + description: Retrieves the information for the specified snapshot. + parameters: + - name: id + in: path + description: ID of the branch snapshot + required: true + schema: + type: string + - name: Verification-Token + in: header + required: true + schema: + type: string + responses: + 200: + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/SnapshotDetails' + 400: + description: Bad request + content: + '*/*': + schema: + $ref: '#/components/schemas/Error' + /branch: + post: + tags: + - Branches + summary: Create a branch + parameters: + - name: Verification-Token + in: header + required: true + schema: + type: string + requestBody: + content: + '*/*': + schema: + type: object + properties: + branchName: + type: string + description: The name of the new branch. + baseBranch: + type: string + description: "The name of parent branch user to create a new branch. + Must not be specified if 'snapshotID' is specified." + snapshotID: + type: string + description: "The ID of the snapshot used to create a new branch. + Must not be specified if 'baseBranch' is specified." + required: true + responses: + 200: + description: OK + content: + '*/*': + schema: + type: object + properties: + name: + type: string + 400: + description: Bad request + content: + '*/*': + schema: + $ref: '#/components/schemas/Error' + x-codegen-request-body-name: body + /branch/snapshot: + post: + tags: + - Snapshots + summary: Create a snapshot + description: "Create a new snapshot using the specified clone. After a snapshot + has been created, the original clone can be deleted in order to free up compute resources, if necessary. + The snapshot created by this endpoint can be used later to create one or more new clones." + parameters: + - name: Verification-Token + in: header + required: true + schema: + type: string + requestBody: + description: "Parameters necessary for snapshot creation: 'cloneID' – the + ID of the clone, 'message' – description of the snapshot" + content: + '*/*': + schema: + type: object + properties: + cloneID: + type: string + message: + type: string + required: true + responses: + 200: + description: OK + content: + '*/*': + schema: + type: object + properties: + snapshotID: + type: string + 400: + description: Bad request + content: + '*/*': + schema: + $ref: '#/components/schemas/Error' + x-codegen-request-body-name: body + /branch/{branchName}: + delete: + tags: + - Branches + summary: Delete a branch + description: "Permanently delete the specified branch. It cannot be undone." + parameters: + - name: branchName + in: path + required: true + schema: + type: string + description: "The name of the branch to be deleted." + - name: Verification-Token + in: header + required: true + schema: + type: string + responses: + 200: + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/ResponseStatus' + 400: + description: Bad request + content: + '*/*': + schema: + $ref: '#/components/schemas/Error' + x-codegen-request-body-name: body + /branch/{branchName}/log: + get: + tags: + - Branches + summary: Retrieve a branch log + description: Retrieve a log of the specified branch (history of snapshots). + parameters: + - name: branchName + in: path + required: true + schema: + type: string + description: The name of the branch. + - name: Verification-Token + in: header + required: true + schema: + type: string + responses: + 200: + description: OK + content: + '*/*': + schema: + type: array + items: + $ref: '#/components/schemas/SnapshotDetails' + x-codegen-request-body-name: body + /instance/retrieval: + get: + tags: + - Instance + summary: Data refresh status + description: 'Report a status of the data refresh subsystem (also known as + "data retrieval"): timestamps of the previous and next refresh runs, status, messages.' + operationId: instanceRetrieval + parameters: + - name: Verification-Token + in: header + required: true + schema: + type: string + responses: + 200: + description: Reported a status of the data retrieval subsystem + content: + application/json: + schema: + $ref: '#/components/schemas/Retrieving' + example: + mode: logical + status: pending + lastRefresh: + nextRefresh: + alerts: {} + activity: + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Instance' + example: + code: "UNAUTHORIZED" + message: "Check your verification token." + /healthz: + get: + tags: + - Instance + summary: Service health check + description: "Check the overall health and availability of the API system. + This endpoint does not require the 'Verification-Token' header." + operationId: healthz + responses: + 200: + description: Successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Engine' + example: + version: "v4.0.0-alpha.5-20230516-0224" + edition: "standard" + instanceID: "chhfqfcnvrvc73d0lij0" + /admin/config: + get: + tags: + - Admin + summary: Get config + description: "Retrieve the DBLab configuration. All sensitive values are masked. + Only limited set of configuration parameters is returned – only those that can be + changed via API (unless reconfiguration via API is disabled by admin). The result + is provided in JSON format." + operationId: getConfig + parameters: + - name: Verification-Token + in: header + required: true + schema: + type: string + responses: + 200: + description: Returned configuration + content: + application/json: + schema: + $ref: '#/components/schemas/Config' + example: + databaseConfigs: + configs: + shared_buffers: 1GB + shared_preload_libraries: pg_stat_statements, pg_stat_kcache, auto_explain, logerrors + databaseContainer: + dockerImage: registry.gitlab.com/postgres-ai/se-images/supabase:15 + global: + debug: true + retrieval: + refresh: + timetable: 0 1 * * 0 + spec: + logicalDump: + options: + customOptions: [] + databases: + test_small: {} + parallelJobs: 4 + source: + connection: + dbname: test_small + host: dev1.postgres.ai + port: 6666 + username: john + logicalRestore: + options: + customOptions: + - "--no-tablespaces" + - "--no-privileges" + - "--no-owner" + - "--exit-on-error" + parallelJobs: 4 + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Instance' + example: + code: "UNAUTHORIZED" + message: "Check your verification token." + post: + tags: + - Admin + summary: Set config + description: "Set specific configurations for the DBLab instance using this endpoint. + The returned configuration parameters are limited to those that can be modified + via the API (unless the API-based reconfiguration has been disabled by an administrator). + The result will be provided in JSON format." + operationId: setConfig + parameters: + - name: Verification-Token + in: header + required: true + schema: + type: string + requestBody: + description: Set configuration object + content: + application/json: + schema: + $ref: '#/components/schemas/Config' + required: true + responses: + 200: + description: Successfully saved configuration parameters + content: + application/json: + schema: + $ref: '#/components/schemas/Config' + 400: + description: Bad request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: BAD_REQUEST + message: configuration management via UI/API disabled by admin + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Instance' + example: + code: "UNAUTHORIZED" + message: "Check your verification token." + x-codegen-request-body-name: body + /admin/config.yaml: + get: + tags: + - Admin + summary: Get full config (YAML) + description: "Retrieve the DBLab configuration in YAML format. All sensitive values are masked. + This method allows seeing the entire configuration file and can be helpful for + reviewing configuration and setting up workflows to automate DBLab provisioning + and configuration." + operationId: getConfigYaml + parameters: + - name: Verification-Token + in: header + required: true + schema: + type: string + responses: + 200: + description: "Returned configuration (YAML)" + content: + application/yaml: + schema: + $ref: '#/components/schemas/Config' + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Instance' + example: + code: "UNAUTHORIZED" + message: "Check your verification token." + /admin/test-db-source: + post: + tags: + - Admin + summary: Test source database + operationId: testDBConnection1 + parameters: + - name: Verification-Token + in: header + required: true + schema: + type: string + requestBody: + description: Connection DB object + content: + application/json: + schema: + $ref: '#/components/schemas/Connection' + required: true + responses: + 200: + description: Successful operation + content: {} + 400: + description: Bad request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: BAD_REQUEST + message: configuration management via UI/API disabled by admin + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Instance' + example: + code: "UNAUTHORIZED" + message: "Check your verification token." + x-codegen-request-body-name: body + /admin/ws-auth: + post: + tags: + - Admin + summary: Test source database + operationId: testDBConnection2 + parameters: + - name: Verification-Token + in: header + required: true + schema: + type: string + responses: + 200: + description: Successful operation + content: + '*/*': + schema: + $ref: '#/components/schemas/WSToken' + 400: + description: Bad request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: BAD_REQUEST + message: configuration management via UI/API disabled by admin + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Instance' + example: + code: "UNAUTHORIZED" + message: "Check your verification token." + /observation/start: + post: + tags: + - Observation + summary: Start observing + description: "[EXPERIMENTAL] Start an observation session for the specified clone. + Observation sessions help detect dangerous (long-lasting, exclusive) locks in CI/CD pipelines. + One of common scenarios is using observation sessions to test schema changes (DB migrations)." + operationId: startObservation + parameters: + - name: Verification-Token + in: header + required: true + schema: + type: string + requestBody: + description: Start observation object + content: + application/json: + schema: + $ref: '#/components/schemas/StartObservationRequest' + required: true + responses: + 200: + description: Successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ObservationSession' + 404: + description: Not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: NOT_FOUND + message: Requested object does not exist. Specify your request. + x-codegen-request-body-name: body + /observation/stop: + post: + tags: + - Observation + summary: Stop observing + description: "[EXPERIMENTAL] Stop the previously started observation session." + operationId: stopObservation + parameters: + - name: Verification-Token + in: header + required: true + schema: + type: string + requestBody: + description: Stop observation object + content: + application/json: + schema: + $ref: '#/components/schemas/StopObservationRequest' + required: true + responses: + 200: + description: Successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ObservationSession' + 400: + description: Bad request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + x-codegen-request-body-name: body + /observation/summary/{clone_id}/{session_id}: + get: + tags: + - Observation + summary: Get observation summary + description: "[EXPERIMENTAL] Collect the observation summary info." + operationId: summaryObservation + parameters: + - name: Verification-Token + in: header + required: true + schema: + type: string + - name: clone_id + in: path + description: Clone ID + required: true + schema: + type: string + - name: session_id + in: path + description: Session ID + required: true + schema: + type: string + responses: + 200: + description: Successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ObservationSummaryArtifact' + 400: + description: Bad request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /observation/download: + get: + tags: + - Observation + summary: Download an observation artifact + description: "[EXPERIMENTAL] Download an artifact for the specified clone and observation session." + operationId: downloadObservationArtifact + parameters: + - name: Verification-Token + in: header + required: true + schema: + type: string + - name: artifact_type + in: query + description: Type of the requested artifact + required: true + schema: + type: string + - name: clone_id + in: query + description: Clone ID + required: true + schema: + type: string + - name: session_id + in: query + description: Session ID + required: true + schema: + type: string + responses: + 200: + description: Successful operation + content: {} + 400: + description: Bad request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + +components: + schemas: + Instance: + type: object + properties: + status: + $ref: '#/components/schemas/Status' + engine: + $ref: '#/components/schemas/Engine' + pools: + type: array + items: + $ref: '#/components/schemas/PoolEntry' + cloning: + $ref: '#/components/schemas/Cloning' + retrieving: + $ref: '#/components/schemas/Retrieving' + provisioner: + $ref: '#/components/schemas/Provisioner' + synchronization: + $ref: '#/components/schemas/Synchronization' + Status: + required: + - code + - message + type: object + properties: + code: + type: string + description: Status code + message: + type: string + description: Status description + Engine: + type: object + properties: + version: + type: string + edition: + type: string + billingActive: + type: string + instanceID: + type: string + startedAt: + type: string + format: date-time + telemetry: + type: boolean + disableConfigModification: + type: boolean + PoolEntry: + type: object + properties: + name: + type: string + mode: + type: string + dataStateAt: + type: string + format: date-time + status: + type: string + cloneList: + type: array + items: + type: string + fileSystem: + $ref: '#/components/schemas/FileSystem' + FileSystem: + type: object + properties: + mode: + type: string + free: + type: integer + format: int64 + size: + type: integer + format: int64 + used: + type: integer + format: int64 + dataSize: + type: integer + format: int64 + usedBySnapshots: + type: integer + format: int64 + usedByClones: + type: integer + format: int64 + compressRatio: + type: integer + format: float64 + Cloning: + type: object + properties: + expectedCloningTime: + type: integer + format: float64 + numClones: + type: integer + format: int64 + clones: + type: array + items: + $ref: '#/components/schemas/Clone' + Retrieving: + type: object + properties: + mode: + type: string + status: + type: string + lastRefresh: + type: string + format: date-time + nextRefresh: + type: string + format: date-time + alerts: + type: array + items: + type: string + activity: + $ref: '#/components/schemas/Activity' + Activity: + type: object + properties: + source: + type: array + items: + $ref: '#/components/schemas/PGActivityEvent' + target: + type: array + items: + $ref: '#/components/schemas/PGActivityEvent' + PGActivityEvent: + type: object + properties: + user: + type: string + query: + type: string + duration: + type: number + waitEventType: + type: string + waitEvent: + type: string + Provisioner: + type: object + properties: + dockerImage: + type: string + containerConfig: + type: object + properties: {} + Synchronization: + type: object + properties: + status: + $ref: '#/components/schemas/Status' + startedAt: + type: string + format: date-time + lastReplayedLsn: + type: string + lastReplayedLsnAt: + type: string + format: date-time + replicationLag: + type: string + replicationUptime: + type: integer + Snapshot: + type: object + properties: + id: + type: string + createdAt: + type: string + format: date-time + dataStateAt: + type: string + format: date-time + physicalSize: + type: integer + format: int64 + logicalSize: + type: integer + format: int64 + pool: + type: string + numClones: + type: integer + format: int + Database: + type: object + properties: + connStr: + type: string + host: + type: string + port: + type: string + username: + type: string + password: + type: string + Clone: + type: object + properties: + id: + type: string + name: + type: string + snapshot: + $ref: '#/components/schemas/Snapshot' + protected: + type: boolean + default: false + deleteAt: + type: string + format: date-time + createdAt: + type: string + format: date-time + status: + $ref: '#/components/schemas/Status' + db: + $ref: '#/components/schemas/Database' + metadata: + $ref: '#/components/schemas/CloneMetadata' + CloneMetadata: + type: object + properties: + cloneDiffSize: + type: integer + format: int64 + logicalSize: + type: integer + format: int64 + cloningTime: + type: integer + format: float64 + maxIdleMinutes: + type: integer + format: int64 + CreateClone: + type: object + properties: + id: + type: string + snapshot: + type: object + properties: + id: + type: string + branch: + type: string + protected: + type: boolean + default: + db: + type: object + properties: + username: + type: string + password: + type: string + restricted: + type: boolean + default: + db_name: + type: string + ResetClone: + type: object + properties: + snapshotID: + type: string + latest: + type: boolean + default: false + description: "Define what snapshot needs to be used when resetting the clone. + 'snapshotID' allows specifying the exact snapshot, while 'latest' allows using + the latest snapshot among all available snapshots. The latter method can be + helpful when the exact snapshot ID is not known." + UpdateClone: + type: object + properties: + protected: + type: boolean + default: false + StartObservationRequest: + type: object + properties: + clone_id: + type: string + config: + $ref: '#/components/schemas/ObservationConfig' + tags: + type: object + properties: {} + db_name: + type: string + ObservationConfig: + type: object + properties: + observation_interval: + type: integer + format: int64 + max_lock_duration: + type: integer + format: int64 + max_duration: + type: integer + format: int64 + ObservationSession: + type: object + properties: + session_id: + type: integer + format: int64 + started_at: + type: string + format: date-time + finished_at: + type: string + format: date-time + config: + $ref: '#/components/schemas/ObservationConfig' + tags: + type: object + properties: {} + artifacts: + type: array + items: + type: string + result: + $ref: '#/components/schemas/ObservationResult' + ObservationResult: + type: object + properties: + status: + type: string + intervals: + type: array + items: + $ref: '#/components/schemas/ObservationInterval' + summary: + $ref: '#/components/schemas/ObservationSummary' + ObservationInterval: + type: object + properties: + started_at: + type: string + format: date-time + duration: + type: integer + format: int64 + warning: + type: string + ObservationSummary: + type: object + properties: + total_duration: + type: integer + format: float64 + total_intervals: + type: integer + format: int + warning_intervals: + type: integer + format: int + checklist: + $ref: '#/components/schemas/ObservationChecklist' + ObservationChecklist: + type: object + properties: + overall_success: + type: boolean + session_duration_acceptable: + type: boolean + no_long_dangerous_locks: + type: boolean + StopObservationRequest: + type: object + properties: + clone_id: + type: string + overall_error: + type: boolean + SummaryObservationRequest: + type: object + properties: + clone_id: + type: string + session_id: + type: string + ObservationSummaryArtifact: + type: object + properties: + session_id: + type: integer + format: int64 + clone_id: + type: string + duration: + type: object + properties: {} + db_size: + type: object + properties: {} + locks: + type: object + properties: {} + log_errors: + type: object + properties: {} + artifact_types: + type: array + items: + type: string + Error: + type: object + properties: + code: + type: string + message: + type: string + detail: + type: string + hint: + type: string + ResponseStatus: + type: object + properties: + status: + type: string + message: + type: string + Config: + type: object + Connection: + type: object + properties: + host: + type: string + port: + type: string + dbname: + type: string + username: + type: string + password: + type: string + db_list: + type: array + items: + type: string + WSToken: + type: object + properties: + token: + type: string + description: WebSocket token + Branch: + type: object + properties: + name: + type: string + parent: + type: string + dataStateAt: + type: string + format: date-time + snapshotID: + type: string + SnapshotDetails: + type: object + properties: + id: + type: string + parent: + type: string + child: + type: string + branch: + type: array + items: + type: string + root: + type: string + dataStateAt: + type: string + format: date-time + message: + type: string + FullRefresh: + type: object + properties: + status: + type: string + example: OK + message: + type: string + example: Full refresh started diff --git a/engine/api/swagger-spec/dblab_server_swagger.yaml b/engine/api/swagger-spec/dblab_server_swagger.yaml index ef02d701..8d44307a 100644 --- a/engine/api/swagger-spec/dblab_server_swagger.yaml +++ b/engine/api/swagger-spec/dblab_server_swagger.yaml @@ -1,883 +1,1353 @@ -swagger: "2.0" +# OpenAPI spec for DBLab API +# Useful links: +# - validate and test: https://editor.swagger.io/ +# - GitHub (give us a ⭐️): https://github.com/postgres-ai/database-lab-engine + +openapi: 3.0.1 info: - description: "This is a Database Lab Engine sample server." - version: "2.5.0" - title: "Database Lab" + title: DBLab API + description: This page provides the OpenAPI specification for the Database Lab (DBLab) + API, previously recognized as the DBLab API (Database Lab Engine API). contact: - email: "team@postgres.ai" + name: DBLab API Support + url: https://postgres.ai/contact + email: api@postgres.ai license: - name: "Database Lab License" - url: "https://gitlab.com/postgres-ai/database-lab/blob/master/LICENSE" -basePath: "/" + name: AGPL v3 / Database Lab License + url: https://github.com/postgres-ai/database-lab-engine/blob/master/LICENSE + version: 3.5.0 +externalDocs: + description: DBLab Docs + url: https://gitlab.com/postgres-ai/docs/tree/master/docs/database-lab + +servers: + - url: "https://demo.dblab.dev/api" + description: "DBLab demo server; token: 'demo-token'" + x-examples: + Verification-Token: "demo-token" + - url: "{scheme}://{host}:{port}/{basePath}" + description: "Any DBLab accessed locally / through SSH port forwarding" + variables: + scheme: + enum: + - "https" + - "http" + default: "http" + description: "'http' for local connections and SSH port forwarding; + 'https' for everything else." + host: + default: "127.0.0.1" + description: "Where DBLab server is installed. Use '127.0.0.1' to work locally + or when SSH port forwarding is used." + port: + default: "2345" + description: "Port to access DLE UI or API. Originally, '2345' is used for + direct work with API and '2346' – with UI. However, with UI, API is also available, + at ':2346/api'." + basePath: + default: "" + description: "'basePath' value to access API. Use empty when working with API port + (2345 by default), or '/api' when working with UI port ('2346' by default)." + x-examples: + Verification-Token: "custom_example_token" + tags: - - name: "Database Lab Engine" - description: "API Reference" + - name: "DBLab" + description: "DBLab API Reference" externalDocs: - description: "Database Lab Engine Docs" + description: "DBLab Docs - tutorials, howtos, references." url: "https://postgres.ai/docs/database-lab" -schemes: - - "https" - - "http" paths: /status: get: tags: - - "instance" - summary: "Get the status of the instance we are working with" - description: "" - operationId: "getInstanceStatus" - consumes: - - "application/json" - produces: - - "application/json" + - Instance + summary: "DBLab instance status, instance info, and list of clones" + description: "Retrieves detailed information about the DBLab instance: + status, version, etc. Additionally retrieves a list of all available clones." + operationId: getInstanceStatus parameters: - in: header name: Verification-Token - type: string required: true + schema: + type: string responses: 200: - description: "Successful operation" - schema: - $ref: "#/definitions/Instance" - 500: - description: "Internal server error" - schema: - $ref: "#/definitions/Error" + description: Returned a list of snapshots. + content: + application/json: + schema: + $ref: "#/components/schemas/Instance" + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: "UNAUTHORIZED" + message: "Check your verification token." /snapshots: get: tags: - - "instance" - summary: "Get the list of snapshots" - description: "" - operationId: "getSnapshots" - consumes: - - "application/json" - produces: - - "application/json" + - Snapshots + summary: List all snapshots + description: Return a list of all available snapshots. + operationId: snapshots parameters: - in: header name: Verification-Token - type: string + schema: + type: string required: true responses: 200: description: "Successful operation" - schema: - type: "array" - items: - $ref: "#/definitions/Snapshot" - 500: - description: "Internal server error" - schema: - $ref: "#/definitions/Error" + content: + application/json: + schema: + type: "array" + items: + $ref: "#/components/schemas/Snapshot" + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: "UNAUTHORIZED" + message: "Check your verification token." /clone: post: tags: - - "clone" - summary: "Create a clone" - description: "" - operationId: "createClone" - consumes: - - "application/json" - produces: - - "application/json" + - Clones + summary: Create a clone + operationId: createClone parameters: - in: header name: Verification-Token - type: string - required: true - - in: body - name: body - description: "Clone object" - required: true schema: - $ref: '#/definitions/CreateClone' + type: string + required: true + requestBody: + description: "Clone object" + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateClone' responses: 201: - description: "Successful operation" - schema: - $ref: "#/definitions/Clone" + description: Created a new clone + content: + application/json: + schema: + $ref: "#/components/schemas/Clone" + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: "UNAUTHORIZED" + message: "Check your verification token." 404: description: "Not found" - schema: - $ref: "#/definitions/Error" - 500: - description: "Internal server error" - schema: - $ref: "#/definitions/Error" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" /clone/{id}: get: tags: - - "clone" - summary: "Get a clone status" - description: "" - operationId: "getClone" - consumes: - - "application/json" - produces: - - "application/json" + - Clones + summary: Retrieve a clone + description: Retrieves the information for the specified clone. + operationId: clones parameters: - in: header name: Verification-Token - type: string + schema: + type: string required: true - in: path required: true name: "id" - type: "string" + schema: + type: "string" description: "Clone ID" responses: 200: - description: "Successful operation" - schema: - $ref: "#/definitions/Clone" + description: Returned detailed information for the specified clone + content: + application/json: + schema: + $ref: "#/components/schemas/Clone" + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: "UNAUTHORIZED" + message: "Check your verification token." 404: description: "Not found" - schema: - $ref: "#/definitions/Error" - 500: - description: "Internal server error" - schema: - $ref: "#/definitions/Error" - + content: + application/json: + schema: + $ref: "#/components/schemas/Error" patch: tags: - - "clone" - summary: "Update a clone" - description: "" - operationId: "patchClone" - consumes: - - "application/json" - produces: - - "application/json" + - Clones + summary: Update a clone + description: "Updates the specified clone by setting the values of the parameters passed. + Currently, only one paramater is supported: 'protected'." + operationId: patchClone parameters: - in: header name: Verification-Token - type: string + schema: + type: string required: true - in: path required: true name: "id" - type: "string" - description: "Clone ID" - - in: body - name: body - description: "Clone object" - required: true schema: - $ref: '#/definitions/UpdateClone' + type: "string" + description: "Clone ID" + requestBody: + description: "Clone object" + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateClone' responses: 200: - description: "Successful operation" - schema: - $ref: "#/definitions/Clone" - 404: - description: "Not found" - schema: - $ref: "#/definitions/Error" - 500: - description: "Internal server error" - schema: - $ref: "#/definitions/Error" + description: Successfully updated the specified clone + content: + application/json: + schema: + $ref: "#/components/schemas/Clone" + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: "UNAUTHORIZED" + message: "Check your verification token." + #404: # TODO: fix it in engine (currently returns 500) + # description: Not found + # content: + # application/json: + # schema: + # $ref: '#/components/schemas/Error' + # example: + # code: NOT_FOUND + # message: Requested object does not exist. Specify your request. delete: tags: - - "clone" - summary: "Delete a clone" - description: "" - operationId: "destroyClone" - consumes: - - "application/json" - produces: - - "application/json" + - Clones + summary: Delete a clone + description: Permanently delete the specified clone. It cannot be undone. + operationId: destroyClone parameters: - in: header name: Verification-Token - type: string + schema: + type: string required: true - in: path required: true name: "id" - type: "string" + schema: + type: "string" description: "Clone ID" responses: + 200: + description: Successfully deleted the specified clone + content: + application/json: + example: + "OK" + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: "UNAUTHORIZED" + message: "Check your verification token." 404: description: "Not found" - schema: - $ref: "#/definitions/Error" - 500: - description: "Internal server error" - schema: - $ref: "#/definitions/Error" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" /clone/{id}/reset: post: tags: - - "clone" - summary: "Reset a clone" - description: "" - operationId: "resetClone" - consumes: - - "application/json" - produces: - - "application/json" + - Clones + summary: Reset a clone + description: "Reset the specified clone to a previously stored state. + This can be done by specifying a particular snapshot ID or using the 'latest' flag. + All changes made after the snapshot are discarded during the reset, unless those + changes were preserved in a snapshot. All database connections will be reset, + requiring users and applications to reconnect. The duration of the reset operation + is comparable to the creation of a new clone. However, unlike creating a new clone, + the reset operation retains the database credentials and does not change the port. + Consequently, users and applications can continue to use the same database credentials + post-reset, though reconnection will be necessary. Please note that any unsaved changes + will be irretrievably lost during this operation, so ensure necessary data is backed up + in a snapshot prior to resetting the clone." + operationId: resetClone parameters: - in: header name: Verification-Token - type: string + schema: + type: string required: true - in: path required: true name: "id" - type: "string" - description: "Clone ID" - - in: body - name: body - description: "Reset object" - required: false schema: - $ref: '#/definitions/ResetClone' + type: "string" + description: "Clone ID" + requestBody: + description: "Reset object" + required: false + content: + application/json: + schema: + $ref: '#/components/schemas/ResetClone' responses: + 200: + description: Successfully reset the state of the specified clone + content: + application/json: + example: + "OK" + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: "UNAUTHORIZED" + message: "Check your verification token." 404: description: "Not found" - schema: - $ref: "#/definitions/Error" - 500: - description: "Internal server error" - schema: - $ref: "#/definitions/Error" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" /observation/start: post: tags: - - "observation" - summary: "Start an observation session" - description: "" - operationId: "startObservation" - consumes: - - "application/json" - produces: - - "application/json" + - Observation + summary: Start observing + description: "[EXPERIMENTAL] Start an observation session for the specified clone. + Observation sessions help detect dangerous (long-lasting, exclusive) locks in CI/CD pipelines. + One of common scenarios is using observation sessions to test schema changes (DB migrations)." + operationId: startObservation parameters: - in: header name: Verification-Token - type: string + schema: + type: string required: true - - in: body - name: body + requestBody: description: "Start observation object" required: true - schema: - $ref: '#/definitions/StartObservationRequest' + content: + application/json: + schema: + $ref: '#/components/schemas/StartObservationRequest' responses: 200: - description: "Successful operation" - schema: - $ref: "#/definitions/ObservationSession" + description: Observation started + content: + application/json: + schema: + $ref: "#/components/schemas/ObservationSession" 400: description: "Bad request" - schema: - $ref: "#/definitions/Error" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" 404: description: "Not found" - schema: - $ref: "#/definitions/Error" - 500: - description: "Internal server error" - schema: - $ref: "#/definitions/Error" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" /observation/stop: post: tags: - - "observation" - summary: "Stop the observation session" - description: "" - operationId: "stopObservation" - consumes: - - "application/json" - produces: - - "application/json" + - Observation + summary: Stop observing + description: "[EXPERIMENTAL] Stop the previously started observation session." + operationId: stopObservation parameters: - in: header name: Verification-Token - type: string - required: true - - in: body - name: body - description: "Stop observation object" - required: true schema: - $ref: '#/definitions/StopObservationRequest' + type: string + required: true + requestBody: + description: Stop observation object + content: + application/json: + schema: + $ref: '#/components/schemas/StopObservationRequest' + required: true responses: 200: - description: "Successful operation" - schema: - $ref: "#/definitions/ObservationSession" + description: Observation stopped + content: + application/json: + schema: + $ref: "#/components/schemas/ObservationSession" 400: description: "Bad request" - schema: - $ref: "#/definitions/Error" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" 404: description: "Not found" - schema: - $ref: "#/definitions/Error" - 500: - description: "Internal server error" - schema: - $ref: "#/definitions/Error" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" /observation/summary/{clone_id}/{session_id}: get: tags: - - "observation" - summary: "Get the observation summary info" - description: "" - operationId: "summaryObservation" - consumes: - - "application/json" - produces: - - "application/json" + - Observation + summary: Get observation summary + description: "[EXPERIMENTAL] Collect the observation summary info." + operationId: summaryObservation parameters: - in: header name: Verification-Token - type: string + schema: + type: string required: true - in: path required: true name: "clone_id" - type: "string" + schema: + type: "string" description: "Clone ID" - in: path required: true name: "session_id" - type: "string" + schema: + type: "string" description: "Session ID" responses: 200: - description: "Successful operation" - schema: - $ref: "#/definitions/ObservationSummaryArtifact" + description: Observation summary collected + content: + application/json: + schema: + $ref: "#/components/schemas/ObservationSummaryArtifact" 400: description: "Bad request" - schema: - $ref: "#/definitions/Error" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" 404: description: "Not found" - schema: - $ref: "#/definitions/Error" - 500: - description: "Internal server error" - schema: - $ref: "#/definitions/Error" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" /observation/download: get: tags: - - "observation" - summary: "Download the observation artifact" - description: "" - operationId: "downloadObservationArtifact" - consumes: - - "application/json" - produces: - - "application/json" + - Observation + summary: Download an observation artifact + description: "[EXPERIMENTAL] Download an artifact for the specified clone and observation session." + operationId: downloadObservationArtifact parameters: - in: header name: Verification-Token - type: string + schema: + type: string required: true - - in: path + - in: query required: true name: "artifact_type" - type: "string" + schema: + type: "string" description: "Type of the requested artifact" - - in: path + - in: query required: true name: "clone_id" - type: "string" + schema: + type: "string" description: "Clone ID" - - in: path + - in: query required: true name: "session_id" - type: "string" + schema: + type: "string" description: "Session ID" responses: 200: - description: "Successful operation" + description: Downloaded the specified artifact of the specified + observation session and clone 400: description: "Bad request" - schema: - $ref: "#/definitions/Error" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" 404: description: "Not found" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + + /instance/retrieval: + get: + tags: + - Instance + summary: Data refresh status + description: 'Report a status of the data refresh subsystem (also known as + "data retrieval"): timestamps of the previous and next refresh runs, status, messages.' + operationId: instanceRetrieval + parameters: + - in: header + name: Verification-Token schema: - $ref: "#/definitions/Error" + type: string + required: true + responses: + 200: + description: Reported a status of the data retrieval subsystem + content: + application/json: + schema: + $ref: "#/components/schemas/Retrieving" + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + example: + code: "UNAUTHORIZED" + message: "Check your verification token." - /estimate: + /healthz: get: tags: - - "observation" - summary: "Run clone estimator" - description: "" - operationId: "runEstimator" - consumes: - - "application/json" - produces: - - "application/json" + - Instance + summary: Service health check + description: "Check the overall health and availability of the API system. + This endpoint does not require the 'Verification-Token' header." + operationId: healthCheck parameters: - in: header name: Verification-Token - type: string + schema: + type: string required: true - - in: path + responses: + 200: + description: Returned general health status + content: + application/json: + schema: + $ref: "#/components/schemas/Engine" + + /admin/config: + get: + tags: + - Admin + summary: Get config + description: "Retrieve the DBLab configuration. All sensitive values are masked. + Only limited set of configuration parameters is returned – only those that can be + changed via API (unless reconfiguration via API is disabled by admin). The result + is provided in JSON format." + operationId: getConfig + parameters: + - in: header + name: Verification-Token + schema: + type: string required: true - name: "clone_id" - type: "string" - description: "Clone ID" - - in: path + responses: + 200: + description: "Successful operation" + content: + application/json: + schema: + $ref: "#/components/schemas/Config" + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + example: + code: "UNAUTHORIZED" + message: "Check your verification token." + post: + tags: + - Admin + summary: Set config + description: "Set specific configurations for the DBLab instance using this endpoint. + The returned configuration parameters are limited to those that can be modified + via the API (unless the API-based reconfiguration has been disabled by an administrator). + The result will be provided in JSON format." + operationId: setConfig + parameters: + - in: header + name: Verification-Token + schema: + type: string required: true - name: "pid" - type: "string" - description: "Process ID" + requestBody: + description: "Set configuration object" + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Config' responses: 200: - description: "The estimation session has been finished successfully." + description: Successfully saved and applied configuration parameters + content: + application/json: + schema: + $ref: "#/components/schemas/Config" 400: - description: "Bad request" + description: Bad request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: BAD_REQUEST + message: configuration management via UI/API disabled by admin + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + example: + code: "UNAUTHORIZED" + message: "Check your verification token." + + /admin/config.yaml: + get: + tags: + - Admin + summary: Get full config (YAML) + description: "Retrieve the DBLab configuration in YAML format. All sensitive values are masked. + This method allows seeing the entire configuration file and can be helpful for + reviewing configuration and setting up workflows to automate DBLab provisioning + and configuration." + operationId: getConfigYaml + parameters: + - in: header + name: Verification-Token schema: - $ref: "#/definitions/Error" - 404: - description: "Not found" + type: string + required: true + responses: + 200: + description: "Returned configuration (YAML)" + content: + application/yaml: + schema: + $ref: "#/components/schemas/Config" + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + example: + code: "UNAUTHORIZED" + message: "Check your verification token." + /admin/test-db-source: + post: + tags: + - Admin + summary: Test source database + description: "" + operationId: testDBConnection + parameters: + - in: header + name: Verification-Token schema: - $ref: "#/definitions/Error" - 500: - description: "Internal server error" + type: string + required: true + requestBody: + description: "Connection DB object" + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Connection' + responses: + 200: + description: "Successful operation" + content: + application/json: + schema: + $ref: "#/components/schemas/TestConnectionResponse" + 400: + description: Bad request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: BAD_REQUEST + message: configuration management via UI/API disabled by admin + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + example: + code: "UNAUTHORIZED" + message: "Check your verification token." + /admin/ws-auth: + post: + tags: + - Admin + summary: "TBD" + description: "" + operationId: testDBConnection2 + parameters: + - in: header + name: Verification-Token schema: - $ref: "#/definitions/Error" - - /healthz: + type: string + required: true + responses: + 200: + description: "Successful operation" + content: + application/json: + schema: + $ref: "#/components/schemas/WSToken" + /admin/billing-status: get: tags: - - "instance" - summary: "Get the state of the instance we are working with" + - Admin + summary: Checks billing status description: "" - operationId: "healthCheck" - produces: - - "application/json" + operationId: billingStatus parameters: - in: header name: Verification-Token - type: string + schema: + type: string required: true responses: 200: description: "Successful operation" + content: + application/json: + schema: + $ref: "#/components/schemas/BillingStatus" + 400: + description: "Bad request" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + example: + code: "UNAUTHORIZED" + message: "Check your verification token." + /admin/activate: + post: + tags: + - Admin + summary: "Activate billing" + description: "Activates billing and sends usage statistics of the instance" + operationId: activateBilling + parameters: + - in: header + name: Verification-Token schema: - $ref: "#/definitions/Engine" - 500: - description: "Internal server error" - schema: - $ref: "#/definitions/Error" - - -definitions: - Instance: - type: "object" - properties: - status: - $ref: "#/definitions/Status" - engine: - $ref: "#/definitions/Engine" - pools: - type: "array" - items: - $ref: "#/definitions/PoolEntry" - cloning: - $ref: "#/definitions/Cloning" - retrieving: - $ref: "#/definitions/Retrieving" - provisioner: - $ref: "#/definitions/Provisioner" - - Status: - type: "object" - required: - - "code" - - "message" - properties: - code: - type: "string" - description: "Status code" - message: - type: "string" - description: "Status description" - - Engine: - type: "object" - properties: - version: - type: "string" - startedAt: - type: "string" - format: "date-time" - telemetry: - type: boolean - - PoolEntry: - type: "object" - properties: - name: - type: "string" - mode: - type: "string" - dataStateAt: - type: "string" - format: "date-time" - status: - type: "string" - cloneList: - type: "array" - items: - type: "string" - fileSystem: - $ref: "#/definitions/FileSystem" - - FileSystem: - type: "object" - properties: - mode: - type: "string" - free: - type: "integer" - format: "int64" - size: - type: "integer" - format: "int64" - used: - type: "integer" - format: "int64" - dataSize: - type: "integer" - format: "int64" - usedBySnapshots: - type: "integer" - format: "int64" - usedByClones: - type: "integer" - format: "int64" - compressRatio: - type: "integer" - format: "float64" - - Cloning: - type: "object" - properties: - expectedCloningTime: - type: "integer" - format: "float64" - numClones: - type: "integer" - format: "int64" - clones: - type: "array" - items: - $ref: "#/definitions/Clone" - - Retrieving: - type: "object" - properties: - mode: - type: "string" - status: - type: "string" - lastRefresh: - type: "string" - format: "date-time" - nextRefresh: - type: "string" - format: "date-time" - - Provisioner: - type: "object" - properties: - dockerImage: - type: "string" - containerConfig: - type: "object" - - Snapshot: - type: "object" - properties: - id: - type: "string" - createdAt: - type: "string" - format: "date-time" - dataStateAt: - type: "string" - format: "date-time" - physicalSize: - type: "integer" - format: "int64" - logicalSize: - type: "integer" - format: "int64" - pool: - type: "string" - numClones: - type: "integer" - format: "int" - - Database: - type: "object" - properties: - connStr: - type: "string" - host: - type: "string" - port: - type: "string" - username: - type: "string" - password: - type: "string" - - Clone: - type: "object" - properties: - id: - type: "string" - name: - type: "string" - snapshot: - $ref: "#/definitions/Snapshot" - protected: - type: "boolean" - default: false - deleteAt: - type: "string" - format: "date-time" - createdAt: - type: "string" - format: "date-time" - status: - $ref: "#/definitions/Status" - db: - $ref: "#/definitions/Database" - metadata: - $ref: "#/definitions/CloneMetadata" - - CloneMetadata: - type: "object" - properties: - cloneDiffSize: - type: "integer" - format: "int64" - logicalSize: - type: "integer" - format: "int64" - cloningTime: - type: "integer" - format: "float64" - maxIdleMinutes: - type: "integer" - format: "int64" - - CreateClone: - type: "object" - properties: - id: - type: "string" - snapshot: - type: "object" - properties: - id: + type: string + required: true + responses: + 200: + description: "Successful operation" + content: + application/json: + schema: + $ref: "#/components/schemas/Engine" + 400: + description: "Bad request" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + 401: + description: Unauthorized access + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + example: + code: "UNAUTHORIZED" + message: "Check your verification token." + +components: + schemas: + + Instance: + type: "object" + properties: + status: + $ref: "#/components/schemas/Status" + engine: + $ref: "#/components/schemas/Engine" + pools: + type: "array" + items: + $ref: "#/components/schemas/PoolEntry" + cloning: + $ref: "#/components/schemas/Cloning" + retrieving: + $ref: "#/components/schemas/Retrieving" + provisioner: + $ref: "#/components/schemas/Provisioner" + synchronization: + $ref: "#/components/schemas/Synchronization" + + Status: + type: "object" + required: + - "code" + - "message" + properties: + code: + type: "string" + description: "Status code" + message: + type: "string" + description: "Status description" + + Engine: + type: "object" + properties: + version: + type: "string" + edition: + type: "string" + billingActive: + type: boolean + instanceID: + type: string + startedAt: + type: "string" + format: "date-time" + telemetry: + type: boolean + disableConfigModification: + type: boolean + + PoolEntry: + type: "object" + properties: + name: + type: "string" + mode: + type: "string" + dataStateAt: + type: "string" + format: "date-time" + status: + type: "string" + cloneList: + type: "array" + items: type: "string" - protected: - type: "boolean" - default: false - db: - type: "object" - properties: - username: + fileSystem: + $ref: "#/components/schemas/FileSystem" + + FileSystem: + type: "object" + properties: + mode: + type: "string" + free: + type: "integer" + format: "int64" + size: + type: "integer" + format: "int64" + used: + type: "integer" + format: "int64" + dataSize: + type: "integer" + format: "int64" + usedBySnapshots: + type: "integer" + format: "int64" + usedByClones: + type: "integer" + format: "int64" + compressRatio: + type: "integer" + format: "float64" + + Cloning: + type: "object" + properties: + expectedCloningTime: + type: "integer" + format: "float64" + numClones: + type: "integer" + format: "int64" + clones: + type: "array" + items: + $ref: "#/components/schemas/Clone" + + Retrieving: + type: "object" + properties: + mode: + type: "string" + status: + type: "string" + lastRefresh: + type: "string" + format: "date-time" + nextRefresh: + type: "string" + format: "date-time" + activity: + $ref: "#/components/schemas/Activity" + + Activity: + type: "object" + properties: + source: + type: "array" + items: + $ref: "#/components/schemas/PGActivityEvent" + target: + type: "array" + items: + $ref: "#/components/schemas/PGActivityEvent" + + PGActivityEvent: + type: "object" + properties: + user: + type: "string" + query: + type: "string" + duration: + type: "number" + waitEventType: + type: "string" + waitEvent: + type: "string" + + Provisioner: + type: "object" + properties: + dockerImage: + type: "string" + containerConfig: + type: "object" + + Synchronization: + type: "object" + properties: + status: + $ref: "#/components/schemas/Status" + startedAt: + type: "string" + format: "date-time" + lastReplayedLsn: + type: "string" + lastReplayedLsnAt: + type: "string" + format: "date-time" + replicationLag: + type: "string" + replicationUptime: + type: "integer" + + Snapshot: + type: "object" + properties: + id: + type: "string" + createdAt: + type: "string" + format: "date-time" + dataStateAt: + type: "string" + format: "date-time" + physicalSize: + type: "integer" + format: "int64" + logicalSize: + type: "integer" + format: "int64" + pool: + type: "string" + numClones: + type: "integer" + format: "int" + + Database: + type: "object" + properties: + connStr: + type: "string" + host: + type: "string" + port: + type: "string" + username: + type: "string" + password: + type: "string" + + Clone: + type: "object" + properties: + id: + type: "string" + name: + type: "string" + snapshot: + $ref: "#/components/schemas/Snapshot" + protected: + type: "boolean" + default: false + deleteAt: + type: "string" + format: "date-time" + createdAt: + type: "string" + format: "date-time" + status: + $ref: "#/components/schemas/Status" + db: + $ref: "#/components/schemas/Database" + metadata: + $ref: "#/components/schemas/CloneMetadata" + + CloneMetadata: + type: "object" + properties: + cloneDiffSize: + type: "integer" + format: "int64" + logicalSize: + type: "integer" + format: "int64" + cloningTime: + type: "integer" + format: "float64" + maxIdleMinutes: + type: "integer" + format: "int64" + + CreateClone: + type: "object" + properties: + id: + type: "string" + snapshot: + type: "object" + properties: + id: + type: "string" + protected: + type: "boolean" + default: false + db: + type: "object" + properties: + username: + type: "string" + password: + type: "string" + restricted: + type: "boolean" + default: false + db_name: + type: "string" + + ResetClone: + type: "object" + description: "Object defining specific snapshot used when resetting clone. Optional parameters `latest` and `snapshotID` must not be specified together" + properties: + snapshotID: + type: "string" + latest: + type: "boolean" + default: false + + UpdateClone: + type: "object" + properties: + protected: + type: "boolean" + default: false + + StartObservationRequest: + type: "object" + properties: + clone_id: + type: "string" + config: + $ref: "#/components/schemas/ObservationConfig" + tags: + type: "object" + db_name: + type: "string" + + ObservationConfig: + type: "object" + properties: + observation_interval: + type: "integer" + format: "int64" + max_lock_duration: + type: "integer" + format: "int64" + max_duration: + type: "integer" + format: "int64" + + ObservationSession: + type: "object" + properties: + session_id: + type: "integer" + format: "int64" + started_at: + type: "string" + format: "date-time" + finished_at: + type: "string" + format: "date-time" + config: + $ref: "#/components/schemas/ObservationConfig" + tags: + type: "object" + artifacts: + type: array + items: + type: string + result: + $ref: "#/components/schemas/ObservationResult" + + ObservationResult: + type: "object" + properties: + status: + type: "string" + intervals: + type: array + items: + $ref: "#/components/schemas/ObservationInterval" + summary: + $ref: "#/components/schemas/ObservationSummary" + + ObservationInterval: + type: "object" + properties: + started_at: + type: "string" + format: "date-time" + duration: + type: "integer" + format: "int64" + warning: + type: string + + ObservationSummary: + type: "object" + properties: + total_duration: + type: "integer" + format: "float64" + total_intervals: + type: "integer" + format: "int" + warning_intervals: + type: "integer" + format: "int" + checklist: + $ref: "#/components/schemas/ObservationChecklist" + + ObservationChecklist: + type: "object" + properties: + overall_success: + type: boolean + session_duration_acceptable: + type: boolean + no_long_dangerous_locks: + type: boolean + + StopObservationRequest: + type: "object" + properties: + clone_id: + type: "string" + overall_error: + type: "boolean" + + SummaryObservationRequest: + type: "object" + properties: + clone_id: + type: "string" + session_id: + type: "string" + + ObservationSummaryArtifact: + type: "object" + properties: + session_id: + type: "integer" + format: "int64" + clone_id: + type: "string" + duration: + type: "object" + db_size: + type: "object" + locks: + type: "object" + log_errors: + type: "object" + artifact_types: + type: "array" + items: type: "string" - password: + + Error: + type: "object" + properties: + code: + type: "string" + message: + type: "string" + detail: + type: "string" + hint: + type: "string" + + Config: + type: object + + Connection: + type: "object" + properties: + host: + type: "string" + port: + type: "string" + dbname: + type: "string" + username: + type: "string" + password: + type: "string" + db_list: + type: "array" + items: type: "string" - restricted: - type: "boolean" - default: false - db_name: + + TestConnectionResponse: + type: "object" + properties: + status: + type: "string" + result: + type: "string" + message: + type: "string" + dbVersion: + type: "integer" + tuningParams: + type: "object" + additionalProperties: type: "string" - ResetClone: - type: "object" - description: "Object defining specific snapshot used when resetting clone. Optional parameters `latest` and `snapshotID` must not be specified together" - properties: - snapshotID: - type: "string" - latest: - type: "boolean" - default: false - - UpdateClone: - type: "object" - properties: - protected: - type: "boolean" - default: false - - StartObservationRequest: - type: "object" - properties: - clone_id: - type: "string" - config: - $ref: "#/definitions/ObservationConfig" - tags: - type: "object" - db_name: - type: "string" - - ObservationConfig: - type: "object" - properties: - observation_interval: - type: "integer" - format: "int64" - max_lock_duration: - type: "integer" - format: "int64" - max_duration: - type: "integer" - format: "int64" - - ObservationSession: - type: "object" - properties: - session_id: - type: "integer" - format: "int64" - started_at: - type: "string" - format: "date-time" - finished_at: - type: "string" - format: "date-time" - config: - $ref: "#/definitions/ObservationConfig" - tags: - type: "object" - artifacts: - type: array - items: + WSToken: + type: "object" + properties: + token: + type: "string" + description: "WebSocket token" + + BillingStatus: + type: "object" + properties: + result: type: string - result: - $ref: "#/definitions/ObservationResult" - - ObservationResult: - type: "object" - properties: - status: - type: "string" - intervals: - type: array - items: - $ref: "#/definitions/ObservationInterval" - summary: - $ref: "#/definitions/ObservationSummary" - - ObservationInterval: - type: "object" - properties: - started_at: - type: "string" - format: "date-time" - duration: - type: "integer" - format: "int64" - warning: - type: string - - ObservationSummary: - type: "object" - properties: - total_duration: - type: "integer" - format: "float64" - total_intervals: - type: "integer" - format: "int" - warning_intervals: - type: "integer" - format: "int" - checklist: - $ref: "#/definitions/ObservationChecklist" - - ObservationChecklist: - type: "object" - properties: - overall_success: - type: boolean - session_duration_acceptable: - type: boolean - no_long_dangerous_locks: - type: boolean - - StopObservationRequest: - type: "object" - properties: - clone_id: - type: "string" - overall_error: - type: "boolean" - - SummaryObservationRequest: - type: "object" - properties: - clone_id: - type: "string" - session_id: - type: "string" - - ObservationSummaryArtifact: - type: "object" - properties: - session_id: - type: "integer" - format: "int64" - clone_id: - type: "string" - duration: - type: "object" - db_size: - type: "object" - locks: - type: "object" - log_errors: - type: "object" - artifact_types: - type: "array" - items: - type: "string" - - Error: - type: "object" - properties: - code: - type: "string" - message: - type: "string" - detail: - type: "string" - hint: - type: "string" + billing_active: + type: boolean + recognized_org: + $ref: "#/components/schemas/RecognizedOrg" -externalDocs: - description: "Database Lab Docs" - url: "https://gitlab.com/postgres-ai/docs/tree/master/docs/database-lab" + RecognizedOrg: + type: object + properties: + id: + type: integer + name: + type: string + alias: + type: string + billing_page: + type: string + priveleged_until: + type: string + format: date-time diff --git a/engine/api/swagger-ui/index.css b/engine/api/swagger-ui/index.css new file mode 100644 index 00000000..f2376fda --- /dev/null +++ b/engine/api/swagger-ui/index.css @@ -0,0 +1,16 @@ +html { + box-sizing: border-box; + overflow: -moz-scrollbars-vertical; + overflow-y: scroll; +} + +*, +*:before, +*:after { + box-sizing: inherit; +} + +body { + margin: 0; + background: #fafafa; +} diff --git a/engine/api/swagger-ui/index.html b/engine/api/swagger-ui/index.html index ebb550b3..84ae62d3 100644 --- a/engine/api/swagger-ui/index.html +++ b/engine/api/swagger-ui/index.html @@ -5,56 +5,15 @@ Swagger UI + -

- - + diff --git a/engine/api/swagger-ui/oauth2-redirect.html b/engine/api/swagger-ui/oauth2-redirect.html index 64b171f7..56409171 100644 --- a/engine/api/swagger-ui/oauth2-redirect.html +++ b/engine/api/swagger-ui/oauth2-redirect.html @@ -13,7 +13,7 @@ var isValid, qp, arr; if (/code|token|error/.test(window.location.hash)) { - qp = window.location.hash.substring(1); + qp = window.location.hash.substring(1).replace('?', '&'); } else { qp = location.search.substring(1); } @@ -38,7 +38,7 @@ authId: oauth2.auth.name, source: "auth", level: "warning", - message: "Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server" + message: "Authorization may be unsafe, passed state was changed in server. The passed state wasn't returned from auth server." }); } @@ -58,7 +58,7 @@ authId: oauth2.auth.name, source: "auth", level: "error", - message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server" + message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server." }); } } else { @@ -67,9 +67,13 @@ window.close(); } - window.addEventListener('DOMContentLoaded', function () { - run(); - }); + if (document.readyState !== 'loading') { + run(); + } else { + document.addEventListener('DOMContentLoaded', function () { + run(); + }); + } diff --git a/engine/api/swagger-ui/swagger-initializer.js b/engine/api/swagger-ui/swagger-initializer.js new file mode 100644 index 00000000..c5e40fbe --- /dev/null +++ b/engine/api/swagger-ui/swagger-initializer.js @@ -0,0 +1,20 @@ +window.onload = function() { + // + + // the following lines will be replaced by docker/configurator, when it runs in a docker-container + window.ui = SwaggerUIBundle({ + url: "api/swagger-spec/dblab_openapi.yaml", + dom_id: '#swagger-ui', + deepLinking: true, + presets: [ + SwaggerUIBundle.presets.apis, + SwaggerUIStandalonePreset + ], + plugins: [ + SwaggerUIBundle.plugins.DownloadUrl + ], + layout: "StandaloneLayout" + }); + + // +}; diff --git a/engine/api/swagger-ui/swagger-ui-bundle.js b/engine/api/swagger-ui/swagger-ui-bundle.js index 2cbe107d..a9c1a20e 100644 --- a/engine/api/swagger-ui/swagger-ui-bundle.js +++ b/engine/api/swagger-ui/swagger-ui-bundle.js @@ -1,3 +1,3 @@ /*! For license information please see swagger-ui-bundle.js.LICENSE.txt */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.SwaggerUIBundle=t():e.SwaggerUIBundle=t()}(this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/dist",n(n.s=481)}([function(e,t,n){"use strict";e.exports=n(555)},function(e,t,n){e.exports=function(){"use strict";var e=Array.prototype.slice;function t(e,t){t&&(e.prototype=Object.create(t.prototype)),e.prototype.constructor=e}function n(e){return i(e)?e:J(e)}function r(e){return u(e)?e:K(e)}function o(e){return s(e)?e:Y(e)}function a(e){return i(e)&&!c(e)?e:G(e)}function i(e){return!(!e||!e[f])}function u(e){return!(!e||!e[p])}function s(e){return!(!e||!e[h])}function c(e){return u(e)||s(e)}function l(e){return!(!e||!e[d])}t(r,n),t(o,n),t(a,n),n.isIterable=i,n.isKeyed=u,n.isIndexed=s,n.isAssociative=c,n.isOrdered=l,n.Keyed=r,n.Indexed=o,n.Set=a;var f="@@__IMMUTABLE_ITERABLE__@@",p="@@__IMMUTABLE_KEYED__@@",h="@@__IMMUTABLE_INDEXED__@@",d="@@__IMMUTABLE_ORDERED__@@",m="delete",v=5,g=1<>>0;if(""+n!==t||4294967295===n)return NaN;t=n}return t<0?A(e)+t:t}function C(){return!0}function j(e,t,n){return(0===e||void 0!==n&&e<=-n)&&(void 0===t||void 0!==n&&t>=n)}function T(e,t){return N(e,t,0)}function I(e,t){return N(e,t,t)}function N(e,t,n){return void 0===e?n:e<0?Math.max(0,t+e):void 0===t?e:Math.min(t,e)}var P=0,M=1,R=2,D="function"==typeof Symbol&&Symbol.iterator,L="@@iterator",B=D||L;function F(e){this.next=e}function z(e,t,n,r){var o=0===e?t:1===e?n:[t,n];return r?r.value=o:r={value:o,done:!1},r}function q(){return{value:void 0,done:!0}}function U(e){return!!H(e)}function V(e){return e&&"function"==typeof e.next}function W(e){var t=H(e);return t&&t.call(e)}function H(e){var t=e&&(D&&e[D]||e[L]);if("function"==typeof t)return t}function $(e){return e&&"number"==typeof e.length}function J(e){return null==e?ie():i(e)?e.toSeq():ce(e)}function K(e){return null==e?ie().toKeyedSeq():i(e)?u(e)?e.toSeq():e.fromEntrySeq():ue(e)}function Y(e){return null==e?ie():i(e)?u(e)?e.entrySeq():e.toIndexedSeq():se(e)}function G(e){return(null==e?ie():i(e)?u(e)?e.entrySeq():e:se(e)).toSetSeq()}F.prototype.toString=function(){return"[Iterator]"},F.KEYS=P,F.VALUES=M,F.ENTRIES=R,F.prototype.inspect=F.prototype.toSource=function(){return this.toString()},F.prototype[B]=function(){return this},t(J,n),J.of=function(){return J(arguments)},J.prototype.toSeq=function(){return this},J.prototype.toString=function(){return this.__toString("Seq {","}")},J.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},J.prototype.__iterate=function(e,t){return fe(this,e,t,!0)},J.prototype.__iterator=function(e,t){return pe(this,e,t,!0)},t(K,J),K.prototype.toKeyedSeq=function(){return this},t(Y,J),Y.of=function(){return Y(arguments)},Y.prototype.toIndexedSeq=function(){return this},Y.prototype.toString=function(){return this.__toString("Seq [","]")},Y.prototype.__iterate=function(e,t){return fe(this,e,t,!1)},Y.prototype.__iterator=function(e,t){return pe(this,e,t,!1)},t(G,J),G.of=function(){return G(arguments)},G.prototype.toSetSeq=function(){return this},J.isSeq=ae,J.Keyed=K,J.Set=G,J.Indexed=Y;var Q,Z,X,ee="@@__IMMUTABLE_SEQ__@@";function te(e){this._array=e,this.size=e.length}function ne(e){var t=Object.keys(e);this._object=e,this._keys=t,this.size=t.length}function re(e){this._iterable=e,this.size=e.length||e.size}function oe(e){this._iterator=e,this._iteratorCache=[]}function ae(e){return!(!e||!e[ee])}function ie(){return Q||(Q=new te([]))}function ue(e){var t=Array.isArray(e)?new te(e).fromEntrySeq():V(e)?new oe(e).fromEntrySeq():U(e)?new re(e).fromEntrySeq():"object"==typeof e?new ne(e):void 0;if(!t)throw new TypeError("Expected Array or iterable object of [k, v] entries, or keyed object: "+e);return t}function se(e){var t=le(e);if(!t)throw new TypeError("Expected Array or iterable object of values: "+e);return t}function ce(e){var t=le(e)||"object"==typeof e&&new ne(e);if(!t)throw new TypeError("Expected Array or iterable object of values, or keyed object: "+e);return t}function le(e){return $(e)?new te(e):V(e)?new oe(e):U(e)?new re(e):void 0}function fe(e,t,n,r){var o=e._cache;if(o){for(var a=o.length-1,i=0;i<=a;i++){var u=o[n?a-i:i];if(!1===t(u[1],r?u[0]:i,e))return i+1}return i}return e.__iterateUncached(t,n)}function pe(e,t,n,r){var o=e._cache;if(o){var a=o.length-1,i=0;return new F((function(){var e=o[n?a-i:i];return i++>a?q():z(t,r?e[0]:i-1,e[1])}))}return e.__iteratorUncached(t,n)}function he(e,t){return t?de(t,e,"",{"":e}):me(e)}function de(e,t,n,r){return Array.isArray(t)?e.call(r,n,Y(t).map((function(n,r){return de(e,n,r,t)}))):ve(t)?e.call(r,n,K(t).map((function(n,r){return de(e,n,r,t)}))):t}function me(e){return Array.isArray(e)?Y(e).map(me).toList():ve(e)?K(e).map(me).toMap():e}function ve(e){return e&&(e.constructor===Object||void 0===e.constructor)}function ge(e,t){if(e===t||e!=e&&t!=t)return!0;if(!e||!t)return!1;if("function"==typeof e.valueOf&&"function"==typeof t.valueOf){if((e=e.valueOf())===(t=t.valueOf())||e!=e&&t!=t)return!0;if(!e||!t)return!1}return!("function"!=typeof e.equals||"function"!=typeof t.equals||!e.equals(t))}function ye(e,t){if(e===t)return!0;if(!i(t)||void 0!==e.size&&void 0!==t.size&&e.size!==t.size||void 0!==e.__hash&&void 0!==t.__hash&&e.__hash!==t.__hash||u(e)!==u(t)||s(e)!==s(t)||l(e)!==l(t))return!1;if(0===e.size&&0===t.size)return!0;var n=!c(e);if(l(e)){var r=e.entries();return t.every((function(e,t){var o=r.next().value;return o&&ge(o[1],e)&&(n||ge(o[0],t))}))&&r.next().done}var o=!1;if(void 0===e.size)if(void 0===t.size)"function"==typeof e.cacheResult&&e.cacheResult();else{o=!0;var a=e;e=t,t=a}var f=!0,p=t.__iterate((function(t,r){if(n?!e.has(t):o?!ge(t,e.get(r,b)):!ge(e.get(r,b),t))return f=!1,!1}));return f&&e.size===p}function be(e,t){if(!(this instanceof be))return new be(e,t);if(this._value=e,this.size=void 0===t?1/0:Math.max(0,t),0===this.size){if(Z)return Z;Z=this}}function we(e,t){if(!e)throw new Error(t)}function xe(e,t,n){if(!(this instanceof xe))return new xe(e,t,n);if(we(0!==n,"Cannot step a Range by 0"),e=e||0,void 0===t&&(t=1/0),n=void 0===n?1:Math.abs(n),tr?q():z(e,o,n[t?r-o++:o++])}))},t(ne,K),ne.prototype.get=function(e,t){return void 0===t||this.has(e)?this._object[e]:t},ne.prototype.has=function(e){return this._object.hasOwnProperty(e)},ne.prototype.__iterate=function(e,t){for(var n=this._object,r=this._keys,o=r.length-1,a=0;a<=o;a++){var i=r[t?o-a:a];if(!1===e(n[i],i,this))return a+1}return a},ne.prototype.__iterator=function(e,t){var n=this._object,r=this._keys,o=r.length-1,a=0;return new F((function(){var i=r[t?o-a:a];return a++>o?q():z(e,i,n[i])}))},ne.prototype[d]=!0,t(re,Y),re.prototype.__iterateUncached=function(e,t){if(t)return this.cacheResult().__iterate(e,t);var n=W(this._iterable),r=0;if(V(n))for(var o;!(o=n.next()).done&&!1!==e(o.value,r++,this););return r},re.prototype.__iteratorUncached=function(e,t){if(t)return this.cacheResult().__iterator(e,t);var n=W(this._iterable);if(!V(n))return new F(q);var r=0;return new F((function(){var t=n.next();return t.done?t:z(e,r++,t.value)}))},t(oe,Y),oe.prototype.__iterateUncached=function(e,t){if(t)return this.cacheResult().__iterate(e,t);for(var n,r=this._iterator,o=this._iteratorCache,a=0;a=r.length){var t=n.next();if(t.done)return t;r[o]=t.value}return z(e,o,r[o++])}))},t(be,Y),be.prototype.toString=function(){return 0===this.size?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},be.prototype.get=function(e,t){return this.has(e)?this._value:t},be.prototype.includes=function(e){return ge(this._value,e)},be.prototype.slice=function(e,t){var n=this.size;return j(e,t,n)?this:new be(this._value,I(t,n)-T(e,n))},be.prototype.reverse=function(){return this},be.prototype.indexOf=function(e){return ge(this._value,e)?0:-1},be.prototype.lastIndexOf=function(e){return ge(this._value,e)?this.size:-1},be.prototype.__iterate=function(e,t){for(var n=0;n=0&&t=0&&nn?q():z(e,a++,i)}))},xe.prototype.equals=function(e){return e instanceof xe?this._start===e._start&&this._end===e._end&&this._step===e._step:ye(this,e)},t(_e,n),t(Ee,_e),t(Se,_e),t(ke,_e),_e.Keyed=Ee,_e.Indexed=Se,_e.Set=ke;var Ae="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(e,t){var n=65535&(e|=0),r=65535&(t|=0);return n*r+((e>>>16)*r+n*(t>>>16)<<16>>>0)|0};function Oe(e){return e>>>1&1073741824|3221225471&e}function Ce(e){if(!1===e||null==e)return 0;if("function"==typeof e.valueOf&&(!1===(e=e.valueOf())||null==e))return 0;if(!0===e)return 1;var t=typeof e;if("number"===t){if(e!=e||e===1/0)return 0;var n=0|e;for(n!==e&&(n^=4294967295*e);e>4294967295;)n^=e/=4294967295;return Oe(n)}if("string"===t)return e.length>Fe?je(e):Te(e);if("function"==typeof e.hashCode)return e.hashCode();if("object"===t)return Ie(e);if("function"==typeof e.toString)return Te(e.toString());throw new Error("Value type "+t+" cannot be hashed.")}function je(e){var t=Ue[e];return void 0===t&&(t=Te(e),qe===ze&&(qe=0,Ue={}),qe++,Ue[e]=t),t}function Te(e){for(var t=0,n=0;n0)switch(e.nodeType){case 1:return e.uniqueID;case 9:return e.documentElement&&e.documentElement.uniqueID}}var Re,De="function"==typeof WeakMap;De&&(Re=new WeakMap);var Le=0,Be="__immutablehash__";"function"==typeof Symbol&&(Be=Symbol(Be));var Fe=16,ze=255,qe=0,Ue={};function Ve(e){we(e!==1/0,"Cannot perform this action with an infinite size.")}function We(e){return null==e?ot():He(e)&&!l(e)?e:ot().withMutations((function(t){var n=r(e);Ve(n.size),n.forEach((function(e,n){return t.set(n,e)}))}))}function He(e){return!(!e||!e[Je])}t(We,Ee),We.of=function(){var t=e.call(arguments,0);return ot().withMutations((function(e){for(var n=0;n=t.length)throw new Error("Missing value for key: "+t[n]);e.set(t[n],t[n+1])}}))},We.prototype.toString=function(){return this.__toString("Map {","}")},We.prototype.get=function(e,t){return this._root?this._root.get(0,void 0,e,t):t},We.prototype.set=function(e,t){return at(this,e,t)},We.prototype.setIn=function(e,t){return this.updateIn(e,b,(function(){return t}))},We.prototype.remove=function(e){return at(this,e,b)},We.prototype.deleteIn=function(e){return this.updateIn(e,(function(){return b}))},We.prototype.update=function(e,t,n){return 1===arguments.length?e(this):this.updateIn([e],t,n)},We.prototype.updateIn=function(e,t,n){n||(n=t,t=void 0);var r=vt(this,_n(e),t,n);return r===b?void 0:r},We.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):ot()},We.prototype.merge=function(){return pt(this,void 0,arguments)},We.prototype.mergeWith=function(t){return pt(this,t,e.call(arguments,1))},We.prototype.mergeIn=function(t){var n=e.call(arguments,1);return this.updateIn(t,ot(),(function(e){return"function"==typeof e.merge?e.merge.apply(e,n):n[n.length-1]}))},We.prototype.mergeDeep=function(){return pt(this,ht,arguments)},We.prototype.mergeDeepWith=function(t){var n=e.call(arguments,1);return pt(this,dt(t),n)},We.prototype.mergeDeepIn=function(t){var n=e.call(arguments,1);return this.updateIn(t,ot(),(function(e){return"function"==typeof e.mergeDeep?e.mergeDeep.apply(e,n):n[n.length-1]}))},We.prototype.sort=function(e){return Ut(fn(this,e))},We.prototype.sortBy=function(e,t){return Ut(fn(this,t,e))},We.prototype.withMutations=function(e){var t=this.asMutable();return e(t),t.wasAltered()?t.__ensureOwner(this.__ownerID):this},We.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new S)},We.prototype.asImmutable=function(){return this.__ensureOwner()},We.prototype.wasAltered=function(){return this.__altered},We.prototype.__iterator=function(e,t){return new et(this,e,t)},We.prototype.__iterate=function(e,t){var n=this,r=0;return this._root&&this._root.iterate((function(t){return r++,e(t[1],t[0],n)}),t),r},We.prototype.__ensureOwner=function(e){return e===this.__ownerID?this:e?rt(this.size,this._root,e,this.__hash):(this.__ownerID=e,this.__altered=!1,this)},We.isMap=He;var $e,Je="@@__IMMUTABLE_MAP__@@",Ke=We.prototype;function Ye(e,t){this.ownerID=e,this.entries=t}function Ge(e,t,n){this.ownerID=e,this.bitmap=t,this.nodes=n}function Qe(e,t,n){this.ownerID=e,this.count=t,this.nodes=n}function Ze(e,t,n){this.ownerID=e,this.keyHash=t,this.entries=n}function Xe(e,t,n){this.ownerID=e,this.keyHash=t,this.entry=n}function et(e,t,n){this._type=t,this._reverse=n,this._stack=e._root&&nt(e._root)}function tt(e,t){return z(e,t[0],t[1])}function nt(e,t){return{node:e,index:0,__prev:t}}function rt(e,t,n,r){var o=Object.create(Ke);return o.size=e,o._root=t,o.__ownerID=n,o.__hash=r,o.__altered=!1,o}function ot(){return $e||($e=rt(0))}function at(e,t,n){var r,o;if(e._root){var a=_(w),i=_(x);if(r=it(e._root,e.__ownerID,0,void 0,t,n,a,i),!i.value)return e;o=e.size+(a.value?n===b?-1:1:0)}else{if(n===b)return e;o=1,r=new Ye(e.__ownerID,[[t,n]])}return e.__ownerID?(e.size=o,e._root=r,e.__hash=void 0,e.__altered=!0,e):r?rt(o,r):ot()}function it(e,t,n,r,o,a,i,u){return e?e.update(t,n,r,o,a,i,u):a===b?e:(E(u),E(i),new Xe(t,r,[o,a]))}function ut(e){return e.constructor===Xe||e.constructor===Ze}function st(e,t,n,r,o){if(e.keyHash===r)return new Ze(t,r,[e.entry,o]);var a,i=(0===n?e.keyHash:e.keyHash>>>n)&y,u=(0===n?r:r>>>n)&y;return new Ge(t,1<>>=1)i[u]=1&n?t[a++]:void 0;return i[r]=o,new Qe(e,a+1,i)}function pt(e,t,n){for(var o=[],a=0;a>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,e+=e>>8,127&(e+=e>>16)}function yt(e,t,n,r){var o=r?e:k(e);return o[t]=n,o}function bt(e,t,n,r){var o=e.length+1;if(r&&t+1===o)return e[t]=n,e;for(var a=new Array(o),i=0,u=0;u=xt)return ct(e,s,r,o);var p=e&&e===this.ownerID,h=p?s:k(s);return f?u?c===l-1?h.pop():h[c]=h.pop():h[c]=[r,o]:h.push([r,o]),p?(this.entries=h,this):new Ye(e,h)}},Ge.prototype.get=function(e,t,n,r){void 0===t&&(t=Ce(n));var o=1<<((0===e?t:t>>>e)&y),a=this.bitmap;return 0==(a&o)?r:this.nodes[gt(a&o-1)].get(e+v,t,n,r)},Ge.prototype.update=function(e,t,n,r,o,a,i){void 0===n&&(n=Ce(r));var u=(0===t?n:n>>>t)&y,s=1<=_t)return ft(e,p,c,u,d);if(l&&!d&&2===p.length&&ut(p[1^f]))return p[1^f];if(l&&d&&1===p.length&&ut(d))return d;var m=e&&e===this.ownerID,g=l?d?c:c^s:c|s,w=l?d?yt(p,f,d,m):wt(p,f,m):bt(p,f,d,m);return m?(this.bitmap=g,this.nodes=w,this):new Ge(e,g,w)},Qe.prototype.get=function(e,t,n,r){void 0===t&&(t=Ce(n));var o=(0===e?t:t>>>e)&y,a=this.nodes[o];return a?a.get(e+v,t,n,r):r},Qe.prototype.update=function(e,t,n,r,o,a,i){void 0===n&&(n=Ce(r));var u=(0===t?n:n>>>t)&y,s=o===b,c=this.nodes,l=c[u];if(s&&!l)return this;var f=it(l,e,t+v,n,r,o,a,i);if(f===l)return this;var p=this.count;if(l){if(!f&&--p0&&r=0&&e>>t&y;if(r>=this.array.length)return new Ct([],e);var o,a=0===r;if(t>0){var i=this.array[r];if((o=i&&i.removeBefore(e,t-v,n))===i&&a)return this}if(a&&!o)return this;var u=Lt(this,e);if(!a)for(var s=0;s>>t&y;if(o>=this.array.length)return this;if(t>0){var a=this.array[o];if((r=a&&a.removeAfter(e,t-v,n))===a&&o===this.array.length-1)return this}var i=Lt(this,e);return i.array.splice(o+1),r&&(i.array[o]=r),i};var jt,Tt,It={};function Nt(e,t){var n=e._origin,r=e._capacity,o=qt(r),a=e._tail;return i(e._root,e._level,0);function i(e,t,n){return 0===t?u(e,n):s(e,t,n)}function u(e,i){var u=i===o?a&&a.array:e&&e.array,s=i>n?0:n-i,c=r-i;return c>g&&(c=g),function(){if(s===c)return It;var e=t?--c:s++;return u&&u[e]}}function s(e,o,a){var u,s=e&&e.array,c=a>n?0:n-a>>o,l=1+(r-a>>o);return l>g&&(l=g),function(){for(;;){if(u){var e=u();if(e!==It)return e;u=null}if(c===l)return It;var n=t?--l:c++;u=i(s&&s[n],o-v,a+(n<=e.size||t<0)return e.withMutations((function(e){t<0?Ft(e,t).set(0,n):Ft(e,0,t+1).set(t,n)}));t+=e._origin;var r=e._tail,o=e._root,a=_(x);return t>=qt(e._capacity)?r=Dt(r,e.__ownerID,0,t,n,a):o=Dt(o,e.__ownerID,e._level,t,n,a),a.value?e.__ownerID?(e._root=o,e._tail=r,e.__hash=void 0,e.__altered=!0,e):Pt(e._origin,e._capacity,e._level,o,r):e}function Dt(e,t,n,r,o,a){var i,u=r>>>n&y,s=e&&u0){var c=e&&e.array[u],l=Dt(c,t,n-v,r,o,a);return l===c?e:((i=Lt(e,t)).array[u]=l,i)}return s&&e.array[u]===o?e:(E(a),i=Lt(e,t),void 0===o&&u===i.array.length-1?i.array.pop():i.array[u]=o,i)}function Lt(e,t){return t&&e&&t===e.ownerID?e:new Ct(e?e.array.slice():[],t)}function Bt(e,t){if(t>=qt(e._capacity))return e._tail;if(t<1<0;)n=n.array[t>>>r&y],r-=v;return n}}function Ft(e,t,n){void 0!==t&&(t|=0),void 0!==n&&(n|=0);var r=e.__ownerID||new S,o=e._origin,a=e._capacity,i=o+t,u=void 0===n?a:n<0?a+n:o+n;if(i===o&&u===a)return e;if(i>=u)return e.clear();for(var s=e._level,c=e._root,l=0;i+l<0;)c=new Ct(c&&c.array.length?[void 0,c]:[],r),l+=1<<(s+=v);l&&(i+=l,o+=l,u+=l,a+=l);for(var f=qt(a),p=qt(u);p>=1<f?new Ct([],r):h;if(h&&p>f&&iv;g-=v){var b=f>>>g&y;m=m.array[b]=Lt(m.array[b],r)}m.array[f>>>v&y]=h}if(u=p)i-=p,u-=p,s=v,c=null,d=d&&d.removeBefore(r,0,i);else if(i>o||p>>s&y;if(w!==p>>>s&y)break;w&&(l+=(1<o&&(c=c.removeBefore(r,s,i-l)),c&&pa&&(a=c.size),i(s)||(c=c.map((function(e){return he(e)}))),r.push(c)}return a>e.size&&(e=e.setSize(a)),mt(e,t,r)}function qt(e){return e>>v<=g&&i.size>=2*a.size?(r=(o=i.filter((function(e,t){return void 0!==e&&u!==t}))).toKeyedSeq().map((function(e){return e[0]})).flip().toMap(),e.__ownerID&&(r.__ownerID=o.__ownerID=e.__ownerID)):(r=a.remove(t),o=u===i.size-1?i.pop():i.set(u,void 0))}else if(s){if(n===i.get(u)[1])return e;r=a,o=i.set(u,[t,n])}else r=a.set(t,i.size),o=i.set(i.size,[t,n]);return e.__ownerID?(e.size=r.size,e._map=r,e._list=o,e.__hash=void 0,e):Wt(r,o)}function Jt(e,t){this._iter=e,this._useKeys=t,this.size=e.size}function Kt(e){this._iter=e,this.size=e.size}function Yt(e){this._iter=e,this.size=e.size}function Gt(e){this._iter=e,this.size=e.size}function Qt(e){var t=bn(e);return t._iter=e,t.size=e.size,t.flip=function(){return e},t.reverse=function(){var t=e.reverse.apply(this);return t.flip=function(){return e.reverse()},t},t.has=function(t){return e.includes(t)},t.includes=function(t){return e.has(t)},t.cacheResult=wn,t.__iterateUncached=function(t,n){var r=this;return e.__iterate((function(e,n){return!1!==t(n,e,r)}),n)},t.__iteratorUncached=function(t,n){if(t===R){var r=e.__iterator(t,n);return new F((function(){var e=r.next();if(!e.done){var t=e.value[0];e.value[0]=e.value[1],e.value[1]=t}return e}))}return e.__iterator(t===M?P:M,n)},t}function Zt(e,t,n){var r=bn(e);return r.size=e.size,r.has=function(t){return e.has(t)},r.get=function(r,o){var a=e.get(r,b);return a===b?o:t.call(n,a,r,e)},r.__iterateUncached=function(r,o){var a=this;return e.__iterate((function(e,o,i){return!1!==r(t.call(n,e,o,i),o,a)}),o)},r.__iteratorUncached=function(r,o){var a=e.__iterator(R,o);return new F((function(){var o=a.next();if(o.done)return o;var i=o.value,u=i[0];return z(r,u,t.call(n,i[1],u,e),o)}))},r}function Xt(e,t){var n=bn(e);return n._iter=e,n.size=e.size,n.reverse=function(){return e},e.flip&&(n.flip=function(){var t=Qt(e);return t.reverse=function(){return e.flip()},t}),n.get=function(n,r){return e.get(t?n:-1-n,r)},n.has=function(n){return e.has(t?n:-1-n)},n.includes=function(t){return e.includes(t)},n.cacheResult=wn,n.__iterate=function(t,n){var r=this;return e.__iterate((function(e,n){return t(e,n,r)}),!n)},n.__iterator=function(t,n){return e.__iterator(t,!n)},n}function en(e,t,n,r){var o=bn(e);return r&&(o.has=function(r){var o=e.get(r,b);return o!==b&&!!t.call(n,o,r,e)},o.get=function(r,o){var a=e.get(r,b);return a!==b&&t.call(n,a,r,e)?a:o}),o.__iterateUncached=function(o,a){var i=this,u=0;return e.__iterate((function(e,a,s){if(t.call(n,e,a,s))return u++,o(e,r?a:u-1,i)}),a),u},o.__iteratorUncached=function(o,a){var i=e.__iterator(R,a),u=0;return new F((function(){for(;;){var a=i.next();if(a.done)return a;var s=a.value,c=s[0],l=s[1];if(t.call(n,l,c,e))return z(o,r?c:u++,l,a)}}))},o}function tn(e,t,n){var r=We().asMutable();return e.__iterate((function(o,a){r.update(t.call(n,o,a,e),0,(function(e){return e+1}))})),r.asImmutable()}function nn(e,t,n){var r=u(e),o=(l(e)?Ut():We()).asMutable();e.__iterate((function(a,i){o.update(t.call(n,a,i,e),(function(e){return(e=e||[]).push(r?[i,a]:a),e}))}));var a=yn(e);return o.map((function(t){return mn(e,a(t))}))}function rn(e,t,n,r){var o=e.size;if(void 0!==t&&(t|=0),void 0!==n&&(n===1/0?n=o:n|=0),j(t,n,o))return e;var a=T(t,o),i=I(n,o);if(a!=a||i!=i)return rn(e.toSeq().cacheResult(),t,n,r);var u,s=i-a;s==s&&(u=s<0?0:s);var c=bn(e);return c.size=0===u?u:e.size&&u||void 0,!r&&ae(e)&&u>=0&&(c.get=function(t,n){return(t=O(this,t))>=0&&tu)return q();var e=o.next();return r||t===M?e:z(t,s-1,t===P?void 0:e.value[1],e)}))},c}function on(e,t,n){var r=bn(e);return r.__iterateUncached=function(r,o){var a=this;if(o)return this.cacheResult().__iterate(r,o);var i=0;return e.__iterate((function(e,o,u){return t.call(n,e,o,u)&&++i&&r(e,o,a)})),i},r.__iteratorUncached=function(r,o){var a=this;if(o)return this.cacheResult().__iterator(r,o);var i=e.__iterator(R,o),u=!0;return new F((function(){if(!u)return q();var e=i.next();if(e.done)return e;var o=e.value,s=o[0],c=o[1];return t.call(n,c,s,a)?r===R?e:z(r,s,c,e):(u=!1,q())}))},r}function an(e,t,n,r){var o=bn(e);return o.__iterateUncached=function(o,a){var i=this;if(a)return this.cacheResult().__iterate(o,a);var u=!0,s=0;return e.__iterate((function(e,a,c){if(!u||!(u=t.call(n,e,a,c)))return s++,o(e,r?a:s-1,i)})),s},o.__iteratorUncached=function(o,a){var i=this;if(a)return this.cacheResult().__iterator(o,a);var u=e.__iterator(R,a),s=!0,c=0;return new F((function(){var e,a,l;do{if((e=u.next()).done)return r||o===M?e:z(o,c++,o===P?void 0:e.value[1],e);var f=e.value;a=f[0],l=f[1],s&&(s=t.call(n,l,a,i))}while(s);return o===R?e:z(o,a,l,e)}))},o}function un(e,t){var n=u(e),o=[e].concat(t).map((function(e){return i(e)?n&&(e=r(e)):e=n?ue(e):se(Array.isArray(e)?e:[e]),e})).filter((function(e){return 0!==e.size}));if(0===o.length)return e;if(1===o.length){var a=o[0];if(a===e||n&&u(a)||s(e)&&s(a))return a}var c=new te(o);return n?c=c.toKeyedSeq():s(e)||(c=c.toSetSeq()),(c=c.flatten(!0)).size=o.reduce((function(e,t){if(void 0!==e){var n=t.size;if(void 0!==n)return e+n}}),0),c}function sn(e,t,n){var r=bn(e);return r.__iterateUncached=function(r,o){var a=0,u=!1;function s(e,c){var l=this;e.__iterate((function(e,o){return(!t||c0}function dn(e,t,r){var o=bn(e);return o.size=new te(r).map((function(e){return e.size})).min(),o.__iterate=function(e,t){for(var n,r=this.__iterator(M,t),o=0;!(n=r.next()).done&&!1!==e(n.value,o++,this););return o},o.__iteratorUncached=function(e,o){var a=r.map((function(e){return e=n(e),W(o?e.reverse():e)})),i=0,u=!1;return new F((function(){var n;return u||(n=a.map((function(e){return e.next()})),u=n.some((function(e){return e.done}))),u?q():z(e,i++,t.apply(null,n.map((function(e){return e.value}))))}))},o}function mn(e,t){return ae(e)?t:e.constructor(t)}function vn(e){if(e!==Object(e))throw new TypeError("Expected [K, V] tuple: "+e)}function gn(e){return Ve(e.size),A(e)}function yn(e){return u(e)?r:s(e)?o:a}function bn(e){return Object.create((u(e)?K:s(e)?Y:G).prototype)}function wn(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):J.prototype.cacheResult.call(this)}function xn(e,t){return e>t?1:e=0;n--)t={value:arguments[n],next:t};return this.__ownerID?(this.size=e,this._head=t,this.__hash=void 0,this.__altered=!0,this):Kn(e,t)},Vn.prototype.pushAll=function(e){if(0===(e=o(e)).size)return this;Ve(e.size);var t=this.size,n=this._head;return e.reverse().forEach((function(e){t++,n={value:e,next:n}})),this.__ownerID?(this.size=t,this._head=n,this.__hash=void 0,this.__altered=!0,this):Kn(t,n)},Vn.prototype.pop=function(){return this.slice(1)},Vn.prototype.unshift=function(){return this.push.apply(this,arguments)},Vn.prototype.unshiftAll=function(e){return this.pushAll(e)},Vn.prototype.shift=function(){return this.pop.apply(this,arguments)},Vn.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Yn()},Vn.prototype.slice=function(e,t){if(j(e,t,this.size))return this;var n=T(e,this.size);if(I(t,this.size)!==this.size)return Se.prototype.slice.call(this,e,t);for(var r=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=r,this._head=o,this.__hash=void 0,this.__altered=!0,this):Kn(r,o)},Vn.prototype.__ensureOwner=function(e){return e===this.__ownerID?this:e?Kn(this.size,this._head,e,this.__hash):(this.__ownerID=e,this.__altered=!1,this)},Vn.prototype.__iterate=function(e,t){if(t)return this.reverse().__iterate(e);for(var n=0,r=this._head;r&&!1!==e(r.value,n++,this);)r=r.next;return n},Vn.prototype.__iterator=function(e,t){if(t)return this.reverse().__iterator(e);var n=0,r=this._head;return new F((function(){if(r){var t=r.value;return r=r.next,z(e,n++,t)}return q()}))},Vn.isStack=Wn;var Hn,$n="@@__IMMUTABLE_STACK__@@",Jn=Vn.prototype;function Kn(e,t,n,r){var o=Object.create(Jn);return o.size=e,o._head=t,o.__ownerID=n,o.__hash=r,o.__altered=!1,o}function Yn(){return Hn||(Hn=Kn(0))}function Gn(e,t){var n=function(n){e.prototype[n]=t[n]};return Object.keys(t).forEach(n),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(t).forEach(n),e}Jn[$n]=!0,Jn.withMutations=Ke.withMutations,Jn.asMutable=Ke.asMutable,Jn.asImmutable=Ke.asImmutable,Jn.wasAltered=Ke.wasAltered,n.Iterator=F,Gn(n,{toArray:function(){Ve(this.size);var e=new Array(this.size||0);return this.valueSeq().__iterate((function(t,n){e[n]=t})),e},toIndexedSeq:function(){return new Kt(this)},toJS:function(){return this.toSeq().map((function(e){return e&&"function"==typeof e.toJS?e.toJS():e})).__toJS()},toJSON:function(){return this.toSeq().map((function(e){return e&&"function"==typeof e.toJSON?e.toJSON():e})).__toJS()},toKeyedSeq:function(){return new Jt(this,!0)},toMap:function(){return We(this.toKeyedSeq())},toObject:function(){Ve(this.size);var e={};return this.__iterate((function(t,n){e[n]=t})),e},toOrderedMap:function(){return Ut(this.toKeyedSeq())},toOrderedSet:function(){return Ln(u(this)?this.valueSeq():this)},toSet:function(){return jn(u(this)?this.valueSeq():this)},toSetSeq:function(){return new Yt(this)},toSeq:function(){return s(this)?this.toIndexedSeq():u(this)?this.toKeyedSeq():this.toSetSeq()},toStack:function(){return Vn(u(this)?this.valueSeq():this)},toList:function(){return St(u(this)?this.valueSeq():this)},toString:function(){return"[Iterable]"},__toString:function(e,t){return 0===this.size?e+t:e+" "+this.toSeq().map(this.__toStringMapper).join(", ")+" "+t},concat:function(){return mn(this,un(this,e.call(arguments,0)))},includes:function(e){return this.some((function(t){return ge(t,e)}))},entries:function(){return this.__iterator(R)},every:function(e,t){Ve(this.size);var n=!0;return this.__iterate((function(r,o,a){if(!e.call(t,r,o,a))return n=!1,!1})),n},filter:function(e,t){return mn(this,en(this,e,t,!0))},find:function(e,t,n){var r=this.findEntry(e,t);return r?r[1]:n},forEach:function(e,t){return Ve(this.size),this.__iterate(t?e.bind(t):e)},join:function(e){Ve(this.size),e=void 0!==e?""+e:",";var t="",n=!0;return this.__iterate((function(r){n?n=!1:t+=e,t+=null!=r?r.toString():""})),t},keys:function(){return this.__iterator(P)},map:function(e,t){return mn(this,Zt(this,e,t))},reduce:function(e,t,n){var r,o;return Ve(this.size),arguments.length<2?o=!0:r=t,this.__iterate((function(t,a,i){o?(o=!1,r=t):r=e.call(n,r,t,a,i)})),r},reduceRight:function(e,t,n){var r=this.toKeyedSeq().reverse();return r.reduce.apply(r,arguments)},reverse:function(){return mn(this,Xt(this,!0))},slice:function(e,t){return mn(this,rn(this,e,t,!0))},some:function(e,t){return!this.every(tr(e),t)},sort:function(e){return mn(this,fn(this,e))},values:function(){return this.__iterator(M)},butLast:function(){return this.slice(0,-1)},isEmpty:function(){return void 0!==this.size?0===this.size:!this.some((function(){return!0}))},count:function(e,t){return A(e?this.toSeq().filter(e,t):this)},countBy:function(e,t){return tn(this,e,t)},equals:function(e){return ye(this,e)},entrySeq:function(){var e=this;if(e._cache)return new te(e._cache);var t=e.toSeq().map(er).toIndexedSeq();return t.fromEntrySeq=function(){return e.toSeq()},t},filterNot:function(e,t){return this.filter(tr(e),t)},findEntry:function(e,t,n){var r=n;return this.__iterate((function(n,o,a){if(e.call(t,n,o,a))return r=[o,n],!1})),r},findKey:function(e,t){var n=this.findEntry(e,t);return n&&n[0]},findLast:function(e,t,n){return this.toKeyedSeq().reverse().find(e,t,n)},findLastEntry:function(e,t,n){return this.toKeyedSeq().reverse().findEntry(e,t,n)},findLastKey:function(e,t){return this.toKeyedSeq().reverse().findKey(e,t)},first:function(){return this.find(C)},flatMap:function(e,t){return mn(this,cn(this,e,t))},flatten:function(e){return mn(this,sn(this,e,!0))},fromEntrySeq:function(){return new Gt(this)},get:function(e,t){return this.find((function(t,n){return ge(n,e)}),void 0,t)},getIn:function(e,t){for(var n,r=this,o=_n(e);!(n=o.next()).done;){var a=n.value;if((r=r&&r.get?r.get(a,b):b)===b)return t}return r},groupBy:function(e,t){return nn(this,e,t)},has:function(e){return this.get(e,b)!==b},hasIn:function(e){return this.getIn(e,b)!==b},isSubset:function(e){return e="function"==typeof e.includes?e:n(e),this.every((function(t){return e.includes(t)}))},isSuperset:function(e){return(e="function"==typeof e.isSubset?e:n(e)).isSubset(this)},keyOf:function(e){return this.findKey((function(t){return ge(t,e)}))},keySeq:function(){return this.toSeq().map(Xn).toIndexedSeq()},last:function(){return this.toSeq().reverse().first()},lastKeyOf:function(e){return this.toKeyedSeq().reverse().keyOf(e)},max:function(e){return pn(this,e)},maxBy:function(e,t){return pn(this,t,e)},min:function(e){return pn(this,e?nr(e):ar)},minBy:function(e,t){return pn(this,t?nr(t):ar,e)},rest:function(){return this.slice(1)},skip:function(e){return this.slice(Math.max(0,e))},skipLast:function(e){return mn(this,this.toSeq().reverse().skip(e).reverse())},skipWhile:function(e,t){return mn(this,an(this,e,t,!0))},skipUntil:function(e,t){return this.skipWhile(tr(e),t)},sortBy:function(e,t){return mn(this,fn(this,t,e))},take:function(e){return this.slice(0,Math.max(0,e))},takeLast:function(e){return mn(this,this.toSeq().reverse().take(e).reverse())},takeWhile:function(e,t){return mn(this,on(this,e,t))},takeUntil:function(e,t){return this.takeWhile(tr(e),t)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=ir(this))}});var Qn=n.prototype;Qn[f]=!0,Qn[B]=Qn.values,Qn.__toJS=Qn.toArray,Qn.__toStringMapper=rr,Qn.inspect=Qn.toSource=function(){return this.toString()},Qn.chain=Qn.flatMap,Qn.contains=Qn.includes,Gn(r,{flip:function(){return mn(this,Qt(this))},mapEntries:function(e,t){var n=this,r=0;return mn(this,this.toSeq().map((function(o,a){return e.call(t,[a,o],r++,n)})).fromEntrySeq())},mapKeys:function(e,t){var n=this;return mn(this,this.toSeq().flip().map((function(r,o){return e.call(t,r,o,n)})).flip())}});var Zn=r.prototype;function Xn(e,t){return t}function er(e,t){return[t,e]}function tr(e){return function(){return!e.apply(this,arguments)}}function nr(e){return function(){return-e.apply(this,arguments)}}function rr(e){return"string"==typeof e?JSON.stringify(e):String(e)}function or(){return k(arguments)}function ar(e,t){return et?-1:0}function ir(e){if(e.size===1/0)return 0;var t=l(e),n=u(e),r=t?1:0;return ur(e.__iterate(n?t?function(e,t){r=31*r+sr(Ce(e),Ce(t))|0}:function(e,t){r=r+sr(Ce(e),Ce(t))|0}:t?function(e){r=31*r+Ce(e)|0}:function(e){r=r+Ce(e)|0}),r)}function ur(e,t){return t=Ae(t,3432918353),t=Ae(t<<15|t>>>-15,461845907),t=Ae(t<<13|t>>>-13,5),t=Ae((t=(t+3864292196|0)^e)^t>>>16,2246822507),t=Oe((t=Ae(t^t>>>13,3266489909))^t>>>16)}function sr(e,t){return e^t+2654435769+(e<<6)+(e>>2)|0}return Zn[p]=!0,Zn[B]=Qn.entries,Zn.__toJS=Qn.toObject,Zn.__toStringMapper=function(e,t){return JSON.stringify(t)+": "+rr(e)},Gn(o,{toKeyedSeq:function(){return new Jt(this,!1)},filter:function(e,t){return mn(this,en(this,e,t,!1))},findIndex:function(e,t){var n=this.findEntry(e,t);return n?n[0]:-1},indexOf:function(e){var t=this.keyOf(e);return void 0===t?-1:t},lastIndexOf:function(e){var t=this.lastKeyOf(e);return void 0===t?-1:t},reverse:function(){return mn(this,Xt(this,!1))},slice:function(e,t){return mn(this,rn(this,e,t,!1))},splice:function(e,t){var n=arguments.length;if(t=Math.max(0|t,0),0===n||2===n&&!t)return this;e=T(e,e<0?this.count():this.size);var r=this.slice(0,e);return mn(this,1===n?r:r.concat(k(arguments,2),this.slice(e+t)))},findLastIndex:function(e,t){var n=this.findLastEntry(e,t);return n?n[0]:-1},first:function(){return this.get(0)},flatten:function(e){return mn(this,sn(this,e,!1))},get:function(e,t){return(e=O(this,e))<0||this.size===1/0||void 0!==this.size&&e>this.size?t:this.find((function(t,n){return n===e}),void 0,t)},has:function(e){return(e=O(this,e))>=0&&(void 0!==this.size?this.size===1/0||e1)try{return decodeURIComponent(t[1])}catch(e){console.error(e)}return null}function Ne(e){return t=e.replace(/\.[^./]*$/,""),Y()(J()(t));var t}function Pe(e,t,n,r,a){if(!t)return[];var u=[],s=t.get("nullable"),c=t.get("required"),f=t.get("maximum"),h=t.get("minimum"),d=t.get("type"),m=t.get("format"),g=t.get("maxLength"),b=t.get("minLength"),x=t.get("uniqueItems"),_=t.get("maxItems"),E=t.get("minItems"),S=t.get("pattern"),k=n||!0===c,A=null!=e;if(s&&null===e||!d||!(k||A&&"array"===d||!(!k&&!A)))return[];var O="string"===d&&e,C="array"===d&&l()(e)&&e.length,j="array"===d&&W.a.List.isList(e)&&e.count(),T=[O,C,j,"array"===d&&"string"==typeof e&&e,"file"===d&&e instanceof ue.a.File,"boolean"===d&&(e||!1===e),"number"===d&&(e||0===e),"integer"===d&&(e||0===e),"object"===d&&"object"===i()(e)&&null!==e,"object"===d&&"string"==typeof e&&e],I=N()(T).call(T,(function(e){return!!e}));if(k&&!I&&!r)return u.push("Required field is not provided"),u;if("object"===d&&(null===a||"application/json"===a)){var P,M=e;if("string"==typeof e)try{M=JSON.parse(e)}catch(e){return u.push("Parameter string value must be valid JSON"),u}if(t&&t.has("required")&&Ee(c.isList)&&c.isList()&&y()(c).call(c,(function(e){void 0===M[e]&&u.push({propKey:e,error:"Required property not found"})})),t&&t.has("properties"))y()(P=t.get("properties")).call(P,(function(e,t){var n=Pe(M[t],e,!1,r,a);u.push.apply(u,o()(p()(n).call(n,(function(e){return{propKey:t,error:e}}))))}))}if(S){var R=function(e,t){if(!new RegExp(t).test(e))return"Value must follow pattern "+t}(e,S);R&&u.push(R)}if(E&&"array"===d){var D=function(e,t){var n;if(!e&&t>=1||e&&e.lengtht)return v()(n="Array must not contain more then ".concat(t," item")).call(n,1===t?"":"s")}(e,_);L&&u.push({needRemove:!0,error:L})}if(x&&"array"===d){var B=function(e,t){if(e&&("true"===t||!0===t)){var n=Object(V.fromJS)(e),r=n.toSet();if(e.length>r.size){var o=Object(V.Set)();if(y()(n).call(n,(function(e,t){w()(n).call(n,(function(t){return Ee(t.equals)?t.equals(e):t===e})).size>1&&(o=o.add(t))})),0!==o.size)return p()(o).call(o,(function(e){return{index:e,error:"No duplicates allowed."}})).toArray()}}}(e,x);B&&u.push.apply(u,o()(B))}if(g||0===g){var F=function(e,t){var n;if(e.length>t)return v()(n="Value must be no longer than ".concat(t," character")).call(n,1!==t?"s":"")}(e,g);F&&u.push(F)}if(b){var z=function(e,t){var n;if(e.lengtht)return"Value must be less than ".concat(t)}(e,f);q&&u.push(q)}if(h||0===h){var U=function(e,t){if(e2&&void 0!==arguments[2]?arguments[2]:{},r=n.isOAS3,o=void 0!==r&&r,a=n.bypassRequiredCheck,i=void 0!==a&&a,u=e.get("required"),s=Object(le.a)(e,{isOAS3:o}),c=s.schema,l=s.parameterContentMediaType;return Pe(t,c,u,i,l)},Re=function(e,t,n){if(e&&(!e.xml||!e.xml.name)){if(e.xml=e.xml||{},!e.$$ref)return e.type||e.items||e.properties||e.additionalProperties?'\n\x3c!-- XML example cannot be generated; root element name is undefined --\x3e':null;var r=e.$$ref.match(/\S*\/(\S+)$/);e.xml.name=r[1]}return Object(ie.memoizedCreateXMLExample)(e,t,n)},De=[{when:/json/,shouldStringifyTypes:["string"]}],Le=["object"],Be=function(e,t,n,r){var a=Object(ie.memoizedSampleFromSchema)(e,t,r),u=i()(a),s=S()(De).call(De,(function(e,t){var r;return t.when.test(n)?v()(r=[]).call(r,o()(e),o()(t.shouldStringifyTypes)):e}),Le);return te()(s,(function(e){return e===u}))?M()(a,null,2):a},Fe=function(e,t,n,r){var o,a=Be(e,t,n,r);try{"\n"===(o=me.a.dump(me.a.load(a),{lineWidth:-1}))[o.length-1]&&(o=T()(o).call(o,0,o.length-1))}catch(e){return console.error(e),"error: could not generate yaml example"}return o.replace(/\t/g," ")},ze=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0;return e&&Ee(e.toJS)&&(e=e.toJS()),r&&Ee(r.toJS)&&(r=r.toJS()),/xml/.test(t)?Re(e,n,r):/(yaml|yml)/.test(t)?Fe(e,n,t,r):Be(e,n,t,r)},qe=function(){var e={},t=ue.a.location.search;if(!t)return{};if(""!=t){var n=t.substr(1).split("&");for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(r=n[r].split("="),e[decodeURIComponent(r[0])]=r[1]&&decodeURIComponent(r[1])||"")}return e},Ue=function(t){return(t instanceof e?t:e.from(t.toString(),"utf-8")).toString("base64")},Ve={operationsSorter:{alpha:function(e,t){return e.get("path").localeCompare(t.get("path"))},method:function(e,t){return e.get("method").localeCompare(t.get("method"))}},tagsSorter:{alpha:function(e,t){return e.localeCompare(t)}}},We=function(e){var t=[];for(var n in e){var r=e[n];void 0!==r&&""!==r&&t.push([n,"=",encodeURIComponent(r).replace(/%20/g,"+")].join(""))}return t.join("&")},He=function(e,t,n){return!!X()(n,(function(n){return re()(e[n],t[n])}))};function $e(e){return"string"!=typeof e||""===e?"":Object(H.sanitizeUrl)(e)}function Je(e){return!(!e||D()(e).call(e,"localhost")>=0||D()(e).call(e,"127.0.0.1")>=0||"none"===e)}function Ke(e){if(!W.a.OrderedMap.isOrderedMap(e))return null;if(!e.size)return null;var t=B()(e).call(e,(function(e,t){return z()(t).call(t,"2")&&_()(e.get("content")||{}).length>0})),n=e.get("default")||W.a.OrderedMap(),r=(n.get("content")||W.a.OrderedMap()).keySeq().toJS().length?n:null;return t||r}var Ye=function(e){return"string"==typeof e||e instanceof String?U()(e).call(e).replace(/\s/g,"%20"):""},Ge=function(e){return ce()(Ye(e).replace(/%20/g,"_"))},Qe=function(e){return w()(e).call(e,(function(e,t){return/^x-/.test(t)}))},Ze=function(e){return w()(e).call(e,(function(e,t){return/^pattern|maxLength|minLength|maximum|minimum/.test(t)}))};function Xe(e,t){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){return!0};if("object"!==i()(e)||l()(e)||null===e||!t)return e;var o=A()({},e);return y()(n=_()(o)).call(n,(function(e){e===t&&r(o[e],e)?delete o[e]:o[e]=Xe(o[e],t,r)})),o}function et(e){if("string"==typeof e)return e;if(e&&e.toJS&&(e=e.toJS()),"object"===i()(e)&&null!==e)try{return M()(e,null,2)}catch(t){return String(e)}return null==e?"":e.toString()}function tt(e){return"number"==typeof e?e.toString():e}function nt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.returnAll,r=void 0!==n&&n,o=t.allowHashes,a=void 0===o||o;if(!W.a.Map.isMap(e))throw new Error("paramToIdentifier: received a non-Im.Map parameter as input");var i,u,s,c=e.get("name"),l=e.get("in"),f=[];e&&e.hashCode&&l&&c&&a&&f.push(v()(i=v()(u="".concat(l,".")).call(u,c,".hash-")).call(i,e.hashCode()));l&&c&&f.push(v()(s="".concat(l,".")).call(s,c));return f.push(c),r?f:f[0]||""}function rt(e,t){var n,r=nt(e,{returnAll:!0});return w()(n=p()(r).call(r,(function(e){return t[e]}))).call(n,(function(e){return void 0!==e}))[0]}function ot(){return it(pe()(32).toString("base64"))}function at(e){return it(de()("sha256").update(e).digest("base64"))}function it(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}var ut=function(e){return!e||!(!ge(e)||!e.isEmpty())}}).call(this,n(132).Buffer)},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){var r=n(226);function o(e,t){for(var n=0;n1?t-1:0),r=1;r1&&void 0!==arguments[1]?arguments[1]:r,n=null,a=null;return function(){return o(t,n,arguments)||(a=e.apply(null,arguments)),n=arguments,a}}))},function(e,t,n){(function(t){var n=function(e){return e&&e.Math==Math&&e};e.exports=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof t&&t)||function(){return this}()||Function("return this")()}).call(this,n(57))},function(e,t,n){e.exports=n(385)},function(e,t,n){var r=n(166),o=n(515);function a(t){return"function"==typeof r&&"symbol"==typeof o?(e.exports=a=function(e){return typeof e},e.exports.default=e.exports,e.exports.__esModule=!0):(e.exports=a=function(e){return e&&"function"==typeof r&&e.constructor===r&&e!==r.prototype?"symbol":typeof e},e.exports.default=e.exports,e.exports.__esModule=!0),a(t)}e.exports=a,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){e.exports=n(351)},function(e,t,n){e.exports=n(349)},function(e,t,n){"use strict";var r=n(17),o=n(93),a=n(27),i=n(41),u=n(111).f,s=n(331),c=n(34),l=n(84),f=n(85),p=n(44),h=function(e){var t=function(n,r,a){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(n);case 2:return new e(n,r)}return new e(n,r,a)}return o(e,this,arguments)};return t.prototype=e.prototype,t};e.exports=function(e,t){var n,o,d,m,v,g,y,b,w=e.target,x=e.global,_=e.stat,E=e.proto,S=x?r:_?r[w]:(r[w]||{}).prototype,k=x?c:c[w]||f(c,w,{})[w],A=k.prototype;for(d in t)n=!s(x?d:w+(_?".":"#")+d,e.forced)&&S&&p(S,d),v=k[d],n&&(g=e.noTargetGet?(b=u(S,d))&&b.value:S[d]),m=n&&g?g:t[d],n&&typeof v==typeof m||(y=e.bind&&n?l(m,r):e.wrap&&n?h(m):E&&i(m)?a(m):m,(e.sham||m&&m.sham||v&&v.sham)&&f(y,"sham",!0),f(k,d,y),E&&(p(c,o=w+"Prototype")||f(c,o,{}),f(c[o],d,m),e.real&&A&&!A[d]&&f(A,d,m)))}},function(e,t,n){e.exports=n(381)},function(e,t,n){e.exports=n(352)},function(e,t,n){var r=n(420),o=n(421),a=n(800),i=n(802),u=n(807),s=n(809),c=n(814),l=n(226),f=n(3);function p(e,t){var n=r(e);if(o){var u=o(e);t&&(u=a(u).call(u,(function(t){return i(e,t).enumerable}))),n.push.apply(n,u)}return n}e.exports=function(e){for(var t=1;t>",i=function(){invariant(!1,"ImmutablePropTypes type checking code is stripped in production.")};i.isRequired=i;var u=function(){return i};function s(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":e instanceof o.Iterable?"Immutable."+e.toSource().split(" ")[0]:t}function c(e){function t(t,n,r,o,i,u){for(var s=arguments.length,c=Array(s>6?s-6:0),l=6;l4)}function l(e){var t=e.get("swagger");return"string"==typeof t&&i()(t).call(t,"2.0")}function f(e){return function(t,n){return function(r){return n&&n.specSelectors&&n.specSelectors.specJson?c(n.specSelectors.specJson())?s.a.createElement(e,o()({},r,n,{Ori:t})):s.a.createElement(t,r):(console.warn("OAS3 wrapper: couldn't get spec"),null)}}}},function(e,t,n){e.exports=n(535)},function(e,t,n){var r=n(17),o=n(212),a=n(44),i=n(171),u=n(210),s=n(329),c=o("wks"),l=r.Symbol,f=l&&l.for,p=s?l:l&&l.withoutSetter||i;e.exports=function(e){if(!a(c,e)||!u&&"string"!=typeof c[e]){var t="Symbol."+e;u&&a(l,e)?c[e]=l[e]:c[e]=s&&f?f(t):p(t)}return c[e]}},function(e,t,n){var r=n(242);e.exports=function(e,t,n){var o=null==e?void 0:r(e,t);return void 0===o?n:o}},function(e,t,n){e.exports=n(840)},function(e,t){e.exports=function(e){return"function"==typeof e}},function(e,t,n){var r=n(34);e.exports=function(e){return r[e+"Prototype"]}},function(e,t,n){var r=n(41);e.exports=function(e){return"object"==typeof e?null!==e:r(e)}},function(e,t,n){var r=n(27),o=n(62),a=r({}.hasOwnProperty);e.exports=Object.hasOwn||function(e,t){return a(o(e),t)}},function(e,t,n){var r=n(34),o=n(44),a=n(223),i=n(63).f;e.exports=function(e){var t=r.Symbol||(r.Symbol={});o(t,e)||i(t,e,{value:a.f(e)})}},function(e,t,n){"use strict";n.r(t),n.d(t,"UPDATE_SPEC",(function(){return ee})),n.d(t,"UPDATE_URL",(function(){return te})),n.d(t,"UPDATE_JSON",(function(){return ne})),n.d(t,"UPDATE_PARAM",(function(){return re})),n.d(t,"UPDATE_EMPTY_PARAM_INCLUSION",(function(){return oe})),n.d(t,"VALIDATE_PARAMS",(function(){return ae})),n.d(t,"SET_RESPONSE",(function(){return ie})),n.d(t,"SET_REQUEST",(function(){return ue})),n.d(t,"SET_MUTATED_REQUEST",(function(){return se})),n.d(t,"LOG_REQUEST",(function(){return ce})),n.d(t,"CLEAR_RESPONSE",(function(){return le})),n.d(t,"CLEAR_REQUEST",(function(){return fe})),n.d(t,"CLEAR_VALIDATE_PARAMS",(function(){return pe})),n.d(t,"UPDATE_OPERATION_META_VALUE",(function(){return he})),n.d(t,"UPDATE_RESOLVED",(function(){return de})),n.d(t,"UPDATE_RESOLVED_SUBTREE",(function(){return me})),n.d(t,"SET_SCHEME",(function(){return ve})),n.d(t,"updateSpec",(function(){return ge})),n.d(t,"updateResolved",(function(){return ye})),n.d(t,"updateUrl",(function(){return be})),n.d(t,"updateJsonSpec",(function(){return we})),n.d(t,"parseToJson",(function(){return xe})),n.d(t,"resolveSpec",(function(){return Ee})),n.d(t,"requestResolvedSubtree",(function(){return Ae})),n.d(t,"changeParam",(function(){return Oe})),n.d(t,"changeParamByIdentity",(function(){return Ce})),n.d(t,"updateResolvedSubtree",(function(){return je})),n.d(t,"invalidateResolvedSubtreeCache",(function(){return Te})),n.d(t,"validateParams",(function(){return Ie})),n.d(t,"updateEmptyParamInclusion",(function(){return Ne})),n.d(t,"clearValidateParams",(function(){return Pe})),n.d(t,"changeConsumesValue",(function(){return Me})),n.d(t,"changeProducesValue",(function(){return Re})),n.d(t,"setResponse",(function(){return De})),n.d(t,"setRequest",(function(){return Le})),n.d(t,"setMutatedRequest",(function(){return Be})),n.d(t,"logRequest",(function(){return Fe})),n.d(t,"executeRequest",(function(){return ze})),n.d(t,"execute",(function(){return qe})),n.d(t,"clearResponse",(function(){return Ue})),n.d(t,"clearRequest",(function(){return Ve})),n.d(t,"setScheme",(function(){return We}));var r=n(25),o=n.n(r),a=n(54),i=n.n(a),u=n(72),s=n.n(u),c=n(19),l=n.n(c),f=n(40),p=n.n(f),h=n(24),d=n.n(h),m=n(4),v=n.n(m),g=n(319),y=n.n(g),b=n(30),w=n.n(b),x=n(197),_=n.n(x),E=n(66),S=n.n(E),k=n(12),A=n.n(k),O=n(198),C=n.n(O),j=n(18),T=n.n(j),I=n(23),N=n.n(I),P=n(2),M=n.n(P),R=n(15),D=n.n(R),L=n(21),B=n.n(L),F=n(320),z=n.n(F),q=n(70),U=n(1),V=n(89),W=n.n(V),H=n(141),$=n(457),J=n.n($),K=n(458),Y=n.n(K),G=n(321),Q=n.n(G),Z=n(5),X=["path","method"],ee="spec_update_spec",te="spec_update_url",ne="spec_update_json",re="spec_update_param",oe="spec_update_empty_param_inclusion",ae="spec_validate_param",ie="spec_set_response",ue="spec_set_request",se="spec_set_mutated_request",ce="spec_log_request",le="spec_clear_response",fe="spec_clear_request",pe="spec_clear_validate_param",he="spec_update_operation_meta_value",de="spec_update_resolved",me="spec_update_resolved_subtree",ve="set_scheme";function ge(e){var t,n=(t=e,J()(t)?t:"").replace(/\t/g," ");if("string"==typeof e)return{type:ee,payload:n}}function ye(e){return{type:de,payload:e}}function be(e){return{type:te,payload:e}}function we(e){return{type:ne,payload:e}}var xe=function(e){return function(t){var n=t.specActions,r=t.specSelectors,o=t.errActions,a=r.specStr,i=null;try{e=e||a(),o.clear({source:"parser"}),i=q.a.load(e)}catch(e){return console.error(e),o.newSpecErr({source:"parser",level:"error",message:e.reason,line:e.mark&&e.mark.line?e.mark.line+1:void 0})}return i&&"object"===l()(i)?n.updateJsonSpec(i):{}}},_e=!1,Ee=function(e,t){return function(n){var r=n.specActions,o=n.specSelectors,a=n.errActions,i=n.fn,u=i.fetch,s=i.resolve,c=i.AST,l=void 0===c?{}:c,f=n.getConfigs;_e||(console.warn("specActions.resolveSpec is deprecated since v3.10.0 and will be removed in v4.0.0; use requestResolvedSubtree instead!"),_e=!0);var p=f(),h=p.modelPropertyMacro,m=p.parameterMacro,g=p.requestInterceptor,b=p.responseInterceptor;void 0===e&&(e=o.specJson()),void 0===t&&(t=o.url());var w=l.getLineNumberForPath?l.getLineNumberForPath:function(){},x=o.specStr();return s({fetch:u,spec:e,baseDoc:t,modelPropertyMacro:h,parameterMacro:m,requestInterceptor:g,responseInterceptor:b}).then((function(e){var t=e.spec,n=e.errors;if(a.clear({type:"thrown"}),d()(n)&&n.length>0){var o=v()(n).call(n,(function(e){return console.error(e),e.line=e.fullPath?w(x,e.fullPath):null,e.path=e.fullPath?e.fullPath.join("."):null,e.level="error",e.type="thrown",e.source="resolver",y()(e,"message",{enumerable:!0,value:e.message}),e}));a.newThrownErrBatch(o)}return r.updateResolved(t)}))}},Se=[],ke=Y()(s()(p.a.mark((function e(){var t,n,r,o,a,i,u,c,l,f,h,m,g,b,x,E,k,O;return p.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=Se.system){e.next=4;break}return console.error("debResolveSubtrees: don't have a system to operate on, aborting."),e.abrupt("return");case 4:if(n=t.errActions,r=t.errSelectors,o=t.fn,a=o.resolveSubtree,i=o.fetch,u=o.AST,c=void 0===u?{}:u,l=t.specSelectors,f=t.specActions,a){e.next=8;break}return console.error("Error: Swagger-Client did not provide a `resolveSubtree` method, doing nothing."),e.abrupt("return");case 8:return h=c.getLineNumberForPath?c.getLineNumberForPath:function(){},m=l.specStr(),g=t.getConfigs(),b=g.modelPropertyMacro,x=g.parameterMacro,E=g.requestInterceptor,k=g.responseInterceptor,e.prev=11,e.next=14,w()(Se).call(Se,function(){var e=s()(p.a.mark((function e(t,o){var u,c,f,g,w,O,j,T,I;return p.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t;case 2:return u=e.sent,c=u.resultMap,f=u.specWithCurrentSubtrees,e.next=7,a(f,o,{baseDoc:l.url(),modelPropertyMacro:b,parameterMacro:x,requestInterceptor:E,responseInterceptor:k});case 7:if(g=e.sent,w=g.errors,O=g.spec,r.allErrors().size&&n.clearBy((function(e){var t;return"thrown"!==e.get("type")||"resolver"!==e.get("source")||!_()(t=e.get("fullPath")).call(t,(function(e,t){return e===o[t]||void 0===o[t]}))})),d()(w)&&w.length>0&&(j=v()(w).call(w,(function(e){return e.line=e.fullPath?h(m,e.fullPath):null,e.path=e.fullPath?e.fullPath.join("."):null,e.level="error",e.type="thrown",e.source="resolver",y()(e,"message",{enumerable:!0,value:e.message}),e})),n.newThrownErrBatch(j)),!O||!l.isOAS3()||"components"!==o[0]||"securitySchemes"!==o[1]){e.next=15;break}return e.next=15,S.a.all(v()(T=A()(I=C()(O)).call(I,(function(e){return"openIdConnect"===e.type}))).call(T,function(){var e=s()(p.a.mark((function e(t){var n,r;return p.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={url:t.openIdConnectUrl,requestInterceptor:E,responseInterceptor:k},e.prev=1,e.next=4,i(n);case 4:(r=e.sent)instanceof Error||r.status>=400?console.error(r.statusText+" "+n.url):t.openIdConnectData=JSON.parse(r.text),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),console.error(e.t0);case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t){return e.apply(this,arguments)}}()));case 15:return Q()(c,o,O),Q()(f,o,O),e.abrupt("return",{resultMap:c,specWithCurrentSubtrees:f});case 18:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),S.a.resolve({resultMap:(l.specResolvedSubtree([])||Object(U.Map)()).toJS(),specWithCurrentSubtrees:l.specJson().toJS()}));case 14:O=e.sent,delete Se.system,Se=[],e.next=22;break;case 19:e.prev=19,e.t0=e.catch(11),console.error(e.t0);case 22:f.updateResolvedSubtree([],O.resultMap);case 23:case"end":return e.stop()}}),e,null,[[11,19]])}))),35),Ae=function(e){return function(t){var n;T()(n=v()(Se).call(Se,(function(e){return e.join("@@")}))).call(n,e.join("@@"))>-1||(Se.push(e),Se.system=t,ke())}};function Oe(e,t,n,r,o){return{type:re,payload:{path:e,value:r,paramName:t,paramIn:n,isXml:o}}}function Ce(e,t,n,r){return{type:re,payload:{path:e,param:t,value:n,isXml:r}}}var je=function(e,t){return{type:me,payload:{path:e,value:t}}},Te=function(){return{type:me,payload:{path:[],value:Object(U.Map)()}}},Ie=function(e,t){return{type:ae,payload:{pathMethod:e,isOAS3:t}}},Ne=function(e,t,n,r){return{type:oe,payload:{pathMethod:e,paramName:t,paramIn:n,includeEmptyValue:r}}};function Pe(e){return{type:pe,payload:{pathMethod:e}}}function Me(e,t){return{type:he,payload:{path:e,value:t,key:"consumes_value"}}}function Re(e,t){return{type:he,payload:{path:e,value:t,key:"produces_value"}}}var De=function(e,t,n){return{payload:{path:e,method:t,res:n},type:ie}},Le=function(e,t,n){return{payload:{path:e,method:t,req:n},type:ue}},Be=function(e,t,n){return{payload:{path:e,method:t,req:n},type:se}},Fe=function(e){return{payload:e,type:ce}},ze=function(e){return function(t){var n,r,o=t.fn,a=t.specActions,i=t.specSelectors,u=t.getConfigs,c=t.oas3Selectors,l=e.pathName,f=e.method,h=e.operation,m=u(),g=m.requestInterceptor,y=m.responseInterceptor,b=h.toJS();h&&h.get("parameters")&&N()(n=A()(r=h.get("parameters")).call(r,(function(e){return e&&!0===e.get("allowEmptyValue")}))).call(n,(function(t){if(i.parameterInclusionSettingFor([l,f],t.get("name"),t.get("in"))){e.parameters=e.parameters||{};var n=Object(Z.B)(t,e.parameters);(!n||n&&0===n.size)&&(e.parameters[t.get("name")]="")}}));if(e.contextUrl=W()(i.url()).toString(),b&&b.operationId?e.operationId=b.operationId:b&&l&&f&&(e.operationId=o.opId(b,l,f)),i.isOAS3()){var w,x=M()(w="".concat(l,":")).call(w,f);e.server=c.selectedServer(x)||c.selectedServer();var _=c.serverVariables({server:e.server,namespace:x}).toJS(),E=c.serverVariables({server:e.server}).toJS();e.serverVariables=D()(_).length?_:E,e.requestContentType=c.requestContentType(l,f),e.responseContentType=c.responseContentType(l,f)||"*/*";var S,k=c.requestBodyValue(l,f),O=c.requestBodyInclusionSetting(l,f);if(k&&k.toJS)e.requestBody=A()(S=v()(k).call(k,(function(e){return U.Map.isMap(e)?e.get("value"):e}))).call(S,(function(e,t){return(d()(e)?0!==e.length:!Object(Z.q)(e))||O.get(t)})).toJS();else e.requestBody=k}var C=B()({},e);C=o.buildRequest(C),a.setRequest(e.pathName,e.method,C);var j=function(){var t=s()(p.a.mark((function t(n){var r,o;return p.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,g.apply(undefined,[n]);case 2:return r=t.sent,o=B()({},r),a.setMutatedRequest(e.pathName,e.method,o),t.abrupt("return",r);case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();e.requestInterceptor=j,e.responseInterceptor=y;var T=z()();return o.execute(e).then((function(t){t.duration=z()()-T,a.setResponse(e.pathName,e.method,t)})).catch((function(t){"Failed to fetch"===t.message&&(t.name="",t.message='**Failed to fetch.** \n**Possible Reasons:** \n - CORS \n - Network Failure \n - URL scheme must be "http" or "https" for CORS request.'),a.setResponse(e.pathName,e.method,{error:!0,err:Object(H.serializeError)(t)})}))}},qe=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.path,n=e.method,r=i()(e,X);return function(e){var a=e.fn.fetch,i=e.specSelectors,u=e.specActions,s=i.specJsonWithResolvedSubtrees().toJS(),c=i.operationScheme(t,n),l=i.contentTypeValues([t,n]).toJS(),f=l.requestContentType,p=l.responseContentType,h=/xml/i.test(f),d=i.parameterValues([t,n],h).toJS();return u.executeRequest(o()(o()({},r),{},{fetch:a,spec:s,pathName:t,method:n,parameters:d,requestContentType:f,scheme:c,responseContentType:p}))}};function Ue(e,t){return{type:le,payload:{path:e,method:t}}}function Ve(e,t){return{type:fe,payload:{path:e,method:t}}}function We(e,t,n){return{type:ve,payload:{scheme:e,path:t,method:n}}}},function(e,t,n){var r;!function(){"use strict";var n={}.hasOwnProperty;function o(){for(var e=[],t=0;t=e.length?{done:!0}:{done:!1,value:e[u++]}},e:function(e){throw e},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,l=!0,f=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return l=e.done,e},e:function(e){f=!0,c=e},f:function(){try{l||null==n.return||n.return()}finally{if(f)throw c}}}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){var n=Function.prototype.call;e.exports=n.bind?n.bind(n):function(){return n.apply(n,arguments)}},function(e,t,n){var r=n(17),o=n(43),a=r.String,i=r.TypeError;e.exports=function(e){if(o(e))return e;throw i(a(e)+" is not an object")}},function(e,t){var n=Array.isArray;e.exports=n},function(e,t){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},function(e,t,n){var r=n(421),o=n(423),a=n(820);e.exports=function(e,t){if(null==e)return{};var n,i,u=a(e,t);if(r){var s=r(e);for(i=0;i=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(u[n]=e[n])}return u},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){"use strict";n.r(t),n.d(t,"UPDATE_SELECTED_SERVER",(function(){return r})),n.d(t,"UPDATE_REQUEST_BODY_VALUE",(function(){return o})),n.d(t,"UPDATE_REQUEST_BODY_VALUE_RETAIN_FLAG",(function(){return a})),n.d(t,"UPDATE_REQUEST_BODY_INCLUSION",(function(){return i})),n.d(t,"UPDATE_ACTIVE_EXAMPLES_MEMBER",(function(){return u})),n.d(t,"UPDATE_REQUEST_CONTENT_TYPE",(function(){return s})),n.d(t,"UPDATE_RESPONSE_CONTENT_TYPE",(function(){return c})),n.d(t,"UPDATE_SERVER_VARIABLE_VALUE",(function(){return l})),n.d(t,"SET_REQUEST_BODY_VALIDATE_ERROR",(function(){return f})),n.d(t,"CLEAR_REQUEST_BODY_VALIDATE_ERROR",(function(){return p})),n.d(t,"CLEAR_REQUEST_BODY_VALUE",(function(){return h})),n.d(t,"setSelectedServer",(function(){return d})),n.d(t,"setRequestBodyValue",(function(){return m})),n.d(t,"setRetainRequestBodyValueFlag",(function(){return v})),n.d(t,"setRequestBodyInclusion",(function(){return g})),n.d(t,"setActiveExamplesMember",(function(){return y})),n.d(t,"setRequestContentType",(function(){return b})),n.d(t,"setResponseContentType",(function(){return w})),n.d(t,"setServerVariableValue",(function(){return x})),n.d(t,"setRequestBodyValidateError",(function(){return _})),n.d(t,"clearRequestBodyValidateError",(function(){return E})),n.d(t,"initRequestBodyValidateError",(function(){return S})),n.d(t,"clearRequestBodyValue",(function(){return k}));var r="oas3_set_servers",o="oas3_set_request_body_value",a="oas3_set_request_body_retain_flag",i="oas3_set_request_body_inclusion",u="oas3_set_active_examples_member",s="oas3_set_request_content_type",c="oas3_set_response_content_type",l="oas3_set_server_variable_value",f="oas3_set_request_body_validate_error",p="oas3_clear_request_body_validate_error",h="oas3_clear_request_body_value";function d(e,t){return{type:r,payload:{selectedServerUrl:e,namespace:t}}}function m(e){var t=e.value,n=e.pathMethod;return{type:o,payload:{value:t,pathMethod:n}}}var v=function(e){var t=e.value,n=e.pathMethod;return{type:a,payload:{value:t,pathMethod:n}}};function g(e){var t=e.value,n=e.pathMethod,r=e.name;return{type:i,payload:{value:t,pathMethod:n,name:r}}}function y(e){var t=e.name,n=e.pathMethod,r=e.contextType,o=e.contextName;return{type:u,payload:{name:t,pathMethod:n,contextType:r,contextName:o}}}function b(e){var t=e.value,n=e.pathMethod;return{type:s,payload:{value:t,pathMethod:n}}}function w(e){var t=e.value,n=e.path,r=e.method;return{type:c,payload:{value:t,path:n,method:r}}}function x(e){var t=e.server,n=e.namespace,r=e.key,o=e.val;return{type:l,payload:{server:t,namespace:n,key:r,val:o}}}var _=function(e){var t=e.path,n=e.method,r=e.validationErrors;return{type:f,payload:{path:t,method:n,validationErrors:r}}},E=function(e){var t=e.path,n=e.method;return{type:p,payload:{path:t,method:n}}},S=function(e){var t=e.pathMethod;return{type:p,payload:{path:t[0],method:t[1]}}},k=function(e){var t=e.pathMethod;return{type:h,payload:{pathMethod:t}}}},function(e,t,n){e.exports=n(647)},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){var r=n(34),o=n(17),a=n(41),i=function(e){return a(e)?e:void 0};e.exports=function(e,t){return arguments.length<2?i(r[e])||i(o[e]):r[e]&&r[e][t]||o[e]&&o[e][t]}},function(e,t,n){"use strict";n.d(t,"b",(function(){return m})),n.d(t,"e",(function(){return v})),n.d(t,"c",(function(){return y})),n.d(t,"a",(function(){return b})),n.d(t,"d",(function(){return w}));var r=n(49),o=n.n(r),a=n(19),i=n.n(a),u=n(108),s=n.n(u),c=n(2),l=n.n(c),f=n(53),p=n.n(f),h=function(e){return String.prototype.toLowerCase.call(e)},d=function(e){return e.replace(/[^\w]/gi,"_")};function m(e){var t=e.openapi;return!!t&&s()(t).call(t,"3")}function v(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=r.v2OperationIdCompatibilityMode;if(!e||"object"!==i()(e))return null;var a=(e.operationId||"").replace(/\s/g,"");return a.length?d(e.operationId):g(t,n,{v2OperationIdCompatibilityMode:o})}function g(e,t){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=r.v2OperationIdCompatibilityMode;if(o){var a,i,u=l()(a="".concat(t.toLowerCase(),"_")).call(a,e).replace(/[\s!@#$%^&*()_+=[{\]};:<>|./?,\\'""-]/g,"_");return(u=u||l()(i="".concat(e.substring(1),"_")).call(i,t)).replace(/((_){2,})/g,"_").replace(/^(_)*/g,"").replace(/([_])*$/g,"")}return l()(n="".concat(h(t))).call(n,d(e))}function y(e,t){var n;return l()(n="".concat(h(t),"-")).call(n,e)}function b(e,t){return e&&e.paths?function(e,t){return function(e,t,n){if(!e||"object"!==i()(e)||!e.paths||"object"!==i()(e.paths))return null;var r=e.paths;for(var o in r)for(var a in r[o])if("PARAMETERS"!==a.toUpperCase()){var u=r[o][a];if(u&&"object"===i()(u)){var s={spec:e,pathName:o,method:a.toUpperCase(),operation:u},c=t(s);if(n&&c)return s}}return}(e,t,!0)||null}(e,(function(e){var n=e.pathName,r=e.method,o=e.operation;if(!o||"object"!==i()(o))return!1;var a=o.operationId;return[v(o,n,r),y(n,r),a].some((function(e){return e&&e===t}))})):null}function w(e){var t=e.spec,n=t.paths,r={};if(!n||t.$$normalized)return e;for(var a in n){var i=n[a];if(p()(i)){var u=i.parameters,s=function(e){var n=i[e];if(!p()(n))return"continue";var s=v(n,a,e);if(s){r[s]?r[s].push(n):r[s]=[n];var c=r[s];if(c.length>1)c.forEach((function(e,t){var n;e.__originalOperationId=e.__originalOperationId||e.operationId,e.operationId=l()(n="".concat(s)).call(n,t+1)}));else if(void 0!==n.operationId){var f=c[0];f.__originalOperationId=f.__originalOperationId||n.operationId,f.operationId=s}}if("parameters"!==e){var h=[],d={};for(var m in t)"produces"!==m&&"consumes"!==m&&"security"!==m||(d[m]=t[m],h.push(d));if(u&&(d.parameters=u,h.push(d)),h.length){var g,y=o()(h);try{for(y.s();!(g=y.n()).done;){var b=g.value;for(var w in b)if(n[w]){if("parameters"===w){var x,_=o()(b[w]);try{var E=function(){var e=x.value;n[w].some((function(t){return t.name&&t.name===e.name||t.$ref&&t.$ref===e.$ref||t.$$ref&&t.$$ref===e.$$ref||t===e}))||n[w].push(e)};for(_.s();!(x=_.n()).done;)E()}catch(e){_.e(e)}finally{_.f()}}}else n[w]=b[w]}}catch(e){y.e(e)}finally{y.f()}}}};for(var c in i)s(c)}}return t.$$normalized=!0,e}},function(e,t,n){"use strict";n.r(t),n.d(t,"NEW_THROWN_ERR",(function(){return o})),n.d(t,"NEW_THROWN_ERR_BATCH",(function(){return a})),n.d(t,"NEW_SPEC_ERR",(function(){return i})),n.d(t,"NEW_SPEC_ERR_BATCH",(function(){return u})),n.d(t,"NEW_AUTH_ERR",(function(){return s})),n.d(t,"CLEAR",(function(){return c})),n.d(t,"CLEAR_BY",(function(){return l})),n.d(t,"newThrownErr",(function(){return f})),n.d(t,"newThrownErrBatch",(function(){return p})),n.d(t,"newSpecErr",(function(){return h})),n.d(t,"newSpecErrBatch",(function(){return d})),n.d(t,"newAuthErr",(function(){return m})),n.d(t,"clear",(function(){return v})),n.d(t,"clearBy",(function(){return g}));var r=n(141),o="err_new_thrown_err",a="err_new_thrown_err_batch",i="err_new_spec_err",u="err_new_spec_err_batch",s="err_new_auth_err",c="err_clear",l="err_clear_by";function f(e){return{type:o,payload:Object(r.serializeError)(e)}}function p(e){return{type:a,payload:e}}function h(e){return{type:i,payload:e}}function d(e){return{type:u,payload:e}}function m(e){return{type:s,payload:e}}function v(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{type:c,payload:e}}function g(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){return!0};return{type:l,payload:e}}},function(e,t,n){var r=n(168),o=n(113);e.exports=function(e){return r(o(e))}},function(e,t,n){var r=n(17),o=n(113),a=r.Object;e.exports=function(e){return a(o(e))}},function(e,t,n){var r=n(17),o=n(48),a=n(330),i=n(51),u=n(169),s=r.TypeError,c=Object.defineProperty;t.f=o?c:function(e,t,n){if(i(e),t=u(t),i(n),a)try{return c(e,t,n)}catch(e){}if("get"in n||"set"in n)throw s("Accessors not supported");return"value"in n&&(e[t]=n.value),e}},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},function(e,t,n){var r=n(132),o=r.Buffer;function a(e,t){for(var n in e)t[n]=e[n]}function i(e,t,n){return o(e,t,n)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?e.exports=r:(a(r,t),t.Buffer=i),a(o,i),i.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,n)},i.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=o(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},i.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o(e)},i.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},function(e,t,n){e.exports=n(424)},function(e,t,n){var r=n(17),o=n(75),a=r.String;e.exports=function(e){if("Symbol"===o(e))throw TypeError("Cannot convert a Symbol value to a string");return a(e)}},function(e,t,n){n(77);var r=n(507),o=n(17),a=n(75),i=n(85),u=n(130),s=n(38)("toStringTag");for(var c in r){var l=o[c],f=l&&l.prototype;f&&a(f)!==s&&i(f,s,c),u[c]=u.Array}},function(e,t,n){var r=n(355),o="object"==typeof self&&self&&self.Object===Object&&self,a=r||o||Function("return this")();e.exports=a},function(e,t,n){"use strict";function r(e){return null==e}var o={isNothing:r,isObject:function(e){return"object"==typeof e&&null!==e},toArray:function(e){return Array.isArray(e)?e:r(e)?[]:[e]},repeat:function(e,t){var n,r="";for(n=0;nu&&(t=r-u+(a=" ... ").length),n-r>u&&(n=r+u-(i=" ...").length),{str:a+e.slice(t,n).replace(/\t/g,"→")+i,pos:r-t+a.length}}function c(e,t){return o.repeat(" ",t-e.length)+e}var l=function(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),"number"!=typeof t.indent&&(t.indent=1),"number"!=typeof t.linesBefore&&(t.linesBefore=3),"number"!=typeof t.linesAfter&&(t.linesAfter=2);for(var n,r=/\r?\n|\r|\0/g,a=[0],i=[],u=-1;n=r.exec(e.buffer);)i.push(n.index),a.push(n.index+n[0].length),e.position<=n.index&&u<0&&(u=a.length-2);u<0&&(u=a.length-1);var l,f,p="",h=Math.min(e.line+t.linesAfter,i.length).toString().length,d=t.maxLength-(t.indent+h+3);for(l=1;l<=t.linesBefore&&!(u-l<0);l++)f=s(e.buffer,a[u-l],i[u-l],e.position-(a[u]-a[u-l]),d),p=o.repeat(" ",t.indent)+c((e.line-l+1).toString(),h)+" | "+f.str+"\n"+p;for(f=s(e.buffer,a[u],i[u],e.position,d),p+=o.repeat(" ",t.indent)+c((e.line+1).toString(),h)+" | "+f.str+"\n",p+=o.repeat("-",t.indent+h+3+f.pos)+"^\n",l=1;l<=t.linesAfter&&!(u+l>=i.length);l++)f=s(e.buffer,a[u+l],i[u+l],e.position-(a[u]-a[u+l]),d),p+=o.repeat(" ",t.indent)+c((e.line+l+1).toString(),h)+" | "+f.str+"\n";return p.replace(/\n$/,"")},f=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],p=["scalar","sequence","mapping"];var h=function(e,t){if(t=t||{},Object.keys(t).forEach((function(t){if(-1===f.indexOf(t))throw new u('Unknown option "'+t+'" is met in definition of "'+e+'" YAML type.')})),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=function(e){var t={};return null!==e&&Object.keys(e).forEach((function(n){e[n].forEach((function(e){t[String(e)]=n}))})),t}(t.styleAliases||null),-1===p.indexOf(this.kind))throw new u('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')};function d(e,t){var n=[];return e[t].forEach((function(e){var t=n.length;n.forEach((function(n,r){n.tag===e.tag&&n.kind===e.kind&&n.multi===e.multi&&(t=r)})),n[t]=e})),n}function m(e){return this.extend(e)}m.prototype.extend=function(e){var t=[],n=[];if(e instanceof h)n.push(e);else if(Array.isArray(e))n=n.concat(e);else{if(!e||!Array.isArray(e.implicit)&&!Array.isArray(e.explicit))throw new u("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");e.implicit&&(t=t.concat(e.implicit)),e.explicit&&(n=n.concat(e.explicit))}t.forEach((function(e){if(!(e instanceof h))throw new u("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(e.loadKind&&"scalar"!==e.loadKind)throw new u("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(e.multi)throw new u("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),n.forEach((function(e){if(!(e instanceof h))throw new u("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var r=Object.create(m.prototype);return r.implicit=(this.implicit||[]).concat(t),r.explicit=(this.explicit||[]).concat(n),r.compiledImplicit=d(r,"implicit"),r.compiledExplicit=d(r,"explicit"),r.compiledTypeMap=function(){var e,t,n={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function r(e){e.multi?(n.multi[e.kind].push(e),n.multi.fallback.push(e)):n[e.kind][e.tag]=n.fallback[e.tag]=e}for(e=0,t=arguments.length;e=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),A=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");var O=/^[-+]?[0-9]+e/;var C=new h("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(e){return null!==e&&!(!A.test(e)||"_"===e[e.length-1])},construct:function(e){var t,n;return n="-"===(t=e.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),".inf"===t?1===n?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===t?NaN:n*parseFloat(t,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&(e%1!=0||o.isNegativeZero(e))},represent:function(e,t){var n;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(o.isNegativeZero(e))return"-0.0";return n=e.toString(10),O.test(n)?n.replace("e",".e"):n},defaultStyle:"lowercase"}),j=w.extend({implicit:[x,_,k,C]}),T=j,I=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),N=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");var P=new h("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(e){return null!==e&&(null!==I.exec(e)||null!==N.exec(e))},construct:function(e){var t,n,r,o,a,i,u,s,c=0,l=null;if(null===(t=I.exec(e))&&(t=N.exec(e)),null===t)throw new Error("Date resolve error");if(n=+t[1],r=+t[2]-1,o=+t[3],!t[4])return new Date(Date.UTC(n,r,o));if(a=+t[4],i=+t[5],u=+t[6],t[7]){for(c=t[7].slice(0,3);c.length<3;)c+="0";c=+c}return t[9]&&(l=6e4*(60*+t[10]+ +(t[11]||0)),"-"===t[9]&&(l=-l)),s=new Date(Date.UTC(n,r,o,a,i,u,c)),l&&s.setTime(s.getTime()-l),s},instanceOf:Date,represent:function(e){return e.toISOString()}});var M=new h("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(e){return"<<"===e||null===e}}),R="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";var D=new h("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,n,r=0,o=e.length,a=R;for(n=0;n64)){if(t<0)return!1;r+=6}return r%8==0},construct:function(e){var t,n,r=e.replace(/[\r\n=]/g,""),o=r.length,a=R,i=0,u=[];for(t=0;t>16&255),u.push(i>>8&255),u.push(255&i)),i=i<<6|a.indexOf(r.charAt(t));return 0===(n=o%4*6)?(u.push(i>>16&255),u.push(i>>8&255),u.push(255&i)):18===n?(u.push(i>>10&255),u.push(i>>2&255)):12===n&&u.push(i>>4&255),new Uint8Array(u)},predicate:function(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)},represent:function(e){var t,n,r="",o=0,a=e.length,i=R;for(t=0;t>18&63],r+=i[o>>12&63],r+=i[o>>6&63],r+=i[63&o]),o=(o<<8)+e[t];return 0===(n=a%3)?(r+=i[o>>18&63],r+=i[o>>12&63],r+=i[o>>6&63],r+=i[63&o]):2===n?(r+=i[o>>10&63],r+=i[o>>4&63],r+=i[o<<2&63],r+=i[64]):1===n&&(r+=i[o>>2&63],r+=i[o<<4&63],r+=i[64],r+=i[64]),r}}),L=Object.prototype.hasOwnProperty,B=Object.prototype.toString;var F=new h("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(e){if(null===e)return!0;var t,n,r,o,a,i=[],u=e;for(t=0,n=u.length;t>10),56320+(e-65536&1023))}for(var ae=new Array(256),ie=new Array(256),ue=0;ue<256;ue++)ae[ue]=re(ue)?1:0,ie[ue]=re(ue);function se(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||W,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function ce(e,t){var n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=l(n),new u(t,n)}function le(e,t){throw ce(e,t)}function fe(e,t){e.onWarning&&e.onWarning.call(null,ce(e,t))}var pe={YAML:function(e,t,n){var r,o,a;null!==e.version&&le(e,"duplication of %YAML directive"),1!==n.length&&le(e,"YAML directive accepts exactly one argument"),null===(r=/^([0-9]+)\.([0-9]+)$/.exec(n[0]))&&le(e,"ill-formed argument of the YAML directive"),o=parseInt(r[1],10),a=parseInt(r[2],10),1!==o&&le(e,"unacceptable YAML version of the document"),e.version=n[0],e.checkLineBreaks=a<2,1!==a&&2!==a&&fe(e,"unsupported YAML version of the document")},TAG:function(e,t,n){var r,o;2!==n.length&&le(e,"TAG directive accepts exactly two arguments"),r=n[0],o=n[1],Y.test(r)||le(e,"ill-formed tag handle (first argument) of the TAG directive"),H.call(e.tagMap,r)&&le(e,'there is a previously declared suffix for "'+r+'" tag handle'),G.test(o)||le(e,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch(t){le(e,"tag prefix is malformed: "+o)}e.tagMap[r]=o}};function he(e,t,n,r){var o,a,i,u;if(t1&&(e.result+=o.repeat("\n",t-1))}function we(e,t){var n,r,o=e.tag,a=e.anchor,i=[],u=!1;if(-1!==e.firstTabInLine)return!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=i),r=e.input.charCodeAt(e.position);0!==r&&(-1!==e.firstTabInLine&&(e.position=e.firstTabInLine,le(e,"tab characters must not be used in indentation")),45===r)&&ee(e.input.charCodeAt(e.position+1));)if(u=!0,e.position++,ge(e,!0,-1)&&e.lineIndent<=t)i.push(null),r=e.input.charCodeAt(e.position);else if(n=e.line,Ee(e,t,3,!1,!0),i.push(e.result),ge(e,!0,-1),r=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&0!==r)le(e,"bad indentation of a sequence entry");else if(e.lineIndentt?m=1:e.lineIndent===t?m=0:e.lineIndentt?m=1:e.lineIndent===t?m=0:e.lineIndentt)&&(g&&(i=e.line,u=e.lineStart,s=e.position),Ee(e,t,4,!0,o)&&(g?m=e.result:v=e.result),g||(me(e,p,h,d,m,v,i,u,s),d=m=v=null),ge(e,!0,-1),c=e.input.charCodeAt(e.position)),(e.line===a||e.lineIndent>t)&&0!==c)le(e,"bad indentation of a mapping entry");else if(e.lineIndent=0))break;0===a?le(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):l?le(e,"repeat of an indentation width identifier"):(f=t+a-1,l=!0)}if(X(i)){do{i=e.input.charCodeAt(++e.position)}while(X(i));if(35===i)do{i=e.input.charCodeAt(++e.position)}while(!Z(i)&&0!==i)}for(;0!==i;){for(ve(e),e.lineIndent=0,i=e.input.charCodeAt(e.position);(!l||e.lineIndentf&&(f=e.lineIndent),Z(i))p++;else{if(e.lineIndent0){for(o=i,a=0;o>0;o--)(i=ne(u=e.input.charCodeAt(++e.position)))>=0?a=(a<<4)+i:le(e,"expected hexadecimal character");e.result+=oe(a),e.position++}else le(e,"unknown escape sequence");n=r=e.position}else Z(u)?(he(e,n,r,!0),be(e,ge(e,!1,t)),n=r=e.position):e.position===e.lineStart&&ye(e)?le(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}le(e,"unexpected end of the stream within a double quoted scalar")}(e,h)?g=!0:!function(e){var t,n,r;if(42!==(r=e.input.charCodeAt(e.position)))return!1;for(r=e.input.charCodeAt(++e.position),t=e.position;0!==r&&!ee(r)&&!te(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&le(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),H.call(e.anchorMap,n)||le(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],ge(e,!0,-1),!0}(e)?function(e,t,n){var r,o,a,i,u,s,c,l,f=e.kind,p=e.result;if(ee(l=e.input.charCodeAt(e.position))||te(l)||35===l||38===l||42===l||33===l||124===l||62===l||39===l||34===l||37===l||64===l||96===l)return!1;if((63===l||45===l)&&(ee(r=e.input.charCodeAt(e.position+1))||n&&te(r)))return!1;for(e.kind="scalar",e.result="",o=a=e.position,i=!1;0!==l;){if(58===l){if(ee(r=e.input.charCodeAt(e.position+1))||n&&te(r))break}else if(35===l){if(ee(e.input.charCodeAt(e.position-1)))break}else{if(e.position===e.lineStart&&ye(e)||n&&te(l))break;if(Z(l)){if(u=e.line,s=e.lineStart,c=e.lineIndent,ge(e,!1,-1),e.lineIndent>=t){i=!0,l=e.input.charCodeAt(e.position);continue}e.position=a,e.line=u,e.lineStart=s,e.lineIndent=c;break}}i&&(he(e,o,a,!1),be(e,e.line-u),o=a=e.position,i=!1),X(l)||(a=e.position+1),l=e.input.charCodeAt(++e.position)}return he(e,o,a,!1),!!e.result||(e.kind=f,e.result=p,!1)}(e,h,1===n)&&(g=!0,null===e.tag&&(e.tag="?")):(g=!0,null===e.tag&&null===e.anchor||le(e,"alias node should not have any properties")),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):0===m&&(g=s&&we(e,d))),null===e.tag)null!==e.anchor&&(e.anchorMap[e.anchor]=e.result);else if("?"===e.tag){for(null!==e.result&&"scalar"!==e.kind&&le(e,'unacceptable node kind for ! tag; it should be "scalar", not "'+e.kind+'"'),c=0,l=e.implicitTypes.length;c"),null!==e.result&&p.kind!==e.kind&&le(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+p.kind+'", not "'+e.kind+'"'),p.resolve(e.result,e.tag)?(e.result=p.construct(e.result,e.tag),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):le(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return null!==e.listener&&e.listener("close",e),null!==e.tag||null!==e.anchor||g}function Se(e){var t,n,r,o,a=e.position,i=!1;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);0!==(o=e.input.charCodeAt(e.position))&&(ge(e,!0,-1),o=e.input.charCodeAt(e.position),!(e.lineIndent>0||37!==o));){for(i=!0,o=e.input.charCodeAt(++e.position),t=e.position;0!==o&&!ee(o);)o=e.input.charCodeAt(++e.position);for(r=[],(n=e.input.slice(t,e.position)).length<1&&le(e,"directive name must not be less than one character in length");0!==o;){for(;X(o);)o=e.input.charCodeAt(++e.position);if(35===o){do{o=e.input.charCodeAt(++e.position)}while(0!==o&&!Z(o));break}if(Z(o))break;for(t=e.position;0!==o&&!ee(o);)o=e.input.charCodeAt(++e.position);r.push(e.input.slice(t,e.position))}0!==o&&ve(e),H.call(pe,n)?pe[n](e,n,r):fe(e,'unknown document directive "'+n+'"')}ge(e,!0,-1),0===e.lineIndent&&45===e.input.charCodeAt(e.position)&&45===e.input.charCodeAt(e.position+1)&&45===e.input.charCodeAt(e.position+2)?(e.position+=3,ge(e,!0,-1)):i&&le(e,"directives end mark is expected"),Ee(e,e.lineIndent-1,4,!1,!0),ge(e,!0,-1),e.checkLineBreaks&&J.test(e.input.slice(a,e.position))&&fe(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&ye(e)?46===e.input.charCodeAt(e.position)&&(e.position+=3,ge(e,!0,-1)):e.position=55296&&r<=56319&&t+1=56320&&n<=57343?1024*(r-55296)+n-56320+65536:r}function Ue(e){return/^\n* /.test(e)}function Ve(e,t,n,r,o,a,i,u){var s,c,l=0,f=null,p=!1,h=!1,d=-1!==r,m=-1,v=Be(c=qe(e,0))&&c!==je&&!Le(c)&&45!==c&&63!==c&&58!==c&&44!==c&&91!==c&&93!==c&&123!==c&&125!==c&&35!==c&&38!==c&&42!==c&&33!==c&&124!==c&&61!==c&&62!==c&&39!==c&&34!==c&&37!==c&&64!==c&&96!==c&&function(e){return!Le(e)&&58!==e}(qe(e,e.length-1));if(t||i)for(s=0;s=65536?s+=2:s++){if(!Be(l=qe(e,s)))return 5;v=v&&ze(l,f,u),f=l}else{for(s=0;s=65536?s+=2:s++){if(10===(l=qe(e,s)))p=!0,d&&(h=h||s-m-1>r&&" "!==e[m+1],m=s);else if(!Be(l))return 5;v=v&&ze(l,f,u),f=l}h=h||d&&s-m-1>r&&" "!==e[m+1]}return p||h?n>9&&Ue(e)?5:i?2===a?5:2:h?4:3:!v||i||o(e)?2===a?5:2:1}function We(e,t,n,r,o){e.dump=function(){if(0===t.length)return 2===e.quotingType?'""':"''";if(!e.noCompatMode&&(-1!==Ie.indexOf(t)||Ne.test(t)))return 2===e.quotingType?'"'+t+'"':"'"+t+"'";var a=e.indent*Math.max(1,n),i=-1===e.lineWidth?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-a),s=r||e.flowLevel>-1&&n>=e.flowLevel;switch(Ve(t,s,e.indent,i,(function(t){return function(e,t){var n,r;for(n=0,r=e.implicitTypes.length;n"+He(t,e.indent)+$e(Re(function(e,t){var n,r,o=/(\n+)([^\n]*)/g,a=(u=e.indexOf("\n"),u=-1!==u?u:e.length,o.lastIndex=u,Je(e.slice(0,u),t)),i="\n"===e[0]||" "===e[0];var u;for(;r=o.exec(e);){var s=r[1],c=r[2];n=" "===c[0],a+=s+(i||n||""===c?"":"\n")+Je(c,t),i=n}return a}(t,i),a));case 5:return'"'+function(e){for(var t,n="",r=0,o=0;o=65536?o+=2:o++)r=qe(e,o),!(t=Te[r])&&Be(r)?(n+=e[o],r>=65536&&(n+=e[o+1])):n+=t||Pe(r);return n}(t)+'"';default:throw new u("impossible error: invalid scalar style")}}()}function He(e,t){var n=Ue(e)?String(t):"",r="\n"===e[e.length-1];return n+(r&&("\n"===e[e.length-2]||"\n"===e)?"+":r?"":"-")+"\n"}function $e(e){return"\n"===e[e.length-1]?e.slice(0,-1):e}function Je(e,t){if(""===e||" "===e[0])return e;for(var n,r,o=/ [^ ]/g,a=0,i=0,u=0,s="";n=o.exec(e);)(u=n.index)-a>t&&(r=i>a?i:u,s+="\n"+e.slice(a,r),a=r+1),i=u;return s+="\n",e.length-a>t&&i>a?s+=e.slice(a,i)+"\n"+e.slice(i+1):s+=e.slice(a),s.slice(1)}function Ke(e,t,n,r){var o,a,i,u="",s=e.tag;for(o=0,a=n.length;o tag resolver accepts not "'+c+'" style');r=s.represent[c](t,c)}e.dump=r}return!0}return!1}function Ge(e,t,n,r,o,a,i){e.tag=null,e.dump=n,Ye(e,n,!1)||Ye(e,n,!0);var s,c=Oe.call(e.dump),l=r;r&&(r=e.flowLevel<0||e.flowLevel>t);var f,p,h="[object Object]"===c||"[object Array]"===c;if(h&&(p=-1!==(f=e.duplicates.indexOf(n))),(null!==e.tag&&"?"!==e.tag||p||2!==e.indent&&t>0)&&(o=!1),p&&e.usedDuplicates[f])e.dump="*ref_"+f;else{if(h&&p&&!e.usedDuplicates[f]&&(e.usedDuplicates[f]=!0),"[object Object]"===c)r&&0!==Object.keys(e.dump).length?(!function(e,t,n,r){var o,a,i,s,c,l,f="",p=e.tag,h=Object.keys(n);if(!0===e.sortKeys)h.sort();else if("function"==typeof e.sortKeys)h.sort(e.sortKeys);else if(e.sortKeys)throw new u("sortKeys must be a boolean or a function");for(o=0,a=h.length;o1024)&&(e.dump&&10===e.dump.charCodeAt(0)?l+="?":l+="? "),l+=e.dump,c&&(l+=De(e,t)),Ge(e,t+1,s,!0,c)&&(e.dump&&10===e.dump.charCodeAt(0)?l+=":":l+=": ",f+=l+=e.dump));e.tag=p,e.dump=f||"{}"}(e,t,e.dump,o),p&&(e.dump="&ref_"+f+e.dump)):(!function(e,t,n){var r,o,a,i,u,s="",c=e.tag,l=Object.keys(n);for(r=0,o=l.length;r1024&&(u+="? "),u+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),Ge(e,t,i,!1,!1)&&(s+=u+=e.dump));e.tag=c,e.dump="{"+s+"}"}(e,t,e.dump),p&&(e.dump="&ref_"+f+" "+e.dump));else if("[object Array]"===c)r&&0!==e.dump.length?(e.noArrayIndent&&!i&&t>0?Ke(e,t-1,e.dump,o):Ke(e,t,e.dump,o),p&&(e.dump="&ref_"+f+e.dump)):(!function(e,t,n){var r,o,a,i="",u=e.tag;for(r=0,o=n.length;r",e.dump=s+" "+e.dump)}return!0}function Qe(e,t){var n,r,o=[],a=[];for(Ze(e,o,a),n=0,r=a.length;n=t.length?(e.target=void 0,{value:void 0,done:!0}):"keys"==n?{value:r,done:!1}:"values"==n?{value:t[r],done:!1}:{value:[r,t[r]],done:!1}}),"values"),a.Arguments=a.Array,o("keys"),o("values"),o("entries")},function(e,t){e.exports=function(e){return null!=e&&"object"==typeof e}},function(e,t,n){"use strict";(function(t){function n(e){return e instanceof t||e instanceof Date||e instanceof RegExp}function r(e){if(e instanceof t){var n=t.alloc?t.alloc(e.length):new t(e.length);return e.copy(n),n}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e);throw new Error("Unexpected situation")}function o(e){var t=[];return e.forEach((function(e,a){"object"==typeof e&&null!==e?Array.isArray(e)?t[a]=o(e):n(e)?t[a]=r(e):t[a]=i({},e):t[a]=e})),t}function a(e,t){return"__proto__"===t?void 0:e[t]}var i=e.exports=function(){if(arguments.length<1||"object"!=typeof arguments[0])return!1;if(arguments.length<2)return arguments[0];var e,t,u=arguments[0],s=Array.prototype.slice.call(arguments,1);return s.forEach((function(s){"object"!=typeof s||null===s||Array.isArray(s)||Object.keys(s).forEach((function(c){return t=a(u,c),(e=a(s,c))===u?void 0:"object"!=typeof e||null===e?void(u[c]=e):Array.isArray(e)?void(u[c]=o(e)):n(e)?void(u[c]=r(e)):"object"!=typeof t||null===t||Array.isArray(t)?void(u[c]=i({},e)):void(u[c]=i(t,e))}))})),u}}).call(this,n(132).Buffer)},function(e,t,n){e.exports=n(619)},function(e,t,n){"use strict";var r=n(946),o=n(947);function a(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}t.parse=b,t.resolve=function(e,t){return b(e,!1,!0).resolve(t)},t.resolveObject=function(e,t){return e?b(e,!1,!0).resolveObject(t):t},t.format=function(e){o.isString(e)&&(e=b(e));return e instanceof a?e.format():a.prototype.format.call(e)},t.Url=a;var i=/^([a-z0-9.+-]+:)/i,u=/:[0-9]*$/,s=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,c=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),l=["'"].concat(c),f=["%","/","?",";","#"].concat(l),p=["/","?","#"],h=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,m={javascript:!0,"javascript:":!0},v={javascript:!0,"javascript:":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},y=n(948);function b(e,t,n){if(e&&o.isObject(e)&&e instanceof a)return e;var r=new a;return r.parse(e,t,n),r}a.prototype.parse=function(e,t,n){if(!o.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var a=e.indexOf("?"),u=-1!==a&&a127?P+="x":P+=N[M];if(!P.match(h)){var D=T.slice(0,O),L=T.slice(O+1),B=N.match(d);B&&(D.push(B[1]),L.unshift(B[2])),L.length&&(b="/"+L.join(".")+b),this.hostname=D.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),j||(this.hostname=r.toASCII(this.hostname));var F=this.port?":"+this.port:"",z=this.hostname||"";this.host=z+F,this.href+=this.host,j&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==b[0]&&(b="/"+b))}if(!m[_])for(O=0,I=l.length;O0)&&n.host.split("@"))&&(n.auth=j.shift(),n.host=n.hostname=j.shift());return n.search=e.search,n.query=e.query,o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!E.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var k=E.slice(-1)[0],A=(n.host||e.host||E.length>1)&&("."===k||".."===k)||""===k,O=0,C=E.length;C>=0;C--)"."===(k=E[C])?E.splice(C,1):".."===k?(E.splice(C,1),O++):O&&(E.splice(C,1),O--);if(!x&&!_)for(;O--;O)E.unshift("..");!x||""===E[0]||E[0]&&"/"===E[0].charAt(0)||E.unshift(""),A&&"/"!==E.join("/").substr(-1)&&E.push("");var j,T=""===E[0]||E[0]&&"/"===E[0].charAt(0);S&&(n.hostname=n.host=T?"":E.length?E.shift():"",(j=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=j.shift(),n.host=n.hostname=j.shift()));return(x=x||n.host&&E.length)&&!T&&E.unshift(""),E.length?n.pathname=E.join("/"):(n.pathname=null,n.path=null),o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},a.prototype.parseHost=function(){var e=this.host,t=u.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},function(e,t,n){"use strict";n.r(t),n.d(t,"SHOW_AUTH_POPUP",(function(){return h})),n.d(t,"AUTHORIZE",(function(){return d})),n.d(t,"LOGOUT",(function(){return m})),n.d(t,"PRE_AUTHORIZE_OAUTH2",(function(){return v})),n.d(t,"AUTHORIZE_OAUTH2",(function(){return g})),n.d(t,"VALIDATE",(function(){return y})),n.d(t,"CONFIGURE_AUTH",(function(){return b})),n.d(t,"RESTORE_AUTHORIZATION",(function(){return w})),n.d(t,"showDefinitions",(function(){return x})),n.d(t,"authorize",(function(){return _})),n.d(t,"authorizeWithPersistOption",(function(){return E})),n.d(t,"logout",(function(){return S})),n.d(t,"logoutWithPersistOption",(function(){return k})),n.d(t,"preAuthorizeImplicit",(function(){return A})),n.d(t,"authorizeOauth2",(function(){return O})),n.d(t,"authorizeOauth2WithPersistOption",(function(){return C})),n.d(t,"authorizePassword",(function(){return j})),n.d(t,"authorizeApplication",(function(){return T})),n.d(t,"authorizeAccessCodeWithFormParams",(function(){return I})),n.d(t,"authorizeAccessCodeWithBasicAuthentication",(function(){return N})),n.d(t,"authorizeRequest",(function(){return P})),n.d(t,"configureAuth",(function(){return M})),n.d(t,"restoreAuthorization",(function(){return R})),n.d(t,"persistAuthorizationIfNeeded",(function(){return D}));var r=n(19),o=n.n(r),a=n(32),i=n.n(a),u=n(21),s=n.n(u),c=n(89),l=n.n(c),f=n(26),p=n(5),h="show_popup",d="authorize",m="logout",v="pre_authorize_oauth2",g="authorize_oauth2",y="validate",b="configure_auth",w="restore_authorization";function x(e){return{type:h,payload:e}}function _(e){return{type:d,payload:e}}var E=function(e){return function(t){var n=t.authActions;n.authorize(e),n.persistAuthorizationIfNeeded()}};function S(e){return{type:m,payload:e}}var k=function(e){return function(t){var n=t.authActions;n.logout(e),n.persistAuthorizationIfNeeded()}},A=function(e){return function(t){var n=t.authActions,r=t.errActions,o=e.auth,a=e.token,u=e.isValid,s=o.schema,c=o.name,l=s.get("flow");delete f.a.swaggerUIRedirectOauth2,"accessCode"===l||u||r.newAuthErr({authId:c,source:"auth",level:"warning",message:"Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server"}),a.error?r.newAuthErr({authId:c,source:"auth",level:"error",message:i()(a)}):n.authorizeOauth2WithPersistOption({auth:o,token:a})}};function O(e){return{type:g,payload:e}}var C=function(e){return function(t){var n=t.authActions;n.authorizeOauth2(e),n.persistAuthorizationIfNeeded()}},j=function(e){return function(t){var n=t.authActions,r=e.schema,o=e.name,a=e.username,i=e.password,u=e.passwordType,c=e.clientId,l=e.clientSecret,f={grant_type:"password",scope:e.scopes.join(" "),username:a,password:i},h={};switch(u){case"request-body":!function(e,t,n){t&&s()(e,{client_id:t});n&&s()(e,{client_secret:n})}(f,c,l);break;case"basic":h.Authorization="Basic "+Object(p.a)(c+":"+l);break;default:console.warn("Warning: invalid passwordType ".concat(u," was passed, not including client id and secret"))}return n.authorizeRequest({body:Object(p.b)(f),url:r.get("tokenUrl"),name:o,headers:h,query:{},auth:e})}};var T=function(e){return function(t){var n=t.authActions,r=e.schema,o=e.scopes,a=e.name,i=e.clientId,u=e.clientSecret,s={Authorization:"Basic "+Object(p.a)(i+":"+u)},c={grant_type:"client_credentials",scope:o.join(" ")};return n.authorizeRequest({body:Object(p.b)(c),name:a,url:r.get("tokenUrl"),auth:e,headers:s})}},I=function(e){var t=e.auth,n=e.redirectUrl;return function(e){var r=e.authActions,o=t.schema,a=t.name,i=t.clientId,u=t.clientSecret,s=t.codeVerifier,c={grant_type:"authorization_code",code:t.code,client_id:i,client_secret:u,redirect_uri:n,code_verifier:s};return r.authorizeRequest({body:Object(p.b)(c),name:a,url:o.get("tokenUrl"),auth:t})}},N=function(e){var t=e.auth,n=e.redirectUrl;return function(e){var r=e.authActions,o=t.schema,a=t.name,i=t.clientId,u=t.clientSecret,s=t.codeVerifier,c={Authorization:"Basic "+Object(p.a)(i+":"+u)},l={grant_type:"authorization_code",code:t.code,client_id:i,redirect_uri:n,code_verifier:s};return r.authorizeRequest({body:Object(p.b)(l),name:a,url:o.get("tokenUrl"),auth:t,headers:c})}},P=function(e){return function(t){var n,r=t.fn,a=t.getConfigs,u=t.authActions,c=t.errActions,f=t.oas3Selectors,p=t.specSelectors,h=t.authSelectors,d=e.body,m=e.query,v=void 0===m?{}:m,g=e.headers,y=void 0===g?{}:g,b=e.name,w=e.url,x=e.auth,_=(h.getConfigs()||{}).additionalQueryStringParams;if(p.isOAS3()){var E=f.serverEffectiveValue(f.selectedServer());n=l()(w,E,!0)}else n=l()(w,p.url(),!0);"object"===o()(_)&&(n.query=s()({},n.query,_));var S=n.toString(),k=s()({Accept:"application/json, text/plain, */*","Content-Type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"},y);r.fetch({url:S,method:"post",headers:k,query:v,body:d,requestInterceptor:a().requestInterceptor,responseInterceptor:a().responseInterceptor}).then((function(e){var t=JSON.parse(e.data),n=t&&(t.error||""),r=t&&(t.parseError||"");e.ok?n||r?c.newAuthErr({authId:b,level:"error",source:"auth",message:i()(t)}):u.authorizeOauth2WithPersistOption({auth:x,token:t}):c.newAuthErr({authId:b,level:"error",source:"auth",message:e.statusText})})).catch((function(e){var t=new Error(e).message;if(e.response&&e.response.data){var n=e.response.data;try{var r="string"==typeof n?JSON.parse(n):n;r.error&&(t+=", error: ".concat(r.error)),r.error_description&&(t+=", description: ".concat(r.error_description))}catch(e){}}c.newAuthErr({authId:b,level:"error",source:"auth",message:t})}))}};function M(e){return{type:b,payload:e}}function R(e){return{type:w,payload:e}}var D=function(){return function(e){var t=e.authSelectors;if((0,e.getConfigs)().persistAuthorization){var n=t.authorized();localStorage.setItem("authorized",i()(n.toJS()))}}}},function(e,t,n){var r=n(919);e.exports=function(e){for(var t=1;tS;S++)if((h||S in x)&&(b=_(y=x[S],S,w),e))if(t)A[S]=b;else if(b)switch(e){case 3:return!0;case 5:return y;case 6:return S;case 2:c(A,y)}else switch(e){case 4:return!1;case 7:c(A,y)}return f?-1:o||l?l:A}};e.exports={forEach:l(0),map:l(1),filter:l(2),some:l(3),every:l(4),find:l(5),findIndex:l(6),filterReject:l(7)}},function(e,t,n){"use strict";n.r(t),n.d(t,"lastError",(function(){return M})),n.d(t,"url",(function(){return R})),n.d(t,"specStr",(function(){return D})),n.d(t,"specSource",(function(){return L})),n.d(t,"specJson",(function(){return B})),n.d(t,"specResolved",(function(){return F})),n.d(t,"specResolvedSubtree",(function(){return z})),n.d(t,"specJsonWithResolvedSubtrees",(function(){return U})),n.d(t,"spec",(function(){return V})),n.d(t,"isOAS3",(function(){return W})),n.d(t,"info",(function(){return H})),n.d(t,"externalDocs",(function(){return $})),n.d(t,"version",(function(){return J})),n.d(t,"semver",(function(){return K})),n.d(t,"paths",(function(){return Y})),n.d(t,"operations",(function(){return G})),n.d(t,"consumes",(function(){return Q})),n.d(t,"produces",(function(){return Z})),n.d(t,"security",(function(){return X})),n.d(t,"securityDefinitions",(function(){return ee})),n.d(t,"findDefinition",(function(){return te})),n.d(t,"definitions",(function(){return ne})),n.d(t,"basePath",(function(){return re})),n.d(t,"host",(function(){return oe})),n.d(t,"schemes",(function(){return ae})),n.d(t,"operationsWithRootInherited",(function(){return ie})),n.d(t,"tags",(function(){return ue})),n.d(t,"tagDetails",(function(){return se})),n.d(t,"operationsWithTags",(function(){return ce})),n.d(t,"taggedOperations",(function(){return le})),n.d(t,"responses",(function(){return fe})),n.d(t,"requests",(function(){return pe})),n.d(t,"mutatedRequests",(function(){return he})),n.d(t,"responseFor",(function(){return de})),n.d(t,"requestFor",(function(){return me})),n.d(t,"mutatedRequestFor",(function(){return ve})),n.d(t,"allowTryItOutFor",(function(){return ge})),n.d(t,"parameterWithMetaByIdentity",(function(){return ye})),n.d(t,"parameterInclusionSettingFor",(function(){return be})),n.d(t,"parameterWithMeta",(function(){return we})),n.d(t,"operationWithMeta",(function(){return xe})),n.d(t,"getParameter",(function(){return _e})),n.d(t,"hasHost",(function(){return Ee})),n.d(t,"parameterValues",(function(){return Se})),n.d(t,"parametersIncludeIn",(function(){return ke})),n.d(t,"parametersIncludeType",(function(){return Ae})),n.d(t,"contentTypeValues",(function(){return Oe})),n.d(t,"currentProducesFor",(function(){return Ce})),n.d(t,"producesOptionsFor",(function(){return je})),n.d(t,"consumesOptionsFor",(function(){return Te})),n.d(t,"operationScheme",(function(){return Ie})),n.d(t,"canExecuteScheme",(function(){return Ne})),n.d(t,"validateBeforeExecute",(function(){return Pe})),n.d(t,"getOAS3RequiredRequestBodyContentType",(function(){return Me})),n.d(t,"isMediaTypeSchemaPropertiesEqual",(function(){return Re}));var r=n(13),o=n.n(r),a=n(14),i=n.n(a),u=n(2),s=n.n(u),c=n(20),l=n.n(c),f=n(23),p=n.n(f),h=n(18),d=n.n(h),m=n(4),v=n.n(m),g=n(12),y=n.n(g),b=n(56),w=n.n(b),x=n(30),_=n.n(x),E=n(196),S=n.n(E),k=n(71),A=n.n(k),O=n(24),C=n.n(O),j=n(16),T=n(5),I=n(1),N=["get","put","post","delete","options","head","patch","trace"],P=function(e){return e||Object(I.Map)()},M=Object(j.a)(P,(function(e){return e.get("lastError")})),R=Object(j.a)(P,(function(e){return e.get("url")})),D=Object(j.a)(P,(function(e){return e.get("spec")||""})),L=Object(j.a)(P,(function(e){return e.get("specSource")||"not-editor"})),B=Object(j.a)(P,(function(e){return e.get("json",Object(I.Map)())})),F=Object(j.a)(P,(function(e){return e.get("resolved",Object(I.Map)())})),z=function(e,t){var n;return e.getIn(s()(n=["resolvedSubtrees"]).call(n,i()(t)),void 0)},q=function e(t,n){return I.Map.isMap(t)&&I.Map.isMap(n)?n.get("$$ref")?n:Object(I.OrderedMap)().mergeWith(e,t,n):n},U=Object(j.a)(P,(function(e){return Object(I.OrderedMap)().mergeWith(q,e.get("json"),e.get("resolvedSubtrees"))})),V=function(e){return B(e)},W=Object(j.a)(V,(function(){return!1})),H=Object(j.a)(V,(function(e){return De(e&&e.get("info"))})),$=Object(j.a)(V,(function(e){return De(e&&e.get("externalDocs"))})),J=Object(j.a)(H,(function(e){return e&&e.get("version")})),K=Object(j.a)(J,(function(e){var t;return l()(t=/v?([0-9]*)\.([0-9]*)\.([0-9]*)/i.exec(e)).call(t,1)})),Y=Object(j.a)(U,(function(e){return e.get("paths")})),G=Object(j.a)(Y,(function(e){if(!e||e.size<1)return Object(I.List)();var t=Object(I.List)();return e&&p()(e)?(p()(e).call(e,(function(e,n){if(!e||!p()(e))return{};p()(e).call(e,(function(e,r){var o;d()(N).call(N,r)<0||(t=t.push(Object(I.fromJS)({path:n,method:r,operation:e,id:s()(o="".concat(r,"-")).call(o,n)})))}))})),t):Object(I.List)()})),Q=Object(j.a)(V,(function(e){return Object(I.Set)(e.get("consumes"))})),Z=Object(j.a)(V,(function(e){return Object(I.Set)(e.get("produces"))})),X=Object(j.a)(V,(function(e){return e.get("security",Object(I.List)())})),ee=Object(j.a)(V,(function(e){return e.get("securityDefinitions")})),te=function(e,t){var n=e.getIn(["resolvedSubtrees","definitions",t],null),r=e.getIn(["json","definitions",t],null);return n||r||null},ne=Object(j.a)(V,(function(e){var t=e.get("definitions");return I.Map.isMap(t)?t:Object(I.Map)()})),re=Object(j.a)(V,(function(e){return e.get("basePath")})),oe=Object(j.a)(V,(function(e){return e.get("host")})),ae=Object(j.a)(V,(function(e){return e.get("schemes",Object(I.Map)())})),ie=Object(j.a)(G,Q,Z,(function(e,t,n){return v()(e).call(e,(function(e){return e.update("operation",(function(e){if(e){if(!I.Map.isMap(e))return;return e.withMutations((function(e){return e.get("consumes")||e.update("consumes",(function(e){return Object(I.Set)(e).merge(t)})),e.get("produces")||e.update("produces",(function(e){return Object(I.Set)(e).merge(n)})),e}))}return Object(I.Map)()}))}))})),ue=Object(j.a)(V,(function(e){var t=e.get("tags",Object(I.List)());return I.List.isList(t)?y()(t).call(t,(function(e){return I.Map.isMap(e)})):Object(I.List)()})),se=function(e,t){var n,r=ue(e)||Object(I.List)();return w()(n=y()(r).call(r,I.Map.isMap)).call(n,(function(e){return e.get("name")===t}),Object(I.Map)())},ce=Object(j.a)(ie,ue,(function(e,t){return _()(e).call(e,(function(e,t){var n=Object(I.Set)(t.getIn(["operation","tags"]));return n.count()<1?e.update("default",Object(I.List)(),(function(e){return e.push(t)})):_()(n).call(n,(function(e,n){return e.update(n,Object(I.List)(),(function(e){return e.push(t)}))}),e)}),_()(t).call(t,(function(e,t){return e.set(t.get("name"),Object(I.List)())}),Object(I.OrderedMap)()))})),le=function(e){return function(t){var n,r=(0,t.getConfigs)(),o=r.tagsSorter,a=r.operationsSorter;return v()(n=ce(e).sortBy((function(e,t){return t}),(function(e,t){var n="function"==typeof o?o:T.H.tagsSorter[o];return n?n(e,t):null}))).call(n,(function(t,n){var r="function"==typeof a?a:T.H.operationsSorter[a],o=r?S()(t).call(t,r):t;return Object(I.Map)({tagDetails:se(e,n),operations:o})}))}},fe=Object(j.a)(P,(function(e){return e.get("responses",Object(I.Map)())})),pe=Object(j.a)(P,(function(e){return e.get("requests",Object(I.Map)())})),he=Object(j.a)(P,(function(e){return e.get("mutatedRequests",Object(I.Map)())})),de=function(e,t,n){return fe(e).getIn([t,n],null)},me=function(e,t,n){return pe(e).getIn([t,n],null)},ve=function(e,t,n){return he(e).getIn([t,n],null)},ge=function(){return!0},ye=function(e,t,n){var r,o,a=U(e).getIn(s()(r=["paths"]).call(r,i()(t),["parameters"]),Object(I.OrderedMap)()),u=e.getIn(s()(o=["meta","paths"]).call(o,i()(t),["parameters"]),Object(I.OrderedMap)()),c=v()(a).call(a,(function(e){var t,r,o,a=u.get(s()(t="".concat(n.get("in"),".")).call(t,n.get("name"))),i=u.get(s()(r=s()(o="".concat(n.get("in"),".")).call(o,n.get("name"),".hash-")).call(r,n.hashCode()));return Object(I.OrderedMap)().merge(e,a,i)}));return w()(c).call(c,(function(e){return e.get("in")===n.get("in")&&e.get("name")===n.get("name")}),Object(I.OrderedMap)())},be=function(e,t,n,r){var o,a,u=s()(o="".concat(r,".")).call(o,n);return e.getIn(s()(a=["meta","paths"]).call(a,i()(t),["parameter_inclusions",u]),!1)},we=function(e,t,n,r){var o,a=U(e).getIn(s()(o=["paths"]).call(o,i()(t),["parameters"]),Object(I.OrderedMap)()),u=w()(a).call(a,(function(e){return e.get("in")===r&&e.get("name")===n}),Object(I.OrderedMap)());return ye(e,t,u)},xe=function(e,t,n){var r,o=U(e).getIn(["paths",t,n],Object(I.OrderedMap)()),a=e.getIn(["meta","paths",t,n],Object(I.OrderedMap)()),i=v()(r=o.get("parameters",Object(I.List)())).call(r,(function(r){return ye(e,[t,n],r)}));return Object(I.OrderedMap)().merge(o,a).set("parameters",i)};function _e(e,t,n,r){var o;t=t||[];var a=e.getIn(s()(o=["meta","paths"]).call(o,i()(t),["parameters"]),Object(I.fromJS)([]));return w()(a).call(a,(function(e){return I.Map.isMap(e)&&e.get("name")===n&&e.get("in")===r}))||Object(I.Map)()}var Ee=Object(j.a)(V,(function(e){var t=e.get("host");return"string"==typeof t&&t.length>0&&"/"!==t[0]}));function Se(e,t,n){var r;t=t||[];var o=xe.apply(void 0,s()(r=[e]).call(r,i()(t))).get("parameters",Object(I.List)());return _()(o).call(o,(function(e,t){var r=n&&"body"===t.get("in")?t.get("value_xml"):t.get("value");return e.set(Object(T.A)(t,{allowHashes:!1}),r)}),Object(I.fromJS)({}))}function ke(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(I.List.isList(e))return A()(e).call(e,(function(e){return I.Map.isMap(e)&&e.get("in")===t}))}function Ae(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(I.List.isList(e))return A()(e).call(e,(function(e){return I.Map.isMap(e)&&e.get("type")===t}))}function Oe(e,t){var n,r;t=t||[];var o=U(e).getIn(s()(n=["paths"]).call(n,i()(t)),Object(I.fromJS)({})),a=e.getIn(s()(r=["meta","paths"]).call(r,i()(t)),Object(I.fromJS)({})),u=Ce(e,t),c=o.get("parameters")||new I.List,l=a.get("consumes_value")?a.get("consumes_value"):Ae(c,"file")?"multipart/form-data":Ae(c,"formData")?"application/x-www-form-urlencoded":void 0;return Object(I.fromJS)({requestContentType:l,responseContentType:u})}function Ce(e,t){var n,r;t=t||[];var o=U(e).getIn(s()(n=["paths"]).call(n,i()(t)),null);if(null!==o){var a=e.getIn(s()(r=["meta","paths"]).call(r,i()(t),["produces_value"]),null),u=o.getIn(["produces",0],null);return a||u||"application/json"}}function je(e,t){var n;t=t||[];var r=U(e),a=r.getIn(s()(n=["paths"]).call(n,i()(t)),null);if(null!==a){var u=t,c=o()(u,1)[0],l=a.get("produces",null),f=r.getIn(["paths",c,"produces"],null),p=r.getIn(["produces"],null);return l||f||p}}function Te(e,t){var n;t=t||[];var r=U(e),a=r.getIn(s()(n=["paths"]).call(n,i()(t)),null);if(null!==a){var u=t,c=o()(u,1)[0],l=a.get("consumes",null),f=r.getIn(["paths",c,"consumes"],null),p=r.getIn(["consumes"],null);return l||f||p}}var Ie=function(e,t,n){var r=e.get("url").match(/^([a-z][a-z0-9+\-.]*):/),o=C()(r)?r[1]:null;return e.getIn(["scheme",t,n])||e.getIn(["scheme","_defaultScheme"])||o||""},Ne=function(e,t,n){var r;return d()(r=["http","https"]).call(r,Ie(e,t,n))>-1},Pe=function(e,t){var n;t=t||[];var r=e.getIn(s()(n=["meta","paths"]).call(n,i()(t),["parameters"]),Object(I.fromJS)([])),o=!0;return p()(r).call(r,(function(e){var t=e.get("errors");t&&t.count()&&(o=!1)})),o},Me=function(e,t){var n,r,o={requestBody:!1,requestContentType:{}},a=e.getIn(s()(n=["resolvedSubtrees","paths"]).call(n,i()(t),["requestBody"]),Object(I.fromJS)([]));return a.size<1||(a.getIn(["required"])&&(o.requestBody=a.getIn(["required"])),p()(r=a.getIn(["content"]).entrySeq()).call(r,(function(e){var t=e[0];if(e[1].getIn(["schema","required"])){var n=e[1].getIn(["schema","required"]).toJS();o.requestContentType[t]=n}}))),o},Re=function(e,t,n,r){var o;if((n||r)&&n===r)return!0;var a=e.getIn(s()(o=["resolvedSubtrees","paths"]).call(o,i()(t),["requestBody","content"]),Object(I.fromJS)([]));if(a.size<2||!n||!r)return!1;var u=a.getIn([n,"schema","properties"],Object(I.fromJS)([])),c=a.getIn([r,"schema","properties"],Object(I.fromJS)([]));return!!u.equals(c)};function De(e){return I.Map.isMap(e)?e:new I.Map}},function(e,t,n){"use strict";(function(t){var r=n(847),o=n(848),a=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,i=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,u=/^[a-zA-Z]:/,s=new RegExp("^[\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\xA0\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF]+");function c(e){return(e||"").toString().replace(s,"")}var l=[["#","hash"],["?","query"],function(e,t){return h(t.protocol)?e.replace(/\\/g,"/"):e},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d+)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],f={hash:1,query:1};function p(e){var n,r=("undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{}).location||{},o={},i=typeof(e=e||r);if("blob:"===e.protocol)o=new m(unescape(e.pathname),{});else if("string"===i)for(n in o=new m(e,{}),f)delete o[n];else if("object"===i){for(n in e)n in f||(o[n]=e[n]);void 0===o.slashes&&(o.slashes=a.test(e.href))}return o}function h(e){return"file:"===e||"ftp:"===e||"http:"===e||"https:"===e||"ws:"===e||"wss:"===e}function d(e,t){e=c(e),t=t||{};var n,r=i.exec(e),o=r[1]?r[1].toLowerCase():"",a=!!r[2],u=!!r[3],s=0;return a?u?(n=r[2]+r[3]+r[4],s=r[2].length+r[3].length):(n=r[2]+r[4],s=r[2].length):u?(n=r[3]+r[4],s=r[3].length):n=r[4],"file:"===o?s>=2&&(n=n.slice(2)):h(o)?n=r[4]:o?a&&(n=n.slice(2)):s>=2&&h(t.protocol)&&(n=r[4]),{protocol:o,slashes:a||h(o),slashesCount:s,rest:n}}function m(e,t,n){if(e=c(e),!(this instanceof m))return new m(e,t,n);var a,i,s,f,v,g,y=l.slice(),b=typeof t,w=this,x=0;for("object"!==b&&"string"!==b&&(n=t,t=null),n&&"function"!=typeof n&&(n=o.parse),a=!(i=d(e||"",t=p(t))).protocol&&!i.slashes,w.slashes=i.slashes||a&&t.slashes,w.protocol=i.protocol||t.protocol||"",e=i.rest,("file:"===i.protocol&&(2!==i.slashesCount||u.test(e))||!i.slashes&&(i.protocol||i.slashesCount<2||!h(w.protocol)))&&(y[3]=[/(.*)/,"pathname"]);x=4?[t[0],t[1],t[2],t[3],"".concat(t[0],".").concat(t[1]),"".concat(t[0],".").concat(t[2]),"".concat(t[0],".").concat(t[3]),"".concat(t[1],".").concat(t[0]),"".concat(t[1],".").concat(t[2]),"".concat(t[1],".").concat(t[3]),"".concat(t[2],".").concat(t[0]),"".concat(t[2],".").concat(t[1]),"".concat(t[2],".").concat(t[3]),"".concat(t[3],".").concat(t[0]),"".concat(t[3],".").concat(t[1]),"".concat(t[3],".").concat(t[2]),"".concat(t[0],".").concat(t[1],".").concat(t[2]),"".concat(t[0],".").concat(t[1],".").concat(t[3]),"".concat(t[0],".").concat(t[2],".").concat(t[1]),"".concat(t[0],".").concat(t[2],".").concat(t[3]),"".concat(t[0],".").concat(t[3],".").concat(t[1]),"".concat(t[0],".").concat(t[3],".").concat(t[2]),"".concat(t[1],".").concat(t[0],".").concat(t[2]),"".concat(t[1],".").concat(t[0],".").concat(t[3]),"".concat(t[1],".").concat(t[2],".").concat(t[0]),"".concat(t[1],".").concat(t[2],".").concat(t[3]),"".concat(t[1],".").concat(t[3],".").concat(t[0]),"".concat(t[1],".").concat(t[3],".").concat(t[2]),"".concat(t[2],".").concat(t[0],".").concat(t[1]),"".concat(t[2],".").concat(t[0],".").concat(t[3]),"".concat(t[2],".").concat(t[1],".").concat(t[0]),"".concat(t[2],".").concat(t[1],".").concat(t[3]),"".concat(t[2],".").concat(t[3],".").concat(t[0]),"".concat(t[2],".").concat(t[3],".").concat(t[1]),"".concat(t[3],".").concat(t[0],".").concat(t[1]),"".concat(t[3],".").concat(t[0],".").concat(t[2]),"".concat(t[3],".").concat(t[1],".").concat(t[0]),"".concat(t[3],".").concat(t[1],".").concat(t[2]),"".concat(t[3],".").concat(t[2],".").concat(t[0]),"".concat(t[3],".").concat(t[2],".").concat(t[1]),"".concat(t[0],".").concat(t[1],".").concat(t[2],".").concat(t[3]),"".concat(t[0],".").concat(t[1],".").concat(t[3],".").concat(t[2]),"".concat(t[0],".").concat(t[2],".").concat(t[1],".").concat(t[3]),"".concat(t[0],".").concat(t[2],".").concat(t[3],".").concat(t[1]),"".concat(t[0],".").concat(t[3],".").concat(t[1],".").concat(t[2]),"".concat(t[0],".").concat(t[3],".").concat(t[2],".").concat(t[1]),"".concat(t[1],".").concat(t[0],".").concat(t[2],".").concat(t[3]),"".concat(t[1],".").concat(t[0],".").concat(t[3],".").concat(t[2]),"".concat(t[1],".").concat(t[2],".").concat(t[0],".").concat(t[3]),"".concat(t[1],".").concat(t[2],".").concat(t[3],".").concat(t[0]),"".concat(t[1],".").concat(t[3],".").concat(t[0],".").concat(t[2]),"".concat(t[1],".").concat(t[3],".").concat(t[2],".").concat(t[0]),"".concat(t[2],".").concat(t[0],".").concat(t[1],".").concat(t[3]),"".concat(t[2],".").concat(t[0],".").concat(t[3],".").concat(t[1]),"".concat(t[2],".").concat(t[1],".").concat(t[0],".").concat(t[3]),"".concat(t[2],".").concat(t[1],".").concat(t[3],".").concat(t[0]),"".concat(t[2],".").concat(t[3],".").concat(t[0],".").concat(t[1]),"".concat(t[2],".").concat(t[3],".").concat(t[1],".").concat(t[0]),"".concat(t[3],".").concat(t[0],".").concat(t[1],".").concat(t[2]),"".concat(t[3],".").concat(t[0],".").concat(t[2],".").concat(t[1]),"".concat(t[3],".").concat(t[1],".").concat(t[0],".").concat(t[2]),"".concat(t[3],".").concat(t[1],".").concat(t[2],".").concat(t[0]),"".concat(t[3],".").concat(t[2],".").concat(t[0],".").concat(t[1]),"".concat(t[3],".").concat(t[2],".").concat(t[1],".").concat(t[0])]:void 0),g[r]}function b(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,r=e.filter((function(e){return"token"!==e})),o=y(r);return o.reduce((function(e,t){return p()({},e,n[t])}),t)}function w(e){return e.join(" ")}function x(e){var t=e.node,n=e.stylesheet,r=e.style,o=void 0===r?{}:r,a=e.useInlineStyles,i=e.key,u=t.properties,s=t.type,c=t.tagName,l=t.value;if("text"===s)return l;if(c){var f,h=function(e,t){var n=0;return function(r){return n+=1,r.map((function(r,o){return x({node:r,stylesheet:e,useInlineStyles:t,key:"code-segment-".concat(n,"-").concat(o)})}))}}(n,a);if(a){var m=Object.keys(n).reduce((function(e,t){return t.split(".").forEach((function(t){e.includes(t)||e.push(t)})),e}),[]),g=u.className&&u.className.includes("token")?["token"]:[],y=u.className&&g.concat(u.className.filter((function(e){return!m.includes(e)})));f=p()({},u,{className:w(y)||void 0,style:b(u.className,Object.assign({},u.style,o),n)})}else f=p()({},u,{className:w(u.className)});var _=h(t.children);return d.a.createElement(c,v()({key:i},f),_)}}var _=/\n/g;function E(e){var t=e.codeString,n=e.codeStyle,r=e.containerStyle,o=void 0===r?{float:"left",paddingRight:"10px"}:r,a=e.numberStyle,i=void 0===a?{}:a,u=e.startingLineNumber;return d.a.createElement("code",{style:Object.assign({},n,o)},function(e){var t=e.lines,n=e.startingLineNumber,r=e.style;return t.map((function(e,t){var o=t+n;return d.a.createElement("span",{key:"line-".concat(t),className:"react-syntax-highlighter-line-number",style:"function"==typeof r?r(o):r},"".concat(o,"\n"))}))}({lines:t.replace(/\n$/,"").split("\n"),style:i,startingLineNumber:u}))}function S(e,t){return{type:"element",tagName:"span",properties:{key:"line-number--".concat(e),className:["comment","linenumber","react-syntax-highlighter-line-number"],style:t},children:[{type:"text",value:e}]}}function k(e,t,n){var r,o={display:"inline-block",minWidth:(r=n,"".concat(r.toString().length,".25em")),paddingRight:"1em",textAlign:"right",userSelect:"none"},a="function"==typeof e?e(t):e;return p()({},o,a)}function A(e){var t=e.children,n=e.lineNumber,r=e.lineNumberStyle,o=e.largestLineNumber,a=e.showInlineLineNumbers,i=e.lineProps,u=void 0===i?{}:i,s=e.className,c=void 0===s?[]:s,l=e.showLineNumbers,f=e.wrapLongLines,h="function"==typeof u?u(n):u;if(h.className=c,n&&a){var d=k(r,n,o);t.unshift(S(n,d))}return f&l&&(h.style=p()({},h.style,{display:"flex"})),{type:"element",tagName:"span",properties:h,children:t}}function O(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=0;r2&&void 0!==arguments[2]?arguments[2]:[];return A({children:e,lineNumber:t,lineNumberStyle:u,largestLineNumber:i,showInlineLineNumbers:o,lineProps:n,className:a,showLineNumbers:r,wrapLongLines:s})}function m(e,t){if(r&&t&&o){var n=k(u,t,i);e.unshift(S(t,n))}return e}function v(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return t||r.length>0?d(e,n,r):m(e,n)}for(var g=function(){var e=l[h],t=e.children[0].value;if(t.match(_)){var n=t.split("\n");n.forEach((function(t,o){var i=r&&f.length+a,u={type:"text",value:"".concat(t,"\n")};if(0===o){var s=v(l.slice(p+1,h).concat(A({children:[u],className:e.properties.className})),i);f.push(s)}else if(o===n.length-1){if(l[h+1]&&l[h+1].children&&l[h+1].children[0]){var c=A({children:[{type:"text",value:"".concat(t)}],className:e.properties.className});l.splice(h+1,0,c)}else{var d=v([u],i,e.properties.className);f.push(d)}}else{var m=v([u],i,e.properties.className);f.push(m)}})),p=h}h++};h .hljs-title":{color:"#88C0D0"},"hljs-keyword":{color:"#81A1C1"},"hljs-literal":{color:"#81A1C1"},"hljs-symbol":{color:"#81A1C1"},"hljs-number":{color:"#B48EAD"},"hljs-regexp":{color:"#EBCB8B"},"hljs-string":{color:"#A3BE8C"},"hljs-title":{color:"#8FBCBB"},"hljs-params":{color:"#D8DEE9"},"hljs-bullet":{color:"#81A1C1"},"hljs-code":{color:"#8FBCBB"},"hljs-emphasis":{fontStyle:"italic"},"hljs-formula":{color:"#8FBCBB"},"hljs-strong":{fontWeight:"bold"},"hljs-link:hover":{textDecoration:"underline"},"hljs-quote":{color:"#4C566A"},"hljs-comment":{color:"#4C566A"},"hljs-doctag":{color:"#8FBCBB"},"hljs-meta":{color:"#5E81AC"},"hljs-meta-keyword":{color:"#5E81AC"},"hljs-meta-string":{color:"#A3BE8C"},"hljs-attr":{color:"#8FBCBB"},"hljs-attribute":{color:"#D8DEE9"},"hljs-builtin-name":{color:"#81A1C1"},"hljs-name":{color:"#81A1C1"},"hljs-section":{color:"#88C0D0"},"hljs-tag":{color:"#81A1C1"},"hljs-variable":{color:"#D8DEE9"},"hljs-template-variable":{color:"#D8DEE9"},"hljs-template-tag":{color:"#5E81AC"},"abnf .hljs-attribute":{color:"#88C0D0"},"abnf .hljs-symbol":{color:"#EBCB8B"},"apache .hljs-attribute":{color:"#88C0D0"},"apache .hljs-section":{color:"#81A1C1"},"arduino .hljs-built_in":{color:"#88C0D0"},"aspectj .hljs-meta":{color:"#D08770"},"aspectj > .hljs-title":{color:"#88C0D0"},"bnf .hljs-attribute":{color:"#8FBCBB"},"clojure .hljs-name":{color:"#88C0D0"},"clojure .hljs-symbol":{color:"#EBCB8B"},"coq .hljs-built_in":{color:"#88C0D0"},"cpp .hljs-meta-string":{color:"#8FBCBB"},"css .hljs-built_in":{color:"#88C0D0"},"css .hljs-keyword":{color:"#D08770"},"diff .hljs-meta":{color:"#8FBCBB"},"ebnf .hljs-attribute":{color:"#8FBCBB"},"glsl .hljs-built_in":{color:"#88C0D0"},"groovy .hljs-meta:not(:first-child)":{color:"#D08770"},"haxe .hljs-meta":{color:"#D08770"},"java .hljs-meta":{color:"#D08770"},"ldif .hljs-attribute":{color:"#8FBCBB"},"lisp .hljs-name":{color:"#88C0D0"},"lua .hljs-built_in":{color:"#88C0D0"},"moonscript .hljs-built_in":{color:"#88C0D0"},"nginx .hljs-attribute":{color:"#88C0D0"},"nginx .hljs-section":{color:"#5E81AC"},"pf .hljs-built_in":{color:"#88C0D0"},"processing .hljs-built_in":{color:"#88C0D0"},"scss .hljs-keyword":{color:"#81A1C1"},"stylus .hljs-keyword":{color:"#81A1C1"},"swift .hljs-meta":{color:"#D08770"},"vim .hljs-built_in":{color:"#88C0D0",fontStyle:"italic"},"yaml .hljs-meta":{color:"#D08770"}},obsidian:{hljs:{display:"block",overflowX:"auto",padding:"0.5em",background:"#282b2e",color:"#e0e2e4"},"hljs-keyword":{color:"#93c763",fontWeight:"bold"},"hljs-selector-tag":{color:"#93c763",fontWeight:"bold"},"hljs-literal":{color:"#93c763",fontWeight:"bold"},"hljs-selector-id":{color:"#93c763"},"hljs-number":{color:"#ffcd22"},"hljs-attribute":{color:"#668bb0"},"hljs-code":{color:"white"},"hljs-class .hljs-title":{color:"white"},"hljs-section":{color:"white",fontWeight:"bold"},"hljs-regexp":{color:"#d39745"},"hljs-link":{color:"#d39745"},"hljs-meta":{color:"#557182"},"hljs-tag":{color:"#8cbbad"},"hljs-name":{color:"#8cbbad",fontWeight:"bold"},"hljs-bullet":{color:"#8cbbad"},"hljs-subst":{color:"#8cbbad"},"hljs-emphasis":{color:"#8cbbad"},"hljs-type":{color:"#8cbbad",fontWeight:"bold"},"hljs-built_in":{color:"#8cbbad"},"hljs-selector-attr":{color:"#8cbbad"},"hljs-selector-pseudo":{color:"#8cbbad"},"hljs-addition":{color:"#8cbbad"},"hljs-variable":{color:"#8cbbad"},"hljs-template-tag":{color:"#8cbbad"},"hljs-template-variable":{color:"#8cbbad"},"hljs-string":{color:"#ec7600"},"hljs-symbol":{color:"#ec7600"},"hljs-comment":{color:"#818e96"},"hljs-quote":{color:"#818e96"},"hljs-deletion":{color:"#818e96"},"hljs-selector-class":{color:"#A082BD"},"hljs-doctag":{fontWeight:"bold"},"hljs-title":{fontWeight:"bold"},"hljs-strong":{fontWeight:"bold"}},"tomorrow-night":{"hljs-comment":{color:"#969896"},"hljs-quote":{color:"#969896"},"hljs-variable":{color:"#cc6666"},"hljs-template-variable":{color:"#cc6666"},"hljs-tag":{color:"#cc6666"},"hljs-name":{color:"#cc6666"},"hljs-selector-id":{color:"#cc6666"},"hljs-selector-class":{color:"#cc6666"},"hljs-regexp":{color:"#cc6666"},"hljs-deletion":{color:"#cc6666"},"hljs-number":{color:"#de935f"},"hljs-built_in":{color:"#de935f"},"hljs-builtin-name":{color:"#de935f"},"hljs-literal":{color:"#de935f"},"hljs-type":{color:"#de935f"},"hljs-params":{color:"#de935f"},"hljs-meta":{color:"#de935f"},"hljs-link":{color:"#de935f"},"hljs-attribute":{color:"#f0c674"},"hljs-string":{color:"#b5bd68"},"hljs-symbol":{color:"#b5bd68"},"hljs-bullet":{color:"#b5bd68"},"hljs-addition":{color:"#b5bd68"},"hljs-title":{color:"#81a2be"},"hljs-section":{color:"#81a2be"},"hljs-keyword":{color:"#b294bb"},"hljs-selector-tag":{color:"#b294bb"},hljs:{display:"block",overflowX:"auto",background:"#1d1f21",color:"#c5c8c6",padding:"0.5em"},"hljs-emphasis":{fontStyle:"italic"},"hljs-strong":{fontWeight:"bold"}}},X=o()(Z),ee=function(e){return i()(X).call(X,e)?Z[e]:(console.warn("Request style '".concat(e,"' is not available, returning default instead")),Q)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.File=t.Blob=t.FormData=void 0;const r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:window;t.FormData=r.FormData,t.Blob=r.Blob,t.File=r.File},function(e,t){var n=Function.prototype,r=n.apply,o=n.bind,a=n.call;e.exports="object"==typeof Reflect&&Reflect.apply||(o?a.bind(r):function(){return a.apply(r,arguments)})},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t,n){var r=n(58);e.exports=r("navigator","userAgent")||""},function(e,t){e.exports=!0},function(e,t){},function(e,t,n){var r,o=n(51),a=n(218),i=n(221),u=n(150),s=n(335),c=n(214),l=n(173),f=l("IE_PROTO"),p=function(){},h=function(e){return" - - diff --git a/ui/packages/platform/public/favicon.ico b/ui/packages/platform/public/favicon.ico deleted file mode 100644 index 404f4e98..00000000 Binary files a/ui/packages/platform/public/favicon.ico and /dev/null differ diff --git a/ui/packages/platform/public/images/avatar.jpg b/ui/packages/platform/public/images/avatar.jpg deleted file mode 100644 index deae82ed..00000000 Binary files a/ui/packages/platform/public/images/avatar.jpg and /dev/null differ diff --git a/ui/packages/platform/public/images/dblab.svg b/ui/packages/platform/public/images/dblab.svg deleted file mode 100644 index aea43a93..00000000 --- a/ui/packages/platform/public/images/dblab.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/ui/packages/platform/public/images/infosrc.png b/ui/packages/platform/public/images/infosrc.png deleted file mode 100644 index 244c86ab..00000000 Binary files a/ui/packages/platform/public/images/infosrc.png and /dev/null differ diff --git a/ui/packages/platform/public/images/oauth-github-logo.png b/ui/packages/platform/public/images/oauth-github-logo.png deleted file mode 100644 index 1fa19c55..00000000 Binary files a/ui/packages/platform/public/images/oauth-github-logo.png and /dev/null differ diff --git a/ui/packages/platform/public/images/oauth-gitlab-logo.png b/ui/packages/platform/public/images/oauth-gitlab-logo.png deleted file mode 100644 index 7ab02d6a..00000000 Binary files a/ui/packages/platform/public/images/oauth-gitlab-logo.png and /dev/null differ diff --git a/ui/packages/platform/public/images/oauth-google-logo.png b/ui/packages/platform/public/images/oauth-google-logo.png deleted file mode 100644 index 389c1cd5..00000000 Binary files a/ui/packages/platform/public/images/oauth-google-logo.png and /dev/null differ diff --git a/ui/packages/platform/public/images/oauth-linkedin-logo.png b/ui/packages/platform/public/images/oauth-linkedin-logo.png deleted file mode 100644 index 9086cb15..00000000 Binary files a/ui/packages/platform/public/images/oauth-linkedin-logo.png and /dev/null differ diff --git a/ui/packages/platform/public/images/warning.png b/ui/packages/platform/public/images/warning.png deleted file mode 100644 index cd747ffe..00000000 Binary files a/ui/packages/platform/public/images/warning.png and /dev/null differ diff --git a/ui/packages/platform/public/index.html b/ui/packages/platform/public/index.html deleted file mode 100644 index 0b7b6259..00000000 --- a/ui/packages/platform/public/index.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - Postgres.ai - - - - - - - -
- - - - diff --git a/ui/packages/platform/public/manifest.json b/ui/packages/platform/public/manifest.json deleted file mode 100644 index 56180c0d..00000000 --- a/ui/packages/platform/public/manifest.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "short_name": "Database Lab Platform", - "name": "Database Lab Platform", - "icons": [ - { - "src": "favicon.ico", - "sizes": "64x64 32x32 24x24 16x16", - "type": "image/x-icon" - } - ], - "start_url": "./index.html", - "display": "standalone", - "theme_color": "#000000", - "background_color": "#ffffff" -} diff --git a/ui/packages/platform/src/App.test.js b/ui/packages/platform/src/App.test.js deleted file mode 100644 index 076db353..00000000 --- a/ui/packages/platform/src/App.test.js +++ /dev/null @@ -1,17 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -/* eslint-disable */ -import React from 'react'; -import ReactDOM from 'react-dom'; -import App from './App'; - -it('renders without crashing', () => { - const div = document.createElement('div'); - ReactDOM.render(, div); - ReactDOM.unmountComponentAtNode(div); -}); diff --git a/ui/packages/platform/src/App.tsx b/ui/packages/platform/src/App.tsx deleted file mode 100644 index ec9d47fa..00000000 --- a/ui/packages/platform/src/App.tsx +++ /dev/null @@ -1,25 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import React, { Component } from 'react' -import { BrowserRouter as Router, Route } from 'react-router-dom' - -import { ROUTES } from 'config/routes' - -import IndexPage from './components/IndexPage' - -class App extends Component { - render() { - return ( - - - - ) - } -} - -export default App diff --git a/ui/packages/platform/src/actions/actions.js b/ui/packages/platform/src/actions/actions.js deleted file mode 100644 index 0049e250..00000000 --- a/ui/packages/platform/src/actions/actions.js +++ /dev/null @@ -1,1499 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import Reflux from 'reflux'; - -import { localStorage } from 'helpers/localStorage'; - -import Api from '../api/api'; -import ExplainDepeszApi from '../api/explain/depesz'; -import ExplainPev2Api from '../api/explain/pev2'; -import settings from '../utils/settings'; -import visualizeTypes from '../assets/visualizeTypes'; - -let api; -let explainDepeszApi; -let explainPev2Api; - -settings.init(() => { - api = new Api(settings); - explainDepeszApi = new ExplainDepeszApi(settings); - explainPev2Api = new ExplainPev2Api(settings); -}); - -// Timeout: 30 sec. -const REQUEST_TIMEOUT = 30000; -const ASYNC_ACTION = { - asyncResult: true, - children: ['progressed', 'completed', 'failed'] -}; - -const Actions = Reflux.createActions([{ - auth: {}, - signOut: {}, - ASYNC_ACTION: ASYNC_ACTION, - doAuth: ASYNC_ACTION, - getUserProfile: ASYNC_ACTION, - getAccessTokens: ASYNC_ACTION, - getAccessToken: ASYNC_ACTION, - hideGeneratedAccessToken: {}, - revokeAccessToken: ASYNC_ACTION, - getCheckupReports: ASYNC_ACTION, - getCheckupReportFiles: ASYNC_ACTION, - getCheckupReportFile: ASYNC_ACTION, - getJoeSessions: ASYNC_ACTION, - getJoeSessionCommands: ASYNC_ACTION, - getJoeSessionCommand: ASYNC_ACTION, - getProjects: ASYNC_ACTION, - getOrgs: ASYNC_ACTION, - getOrgUsers: ASYNC_ACTION, - updateOrg: ASYNC_ACTION, - createOrg: ASYNC_ACTION, - inviteUser: ASYNC_ACTION, - useDemoData: ASYNC_ACTION, - setReportsProject: {}, - setSessionsProject: {}, - setDbLabInstancesProject: {}, - refresh: {}, - getDbLabInstances: ASYNC_ACTION, - addDbLabInstance: ASYNC_ACTION, - destroyDbLabInstance: ASYNC_ACTION, - resetNewDbLabInstance: {}, - getDbLabInstanceStatus: ASYNC_ACTION, - checkDbLabInstanceUrl: ASYNC_ACTION, - downloadReportJsonFiles: ASYNC_ACTION, - addOrgDomain: ASYNC_ACTION, - deleteOrgDomain: ASYNC_ACTION, - showNotification: {}, - hideNotification: {}, - setJoeInstancesProject: {}, - getJoeInstances: ASYNC_ACTION, - getJoeInstanceChannels: ASYNC_ACTION, - sendJoeInstanceCommand: ASYNC_ACTION, - initJoeWebSocketConnection: {}, - getJoeInstanceMessages: ASYNC_ACTION, - getJoeMessageArtifacts: ASYNC_ACTION, - resetNewJoeInstance: {}, - checkJoeInstanceUrl: ASYNC_ACTION, - addJoeInstance: ASYNC_ACTION, - destroyJoeInstance: ASYNC_ACTION, - closeJoeWebSocketConnection: {}, - getExternalVisualizationData: ASYNC_ACTION, - closeExternalVisualization: {}, - deleteJoeSessions: ASYNC_ACTION, - deleteJoeCommands: ASYNC_ACTION, - deleteCheckupReports: ASYNC_ACTION, - joeCommandFavorite: ASYNC_ACTION, - clearJoeInstanceChannelMessages: {}, - getSharedUrlData: ASYNC_ACTION, - getSharedUrl: ASYNC_ACTION, - addSharedUrl: ASYNC_ACTION, - removeSharedUrl: ASYNC_ACTION, - showShareUrlDialog: {}, - closeShareUrlDialog: {}, - getBillingDataUsage: ASYNC_ACTION, - subscribeBilling: ASYNC_ACTION, - setSubscriptionError: {}, - getDbLabInstance: ASYNC_ACTION, - getJoeInstance: ASYNC_ACTION, - updateOrgUser: ASYNC_ACTION, - deleteOrgUser: ASYNC_ACTION, - getDbLabSessions: ASYNC_ACTION, - getDbLabSession: ASYNC_ACTION, - getDbLabSessionLogs: ASYNC_ACTION, - getDbLabSessionArtifacts: ASYNC_ACTION, - getDbLabSessionArtifact: ASYNC_ACTION, - getAuditLog: ASYNC_ACTION, - downloadDblabSessionLog: ASYNC_ACTION, - downloadDblabSessionArtifact: ASYNC_ACTION, - sendUserCode: ASYNC_ACTION, - confirmUserEmail: ASYNC_ACTION, - confirmTosAgreement: ASYNC_ACTION -}]); - -function timeoutPromise(ms, promise) { - return new Promise((resolve, reject) => { - const timeoutId = setTimeout(function () { - reject(new Error('timeout')); - }, ms); - - promise - .then( - (res) => { - clearTimeout(timeoutId); - resolve(res); - }, - (err) => { - clearTimeout(timeoutId); - reject(err); - }); - }); -} - -function actionResult(promise, cb, errorCb) { - timeoutPromise(REQUEST_TIMEOUT, promise). - then(result => { - let count; - try { - let range = result.headers.get('content-range'); - if (range) { - range = range.split('/'); - if (Array.isArray(range) && range.length) { - range = range[range.length - 1]; - count = parseInt(range, 10); - } - } - } catch (e) { - console.log('Range is empty'); - } - - result.json(). - then(json => { - if (!json) { - if (errorCb) { - errorCb(new Error('wrong_reply')); - } else { - this.failed(new Error('wrong_reply')); - } - } - - if (cb) { - cb(json, count); - } else { - this.completed(json, count); - } - }) - .catch(err => { - console.error(err); - - if (errorCb) { - errorCb(new Error('wrong_reply')); - } else { - this.failed(new Error('wrong_reply')); - } - }); - }). - catch(err => { - console.error(err); - let actionErr = new Error('wrong_reply'); - - if (err && err.message && err.message === 'timeout') { - actionErr = new Error('failed_fetch'); - } - - if (errorCb) { - errorCb(new Error(actionErr)); - } else { - this.failed(actionErr); - } - }); -} - -Actions.doAuth.listen(function (email, password) { - const action = this; - - if (!api) { - settings.init(function () { - api = new Api(settings); - }); - } - - if (!email && !password) { - // Token should be passed through /auth.html page. - // Example: /auth-gate.html?token=some-token - const token = localStorage.getAuthToken(); - - if (token) { - action.completed({ token: token }); - } else { - action.failed(new Error('empty_request')); - } - - return; - } - - action.progressed(); - - timeoutPromise(REQUEST_TIMEOUT, api.login(email, password)) - .then(result => { - if (result.status !== 200) { - action.failed(new Error('wrong_reply')); - } - - result.json() - .then(json => { - if (json) { - if (typeof json === 'object') { - action.failed(new Error(json.message)); - } else { - action.completed({ token: json }); - } - } else { - action.failed(new Error('wrong_reply')); - } - }) - .catch(err => { - console.error(err); - action.failed(new Error('wrong_reply')); - }); - }) - .catch(err => { - console.error(err); - if (err && err.message && err.message === 'timeout') { - action.failed(new Error('failed_fetch')); - } else { - action.failed(new Error('wrong_reply')); - } - }); -}); - -Actions.getUserProfile.listen(function (token) { - this.progressed(); - - actionResult.bind(this)( - api.getUserProfile(token), - (json) => { - this.completed(json); - } - ); -}); - -Actions.getAccessTokens.listen(function (token, orgId) { - let action = this; - - if (!api) { - settings.init(function () { - api = new Api(settings); - }); - } - - action.progressed(); - - timeoutPromise(REQUEST_TIMEOUT, api.getAccessTokens(token, orgId)) - .then(result => { - result.json() - .then(json => { - if (json) { - action.completed({ data: json, orgId: orgId }); - } else { - action.failed(new Error('wrong_reply')); - } - }) - .catch(err => { - console.error(err); - action.failed(new Error('wrong_reply')); - }); - }) - .catch(err => { - console.error(err); - if (err && err.message && err.message === 'timeout') { - action.failed(new Error('failed_fetch')); - } else { - action.failed(new Error('wrong_reply')); - } - }); -}); - -Actions.getAccessToken.listen(function (token, name, expires, orgId, isPersonal) { - let requestExpires = expires.split('-').join('') + 'T235959-0330'; - - this.progressed(); - actionResult.bind(this)( - api.getAccessToken(token, name, requestExpires, orgId, isPersonal), - (json) => { - this.completed({ orgId: orgId, data: json }); - }); -}); - -Actions.revokeAccessToken.listen(function (token, orgId, id) { - let action = this; - - if (!api) { - settings.init(function () { - api = new Api(settings); - }); - } - - action.progressed(id); - - timeoutPromise(REQUEST_TIMEOUT, api.revokeAccessToken(token, id)) - .then(result => { - result.json() - .then(json => { - if (json) { - action.completed({ orgId: orgId, data: json }); - } else { - action.failed(new Error('wrong_reply')); - } - }) - .catch(err => { - console.error(err); - action.failed(new Error('wrong_reply')); - }); - }) - .catch(err => { - console.error(err); - if (err && err.message && err.message === 'timeout') { - action.failed(new Error('failed_fetch')); - } else { - action.failed(new Error('wrong_reply')); - } - }); -}); - -Actions.getCheckupReports.listen(function (token, orgId, projectId, reportId) { - this.progressed(); - - actionResult.bind(this)( - api.getCheckupReports(token, orgId, projectId, reportId), - (json) => { - this.completed({ - data: json, - orgId: orgId, - projectId: projectId, - reportId: reportId - }); - } - ); -}); - -Actions.getCheckupReportFiles.listen(function (token, reportId, type, orderBy, - orderDirection) { - this.progressed(); - - actionResult.bind(this)( - api.getCheckupReportFiles(token, reportId, type, orderBy, orderDirection), - (json) => { - this.completed({ reportId: reportId, data: json, type: type }); - } - ); -}); - -Actions.getCheckupReportFile.listen(function (token, projectId, reportId, fileId, type) { - this.progressed(); - - actionResult.bind(this)( - api.getCheckupReportFile(token, projectId, reportId, fileId, type), - (json) => { - this.completed(fileId, json); - } - ); -}); - -Actions.getJoeSessions.listen(function (token, orgId, projectId) { - let action = this; - - if (!api) { - settings.init(function () { - api = new Api(settings); - }); - } - - action.progressed(); - - timeoutPromise(REQUEST_TIMEOUT, api.getJoeSessions(token, orgId, projectId)) - .then(result => { - result.json() - .then(json => { - if (json) { - action.completed({ data: json, orgId: orgId, projectId: projectId }); - } else { - action.failed(new Error('wrong_reply')); - } - }) - .catch(err => { - console.error(err); - action.failed(new Error('wrong_reply')); - }); - }) - .catch(err => { - console.error(err); - if (err && err.message && err.message === 'timeout') { - action.failed(new Error('failed_fetch')); - } else { - action.failed(new Error('wrong_reply')); - } - }); -}); - -Actions.getJoeSessionCommands.listen(function (token, params) { - let action = this; - - if (!api) { - settings.init(function () { - api = new Api(settings); - }); - } - - action.progressed(params); - - timeoutPromise(REQUEST_TIMEOUT, api.getJoeSessionCommands(token, params)) - .then(result => { - result.json() - .then(json => { - if (json) { - action.completed(json, params); - } else { - action.failed(new Error('wrong_reply')); - } - }) - .catch(err => { - console.error(err); - action.failed(new Error('wrong_reply')); - }); - }) - .catch(err => { - console.error(err); - if (err && err.message && err.message === 'timeout') { - action.failed(new Error('failed_fetch')); - } else { - action.failed(new Error('wrong_reply')); - } - }); -}); - -Actions.getJoeSessionCommand.listen(function (token, orgId, commandId) { - let action = this; - - if (!api) { - settings.init(function () { - api = new Api(settings); - }); - } - - action.progressed(); - - timeoutPromise(REQUEST_TIMEOUT, api.getJoeSessionCommand(token, orgId, commandId)) - - .then(result => { - result.json() - .then(json => { - if (json) { - const command = json[0]; - action.completed(command); - } else { - action.failed(new Error('wrong_reply')); - } - }) - .catch(err => { - console.error(err); - action.failed(new Error('wrong_reply')); - }); - }) - .catch(err => { - console.error(err); - if (err && err.message && err.message === 'timeout') { - action.failed(new Error('failed_fetch')); - } else { - action.failed(new Error('wrong_reply')); - } - }); -}); - -Actions.getProjects.listen(function (token, orgId) { - if (!api) { - settings.init(function () { - api = new Api(settings); - }); - } - - let action = this; - - action.progressed(); - - timeoutPromise(REQUEST_TIMEOUT, api.getProjects(token, orgId)) - .then(result => { - result.json() - .then(json => { - if (json) { - action.completed({ data: json, orgId: orgId }); - } else { - action.failed(new Error('wrong_reply')); - } - }) - .catch(err => { - console.error(err); - action.failed(new Error('wrong_reply')); - }); - }) - .catch(err => { - console.error(err); - if (err && err.message && err.message === 'timeout') { - action.failed(new Error('failed_fetch')); - } else { - action.failed(new Error('wrong_reply')); - } - }); -}); - -Actions.getOrgs.listen(function (token, orgId) { - let action = this; - - if (!api) { - settings.init(function () { - api = new Api(settings); - }); - } - - action.progressed({ orgId }); - - timeoutPromise(REQUEST_TIMEOUT, api.getOrgs(token, orgId)) - .then(result => { - result.json() - .then(json => { - if (json) { - action.completed({ data: json, orgId: orgId }); - } else { - action.failed(new Error('wrong_reply')); - } - }) - .catch(err => { - console.error(err); - action.failed(new Error('wrong_reply')); - }); - }) - .catch(err => { - console.error(err); - if (err && err.message && err.message === 'timeout') { - action.failed(new Error('failed_fetch')); - } else { - action.failed(new Error('wrong_reply')); - } - }); -}); - -Actions.getOrgUsers.listen(function (token, orgId) { - this.progressed(orgId); - - actionResult.bind(this)( - api.getOrgUsers(token, orgId), - (json) => { - this.completed(orgId, json); - }, - (err) => { - this.failed(orgId, err); - } - ); -}); - -Actions.updateOrg.listen(function (token, orgId, orgData) { - let action = this; - - if (!api) { - settings.init(function () { - api = new Api(settings); - }); - } - - action.progressed({ orgId } + orgData); - timeoutPromise(REQUEST_TIMEOUT, api.updateOrg(token, orgId, orgData)) - - .then(result => { - result.json() - .then(json => { - if (json) { - action.completed(json); - } else { - action.failed(new Error('wrong_reply')); - } - }) - .catch(err => { - console.error(err); - action.failed(new Error('wrong_reply')); - }); - }) - .catch(err => { - console.error(err); - if (err && err.message && err.message === 'timeout') { - action.failed(new Error('failed_fetch')); - } else { - action.failed(new Error('wrong_reply')); - } - }); -}); - -Actions.createOrg.listen(function (token, orgData) { - let action = this; - - if (!api) { - settings.init(function () { - api = new Api(settings); - }); - } - - action.progressed(orgData); - timeoutPromise(REQUEST_TIMEOUT, api.createOrg(token, orgData)) - .then(result => { - result.json() - .then(json => { - if (json) { - action.completed(json); - } else { - action.failed(new Error('wrong_reply')); - } - }) - .catch(err => { - console.error(err); - action.failed(new Error('wrong_reply')); - }); - }) - .catch(err => { - console.error(err); - if (err && err.message && err.message === 'timeout') { - action.failed(new Error('failed_fetch')); - } else { - action.failed(new Error('wrong_reply')); - } - }); -}); - -Actions.inviteUser.listen(function (token, orgId, email) { - let action = this; - - if (!api) { - settings.init(function () { - api = new Api(settings); - }); - } - - action.progressed({ orgId, email }); - timeoutPromise(REQUEST_TIMEOUT, api.inviteUser(token, orgId, email)) - .then(result => { - result.json() - .then(json => { - if (json) { - action.completed(json); - } else { - action.failed(new Error('wrong_reply')); - } - }) - .catch(err => { - console.error(err); - action.failed(new Error('wrong_reply')); - }); - }) - .catch(err => { - console.error(err); - if (err && err.message && err.message === 'timeout') { - action.failed(new Error('failed_fetch')); - } else { - action.failed(new Error('wrong_reply')); - } - }); -}); - -Actions.useDemoData.listen(function (token) { - this.progressed(); - - actionResult.bind(this)( - api.useDemoData(token), - (json) => { - this.completed(json); - }, - (err) => { - this.failed(err); - } - ); -}); - -Actions.getDbLabInstances.listen(function (token, orgId, projectId) { - let action = this; - - if (!api) { - settings.init(function () { - api = new Api(settings); - }); - } - - action.progressed(); - timeoutPromise(REQUEST_TIMEOUT, api.getDbLabInstances(token, orgId, projectId)) - .then(result => { - result.json() - .then(json => { - if (json) { - action.completed({ data: json, orgId: orgId, projectId: projectId }); - } else { - action.failed(new Error('wrong_reply')); - } - }) - .catch(err => { - console.error(err); - action.failed(new Error('wrong_reply')); - }); - }) - .catch(err => { - console.error(err); - if (err && err.message && err.message === 'timeout') { - action.failed(new Error('failed_fetch')); - } else { - action.failed(new Error('wrong_reply')); - } - }); -}); - -Actions.addDbLabInstance.listen(function (token, instanceData) { - let action = this; - - if (!api) { - settings.init(function () { - api = new Api(settings); - }); - } - - action.progressed(); - - timeoutPromise(REQUEST_TIMEOUT, api.addDbLabInstance(token, instanceData)) - .then(result => { - result.json() - .then(json => { - if (json) { - action.completed( - { data: json, orgId: instanceData.orgId, project: instanceData.project }); - } else { - action.failed(new Error('wrong_reply')); - } - }) - .catch(err => { - console.error(err); - action.failed(new Error('wrong_reply')); - }); - }) - .catch(err => { - console.error(err); - if (err && err.message && err.message === 'timeout') { - action.failed(new Error('failed_fetch')); - } else { - action.failed(new Error('wrong_reply')); - } - }); -}); - -Actions.destroyDbLabInstance.listen(function (token, instanceId) { - let action = this; - - if (!api) { - settings.init(function () { - api = new Api(settings); - }); - } - - action.progressed({ instanceId: instanceId }); - - timeoutPromise(REQUEST_TIMEOUT, api.destroyDbLabInstance(token, instanceId)) - .then(result => { - result.json() - .then(json => { - if (json) { - action.completed({ data: json, instanceId: instanceId }); - } else { - action.failed(new Error('wrong_reply')); - } - }) - .catch(err => { - console.error(err); - action.failed(new Error('wrong_reply')); - }); - }) - .catch(err => { - console.error(err); - if (err && err.message && err.message === 'timeout') { - action.failed(new Error('failed_fetch')); - } else { - action.failed(new Error('wrong_reply')); - } - }); -}); - -Actions.getDbLabInstanceStatus.listen(function (token, instanceId) { - let action = this; - - if (!api) { - settings.init(function () { - api = new Api(settings); - }); - } - - action.progressed({ instanceId: instanceId }); - - timeoutPromise(REQUEST_TIMEOUT, api.getDbLabInstanceStatus(token, instanceId)) - .then(result => { - result.json() - .then(json => { - if (json) { - action.completed({ data: json, instanceId: instanceId }); - } else { - action.failed({ instanceId: instanceId }, new Error( - 'wrong_reply')); - } - }) - .catch(err => { - console.error(err); - action.failed({ instanceId: instanceId }, new Error( - 'wrong_reply')); - }); - }) - .catch(err => { - console.error(err); - if (err && err.message && err.message === 'timeout') { - action.failed({ instanceId: instanceId }, new Error( - 'failed_fetch')); - } else { - action.failed({ instanceId: instanceId }, new Error( - 'wrong_reply')); - } - }); -}); - -Actions.checkDbLabInstanceUrl.listen(function (token, url, verifyToken, useTunnel) { - let action = this; - - if (!api) { - settings.init(function () { - api = new Api(settings); - }); - } - - action.progressed(); - - timeoutPromise(REQUEST_TIMEOUT, api.checkDbLabInstanceUrl(token, url, verifyToken, useTunnel)) - .then(result => { - result.json() - .then(json => { - if (json) { - action.completed(json); - } else { - action.failed(new Error('wrong_reply')); - } - }) - .catch(err => { - console.error(err); - action.failed(new Error('wrong_reply')); - }); - }) - .catch(err => { - console.error(err); - if (err && err.message && err.message === 'timeout') { - action.failed(new Error('failed_fetch')); - } else { - action.failed(new Error('wrong_reply')); - } - }); -}); - -Actions.downloadBinaryFile = (action, token, fileUrl, storeParams = {}) => { - let xhr = new XMLHttpRequest(); - - action.progressed(storeParams); - xhr.open('GET', fileUrl); - xhr.setRequestHeader('authorization', 'Bearer ' + token); - xhr.setRequestHeader('accept', 'application/octet-stream'); - xhr.responseType = 'arraybuffer'; - xhr.addEventListener('readystatechange', function () { - if (this.readyState === 4) { - let blob; - let filename = ''; - let type = xhr.getResponseHeader('Content-Type'); - let disposition = xhr.getResponseHeader('Content-Disposition'); - let url = window.URL || window.webkitURL; - - if (disposition && disposition.indexOf('attachment') !== -1) { - let filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/; - let matches = filenameRegex.exec(disposition); - - if (matches !== null && matches[1]) { - filename = matches[1].replace(/['"]/g, ''); - } - } - - if (typeof File === 'function') { - try { - blob = new File([this.response], filename, { type: type }); - } catch (e) { - /* IE 10 or less do not support constructor for File. - In this case we will use Blob on next step. */ - } - } - - if (this.status === 404) { - try { - const jsonBody = JSON.parse(new TextDecoder().decode(this.response)); - action.failed(jsonBody); - } catch (e) { - action.failed({}); - } - return; - } - - if (typeof blob === 'undefined') { - blob = new Blob([this.response], { type: type }); - } - - action.completed(); - - if (typeof window.navigator.msSaveBlob !== 'undefined') { - window.navigator.msSaveBlob(blob, filename); - - return; - } - - let downloadUrl = url.createObjectURL(blob); - - if (filename) { - // use HTML5 a[download] attribute to specify filename. - let a = document.createElement('a'); - // safari doesn't support this yet - if (typeof a.download === 'undefined') { - window.location = downloadUrl; - } else { - a.href = downloadUrl; - a.download = filename; - document.body.appendChild(a); - a.click(); - } - - return; - } - - window.location = downloadUrl; - } - }); - - xhr.send(); -}; - - -Actions.downloadReportJsonFiles.listen(function (token, reportId) { - let url = settings.apiServer + - '/rpc/checkup_report_json_download?checkup_report_id=' + reportId; - Actions.downloadBinaryFile(this, token, url); -}); - -Actions.deleteOrgDomain.listen(function (token, orgId, domainId) { - let action = this; - - if (!api) { - settings.init(function () { - api = new Api(settings); - }); - } - - action.progressed({ orgId, domainId }); - timeoutPromise(REQUEST_TIMEOUT, api.deleteOrgDomain(token, domainId)) - .then(result => { - result.json() - .then(json => { - if (json) { - action.completed({ orgId, domainId }); - } else { - action.failed(new Error('wrong_reply')); - } - }) - .catch(err => { - console.error(err); - action.failed(new Error('wrong_reply')); - }); - }) - .catch(err => { - console.error(err); - if (err && err.message && err.message === 'timeout') { - action.failed(new Error('failed_fetch')); - } else { - action.failed(new Error('wrong_reply')); - } - }); -}); - -Actions.addOrgDomain.listen(function (token, orgId, domain) { - let action = this; - - if (!api) { - settings.init(function () { - api = new Api(settings); - }); - } - - action.progressed({ orgId, domain }); - timeoutPromise(REQUEST_TIMEOUT, api.addOrgDomain(token, orgId, domain)) - .then(result => { - result.json() - .then(json => { - if (json) { - action.completed({ orgId, domain }); - } else { - action.failed(new Error('wrong_reply')); - } - }) - .catch(err => { - console.error(err); - action.failed(new Error('wrong_reply')); - }); - }) - .catch(err => { - console.error(err); - if (err && err.message && err.message === 'timeout') { - action.failed(new Error('failed_fetch')); - } else { - action.failed(new Error('wrong_reply')); - } - }); -}); - -Actions.getJoeInstances.listen(function (token, orgId, projectId) { - this.progressed(); - - actionResult.bind(this)( - api.getJoeInstances(token, orgId, projectId), - (json) => { - this.completed(orgId, projectId, json); - }); -}); - -Actions.getJoeInstanceChannels.listen(function (token, instanceId) { - this.progressed(instanceId); - actionResult.bind(this)( - api.getJoeInstanceChannels(token, instanceId), - (json) => { - this.completed(instanceId, json); - }, - (err) => { - this.failed(instanceId, err); - }); -}); - -Actions.sendJoeInstanceCommand.listen(function (token, instanceId, - channelId, command, sessionId) { - this.progressed(instanceId); - actionResult.bind(this)( - api.sendJoeInstanceCommand(token, instanceId, channelId, command, sessionId), - (json) => { - json.message = command; - this.completed(instanceId, json); - }, - (err) => { - this.failed(instanceId, err); - } - ); -}); - -Actions.getJoeInstanceMessages.listen(function (token, instanceId, - channelId, sessionId) { - this.progressed(instanceId); - actionResult.bind(this)( - api.getJoeInstanceMessages(token, channelId, sessionId), - (json) => { - this.completed(instanceId, channelId, json); - }, - (err) => { - this.failed(instanceId, channelId, err); - }); -}); - -Actions.getJoeMessageArtifacts.listen(function (token, instanceId, channelId, messageId) { - this.progressed(instanceId, channelId, messageId); - actionResult.bind(this)( - api.getJoeMessageArtifacts(token, messageId), - (json) => { - this.completed(instanceId, channelId, messageId, json); - }, - (err) => { - this.failed(instanceId, channelId, messageId, err); - } - ); -}); - -Actions.checkJoeInstanceUrl.listen(function (token, instanceData) { - this.progressed(); - - instanceData.dryRun = true; - - actionResult.bind(this)(api.addJoeInstance(token, instanceData)); -}); - -Actions.addJoeInstance.listen(function (token, instanceData) { - this.progressed(); - - instanceData.dryRun = false; - - actionResult.bind(this)( - api.addJoeInstance(token, instanceData), - (json) => { - this.completed(instanceData.orgId, json); - } - ); -}); - -Actions.destroyJoeInstance.listen(function (token, instanceId) { - this.progressed(instanceId); - - actionResult.bind(this)( - api.destroyJoeInstance(token, instanceId), - (json) => { - this.completed(instanceId, json); - } - ); -}); - -Actions.getExternalVisualizationData.listen(function (type, plan, query) { - if (type !== visualizeTypes.depesz && type !== visualizeTypes.pev2) { - console.log('Unsupported visualization type.'); - return; - } - - this.progressed(type, plan, query); - - if (type === visualizeTypes.pev2) { - explainPev2Api.postPlan(plan.json, query) - .then((result) => { - result.json() - .then((response) => { - console.log(response.json); - - if (!response || !response.id) { - this.failed(type); - return; - } - - const url = `${settings.explainPev2Server}#${response.id}`; - this.completed(type, plan, query, url); - }).catch((error) => { - console.error('Error:', error); - this.failed(type); - }); - }).catch((error) => { - console.error('Error:', error); - this.failed(type); - }); - } else { - explainDepeszApi.postPlan(plan.text, query) - .then((response) => { - console.log(response); - - const xFinalUrl = response.headers.get('x-final-url'); - - let url = response.url; - if (response.url === settings.explainDepeszServer && !!xFinalUrl) { - url = xFinalUrl; - } - - this.completed(type, plan, query, url); - }).catch((error) => { - console.error('Error:', error); - this.failed(type); - }); - } -}); - -Actions.deleteJoeSessions.listen(function (token, ids) { - this.progressed(ids); - - actionResult.bind(this)( - api.deleteJoeSessions(token, ids), - (json) => { - this.completed(ids, json); - } - ); -}); - -Actions.deleteJoeCommands.listen(function (token, ids) { - this.progressed(ids); - - actionResult.bind(this)( - api.deleteJoeCommands(token, ids), - (json) => { - this.completed(ids, json); - } - ); -}); - - -Actions.deleteCheckupReports.listen(function (token, ids) { - this.progressed(ids); - - actionResult.bind(this)( - api.deleteCheckupReports(token, ids), - (json) => { - this.completed(ids, json); - } - ); -}); - -Actions.joeCommandFavorite.listen(function (token, commandId, favorite) { - this.progressed(commandId, favorite); - - actionResult.bind(this)( - api.joeCommandFavorite(token, commandId, favorite), - (json) => { - this.completed(json, commandId, favorite); - } - ); -}); - -Actions.getSharedUrlData.listen(function (uuid) { - this.progressed(uuid); - - actionResult.bind(this)( - api.getSharedUrlData(uuid), - (json) => { - this.completed(uuid, json); - } - ); -}); - -Actions.getSharedUrl.listen(function (token, orgId, objectType, objectId) { - this.progressed(orgId, objectType, objectId); - - actionResult.bind(this)( - api.getSharedUrl(token, orgId, objectType, objectId), - (json) => { - this.completed(orgId, objectType, objectId, json); - } - ); -}); - -Actions.removeSharedUrl.listen(function (token, orgId, objectType, objectId, urlId) { - this.progressed(); - - actionResult.bind(this)( - api.removeSharedUrl(token, orgId, urlId), - (json) => { - this.completed(orgId, objectType, objectId, urlId, json); - } - ); -}); - -Actions.addSharedUrl.listen(function (token, params) { - this.progressed(params); - - actionResult.bind(this)( - api.addSharedUrl(token, params), - (json) => { - this.completed(params, json); - } - ); -}); - -Actions.getBillingDataUsage.listen(function (token, orgId) { - this.progressed(orgId); - - actionResult.bind(this)( - api.getBillingDataUsage(token, orgId), - (json) => { - this.completed(orgId, json); - } - ); -}); - -Actions.subscribeBilling.listen(function (token, orgId, paymentMethodId) { - this.progressed(orgId, paymentMethodId); - - actionResult.bind(this)( - api.subscribeBilling(token, orgId, paymentMethodId), - (json) => { - this.completed(orgId, paymentMethodId, json); - } - ); -}); - -Actions.getDbLabInstance.listen(function (token, orgId, projectId, instanceId) { - this.progressed(orgId, projectId, instanceId); - - actionResult.bind(this)( - api.getDbLabInstances(token, orgId, projectId, instanceId), - (json) => { - this.completed(orgId, projectId, instanceId, json); - }, - (err) => { - this.failed(orgId, projectId, instanceId, err); - } - ); -}); - -Actions.getJoeInstance.listen(function (token, orgId, projectId, instanceId) { - this.progressed(orgId, projectId, instanceId); - - actionResult.bind(this)( - api.getJoeInstances(token, orgId, projectId, instanceId), - (json) => { - this.completed(orgId, projectId, instanceId, json); - }, - (err) => { - this.failed(orgId, projectId, instanceId, err); - } - ); -}); - -Actions.getDbLabSessions.listen(function (token, params) { - this.progressed(params); - - actionResult.bind(this)( - api.getDbLabSessions(token, params), - (json, count) => { - this.completed(params, json, count); - }, - (err) => { - this.failed(params, err); - } - ); -}); - -Actions.getDbLabSession.listen(function (token, sessionId) { - this.progressed(sessionId); - - actionResult.bind(this)( - api.getDbLabSession(token, sessionId), - (json) => { - this.completed(sessionId, json); - }, - (err) => { - this.failed(sessionId, err); - } - ); -}); - -Actions.getDbLabSessionLogs.listen(function (token, params) { - this.progressed(params); - - actionResult.bind(this)( - api.getDbLabSessionLogs(token, params), - (json, count) => { - this.completed(params, json, count); - }, - (err) => { - this.failed(params, err); - } - ); -}); - -Actions.getDbLabSessionArtifacts.listen(function (token, sessionId) { - this.progressed(sessionId); - - actionResult.bind(this)( - api.getDbLabSessionArtifacts(token, sessionId), - (json) => { - this.completed(sessionId, json); - }, - (err) => { - this.failed(sessionId, err); - } - ); -}); - -Actions.getDbLabSessionArtifact.listen(function (token, sessionId, artifactType) { - this.progressed(sessionId, artifactType); - - actionResult.bind(this)( - api.getDbLabSessionArtifact(token, sessionId, artifactType), - (json) => { - this.completed(sessionId, artifactType, json); - }, - (err) => { - this.failed(sessionId, artifactType, err); - } - ); -}); - - -Actions.updateOrgUser.listen(function (token, orgId, userId, role) { - this.progressed(orgId, userId, role); - - actionResult.bind(this)( - api.updateOrgUser(token, orgId, userId, role), - (json) => { - this.completed(orgId, userId, role, json); - }, - (err) => { - this.failed(orgId, userId, role, err); - } - ); -}); - -Actions.deleteOrgUser.listen(function (token, orgId, userId) { - this.progressed(orgId, userId); - - actionResult.bind(this)( - api.deleteOrgUser(token, orgId, userId), - (json) => { - this.completed(orgId, userId, json); - }, - (err) => { - this.failed(orgId, userId, err); - } - ); -}); - -Actions.getAuditLog.listen(function (token, params) { - this.progressed(params); - - actionResult.bind(this)( - api.getAuditLog(token, params), - (json, count) => { - this.completed(params, json, count); - }, - (err) => { - this.failed(params, err); - } - ); -}); - -Actions.downloadDblabSessionLog.listen(function (token, sessionId) { - let url = settings.apiServer + - '/rpc/dblab_session_logs_download?dblab_session_id=' + sessionId; - Actions.downloadBinaryFile(this, token, url); -}); - - -Actions.downloadDblabSessionArtifact.listen(function (token, sessionId, artifactType) { - let url = settings.apiServer + - '/rpc/dblab_session_artifacts_download?' + - 'dblab_session_id=' + sessionId + - '&artifact_type=' + artifactType; - Actions.downloadBinaryFile(this, token, url, { artifactType }); -}); - -Actions.sendUserCode.listen(function (token) { - this.progressed(); - - actionResult.bind(this)( - api.sendUserCode(token), - (json, count) => { - this.completed(json, count); - }, - (err) => { - this.failed(err); - } - ); -}); - -Actions.confirmUserEmail.listen(function (token, code) { - this.progressed(); - - actionResult.bind(this)( - api.confirmUserEmail(token, code), - (json) => { - this.completed(json); - }, - (err) => { - this.failed(err); - } - ); -}); - -Actions.confirmTosAgreement.listen(function (token) { - this.progressed(); - - actionResult.bind(this)( - api.confirmTosAgreement(token), - (json) => { - this.completed(json); - }, - (err) => { - this.failed(err); - } - ); -}); - -export default Actions; diff --git a/ui/packages/platform/src/api/api.js b/ui/packages/platform/src/api/api.js deleted file mode 100644 index 25dbe7d1..00000000 --- a/ui/packages/platform/src/api/api.js +++ /dev/null @@ -1,946 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import 'es6-promise/auto'; -import 'whatwg-fetch'; - -function encodeData(data) { - return Object.keys(data).map(function (key) { - return [key, data[key]].map(encodeURIComponent).join('='); - }).join('&'); -} - -class Api { - constructor(setting) { - this.server = setting.server; - this.apiServer = setting.apiServer; - } - - get(url, query, options) { - let params = ''; - - if (query) { - params = `?${encodeData(query)}`; - } - - if (options) { - options.Prefer = 'count=none'; - } - - let fetchOptions = { - ...options, - method: 'get', - credentials: 'include' - }; - - return fetch(`${url}${params}`, fetchOptions); - } - - post(url, data, options = {}) { - let headers = options.headers || {}; - - let fetchOptions = { - ...options, - method: 'post', - credentials: 'include', - headers: { - ...headers, - 'Content-Type': 'application/json' - }, - body: JSON.stringify(data) - }; - - return fetch(url, fetchOptions); - } - - patch(url, data, options = {}) { - let headers = options.headers || {}; - - let fetchOptions = { - ...options, - method: 'PATCH', - credentials: 'include', - headers: { - ...headers, - 'Content-Type': 'application/json' - }, - body: JSON.stringify(data) - }; - - return fetch(url, fetchOptions); - } - - delete(url, data, options = {}) { - let headers = options.headers || {}; - - let fetchOptions = { - ...options, - method: 'DELETE', - credentials: 'include', - headers: { - ...headers, - 'Content-Type': 'application/json' - }, - body: JSON.stringify(data) - }; - - return fetch(url, fetchOptions); - } - - login(login, password) { - let headers = {}; - - return this.post(`${this.apiServer}/rpc/login`, { - email: login, - password: password - }, { - headers: headers - }); - } - - getUserProfile(token) { - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.get(`${this.apiServer}/user_get`, {}, { - headers: headers - }); - } - - getAccessTokens(token, orgId) { - let params = {}; - let headers = { - Authorization: 'Bearer ' + token - }; - - if (orgId !== null && orgId !== 0) { - params.org_id = `eq.${orgId}`; - } - - return this.get(`${this.apiServer}/api_tokens`, params, { - headers: headers - }); - } - - getAccessToken(token, name, expires, orgId, isPersonal) { - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.post(`${this.apiServer}/rpc/api_token_create`, { - name: name, - expires: expires, - org_id: orgId, - is_personal: isPersonal - }, { - headers: headers - }); - } - - revokeAccessToken(token, id) { - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.post(`${this.apiServer}/rpc/api_token_revoke`, { id: id }, { - headers: headers - }); - } - - getCheckupReports(token, orgId, projectId, reportId) { - let params = {}; - let headers = { - Authorization: 'Bearer ' + token - }; - - if (orgId !== null && orgId !== 0) { - params.org_id = `eq.${orgId}`; - } - - if (projectId !== null && projectId !== 0) { - params.project_id = `eq.${projectId}`; - } - - if (typeof reportId !== 'undefined' && reportId !== 0) { - params.id = `eq.${reportId}`; - } - - return this.get(`${this.apiServer}/checkup_reports`, params, { - headers: headers - }); - } - - getCheckupReportFiles(token, reportId, type, orderBy, orderDirection) { - let headers = { - Authorization: 'Bearer ' + token - }; - let params = { - checkup_report_id: `eq.${reportId}` - }; - - if (type) { - params.type = `eq.${type}`; - } - - if (orderBy && orderDirection) { - params.order = `${orderBy}.${orderDirection}`; - } - - return this.get(`${this.apiServer}/checkup_report_files`, params, { - headers: headers - }); - } - - getCheckupReportFile(token, projectId, reportId, fileId, type) { - let headers = { - Authorization: 'Bearer ' + token - }; - let params = { - project_id: `eq.${projectId}`, - checkup_report_id: `eq.${reportId}`, - type: `eq.${type}` - }; - - if (fileId === parseInt(fileId, 10)) { - params.id = `eq.${fileId}`; - } else { - params.filename = `eq.${fileId}`; - } - - return this.get(`${this.apiServer}/checkup_report_file_data`, params, { - headers: headers - }); - } - - getProjects(token, orgId) { - let params = {}; - let headers = { - Authorization: 'Bearer ' + token - }; - - if (orgId) { - params.org_id = `eq.${orgId}`; - } - - return this.get(`${this.apiServer}/projects`, params, { - headers: headers - }); - } - - getJoeSessions(token, orgId, projectId) { - let params = {}; - let headers = { - Authorization: 'Bearer ' + token - }; - - if (orgId !== null && orgId !== 0) { - params.org_id = `eq.${orgId}`; - } - - if (projectId !== null && projectId !== 0) { - params.project_id = `eq.${projectId}`; - } - - return this.get(`${this.apiServer}/joe_sessions`, params, { - headers: headers - }); - } - - getJoeSessionCommands(token, - { orgId, session, fingerprint, command, project, - author, startAt, limit, lastId, search, isFavorite }) { - const params = {}; - const headers = { - Authorization: 'Bearer ' + token - }; - - if (orgId && orgId !== 0) { - params['org_id'] = `eq.${orgId}`; - } - - if (session && session !== 0) { - params['joe_session_id'] = `eq.${session}`; - } - - if (fingerprint) { - params.fingerprint = `ilike.${fingerprint}*`; - } - - if (command) { - params.command = `eq.${command}`; - } - - if (startAt) { - params.created_at = `gt.${startAt}`; - } - - if (limit) { - params.limit = limit; - } - - if (lastId) { - // backend order by id.desc - params.id = `lt.${lastId}`; - } - - if (project) { - // backend order by id.desc - params.project_name = `ilike.${project}*`; - } - - if (author) { - params.or = `(username.ilike.${author}*,` + - `useremail.ilike.${author}*,` + - `slack_username.ilike.${author}*)`; - } - - if (search) { - let searchText = encodeURIComponent(search); - params.tsv = `fts(simple).${searchText}`; - } - - if (isFavorite) { - params.is_favorite = `gt.0`; - } - - - return this.get(`${this.apiServer}/joe_session_commands`, params, { - headers: headers - }); - } - - getJoeSessionCommand(token, orgId, commandId) { - let params = { org_id: `eq.${orgId}` }; - let headers = { - Authorization: 'Bearer ' + token - }; - - if (!!commandId && commandId !== 0) { - params.id = `eq.${commandId}`; - } - - return this.get(`${this.apiServer}/joe_session_commands`, params, { - headers: headers - }); - } - - getOrgs(token, orgId) { - let params = {}; - let headers = { - Authorization: 'Bearer ' + token - }; - - if (orgId) { - params.id = `eq.${orgId}`; - } - - return this.get(`${this.apiServer}/orgs`, params, { - headers: headers - }); - } - - getOrgUsers(token, orgId) { - let params = {}; - let headers = { - Authorization: 'Bearer ' + token - }; - - if (orgId) { - params.id = `eq.${orgId}`; - } - - return this.get(`${this.apiServer}/org_users`, params, { - headers: headers - }); - } - - updateOrg(token, orgId, orgData) { - let params = {}; - let headers = { - Authorization: 'Bearer ' + token, - prefer: 'return=representation' - }; - - if (orgData.name) { - params.name = orgData.name; - } - - if (orgData.alias) { - params.alias = orgData.alias; - } - - if (typeof orgData.users_autojoin !== 'undefined') { - params.users_autojoin = orgData.users_autojoin; - } - - if (typeof orgData.onboarding_text !== 'undefined') { - params.onboarding_text = orgData.onboarding_text; - } - - return this.patch(`${this.apiServer}/orgs?id=eq.` + orgId, params, { - headers: headers - }); - } - - createOrg(token, orgData) { - let params = { - name: orgData.name, - alias: orgData.alias - }; - let headers = { - Authorization: 'Bearer ' + token - }; - - if (orgData.email_domain_autojoin) { - params.org_domain = orgData.email_domain_autojoin; - } - - if (typeof orgData.users_autojoin !== 'undefined') { - params.users_autojoin = orgData.users_autojoin; - } - - return this.post(`${this.apiServer}/rpc/user_create_org`, params, { - headers: headers - }); - } - - addOrgDomain(token, orgId, domain) { - let params = { - org_id: orgId, - domain_name: domain - }; - let headers = { - Authorization: 'Bearer ' + token, - prefer: 'return=representation' - }; - - return this.post(`${this.apiServer}/org_domains`, params, { - headers: headers - }); - } - - deleteOrgDomain(token, domainId) { - let headers = { - Authorization: 'Bearer ' + token, - prefer: 'return=representation' - }; - - return this.delete(`${this.apiServer}/org_domains?id=eq.${domainId}`, {}, { - headers: headers - }); - } - - inviteUser(token, orgId, email) { - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.post(`${this.apiServer}/rpc/user_invite_org_user`, { - org_id: orgId, - email: email - }, { - headers: headers - }); - } - - useDemoData(token) { - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.post(`${this.apiServer}/rpc/use_demo_data`, {}, { - headers: headers - }); - } - - getDbLabInstances(token, orgId, projectId, instanceId) { - let params = {}; - let headers = { - Authorization: 'Bearer ' + token - }; - - if (orgId !== null && orgId !== 0) { - params.org_id = `eq.${orgId}`; - } - if (projectId !== null && projectId !== 0) { - params.project_id = `eq.${projectId}`; - } - if (typeof instanceId !== 'undefined' && instanceId !== 0) { - params.id = `eq.${instanceId}`; - } - - return this.get(`${this.apiServer}/dblab_instances`, params, { - headers: headers - }); - } - - addDbLabInstance(token, instanceData) { - let headers = { - Authorization: 'Bearer ' + token - }; - let params = { - url: instanceData.url, - org_id: instanceData.orgId, - token: instanceData.instanceToken, - project: instanceData.project, - use_tunnel: instanceData.useTunnel, - ssh_server_url: instanceData.sshServerUrl - }; - - return this.post(`${this.apiServer}/rpc/dblab_instance_create`, params, { - headers: headers - }); - } - - destroyDbLabInstance(token, instanceId) { - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.post(`${this.apiServer}/rpc/dblab_instance_destroy`, { - instance_id: instanceId - }, { - headers: headers - }); - } - - getDbLabInstanceStatus(token, instanceId) { - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.post(`${this.apiServer}/rpc/dblab_instance_status_refresh`, { - instance_id: instanceId - }, { - headers: headers - }); - } - - checkDbLabInstanceUrl(token, url, verifyToken, useTunnel) { - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.post(`${this.apiServer}/rpc/dblab_instance_status`, { - url: url, - verify_token: verifyToken, - use_tunnel: useTunnel - }, { - headers: headers - }); - } - - getJoeInstances(token, orgId, projectId, instanceId) { - let params = {}; - let headers = { - Authorization: 'Bearer ' + token - }; - - if (orgId !== null && orgId !== 0) { - params.org_id = `eq.${orgId}`; - } - if (typeof projectId !== 'undefined' && projectId !== 0) { - params.project_id = `eq.${projectId}`; - } - if (typeof instanceId !== 'undefined' && instanceId !== 0) { - params.id = `eq.${instanceId}`; - } - - return this.get(`${this.apiServer}/joe_instances`, params, { - headers: headers - }); - } - - getJoeInstanceChannels(token, instanceId) { - let params = { - instance_id: instanceId - }; - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.get(`${this.apiServer}/rpc/joe_instance_channels_get`, params, { - headers: headers - }); - } - - sendJoeInstanceCommand(token, instanceId, channelId, command, sessionId) { - let params = { - instance_id: instanceId, - channel_id: channelId, - command: command - }; - let headers = { - Authorization: 'Bearer ' + token - }; - - if (sessionId !== null && sessionId !== 0) { - params.session_id = sessionId; - } - - return this.post(`${this.apiServer}/rpc/joe_command_send`, params, { - headers: headers - }); - } - - getJoeInstanceMessages(token, channelId, sessionId) { - let params = { - channel_id: `eq.${channelId}`, - session_id: `eq.${sessionId}` - }; - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.get(`${this.apiServer}/joe_messages`, params, { - headers: headers - }); - } - - getJoeMessageArtifacts(token, messageId) { - let params = { - message_id: `eq.${messageId}` - }; - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.get(`${this.apiServer}/joe_message_artifacts`, params, { - headers: headers - }); - } - - addJoeInstance(token, instanceData) { - let headers = { - Authorization: 'Bearer ' + token - }; - let params = { - url: instanceData.url, - org_id: instanceData.orgId, - token: instanceData.verifyToken, - project: instanceData.project, - use_tunnel: instanceData.useTunnel, - dry_run: instanceData.dryRun - }; - - if (instanceData.useTunnel && instanceData.sshServerUrl) { - params.ssh_server_url = instanceData.sshServerUrl; - } - - return this.post(`${this.apiServer}/rpc/joe_instance_create`, params, { - headers: headers - }); - } - - destroyJoeInstance(token, instanceId) { - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.post(`${this.apiServer}/rpc/joe_instance_destroy`, { - instance_id: instanceId - }, { - headers: headers - }); - } - - deleteJoeSessions(token, ids) { - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.post(`${this.apiServer}/rpc/joe_session_delete`, { - ids: ids - }, { - headers: headers - }); - } - - deleteJoeCommands(token, ids) { - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.post(`${this.apiServer}/rpc/joe_command_delete`, { ids }, - { headers }); - } - - - deleteCheckupReports(token, ids) { - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.post(`${this.apiServer}/rpc/checkup_report_delete`, { - ids: ids - }, { - headers: headers - }); - } - - joeCommandFavorite(token, commandId, favorite) { - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.post(`${this.apiServer}/rpc/joe_command_favorite`, { - command_id: parseInt(commandId, 10), - favorite - }, { headers }); - } - - getSharedUrlData(uuid) { - return this.get(`${this.apiServer}/rpc/shared_url_get_data`, { uuid }, {}); - } - - getSharedUrl(token, org_id, object_type, object_id) { - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.post(`${this.apiServer}/rpc/shared_url_get`, { - org_id, - object_type, - object_id - }, { headers }); - } - - addSharedUrl(token, urlParams) { - let headers = { - Authorization: 'Bearer ' + token - }; - let params = { - org_id: urlParams.orgId, - url: urlParams.url, - object_type: urlParams.objectType, - object_id: urlParams.objectId - }; - - if (urlParams.uuid) { - params['uuid'] = urlParams.uuid; - } - - return this.post(`${this.apiServer}/rpc/shared_url_add`, params, { headers }); - } - - removeSharedUrl(token, org_id, id) { - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.post(`${this.apiServer}/rpc/shared_url_remove`, { org_id, id }, { headers }); - } - - subscribeBilling(token, org_id, payment_method_id) { - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.post( - `${this.apiServer}/rpc/billing_subscribe`, - { org_id, payment_method_id }, - { headers } - ); - } - - getBillingDataUsage(token, orgId) { - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.get( - `${this.apiServer}/billing_data_usage`, - { org_id: `eq.${orgId}` }, - { headers } - ); - } - - getDbLabSessions(token, { orgId, projectId, instanceId, limit, lastId }) { - let headers = { - Authorization: 'Bearer ' + token, - Prefer: 'count=exact' - }; - - let params = { - org_id: `eq.${orgId}` - }; - - if (typeof projectId !== 'undefined' && projectId) { - params.project_id = `eq.$(projectId)`; - } - - if (typeof instanceId !== 'undefined' && instanceId) { - params.instance_id = `eq.$(instanceId)`; - } - - if (lastId) { - params.id = `lt.${lastId}`; - } - - if (limit) { - params.limit = limit; - } - - return this.get(`${this.apiServer}/dblab_sessions`, params, { - headers: headers - }); - } - - getDbLabSession(token, sessionId) { - let headers = { - Authorization: 'Bearer ' + token - }; - - let params = { - id: `eq.${sessionId}` - }; - - return this.get(`${this.apiServer}/dblab_sessions`, params, { - headers: headers - }); - } - - getDbLabSessionLogs(token, { sessionId, limit, lastId }) { - let headers = { - Authorization: 'Bearer ' + token, - Prefer: 'count=exact' - }; - - let params = { - dblab_session_id: `eq.${sessionId}` - }; - - if (lastId) { - params.id = `lt.${lastId}`; - } - - if (limit) { - params.limit = limit; - } - - return this.get(`${this.apiServer}/dblab_session_logs`, params, { - headers: headers - }); - } - - getDbLabSessionArtifacts(token, sessionId) { - let headers = { - Authorization: 'Bearer ' + token, - Prefer: 'count=exact' - }; - - let params = { - dblab_session_id: `eq.${sessionId}` - }; - - return this.get(`${this.apiServer}/dblab_session_artifacts`, params, { - headers: headers - }); - } - - getDbLabSessionArtifact(token, sessionId, artifactType) { - let headers = { - Authorization: 'Bearer ' + token, - Prefer: 'count=exact' - }; - - let params = { - dblab_session_id: `eq.${sessionId}`, - artifact_type: `eq.${artifactType}` - }; - - return this.get(`${this.apiServer}/dblab_session_artifacts_data`, params, { - headers: headers - }); - } - - updateOrgUser(token, org_id, user_id, role_id) { - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.post( - `${this.apiServer}/rpc/user_update_org_user`, - { org_id, user_id, role_id }, - { headers } - ); - } - - deleteOrgUser(token, org_id, user_id) { - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.post( - `${this.apiServer}/rpc/user_delete_org_user`, - { org_id, user_id }, - { headers } - ); - } - - getAuditLog(token, { orgId, lastId, limit }) { - let headers = { - Authorization: 'Bearer ' + token, - Prefer: 'count=exact' - }; - - let params = { - org_id: `eq.${orgId}` - }; - - if (lastId) { - params.id = `lt.${lastId}`; - } - - if (limit) { - params.limit = limit; - } - - return this.get(`${this.apiServer}/audit_log`, params, { - headers: headers - }); - } - - sendUserCode(token) { - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.post( - `${this.apiServer}/rpc/user_send_code`, - {}, - { headers } - ); - } - - confirmUserEmail(token, verification_code) { - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.post( - `${this.apiServer}/rpc/user_confirm_email`, - { verification_code }, - { headers } - ); - } - - confirmTosAgreement(token) { - let headers = { - Authorization: 'Bearer ' + token - }; - - return this.post( - `${this.apiServer}/rpc/user_confirm_tos_agreement`, - {}, - { headers } - ); - } -} - -export default Api; diff --git a/ui/packages/platform/src/api/clones/createClone.ts b/ui/packages/platform/src/api/clones/createClone.ts deleted file mode 100644 index 8a8b1f8b..00000000 --- a/ui/packages/platform/src/api/clones/createClone.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { CloneDto, formatCloneDto } from '@postgres.ai/shared/types/api/entities/clone' - -import { request } from 'helpers/request' - -type Req = { - instanceId: string - cloneId: string - snapshotId: string - dbUser: string - dbPassword: string - isProtected: boolean -} - -export const createClone = async (req: Req) => { - const response = await request('/rpc/dblab_clone_create', { - method: 'POST', - body: JSON.stringify({ - instance_id: req.instanceId, - clone_data: { - id: req.cloneId, - snapshot: { - id: req.snapshotId, - }, - db: { - username: req.dbUser, - password: req.dbPassword, - }, - protected: req.isProtected, - }, - }), - }) - - return { - response: response.ok ? formatCloneDto(await response.json() as CloneDto) : null, - error: response.ok ? null : response, - } -} diff --git a/ui/packages/platform/src/api/clones/getClone.ts b/ui/packages/platform/src/api/clones/getClone.ts deleted file mode 100644 index 629d9606..00000000 --- a/ui/packages/platform/src/api/clones/getClone.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { CloneDto, formatCloneDto } from '@postgres.ai/shared/types/api/entities/clone' - -import { request } from 'helpers/request' - -type Request = { - instanceId: string - cloneId: string -} - -export const getClone = async (req: Request) => { - const response = await request('/rpc/dblab_clone_status', { - method: 'POST', - body: JSON.stringify({ - instance_id: req.instanceId, - clone_id: req.cloneId, - }) - }) - - return { - response: response.ok ? formatCloneDto(await response.json() as CloneDto) : null, - error: response.ok ? null : response, - } -} diff --git a/ui/packages/platform/src/api/clones/updateClone.ts b/ui/packages/platform/src/api/clones/updateClone.ts deleted file mode 100644 index fb61b1ae..00000000 --- a/ui/packages/platform/src/api/clones/updateClone.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { UpdateClone } from '@postgres.ai/shared/types/api/endpoints/updateClone' - -import { request } from 'helpers/request' - -export const updateClone: UpdateClone = async (req) => { - const response = await request('/rpc/dblab_clone_update', { - method: 'POST', - body: JSON.stringify({ - instance_id: req.instanceId, - clone_id: req.cloneId, - clone: { - protected: req.clone.isProtected, - }, - }), - }) - - return { - response: response.ok ? true : null, - error: response.ok ? null : response, - } -} diff --git a/ui/packages/platform/src/api/explain/depesz.js b/ui/packages/platform/src/api/explain/depesz.js deleted file mode 100644 index 13dde5b0..00000000 --- a/ui/packages/platform/src/api/explain/depesz.js +++ /dev/null @@ -1,36 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import 'es6-promise/auto'; -import 'whatwg-fetch'; - -class ExplainDepeszApi { - constructor(setting) { - this.server = setting.explainDepeszServer; - } - - post(url, data, options = {}) { - let fetchOptions = { - ...options, - method: 'post', - body: data - }; - - return fetch(url, fetchOptions); - } - - postPlan(plan, query) { - const formData = new FormData(); - formData.append('is_public', '0'); - formData.append('plan', plan); - formData.append('query', query); - - return this.post(this.server, formData); - } -} - -export default ExplainDepeszApi; diff --git a/ui/packages/platform/src/api/explain/pev2.js b/ui/packages/platform/src/api/explain/pev2.js deleted file mode 100644 index 92ceb51f..00000000 --- a/ui/packages/platform/src/api/explain/pev2.js +++ /dev/null @@ -1,37 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import 'es6-promise/auto'; -import 'whatwg-fetch'; - -class ExplainPev2Api { - constructor(setting) { - this.server = setting.explainPev2Server; - } - - post(url, data, options = {}) { - let fetchOptions = { - ...options, - method: 'post', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(data) - }; - - return fetch(url, fetchOptions); - } - - postPlan(plan, query) { - return this.post(`${this.server}/api/rpc/post_plan`, { - plan: plan, - query: query || '' - }); - } -} - -export default ExplainPev2Api; diff --git a/ui/packages/platform/src/api/getMeta.ts b/ui/packages/platform/src/api/getMeta.ts deleted file mode 100644 index d88573c6..00000000 --- a/ui/packages/platform/src/api/getMeta.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { request } from '@postgres.ai/shared/helpers/request' - -import { MetaDto, formatMetaDto } from 'types/api/entities/meta' - -export const getMeta = async () => { - const response = await request('/meta.json') - - return { - response: response.ok ? formatMetaDto(await response.json() as MetaDto) : null, - error: response.ok ? null : response, - } -} diff --git a/ui/packages/platform/src/api/instances/getInstance.ts b/ui/packages/platform/src/api/instances/getInstance.ts deleted file mode 100644 index fdaf3354..00000000 --- a/ui/packages/platform/src/api/instances/getInstance.ts +++ /dev/null @@ -1,30 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import { - formatInstanceDto, - InstanceDto, -} from '@postgres.ai/shared/types/api/entities/instance' -import { GetInstance } from '@postgres.ai/shared/types/api/endpoints/getInstance' - -import { request } from 'helpers/request' - -export const getInstance: GetInstance = async (req) => { - const response = await request('/dblab_instances', { - params: { - id: `eq.${req.instanceId}`, - }, - }) - - return { - response: response.ok - ? ((await response.json()) as InstanceDto[]).map(formatInstanceDto)[0] ?? - null - : null, - error: response.ok ? null : response, - } -} diff --git a/ui/packages/platform/src/api/snapshots/getSnapshots.ts b/ui/packages/platform/src/api/snapshots/getSnapshots.ts deleted file mode 100644 index 35d08eb3..00000000 --- a/ui/packages/platform/src/api/snapshots/getSnapshots.ts +++ /dev/null @@ -1,30 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import { - SnapshotDto, - formatSnapshotDto, -} from '@postgres.ai/shared/types/api/entities/snapshot' -import { GetSnapshots } from '@postgres.ai/shared/types/api/endpoints/getSnapshots' - -import { request } from 'helpers/request' - -export const getSnapshots: GetSnapshots = async (req) => { - const response = await request('/rpc/dblab_instance_snapshots', { - method: 'POST', - body: JSON.stringify({ - instance_id: req.instanceId, - }), - }) - - return { - response: response.ok - ? ((await response.json()) as SnapshotDto[]).map(formatSnapshotDto) - : null, - error: response.ok ? null : response, - } -} diff --git a/ui/packages/platform/src/assets/explainSamples.js b/ui/packages/platform/src/assets/explainSamples.js deleted file mode 100644 index 87590585..00000000 --- a/ui/packages/platform/src/assets/explainSamples.js +++ /dev/null @@ -1,600 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -const sampleExplain1 = - `[ - { - "Plan": { - "Node Type": "Limit", - "Startup Cost": 17024.84, - "Total Cost": 17024.87, - "Plan Rows": 10, - "Plan Width": 133, - "Actual Startup Time": 725.773, - "Actual Total Time": 725.775, - "Actual Rows": 10, - "Actual Loops": 1, - "Output": ["c.state", "cat.categoryname", "(sum(o.netamount))", "(sum(o.totalamount))"], - "Shared Hit Blocks": 23, - "Shared Read Blocks": 1392, - "Shared Dirtied Blocks": 0, - "Shared Written Blocks": 0, - "Local Hit Blocks": 0, - "Local Read Blocks": 0, - "Local Dirtied Blocks": 0, - "Local Written Blocks": 0, - "Temp Read Blocks": 0, - "Temp Written Blocks": 0, - "I/O Read Time": 0.000, - "I/O Write Time": 0.000, - "Plans": [ - { - "Node Type": "Sort", - "Parent Relationship": "Outer", - "Startup Cost": 17024.84, - "Total Cost": 17026.88, - "Plan Rows": 816, - "Plan Width": 133, - "Actual Startup Time": 725.771, - "Actual Total Time": 725.772, - "Actual Rows": 11, - "Actual Loops": 1, - "Output": ["c.state", "cat.categoryname", "(sum(o.netamount))", "(sum(o.totalamount))"], - "Sort Key": ["c.state", "(sum(o.totalamount))"], - "Sort Method": "top-N heapsort", - "Sort Space Used": 25, - "Sort Space Type": "Memory", - "Shared Hit Blocks": 23, - "Shared Read Blocks": 1392, - "Shared Dirtied Blocks": 0, - "Shared Written Blocks": 0, - "Local Hit Blocks": 0, - "Local Read Blocks": 0, - "Local Dirtied Blocks": 0, - "Local Written Blocks": 0, - "Temp Read Blocks": 0, - "Temp Written Blocks": 0, - "I/O Read Time": 0.000, - "I/O Write Time": 0.000, - "Plans": [ - { - "Node Type": "Aggregate", - "Strategy": "Hashed", - "Parent Relationship": "Outer", - "Startup Cost": 16994.41, - "Total Cost": 17006.65, - "Plan Rows": 816, - "Plan Width": 133, - "Actual Startup Time": 723.877, - "Actual Total Time": 724.417, - "Actual Rows": 832, - "Actual Loops": 1, - "Output": ["c.state", "cat.categoryname", "sum(o.netamount)", "sum(o.totalamount)"], - "Group Key": ["c.state", "cat.categoryname"], - "Shared Hit Blocks": 13, - "Shared Read Blocks": 1392, - "Shared Dirtied Blocks": 0, - "Shared Written Blocks": 0, - "Local Hit Blocks": 0, - "Local Read Blocks": 0, - "Local Dirtied Blocks": 0, - "Local Written Blocks": 0, - "Temp Read Blocks": 0, - "Temp Written Blocks": 0, - "I/O Read Time": 0.000, - "I/O Write Time": 0.000, - "Plans": [ - { - "Node Type": "Hash Join", - "Parent Relationship": "Outer", - "Join Type": "Inner", - "Startup Cost": 4966.48, - "Total Cost": 13742.65, - "Plan Rows": 325176, - "Plan Width": 133, - "Actual Startup Time": 118.314, - "Actual Total Time": 354.285, - "Actual Rows": 383270, - "Actual Loops": 1, - "Output": ["c.state", "o.netamount", "o.totalamount", "cat.categoryname"], - "Hash Cond": "(o.orderid = ch.orderid)", - "Shared Hit Blocks": 13, - "Shared Read Blocks": 1392, - "Shared Dirtied Blocks": 0, - "Shared Written Blocks": 0, - "Local Hit Blocks": 0, - "Local Read Blocks": 0, - "Local Dirtied Blocks": 0, - "Local Written Blocks": 0, - "Temp Read Blocks": 0, - "Temp Written Blocks": 0, - "I/O Read Time": 0.000, - "I/O Write Time": 0.000, - "Plans": [ - { - "Node Type": "Hash Join", - "Parent Relationship": "Outer", - "Join Type": "Inner", - "Startup Cost": 834.86, - "Total Cost": 4539.11, - "Plan Rows": 60350, - "Plan Width": 138, - "Actual Startup Time": 22.651, - "Actual Total Time": 133.484, - "Actual Rows": 60350, - "Actual Loops": 1, - "Output": [ - "o.netamount", - "o.totalamount", - "o.orderid", - "ol.orderid", - "cat.categoryname" - ], - "Hash Cond": "(ol.orderid = o.orderid)", - "Shared Hit Blocks": 9, - "Shared Read Blocks": 581, - "Shared Dirtied Blocks": 0, - "Shared Written Blocks": 0, - "Local Hit Blocks": 0, - "Local Read Blocks": 0, - "Local Dirtied Blocks": 0, - "Local Written Blocks": 0, - "Temp Read Blocks": 0, - "Temp Written Blocks": 0, - "I/O Read Time": 0.000, - "I/O Write Time": 0.000, - "Plans": [ - { - "Node Type": "Hash Join", - "Parent Relationship": "Outer", - "Join Type": "Inner", - "Startup Cost": 464.86, - "Total Cost": 2962.11, - "Plan Rows": 60350, - "Plan Width": 122, - "Actual Startup Time": 12.467, - "Actual Total Time": 85.647, - "Actual Rows": 60350, - "Actual Loops": 1, - "Output": ["ol.orderid", "cat.categoryname"], - "Hash Cond": "(ol.prod_id = p.prod_id)", - "Shared Hit Blocks": 4, - "Shared Read Blocks": 483, - "Shared Dirtied Blocks": 0, - "Shared Written Blocks": 0, - "Local Hit Blocks": 0, - "Local Read Blocks": 0, - "Local Dirtied Blocks": 0, - "Local Written Blocks": 0, - "Temp Read Blocks": 0, - "Temp Written Blocks": 0, - "I/O Read Time": 0.000, - "I/O Write Time": 0.000, - "Plans": [ - { - "Node Type": "Seq Scan", - "Parent Relationship": "Outer", - "Relation Name": "orderlines", - "Schema": "public", - "Alias": "ol", - "Startup Cost": 0.00, - "Total Cost": 988.50, - "Plan Rows": 60350, - "Plan Width": 8, - "Actual Startup Time": 0.005, - "Actual Total Time": 14.054, - "Actual Rows": 60350, - "Actual Loops": 1, - "Output": [ - "ol.orderlineid", - "ol.orderid", - "ol.prod_id", - "ol.quantity", - "ol.orderdate" - ], - "Shared Hit Blocks": 2, - "Shared Read Blocks": 383, - "Shared Dirtied Blocks": 0, - "Shared Written Blocks": 0, - "Local Hit Blocks": 0, - "Local Read Blocks": 0, - "Local Dirtied Blocks": 0, - "Local Written Blocks": 0, - "Temp Read Blocks": 0, - "Temp Written Blocks": 0, - "I/O Read Time": 0.000, - "I/O Write Time": 0.000 - }, - { - "Node Type": "Hash", - "Parent Relationship": "Inner", - "Startup Cost": 339.86, - "Total Cost": 339.86, - "Plan Rows": 10000, - "Plan Width": 122, - "Actual Startup Time": 12.446, - "Actual Total Time": 12.446, - "Actual Rows": 10000, - "Actual Loops": 1, - "Output": ["p.prod_id", "cat.categoryname"], - "Hash Buckets": 1024, - "Hash Batches": 1, - "Original Hash Batches": 1, - "Peak Memory Usage": 425, - "Shared Hit Blocks": 2, - "Shared Read Blocks": 100, - "Shared Dirtied Blocks": 0, - "Shared Written Blocks": 0, - "Local Hit Blocks": 0, - "Local Read Blocks": 0, - "Local Dirtied Blocks": 0, - "Local Written Blocks": 0, - "Temp Read Blocks": 0, - "Temp Written Blocks": 0, - "I/O Read Time": 0.000, - "I/O Write Time": 0.000, - "Plans": [ - { - "Node Type": "Hash Join", - "Parent Relationship": "Outer", - "Join Type": "Inner", - "Startup Cost": 1.36, - "Total Cost": 339.86, - "Plan Rows": 10000, - "Plan Width": 122, - "Actual Startup Time": 0.283, - "Actual Total Time": 9.015, - "Actual Rows": 10000, - "Actual Loops": 1, - "Output": ["p.prod_id", "cat.categoryname"], - "Hash Cond": "(p.category = cat.category)", - "Shared Hit Blocks": 2, - "Shared Read Blocks": 100, - "Shared Dirtied Blocks": 0, - "Shared Written Blocks": 0, - "Local Hit Blocks": 0, - "Local Read Blocks": 0, - "Local Dirtied Blocks": 0, - "Local Written Blocks": 0, - "Temp Read Blocks": 0, - "Temp Written Blocks": 0, - "I/O Read Time": 0.000, - "I/O Write Time": 0.000, - "Plans": [ - { - "Node Type": "Seq Scan", - "Parent Relationship": "Outer", - "Relation Name": "products", - "Schema": "public", - "Alias": "p", - "Startup Cost": 0.00, - "Total Cost": 201.00, - "Plan Rows": 10000, - "Plan Width": 8, - "Actual Startup Time": 0.003, - "Actual Total Time": 4.330, - "Actual Rows": 10000, - "Actual Loops": 1, - "Output": [ - "p.prod_id", - "p.category", - "p.title", - "p.actor", - "p.price", - "p.special", - "p.common_prod_id" - ], - "Shared Hit Blocks": 2, - "Shared Read Blocks": 99, - "Shared Dirtied Blocks": 0, - "Shared Written Blocks": 0, - "Local Hit Blocks": 0, - "Local Read Blocks": 0, - "Local Dirtied Blocks": 0, - "Local Written Blocks": 0, - "Temp Read Blocks": 0, - "Temp Written Blocks": 0, - "I/O Read Time": 0.000, - "I/O Write Time": 0.000 - }, - { - "Node Type": "Hash", - "Parent Relationship": "Inner", - "Startup Cost": 1.16, - "Total Cost": 1.16, - "Plan Rows": 16, - "Plan Width": 122, - "Actual Startup Time": 0.265, - "Actual Total Time": 0.265, - "Actual Rows": 16, - "Actual Loops": 1, - "Output": [ - "cat.categoryname", - "cat.category" - ], - "Hash Buckets": 1024, - "Hash Batches": 1, - "Original Hash Batches": 1, - "Peak Memory Usage": 1, - "Shared Hit Blocks": 0, - "Shared Read Blocks": 1, - "Shared Dirtied Blocks": 0, - "Shared Written Blocks": 0, - "Local Hit Blocks": 0, - "Local Read Blocks": 0, - "Local Dirtied Blocks": 0, - "Local Written Blocks": 0, - "Temp Read Blocks": 0, - "Temp Written Blocks": 0, - "I/O Read Time": 0.000, - "I/O Write Time": 0.000, - "Plans": [ - { - "Node Type": "Seq Scan", - "Parent Relationship": "Outer", - "Relation Name": "categories", - "Schema": "public", - "Alias": "cat", - "Startup Cost": 0.00, - "Total Cost": 1.16, - "Plan Rows": 16, - "Plan Width": 122, - "Actual Startup Time": 0.250, - "Actual Total Time": 0.252, - "Actual Rows": 16, - "Actual Loops": 1, - "Output": ["cat.categoryname", "cat.category"], - "Shared Hit Blocks": 0, - "Shared Read Blocks": 1, - "Shared Dirtied Blocks": 0, - "Shared Written Blocks": 0, - "Local Hit Blocks": 0, - "Local Read Blocks": 0, - "Local Dirtied Blocks": 0, - "Local Written Blocks": 0, - "Temp Read Blocks": 0, - "Temp Written Blocks": 0, - "I/O Read Time": 0.000, - "I/O Write Time": 0.000 - } - ] - } - ] - } - ] - } - ] - }, - { - "Node Type": "Hash", - "Parent Relationship": "Inner", - "Startup Cost": 220.00, - "Total Cost": 220.00, - "Plan Rows": 12000, - "Plan Width": 16, - "Actual Startup Time": 10.159, - "Actual Total Time": 10.159, - "Actual Rows": 12000, - "Actual Loops": 1, - "Output": ["o.netamount", "o.totalamount", "o.orderid"], - "Hash Buckets": 2048, - "Hash Batches": 1, - "Original Hash Batches": 1, - "Peak Memory Usage": 609, - "Shared Hit Blocks": 2, - "Shared Read Blocks": 98, - "Shared Dirtied Blocks": 0, - "Shared Written Blocks": 0, - "Local Hit Blocks": 0, - "Local Read Blocks": 0, - "Local Dirtied Blocks": 0, - "Local Written Blocks": 0, - "Temp Read Blocks": 0, - "Temp Written Blocks": 0, - "I/O Read Time": 0.000, - "I/O Write Time": 0.000, - "Plans": [ - { - "Node Type": "Seq Scan", - "Parent Relationship": "Outer", - "Relation Name": "orders", - "Schema": "public", - "Alias": "o", - "Startup Cost": 0.00, - "Total Cost": 220.00, - "Plan Rows": 12000, - "Plan Width": 16, - "Actual Startup Time": 0.008, - "Actual Total Time": 5.548, - "Actual Rows": 12000, - "Actual Loops": 1, - "Output": ["o.netamount", "o.totalamount", "o.orderid"], - "Shared Hit Blocks": 2, - "Shared Read Blocks": 98, - "Shared Dirtied Blocks": 0, - "Shared Written Blocks": 0, - "Local Hit Blocks": 0, - "Local Read Blocks": 0, - "Local Dirtied Blocks": 0, - "Local Written Blocks": 0, - "Temp Read Blocks": 0, - "Temp Written Blocks": 0, - "I/O Read Time": 0.000, - "I/O Write Time": 0.000 - } - ] - } - ] - }, - { - "Node Type": "Hash", - "Parent Relationship": "Inner", - "Startup Cost": 3377.25, - "Total Cost": 3377.25, - "Plan Rows": 60350, - "Plan Width": 7, - "Actual Startup Time": 95.610, - "Actual Total Time": 95.610, - "Actual Rows": 60350, - "Actual Loops": 1, - "Output": ["c.state", "ch.orderid"], - "Hash Buckets": 8192, - "Hash Batches": 1, - "Original Hash Batches": 1, - "Peak Memory Usage": 2239, - "Shared Hit Blocks": 4, - "Shared Read Blocks": 811, - "Shared Dirtied Blocks": 0, - "Shared Written Blocks": 0, - "Local Hit Blocks": 0, - "Local Read Blocks": 0, - "Local Dirtied Blocks": 0, - "Local Written Blocks": 0, - "Temp Read Blocks": 0, - "Temp Written Blocks": 0, - "I/O Read Time": 0.000, - "I/O Write Time": 0.000, - "Plans": [ - { - "Node Type": "Hash Join", - "Parent Relationship": "Outer", - "Join Type": "Inner", - "Startup Cost": 938.00, - "Total Cost": 3377.25, - "Plan Rows": 60350, - "Plan Width": 7, - "Actual Startup Time": 24.115, - "Actual Total Time": 74.639, - "Actual Rows": 60350, - "Actual Loops": 1, - "Output": ["c.state", "ch.orderid"], - "Hash Cond": "(ch.customerid = c.customerid)", - "Shared Hit Blocks": 4, - "Shared Read Blocks": 811, - "Shared Dirtied Blocks": 0, - "Shared Written Blocks": 0, - "Local Hit Blocks": 0, - "Local Read Blocks": 0, - "Local Dirtied Blocks": 0, - "Local Written Blocks": 0, - "Temp Read Blocks": 0, - "Temp Written Blocks": 0, - "I/O Read Time": 0.000, - "I/O Write Time": 0.000, - "Plans": [ - { - "Node Type": "Seq Scan", - "Parent Relationship": "Outer", - "Relation Name": "cust_hist", - "Schema": "public", - "Alias": "ch", - "Startup Cost": 0.00, - "Total Cost": 930.50, - "Plan Rows": 60350, - "Plan Width": 8, - "Actual Startup Time": 0.294, - "Actual Total Time": 11.812, - "Actual Rows": 60350, - "Actual Loops": 1, - "Output": ["ch.customerid", "ch.orderid", "ch.prod_id"], - "Shared Hit Blocks": 2, - "Shared Read Blocks": 325, - "Shared Dirtied Blocks": 0, - "Shared Written Blocks": 0, - "Local Hit Blocks": 0, - "Local Read Blocks": 0, - "Local Dirtied Blocks": 0, - "Local Written Blocks": 0, - "Temp Read Blocks": 0, - "Temp Written Blocks": 0, - "I/O Read Time": 0.000, - "I/O Write Time": 0.000 - }, - { - "Node Type": "Hash", - "Parent Relationship": "Inner", - "Startup Cost": 688.00, - "Total Cost": 688.00, - "Plan Rows": 20000, - "Plan Width": 7, - "Actual Startup Time": 23.786, - "Actual Total Time": 23.786, - "Actual Rows": 20000, - "Actual Loops": 1, - "Output": ["c.state", "c.customerid"], - "Hash Buckets": 2048, - "Hash Batches": 1, - "Original Hash Batches": 1, - "Peak Memory Usage": 743, - "Shared Hit Blocks": 2, - "Shared Read Blocks": 486, - "Shared Dirtied Blocks": 0, - "Shared Written Blocks": 0, - "Local Hit Blocks": 0, - "Local Read Blocks": 0, - "Local Dirtied Blocks": 0, - "Local Written Blocks": 0, - "Temp Read Blocks": 0, - "Temp Written Blocks": 0, - "I/O Read Time": 0.000, - "I/O Write Time": 0.000, - "Plans": [ - { - "Node Type": "Seq Scan", - "Parent Relationship": "Outer", - "Relation Name": "customers", - "Schema": "public", - "Alias": "c", - "Startup Cost": 0.00, - "Total Cost": 688.00, - "Plan Rows": 20000, - "Plan Width": 7, - "Actual Startup Time": 0.005, - "Actual Total Time": 16.771, - "Actual Rows": 20000, - "Actual Loops": 1, - "Output": ["c.state", "c.customerid"], - "Shared Hit Blocks": 2, - "Shared Read Blocks": 486, - "Shared Dirtied Blocks": 0, - "Shared Written Blocks": 0, - "Local Hit Blocks": 0, - "Local Read Blocks": 0, - "Local Dirtied Blocks": 0, - "Local Written Blocks": 0, - "Temp Read Blocks": 0, - "Temp Written Blocks": 0, - "I/O Read Time": 0.000, - "I/O Write Time": 0.000 - } - ] - } - ] - } - ] - } - ] - } - ] - } - ] - } - ] - }, - "Planning Time": 26.171, - "Triggers": [ - ], - "Execution Time": 726.800 - } -]`; - -const explainSamples = [{ - value: sampleExplain1, - label: 'Sample 1' -}]; - -export default explainSamples; diff --git a/ui/packages/platform/src/assets/messages.js b/ui/packages/platform/src/assets/messages.js deleted file mode 100644 index 66d43a13..00000000 --- a/ui/packages/platform/src/assets/messages.js +++ /dev/null @@ -1,11 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -export default { - noPermission: 'You do not have permission to do this.', - noPermissionPage: 'You do not have permission to view this page.' -}; diff --git a/ui/packages/platform/src/assets/plans.js b/ui/packages/platform/src/assets/plans.js deleted file mode 100644 index 0a2d98ae..00000000 --- a/ui/packages/platform/src/assets/plans.js +++ /dev/null @@ -1,26 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import ConsoleColors from '../styles/ConsoleColors'; - -export default { - ce: { - id: 'ce', - name: 'CE', - title: 'Postgres.ai Community Edition', - color: ConsoleColors.secondary2.main, - limits: { - maxDblabInstances: 1, - maxJoeInstances: 1, - daysJoeHistory: 14, - emailDomainRestricted: true - } - }, - ee_gold_monthly: { - color: ConsoleColors.pgaiOrange - } -}; diff --git a/ui/packages/platform/src/assets/visualizeTypes.js b/ui/packages/platform/src/assets/visualizeTypes.js deleted file mode 100644 index f1fd6ee2..00000000 --- a/ui/packages/platform/src/assets/visualizeTypes.js +++ /dev/null @@ -1,12 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -export default { - depesz: 'depesz', - pev2: 'pev2', - flame: 'flame-graph' -}; diff --git a/ui/packages/platform/src/components/AccessTokens.js b/ui/packages/platform/src/components/AccessTokens.js deleted file mode 100644 index 10135def..00000000 --- a/ui/packages/platform/src/components/AccessTokens.js +++ /dev/null @@ -1,423 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import { Component } from 'react'; -import PropTypes from 'prop-types'; -import { withStyles } from '@material-ui/core/styles'; -import { - Table, - TableBody, - TableCell, - TableHead, - TableRow, - TextField, - Button, - FormControlLabel, - Checkbox -} from '@material-ui/core'; - -import { - HorizontalScrollContainer -} from '@postgres.ai/shared/components/HorizontalScrollContainer'; -import { styles } from '@postgres.ai/shared/styles/styles'; -import { PageSpinner } from '@postgres.ai/shared/components/PageSpinner'; - -import Store from '../stores/store'; -import Actions from '../actions/actions'; -import Error from './Error'; -import DisplayToken from './DisplayToken'; -import ConsoleBreadcrumbs from './ConsoleBreadcrumbs'; -import ConsolePageTitle from './ConsolePageTitle'; - -const getStyles = theme => ({ - root: { - ...styles.root, - display: 'flex', - flexDirection: 'column', - paddingBottom: '20px' - }, - container: { - display: 'flex', - flexWrap: 'wrap' - }, - textField: { - ...styles.inputField, - maxWidth: 400, - marginBottom: 15, - marginRight: theme.spacing(1), - marginTop: '16px' - }, - nameField: { - ...styles.inputField, - maxWidth: 400, - marginBottom: 15, - width: '400px', - marginRight: theme.spacing(1) - }, - addTokenButton: { - marginTop: 15, - height: '33px', - marginBottom: 10 - }, - revokeButton: { - paddingRight: 5, - paddingLeft: 5, - paddingTop: 3, - paddingBottom: 3 - }, - errorMessage: { - color: 'red', - width: '100%' - }, - remark: { - width: '100%', - maxWidth: 960 - }, - bottomSpace: { - ...styles.bottomSpace - } -}); - -class AccessTokens extends Component { - state = { - tokenName: '', - tokenExpires: '', - processed: false, - isPersonal: true - }; - - handleChange = event => { - const name = event.target.name; - const value = event.target.value; - - if (name === 'tokenName') { - this.setState({ tokenName: value }); - } else if (name === 'tokenExpires') { - this.setState({ tokenExpires: value }); - } else if (name === 'isPersonal') { - this.setState({ isPersonal: event.target.checked }); - } - } - - componentDidMount() { - const that = this; - const orgId = this.props.orgId ? this.props.orgId : null; - let date = new Date(); - let expiresDate = (date.getFullYear() + 1) + '-' + - ('0' + (date.getMonth() + 1)).slice(-2) + - '-' + ('0' + date.getDate()).slice(-2); - - document.getElementsByTagName('html')[0].style.overflow = 'hidden'; - - this.unsubscribe = Store.listen(function () { - const auth = this.data && this.data.auth ? this.data.auth : null; - const userTokens = this.data && this.data.userTokens ? - this.data.userTokens : null; - const tokenRequest = this.data && this.data.tokenRequest ? - this.data.tokenRequest : null; - - that.setState({ data: this.data }); - - if (auth && auth.token && (!userTokens.isProcessed || - orgId !== userTokens.orgId) && !userTokens.isProcessing && - !userTokens.error) { - Actions.getAccessTokens(auth.token, orgId); - } - - if (tokenRequest && tokenRequest.isProcessed && !tokenRequest.error && - tokenRequest.data && tokenRequest.data.name === that.state.tokenName && - tokenRequest.data.expires_at && tokenRequest.data.token) { - that.setState({ - tokenName: '', - tokenExpires: expiresDate, - processed: false, - isPersonal: true - }); - } - }); - - that.setState({ tokenName: '', tokenExpires: expiresDate, processed: false }); - - Actions.refresh(); - } - - componentWillUnmount() { - Actions.hideGeneratedAccessToken(); - this.unsubscribe(); - } - - addToken = () => { - const orgId = this.props.orgId ? this.props.orgId : null; - const auth = this.state.data && this.state.data.auth ? - this.state.data.auth : null; - const tokenRequest = this.state.data && this.state.data.tokenRequest ? - this.state.data.tokenRequest : null; - - if (this.state.tokenName === null || this.state.tokenName === '' || - this.state.tokenExpires === null || this.state.tokenExpires === '') { - this.setState({ processed: true }); - return; - } - - if (auth && auth.token && !tokenRequest.isProcessing) { - Actions.getAccessToken(auth.token, this.state.tokenName, - this.state.tokenExpires, orgId, this.state.isPersonal); - } - } - - getTodayDate() { - const date = new Date(); - - return date.getFullYear() + '-' + ('0' + (date.getMonth() + 1)).slice(-2) + - '-' + ('0' + date.getDate()).slice(-2); - } - - revokeToken = (event, id, name) => { - const orgId = this.props.orgId ? this.props.orgId : null; - const auth = this.state.data && this.state.data.auth ? - this.state.data.auth : null; - - /* eslint no-alert: 0 */ - if (window.confirm('Are you sure you want to revoke token "' + - name + '"?') === true) { - Actions.revokeAccessToken(auth.token, orgId, id); - } - } - - render() { - const { classes, orgPermissions, orgId } = this.props; - const data = this.state && this.state.data ? - this.state.data.userTokens : null; - const tokenRequest = this.state && this.state.data && - this.state.data.tokenRequest ? this.state.data.tokenRequest : null; - const pageTitle = ( - - ); - - let tokenDisplay = null; - if (tokenRequest && tokenRequest.isProcessed && !tokenRequest.error && - tokenRequest.data && tokenRequest.data.name && - tokenRequest.data.expires_at && tokenRequest.data.token) { - tokenDisplay = ( -
-

{tokenRequest.data.is_personal ? 'Your new personal access token' : - 'New administrative access token'}

- -
- ); - } - - let tokenError = null; - if (tokenRequest && tokenRequest.error) { - tokenError = ( -
- {tokenRequest.errorMessage} -
- ); - } - - const tokenForm = ( -
-

Add token

-
- { tokenError } - - - - - - - } - label='Personal token' - /> - - -
-
- ); - - let breadcrumbs = ( - - ); - - if (this.state && this.state.data && this.state.data.userTokens.error) { - return ( -
- {breadcrumbs} - - {pageTitle} - -

Access tokens

- -
- ); - } - - if (!data || (data && data.isProcessing) || (data && data.orgId !== orgId)) { - return ( -
- {breadcrumbs} - {pageTitle} - - -
- ); - } - - return ( -
- {breadcrumbs} - - {pageTitle} - - {tokenDisplay} - - {tokenForm} - -
- Users may manage their personal tokens only. Admins may manage their -  personal tokens, as well as administrative (impersonal) tokens -  used to organize infrastructure. Tokens of all types work in -  the context of a particular organization. -
- -
-

Active access tokens

- - {data.data.length > 0 ? ( - - - - - Name - Type - Creator - Created - Expires - Actions - - - - - {data.data.map(t => { - return ( - - {t.name} - - {t.is_personal ? 'Personal' : 'Administrative'} - - {t.username} - {t.created_formatted} - {t.expires_formatted} - - - - - ); - })} - -
-
) : 'This user has no active access tokens' - } - -
-
- ); - } -} - -AccessTokens.propTypes = { - classes: PropTypes.object.isRequired, - theme: PropTypes.object.isRequired -}; - -export default withStyles(getStyles, { withTheme: true })(AccessTokens); diff --git a/ui/packages/platform/src/components/AddMemberForm.js b/ui/packages/platform/src/components/AddMemberForm.js deleted file mode 100644 index 9c3c3ae7..00000000 --- a/ui/packages/platform/src/components/AddMemberForm.js +++ /dev/null @@ -1,234 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import { Component } from 'react'; -import Button from '@material-ui/core/Button'; -import Grid from '@material-ui/core/Grid'; -import PropTypes from 'prop-types'; -import TextField from '@material-ui/core/TextField'; -import { withStyles } from '@material-ui/core/styles'; - -import { styles } from '@postgres.ai/shared/styles/styles'; -import { PageSpinner } from '@postgres.ai/shared/components/PageSpinner'; - -import Actions from '../actions/actions'; -import ConsoleBreadcrumbs from './ConsoleBreadcrumbs'; -import ConsolePageTitle from './ConsolePageTitle'; -import Error from './Error'; -import Store from '../stores/store'; -import Warning from './Warning'; -import messages from '../assets/messages'; - - -const getStyles = () => ({ - container: { - display: 'flex', - flexWrap: 'wrap' - }, - textField: { - ...styles.inputField, - maxWidth: 400 - }, - dense: { - marginTop: 10 - }, - errorMessage: { - color: 'red' - }, - button: { - marginTop: 17, - display: 'inline-block', - marginLeft: 7 - } -}); - -class InviteForm extends Component { - state = { - email: '' - }; - - componentDidMount() { - const that = this; - const { org, orgId } = this.props; - - this.unsubscribe = Store.listen(function () { - that.setState({ data: this.data }); - - if (this.data.inviteUser.isProcessed && !this.data.inviteUser.error) { - that.props.history.push('/' + org + '/members'); - } - - const auth = this.data && this.data.auth ? this.data.auth : null; - const orgProfile = this.data && this.data.orgProfile ? - this.data.orgProfile : null; - - if (auth && auth.token && orgProfile && - orgProfile.orgId !== orgId && !orgProfile.isProcessing && !orgProfile.error) { - Actions.getOrgs(auth.token, orgId); - } - }); - - Actions.refresh(); - } - - componentWillUnmount() { - this.unsubscribe(); - } - - handleChange = event => { - const name = event.target.name; - const value = event.target.value; - - this.setState({ - [name]: value - }); - } - - buttonHandler = () => { - const orgId = this.props.orgId ? this.props.orgId : null; - const auth = this.state.data && this.state.data.auth ? - this.state.data.auth : null; - const data = this.state.data ? this.state.data.inviteUser : null; - - if (auth && data && !data.isUpdating && this.state.email) { - Actions.inviteUser(auth.token, orgId, this.state.email.trim()); - } - } - - render() { - const { classes, orgPermissions, theme } = this.props; - - const breadcrumbs = ( - - ); - - const pageTitle = ( - - ); - - if (orgPermissions && !orgPermissions.settingsMemberAdd) { - return ( -
- { breadcrumbs } - - { pageTitle } - - { messages.noPermissionPage } -
- ); - } - - if (this.state && this.state.data && this.state.data.orgProfile.error) { - return ( -
- { breadcrumbs } - - { pageTitle } - - -
- ); - } - - if (!this.state || !this.state.data || - !(this.state.data.orgProfile && this.state.data.orgProfile.isProcessed)) { - return ( -
- { breadcrumbs } - - { pageTitle } - - -
- ); - } - - const inviteData = this.state.data.inviteUser; - - return ( -
- { breadcrumbs } - - { pageTitle } - -
- If the person is not registered yet, ask them to register first. -
- -
- {inviteData && inviteData.errorMessage ? ( -
{inviteData.errorMessage}
- ) : null} -
- - - - - - - - - - - - -
- ); - } -} - -InviteForm.propTypes = { - classes: PropTypes.object.isRequired, - theme: PropTypes.object.isRequired -}; - -export default withStyles(getStyles, { withTheme: true })(InviteForm); diff --git a/ui/packages/platform/src/components/AppUpdateBanner/index.tsx b/ui/packages/platform/src/components/AppUpdateBanner/index.tsx deleted file mode 100644 index 05f68684..00000000 --- a/ui/packages/platform/src/components/AppUpdateBanner/index.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import { observer } from 'mobx-react-lite' - -import { icons } from '@postgres.ai/shared/styles/icons' -import { Button } from '@postgres.ai/shared/components/Button' - -import { appStore } from 'stores/app' - -import styles from './styles.module.scss' - -export const AppUpdateBanner = observer(() => { - if (!appStore.isOutdatedVersion) return null - - return ( -
-
- {icons.updateIcon} UI update is available -
- -
- ) -}) diff --git a/ui/packages/platform/src/components/AppUpdateBanner/styles.module.scss b/ui/packages/platform/src/components/AppUpdateBanner/styles.module.scss deleted file mode 100644 index cc51c1d2..00000000 --- a/ui/packages/platform/src/components/AppUpdateBanner/styles.module.scss +++ /dev/null @@ -1,14 +0,0 @@ -.root { - display: flex; - align-items: center; - flex-wrap: wrap; - background-color: #d7eef2; - padding: 4px 14px; - color: #013a44; -} - -.text { - display: flex; - align-items: center; - margin-right: 16px; -} diff --git a/ui/packages/platform/src/components/Audit.js b/ui/packages/platform/src/components/Audit.js deleted file mode 100644 index 680622a0..00000000 --- a/ui/packages/platform/src/components/Audit.js +++ /dev/null @@ -1,457 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import React, { Component } from 'react'; -import PropTypes from 'prop-types'; -import { withStyles } from '@material-ui/core/styles'; -import { - Table, TableBody, TableCell, TableHead, TableRow, Button -} from '@material-ui/core'; -import ExpansionPanel from '@material-ui/core/ExpansionPanel'; -import ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary'; -import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails'; -import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; -import TextField from '@material-ui/core/TextField'; - -import { - HorizontalScrollContainer -} from '@postgres.ai/shared/components/HorizontalScrollContainer'; -import { PageSpinner } from '@postgres.ai/shared/components/PageSpinner'; -import { Spinner } from '@postgres.ai/shared/components/Spinner'; -import { styles } from '@postgres.ai/shared/styles/styles'; - -import Actions from '../actions/actions'; -import ConsoleBreadcrumbs from './ConsoleBreadcrumbs'; -import ConsolePageTitle from './ConsolePageTitle'; -import Error from './Error'; -import Store from '../stores/store'; -import Warning from './Warning'; -import messages from '../assets/messages'; -import format from '../utils/format'; - -const PAGE_SIZE = 20; - -const getStyles = theme => ({ - root: { - ...styles.root, - display: 'flex', - flexDirection: 'column', - paddingBottom: '20px' - }, - container: { - display: 'flex', - flexWrap: 'wrap' - }, - textField: { - marginLeft: theme.spacing(1), - marginRight: theme.spacing(1), - width: '80%' - }, - dense: { - marginTop: 16 - }, - menu: { - width: 200 - }, - updateButtonContainer: { - marginTop: 20, - textAlign: 'right' - }, - errorMessage: { - color: 'red' - }, - orgsHeader: { - position: 'relative' - }, - newOrgBtn: { - position: 'absolute', - top: 0, - right: 10 - }, - timeCell: { - verticalAlign: 'top', - minWidth: 200 - }, - expansionPanel: { - boxShadow: 'none', - background: 'transparent', - fontSize: '12px', - marginBottom: '5px' - }, - expansionPanelSummary: { - 'display': 'inline-block', - 'padding': '0px', - 'minHeight': '22px', - '& .MuiExpansionPanelSummary-content': { - margin: '0px', - display: 'inline-block' - }, - '&.Mui-expanded': { - minHeight: '22px' - }, - '& .MuiExpansionPanelSummary-expandIcon': { - display: 'inline-block', - padding: '0px' - } - }, - expansionPanelDetails: { - padding: '0px', - [theme.breakpoints.down('md')]: { - display: 'block' - } - }, - actionDescription: { - marginBottom: '5px' - }, - code: { - 'width': '100%', - 'margin-top': 0, - '& > div': { - paddingTop: 8, - padding: 8 - }, - 'background-color': 'rgb(246, 248, 250)', - '& > div > textarea': { - fontFamily: '"Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas",' + - ' "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace', - color: 'black', - fontSize: '12px' - } - }, - showMoreContainer: { - marginTop: 20, - textAlign: 'center' - }, - data: { - width: '50%', - [theme.breakpoints.up('md')]: { - width: '50%', - marginRight: '10px' - } - }, - bottomSpace: { - ...styles.bottomSpace - } -}); - -const auditTitle = 'Audit log'; - -class Audit extends Component { - componentDidMount() { - const that = this; - const orgId = this.props.orgId; - - this.unsubscribe = Store.listen(function () { - const auth = this.data && this.data.auth ? this.data.auth : null; - const auditLog = this.data && this.data.auditLog ? this.data.auditLog : - null; - - that.setState({ data: this.data }); - - if (auth && auth.token && auditLog && - !auditLog.isProcessing && !auditLog.error && !that.state) { - Actions.getAuditLog( - auth.token, - { - orgId, - limit: PAGE_SIZE - } - ); - } - }); - - let contentContainer = document.getElementById('content-container'); - if (contentContainer) { - contentContainer.addEventListener('scroll', () => { - if (contentContainer.scrollTop >= - (contentContainer.scrollHeight - contentContainer.offsetHeight)) { - if (that.refs.showMoreBtn) { - that.refs.showMoreBtn.click(); - } - } - }); - } - - Actions.refresh(); - } - - componentWillUnmount() { - this.unsubscribe(); - } - - handleChange = event => { - const name = event.target.name; - const value = event.target.value; - - this.setState({ - [name]: value - }); - } - - buttonAddHandler = () => { - const org = this.props.org ? this.props.org : null; - - this.props.history.push('/' + org + '/members/add'); - } - - showMore() { - const { orgId } = this.props; - const auth = this.state.data && this.state.data.auth ? - this.state.data.auth : null; - const logs = this.state && this.state.data ? this.state.data.auditLog : []; - let lastId = null; - - if (logs && logs.data && logs.data.length) { - lastId = logs.data[logs.data.length - 1].id; - } - - if (auth && auth.token && !logs.isProcessing && lastId) { - Actions.getAuditLog( - auth.token, - { - orgId, - limit: PAGE_SIZE, - lastId - } - ); - } - } - - formatAction = (r) => { - const { classes } = this.props; - let acted = r.action; - let actor = r.actor; - let actorSrc = ''; - let rows = 'row'; - - if (!actor) { - actor = 'Unknown'; - actorSrc = ' (changed directly in database) '; - } - - if (r.action_data && r.action_data.processed_rows_count) { - rows = r.action_data.processed_rows_count + ' ' + - (r.action_data.processed_rows_count > 1 ? 'rows' : 'row'); - } - - switch (r.action) { - case 'insert': - acted = ' added ' + rows + ' to'; - break; - case 'delete': - acted = ' deleted ' + rows + ' from'; - break; - default: - acted = ' updated ' + rows + ' in'; - } - - return ( -
- {actor}{actorSrc} {acted} table {r.table_name} -
- ); - } - - getDataSectionTitle = (r, before) => { - switch (r.action) { - case 'insert': - return ''; - case 'delete': - return ''; - default: - return before ? 'Before:' : 'After:'; - } - } - - getChangesTitle = (r) => { - let displayedCount = r.data_before ? r.data_before.length : r.data_after.length; - let objCount = r.action_data && r.action_data.processed_rows_count ? - r.action_data.processed_rows_count : null; - - if (displayedCount && objCount > displayedCount) { - return 'Changes (displayed ' + displayedCount + ' rows out of ' + objCount + ')'; - } - - return 'Changes'; - } - - render() { - const { classes, orgPermissions, orgId } = this.props; - const data = this.state && this.state.data ? this.state.data.auditLog : null; - const logsStore = this.state && this.state.data && - this.state.data.auditLog || null; - const logs = logsStore && logsStore.data || []; - - const breadcrumbs = ( - - ); - - const pageTitle = ( - - ); - - if (orgPermissions && !orgPermissions.auditLogView) { - return ( -
- { breadcrumbs } - - { pageTitle } - - { messages.noPermissionPage } -
- ); - } - - if (!logsStore || !logsStore.data || (logsStore && logsStore.orgId !== orgId)) { - return ( -
- { breadcrumbs } - - { pageTitle } - - -
- ); - } - - if (logsStore.error) { - return ( -
- -
- ); - } - - return ( -
- { breadcrumbs } - - { pageTitle } - - { logs && logs.length > 0 ? ( -
- - - - - Action - Time - - - - {logs.map(r => { - return ( - - - {this.formatAction(r)} - {(r.data_before || r.data_after) && ( -
- - } - aria-controls='panel1b-content' - id='panel1b-header' - className={classes.expansionPanelSummary} - > - {this.getChangesTitle(r)} - - - {r.data_before && ( -
- {this.getDataSectionTitle(r, true)} - -
- )} - {r.data_after && ( -
- {this.getDataSectionTitle(r, false)} - -
- )} -
-
-
- )} -
- - {format.formatTimestampUtc(r.created_at)} - -
- ); - })} -
-
-
-
- {data && data.isProcessing && - } - {data && !data.isProcessing && !data.isComplete && - - } -
-
) : 'Audit log records not found' - } - -
-
- ); - } -} - -Audit.propTypes = { - classes: PropTypes.object.isRequired, - theme: PropTypes.object.isRequired -}; - -export default withStyles(getStyles, { withTheme: true })(Audit); diff --git a/ui/packages/platform/src/components/Billing.js b/ui/packages/platform/src/components/Billing.js deleted file mode 100644 index 34556d70..00000000 --- a/ui/packages/platform/src/components/Billing.js +++ /dev/null @@ -1,554 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import React, { Component } from 'react'; -import PropTypes from 'prop-types'; -import { NavLink } from 'react-router-dom'; -import { withStyles } from '@material-ui/core/styles'; -import { loadStripe } from '@stripe/stripe-js'; -import { Elements } from '@stripe/react-stripe-js'; -import { - Table, TableBody, TableCell, - TableHead, TableRow, Tooltip, Paper -} from '@material-ui/core'; -import Link from './Link'; -import ExpansionPanel from '@material-ui/core/ExpansionPanel'; -import ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary'; -import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails'; -import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; - -import { - HorizontalScrollContainer -} from '@postgres.ai/shared/components/HorizontalScrollContainer'; -import { PageSpinner } from '@postgres.ai/shared/components/PageSpinner'; -import { colors } from '@postgres.ai/shared/styles/colors'; -import { styles } from '@postgres.ai/shared/styles/styles'; -import { icons } from '@postgres.ai/shared/styles/icons'; - -import ConsoleBreadcrumbs from './ConsoleBreadcrumbs'; -import ConsolePageTitle from './ConsolePageTitle'; -import StripeForm from './StripeForm'; -import settings from '../utils/settings'; -import format from '../utils/format'; -import Urls from '../utils/urls'; -import Store from '../stores/store'; -import Actions from '../actions/actions'; -import Permissions from '../utils/permissions.js'; -import Error from './Error'; - -const stripePromise = loadStripe(settings.stripeApiKey, { - locale: 'en' -}); - - -const getStyles = theme => ({ - root: { - '& ul': { - '& > li': { - 'list-style-position': 'inside' - }, - 'padding': 0 - }, - '& h1': { - fontSize: '16px!important', - fontWeight: 'bold' - }, - '& h2': { - fontSize: '14px!important', - fontWeight: 'bold' - }, - 'width': '100%', - 'min-height': '100%', - 'z-index': 1, - 'position': 'relative', - [theme.breakpoints.down('sm')]: { - maxWidth: '100vw' - }, - [theme.breakpoints.up('md')]: { - maxWidth: 'calc(100vw - 200px)' - }, - [theme.breakpoints.up('lg')]: { - maxWidth: 'calc(100vw - 200px)' - }, - 'font-size': '14px!important', - 'font-family': '"Roboto", "Helvetica", "Arial", sans-serif', - - 'display': 'flex', - 'flexDirection': 'column', - 'paddingBottom': '20px' - }, - billingError: { - color: colors.state.warning - }, - errorMessage: { - color: colors.state.error, - marginBottom: 10 - }, - subscriptionForm: { - marginBottom: 20 - }, - orgStatusActive: { - color: colors.state.ok, - display: 'block', - marginBottom: 20 - }, - orgStatusBlocked: { - color: colors.state.error, - display: 'block', - marginBottom: 20 - }, - navLink: { - 'color': colors.secondary2.main, - '&:visited': { - color: colors.secondary2.main - } - }, - sortArrow: { - '& svg': { - marginBottom: -8 - } - }, - paperSection: { - display: 'block', - width: '100%', - marginBottom: 20, - overflow: 'auto' - }, - monthColumn: { - width: 255, - float: 'left' - }, - monthInfo: { - '& strong': { - display: 'inline-block', - marginBottom: 10 - } - }, - monthValue: { - marginBottom: '0px!important' - }, - - toolTip: { - fontSize: '12px!important', - maxWidth: '300px!important' - }, - paper: { - maxWidth: 510, - padding: 15, - marginBottom: 20, - display: 'block', - borderWidth: 1, - borderColor: colors.consoleStroke, - borderStyle: 'solid' - }, - expansionPaper: { - maxWidth: 540, - borderWidth: 1, - borderColor: colors.consoleStroke, - borderStyle: 'solid', - borderRadius: 4, - marginBottom: 30 - }, - expansionPaperHeader: { - 'padding': 15, - 'minHeight': 0, - 'justify-content': 'left', - '& div.MuiExpansionPanelSummary-content': { - margin: 0 - }, - '&.Mui-expanded': { - minHeight: '0px!important' - }, - '& .MuiExpansionPanelSummary-expandIcon': { - padding: 0, - marginRight: 0 - } - }, - expansionPaperBody: { - padding: 15, - paddingTop: 0, - display: 'block', - marginTop: -15 - }, - bottomSpace: { - ...styles.bottomSpace - } -}); - -const page = { - title: 'Billing' -}; - -class Billing extends Component { - componentDidMount() { - const that = this; - const { orgId } = this.props; - - this.unsubscribe = Store.listen(function () { - const auth = this.data && this.data.auth ? this.data.auth : null; - const billing = this.data && this.data.billing ? this.data.billing : null; - - that.setState({ data: this.data }); - - if (auth && auth.token && billing && - !billing.isProcessing && !billing.error && !that.state) { - Actions.getBillingDataUsage(auth.token, orgId); - } - }); - - Actions.refresh(); - } - - componentWillUnmount() { - this.unsubscribe(); - } - - toFixed(value) { - if (value && value.toFixed && value !== 0) { - return value.toFixed(4); - } - - return '0.0'; - } - - getDataUsageTable(isPriveleged) { - const billing = this.state && this.state.data && - this.state.data.billing ? - this.state.data.billing : null; - const { orgId, classes } = this.props; - let unitAmount; - let tibAmount; - let periodAmount = 0; - let estAmount = 0; - let startDate; - let endDate; - let period; - - if (!billing || (billing && billing.isProcessing) || (billing && billing.orgId !== orgId)) { - return ( - - ); - } - - if (!billing) { - return null; - } - - if (billing.data && billing.data.unit_amount) { - // Anatoly: Logic behind `/100` is unknown, but currently we store 0.26 in the DB - // So unitAmount will have the right value of 0.0026 per GiB*hour. - unitAmount = (parseFloat(billing.data.unit_amount) / 100); - tibAmount = (unitAmount * 1024); - } - - if (billing && billing.data) { - let periodDataUsage = parseFloat(billing.data.data_usage_sum); - let periodEstDataUsage = parseFloat(billing.data.data_usage_estimate) + periodDataUsage; - if (!isPriveleged && periodDataUsage) { - periodAmount = periodDataUsage * unitAmount; - } - if (!isPriveleged && periodEstDataUsage) { - estAmount = periodEstDataUsage * unitAmount; - } - if (billing.data.period_start) { - startDate = format.formatDate(billing.data.period_start); - } - if (billing.data.period_now) { - endDate = format.formatDate(billing.data.period_now); - } - } - - if (!startDate && !endDate) { - period = '-'; - } else { - period = startDate + ' – ' + endDate; - } - - return ( - <> - <> - -
-
- Current month -
- {period} -
- -
-
- Month-to-date total cost   - - Total cost for the {period} interval. - - } - classes={{ tooltip: classes.toolTip }} - > - {icons.infoIcon} - -
- - ${this.toFixed(periodAmount)} - -
- -
- End-of-month total cost (forecast)   - - The forecast for this period is a sum - of the actual cost to the date and the projected - cost based on average usage from {period}. - - } - classes={{ tooltip: classes.toolTip }} - > - {icons.infoIcon} -
- - ${this.toFixed(estAmount)} - -
-
- This is not an invoice -
-
- - - } - aria-controls='panel1a-content' - id='panel1a-header' - className={classes.expansionPaperHeader} - > - How is billing calculated? - - -

Billing is based on the total size of the databases - running within Database Lab.

-

The base cost per TiB per hour:  - - ${tibAmount && this.toFixed(tibAmount)} - .
- Discounts are not shown here and will be applied when the - invoice is issued.

-

We account only for the actual physical disk space used and monitor - this hourly with 1 GiB precision. Free disk space is always ignored. - The logical size of the database also does not factor into our - calculation. -

- - Learn more - -
-
- - -

Data usage

- {billing.data && billing.data.data_usage && billing.data.data_usage.length ? ( - - - - - Database Lab instance ID - - Date  - {icons.sortArrowUp} - - Consumption, GiB·h - Amount, $ - Billable - - - - {billing.data.data_usage.map(d => { - return ( - - - - {d.instance_id} - - - - {format.formatDate(d.day_date)} - - {d.data_size_gib} - - {!isPriveleged && d.to_invoice ? - this.toFixed(d.data_size_gib * unitAmount) : 0} - - - {d.to_invoice ? 'Yes' : 'No'} - - - ); - })} - -
-
) : 'Data usage metrics are not gathered yet.'} - - ); - } - - render() { - const { classes, orgId } = this.props; - const auth = this.state && this.state.data && this.state.data.auth ? - this.state.data.auth : null; - const data = this.state && this.state.data && this.state.data.billing ? - this.state.data.billing : null; - const orgData = this.props.orgData; - const dataUsage = this.getDataUsageTable(orgData.is_priveleged); - - const breadcrumbs = ( - - ); - - if (!Permissions.isAdmin(orgData)) { - return ( -
- {breadcrumbs} - - {} - - - -
- ); - } - - let subscription = null; - - let mode = 'new'; - if (orgData.is_blocked && orgData.stripe_subscription_id) { - mode = 'resume'; - } - if (!orgData.is_blocked && orgData.stripe_subscription_id) { - mode = 'update'; - } - - if (!orgData.is_priveleged) { - subscription = ( -
- {orgData.stripe_subscription_id && ( -
- {!orgData.is_blocked ? - (Subscription is active) : - ( -
- {icons.warningIcon} Subscription is NOT active.  - {orgData.new_subscription ? - 'Payment processing.' : 'Payment processing error.'} -
- ) - } -
- )} - - {!orgData.stripe_subscription_id && ( -
- {!orgData.is_blocked_on_creation ? ( -
- {icons.warningIcon}  - Trial period is expired. Enter payment details to activate the organization. -
- ) : ( -
- {icons.warningIcon} Enter payment details to activate the organization. -
- )} -
- )} - -
- -
- {Permissions.isAdmin(orgData) && ( -
- {data && data.subscriptionError && ( -
- {data.subscriptionErrorMessage} -
- )} - - - -
- )} -
-
- ); - } - - return ( -
- {breadcrumbs} - - {} - - {orgData.is_blocked && !orgData.is_priveleged && ( - Organization is suspended. - )} - - {!orgData.is_blocked && orgData.is_priveleged && ( - - Subscription is active till {format.formatTimestampUtc(orgData.priveleged_until)}. - - )} - - {!orgData.is_blocked && !orgData.is_priveleged && orgData.stripe_subscription_id && ( - - Subscription is active. Payment details are set. - - )} - - {mode !== 'update' && subscription} - - {!this.props.short && dataUsage } - -
-
- ); - } -} - -Billing.propTypes = { - classes: PropTypes.object.isRequired, - theme: PropTypes.object.isRequired -}; - -export default withStyles(getStyles, { withTheme: true })(Billing); diff --git a/ui/packages/platform/src/components/CheckupAgentForm.js b/ui/packages/platform/src/components/CheckupAgentForm.js deleted file mode 100644 index ef75cf42..00000000 --- a/ui/packages/platform/src/components/CheckupAgentForm.js +++ /dev/null @@ -1,972 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import { Component } from 'react'; -import PropTypes from 'prop-types'; -import { withStyles } from '@material-ui/core/styles'; -import Typography from '@material-ui/core/Typography'; -import IconButton from '@material-ui/core/IconButton'; -import TextField from '@material-ui/core/TextField'; -import Chip from '@material-ui/core/Chip'; -import Grid from '@material-ui/core/Grid'; -import Tabs from '@material-ui/core/Tabs'; -import Tab from '@material-ui/core/Tab'; -import Box from '@material-ui/core/Box'; -import Button from '@material-ui/core/Button'; -import Radio from '@material-ui/core/Radio'; -import RadioGroup from '@material-ui/core/RadioGroup'; -import FormControlLabel from '@material-ui/core/FormControlLabel'; -import FormLabel from '@material-ui/core/FormLabel'; -import ExpansionPanel from '@material-ui/core/ExpansionPanel'; -import ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary'; -import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails'; -import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; - -import { styles } from '@postgres.ai/shared/styles/styles'; -import { icons } from '@postgres.ai/shared/styles/icons'; -import { theme } from '@postgres.ai/shared/styles/theme'; -import { Spinner } from '@postgres.ai/shared/components/Spinner'; - -import Store from '../stores/store'; -import Actions from '../actions/actions'; -import Error from './Error'; -import ConsoleBreadcrumbs from './ConsoleBreadcrumbs'; -import CfgGen from '../utils/cfggen'; - - -const AUTO_GENERATED_TOKEN_NAME = 'Auto-generated 1-year token'; - -const getStyles = muiTheme => ({ - root: { - 'min-height': '100%', - 'z-index': 1, - 'position': 'relative', - [muiTheme.breakpoints.down('sm')]: { - maxWidth: '100vw' - }, - [muiTheme.breakpoints.up('md')]: { - maxWidth: 'calc(100vw - 200px)' - }, - [muiTheme.breakpoints.up('lg')]: { - maxWidth: 'calc(100vw - 200px)' - }, - '& h2': { - ...theme.typography.h2 - }, - '& h3': { - ...theme.typography.h3 - }, - '& h4': { - ...theme.typography.h4 - }, - '& .MuiExpansionPanelSummary-root.Mui-expanded': { - minHeight: 24 - } - }, - heading: { - ...theme.typography.h3 - }, - fieldValue: { - display: 'inline-block', - width: '100%' - }, - tokenInput: { - ...styles.inputField, - 'margin': 0, - 'margin-top': 10, - 'margin-bottom': 10 - }, - textInput: { - ...styles.inputField, - margin: 0, - marginTop: 0, - marginBottom: 10 - }, - hostItem: { - marginRight: 10, - marginBottom: 5, - marginTop: 5 - }, - fieldRow: { - marginBottom: 10, - display: 'block' - }, - fieldBlock: { - 'width': '100%', - 'max-width': 600, - 'margin-bottom': 15, - '& > div.MuiFormControl- > label': { - fontSize: 20 - }, - '& input, & .MuiOutlinedInput-multiline': { - padding: 13 - } - }, - relativeFieldBlock: { - marginBottom: 10, - marginRight: 20, - position: 'relative' - }, - addTokenButton: { - marginLeft: 10, - marginTop: 10 - }, - code: { - 'width': '100%', - 'margin-top': 0, - '& > div': { - paddingTop: 12 - }, - 'background-color': 'rgb(246, 248, 250)', - '& > div > textarea': { - fontFamily: '"Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas",' + - ' "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace', - color: 'black', - fontSize: 14 - } - }, - codeBlock: { - fontFamily: '"Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas",' + - ' "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace', - width: '100%', - padding: 3, - marginTop: 0, - border: 'rgb(204, 204, 204);', - borderRadius: 3, - color: 'black', - backgroundColor: 'rgb(246, 248, 250)' - }, - details: { - display: 'block' - }, - copyButton: { - position: 'absolute', - top: 6, - right: 6, - fontSize: 20 - }, - relativeDiv: { - position: 'relative' - }, - radioButton: { - '& > label > span.MuiFormControlLabel-label': { - fontSize: '0.9rem' - } - }, - legend: { - fontSize: '10px' - }, - advancedExpansionPanelSummary: { - 'justify-content': 'left', - '& div.MuiExpansionPanelSummary-content': { - 'flex-grow': 0 - } - } -}); - -function TabPanel(props) { - const { children, value, index, ...other } = props; - - return ( - - ); -} - -TabPanel.propTypes = { - children: PropTypes.node, - index: PropTypes.any.isRequired, - value: PropTypes.any.isRequired -}; - -function a11yProps(index) { - return { - 'id': `simple-tab-${index}`, - 'aria-controls': `simple-tabpanel-${index}` - }; -} - -class CheckupAgentForm extends Component { - state = { - hosts: '', - projectName: '', - databaseName: '', - databaseUserName: '', - ssDatabaseName: '', - port: null, - sshPort: null, - pgPort: null, - statementTimeout: null, - pgSocketDir: '', - psqlBinary: '', - collectPeriod: 600, - newHostName: '', - apiToken: '', - sshKeysPath: '', - password: '', - connectionType: '', - tab: 0 - }; - - componentDidMount() { - const that = this; - - this.unsubscribe = Store.listen(function () { - const auth = this.data && this.data.auth ? this.data.auth : null; - const reports = this.data && this.data.reports ? - this.data.reports : null; - const projects = this.data && this.data.projects ? - this.data.projects : null; - const tokenRequest = this.data && this.data.tokenRequest ? - this.data.tokenRequest : null; - - that.setState({ data: this.data }); - - if (auth && auth.token && !reports.isProcessed && !reports.isProcessing && - !reports.error) { - Actions.getCheckupReports(auth.token); - } - - if (auth && auth.token && !projects.isProcessed && !projects.isProcessing && - !projects.error) { - Actions.getProjects(auth.token); - } - - if (tokenRequest && tokenRequest.isProcessed && !tokenRequest.error && - tokenRequest.data && tokenRequest.data.name && tokenRequest.data.name - .startsWith(AUTO_GENERATED_TOKEN_NAME) && - tokenRequest.data.expires_at && tokenRequest.data.token) { - that.setState({ apiToken: tokenRequest.data.token }); - } - }); - - Actions.refresh(); - CfgGen.generateRunCheckupSh(this.state); - } - - componentWillUnmount() { - Actions.hideGeneratedAccessToken(); - this.unsubscribe(); - } - - handleClick = (event, id) => { - this.props.history.push('/report/' + id); - }; - - linkClick = (event) => { - this.props.history.push(event.target.getAttribute('hrefurl')); - - return false; - }; - - handleDeleteHost = (event, host) => { - let curHosts = CfgGen.uniqueHosts(this.state.hosts); - let curDividers = this.state.hosts.match(/[;,(\s)(\n)(\r)(\t)(\r\n)]/gm); - let hosts = curHosts.split(';'); - let newHosts = ''; - - for (let i in hosts) { - if (hosts[i] !== host) { - newHosts = newHosts + hosts[i] + - (curDividers[i] ? curDividers[i] : ''); - } - } - - this.setState({ hosts: newHosts }); - } - - handleChange = event => { - const name = event.target.name; - const value = event.target.value; - - this.setState({ - [name]: value - }); - }; - - handleChangeTab = (event, tabValue) => { - this.setState({ tab: tabValue }); - } - - addToken = () => { - const orgId = this.props.orgId ? this.props.orgId : null; - const auth = this.state.data && this.state.data.auth ? - this.state.data.auth : null; - const tokenRequest = this.state.data && this.state.data.tokenRequest ? - this.state.data.tokenRequest : null; - - if (auth && auth.token && !tokenRequest.isProcessing) { - let date = new Date(); - let expiresAt = (date.getFullYear() + 1) + '-' + ('0' + (date.getMonth() + - 1)).slice(-2) + '-' + ('0' + date.getDate()).slice(-2); - let nowDateTime = date.getFullYear() + '-' + ('0' + (date.getMonth() + - 1)).slice(-2) + '-' + ('0' + date.getDate()).slice(-2) + - ' ' + ('0' + date.getHours()).slice(-2) + ':' + ('0' + date.getMinutes()) - .slice(-2); - let tokenName = AUTO_GENERATED_TOKEN_NAME + ' (' + nowDateTime + ')'; - - Actions.getAccessToken(auth.token, tokenName, expiresAt, orgId); - } - } - - copyDockerCfg = () => { - let copyText = document.getElementById('generatedDockerCfg'); - - copyText.select(); - copyText.setSelectionRange(0, 99999); - document.execCommand('copy'); - copyText.setSelectionRange(0, 0); - } - - copySrcCfg = () => { - let copyText = document.getElementById('generatedSrcCfg'); - - copyText.select(); - copyText.setSelectionRange(0, 99999); - document.execCommand('copy'); - copyText.setSelectionRange(0, 0); - } - - render() { - const that = this; - const { classes } = this.props; - const reports = this.state.data && this.state.data.reports ? - this.state.data.reports : null; - const projects = this.state.data && this.state.data.projects ? - this.state.data.projects : null; - const tokenRequest = this.state.data && this.state.data.tokenRequest ? - this.state.data.tokenRequest : null; - let copySrcCfgBtn = null; - let copyDockerCfgBtn = null; - let token = null; - let content = null; - - if (this.state.projectName !== '' && this.state.databaseName !== '' && - this.state.databaseUserName !== '' && this.state.hosts !== '' && - this.state.apiToken !== '') { - copySrcCfgBtn = ( - - {icons.copyIcon} - - ); - copyDockerCfgBtn = ( - - {icons.copyIcon} - - ); - } - - token = ( -
- - - -
- ); - - if (this.state && this.state.data && (this.state.data.reports.error || - this.state.data.projects.error)) { - return ( -
- -
- ); - } - - if (reports && reports.isProcessed && projects.isProcessed) { - content = ( -
- Use postgres-checkup to check health of your Postgres databases. - This page will help you to generate the configuration file. - Provide settings that you will use inside your private network - (local hostnames, IPs, etc). - -
- - - Do not leave the page in order not to loose the configuration data. - -
- -

1. Configure

- - - - - General options - - - - - -
- -
- -
- - Connection type * - - - } - label='Connect to defined host via SSH' - /> - } - label={'Connect directly to PostgreSQL (some ' + - 'reports won’t be available)'} - /> - -
- -
-
-
- -
- -
- { CfgGen.uniqueHosts(that.state.hosts).split(';').map(h => { - if (h !== '') { - return ( - this.handleDeleteHost(event, h)} - color='primary' - /> - ); - } - - return null; - })} -
-
-
- -
- -
- -
- - Database password * - - - } - label={'No password is required or PGPASSWORD ' + - 'environment variable is predefined'} - /> - } - label={'I will enter the password manually ' + - '(choose this only for manual testing)'} - /> - -
- -
- -
- -
- -
-
-
-
- - - } - aria-controls='panel1b-content' - id='panel1b-header' - className={classes.advancedExpansionPanelSummary} - > - Advanced options - - - - -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
-
-
-
-
-

2. Generate token to upload postgres-checkup reports to console

-
- {token} -
- -

3. Deploy using Docker or building from source

- - - - - - - - - Requirements: - bash, coreutils, jq, golang, awk, sed, pandoc, wkhtmltopdf - (see README ). -
- Clone repo: - - git clone https://gitlab.com/postgres-ai/postgres-checkup.git - && cd postgres-checkup -
- Start script below: -
-
- - {copySrcCfgBtn} -
-
- - - - Requirements: Docker
- Start script below: -
-
- - {copyDockerCfgBtn} -
-
-
- ); - } else { - content = ( -
- -
- ); - } - - return ( -
- {} - - {content} -
- ); - } -} - -CheckupAgentForm.propTypes = { - classes: PropTypes.object.isRequired, - theme: PropTypes.object.isRequired -}; - -export default withStyles(getStyles, { withTheme: true })(CheckupAgentForm); diff --git a/ui/packages/platform/src/components/ConsoleBreadcrumbs.js b/ui/packages/platform/src/components/ConsoleBreadcrumbs.js deleted file mode 100644 index 2a433e06..00000000 --- a/ui/packages/platform/src/components/ConsoleBreadcrumbs.js +++ /dev/null @@ -1,170 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import { Component } from 'react'; -import { NavLink } from 'react-router-dom'; -import PropTypes from 'prop-types'; -import { withStyles } from '@material-ui/core/styles'; -import Typography from '@material-ui/core/Typography'; -import Paper from '@material-ui/core/Paper'; -import Breadcrumbs from '@material-ui/core/Breadcrumbs'; -import clsx from 'clsx'; - -import { colors } from '@postgres.ai/shared/styles/colors'; - -import { Head, createTitle as createTitleBase } from 'components/Head'; - -import Store from '../stores/store'; -import Actions from '../actions/actions'; -import Urls from '../utils/urls'; - - -const styles = () => ({ - pointerLink: { - cursor: 'pointer' - }, - breadcrumbsLink: { - maxWidth: 150, - textOverflow: 'ellipsis', - overflow: 'hidden', - display: 'block', - cursor: 'pointer', - whiteSpace: 'nowrap', - fontSize: '12px', - lineHeight: '14px', - textDecoration: 'none', - color: colors.consoleFadedFont - }, - breadcrumbsItem: { - fontSize: '12px', - lineHeight: '14px', - color: colors.consoleFadedFont - }, - breadcrumbsActiveItem: { - fontSize: '12px', - lineHeight: '14px', - color: '#000000' - }, - breadcrumbPaper: { - '& a, & a:visited': { - color: colors.consoleFadedFont - }, - 'padding-bottom': '8px', - 'marginTop': '-10px', - 'font-size': '12px', - 'borderRadius': 0 - }, - breadcrumbPaperWithDivider: { - borderBottom: `1px solid ${colors.consoleStroke}` - } -}); - -const createTitle = (parts) => { - const filteredParts = parts.filter(part => part !== 'Organizations'); - return createTitleBase(filteredParts); -}; - -class ConsoleBreadcrumbs extends Component { - componentDidMount() { - const that = this; - - this.unsubscribe = Store.listen(function () { - that.setState({ data: this.data }); - }); - Actions.refresh(); - } - - componentWillUnmount() { - this.unsubscribe(); - } - - render() { - const { classes, hasDivider = false } = this.props; - const breadcrumbs = this.props.breadcrumbs; - const org = this.props.org ? this.props.org : null; - const project = this.props.project ? this.props.project : null; - const orgs = this.state && this.state.data && this.state.data.userProfile.data && - this.state.data.userProfile.data.orgs ? this.state.data.userProfile.data.orgs : null; - const paths = []; - let lastUrl = ''; - - if (!breadcrumbs.length || Urls.isSharedUrl()) { - return null; - } - - if (org && orgs && orgs[org]) { - if (orgs[org].name) { - paths.push({ name: 'Organizations', url: '/' }); - paths.push({ name: orgs[org].name, url: '/' + org }); - lastUrl = '/' + org; - } - - if (project && orgs[org].projects && orgs[org].projects[project]) { - paths.push({ name: orgs[org].projects[project].name, url: null }); - lastUrl = '/' + org + '/' + project; - } - } - - for (let i = 0; i < breadcrumbs.length; i++) { - if (breadcrumbs[i].url && breadcrumbs[i].url.indexOf('/') === -1) { - breadcrumbs[i].url = lastUrl + '/' + breadcrumbs[i].url; - lastUrl = breadcrumbs[i].url; - } - breadcrumbs[i].isLast = (i === breadcrumbs.length - 1); - paths.push(breadcrumbs[i]); - } - - return ( - <> - path.name))} /> - - - {paths.map((b) => { - return ( - - {b.url ? ( - - {b.name} - - ) : ( - - {b.name} - - )} - - ); - })} - - - - ); - } -} - -ConsoleBreadcrumbs.propTypes = { - hasDivider: PropTypes.bool, - classes: PropTypes.object.isRequired, - theme: PropTypes.object.isRequired, - org: PropTypes.string, - project: PropTypes.string, - breadcrumbs: PropTypes.arrayOf( - PropTypes.shape({ - name: PropTypes.string.isRequired, - url: PropTypes.string - }).isRequired - ).isRequired -}; - -export default withStyles(styles, { withTheme: true })(ConsoleBreadcrumbs); diff --git a/ui/packages/platform/src/components/ConsoleButton.js b/ui/packages/platform/src/components/ConsoleButton.js deleted file mode 100644 index 77fe4346..00000000 --- a/ui/packages/platform/src/components/ConsoleButton.js +++ /dev/null @@ -1,50 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import React, { Component } from 'react'; -import PropTypes from 'prop-types'; -import { withStyles } from '@material-ui/core/styles'; -import Tooltip from '@material-ui/core/Tooltip'; -import Button from '@material-ui/core/Button'; - - -const styles = () => ({ - tooltip: { - fontSize: '10px!important' - } -}); - -class ConsoleButton extends Component { - render() { - const { classes, title, children, ...other } = this.props; - - // We have to use external tooltip component as disable button cannot show tooltip. - // Details: https://material-ui.com/components/tooltips/#disabled-elements. - return ( - - - - - - ); - } -} - -ConsoleButton.propTypes = { - title: PropTypes.string, - variant: PropTypes.string, - color: PropTypes.string, - classes: PropTypes.object.isRequired, - theme: PropTypes.object.isRequired -}; - -export default withStyles(styles, { withTheme: true })(ConsoleButton); diff --git a/ui/packages/platform/src/components/ConsolePageTitle.js b/ui/packages/platform/src/components/ConsolePageTitle.js deleted file mode 100644 index fe8e0f41..00000000 --- a/ui/packages/platform/src/components/ConsolePageTitle.js +++ /dev/null @@ -1,124 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import PropTypes from 'prop-types'; -import { makeStyles } from '@material-ui/core/styles'; -import Tooltip from '@material-ui/core/Tooltip'; - -import { colors } from '@postgres.ai/shared/styles/colors'; -import { icons } from '@postgres.ai/shared/styles/icons'; - -const useStyles = makeStyles({ - pageTitle: { - 'flex': '0 0 auto', - '& > h1': { - display: 'inline-block', - fontSize: '16px', - lineHeight: '19px', - marginRight: '10px' - }, - 'border-top': '1px solid ' + colors.consoleStroke, - 'border-bottom': '1px solid ' + colors.consoleStroke, - 'padding-top': '8px', - 'padding-bottom': '8px', - 'display': 'block', - 'overflow': 'auto', - 'margin-bottom': '20px', - 'max-width': '100%' - }, - pageTitleTop: { - 'flex': '0 0 auto', - '& > h1': { - display: 'inline-block', - fontSize: '16px', - lineHeight: '19px', - marginRight: '10px' - }, - 'border-bottom': '1px solid ' + colors.consoleStroke, - 'padding-top': '0px', - 'margin-top': '-10px', - 'padding-bottom': '8px', - 'display': 'block', - 'overflow': 'auto', - 'margin-bottom': '20px' - }, - pageTitleActions: { - lineHeight: '37px', - display: 'inline-block', - float: 'right' - }, - pageTitleActionContainer: { - marginLeft: '10px' - }, - tooltip: { - fontSize: '10px!important' - }, - label: { - backgroundColor: colors.primary.main, - color: colors.primary.contrastText, - display: 'inline-block', - borderRadius: 3, - fontSize: 10, - lineHeight: '12px', - padding: 2, - paddingLeft: 3, - paddingRight: 3, - verticalAlign: 'text-top' - } -}); - - -const ConsolePageTitle = (props) => { - const { title, information, label, actions, top } = props; - - const classes = useStyles(); - - if (!title) { - return null; - } - - return ( -
-

{title}

- {information ? ( - - {icons.infoIcon} - - ) : null} - {label ? ( - - {label} - - ) : null} - {actions ? ( - - {actions.map(a => { - return ( - - {a} - - ); - })} - - ) : null} -
- ); -}; - -ConsolePageTitle.propTypes = { - title: PropTypes.string, - information: PropTypes.string, - label: PropTypes.string, - actions: PropTypes.arrayOf(PropTypes.any), - top: PropTypes.bool -}; - -export default ConsolePageTitle; diff --git a/ui/packages/platform/src/components/ContentLayout/DemoOrgNotice/index.tsx b/ui/packages/platform/src/components/ContentLayout/DemoOrgNotice/index.tsx deleted file mode 100644 index 8ea30209..00000000 --- a/ui/packages/platform/src/components/ContentLayout/DemoOrgNotice/index.tsx +++ /dev/null @@ -1,75 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import { makeStyles, Button } from '@material-ui/core' -import { useHistory } from 'react-router-dom' - -import { colors } from '@postgres.ai/shared/styles/colors'; -import { icons } from '@postgres.ai/shared/styles/icons'; - -import { ROUTES } from 'config/routes' - -const useStyles = makeStyles({ - demoNoticeText: { - marginLeft: '0px', - display: 'inline-block', - position: 'relative', - backgroundColor: colors.blue, - color: colors.secondary2.darkDark, - width: '100%', - fontSize: '12px', - lineHeight: '24px', - fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif', - paddingLeft: '10px', - paddingTop: '4px', - paddingBottom: '4px', - '& > svg': { - verticalAlign: 'baseline', - marginBottom: '-1px', - marginLeft: '0px', - marginRight: '4px', - }, - }, - demoOrgNoticeButton: { - padding: '2px', - paddingLeft: '6px', - paddingRight: '6px', - borderRadius: '3px', - marginLeft: '5px', - marginTop: '-2px', - backgroundColor: colors.white, - height: '20px', - lineHeight: '20px', - fontSize: '12px', - fontWeight: 'bold', - }, - noWrap: { - whiteSpace: 'nowrap', - }, -}) - -export const DemoOrgNotice = () => { - const classes = useStyles() - const history = useHistory() - - const goToOrgForm = () => history.push(ROUTES.CREATE_ORG.path) - - return ( -
- {icons.infoIconBlue} This is a Demo organization, once you’ve - explored Database Lab features: - -
- ) -} diff --git a/ui/packages/platform/src/components/ContentLayout/DeprecatedApiBanner/index.tsx b/ui/packages/platform/src/components/ContentLayout/DeprecatedApiBanner/index.tsx deleted file mode 100644 index 9b1d7e8e..00000000 --- a/ui/packages/platform/src/components/ContentLayout/DeprecatedApiBanner/index.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import { makeStyles } from '@material-ui/core' - -import { Status } from '@postgres.ai/shared/components/Status' -import { GatewayLink } from '@postgres.ai/shared/components/GatewayLink' -import { colors } from '@postgres.ai/shared/styles/vars' - -const useStyles = makeStyles({ - root: { - background: colors.status.warning, - color: colors.white, - fontSize: '12px', - padding: '4px 10px', - lineHeight: '1.5', - }, - status: { - color: 'inherit', - }, - link: { - color: 'inherit', - }, -}) - -export const DeprecatedApiBanner = () => { - const classes = useStyles() - - return ( -
- - The version of your DLE instance is deprecated. - {' '} - Some information about DLE, disks, clones, and snapshots may be - unavailable. -
- Please upgrade your DLE to  - - the latest available version - - . -
- ) -} diff --git a/ui/packages/platform/src/components/ContentLayout/Footer/index.tsx b/ui/packages/platform/src/components/ContentLayout/Footer/index.tsx deleted file mode 100644 index 807b46e2..00000000 --- a/ui/packages/platform/src/components/ContentLayout/Footer/index.tsx +++ /dev/null @@ -1,94 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import React from 'react' -import { makeStyles } from '@material-ui/core' - -import settings from 'utils/settings' -import Link from '@material-ui/core/Link' - -const useStyles = makeStyles((theme) => ({ - footer: { - flex: '0 0 auto', - backgroundColor: 'rgb(68, 79, 96)', - color: '#fff', - display: 'flex', - justifyContent: 'center', - padding: '16px 20px', - [theme.breakpoints.down('sm')]: { - padding: '16px 12px', - flexDirection: 'column' - } - }, - footerCopyrightItem: { - marginRight: 50, - [theme.breakpoints.down('sm')]: { - marginBottom: 10, - }, - }, - footerItem: { - marginLeft: 10, - marginRight: 10, - color: '#fff', - '& a': { - color: '#fff', - textDecoration: 'none', - }, - '& a:hover': { - textDecoration: 'none', - }, - [theme.breakpoints.down('sm')]: { - marginLeft: 0, - marginBottom: 5, - }, - }, - footerItemSeparator: { - display: 'inline-block', - [theme.breakpoints.down('sm')]: { - display: 'none', - }, - }, -})) - -export const Footer = () => { - const classes = useStyles() - - return ( -
-
{new Date().getFullYear()} © Postgres.ai
-
- - Documentation - -
-
|
-
- - News - -
-
|
-
- - Terms of Service - -
-
|
-
- - Privacy Policy - -
-
|
-
- - Ask support - -
-
- ) -} diff --git a/ui/packages/platform/src/components/ContentLayout/index.tsx b/ui/packages/platform/src/components/ContentLayout/index.tsx deleted file mode 100644 index ae3f85b0..00000000 --- a/ui/packages/platform/src/components/ContentLayout/index.tsx +++ /dev/null @@ -1,57 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import React from 'react' -import { useRouteMatch } from 'react-router-dom' -import clsx from 'clsx' -import { observer } from 'mobx-react-lite' - -import { ROUTES } from 'config/routes' -import settings from 'utils/settings' -import { bannersStore } from 'stores/banners' - -import { DemoOrgNotice } from './DemoOrgNotice' -import { DeprecatedApiBanner } from './DeprecatedApiBanner' -import { Footer } from './Footer' - -import styles from './styles.module.scss' - -type Props = { - children: React.ReactNode -} - -export const ContentLayout = React.memo(observer((props: Props) => { - const { children } = props - - const isOrgJoeInstance = Boolean( - useRouteMatch(ROUTES.ORG.JOE_INSTANCES.JOE_INSTANCE.createPath()), - ) - - const isProjectJoeInstance = Boolean( - useRouteMatch(ROUTES.ORG.PROJECT.JOE_INSTANCES.JOE_INSTANCE.createPath()), - ) - - const isDemoOrg = Boolean(useRouteMatch(`/${settings.demoOrgAlias}`)) - - const isHiddenFooter = isOrgJoeInstance || isProjectJoeInstance - - return ( -
- {isDemoOrg && } - { bannersStore.isOpenDeprecatedApi && } - -
-
- {children} -
-
-
-
- ) -})) diff --git a/ui/packages/platform/src/components/ContentLayout/styles.module.scss b/ui/packages/platform/src/components/ContentLayout/styles.module.scss deleted file mode 100644 index 0df13e06..00000000 --- a/ui/packages/platform/src/components/ContentLayout/styles.module.scss +++ /dev/null @@ -1,40 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -@import '@postgres.ai/shared/styles/mixins'; - -.root { - display: flex; - flex-direction: column; - flex: 1 1 100%; - padding-top: 40px; - width: 100%; - // Flexbox bug fix - https://bugzilla.mozilla.org/show_bug.cgi?id=1086218#c4. - min-width: 0; -} - -.wrapper { - flex: 1 1 100%; - overflow: auto; - display: flex; - flex-direction: column; -} - -.content { - flex: 1 1 100%; - display: flex; - flex-direction: column; - padding: 20px; - - &.fullScreen { - flex-shrink: 0; - } - - @include sm { - padding: 20px 12px; - } -} diff --git a/ui/packages/platform/src/components/Dashboard.js b/ui/packages/platform/src/components/Dashboard.js deleted file mode 100644 index cc983bdf..00000000 --- a/ui/packages/platform/src/components/Dashboard.js +++ /dev/null @@ -1,613 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import React, { Component } from 'react'; -import { NavLink } from 'react-router-dom'; -import PropTypes from 'prop-types'; -import { withStyles } from '@material-ui/core/styles'; -import { - Table, TableBody, TableCell, - TableHead, TableRow, Button, Grid -} from '@material-ui/core'; -import ReactMarkdown from 'react-markdown'; -import rehypeRaw from 'rehype-raw'; -import remarkGfm from 'remark-gfm'; - -import { - HorizontalScrollContainer -} from '@postgres.ai/shared/components/HorizontalScrollContainer'; -import { PageSpinner } from '@postgres.ai/shared/components/PageSpinner'; -import { StubContainer } from '@postgres.ai/shared/components/StubContainer'; -import { colors } from '@postgres.ai/shared/styles/colors'; -import { icons } from '@postgres.ai/shared/styles/icons'; - -import { ROUTES } from 'config/routes'; - -import Actions from '../actions/actions'; -import ConsoleBreadcrumbs from './ConsoleBreadcrumbs'; -import ConsoleButton from './ConsoleButton'; -import ConsolePageTitle from './ConsolePageTitle'; -import Error from './Error'; -import Link from './Link'; -import messages from '../assets/messages'; -import ProductCard from './ProductCard'; -import Store from '../stores/store'; -import Urls from '../utils/urls'; - -import settings from '../utils/settings'; - -const styles = theme => ({ - stubContainerProjects: { - marginRight: '-20px', - paddingBottom: 0, - [theme.breakpoints.down('sm')]: { - flexDirection: 'column', - marginRight: 0, - marginTop: '-20px' - } - }, - productCardProjects: { - flex: '1 1 100%', - marginRight: '20px', - [theme.breakpoints.down('sm')]: { - flex: '0 0 auto', - marginRight: 0, - marginTop: '20px' - } - }, - orgsHeader: { - position: 'relative' - }, - newOrgBtn: { - position: 'absolute', - top: 0, - right: 10 - }, - nameColumn: { - 'word-wrap': 'break-word', - [theme.breakpoints.down('sm')]: { - maxWidth: 'calc(100vw - 150px)' - }, - [theme.breakpoints.up('md')]: { - maxWidth: 'calc(100vw - 350px)' - }, - [theme.breakpoints.up('lg')]: { - maxWidth: 'calc(100vw - 350px)' - }, - '& > a': { - color: 'black', - textDecoration: 'none' - }, - '& > a:hover': { - color: 'black', - textDecoration: 'none' - } - }, - cell: { - '& > a': { - color: 'black', - textDecoration: 'none' - }, - '& > a:hover': { - color: 'black', - textDecoration: 'none' - } - }, - activityButton: { - '&:not(:first-child)': { - marginLeft: '15px' - } - }, - onboardingCard: { - 'border': '1px solid ' + colors.consoleStroke, - 'borderRadius': 3, - 'padding': 15, - '& h1': { - fontSize: '16px', - margin: '0' - } - }, - onboarding: { - '& ul': { - paddingInlineStart: '20px' - } - } -}); - -class Dashboard extends Component { - componentDidMount() { - const that = this; - const orgId = this.props.orgId; - const onlyProjects = this.props.onlyProjects; - - this.unsubscribe = Store.listen(function () { - that.setState({ data: this.data }); - const auth = this.data && this.data.auth ? this.data.auth : null; - const userProfile = this.data && this.data.userProfile ? - this.data.userProfile : null; - - if (onlyProjects) { - const projects = this.data && this.data.projects ? - this.data.projects : null; - - if (auth && auth.token && !projects.isProcessing && - !projects.error && !that.state) { - Actions.getProjects(auth.token, orgId); - } - - if (auth && !that.state && !userProfile.isProcessing - && !userProfile.error) { - Actions.getUserProfile(auth.token); - } - } else { - const useDemoData = this.data && this.data.useDemoData ? - this.data.useDemoData : null; - const profileUpdateInitAfterDemo = this.data && this.data.dashboard ? - this.data.dashboard.profileUpdateInitAfterDemo : null; - - if (auth && auth.token && - ((!userProfile.isProcessed && !userProfile.isProcessing && !userProfile.error) || - (!profileUpdateInitAfterDemo && useDemoData.isProcessed && !useDemoData.error))) { - if (useDemoData.isProcessed) { - this.data.dashboard.profileUpdateInitAfterDemo = true; - } - - Actions.getUserProfile(auth.token); - } - } - }); - - Actions.refresh(); - } - - componentWillUnmount() { - this.unsubscribe(); - } - - handleClick = (event, alias) => { - this.props.history.push('/' + alias); - } - - useDemoDataButtonHandler = () => { - const auth = this.state.data && this.state.data.auth ? - this.state.data.auth : null; - Actions.useDemoData(auth.token); - } - - addOrgButtonHandler = () => { - this.props.history.push(ROUTES.CREATE_ORG.path); - } - - addDblabInstanceButtonHandler = () => { - this.props.history.push(Urls.linkDbLabInstanceAdd(this.props)); - } - - addCheckupAgentButtonHandler = () => { - this.props.history.push(Urls.linkCheckupAgentAdd(this.props)); - } - - dblabInstancesButtonHandler = (org, project) => { - return () => { - this.props.history.push(Urls.linkDbLabInstances({ org, project })); - }; - } - - joeInstancesButtonHandler = (org, project) => { - return () => { - this.props.history.push(Urls.linkJoeInstances({ org, project })); - }; - } - - checkupReportsButtonHandler = (org, project) => { - return () => { - this.props.history.push(Urls.linkReports({ org, project })); - }; - } - - render() { - const renderProjects = this.props.onlyProjects; - - if (renderProjects) { - return this.renderProjects(); - } - - // TODO(anatoly): Move organization to a separate page component. - return this.renderOrgs(); - } - - renderProjects() { - const { classes, org } = this.props; - const projectsData = this.state && this.state.data && - this.state.data.projects ? this.state.data.projects : null; - const orgId = this.props.orgId; - - const breadcrumbs = ( - - ); - - const pageTitle = ( - - ); - - if (projectsData && projectsData.error) { - return ( - <> - { breadcrumbs } - - - ); - } - - if (!projectsData || !projectsData.data || projectsData.orgId !== orgId) { - return ( - <> - { breadcrumbs } - - - ); - } - - const projects = projectsData.data; - - const dblabPermitted = this.props.orgPermissions.dblabInstanceCreate; - const checkupPermitted = this.props.orgPermissions.checkupReportConfigure; - - const addDblabInstanceButton = ( - - Add instance - - ); - - const addCheckupAgentButton = ( - - Add agent - - ); - - let table = ( - - -

- Clone multi-terabyte databases in seconds and use them to - test your database migrations, optimize SQL, or deploy full-size - staging apps. Start here to work with all Database Lab tools. - - Learn more - - . -

-
- -

- Automated routine checkup for your PostgreSQL databases. - Configure Checkup agent to start collecting reports ( - - Learn more - - ). -

-
-
- ); - - if (projects.length > 0) { - table = ( - - - - - Project - Activity - - - - {projects.map(p => { - return ( - - {p.name} - - - - - - - ); - })} - -
-
- ); - } - - let onboarding = null; - if (this.state.data && this.state.data.userProfile && - this.state.data.userProfile.data && this.state.data.userProfile.data.orgs && - this.state.data.userProfile.data.orgs[org] && - this.state.data.userProfile.data.orgs[org].onboarding_text) { - onboarding = ( -
- - -
-

Getting started

- { - const { href, target, children } = props; - return ( - - {children} - - ); - } - }} - /> -
-
- -
-

Useful links

- { - const { href, target, children } = props; - return ( - - {children} - - ); - } - }} - /> -
-
-
-
- ); - } - - return ( -
- { breadcrumbs } - - { pageTitle } - - { onboarding } - - { table } -
- ); - } - - renderOrgs() { - const { classes } = this.props; - const profile = this.state && this.state.data ? - this.state.data.userProfile : null; - const useDemoData = this.state && this.state.data ? - this.state.data.useDemoData : null; - const profileUpdateInitAfterDemo = this.state && this.state.data && this.state.data.dashboard ? - this.state.data.dashboard.profileUpdateInitAfterDemo : null; - - // Show organizations. - if (this.state && this.state.data.projects.error) { - return ( -
- -
- ); - } - - if (!profile || profile.isProcessing || (profile && !profile.data) || - !useDemoData || useDemoData.isProcessing || - (useDemoData.isProcessed && !profileUpdateInitAfterDemo)) { - return ( - <> - - - ); - } - - const useDemoDataButton = ( - - Join demo organization - - ); - - const createOrgButton = ( - - Create new organization - - ); - - const orgsPlaceholder = ( - - -

- An organization represents a workspace for you and your colleagues. - Organizations allow you to manage users and collaborate across multiple projects. -

-

- You can create a new organization, join the demo organization or - ask existing members of your organization to invite you. -

-
-
- ); - - const pageActions = []; - if (!profile.data.orgs || profile.data.orgs.length === 0 || - !profile.data.orgs[settings.demoOrgAlias]) { - pageActions.push(useDemoDataButton); - } - pageActions.push(createOrgButton); - - return ( -
- - - {profile.data.orgs && Object.keys(profile.data.orgs).length > 0 ? ( - - - - - Organization - Projects count - - - - {Object.keys(profile.data.orgs).map(o => { - return ( - this.handleClick(event, profile.data.orgs[o].alias)} - style={ { cursor: 'pointer' } } - data-org-id={profile.data.orgs[o].id} - data-org-alias={profile.data.orgs[o].alias} - > - - - {profile.data.orgs[o].name} - - - - - {profile.data.orgs[o].projects ? - Object.keys(profile.data.orgs[o].projects).length : '0'} - - - - ); - })} - -
-
- ) : orgsPlaceholder - } - -
- ); - } -} - -Dashboard.propTypes = { - classes: PropTypes.object.isRequired, - theme: PropTypes.object.isRequired -}; - -export default withStyles(styles, { withTheme: true })(Dashboard); diff --git a/ui/packages/platform/src/components/DbLabInstanceForm.js b/ui/packages/platform/src/components/DbLabInstanceForm.js deleted file mode 100644 index b0763543..00000000 --- a/ui/packages/platform/src/components/DbLabInstanceForm.js +++ /dev/null @@ -1,474 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import { Component } from 'react'; -import PropTypes from 'prop-types'; -import { withStyles } from '@material-ui/core/styles'; -import { Checkbox } from '@material-ui/core'; -import Grid from '@material-ui/core/Grid'; -import Button from '@material-ui/core/Button'; -import TextField from '@material-ui/core/TextField'; -import CheckCircleOutlineIcon from '@material-ui/icons/CheckCircleOutline'; -import BlockIcon from '@material-ui/icons/Block'; -import WarningIcon from '@material-ui/icons/Warning'; -import FormControlLabel from '@material-ui/core/FormControlLabel'; - -import { styles } from '@postgres.ai/shared/styles/styles'; -import { PageSpinner } from '@postgres.ai/shared/components/PageSpinner'; - -import Actions from '../actions/actions'; -import ConsoleBreadcrumbs from './ConsoleBreadcrumbs'; -import ConsolePageTitle from './ConsolePageTitle'; -import Store from '../stores/store'; -import Urls from '../utils/urls'; -import Utils from '../utils/utils'; -import Warning from './Warning'; - - -const getStyles = () => ({ - textField: { - ...styles.inputField, - maxWidth: 400 - }, - errorMessage: { - color: 'red' - }, - fieldBlock: { - width: '100%' - }, - urlOkIcon: { - marginBottom: -5, - marginLeft: 10, - color: 'green' - }, - urlOk: { - color: 'green' - }, - urlFailIcon: { - marginBottom: -5, - marginLeft: 10, - color: 'red' - }, - urlFail: { - color: 'red' - }, - warning: { - color: '#801200', - fontSize: '0.9em' - }, - warningIcon: { - color: '#801200', - fontSize: '1.2em', - position: 'relative', - marginBottom: -3 - } -}); - -class DbLabInstanceForm extends Component { - state = { - url: 'https://', - token: '', - useTunnel: false, - project: this.props.project ? this.props.project : '', - errorFields: [], - sshServerUrl: '' - }; - - componentDidMount() { - const that = this; - const { orgId } = this.props; - - this.unsubscribe = Store.listen(function () { - that.setState({ data: this.data }); - const auth = this.data && this.data.auth ? this.data.auth : null; - const projects = this.data && this.data.projects ? - this.data.projects : null; - const dbLabInstances = this.data && this.data.dbLabInstances ? - this.data.dbLabInstances : null; - - if (auth && auth.token && !projects.isProcessing && !projects.error && - !projects.isProcessed) { - Actions.getProjects(auth.token, orgId); - } - - if (auth && auth.token && !dbLabInstances.isProcessing && - !dbLabInstances.error && !dbLabInstances.isProcessed) { - Actions.getDbLabInstances(auth.token, orgId, 0); - } - }); - - Actions.refresh(); - } - - componentWillUnmount() { - this.unsubscribe(); - Actions.resetNewDbLabInstance(); - } - - handleChange = event => { - const name = event.target.name; - let value = event.target.value; - - if (name === 'useTunnel') { - value = event.target.checked; - } - - this.setState({ - [name]: value - }); - - Actions.resetNewDbLabInstance(); - }; - - buttonHandler = () => { - const orgId = this.props.orgId ? this.props.orgId : null; - const auth = this.state.data && this.state.data.auth ? - this.state.data.auth : null; - const data = this.state.data ? this.state.data.newDbLabInstance : null; - let errorFields = []; - - if (!this.state.url) { - errorFields.push('url'); - } - - if (!this.state.project) { - errorFields.push('project'); - } - - if (!this.state.token) { - errorFields.push('token'); - } - - if (errorFields.length > 0) { - this.setState({ errorFields: errorFields }); - return; - } - - this.setState({ errorFields: [] }); - - if (auth && data && !data.isUpdating && this.state.url && - this.state.token && this.state.project) { - Actions.addDbLabInstance(auth.token, { - orgId: orgId, - project: this.state.project, - url: this.state.url, - instanceToken: this.state.token, - useTunnel: this.state.useTunnel, - sshServerUrl: this.state.sshServerUrl - }); - } - }; - - checkUrlHandler = () => { - const auth = this.state.data && this.state.data.auth ? - this.state.data.auth : null; - const data = this.state.data ? this.state.data.newDbLabInstance : null; - let errorFields = []; - - if (!this.state.url) { - errorFields.push('url'); - return; - } - - if (auth && data && !data.isChecking && this.state.url) { - Actions.checkDbLabInstanceUrl(auth.token, this.state.url, this.state.token, - this.state.useTunnel); - } - }; - - returnHandler = () => { - this.props.history.push(Urls.linkDbLabInstances(this.props)); - }; - - processedHandler = () => { - const data = this.state.data ? this.state.data.newDbLabInstance : null; - - this.props.history.push(Urls.linkDbLabInstance(this.props, data.data.id)); - }; - - generateTokenHandler = () => { - this.setState({ token: Utils.generateToken() }); - } - - render() { - const { classes, orgPermissions } = this.props; - const data = this.state && this.state.data ? - this.state.data.newDbLabInstance : null; - const projects = this.state && this.state.data && - this.state.data.projects ? this.state.data.projects : null; - let projectsList = []; - const dbLabInstances = this.state && this.state.data && - this.state.data.dbLabInstances ? this.state.data.dbLabInstances : null; - - if (data && data.isProcessed && !data.error) { - this.processedHandler(); - Actions.resetNewDbLabInstance(); - } - - const breadcrumbs = ( - - ); - - const pageTitle = ( - - ); - - const permitted = !orgPermissions || orgPermissions.dblabInstanceCreate; - - const instancesLoaded = dbLabInstances && dbLabInstances.data; - - if (!projects || !projects.data || !instancesLoaded) { - return ( -
- { breadcrumbs } - - { pageTitle } - - -
- ); - } - - if (projects.data) { - projects.data.map(p => { - projectsList.push({ title: p.name, value: p.id }); - }); - } - - const isDataUpdating = (data && (data.isUpdating || data.isChecking)); - - return ( -
- { breadcrumbs } - - { pageTitle } - - { !permitted && - - You do not have permission to add Database Lab instances. - - } - - - Database Lab provisioning is currently semi-automated.
- First, you need to prepare a Database Lab instance on a separate  - machine. Once the instance is ready, register it here. -
- -
- { data.errorMessage ? data.errorMessage : null } -
- - -
- -
- -
- -
- -
-
- -
- - - - The connection to the Database Lab API is not secure. Use HTTPS. - - ) : null - } - error={ this.state.errorFields.indexOf('url') !== -1 } - fullWidth - inputProps={ { - name: 'url', - id: 'url', - shrink: true - } } - InputLabelProps={ { - shrink: true, - style: styles.inputFieldLabel - } } - FormHelperTextProps={ { - style: styles.inputFieldHelper - } } - /> -
- -
- - } - label='Use tunnel' - labelPlacement='end' - /> -
- -
-
-
- - - { data.isCheckProcessed && data.isChecked && - (Utils.isHttps(this.state.url) || this.state.useTunnel) ? ( - - Verified - ) : null } - - { data.isCheckProcessed && data.isChecked && - !Utils.isHttps(this.state.url) && !this.state.useTunnel ? ( - - Verified but is not secure - ) : null } - - { data.isCheckProcessed && !data.isChecked ? ( - - Not available - ) : null } -
- -
- -    - -
-
-
- ); - } -} - -DbLabInstanceForm.propTypes = { - classes: PropTypes.object.isRequired, - theme: PropTypes.object.isRequired -}; - -export default withStyles(getStyles, { withTheme: true })(DbLabInstanceForm); diff --git a/ui/packages/platform/src/components/DbLabInstances.js b/ui/packages/platform/src/components/DbLabInstances.js deleted file mode 100644 index 9b1e3cf2..00000000 --- a/ui/packages/platform/src/components/DbLabInstances.js +++ /dev/null @@ -1,498 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import { Component } from 'react'; -import PropTypes from 'prop-types'; -import { withStyles } from '@material-ui/core/styles'; -import { - Table, TableBody, TableCell, TableHead, - TableRow, TextField, IconButton, Menu, MenuItem, Tooltip -} from '@material-ui/core'; -import MoreVertIcon from '@material-ui/icons/MoreVert'; -import WarningIcon from '@material-ui/icons/Warning'; - -import { - HorizontalScrollContainer -} from '@postgres.ai/shared/components/HorizontalScrollContainer'; -import { StubContainer } from '@postgres.ai/shared/components/StubContainer'; -import { PageSpinner } from '@postgres.ai/shared/components/PageSpinner'; -import { Spinner } from '@postgres.ai/shared/components/Spinner'; -import { colors } from '@postgres.ai/shared/styles/colors'; -import { styles } from '@postgres.ai/shared/styles/styles'; -import { icons } from '@postgres.ai/shared/styles/icons'; - -import Actions from '../actions/actions'; -import Aliases from '../utils/aliases'; -import ConsoleBreadcrumbs from './ConsoleBreadcrumbs'; -import ConsoleButton from './ConsoleButton'; -import ConsolePageTitle from './ConsolePageTitle'; -import DbLabStatus from './DbLabStatus'; -import Error from './Error'; -import Link from './Link'; -import messages from '../assets/messages'; -import ProductCard from './ProductCard'; -import Store from '../stores/store'; -import Urls from '../utils/urls'; -import Utils from '../utils/utils'; -import Warning from './Warning'; - - -const getStyles = () => ({ - root: { - ...styles.root, - display: 'flex', - flexDirection: 'column' - }, - stubContainer: { - marginTop: '10px' - }, - filterSelect: { - ...styles.inputField, - width: 150 - }, - cell: { - '& > a': { - color: 'black', - textDecoration: 'none' - }, - '& > a:hover': { - color: 'black', - textDecoration: 'none' - } - }, - inTableProgress: { - width: '30px!important', - height: '30px!important' - }, - warningIcon: { - color: colors.state.warning, - fontSize: '1.2em', - position: 'absolute', - marginLeft: 5 - }, - tooltip: { - fontSize: '10px!important' - } -}); - -class DbLabInstances extends Component { - componentDidMount() { - const that = this; - let orgId = this.props.orgId ? this.props.orgId : null; - let projectId = this.props.projectId ? this.props.projectId : null; - - if (!projectId) { - projectId = this.props.match && this.props.match.params && this.props.match - .params.projectId ? - this.props.match.params.projectId : null; - } - - if (projectId) { - Actions.setDbLabInstancesProject(orgId, projectId); - } else { - Actions.setDbLabInstancesProject(orgId, 0); - } - - this.unsubscribe = Store.listen(function () { - const auth = this.data && this.data.auth ? this.data.auth : null; - const dbLabInstances = this.data && this.data.dbLabInstances ? this - .data.dbLabInstances : null; - const projects = this.data && this.data.projects ? this.data.projects : - null; - - if (auth && auth.token && !dbLabInstances.isProcessing && - !dbLabInstances.error && !that.state) { - Actions.getDbLabInstances(auth.token, orgId, projectId); - } - - if (auth && auth.token && !projects.isProcessing && !projects.error && - !that.state) { - Actions.getProjects(auth.token, orgId); - } - - that.setState({ data: this.data }); - }); - - Actions.refresh(); - } - - componentWillUnmount() { - this.unsubscribe(); - } - - handleClick = (event, id) => { - const url = Urls.linkDbLabInstance(this.props, id); - - if (url) { - this.props.history.push(url); - } - } - - handleChangeProject = (event) => { - const org = this.props.org ? this.props.org : null; - const orgId = this.props.orgId ? this.props.orgId : null; - const projectId = event.target.value; - const project = Aliases.getProjectAliasById(this.state.data.userProfile.data - .orgs, projectId); - const props = { org, orgId, projectId, project }; - - Actions.setDbLabInstancesProject(orgId, event.target.value); - this.props.history.push(Urls.linkDbLabInstances(props)); - }; - - registerButtonHandler = () => { - this.props.history.push(Urls.linkDbLabInstanceAdd(this.props)); - }; - - openMenu = (event) => { - event.stopPropagation(); - this.setState({ anchorEl: event.currentTarget }); - }; - - closeMenu = () => { - this.setState({ anchorEl: null }); - } - - menuHandler = (event, action) => { - const anchorEl = this.state.anchorEl; - - this.closeMenu(); - - setTimeout(() => { - const auth = this.state.data && this.state.data.auth ? this.state.data - .auth : null; - const data = this.state.data && this.state.data.dbLabInstances ? - this.state.data.dbLabInstances : null; - - if (anchorEl) { - let instanceId = anchorEl.getAttribute('instanceid'); - if (!instanceId) { - return; - } - - let project = ''; - if (data.data) { - for (let i in data.data) { - if (parseInt(data.data[i].id, 10) === parseInt(instanceId, 10)) { - project = data.data[i].project_alias; - } - } - } - - switch (action) { - case 'addclone': - let props = { org: this.props.org, project: project }; - this.props.history.push(Urls.linkDbLabCloneAdd(props, - instanceId)); - - break; - - case 'destroy': - /* eslint no-alert: 0 */ - if (window.confirm('Are you sure you want to remove this' + - ' Database Lab instance?') === true) { - Actions.destroyDbLabInstance(auth.token, instanceId); - } - - break; - - case 'refresh': - Actions.getDbLabInstanceStatus(auth.token, instanceId); - - break; - - default: - break; - } - } - }, 100); - } - - render() { - const { classes, orgPermissions, orgId } = this.props; - const data = this.state && this.state.data && - this.state.data.dbLabInstances ? this.state .data.dbLabInstances : null; - const projects = this.state && this.state.data && - this.state.data.projects ? this.state.data.projects : null; - let projectId = this.props.projectId ? this.props.projectId : null; - const menuOpen = Boolean(this.state && this.state.anchorEl); - const title = 'Database Lab Instances'; - const addPermitted = !orgPermissions || orgPermissions.dblabInstanceCreate; - const deletePermitted = !orgPermissions || orgPermissions.dblabInstanceDelete; - const addInstanceButton = ( - - Add instance - - ); - const pageTitle = (); - - if (!projectId) { - projectId = this.props.match && this.props.match.params && this.props.match - .params.projectId ? - this.props.match.params.projectId : null; - } - - let projectFilter = null; - if (projects && projects.data && data) { - projectFilter = ( -
- this.handleChangeProject(event)} - select - label='Project' - inputProps={{ - name: 'project', - id: 'project-filter' - }} - InputLabelProps={{ - shrink: true, - style: styles.inputFieldLabel - }} - FormHelperTextProps={{ - style: styles.inputFieldHelper - }} - variant='outlined' - className={classes.filterSelect} - > - All - - {projects.data.map(p => { - return ( - {p.name} - ); - })} - -
- ); - } - - let breadcrumbs = ( - - ); - - if (orgPermissions && !orgPermissions.dblabInstanceList) { - return ( -
- { breadcrumbs } - - { pageTitle } - - { messages.noPermissionPage } -
- ); - } - - if (this.state && this.state.data.dbLabInstances.error) { - return ( -
- {breadcrumbs} - - - - -
- ); - } - - if (!data || (data && data.isProcessing) || - (data.orgId !== orgId) || (data.projectId !== (projectId ? projectId : 0))) { - return ( -
- {breadcrumbs} - - - - -
- ); - } - - const emptyListTitle = projectId ? - 'There are no Database Lab instances in this project yet' : - 'There are no Database Lab instances yet'; - - let table = ( - - -

- Clone multi-terabyte databases in seconds and use them to - test your database migrations, optimize SQL, or deploy full-size - staging apps. Start here to work with all Database Lab tools. - Setup - - documentation here - - . -

-
-
- ); - - let menu = null; - if (data.data && Object.keys(data.data).length > 0) { - table = ( - - - - - Project - URL - Status - Clones -   - - - - - {Object.keys(data.data).map(i => { - return ( - this.handleClick(event, - data.data[i].id, data.data[i].project_id)} - style={{ cursor: 'pointer' }} - > - - {data.data[i].project_name} - - - - {data.data[i].state && data.data[i].url ? data.data[i].url : ''} - {!Utils.isHttps(data.data[i].url) && !data.data[i].use_tunnel ? ( - - - ) : null} - - - - - - - - { - data.data[i]?.state?.cloning?.numClones ?? - data.data[i]?.state?.clones?.length ?? - '' - } - - - - {(data.data[i].isProcessing) || - (this.state.data.dbLabInstanceStatus.instanceId === i && - this.state.data.dbLabInstanceStatus.isProcessing) ? ( - - ) : null} - - - - - - ); - })} - -
-
- ); - - menu = ( - - this.menuHandler(event, 'addclone')} - > - Create clone - - this.menuHandler(event, 'refresh')} - > - Refresh - - this.menuHandler(event, 'destroy')} - > - Remove - - - ); - } - - return ( -
- {breadcrumbs} - - {pageTitle} - - {projectFilter} - - {table} - - {menu} -
- ); - } -} - -DbLabInstances.propTypes = { - classes: PropTypes.object.isRequired, - theme: PropTypes.object.isRequired -}; - -export default withStyles(getStyles, { withTheme: true })(DbLabInstances); diff --git a/ui/packages/platform/src/components/DbLabSession.js b/ui/packages/platform/src/components/DbLabSession.js deleted file mode 100644 index 1ebaf8fe..00000000 --- a/ui/packages/platform/src/components/DbLabSession.js +++ /dev/null @@ -1,1038 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import { Component } from 'react'; -import { NavLink } from 'react-router-dom'; -import PropTypes from 'prop-types'; -import { withStyles } from '@material-ui/core/styles'; -import { - Button, - Table, - TableBody, - TableCell, - TableRow -} from '@material-ui/core'; -import Typography from '@material-ui/core/Typography'; -import ExpansionPanel from '@material-ui/core/ExpansionPanel'; -import ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary'; -import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails'; -import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; -import TextField from '@material-ui/core/TextField'; -import { formatDistanceToNowStrict } from 'date-fns'; - -import { - HorizontalScrollContainer -} from '@postgres.ai/shared/components/HorizontalScrollContainer'; -import { PageSpinner } from '@postgres.ai/shared/components/PageSpinner'; -import { Spinner } from '@postgres.ai/shared/components/Spinner'; -import { colors } from '@postgres.ai/shared/styles/colors'; -import { styles } from '@postgres.ai/shared/styles/styles'; -import { icons } from '@postgres.ai/shared/styles/icons'; - -import Store from '../stores/store'; -import Actions from '../actions/actions'; -import Error from './Error'; -import ConsoleBreadcrumbs from './ConsoleBreadcrumbs'; -import ConsolePageTitle from './ConsolePageTitle'; -import Warning from './Warning'; -import messages from '../assets/messages'; -import format from '../utils/format'; -import urls from '../utils/urls'; -import Link from './Link'; -import DbLabStatus from './DbLabStatus'; -import dblabutils from '../utils/dblabutils'; - - -const PAGE_SIZE = 20; - -const getStyles = (theme) => ({ - root: { - ...styles.root, - flex: '1 1 100%', - display: 'flex', - flexDirection: 'column' - }, - summary: { - marginTop: 20, - marginBottom: 20 - }, - paramTitle: { - display: 'inline-block', - width: 200 - }, - sectionHeader: { - fontWeight: 600, - display: 'block', - paddingBottom: 10, - marginBottom: 10, - borderBottom: '1px solid ' + colors.consoleStroke - }, - logContainer: { - 'backgroundColor': 'black', - 'color': 'white', - 'fontFamily': '"Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas",' + - ' "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace', - 'fontSize': '13px', - 'maxHeight': 'calc(100vh - 120px)', - 'overflowY': 'auto', - 'width': '100%', - '& > div': { - overflowWrap: 'anywhere' - } - }, - artifactContainer: { - backgroundColor: 'black', - color: 'white', - fontFamily: '"Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas",' + - ' "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace', - fontSize: '13px', - maxHeight: 'calc(100vh - 300px)', - width: '100%', - whiteSpace: 'break-spaces', - overflowWrap: 'anywhere', - overflow: 'auto' - }, - showMoreContainer: { - marginTop: 20, - textAlign: 'center' - }, - link: { - 'color': colors.secondary2.main, - '&:visited': { - color: colors.secondary2.main - }, - '&:hover': { - color: colors.secondary2.main - }, - '&:active': { - color: colors.secondary2.main - } - }, - checkStatusColumn: { - display: 'block', - width: 80, - marginTop: 10, - height: 30, - float: 'left' - }, - checkDescriptionColumn: { - display: 'inline-block' - }, - checkDetails: { - clear: 'both', - display: 'block', - color: colors.pgaiDarkGray - }, - checkListItem: { - marginBottom: 10, - minHeight: 30 - }, - cfgListItem: { - marginBottom: 5 - }, - expansionPanel: { - marginTop: '5px!important', - borderRadius: '0px!important' - }, - expansionPanelSummary: { - 'display': 'inline-block', - 'padding': '5px', - 'paddingLeft': '12px', - 'minHeight': '30px', - 'lineHeight': '30px', - 'width': '100%', - '& .MuiExpansionPanelSummary-content': { - margin: '0px', - display: 'inline-block' - }, - '&.Mui-expanded': { - minHeight: '22px' - }, - '& .MuiExpansionPanelSummary-expandIcon': { - display: 'inline-block', - padding: '0px', - marginTop: '-1px' - } - }, - expansionPanelDetails: { - padding: '12px', - paddingTop: '0px', - [theme.breakpoints.down('md')]: { - display: 'block' - } - }, - intervalsRow: { - 'borderBottom': '1px solid ' + colors.consoleStroke, - 'width': '100%', - 'lineHeight': '22px', - '&:last-child': { - borderBottom: 'none' - } - }, - intervalIcon: { - display: 'inline-block', - width: 25 - }, - intervalStarted: { - display: 'inline-block', - width: 200 - }, - intervalDuration: { - display: 'inline-block' - }, - intervalWarning: { - display: 'inline-block', - width: '100%' - }, - code: { - 'width': '100%', - 'margin-top': 0, - '& > div': { - paddingTop: 8, - padding: 8 - }, - 'background-color': 'rgb(246, 248, 250)', - '& > div > textarea': { - fontFamily: '"Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas",' + - ' "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace', - color: 'black', - fontSize: '12px' - } - }, - button: { - marginTop: 5, - marginBottom: 10 - }, - bottomSpace: { - ...styles.bottomSpace - }, - artifactRow: { - padding: '5px', - cursor: 'pointer', - [theme.breakpoints.down('sm')]: { - paddingLeft: '0px', - paddingRight: '0px', - paddingTop: '10px' - } - }, - artifactName: { - 'display': 'inline-block', - 'width': '20%', - [theme.breakpoints.down('sm')]: { - display: 'block', - width: '100%', - marginBottom: '10px' - }, - '& svg': { - verticalAlign: 'middle' - } - }, - artifactDescription: { - display: 'inline-block', - width: '40%', - [theme.breakpoints.down('sm')]: { - display: 'block', - width: '100%', - marginBottom: '10px' - } - }, - artifactSize: { - display: 'inline-block', - width: '20%', - [theme.breakpoints.down('sm')]: { - display: 'block', - width: '100%', - marginBottom: '10px' - } - }, - artifactAction: { - 'display': 'inline-block', - 'width': '20%', - 'textAlign': 'right', - '& button': { - marginBottom: '5px' - }, - [theme.breakpoints.down('sm')]: { - display: 'block', - width: '100%' - } - }, - artifactExpansionPanel: { - padding: '0px!important', - boxShadow: 'none' - }, - artifactExpansionPanelSummary: { - display: 'none', - minHeight: '0px!important' - }, - artifactsExpansionPanelDetails: { - padding: '0px!important' - }, - summaryDivider: { - minHeight: '10px' - }, - rotate180Icon: { - '& svg': { - transform: 'rotate(180deg)' - } - }, - rotate0Icon: { - '& svg': { - transform: 'rotate(0deg)' - } - } -}); - -class DbLabSession extends Component { - componentDidMount() { - let sessionId = this.props.match.params.sessionId; - let that = this; - - this.unsubscribe = Store.listen(function () { - const auth = this.data && this.data.auth ? this.data.auth : null; - const dbLabSession = this.data && this.data.dbLabSession ? - this.data.dbLabSession : null; - - if (auth && auth.token && !dbLabSession.isProcessing && - !that.state) { - Actions.getDbLabSession(auth.token, sessionId); - } - - if (auth && auth.token && !dbLabSession.isLogsProcessing && - !that.state) { - Actions.getDbLabSessionLogs(auth.token, { sessionId, limit: PAGE_SIZE }); - } - - if (auth && auth.token && !dbLabSession.isArtifactsProcessing && - !that.state) { - Actions.getDbLabSessionArtifacts(auth.token, sessionId); - } - - that.setState({ data: this.data }); - - let contentContainer = document.getElementById('logs-container'); - if (contentContainer && !contentContainer.getAttribute('onscroll')) { - contentContainer.addEventListener('scroll', () => { - if (contentContainer.scrollTop >= - (contentContainer.scrollHeight - contentContainer.offsetHeight)) { - if (that.refs.showMoreBtn) { - that.refs.showMoreBtn.click(); - } - } - }); - contentContainer.setAttribute('onscroll', 1); - } - }); - - Actions.refresh(); - } - - componentWillUnmount() { - this.unsubscribe(); - } - - showMore() { - const sessionId = this.props.match.params.sessionId; - const auth = this.state.data && this.state.data.auth ? - this.state.data.auth : null; - const session = this.state.data && this.state.data.dbLabSession ? - this.state.data.dbLabSession : []; - let lastId = null; - - if (session && session.logs && session.logs.length) { - lastId = session.logs[session.logs.length - 1].id; - } - - if (auth && auth.token && !session.isLogsProcessing && lastId) { - Actions.getDbLabSessionLogs( - auth.token, - { - sessionId, - limit: PAGE_SIZE, - lastId - } - ); - } - } - - getCheckDetails(session, check) { - switch (check) { - case 'no_long_dangerous_locks': - let intervals = null; - let maxIntervals = null; - if (session && session.result && session.result.summary && - session.result.summary.total_intervals) { - intervals = session.result.summary.total_intervals; - } - if (session && session.config && session.config.observation_interval) { - maxIntervals = session.config.observation_interval; - } - if (intervals && maxIntervals) { - return '(' + intervals + ' ' + - (intervals > 1 ? 'intervals' : 'interval') + ' with locks of ' + - maxIntervals + ' allowed)'; - } - break; - - case 'session_duration_acceptable': - let totalDuration = null; - let maxDuration = null; - if (session && session.result && session.result.summary && - session.result.summary.total_duration) { - totalDuration = session.result.summary.total_duration; - } - if (session && session.config && session.config.max_duration) { - maxDuration = session.config.max_duration; - } - if (totalDuration && maxDuration) { - return '(spent ' + format.formatSeconds(totalDuration, 0, '') + ' of the allowed ' + - format.formatSeconds(maxDuration, 0, '') + ')'; - } - break; - - default: - } - - return ''; - } - - downloadLog = () => { - const auth = this.state && this.state.data && this.state.data.auth ? - this.state.data.auth : null; - const sessionId = this.props.match.params.sessionId; - - Actions.downloadDblabSessionLog(auth.token, sessionId); - } - - downloadArtifact = (artifactType) => { - const auth = this.state && this.state.data && this.state.data.auth ? - this.state.data.auth : null; - const sessionId = this.props.match.params.sessionId; - - Actions.downloadDblabSessionArtifact(auth.token, sessionId, artifactType); - } - - getArtifact = (artifactType) => { - const auth = this.state && this.state.data && this.state.data.auth ? - this.state.data.auth : null; - const sessionId = this.props.match.params.sessionId; - - Actions.getDbLabSessionArtifact(auth.token, sessionId, artifactType); - } - - render() { - const that = this; - const { classes, orgPermissions } = this.props; - const sessionId = this.props.match.params.sessionId; - const data = this.state && this.state.data && - this.state.data.dbLabSession ? this.state.data.dbLabSession : null; - const title = 'Database Lab observed session #' + sessionId; - - const pageTitle = ( - - ); - const breadcrumbs = ( - - ); - - if (orgPermissions && !orgPermissions.dblabSessionView) { - return ( -
- { breadcrumbs } - - { pageTitle } - - { messages.noPermissionPage } -
- ); - } - - let errorWidget = null; - if (this.state && this.state.data.dbLabSession.error) { - errorWidget = ( - - ); - } - - if (this.state && (this.state.data.dbLabSession.error || - this.state.data.dbLabInstanceStatus.error)) { - return ( -
- {breadcrumbs} - - { pageTitle } - - {errorWidget} -
- ); - } - - if (!data || - (this.state && this.state.data && - (this.state.data.dbLabSession.isProcessing))) { - return ( -
- {breadcrumbs} - - { pageTitle } - - -
- ); - } - - const session = data && data.data ? data.data : null; - const logs = data && data.logs ? data.logs : null; - const artifacts = data && data.artifacts ? data.artifacts : null; - const artifactData = data && data.artifactData ? data.artifactData : null; - - return ( -
- {breadcrumbs} - - { pageTitle } - -
-
- Summary -
- - - Status: - - - -
- - - Session: - {session ? '#' + session.id : '-'} - - - - Project: - {session.project_name ? session.project_name : '-'} - - - - DLE instance: - {session.internal_instance_id ? ( - - {'#' + session.internal_instance_id} - - ) : ''} - - - - DLE version: - {session && session.tags && session.tags.dle_version ? - session.tags.dle_version : '-'} - - -
- - - Data state at: - {session && session.tags && session.tags.data_state_at ? - session.tags.data_state_at : '-'} - - - -
- - - Duration: - {session && session.result && session.result.summary && - session.result.summary.elapsed ? - session.result.summary.elapsed : null} - {!(session && session.result && session.result.summary && - session.result.summary.elapsed) && session.duration > 0 ? - format.formatSeconds(session.duration, 0, '') : null} - - - - Created: - { - session && - formatDistanceToNowStrict(new Date(session.started_at), { addSuffix: true }) - } - - -
- - - Branch: - {session && session.tags && session.tags.branch && - session.tags.branch_link ? ( - - {session.tags.branch} - - ) : ( - - {session && session.tags && session.tags.branch ? - session.tags.branch : '-'} - - ) - } - - - - Commit: - {session && session.tags && session.tags.revision && - session.tags.revision_link ? ( - - {session.tags.revision} - - ) : ( - - {session && session.tags && session.tags.revision ? - session.tags.revision : '-'} - - ) - } - - - - Triggered by: - {session && session.tags && session.tags.launched_by && - session.tags.username_link ? ( - - {session.tags.launched_by} - {session.tags.username_full ? - ' (' + session.tags.username_full + ')' : ''} - - ) : ( - - {session && session.tags && session.tags.launched_by ? - session.tags.launched_by : '-'} - - ) - } - - - - PR/MR: - {session && session.tags && session.tags.request_link ? ( - - {session.tags.request_link} - ) : '-'} - - - - Changes: - {session && session.tags && session.tags.request_link ? ( - - {session.tags.request_link} - ) : '-'} - - - {false && - Check documentation for the details about observed sessions: - - Database Lab – CI Observer - - } -
- -
- -
-
- Checklist -
- - {session.result && session.result.summary && - session.result.summary.checklist ? ( -
- {Object.keys(session.result.summary.checklist).map(function (key) { - let details = that.getCheckDetails(session, key); - return ( - -
- {session.result.summary.checklist[key] ? - () : - () - } -
-
- {format.formatDbLabSessionCheck(key)} -
- {details} -
-
-
- ); - })} -
- ) : (icons.processingLargeIcon)} -
- -
- -
-
- Observed intervals and details -
- { - that.setState({ intervalsExpanded: expanded }); - }} - > - } - aria-controls='panel1b-content' - id='panel1b-header' - className={classes.expansionPanelSummary} - > - {that.state.intervalsExpanded ? 'Hide intervals' : 'Show intervals'} - - - {session.result && session.result.intervals && - session.result.intervals.length > 0 ? ( -
-
-
-
Started at
-
Duration
-
- {session.result.intervals.map(i => { - return ( -
-
-
- {i.warning ? - icons.intervalWarning : - icons.intervalOk - } -
-
- {format.formatTimestampUtc(i.started_at)} -
-
- {format.formatSeconds(i.duration, 0, '')} -
-
- {i.warning && -
-
- -
-
- } -
- ); - })} -
- ) : ( - - Not specified - - )} - - -
- -
- -
-
- Configuration -
- - { - that.setState({ configurationExpanded: expanded }); - }} - > - } - aria-controls='panel1b-content' - id='panel1b-header' - className={classes.expansionPanelSummary} - > - {that.state.configurationExpanded ? 'Hide configuration' : - 'Show configuration'} - - - {session.config ? ( -
- {Object.keys(session.config).map(function (key) { - return ( - - {key}: - {session.config[key]} - - ); - })} -
- ) : ( - - Not specified - - )} -
-
-
- -
- -
- -
-
- Artifacts -
- - {Array.isArray(artifacts) && artifacts.length ? - ( - - - - {artifacts.map(a => { - return ( - { - if (orgPermissions && !orgPermissions.dblabSessionArtifactsView) { - return; - } - let artifactsExpanded = that.state.artifactsExpanded || {}; - artifactsExpanded[a.artifact_type] = - !artifactsExpanded[a.artifact_type]; - that.setState({ artifactsExpanded: artifactsExpanded }); - if (artifactsExpanded[a.artifact_type] && - a.artifact_type !== 'log' && - (!data.artifactsData || - data.artifactsData && !data.artifactsData[a.artifact_type])) { - this.getArtifact(a.artifact_type); - } - }} - > - -
-
- {a.artifact_type}  - {orgPermissions && orgPermissions.dblabSessionArtifactsView && - - {icons.detailsArrow} - } -
-
- {dblabutils.getArtifactDescription(a.artifact_type)} -
-
- {format.formatBytes(a.artifact_size, 0, true)} -
- {orgPermissions && orgPermissions.dblabSessionArtifactsView && -
- -
} -
-
- - } - aria-controls='panel1b-content' - id='panel1b-header' - className={classes.artifactExpansionPanelSummary} - > - {that.state.logsExpanded ? 'Hide log' : 'Show log'} - - - { a.artifact_type === 'log' ?
- {Array.isArray(logs) && logs.length ? ( -
- {logs.map(r => { - return ( -
- {r.log_time}, - {r.user_name}, - {r.database_name}, - {r.process_id}, - {r.connection_from}, - {r.session_id}, - {r.session_line_num}, - {r.command_tag}, - {r.session_start_time}, - {r.virtual_transaction_id}, - {r.transaction_id}, - {r.error_severity}, - {r.sql_state_code}, - {r.message}, - {r.detail}, - {r.hint}, - {r.internal_query}, - {r.internal_query_pos}, - {r.context}, - {r.query}, - {r.query_pos}, - {r.location}, - {r.application_name}, - {r.backend_type} -
- ); - })} -
- {data && data.isLogsProcessing && - } - {data && !data.isLogsProcessing && !data.isLogsComplete && - - } -
-
- ) : 'No log uploaded yet.'} -
:
- {artifactData && artifactData[a.artifact_type] && - artifactData[a.artifact_type].isProcessing ? - : null} - {artifactData && artifactData[a.artifact_type] && - artifactData[a.artifact_type].isProcessed && - artifactData[a.artifact_type].data ? -
- {artifactData[a.artifact_type].data} -
: null} -
} -
-
-
-
-
- ); - })} -
-
-
- ) : - ( - {data.isArtifactsProcessed ? 'Artifacts not found' : ''} - {data.isArtifactsProcessing ? - : null} - ) - } -
- -
-
- ); - } -} - -DbLabSession.propTypes = { - classes: PropTypes.object.isRequired, - theme: PropTypes.object.isRequired -}; - -export default withStyles(getStyles, { withTheme: true })(DbLabSession); diff --git a/ui/packages/platform/src/components/DbLabSessions.js b/ui/packages/platform/src/components/DbLabSessions.js deleted file mode 100644 index add57e6d..00000000 --- a/ui/packages/platform/src/components/DbLabSessions.js +++ /dev/null @@ -1,362 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import { Component } from 'react'; -import PropTypes from 'prop-types'; -import { withStyles } from '@material-ui/core/styles'; -import { - Table, TableBody, TableCell, - TableHead, TableRow, Button -} from '@material-ui/core'; -import { formatDistanceToNowStrict } from 'date-fns'; - -import { - HorizontalScrollContainer -} from '@postgres.ai/shared/components/HorizontalScrollContainer'; -import { StubContainer } from '@postgres.ai/shared/components/StubContainer'; -import { PageSpinner } from '@postgres.ai/shared/components/PageSpinner'; -import { Spinner } from '@postgres.ai/shared/components/Spinner'; -import { styles } from '@postgres.ai/shared/styles/styles'; -import { icons } from '@postgres.ai/shared/styles/icons'; - -import ProductCard from 'components/ProductCard'; - -import Store from '../stores/store'; -import Actions from '../actions/actions'; -import Error from './Error'; -import ConsoleBreadcrumbs from './ConsoleBreadcrumbs'; -import ConsolePageTitle from './ConsolePageTitle'; -import format from '../utils/format'; -import DbLabStatus from './DbLabStatus'; - - -const PAGE_SIZE = 20; - -const getStyles = () => ({ - root: { - ...styles.root, - paddingBottom: '20px', - display: 'flex', - flexDirection: 'column' - }, - tableHead: { - ...styles.tableHead, - textAlign: 'left' - }, - tableCell: { - textAlign: 'left' - }, - showMoreContainer: { - marginTop: 20, - textAlign: 'center' - } -}); - -class DbLabSessions extends Component { - componentDidMount() { - const that = this; - const { orgId } = this.props; - - this.unsubscribe = Store.listen(function () { - const auth = this.data && this.data.auth ? this.data.auth : null; - const sessions = this.data && this.data.dbLabSessions ? - this.data.dbLabSessions : null; - - if (auth && auth.token && !sessions.isProcessing && !sessions.error && - !that.state) { - Actions.getDbLabSessions(auth.token, { orgId, limit: PAGE_SIZE }); - } - - that.setState({ data: this.data }); - }); - - let contentContainer = document.getElementById('content-container'); - if (contentContainer) { - contentContainer.addEventListener('scroll', () => { - if (contentContainer.scrollTop >= - (contentContainer.scrollHeight - contentContainer.offsetHeight)) { - if (that.refs.showMoreBtn) { - that.refs.showMoreBtn.click(); - } - } - }); - } - - Actions.refresh(); - } - - componentWillUnmount() { - this.unsubscribe(); - } - - onSessionClick(event, sessionId) { - const { org } = this.props; - - this.props.history.push( - '/' + org + - '/observed-sessions/' + sessionId - ); - } - - formatStatus(status) { - const { classes } = this.props; - let icon = null; - let className = null; - let label = status; - if (status.length) { - label = status.charAt(0).toUpperCase() + status.slice(1); - } - - switch (status) { - case 'passed': - icon = icons.okIcon; - className = classes.passedStatus; - break; - case 'failed': - icon = icons.failedIcon; - className = classes.failedStatus; - break; - default: - icon = icons.processingIcon; - className = classes.processingStatus; - } - - return ( -
- {icon} {label} -
- ); - } - - showMore() { - const { orgId } = this.props; - const auth = this.state.data && this.state.data.auth ? - this.state.data.auth : null; - const sessions = this.state.data && this.state.data.dbLabSessions ? - this.state.data.dbLabSessions : []; - let lastId = null; - - if (sessions && sessions.data && sessions.data.length) { - lastId = sessions.data[sessions.data.length - 1].id; - } - - if (auth && auth.token && !sessions.isProcessing && lastId) { - Actions.getDbLabSessions( - auth.token, - { - orgId, - limit: PAGE_SIZE, - lastId - } - ); - } - } - - render() { - const { classes, org } = this.props; - - const breadcrumbs = ( - - ); - - const pageTitle = ( - - ); - - if (!this.state || !this.state.data) { - return ( -
- {breadcrumbs} - {pageTitle} - - -
- ); - } - - const sessionsStore = this.state.data && this.state.data.dbLabSessions || null; - const sessions = sessionsStore && sessionsStore.data || []; - - if ((sessionsStore && sessionsStore.error)) { - return ( -
- {breadcrumbs} - - {pageTitle} - - -
- ); - } - - if (!sessionsStore || !sessionsStore.data) { - return ( -
- {breadcrumbs} - - {pageTitle} - - -
- ); - } - - return ( -
- {breadcrumbs} - {pageTitle} - - {sessions && sessions.length > 0 ? ( -
- - - - - Status - - - Session - - - Project/Instance - - - Commit - - - Checklist - - -   - - - - - {sessions.map(s => { - if (s) { - return ( - { - this.onSessionClick( - event, - s.id - ); - return false; - }} - style={{ cursor: 'pointer' }} - > - - - - - #{s.id} - - - {s.tags && s.tags.project_id ? s.tags.project_id : '-'}/ - {s.tags && s.tags.instance_id ? s.tags.instance_id : '-'} - - - {icons.branch} {s.tags && s.tags.branch && s.tags.revision ? - s.tags.branch + '/' + s.tags.revision : '-'} - - - {s.result && s.result.summary && s.result.summary.checklist ? ( -
- {Object.keys(s.result.summary.checklist).map(function (key) { - return ( - - {s.result.summary.checklist[key] ? icons.okLargeIcon : - icons.failedLargeIcon}  - - ); - })} -
- ) : (icons.processingLargeIcon)} -
- -
- {s.duration > 0 || - (s.result && s.result.summary && s.result.summary.elapsed) ? ( - - {icons.timer}  - {s.result && s.result.summary && s.result.summary.elapsed ? - s.result.summary.elapsed : - format.formatSeconds(s.duration, 0, '') - } - - ) : '-'} -
-
- {icons.calendar} created  - { - formatDistanceToNowStrict( - new Date(s.started_at), - { addSuffix: true } - ) - } - {s.tags && s.tags.launched_by ? ( - by {s.tags.launched_by} - ) : ''} -
-
-
- ); - } - - return null; - })} -
-
-
-
- {sessionsStore && sessionsStore.isProcessing && - } - {sessionsStore && !sessionsStore.isProcessing && !sessionsStore.isComplete && - - } -
-
) : ( - <> - { sessions && sessions.length === 0 && sessionsStore.isProcessed && - - } - - )} -
- ); - } -} - - -DbLabSessions.propTypes = { - classes: PropTypes.object.isRequired, - theme: PropTypes.object.isRequired -}; - -export default withStyles(getStyles, { withTheme: true })(DbLabSessions); diff --git a/ui/packages/platform/src/components/DbLabStatus.js b/ui/packages/platform/src/components/DbLabStatus.js deleted file mode 100644 index 0962d003..00000000 --- a/ui/packages/platform/src/components/DbLabStatus.js +++ /dev/null @@ -1,334 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import { Component } from 'react'; -import PropTypes from 'prop-types'; -import { withStyles } from '@material-ui/core/styles'; -import Brightness1Icon from '@material-ui/icons/Brightness1'; -import Tooltip from '@material-ui/core/Tooltip'; - -import { colors } from '@postgres.ai/shared/styles/colors'; -import { icons } from '@postgres.ai/shared/styles/icons'; - -import Format from '../utils/format'; - -const styles = () => ({ - cloneReadyStatus: { - color: colors.state.ok, - fontSize: '1.1em', - verticalAlign: 'middle', - ['& svg']: { - marginTop: '-3px' - } - }, - cloneCreatingStatus: { - color: colors.state.processing, - fontSize: '1.1em', - verticalAlign: 'middle', - ['& svg']: { - marginTop: '-3px' - } - }, - cloneResettingStatus: { - color: colors.state.processing, - fontSize: '1.1em', - verticalAlign: 'middle', - ['& svg']: { - marginTop: '-3px' - } - }, - cloneDeletingStatus: { - color: colors.state.warning, - fontSize: '1.1em', - verticalAlign: 'middle', - ['& svg']: { - marginTop: '-3px' - } - }, - cloneFatalStatus: { - color: colors.state.error, - fontSize: '1.1em', - verticalAlign: 'middle', - ['& svg']: { - marginTop: '-3px' - } - - }, - instanceReadyStatus: { - color: colors.state.ok, - fontSize: '1.1em', - verticalAlign: 'middle', - ['& svg']: { - marginTop: '-3px' - } - }, - instanceWarningStatus: { - color: colors.state.warning, - fontSize: '1.1em', - verticalAlign: 'middle', - ['& svg']: { - marginTop: '-3px' - } - }, - instanceNoResponseStatus: { - color: colors.state.error, - fontSize: '1.1em', - verticalAlign: 'middle', - ['& svg']: { - marginTop: '-3px' - } - }, - toolTip: { - fontSize: '10px!important' - }, - sessionPassedStatus: { - 'display': 'inline-block', - 'border': '1px solid ' + colors.state.ok, - 'fontSize': '12px', - 'color': '#FFFFFF', - 'backgroundColor': colors.state.ok, - 'padding': '3px', - 'paddingLeft': '5px', - 'paddingRight': '5px', - 'borderRadius': 3, - 'lineHeight': '14px', - '& svg': { - width: 10, - height: 10, - marginBottom: '-1px', - marginRight: '5px' - } - }, - sessionFailedStatus: { - 'display': 'inline-block', - 'border': '1px solid ' + colors.state.error, - 'fontSize': '12px', - 'color': '#FFFFFF', - 'backgroundColor': colors.state.error, - 'padding': '3px', - 'paddingLeft': '5px', - 'paddingRight': '5px', - 'borderRadius': 3, - 'lineHeight': '14px', - '& svg': { - width: 10, - height: 10, - marginBottom: '-1px', - marginRight: '5px' - } - }, - sessionProcessingStatus: { - 'display': 'inline-block', - 'border': '1px solid ' + colors.state.processing, - 'fontSize': '12px', - 'color': '#FFFFFF', - 'backgroundColor': colors.state.processing, - 'padding': '3px', - 'paddingLeft': '5px', - 'paddingRight': '5px', - 'borderRadius': 3, - 'lineHeight': '14px', - '& svg': { - width: 10, - height: 10, - marginBottom: '-1px', - marginRight: '5px' - } - } -}); - -class DbLabStatus extends Component { - getCloneStatus = (clone, onlyText, showDescription) => { - const { classes } = this.props; - let className = classes.cloneReadyStatus; - - if (!clone.status) { - return null; - } - - switch (clone.status.code) { - case 'OK': - className = classes.cloneReadyStatus; - break; - case 'CREATING': - className = classes.cloneCreatingStatus; - break; - case 'DELETING': - className = classes.cloneDeletingStatus; - break; - case 'RESETTING': - className = classes.cloneResettingStatus; - break; - case 'FATAL': - className = classes.cloneFatalStatus; - break; - default: - break; - } - - if (onlyText && showDescription) { - return ( - - - -   - {Format.formatStatus(clone.status.code)} - - - {clone.status.message && clone.status.message.length > 100 ? ( - - {Format.limitStr(clone.status.message, 100)} - - ) : clone.status.message} - - - ); - } - - if (onlyText && !showDescription) { - return ( - - - - -   - {Format.formatStatus(clone.status.code)} - - ); - } - - return ( - - - - ); - } - - getInstanceStatus = (instance, onlyText) => { - const { classes } = this.props; - let className = classes.instanceReadyStatus; - - if (!instance.state) { - return null; - } - - if (!instance.state.status) { - return null; - } - switch (instance.state.status.code) { - case 'OK': - className = classes.instanceReadyStatus; - break; - case 'WARNING': - className = classes.instanceWarningStatus; - break; - case 'NO_RESPONSE': - className = classes.instanceNoResponseStatus; - break; - default: - break; - } - - if (onlyText) { - return ( - - - - -   - {Format.formatStatus(instance.state.status.code)} - - ); - } - - return ( - - - - ); - } - - getSessionStatus = (session) => { - const { classes } = this.props; - let icon = null; - let className = null; - let label = session.status; - if (session.status.length) { - label = session.status.charAt(0).toUpperCase() + session.status.slice(1); - } - - switch (session.status) { - case 'passed': - icon = icons.okIconWhite; - className = classes.sessionPassedStatus; - break; - case 'failed': - icon = icons.failedIconWhite; - className = classes.sessionFailedStatus; - break; - default: - icon = icons.processingIconWhite; - className = classes.sessionProcessingStatus; - } - - return ( -
- {icon}{label} -
- ); - } - - render() { - const onlyText = this.props.onlyText; - const showDescription = this.props.showDescription; - const instance = this.props.instance; - const clone = this.props.clone; - const session = this.props.session; - - if (clone) { - return this.getCloneStatus(clone, onlyText, showDescription); - } - - if (instance) { - return this.getInstanceStatus(instance, onlyText); - } - - if (session) { - return this.getSessionStatus(session); - } - - return null; - } -} - -DbLabStatus.propTypes = { - classes: PropTypes.object.isRequired, - theme: PropTypes.object.isRequired -}; - -export default withStyles(styles, { withTheme: true })(DbLabStatus); diff --git a/ui/packages/platform/src/components/DisplayToken.js b/ui/packages/platform/src/components/DisplayToken.js deleted file mode 100644 index 216beb9d..00000000 --- a/ui/packages/platform/src/components/DisplayToken.js +++ /dev/null @@ -1,128 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import { Component } from 'react'; -import PropTypes from 'prop-types'; -import { InputAdornment } from '@material-ui/core'; -import { withStyles } from '@material-ui/core/styles'; -import IconButton from '@material-ui/core/IconButton'; -import TextField from '@material-ui/core/TextField'; - -import { styles } from '@postgres.ai/shared/styles/styles'; -import { icons } from '@postgres.ai/shared/styles/icons'; - -import Store from '../stores/store'; -import Actions from '../actions/actions'; - -const getStyles = () => ({ - textField: { - ...styles.inputField, - marginTop: 0 - }, - input: { - '&.MuiOutlinedInput-adornedEnd': { - padding: 0 - } - }, - // TODO (Anton): Rewrite styling of TextField component and remove !important everywhere. - inputElement: { - marginRight: '-8px' - }, - inputAdornment: { - margin: 0 - }, - inputButton: { - padding: '9px 10px' - } -}); - -class DisplayToken extends Component { - componentDidMount() { - const that = this; - - document.getElementsByTagName('html')[0].style.overflow = 'hidden'; - - this.unsubscribe = Store.listen(function () { - that.setState({ data: this.data }); - }); - - Actions.refresh(); - } - - componentWillUnmount() { - this.unsubscribe(); - } - - copyToken = () => { - let copyText = document.getElementById('generatedToken'); - - copyText.select(); - copyText.setSelectionRange(0, 99999); - document.execCommand('copy'); - } - - render() { - const { classes } = this.props; - const tokenRequest = this.state && this.state.data && - this.state.data.tokenRequest ? this.state.data.tokenRequest : null; - let tokenDisplay = null; - - if (tokenRequest && tokenRequest.isProcessed && !tokenRequest.error && - tokenRequest.data && tokenRequest.data.name && - tokenRequest.data.expires_at && tokenRequest.data.token) { - tokenDisplay = ( - - - {icons.copyIcon} - - - ) - }} - InputLabelProps={{ - shrink: true, - style: styles.inputFieldLabel - }} - FormHelperTextProps={{ - style: styles.inputFieldHelper - }} - helperText='Make sure you have saved token - you will not be able to access it again' - /> - ); - } - - return ( -
- {tokenDisplay} -
- ); - } -} - -DisplayToken.propTypes = { - classes: PropTypes.object.isRequired, - theme: PropTypes.object.isRequired -}; - -export default withStyles(getStyles, { withTheme: true })(DisplayToken); diff --git a/ui/packages/platform/src/components/Error.js b/ui/packages/platform/src/components/Error.js deleted file mode 100644 index 98540fe1..00000000 --- a/ui/packages/platform/src/components/Error.js +++ /dev/null @@ -1,65 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import React, { Component } from 'react'; -import PropTypes from 'prop-types'; -import { withStyles } from '@material-ui/core/styles'; -import Paper from '@material-ui/core/Paper'; -import Typography from '@material-ui/core/Typography'; - - -const styles = theme => ({ - paper: theme.mixins.gutters({ - paddingTop: 16, - paddingBottom: 16, - marginTop: 0 - }), - errorHead: { - color: '#c00111', - fontWeight: 'bold!important', - fontSize: '16px!important' - }, - errorText: { - color: '#c00111' - } -}); - -class Error extends Component { - render() { - const { classes } = this.props; - - return ( -
- - - ERROR {this.props.code ? this.props.code : null} - - -
- - - {this.props.message ? this.props.message : - 'Unknown error occurred. Please try again later.'} - -
-
- ); - } -} - -Error.propTypes = { - classes: PropTypes.object.isRequired -}; - -export default withStyles(styles)(Error); diff --git a/ui/packages/platform/src/components/ExplainVisualization.js b/ui/packages/platform/src/components/ExplainVisualization.js deleted file mode 100644 index 790c43f8..00000000 --- a/ui/packages/platform/src/components/ExplainVisualization.js +++ /dev/null @@ -1,344 +0,0 @@ -/*-------------------------------------------------------------------------- - * Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai - * All Rights Reserved. Proprietary and confidential. - * Unauthorized copying of this file, via any medium is strictly prohibited - *-------------------------------------------------------------------------- - */ - -import AppBar from '@material-ui/core/AppBar'; -import Button from '@material-ui/core/Button'; -import CloseIcon from '@material-ui/icons/Close'; -import Dialog from '@material-ui/core/Dialog'; -import IconButton from '@material-ui/core/IconButton'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import Slide from '@material-ui/core/Slide'; -import Store from '../stores/store'; -import TextField from '@material-ui/core/TextField'; -import Toolbar from '@material-ui/core/Toolbar'; -import Typography from '@material-ui/core/Typography'; -import { withStyles } from '@material-ui/core/styles'; - -import { styles } from '@postgres.ai/shared/styles/styles'; -import { Spinner } from '@postgres.ai/shared/components/Spinner'; - -import Actions from '../actions/actions'; -import ConsoleBreadcrumbs from './ConsoleBreadcrumbs'; -import ConsolePageTitle from './ConsolePageTitle'; -import FlameGraph from './FlameGraph'; -import explainSamples from '../assets/explainSamples'; -import visualizeTypes from '../assets/visualizeTypes'; - - -const getStyles = theme => ({ - root: { - width: '100%', - [theme.breakpoints.down('sm')]: { - maxWidth: 'calc(100vw - 40px)' - }, - [theme.breakpoints.up('md')]: { - maxWidth: 'calc(100vw - 220px)' - }, - [theme.breakpoints.up('lg')]: { - maxWidth: 'calc(100vw - 220px)' - }, - minHeight: '100%', - zIndex: 1, - position: 'relative' - }, - pointerLink: { - cursor: 'pointer' - }, - breadcrumbPaper: { - marginBottom: 15 - }, - planTextField: { - '& .MuiInputBase-root': { - width: '100%' - }, - 'display': 'block', - 'width': '100%' - }, - appBar: { - position: 'relative' - }, - title: { - marginLeft: theme.spacing(2), - flex: 1, - fontSize: '16px' - }, - visFrame: { - height: '100%' - }, - nextButton: { - marginLeft: '10px' - }, - flameGraphContainer: { - padding: '20px' - } -}); - -const FullScreenDialogTransition = React.forwardRef(function Transition(props, ref) { - return ; -}); - -class ExplainVisualization extends Component { - componentDidMount() { - const that = this; - - this.unsubscribe = Store.listen(function () { - that.setState({ data: this.data }); - }); - - Actions.refresh(); - } - - componentWillUnmount() { - this.unsubscribe(); - } - - handleChange = event => { - let id = event.target.id; - let value = event.target.value; - - this.setState({ - [id]: value - }); - } - - insertSample = () => { - this.setState({ plan: explainSamples[0].value }); - } - - getExternalVisualization = () => { - return this.state && this.state.data && - this.state.data.externalVisualization ? this.state.data.externalVisualization : null; - } - - showExternalVisualization = (type) => { - const { plan } = this.state; - - if (!plan) { - return; - } - - Actions.getExternalVisualizationData(type, plan, ''); - } - - closeExternalVisualization = () => { - Actions.closeExternalVisualization(); - this.setState({ - showFlameGraph: false - }); - } - - handleExternalVisualizationClick = (type) => { - return () => { - this.showExternalVisualization(type); - }; - } - - showFlameGraphVisualization = () => { - this.setState({ - showFlameGraph: true - }); - } - - render() { - const { classes } = this.props; - - const breadcrumbs = ( - - ); - - const pageTitle = ( - -

- Visualize explain plans gathered manually. Plans gathered with Joe - will be automatically saved in Joe history and can be visualized in - command page without copy-pasting of a plan. -

-

- Currently only JSON format is supported. -

-

- For better results, use: explain (analyze, costs, verbose, buffers, format json). -

- - } - /> - ); - - if (!this.state || !this.state.data) { - return ( -
- {breadcrumbs} - - {pageTitle} - - -
- ); - } - - const { plan, showFlameGraph } = this.state; - - const externalVisualization = this.getExternalVisualization(); - - const disableVizButtons = !plan || showFlameGraph || - (externalVisualization && externalVisualization.isProcessing); - const openVizDialog = showFlameGraph || (externalVisualization && - externalVisualization.url && externalVisualization.url.length > 0); - - return ( -
- { breadcrumbs } - - { pageTitle } - -
- -
- - - -
- - - - - -
- -
- - - - - Visualization - - - - - - - - { showFlameGraph && -
-

Flame Graph (buffers):

- - -

Flame Graph (timing):

- -
- } - - { externalVisualization.url && -