diff --git a/.eslintrc.json b/.eslintrc.json index e85a32f..55280c9 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,4 +1,5 @@ { + "root": true, "env": { "browser": true, "es2021": true, @@ -9,12 +10,15 @@ "prettier", "prettier/vue", "plugin:prettier/recommended", - "eslint:recommended" + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" ], + "parser": "vue-eslint-parser", "parserOptions": { "ecmaVersion": 12, "sourceType": "module", - "parser": "@babel/eslint-parser" + "parser": "@typescript-eslint/parser" }, "plugins": ["vue", "prettier"], "rules": { @@ -25,6 +29,9 @@ "after": true } ], + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-var-requires": "off", + "@typescript-eslint/no-array-constructor": "off", //"array-bracket-spacing": [2, "always"], "block-spacing": [2, "always"], "camelcase": [ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..65a1965 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "editor.defaultFormatter": "esbenp.prettier-vscode" +} diff --git a/package-lock.json b/package-lock.json index 837e821..7c14161 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4607,6 +4607,12 @@ "integrity": "sha1-YcyEaYSeW83QxwRBIiZcOc7BDPQ=", "dev": true }, + "@types/crypto-js": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/@types/crypto-js/-/crypto-js-4.2.1.tgz", + "integrity": "sha512-FSPGd9+OcSok3RsM0UZ/9fcvMOXJ1ENE/ZbLfOPlBWj7BgXtEAM8VYfTtT760GiLbQIMoVozwVuisjvsVwqYWw==", + "dev": true + }, "@types/express": { "version": "4.17.11", "resolved": "https://registry.npm.taobao.org/@types/express/download/@types/express-4.17.11.tgz", @@ -4771,6 +4777,18 @@ "integrity": "sha1-5IbQ2XOW15vu3QpuM/RTT/a0lz4=", "dev": true }, + "@types/office-js": { + "version": "1.0.364", + "resolved": "https://registry.npmjs.org/@types/office-js/-/office-js-1.0.364.tgz", + "integrity": "sha512-sEoI3Rhtyz83WjMo3GamshNU7/j8CNY/UVrSVr3n6yOTWo6eG94pZvT4f00g0bvOYlY7Wi+OTZWEqY+MtQ81MQ==", + "dev": true + }, + "@types/office-runtime": { + "version": "1.0.35", + "resolved": "https://registry.npmjs.org/@types/office-runtime/-/office-runtime-1.0.35.tgz", + "integrity": "sha512-qrP3bkDNoPY6WZMTOoutFdkZHdK91OUC1/Ohzw94bE8OD8pVoPjHKSoYaS+NlTFyXH3SNKYmQU+E6o966zARIA==", + "dev": true + }, "@types/q": { "version": "1.5.4", "resolved": "https://registry.npm.taobao.org/@types/q/download/@types/q-1.5.4.tgz", @@ -4906,6 +4924,297 @@ "integrity": "sha1-gIyfp+RRcnTtVV+hWPLeS09GjnE=", "dev": true }, + "@typescript-eslint/eslint-plugin": { + "version": "4.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.33.0.tgz", + "integrity": "sha512-aINiAxGVdOl1eJyVjaWn/YcVAq4Gi/Yo35qHGCnqbWVz61g39D0h23veY/MA0rFFGfxK7TySg2uwDeNv+JgVpg==", + "dev": true, + "requires": { + "@typescript-eslint/experimental-utils": "4.33.0", + "@typescript-eslint/scope-manager": "4.33.0", + "debug": "^4.3.1", + "functional-red-black-tree": "^1.0.1", + "ignore": "^5.1.8", + "regexpp": "^3.1.0", + "semver": "^7.3.5", + "tsutils": "^3.21.0" + }, + "dependencies": { + "ignore": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.0.tgz", + "integrity": "sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg==", + "dev": true + }, + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + }, + "semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + } + } + }, + "@typescript-eslint/experimental-utils": { + "version": "4.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.33.0.tgz", + "integrity": "sha512-zeQjOoES5JFjTnAhI5QY7ZviczMzDptls15GFsI6jyUOq0kOf9+WonkhtlIhh0RgHRnqj5gdNxW5j1EvAyYg6Q==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.7", + "@typescript-eslint/scope-manager": "4.33.0", + "@typescript-eslint/types": "4.33.0", + "@typescript-eslint/typescript-estree": "4.33.0", + "eslint-scope": "^5.1.1", + "eslint-utils": "^3.0.0" + }, + "dependencies": { + "eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "requires": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + } + }, + "eslint-utils": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", + "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^2.0.0" + } + }, + "eslint-visitor-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", + "dev": true + } + } + }, + "@typescript-eslint/parser": { + "version": "4.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.33.0.tgz", + "integrity": "sha512-ZohdsbXadjGBSK0/r+d87X0SBmKzOq4/S5nzK6SBgJspFo9/CUDJ7hjayuze+JK7CZQLDMroqytp7pOcFKTxZA==", + "dev": true, + "requires": { + "@typescript-eslint/scope-manager": "4.33.0", + "@typescript-eslint/types": "4.33.0", + "@typescript-eslint/typescript-estree": "4.33.0", + "debug": "^4.3.1" + } + }, + "@typescript-eslint/scope-manager": { + "version": "4.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.33.0.tgz", + "integrity": "sha512-5IfJHpgTsTZuONKbODctL4kKuQje/bzBRkwHE8UOZ4f89Zeddg+EGZs8PD8NcN4LdM3ygHWYB3ukPAYjvl/qbQ==", + "dev": true, + "requires": { + "@typescript-eslint/types": "4.33.0", + "@typescript-eslint/visitor-keys": "4.33.0" + } + }, + "@typescript-eslint/types": { + "version": "4.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.33.0.tgz", + "integrity": "sha512-zKp7CjQzLQImXEpLt2BUw1tvOMPfNoTAfb8l51evhYbOEEzdWyQNmHWWGPR6hwKJDAi+1VXSBmnhL9kyVTTOuQ==", + "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "4.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.33.0.tgz", + "integrity": "sha512-rkWRY1MPFzjwnEVHsxGemDzqqddw2QbTJlICPD9p9I9LfsO8fdmfQPOX3uKfUaGRDFJbfrtm/sXhVXN4E+bzCA==", + "dev": true, + "requires": { + "@typescript-eslint/types": "4.33.0", + "@typescript-eslint/visitor-keys": "4.33.0", + "debug": "^4.3.1", + "globby": "^11.0.3", + "is-glob": "^4.0.1", + "semver": "^7.3.5", + "tsutils": "^3.21.0" + }, + "dependencies": { + "@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true + }, + "array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "dir-glob": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dev": true, + "requires": { + "path-type": "^4.0.0" + } + }, + "fast-glob": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", + "dev": true, + "requires": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + } + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "globby": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", + "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", + "dev": true, + "requires": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.9", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^3.0.0" + } + }, + "ignore": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.0.tgz", + "integrity": "sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg==", + "dev": true + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + }, + "micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dev": true, + "requires": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + } + }, + "path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true + }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + }, + "semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + }, + "slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + } + } + }, + "@typescript-eslint/visitor-keys": { + "version": "4.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.33.0.tgz", + "integrity": "sha512-uqi/2aSz9g2ftcHWf8uLPJA70rUv6yuMW5Bohw+bwcuzaxQIHaKFZCKGoGXIrc9vkTJ3+0txM73K0Hq3d5wgIg==", + "dev": true, + "requires": { + "@typescript-eslint/types": "4.33.0", + "eslint-visitor-keys": "^2.0.0" + }, + "dependencies": { + "eslint-visitor-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", + "dev": true + } + } + }, "@vue/babel-helper-vue-jsx-merge-props": { "version": "1.2.1", "resolved": "https://registry.npm.taobao.org/@vue/babel-helper-vue-jsx-merge-props/download/@vue/babel-helper-vue-jsx-merge-props-1.2.1.tgz", @@ -5215,6 +5524,63 @@ "integrity": "sha1-/q7SVZc9LndVW4PbwIhRpsY1IPo=", "dev": true }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "optional": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "optional": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "optional": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "optional": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "optional": true + }, + "loader-utils": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.4.tgz", + "integrity": "sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==", + "dev": true, + "optional": true, + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^2.1.2" + } + }, "ssri": { "version": "8.0.1", "resolved": "https://registry.npm.taobao.org/ssri/download/ssri-8.0.1.tgz?cache=0&sync_timestamp=1617826339976&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fssri%2Fdownload%2Fssri-8.0.1.tgz", @@ -5223,6 +5589,28 @@ "requires": { "minipass": "^3.1.1" } + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "optional": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "vue-loader-v16": { + "version": "npm:vue-loader@16.8.3", + "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.8.3.tgz", + "integrity": "sha512-7vKN45IxsKxe5GcVCbc2qFU5aWzyiLrYJyUuMz4BQLKctCj/fmCa0w6fGiiQ2cLFetNcek1ppGJQDCup0c1hpA==", + "dev": true, + "optional": true, + "requires": { + "chalk": "^4.1.0", + "hash-sum": "^2.0.0", + "loader-utils": "^2.0.0" + } } } }, @@ -18672,6 +19060,15 @@ "integrity": "sha1-zy04vcNKE0vK8QkcQfZhni9nLQA=", "dev": true }, + "tsutils": { + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", + "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + }, "tty": { "version": "1.0.1", "resolved": "https://registry.npm.taobao.org/tty/download/tty-1.0.1.tgz", @@ -18739,6 +19136,12 @@ "is-typedarray": "^1.0.0" } }, + "typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "dev": true + }, "ua-parser-js": { "version": "0.7.28", "resolved": "https://registry.npm.taobao.org/ua-parser-js/download/ua-parser-js-0.7.28.tgz?cache=0&sync_timestamp=1618065908450&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fua-parser-js%2Fdownload%2Fua-parser-js-0.7.28.tgz", @@ -19669,87 +20072,6 @@ } } }, - "vue-loader-v16": { - "version": "npm:vue-loader@16.8.3", - "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.8.3.tgz", - "integrity": "sha512-7vKN45IxsKxe5GcVCbc2qFU5aWzyiLrYJyUuMz4BQLKctCj/fmCa0w6fGiiQ2cLFetNcek1ppGJQDCup0c1hpA==", - "dev": true, - "optional": true, - "requires": { - "chalk": "^4.1.0", - "hash-sum": "^2.0.0", - "loader-utils": "^2.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "optional": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "optional": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "optional": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true, - "optional": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "optional": true - }, - "loader-utils": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.4.tgz", - "integrity": "sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==", - "dev": true, - "optional": true, - "requires": { - "big.js": "^5.2.2", - "emojis-list": "^3.0.0", - "json5": "^2.1.2" - } - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "optional": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, "vue-mixpanel": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/vue-mixpanel/-/vue-mixpanel-1.0.7.tgz", diff --git a/package.json b/package.json index 47ec177..82f1922 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,10 @@ "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", + "compile": "tsc && prettier ./src/**/*.js --write", "lint": "vue-cli-service lint", "excel": "office-addin-debugging start public/manifest.xml", - "excel:web": "office-addin-debugging start public/manifest.xml web --document https://skfn3-my.sharepoint.com/:x:/r/personal/connorisadmin_skfn3_onmicrosoft_com/_layouts/15/Doc.aspx?sourcedoc=%7B46999CFC-9B5A-4716-9F71-FECAEA59A6E8%7D", + "excel:web": "office-addin-debugging start public/manifest.xml web --document https://v2k0p-my.sharepoint.com/:x:/r/personal/connor_v2k0p_onmicrosoft_com/_layouts/15/Doc.aspx?sourcedoc=%7B101920A4-0AEA-4E82-B0E5-36E3162F7E86%7D&file=signalisation-permanente.xlsx&action=default&mobileredirect=true&DefaultItemOpen=1&ct=1705007910553&wdOrigin=OFFICECOM-WEB.MAIN.REC&cid=634f97aa-c5a2-411a-a705-412dc57eaaf7&wdPreviousSessionSrc=HarmonyWeb&wdPreviousSession=96a3ad12-6cd0-44ee-bf8b-c523c706e44e", "excel:web2": "office-addin-debugging start public/manifest.xml web --document https://teocomi-my.sharepoint.com/:x:/g/personal/teocomi_teocomi_onmicrosoft_com/EdxKPPFhnMdDoGclr4J-xJABLf-Ao6CJ902W95kcFPL2fA?e=mD0B8a", "excel:prod": "office-addin-debugging start public/manifest-prod.xml", "excel:web-prod": "office-addin-debugging start public/manifest-prod.xml web --document https://teocomi-my.sharepoint.com/:x:/g/personal/teocomi_teocomi_onmicrosoft_com/EdxKPPFhnMdDoGclr4J-xJAB7H6-TRJ5s5ZnXzVdrdFyUg?e=VAFmBN", @@ -34,6 +35,11 @@ }, "devDependencies": { "@babel/eslint-parser": "^7.14.3", + "@types/crypto-js": "^4.2.1", + "@types/office-js": "^1.0.364", + "@types/office-runtime": "^1.0.35", + "@typescript-eslint/eslint-plugin": "^4.33.0", + "@typescript-eslint/parser": "^4.33.0", "@vue/cli-plugin-babel": "~4.5.13", "@vue/cli-plugin-eslint": "~4.5.13", "@vue/cli-plugin-router": "^4.5.13", @@ -52,6 +58,7 @@ "prettier": "^2.2.1", "sass": "^1.32.0", "sass-loader": "^10.0.0", + "typescript": "^4.9.5", "vue-cli-plugin-apollo": "~0.22.2", "vue-cli-plugin-vuetify": "~2.4.0", "vue-template-compiler": "^2.6.11", @@ -61,5 +68,8 @@ "> 1%", "last 2 versions", "not dead" - ] + ], + "engines": { + "node": ">=14.0.0 <15.0.0" + } } diff --git a/src/components/ObjectSimpleViewer.vue b/src/components/ObjectSimpleViewer.vue index 4bc14f1..01c69b6 100644 --- a/src/components/ObjectSimpleViewer.vue +++ b/src/components/ObjectSimpleViewer.vue @@ -55,8 +55,7 @@ export default { }, props: { value: { - type: Object, - default: () => {} + type: Object }, streamId: { type: String, diff --git a/src/plugins/BaseObjectSerializer.js b/src/plugins/BaseObjectSerializer.js new file mode 100644 index 0000000..762dc48 --- /dev/null +++ b/src/plugins/BaseObjectSerializer.js @@ -0,0 +1,131 @@ +'use strict' +Object.defineProperty(exports, '__esModule', { value: true }) +exports.SerializedBase = exports.ObjectReference = exports.DataChunk = exports.BaseObjectSerializer = void 0 +/* eslint-disable @typescript-eslint/ban-types */ +const crypto_js_1 = require('crypto-js') +/** + * Serializer for Speckle objects written in Typescript + */ +class BaseObjectSerializer { + constructor(transports) { + this.transports = transports + } + async SerializeBase(object) { + return await this.SerializeBaseWithClosures(object, []) + } + async SerializeBaseWithClosures(object, closures) { + const thisClosure = new Map() + closures.push(thisClosure) + const converted = await this.PreserializeEachObjectProperty(object, closures) + let json = this.SerializeMap(converted) + const id = this.GetId(json) + converted.set('id', id) + this.AddSelfToParentClosures(id, closures) + if (thisClosure.size > 0) { + converted.set('__closure', Object.fromEntries(thisClosure)) + } + converted.set('totalChildrenCount', thisClosure.size) + json = this.SerializeMap(converted) + await this.StoreObject(id, converted) + return new SerializedBase(id, json) + } + async PreserializeObject(object, closures) { + if (!(object instanceof Object) || object instanceof String) { + return object + } + if (object instanceof DataChunk) { + const serialized = await this.SerializeBaseWithClosures(object, [...closures]) + return new ObjectReference(serialized.id) + } + if (object instanceof Array) { + // chunk array into 5000 by default + const chunkSize = 5000 + if (object.length > chunkSize) { + let serializedCount = 0 + const data = new Array() + while (serializedCount < object.length) { + const dataChunkCount = Math.min(chunkSize, object.length - serializedCount) + data.push(new DataChunk(object.slice(serializedCount, serializedCount + dataChunkCount))) + serializedCount += dataChunkCount + } + return await this.PreserializeObject(data, closures) + } + const convertedList = new Array() + for (const element of object) { + convertedList.push(await this.PreserializeObject(element, closures)) + } + return convertedList + } + if (object instanceof Object) { + return Object.fromEntries(await this.PreserializeEachObjectProperty(object, closures)) + } + throw new Error(`Cannot serialize object ${object}`) + } + async PreserializeEachObjectProperty(o, closures) { + const converted = new Map() + for (const key of Object.keys(o)) { + const objKey = key + converted.set( + BaseObjectSerializer.CleanKey(key), + await this.PreserializeObject(o[objKey], closures) + ) + } + return converted + } + static CleanKey(originalKey) { + const newStringChars = [] + for (let i = 0; i < originalKey.length; i++) { + if (i == 1 && originalKey[i] == '@' && originalKey[0] == '@') { + continue + } + if (this.disallowedCharacters.includes(originalKey[i])) { + continue + } + newStringChars.push(originalKey[i]) + } + return newStringChars.join('') + } + async StoreObject(objectId, object) { + for (const transport of this.transports) { + await transport.SaveObject(objectId, object) + } + } + SerializeMap(map) { + return JSON.stringify(Object.fromEntries(map)) + } + GetId(json) { + return (0, crypto_js_1.MD5)(json).toString(crypto_js_1.enc.Hex) + } + AddSelfToParentClosures(objectId, closureTables) { + // only go to closureTable length - 1 because the last closure table belongs to the object with the + // provided id + const parentClosureTablesCount = closureTables.length - 1 + for (let parentLevel = 0; parentLevel < parentClosureTablesCount; parentLevel++) { + const childDepth = parentClosureTablesCount - parentLevel + closureTables[parentLevel].set(objectId, childDepth) + } + } +} +exports.BaseObjectSerializer = BaseObjectSerializer +BaseObjectSerializer.disallowedCharacters = ['.', '/'] +class DataChunk { + constructor(data) { + this.speckle_type = 'Speckle.Core.Models.DataChunk' + this.data = data ?? [] + } +} +exports.DataChunk = DataChunk +class ObjectReference { + constructor(referencedId) { + this.referencedId = referencedId + this.speckle_type = 'reference' + } +} +exports.ObjectReference = ObjectReference +class SerializedBase { + constructor(id, json) { + this.id = id + this.json = json + } +} +exports.SerializedBase = SerializedBase diff --git a/src/plugins/BaseObjectSerializer.ts b/src/plugins/BaseObjectSerializer.ts new file mode 100644 index 0000000..cec7e1d --- /dev/null +++ b/src/plugins/BaseObjectSerializer.ts @@ -0,0 +1,158 @@ +/* eslint-disable @typescript-eslint/ban-types */ +import { MD5, enc } from 'crypto-js' + +/** + * Serializer for Speckle objects written in Typescript + */ +export class BaseObjectSerializer { + constructor(public transports: ITransport[]) {} + + public async SerializeBase(object: object): Promise { + return await this.SerializeBaseWithClosures(object, []) + } + + private async SerializeBaseWithClosures(object: object, closures: Array>) { + const thisClosure = new Map() + closures.push(thisClosure) + + const converted = await this.PreserializeEachObjectProperty(object, closures) + let json = this.SerializeMap(converted) + const id = this.GetId(json) + converted.set('id', id) + + this.AddSelfToParentClosures(id, closures) + if (thisClosure.size > 0) { + converted.set('__closure', Object.fromEntries(thisClosure)) + } + converted.set('totalChildrenCount', thisClosure.size) + + json = this.SerializeMap(converted) + await this.StoreObject(id, converted) + return new SerializedBase(id, json) + } + + private async PreserializeObject( + object: any, + closures: Array> + ): Promise { + if (!(object instanceof Object) || object instanceof String) { + return object + } + + if (object instanceof DataChunk) { + const serialized = await this.SerializeBaseWithClosures(object, [...closures]) + return new ObjectReference(serialized.id) + } + + if (object instanceof Array) { + // chunk array into 5000 by default + const chunkSize = 5000 + if (object.length > chunkSize) { + let serializedCount = 0 + const data = new Array() + while (serializedCount < object.length) { + const dataChunkCount = Math.min(chunkSize, object.length - serializedCount) + data.push(new DataChunk(object.slice(serializedCount, serializedCount + dataChunkCount))) + serializedCount += dataChunkCount + } + return await this.PreserializeObject(data, closures) + } + + const convertedList = new Array() + for (const element of object) { + convertedList.push(await this.PreserializeObject(element, closures)) + } + return convertedList + } + + if (object instanceof Object) { + return Object.fromEntries(await this.PreserializeEachObjectProperty(object, closures)) + } + + throw new Error(`Cannot serialize object ${object}`) + } + + private async PreserializeEachObjectProperty( + o: object, + closures: Array> + ): Promise> { + const converted = new Map() + + for (const key of Object.keys(o)) { + const objKey = key as keyof object + converted.set( + BaseObjectSerializer.CleanKey(key), + await this.PreserializeObject(o[objKey], closures) + ) + } + + return converted + } + + private static disallowedCharacters: string[] = ['.', '/'] + private static CleanKey(originalKey: string): string { + const newStringChars = [] + for (let i = 0; i < originalKey.length; i++) { + if (i == 1 && originalKey[i] == '@' && originalKey[0] == '@') { + continue + } + if (this.disallowedCharacters.includes(originalKey[i])) { + continue + } + + newStringChars.push(originalKey[i]) + } + return newStringChars.join('') + } + + private async StoreObject(objectId: string, object: Map) { + for (const transport of this.transports) { + await transport.SaveObject(objectId, object) + } + } + + private SerializeMap(map: Map): string { + return JSON.stringify(Object.fromEntries(map)) + } + + private GetId(json: string): string { + return MD5(json).toString(enc.Hex) + } + + private AddSelfToParentClosures(objectId: string, closureTables: Array>) { + // only go to closureTable length - 1 because the last closure table belongs to the object with the + // provided id + const parentClosureTablesCount = closureTables.length - 1 + + for (let parentLevel = 0; parentLevel < parentClosureTablesCount; parentLevel++) { + const childDepth = parentClosureTablesCount - parentLevel + closureTables[parentLevel].set(objectId, childDepth) + } + } +} + +export class DataChunk implements IBase { + public speckle_type = 'Speckle.Core.Models.DataChunk' + public data: any[] + constructor(data: any[] | null) { + this.data = data ?? [] + } +} + +export class ObjectReference implements IBase { + public speckle_type = 'reference' + + constructor(public referencedId: string) {} +} + +export interface IBase { + readonly speckle_type: string +} + +export interface ITransport { + SaveObject(id: string, object: Map): Promise +} + +export class SerializedBase { + constructor(public id: string, public json: string) {} +} diff --git a/src/plugins/ExcelSheetDataRetreiver.js b/src/plugins/ExcelSheetDataRetreiver.js new file mode 100644 index 0000000..1a535b7 --- /dev/null +++ b/src/plugins/ExcelSheetDataRetreiver.js @@ -0,0 +1,33 @@ +'use strict' +Object.defineProperty(exports, '__esModule', { value: true }) +exports.ExcelSheetDataRetriever = void 0 +class ExcelSheetDataRetriever { + // Takes address as a string formatted like this 'Sheet1!A1:B4' and returns a 2d array of values. + // This queries the document in batches in order to avoid api errors about requests that are too large + static async GetValuesAsNestedList(context, address) { + const sheetName = address.split('!')[0].replace(/'/g, '') + const rangeAddress = address.split('!')[1] + const sheet = context.workbook.worksheets.getItem(sheetName) + const totalRange = sheet.getRange(rangeAddress) + totalRange.load('columnCount, columnIndex, rowCount, rowIndex') + await context.sync() + let numRowsRetrieved = 0 + const chunkSize = 5000 + let values = [] + while (numRowsRetrieved < totalRange.rowCount) { + const numRowsToRetrieve = Math.min(chunkSize, totalRange.rowCount - numRowsRetrieved) + const currentRange = sheet.getRangeByIndexes( + totalRange.rowIndex + numRowsRetrieved, + totalRange.columnIndex, + numRowsToRetrieve, + totalRange.columnCount + ) + currentRange.load('values') + await context.sync() + values = values.concat(currentRange.values) + numRowsRetrieved += numRowsToRetrieve + } + return values + } +} +exports.ExcelSheetDataRetriever = ExcelSheetDataRetriever diff --git a/src/plugins/ExcelSheetDataRetreiver.ts b/src/plugins/ExcelSheetDataRetreiver.ts new file mode 100644 index 0000000..c81d190 --- /dev/null +++ b/src/plugins/ExcelSheetDataRetreiver.ts @@ -0,0 +1,37 @@ +export class ExcelSheetDataRetriever { + // Takes address as a string formatted like this 'Sheet1!A1:B4' and returns a 2d array of values. + // This queries the document in batches in order to avoid api errors about requests that are too large + static async GetValuesAsNestedList( + context: Excel.RequestContext, + address: string + ): Promise { + const sheetName = address.split('!')[0].replace(/'/g, '') + const rangeAddress = address.split('!')[1] + const sheet = context.workbook.worksheets.getItem(sheetName) + + const totalRange = sheet.getRange(rangeAddress) + totalRange.load('columnCount, columnIndex, rowCount, rowIndex') + await context.sync() + + let numRowsRetrieved = 0 + const chunkSize = 5000 + let values: any[][] = [] + + while (numRowsRetrieved < totalRange.rowCount) { + const numRowsToRetrieve = Math.min(chunkSize, totalRange.rowCount - numRowsRetrieved) + const currentRange = sheet.getRangeByIndexes( + totalRange.rowIndex + numRowsRetrieved, + totalRange.columnIndex, + numRowsToRetrieve, + totalRange.columnCount + ) + currentRange.load('values') + await context.sync() + values = values.concat(currentRange.values) + + numRowsRetrieved += numRowsToRetrieve + } + + return values + } +} diff --git a/src/plugins/ServerTransport.js b/src/plugins/ServerTransport.js new file mode 100644 index 0000000..ee2e0eb --- /dev/null +++ b/src/plugins/ServerTransport.js @@ -0,0 +1,57 @@ +'use strict' +Object.defineProperty(exports, '__esModule', { value: true }) +exports.ServerTransport = void 0 +class ServerTransport { + /** + * + */ + constructor(serverUrl, token, streamId) { + this.serverUrl = serverUrl + this.token = token + this.streamId = streamId + } + async SaveObject(id, map) { + const query = `mutation objectCreate ($object: ObjectCreateInput!) {objectCreate(objectInput: $object)}` + await fetch(`${this.serverUrl}/graphql`, { + method: 'POST', + headers: { + Authorization: 'Bearer ' + this.token, + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + query: query, + variables: { + object: { + streamId: this.streamId, + objects: [Object.fromEntries(map)] + } + } + }) + }) + // const data = (await response.json()) as any + } + async CreateCommit(branchName, objectId, message) { + const query = `mutation commitCreate($myCommit: CommitCreateInput!){ commitCreate(commit: $myCommit)}` + await fetch(`${this.serverUrl}/graphql`, { + method: 'POST', + headers: { + Authorization: 'Bearer ' + this.token, + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + query: query, + variables: { + myCommit: { + streamId: this.streamId, + branchName: branchName, + objectId: objectId, + message: message ? message : 'Data from Excel', + sourceApplication: 'excel' + } + } + }) + }) + // const data = (await response.json()) as any + } +} +exports.ServerTransport = ServerTransport diff --git a/src/plugins/ServerTransport.ts b/src/plugins/ServerTransport.ts new file mode 100644 index 0000000..24d3a03 --- /dev/null +++ b/src/plugins/ServerTransport.ts @@ -0,0 +1,57 @@ +import { ITransport } from './BaseObjectSerializer' + +export class ServerTransport implements ITransport { + /** + * + */ + constructor(private serverUrl: string, private token: string, private streamId: string) {} + + async SaveObject(id: string, map: Map): Promise { + const query = `mutation objectCreate ($object: ObjectCreateInput!) {objectCreate(objectInput: $object)}` + + await fetch(`${this.serverUrl}/graphql`, { + method: 'POST', + headers: { + Authorization: 'Bearer ' + this.token, + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + query: query, + variables: { + object: { + streamId: this.streamId, + objects: [Object.fromEntries(map)] + } + } + }) + }) + + // const data = (await response.json()) as any + } + + async CreateCommit(branchName: string, objectId: string, message: string | null) { + const query = `mutation commitCreate($myCommit: CommitCreateInput!){ commitCreate(commit: $myCommit)}` + + await fetch(`${this.serverUrl}/graphql`, { + method: 'POST', + headers: { + Authorization: 'Bearer ' + this.token, + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + query: query, + variables: { + myCommit: { + streamId: this.streamId, + branchName: branchName, + objectId: objectId, + message: message ? message : 'Data from Excel', + sourceApplication: 'excel' + } + } + }) + }) + + // const data = (await response.json()) as any + } +} diff --git a/src/plugins/excel.js b/src/plugins/excel.js index 6dcc944..4eb0aaa 100644 --- a/src/plugins/excel.js +++ b/src/plugins/excel.js @@ -11,6 +11,7 @@ import { onTableChanged, onTableDeleted } from './dataTable.js' +import { ExcelSheetDataRetriever } from './ExcelSheetDataRetreiver.js' const unflatten = require('flat').unflatten @@ -668,11 +669,12 @@ export async function send(savedStream, streamId, branchName, message) { let sheetName = savedStream.selection.split('!')[0].replace(/'/g, '') let rangeAddress = savedStream.selection.split('!')[1] let sheet = context.workbook.worksheets.getItem(sheetName) - let range = sheet.getRange(rangeAddress) - range.load('values') - await context.sync() - let values = range.values + + let values = await ExcelSheetDataRetriever.GetValuesAsNestedList( + context, + savedStream.selection + ) let data = [] // check for specific conversion diff --git a/src/store/index.js b/src/store/index.js index e3a890d..a0380cb 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -6,6 +6,8 @@ import ObjectLoader from '@speckle/objectloader' import streamsModule from './streams' import userModule from './user' import router from '../router' +import { BaseObjectSerializer } from '../plugins/BaseObjectSerializer' +import { ServerTransport } from '../plugins/ServerTransport' const xml2js = require('xml2js') @@ -193,51 +195,14 @@ export default new Vuex.Store({ } }, async createCommit(context, { streamId, branchName, message, object }) { - let query = `mutation objectCreate ($object: ObjectCreateInput!) {objectCreate(objectInput: $object)}` - let serverUrl = localStorage.getItem('serverUrl') let token = localStorage.getItem(TOKEN) - let response = await fetch(`${serverUrl}/graphql`, { - method: 'POST', - headers: { - Authorization: 'Bearer ' + token, - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ - query: query, - variables: { - object: { - streamId: streamId, - objects: [object] - } - } - }) - }) - let data = await response.json() - let objectId = data.data.objectCreate[0] + const serverTransport = new ServerTransport(serverUrl, token, streamId) + const serializer = new BaseObjectSerializer([serverTransport]) + const serialized = await serializer.SerializeBase(object) - query = `mutation commitCreate($myCommit: CommitCreateInput!){ commitCreate(commit: $myCommit)}` - - response = await fetch(`${serverUrl}/graphql`, { - method: 'POST', - headers: { - Authorization: 'Bearer ' + token, - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ - query: query, - variables: { - myCommit: { - streamId: streamId, - branchName: branchName, - objectId: objectId, - message: message ? message : 'Data from Excel', - sourceApplication: 'excel' - } - } - }) - }) + await serverTransport.CreateCommit(branchName, serialized.id, message) }, async receiveCommit(context, { sourceApplication, streamId, commitId, message }) { let query = `mutation objectReceive ($myInput:CommitReceivedInput!) {commitReceive(input:$myInput)}` diff --git a/src/views/Login.vue b/src/views/Login.vue index f42eab3..7aa287b 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -53,8 +53,6 @@ export default { 'URL must be valid, with no trailing slash' ] }), - mounted() {}, - methods: { async login() { //when for is not visible (coming from web) don't validate diff --git a/src/views/SingleStream.vue b/src/views/SingleStream.vue index c184341..879cbe2 100644 --- a/src/views/SingleStream.vue +++ b/src/views/SingleStream.vue @@ -423,7 +423,7 @@ export default { speckleIdRange.load('text') await context.sync() - let idsInViewer = new Array() + let idsInViewer = [] for (let i = 0; i < speckleIdRange.text?.length; i++) { for (let j = 0; j < speckleIdRange.text[i].length; j++) { if (speckleIdRange.text[i][j].length < 32) continue diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..45d5c25 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,109 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "es2021" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + + /* Modules */ + "module": "commonjs" /* Specify what module code is generated. */, + // "rootDir": "./", /* Specify the root folder within your source files. */ + // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + // "allowJs": true /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */, + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + // "outDir": "./", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, + + /* Type Checking */ + "strict": true /* Enable all strict type-checking options. */, + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + } +}