├── .bazelrc ├── .bazelversion ├── .factory └── automation.yml ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── BUG_REPORT.md │ ├── FEATURE_REQUEST.md │ └── REFACTOR.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── BUILD ├── LICENSE ├── README.md ├── RELEASE_NOTES_LATEST.md ├── RELEASE_TEMPLATE.md ├── VERSION ├── WORKSPACE ├── dependencies ├── maven │ ├── BUILD │ ├── artifacts.bzl │ ├── artifacts.snapshot │ └── update.sh └── typedb │ ├── BUILD │ └── repositories.bzl ├── deployment.bzl ├── grpc ├── java │ └── BUILD ├── nodejs │ ├── BUILD │ ├── package.json │ ├── pnpm-lock.yaml │ └── rules.bzl └── rust │ ├── BUILD │ ├── Cargo.toml │ ├── build.rs │ └── lib.rs ├── proto ├── BUILD ├── answer.proto ├── authentication.proto ├── concept.proto ├── connection.proto ├── database.proto ├── options.proto ├── query.proto ├── server.proto ├── transaction.proto ├── typedb-service.proto ├── user.proto └── version.proto └── tool └── release ├── BUILD └── create_notes.sh /.bazelrc: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | try-import ./.bazel-remote-cache.rc 6 | 7 | build --incompatible_strict_action_env --java_language_version=11 --javacopt='--release 11' --enable_runfiles 8 | run --incompatible_strict_action_env --java_runtime_version=remotejdk_11 9 | test --incompatible_strict_action_env --test_env=PATH --cache_test_results=no --java_runtime_version=remotejdk_11 10 | 11 | build --@aspect_rules_ts//ts:skipLibCheck=always 12 | fetch --@aspect_rules_ts//ts:skipLibCheck=always 13 | query --@aspect_rules_ts//ts:skipLibCheck=always 14 | -------------------------------------------------------------------------------- /.bazelversion: -------------------------------------------------------------------------------- 1 | 6.2.0 2 | -------------------------------------------------------------------------------- /.factory/automation.yml: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | config: 6 | version-candidate: VERSION 7 | dependencies: 8 | dependencies: [build] 9 | 10 | build: 11 | quality: 12 | filter: 13 | owner: typedb 14 | branch: master 15 | dependency-analysis: 16 | image: typedb-ubuntu-22.04 17 | command: | 18 | bazel run @typedb_dependencies//factory/analysis:dependency-analysis 19 | correctness: 20 | # build: 21 | # image: typedb-ubuntu-22.04 22 | # command: | 23 | # bazel run @typedb_dependencies//tool/bazelinstall:remote_cache_setup.sh 24 | # bazel build //... 25 | # bazel run @typedb_dependencies//tool/checkstyle:test-coverage 26 | # bazel test $(bazel query 'kind(checkstyle_test, //...)') --test_output=errors 27 | # build-dependency: 28 | # image: typedb-ubuntu-22.04 29 | # command: | 30 | # bazel run @typedb_dependencies//tool/bazelinstall:remote_cache_setup.sh 31 | # dependencies/maven/update.sh 32 | # git diff --exit-code dependencies/maven/artifacts.snapshot 33 | # bazel run @typedb_dependencies//tool/unuseddeps:unused-deps -- list 34 | deploy-crate-snapshot: 35 | filter: 36 | owner: typedb 37 | branch: [master, development, "3.0"] 38 | # dependencies: [build, build-dependency] 39 | image: typedb-ubuntu-22.04 40 | command: | 41 | bazel run @typedb_dependencies//tool/bazelinstall:remote_cache_setup.sh 42 | export DEPLOY_CRATE_TOKEN=$REPO_TYPEDB_CRATES_TOKEN 43 | bazel run --define version=$(git rev-parse HEAD) //grpc/rust:deploy_crate -- snapshot 44 | # deploy-npm-snapshot: 45 | # filter: 46 | # owner: typedb 47 | # branch: [master, development] 48 | # dependencies: [build, build-dependency] 49 | # image: typedb-ubuntu-20.04 50 | # command: | 51 | # export DEPLOY_NPM_USERNAME=$REPO_TYPEDB_USERNAME 52 | # export DEPLOY_NPM_PASSWORD=$REPO_TYPEDB_PASSWORD 53 | # bazel run --define version=$(git rev-parse HEAD) //grpc/nodejs:deploy-npm -- snapshot 54 | # sync-dependencies: 55 | # image: typedb-ubuntu-22.04 56 | # filter: 57 | # owner: typedb 58 | # branch: [master, development] 59 | # dependencies: 60 | # - build 61 | # - build-dependency 62 | # - deploy-crate-snapshot 63 | # - deploy-npm-snapshot 64 | # command: | 65 | # export SYNC_DEPENDENCIES_TOKEN=$REPO_GITHUB_TOKEN 66 | # bazel run @typedb_dependencies//tool/sync:dependencies -- --source ${FACTORY_REPO}@${FACTORY_COMMIT} 67 | 68 | release: 69 | filter: 70 | owner: typedb 71 | branch: [ master, "3.0" ] 72 | validation: 73 | validate-release-notes: 74 | image: typedb-ubuntu-22.04 75 | command: | 76 | export NOTES_VALIDATE_TOKEN=$REPO_GITHUB_TOKEN 77 | bazel run @typedb_dependencies//tool/release/notes:validate --test_output=streamed -- $FACTORY_OWNER $FACTORY_REPO ./RELEASE_NOTES_LATEST.md 78 | deployment: 79 | deploy-github: 80 | image: typedb-ubuntu-22.04 81 | command: | 82 | export PYENV_ROOT="/opt/pyenv" 83 | pyenv install 3.7.9 84 | pyenv global 3.7.9 85 | sudo unlink /usr/bin/python3 86 | sudo ln -s $(which python3) /usr/bin/python3 87 | sudo ln -s /usr/share/pyshared/lsb_release.py /opt/pyenv/versions/3.7.9/lib/python3.7/site-packages/lsb_release.py 88 | python3 -m pip install certifi 89 | export DEPLOY_GITHUB_TOKEN=$REPO_GITHUB_TOKEN 90 | bazel run --define version=$(cat VERSION) //:deploy-github -- $FACTORY_COMMIT 91 | deploy-crate-release: 92 | image: typedb-ubuntu-22.04 93 | dependencies: [deploy-github] 94 | command: | 95 | export DEPLOY_CRATE_TOKEN=$REPO_CRATES_TOKEN 96 | bazel run --define version=$(cat VERSION) //grpc/rust:deploy_crate -- release 97 | # deploy-npm-release: 98 | # image: typedb-ubuntu-22.04 99 | # dependencies: [deploy-github] 100 | # command: | 101 | # wget -q -O - https://cli-assets.heroku.com/apt/release.key | sudo apt-key add - 102 | # wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add - 103 | # sudo apt update -y 104 | # sudo apt install -y expect 105 | # export DEPLOY_NPM_TOKEN=$REPO_NPM_TOKEN 106 | # bazel run --define version=$(cat VERSION) //grpc/nodejs:deploy-npm -- release 107 | # sync-dependencies-release: 108 | # image: typedb-ubuntu-22.04 109 | # filter: 110 | # owner: typedb 111 | # branch: [master, development] 112 | # dependencies: 113 | # - deploy-github 114 | # - deploy-crate-release 115 | # - deploy-npm-release 116 | # command: | 117 | # export SYNC_DEPENDENCIES_TOKEN=$REPO_GITHUB_TOKEN 118 | # bazel run @typedb_dependencies//tool/sync:dependencies -- --source ${FACTORY_REPO}@$(cat VERSION) 119 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @haikalpribadi 2 | 3 | /dependencies/typedb/ @haikalpribadi @flyingsilverfin 4 | /dependencies/maven/ @haikalpribadi @lolski 5 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/BUG_REPORT.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Report a bug here, or visit forum.typedb.com for troubleshooting discussions 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## Description 11 | 12 | 13 | ## Environment 14 | 15 | 1. TypeDB distribution: Core/Enterprise/Cloud 16 | 2. TypeDB version: 17 | 3. Environment: Linux/Mac/Windows/TypeDB Cloud/Google Cloud/AWS/Azure 18 | 4. Driver version: 19 | 5. Other details: 20 | 21 | ## Reproducible Steps 22 | 23 | 1. Set up 24 | 25 | 26 | 2. Execute 27 | 28 | 29 | 3. Test/Query 30 | 31 | 32 | 4. Unexpected result 33 | 34 | 35 | 36 | ## Expected result 37 | 38 | 39 | ## Additional information 40 | 41 | Relevant logs from TypeDB or Driver: 42 | 43 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Request a feature here, or visit forum.typedb.com for ideas and questions 4 | labels: feature 5 | --- 6 | 7 | ## Problem to Solve 8 | 9 | 10 | ## Current Workaround 11 | 12 | 13 | ## Proposed Solution 14 | 15 | 16 | ## Additional Information 17 | 18 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/REFACTOR.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Refactor 3 | about: Propose an architecture refactor here 4 | labels: refactor 5 | --- 6 | 7 | ## Problem to Solve 8 | 9 | 10 | ## Proposed Solution 11 | 12 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Release notes: usage and product changes 2 | 3 | 4 | ## Implementation 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | # Mac files # 6 | .DS_Store 7 | 8 | # Bazel files # 9 | bazel-* 10 | 11 | # IDE files # 12 | .idea/ 13 | *.iml 14 | *.geany 15 | .ijwb/ 16 | 17 | # VS Code files # 18 | .vscode/ 19 | .settings/ 20 | .project 21 | .classpath 22 | 23 | # Compiled files # 24 | dist/ 25 | out/ 26 | target/ 27 | *.class 28 | 29 | # Cargo files # 30 | Cargo.lock 31 | 32 | # Mobile Tools for Java (J2ME) files # 33 | .mtj.tmp/ 34 | 35 | # Package Files # 36 | *.jarg 37 | *.war 38 | *.ear 39 | 40 | # Debug files # 41 | dep.tree 42 | 43 | # Databases # 44 | db/ 45 | 46 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml # 47 | hs_err_pid* 48 | 49 | # Log files # 50 | logs/ 51 | *.log 52 | 53 | 54 | # VIM swap files # 55 | *.swp 56 | *.swo 57 | 58 | # Python cache # 59 | __pycache__ 60 | 61 | # Node Modules # 62 | node_modules 63 | -------------------------------------------------------------------------------- /BUILD: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | package(default_visibility = ["//visibility:public"]) 6 | 7 | exports_files(["VERSION", "package.json"]) 8 | load("@typedb_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") 9 | load("@typedb_bazel_distribution//github:rules.bzl", "deploy_github") 10 | load("//:deployment.bzl", "deployment") 11 | 12 | checkstyle_test( 13 | name = "checkstyle", 14 | include = glob([ 15 | ".bazelrc", 16 | ".gitignore", 17 | "BUILD", 18 | "deployment.bzl", 19 | "WORKSPACE", 20 | ".factory/automation.yml", 21 | ]), 22 | exclude = [ 23 | ".bazel-remote-cache.rc", 24 | ".bazel-cache-credential.json", 25 | ], 26 | license_type = "mpl-header", 27 | size = "small", 28 | ) 29 | 30 | checkstyle_test( 31 | name = "checkstyle-license", 32 | include = ["LICENSE"], 33 | license_type = "mpl-fulltext", 34 | size = "small", 35 | ) 36 | 37 | deploy_github( 38 | name = "deploy-github", 39 | organisation = deployment["github.organisation"], 40 | repository = deployment["github.repository"], 41 | release_description = "//:RELEASE_NOTES_LATEST.md", 42 | title = "TypeDB Protocol", 43 | title_append_version = True, 44 | draft = False, 45 | ) 46 | 47 | exports_files(["README.md"]) 48 | 49 | # Tools to be built during `build //...` 50 | filegroup( 51 | name = "tools", 52 | data = [ 53 | "@typedb_dependencies//library/maven:update", 54 | "@typedb_dependencies//tool/ide:rust_sync", 55 | "@typedb_dependencies//tool/unuseddeps:unused-deps", 56 | "@typedb_dependencies//tool/release/notes:create", 57 | "@typedb_dependencies//tool/sync:dependencies", 58 | ], 59 | ) 60 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | 1. Definitions 5 | -------------- 6 | 7 | 1.1. "Contributor" 8 | means each individual or legal entity that creates, contributes to 9 | the creation of, or owns Covered Software. 10 | 11 | 1.2. "Contributor Version" 12 | means the combination of the Contributions of others (if any) used 13 | by a Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | means Covered Software of a particular Contributor. 17 | 18 | 1.4. "Covered Software" 19 | means Source Code Form to which the initial Contributor has attached 20 | the notice in Exhibit A, the Executable Form of such Source Code 21 | Form, and Modifications of such Source Code Form, in each case 22 | including portions thereof. 23 | 24 | 1.5. "Incompatible With Secondary Licenses" 25 | means 26 | 27 | (a) that the initial Contributor has attached the notice described 28 | in Exhibit B to the Covered Software; or 29 | 30 | (b) that the Covered Software was made available under the terms of 31 | version 1.1 or earlier of the License, but not also under the 32 | terms of a Secondary License. 33 | 34 | 1.6. "Executable Form" 35 | means any form of the work other than Source Code Form. 36 | 37 | 1.7. "Larger Work" 38 | means a work that combines Covered Software with other material, in 39 | a separate file or files, that is not Covered Software. 40 | 41 | 1.8. "License" 42 | means this document. 43 | 44 | 1.9. "Licensable" 45 | means having the right to grant, to the maximum extent possible, 46 | whether at the time of the initial grant or subsequently, any and 47 | all of the rights conveyed by this License. 48 | 49 | 1.10. "Modifications" 50 | means any of the following: 51 | 52 | (a) any file in Source Code Form that results from an addition to, 53 | deletion from, or modification of the contents of Covered 54 | Software; or 55 | 56 | (b) any new file in Source Code Form that contains any Covered 57 | Software. 58 | 59 | 1.11. "Patent Claims" of a Contributor 60 | means any patent claim(s), including without limitation, method, 61 | process, and apparatus claims, in any patent Licensable by such 62 | Contributor that would be infringed, but for the grant of the 63 | License, by the making, using, selling, offering for sale, having 64 | made, import, or transfer of either its Contributions or its 65 | Contributor Version. 66 | 67 | 1.12. "Secondary License" 68 | means either the GNU General Public License, Version 2.0, the GNU 69 | Lesser General Public License, Version 2.1, the GNU Affero General 70 | Public License, Version 3.0, or any later versions of those 71 | licenses. 72 | 73 | 1.13. "Source Code Form" 74 | means the form of the work preferred for making modifications. 75 | 76 | 1.14. "You" (or "Your") 77 | means an individual or a legal entity exercising rights under this 78 | License. For legal entities, "You" includes any entity that 79 | controls, is controlled by, or is under common control with You. For 80 | purposes of this definition, "control" means (a) the power, direct 81 | or indirect, to cause the direction or management of such entity, 82 | whether by contract or otherwise, or (b) ownership of more than 83 | fifty percent (50%) of the outstanding shares or beneficial 84 | ownership of such entity. 85 | 86 | 2. License Grants and Conditions 87 | -------------------------------- 88 | 89 | 2.1. Grants 90 | 91 | Each Contributor hereby grants You a world-wide, royalty-free, 92 | non-exclusive license: 93 | 94 | (a) under intellectual property rights (other than patent or trademark) 95 | Licensable by such Contributor to use, reproduce, make available, 96 | modify, display, perform, distribute, and otherwise exploit its 97 | Contributions, either on an unmodified basis, with Modifications, or 98 | as part of a Larger Work; and 99 | 100 | (b) under Patent Claims of such Contributor to make, use, sell, offer 101 | for sale, have made, import, and otherwise transfer either its 102 | Contributions or its Contributor Version. 103 | 104 | 2.2. Effective Date 105 | 106 | The licenses granted in Section 2.1 with respect to any Contribution 107 | become effective for each Contribution on the date the Contributor first 108 | distributes such Contribution. 109 | 110 | 2.3. Limitations on Grant Scope 111 | 112 | The licenses granted in this Section 2 are the only rights granted under 113 | this License. No additional rights or licenses will be implied from the 114 | distribution or licensing of Covered Software under this License. 115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 116 | Contributor: 117 | 118 | (a) for any code that a Contributor has removed from Covered Software; 119 | or 120 | 121 | (b) for infringements caused by: (i) Your and any other third party's 122 | modifications of Covered Software, or (ii) the combination of its 123 | Contributions with other software (except as part of its Contributor 124 | Version); or 125 | 126 | (c) under Patent Claims infringed by Covered Software in the absence of 127 | its Contributions. 128 | 129 | This License does not grant any rights in the trademarks, service marks, 130 | or logos of any Contributor (except as may be necessary to comply with 131 | the notice requirements in Section 3.4). 132 | 133 | 2.4. Subsequent Licenses 134 | 135 | No Contributor makes additional grants as a result of Your choice to 136 | distribute the Covered Software under a subsequent version of this 137 | License (see Section 10.2) or under the terms of a Secondary License (if 138 | permitted under the terms of Section 3.3). 139 | 140 | 2.5. Representation 141 | 142 | Each Contributor represents that the Contributor believes its 143 | Contributions are its original creation(s) or it has sufficient rights 144 | to grant the rights to its Contributions conveyed by this License. 145 | 146 | 2.6. Fair Use 147 | 148 | This License is not intended to limit any rights You have under 149 | applicable copyright doctrines of fair use, fair dealing, or other 150 | equivalents. 151 | 152 | 2.7. Conditions 153 | 154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 155 | in Section 2.1. 156 | 157 | 3. Responsibilities 158 | ------------------- 159 | 160 | 3.1. Distribution of Source Form 161 | 162 | All distribution of Covered Software in Source Code Form, including any 163 | Modifications that You create or to which You contribute, must be under 164 | the terms of this License. You must inform recipients that the Source 165 | Code Form of the Covered Software is governed by the terms of this 166 | License, and how they can obtain a copy of this License. You may not 167 | attempt to alter or restrict the recipients' rights in the Source Code 168 | Form. 169 | 170 | 3.2. Distribution of Executable Form 171 | 172 | If You distribute Covered Software in Executable Form then: 173 | 174 | (a) such Covered Software must also be made available in Source Code 175 | Form, as described in Section 3.1, and You must inform recipients of 176 | the Executable Form how they can obtain a copy of such Source Code 177 | Form by reasonable means in a timely manner, at a charge no more 178 | than the cost of distribution to the recipient; and 179 | 180 | (b) You may distribute such Executable Form under the terms of this 181 | License, or sublicense it under different terms, provided that the 182 | license for the Executable Form does not attempt to limit or alter 183 | the recipients' rights in the Source Code Form under this License. 184 | 185 | 3.3. Distribution of a Larger Work 186 | 187 | You may create and distribute a Larger Work under terms of Your choice, 188 | provided that You also comply with the requirements of this License for 189 | the Covered Software. If the Larger Work is a combination of Covered 190 | Software with a work governed by one or more Secondary Licenses, and the 191 | Covered Software is not Incompatible With Secondary Licenses, this 192 | License permits You to additionally distribute such Covered Software 193 | under the terms of such Secondary License(s), so that the recipient of 194 | the Larger Work may, at their option, further distribute the Covered 195 | Software under the terms of either this License or such Secondary 196 | License(s). 197 | 198 | 3.4. Notices 199 | 200 | You may not remove or alter the substance of any license notices 201 | (including copyright notices, patent notices, disclaimers of warranty, 202 | or limitations of liability) contained within the Source Code Form of 203 | the Covered Software, except that You may alter any license notices to 204 | the extent required to remedy known factual inaccuracies. 205 | 206 | 3.5. Application of Additional Terms 207 | 208 | You may choose to offer, and to charge a fee for, warranty, support, 209 | indemnity or liability obligations to one or more recipients of Covered 210 | Software. However, You may do so only on Your own behalf, and not on 211 | behalf of any Contributor. You must make it absolutely clear that any 212 | such warranty, support, indemnity, or liability obligation is offered by 213 | You alone, and You hereby agree to indemnify every Contributor for any 214 | liability incurred by such Contributor as a result of warranty, support, 215 | indemnity or liability terms You offer. You may include additional 216 | disclaimers of warranty and limitations of liability specific to any 217 | jurisdiction. 218 | 219 | 4. Inability to Comply Due to Statute or Regulation 220 | --------------------------------------------------- 221 | 222 | If it is impossible for You to comply with any of the terms of this 223 | License with respect to some or all of the Covered Software due to 224 | statute, judicial order, or regulation then You must: (a) comply with 225 | the terms of this License to the maximum extent possible; and (b) 226 | describe the limitations and the code they affect. Such description must 227 | be placed in a text file included with all distributions of the Covered 228 | Software under this License. Except to the extent prohibited by statute 229 | or regulation, such description must be sufficiently detailed for a 230 | recipient of ordinary skill to be able to understand it. 231 | 232 | 5. Termination 233 | -------------- 234 | 235 | 5.1. The rights granted under this License will terminate automatically 236 | if You fail to comply with any of its terms. However, if You become 237 | compliant, then the rights granted under this License from a particular 238 | Contributor are reinstated (a) provisionally, unless and until such 239 | Contributor explicitly and finally terminates Your grants, and (b) on an 240 | ongoing basis, if such Contributor fails to notify You of the 241 | non-compliance by some reasonable means prior to 60 days after You have 242 | come back into compliance. Moreover, Your grants from a particular 243 | Contributor are reinstated on an ongoing basis if such Contributor 244 | notifies You of the non-compliance by some reasonable means, this is the 245 | first time You have received notice of non-compliance with this License 246 | from such Contributor, and You become compliant prior to 30 days after 247 | Your receipt of the notice. 248 | 249 | 5.2. If You initiate litigation against any entity by asserting a patent 250 | infringement claim (excluding declaratory judgment actions, 251 | counter-claims, and cross-claims) alleging that a Contributor Version 252 | directly or indirectly infringes any patent, then the rights granted to 253 | You by any and all Contributors for the Covered Software under Section 254 | 2.1 of this License shall terminate. 255 | 256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 257 | end user license agreements (excluding distributors and resellers) which 258 | have been validly granted by You or Your distributors under this License 259 | prior to termination shall survive termination. 260 | 261 | ************************************************************************ 262 | * * 263 | * 6. Disclaimer of Warranty * 264 | * ------------------------- * 265 | * * 266 | * Covered Software is provided under this License on an "as is" * 267 | * basis, without warranty of any kind, either expressed, implied, or * 268 | * statutory, including, without limitation, warranties that the * 269 | * Covered Software is free of defects, merchantable, fit for a * 270 | * particular purpose or non-infringing. The entire risk as to the * 271 | * quality and performance of the Covered Software is with You. * 272 | * Should any Covered Software prove defective in any respect, You * 273 | * (not any Contributor) assume the cost of any necessary servicing, * 274 | * repair, or correction. This disclaimer of warranty constitutes an * 275 | * essential part of this License. No use of any Covered Software is * 276 | * authorized under this License except under this disclaimer. * 277 | * * 278 | ************************************************************************ 279 | 280 | ************************************************************************ 281 | * * 282 | * 7. Limitation of Liability * 283 | * -------------------------- * 284 | * * 285 | * Under no circumstances and under no legal theory, whether tort * 286 | * (including negligence), contract, or otherwise, shall any * 287 | * Contributor, or anyone who distributes Covered Software as * 288 | * permitted above, be liable to You for any direct, indirect, * 289 | * special, incidental, or consequential damages of any character * 290 | * including, without limitation, damages for lost profits, loss of * 291 | * goodwill, work stoppage, computer failure or malfunction, or any * 292 | * and all other commercial damages or losses, even if such party * 293 | * shall have been informed of the possibility of such damages. This * 294 | * limitation of liability shall not apply to liability for death or * 295 | * personal injury resulting from such party's negligence to the * 296 | * extent applicable law prohibits such limitation. Some * 297 | * jurisdictions do not allow the exclusion or limitation of * 298 | * incidental or consequential damages, so this exclusion and * 299 | * limitation may not apply to You. * 300 | * * 301 | ************************************************************************ 302 | 303 | 8. Litigation 304 | ------------- 305 | 306 | Any litigation relating to this License may be brought only in the 307 | courts of a jurisdiction where the defendant maintains its principal 308 | place of business and such litigation shall be governed by laws of that 309 | jurisdiction, without reference to its conflict-of-law provisions. 310 | Nothing in this Section shall prevent a party's ability to bring 311 | cross-claims or counter-claims. 312 | 313 | 9. Miscellaneous 314 | ---------------- 315 | 316 | This License represents the complete agreement concerning the subject 317 | matter hereof. If any provision of this License is held to be 318 | unenforceable, such provision shall be reformed only to the extent 319 | necessary to make it enforceable. Any law or regulation which provides 320 | that the language of a contract shall be construed against the drafter 321 | shall not be used to construe this License against a Contributor. 322 | 323 | 10. Versions of the License 324 | --------------------------- 325 | 326 | 10.1. New Versions 327 | 328 | Mozilla Foundation is the license steward. Except as provided in Section 329 | 10.3, no one other than the license steward has the right to modify or 330 | publish new versions of this License. Each version will be given a 331 | distinguishing version number. 332 | 333 | 10.2. Effect of New Versions 334 | 335 | You may distribute the Covered Software under the terms of the version 336 | of the License under which You originally received the Covered Software, 337 | or under the terms of any subsequent version published by the license 338 | steward. 339 | 340 | 10.3. Modified Versions 341 | 342 | If you create software not governed by this License, and you want to 343 | create a new license for such software, you may create and use a 344 | modified version of this License if you rename the license and remove 345 | any references to the name of the license steward (except to note that 346 | such modified license differs from this License). 347 | 348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 349 | Licenses 350 | 351 | If You choose to distribute Source Code Form that is Incompatible With 352 | Secondary Licenses under the terms of this version of the License, the 353 | notice described in Exhibit B of this License must be attached. 354 | 355 | Exhibit A - Source Code Form License Notice 356 | ------------------------------------------- 357 | 358 | This Source Code Form is subject to the terms of the Mozilla Public 359 | License, v. 2.0. If a copy of the MPL was not distributed with this 360 | file, You can obtain one at https://mozilla.org/MPL/2.0/. 361 | 362 | If it is not possible or desirable to put the notice in a particular 363 | file, then You may include the notice in a location (such as a LICENSE 364 | file in a relevant directory) where a recipient would be likely to look 365 | for such a notice. 366 | 367 | You may add additional accurate notices of copyright ownership. 368 | 369 | Exhibit B - "Incompatible With Secondary Licenses" Notice 370 | --------------------------------------------------------- 371 | 372 | This Source Code Form is "Incompatible With Secondary Licenses", as 373 | defined by the Mozilla Public License, v. 2.0. 374 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TypeDB Driver RPC (Remote Procedure Call) Protocol 2 | 3 | A protocol for implementing a TypeDB driver, in many popular programming languages, using [GRPC (Google's Remote Procedure Call)](https://grpc.io) framework. 4 | -------------------------------------------------------------------------------- /RELEASE_NOTES_LATEST.md: -------------------------------------------------------------------------------- 1 | Documentation: https://typedb.com/docs/drivers/ 2 | 3 | ### Distribution 4 | 5 | #### For Rust through crates.io 6 | 7 | Available from https://crates.io/crates/typedb-protocol 8 | 9 | ```sh 10 | cargo add typedb-protocol@3.2.0 11 | ``` 12 | 13 | #### For Node.js through npm 14 | 15 | Available from https://www.npmjs.com/package/typedb-protocol 16 | 17 | ```sh 18 | npm install typedb-protocol@3.2.0 19 | ``` 20 | or 21 | ```sh 22 | yarn add typedb-protocol@3.2.0 23 | ``` 24 | 25 | 26 | ## New Features 27 | - **Rework transaction options** 28 | Reintroduce transaction options available in TypeDB 3.x. Introduce query options for query-specific configuration. 29 | 30 | Remove unused Logic-related messages. 31 | 32 | 33 | - **Add sign-in request for authentication token retrieval** 34 | A new mechanism of authentication tokens has been introduced to replace the old way of sending usernames and passwords through the network with every request. 35 | 36 | Instead, all user credentials (currently, it's usernames and passwords) are sent only: 37 | * as a part of `connection_open` request for authentication and authorization, with a temporary token returned; 38 | * as a part of `sign_in` request for sign ins within an established connection (to change the user or to get a new authentication token). 39 | Then, all further requests are expected to be authenticated only by temporary, less sensitive tokens. 40 | 41 | The approach is extensible to other credential types that can be introduced in the future. 42 | 43 | 44 | 45 | ## Bugs Fixed 46 | 47 | 48 | ## Code Refactors 49 | 50 | 51 | ## Other Improvements 52 | 53 | -------------------------------------------------------------------------------- /RELEASE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Documentation: https://typedb.com/docs/drivers/ 2 | 3 | ### Distribution 4 | 5 | #### For Rust through crates.io 6 | 7 | Available from https://crates.io/crates/typedb-protocol 8 | 9 | ```sh 10 | cargo add typedb-protocol@{version} 11 | ``` 12 | 13 | #### For Node.js through npm 14 | 15 | Available from https://www.npmjs.com/package/typedb-protocol 16 | 17 | ```sh 18 | npm install typedb-protocol@{version} 19 | ``` 20 | or 21 | ```sh 22 | yarn add typedb-protocol@{version} 23 | ``` 24 | 25 | { release notes } 26 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 3.2.0 2 | -------------------------------------------------------------------------------- /WORKSPACE: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | workspace(name = "typedb_protocol") 6 | 7 | ################################ 8 | # Load @typedb_dependencies # 9 | ################################ 10 | 11 | load("//dependencies/typedb:repositories.bzl", "typedb_dependencies") 12 | typedb_dependencies() 13 | 14 | # Load //builder/bazel for RBE 15 | load("@typedb_dependencies//builder/bazel:deps.bzl", "bazel_toolchain") 16 | bazel_toolchain() 17 | 18 | # Load //builder/java 19 | load("@typedb_dependencies//builder/java:deps.bzl", "rules_jvm_external") 20 | rules_jvm_external() 21 | 22 | load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps") 23 | rules_jvm_external_deps() 24 | 25 | load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup") 26 | rules_jvm_external_setup() 27 | 28 | # Load //builder/kotlin 29 | load("@typedb_dependencies//builder/kotlin:deps.bzl", "io_bazel_rules_kotlin") 30 | io_bazel_rules_kotlin() 31 | load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories") 32 | kotlin_repositories() 33 | load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains") 34 | kt_register_toolchains() 35 | 36 | # Load //builder/python 37 | load("@typedb_dependencies//builder/python:deps.bzl", "rules_python") 38 | rules_python() 39 | 40 | # Load //builder/rust 41 | load("@typedb_dependencies//builder/rust:deps.bzl", rust_deps = "deps") 42 | rust_deps() 43 | 44 | load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains") 45 | rules_rust_dependencies() 46 | rust_register_toolchains(edition = "2021") 47 | 48 | load("@typedb_dependencies//library/crates:crates.bzl", "fetch_crates") 49 | fetch_crates() 50 | load("@crates//:defs.bzl", "crate_repositories") 51 | crate_repositories() 52 | 53 | # Load //tool/common 54 | load("@typedb_dependencies//tool/common:deps.bzl", "typedb_dependencies_ci_pip", typedb_dependencies_tool_maven_artifacts = "maven_artifacts") 55 | typedb_dependencies_ci_pip() 56 | load("@typedb_dependencies_ci_pip//:requirements.bzl", "install_deps") 57 | install_deps() 58 | 59 | # Load //builder/proto_grpc 60 | load("@typedb_dependencies//builder/proto_grpc:deps.bzl", typedb_grpc_deps = "deps") 61 | typedb_grpc_deps() 62 | 63 | load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_repos", "rules_proto_grpc_toolchains") 64 | rules_proto_grpc_toolchains() 65 | rules_proto_grpc_repos() 66 | 67 | load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") 68 | rules_proto_dependencies() 69 | rules_proto_toolchains() 70 | 71 | load("@rules_proto_grpc//java:repositories.bzl", rules_proto_grpc_java_repos = "java_repos") 72 | rules_proto_grpc_java_repos() 73 | 74 | load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS", "grpc_java_repositories") 75 | load("@typedb_dependencies//library/maven:rules.bzl", "parse_unversioned") 76 | io_grpc_artifacts = [parse_unversioned(c) for c in IO_GRPC_GRPC_JAVA_ARTIFACTS] 77 | 78 | load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") 79 | grpc_deps() 80 | 81 | load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps") 82 | grpc_extra_deps() 83 | 84 | load("@rules_python//python:pip.bzl", "pip_parse") 85 | pip_parse( 86 | name = "rules_proto_grpc_py3_deps", 87 | python_interpreter = "python3", 88 | requirements_lock = "@rules_proto_grpc//python:requirements.txt", 89 | ) 90 | 91 | load("@rules_proto_grpc_py3_deps//:requirements.bzl", "install_deps") 92 | install_deps() 93 | 94 | # Load //tool/checkstyle 95 | load("@typedb_dependencies//tool/checkstyle:deps.bzl", checkstyle_deps = "deps") 96 | checkstyle_deps() 97 | 98 | # Load //tool/unuseddeps 99 | load("@typedb_dependencies//tool/unuseddeps:deps.bzl", unuseddeps_deps = "deps") 100 | unuseddeps_deps() 101 | 102 | ###################################### 103 | # Load @typedb_bazel_distribution # 104 | ###################################### 105 | 106 | load("@typedb_dependencies//distribution:deps.bzl", "typedb_bazel_distribution") 107 | typedb_bazel_distribution() 108 | 109 | # Load //common 110 | load("@typedb_bazel_distribution//common:deps.bzl", "rules_pkg") 111 | rules_pkg() 112 | load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies") 113 | rules_pkg_dependencies() 114 | 115 | # Load //github 116 | load("@typedb_bazel_distribution//github:deps.bzl", "ghr_osx_zip", "ghr_linux_tar") 117 | ghr_osx_zip() 118 | ghr_linux_tar() 119 | 120 | # Load //maven 121 | load("@typedb_bazel_distribution//maven:deps.bzl", typedb_bazel_distribution_maven_artifacts = "maven_artifacts") 122 | 123 | ############################ 124 | # Load @maven dependencies # 125 | ############################ 126 | 127 | load("@typedb_dependencies//library/maven:rules.bzl", "maven") 128 | load("//dependencies/maven:artifacts.bzl", "artifacts") 129 | maven(artifacts + typedb_dependencies_tool_maven_artifacts + typedb_bazel_distribution_maven_artifacts + io_grpc_artifacts, 130 | override_targets = IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS, 131 | generate_compat_repositories = True, 132 | ) 133 | 134 | load("@maven//:compat.bzl", "compat_repositories") 135 | compat_repositories() 136 | grpc_java_repositories() 137 | 138 | ######################### 139 | # Load NPM dependencies # 140 | ######################### 141 | 142 | # Load //builder/nodejs 143 | load("@typedb_dependencies//builder/nodejs:deps.bzl", nodejs_deps = "deps") 144 | nodejs_deps() 145 | 146 | load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") 147 | rules_js_dependencies() 148 | 149 | load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") 150 | nodejs_register_toolchains( 151 | name = "nodejs", 152 | node_version = "17.9.1", 153 | ) 154 | 155 | load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") 156 | npm_translate_lock( 157 | name = "typedb_protocol_npm", 158 | bins = { 159 | "protoc-gen-ts": { 160 | "protoc-gen-ts-js": "./bin/protoc-gen-ts.js", 161 | }, 162 | }, 163 | pnpm_lock = "//grpc/nodejs:pnpm-lock.yaml", 164 | ) 165 | 166 | load("@typedb_protocol_npm//:repositories.bzl", "npm_repositories") 167 | npm_repositories() 168 | 169 | # Setup rules_ts 170 | load("@aspect_rules_ts//ts:repositories.bzl", "rules_ts_dependencies") 171 | 172 | rules_ts_dependencies( 173 | ts_version_from = "//grpc/nodejs:package.json", 174 | ) 175 | 176 | ################################################## 177 | # Create @typedb_typedb_protocol_workspace_refs # 178 | ################################################## 179 | 180 | load("@typedb_bazel_distribution//common:rules.bzl", "workspace_refs") 181 | workspace_refs( 182 | name = "typedb_typedb_protocol_workspace_refs" 183 | ) 184 | -------------------------------------------------------------------------------- /dependencies/maven/BUILD: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | load("@typedb_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") 6 | 7 | checkstyle_test( 8 | name = "checkstyle", 9 | include = glob(["*"]), 10 | exclude = ["artifacts.snapshot"], 11 | license_type = "mpl-header", 12 | size = "small", 13 | ) 14 | -------------------------------------------------------------------------------- /dependencies/maven/artifacts.bzl: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | artifacts = [ 6 | "com.google.guava:guava", 7 | "com.google.protobuf:protobuf-java", 8 | "io.grpc:grpc-api", 9 | "io.grpc:grpc-core", 10 | "io.grpc:grpc-protobuf", 11 | "io.grpc:grpc-stub", 12 | "javax.annotation:javax.annotation-api", 13 | ] 14 | -------------------------------------------------------------------------------- /dependencies/maven/artifacts.snapshot: -------------------------------------------------------------------------------- 1 | @maven//:com_eclipsesource_minimal_json_minimal_json_0_9_5 2 | @maven//:com_electronwill_night_config_core_3_6_5 3 | @maven//:com_electronwill_night_config_toml_3_6_5 4 | @maven//:com_fasterxml_jackson_core_jackson_annotations_2_16_0 5 | @maven//:com_fasterxml_jackson_core_jackson_core_2_16_0 6 | @maven//:com_fasterxml_jackson_core_jackson_databind_2_16_0 7 | @maven//:com_google_android_annotations_4_1_1_4 8 | @maven//:com_google_api_grpc_proto_google_common_protos_2_9_0 9 | @maven//:com_google_auth_google_auth_library_credentials_1_6_0 10 | @maven//:com_google_auth_google_auth_library_oauth2_http_1_6_0 11 | @maven//:com_google_auto_value_auto_value_1_9 12 | @maven//:com_google_auto_value_auto_value_annotations_1_9 13 | @maven//:com_google_code_findbugs_jsr305_3_0_2 14 | @maven//:com_google_code_gson_gson_2_9_0 15 | @maven//:com_google_errorprone_error_prone_annotations_2_9_0 16 | @maven//:com_google_guava_failureaccess_1_0_1 17 | @maven//:com_google_guava_guava_30_1_jre 18 | @maven//:com_google_guava_listenablefuture_9999_0_empty_to_avoid_conflict_with_guava 19 | @maven//:com_google_http_client_google_http_client_1_41_4 20 | @maven//:com_google_http_client_google_http_client_gson_1_41_4 21 | @maven//:com_google_j2objc_j2objc_annotations_1_3 22 | @maven//:com_google_protobuf_protobuf_java 23 | @maven//:com_google_re2j_re2j_1_6 24 | @maven//:com_google_truth_truth_1_0_1 25 | @maven//:com_googlecode_java_diff_utils_diffutils_1_3_0 26 | @maven//:com_squareup_okhttp_okhttp_2_7_5 27 | @maven//:com_squareup_okio_okio_1_17_5 28 | @maven//:com_vdurmont_semver4j_3_1_0 29 | @maven//:commons_codec_commons_codec_1_13 30 | @maven//:commons_io_commons_io_2_3 31 | @maven//:commons_logging_commons_logging_1_2 32 | @maven//:info_picocli_picocli_4_6_1 33 | @maven//:io_grpc_grpc_api 34 | @maven//:io_grpc_grpc_context 35 | @maven//:io_grpc_grpc_core 36 | @maven//:io_grpc_grpc_protobuf 37 | @maven//:io_grpc_grpc_protobuf_lite 38 | @maven//:io_grpc_grpc_stub 39 | @maven//:io_netty_netty_buffer_4_1_87_Final 40 | @maven//:io_netty_netty_codec_4_1_87_Final 41 | @maven//:io_netty_netty_codec_http2_4_1_87_Final 42 | @maven//:io_netty_netty_codec_http_4_1_87_Final 43 | @maven//:io_netty_netty_codec_socks_4_1_87_Final 44 | @maven//:io_netty_netty_common_4_1_87_Final 45 | @maven//:io_netty_netty_handler_4_1_87_Final 46 | @maven//:io_netty_netty_handler_proxy_4_1_87_Final 47 | @maven//:io_netty_netty_resolver_4_1_87_Final 48 | @maven//:io_netty_netty_tcnative_boringssl_static_2_0_61_Final 49 | @maven//:io_netty_netty_tcnative_boringssl_static_linux_aarch_64_2_0_61_Final 50 | @maven//:io_netty_netty_tcnative_boringssl_static_linux_x86_64_2_0_61_Final 51 | @maven//:io_netty_netty_tcnative_boringssl_static_osx_aarch_64_2_0_61_Final 52 | @maven//:io_netty_netty_tcnative_boringssl_static_osx_x86_64_2_0_61_Final 53 | @maven//:io_netty_netty_tcnative_boringssl_static_windows_x86_64_2_0_61_Final 54 | @maven//:io_netty_netty_tcnative_classes_2_0_61_Final 55 | @maven//:io_netty_netty_transport_4_1_87_Final 56 | @maven//:io_netty_netty_transport_classes_epoll_4_1_87_Final 57 | @maven//:io_netty_netty_transport_native_epoll_linux_x86_64_4_1_87_Final 58 | @maven//:io_netty_netty_transport_native_unix_common_4_1_87_Final 59 | @maven//:io_opencensus_opencensus_api_0_24_0 60 | @maven//:io_opencensus_opencensus_contrib_grpc_metrics_0_24_0 61 | @maven//:io_opencensus_opencensus_contrib_http_util_0_31_0 62 | @maven//:io_perfmark_perfmark_api_0_25_0 63 | @maven//:javax_annotation_javax_annotation_api_1_3_2 64 | @maven//:junit_junit_4_12 65 | @maven//:org_apache_commons_commons_compress_1_21 66 | @maven//:org_apache_commons_commons_lang3_3_9 67 | @maven//:org_apache_httpcomponents_httpclient_4_5_13 68 | @maven//:org_apache_httpcomponents_httpcore_4_4_15 69 | @maven//:org_apache_tomcat_annotations_api_6_0_53 70 | @maven//:org_checkerframework_checker_compat_qual_2_5_5 71 | @maven//:org_checkerframework_checker_qual_3_5_0 72 | @maven//:org_codehaus_mojo_animal_sniffer_annotations_1_21 73 | @maven//:org_hamcrest_hamcrest_core_1_3 74 | @maven//:org_jetbrains_compose_compiler_compiler_1_5_7 75 | @maven//:org_jsoup_jsoup_1_16_1 76 | @maven//:org_kohsuke_github_api_1_101 77 | @maven//:org_slf4j_slf4j_api_1_7_2 78 | @maven//:org_zeroturnaround_zt_exec_1_10 79 | -------------------------------------------------------------------------------- /dependencies/maven/update.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # This Source Code Form is subject to the terms of the Mozilla Public 3 | # License, v. 2.0. If a copy of the MPL was not distributed with this 4 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 5 | 6 | bazel run @typedb_dependencies//library/maven:update 7 | -------------------------------------------------------------------------------- /dependencies/typedb/BUILD: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | load("@typedb_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") 6 | 7 | checkstyle_test( 8 | name = "checkstyle", 9 | include = glob(["*"]), 10 | license_type = "mpl-header", 11 | size = "small", 12 | ) 13 | -------------------------------------------------------------------------------- /dependencies/typedb/repositories.bzl: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") 6 | 7 | def typedb_dependencies(): 8 | git_repository( 9 | name = "typedb_dependencies", 10 | remote = "https://github.com/typedb/typedb-dependencies", 11 | commit = "ab777bf067b1930e35146fd8e25a76a4a360aa74", # sync-marker: do not remove this comment, this is used for sync-dependencies by @typedb_dependencies 12 | ) 13 | -------------------------------------------------------------------------------- /deployment.bzl: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | deployment = { 6 | "github.organisation": "typedb", 7 | "github.repository": "typedb-protocol" 8 | } 9 | -------------------------------------------------------------------------------- /grpc/java/BUILD: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | package(default_visibility = ["//visibility:public"]) 6 | load("@typedb_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") 7 | load("@rules_proto_grpc//java:defs.bzl", "java_grpc_library") 8 | 9 | java_grpc_library( 10 | name = "typedb-protocol", 11 | protos = [ 12 | "//proto:typedb-service", 13 | "//proto:server-proto", 14 | "//proto:user-proto", 15 | "//proto:database-proto", 16 | "//proto:answer-proto", 17 | "//proto:concept-proto", 18 | "//proto:connection-proto", 19 | "//proto:authentication-proto", 20 | "//proto:options-proto", 21 | "//proto:query-proto", 22 | "//proto:transaction-proto", 23 | "//proto:version-proto", 24 | ], 25 | # TypeDB Core bundles JARs by maven coordinate, we can remove this when Core is rewritten in Rust 26 | tags = ["maven_coordinates=com.typedb:typedb-protocol:{pom_version}"], 27 | ) 28 | 29 | checkstyle_test( 30 | name = "checkstyle", 31 | include = glob(["*"]), 32 | license_type = "mpl-header", 33 | size = "small", 34 | ) 35 | -------------------------------------------------------------------------------- /grpc/nodejs/BUILD: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | package(default_visibility = ["//visibility:public"]) 6 | load("@typedb_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") 7 | load("@typedb_bazel_distribution//npm:rules.bzl", "assemble_npm", "deploy_npm") 8 | load("@typedb_dependencies//distribution:deployment.bzl", "deployment") 9 | load("@aspect_rules_js//npm:defs.bzl", "npm_package") 10 | load("@aspect_rules_ts//ts:defs.bzl", "ts_project") 11 | load("@typedb_protocol_npm//:defs.bzl", "npm_link_all_packages") 12 | load("//:deployment.bzl", github_deployment = "deployment") 13 | load("//grpc/nodejs:rules.bzl", "ts_grpc_compile") 14 | 15 | npm_link_all_packages(name = "node_modules") 16 | 17 | exports_files(["package.json", "pnpm-lock.yaml"]) 18 | 19 | load("@typedb_protocol_npm//grpc/nodejs:protoc-gen-ts/package_json.bzl", protoc_gen_ts_bin = "bin") 20 | 21 | protoc_gen_ts_bin.protoc_gen_ts_binary( 22 | name = "protoc-gen-ts", 23 | ) 24 | 25 | ts_grpc_compile( 26 | name = "typedb-protocol-src", 27 | deps = [ 28 | "//proto:typedb-service", 29 | "//proto:server-proto", 30 | "//proto:user-proto", 31 | "//proto:database-proto", 32 | "//proto:answer-proto", 33 | "//proto:concept-proto", 34 | "//proto:connection-proto", 35 | "//proto:authentication-proto", 36 | "//proto:options-proto", 37 | "//proto:query-proto", 38 | "//proto:transaction-proto", 39 | "//proto:version-proto", 40 | ] 41 | ) 42 | 43 | ts_project( 44 | name = "typedb-protocol", 45 | srcs = [":typedb-protocol-src"], 46 | tsconfig = { 47 | "compilerOptions": { 48 | "target": "es2019", 49 | "module": "commonjs", 50 | "moduleResolution": "node", 51 | "esModuleInterop": True, 52 | }, 53 | "include": [ 54 | "proto", 55 | ] 56 | }, 57 | declaration = True, 58 | deps = [ 59 | ":node_modules/@grpc/grpc-js", 60 | ":node_modules/google-protobuf", 61 | ":node_modules/@types/google-protobuf", 62 | ":node_modules/@types/node", 63 | ":node_modules/typescript", 64 | ], 65 | transpiler = "tsc", 66 | visibility = ["//visibility:public"], 67 | ) 68 | 69 | npm_package( 70 | name = "typedb-protocol-package", 71 | srcs = [":typedb-protocol", "package.json"], 72 | include_runfiles = False, 73 | package = "typedb-protocol", 74 | include_external_repositories = ["typedb_protocol"], 75 | visibility = ["//visibility:public"], 76 | ) 77 | 78 | assemble_npm( 79 | name = "assemble-npm", 80 | target = ":typedb-protocol-package", 81 | ) 82 | 83 | deploy_npm( 84 | name = "deploy-npm", 85 | target = ":assemble-npm", 86 | snapshot = deployment["npm"]["snapshot"], 87 | release = deployment["npm"]["release"], 88 | ) 89 | 90 | checkstyle_test( 91 | name = "checkstyle", 92 | include = glob(["*"]), 93 | exclude = [ 94 | "package.json", 95 | "pnpm-lock.yaml", 96 | ], 97 | license_type = "mpl-header", 98 | size = "small", 99 | ) 100 | -------------------------------------------------------------------------------- /grpc/nodejs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "typedb-protocol", 3 | "version": "2.20.0", 4 | "description": "TypeDB Protocol", 5 | "author": "TypeDB", 6 | "license": "MPL-2.0", 7 | "homepage": "https://typedb.com", 8 | "repository": { 9 | "type": "git", 10 | "url": "https://github.com/typedb/typedb-protocol" 11 | }, 12 | "dependencies": { 13 | "@grpc/grpc-js": "1.9.0", 14 | "google-protobuf": "3.19.3" 15 | }, 16 | "devDependencies": { 17 | "@types/google-protobuf": "3.15.5", 18 | "@types/node": "20.0.0", 19 | "protoc-gen-ts": "0.8.6", 20 | "typescript": "4.9.5" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /grpc/nodejs/pnpm-lock.yaml: -------------------------------------------------------------------------------- 1 | lockfileVersion: '6.0' 2 | 3 | settings: 4 | autoInstallPeers: true 5 | excludeLinksFromLockfile: false 6 | 7 | dependencies: 8 | '@grpc/grpc-js': 9 | specifier: 1.9.0 10 | version: 1.9.0 11 | google-protobuf: 12 | specifier: 3.19.3 13 | version: 3.19.3 14 | 15 | devDependencies: 16 | '@types/google-protobuf': 17 | specifier: 3.15.5 18 | version: 3.15.5 19 | '@types/node': 20 | specifier: 20.0.0 21 | version: 20.0.0 22 | protoc-gen-ts: 23 | specifier: 0.8.6 24 | version: 0.8.6(google-protobuf@3.19.3)(typescript@4.9.5) 25 | typescript: 26 | specifier: 4.9.5 27 | version: 4.9.5 28 | 29 | packages: 30 | 31 | /@grpc/grpc-js@1.9.0: 32 | resolution: {integrity: sha512-H8+iZh+kCE6VR/Krj6W28Y/ZlxoZ1fOzsNt77nrdE3knkbSelW1Uus192xOFCxHyeszLj8i4APQkSIXjAoOxXg==} 33 | engines: {node: ^8.13.0 || >=10.10.0} 34 | dependencies: 35 | '@grpc/proto-loader': 0.7.8 36 | '@types/node': 20.0.0 37 | dev: false 38 | 39 | /@grpc/proto-loader@0.7.8: 40 | resolution: {integrity: sha512-GU12e2c8dmdXb7XUlOgYWZ2o2i+z9/VeACkxTA/zzAe2IjclC5PnVL0lpgjhrqfpDYHzM8B1TF6pqWegMYAzlA==} 41 | engines: {node: '>=6'} 42 | hasBin: true 43 | dependencies: 44 | '@types/long': 4.0.2 45 | lodash.camelcase: 4.3.0 46 | long: 4.0.0 47 | protobufjs: 7.2.4 48 | yargs: 17.7.2 49 | dev: false 50 | 51 | /@protobufjs/aspromise@1.1.2: 52 | resolution: {integrity: sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==} 53 | dev: false 54 | 55 | /@protobufjs/base64@1.1.2: 56 | resolution: {integrity: sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==} 57 | dev: false 58 | 59 | /@protobufjs/codegen@2.0.4: 60 | resolution: {integrity: sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==} 61 | dev: false 62 | 63 | /@protobufjs/eventemitter@1.1.0: 64 | resolution: {integrity: sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==} 65 | dev: false 66 | 67 | /@protobufjs/fetch@1.1.0: 68 | resolution: {integrity: sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==} 69 | dependencies: 70 | '@protobufjs/aspromise': 1.1.2 71 | '@protobufjs/inquire': 1.1.0 72 | dev: false 73 | 74 | /@protobufjs/float@1.0.2: 75 | resolution: {integrity: sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==} 76 | dev: false 77 | 78 | /@protobufjs/inquire@1.1.0: 79 | resolution: {integrity: sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==} 80 | dev: false 81 | 82 | /@protobufjs/path@1.1.2: 83 | resolution: {integrity: sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==} 84 | dev: false 85 | 86 | /@protobufjs/pool@1.1.0: 87 | resolution: {integrity: sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==} 88 | dev: false 89 | 90 | /@protobufjs/utf8@1.1.0: 91 | resolution: {integrity: sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==} 92 | dev: false 93 | 94 | /@types/google-protobuf@3.15.5: 95 | resolution: {integrity: sha512-6bgv24B+A2bo9AfzReeg5StdiijKzwwnRflA8RLd1V4Yv995LeTmo0z69/MPbBDFSiZWdZHQygLo/ccXhMEDgw==} 96 | dev: true 97 | 98 | /@types/long@4.0.2: 99 | resolution: {integrity: sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==} 100 | dev: false 101 | 102 | /@types/node@20.0.0: 103 | resolution: {integrity: sha512-cD2uPTDnQQCVpmRefonO98/PPijuOnnEy5oytWJFPY1N9aJCz2wJ5kSGWO+zJoed2cY2JxQh6yBuUq4vIn61hw==} 104 | 105 | /ansi-regex@5.0.1: 106 | resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} 107 | engines: {node: '>=8'} 108 | dev: false 109 | 110 | /ansi-styles@4.3.0: 111 | resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} 112 | engines: {node: '>=8'} 113 | dependencies: 114 | color-convert: 2.0.1 115 | dev: false 116 | 117 | /cliui@8.0.1: 118 | resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} 119 | engines: {node: '>=12'} 120 | dependencies: 121 | string-width: 4.2.3 122 | strip-ansi: 6.0.1 123 | wrap-ansi: 7.0.0 124 | dev: false 125 | 126 | /color-convert@2.0.1: 127 | resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} 128 | engines: {node: '>=7.0.0'} 129 | dependencies: 130 | color-name: 1.1.4 131 | dev: false 132 | 133 | /color-name@1.1.4: 134 | resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} 135 | dev: false 136 | 137 | /emoji-regex@8.0.0: 138 | resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} 139 | dev: false 140 | 141 | /escalade@3.1.1: 142 | resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} 143 | engines: {node: '>=6'} 144 | dev: false 145 | 146 | /get-caller-file@2.0.5: 147 | resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} 148 | engines: {node: 6.* || 8.* || >= 10.*} 149 | dev: false 150 | 151 | /google-protobuf@3.19.3: 152 | resolution: {integrity: sha512-3GRDj8o9XjcALYjgxNKeD7Wm6w/V8r1Jo4sLYMic9+VaIMLBx8TQeHP9yaoRoDymNONhnkmmveDPyjw/Fpw8+A==} 153 | 154 | /is-fullwidth-code-point@3.0.0: 155 | resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} 156 | engines: {node: '>=8'} 157 | dev: false 158 | 159 | /lodash.camelcase@4.3.0: 160 | resolution: {integrity: sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==} 161 | dev: false 162 | 163 | /long@4.0.0: 164 | resolution: {integrity: sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==} 165 | dev: false 166 | 167 | /long@5.2.3: 168 | resolution: {integrity: sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==} 169 | dev: false 170 | 171 | /protobufjs@7.2.4: 172 | resolution: {integrity: sha512-AT+RJgD2sH8phPmCf7OUZR8xGdcJRga4+1cOaXJ64hvcSkVhNcRHOwIxUatPH15+nj59WAGTDv3LSGZPEQbJaQ==} 173 | engines: {node: '>=12.0.0'} 174 | requiresBuild: true 175 | dependencies: 176 | '@protobufjs/aspromise': 1.1.2 177 | '@protobufjs/base64': 1.1.2 178 | '@protobufjs/codegen': 2.0.4 179 | '@protobufjs/eventemitter': 1.1.0 180 | '@protobufjs/fetch': 1.1.0 181 | '@protobufjs/float': 1.0.2 182 | '@protobufjs/inquire': 1.1.0 183 | '@protobufjs/path': 1.1.2 184 | '@protobufjs/pool': 1.1.0 185 | '@protobufjs/utf8': 1.1.0 186 | '@types/node': 20.0.0 187 | long: 5.2.3 188 | dev: false 189 | 190 | /protoc-gen-ts@0.8.6(google-protobuf@3.19.3)(typescript@4.9.5): 191 | resolution: {integrity: sha512-66oeorGy4QBvYjQGd/gaeOYyFqKyRmRgTpofmnw8buMG0P7A0jQjoKSvKJz5h5tNUaVkIzvGBUTRVGakrhhwpA==} 192 | hasBin: true 193 | peerDependencies: 194 | google-protobuf: ^3.13.0 195 | typescript: 4.x.x 196 | dependencies: 197 | google-protobuf: 3.19.3 198 | typescript: 4.9.5 199 | dev: true 200 | 201 | /require-directory@2.1.1: 202 | resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} 203 | engines: {node: '>=0.10.0'} 204 | dev: false 205 | 206 | /string-width@4.2.3: 207 | resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} 208 | engines: {node: '>=8'} 209 | dependencies: 210 | emoji-regex: 8.0.0 211 | is-fullwidth-code-point: 3.0.0 212 | strip-ansi: 6.0.1 213 | dev: false 214 | 215 | /strip-ansi@6.0.1: 216 | resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} 217 | engines: {node: '>=8'} 218 | dependencies: 219 | ansi-regex: 5.0.1 220 | dev: false 221 | 222 | /typescript@4.9.5: 223 | resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} 224 | engines: {node: '>=4.2.0'} 225 | hasBin: true 226 | dev: true 227 | 228 | /wrap-ansi@7.0.0: 229 | resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} 230 | engines: {node: '>=10'} 231 | dependencies: 232 | ansi-styles: 4.3.0 233 | string-width: 4.2.3 234 | strip-ansi: 6.0.1 235 | dev: false 236 | 237 | /y18n@5.0.8: 238 | resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} 239 | engines: {node: '>=10'} 240 | dev: false 241 | 242 | /yargs-parser@21.1.1: 243 | resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} 244 | engines: {node: '>=12'} 245 | dev: false 246 | 247 | /yargs@17.7.2: 248 | resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==} 249 | engines: {node: '>=12'} 250 | dependencies: 251 | cliui: 8.0.1 252 | escalade: 3.1.1 253 | get-caller-file: 2.0.5 254 | require-directory: 2.1.1 255 | string-width: 4.2.3 256 | y18n: 5.0.8 257 | yargs-parser: 21.1.1 258 | dev: false 259 | -------------------------------------------------------------------------------- /grpc/nodejs/rules.bzl: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | load("@bazel_skylib//lib:paths.bzl", "paths") 6 | load("@rules_proto//proto:defs.bzl", "ProtoInfo") 7 | 8 | def _as_path(path, is_windows_host): 9 | if is_windows_host: 10 | return path.replace("/", "\\") 11 | else: 12 | return path 13 | 14 | def _get_outputs(target, ctx): 15 | outputs = [] 16 | root = target[ProtoInfo].proto_source_root 17 | for source in target[ProtoInfo].direct_sources: 18 | name = source.path 19 | # test.proto -> {designated output dir}/test.ts 20 | if name.endswith("." + source.extension): 21 | name = name.rsplit(".", 1)[0] 22 | name += ".ts" 23 | 24 | dest = root 25 | # if the dest is pwd then make sure that we do not strip subdirectories. 26 | if dest == ".": 27 | dest = source.dirname[len(ctx.label.package) + 1:] 28 | if not dest: 29 | dest = "." 30 | 31 | if dest != ".": 32 | if name.startswith(dest): 33 | name = name[len(dest)+1:] 34 | 35 | output = ctx.actions.declare_file(name) # preserve dir structure for now 36 | outputs.append(output) 37 | return outputs 38 | 39 | def _imported_protos(target, provided_sources = []): 40 | proto_info = target[ProtoInfo] 41 | source_root = proto_info.proto_source_root 42 | if source_root == ".": 43 | return [src.path for src in proto_info.direct_sources] 44 | offset = len(source_root) + 1 # + '/'. 45 | return [src.path[offset:] for src in proto_info.direct_sources] 46 | 47 | def _node_protoc(ctx): 48 | all_outputs = [] 49 | is_windows_host = ctx.configuration.host_path_separator == ";" 50 | for target in ctx.attr.deps: 51 | args = ctx.actions.args() 52 | # Output and Plugin path 53 | args.add(_as_path(ctx.executable._protoc_gen_ts.path, is_windows_host), format = "--plugin=protoc-gen-ts=%s") 54 | args.add(paths.join(ctx.bin_dir.path, paths.dirname(ctx.file._file_in_project.path)), format = "--ts_out=%s") 55 | args.add("--ts_opt=no_namespace") 56 | 57 | # Set in descriptors 58 | descriptor_sets_paths = [desc.path for desc in target[ProtoInfo].transitive_descriptor_sets.to_list()] 59 | args.add_joined("--descriptor_set_in", descriptor_sets_paths, join_with = ctx.configuration.host_path_separator) 60 | 61 | # Direct sources 62 | args.add_all(_imported_protos(target)) 63 | 64 | if not len(ctx.outputs.outs): 65 | outputs = _get_outputs(target, ctx) 66 | all_outputs.extend(outputs) 67 | else: 68 | outputs = ctx.outputs.outs 69 | all_outputs = ctx.outputs.outs 70 | 71 | ctx.actions.run( 72 | inputs = depset(target[ProtoInfo].direct_sources, transitive = [target[ProtoInfo].transitive_descriptor_sets]), 73 | tools = [ctx.executable._protoc_gen_ts], 74 | executable = ctx.executable._protoc, 75 | outputs = outputs, 76 | arguments = [args], 77 | progress_message = "Generating Protocol Buffers for Typescript %s" % ctx.label, 78 | env = {"BAZEL_BINDIR": ctx.bin_dir.path}, 79 | ) 80 | 81 | return [ 82 | DefaultInfo(files = depset(all_outputs)) 83 | ] 84 | 85 | 86 | ts_grpc_compile = rule( 87 | implementation = _node_protoc, 88 | attrs = { 89 | "deps": attr.label_list( 90 | doc = "List of proto_library targets.", 91 | providers = [ProtoInfo], 92 | mandatory = True 93 | ), 94 | "outs": attr.output_list(), 95 | "_protoc": attr.label( 96 | cfg = "exec", 97 | executable = True, 98 | default = "@com_google_protobuf//:protoc" 99 | ), 100 | "_protoc_gen_ts": attr.label( 101 | cfg = "exec", 102 | executable = True, 103 | default = "@typedb_protocol//grpc/nodejs:protoc-gen-ts", 104 | ), 105 | "_file_in_project": attr.label( 106 | default = "@typedb_protocol//grpc/nodejs:BUILD", 107 | allow_single_file = True, 108 | ), 109 | } 110 | ) 111 | -------------------------------------------------------------------------------- /grpc/rust/BUILD: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | load("@rules_rust//rust:defs.bzl", "rust_library") 6 | load("@typedb_bazel_distribution//crates:rules.bzl", "assemble_crate", "deploy_crate") 7 | load("@typedb_dependencies//distribution:deployment.bzl", "deployment") 8 | load("@typedb_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") 9 | load("@typedb_dependencies//builder/proto_grpc/rust:compile.bzl", "rust_tonic_compile") 10 | 11 | rust_tonic_compile( 12 | name = "typedb_protocol_src", 13 | packages = ["typedb.protocol"], 14 | srcs = [ 15 | "//proto:typedb-service", 16 | "//proto:server-proto", 17 | "//proto:user-proto", 18 | "//proto:database-proto", 19 | "//proto:answer-proto", 20 | "//proto:concept-proto", 21 | "//proto:connection-proto", 22 | "//proto:authentication-proto", 23 | "//proto:options-proto", 24 | "//proto:query-proto", 25 | "//proto:transaction-proto", 26 | "//proto:version-proto", 27 | ] 28 | ) 29 | 30 | rust_library( 31 | name = "typedb_protocol", 32 | crate_root = ":typedb_protocol_src", 33 | srcs = [ 34 | ":typedb_protocol_src", 35 | ], 36 | deps = [ 37 | "@crates//:tonic", 38 | "@crates//:prost", 39 | ], 40 | tags = [ 41 | "crate-name=typedb-protocol", 42 | ], 43 | visibility = ["//visibility:public"], 44 | ) 45 | 46 | assemble_crate( 47 | name = "assemble_crate", 48 | target = ":typedb_protocol", 49 | description = "TypeDB Protocol", 50 | homepage = "https://github.com/typedb/typedb-protocol", 51 | readme_file = "//:README.md", 52 | license = "MPL-2.0", 53 | license_file = "//:LICENSE", 54 | repository = "https://github.com/typedb/typedb-protocol", 55 | ) 56 | 57 | deploy_crate( 58 | name = "deploy_crate", 59 | target = ":assemble_crate", 60 | snapshot = deployment["crate"]["snapshot"], 61 | release = deployment["crate"]["release"] 62 | ) 63 | 64 | checkstyle_test( 65 | name = "checkstyle", 66 | include = glob(["*"]), 67 | license_type = "mpl-header", 68 | size = "small", 69 | ) 70 | -------------------------------------------------------------------------------- /grpc/rust/Cargo.toml: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | [package] 6 | name = "typedb-protocol" 7 | version = "0.0.0" 8 | edition = "2021" 9 | 10 | [lib] 11 | path = "lib.rs" 12 | 13 | [build-dependencies] 14 | tonic-build = "^0.12" 15 | 16 | [dependencies] 17 | prost = "^0.13" 18 | tonic = { version = "^0.12", features = ["tls", "tls-roots"] } 19 | -------------------------------------------------------------------------------- /grpc/rust/build.rs: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this 3 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | fn main() -> std::io::Result<()> { 6 | let protos = vec![ 7 | "../../proto/answer.proto", 8 | "../../proto/authentication.proto", 9 | "../../proto/concept.proto", 10 | "../../proto/connection.proto", 11 | "../../proto/database.proto", 12 | "../../proto/options.proto", 13 | "../../proto/query.proto", 14 | "../../proto/server.proto", 15 | "../../proto/transaction.proto", 16 | "../../proto/typedb-service.proto", 17 | "../../proto/user.proto", 18 | "../../proto/version.proto", 19 | ]; 20 | 21 | tonic_build::configure() 22 | .server_mod_attribute(".", "#[allow(non_camel_case_types)]") 23 | .client_mod_attribute(".", "#[allow(non_camel_case_types)]") 24 | .compile_protos(&protos, &["../.."]) 25 | } 26 | -------------------------------------------------------------------------------- /grpc/rust/lib.rs: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this 3 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | tonic::include_proto!("typedb.protocol"); 6 | -------------------------------------------------------------------------------- /proto/BUILD: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | package(default_visibility = ["//visibility:public"]) 6 | 7 | load("@typedb_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") 8 | 9 | proto_library( 10 | name = "typedb-service", 11 | srcs = [":typedb-service.proto"], 12 | deps = [ 13 | ":connection-proto", 14 | ":authentication-proto", 15 | ":server-proto", 16 | ":user-proto", 17 | ":database-proto", 18 | ":transaction-proto", 19 | ], 20 | ) 21 | 22 | proto_library( 23 | name = "server-proto", 24 | srcs = [":server.proto"], 25 | ) 26 | 27 | proto_library( 28 | name = "database-proto", 29 | srcs = [":database.proto"], 30 | ) 31 | 32 | proto_library( 33 | name = "user-proto", 34 | srcs = [":user.proto"], 35 | ) 36 | 37 | proto_library( 38 | name = "answer-proto", 39 | srcs = ["answer.proto"], 40 | deps = [":concept-proto"], 41 | ) 42 | 43 | proto_library( 44 | name = "authentication-proto", 45 | srcs = ["authentication.proto"], 46 | ) 47 | 48 | proto_library( 49 | name = "concept-proto", 50 | srcs = ["concept.proto"], 51 | ) 52 | 53 | proto_library( 54 | name = "connection-proto", 55 | srcs = ["connection.proto"], 56 | deps = [ 57 | ":authentication-proto", 58 | ":database-proto", 59 | ":version-proto" 60 | ], 61 | ) 62 | 63 | proto_library( 64 | name = "options-proto", 65 | srcs = ["options.proto"], 66 | ) 67 | 68 | proto_library( 69 | name = "query-proto", 70 | srcs = ["query.proto"], 71 | deps = [ 72 | ":answer-proto", 73 | ":options-proto", 74 | ":concept-proto", 75 | ], 76 | ) 77 | 78 | proto_library( 79 | name = "transaction-proto", 80 | srcs = ["transaction.proto"], 81 | deps = [ 82 | ":answer-proto", 83 | ":concept-proto", 84 | ":options-proto", 85 | ":query-proto", 86 | ] 87 | ) 88 | 89 | proto_library( 90 | name = "version-proto", 91 | srcs = ["version.proto"], 92 | ) 93 | 94 | # TODO: THIS SHOULD BE MADE TO STOP EXISTING 95 | # This exists to support the nodejs build- when it becomes a real rule, we should extract the .src_files 96 | # from the above proto_library rules, but for now this is required to get the source files. 97 | filegroup( 98 | name = "proto-raw-buffers", 99 | srcs = [ 100 | "answer.proto", 101 | "concept.proto", 102 | "connection.proto", 103 | "options.proto", 104 | "query.proto", 105 | "transaction.proto", 106 | "version.proto", 107 | ] 108 | ) 109 | 110 | checkstyle_test( 111 | name = "checkstyle", 112 | include = glob(["*"]), 113 | license_type = "mpl-header", 114 | size = "small", 115 | ) 116 | -------------------------------------------------------------------------------- /proto/answer.proto: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this 3 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | syntax = "proto3"; 6 | 7 | import "proto/concept.proto"; 8 | 9 | package typedb.protocol; 10 | 11 | message ConceptRow { 12 | repeated RowEntry row = 1; 13 | // Explainables explainables = 2; 14 | } 15 | 16 | message RowEntry { 17 | oneof entry { 18 | Empty empty = 1; 19 | Concept concept = 2; 20 | Value value = 3; 21 | ConceptList concept_list = 4; 22 | ValueList value_list = 5; 23 | } 24 | 25 | message Empty {} 26 | 27 | message ConceptList { 28 | repeated Concept concepts = 1; 29 | } 30 | 31 | message ValueList { 32 | repeated Value values = 1; 33 | } 34 | } 35 | 36 | message ConceptDocument { 37 | 38 | Node root = 1; 39 | 40 | message Node { 41 | oneof node { 42 | Map map = 1; 43 | List list = 2; 44 | Leaf leaf = 3; 45 | } 46 | 47 | message Map { 48 | map map = 1; 49 | } 50 | 51 | message List { 52 | repeated Node list = 1; 53 | } 54 | 55 | message Leaf { 56 | oneof leaf { 57 | Empty empty = 1; 58 | 59 | EntityType entity_type = 10; 60 | RelationType relation_type = 11; 61 | AttributeType attribute_type = 12; 62 | RoleType role_type = 13; 63 | ValueType value_type = 15; 64 | 65 | Attribute attribute = 20; 66 | Value value = 21; 67 | 68 | Kind kind = 30; 69 | } 70 | 71 | message Empty {} 72 | 73 | enum Kind { 74 | Entity = 0; 75 | Relation = 1; 76 | Attribute = 3; 77 | Role = 4; 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /proto/authentication.proto: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this 3 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | syntax = "proto3"; 6 | 7 | package typedb.protocol; 8 | 9 | message Authentication { 10 | message Token { 11 | message Create { 12 | message Req { 13 | message Password { 14 | string username = 1; 15 | string password = 2; 16 | } 17 | 18 | oneof credentials { 19 | Password password = 1; 20 | // extend by other credential kinds 21 | } 22 | } 23 | 24 | message Res { 25 | string token = 1; 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /proto/concept.proto: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this 3 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | syntax = "proto3"; 6 | 7 | package typedb.protocol; 8 | 9 | message Concept { 10 | oneof concept { 11 | EntityType entity_type = 1; 12 | RelationType relation_type = 2; 13 | AttributeType attribute_type = 3; 14 | RoleType role_type = 4; 15 | 16 | Entity entity = 5; 17 | Relation relation = 6; 18 | Attribute attribute = 7; 19 | } 20 | } 21 | 22 | message Thing { 23 | oneof thing { 24 | Entity entity = 1; 25 | Relation relation = 2; 26 | Attribute attribute = 3; 27 | } 28 | } 29 | 30 | message Entity { 31 | bytes iid = 1; 32 | // TODO: not sure we should include types by default, since now they can get quite large with annotations included in every single response! 33 | // perhaps it's a query option? 34 | optional EntityType entity_type = 2; 35 | } 36 | 37 | message Relation { 38 | bytes iid = 1; 39 | // TODO: not sure we should include types by default, since now they can get quite large with annotations included in every single response! 40 | // perhaps it's a query option? 41 | optional RelationType relation_type = 2; 42 | } 43 | 44 | message Attribute { 45 | bytes iid = 1; 46 | // TODO: not sure we should include types by default, since now they can get quite large with annotations included in every single response! 47 | // perhaps it's a query option? 48 | optional AttributeType attribute_type = 2; 49 | Value value = 3; 50 | } 51 | 52 | message Value { 53 | oneof value { 54 | bool boolean = 1; 55 | sint64 integer = 2; 56 | double double = 3; 57 | Decimal decimal = 4; 58 | string string = 5; 59 | Date date = 6; 60 | // time since epoch in milliseconds 61 | Datetime datetime = 7; 62 | Datetime_TZ datetime_tz = 8; 63 | Duration duration = 9; 64 | Struct struct = 10; 65 | } 66 | 67 | message Decimal { 68 | sint64 integer = 1; 69 | uint64 fractional = 2; 70 | } 71 | 72 | message Date { 73 | // days since January 1, 0001 as day 1 in the Gregorian Calendar (following Rust conventions) 74 | sint32 num_days_since_ce = 1; 75 | } 76 | 77 | message Datetime { 78 | // seconds since epoch 79 | sint64 seconds = 1; 80 | uint32 nanos = 2; 81 | } 82 | 83 | message Datetime_TZ { 84 | Datetime datetime = 1; 85 | oneof timezone { 86 | string named = 2; 87 | // offset in seconds 88 | sint32 offset = 3; 89 | } 90 | } 91 | 92 | message Duration { 93 | uint32 months = 1; 94 | uint32 days = 2; 95 | uint64 nanos = 3; 96 | } 97 | 98 | message Struct { 99 | string struct_type_name = 1; 100 | } 101 | } 102 | 103 | message Type { 104 | oneof type { 105 | EntityType entity_type = 1; 106 | RelationType relation_type = 2; 107 | AttributeType attribute_type = 3; 108 | RoleType role_type = 4; 109 | } 110 | } 111 | 112 | message RoleType { 113 | string label = 1; 114 | } 115 | 116 | message EntityType { 117 | string label = 1; 118 | } 119 | 120 | message RelationType { 121 | string label = 1; 122 | } 123 | 124 | message AttributeType { 125 | string label = 1; 126 | optional ValueType value_type = 2; 127 | } 128 | 129 | message ValueType { 130 | oneof value_type { 131 | Boolean boolean = 1; 132 | Integer integer = 2; 133 | Double double = 3; 134 | Decimal decimal = 4; 135 | String string = 5; 136 | Date date = 6; 137 | DateTime datetime = 7; 138 | DateTime_TZ datetime_tz = 8; 139 | Duration duration = 9; 140 | Struct struct = 10; 141 | } 142 | message Boolean {}; 143 | message Integer {}; 144 | message Double {}; 145 | message Decimal {}; 146 | message String {}; 147 | message Date {}; 148 | message DateTime {}; 149 | message DateTime_TZ {}; 150 | message Duration {}; 151 | message Struct { 152 | string name = 1; 153 | }; 154 | } 155 | 156 | message Annotation { 157 | oneof annotation { 158 | Key key = 1; 159 | Unique unique = 2; 160 | // TODO 161 | } 162 | 163 | message Key {} 164 | message Unique {} 165 | } 166 | -------------------------------------------------------------------------------- /proto/connection.proto: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this 3 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | syntax = "proto3"; 6 | 7 | import "proto/authentication.proto"; 8 | import "proto/database.proto"; 9 | import "proto/version.proto"; 10 | 11 | package typedb.protocol; 12 | 13 | message Connection { 14 | 15 | message Open { 16 | message Req { 17 | Version version = 1; 18 | string driver_lang = 2; 19 | string driver_version = 3; 20 | 21 | Authentication.Token.Create.Req authentication = 4; 22 | } 23 | 24 | message Res { 25 | uint64 server_duration_millis = 1; 26 | ConnectionID connection_id = 2; 27 | 28 | // pre-send all databases and replica info 29 | DatabaseManager.All.Res databases_all = 3; 30 | 31 | Authentication.Token.Create.Res authentication = 4; 32 | } 33 | } 34 | } 35 | 36 | // Connection ID and Token are expected in all message metadata 37 | message ConnectionID { 38 | bytes id = 1; 39 | } 40 | -------------------------------------------------------------------------------- /proto/database.proto: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this 3 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | syntax = "proto3"; 6 | 7 | package typedb.protocol; 8 | 9 | message DatabaseManager { 10 | 11 | message Get { 12 | message Req { 13 | string name = 1; 14 | } 15 | message Res { 16 | DatabaseReplicas database = 1; 17 | } 18 | } 19 | 20 | message All { 21 | message Req {} 22 | message Res { 23 | repeated DatabaseReplicas databases = 1; 24 | } 25 | } 26 | 27 | message Contains { 28 | message Req { 29 | string name = 1; 30 | } 31 | message Res { 32 | bool contains = 1; 33 | } 34 | } 35 | 36 | message Create { 37 | message Req { 38 | string name = 1; 39 | } 40 | message Res { 41 | DatabaseReplicas database = 1; 42 | } 43 | } 44 | } 45 | 46 | message DatabaseReplicas { 47 | 48 | string name = 1; 49 | repeated Replica replicas = 2; 50 | 51 | message Replica { 52 | string address = 1; 53 | bool primary = 2; 54 | bool preferred = 3; 55 | int64 term = 4; 56 | } 57 | } 58 | 59 | message Database { 60 | 61 | message Schema { 62 | message Req { 63 | string name = 1; 64 | } 65 | message Res { 66 | string schema = 1; 67 | } 68 | } 69 | 70 | message TypeSchema { 71 | message Req { 72 | string name = 1; 73 | } 74 | message Res { 75 | string schema = 1; 76 | } 77 | } 78 | 79 | // message RuleSchema { 80 | // message Req { 81 | // string name = 1; 82 | // } 83 | // message Res { 84 | // string schema = 1; 85 | // } 86 | // } 87 | 88 | message Delete { 89 | message Req { 90 | string name = 1; 91 | } 92 | message Res {} 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /proto/options.proto: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this 3 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | syntax = "proto3"; 6 | 7 | package typedb.protocol; 8 | 9 | message Options { 10 | message Transaction { 11 | optional bool parallel = 1; 12 | optional uint64 transaction_timeout_millis = 2; 13 | optional uint64 schema_lock_acquire_timeout_millis = 3; 14 | } 15 | 16 | message Query { 17 | optional bool include_instance_types = 1; 18 | optional uint64 prefetch_size = 2; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /proto/query.proto: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this 3 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | syntax = "proto3"; 6 | 7 | import "proto/answer.proto"; 8 | import "proto/options.proto"; 9 | 10 | package typedb.protocol; 11 | 12 | message Query { 13 | 14 | enum Type { 15 | READ = 0; 16 | WRITE = 1; 17 | SCHEMA = 2; 18 | } 19 | 20 | message Req { 21 | Options.Query options = 1; 22 | string query = 2; 23 | } 24 | 25 | message InitialRes { 26 | oneof res { 27 | Error error = 1; 28 | Ok ok = 2; 29 | } 30 | 31 | message Ok { 32 | oneof ok { 33 | Done done = 1; 34 | ConceptDocumentStream concept_document_stream = 3; 35 | ConceptRowStream concept_row_stream = 4; 36 | } 37 | 38 | message Done { 39 | Type query_type = 1; 40 | } 41 | 42 | message ConceptDocumentStream { 43 | // note: we could use this first response to record debug info, type annotations, warnings, etc 44 | // TODO: network optimisation: replace keys with IDs, sending keys in the header to rebuild the document on the client side 45 | // TODO: network optimisation: replace types (== mostly constant strings) with a IDs, sending types in the header to rebuild on the client side 46 | Type query_type = 2; 47 | } 48 | 49 | message ConceptRowStream { 50 | // TODO: network optimisation: replace types (== mostly constant strings) with a IDs, sending types in the header to rebuild on the client side 51 | repeated string column_variable_names = 1; 52 | Type query_type = 2; 53 | } 54 | } 55 | } 56 | 57 | message ResPart { 58 | oneof res { 59 | ConceptDocumentsRes documents_res = 1; 60 | ConceptRowsRes rows_res = 2; 61 | } 62 | 63 | message ConceptDocumentsRes { 64 | repeated ConceptDocument documents = 1; 65 | } 66 | 67 | message ConceptRowsRes { 68 | repeated ConceptRow rows = 1; 69 | } 70 | } 71 | } 72 | 73 | // This is an emulation of the google ErrorDetails message. Sometimes we submit ErrorDetails via the GRPC error mechanism 74 | // and sometimes (in streams) we have to manually send errors 75 | message Error { 76 | string error_code = 1; 77 | string domain = 2; 78 | repeated string stack_trace = 3; 79 | } 80 | -------------------------------------------------------------------------------- /proto/server.proto: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this 3 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | syntax = "proto3"; 6 | 7 | package typedb.protocol; 8 | 9 | message ServerManager { 10 | 11 | message All { 12 | message Req {} 13 | message Res { 14 | repeated Server servers = 1; 15 | } 16 | } 17 | } 18 | 19 | message Server { 20 | string address = 1; 21 | } 22 | -------------------------------------------------------------------------------- /proto/transaction.proto: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this 3 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | syntax = "proto3"; 6 | 7 | import "proto/options.proto"; 8 | import "proto/query.proto"; 9 | 10 | package typedb.protocol; 11 | 12 | message Transaction { 13 | 14 | message Client { 15 | repeated Req reqs = 1; 16 | } 17 | 18 | message Server { 19 | oneof server { 20 | Res res = 1; 21 | ResPart res_part = 2; 22 | } 23 | } 24 | 25 | message Req { 26 | bytes req_id = 1; 27 | map metadata = 2; 28 | oneof req { 29 | Open.Req open_req = 3; 30 | Query.Req query_req = 4; 31 | StreamSignal.Req stream_req = 5; 32 | Commit.Req commit_req = 6; 33 | Rollback.Req rollback_req = 7; 34 | Close.Req close_req = 8; 35 | } 36 | } 37 | 38 | message Res { 39 | bytes req_id = 1; 40 | oneof res { 41 | Open.Res open_res = 2; 42 | Query.InitialRes query_initial_res = 3; 43 | Commit.Res commit_res = 5; 44 | Rollback.Res rollback_res = 6; 45 | } 46 | } 47 | 48 | message ResPart { 49 | bytes req_id = 1; 50 | oneof res_part { 51 | Query.ResPart query_res = 2; 52 | StreamSignal.ResPart stream_res = 3; 53 | } 54 | } 55 | 56 | enum Type { 57 | READ = 0; 58 | WRITE = 1; 59 | SCHEMA = 2; 60 | } 61 | 62 | message Open { 63 | message Req { 64 | string database = 1; 65 | Type type = 2; 66 | Options.Transaction options = 3; 67 | uint64 network_latency_millis = 4; 68 | } 69 | message Res { 70 | uint64 server_duration_millis = 2; 71 | } 72 | } 73 | 74 | message Commit { 75 | message Req {} 76 | message Res {} 77 | } 78 | 79 | message Rollback { 80 | message Req {} 81 | message Res {} 82 | } 83 | 84 | message Close { 85 | message Req {} 86 | message Res {} 87 | } 88 | 89 | message GetSchemaExceptions { 90 | message Req {} 91 | message Res { 92 | repeated SchemaException exceptions = 1; 93 | } 94 | } 95 | 96 | message SchemaException { 97 | string code = 1; 98 | string message = 2; 99 | } 100 | 101 | message StreamSignal { 102 | message Req {} 103 | 104 | message ResPart { 105 | oneof state { 106 | Continue continue = 1; 107 | Done done = 2; 108 | Error error = 3; 109 | } 110 | 111 | message Continue {} 112 | 113 | message Done {} 114 | } 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /proto/typedb-service.proto: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this 3 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | syntax = "proto3"; 6 | 7 | import "proto/authentication.proto"; 8 | import "proto/connection.proto"; 9 | import "proto/database.proto"; 10 | import "proto/server.proto"; 11 | import "proto/user.proto"; 12 | import "proto/transaction.proto"; 13 | 14 | package typedb.protocol; 15 | 16 | service TypeDB { 17 | 18 | // Connection API 19 | rpc connection_open (Connection.Open.Req) returns (Connection.Open.Res); 20 | 21 | // Authentication API 22 | rpc authentication_token_create (Authentication.Token.Create.Req) returns (Authentication.Token.Create.Res); 23 | 24 | // Server Manager API 25 | rpc servers_all (ServerManager.All.Req) returns (ServerManager.All.Res); 26 | 27 | // User Manager API 28 | rpc users_get (UserManager.Get.Req) returns (UserManager.Get.Res); 29 | rpc users_all (UserManager.All.Req) returns (UserManager.All.Res); 30 | rpc users_contains (UserManager.Contains.Req) returns (UserManager.Contains.Res); 31 | rpc users_create (UserManager.Create.Req) returns (UserManager.Create.Res); 32 | 33 | // User API 34 | rpc users_update (User.Update.Req) returns (User.Update.Res); 35 | rpc users_delete (User.Delete.Req) returns (User.Delete.Res); 36 | 37 | // Database Manager API 38 | rpc databases_get (DatabaseManager.Get.Req) returns (DatabaseManager.Get.Res); 39 | rpc databases_all (DatabaseManager.All.Req) returns (DatabaseManager.All.Res); 40 | rpc databases_contains (DatabaseManager.Contains.Req) returns (DatabaseManager.Contains.Res); 41 | rpc databases_create (DatabaseManager.Create.Req) returns (DatabaseManager.Create.Res); 42 | 43 | // Database API 44 | rpc database_schema (Database.Schema.Req) returns (Database.Schema.Res); 45 | rpc database_type_schema (Database.TypeSchema.Req) returns (Database.TypeSchema.Res); 46 | rpc database_delete (Database.Delete.Req) returns (Database.Delete.Res); 47 | 48 | // Transaction Streaming API 49 | // Opens a bi-directional stream representing a stateful transaction, streaming 50 | // requests and responses back-and-forth. The first transaction client message must 51 | // be {Transaction.Open.Req}. Closing the stream closes the transaction. 52 | rpc transaction (stream Transaction.Client) returns (stream Transaction.Server); 53 | 54 | } 55 | -------------------------------------------------------------------------------- /proto/user.proto: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this 3 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | syntax = "proto3"; 6 | 7 | package typedb.protocol; 8 | 9 | message UserManager { 10 | message All { 11 | message Req {} 12 | 13 | message Res { 14 | repeated User users = 1; 15 | } 16 | } 17 | 18 | message Contains { 19 | message Req { 20 | string name = 1; 21 | } 22 | 23 | message Res { 24 | bool contains = 1; 25 | } 26 | } 27 | 28 | message Get { 29 | message Req { 30 | string name = 1; 31 | } 32 | 33 | message Res { 34 | User user = 1; 35 | } 36 | } 37 | 38 | message Create { 39 | message Req { 40 | User user = 1; 41 | } 42 | 43 | message Res {} 44 | } 45 | } 46 | 47 | message User { 48 | string name = 1; 49 | optional string password = 2; 50 | 51 | message Update { 52 | message Req { 53 | string name = 1; 54 | User user = 2; 55 | } 56 | 57 | message Res {} 58 | } 59 | 60 | message Delete { 61 | message Req { 62 | string name = 1; 63 | } 64 | 65 | message Res {} 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /proto/version.proto: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this 3 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | syntax = "proto3"; 6 | 7 | package typedb.protocol; 8 | 9 | enum Version { 10 | reserved 1, 2, 3, 4, 5; // add past version numbers into the reserved range 11 | UNSPECIFIED = 0; 12 | VERSION = 6; 13 | } 14 | -------------------------------------------------------------------------------- /tool/release/BUILD: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | load("@typedb_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") 6 | 7 | checkstyle_test( 8 | name = "checkstyle", 9 | include = glob(["*"]), 10 | license_type = "mpl-header", 11 | ) 12 | -------------------------------------------------------------------------------- /tool/release/create_notes.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This Source Code Form is subject to the terms of the Mozilla Public 3 | # License, v. 2.0. If a copy of the MPL was not distributed with this 4 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 5 | 6 | bazel run @typedb_dependencies//tool/release/notes:create -- typedb typedb-protocol HEAD "$(cat VERSION)" ./RELEASE_TEMPLATE.md ./RELEASE_NOTES_LATEST.md 7 | --------------------------------------------------------------------------------