From ceb05bd97d76a9b56a99f096310a486f25b671ff Mon Sep 17 00:00:00 2001 From: Steven Normore Date: Thu, 10 Feb 2022 09:19:15 -0500 Subject: [PATCH 1/4] ci: fix version in nvmrc --- .nvmrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.nvmrc b/.nvmrc index 13c38c964..121915258 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -^16.9 +16.9 From 7f088497e29f92eaa6754cd0f2de855a8c40167e Mon Sep 17 00:00:00 2001 From: Steven Normore Date: Thu, 10 Feb 2022 09:11:49 -0500 Subject: [PATCH 2/4] docs: generate with typedoc --- .eslintrc.js | 18 ++- .gitignore | 4 + .prettierignore | 2 + package-lock.json | 241 +++++++++++++++++++++++++++++++++--- package.json | 3 + src/Client.ts | 8 +- src/store/EncryptedStore.ts | 14 +-- 7 files changed, 265 insertions(+), 25 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index c4ac64f54..35ba38795 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -6,6 +6,7 @@ module.exports = { 'prettier', 'plugin:@typescript-eslint/recommended', 'eslint-config-prettier', + 'plugin:jsdoc/recommended', ], parserOptions: { sourceType: 'module', @@ -13,7 +14,20 @@ module.exports = { }, rules: { 'prettier/prettier': 'error', + 'jsdoc/require-jsdoc': 'off', + 'jsdoc/require-description': 'off', + 'jsdoc/require-param': 'off', + 'jsdoc/require-param-type': 'off', + 'jsdoc/require-returns': 'off', }, - plugins: ['@typescript-eslint', 'prettier'], - ignorePatterns: ['dist', 'node_modules', 'examples', 'scripts', 'src/types'], + plugins: ['@typescript-eslint', 'prettier', 'jsdoc'], + ignorePatterns: [ + 'dist', + 'node_modules', + 'examples', + 'scripts', + 'src/types', + 'docs', + 'tmp', + ], } diff --git a/.gitignore b/.gitignore index 003264491..6b5cb6af5 100644 --- a/.gitignore +++ b/.gitignore @@ -116,3 +116,7 @@ dist .yarn/install-state.gz .pnp.* scratch + +# generated docs +docs/ +tmp/ diff --git a/.prettierignore b/.prettierignore index 009af5438..0f2800a1b 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,2 +1,4 @@ dist coverage +docs +tmp diff --git a/package-lock.json b/package-lock.json index 103e25ea3..f80f4ff83 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,6 +27,7 @@ "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-config-standard": "^16.0.3", + "eslint-plugin-jsdoc": "^37.9.1", "eslint-plugin-prettier": "^4.0.0", "husky": "^7.0.4", "jest": "^27.2.0", @@ -37,6 +38,7 @@ "ts-jest": "^27.0.5", "ts-loader": "^9.2.5", "ts-proto": "^1.104.0", + "typedoc": "^0.22.11", "typescript": "^4.4.3", "webpack": "^5.52.1", "webpack-cli": "^4.8.0" @@ -1037,6 +1039,20 @@ "node": ">=10.0.0" } }, + "node_modules/@es-joy/jsdoccomment": { + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.19.0.tgz", + "integrity": "sha512-lRx/5ChsOwv7gIU05m8Ur1Rxa4/XkE23wTsX8XFBGWRYrCcCrngPf6yGJMG6n9dqnyDehPrBBVeFIm2INEIeQA==", + "dev": true, + "dependencies": { + "comment-parser": "1.3.0", + "esquery": "^1.4.0", + "jsdoc-type-pratt-parser": "~2.2.2" + }, + "engines": { + "node": "^12 || ^14 || ^16 || ^17" + } + }, "node_modules/@eslint/eslintrc": { "version": "0.4.3", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz", @@ -4120,6 +4136,15 @@ "node": ">= 10" } }, + "node_modules/comment-parser": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.3.0.tgz", + "integrity": "sha512-hRpmWIKgzd81vn0ydoWoyPoALEOnF4wt8yKD35Ib1D6XC2siLiYaiqfGkYrunuKdsXGwpBpHU3+9r+RVw2NZfA==", + "dev": true, + "engines": { + "node": ">= 12.0.0" + } + }, "node_modules/compare-func": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-2.0.0.tgz", @@ -5346,6 +5371,28 @@ "dev": true, "peer": true }, + "node_modules/eslint-plugin-jsdoc": { + "version": "37.9.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-37.9.1.tgz", + "integrity": "sha512-ynIsYL+rOtIKWOttAYWCgOJawPwYKexcX3cuoYHwifvz4+uY+MZ2un5nMHBULigdSITnQ5/ZSHpO/O1nwv/uJA==", + "dev": true, + "dependencies": { + "@es-joy/jsdoccomment": "~0.19.0", + "comment-parser": "1.3.0", + "debug": "^4.3.3", + "escape-string-regexp": "^4.0.0", + "esquery": "^1.4.0", + "regextras": "^0.8.0", + "semver": "^7.3.5", + "spdx-expression-parse": "^3.0.1" + }, + "engines": { + "node": "^12 || ^14 || ^16 || ^17" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, "node_modules/eslint-plugin-node": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz", @@ -8093,6 +8140,15 @@ "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz", "integrity": "sha1-sBMHyym2GKHtJux56RH4A8TaAEA=" }, + "node_modules/jsdoc-type-pratt-parser": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-2.2.3.tgz", + "integrity": "sha512-QPyxq62Q8veBSDtDrWmqaEPjSCeknUV9dH/OAGt3q9an8qC8UQDqitQiw1NvoMskIESpoRZ6qzt4H3rlK0xo8A==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/jsdom": { "version": "16.7.0", "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-16.7.0.tgz", @@ -8211,6 +8267,12 @@ "node": ">=6" } }, + "node_modules/jsonc-parser": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.0.0.tgz", + "integrity": "sha512-fQzRfAbIBnR0IQvftw9FJveWiHp72Fg20giDrHz6TdfB12UH/uue0D3hm57UB5KgAVuniLMCaS8P1IMj9NR7cA==", + "dev": true + }, "node_modules/jsonfile": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", @@ -8795,6 +8857,12 @@ "node": ">=10" } }, + "node_modules/lunr": { + "version": "2.3.9", + "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", + "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==", + "dev": true + }, "node_modules/mafmt": { "version": "10.0.0", "resolved": "https://registry.npmjs.org/mafmt/-/mafmt-10.0.0.tgz", @@ -12926,6 +12994,15 @@ "url": "https://github.com/sponsors/mysticatea" } }, + "node_modules/regextras": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/regextras/-/regextras-0.8.0.tgz", + "integrity": "sha512-k519uI04Z3SaY0fLX843MRXnDeG2+vHOFsyhiPZvNLe7r8rD2YNRjq4BQLZZ0oAr2NrtvZlICsXysGNFPGa3CQ==", + "dev": true, + "engines": { + "node": ">=0.1.14" + } + }, "node_modules/registry-auth-token": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-4.2.1.tgz", @@ -13364,6 +13441,17 @@ "node": ">=8" } }, + "node_modules/shiki": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.10.0.tgz", + "integrity": "sha512-iczxaIYeBFHTFrQPb9DVy2SKgYxC4Wo7Iucm7C17cCh2Ge/refnvHscUOxM85u57MfLoNOtjoEFUWt9gBexblA==", + "dev": true, + "dependencies": { + "jsonc-parser": "^3.0.0", + "vscode-oniguruma": "^1.6.1", + "vscode-textmate": "5.2.0" + } + }, "node_modules/side-channel": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", @@ -14431,6 +14519,12 @@ "node": ">=4" } }, + "node_modules/tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + }, "node_modules/tsutils": { "version": "3.21.0", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", @@ -14446,12 +14540,6 @@ "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" } }, - "node_modules/tsutils/node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true - }, "node_modules/tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -14510,6 +14598,28 @@ "is-typedarray": "^1.0.0" } }, + "node_modules/typedoc": { + "version": "0.22.11", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.11.tgz", + "integrity": "sha512-pVr3hh6dkS3lPPaZz1fNpvcrqLdtEvXmXayN55czlamSgvEjh+57GUqfhAI1Xsuu/hNHUT1KNSx8LH2wBP/7SA==", + "dev": true, + "dependencies": { + "glob": "^7.2.0", + "lunr": "^2.3.9", + "marked": "^4.0.10", + "minimatch": "^3.0.4", + "shiki": "^0.10.0" + }, + "bin": { + "typedoc": "bin/typedoc" + }, + "engines": { + "node": ">= 12.10.0" + }, + "peerDependencies": { + "typescript": "4.0.x || 4.1.x || 4.2.x || 4.3.x || 4.4.x || 4.5.x" + } + }, "node_modules/typescript": { "version": "4.5.5", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", @@ -14700,6 +14810,18 @@ "extsprintf": "^1.2.0" } }, + "node_modules/vscode-oniguruma": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.6.1.tgz", + "integrity": "sha512-vc4WhSIaVpgJ0jJIejjYxPvURJavX6QG41vu0mGhqywMkQqulezEqEQ3cO3gc8GvcOpX6ycmKGqRoROEMBNXTQ==", + "dev": true + }, + "node_modules/vscode-textmate": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-5.2.0.tgz", + "integrity": "sha512-Uw5ooOQxRASHgu6C7GVvUxisKXfSgW4oFlO+aa+PAkgmH89O3CXxEEzNRNtHSqtXFTl0nAC1uYj0GMSH27uwtQ==", + "dev": true + }, "node_modules/w3c-hr-time": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz", @@ -15922,6 +16044,17 @@ "integrity": "sha512-ws57AidsDvREKrZKYffXddNkyaF14iHNHm8VQnZH6t99E8gczjNN0GpvcGny0imC80yQ0tHz1xVUKk/KFQSUyA==", "dev": true }, + "@es-joy/jsdoccomment": { + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.19.0.tgz", + "integrity": "sha512-lRx/5ChsOwv7gIU05m8Ur1Rxa4/XkE23wTsX8XFBGWRYrCcCrngPf6yGJMG6n9dqnyDehPrBBVeFIm2INEIeQA==", + "dev": true, + "requires": { + "comment-parser": "1.3.0", + "esquery": "^1.4.0", + "jsdoc-type-pratt-parser": "~2.2.2" + } + }, "@eslint/eslintrc": { "version": "0.4.3", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz", @@ -18274,6 +18407,12 @@ "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", "dev": true }, + "comment-parser": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.3.0.tgz", + "integrity": "sha512-hRpmWIKgzd81vn0ydoWoyPoALEOnF4wt8yKD35Ib1D6XC2siLiYaiqfGkYrunuKdsXGwpBpHU3+9r+RVw2NZfA==", + "dev": true + }, "compare-func": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-2.0.0.tgz", @@ -19259,6 +19398,22 @@ } } }, + "eslint-plugin-jsdoc": { + "version": "37.9.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-37.9.1.tgz", + "integrity": "sha512-ynIsYL+rOtIKWOttAYWCgOJawPwYKexcX3cuoYHwifvz4+uY+MZ2un5nMHBULigdSITnQ5/ZSHpO/O1nwv/uJA==", + "dev": true, + "requires": { + "@es-joy/jsdoccomment": "~0.19.0", + "comment-parser": "1.3.0", + "debug": "^4.3.3", + "escape-string-regexp": "^4.0.0", + "esquery": "^1.4.0", + "regextras": "^0.8.0", + "semver": "^7.3.5", + "spdx-expression-parse": "^3.0.1" + } + }, "eslint-plugin-node": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz", @@ -21336,6 +21491,12 @@ "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz", "integrity": "sha1-sBMHyym2GKHtJux56RH4A8TaAEA=" }, + "jsdoc-type-pratt-parser": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-2.2.3.tgz", + "integrity": "sha512-QPyxq62Q8veBSDtDrWmqaEPjSCeknUV9dH/OAGt3q9an8qC8UQDqitQiw1NvoMskIESpoRZ6qzt4H3rlK0xo8A==", + "dev": true + }, "jsdom": { "version": "16.7.0", "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-16.7.0.tgz", @@ -21427,6 +21588,12 @@ "minimist": "^1.2.5" } }, + "jsonc-parser": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.0.0.tgz", + "integrity": "sha512-fQzRfAbIBnR0IQvftw9FJveWiHp72Fg20giDrHz6TdfB12UH/uue0D3hm57UB5KgAVuniLMCaS8P1IMj9NR7cA==", + "dev": true + }, "jsonfile": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", @@ -21946,6 +22113,12 @@ "yallist": "^4.0.0" } }, + "lunr": { + "version": "2.3.9", + "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", + "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==", + "dev": true + }, "mafmt": { "version": "10.0.0", "resolved": "https://registry.npmjs.org/mafmt/-/mafmt-10.0.0.tgz", @@ -24910,6 +25083,12 @@ "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", "dev": true }, + "regextras": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/regextras/-/regextras-0.8.0.tgz", + "integrity": "sha512-k519uI04Z3SaY0fLX843MRXnDeG2+vHOFsyhiPZvNLe7r8rD2YNRjq4BQLZZ0oAr2NrtvZlICsXysGNFPGa3CQ==", + "dev": true + }, "registry-auth-token": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-4.2.1.tgz", @@ -25236,6 +25415,17 @@ "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==" }, + "shiki": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.10.0.tgz", + "integrity": "sha512-iczxaIYeBFHTFrQPb9DVy2SKgYxC4Wo7Iucm7C17cCh2Ge/refnvHscUOxM85u57MfLoNOtjoEFUWt9gBexblA==", + "dev": true, + "requires": { + "jsonc-parser": "^3.0.0", + "vscode-oniguruma": "^1.6.1", + "vscode-textmate": "5.2.0" + } + }, "side-channel": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", @@ -26041,6 +26231,12 @@ } } }, + "tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + }, "tsutils": { "version": "3.21.0", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", @@ -26048,14 +26244,6 @@ "dev": true, "requires": { "tslib": "^1.8.1" - }, - "dependencies": { - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true - } } }, "tunnel-agent": { @@ -26101,6 +26289,19 @@ "is-typedarray": "^1.0.0" } }, + "typedoc": { + "version": "0.22.11", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.11.tgz", + "integrity": "sha512-pVr3hh6dkS3lPPaZz1fNpvcrqLdtEvXmXayN55czlamSgvEjh+57GUqfhAI1Xsuu/hNHUT1KNSx8LH2wBP/7SA==", + "dev": true, + "requires": { + "glob": "^7.2.0", + "lunr": "^2.3.9", + "marked": "^4.0.10", + "minimatch": "^3.0.4", + "shiki": "^0.10.0" + } + }, "typescript": { "version": "4.5.5", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", @@ -26255,6 +26456,18 @@ "extsprintf": "^1.2.0" } }, + "vscode-oniguruma": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.6.1.tgz", + "integrity": "sha512-vc4WhSIaVpgJ0jJIejjYxPvURJavX6QG41vu0mGhqywMkQqulezEqEQ3cO3gc8GvcOpX6ycmKGqRoROEMBNXTQ==", + "dev": true + }, + "vscode-textmate": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-5.2.0.tgz", + "integrity": "sha512-Uw5ooOQxRASHgu6C7GVvUxisKXfSgW4oFlO+aa+PAkgmH89O3CXxEEzNRNtHSqtXFTl0nAC1uYj0GMSH27uwtQ==", + "dev": true + }, "w3c-hr-time": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz", diff --git a/package.json b/package.json index fb73925e7..58a32a45a 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "build:esm": "node tools/cleanup esm && tsc -p config/tsconfig.esm.json", "build:umd": "node tools/cleanup umd && webpack --config config/webpack.config.js", "build:types": "node tools/cleanup types && tsc -p config/tsconfig.types.json", + "build:docs": "rm -rf docs && mkdir -p tmp && cp README.md tmp/ && sed -i.bak '/badge.svg/d' tmp/README.md && typedoc --excludePrivate --readme tmp/README.md src/index.ts", "clean": "node tools/cleanup && npm run clean:proto", "clean:proto": "rm -rf src/proto/*.ts", "package": "npm run build && npm pack", @@ -75,6 +76,7 @@ "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-config-standard": "^16.0.3", + "eslint-plugin-jsdoc": "^37.9.1", "eslint-plugin-prettier": "^4.0.0", "husky": "^7.0.4", "jest": "^27.2.0", @@ -85,6 +87,7 @@ "ts-jest": "^27.0.5", "ts-loader": "^9.2.5", "ts-proto": "^1.104.0", + "typedoc": "^0.22.11", "typescript": "^4.4.3", "webpack": "^5.52.1", "webpack-cli": "^4.8.0" diff --git a/src/Client.ts b/src/Client.ts index a7ac1c79b..0dd49e397 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -62,8 +62,12 @@ export default class Client { return this._conversations } - // create and start a client associated with given wallet; - // create options specify how to to connect to the network + /** + * Create and start a client associated with given wallet. + * + * @param wallet the wallet as a Signer instance + * @param opts specify how to to connect to the network + */ static async create(wallet: Signer, opts?: CreateOptions): Promise { const waku = await createWaku(opts || {}) const keys = await loadOrCreateKeys(wallet) diff --git a/src/store/EncryptedStore.ts b/src/store/EncryptedStore.ts index ace329b63..9052cbcf9 100644 --- a/src/store/EncryptedStore.ts +++ b/src/store/EncryptedStore.ts @@ -3,13 +3,13 @@ import { Signer } from 'ethers' import { PrivateKeyBundle } from '../crypto' const KEY_BUNDLE_NAME = 'key_bundle' -/* - EncryptedStore is an abstraction on top of the generic Store which enables the decryption and decoding - of specific data types. - - Currently supports: - - PrivateKeyBundle -*/ +/** + * EncryptedStore is an abstraction on top of the generic Store which enables the decryption and decoding + * of specific data types. + * + * Currently supports: + * - PrivateKeyBundle + */ export default class EncryptedStore { private store: Store private signer: Signer From 17c24b2c02a151d5340fbee79f7d1dfc63b8263f Mon Sep 17 00:00:00 2001 From: Nick Molnar Date: Fri, 11 Feb 2022 14:16:04 -0800 Subject: [PATCH 3/4] fix: add Conversation to exports and make contacts private --- src/Client.ts | 4 ++-- src/Stream.ts | 6 ++++-- src/index.ts | 9 ++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Client.ts b/src/Client.ts index 0dd49e397..9a94ed5a4 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -45,9 +45,9 @@ type CreateOptions = { // most relevant functionality is accessed through methods on the Client. export default class Client { waku: Waku - keys: PrivateKeyBundle address: string - contacts: Map // addresses and key bundles that we already have connection with + keys: PrivateKeyBundle + private contacts: Map // addresses and key bundles that we already have connection with private _conversations: Conversations constructor(waku: Waku, keys: PrivateKeyBundle) { diff --git a/src/Stream.ts b/src/Stream.ts index 775780048..b8d7ae647 100644 --- a/src/Stream.ts +++ b/src/Stream.ts @@ -6,8 +6,10 @@ export type MessageTransformer = (msg: Message) => T export type MessageFilter = (msg: Message) => boolean -// Stream implements an Asynchronous Iterable over messages received from a topic. -// As such can be used with constructs like for-await-of, yield*, array destructing, etc. +/** + * Stream implements an Asynchronous Iterable over messages received from a topic. + * As such can be used with constructs like for-await-of, yield*, array destructing, etc. + */ export default class Stream { topic: string client: Client diff --git a/src/index.ts b/src/index.ts index 0fc0a9042..8a3443b03 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,13 +7,16 @@ import { } from '../src/crypto' import Stream from './Stream' import Client from './Client' +import { Conversation, Conversations } from './conversations' export { Client, - Stream, + Conversation, + Conversations, Message, - PublicKey, - PublicKeyBundle, PrivateKey, PrivateKeyBundle, + PublicKey, + PublicKeyBundle, + Stream, } From 7f1c135a3719d014c9fc85bc220398cbc66e4673 Mon Sep 17 00:00:00 2001 From: Nick Molnar Date: Fri, 11 Feb 2022 14:20:52 -0800 Subject: [PATCH 4/4] fix: add esdoc @type field and reformat some comments --- src/Client.ts | 27 +++++++++++++++++++-------- src/index.ts | 4 +++- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/Client.ts b/src/Client.ts index 9a94ed5a4..8ed18f726 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -30,19 +30,25 @@ export type ListMessagesOptions = { endTime?: Date } -// Network startup options -type CreateOptions = { - // bootstrap node multiaddrs +/** + * Network startup options + */ +export type CreateOptions = { + /** List of multiaddrs for boot nodes */ bootstrapAddrs?: string[] // Allow for specifying different envs later env?: keyof NodesList - // how long should we wait for the initial peer connection - // to declare the startup as successful or failed + /** + * How long we should wait for the initial peer connection + * to declare the startup as successful or failed + */ waitForPeersTimeoutMs?: number } -// Client is the central hub of interaction with the network, -// most relevant functionality is accessed through methods on the Client. +/** + * Client class initiates connection to the XMTP network. + * Should be created with `await Client.create(options)` + */ export default class Client { waku: Waku address: string @@ -58,6 +64,9 @@ export default class Client { this._conversations = new Conversations(this) } + /** + * @type {Conversations} + */ get conversations(): Conversations { return this._conversations } @@ -109,7 +118,9 @@ export default class Client { return recipientKeys.length > 0 ? recipientKeys[0] : undefined } - // send a message to the wallet identified by @peerAddress + /** + * Send a message to the wallet identified by @peerAddress + */ async sendMessage(peerAddress: string, msgString: string): Promise { let topics: string[] let recipient = this.contacts.get(peerAddress) diff --git a/src/index.ts b/src/index.ts index 8a3443b03..299b1cb7f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,13 +6,15 @@ import { PrivateKeyBundle, } from '../src/crypto' import Stream from './Stream' -import Client from './Client' +import Client, { CreateOptions, ListMessagesOptions } from './Client' import { Conversation, Conversations } from './conversations' export { Client, Conversation, Conversations, + CreateOptions, + ListMessagesOptions, Message, PrivateKey, PrivateKeyBundle,