Browse Source

fix: nested insert correction in belongs to

re #2228

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/2237/head
Pranav C 3 years ago
parent
commit
aaf3fb52c5
  1. 25
      packages/nc-gui/components/project/spreadsheet/public/XcForm.vue
  2. 30
      packages/noco-docs/content/en/setup-and-usages/usage-information.md
  3. 294
      packages/nocodb/package-lock.json
  4. 2
      packages/nocodb/package.json
  5. 4
      packages/nocodb/src/lib/Noco.ts
  6. 2
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts
  7. 23
      packages/nocodb/src/lib/meta/api/publicApis/publicMetaApis.ts
  8. 7
      packages/nocodb/src/lib/models/Project.ts
  9. 3
      packages/nocodb/src/lib/models/User.ts
  10. 47
      packages/nocodb/src/lib/utils/getInstance.ts
  11. 3
      packages/nocodb/src/lib/utils/globals.ts

25
packages/nc-gui/components/project/spreadsheet/public/XcForm.vue

@ -128,18 +128,6 @@
>
Field is required.
</div>
<!-- todo: optimize -->
<template
v-if="col.bt && $v.localState && $v.localState.$dirty && $v.localState[meta.columns.find(c => c.column_name === col.bt.column_name).title]"
>
<div
v-if="!$v.localState[meta.columns.find(c => c.column_name === col.bt.column_name).title].required"
class="error--text caption"
>
Field is required.
</div>
</template>
</div>
<template v-else>
<div
@ -270,6 +258,17 @@ export default {
},
computed: {
btColumnsRefs() {
return (this.columns || []).reduce((aggObj, column) => {
if (column.uidt === UITypes.LinkToAnotherRecord && column.colOptions && column.colOptions.type === RelationTypes.BELONGS_TO) {
const col = this.meta.columns.find(c => c.id === column.colOptions.fk_child_column_id)
aggObj[column.title] = col
}
return aggObj
}, {})
},
sqlUiLoc() {
// todo: replace with correct client
return this.client && SqlUiFactory.create({ client: this.client })
@ -376,7 +375,7 @@ export default {
const col = this.meta.columns.find(c => c.id === column.colOptions.fk_child_column_id)
if ((col && col.rqd && !col.cdf) || column.required) {
obj.localState[column.title] = { required }
if (col) { obj.virtual[column.title] = { required } }
}
} else if (isVirtualCol(column) && column.required) {
obj.virtual[column.title] = {

30
packages/noco-docs/content/en/setup-and-usages/usage-information.md

@ -26,44 +26,22 @@ However, these above actions alone are often insufficient
## What we collect ?
We collect actions made on models (project, table, view, sharedView, user, hook, image, sharedBase etc) periodically with :
- Unique machine ID (generated with node-machine-id)
- Environment (dev, staging, production)
- System information (OS, node version, docker or npm)
- Environment (dev, staging, production)
- Instance information (Unique machine ID, database type, count of projects and users)
- Failures.
Here is an example :
```
{
"machine_id" : "a0885e8e6a38d9fbb5d39e7d04a44da7773d4f",
"evt_type": "project:created"
"package_id" : "0.84.15",
"os_type" : "Linux",
"os_platform" : "linux",
"os_release" : "5.10.25-linuxkit",
"node_version" : "14.18.2",
"docker" : "true",
"xc_version" : "a0885e8e6a38d9fbb5d39e7d04a44da7773d4f",
"env" : "dev",
}
```
Our UI Dashboard is a Vuejs-Nuxtjs app. Actions taken on UI with completely anonymized route names are sent as payload.
Here is an example :
```
{
"id": "a0885e8e6a38d9fbb5d39e7d04a44da7773d4f",
"event": "table:create",
"path": "/nc/:project_id",
}
```
## What we DO NOT collect ?
We do not collect any private or sensitive information, such as:
- Personally identifiable information
- Credential information (endpoints, ports, DB connections, username/password)
- User data
- Database/User data
## Opt-out

294
packages/nocodb/package-lock.json generated

@ -69,7 +69,7 @@
"mysql2": "^2.2.5",
"nanoid": "^3.1.20",
"nc-common": "0.0.6",
"nc-help": "0.2.59",
"nc-help": "0.2.60",
"nc-lib-gui": "0.91.7",
"nc-plugin": "0.1.2",
"ncp": "^2.0.0",
@ -154,6 +154,81 @@
"node": ">=8.9"
}
},
"../../../xc-lib-private": {
"name": "nc-help",
"version": "0.0.2",
"extraneous": true,
"license": "AGPL-3.0-or-later",
"dependencies": {
"@rudderstack/rudder-sdk-node": "^1.1.3",
"axios": "^0.21.1",
"boxen": "^4.2.0",
"colors": "1.4.0",
"dayjs": "^1.8.32",
"debug": "^4.1.1",
"ejs": "^3.1.3",
"emittery": "^0.7.1",
"faker": "^4.1.0",
"fast-levenshtein": "^2.0.6",
"fs-extra": "^9.0.1",
"glob": "^7.1.6",
"handlebars": "^4.7.6",
"import-fresh": "^3.2.1",
"inflection": "^1.12.0",
"is-docker": "^2.1.1",
"js-beautify": "^1.11.0",
"json5": "^2.1.3",
"jsonfile": "^6.1.0",
"knex": "^0.21.2",
"lodash": "^4.17.19",
"md5": "^2.2.1",
"mkdirp": "^0.5.1",
"mssql": "^6.2.0",
"mysql2": "^2.2.5",
"nanoid": "^3.1.22",
"pg": "^8.3.0",
"pkginfo": "^0.4.1",
"rmdir": "^1.2.0",
"sha.js": "^2.4.11",
"slash": "^3.0.0",
"sqlite3": "^5.0.0",
"ts-morph": "^7.1.2"
},
"devDependencies": {
"@bitjson/npm-scripts-info": "^1.0.0",
"@bitjson/typedoc": "^0.15.0-0",
"@istanbuljs/nyc-config-typescript": "^0.1.3",
"@types/inflection": "^1.5.28",
"ava": "2.2.0",
"codecov": "^3.5.0",
"copy-webpack-plugin": "^6.0.3",
"crypto-js": "^4.0.0",
"cz-conventional-changelog": "^2.1.0",
"declaration-bundler-webpack-plugin": "^1.0.3",
"gh-pages": "^2.0.1",
"node-machine-id": "^1.1.12",
"npm-run-all": "^4.1.5",
"nyc": "^14.1.1",
"open-cli": "^5.0.0",
"prettier": "^1.18.2",
"shelljs": "^0.8.4",
"standard-version": "^6.0.1",
"trash-cli": "^3.0.0",
"ts-loader": "^8.0.1",
"ts-node": "^8.10.2",
"tslint": "^5.18.0",
"tslint-config-prettier": "^1.18.0",
"tslint-immutable": "^6.0.1",
"typescript": "^3.5.3",
"webpack": "^4.44.2",
"webpack-cli": "^3.3.12",
"webpack-node-externals": "^2.5.0",
"webpack-obfuscator": "^1.7.0"
},
"engines": {
"node": ">=8.9"
}
},
"../nocodb-sdk": {
"version": "0.91.7",
"license": "MIT",
@ -1039,6 +1114,19 @@
"kuler": "^2.0.0"
}
},
"node_modules/@dsherret/to-absolute-glob": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/@dsherret/to-absolute-glob/-/to-absolute-glob-2.0.2.tgz",
"integrity": "sha512-InCaQ/KEOcFtAFztn47wadritBLP2nT6m/ucbBnIgI5YwxuMzKKCHtqazR2+D1yR6y1ZTnPea9aLFEUrTttUSQ==",
"peer": true,
"dependencies": {
"is-absolute": "^1.0.0",
"is-negated-glob": "^1.0.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/@eslint/eslintrc": {
"version": "0.4.3",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz",
@ -1290,7 +1378,6 @@
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
"integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==",
"dev": true,
"dependencies": {
"@nodelib/fs.stat": "2.0.5",
"run-parallel": "^1.1.9"
@ -1303,7 +1390,6 @@
"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,
"engines": {
"node": ">= 8"
}
@ -1312,7 +1398,6 @@
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz",
"integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==",
"dev": true,
"dependencies": {
"@nodelib/fs.scandir": "2.1.5",
"fastq": "^1.6.0"
@ -1742,6 +1827,33 @@
"node": ">= 10"
}
},
"node_modules/@ts-morph/common": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/@ts-morph/common/-/common-0.5.2.tgz",
"integrity": "sha512-eLmfYV6u6gUgHrB9QV9lpuWg3cD60mhXdv0jvM5exWR/Cor8HG+GziFIj2hPEWHJknqzuU4meZd8DTqIzZfDRQ==",
"peer": true,
"dependencies": {
"@dsherret/to-absolute-glob": "^2.0.2",
"fast-glob": "^3.2.2",
"fs-extra": "^9.0.0",
"is-negated-glob": "^1.0.0",
"multimatch": "^4.0.0",
"typescript": "~3.9.7"
}
},
"node_modules/@ts-morph/common/node_modules/typescript": {
"version": "3.9.10",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz",
"integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==",
"peer": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=4.2.0"
}
},
"node_modules/@types/body-parser": {
"version": "1.19.2",
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz",
@ -1854,8 +1966,7 @@
"node_modules/@types/minimatch": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz",
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==",
"dev": true
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
},
"node_modules/@types/minimist": {
"version": "1.2.2",
@ -2862,7 +2973,6 @@
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/array-differ/-/array-differ-3.0.0.tgz",
"integrity": "sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg==",
"dev": true,
"engines": {
"node": ">=8"
}
@ -2926,7 +3036,6 @@
"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,
"engines": {
"node": ">=8"
}
@ -5096,6 +5205,12 @@
"node": ">=0.10.0"
}
},
"node_modules/code-block-writer": {
"version": "10.1.1",
"resolved": "https://registry.npmjs.org/code-block-writer/-/code-block-writer-10.1.1.tgz",
"integrity": "sha512-67ueh2IRGst/51p0n6FvPrnRjAGHY5F8xdjkgrYE7DDzpJe6qA07RYQ9VcoUeo5ATOjSOiWpSL3SWBRRbempMw==",
"peer": true
},
"node_modules/code-excerpt": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/code-excerpt/-/code-excerpt-2.1.1.tgz",
@ -7673,7 +7788,7 @@
"node_modules/debuglog": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/debuglog/-/debuglog-1.0.1.tgz",
"integrity": "sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI=",
"integrity": "sha512-syBZ+rnAK3EgMsH2aYEOLUW7mZSY9Gb+0wUMCFsZvcmiz+HigA0LOcq/HoQqVuGG+EKykunc7QG2bzrponfaSw==",
"engines": {
"node": "*"
}
@ -9573,6 +9688,12 @@
],
"optional": true
},
"node_modules/faker": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/faker/-/faker-4.1.0.tgz",
"integrity": "sha512-ILKg69P6y/D8/wSmDXw35Ly0re8QzQ8pMfBCflsGiZG2ZjMUNLYNexA6lz5pkmJlepVdsiDFUxYAzPQ9/+iGLA==",
"peer": true
},
"node_modules/fast-deep-equal": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
@ -9589,7 +9710,6 @@
"version": "3.2.7",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.7.tgz",
"integrity": "sha512-rYGMRwip6lUMvYD3BTScMwT1HtAs2d71SMv66Vrxs0IekGZEjhM0pcMfjQPnknBt2zeCwQMEupiN02ZP4DiT1Q==",
"dev": true,
"dependencies": {
"@nodelib/fs.stat": "^2.0.2",
"@nodelib/fs.walk": "^1.2.3",
@ -9605,7 +9725,6 @@
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
"dev": true,
"dependencies": {
"fill-range": "^7.0.1"
},
@ -9617,7 +9736,6 @@
"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,
"dependencies": {
"to-regex-range": "^5.0.1"
},
@ -9629,7 +9747,6 @@
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true,
"engines": {
"node": ">=0.12.0"
}
@ -9638,7 +9755,6 @@
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz",
"integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==",
"dev": true,
"dependencies": {
"braces": "^3.0.1",
"picomatch": "^2.2.3"
@ -9651,7 +9767,6 @@
"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,
"dependencies": {
"is-number": "^7.0.0"
},
@ -9703,7 +9818,6 @@
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz",
"integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==",
"dev": true,
"dependencies": {
"reusify": "^1.0.4"
}
@ -11704,7 +11818,6 @@
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
"dev": true,
"dependencies": {
"is-glob": "^4.0.1"
},
@ -12913,6 +13026,15 @@
"node": ">=8"
}
},
"node_modules/is-negated-glob": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-negated-glob/-/is-negated-glob-1.0.0.tgz",
"integrity": "sha512-czXVVn/QEmgvej1f50BZ648vUI+em0xqMq2Sn+QncCLN4zj1UAxlT+kw/6ggQTOaZPd1HqKQGEqbpQVtJucWug==",
"peer": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-negative-zero": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz",
@ -13604,7 +13726,7 @@
"node_modules/join-component": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/join-component/-/join-component-1.1.0.tgz",
"integrity": "sha1-uEF7dQZho5K+4sJTfGiyqdSXfNU="
"integrity": "sha512-bF7vcQxbODoGK1imE2P9GS9aw4zD0Sd+Hni68IMZLj7zRnquH7dXUmMw9hDI5S/Jzt7q+IyTXN0rSg2GI0IKhQ=="
},
"node_modules/jquery": {
"version": "3.6.0",
@ -14716,7 +14838,6 @@
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",
"integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==",
"dev": true,
"engines": {
"node": ">= 8"
}
@ -15814,7 +15935,6 @@
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/multimatch/-/multimatch-4.0.0.tgz",
"integrity": "sha512-lDmx79y1z6i7RNx0ZGCPq1bzJ6ZoDDKbvh7jxr9SJcWLkShMzXrHbYVpTdnhNM5MXpDUxCQ4DgqVttVXlBgiBQ==",
"dev": true,
"dependencies": {
"@types/minimatch": "^3.0.3",
"array-differ": "^3.0.0",
@ -15944,9 +16064,9 @@
}
},
"node_modules/nc-help": {
"version": "0.2.59",
"resolved": "https://registry.npmjs.org/nc-help/-/nc-help-0.2.59.tgz",
"integrity": "sha512-tz1WzykP+3ga6aaiv+ZZkzUK/FgHj7Q/mqb6PSN6c6OwiYJDAA7+4JRc7cyVAWyr9t/6+NQxJsEnmd9tbKzI7w==",
"version": "0.2.60",
"resolved": "https://registry.npmjs.org/nc-help/-/nc-help-0.2.60.tgz",
"integrity": "sha512-D7tEV3pwJrhsk0t3ZPWtXl3446YkFbTZFA9hdxpYCGA8XyWrJgwClP2EXU0ne4FXEnTXIA/EwtpTiJtJCOdHbw==",
"dependencies": {
"@rudderstack/rudder-sdk-node": "^1.1.3",
"axios": "^0.21.1",
@ -18292,7 +18412,6 @@
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
"dev": true,
"engines": {
"node": ">=8.6"
},
@ -18535,7 +18654,7 @@
"node_modules/pkginfo": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.4.1.tgz",
"integrity": "sha1-tUGO8EOd5UJfxJlQQtztFPsqhP8=",
"integrity": "sha512-8xCNE/aT/EXKenuMDZ+xTVwkT8gsoHN2z/Q29l80u0ppGEXVvsKRzNMbtKhg8LS8k1tJLAHHylf6p4VFmP6XUQ==",
"engines": {
"node": ">= 0.4.0"
}
@ -18863,7 +18982,6 @@
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
"integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==",
"dev": true,
"funding": [
{
"type": "github",
@ -19507,7 +19625,6 @@
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz",
"integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==",
"dev": true,
"engines": {
"iojs": ">=1.0.0",
"node": ">=0.10.0"
@ -19562,7 +19679,6 @@
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
"integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==",
"dev": true,
"funding": [
{
"type": "github",
@ -22321,6 +22437,17 @@
"node": ">=8.0"
}
},
"node_modules/ts-morph": {
"version": "7.3.0",
"resolved": "https://registry.npmjs.org/ts-morph/-/ts-morph-7.3.0.tgz",
"integrity": "sha512-BUKSoz7AFSKPcYTZODbICW2mOthAN4vc5juD6FL1lD/dLwZ0WvrC3zqBM3/X6f5gHxq3yaz+HmanHGaWm0ddbQ==",
"peer": true,
"dependencies": {
"@dsherret/to-absolute-glob": "^2.0.2",
"@ts-morph/common": "~0.5.2",
"code-block-writer": "^10.1.0"
}
},
"node_modules/ts-node": {
"version": "8.10.2",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.10.2.tgz",
@ -25499,6 +25626,16 @@
"kuler": "^2.0.0"
}
},
"@dsherret/to-absolute-glob": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/@dsherret/to-absolute-glob/-/to-absolute-glob-2.0.2.tgz",
"integrity": "sha512-InCaQ/KEOcFtAFztn47wadritBLP2nT6m/ucbBnIgI5YwxuMzKKCHtqazR2+D1yR6y1ZTnPea9aLFEUrTttUSQ==",
"peer": true,
"requires": {
"is-absolute": "^1.0.0",
"is-negated-glob": "^1.0.0"
}
},
"@eslint/eslintrc": {
"version": "0.4.3",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz",
@ -25694,7 +25831,6 @@
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
"integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==",
"dev": true,
"requires": {
"@nodelib/fs.stat": "2.0.5",
"run-parallel": "^1.1.9"
@ -25703,14 +25839,12 @@
"@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
"integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A=="
},
"@nodelib/fs.walk": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz",
"integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==",
"dev": true,
"requires": {
"@nodelib/fs.scandir": "2.1.5",
"fastq": "^1.6.0"
@ -26064,6 +26198,28 @@
"resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz",
"integrity": "sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A=="
},
"@ts-morph/common": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/@ts-morph/common/-/common-0.5.2.tgz",
"integrity": "sha512-eLmfYV6u6gUgHrB9QV9lpuWg3cD60mhXdv0jvM5exWR/Cor8HG+GziFIj2hPEWHJknqzuU4meZd8DTqIzZfDRQ==",
"peer": true,
"requires": {
"@dsherret/to-absolute-glob": "^2.0.2",
"fast-glob": "^3.2.2",
"fs-extra": "^9.0.0",
"is-negated-glob": "^1.0.0",
"multimatch": "^4.0.0",
"typescript": "~3.9.7"
},
"dependencies": {
"typescript": {
"version": "3.9.10",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz",
"integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==",
"peer": true
}
}
},
"@types/body-parser": {
"version": "1.19.2",
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz",
@ -26176,8 +26332,7 @@
"@types/minimatch": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz",
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==",
"dev": true
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
},
"@types/minimist": {
"version": "1.2.2",
@ -27022,8 +27177,7 @@
"array-differ": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/array-differ/-/array-differ-3.0.0.tgz",
"integrity": "sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg==",
"dev": true
"integrity": "sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg=="
},
"array-each": {
"version": "1.0.1",
@ -27068,8 +27222,7 @@
"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
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw=="
},
"array-uniq": {
"version": "2.1.0",
@ -28807,6 +28960,12 @@
"resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.0.tgz",
"integrity": "sha512-2Nii8p3RwAPiFwsnZvukotvow2rIHM+yQ6ZcBXGHdniadkYGZYiGmkHJIbZPIV9nfv7m/U1IPMVVcAhoWFeklw=="
},
"code-block-writer": {
"version": "10.1.1",
"resolved": "https://registry.npmjs.org/code-block-writer/-/code-block-writer-10.1.1.tgz",
"integrity": "sha512-67ueh2IRGst/51p0n6FvPrnRjAGHY5F8xdjkgrYE7DDzpJe6qA07RYQ9VcoUeo5ATOjSOiWpSL3SWBRRbempMw==",
"peer": true
},
"code-excerpt": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/code-excerpt/-/code-excerpt-2.1.1.tgz",
@ -30840,7 +30999,7 @@
"debuglog": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/debuglog/-/debuglog-1.0.1.tgz",
"integrity": "sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI="
"integrity": "sha512-syBZ+rnAK3EgMsH2aYEOLUW7mZSY9Gb+0wUMCFsZvcmiz+HigA0LOcq/HoQqVuGG+EKykunc7QG2bzrponfaSw=="
},
"decamelize": {
"version": "1.2.0",
@ -32329,6 +32488,12 @@
"integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=",
"optional": true
},
"faker": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/faker/-/faker-4.1.0.tgz",
"integrity": "sha512-ILKg69P6y/D8/wSmDXw35Ly0re8QzQ8pMfBCflsGiZG2ZjMUNLYNexA6lz5pkmJlepVdsiDFUxYAzPQ9/+iGLA==",
"peer": true
},
"fast-deep-equal": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
@ -32345,7 +32510,6 @@
"version": "3.2.7",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.7.tgz",
"integrity": "sha512-rYGMRwip6lUMvYD3BTScMwT1HtAs2d71SMv66Vrxs0IekGZEjhM0pcMfjQPnknBt2zeCwQMEupiN02ZP4DiT1Q==",
"dev": true,
"requires": {
"@nodelib/fs.stat": "^2.0.2",
"@nodelib/fs.walk": "^1.2.3",
@ -32358,7 +32522,6 @@
"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"
}
@ -32367,7 +32530,6 @@
"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"
}
@ -32375,14 +32537,12 @@
"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
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="
},
"micromatch": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz",
"integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==",
"dev": true,
"requires": {
"braces": "^3.0.1",
"picomatch": "^2.2.3"
@ -32392,7 +32552,6 @@
"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"
}
@ -32436,7 +32595,6 @@
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz",
"integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==",
"dev": true,
"requires": {
"reusify": "^1.0.4"
}
@ -33996,7 +34154,6 @@
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
"dev": true,
"requires": {
"is-glob": "^4.0.1"
}
@ -34881,6 +35038,12 @@
"resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz",
"integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w=="
},
"is-negated-glob": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-negated-glob/-/is-negated-glob-1.0.0.tgz",
"integrity": "sha512-czXVVn/QEmgvej1f50BZ648vUI+em0xqMq2Sn+QncCLN4zj1UAxlT+kw/6ggQTOaZPd1HqKQGEqbpQVtJucWug==",
"peer": true
},
"is-negative-zero": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz",
@ -35382,7 +35545,7 @@
"join-component": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/join-component/-/join-component-1.1.0.tgz",
"integrity": "sha1-uEF7dQZho5K+4sJTfGiyqdSXfNU="
"integrity": "sha512-bF7vcQxbODoGK1imE2P9GS9aw4zD0Sd+Hni68IMZLj7zRnquH7dXUmMw9hDI5S/Jzt7q+IyTXN0rSg2GI0IKhQ=="
},
"jquery": {
"version": "3.6.0",
@ -36295,8 +36458,7 @@
"merge2": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",
"integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==",
"dev": true
"integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg=="
},
"methods": {
"version": "1.1.2",
@ -37147,7 +37309,6 @@
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/multimatch/-/multimatch-4.0.0.tgz",
"integrity": "sha512-lDmx79y1z6i7RNx0ZGCPq1bzJ6ZoDDKbvh7jxr9SJcWLkShMzXrHbYVpTdnhNM5MXpDUxCQ4DgqVttVXlBgiBQ==",
"dev": true,
"requires": {
"@types/minimatch": "^3.0.3",
"array-differ": "^3.0.0",
@ -37257,9 +37418,9 @@
"integrity": "sha512-3AryS9uwa5NfISLxMciUonrH7YfXp+nlahB9T7girXIsLQrmwX4MdnuKs32akduCOGpKmjTJSWmATULbuMkbfw=="
},
"nc-help": {
"version": "0.2.59",
"resolved": "https://registry.npmjs.org/nc-help/-/nc-help-0.2.59.tgz",
"integrity": "sha512-tz1WzykP+3ga6aaiv+ZZkzUK/FgHj7Q/mqb6PSN6c6OwiYJDAA7+4JRc7cyVAWyr9t/6+NQxJsEnmd9tbKzI7w==",
"version": "0.2.60",
"resolved": "https://registry.npmjs.org/nc-help/-/nc-help-0.2.60.tgz",
"integrity": "sha512-D7tEV3pwJrhsk0t3ZPWtXl3446YkFbTZFA9hdxpYCGA8XyWrJgwClP2EXU0ne4FXEnTXIA/EwtpTiJtJCOdHbw==",
"requires": {
"@rudderstack/rudder-sdk-node": "^1.1.3",
"axios": "^0.21.1",
@ -39136,8 +39297,7 @@
"picomatch": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
"dev": true
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="
},
"pidtree": {
"version": "0.3.1",
@ -39309,7 +39469,7 @@
"pkginfo": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.4.1.tgz",
"integrity": "sha1-tUGO8EOd5UJfxJlQQtztFPsqhP8="
"integrity": "sha512-8xCNE/aT/EXKenuMDZ+xTVwkT8gsoHN2z/Q29l80u0ppGEXVvsKRzNMbtKhg8LS8k1tJLAHHylf6p4VFmP6XUQ=="
},
"plur": {
"version": "3.1.1",
@ -39556,8 +39716,7 @@
"queue-microtask": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
"integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==",
"dev": true
"integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A=="
},
"quick-lru": {
"version": "1.1.0",
@ -40048,8 +40207,7 @@
"reusify": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz",
"integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==",
"dev": true
"integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw=="
},
"right-pad": {
"version": "1.0.1",
@ -40091,7 +40249,6 @@
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
"integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==",
"dev": true,
"requires": {
"queue-microtask": "^1.2.2"
}
@ -42241,6 +42398,17 @@
}
}
},
"ts-morph": {
"version": "7.3.0",
"resolved": "https://registry.npmjs.org/ts-morph/-/ts-morph-7.3.0.tgz",
"integrity": "sha512-BUKSoz7AFSKPcYTZODbICW2mOthAN4vc5juD6FL1lD/dLwZ0WvrC3zqBM3/X6f5gHxq3yaz+HmanHGaWm0ddbQ==",
"peer": true,
"requires": {
"@dsherret/to-absolute-glob": "^2.0.2",
"@ts-morph/common": "~0.5.2",
"code-block-writer": "^10.1.0"
}
},
"ts-node": {
"version": "8.10.2",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.10.2.tgz",

2
packages/nocodb/package.json

@ -152,7 +152,7 @@
"mysql2": "^2.2.5",
"nanoid": "^3.1.20",
"nc-common": "0.0.6",
"nc-help": "0.2.59",
"nc-help": "0.2.60",
"nc-lib-gui": "0.91.7",
"nc-plugin": "0.1.2",
"ncp": "^2.0.0",

4
packages/nocodb/src/lib/Noco.ts

@ -41,6 +41,7 @@ import User from './models/User';
import { Tele } from 'nc-help';
import * as http from 'http';
import weAreHiring from './utils/weAreHiring';
import getInstance from './utils/getInstance';
const log = debug('nc:app');
require('dotenv').config();
@ -263,6 +264,9 @@ export default class Noco {
}
next();
});
Tele.init({
instance: getInstance
});
Tele.emit('evt_app_started', await User.count());
weAreHiring();
return this.router;

2
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

@ -1406,7 +1406,7 @@ class BaseModelSqlv2 {
switch (colOptions.type) {
case RelationTypes.BELONGS_TO:
{
const parentCol = await colOptions.getParentColumn();
const parentCol = await colOptions.getChildColumn();
insertObj[parentCol.column_name] =
nestedData?.[parentCol.title];
}

23
packages/nocodb/src/lib/meta/api/publicApis/publicMetaApis.ts

@ -2,10 +2,16 @@ import { Request, Response, Router } from 'express';
import catchError, { NcError } from '../../helpers/catchError';
import View from '../../../models/View';
import Model from '../../../models/Model';
import { ErrorMessages, LinkToAnotherRecordType, UITypes } from 'nocodb-sdk';
import {
ErrorMessages,
LinkToAnotherRecordType,
RelationTypes,
UITypes
} from 'nocodb-sdk';
import Column from '../../../models/Column';
import Base from '../../../models/Base';
import Project from '../../../models/Project';
import LinkToAnotherRecordColumn from '../../../models/LinkToAnotherRecordColumn';
export async function viewMetaGet(req: Request, res: Response) {
const view: View & {
@ -38,7 +44,20 @@ export async function viewMetaGet(req: Request, res: Response) {
view.model.columns = view.columns
.filter(c => {
const column = view.model.columnsById[c.fk_column_id];
return c.show || (column.rqd && !column.cdf && !column.ai) || column.pk;
return (
c.show ||
(column.rqd && !column.cdf && !column.ai) ||
column.pk ||
view.model.columns.some(
c1 =>
c1.uidt === UITypes.LinkToAnotherRecord &&
(<LinkToAnotherRecordColumn>c1.colOptions).type ===
RelationTypes.BELONGS_TO &&
view.columns.some(vc => vc.fk_column_id === c1.id && vc.show) &&
(<LinkToAnotherRecordColumn>c1.colOptions).fk_child_column_id ===
c.fk_column_id
)
);
})
.map(
c =>

7
packages/nocodb/src/lib/models/Project.ts

@ -73,6 +73,8 @@ export default class Project implements ProjectType {
ncMeta
);
}
await NocoCache.del(CacheScope.INSTANCE_META);
return this.getWithInfo(projectId, ncMeta);
}
@ -191,6 +193,8 @@ export default class Project implements ProjectType {
await NocoCache.del(`${CacheScope.PROJECT}:ref:${o.id}`);
}
await NocoCache.del(CacheScope.INSTANCE_META);
// remove item in cache list
await NocoCache.deepDel(
CacheScope.PROJECT,
@ -248,6 +252,9 @@ export default class Project implements ProjectType {
);
}
o = { ...o, ...updateObj };
await NocoCache.del(CacheScope.INSTANCE_META);
// set cache
await NocoCache.set(key, o);
}

3
packages/nocodb/src/lib/models/User.ts

@ -51,6 +51,9 @@ export default class User implements UserType {
MetaTable.USERS,
insertObj
);
await NocoCache.del(CacheScope.INSTANCE_META);
return this.get(id, ncMeta);
}
public static async update(id, user: Partial<User>, ncMeta = Noco.ncMeta) {

47
packages/nocodb/src/lib/utils/getInstance.ts

@ -0,0 +1,47 @@
import Noco from '../Noco';
import { CacheGetType, CacheScope, MetaTable } from './globals';
import NocoCache from '../cache/NocoCache';
export default async function(force = false, ncMeta = Noco.ncMeta) {
try {
let res = await NocoCache.get(
CacheScope.INSTANCE_META,
CacheGetType.TYPE_OBJECT
);
if (!res || force) {
const projectsMeta = await ncMeta
.knex(MetaTable.PROJECT)
.count('id as count')
.first()
.where('deleted', false)
.where('is_meta', true)
.then(c => c.count);
const projectsExt = await ncMeta
.knex(MetaTable.PROJECT)
.count('id as count')
.first()
.where('deleted', false)
.where('is_meta', false)
.then(c => c.count);
const impacted = await ncMeta
.knex(MetaTable.USERS)
.count('id as count')
.first()
.then(c => c.count);
const created = await ncMeta
.knex('nc_store')
.select('created_at')
.where('key', 'nc_server_id')
.first()
.then(c => c.created_at);
const nc_db_type = Noco.getConfig()?.meta?.db?.client;
res = { projectsMeta, projectsExt, impacted, nc_db_type, created };
await NocoCache.set(CacheScope.INSTANCE_META, res);
}
return res;
} catch {
return {};
}
}

3
packages/nocodb/src/lib/utils/globals.ts

@ -72,7 +72,8 @@ export enum CacheScope {
PLUGIN = 'plugin',
PROJECT_USER = 'projectUser',
MODEL_ROLE_VISIBILITY = 'modelRoleVisibility',
API_TOKEN = 'apiToken'
API_TOKEN = 'apiToken',
INSTANCE_META = 'instanceMeta'
}
export enum CacheGetType {
TYPE_ARRAY = 'TYPE_ARRAY',

Loading…
Cancel
Save