From 104825077bf5ac477933561cdc736ddcadd8a9ea Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 8 Apr 2022 11:18:35 +0530 Subject: [PATCH 01/81] fix: update hideAll args re #1615 Signed-off-by: Pranav C --- .../components/project/spreadsheet/components/fieldsMenu.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nc-gui/components/project/spreadsheet/components/fieldsMenu.vue b/packages/nc-gui/components/project/spreadsheet/components/fieldsMenu.vue index 301854ca39..aac906b6c7 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/fieldsMenu.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/fieldsMenu.vue @@ -367,7 +367,7 @@ export default { }, async hideAll() { if (!this.isPublic) { - await this.$api.dbView.hideAllColumn({ viewId: this.viewId }) + await this.$api.dbView.hideAllColumn(this.viewId) } for (const f of this.fields) { f.show = false From 5225f7f79a210fe1c25e3beff0e64d93355ae965 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 8 Apr 2022 16:18:50 +0530 Subject: [PATCH 02/81] feat: add auth middleware Signed-off-by: Pranav C --- .run/Clear metadb.run.xml | 5 + .run/build.run.xml | 14 + .run/dev.run.xml | 12 + .run/watch_run_mysql.run.xml | 14 + packages/nc-gui/package-lock.json | 340 ++++++----------- packages/nc-gui/package.json | 2 +- packages/nc-gui/plugins/tele.js | 25 +- packages/nocodb/package-lock.json | 360 +++++++----------- packages/nocodb/package.json | 2 +- .../nocodb/src/lib/noco/meta/api/index.ts | 35 +- .../noco/meta/api/userApi/initStrategies.ts | 2 + 11 files changed, 339 insertions(+), 472 deletions(-) create mode 100644 .run/Clear metadb.run.xml create mode 100644 .run/build.run.xml create mode 100644 .run/dev.run.xml create mode 100644 .run/watch_run_mysql.run.xml diff --git a/.run/Clear metadb.run.xml b/.run/Clear metadb.run.xml new file mode 100644 index 0000000000..2fc4fdd987 --- /dev/null +++ b/.run/Clear metadb.run.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/.run/build.run.xml b/.run/build.run.xml new file mode 100644 index 0000000000..10e00dff5c --- /dev/null +++ b/.run/build.run.xml @@ -0,0 +1,14 @@ + + + + + + + + diff --git a/packages/nc-gui/layouts/default.vue b/packages/nc-gui/layouts/default.vue index bbc770cea4..d51a9038f6 100644 --- a/packages/nc-gui/layouts/default.vue +++ b/packages/nc-gui/layouts/default.vue @@ -33,7 +33,7 @@ }}) - {{ brandName }} + {{ brandName }} diff --git a/packages/nc-gui/mixins/colors.js b/packages/nc-gui/mixins/colors.js index c05f118b43..e15010f642 100644 --- a/packages/nc-gui/mixins/colors.js +++ b/packages/nc-gui/mixins/colors.js @@ -8,5 +8,13 @@ export default { textColors() { return this.$store.state.windows.darkTheme ? colors.light : colors.dark } + }, + methods: { + getColor(i) { + return this.colors[i % this.colors.length] + }, + getTextColor(i) { + return this.textColors[i % this.textColors.length] + } } } diff --git a/packages/nc-gui/pages/projects/list.vue b/packages/nc-gui/pages/projects/list.vue new file mode 100644 index 0000000000..66fb582761 --- /dev/null +++ b/packages/nc-gui/pages/projects/list.vue @@ -0,0 +1,229 @@ + + + + + From 099f7cadcdf5bb626245fc9c24220e1ebdc1e76a Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 9 Apr 2022 00:01:42 +0800 Subject: [PATCH 06/81] fix: nightly build for nocodb-sdk Signed-off-by: Wing-Kam Wong --- .github/workflows/release-npm.yml | 5 ++--- scripts/upgradeNocodbSdk.js | 5 +++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml index b2bbf985e6..4e58751435 100644 --- a/.github/workflows/release-npm.yml +++ b/.github/workflows/release-npm.yml @@ -46,10 +46,9 @@ jobs: node-version: '16.x' registry-url: 'https://registry.npmjs.org' - run: | + targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} targetVersion=${{ github.event.inputs.tag || inputs.tag }} node scripts/bumpNocodbSdkVersion.js cd packages/nocodb-sdk - targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} targetVersion=${{ github.event.inputs.tag || inputs.tag }} node ../../scripts/bumpNocodbSdkVersion.js - npm install && npm run build - npm publish + npm install && npm run build && npm publish cd ../.. targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} node scripts/upgradeNocodbSdk.js cd packages/nc-gui diff --git a/scripts/upgradeNocodbSdk.js b/scripts/upgradeNocodbSdk.js index 5f41dd29c5..a72937f274 100644 --- a/scripts/upgradeNocodbSdk.js +++ b/scripts/upgradeNocodbSdk.js @@ -58,9 +58,10 @@ const searchAndReplace = (target) => { fs.readFile(d, function(err, content) { if (err) reject(err) if (content.indexOf(target) > -1) { - replacePackageName(d) + resolve(replacePackageName(d)) + } else { + resolve() } - resolve() }) }) })) From 9e9182349f89fc205d970d9ae05f83205cab8039 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 9 Apr 2022 12:31:55 +0800 Subject: [PATCH 07/81] fix: nightly build docker issue Signed-off-by: Wing-Kam Wong --- .github/workflows/release-docker.yml | 6 ++++++ .github/workflows/release-npm.yml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-docker.yml b/.github/workflows/release-docker.yml index 0fb8da4fbf..ddb7863e99 100644 --- a/.github/workflows/release-docker.yml +++ b/.github/workflows/release-docker.yml @@ -73,6 +73,12 @@ jobs: with: node-version: ${{ matrix.node-version }} + - name: upgrade packages for nightly build + if: ${{ github.event.inputs.targetEnv == 'DEV' || inputs.targetEnv == 'DEV' }} + run: | + targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} node ../../scripts/upgradeNocodbSdk.js + targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} node ../../scripts/upgradeNcGui.js + - uses: bahmutov/npm-install@v1 with: working-directory: ${{ env.working-directory }} diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml index 4e58751435..c91b921e1f 100644 --- a/.github/workflows/release-npm.yml +++ b/.github/workflows/release-npm.yml @@ -56,7 +56,7 @@ jobs: targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} targetVersion=${{ github.event.inputs.tag || inputs.tag }} npm run build:copy:jsdeliver cd ../.. npm install - targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} targetVersion=${{ github.event.inputs.tag || inputs.tag }} node scripts/upgradeNcGui.js && cd packages/nocodb && npm install && npm run obfuscate:build:publish + targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} node scripts/upgradeNcGui.js && cd packages/nocodb && npm install && npm run obfuscate:build:publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Create Pull Request From 158c3d9cb9850b7f7d60da60da6647e1036f5a66 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 9 Apr 2022 04:33:47 +0000 Subject: [PATCH 08/81] chore(deps): bump moment from 2.29.1 to 2.29.2 in /packages/nocodb Bumps [moment](https://github.com/moment/moment) from 2.29.1 to 2.29.2. - [Release notes](https://github.com/moment/moment/releases) - [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md) - [Commits](https://github.com/moment/moment/compare/2.29.1...2.29.2) --- updated-dependencies: - dependency-name: moment dependency-type: indirect ... Signed-off-by: dependabot[bot] --- packages/nocodb/package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/nocodb/package-lock.json b/packages/nocodb/package-lock.json index c236fa1309..1bf2ce31d0 100644 --- a/packages/nocodb/package-lock.json +++ b/packages/nocodb/package-lock.json @@ -15676,9 +15676,9 @@ } }, "node_modules/moment": { - "version": "2.29.1", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", - "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==", + "version": "2.29.2", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.2.tgz", + "integrity": "sha512-UgzG4rvxYpN15jgCmVJwac49h9ly9NurikMWGPdVxm8GZD6XjkKPxDTjQQ43gtGgnV3X0cAyWDdP2Wexoquifg==", "engines": { "node": "*" } @@ -37177,9 +37177,9 @@ "dev": true }, "moment": { - "version": "2.29.1", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", - "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==" + "version": "2.29.2", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.2.tgz", + "integrity": "sha512-UgzG4rvxYpN15jgCmVJwac49h9ly9NurikMWGPdVxm8GZD6XjkKPxDTjQQ43gtGgnV3X0cAyWDdP2Wexoquifg==" }, "moment-timezone": { "version": "0.5.34", From 9fc5dad08d0c291859bd0a3d24b90bf77b6f9191 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 9 Apr 2022 12:48:15 +0800 Subject: [PATCH 09/81] fix: wrong paths of scripts Signed-off-by: Wing-Kam Wong --- .github/workflows/release-docker.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-docker.yml b/.github/workflows/release-docker.yml index ddb7863e99..2909fe5865 100644 --- a/.github/workflows/release-docker.yml +++ b/.github/workflows/release-docker.yml @@ -76,9 +76,9 @@ jobs: - name: upgrade packages for nightly build if: ${{ github.event.inputs.targetEnv == 'DEV' || inputs.targetEnv == 'DEV' }} run: | - targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} node ../../scripts/upgradeNocodbSdk.js - targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} node ../../scripts/upgradeNcGui.js - + targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} node scripts/upgradeNocodbSdk.js + targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} node scripts/upgradeNcGui.js + - uses: bahmutov/npm-install@v1 with: working-directory: ${{ env.working-directory }} From aeed8742ace38f947b4047f497388f0c1d7bef4d Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 9 Apr 2022 13:43:31 +0800 Subject: [PATCH 10/81] fix: add build:copy:jsdeliver to release-docker Signed-off-by: Wing-Kam Wong --- .github/workflows/release-docker.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/release-docker.yml b/.github/workflows/release-docker.yml index 2909fe5865..552fff63fc 100644 --- a/.github/workflows/release-docker.yml +++ b/.github/workflows/release-docker.yml @@ -77,6 +77,10 @@ jobs: if: ${{ github.event.inputs.targetEnv == 'DEV' || inputs.targetEnv == 'DEV' }} run: | targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} node scripts/upgradeNocodbSdk.js + cd packages/nc-gui + npm install + targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} targetVersion=${{ github.event.inputs.tag || inputs.tag }} npm run build:copy + cd ../.. targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} node scripts/upgradeNcGui.js - uses: bahmutov/npm-install@v1 From 73eb0cb63acc6604381558d19b2758027bddcd8b Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 9 Apr 2022 14:24:18 +0800 Subject: [PATCH 11/81] fix: add bumpNocodbSdkVersion to release-docker Signed-off-by: Wing-Kam Wong --- .github/workflows/release-docker.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/release-docker.yml b/.github/workflows/release-docker.yml index 552fff63fc..6168972cec 100644 --- a/.github/workflows/release-docker.yml +++ b/.github/workflows/release-docker.yml @@ -76,6 +76,10 @@ jobs: - name: upgrade packages for nightly build if: ${{ github.event.inputs.targetEnv == 'DEV' || inputs.targetEnv == 'DEV' }} run: | + targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} targetVersion=${{ github.event.inputs.tag || inputs.tag }} node scripts/bumpNocodbSdkVersion.js + cd packages/nocodb-sdk + npm install && npm run build + cd ../.. targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} node scripts/upgradeNocodbSdk.js cd packages/nc-gui npm install From a7114cd531e83b79997e0de82de3e29ba440520f Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 9 Apr 2022 16:16:45 +0800 Subject: [PATCH 12/81] chore: rm unnecessary npm install Signed-off-by: Wing-Kam Wong --- .github/workflows/release-npm.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml index c91b921e1f..428f2ef2bd 100644 --- a/.github/workflows/release-npm.yml +++ b/.github/workflows/release-npm.yml @@ -55,7 +55,6 @@ jobs: npm install targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} targetVersion=${{ github.event.inputs.tag || inputs.tag }} npm run build:copy:jsdeliver cd ../.. - npm install targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} node scripts/upgradeNcGui.js && cd packages/nocodb && npm install && npm run obfuscate:build:publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} From 763a9c65fbf94dfc7221fc00f3720f9ffe4ba8b0 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 9 Apr 2022 16:17:03 +0800 Subject: [PATCH 13/81] chore: update package-lock.json Signed-off-by: Wing-Kam Wong --- packages/nocodb-sdk/package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nocodb-sdk/package-lock.json b/packages/nocodb-sdk/package-lock.json index 433a4e01e6..5778a0a8c6 100644 --- a/packages/nocodb-sdk/package-lock.json +++ b/packages/nocodb-sdk/package-lock.json @@ -1,12 +1,12 @@ { "name": "nocodb-sdk", - "version": "0.0.6", + "version": "0.0.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "nocodb-sdk", - "version": "0.0.6", + "version": "0.0.9", "license": "MIT", "dependencies": { "axios": "^0.21.1", From 8749c006f8d14ebc0903fcdec2679c70772bca47 Mon Sep 17 00:00:00 2001 From: Mert Ersoy Date: Sat, 9 Apr 2022 12:54:11 +0300 Subject: [PATCH 14/81] fix: disable update call if column undefined re #1630 Signed-off-by: Mert Ersoy --- .../nc-gui/components/project/spreadsheet/rowsXcDataTable.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue b/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue index 01994ec987..75844f818d 100644 --- a/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue +++ b/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue @@ -1100,7 +1100,7 @@ export default { // return // } // return if there is no change - if (oldRow[column.title] === rowObj[column.title] && ((lastSave || rowObj[column.title]) === rowObj[column.title])) { + if (!column || (oldRow[column.title] === rowObj[column.title] && ((lastSave || rowObj[column.title]) === rowObj[column.title]))) { return } if (saved) { this.$set(this.data[row], 'lastSave', oldRow[column.title]) } From 38b29e29a74fa44724a5f2388c1a269d31414235 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 9 Apr 2022 19:09:14 +0800 Subject: [PATCH 15/81] fix: use node 14 Signed-off-by: Wing-Kam Wong --- .github/workflows/release-docker.yml | 2 +- .github/workflows/release-npm.yml | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release-docker.yml b/.github/workflows/release-docker.yml index 6168972cec..093f064809 100644 --- a/.github/workflows/release-docker.yml +++ b/.github/workflows/release-docker.yml @@ -42,7 +42,7 @@ jobs: working-directory: ./packages/nocodb strategy: matrix: - node-version: [12] + node-version: [14] steps: - name: Get Docker Repository id: get-docker-repository diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml index 428f2ef2bd..e400b13655 100644 --- a/.github/workflows/release-npm.yml +++ b/.github/workflows/release-npm.yml @@ -37,13 +37,20 @@ jobs: working-directory: ./packages/nocodb strategy: matrix: - node-version: [12] + node-version: [14] steps: - - uses: actions/checkout@v2 - # Setup .npmrc file to publish to npm - - uses: actions/setup-node@v2 + - name: Checkout + uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 with: - node-version: '16.x' + node-version: ${{ matrix.node-version }} + + - name: NPM Setup and Publish + # Setup .npmrc file to publish to npm + uses: actions/setup-node@v2 + with: + # node-version: '16.x' registry-url: 'https://registry.npmjs.org' - run: | targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} targetVersion=${{ github.event.inputs.tag || inputs.tag }} node scripts/bumpNocodbSdkVersion.js From 48a39ff364396a4fb2c8f46ee19e1ed08bf310e5 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 9 Apr 2022 19:37:23 +0800 Subject: [PATCH 16/81] fix: search .js files as well Signed-off-by: Wing-Kam Wong --- scripts/upgradeNocodbSdk.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgradeNocodbSdk.js b/scripts/upgradeNocodbSdk.js index a72937f274..58daf921d9 100644 --- a/scripts/upgradeNocodbSdk.js +++ b/scripts/upgradeNocodbSdk.js @@ -37,7 +37,7 @@ const dfs = function(dir) { res = res.concat(dfs(file)); } else { const ext = path.extname(file).toLowerCase() - if (ext == '.vue' || ext == '.ts') { + if (ext == '.vue' || ext == '.ts' || ext == '.js') { res.push(file); } } From 371ee48bcaece6ed81508fca7edcde0d1180feb9 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 9 Apr 2022 20:36:58 +0800 Subject: [PATCH 17/81] refactor: combine setup-node Signed-off-by: Wing-Kam Wong --- .github/workflows/release-npm.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml index e400b13655..024e23f59a 100644 --- a/.github/workflows/release-npm.yml +++ b/.github/workflows/release-npm.yml @@ -41,16 +41,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node-version }} - - - name: NPM Setup and Publish + - name: NPM Setup and Publish with ${{ matrix.node-version }} # Setup .npmrc file to publish to npm uses: actions/setup-node@v2 with: - # node-version: '16.x' + node-version: ${{ matrix.node-version }} registry-url: 'https://registry.npmjs.org' - run: | targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} targetVersion=${{ github.event.inputs.tag || inputs.tag }} node scripts/bumpNocodbSdkVersion.js From 8b7941a7dc23cf1cfde7d15486ddc78ee8cba260 Mon Sep 17 00:00:00 2001 From: mertmit Date: Sun, 10 Apr 2022 16:50:26 +0300 Subject: [PATCH 18/81] fix: add date and URL to formulaQueryBuilder Signed-off-by: mertmit --- .../sql/formulav2/formulaQueryBuilderv2.ts | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/packages/nocodb/src/lib/dataMapper/lib/sql/formulav2/formulaQueryBuilderv2.ts b/packages/nocodb/src/lib/dataMapper/lib/sql/formulav2/formulaQueryBuilderv2.ts index 55cac2ffee..632b32f33f 100644 --- a/packages/nocodb/src/lib/dataMapper/lib/sql/formulav2/formulaQueryBuilderv2.ts +++ b/packages/nocodb/src/lib/dataMapper/lib/sql/formulav2/formulaQueryBuilderv2.ts @@ -564,6 +564,41 @@ export default async function formulaQueryBuilderv2( } } break; + case 'DATEADD': + if (pt.arguments[1].value) { + pt.callee.name = 'DATE_ADD'; + return fn(pt, alias, prevBinaryOp); + } else if (pt.arguments[1].operator == '-') { + pt.callee.name = 'DATE_SUB'; + return fn(pt, alias, prevBinaryOp); + } + break; + case 'URL': + return fn( + { + type: 'CallExpression', + arguments: [ + { + type: 'Literal', + value: 'URI::(', + raw: '"URI::("' + }, + pt.arguments[0], + { + type: 'Literal', + value: ')', + raw: '")"' + } + ], + callee: { + type: 'Identifier', + name: 'CONCAT' + } + }, + alias, + prevBinaryOp + ); + break; default: { const res = mapFunctionName({ From 66e414d8591bf1c91c49d72799849275453ef8a7 Mon Sep 17 00:00:00 2001 From: mertmit Date: Sun, 10 Apr 2022 16:50:32 +0300 Subject: [PATCH 19/81] fix: URL parsing on UI Signed-off-by: mertmit --- .../spreadsheet/components/virtualCell/formulaCell.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/formulaCell.vue b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/formulaCell.vue index 0d27545f3f..b49dab2551 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/formulaCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/formulaCell.vue @@ -25,12 +25,13 @@ export default { const rawText = this.row[this.column.title].toString() let found = false - const out = rawText.match(/URI::\((.*?)\)/g, (_, url) => { + const out = rawText.replace(/URI::\((.*?)\)/g, (_, url) => { found = true const a = document.createElement('a') a.textContent = url a.setAttribute('href', url) - return a.innerHTML + a.setAttribute('target', '_blank') + return a.outerHTML }) return found && out From 999b93d0a9b48c13131d2b39482df79f0c3825fa Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 11 Apr 2022 12:48:59 +0800 Subject: [PATCH 20/81] fix: pass fn names manually to ncMetaAclMw instead of using minified ones Signed-off-by: Wing-Kam Wong --- .../src/lib/noco/meta/api/apiTokenApis.ts | 12 +++++-- .../src/lib/noco/meta/api/attachmentApis.ts | 2 +- .../nocodb/src/lib/noco/meta/api/auditApis.ts | 11 +++--- .../src/lib/noco/meta/api/columnApis.ts | 14 +++++--- .../meta/api/dataApis/bulkDataAliasApis.ts | 10 +++--- .../noco/meta/api/dataApis/dataAliasApis.ts | 12 +++---- .../lib/noco/meta/api/dataApis/dataApis.ts | 24 ++++++------- .../lib/noco/meta/api/dataApis/oldDataApis.ts | 22 +++++++++--- .../src/lib/noco/meta/api/exportApis.ts | 2 +- .../src/lib/noco/meta/api/filterApis.ts | 24 +++++++++---- .../src/lib/noco/meta/api/formViewApis.ts | 14 +++++--- .../lib/noco/meta/api/formViewColumnApis.ts | 5 ++- .../src/lib/noco/meta/api/galleryViewApis.ts | 15 ++++++-- .../src/lib/noco/meta/api/gridViewApis.ts | 5 ++- .../lib/noco/meta/api/gridViewColumnApis.ts | 10 ++++-- .../nocodb/src/lib/noco/meta/api/hookApis.ts | 10 +++--- .../src/lib/noco/meta/api/hookFilterApis.ts | 24 +++++++++---- .../src/lib/noco/meta/api/metaDiffApis.ts | 7 ++-- .../src/lib/noco/meta/api/pluginApis.ts | 10 +++--- .../src/lib/noco/meta/api/projectApis.ts | 16 ++++++--- .../src/lib/noco/meta/api/projectUserApis.ts | 11 +++--- .../src/lib/noco/meta/api/sharedBaseApis.ts | 11 +++--- .../nocodb/src/lib/noco/meta/api/sortApis.ts | 16 ++++++--- .../nocodb/src/lib/noco/meta/api/tableApis.ts | 21 +++++++---- .../src/lib/noco/meta/api/userApi/userApis.ts | 6 ++-- .../nocodb/src/lib/noco/meta/api/utilApis.ts | 2 +- .../nocodb/src/lib/noco/meta/api/viewApis.ts | 35 +++++++++++++------ .../src/lib/noco/meta/api/viewColumnApis.ts | 4 +-- .../src/lib/noco/meta/helpers/ncMetaAclMw.ts | 2 +- 29 files changed, 241 insertions(+), 116 deletions(-) diff --git a/packages/nocodb/src/lib/noco/meta/api/apiTokenApis.ts b/packages/nocodb/src/lib/noco/meta/api/apiTokenApis.ts index 360d0c2402..5043225c24 100644 --- a/packages/nocodb/src/lib/noco/meta/api/apiTokenApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/apiTokenApis.ts @@ -17,11 +17,17 @@ export async function apiTokenDelete(req: Request, res: Response) { const router = Router({ mergeParams: true }); -router.get('/projects/:projectId/apiTokens', ncMetaAclMw(apiTokenList)); -router.post('/projects/:projectId/apiTokens', ncMetaAclMw(apiTokenCreate)); +router.get( + '/projects/:projectId/apiTokens', + ncMetaAclMw(apiTokenList, 'apiTokenList') +); +router.post( + '/projects/:projectId/apiTokens', + ncMetaAclMw(apiTokenCreate, 'apiTokenCreate') +); router.delete( '/projects/:projectId/apiTokens/:token', - ncMetaAclMw(apiTokenDelete) + ncMetaAclMw(apiTokenDelete, 'apiTokenDelete') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/attachmentApis.ts b/packages/nocodb/src/lib/noco/meta/api/attachmentApis.ts index 9debc6f4a6..b5604a2e21 100644 --- a/packages/nocodb/src/lib/noco/meta/api/attachmentApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/attachmentApis.ts @@ -87,7 +87,7 @@ router.post( multer({ storage: multer.diskStorage({}) }).any(), - ncMetaAclMw(upload) + ncMetaAclMw(upload, 'upload') ); router.get('/download/:projectId/:viewId/:fileName', catchError(fileRead)); diff --git a/packages/nocodb/src/lib/noco/meta/api/auditApis.ts b/packages/nocodb/src/lib/noco/meta/api/auditApis.ts index 62a59fe246..2ec433fd0c 100644 --- a/packages/nocodb/src/lib/noco/meta/api/auditApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/auditApis.ts @@ -58,9 +58,12 @@ export async function commentsCount(req: Request, res) { } const router = Router({ mergeParams: true }); -router.get('/audits/comments', ncMetaAclMw(commentList)); +router.get('/audits/comments', ncMetaAclMw(commentList, 'commentList')); router.post('/audits/rowUpdate', ncMetaAclMw(auditRowUpdate, 'auditRowUpdate')); -router.post('/audits/comments', ncMetaAclMw(commentRow)); -router.get('/audits/comments/count', ncMetaAclMw(commentsCount)); -router.get('/project/:projectId/audits', ncMetaAclMw(auditList)); +router.post('/audits/comments', ncMetaAclMw(commentRow, 'commentRow')); +router.get( + '/audits/comments/count', + ncMetaAclMw(commentsCount, 'commentsCount') +); +router.get('/project/:projectId/audits', ncMetaAclMw(auditList, 'auditList')); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/columnApis.ts b/packages/nocodb/src/lib/noco/meta/api/columnApis.ts index bee441428b..91b18ce1a5 100644 --- a/packages/nocodb/src/lib/noco/meta/api/columnApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/columnApis.ts @@ -900,11 +900,17 @@ const deleteHmOrBtRelation = async ( }; const router = Router({ mergeParams: true }); -router.post('/tables/:tableId/columns/', ncMetaAclMw(columnAdd)); -router.put('/tables/:tableId/columns/:columnId', ncMetaAclMw(columnUpdate)); -router.delete('/tables/:tableId/columns/:columnId', ncMetaAclMw(columnDelete)); +router.post('/tables/:tableId/columns/', ncMetaAclMw(columnAdd, 'columnAdd')); +router.put( + '/tables/:tableId/columns/:columnId', + ncMetaAclMw(columnUpdate, 'columnUpdate') +); +router.delete( + '/tables/:tableId/columns/:columnId', + ncMetaAclMw(columnDelete, 'columnDelete') +); router.post( '/tables/:tableId/columns/:columnId/primary', - ncMetaAclMw(columnSetAsPrimary) + ncMetaAclMw(columnSetAsPrimary, 'columnSetAsPrimary') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/bulkDataAliasApis.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/bulkDataAliasApis.ts index 5ac4f237e8..da81a2df3e 100644 --- a/packages/nocodb/src/lib/noco/meta/api/dataApis/bulkDataAliasApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/bulkDataAliasApis.ts @@ -92,23 +92,23 @@ const router = Router({ mergeParams: true }); router.post( '/bulkData/:orgs/:projectName/:tableAlias', - ncMetaAclMw(bulkDataInsert) + ncMetaAclMw(bulkDataInsert, 'bulkDataInsert') ); router.patch( '/bulkData/:orgs/:projectName/:tableAlias', - ncMetaAclMw(bulkDataUpdate) + ncMetaAclMw(bulkDataUpdate, 'bulkDataUpdate') ); router.patch( '/bulkData/:orgs/:projectName/:tableAlias/all', - ncMetaAclMw(bulkDataUpdateAll) + ncMetaAclMw(bulkDataUpdateAll, 'bulkDataUpdateAll') ); router.delete( '/bulkData/:orgs/:projectName/:tableAlias', - ncMetaAclMw(bulkDataDelete) + ncMetaAclMw(bulkDataDelete, 'bulkDataDelete') ); router.delete( '/bulkData/:orgs/:projectName/:tableAlias/all', - ncMetaAclMw(bulkDataDeleteAll) + ncMetaAclMw(bulkDataDeleteAll, 'bulkDataDeleteAll') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasApis.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasApis.ts index d301c05a7d..92b16f9341 100644 --- a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasApis.ts @@ -125,27 +125,27 @@ async function dataRead(req: Request, res: Response) { const router = Router({ mergeParams: true }); -router.get('/data/:orgs/:projectName/:tableName', ncMetaAclMw(dataList)); +router.get('/data/:orgs/:projectName/:tableName', ncMetaAclMw(dataList, 'dataList')); router.get( '/data/:orgs/:projectName/:tableName/views/:viewName', - ncMetaAclMw(dataList) + ncMetaAclMw(dataList, 'dataList') ); router.post( '/data/:orgs/:projectName/:tableName/views/:viewName', - ncMetaAclMw(dataInsert) + ncMetaAclMw(dataInsert, 'dataInsert') ); router.put( '/data/:orgs/:projectName/:tableName/views/:viewName/:rowId', - ncMetaAclMw(dataUpdate) + ncMetaAclMw(dataUpdate, 'dataUpdate') ); router.get( '/data/:orgs/:projectName/:tableName/views/:viewName/:rowId', - ncMetaAclMw(dataRead) + ncMetaAclMw(dataRead, 'dataRead') ); router.delete( '/data/:orgs/:projectName/:tableName/views/:viewName/:rowId', - ncMetaAclMw(dataDelete) + ncMetaAclMw(dataDelete, 'dataDelete') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataApis.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataApis.ts index e298aded0c..edefdf35d2 100644 --- a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataApis.ts @@ -563,34 +563,34 @@ const router = Router({ mergeParams: true }); // ncMetaAclMw(dataDeleteNew) // ); -router.get('/data/:viewId/', ncMetaAclMw(dataList)); -router.post('/data/:viewId/', ncMetaAclMw(dataInsert)); -router.get('/data/:viewId/:rowId', ncMetaAclMw(dataRead)); -router.put('/data/:viewId/:rowId', ncMetaAclMw(dataUpdate)); -router.delete('/data/:viewId/:rowId', ncMetaAclMw(dataDelete)); +router.get('/data/:viewId/', ncMetaAclMw(dataList, 'dataList')); +router.post('/data/:viewId/', ncMetaAclMw(dataInsert, 'dataInsert')); +router.get('/data/:viewId/:rowId', ncMetaAclMw(dataRead, 'dataRead')); +router.put('/data/:viewId/:rowId', ncMetaAclMw(dataUpdate, 'dataUpdate')); +router.delete('/data/:viewId/:rowId', ncMetaAclMw(dataDelete, 'dataDelete')); -router.get('/data/:viewId/:rowId/mm/:colId', ncMetaAclMw(mmList)); -router.get('/data/:viewId/:rowId/hm/:colId', ncMetaAclMw(hmList)); +router.get('/data/:viewId/:rowId/mm/:colId', ncMetaAclMw(mmList, 'mmList')); +router.get('/data/:viewId/:rowId/hm/:colId', ncMetaAclMw(hmList, 'hmList')); router.get( '/data/:viewId/:rowId/mm/:colId/exclude', - ncMetaAclMw(mmExcludedList) + ncMetaAclMw(mmExcludedList, 'mmExcludedList') ); router.get( '/data/:viewId/:rowId/hm/:colId/exclude', - ncMetaAclMw(hmExcludedList) + ncMetaAclMw(hmExcludedList, 'hmExcludedList') ); router.get( '/data/:viewId/:rowId/bt/:colId/exclude', - ncMetaAclMw(btExcludedList) + ncMetaAclMw(btExcludedList, 'btExcludedList') ); router.post( '/data/:viewId/:rowId/:relationType/:colId/:childId', - ncMetaAclMw(relationDataAdd) + ncMetaAclMw(relationDataAdd, 'relationDataAdd') ); router.delete( '/data/:viewId/:rowId/:relationType/:colId/:childId', - ncMetaAclMw(relationDataDelete) + ncMetaAclMw(relationDataDelete, 'relationDataDelete') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/oldDataApis.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/oldDataApis.ts index 564f867206..14d9b68654 100644 --- a/packages/nocodb/src/lib/noco/meta/api/dataApis/oldDataApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/oldDataApis.ts @@ -125,14 +125,26 @@ async function dataRead(req: Request, res: Response) { const router = Router({ mergeParams: true }); -router.get('/nc/:projectId/api/v2/:tableName', ncMetaAclMw(dataList)); +router.get( + '/nc/:projectId/api/v2/:tableName', + ncMetaAclMw(dataList, 'dataList') +); -router.post('/nc/:projectId/api/v2/:tableName', ncMetaAclMw(dataInsert)); -router.get('/nc/:projectId/api/v2/:tableName/:rowId', ncMetaAclMw(dataRead)); -router.put('/nc/:projectId/api/v2/:tableName/:rowId', ncMetaAclMw(dataUpdate)); +router.post( + '/nc/:projectId/api/v2/:tableName', + ncMetaAclMw(dataInsert, 'dataInsert') +); +router.get( + '/nc/:projectId/api/v2/:tableName/:rowId', + ncMetaAclMw(dataRead, 'dataRead') +); +router.put( + '/nc/:projectId/api/v2/:tableName/:rowId', + ncMetaAclMw(dataUpdate, 'dataUpdate') +); router.delete( '/nc/:projectId/api/v2/:tableName/:rowId', - ncMetaAclMw(dataDelete) + ncMetaAclMw(dataDelete, 'dataDelete') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/exportApis.ts b/packages/nocodb/src/lib/noco/meta/api/exportApis.ts index 33cca96cd9..d995aefa25 100644 --- a/packages/nocodb/src/lib/noco/meta/api/exportApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/exportApis.ts @@ -173,5 +173,5 @@ async function serializeCellValue({ } const router = Router({ mergeParams: true }); -router.get('/data/:viewId/export/csv', ncMetaAclMw(exportCsv)); +router.get('/data/:viewId/export/csv', ncMetaAclMw(exportCsv, 'exportCsv')); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/filterApis.ts b/packages/nocodb/src/lib/noco/meta/api/filterApis.ts index 39890c9471..a67484f015 100644 --- a/packages/nocodb/src/lib/noco/meta/api/filterApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/filterApis.ts @@ -106,13 +106,25 @@ export async function filterDelete(req: Request, res: Response, next) { } const router = Router({ mergeParams: true }); -router.get('/views/:viewId/filters/', ncMetaAclMw(filterList)); -router.post('/views/:viewId/filters/', ncMetaAclMw(filterCreate)); -router.get('/views/:viewId/filters/:filterId', ncMetaAclMw(filterGet)); -router.put('/views/:viewId/filters/:filterId', ncMetaAclMw(filterUpdate)); -router.delete('/views/:viewId/filters/:filterId', ncMetaAclMw(filterDelete)); +router.get('/views/:viewId/filters/', ncMetaAclMw(filterList, 'filterList')); +router.post( + '/views/:viewId/filters/', + ncMetaAclMw(filterCreate, 'filterCreate') +); +router.get( + '/views/:viewId/filters/:filterId', + ncMetaAclMw(filterGet, 'filterGet') +); +router.put( + '/views/:viewId/filters/:filterId', + ncMetaAclMw(filterUpdate, 'filterUpdate') +); +router.delete( + '/views/:viewId/filters/:filterId', + ncMetaAclMw(filterDelete, 'filterDelete') +); router.get( '/views/:viewId/filters/:filterParentId/children', - ncMetaAclMw(filterChildrenRead) + ncMetaAclMw(filterChildrenRead, 'filterChildrenRead') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/formViewApis.ts b/packages/nocodb/src/lib/noco/meta/api/formViewApis.ts index 2aa7055155..f379b5b7a6 100644 --- a/packages/nocodb/src/lib/noco/meta/api/formViewApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/formViewApis.ts @@ -39,8 +39,14 @@ export async function formViewUpdate(req, res) { export async function formViewDelete(req: Request, res: Response, next) {} const router = Router({ mergeParams: true }); -router.post('/tables/:tableId/forms', ncMetaAclMw(formViewCreate)); -router.get('/forms/:formViewId', ncMetaAclMw(formViewGet)); -router.put('/forms/:formViewId', ncMetaAclMw(formViewUpdate)); -router.delete('/forms/:formViewId', ncMetaAclMw(formViewDelete)); +router.post( + '/tables/:tableId/forms', + ncMetaAclMw(formViewCreate, 'formViewCreate') +); +router.get('/forms/:formViewId', ncMetaAclMw(formViewGet, 'formViewGet')); +router.put('/forms/:formViewId', ncMetaAclMw(formViewUpdate, 'formViewUpdate')); +router.delete( + '/forms/:formViewId', + ncMetaAclMw(formViewDelete, 'formViewDelete') +); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/formViewColumnApis.ts b/packages/nocodb/src/lib/noco/meta/api/formViewColumnApis.ts index 06537da9b7..891ad603fb 100644 --- a/packages/nocodb/src/lib/noco/meta/api/formViewColumnApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/formViewColumnApis.ts @@ -9,5 +9,8 @@ export async function columnUpdate(req: Request, res: Response) { } const router = Router({ mergeParams: true }); -router.put('/formColumns/:formViewColumnId', ncMetaAclMw(columnUpdate)); +router.put( + '/formColumns/:formViewColumnId', + ncMetaAclMw(columnUpdate, 'columnUpdate') +); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/galleryViewApis.ts b/packages/nocodb/src/lib/noco/meta/api/galleryViewApis.ts index a7be5b7d75..5c662ff0b4 100644 --- a/packages/nocodb/src/lib/noco/meta/api/galleryViewApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/galleryViewApis.ts @@ -46,9 +46,18 @@ export async function galleyViewDelete(req: Request, res: Response, next) {} const router = Router({ mergeParams: true }); // router.get('/', galleyViewList); -router.post('/tables/:tableId/galleries', ncMetaAclMw(galleryViewCreate)); +router.post( + '/tables/:tableId/galleries', + ncMetaAclMw(galleryViewCreate, 'galleryViewCreate') +); // router.get('/:galleryViewId', galleyViewGet); -router.put('/galleries/:galleryViewId', ncMetaAclMw(galleryViewUpdate)); -router.get('/galleries/:galleryViewId', ncMetaAclMw(galleryViewGet)); +router.put( + '/galleries/:galleryViewId', + ncMetaAclMw(galleryViewUpdate, 'galleryViewUpdate') +); +router.get( + '/galleries/:galleryViewId', + ncMetaAclMw(galleryViewGet, 'galleryViewGet') +); // router.delete('/:galleryViewId', galleyViewDelete); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/gridViewApis.ts b/packages/nocodb/src/lib/noco/meta/api/gridViewApis.ts index 47cc17e2fb..119b825245 100644 --- a/packages/nocodb/src/lib/noco/meta/api/gridViewApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/gridViewApis.ts @@ -25,5 +25,8 @@ export async function gridViewCreate(req: Request, res) { } const router = Router({ mergeParams: true }); -router.post('/tables/:tableId/grids/', ncMetaAclMw(gridViewCreate)); +router.post( + '/tables/:tableId/grids/', + ncMetaAclMw(gridViewCreate, 'gridViewCreate') +); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/gridViewColumnApis.ts b/packages/nocodb/src/lib/noco/meta/api/gridViewColumnApis.ts index 69bacd8d91..6ef54970d8 100644 --- a/packages/nocodb/src/lib/noco/meta/api/gridViewColumnApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/gridViewColumnApis.ts @@ -13,6 +13,12 @@ export async function gridColumnUpdate(req: Request, res: Response) { } const router = Router({ mergeParams: true }); -router.get('/grid/:gridViewId/gridColumns', ncMetaAclMw(columnList)); -router.put('/gridColumns/:gridViewColumnId', ncMetaAclMw(gridColumnUpdate)); +router.get( + '/grid/:gridViewId/gridColumns', + ncMetaAclMw(columnList, 'columnList') +); +router.put( + '/gridColumns/:gridViewColumnId', + ncMetaAclMw(gridColumnUpdate, 'gridColumnUpdate') +); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/hookApis.ts b/packages/nocodb/src/lib/noco/meta/api/hookApis.ts index b83111c553..f116b33cd5 100644 --- a/packages/nocodb/src/lib/noco/meta/api/hookApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/hookApis.ts @@ -75,11 +75,11 @@ export async function tableSampleData(req: Request, res: Response) { } const router = Router({ mergeParams: true }); -router.get('/tables/:tableId/hooks', ncMetaAclMw(hookList)); -router.post('/tables/:tableId/hooks/test', ncMetaAclMw(hookTest)); -router.post('/tables/:tableId/hooks', ncMetaAclMw(hookCreate)); -router.delete('/hooks/:hookId', ncMetaAclMw(hookDelete)); -router.put('/hooks/:hookId', ncMetaAclMw(hookUpdate)); +router.get('/tables/:tableId/hooks', ncMetaAclMw(hookList, 'hookList')); +router.post('/tables/:tableId/hooks/test', ncMetaAclMw(hookTest, 'hookTest')); +router.post('/tables/:tableId/hooks', ncMetaAclMw(hookCreate, 'hookCreate')); +router.delete('/hooks/:hookId', ncMetaAclMw(hookDelete, 'hookDelete')); +router.put('/hooks/:hookId', ncMetaAclMw(hookUpdate, 'hookUpdate')); router.get( '/tables/:tableId/hooks/samplePayload/:operation', catchError(tableSampleData) diff --git a/packages/nocodb/src/lib/noco/meta/api/hookFilterApis.ts b/packages/nocodb/src/lib/noco/meta/api/hookFilterApis.ts index 4e62527739..73573324f9 100644 --- a/packages/nocodb/src/lib/noco/meta/api/hookFilterApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/hookFilterApis.ts @@ -108,13 +108,25 @@ export async function filterDelete(req: Request, res: Response, next) { } const router = Router({ mergeParams: true }); -router.get('/hooks/:hookId/filters/', ncMetaAclMw(filterList)); -router.post('/hooks/:hookId/filters/', ncMetaAclMw(filterCreate)); -router.get('/hooks/:hookId/filters/:filterId', ncMetaAclMw(filterGet)); -router.put('/hooks/:hookId/filters/:filterId', ncMetaAclMw(filterUpdate)); -router.delete('/hooks/:hookId/filters/:filterId', ncMetaAclMw(filterDelete)); +router.get('/hooks/:hookId/filters/', ncMetaAclMw(filterList, 'filterList')); +router.post( + '/hooks/:hookId/filters/', + ncMetaAclMw(filterCreate, 'filterCreate') +); +router.get( + '/hooks/:hookId/filters/:filterId', + ncMetaAclMw(filterGet, 'filterGet') +); +router.put( + '/hooks/:hookId/filters/:filterId', + ncMetaAclMw(filterUpdate, 'filterUpdate') +); +router.delete( + '/hooks/:hookId/filters/:filterId', + ncMetaAclMw(filterDelete, 'filterDelete') +); router.get( '/hooks/:hookId/filters/:filterParentId/children', - ncMetaAclMw(filterChildrenRead) + ncMetaAclMw(filterChildrenRead, 'filterChildrenRead') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts b/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts index c474075338..6b9f2ead4a 100644 --- a/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts @@ -826,6 +826,9 @@ export async function extractAndGenerateManyToManyRelations( } const router = Router(); -router.get('/projects/:projectId/metaDiff', ncMetaAclMw(metaDiff)); -router.post('/projects/:projectId/metaDiff', ncMetaAclMw(metaDiffSync)); +router.get('/projects/:projectId/metaDiff', ncMetaAclMw(metaDiff, 'metaDiff')); +router.post( + '/projects/:projectId/metaDiff', + ncMetaAclMw(metaDiffSync, 'metaDiffSync') +); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/pluginApis.ts b/packages/nocodb/src/lib/noco/meta/api/pluginApis.ts index 18455285aa..2b3fd1657a 100644 --- a/packages/nocodb/src/lib/noco/meta/api/pluginApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/pluginApis.ts @@ -34,9 +34,9 @@ export async function isPluginActive(req: Request, res: Response) { } const router = Router({ mergeParams: true }); -router.get('/plugins', ncMetaAclMw(pluginList)); -router.post('/plugins/test', ncMetaAclMw(pluginTest)); -router.get('/plugins/:pluginId', ncMetaAclMw(pluginRead)); -router.put('/plugins/:pluginId', ncMetaAclMw(pluginUpdate)); -router.get('/plugins/:pluginTitle/status', ncMetaAclMw(isPluginActive)); +router.get('/plugins', ncMetaAclMw(pluginList, 'pluginList')); +router.post('/plugins/test', ncMetaAclMw(pluginTest, 'pluginTest')); +router.get('/plugins/:pluginId', ncMetaAclMw(pluginRead, 'pluginRead')); +router.put('/plugins/:pluginId', ncMetaAclMw(pluginUpdate, 'pluginUpdate')); +router.get('/plugins/:pluginTitle/status', ncMetaAclMw(isPluginActive, 'isPluginActive')); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/projectApis.ts b/packages/nocodb/src/lib/noco/meta/api/projectApis.ts index 09cdeeb1be..5323efd884 100644 --- a/packages/nocodb/src/lib/noco/meta/api/projectApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/projectApis.ts @@ -391,9 +391,15 @@ export async function projectInfoGet(req, res) { } export default router => { - router.get('/projects/:projectId/info', ncMetaAclMw(projectInfoGet)); - router.get('/projects/:projectId', ncMetaAclMw(projectGet)); - router.delete('/projects/:projectId', ncMetaAclMw(projectDelete)); - router.post('/projects', ncMetaAclMw(projectCreate)); - router.get('/projects', ncMetaAclMw(projectList)); + router.get( + '/projects/:projectId/info', + ncMetaAclMw(projectInfoGet, 'projectInfoGet') + ); + router.get('/projects/:projectId', ncMetaAclMw(projectGet, 'projectGet')); + router.delete( + '/projects/:projectId', + ncMetaAclMw(projectDelete, 'projectDelete') + ); + router.post('/projects', ncMetaAclMw(projectCreate, 'projectCreate')); + router.get('/projects', ncMetaAclMw(projectList, 'projectList')); }; diff --git a/packages/nocodb/src/lib/noco/meta/api/projectUserApis.ts b/packages/nocodb/src/lib/noco/meta/api/projectUserApis.ts index ce132be1ca..62c5f0b3ff 100644 --- a/packages/nocodb/src/lib/noco/meta/api/projectUserApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/projectUserApis.ts @@ -249,14 +249,17 @@ async function resendInvite(req, res, next): Promise { } const router = Router({ mergeParams: true }); -router.get('/projects/:projectId/users', ncMetaAclMw(userList)); -router.post('/projects/:projectId/users', ncMetaAclMw(userInvite)); +router.get('/projects/:projectId/users', ncMetaAclMw(userList, 'userList')); +router.post( + '/projects/:projectId/users', + ncMetaAclMw(userInvite, 'userInvite') +); router.put( '/projects/:projectId/users/:userId', - ncMetaAclMw(projectUserUpdate) + ncMetaAclMw(projectUserUpdate, 'projectUserUpdate') ); router.delete( '/projects/:projectId/users/:userId', - ncMetaAclMw(projectUserDelete) + ncMetaAclMw(projectUserDelete, 'projectUserDelete') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/sharedBaseApis.ts b/packages/nocodb/src/lib/noco/meta/api/sharedBaseApis.ts index ee5aa59427..df588e1ac6 100644 --- a/packages/nocodb/src/lib/noco/meta/api/sharedBaseApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/sharedBaseApis.ts @@ -99,18 +99,21 @@ async function publicSharedBaseGet(req, res): Promise { } const router = Router({ mergeParams: true }); -router.get('/projects/:projectId/sharedBase', ncMetaAclMw(getSharedBaseLink)); +router.get( + '/projects/:projectId/sharedBase', + ncMetaAclMw(getSharedBaseLink, 'getSharedBaseLink') +); router.post( '/projects/:projectId/sharedBase', - ncMetaAclMw(createSharedBaseLink) + ncMetaAclMw(createSharedBaseLink, 'createSharedBaseLink') ); router.put( '/projects/:projectId/sharedBase', - ncMetaAclMw(updateSharedBaseLink) + ncMetaAclMw(updateSharedBaseLink, 'updateSharedBaseLink') ); router.delete( '/projects/:projectId/sharedBase', - ncMetaAclMw(disableSharedBaseLink) + ncMetaAclMw(disableSharedBaseLink, 'disableSharedBaseLink') ); router.get('/public/sharedBase/:uuid', catchError(publicSharedBaseGet)); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/sortApis.ts b/packages/nocodb/src/lib/noco/meta/api/sortApis.ts index 9022b42b83..4ab4cfe0f0 100644 --- a/packages/nocodb/src/lib/noco/meta/api/sortApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/sortApis.ts @@ -51,9 +51,15 @@ export async function sortDelete(req: Request, res: Response, next) { } const router = Router({ mergeParams: true }); -router.get('/views/:viewId/sorts/', ncMetaAclMw(sortList)); -router.post('/views/:viewId/sorts/', ncMetaAclMw(sortCreate)); -router.get('/views/:viewId/sorts/:sortId', ncMetaAclMw(sortGet)); -router.put('/views/:viewId/sorts/:sortId', ncMetaAclMw(sortUpdate)); -router.delete('/views/:viewId/sorts/:sortId', ncMetaAclMw(sortDelete)); +router.get('/views/:viewId/sorts/', ncMetaAclMw(sortList, 'sortList')); +router.post('/views/:viewId/sorts/', ncMetaAclMw(sortCreate, 'sortCreate')); +router.get('/views/:viewId/sorts/:sortId', ncMetaAclMw(sortGet, 'sortGet')); +router.put( + '/views/:viewId/sorts/:sortId', + ncMetaAclMw(sortUpdate, 'sortUpdate') +); +router.delete( + '/views/:viewId/sorts/:sortId', + ncMetaAclMw(sortDelete, 'sortDelete') +); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/tableApis.ts b/packages/nocodb/src/lib/noco/meta/api/tableApis.ts index 8167fdaacb..58ee9686fa 100644 --- a/packages/nocodb/src/lib/noco/meta/api/tableApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/tableApis.ts @@ -222,10 +222,19 @@ export async function tableDelete(req: Request, res: Response, next) { } const router = Router({ mergeParams: true }); -router.get('/projects/:projectId/:baseId/tables', ncMetaAclMw(tableList)); -router.post('/projects/:projectId/:baseId/tables', ncMetaAclMw(tableCreate)); -router.get('/tables/:tableId', ncMetaAclMw(tableGet)); -router.put('/tables/:tableId', ncMetaAclMw(tableUpdate)); -router.delete('/tables/:tableId', ncMetaAclMw(tableDelete)); -router.post('/tables/:tableId/reorder', ncMetaAclMw(tableReorder)); +router.get( + '/projects/:projectId/:baseId/tables', + ncMetaAclMw(tableList, 'tableList') +); +router.post( + '/projects/:projectId/:baseId/tables', + ncMetaAclMw(tableCreate, 'tableCreate') +); +router.get('/tables/:tableId', ncMetaAclMw(tableGet, 'tableGet')); +router.put('/tables/:tableId', ncMetaAclMw(tableUpdate, 'tableUpdate')); +router.delete('/tables/:tableId', ncMetaAclMw(tableDelete, 'tableDelete')); +router.post( + '/tables/:tableId/reorder', + ncMetaAclMw(tableReorder, 'tableReorder') +); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/userApi/userApis.ts b/packages/nocodb/src/lib/noco/meta/api/userApi/userApis.ts index b840760fd0..d4bb10773c 100644 --- a/packages/nocodb/src/lib/noco/meta/api/userApi/userApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/userApi/userApis.ts @@ -401,7 +401,9 @@ const mapRoutes = router => { router.post('/auth/token/validate/:tokenId', catchError(tokenValidate)); router.post('/auth/password/reset/:tokenId', catchError(passwordReset)); router.post('/auth/email/validate/:tokenId', catchError(emailVerification)); - - router.post('/user/password/change', ncMetaAclMw(passwordChange)); + router.post( + '/user/password/change', + ncMetaAclMw(passwordChange, 'passwordChange') + ); }; export { mapRoutes as userApis }; diff --git a/packages/nocodb/src/lib/noco/meta/api/utilApis.ts b/packages/nocodb/src/lib/noco/meta/api/utilApis.ts index f49621e733..12243fac73 100644 --- a/packages/nocodb/src/lib/noco/meta/api/utilApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/utilApis.ts @@ -44,6 +44,6 @@ export async function appInfo(_req: Request, res: Response) { } export default router => { - router.post('/testConnection', ncMetaAclMw(testConnection)); + router.post('/testConnection', ncMetaAclMw(testConnection, 'testConnection')); router.get('/appInfo', catchError(appInfo)); }; diff --git a/packages/nocodb/src/lib/noco/meta/api/viewApis.ts b/packages/nocodb/src/lib/noco/meta/api/viewApis.ts index 7504cd470b..f61633cd8a 100644 --- a/packages/nocodb/src/lib/noco/meta/api/viewApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/viewApis.ts @@ -101,15 +101,30 @@ async function shareViewList(req: Request, res) { } const router = Router({ mergeParams: true }); -router.get('/tables/:tableId/views', ncMetaAclMw(viewList)); -router.put('/views/:viewId', ncMetaAclMw(viewUpdate)); -router.delete('/views/:viewId', ncMetaAclMw(viewDelete)); -router.post('/views/:viewId/showAll', ncMetaAclMw(showAllColumns)); -router.post('/views/:viewId/hideAll', ncMetaAclMw(hideAllColumns)); - -router.get('/tables/:tableId/share', ncMetaAclMw(shareViewList)); -router.post('/views/:viewId/share', ncMetaAclMw(shareView)); -router.put('/views/:viewId/share', ncMetaAclMw(shareViewPasswordUpdate)); -router.delete('/views/:viewId/share', ncMetaAclMw(shareViewDelete)); +router.get('/tables/:tableId/views', ncMetaAclMw(viewList, 'viewList')); +router.put('/views/:viewId', ncMetaAclMw(viewUpdate, 'viewUpdate')); +router.delete('/views/:viewId', ncMetaAclMw(viewDelete, 'viewDelete')); +router.post( + '/views/:viewId/showAll', + ncMetaAclMw(showAllColumns, 'showAllColumns') +); +router.post( + '/views/:viewId/hideAll', + ncMetaAclMw(hideAllColumns, 'hideAllColumns') +); + +router.get( + '/tables/:tableId/share', + ncMetaAclMw(shareViewList, 'shareViewList') +); +router.post('/views/:viewId/share', ncMetaAclMw(shareView, 'shareView')); +router.put( + '/views/:viewId/share', + ncMetaAclMw(shareViewPasswordUpdate, 'shareViewPasswordUpdate') +); +router.delete( + '/views/:viewId/share', + ncMetaAclMw(shareViewDelete, 'shareViewDelete') +); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/viewColumnApis.ts b/packages/nocodb/src/lib/noco/meta/api/viewColumnApis.ts index b8a6a3119e..dc15c5669e 100644 --- a/packages/nocodb/src/lib/noco/meta/api/viewColumnApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/viewColumnApis.ts @@ -31,8 +31,8 @@ export async function columnUpdate(req: Request, res: Response) { } const router = Router({ mergeParams: true }); -router.get('/views/:viewId/columns/', ncMetaAclMw(columnList)); -router.post('/views/:viewId/columns/', ncMetaAclMw(columnAdd)); +router.get('/views/:viewId/columns/', ncMetaAclMw(columnList, 'columnList')); +router.post('/views/:viewId/columns/', ncMetaAclMw(columnAdd, 'columnAdd')); router.put( '/views/:viewId/columns/:columnId', ncMetaAclMw(columnUpdate, 'viewColumnUpdate') diff --git a/packages/nocodb/src/lib/noco/meta/helpers/ncMetaAclMw.ts b/packages/nocodb/src/lib/noco/meta/helpers/ncMetaAclMw.ts index 27f199c570..90e7687750 100644 --- a/packages/nocodb/src/lib/noco/meta/helpers/ncMetaAclMw.ts +++ b/packages/nocodb/src/lib/noco/meta/helpers/ncMetaAclMw.ts @@ -2,7 +2,7 @@ import projectAcl from '../../../utils/projectAcl'; import { NextFunction, Request, Response } from 'express'; import catchError, { NcError } from './catchError'; import extractProjectIdAndAuthenticate from './extractProjectIdAndAuthenticate'; -export default function(handlerFn, permissionName = handlerFn.name) { +export default function(handlerFn, permissionName) { return [ extractProjectIdAndAuthenticate, catchError(function authMiddleware(req, _res, next) { From bb936e0e8021b604ae482209ba95753a8de07b14 Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Mon, 11 Apr 2022 11:54:28 +0530 Subject: [PATCH 21/81] test: enable screenshot on failure flag --- scripts/cypress/cypress.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cypress/cypress.json b/scripts/cypress/cypress.json index bb73f2de4c..006765dfbc 100644 --- a/scripts/cypress/cypress.json +++ b/scripts/cypress/cypress.json @@ -28,7 +28,7 @@ "viewportHeight": 1000, "video": false, "retries": 0, - "screenshotOnRunFailure": false, + "screenshotOnRunFailure": true, "numTestsKeptInMemory": 0, "env": { "testMode": [ From 97a0c09a1b20ecfa9634b93061d7b09328ad905d Mon Sep 17 00:00:00 2001 From: Pranav C Date: Mon, 11 Apr 2022 13:53:12 +0530 Subject: [PATCH 22/81] refactor(gui): hide row count from pagination component re #1644 Signed-off-by: Pranav C --- .../project/spreadsheet/components/pagination.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/components/pagination.vue b/packages/nc-gui/components/project/spreadsheet/components/pagination.vue index 481c056d43..ed69184d79 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/pagination.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/pagination.vue @@ -1,8 +1,8 @@ From 75155152cc32e981f065ab3cc921ae9cb990d6ac Mon Sep 17 00:00:00 2001 From: Pranav C Date: Mon, 11 Apr 2022 13:54:12 +0530 Subject: [PATCH 23/81] fix: extract project_id and base_id by using view id (#1645) Signed-off-by: Pranav C --- .../nocodb/src/lib/noco-models/ModelRoleVisibility.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/nocodb/src/lib/noco-models/ModelRoleVisibility.ts b/packages/nocodb/src/lib/noco-models/ModelRoleVisibility.ts index 3f0074a1d6..e3f2026112 100644 --- a/packages/nocodb/src/lib/noco-models/ModelRoleVisibility.ts +++ b/packages/nocodb/src/lib/noco-models/ModelRoleVisibility.ts @@ -6,8 +6,8 @@ import { CacheScope, MetaTable } from '../utils/globals'; -import Model from './Model'; import NocoCache from '../noco-cache/NocoCache'; +import View from './View'; export default class ModelRoleVisibility implements ModelRoleVisibilityType { id?: string; @@ -137,7 +137,6 @@ export default class ModelRoleVisibility implements ModelRoleVisibilityType { const insertObj = { role: body.role, disabled: body.disabled, - // fk_model_id: body.fk_model_id, fk_view_id: body.fk_view_id, project_id: body.project_id, base_id: body.base_id, @@ -146,9 +145,9 @@ export default class ModelRoleVisibility implements ModelRoleVisibilityType { }; if (!(body.project_id && body.base_id)) { - const model = await Model.getByIdOrName({ id: body.fk_model_id }, ncMeta); - insertObj.project_id = model.project_id; - insertObj.base_id = model.base_id; + const view = await View.get(body.fk_view_id, ncMeta); + insertObj.project_id = view.project_id; + insertObj.base_id = view.base_id; } await ncMeta.metaInsert2( From f5da0d8ac2db8e79eaec7d6809b060987dc15203 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Mon, 11 Apr 2022 14:49:07 +0530 Subject: [PATCH 24/81] refactor: close socket connection on error Signed-off-by: Pranav C --- packages/nc-gui/plugins/tele.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/nc-gui/plugins/tele.js b/packages/nc-gui/plugins/tele.js index dff1b6578e..20afcdef4c 100644 --- a/packages/nc-gui/plugins/tele.js +++ b/packages/nc-gui/plugins/tele.js @@ -33,6 +33,11 @@ export default function({ path: route.matched[0].path + (route.query && route.query.type ? `?type=${route.query.type}` : '') }) }) + + socket.on('connect_error', () => { + socket.disconnect() + socket = null + }) } const tele = { emit(evt, data) { From 12af229d8e32059c81d44ca46d185ef981d3fb01 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Mon, 11 Apr 2022 16:46:45 +0530 Subject: [PATCH 25/81] refactor: extract websocket and path based on axios baseurl Signed-off-by: Pranav C --- packages/nc-gui/plugins/tele.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/plugins/tele.js b/packages/nc-gui/plugins/tele.js index 20afcdef4c..bb4297d1f4 100644 --- a/packages/nc-gui/plugins/tele.js +++ b/packages/nc-gui/plugins/tele.js @@ -13,8 +13,12 @@ export default function({ if (socket) { socket.disconnect() } + const isUrl = $axios.defaults.baseURL.startsWith('http') + const url = isUrl ? $axios.defaults.baseURL : location.origin + const path = isUrl ? undefined : $axios.defaults.baseURL - socket = io($axios.defaults.baseURL, { + socket = io(url, { + path, extraHeaders: { 'xc-auth': token } }) @@ -81,7 +85,9 @@ export default function({ }) store.watch(state => state.project.projectInfo && state.project.projectInfo.teleEnabled && state.users.token, (token) => { - if (token) { init(token) } else if (socket) { + if (token) { + init(token) + } else if (socket) { socket.disconnect() socket = null } From 4f76ebffcd6f6428e5f11b620480c59f5c9c00bc Mon Sep 17 00:00:00 2001 From: Pranav C Date: Mon, 11 Apr 2022 17:21:26 +0530 Subject: [PATCH 26/81] wip Signed-off-by: Pranav C --- packages/nc-gui/package-lock.json | 79 ++- packages/nc-gui/package.json | 2 +- packages/nocodb/package-lock.json | 79 ++- .../noco/meta/api/dataApis/dataAliasApis.ts | 44 +- .../meta/api/dataApis/dataAliasExportApis.ts | 44 ++ .../src/lib/noco/meta/api/dataApis/helpers.ts | 155 +++++ .../src/lib/noco/meta/api/exportApis.ts | 136 +---- scripts/sdk/swagger.json | 569 +++++++++++------- 8 files changed, 707 insertions(+), 401 deletions(-) create mode 100644 packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasExportApis.ts create mode 100644 packages/nocodb/src/lib/noco/meta/api/dataApis/helpers.ts diff --git a/packages/nc-gui/package-lock.json b/packages/nc-gui/package-lock.json index 64c5383bdd..b81a35b561 100644 --- a/packages/nc-gui/package-lock.json +++ b/packages/nc-gui/package-lock.json @@ -26,7 +26,7 @@ "monaco-editor": "^0.19.3", "monaco-themes": "^0.2.5", "nano-assign": "^1.0.1", - "nocodb-sdk": "0.0.9", + "nocodb-sdk": "file:../nocodb-sdk", "nuxt": "^2.14.0", "odometer": "^0.4.8", "papaparse": "^5.3.1", @@ -69,6 +69,42 @@ "vue-eslint-parser": "^7.9.0" } }, + "../nocodb-sdk": { + "version": "0.0.9", + "license": "MIT", + "dependencies": { + "axios": "^0.21.1", + "jsep": "^0.4.0" + }, + "devDependencies": { + "@ava/typescript": "^1.1.1", + "@istanbuljs/nyc-config-typescript": "^1.0.1", + "@typescript-eslint/eslint-plugin": "^4.0.1", + "@typescript-eslint/parser": "^4.0.1", + "ava": "^3.12.1", + "codecov": "^3.5.0", + "cspell": "^4.1.0", + "cz-conventional-changelog": "^3.3.0", + "eslint": "^7.8.0", + "eslint-config-prettier": "^6.11.0", + "eslint-plugin-eslint-comments": "^3.2.0", + "eslint-plugin-functional": "^3.0.2", + "eslint-plugin-import": "^2.22.0", + "eslint-plugin-prettier": "^4.0.0", + "gh-pages": "^3.1.0", + "npm-run-all": "^4.1.5", + "nyc": "^15.1.0", + "open-cli": "^6.0.1", + "prettier": "^2.1.1", + "standard-version": "^9.0.0", + "ts-node": "^9.0.0", + "typedoc": "^0.19.0", + "typescript": "^4.0.2" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@ampproject/remapping": { "version": "2.1.2", "license": "Apache-2.0", @@ -9541,16 +9577,8 @@ } }, "node_modules/nocodb-sdk": { - "version": "0.0.9", - "resolved": "https://registry.npmjs.org/nocodb-sdk/-/nocodb-sdk-0.0.9.tgz", - "integrity": "sha512-MwvHh9WtplJtB2z41DbDUF09bYRLX4WBA+IytgPRWr5e3s8UEBzKZiKN7sLcVnmiY6a9ctT4Ad0CS4viwExoQw==", - "dependencies": { - "axios": "^0.21.1", - "jsep": "^0.4.0" - }, - "engines": { - "node": ">=10" - } + "resolved": "../nocodb-sdk", + "link": true }, "node_modules/node-fetch": { "version": "2.6.7", @@ -21397,12 +21425,33 @@ } }, "nocodb-sdk": { - "version": "0.0.9", - "resolved": "https://registry.npmjs.org/nocodb-sdk/-/nocodb-sdk-0.0.9.tgz", - "integrity": "sha512-MwvHh9WtplJtB2z41DbDUF09bYRLX4WBA+IytgPRWr5e3s8UEBzKZiKN7sLcVnmiY6a9ctT4Ad0CS4viwExoQw==", + "version": "file:../nocodb-sdk", "requires": { + "@ava/typescript": "^1.1.1", + "@istanbuljs/nyc-config-typescript": "^1.0.1", + "@typescript-eslint/eslint-plugin": "^4.0.1", + "@typescript-eslint/parser": "^4.0.1", + "ava": "^3.12.1", "axios": "^0.21.1", - "jsep": "^0.4.0" + "codecov": "^3.5.0", + "cspell": "^4.1.0", + "cz-conventional-changelog": "^3.3.0", + "eslint": "^7.8.0", + "eslint-config-prettier": "^6.11.0", + "eslint-plugin-eslint-comments": "^3.2.0", + "eslint-plugin-functional": "^3.0.2", + "eslint-plugin-import": "^2.22.0", + "eslint-plugin-prettier": "^4.0.0", + "gh-pages": "^3.1.0", + "jsep": "^0.4.0", + "npm-run-all": "^4.1.5", + "nyc": "^15.1.0", + "open-cli": "^6.0.1", + "prettier": "^2.1.1", + "standard-version": "^9.0.0", + "ts-node": "^9.0.0", + "typedoc": "^0.19.0", + "typescript": "^4.0.2" } }, "node-fetch": { diff --git a/packages/nc-gui/package.json b/packages/nc-gui/package.json index 0d4d1143c0..67e5eb682c 100644 --- a/packages/nc-gui/package.json +++ b/packages/nc-gui/package.json @@ -29,7 +29,7 @@ "monaco-editor": "^0.19.3", "monaco-themes": "^0.2.5", "nano-assign": "^1.0.1", - "nocodb-sdk": "0.0.9", + "nocodb-sdk": "file:../nocodb-sdk", "nuxt": "^2.14.0", "odometer": "^0.4.8", "papaparse": "^5.3.1", diff --git a/packages/nocodb/package-lock.json b/packages/nocodb/package-lock.json index c236fa1309..5b18455bdd 100644 --- a/packages/nocodb/package-lock.json +++ b/packages/nocodb/package-lock.json @@ -72,7 +72,7 @@ "nc-lib-gui": "0.84.15", "nc-plugin": "^0.1.1", "ncp": "^2.0.0", - "nocodb-sdk": "0.0.9", + "nocodb-sdk": "file:../nocodb-sdk", "nodemailer": "^6.4.10", "ora": "^4.0.4", "os-locale": "^5.0.0", @@ -227,6 +227,42 @@ "node": ">=8.9" } }, + "../nocodb-sdk": { + "version": "0.0.9", + "license": "MIT", + "dependencies": { + "axios": "^0.21.1", + "jsep": "^0.4.0" + }, + "devDependencies": { + "@ava/typescript": "^1.1.1", + "@istanbuljs/nyc-config-typescript": "^1.0.1", + "@typescript-eslint/eslint-plugin": "^4.0.1", + "@typescript-eslint/parser": "^4.0.1", + "ava": "^3.12.1", + "codecov": "^3.5.0", + "cspell": "^4.1.0", + "cz-conventional-changelog": "^3.3.0", + "eslint": "^7.8.0", + "eslint-config-prettier": "^6.11.0", + "eslint-plugin-eslint-comments": "^3.2.0", + "eslint-plugin-functional": "^3.0.2", + "eslint-plugin-import": "^2.22.0", + "eslint-plugin-prettier": "^4.0.0", + "gh-pages": "^3.1.0", + "npm-run-all": "^4.1.5", + "nyc": "^15.1.0", + "open-cli": "^6.0.1", + "prettier": "^2.1.1", + "standard-version": "^9.0.0", + "ts-node": "^9.0.0", + "typedoc": "^0.19.0", + "typescript": "^4.0.2" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@assemblyscript/loader": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/@assemblyscript/loader/-/loader-0.10.1.tgz", @@ -16216,16 +16252,8 @@ "dev": true }, "node_modules/nocodb-sdk": { - "version": "0.0.9", - "resolved": "https://registry.npmjs.org/nocodb-sdk/-/nocodb-sdk-0.0.9.tgz", - "integrity": "sha512-MwvHh9WtplJtB2z41DbDUF09bYRLX4WBA+IytgPRWr5e3s8UEBzKZiKN7sLcVnmiY6a9ctT4Ad0CS4viwExoQw==", - "dependencies": { - "axios": "^0.21.1", - "jsep": "^0.4.0" - }, - "engines": { - "node": ">=10" - } + "resolved": "../nocodb-sdk", + "link": true }, "node_modules/node-addon-api": { "version": "2.0.0", @@ -37627,12 +37655,33 @@ "dev": true }, "nocodb-sdk": { - "version": "0.0.9", - "resolved": "https://registry.npmjs.org/nocodb-sdk/-/nocodb-sdk-0.0.9.tgz", - "integrity": "sha512-MwvHh9WtplJtB2z41DbDUF09bYRLX4WBA+IytgPRWr5e3s8UEBzKZiKN7sLcVnmiY6a9ctT4Ad0CS4viwExoQw==", + "version": "file:../nocodb-sdk", "requires": { + "@ava/typescript": "^1.1.1", + "@istanbuljs/nyc-config-typescript": "^1.0.1", + "@typescript-eslint/eslint-plugin": "^4.0.1", + "@typescript-eslint/parser": "^4.0.1", + "ava": "^3.12.1", "axios": "^0.21.1", - "jsep": "^0.4.0" + "codecov": "^3.5.0", + "cspell": "^4.1.0", + "cz-conventional-changelog": "^3.3.0", + "eslint": "^7.8.0", + "eslint-config-prettier": "^6.11.0", + "eslint-plugin-eslint-comments": "^3.2.0", + "eslint-plugin-functional": "^3.0.2", + "eslint-plugin-import": "^2.22.0", + "eslint-plugin-prettier": "^4.0.0", + "gh-pages": "^3.1.0", + "jsep": "^0.4.0", + "npm-run-all": "^4.1.5", + "nyc": "^15.1.0", + "open-cli": "^6.0.1", + "prettier": "^2.1.1", + "standard-version": "^9.0.0", + "ts-node": "^9.0.0", + "typedoc": "^0.19.0", + "typescript": "^4.0.2" } }, "node-addon-api": { diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasApis.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasApis.ts index 92b16f9341..0167b8692f 100644 --- a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasApis.ts @@ -6,16 +6,15 @@ import NcConnectionMgrv2 from '../../../common/NcConnectionMgrv2'; import { PagedResponseImpl } from '../../helpers/PagedResponse'; import View from '../../../../noco-models/View'; import ncMetaAclMw from '../../helpers/ncMetaAclMw'; -import Project from '../../../../noco-models/Project'; -import { NcError } from '../../helpers/catchError'; +import { getViewAndModelFromRequestByAliasOrId } from './helpers'; export async function dataList(req: Request, res: Response) { - const { model, view } = await getViewAndModelFromRequest(req); + const { model, view } = await getViewAndModelFromRequestByAliasOrId(req); res.json(await getDataList(model, view, req)); } async function dataInsert(req: Request, res: Response) { - const { model, view } = await getViewAndModelFromRequest(req); + const { model, view } = await getViewAndModelFromRequestByAliasOrId(req); const base = await Base.get(model.base_id); @@ -29,7 +28,7 @@ async function dataInsert(req: Request, res: Response) { } async function dataUpdate(req: Request, res: Response) { - const { model, view } = await getViewAndModelFromRequest(req); + const { model, view } = await getViewAndModelFromRequestByAliasOrId(req); const base = await Base.get(model.base_id); const baseModel = await Model.getBaseModelSQL({ @@ -42,7 +41,7 @@ async function dataUpdate(req: Request, res: Response) { } async function dataDelete(req: Request, res: Response) { - const { model, view } = await getViewAndModelFromRequest(req); + const { model, view } = await getViewAndModelFromRequestByAliasOrId(req); const base = await Base.get(model.base_id); const baseModel = await Model.getBaseModelSQL({ id: model.id, @@ -85,25 +84,9 @@ async function getDataList(model, view: View, req) { count }); } -async function getViewAndModelFromRequest(req) { - const project = await Project.getWithInfoByTitle(req.params.projectName); - const model = await Model.getByAliasOrId({ - project_id: project.id, - base_id: project.bases?.[0]?.id, - aliasOrId: req.params.tableName - }); - const view = - req.params.viewName && - (await View.getByTitleOrId({ - titleOrId: req.params.viewName, - fk_model_id: model.id - })); - if (!model) NcError.notFound('Table not found'); - return { model, view }; -} async function dataRead(req: Request, res: Response) { - const { model, view } = await getViewAndModelFromRequest(req); + const { model, view } = await getViewAndModelFromRequestByAliasOrId(req); const base = await Base.get(model.base_id); @@ -125,26 +108,29 @@ async function dataRead(req: Request, res: Response) { const router = Router({ mergeParams: true }); -router.get('/data/:orgs/:projectName/:tableName', ncMetaAclMw(dataList, 'dataList')); router.get( - '/data/:orgs/:projectName/:tableName/views/:viewName', + '/api/v1/db/data/:orgs/:projectName/:tableName', + ncMetaAclMw(dataList, 'dataList') +); +router.get( + '/api/v1/db/data/:orgs/:projectName/:tableName/views/:viewName', ncMetaAclMw(dataList, 'dataList') ); router.post( - '/data/:orgs/:projectName/:tableName/views/:viewName', + '/api/v1/db/data/:orgs/:projectName/:tableName/views/:viewName', ncMetaAclMw(dataInsert, 'dataInsert') ); router.put( - '/data/:orgs/:projectName/:tableName/views/:viewName/:rowId', + '/api/v1/db/data/:orgs/:projectName/:tableName/views/:viewName/:rowId', ncMetaAclMw(dataUpdate, 'dataUpdate') ); router.get( - '/data/:orgs/:projectName/:tableName/views/:viewName/:rowId', + '/api/v1/db/data/:orgs/:projectName/:tableName/views/:viewName/:rowId', ncMetaAclMw(dataRead, 'dataRead') ); router.delete( - '/data/:orgs/:projectName/:tableName/views/:viewName/:rowId', + '/api/v1/db/data/:orgs/:projectName/:tableName/views/:viewName/:rowId', ncMetaAclMw(dataDelete, 'dataDelete') ); diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasExportApis.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasExportApis.ts new file mode 100644 index 0000000000..7f0ab6e9f7 --- /dev/null +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasExportApis.ts @@ -0,0 +1,44 @@ +import { Request, Response, Router } from 'express'; +import ncMetaAclMw from '../../helpers/ncMetaAclMw'; +import { + extractCsvData, + getViewAndModelFromRequestByAliasOrId +} from './helpers'; +import papaparse from 'papaparse'; + +async function csvDataExport(req: Request, res: Response) { + const { model, view } = await getViewAndModelFromRequestByAliasOrId(req); + + const { offset, csvRows, elapsed } = await extractCsvData(model, view, req); + + const data = papaparse.unparse( + { + fields: model.columns.map(c => c.title), + data: csvRows + }, + { + escapeFormulae: true + } + ); + + res.set({ + 'Access-Control-Expose-Headers': 'nc-export-offset', + 'nc-export-offset': offset, + 'nc-export-elapsed-time': elapsed, + 'Content-Disposition': `attachment; filename="${view.title}-export.csv"` + }); + res.send(data); +} + +const router = Router({ mergeParams: true }); + +router.get( + '/api/v1/db/data/:orgs/:projectName/:tableName/export/csv', + ncMetaAclMw(csvDataExport, 'csvDataExport') +); +router.get( + '/api/v1/db/data/:orgs/:projectName/:tableName/views/:viewName/export/csv', + ncMetaAclMw(csvDataExport, 'csvDataExport') +); + +export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/helpers.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/helpers.ts new file mode 100644 index 0000000000..1ec91fe880 --- /dev/null +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/helpers.ts @@ -0,0 +1,155 @@ +import Project from '../../../../noco-models/Project'; +import Model from '../../../../noco-models/Model'; +import View from '../../../../noco-models/View'; +import { NcError } from '../../helpers/catchError'; +import { Request } from 'express'; +import Base from '../../../../noco-models/Base'; +import NcConnectionMgrv2 from '../../../common/NcConnectionMgrv2'; +import { isSystemColumn, UITypes } from 'nocodb-sdk'; + +import { nocoExecute } from 'nc-help'; +import Column from '../../../../noco-models/Column'; +import LookupColumn from '../../../../noco-models/LookupColumn'; +import LinkToAnotherRecordColumn from '../../../../noco-models/LinkToAnotherRecordColumn'; + +export async function getViewAndModelFromRequestByAliasOrId( + req: + | Request<{ projectName: string; tableName: string; viewName?: string }> + | Request +) { + let project = await Project.getWithInfoByTitle(req.params.projectName); + + if (!project) { + project = await Project.getWithInfo(req.params.projectName); + } + + const model = await Model.getByAliasOrId({ + project_id: project.id, + base_id: project.bases?.[0]?.id, + aliasOrId: req.params.tableName + }); + const view = + req.params.viewName && + (await View.getByTitleOrId({ + titleOrId: req.params.viewName, + fk_model_id: model.id + })); + if (!model) NcError.notFound('Table not found'); + return { model, view }; +} + +export async function extractCsvData(model: Model, view: View, req: Request) { + const base = await Base.get(model.base_id); + const baseModel = await Model.getBaseModelSQL({ + id: model.id, + viewId: view?.id, + dbDriver: NcConnectionMgrv2.get(base) + }); + + let offset = +req.query.offset || 0; + const limit = 100; + // const size = +process.env.NC_EXPORT_MAX_SIZE || 1024; + const timeout = +process.env.NC_EXPORT_MAX_TIMEOUT || 5000; + const csvRows = []; + const startTime = process.hrtime(); + let elapsed, temp; + + for ( + elapsed = 0; + elapsed < timeout; + offset += limit, + temp = process.hrtime(startTime), + elapsed = temp[0] * 1000 + temp[1] / 1000000 + ) { + const rows = await nocoExecute( + await baseModel.defaultResolverReq(req.query, false, false), + await baseModel.list({ ...req.query, offset, limit }), + {}, + req.query + ); + + if (!rows?.length) { + offset = -1; + break; + } + + for (const row of rows) { + const csvRow = { ...row }; + + for (const column of view.model.columns) { + if (isSystemColumn(column) && !view.show_system_fields) continue; + csvRow[column.title] = await serializeCellValue({ + value: row[column.title], + column + }); + } + csvRows.push(csvRow); + } + } + return { offset, csvRows, elapsed }; +} + +export async function serializeCellValue({ + value, + column +}: { + column?: Column; + value: any; +}) { + if (!column) { + return value; + } + + if (!value) return value; + + switch (column?.uidt) { + case UITypes.Attachment: { + let data = value; + try { + if (typeof value === 'string') { + data = JSON.parse(value); + } + } catch {} + + return (data || []).map( + attachment => + `${encodeURI(attachment.title)}(${encodeURI(attachment.url)})` + ); + } + case UITypes.Lookup: + { + const colOptions = await column.getColOptions(); + const lookupColumn = await colOptions.getLookupColumn(); + return ( + await Promise.all( + [...(Array.isArray(value) ? value : [value])].map(async v => + serializeCellValue({ + value: v, + column: lookupColumn + }) + ) + ) + ).join(', '); + } + break; + case UITypes.LinkToAnotherRecord: + { + const colOptions = await column.getColOptions< + LinkToAnotherRecordColumn + >(); + const relatedModel = await colOptions.getRelatedTable(); + await relatedModel.getColumns(); + return [...(Array.isArray(value) ? value : [value])] + .map(v => { + return v[relatedModel.primaryValue?.title]; + }) + .join(', '); + } + break; + default: + if (value && typeof value === 'object') { + return JSON.stringify(value); + } + return value; + } +} diff --git a/packages/nocodb/src/lib/noco/meta/api/exportApis.ts b/packages/nocodb/src/lib/noco/meta/api/exportApis.ts index d995aefa25..0f2c2b14d9 100644 --- a/packages/nocodb/src/lib/noco/meta/api/exportApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/exportApis.ts @@ -1,15 +1,10 @@ import { Request, Response, Router } from 'express'; import View from '../../../noco-models/View'; -import Model from '../../../noco-models/Model'; -import Base from '../../../noco-models/Base'; -import NcConnectionMgrv2 from '../../common/NcConnectionMgrv2'; -import { nocoExecute } from 'nc-help'; import papaparse from 'papaparse'; -import { isSystemColumn, UITypes } from 'nocodb-sdk'; +import { isSystemColumn } from 'nocodb-sdk'; import Column from '../../../noco-models/Column'; -import LinkToAnotherRecordColumn from '../../../noco-models/LinkToAnotherRecordColumn'; -import LookupColumn from '../../../noco-models/LookupColumn'; import ncMetaAclMw from '../helpers/ncMetaAclMw'; +import { extractCsvData } from './dataApis/helpers'; async function exportCsv(req: Request, res: Response, next) { const view = await View.get(req.params.viewId); @@ -26,67 +21,7 @@ async function exportCsv(req: Request, res: Response, next) { .filter(column => !isSystemColumn(column) || view.show_system_fields); if (!model) return next(new Error('Table not found')); - - const base = await Base.get(model.base_id); - const baseModel = await Model.getBaseModelSQL({ - id: model.id, - viewId: view?.id, - dbDriver: NcConnectionMgrv2.get(base) - }); - - const key = `${model.title}List`; - const requestObj = { - [key]: await baseModel.defaultResolverReq(req.query, false, false) - }; - - let offset = +req.query.offset || 0; - const limit = 100; - // const size = +process.env.NC_EXPORT_MAX_SIZE || 1024; - const timeout = +process.env.NC_EXPORT_MAX_TIMEOUT || 5000; - const csvRows = []; - const startTime = process.hrtime(); - let elapsed, temp; - - for ( - elapsed = 0; - elapsed < timeout; - offset += limit, - temp = process.hrtime(startTime), - elapsed = temp[0] * 1000 + temp[1] / 1000000 - ) { - console.time('nocoExecute'); - const rows = ( - await nocoExecute( - requestObj, - { - [key]: async args => { - return await baseModel.list({ ...args, offset, limit }); - } - }, - {}, - { nested: { [key]: req.query } } - ) - )?.[key]; - - if (!rows?.length) { - offset = -1; - break; - } - - for (const row of rows) { - const csvRow = { ...row }; - - for (const column of view.model.columns) { - if (isSystemColumn(column) && !view.show_system_fields) continue; - csvRow[column.title] = await serializeCellValue({ - value: row[column.title], - column - }); - } - csvRows.push(csvRow); - } - console.timeEnd('nocoExecute'); - } + const { offset, csvRows, elapsed } = await extractCsvData(model, view, req); const data = papaparse.unparse( { @@ -107,71 +42,6 @@ async function exportCsv(req: Request, res: Response, next) { res.send(data); } -async function serializeCellValue({ - value, - column -}: { - column?: Column; - value: any; -}) { - if (!column) { - return value; - } - - if (!value) return value; - - switch (column?.uidt) { - case UITypes.Attachment: { - let data = value; - try { - if (typeof value === 'string') { - data = JSON.parse(value); - } - } catch {} - - return (data || []).map( - attachment => - `${encodeURI(attachment.title)}(${encodeURI(attachment.url)})` - ); - } - case UITypes.Lookup: - { - const colOptions = await column.getColOptions(); - const lookupColumn = await colOptions.getLookupColumn(); - return ( - await Promise.all( - [...(Array.isArray(value) ? value : [value])].map(async v => - serializeCellValue({ - value: v, - column: lookupColumn - }) - ) - ) - ).join(', '); - } - break; - case UITypes.LinkToAnotherRecord: - { - const colOptions = await column.getColOptions< - LinkToAnotherRecordColumn - >(); - const relatedModel = await colOptions.getRelatedTable(); - await relatedModel.getColumns(); - return [...(Array.isArray(value) ? value : [value])] - .map(v => { - return v[relatedModel.primaryValue?.title]; - }) - .join(', '); - } - break; - default: - if (value && typeof value === 'object') { - return JSON.stringify(value); - } - return value; - } -} - const router = Router({ mergeParams: true }); router.get('/data/:viewId/export/csv', ncMetaAclMw(exportCsv, 'exportCsv')); export default router; diff --git a/scripts/sdk/swagger.json b/scripts/sdk/swagger.json index 7df510d1c4..11be38b85d 100644 --- a/scripts/sdk/swagger.json +++ b/scripts/sdk/swagger.json @@ -2817,7 +2817,59 @@ } } }, - "/data/{orgs}/{projectName}/{tableAlias}": { + "/data/{tableId}/export/{type}": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "tableId", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string", + "enum": [ + "csv", + "excel" + ] + }, + "name": "type", + "in": "path", + "required": true + } + ], + "get": { + "summary": "", + "operationId": "data-csv-export", + "description": "CSV or Excel export", + "tags": [ + "Data" + ], + "wrapped": true, + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": {} + } + }, + "headers": { + "nc-export-offset": { + "schema": { + "type": "integer" + } + } + } + } + }, + "parameters": [] + } + }, + + "/api/v1/db/data/{orgs}/{projectName}/{tableAlias}": { "parameters": [ { "schema": { @@ -2910,7 +2962,7 @@ } } }, - "/data/{orgs}/{projectName}/{tableAlias}/views/{viewName}": { + "/api/v1/db/data/{orgs}/{projectName}/{tableAlias}/views/{viewName}": { "parameters": [ { "schema": { @@ -2991,39 +3043,328 @@ } } } - }, - "post": { + }, + "post": { + "summary": "", + "operationId": "db-view-row-create", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": {} + } + } + } + }, + "tags": [ + "DB View Row" + ], + "requestBody": { + "content": { + "application/json": { + "schema": {} + } + } + } + } + }, + "/api/v1/db/data/{orgs}/{projectName}/{tableAlias}/views/{viewName}/{rowId}": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "orgs", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "projectName", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "tableAlias", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "viewName", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "rowId", + "in": "path", + "required": true + } + ], + "get": { + "summary": "", + "operationId": "db-view-row-read", + "responses": { + "201": { + "description": "Created", + "content": { + "application/json": { + "schema": {} + } + } + } + }, + "description": "", + "tags": [ + "DB View Row" + ] + }, + "put": { + "summary": "", + "operationId": "db-view-row-update", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": {} + } + } + } + }, + "tags": [ + "DB View Row" + ], + "requestBody": { + "content": { + "application/json": { + "schema": {} + } + } + } + }, + "delete": { + "summary": "", + "operationId": "db-view-row-delete", + "responses": { + "200": { + "description": "OK" + } + }, + "tags": [ + "DB View Row" + ], + "description": "" + } + }, + "/api/v1/db/data/{orgs}/{projectName}/{tableAlias}/{rowId}": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "orgs", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "projectName", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "tableAlias", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "rowId", + "in": "path", + "required": true + } + ], + "get": { + "summary": "", + "operationId": "db-table-row-read", + "responses": { + "201": { + "description": "Created", + "content": { + "application/json": { + "schema": {} + } + } + } + }, + "description": "", + "tags": [ + "DB Table Row" + ] + }, + "put": { + "summary": "", + "operationId": "db-table-row-update", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": {} + } + } + } + }, + "tags": [ + "DB Table Row" + ], + "requestBody": { + "content": { + "application/json": { + "schema": {} + } + } + } + }, + "delete": { + "summary": "", + "operationId": "db-table-row-model-delete", + "responses": { + "200": { + "description": "OK" + } + }, + "tags": [ + "DB Table Row" + ], + "description": "" + } + }, + "/api/v1/db/data/{orgs}/{projectName}/{tableAlias}/views/{viewName}/export/{type}": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "orgs", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "projectName", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "tableAlias", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "viewName", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string", + "enum": [ + "csv", + "excel" + ] + }, + "name": "type", + "in": "path", + "required": true + } + ], + "get": { "summary": "", - "operationId": "db-view-row-create", + "operationId": "data-csv-export", + "description": "CSV or Excel export", + "tags": [ + "Data" + ], + "wrapped": true, "responses": { "200": { "description": "OK", "content": { - "application/json": { + "application/octet-stream": { "schema": {} } + }, + "headers": { + "nc-export-offset": { + "schema": { + "type": "integer" + } + } } } }, - "tags": [ - "DB View Row" - ], - "requestBody": { - "content": { - "application/json": { - "schema": {} - } - } - } + "parameters": [] } }, - "/data/{tableId}/export/{type}": { + "/api/v1/db/data/{orgs}/{projectName}/{tableAlias}/export/{type}": { "parameters": [ { "schema": { "type": "string" }, - "name": "tableId", + "name": "orgs", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "projectName", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "tableAlias", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "viewName", "in": "path", "required": true }, @@ -3068,6 +3409,8 @@ "parameters": [] } }, + + "/public/data/{uuid}/list": { "parameters": [ { @@ -3792,196 +4135,6 @@ "description": "" } }, - "/data/{orgs}/{projectName}/{tableAlias}/views/{viewName}/{rowId}": { - "parameters": [ - { - "schema": { - "type": "string" - }, - "name": "orgs", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "projectName", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "tableAlias", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "viewName", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "rowId", - "in": "path", - "required": true - } - ], - "get": { - "summary": "", - "operationId": "db-view-row-read", - "responses": { - "201": { - "description": "Created", - "content": { - "application/json": { - "schema": {} - } - } - } - }, - "description": "", - "tags": [ - "DB View Row" - ] - }, - "put": { - "summary": "", - "operationId": "db-view-row-update", - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": {} - } - } - } - }, - "tags": [ - "DB View Row" - ], - "requestBody": { - "content": { - "application/json": { - "schema": {} - } - } - } - }, - "delete": { - "summary": "", - "operationId": "db-view-row-delete", - "responses": { - "200": { - "description": "OK" - } - }, - "tags": [ - "DB View Row" - ], - "description": "" - } - }, - "/data/{orgs}/{projectName}/{tableAlias}/{rowId}": { - "parameters": [ - { - "schema": { - "type": "string" - }, - "name": "orgs", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "projectName", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "tableAlias", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "rowId", - "in": "path", - "required": true - } - ], - "get": { - "summary": "", - "operationId": "db-table-row-read", - "responses": { - "201": { - "description": "Created", - "content": { - "application/json": { - "schema": {} - } - } - } - }, - "description": "", - "tags": [ - "DB Table Row" - ] - }, - "put": { - "summary": "", - "operationId": "db-table-row-update", - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": {} - } - } - } - }, - "tags": [ - "DB Table Row" - ], - "requestBody": { - "content": { - "application/json": { - "schema": {} - } - } - } - }, - "delete": { - "summary": "", - "operationId": "db-table-row-model-delete", - "responses": { - "200": { - "description": "OK" - } - }, - "tags": [ - "DB Table Row" - ], - "description": "" - } - }, "/audits/comments": { "parameters": [], "get": { From 2b7a929b1655abd2e7527ec7583d27acc193a4c0 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Mon, 11 Apr 2022 16:46:45 +0530 Subject: [PATCH 27/81] refactor: extract websocket and path based on axios baseurl Signed-off-by: Pranav C --- packages/nc-gui/plugins/tele.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/plugins/tele.js b/packages/nc-gui/plugins/tele.js index 20afcdef4c..9cd1437712 100644 --- a/packages/nc-gui/plugins/tele.js +++ b/packages/nc-gui/plugins/tele.js @@ -13,8 +13,12 @@ export default function({ if (socket) { socket.disconnect() } + const isUrl = $axios.defaults.baseURL.startsWith('http') + const url = isUrl ? $axios.defaults.baseURL : window.location.href.split(/[?#]/)[0] + const path = isUrl ? undefined : $axios.defaults.baseURL - socket = io($axios.defaults.baseURL, { + socket = io(url, { + path, extraHeaders: { 'xc-auth': token } }) @@ -81,7 +85,9 @@ export default function({ }) store.watch(state => state.project.projectInfo && state.project.projectInfo.teleEnabled && state.users.token, (token) => { - if (token) { init(token) } else if (socket) { + if (token) { + init(token) + } else if (socket) { socket.disconnect() socket = null } From bf048ce29448dc894041bbbbd51b67b13bc9419e Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 01:36:51 +0530 Subject: [PATCH 28/81] refactor: new api design Signed-off-by: Pranav C --- .../spreadsheet/components/columnFilter.vue | 16 +- .../spreadsheet/components/sortListMenu.vue | 4 +- .../project/spreadsheet/rowsXcDataTable.vue | 11 +- packages/nc-gui/mixins/device.js | 4 +- packages/nc-gui/store/project.js | 8 +- packages/nocodb-sdk/src/lib/Api.ts | 2018 +++++++-------- packages/nocodb/package.json | 2 +- packages/nocodb/src/lib/noco-models/User.ts | 7 + .../src/lib/noco/meta/api/apiTokenApis.ts | 6 +- .../nocodb/src/lib/noco/meta/api/auditApis.ts | 24 +- .../nocodb/src/lib/noco/meta/api/cacheApis.ts | 4 +- .../src/lib/noco/meta/api/columnApis.ts | 29 +- .../noco/meta/api/dataApis/dataAliasApis.ts | 28 +- .../meta/api/dataApis/dataAliasNestedApis.ts | 308 +++ .../lib/noco/meta/api/dataApis/dataApis.ts | 4 +- .../lib/noco/meta/api/dataApis/oldDataApis.ts | 2 +- .../src/lib/noco/meta/api/filterApis.ts | 52 +- .../src/lib/noco/meta/api/formViewApis.ts | 14 +- .../lib/noco/meta/api/formViewColumnApis.ts | 4 +- .../src/lib/noco/meta/api/galleryViewApis.ts | 33 +- .../src/lib/noco/meta/api/gridViewApis.ts | 2 +- .../lib/noco/meta/api/gridViewColumnApis.ts | 6 +- .../nocodb/src/lib/noco/meta/api/hookApis.ts | 27 +- .../src/lib/noco/meta/api/hookFilterApis.ts | 2 +- .../src/lib/noco/meta/api/metaDiffApis.ts | 7 +- .../lib/noco/meta/api/modelVisibilityApis.ts | 2 +- .../src/lib/noco/meta/api/pluginApis.ts | 22 +- .../src/lib/noco/meta/api/projectApis.ts | 19 +- .../src/lib/noco/meta/api/projectUserApis.ts | 2 +- .../meta/api/publicApis/publicDataApis.ts | 2 +- .../meta/api/publicApis/publicMetaApis.ts | 22 +- .../src/lib/noco/meta/api/sharedBaseApis.ts | 22 +- .../nocodb/src/lib/noco/meta/api/sortApis.ts | 24 +- .../nocodb/src/lib/noco/meta/api/tableApis.ts | 21 +- .../noco/meta/api/userApi/initStrategies.ts | 7 +- .../src/lib/noco/meta/api/userApi/userApis.ts | 51 +- .../nocodb/src/lib/noco/meta/api/utilApis.ts | 7 +- .../nocodb/src/lib/noco/meta/api/viewApis.ts | 32 +- .../src/lib/noco/meta/api/viewColumnApis.ts | 14 +- scripts/sdk/swagger.json | 2214 ++++++++--------- 40 files changed, 2594 insertions(+), 2489 deletions(-) create mode 100644 packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasNestedApis.ts diff --git a/packages/nc-gui/components/project/spreadsheet/components/columnFilter.vue b/packages/nc-gui/components/project/spreadsheet/components/columnFilter.vue index 47f9ba6959..d5d0310682 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/columnFilter.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/columnFilter.vue @@ -321,19 +321,19 @@ export default { for (const [i, filter] of Object.entries(this.filters)) { if (filter.status === 'delete') { if (this.hookId || hookId) { - await this.$api.dbTableFilter.delete(this.hookId || hookId, filter.id) + await this.$api.dbTableFilter.delete(filter.id) } else { - await this.$api.dbTableFilter.delete(this.viewId, filter.id) + await this.$api.dbTableFilter.delete(filter.id) } } else if (filter.status === 'update') { if (filter.id) { if (this.hookId || hookId) { - await this.$api.dbTableFilter.update(this.hookId || hookId, filter.id, { + await this.$api.dbTableFilter.update(filter.id, { ...filter, fk_parent_id: this.parentId }) } else { - await this.$api.dbTableFilter.update(this.viewId, filter.id, { + await this.$api.dbTableFilter.update(filter.id, { ...filter, fk_parent_id: this.parentId }) @@ -363,12 +363,12 @@ export default { let filters = [] if (this.viewId && this._isUIAllowed('filterSync')) { filters = this.parentId - ? (await this.$api.dbTableFilter.childrenRead(this.viewId, this.parentId)) + ? (await this.$api.dbTableFilter.childrenRead(this.parentId)) : (await this.$api.dbTableFilter.read(this.viewId)) } if (this.hookId && this._isUIAllowed('filterSync')) { filters = this.parentId - ? (await this.$api.dbTableWebhookFilter.childrenRead(this.hookId, this.parentId)) + ? (await this.$api.dbTableFilter.childrenRead(this.parentId)) : (await this.$api.dbTableWebhookFilter.read(this.hookId)) } @@ -406,7 +406,7 @@ export default { } else if (!this.autoApply) { filter.status = 'update' } else if (filter.id) { - await this.$api.dbTableFilter.update(this.viewId, filter.id, { + await this.$api.dbTableFilter.update(filter.id, { ...filter, fk_parent_id: this.parentId }) @@ -430,7 +430,7 @@ export default { if (!this.autoApply) { this.$set(filter, 'status', 'delete') } else { - await this.$api.dbTableFilter.delete(this.viewId, filter.id) + await this.$api.dbTableFilter.delete(filter.id) await this.loadFilter() this.$emit('updated') } diff --git a/packages/nc-gui/components/project/spreadsheet/components/sortListMenu.vue b/packages/nc-gui/components/project/spreadsheet/components/sortListMenu.vue index 2b6870d640..f4154558c6 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/sortListMenu.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/sortListMenu.vue @@ -148,7 +148,7 @@ export default { async saveOrUpdate(sort, i) { if (!this.shared && this._isUIAllowed('sortSync')) { if (sort.id) { - await this.$api.dbTableSort.update(this.viewId, sort.id, sort) + await this.$api.dbTableSort.update(sort.id, sort) } else { this.$set(this.sortList, i, (await this.$api.dbTableSort.create(this.viewId, sort))) } @@ -161,7 +161,7 @@ export default { }, async deleteSort(sort, i) { if (!this.shared && sort.id && this._isUIAllowed('sortSync')) { - await this.$api.dbTableSort.delete(this.viewId, sort.id) + await this.$api.dbTableSort.delete(sort.id) await this.loadSortList() } else { this.sortList.splice(i, 1) diff --git a/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue b/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue index 75844f818d..d4efdd8036 100644 --- a/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue +++ b/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue @@ -973,8 +973,7 @@ export default { if (this.nodes.newTable && !this.nodes.tableCreated) { const columns = this.sqlUi.getNewTableColumns().filter(col => this.nodes.newTable.columns.includes(col.column_name)) await this.$api.dbTable.create( - this.$store.state.project.projectId, - this.$store.state.project.project.bases[0].id, + this.projectId, { table_name: this.nodes.table_name, title: this.nodes.title, @@ -1050,7 +1049,11 @@ export default { }, {}) // const insertedData = await this.api.insert(insertObj) - const insertedData = (await this.$api.data.create(this.meta.id, insertObj)) + const insertedData = (await this.$api.dbTableRow.create( + 'noco', + this.projectName, + this.meta.title, insertObj + )) this.data.splice(row, 1, { row: insertedData, @@ -1309,7 +1312,7 @@ export default { const { list, pageInfo - } = (await this.$api.dbViewRow.list('noco', this.$store.getters['project/GtrProjectName'], this.meta.title, this.selectedView.title, + } = (await this.$api.dbViewRow.list('noco', this.projectName, this.meta.title, this.selectedView.title, { ...this.queryParams, ...(this._isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(this.sortList) }), diff --git a/packages/nc-gui/mixins/device.js b/packages/nc-gui/mixins/device.js index 09e062e8cf..9e40525e7e 100644 --- a/packages/nc-gui/mixins/device.js +++ b/packages/nc-gui/mixins/device.js @@ -52,7 +52,9 @@ export default { return zhLan.some(l => browserLan.includes(l)) }, ...mapGetters({ - _isUIAllowed: 'users/GtrIsUIAllowed' + _isUIAllowed: 'users/GtrIsUIAllowed', + projectName: 'project/GtrProjectName', + projectId: 'project/GtrProjectId' }) }, mounted() { diff --git a/packages/nc-gui/store/project.js b/packages/nc-gui/store/project.js index 931fe19538..d43cb088af 100644 --- a/packages/nc-gui/store/project.js +++ b/packages/nc-gui/store/project.js @@ -192,10 +192,13 @@ export const getters = { return data }, GtrProjectName(state) { - return state.project && state.project.title// state.unserializedList && state.unserializedList[0] ? state.unserializedList[0].projectJson.title : "__project__"; + return state.project && state.project.title + }, + GtrProjectId(state) { + return state.project && state.project.id }, GtrProjectPrefix(state) { - return state.project && state.project.prefix//state.unserializedList && state.unserializedList[0] ? state.unserializedList[0].projectJson.prefix : null; + return state.project && state.project.prefix }, GtrApiEnvironment(state) { @@ -368,7 +371,6 @@ export const actions = { const tables = (await this.$api.dbTable.list( state.projectId, - state.project.bases[0].id, { includeM2M: rootState.windows.includeM2M || '' })).list diff --git a/packages/nocodb-sdk/src/lib/Api.ts b/packages/nocodb-sdk/src/lib/Api.ts index 9ddcf95453..898fe65392 100644 --- a/packages/nocodb-sdk/src/lib/Api.ts +++ b/packages/nocodb-sdk/src/lib/Api.ts @@ -34,6 +34,12 @@ export interface UserType { createDate?: string; } +export interface PageReqQueryParamsType { + offset?: number; + limit?: number; + query?: string; +} + export interface UserListType { users: { list: UserType; pageInfo: PaginatedType }; } @@ -944,27 +950,6 @@ export class Api< ...params, }), - /** - * No description - * - * @tags Auth - * @name TokenVerify - * @summary Password Verify - * @request POST:/auth/token/verify - * @response `200` `void` OK - */ - tokenVerify: ( - data: { token?: string; email?: string }, - params: RequestParams = {} - ) => - this.request({ - path: `/auth/token/verify`, - method: 'POST', - body: data, - type: ContentType.Json, - ...params, - }), - /** * No description * @@ -987,7 +972,7 @@ export class Api< * @tags Auth * @name ProjectUserList * @summary Project Users - * @request GET:/projects/{projectId}/users + * @request GET:/api/v1/db/meta/projects/{projectId}/users * @response `200` `{ users?: { list: (UserType)[], pageInfo: PaginatedType } }` OK */ projectUserList: (projectId: string, params: RequestParams = {}) => @@ -995,7 +980,7 @@ export class Api< { users?: { list: UserType[]; pageInfo: PaginatedType } }, any >({ - path: `/projects/${projectId}/users`, + path: `/api/v1/db/meta/projects/${projectId}/users`, method: 'GET', format: 'json', ...params, @@ -1007,7 +992,7 @@ export class Api< * @tags Auth * @name ProjectUserAdd * @summary Project User Add - * @request POST:/projects/{projectId}/users + * @request POST:/api/v1/db/meta/projects/{projectId}/users * @response `200` `any` OK */ projectUserAdd: ( @@ -1016,7 +1001,7 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/projects/${projectId}/users`, + path: `/api/v1/db/meta/projects/${projectId}/users`, method: 'POST', body: data, type: ContentType.Json, @@ -1030,7 +1015,7 @@ export class Api< * @tags Auth * @name ProjectUserUpdate * @summary Project User Update - * @request PUT:/projects/{projectId}/users/{userId} + * @request PATCH:/api/v1/db/meta/projects/{projectId}/users/{userId} * @response `200` `any` OK */ projectUserUpdate: ( @@ -1040,8 +1025,8 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/projects/${projectId}/users/${userId}`, - method: 'PUT', + path: `/api/v1/db/meta/projects/${projectId}/users/${userId}`, + method: 'PATCH', body: data, type: ContentType.Json, format: 'json', @@ -1054,7 +1039,7 @@ export class Api< * @tags Auth * @name ProjectUserRemove * @summary Project User Remove - * @request DELETE:/projects/{projectId}/users/{userId} + * @request DELETE:/api/v1/db/meta/projects/{projectId}/users/{userId} * @response `200` `any` OK */ projectUserRemove: ( @@ -1063,7 +1048,7 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/projects/${projectId}/users/${userId}`, + path: `/api/v1/db/meta/projects/${projectId}/users/${userId}`, method: 'DELETE', format: 'json', ...params, @@ -1076,7 +1061,7 @@ export class Api< * @tags Project * @name MetaGet * @summary Project Info - * @request GET:/projects/{projectId}/info + * @request GET:/api/v1/db/meta/projects/{projectId}/info * @response `200` `{ Node?: string, Arch?: string, Platform?: string, Docker?: boolean, Database?: string, ProjectOnRootDB?: string, RootDB?: string, PackageVersion?: string }` OK */ metaGet: (projectId: string, params: RequestParams = {}) => @@ -1093,7 +1078,7 @@ export class Api< }, any >({ - path: `/projects/${projectId}/info`, + path: `/api/v1/db/meta/projects/${projectId}/info`, method: 'GET', format: 'json', ...params, @@ -1105,7 +1090,7 @@ export class Api< * @tags Project * @name ModelVisibilityList * @summary UI ACL - * @request GET:/projects/{projectId}/modelVisibility + * @request GET:/api/v1/db/meta/projects/{projectId}/visibility-rules * @response `200` `(any)[]` OK */ modelVisibilityList: ( @@ -1114,7 +1099,7 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/projects/${projectId}/modelVisibility`, + path: `/api/v1/db/meta/projects/${projectId}/visibility-rules`, method: 'GET', query: query, format: 'json', @@ -1126,7 +1111,7 @@ export class Api< * * @tags Project * @name ModelVisibilitySet - * @request POST:/projects/{projectId}/modelVisibility + * @request POST:/api/v1/db/meta/projects/{projectId}/visibility-rules * @response `200` `any` OK */ modelVisibilitySet: ( @@ -1135,7 +1120,7 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/projects/${projectId}/modelVisibility`, + path: `/api/v1/db/meta/projects/${projectId}/visibility-rules`, method: 'POST', body: data, type: ContentType.Json, @@ -1148,7 +1133,7 @@ export class Api< * * @tags Project * @name List - * @request GET:/projects/ + * @request GET:/api/v1/db/meta/projects/ * @response `201` `ProjectListType` */ list: ( @@ -1156,7 +1141,7 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/projects/`, + path: `/api/v1/db/meta/projects/`, method: 'GET', query: query, ...params, @@ -1167,7 +1152,7 @@ export class Api< * * @tags Project * @name Create - * @request POST:/projects/ + * @request POST:/api/v1/db/meta/projects/ * @response `200` `ProjectType` OK */ create: ( @@ -1175,7 +1160,7 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/projects/`, + path: `/api/v1/db/meta/projects/`, method: 'POST', body: data, type: ContentType.Json, @@ -1188,12 +1173,12 @@ export class Api< * * @tags Project * @name Read - * @request GET:/projects/{projectId} + * @request GET:/api/v1/db/meta/projects/{projectId} * @response `200` `object` OK */ read: (projectId: string, params: RequestParams = {}) => this.request({ - path: `/projects/${projectId}`, + path: `/api/v1/db/meta/projects/${projectId}`, method: 'GET', format: 'json', ...params, @@ -1204,12 +1189,12 @@ export class Api< * * @tags Project * @name Delete - * @request DELETE:/projects/{projectId} + * @request DELETE:/api/v1/db/meta/projects/{projectId} * @response `200` `void` OK */ delete: (projectId: string, params: RequestParams = {}) => this.request({ - path: `/projects/${projectId}`, + path: `/api/v1/db/meta/projects/${projectId}`, method: 'DELETE', ...params, }), @@ -1219,12 +1204,12 @@ export class Api< * * @tags Project * @name SharedBaseGet - * @request GET:/projects/{projectId}/sharedBase + * @request GET:/api/v1/db/meta/projects/{projectId}/shared * @response `200` `{ uuid?: string, url?: string }` OK */ sharedBaseGet: (projectId: string, params: RequestParams = {}) => this.request<{ uuid?: string; url?: string }, any>({ - path: `/projects/${projectId}/sharedBase`, + path: `/api/v1/db/meta/projects/${projectId}/shared`, method: 'GET', format: 'json', ...params, @@ -1235,12 +1220,12 @@ export class Api< * * @tags Project * @name SharedBaseDisable - * @request DELETE:/projects/{projectId}/sharedBase + * @request DELETE:/api/v1/db/meta/projects/{projectId}/shared * @response `200` `void` OK */ sharedBaseDisable: (projectId: string, params: RequestParams = {}) => this.request({ - path: `/projects/${projectId}/sharedBase`, + path: `/api/v1/db/meta/projects/${projectId}/shared`, method: 'DELETE', ...params, }), @@ -1250,7 +1235,7 @@ export class Api< * * @tags Project * @name SharedBaseCreate - * @request POST:/projects/{projectId}/sharedBase + * @request POST:/api/v1/db/meta/projects/{projectId}/shared * @response `200` `{ url?: string, uuid?: string }` OK */ sharedBaseCreate: ( @@ -1259,7 +1244,7 @@ export class Api< params: RequestParams = {} ) => this.request<{ url?: string; uuid?: string }, any>({ - path: `/projects/${projectId}/sharedBase`, + path: `/api/v1/db/meta/projects/${projectId}/shared`, method: 'POST', body: data, type: ContentType.Json, @@ -1272,7 +1257,7 @@ export class Api< * * @tags Project * @name SharedBaseUpdate - * @request PUT:/projects/{projectId}/sharedBase + * @request PATCH:/api/v1/db/meta/projects/{projectId}/shared * @response `200` `void` OK */ sharedBaseUpdate: ( @@ -1281,8 +1266,8 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/projects/${projectId}/sharedBase`, - method: 'PUT', + path: `/api/v1/db/meta/projects/${projectId}/shared`, + method: 'PATCH', body: data, type: ContentType.Json, ...params, @@ -1293,12 +1278,12 @@ export class Api< * * @tags Project * @name MetaDiffSync - * @request POST:/projects/{projectId}/metaDiff + * @request POST:/api/v1/db/meta/projects/{projectId}/meta-diff * @response `200` `any` OK */ metaDiffSync: (projectId: string, params: RequestParams = {}) => this.request({ - path: `/projects/${projectId}/metaDiff`, + path: `/api/v1/db/meta/projects/${projectId}/meta-diff`, method: 'POST', format: 'json', ...params, @@ -1309,12 +1294,12 @@ export class Api< * * @tags Project * @name MetaDiffGet - * @request GET:/projects/{projectId}/metaDiff + * @request GET:/api/v1/db/meta/projects/{projectId}/meta-diff * @response `200` `any` OK */ metaDiffGet: (projectId: string, params: RequestParams = {}) => this.request({ - path: `/projects/${projectId}/metaDiff`, + path: `/api/v1/db/meta/projects/${projectId}/meta-diff`, method: 'GET', format: 'json', ...params, @@ -1325,7 +1310,7 @@ export class Api< * * @tags Project * @name AuditList - * @request GET:project/{projectId}/audits + * @request GET:/api/v1/db/meta/project/{projectId}/audits * @response `200` `{ list: (AuditType)[], pageInfo: PaginatedType }` OK */ auditList: ( @@ -1334,48 +1319,30 @@ export class Api< params: RequestParams = {} ) => this.request<{ list: AuditType[]; pageInfo: PaginatedType }, any>({ - path: `project/${projectId}/audits`, + path: `/api/v1/db/meta/project/${projectId}/audits`, method: 'GET', query: query, format: 'json', ...params, }), }; - public = { - /** - * @description Read project details - * - * @tags Public - * @name SharedBaseGet - * @request GET:/public/sharedBase/{sharedBaseUuid} - * @response `200` `{ project_id?: string }` OK - */ - sharedBaseGet: (sharedBaseUuid: string, params: RequestParams = {}) => - this.request<{ project_id?: string }, any>({ - path: `/public/sharedBase/${sharedBaseUuid}`, - method: 'GET', - format: 'json', - ...params, - }), - + dbTable = { /** * No description * - * @tags Public - * @name DataList - * @request POST:/public/data/{uuid}/list - * @response `200` `any` OK + * @tags DB Table + * @name Create + * @request POST:/api/v1/db/meta/projects/{projectId}/tables + * @response `200` `TableType` OK */ - dataList: ( - uuid: string, - data: { password?: string; sorts?: SortType[]; filters?: FilterType[] }, - query?: { limit?: string; offset?: string }, + create: ( + projectId: string, + data: TableReqType, params: RequestParams = {} ) => - this.request({ - path: `/public/data/${uuid}/list`, + this.request({ + path: `/api/v1/db/meta/projects/${projectId}/tables`, method: 'POST', - query: query, body: data, type: ContentType.Json, format: 'json', @@ -1385,47 +1352,40 @@ export class Api< /** * No description * - * @tags Public - * @name DataNestedList - * @request GET:/public/data/{uuid}/{rowId}/{relationType}/{columnId} - * @response `200` `any` OK + * @tags DB Table + * @name List + * @request GET:/api/v1/db/meta/projects/{projectId}/tables + * @response `200` `TableListType` */ - dataNestedList: ( - uuid: string, - rowId: string, - relationType: 'mm' | 'hm', - columnId: string, - query?: { limit?: string; offset?: string }, + list: ( + projectId: string, + query?: { + page?: number; + pageSize?: number; + sort?: string; + includeM2M?: boolean; + }, params: RequestParams = {} ) => - this.request({ - path: `/public/data/${uuid}/${rowId}/${relationType}/${columnId}`, + this.request({ + path: `/api/v1/db/meta/projects/${projectId}/tables`, method: 'GET', query: query, - format: 'json', ...params, }), /** * No description * - * @tags Public - * @name DataNestedExcludedList - * @request GET:/public/data/{uuid}/{rowId}/{relationType}/{columnId}/exclude - * @response `200` `any` OK + * @tags DB Table + * @name Read + * @request GET:/api/v1/db/meta/tables/{tableId} + * @response `200` `TableInfoType` OK */ - dataNestedExcludedList: ( - uuid: string, - rowId: string, - relationType: 'mm' | 'hm', - columnId: string, - query?: { limit?: string; offset?: string }, - params: RequestParams = {} - ) => - this.request({ - path: `/public/data/${uuid}/${rowId}/${relationType}/${columnId}/exclude`, + read: (tableId: string, params: RequestParams = {}) => + this.request({ + path: `/api/v1/db/meta/tables/${tableId}`, method: 'GET', - query: query, format: 'json', ...params, }), @@ -1433,21 +1393,21 @@ export class Api< /** * No description * - * @tags Public - * @name DataCreate - * @request POST:/public/data/{uuid}/create + * @tags DB Table + * @name Update + * @request PATCH:/api/v1/db/meta/tables/{tableId} * @response `200` `any` OK */ - dataCreate: ( - uuid: string, - data: { data?: any; password?: string }, + update: ( + tableId: string, + data: { title?: string }, params: RequestParams = {} ) => this.request({ - path: `/public/data/${uuid}/create`, - method: 'POST', + path: `/api/v1/db/meta/tables/${tableId}`, + method: 'PATCH', body: data, - type: ContentType.FormData, + type: ContentType.Json, format: 'json', ...params, }), @@ -1455,47 +1415,92 @@ export class Api< /** * No description * - * @tags Public - * @name CsvExport - * @request POST:/public/data/{uuid}/export/{type} - * @response `200` `any` OK + * @tags DB Table + * @name Delete + * @request DELETE:/api/v1/db/meta/tables/{tableId} + * @response `200` `void` OK */ - csvExport: ( - uuid: string, - type: 'csv' | 'excel', - data: { password?: string; filters?: FilterType[]; sorts?: SortType[] }, + delete: (tableId: string, params: RequestParams = {}) => + this.request({ + path: `/api/v1/db/meta/tables/${tableId}`, + method: 'DELETE', + ...params, + }), + + /** + * No description + * + * @tags DB Table + * @name Reorder + * @request POST:/api/v1/db/meta/tables/{tableId}/reorder + * @response `200` `void` OK + */ + reorder: ( + tableId: string, + data: { order?: string }, params: RequestParams = {} ) => - this.request({ - path: `/public/data/${uuid}/export/${type}`, + this.request({ + path: `/api/v1/db/meta/tables/${tableId}/reorder`, method: 'POST', body: data, type: ContentType.Json, - wrapped: true, + ...params, + }), + }; + dbTableColumn = { + /** + * @description Read project details + * + * @tags DB Table column + * @name List + * @summary Column List + * @request GET:/api/v1/db/meta/tables/{tableId}/columns + * @response `200` `ColumnListType` + * @response `201` `ColumnType` Created + */ + list: (tableId: string, params: RequestParams = {}) => + this.request({ + path: `/api/v1/db/meta/tables/${tableId}/columns`, + method: 'GET', ...params, }), /** * No description * - * @tags Public - * @name DataRelationList - * @request POST:/public/data/{uuid}/relationTable/{relationColumnId} - * @response `200` `any` OK + * @tags DB Table column + * @name Create + * @summary Column create + * @request POST:/api/v1/db/meta/tables/{tableId}/columns + * @response `200` `void` OK */ - dataRelationList: ( - uuid: string, - relationColumnId: string, - data: { password?: string }, - query?: { limit?: string; offset?: string }, + create: ( + tableId: string, + data: ColumnReqType, params: RequestParams = {} ) => - this.request({ - path: `/public/data/${uuid}/relationTable/${relationColumnId}`, + this.request({ + path: `/api/v1/db/meta/tables/${tableId}/columns`, method: 'POST', - query: query, body: data, type: ContentType.Json, + ...params, + }), + + /** + * @description Read project details + * + * @tags DB Table column + * @name Read + * @summary Column Read + * @request GET:/api/v1/db/meta/tables/{tableId}/columns/{columnId} + * @response `200` `ColumnType` OK + */ + read: (tableId: string, columnId: string, params: RequestParams = {}) => + this.request({ + path: `/api/v1/db/meta/tables/${tableId}/columns/${columnId}`, + method: 'GET', format: 'json', ...params, }), @@ -1503,45 +1508,74 @@ export class Api< /** * No description * - * @tags Public - * @name SharedViewMetaGet - * @request POST:/public/meta/{uuid} - * @response `200` `object` OK + * @tags DB Table column + * @name Update + * @summary Column Update + * @request PATCH:/api/v1/db/meta/tables/{tableId}/columns/{columnId} + * @response `200` `ColumnType` OK */ - sharedViewMetaGet: ( - uuid: string, - data: { password?: string }, + update: ( + tableId: string, + columnId: string, + data: ColumnReqType, params: RequestParams = {} ) => - this.request({ - path: `/public/meta/${uuid}`, - method: 'POST', + this.request({ + path: `/api/v1/db/meta/tables/${tableId}/columns/${columnId}`, + method: 'PATCH', body: data, type: ContentType.Json, format: 'json', ...params, }), - }; - dbView = { + /** * No description * - * @tags DB View - * @name Upload - * @summary Attachment - * @request POST:/projects/{projectId}/views/{viewId}/upload + * @tags DB Table column + * @name Delete + * @request DELETE:/api/v1/db/meta/tables/{tableId}/columns/{columnId} + * @response `200` `void` OK */ - upload: ( - projectId: string, - viewId: string, - data: { files?: any; json?: string }, + delete: (tableId: string, columnId: string, params: RequestParams = {}) => + this.request({ + path: `/api/v1/db/meta/tables/${tableId}/columns/${columnId}`, + method: 'DELETE', + ...params, + }), + + /** + * No description + * + * @tags DB Table column + * @name PrimaryColumnSet + * @request POST:/api/v1/db/meta/tables/{tableId}/columns/{columnId}/primary + * @response `200` `void` OK + */ + primaryColumnSet: ( + tableId: string, + columnId: string, params: RequestParams = {} ) => - this.request({ - path: `/projects/${projectId}/views/${viewId}/upload`, + this.request({ + path: `/api/v1/db/meta/tables/${tableId}/columns/${columnId}/primary`, method: 'POST', - body: data, - type: ContentType.FormData, + ...params, + }), + }; + dbView = { + /** + * No description + * + * @tags DB View + * @name List + * @request GET:/api/v1/db/meta/tables/{tableId}/views + * @response `200` `ViewListType` + */ + list: (tableId: string, params: RequestParams = {}) => + this.request({ + path: `/api/v1/db/meta/tables/${tableId}/views`, + method: 'GET', ...params, }), @@ -1550,7 +1584,7 @@ export class Api< * * @tags DB View * @name Update - * @request PUT:/views/{viewId} + * @request PATCH:/api/v1/db/meta/views/{viewId} * @response `200` `void` OK */ update: ( @@ -1564,8 +1598,8 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/views/${viewId}`, - method: 'PUT', + path: `/api/v1/db/meta/views/${viewId}`, + method: 'PATCH', body: data, type: ContentType.Json, ...params, @@ -1576,12 +1610,12 @@ export class Api< * * @tags DB View * @name Delete - * @request DELETE:/views/{viewId} + * @request DELETE:/api/v1/db/meta/views/{viewId} * @response `200` `void` OK */ delete: (viewId: string, params: RequestParams = {}) => this.request({ - path: `/views/${viewId}`, + path: `/api/v1/db/meta/views/${viewId}`, method: 'DELETE', ...params, }), @@ -1591,7 +1625,7 @@ export class Api< * * @tags DB View * @name ShowAllColumn - * @request POST:/views/{viewId}/showAll + * @request POST:/api/v1/db/meta/views/{viewId}/showAll * @response `200` `void` OK */ showAllColumn: ( @@ -1600,7 +1634,7 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/views/${viewId}/showAll`, + path: `/api/v1/db/meta/views/${viewId}/showAll`, method: 'POST', query: query, ...params, @@ -1611,7 +1645,7 @@ export class Api< * * @tags DB View * @name HideAllColumn - * @request POST:/views/{viewId}/hideAll + * @request POST:/api/v1/db/meta/views/{viewId}/hideAll * @response `200` `void` OK */ hideAllColumn: ( @@ -1620,7 +1654,7 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/views/${viewId}/hideAll`, + path: `/api/v1/db/meta/views/${viewId}/hideAll`, method: 'POST', query: query, ...params, @@ -1631,12 +1665,12 @@ export class Api< * * @tags DB View * @name GridCreate - * @request POST:/tables/{tableId}/grids + * @request POST:/api/v1/db/meta/tables/{tableId}/grids * @response `200` `GridType` OK */ gridCreate: (tableId: string, data: GridType, params: RequestParams = {}) => this.request({ - path: `/tables/${tableId}/grids`, + path: `/api/v1/db/meta/tables/${tableId}/grids`, method: 'POST', body: data, type: ContentType.Json, @@ -1648,14 +1682,17 @@ export class Api< * No description * * @tags DB View - * @name GridUpdate - * @request PUT:/tables/{tableId}/grids/{gridId} - * @response `200` `void` OK + * @name FormCreate + * @request POST:/api/v1/db/meta/tables/{tableId}/forms + * @response `200` `FormType` OK */ - gridUpdate: (tableId: string, gridId: string, params: RequestParams = {}) => - this.request({ - path: `/tables/${tableId}/grids/${gridId}`, - method: 'PUT', + formCreate: (tableId: string, data: FormType, params: RequestParams = {}) => + this.request({ + path: `/api/v1/db/meta/tables/${tableId}/forms`, + method: 'POST', + body: data, + type: ContentType.Json, + format: 'json', ...params, }), @@ -1663,62 +1700,14 @@ export class Api< * No description * * @tags DB View - * @name GridDelete - * @request DELETE:/tables/{tableId}/grids/{gridId} + * @name FormUpdate + * @request PATCH:/api/v1/db/meta/forms/{formId} * @response `200` `void` OK */ - gridDelete: (tableId: string, gridId: string, params: RequestParams = {}) => + formUpdate: (formId: string, data: FormType, params: RequestParams = {}) => this.request({ - path: `/tables/${tableId}/grids/${gridId}`, - method: 'DELETE', - ...params, - }), - - /** - * No description - * - * @tags DB View - * @name GridRead - * @request GET:/tables/{tableId}/grids/{gridId} - * @response `200` `void` OK - */ - gridRead: (tableId: string, gridId: string, params: RequestParams = {}) => - this.request({ - path: `/tables/${tableId}/grids/${gridId}`, - method: 'GET', - ...params, - }), - - /** - * No description - * - * @tags DB View - * @name FormCreate - * @request POST:/tables/{tableId}/forms - * @response `200` `FormType` OK - */ - formCreate: (tableId: string, data: FormType, params: RequestParams = {}) => - this.request({ - path: `/tables/${tableId}/forms`, - method: 'POST', - body: data, - type: ContentType.Json, - format: 'json', - ...params, - }), - - /** - * No description - * - * @tags DB View - * @name FormUpdate - * @request PUT:/forms/{formId} - * @response `200` `void` OK - */ - formUpdate: (formId: string, data: FormType, params: RequestParams = {}) => - this.request({ - path: `/forms/${formId}`, - method: 'PUT', + path: `/api/v1/db/meta/forms/${formId}`, + method: 'PATCH', body: data, type: ContentType.Json, ...params, @@ -1729,12 +1718,12 @@ export class Api< * * @tags DB View * @name FormRead - * @request GET:/forms/{formId} + * @request GET:/api/v1/db/meta/forms/{formId} * @response `200` `FormType` OK */ formRead: (formId: string, params: RequestParams = {}) => this.request({ - path: `/forms/${formId}`, + path: `/api/v1/db/meta/forms/${formId}`, method: 'GET', format: 'json', ...params, @@ -1745,17 +1734,17 @@ export class Api< * * @tags DB View * @name FormColumnUpdate - * @request PUT:/formColumns/{columnId} + * @request PATCH:/api/v1/db/meta/form/columns/{formViewColumnId} * @response `200` `any` OK */ formColumnUpdate: ( - columnId: string, + formViewColumnId: string, data: FormColumnType, params: RequestParams = {} ) => this.request({ - path: `/formColumns/${columnId}`, - method: 'PUT', + path: `/api/v1/db/meta/form/columns/${formViewColumnId}`, + method: 'PATCH', body: data, type: ContentType.Json, format: 'json', @@ -1767,12 +1756,12 @@ export class Api< * * @tags DB View * @name GridColumnsList - * @request GET:/grid/{gidId}/gridColumns + * @request GET:/api/v1/db/meta/grids/{gidId}/grid/columns * @response `200` `(GridColumnType)[]` OK */ gridColumnsList: (gidId: string, params: RequestParams = {}) => this.request({ - path: `/grid/${gidId}/gridColumns`, + path: `/api/v1/db/meta/grids/${gidId}/grid/columns`, method: 'GET', format: 'json', ...params, @@ -1783,7 +1772,7 @@ export class Api< * * @tags DB View * @name GridColumnUpdate - * @request PUT:/gridColumns/{columnId} + * @request PATCH:/api/v1/db/meta/grid/columns/{columnId} * @response `200` `any` OK */ gridColumnUpdate: ( @@ -1792,8 +1781,8 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/gridColumns/${columnId}`, - method: 'PUT', + path: `/api/v1/db/meta/grid/columns/${columnId}`, + method: 'PATCH', body: data, type: ContentType.Json, format: 'json', @@ -1805,7 +1794,7 @@ export class Api< * * @tags DB View * @name GalleryCreate - * @request POST:/tables/{tableId}/galleries + * @request POST:/api/v1/db/meta/tables/{tableId}/galleries * @response `200` `object` OK */ galleryCreate: ( @@ -1814,7 +1803,7 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/tables/${tableId}/galleries`, + path: `/api/v1/db/meta/tables/${tableId}/galleries`, method: 'POST', body: data, type: ContentType.Json, @@ -1827,7 +1816,7 @@ export class Api< * * @tags DB View * @name GalleryUpdate - * @request PUT:/galleries/{galleryId} + * @request PATCH:/api/v1/db/meta/galleries/{galleryId} * @response `200` `void` OK */ galleryUpdate: ( @@ -1836,39 +1825,24 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/galleries/${galleryId}`, - method: 'PUT', + path: `/api/v1/db/meta/galleries/${galleryId}`, + method: 'PATCH', body: data, type: ContentType.Json, ...params, }), - /** - * No description - * - * @tags DB View - * @name GalleryDelete - * @request DELETE:/galleries/{galleryId} - * @response `200` `void` OK - */ - galleryDelete: (galleryId: string, params: RequestParams = {}) => - this.request({ - path: `/galleries/${galleryId}`, - method: 'DELETE', - ...params, - }), - /** * No description * * @tags DB View * @name GalleryRead - * @request GET:/galleries/{galleryId} + * @request GET:/api/v1/db/meta/galleries/{galleryId} * @response `200` `GalleryType` OK */ galleryRead: (galleryId: string, params: RequestParams = {}) => this.request({ - path: `/galleries/${galleryId}`, + path: `/api/v1/db/meta/galleries/${galleryId}`, method: 'GET', format: 'json', ...params, @@ -1878,150 +1852,138 @@ export class Api< * No description * * @tags DB View - * @name KanbanCreate - * @request POST:/tables/{tableId}/kanbans - * @response `200` `void` OK + * @name Upload + * @summary Attachment + * @request POST:/projects/{projectId}/views/{viewId}/upload */ - kanbanCreate: (tableId: string, params: RequestParams = {}) => - this.request({ - path: `/tables/${tableId}/kanbans`, + upload: ( + projectId: string, + viewId: string, + data: { files?: any; json?: string }, + params: RequestParams = {} + ) => + this.request({ + path: `/projects/${projectId}/views/${viewId}/upload`, method: 'POST', + body: data, + type: ContentType.FormData, ...params, }), - + }; + dbViewShare = { /** * No description * - * @tags DB View - * @name KanbanUpdate - * @request PUT:/tables/{tableId}/kanbans/{kanbanId} - * @response `200` `void` OK + * @tags DB View Share + * @name List + * @summary Shared view list + * @request GET:/api/v1/db/meta/tables/{tableId}/share + * @response `200` `(any)[]` OK */ - kanbanUpdate: ( - tableId: string, - kanbanId: string, - params: RequestParams = {} - ) => - this.request({ - path: `/tables/${tableId}/kanbans/${kanbanId}`, - method: 'PUT', + list: (tableId: string, params: RequestParams = {}) => + this.request({ + path: `/api/v1/db/meta/tables/${tableId}/share`, + method: 'GET', + format: 'json', ...params, }), /** * No description * - * @tags DB View - * @name KanbanDelete - * @request DELETE:/tables/{tableId}/kanbans/{kanbanId} - * @response `200` `void` OK + * @tags DB View Share + * @name Create + * @request POST:/api/v1/db/meta/views/{viewId}/share + * @response `200` `{ uuid?: string }` OK */ - kanbanDelete: ( - tableId: string, - kanbanId: string, - params: RequestParams = {} - ) => - this.request({ - path: `/tables/${tableId}/kanbans/${kanbanId}`, - method: 'DELETE', + create: (viewId: string, params: RequestParams = {}) => + this.request<{ uuid?: string }, any>({ + path: `/api/v1/db/meta/views/${viewId}/share`, + method: 'POST', + format: 'json', ...params, }), /** * No description * - * @tags DB View - * @name KanbanRead - * @request GET:/tables/{tableId}/kanbans/{kanbanId} - * @response `200` `void` OK + * @tags DB View Share + * @name Update + * @request PATCH:/api/v1/db/meta/views/{viewId}/share + * @response `200` `SharedViewType` OK */ - kanbanRead: ( - tableId: string, - kanbanId: string, + update: ( + viewId: string, + data: { password?: string }, params: RequestParams = {} ) => - this.request({ - path: `/tables/${tableId}/kanbans/${kanbanId}`, - method: 'GET', + this.request({ + path: `/api/v1/db/meta/views/${viewId}/share`, + method: 'PATCH', + body: data, + type: ContentType.Json, + format: 'json', ...params, }), /** * No description * - * @tags DB View - * @name List - * @request GET:/tables/{tableId}/views - * @response `200` `ViewListType` + * @tags DB View Share + * @name Delete + * @request DELETE:/api/v1/db/meta/views/{viewId}/share + * @response `200` `void` OK */ - list: (tableId: string, params: RequestParams = {}) => - this.request({ - path: `/tables/${tableId}/views`, - method: 'GET', + delete: (viewId: string, params: RequestParams = {}) => + this.request({ + path: `/api/v1/db/meta/views/${viewId}/share`, + method: 'DELETE', ...params, }), }; - dbTable = { + dbViewColumn = { /** * No description * - * @tags DB Table - * @name Create - * @request POST:/projects/{projectId}/{baseId}/tables - * @response `200` `TableType` OK + * @tags DB View Column + * @name List + * @request GET:/api/v1/db/meta/views/{viewId}/columns */ - create: ( - projectId: string, - baseId: string, - data: TableReqType, - params: RequestParams = {} - ) => - this.request({ - path: `/projects/${projectId}/${baseId}/tables`, - method: 'POST', - body: data, - type: ContentType.Json, - format: 'json', + list: (viewId: string, params: RequestParams = {}) => + this.request({ + path: `/api/v1/db/meta/views/${viewId}/columns`, + method: 'GET', ...params, }), /** * No description * - * @tags DB Table - * @name List - * @request GET:/projects/{projectId}/{baseId}/tables - * @response `200` `TableListType` + * @tags DB View Column + * @name Create + * @request POST:/api/v1/db/meta/views/{viewId}/columns + * @response `200` `void` OK */ - list: ( - projectId: string, - baseId: string, - query?: { - page?: number; - pageSize?: number; - sort?: string; - includeM2M?: boolean; - }, - params: RequestParams = {} - ) => - this.request({ - path: `/projects/${projectId}/${baseId}/tables`, - method: 'GET', - query: query, + create: (viewId: string, data: any, params: RequestParams = {}) => + this.request({ + path: `/api/v1/db/meta/views/${viewId}/columns`, + method: 'POST', + body: data, + type: ContentType.Json, ...params, }), /** * No description * - * @tags DB Table + * @tags DB View Column * @name Read - * @request GET:/tables/{tableId} - * @response `200` `TableInfoType` OK + * @request GET:/api/v1/db/meta/views/{viewId}/columns/{columnId} + * @response `200` `any` OK */ - read: (tableId: string, params: RequestParams = {}) => - this.request({ - path: `/tables/${tableId}`, + read: (viewId: string, columnId: string, params: RequestParams = {}) => + this.request({ + path: `/api/v1/db/meta/views/${viewId}/columns/${columnId}`, method: 'GET', format: 'json', ...params, @@ -2030,399 +1992,103 @@ export class Api< /** * No description * - * @tags DB Table + * @tags DB View Column * @name Update - * @request PUT:/tables/{tableId} - * @response `200` `any` OK + * @request PATCH:/api/v1/db/meta/views/{viewId}/columns/{columnId} + * @response `200` `void` OK */ update: ( - tableId: string, - data: { title?: string }, + viewId: string, + columnId: string, + data: any, params: RequestParams = {} ) => - this.request({ - path: `/tables/${tableId}`, - method: 'PUT', + this.request({ + path: `/api/v1/db/meta/views/${viewId}/columns/${columnId}`, + method: 'PATCH', body: data, type: ContentType.Json, - format: 'json', ...params, }), - + }; + dbTableSort = { /** * No description * - * @tags DB Table - * @name Delete - * @request DELETE:/tables/{tableId} - * @response `200` `void` OK + * @tags DB Table Sort + * @name List + * @request GET:/api/v1/db/meta/views/{viewId}/sorts + * @response `200` `{ uuid?: string, url?: string }` OK */ - delete: (tableId: string, params: RequestParams = {}) => - this.request({ - path: `/tables/${tableId}`, - method: 'DELETE', + list: (viewId: string, params: RequestParams = {}) => + this.request<{ uuid?: string; url?: string }, any>({ + path: `/api/v1/db/meta/views/${viewId}/sorts`, + method: 'GET', + format: 'json', ...params, }), /** * No description * - * @tags DB Table - * @name Reorder - * @request POST:/tables/{tableId}/reorder + * @tags DB Table Sort + * @name Create + * @request POST:/api/v1/db/meta/views/{viewId}/sorts * @response `200` `void` OK */ - reorder: ( - tableId: string, - data: { order?: string }, - params: RequestParams = {} - ) => + create: (viewId: string, data: SortType, params: RequestParams = {}) => this.request({ - path: `/tables/${tableId}/reorder`, + path: `/api/v1/db/meta/views/${viewId}/sorts`, method: 'POST', body: data, type: ContentType.Json, ...params, }), - }; - dbTableColumn = { + /** - * @description Read project details + * No description * - * @tags DB Table column - * @name List - * @summary Column List - * @request GET:/tables/{tableId}/columns - * @response `200` `ColumnListType` - * @response `201` `ColumnType` Created + * @tags DB Table Sort + * @name Get + * @request GET:/api/v1/db/meta/sorts/{sortId} + * @response `200` `SortType` OK */ - list: (tableId: string, params: RequestParams = {}) => - this.request({ - path: `/tables/${tableId}/columns`, + get: (sortId: string, params: RequestParams = {}) => + this.request({ + path: `/api/v1/db/meta/sorts/${sortId}`, method: 'GET', + format: 'json', ...params, }), /** * No description * - * @tags DB Table column - * @name Create - * @summary Column create - * @request POST:/tables/{tableId}/columns + * @tags DB Table Sort + * @name Update + * @request PATCH:/api/v1/db/meta/sorts/{sortId} * @response `200` `void` OK */ - create: ( - tableId: string, - data: ColumnReqType, - params: RequestParams = {} - ) => + update: (sortId: string, data: SortType, params: RequestParams = {}) => this.request({ - path: `/tables/${tableId}/columns`, - method: 'POST', + path: `/api/v1/db/meta/sorts/${sortId}`, + method: 'PATCH', body: data, type: ContentType.Json, ...params, }), /** - * @description Read project details + * No description * - * @tags DB Table column - * @name Read - * @summary Column Read - * @request GET:/tables/{tableId}/columns/{columnId} - * @response `200` `ColumnType` OK + * @tags DB Table Sort + * @name Delete + * @request DELETE:/api/v1/db/meta/sorts/{sortId} + * @response `200` `void` OK */ - read: (tableId: string, columnId: string, params: RequestParams = {}) => - this.request({ - path: `/tables/${tableId}/columns/${columnId}`, - method: 'GET', - format: 'json', - ...params, - }), - - /** - * No description - * - * @tags DB Table column - * @name Update - * @summary Column Update - * @request PUT:/tables/{tableId}/columns/{columnId} - * @response `200` `ColumnType` OK - */ - update: ( - tableId: string, - columnId: string, - data: ColumnReqType, - params: RequestParams = {} - ) => - this.request({ - path: `/tables/${tableId}/columns/${columnId}`, - method: 'PUT', - body: data, - type: ContentType.Json, - format: 'json', - ...params, - }), - - /** - * No description - * - * @tags DB Table column - * @name Delete - * @request DELETE:/tables/{tableId}/columns/{columnId} - * @response `200` `void` OK - */ - delete: (tableId: string, columnId: string, params: RequestParams = {}) => - this.request({ - path: `/tables/${tableId}/columns/${columnId}`, - method: 'DELETE', - ...params, - }), - - /** - * No description - * - * @tags DB Table column - * @name PrimaryColumnSet - * @request POST:/tables/{tableId}/columns/{columnId}/primary - * @response `200` `void` OK - */ - primaryColumnSet: ( - tableId: string, - columnId: string, - params: RequestParams = {} - ) => - this.request({ - path: `/tables/${tableId}/columns/${columnId}/primary`, - method: 'POST', - ...params, - }), - }; - dbViewColumn = { - /** - * No description - * - * @tags DB View Column - * @name List - * @request GET:/views/{viewId}/columns - */ - list: (viewId: string, params: RequestParams = {}) => - this.request({ - path: `/views/${viewId}/columns`, - method: 'GET', - ...params, - }), - - /** - * No description - * - * @tags DB View Column - * @name Create - * @request POST:/views/{viewId}/columns - * @response `200` `void` OK - */ - create: (viewId: string, data: any, params: RequestParams = {}) => - this.request({ - path: `/views/${viewId}/columns`, - method: 'POST', - body: data, - type: ContentType.Json, - ...params, - }), - - /** - * No description - * - * @tags DB View Column - * @name Read - * @request GET:/views/{viewId}/columns/{columnId} - * @response `200` `any` OK - */ - read: (viewId: string, columnId: string, params: RequestParams = {}) => - this.request({ - path: `/views/${viewId}/columns/${columnId}`, - method: 'GET', - format: 'json', - ...params, - }), - - /** - * No description - * - * @tags DB View Column - * @name Update - * @request PUT:/views/{viewId}/columns/{columnId} - * @response `200` `void` OK - */ - update: ( - viewId: string, - columnId: string, - data: any, - params: RequestParams = {} - ) => - this.request({ - path: `/views/${viewId}/columns/${columnId}`, - method: 'PUT', - body: data, - type: ContentType.Json, - ...params, - }), - }; - dbViewShare = { - /** - * No description - * - * @tags DB View Share - * @name Create - * @request POST:/views/{viewId}/share - * @response `200` `{ uuid?: string }` OK - */ - create: (viewId: string, params: RequestParams = {}) => - this.request<{ uuid?: string }, any>({ - path: `/views/${viewId}/share`, - method: 'POST', - format: 'json', - ...params, - }), - - /** - * No description - * - * @tags DB View Share - * @name Update - * @request PUT:/views/{viewId}/share - * @response `200` `SharedViewType` OK - */ - update: ( - viewId: string, - data: { password?: string }, - params: RequestParams = {} - ) => - this.request({ - path: `/views/${viewId}/share`, - method: 'PUT', - body: data, - type: ContentType.Json, - format: 'json', - ...params, - }), - - /** - * No description - * - * @tags DB View Share - * @name Delete - * @request DELETE:/views/{viewId}/share - * @response `200` `void` OK - */ - delete: (viewId: string, params: RequestParams = {}) => - this.request({ - path: `/views/${viewId}/share`, - method: 'DELETE', - ...params, - }), - - /** - * No description - * - * @tags DB View Share - * @name List - * @request GET:/tables/{viewId}/share - * @response `200` `(any)[]` OK - */ - list: (viewId: string, params: RequestParams = {}) => - this.request({ - path: `/tables/${viewId}/share`, - method: 'GET', - format: 'json', - ...params, - }), - }; - dbTableSort = { - /** - * No description - * - * @tags DB Table Sort - * @name List - * @request GET:/views/{viewId}/sorts - * @response `200` `{ uuid?: string, url?: string }` OK - */ - list: (viewId: string, params: RequestParams = {}) => - this.request<{ uuid?: string; url?: string }, any>({ - path: `/views/${viewId}/sorts`, - method: 'GET', - format: 'json', - ...params, - }), - - /** - * No description - * - * @tags DB Table Sort - * @name Create - * @request POST:/views/{viewId}/sorts - * @response `200` `void` OK - */ - create: (viewId: string, data: SortType, params: RequestParams = {}) => - this.request({ - path: `/views/${viewId}/sorts`, - method: 'POST', - body: data, - type: ContentType.Json, - ...params, - }), - - /** - * No description - * - * @tags DB Table Sort - * @name Get - * @request GET:/views/{viewId}/sorts/{sortId} - * @response `200` `SortType` OK - */ - get: (viewId: string, sortId: string, params: RequestParams = {}) => - this.request({ - path: `/views/${viewId}/sorts/${sortId}`, - method: 'GET', - format: 'json', - ...params, - }), - - /** - * No description - * - * @tags DB Table Sort - * @name Update - * @request PUT:/views/{viewId}/sorts/{sortId} - * @response `200` `void` OK - */ - update: ( - viewId: string, - sortId: string, - data: SortType, - params: RequestParams = {} - ) => - this.request({ - path: `/views/${viewId}/sorts/${sortId}`, - method: 'PUT', - body: data, - type: ContentType.Json, - ...params, - }), - - /** - * No description - * - * @tags DB Table Sort - * @name Delete - * @request DELETE:/views/{viewId}/sorts/{sortId} - * @response `200` `void` OK - */ - delete: (viewId: string, sortId: string, params: RequestParams = {}) => + delete: (sortId: string, params: RequestParams = {}) => this.request({ - path: `/views/${viewId}/sorts/${sortId}`, + path: `/api/v1/db/meta/sorts/${sortId}`, method: 'DELETE', ...params, }), @@ -2433,12 +2099,12 @@ export class Api< * * @tags DB Table Filter * @name Read - * @request GET:/views/{viewId}/filters + * @request GET:/api/v1/db/meta/views/{viewId}/filters * @response `200` `FilterListType` */ read: (viewId: string, params: RequestParams = {}) => this.request({ - path: `/views/${viewId}/filters`, + path: `/api/v1/db/meta/views/${viewId}/filters`, method: 'GET', ...params, }), @@ -2448,12 +2114,12 @@ export class Api< * * @tags DB Table Filter * @name Create - * @request POST:/views/{viewId}/filters + * @request POST:/api/v1/db/meta/views/{viewId}/filters * @response `200` `void` OK */ create: (viewId: string, data: FilterType, params: RequestParams = {}) => this.request({ - path: `/views/${viewId}/filters`, + path: `/api/v1/db/meta/views/${viewId}/filters`, method: 'POST', body: data, type: ContentType.Json, @@ -2465,12 +2131,12 @@ export class Api< * * @tags DB Table Filter * @name Get - * @request GET:/views/{viewId}/filters/{filterId} + * @request GET:/api/v1/db/meta/filters/{filterId} * @response `200` `FilterType` OK */ - get: (viewId: string, filterId: string, params: RequestParams = {}) => + get: (filterId: string, params: RequestParams = {}) => this.request({ - path: `/views/${viewId}/filters/${filterId}`, + path: `/api/v1/db/meta/filters/${filterId}`, method: 'GET', format: 'json', ...params, @@ -2481,18 +2147,13 @@ export class Api< * * @tags DB Table Filter * @name Update - * @request PUT:/views/{viewId}/filters/{filterId} + * @request PATCH:/api/v1/db/meta/filters/{filterId} * @response `200` `void` OK */ - update: ( - viewId: string, - filterId: string, - data: FilterType, - params: RequestParams = {} - ) => + update: (filterId: string, data: FilterType, params: RequestParams = {}) => this.request({ - path: `/views/${viewId}/filters/${filterId}`, - method: 'PUT', + path: `/api/v1/db/meta/filters/${filterId}`, + method: 'PATCH', body: data, type: ContentType.Json, ...params, @@ -2503,12 +2164,12 @@ export class Api< * * @tags DB Table Filter * @name Delete - * @request DELETE:/views/{viewId}/filters/{filterId} + * @request DELETE:/api/v1/db/meta/filters/{filterId} * @response `200` `void` OK */ - delete: (viewId: string, filterId: string, params: RequestParams = {}) => + delete: (filterId: string, params: RequestParams = {}) => this.request({ - path: `/views/${viewId}/filters/${filterId}`, + path: `/api/v1/db/meta/filters/${filterId}`, method: 'DELETE', ...params, }), @@ -2518,16 +2179,12 @@ export class Api< * * @tags DB Table Filter * @name ChildrenRead - * @request GET:/views/{viewId}/filters/{filterParentId}/children + * @request GET:/api/v1/db/meta/filters/{filterParentId}/children * @response `200` `FilterType` OK */ - childrenRead: ( - viewId: string, - filterParentId: string, - params: RequestParams = {} - ) => + childrenRead: (filterParentId: string, params: RequestParams = {}) => this.request({ - path: `/views/${viewId}/filters/${filterParentId}/children`, + path: `/api/v1/db/meta/filters/${filterParentId}/children`, method: 'GET', format: 'json', ...params, @@ -2539,12 +2196,12 @@ export class Api< * * @tags DB Table Webhook Filter * @name Read - * @request GET:/hooks/{hookId}/filters + * @request GET:/api/v1/db/meta/hooks/{hookId}/filters * @response `200` `FilterListType` */ read: (hookId: string, params: RequestParams = {}) => this.request({ - path: `/hooks/${hookId}/filters`, + path: `/api/v1/db/meta/hooks/${hookId}/filters`, method: 'GET', ...params, }), @@ -2554,29 +2211,83 @@ export class Api< * * @tags DB Table Webhook Filter * @name Create - * @request POST:/hooks/{hookId}/filters + * @request POST:/api/v1/db/meta/hooks/{hookId}/filters * @response `200` `void` OK */ create: (hookId: string, data: FilterType, params: RequestParams = {}) => this.request({ - path: `/hooks/${hookId}/filters`, + path: `/api/v1/db/meta/hooks/${hookId}/filters`, + method: 'POST', + body: data, + type: ContentType.Json, + ...params, + }), + }; + dbTableRow = { + /** + * No description + * + * @tags DB Table Row + * @name List + * @request GET:/api/v1/db/data/{orgs}/{projectName}/{tableName} + * @response `200` `any` OK + */ + list: ( + orgs: string, + projectName: string, + tableName: string, + query?: { fields?: any[]; sort?: any[]; where?: string }, + params: RequestParams = {} + ) => + this.request({ + path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}`, + method: 'GET', + query: query, + format: 'json', + ...params, + }), + + /** + * No description + * + * @tags DB Table Row + * @name Create + * @request POST:/api/v1/db/data/{orgs}/{projectName}/{tableName} + * @response `200` `any` OK + */ + create: ( + orgs: string, + projectName: string, + tableName: string, + data: any, + params: RequestParams = {} + ) => + this.request({ + path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}`, method: 'POST', body: data, type: ContentType.Json, + format: 'json', ...params, }), /** * No description * - * @tags DB Table Webhook Filter - * @name Get - * @request GET:/hooks/{viewId}/filters/{filterId} - * @response `200` `FilterType` OK + * @tags DB Table Row + * @name Read + * @request GET:/api/v1/db/data/{orgs}/{projectName}/{tableName}/{rowId} + * @response `201` `any` Created */ - get: (viewId: string, filterId: string, params: RequestParams = {}) => - this.request({ - path: `/hooks/${viewId}/filters/${filterId}`, + read: ( + orgs: string, + projectName: string, + tableName: string, + rowId: string, + params: RequestParams = {} + ) => + this.request({ + path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/${rowId}`, method: 'GET', format: 'json', ...params, @@ -2585,36 +2296,45 @@ export class Api< /** * No description * - * @tags DB Table Webhook Filter + * @tags DB Table Row * @name Update - * @request PUT:/hooks/{viewId}/filters/{filterId} - * @response `200` `void` OK + * @request PATCH:/api/v1/db/data/{orgs}/{projectName}/{tableName}/{rowId} + * @response `200` `any` OK */ update: ( - viewId: string, - filterId: string, - data: FilterType, + orgs: string, + projectName: string, + tableName: string, + rowId: string, + data: any, params: RequestParams = {} ) => - this.request({ - path: `/hooks/${viewId}/filters/${filterId}`, - method: 'PUT', + this.request({ + path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/${rowId}`, + method: 'PATCH', body: data, type: ContentType.Json, + format: 'json', ...params, }), /** * No description * - * @tags DB Table Webhook Filter - * @name Delete - * @request DELETE:/hooks/{viewId}/filters/{filterId} + * @tags DB Table Row + * @name ModelDelete + * @request DELETE:/api/v1/db/data/{orgs}/{projectName}/{tableName}/{rowId} * @response `200` `void` OK */ - delete: (viewId: string, filterId: string, params: RequestParams = {}) => + modelDelete: ( + orgs: string, + projectName: string, + tableName: string, + rowId: string, + params: RequestParams = {} + ) => this.request({ - path: `/hooks/${viewId}/filters/${filterId}`, + path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/${rowId}`, method: 'DELETE', ...params, }), @@ -2622,36 +2342,23 @@ export class Api< /** * No description * - * @tags DB Table Webhook Filter - * @name ChildrenRead - * @request GET:/hooks/{viewId}/filters/{filterParentId}/children - * @response `200` `FilterType` OK + * @tags DB Table Row + * @name BulkCreate + * @request POST:/api/v1/db/data/bulk/{orgs}/{projectName}/{tableName} + * @response `200` `any` OK */ - childrenRead: ( - viewId: string, - filterParentId: string, + bulkCreate: ( + orgs: string, + projectName: string, + tableName: string, + data: any, params: RequestParams = {} ) => - this.request({ - path: `/hooks/${viewId}/filters/${filterParentId}/children`, - method: 'GET', - format: 'json', - ...params, - }), - }; - data = { - /** - * No description - * - * @tags Data - * @name List - * @request GET:/data/{tableId} - * @response `200` `any` OK - */ - list: (tableId: string, params: RequestParams = {}) => this.request({ - path: `/data/${tableId}`, - method: 'GET', + path: `/api/v1/db/data/bulk/${orgs}/${projectName}/${tableName}`, + method: 'POST', + body: data, + type: ContentType.Json, format: 'json', ...params, }), @@ -2659,15 +2366,23 @@ export class Api< /** * No description * - * @tags Data - * @name Create - * @request POST:/data/{tableId} + * @tags DB Table Row + * @name BulkCreate2 + * @request PATCH:/api/v1/db/data/bulk/{orgs}/{projectName}/{tableName} + * @originalName bulkCreate + * @duplicate * @response `200` `any` OK */ - create: (tableId: string, data: any, params: RequestParams = {}) => + bulkCreate2: ( + orgs: string, + projectName: string, + tableName: string, + data: any, + params: RequestParams = {} + ) => this.request({ - path: `/data/${tableId}`, - method: 'POST', + path: `/api/v1/db/data/bulk/${orgs}/${projectName}/${tableName}`, + method: 'PATCH', body: data, type: ContentType.Json, format: 'json', @@ -2675,43 +2390,53 @@ export class Api< }), /** - * @description CSV or Excel export + * No description * - * @tags Data - * @name CsvExport - * @request GET:/data/{tableId}/export/{type} + * @tags DB Table Row + * @name BulkCreate3 + * @request DELETE:/api/v1/db/data/bulk/{orgs}/{projectName}/{tableName} + * @originalName bulkCreate + * @duplicate * @response `200` `any` OK */ - csvExport: ( - tableId: string, - type: 'csv' | 'excel', + bulkCreate3: ( + orgs: string, + projectName: string, + tableName: string, + data: any, params: RequestParams = {} ) => this.request({ - path: `/data/${tableId}/export/${type}`, - method: 'GET', - wrapped: true, + path: `/api/v1/db/data/bulk/${orgs}/${projectName}/${tableName}`, + method: 'DELETE', + body: data, + type: ContentType.Json, + format: 'json', ...params, }), /** * No description * - * @tags Data - * @name NestedList - * @request GET:/data/{tableId}/{rowId}/{relationType}/{colId} - * @response `201` `any` Created + * @tags DB Table Row + * @name Create2 + * @request PATCH:/api/v1/db/data/bulk/{orgs}/{projectName}/{tableName}/all + * @originalName create + * @duplicate + * @response `200` `any` OK */ - nestedList: ( - tableId: string, - rowId: string, - colId: string, - relationType: string, + create2: ( + orgs: string, + projectName: string, + tableName: string, + data: any, params: RequestParams = {} ) => this.request({ - path: `/data/${tableId}/${rowId}/${relationType}/${colId}`, - method: 'GET', + path: `/api/v1/db/data/bulk/${orgs}/${projectName}/${tableName}/all`, + method: 'PATCH', + body: data, + type: ContentType.Json, format: 'json', ...params, }), @@ -2719,21 +2444,25 @@ export class Api< /** * No description * - * @tags Data - * @name NestedExcludedList - * @request GET:/data/{tableId}/{rowId}/{relationType}/{colId}/exclude - * @response `201` `any` Created + * @tags DB Table Row + * @name Create3 + * @request DELETE:/api/v1/db/data/bulk/{orgs}/{projectName}/{tableName}/all + * @originalName create + * @duplicate + * @response `200` `any` OK */ - nestedExcludedList: ( - tableId: string, - rowId: string, - colId: string, - relationType: string, + create3: ( + orgs: string, + projectName: string, + tableName: string, + data: any, params: RequestParams = {} ) => this.request({ - path: `/data/${tableId}/${rowId}/${relationType}/${colId}/exclude`, - method: 'GET', + path: `/api/v1/db/data/bulk/${orgs}/${projectName}/${tableName}/all`, + method: 'DELETE', + body: data, + type: ContentType.Json, format: 'json', ...params, }), @@ -2741,60 +2470,69 @@ export class Api< /** * No description * - * @tags Data - * @name NestedAdd - * @request POST:/data/{tableId}/{rowId}/{relationType}/{colId}/{referenceTableRowId} - * @response `201` `any` Created + * @tags DB Table Row + * @name BulkDelete + * @request DELETE:/bulkData/{orgs}/{projectName}/{tableName}/ + * @response `200` `void` OK */ - nestedAdd: ( - tableId: string, - rowId: string, - colId: string, - relationType: string, - referenceTableRowId: string, + bulkDelete: ( + orgs: string, + projectName: string, + tableName: string, + data: any[], params: RequestParams = {} ) => - this.request({ - path: `/data/${tableId}/${rowId}/${relationType}/${colId}/${referenceTableRowId}`, - method: 'POST', - format: 'json', + this.request({ + path: `/bulkData/${orgs}/${projectName}/${tableName}/`, + method: 'DELETE', + body: data, + type: ContentType.Json, ...params, }), /** * No description * - * @tags Data - * @name NestedDelete - * @request DELETE:/data/{tableId}/{rowId}/{relationType}/{colId}/{referenceTableRowId} + * @tags DB Table Row + * @name BulkInsert + * @request POST:/bulkData/{orgs}/{projectName}/{tableName}/ * @response `200` `void` OK */ - nestedDelete: ( - tableId: string, - rowId: string, - colId: string, - relationType: string, - referenceTableRowId: string, + bulkInsert: ( + orgs: string, + projectName: string, + tableName: string, + data: any[], params: RequestParams = {} ) => this.request({ - path: `/data/${tableId}/${rowId}/${relationType}/${colId}/${referenceTableRowId}`, - method: 'DELETE', + path: `/bulkData/${orgs}/${projectName}/${tableName}/`, + method: 'POST', + body: data, + type: ContentType.Json, ...params, }), /** * No description * - * @tags Data - * @name Read - * @request GET:/data/{tableId}/{rowId} - * @response `201` `any` Created + * @tags DB Table Row + * @name BulkUpdate + * @request PATCH:/bulkData/{orgs}/{projectName}/{tableName}/ + * @response `200` `any` OK */ - read: (tableId: string, rowId: string, params: RequestParams = {}) => + bulkUpdate: ( + orgs: string, + projectName: string, + tableName: string, + data: object[], + params: RequestParams = {} + ) => this.request({ - path: `/data/${tableId}/${rowId}`, - method: 'GET', + path: `/bulkData/${orgs}/${projectName}/${tableName}/`, + method: 'PATCH', + body: data, + type: ContentType.Json, format: 'json', ...params, }), @@ -2802,20 +2540,23 @@ export class Api< /** * No description * - * @tags Data - * @name Update - * @request PUT:/data/{tableId}/{rowId} + * @tags DB Table Row + * @name BulkUpdateAll + * @request PATCH:/bulkData/{orgs}/{projectName}/{tableName}/all * @response `200` `any` OK */ - update: ( - tableId: string, - rowId: string, - data: any, + bulkUpdateAll: ( + orgs: string, + projectName: string, + tableName: string, + data: object, + query?: { where?: string }, params: RequestParams = {} ) => this.request({ - path: `/data/${tableId}/${rowId}`, - method: 'PUT', + path: `/bulkData/${orgs}/${projectName}/${tableName}/all`, + method: 'PATCH', + query: query, body: data, type: ContentType.Json, format: 'json', @@ -2825,36 +2566,45 @@ export class Api< /** * No description * - * @tags Data - * @name Delete - * @request DELETE:/data/{tableId}/{rowId} - * @response `200` `void` OK + * @tags DB Table Row + * @name BulkDeleteAll + * @request DELETE:/bulkData/{orgs}/{projectName}/{tableName}/all + * @response `200` `any` OK */ - delete: (tableId: string, rowId: string, params: RequestParams = {}) => - this.request({ - path: `/data/${tableId}/${rowId}`, + bulkDeleteAll: ( + orgs: string, + projectName: string, + tableName: string, + query?: { where?: string }, + params: RequestParams = {} + ) => + this.request({ + path: `/bulkData/${orgs}/${projectName}/${tableName}/all`, method: 'DELETE', + query: query, + format: 'json', ...params, }), }; - dbTableRow = { + dbViewRow = { /** * No description * - * @tags DB Table Row + * @tags DB View Row * @name List - * @request GET:/data/{orgs}/{projectName}/{tableAlias} + * @request GET:/api/v1/db/data/{orgs}/{projectName}/{tableName}/views/{viewName} * @response `200` `any` OK */ list: ( orgs: string, projectName: string, - tableAlias: string, - query?: { fields?: any[]; sort?: any[]; where?: string }, + tableName: string, + viewName: string, + query?: { fields?: any[]; sort?: any[]; where?: string; nested?: any }, params: RequestParams = {} ) => this.request({ - path: `/data/${orgs}/${projectName}/${tableAlias}`, + path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/views/${viewName}`, method: 'GET', query: query, format: 'json', @@ -2864,20 +2614,21 @@ export class Api< /** * No description * - * @tags DB Table Row + * @tags DB View Row * @name Create - * @request POST:/data/{orgs}/{projectName}/{tableAlias} + * @request POST:/api/v1/db/data/{orgs}/{projectName}/{tableName}/views/{viewName} * @response `200` `any` OK */ create: ( orgs: string, projectName: string, - tableAlias: string, + tableName: string, + viewName: string, data: any, params: RequestParams = {} ) => this.request({ - path: `/data/${orgs}/${projectName}/${tableAlias}`, + path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/views/${viewName}`, method: 'POST', body: data, type: ContentType.Json, @@ -2888,135 +2639,196 @@ export class Api< /** * No description * - * @tags DB Table Row + * @tags DB View Row * @name Read - * @request GET:/data/{orgs}/{projectName}/{tableAlias}/{rowId} + * @request GET:/api/v1/db/data/{orgs}/{projectName}/{tableName}/views/{viewName}/{rowId} * @response `201` `any` Created */ read: ( orgs: string, projectName: string, - tableAlias: string, + tableName: string, + viewName: string, rowId: string, params: RequestParams = {} ) => this.request({ - path: `/data/${orgs}/${projectName}/${tableAlias}/${rowId}`, + path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/views/${viewName}/${rowId}`, method: 'GET', format: 'json', ...params, }), - + + /** + * No description + * + * @tags DB View Row + * @name Update + * @request PATCH:/api/v1/db/data/{orgs}/{projectName}/{tableName}/views/{viewName}/{rowId} + * @response `200` `any` OK + */ + update: ( + orgs: string, + projectName: string, + tableName: string, + viewName: string, + rowId: string, + data: any, + params: RequestParams = {} + ) => + this.request({ + path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/views/${viewName}/${rowId}`, + method: 'PATCH', + body: data, + type: ContentType.Json, + format: 'json', + ...params, + }), + + /** + * No description + * + * @tags DB View Row + * @name Delete + * @request DELETE:/api/v1/db/data/{orgs}/{projectName}/{tableName}/views/{viewName}/{rowId} + * @response `200` `void` OK + */ + delete: ( + orgs: string, + projectName: string, + tableName: string, + viewName: string, + rowId: string, + params: RequestParams = {} + ) => + this.request({ + path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/views/${viewName}/${rowId}`, + method: 'DELETE', + ...params, + }), + }; + data = { /** - * No description + * @description CSV or Excel export * - * @tags DB Table Row - * @name Update - * @request PUT:/data/{orgs}/{projectName}/{tableAlias}/{rowId} + * @tags Data + * @name CsvExport + * @request GET:/api/v1/db/data/{orgs}/{projectName}/{tableName}/views/{viewName}/export/{type} * @response `200` `any` OK */ - update: ( + csvExport: ( orgs: string, projectName: string, - tableAlias: string, - rowId: string, - data: any, + tableName: string, + viewName: string, + type: 'csv' | 'excel', params: RequestParams = {} ) => this.request({ - path: `/data/${orgs}/${projectName}/${tableAlias}/${rowId}`, - method: 'PUT', - body: data, - type: ContentType.Json, - format: 'json', + path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/views/${viewName}/export/${type}`, + method: 'GET', + wrapped: true, ...params, }), /** - * No description + * @description CSV or Excel export * - * @tags DB Table Row - * @name ModelDelete - * @request DELETE:/data/{orgs}/{projectName}/{tableAlias}/{rowId} - * @response `200` `void` OK + * @tags Data + * @name CsvExport2 + * @request GET:/api/v1/db/data/{orgs}/{projectName}/{tableName}/export/{type} + * @originalName csvExport + * @duplicate + * @response `200` `any` OK */ - modelDelete: ( + csvExport2: ( orgs: string, projectName: string, - tableAlias: string, - rowId: string, + tableName: string, + type: 'csv' | 'excel', params: RequestParams = {} ) => - this.request({ - path: `/data/${orgs}/${projectName}/${tableAlias}/${rowId}`, - method: 'DELETE', + this.request({ + path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/export/${type}`, + method: 'GET', + wrapped: true, ...params, }), - + }; + public = { /** * No description * - * @tags DB Table Row - * @name BulkDelete - * @request DELETE:/bulkData/{orgs}/{projectName}/{tableAlias}/ - * @response `200` `void` OK + * @tags Public + * @name DataNestedList + * @request GET:/api/v1/db/data/{orgs}/{projectName}/{tableName}/{rowId}/{relationType}/{columnName} + * @response `200` `any` OK */ - bulkDelete: ( + dataNestedList: ( orgs: string, projectName: string, - tableAlias: string, - data: any[], + tableName: string, + rowId: string, + relationType: 'mm' | 'hm', + columnName: string, + query?: { limit?: string; offset?: string }, params: RequestParams = {} ) => - this.request({ - path: `/bulkData/${orgs}/${projectName}/${tableAlias}/`, - method: 'DELETE', - body: data, - type: ContentType.Json, + this.request({ + path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/${rowId}/${relationType}/${columnName}`, + method: 'GET', + query: query, + format: 'json', ...params, }), /** * No description * - * @tags DB Table Row - * @name BulkInsert - * @request POST:/bulkData/{orgs}/{projectName}/{tableAlias}/ - * @response `200` `void` OK + * @tags Public + * @name DataNestedList2 + * @request POST:/api/v1/db/data/{orgs}/{projectName}/{tableName}/{rowId}/{relationType}/{columnName}/{refRowId} + * @originalName dataNestedList + * @duplicate + * @response `200` `any` OK */ - bulkInsert: ( + dataNestedList2: ( orgs: string, projectName: string, - tableAlias: string, - data: any[], + tableName: string, + rowId: string, + relationType: 'mm' | 'hm', + columnName: string, + refRowId: string, + query?: { limit?: string; offset?: string }, params: RequestParams = {} ) => - this.request({ - path: `/bulkData/${orgs}/${projectName}/${tableAlias}/`, + this.request({ + path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/${rowId}/${relationType}/${columnName}/${refRowId}`, method: 'POST', - body: data, - type: ContentType.Json, + query: query, + format: 'json', ...params, }), /** * No description * - * @tags DB Table Row - * @name BulkUpdate - * @request PATCH:/bulkData/{orgs}/{projectName}/{tableAlias}/ + * @tags Public + * @name DataList + * @request GET:/api/v1/db/public/shared-view/{sharedViewUuid}/rows * @response `200` `any` OK */ - bulkUpdate: ( - orgs: string, - projectName: string, - tableAlias: string, - data: object[], + dataList: ( + sharedViewUuid: string, + data: { password?: string; sorts?: SortType[]; filters?: FilterType[] }, + query?: { limit?: string; offset?: string }, params: RequestParams = {} ) => this.request({ - path: `/bulkData/${orgs}/${projectName}/${tableAlias}/`, - method: 'PATCH', + path: `/api/v1/db/public/shared-view/${sharedViewUuid}/rows`, + method: 'GET', + query: query, body: data, type: ContentType.Json, format: 'json', @@ -3026,25 +2838,21 @@ export class Api< /** * No description * - * @tags DB Table Row - * @name BulkUpdateAll - * @request PATCH:/bulkData/{orgs}/{projectName}/{tableAlias}/all + * @tags Public + * @name SharedViewCreate + * @request POST:/api/v1/db/public/shared-view/{sharedViewUuid}/rows * @response `200` `any` OK */ - bulkUpdateAll: ( - orgs: string, - projectName: string, - tableAlias: string, - data: object, - query?: { where?: string }, + sharedViewCreate: ( + sharedViewUuid: string, + data: { data?: any; password?: string }, params: RequestParams = {} ) => this.request({ - path: `/bulkData/${orgs}/${projectName}/${tableAlias}/all`, - method: 'PATCH', - query: query, + path: `/api/v1/db/public/shared-view/${sharedViewUuid}/rows`, + method: 'POST', body: data, - type: ContentType.Json, + type: ContentType.FormData, format: 'json', ...params, }), @@ -3052,45 +2860,47 @@ export class Api< /** * No description * - * @tags DB Table Row - * @name BulkDeleteAll - * @request DELETE:/bulkData/{orgs}/{projectName}/{tableAlias}/all + * @tags Public + * @name DataNestedList3 + * @request GET:/api/v1/db/public/shared-view/{sharedViewUuid}/rows/{rowId}/{relationType}/{columnName} + * @originalName dataNestedList + * @duplicate * @response `200` `any` OK */ - bulkDeleteAll: ( - orgs: string, - projectName: string, - tableAlias: string, - query?: { where?: string }, + dataNestedList3: ( + sharedViewUuid: string, + rowId: string, + relationType: 'mm' | 'hm', + columnName: string, + query?: { limit?: string; offset?: string }, params: RequestParams = {} ) => this.request({ - path: `/bulkData/${orgs}/${projectName}/${tableAlias}/all`, - method: 'DELETE', + path: `/api/v1/db/public/shared-view/${sharedViewUuid}/rows/${rowId}/${relationType}/${columnName}`, + method: 'GET', query: query, format: 'json', ...params, }), - }; - dbViewRow = { + /** * No description * - * @tags DB View Row - * @name List - * @request GET:/data/{orgs}/{projectName}/{tableAlias}/views/{viewName} + * @tags Public + * @name DataNestedExcludedList + * @request GET:/api/v1/db/public/shared-view/{sharedViewUuid}/rows/{rowId}/{relationType}/{columnName}/exclude * @response `200` `any` OK */ - list: ( - orgs: string, - projectName: string, - tableAlias: string, - viewName: string, - query?: { fields?: any[]; sort?: any[]; where?: string; nested?: any }, + dataNestedExcludedList: ( + sharedViewUuid: string, + rowId: string, + relationType: 'mm' | 'hm', + columnName: string, + query?: { limit?: string; offset?: string }, params: RequestParams = {} ) => this.request({ - path: `/data/${orgs}/${projectName}/${tableAlias}/views/${viewName}`, + path: `/api/v1/db/public/shared-view/${sharedViewUuid}/rows/${rowId}/${relationType}/${columnName}/exclude`, method: 'GET', query: query, format: 'json', @@ -3100,47 +2910,47 @@ export class Api< /** * No description * - * @tags DB View Row - * @name Create - * @request POST:/data/{orgs}/{projectName}/{tableAlias}/views/{viewName} + * @tags Public + * @name CsvExport + * @request POST:/api/v1/db/public/shared-view/{sharedViewUuid}/rows/export/{type} * @response `200` `any` OK */ - create: ( - orgs: string, - projectName: string, - tableAlias: string, - viewName: string, - data: any, + csvExport: ( + sharedViewUuid: string, + type: 'csv' | 'excel', + data: { password?: string; filters?: FilterType[]; sorts?: SortType[] }, params: RequestParams = {} ) => this.request({ - path: `/data/${orgs}/${projectName}/${tableAlias}/views/${viewName}`, + path: `/api/v1/db/public/shared-view/${sharedViewUuid}/rows/export/${type}`, method: 'POST', body: data, type: ContentType.Json, - format: 'json', + wrapped: true, ...params, }), /** * No description * - * @tags DB View Row - * @name Read - * @request GET:/data/{orgs}/{projectName}/{tableAlias}/views/{viewName}/{rowId} - * @response `201` `any` Created + * @tags Public + * @name DataRelationList + * @request POST:/api/v1/db/public/shared-view/{sharedViewUuid}/rows/nested/{columnName} + * @response `200` `any` OK */ - read: ( - orgs: string, - projectName: string, - tableAlias: string, - viewName: string, - rowId: string, + dataRelationList: ( + sharedViewUuid: string, + columnName: string, + data: { password?: string }, + query?: { limit?: string; offset?: string }, params: RequestParams = {} ) => this.request({ - path: `/data/${orgs}/${projectName}/${tableAlias}/views/${viewName}/${rowId}`, - method: 'GET', + path: `/api/v1/db/public/shared-view/${sharedViewUuid}/rows/nested/${columnName}`, + method: 'POST', + query: query, + body: data, + type: ContentType.Json, format: 'json', ...params, }), @@ -3148,48 +2958,65 @@ export class Api< /** * No description * - * @tags DB View Row - * @name Update - * @request PUT:/data/{orgs}/{projectName}/{tableAlias}/views/{viewName}/{rowId} - * @response `200` `any` OK + * @tags Public + * @name SharedViewMetaGet + * @request POST:/api/v1/db/public/shared-view/{sharedViewUuid}/meta + * @response `200` `object` OK */ - update: ( - orgs: string, - projectName: string, - tableAlias: string, - viewName: string, - rowId: string, - data: any, + sharedViewMetaGet: ( + sharedViewUuid: string, + data: { password?: string }, params: RequestParams = {} ) => - this.request({ - path: `/data/${orgs}/${projectName}/${tableAlias}/views/${viewName}/${rowId}`, - method: 'PUT', + this.request({ + path: `/api/v1/db/public/shared-view/${sharedViewUuid}/meta`, + method: 'POST', body: data, type: ContentType.Json, format: 'json', ...params, }), + /** + * @description Read project details + * + * @tags Public + * @name SharedBaseGet + * @request GET:/api/v1/db/public/shared-base/{sharedBaseUuid}/meta + * @response `200` `{ project_id?: string }` OK + */ + sharedBaseGet: (sharedBaseUuid: string, params: RequestParams = {}) => + this.request<{ project_id?: string }, any>({ + path: `/api/v1/db/public/shared-base/${sharedBaseUuid}/meta`, + method: 'GET', + format: 'json', + ...params, + }), + }; + dbData = { /** * No description * - * @tags DB View Row - * @name Delete - * @request DELETE:/data/{orgs}/{projectName}/{tableAlias}/views/{viewName}/{rowId} - * @response `200` `void` OK + * @tags DB Data + * @name DataNestedExcludedChildrenList + * @request GET:/api/v1/db/data/{orgs}/{projectName}/{tableName}/{rowId}/{relationType}/{columnName}/exclude + * @response `200` `any` OK */ - delete: ( + dataNestedExcludedChildrenList: ( orgs: string, projectName: string, - tableAlias: string, - viewName: string, + tableName: string, rowId: string, + relationType: 'mm' | 'hm', + columnName: string, + query?: { limit?: string; offset?: string }, params: RequestParams = {} ) => - this.request({ - path: `/data/${orgs}/${projectName}/${tableAlias}/views/${viewName}/${rowId}`, - method: 'DELETE', + this.request({ + path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/${rowId}/${relationType}/${columnName}/exclude`, + method: 'GET', + query: query, + format: 'json', ...params, }), }; @@ -3199,7 +3026,7 @@ export class Api< * * @tags Utils * @name CommentList - * @request GET:/audits/comments + * @request GET:/api/v1/db/meta/audits/comments * @response `201` `any` Created */ commentList: ( @@ -3207,7 +3034,7 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/audits/comments`, + path: `/api/v1/db/meta/audits/comments`, method: 'GET', query: query, format: 'json', @@ -3219,7 +3046,7 @@ export class Api< * * @tags Utils * @name CommentRow - * @request POST:/audits/comments + * @request POST:/api/v1/db/meta/audits/comments * @response `200` `void` OK */ commentRow: ( @@ -3227,7 +3054,7 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/audits/comments`, + path: `/api/v1/db/meta/audits/comments`, method: 'POST', body: data, type: ContentType.Json, @@ -3239,7 +3066,7 @@ export class Api< * * @tags Utils * @name CommentCount - * @request GET:/audits/comments/count + * @request GET:/api/v1/db/meta/meta/audits/comments/count * @response `201` `any` Created */ commentCount: ( @@ -3247,7 +3074,7 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/audits/comments/count`, + path: `/api/v1/db/meta/meta/audits/comments/count`, method: 'GET', query: query, format: 'json', @@ -3259,10 +3086,11 @@ export class Api< * * @tags Utils * @name AuditRowUpdate - * @request POST:/audits/rowUpdate + * @request POST:/api/v1/db/meta/audits/rows/{rowId}/update * @response `200` `void` OK */ auditRowUpdate: ( + rowId: string, data: { fk_model_id?: string; column_name?: string; @@ -3273,7 +3101,7 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/audits/rowUpdate`, + path: `/api/v1/db/meta/audits/rows/${rowId}/update`, method: 'POST', body: data, type: ContentType.Json, @@ -3285,12 +3113,12 @@ export class Api< * * @tags Utils * @name TestConnection - * @request POST:/testConnection + * @request POST:/api/v1/db/meta/connection/test * @response `200` `{ code?: number, message?: string }` OK */ testConnection: (data: any, params: RequestParams = {}) => this.request<{ code?: number; message?: string }, any>({ - path: `/testConnection`, + path: `/api/v1/db/meta/connection/test`, method: 'POST', body: data, type: ContentType.Json, @@ -3303,12 +3131,12 @@ export class Api< * * @tags Utils * @name AppInfo - * @request GET:/appInfo + * @request GET:/api/v1/db/meta/nocodb/info * @response `200` `any` OK */ appInfo: (params: RequestParams = {}) => this.request({ - path: `/appInfo`, + path: `/api/v1/db/meta/nocodb/info`, method: 'GET', format: 'json', ...params, @@ -3320,11 +3148,11 @@ export class Api< * @tags Utils * @name CacheGet * @summary Your GET endpoint - * @request GET:/cache + * @request GET:/api/v1/db/meta/cache */ cacheGet: (params: RequestParams = {}) => this.request({ - path: `/cache`, + path: `/api/v1/db/meta/cache`, method: 'GET', ...params, }), @@ -3334,12 +3162,12 @@ export class Api< * * @tags Utils * @name CacheDelete - * @request DELETE:/cache + * @request DELETE:/api/v1/db/meta/cache * @response `200` `void` OK */ cacheDelete: (params: RequestParams = {}) => this.request({ - path: `/cache`, + path: `/api/v1/db/meta/cache`, method: 'DELETE', ...params, }), @@ -3350,12 +3178,12 @@ export class Api< * * @tags DB Table Webhook * @name List - * @request GET:/tables/{tableId}/hooks + * @request GET:/api/v1/db/meta/tables/{tableId}/hooks * @response `200` `{ list: (HookType)[], pageInfo: PaginatedType }` OK */ list: (tableId: string, params: RequestParams = {}) => this.request<{ list: HookType[]; pageInfo: PaginatedType }, any>({ - path: `/tables/${tableId}/hooks`, + path: `/api/v1/db/meta/tables/${tableId}/hooks`, method: 'GET', format: 'json', ...params, @@ -3366,12 +3194,12 @@ export class Api< * * @tags DB Table Webhook * @name Create - * @request POST:/tables/{tableId}/hooks + * @request POST:/api/v1/db/meta/tables/{tableId}/hooks * @response `200` `AuditType` OK */ create: (tableId: string, data: AuditType, params: RequestParams = {}) => this.request({ - path: `/tables/${tableId}/hooks`, + path: `/api/v1/db/meta/tables/${tableId}/hooks`, method: 'POST', body: data, type: ContentType.Json, @@ -3384,7 +3212,7 @@ export class Api< * * @tags DB Table Webhook * @name Test - * @request POST:/tables/{tableId}/hooks/test + * @request POST:/api/v1/db/meta/tables/{tableId}/hooks/test * @response `200` `any` OK */ test: ( @@ -3393,7 +3221,7 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/tables/${tableId}/hooks/test`, + path: `/api/v1/db/meta/tables/${tableId}/hooks/test`, method: 'POST', body: data, type: ContentType.Json, @@ -3401,18 +3229,41 @@ export class Api< ...params, }), + /** + * No description + * + * @tags DB Table Webhook + * @name SamplePayloadGet + * @request GET:/api/v1/db/meta/tables/{tableId}/hooks/samplePayload/{operation} + * @response `200` `{ plugins?: { list: (PluginType)[], pageInfo: PaginatedType } }` OK + */ + samplePayloadGet: ( + tableId: string, + operation: 'update' | 'delete' | 'insert', + params: RequestParams = {} + ) => + this.request< + { plugins?: { list: PluginType[]; pageInfo: PaginatedType } }, + any + >({ + path: `/api/v1/db/meta/tables/${tableId}/hooks/samplePayload/${operation}`, + method: 'GET', + format: 'json', + ...params, + }), + /** * No description * * @tags DB Table Webhook * @name Update - * @request PUT:/hooks/{hookId} + * @request PATCH:/api/v1/db/meta/hooks/{hookId} * @response `200` `HookType` OK */ update: (hookId: string, data: HookType, params: RequestParams = {}) => this.request({ - path: `/hooks/${hookId}`, - method: 'PUT', + path: `/api/v1/db/meta/hooks/${hookId}`, + method: 'PATCH', body: data, type: ContentType.Json, format: 'json', @@ -3424,38 +3275,15 @@ export class Api< * * @tags DB Table Webhook * @name Delete - * @request DELETE:/hooks/{hookId} + * @request DELETE:/api/v1/db/meta/hooks/{hookId} * @response `200` `void` OK */ delete: (hookId: string, params: RequestParams = {}) => this.request({ - path: `/hooks/${hookId}`, + path: `/api/v1/db/meta/hooks/${hookId}`, method: 'DELETE', ...params, }), - - /** - * No description - * - * @tags DB Table Webhook - * @name SamplePayloadGet - * @request GET:/tables/{tableId}/hooks/samplePayload/{operation} - * @response `200` `{ plugins?: { list: (PluginType)[], pageInfo: PaginatedType } }` OK - */ - samplePayloadGet: ( - tableId: string, - operation: 'update' | 'delete' | 'insert', - params: RequestParams = {} - ) => - this.request< - { plugins?: { list: PluginType[]; pageInfo: PaginatedType } }, - any - >({ - path: `/tables/${tableId}/hooks/samplePayload/${operation}`, - method: 'GET', - format: 'json', - ...params, - }), }; plugin = { /** @@ -3463,12 +3291,12 @@ export class Api< * * @tags Plugin * @name List - * @request GET:/plugins + * @request GET:/api/v1/db/meta/plugins * @response `200` `{ list?: (PluginType)[], pageInfo?: PaginatedType }` OK */ list: (params: RequestParams = {}) => this.request<{ list?: PluginType[]; pageInfo?: PaginatedType }, any>({ - path: `/plugins`, + path: `/api/v1/db/meta/plugins`, method: 'GET', format: 'json', ...params, @@ -3479,12 +3307,12 @@ export class Api< * * @tags Plugin * @name Status - * @request GET:/plugins/{pluginTitle}/status + * @request GET:/api/v1/db/meta/plugins/{pluginTitle}/status * @response `200` `boolean` OK */ status: (pluginTitle: string, params: RequestParams = {}) => this.request({ - path: `/plugins/${pluginTitle}/status`, + path: `/api/v1/db/meta/plugins/${pluginTitle}/status`, method: 'GET', format: 'json', ...params, @@ -3495,7 +3323,7 @@ export class Api< * * @tags Plugin * @name Test - * @request POST:/plugins/test + * @request POST:/api/v1/db/meta/plugins/test * @response `200` `any` OK * @response `400` `void` Bad Request * @response `401` `void` Unauthorized @@ -3505,7 +3333,7 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/plugins/test`, + path: `/api/v1/db/meta/plugins/test`, method: 'POST', body: data, type: ContentType.Json, @@ -3518,13 +3346,13 @@ export class Api< * * @tags Plugin * @name Update - * @request PUT:/plugins/{pluginId} + * @request PATCH:/api/v1/db/meta/plugins/{pluginId} * @response `200` `PluginType` OK */ update: (pluginId: string, data: PluginType, params: RequestParams = {}) => this.request({ - path: `/plugins/${pluginId}`, - method: 'PUT', + path: `/api/v1/db/meta/plugins/${pluginId}`, + method: 'PATCH', body: data, type: ContentType.Json, format: 'json', @@ -3536,12 +3364,12 @@ export class Api< * * @tags Plugin * @name Read - * @request GET:/plugins/{pluginId} + * @request GET:/api/v1/db/meta/plugins/{pluginId} * @response `200` `PluginType` OK */ read: (pluginId: string, params: RequestParams = {}) => this.request({ - path: `/plugins/${pluginId}`, + path: `/api/v1/db/meta/plugins/${pluginId}`, method: 'GET', format: 'json', ...params, @@ -3554,12 +3382,12 @@ export class Api< * @tags Api token * @name List * @summary Your GET endpoint - * @request GET:/projects/{projectId}/apiTokens + * @request GET:/api/v1/db/meta/projects/{projectId}/apiTokens * @response `200` `(ApiTokenType)[]` OK */ list: (projectId: string, params: RequestParams = {}) => this.request({ - path: `/projects/${projectId}/apiTokens`, + path: `/api/v1/db/meta/projects/${projectId}/apiTokens`, method: 'GET', format: 'json', ...params, @@ -3570,7 +3398,7 @@ export class Api< * * @tags Api token * @name Create - * @request POST:/projects/{projectId}/apiTokens + * @request POST:/api/v1/db/meta/projects/{projectId}/apiTokens * @response `200` `void` OK * @response `201` `ApiTokenType` Created */ @@ -3580,7 +3408,7 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/projects/${projectId}/apiTokens`, + path: `/api/v1/db/meta/projects/${projectId}/apiTokens`, method: 'POST', body: data, type: ContentType.Json, @@ -3592,12 +3420,12 @@ export class Api< * * @tags Api token * @name Delete - * @request DELETE:/projects/{projectId}/apiTokens/{token} + * @request DELETE:/api/v1/db/meta/projects/{projectId}/apiTokens/{token} * @response `200` `void` OK */ delete: (projectId: string, token: string, params: RequestParams = {}) => this.request({ - path: `/projects/${projectId}/apiTokens/${token}`, + path: `/api/v1/db/meta/projects/${projectId}/apiTokens/${token}`, method: 'DELETE', ...params, }), diff --git a/packages/nocodb/package.json b/packages/nocodb/package.json index 8ebc269333..97dda45b4a 100644 --- a/packages/nocodb/package.json +++ b/packages/nocodb/package.json @@ -154,7 +154,7 @@ "nc-lib-gui": "0.84.15", "nc-plugin": "^0.1.1", "ncp": "^2.0.0", - "nocodb-sdk": "0.0.9", + "nocodb-sdk": "file:../nocodb-sdk", "nodemailer": "^6.4.10", "ora": "^4.0.4", "os-locale": "^5.0.0", diff --git a/packages/nocodb/src/lib/noco-models/User.ts b/packages/nocodb/src/lib/noco-models/User.ts index 3bb5ab76ae..7e7cdf3bdc 100644 --- a/packages/nocodb/src/lib/noco-models/User.ts +++ b/packages/nocodb/src/lib/noco-models/User.ts @@ -136,4 +136,11 @@ export default class User implements UserType { } return user; } + + static async getByRefreshToken(refresh_token, ncMeta = Noco.ncMeta) { + const user = await ncMeta.metaGet2(null, null, MetaTable.USERS, { + refresh_token + }); + return user; + } } diff --git a/packages/nocodb/src/lib/noco/meta/api/apiTokenApis.ts b/packages/nocodb/src/lib/noco/meta/api/apiTokenApis.ts index 5043225c24..5a02a8bed7 100644 --- a/packages/nocodb/src/lib/noco/meta/api/apiTokenApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/apiTokenApis.ts @@ -18,15 +18,15 @@ export async function apiTokenDelete(req: Request, res: Response) { const router = Router({ mergeParams: true }); router.get( - '/projects/:projectId/apiTokens', + '/api/v1/db/meta/projects/:projectId/apiTokens', ncMetaAclMw(apiTokenList, 'apiTokenList') ); router.post( - '/projects/:projectId/apiTokens', + '/api/v1/db/meta/projects/:projectId/apiTokens', ncMetaAclMw(apiTokenCreate, 'apiTokenCreate') ); router.delete( - '/projects/:projectId/apiTokens/:token', + '/api/v1/db/meta/projects/:projectId/apiTokens/:token', ncMetaAclMw(apiTokenDelete, 'apiTokenDelete') ); diff --git a/packages/nocodb/src/lib/noco/meta/api/auditApis.ts b/packages/nocodb/src/lib/noco/meta/api/auditApis.ts index 2ec433fd0c..c5b9944934 100644 --- a/packages/nocodb/src/lib/noco/meta/api/auditApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/auditApis.ts @@ -20,7 +20,7 @@ export async function auditRowUpdate(req: Request, res) { res.json( await Audit.insert({ fk_model_id: req.body.fk_model_id, - row_id: req.body.row_id, + row_id: req.params.rowId, op_type: AuditOperationTypes.DATA, op_sub_type: AuditOperationSubTypes.UPDATE, description: `Table ${model.table_name} : field ${req.body.column_name} got changed from ${req.body.prev_value} to ${req.body.value}`, @@ -58,12 +58,24 @@ export async function commentsCount(req: Request, res) { } const router = Router({ mergeParams: true }); -router.get('/audits/comments', ncMetaAclMw(commentList, 'commentList')); -router.post('/audits/rowUpdate', ncMetaAclMw(auditRowUpdate, 'auditRowUpdate')); -router.post('/audits/comments', ncMetaAclMw(commentRow, 'commentRow')); router.get( - '/audits/comments/count', + '/api/v1/db/meta/audits/comments', + ncMetaAclMw(commentList, 'commentList') +); +router.post( + '/api/v1/db/meta/audits/comments', + ncMetaAclMw(commentRow, 'commentRow') +); +router.post( + '/api/v1/db/meta/audits/rows/:rowId/update', + ncMetaAclMw(auditRowUpdate, 'auditRowUpdate') +); +router.get( + '/api/v1/db/meta/audits/comments/count', ncMetaAclMw(commentsCount, 'commentsCount') ); -router.get('/project/:projectId/audits', ncMetaAclMw(auditList, 'auditList')); +router.get( + '/api/v1/db/meta/project/:projectId/audits', + ncMetaAclMw(auditList, 'auditList') +); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/cacheApis.ts b/packages/nocodb/src/lib/noco/meta/api/cacheApis.ts index 8813822856..082aab1aa5 100644 --- a/packages/nocodb/src/lib/noco/meta/api/cacheApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/cacheApis.ts @@ -16,6 +16,6 @@ export async function cacheDelete(_, res) { } const router = Router(); -router.get('/cache', catchError(cacheGet)); -router.delete('/cache', catchError(cacheDelete)); +router.get('/api/v1/db/meta/cache', catchError(cacheGet)); +router.delete('/api/v1/db/meta/cache', catchError(cacheDelete)); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/columnApis.ts b/packages/nocodb/src/lib/noco/meta/api/columnApis.ts index 91b18ce1a5..4a74d8c00c 100644 --- a/packages/nocodb/src/lib/noco/meta/api/columnApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/columnApis.ts @@ -498,14 +498,15 @@ export async function columnAdd(req: Request, res: Response) { } export async function columnSetAsPrimary(req: Request, res: Response) { - res.json( - await Model.updatePrimaryColumn(req.params.tableId, req.params.columnId) - ); + const column = await Column.get({ colId: req.params.columnId }); + res.json(await Model.updatePrimaryColumn(column.fk_model_id, column.id)); } export async function columnUpdate(req: Request, res: Response) { + const column = await Column.get({ colId: req.params.columnId }); + const table = await Model.getWithInfo({ - id: req.params.tableId + id: column.fk_model_id }); const base = await Base.get(table.base_id); @@ -529,7 +530,6 @@ export async function columnUpdate(req: Request, res: Response) { NcError.badRequest('Duplicate column alias'); } - const column = table.columns.find(c => c.id === req.params.columnId); let colBody = req.body; if ( [ @@ -622,8 +622,9 @@ export async function columnUpdate(req: Request, res: Response) { } export async function columnDelete(req: Request, res: Response) { + const column = await Column.get({ colId: req.params.columnId }); const table = await Model.getWithInfo({ - id: req.params.tableId + id: column.fk_model_id }); const base = await Base.get(table.base_id); @@ -636,9 +637,6 @@ export async function columnDelete(req: Request, res: Response) { const sqlMgr = await ProjectMgrv2.getSqlMgr({ id: base.project_id }); - // try { - const column: Column = table.columns.find(c => c.id === req.params.columnId); - switch (column.uidt) { case UITypes.Lookup: case UITypes.Rollup: @@ -900,17 +898,20 @@ const deleteHmOrBtRelation = async ( }; const router = Router({ mergeParams: true }); -router.post('/tables/:tableId/columns/', ncMetaAclMw(columnAdd, 'columnAdd')); -router.put( - '/tables/:tableId/columns/:columnId', +router.post( + '/api/v1/db/meta/tables/:tableId/columns/', + ncMetaAclMw(columnAdd, 'columnAdd') +); +router.patch( + '/api/v1/db/meta/columns/:columnId', ncMetaAclMw(columnUpdate, 'columnUpdate') ); router.delete( - '/tables/:tableId/columns/:columnId', + '/api/v1/db/meta/columns/:columnId', ncMetaAclMw(columnDelete, 'columnDelete') ); router.post( - '/tables/:tableId/columns/:columnId/primary', + '/api/v1/db/meta/columns/:columnId/primary', ncMetaAclMw(columnSetAsPrimary, 'columnSetAsPrimary') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasApis.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasApis.ts index 0167b8692f..783741d76a 100644 --- a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasApis.ts @@ -8,7 +8,7 @@ import View from '../../../../noco-models/View'; import ncMetaAclMw from '../../helpers/ncMetaAclMw'; import { getViewAndModelFromRequestByAliasOrId } from './helpers'; -export async function dataList(req: Request, res: Response) { +async function dataList(req: Request, res: Response) { const { model, view } = await getViewAndModelFromRequestByAliasOrId(req); res.json(await getDataList(model, view, req)); } @@ -108,20 +108,44 @@ async function dataRead(req: Request, res: Response) { const router = Router({ mergeParams: true }); +// table data crud apis router.get( '/api/v1/db/data/:orgs/:projectName/:tableName', ncMetaAclMw(dataList, 'dataList') ); +router.get( + '/api/v1/db/data/:orgs/:projectName/:tableName/:rowId', + ncMetaAclMw(dataRead, 'dataRead') +); +router.patch( + '/api/v1/db/data/:orgs/:projectName/:tableName/:rowId', + ncMetaAclMw(dataUpdate, 'dataUpdate') +); +router.patch( + '/api/v1/db/data/:orgs/:projectName/:tableName/:rowId', + ncMetaAclMw(dataUpdate, 'dataUpdate') +); + +router.get( + '/api/v1/db/data/:orgs/:projectName/:tableName', + ncMetaAclMw(dataList, 'dataList') +); + +// table view data crud apis router.get( '/api/v1/db/data/:orgs/:projectName/:tableName/views/:viewName', ncMetaAclMw(dataList, 'dataList') ); +router.post( + '/api/v1/db/data/:orgs/:projectName/:tableName', + ncMetaAclMw(dataInsert, 'dataInsert') +); router.post( '/api/v1/db/data/:orgs/:projectName/:tableName/views/:viewName', ncMetaAclMw(dataInsert, 'dataInsert') ); -router.put( +router.patch( '/api/v1/db/data/:orgs/:projectName/:tableName/views/:viewName/:rowId', ncMetaAclMw(dataUpdate, 'dataUpdate') ); diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasNestedApis.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasNestedApis.ts new file mode 100644 index 0000000000..9d1c99f7f8 --- /dev/null +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasNestedApis.ts @@ -0,0 +1,308 @@ +import { Request, Response, Router } from 'express'; +import Model from '../../../../noco-models/Model'; +import Base from '../../../../noco-models/Base'; +import NcConnectionMgrv2 from '../../../common/NcConnectionMgrv2'; +import { PagedResponseImpl } from '../../helpers/PagedResponse'; +import View from '../../../../noco-models/View'; +import ncMetaAclMw from '../../helpers/ncMetaAclMw'; +import { getViewAndModelFromRequestByAliasOrId } from './helpers'; +import { NcError } from '../../helpers/catchError'; + +export async function mmList(req: Request, res: Response, next) { + const { model, view } = await getViewAndModelFromRequestByAliasOrId(req); + + if (!model) return next(new Error('Table not found')); + + const base = await Base.get(model.base_id); + + const baseModel = await Model.getBaseModelSQL({ + id: model.id, + viewId: view?.id, + dbDriver: NcConnectionMgrv2.get(base) + }); + + const column = await getColumnByIdOrName(req.params.columnName, model); + + const data = await baseModel.mmList( + { + colId: column.id, + parentId: req.params.rowId + }, + req.query as any + ); + const count: any = await baseModel.mmListCount({ + colId: column.id, + parentId: req.params.rowId + }); + + res.json( + new PagedResponseImpl(data, { + count, + ...req.query + }) + ); +} + +export async function mmExcludedList(req: Request, res: Response, next) { + const view = await View.get(req.params.viewId); + + const model = await Model.getByIdOrName({ + id: view?.fk_model_id || req.params.viewId + }); + + if (!model) return next(new Error('Table not found')); + + const base = await Base.get(model.base_id); + + const baseModel = await Model.getBaseModelSQL({ + id: model.id, + viewId: view?.id, + dbDriver: NcConnectionMgrv2.get(base) + }); + const column = await getColumnByIdOrName(req.params.columnName, model); + + const data = await baseModel.getMmChildrenExcludedList( + { + colId: column.id, + pid: req.params.rowId + }, + req.query + ); + + const count = await baseModel.getMmChildrenExcludedListCount( + { + colId: column.id, + pid: req.params.rowId + }, + req.query + ); + + res.json( + new PagedResponseImpl(data, { + count, + ...req.query + }) + ); +} + +export async function hmExcludedList(req: Request, res: Response, next) { + const view = await View.get(req.params.viewId); + + const model = await Model.getByIdOrName({ + id: view?.fk_model_id || req.params.viewId + }); + + if (!model) return next(new Error('Table not found')); + + const base = await Base.get(model.base_id); + + const baseModel = await Model.getBaseModelSQL({ + id: model.id, + viewId: view?.id, + dbDriver: NcConnectionMgrv2.get(base) + }); + + const column = await getColumnByIdOrName(req.params.columnName, model); + + const data = await baseModel.getHmChildrenExcludedList( + { + colId: column.id, + pid: req.params.rowId + }, + req.query + ); + + const count = await baseModel.getHmChildrenExcludedListCount( + { + colId: column.id, + pid: req.params.rowId + }, + req.query + ); + + res.json( + new PagedResponseImpl(data, { + count, + ...req.query + }) + ); +} + +export async function btExcludedList(req: Request, res: Response, next) { + const view = await View.get(req.params.viewId); + + const model = await Model.getByIdOrName({ + id: view?.fk_model_id || req.params.viewId + }); + + if (!model) return next(new Error('Table not found')); + + const base = await Base.get(model.base_id); + + const baseModel = await Model.getBaseModelSQL({ + id: model.id, + viewId: view?.id, + dbDriver: NcConnectionMgrv2.get(base) + }); + + const column = await getColumnByIdOrName(req.params.columnName, model); + + const data = await baseModel.getBtChildrenExcludedList( + { + colId: column.id, + cid: req.params.rowId + }, + req.query + ); + + const count = await baseModel.getBtChildrenExcludedListCount( + { + colId: column.id, + cid: req.params.rowId + }, + req.query + ); + + res.json( + new PagedResponseImpl(data, { + count, + ...req.query + }) + ); +} + +export async function hmList(req: Request, res: Response, next) { + const view = await View.get(req.params.viewId); + + const model = await Model.getByIdOrName({ + id: view?.fk_model_id || req.params.viewId + }); + + if (!model) return next(new Error('Table not found')); + + const base = await Base.get(model.base_id); + + const baseModel = await Model.getBaseModelSQL({ + id: model.id, + viewId: view?.id, + dbDriver: NcConnectionMgrv2.get(base) + }); + + const column = await getColumnByIdOrName(req.params.columnName, model); + + const data = await baseModel.hmList( + { + colId: column.id, + id: req.params.rowId + }, + req.query + ); + + const count = await baseModel.hmListCount({ + colId: column.id, + id: req.params.rowId + }); + + res.json( + new PagedResponseImpl(data, { + totalRows: count + } as any) + ); +} + +//@ts-ignore +async function relationDataDelete(req, res) { + const view = await View.get(req.params.viewId); + + const model = await Model.getByIdOrName({ + id: view?.fk_model_id || req.params.viewId + }); + + if (!model) NcError.notFound('Table not found'); + + const base = await Base.get(model.base_id); + + const baseModel = await Model.getBaseModelSQL({ + id: model.id, + viewId: view?.id, + dbDriver: NcConnectionMgrv2.get(base) + }); + + const column = await getColumnByIdOrName(req.params.columnName, model); + + await baseModel.removeChild({ + colId: column.id, + childId: req.params.childId, + rowId: req.params.rowId + }); + + res.json({ msg: 'success' }); +} + +//@ts-ignore +async function relationDataAdd(req, res) { + const view = await View.get(req.params.viewId); + + const model = await Model.getByIdOrName({ + id: view?.fk_model_id || req.params.viewId + }); + + if (!model) NcError.notFound('Table not found'); + + const base = await Base.get(model.base_id); + + const baseModel = await Model.getBaseModelSQL({ + id: model.id, + viewId: view?.id, + dbDriver: NcConnectionMgrv2.get(base) + }); + + const column = await getColumnByIdOrName(req.params.columnName, model); + await baseModel.addChild({ + colId: column.id, + childId: req.params.childId, + rowId: req.params.rowId + }); + + res.json({ msg: 'success' }); +} + +async function getColumnByIdOrName(columnNameOrId: string, model: Model) { + const column = (await model.getColumns()).find( + c => + column.title === columnNameOrId || + c.id === columnNameOrId || + column.column_name === columnNameOrId + ); + + if (!column) + NcError.notFound(`Column with id/name '${columnNameOrId}' is not found`); + + return column; +} + +const router = Router({ mergeParams: true }); + +router.get( + '/api/v1/db/data/:orgs/:projectName/:tableName/mm/:columnName/exclude', + ncMetaAclMw(mmExcludedList, 'mmExcludedList') +); +router.get( + '/api/v1/db/data/:orgs/:projectName/:tableName/hm/:columnName/exclude', + ncMetaAclMw(hmExcludedList, 'hmExcludedList') +); +router.get( + '/api/v1/db/data/:orgs/:projectName/:tableName/bt/:columnName/exclude', + ncMetaAclMw(btExcludedList, 'btExcludedList') +); + +router.post( + '/api/v1/db/data/:orgs/:projectName/:tableName/:relationType/:columnName/:refRowId', + ncMetaAclMw(relationDataAdd, 'relationDataAdd') +); +router.delete( + '/api/v1/db/data/:orgs/:projectName/:tableName/:relationType/:columnName/:refRowId', + ncMetaAclMw(relationDataDelete, 'relationDataDelete') +); + +export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataApis.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataApis.ts index edefdf35d2..8bcd0d6993 100644 --- a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataApis.ts @@ -554,7 +554,7 @@ const router = Router({ mergeParams: true }); // '/data/:orgs/:projectName/:tableName/views/:viewName', // ncMetaAclMw(dataInsertNew) // ); -// router.put( +// router.patch( // '/data/:orgs/:projectName/:tableName/views/:viewName/:rowId', // ncMetaAclMw(dataUpdateNew) // ); @@ -566,7 +566,7 @@ const router = Router({ mergeParams: true }); router.get('/data/:viewId/', ncMetaAclMw(dataList, 'dataList')); router.post('/data/:viewId/', ncMetaAclMw(dataInsert, 'dataInsert')); router.get('/data/:viewId/:rowId', ncMetaAclMw(dataRead, 'dataRead')); -router.put('/data/:viewId/:rowId', ncMetaAclMw(dataUpdate, 'dataUpdate')); +router.patch('/data/:viewId/:rowId', ncMetaAclMw(dataUpdate, 'dataUpdate')); router.delete('/data/:viewId/:rowId', ncMetaAclMw(dataDelete, 'dataDelete')); router.get('/data/:viewId/:rowId/mm/:colId', ncMetaAclMw(mmList, 'mmList')); diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/oldDataApis.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/oldDataApis.ts index 14d9b68654..a0196854f6 100644 --- a/packages/nocodb/src/lib/noco/meta/api/dataApis/oldDataApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/oldDataApis.ts @@ -138,7 +138,7 @@ router.get( '/nc/:projectId/api/v2/:tableName/:rowId', ncMetaAclMw(dataRead, 'dataRead') ); -router.put( +router.patch( '/nc/:projectId/api/v2/:tableName/:rowId', ncMetaAclMw(dataUpdate, 'dataUpdate') ); diff --git a/packages/nocodb/src/lib/noco/meta/api/filterApis.ts b/packages/nocodb/src/lib/noco/meta/api/filterApis.ts index a67484f015..7dc9964bd7 100644 --- a/packages/nocodb/src/lib/noco/meta/api/filterApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/filterApis.ts @@ -85,7 +85,7 @@ export async function filterUpdate(req, res, next) { ...req.body, fk_view_id: req.params.viewId }); - Tele.emit('evt', { evt_type: 'table:updated' }); + Tele.emit('evt', { evt_type: 'filter:updated' }); res.json(filter); } catch (e) { console.log(e); @@ -97,7 +97,7 @@ export async function filterUpdate(req, res, next) { export async function filterDelete(req: Request, res: Response, next) { try { const filter = await Filter.delete(req.params.filterId); - Tele.emit('evt', { evt_type: 'table:deleted' }); + Tele.emit('evt', { evt_type: 'filter:deleted' }); res.json(filter); } catch (e) { console.log(e); @@ -105,26 +105,60 @@ export async function filterDelete(req: Request, res: Response, next) { } } +export async function hookFilterList( + req: Request, + res: Response +) { + const filter = await Filter.rootFilterListByHook({ + hookId: req.params.hookId + }); + + res.json(filter); +} + +export async function hookFilterCreate(req: Request, res) { + const filter = await Filter.insert({ + ...req.body, + fk_hook_id: req.params.hookId + }); + + Tele.emit('evt', { evt_type: 'hookFilter:created' }); + res.json(filter); +} + const router = Router({ mergeParams: true }); -router.get('/views/:viewId/filters/', ncMetaAclMw(filterList, 'filterList')); +router.get( + '/api/v1/db/meta/views/:viewId/filters', + ncMetaAclMw(filterList, 'filterList') +); router.post( - '/views/:viewId/filters/', + '/api/v1/db/meta/views/:viewId/filters', ncMetaAclMw(filterCreate, 'filterCreate') ); + +router.get( + '/api/v1/db/meta/hooks/:hookId/filters', + ncMetaAclMw(hookFilterList, 'filterList') +); +router.post( + '/api/v1/db/meta/hooks/:hookId/filters', + ncMetaAclMw(hookFilterCreate, 'filterCreate') +); + router.get( - '/views/:viewId/filters/:filterId', + '/api/v1/db/meta/filters/:filterId', ncMetaAclMw(filterGet, 'filterGet') ); -router.put( - '/views/:viewId/filters/:filterId', +router.patch( + '/api/v1/db/meta/filters/:filterId', ncMetaAclMw(filterUpdate, 'filterUpdate') ); router.delete( - '/views/:viewId/filters/:filterId', + '/api/v1/db/meta/filters/:filterId', ncMetaAclMw(filterDelete, 'filterDelete') ); router.get( - '/views/:viewId/filters/:filterParentId/children', + '/api/v1/db/meta/filters/:filterParentId/children', ncMetaAclMw(filterChildrenRead, 'filterChildrenRead') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/formViewApis.ts b/packages/nocodb/src/lib/noco/meta/api/formViewApis.ts index f379b5b7a6..ea99e1ee2b 100644 --- a/packages/nocodb/src/lib/noco/meta/api/formViewApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/formViewApis.ts @@ -40,13 +40,19 @@ export async function formViewDelete(req: Request, res: Response, next) {} const router = Router({ mergeParams: true }); router.post( - '/tables/:tableId/forms', + '/api/v1/db/meta/tables/:tableId/forms', ncMetaAclMw(formViewCreate, 'formViewCreate') ); -router.get('/forms/:formViewId', ncMetaAclMw(formViewGet, 'formViewGet')); -router.put('/forms/:formViewId', ncMetaAclMw(formViewUpdate, 'formViewUpdate')); +router.get( + '/api/v1/db/meta/forms/:formViewId', + ncMetaAclMw(formViewGet, 'formViewGet') +); +router.patch( + '/api/v1/db/meta/forms/:formViewId', + ncMetaAclMw(formViewUpdate, 'formViewUpdate') +); router.delete( - '/forms/:formViewId', + '/api/v1/db/meta/forms/:formViewId', ncMetaAclMw(formViewDelete, 'formViewDelete') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/formViewColumnApis.ts b/packages/nocodb/src/lib/noco/meta/api/formViewColumnApis.ts index 891ad603fb..acf4d11442 100644 --- a/packages/nocodb/src/lib/noco/meta/api/formViewColumnApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/formViewColumnApis.ts @@ -9,8 +9,8 @@ export async function columnUpdate(req: Request, res: Response) { } const router = Router({ mergeParams: true }); -router.put( - '/formColumns/:formViewColumnId', +router.patch( + '/api/v1/db/meta/forms/columns/:formViewColumnId', ncMetaAclMw(columnUpdate, 'columnUpdate') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/galleryViewApis.ts b/packages/nocodb/src/lib/noco/meta/api/galleryViewApis.ts index 5c662ff0b4..de5912c315 100644 --- a/packages/nocodb/src/lib/noco/meta/api/galleryViewApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/galleryViewApis.ts @@ -1,29 +1,13 @@ import { Request, Response, Router } from 'express'; -// @ts-ignore -import Model from '../../../noco-models/Model'; -// @ts-ignore -import { PagedResponseImpl } from '../helpers/PagedResponse'; -import { GalleryType, TableListType, ViewTypes } from 'nocodb-sdk'; -// @ts-ignore -import ProjectMgrv2 from '../../../sqlMgr/v2/ProjectMgrv2'; -// @ts-ignore -import Project from '../../../noco-models/Project'; +import { GalleryType, ViewTypes } from 'nocodb-sdk'; import View from '../../../noco-models/View'; import GalleryView from '../../../noco-models/GalleryView'; import ncMetaAclMw from '../helpers/ncMetaAclMw'; import { Tele } from 'nc-help'; -// @ts-ignore export async function galleryViewGet(req: Request, res: Response) { res.json(await GalleryView.get(req.params.galleryViewId)); } -// @ts-ignore -export async function galleyViewList( - _req: Request, - _res: Response -) {} - -// @ts-ignore export async function galleryViewCreate(req: Request, res) { Tele.emit('evt', { evt_type: 'vtable:created', show_as: 'gallery' }); const view = await View.insert({ @@ -35,29 +19,22 @@ export async function galleryViewCreate(req: Request, res) { res.json(view); } -// @ts-ignore export async function galleryViewUpdate(req, res) { Tele.emit('evt', { evt_type: 'view:updated', type: 'gallery' }); res.json(await GalleryView.update(req.params.galleryViewId, req.body)); } -// @ts-ignore -export async function galleyViewDelete(req: Request, res: Response, next) {} - const router = Router({ mergeParams: true }); -// router.get('/', galleyViewList); router.post( - '/tables/:tableId/galleries', + '/api/v1/db/meta/tables/:tableId/galleries', ncMetaAclMw(galleryViewCreate, 'galleryViewCreate') ); -// router.get('/:galleryViewId', galleyViewGet); -router.put( - '/galleries/:galleryViewId', +router.patch( + '/api/v1/db/meta/galleries/:galleryViewId', ncMetaAclMw(galleryViewUpdate, 'galleryViewUpdate') ); router.get( - '/galleries/:galleryViewId', + '/api/v1/db/meta/galleries/:galleryViewId', ncMetaAclMw(galleryViewGet, 'galleryViewGet') ); -// router.delete('/:galleryViewId', galleyViewDelete); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/gridViewApis.ts b/packages/nocodb/src/lib/noco/meta/api/gridViewApis.ts index 119b825245..23890a928f 100644 --- a/packages/nocodb/src/lib/noco/meta/api/gridViewApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/gridViewApis.ts @@ -26,7 +26,7 @@ export async function gridViewCreate(req: Request, res) { const router = Router({ mergeParams: true }); router.post( - '/tables/:tableId/grids/', + '/api/v1/db/meta/tables/:tableId/grids/', ncMetaAclMw(gridViewCreate, 'gridViewCreate') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/gridViewColumnApis.ts b/packages/nocodb/src/lib/noco/meta/api/gridViewColumnApis.ts index 6ef54970d8..e3463bac58 100644 --- a/packages/nocodb/src/lib/noco/meta/api/gridViewColumnApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/gridViewColumnApis.ts @@ -14,11 +14,11 @@ export async function gridColumnUpdate(req: Request, res: Response) { const router = Router({ mergeParams: true }); router.get( - '/grid/:gridViewId/gridColumns', + '/api/v1/db/meta/grids/:gridViewId/grid/columns', ncMetaAclMw(columnList, 'columnList') ); -router.put( - '/gridColumns/:gridViewColumnId', +router.patch( + '/api/v1/db/meta/grid/columns/:gridViewColumnId', ncMetaAclMw(gridColumnUpdate, 'gridColumnUpdate') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/hookApis.ts b/packages/nocodb/src/lib/noco/meta/api/hookApis.ts index f116b33cd5..e67dddcaef 100644 --- a/packages/nocodb/src/lib/noco/meta/api/hookApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/hookApis.ts @@ -75,13 +75,28 @@ export async function tableSampleData(req: Request, res: Response) { } const router = Router({ mergeParams: true }); -router.get('/tables/:tableId/hooks', ncMetaAclMw(hookList, 'hookList')); -router.post('/tables/:tableId/hooks/test', ncMetaAclMw(hookTest, 'hookTest')); -router.post('/tables/:tableId/hooks', ncMetaAclMw(hookCreate, 'hookCreate')); -router.delete('/hooks/:hookId', ncMetaAclMw(hookDelete, 'hookDelete')); -router.put('/hooks/:hookId', ncMetaAclMw(hookUpdate, 'hookUpdate')); router.get( - '/tables/:tableId/hooks/samplePayload/:operation', + '/api/v1/db/meta/tables/:tableId/hooks', + ncMetaAclMw(hookList, 'hookList') +); +router.post( + '/api/v1/db/meta/tables/:tableId/hooks/test', + ncMetaAclMw(hookTest, 'hookTest') +); +router.post( + '/api/v1/db/meta/tables/:tableId/hooks', + ncMetaAclMw(hookCreate, 'hookCreate') +); +router.delete( + '/api/v1/db/meta/hooks/:hookId', + ncMetaAclMw(hookDelete, 'hookDelete') +); +router.patch( + '/api/v1/db/meta/hooks/:hookId', + ncMetaAclMw(hookUpdate, 'hookUpdate') +); +router.get( + '/api/v1/db/meta/tables/:tableId/hooks/samplePayload/:operation', catchError(tableSampleData) ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/hookFilterApis.ts b/packages/nocodb/src/lib/noco/meta/api/hookFilterApis.ts index 73573324f9..c3bab363f0 100644 --- a/packages/nocodb/src/lib/noco/meta/api/hookFilterApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/hookFilterApis.ts @@ -117,7 +117,7 @@ router.get( '/hooks/:hookId/filters/:filterId', ncMetaAclMw(filterGet, 'filterGet') ); -router.put( +router.patch( '/hooks/:hookId/filters/:filterId', ncMetaAclMw(filterUpdate, 'filterUpdate') ); diff --git a/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts b/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts index 6b9f2ead4a..8324f4f2bf 100644 --- a/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts @@ -826,9 +826,12 @@ export async function extractAndGenerateManyToManyRelations( } const router = Router(); -router.get('/projects/:projectId/metaDiff', ncMetaAclMw(metaDiff, 'metaDiff')); +router.get( + '/api/v1/db/meta/projects/:projectId/metaDiff', + ncMetaAclMw(metaDiff, 'metaDiff') +); router.post( - '/projects/:projectId/metaDiff', + '/api/v1/db/meta/projects/:projectId/metaDiff', ncMetaAclMw(metaDiffSync, 'metaDiffSync') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/modelVisibilityApis.ts b/packages/nocodb/src/lib/noco/meta/api/modelVisibilityApis.ts index 785dbb832e..ae03abf9b2 100644 --- a/packages/nocodb/src/lib/noco/meta/api/modelVisibilityApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/modelVisibilityApis.ts @@ -119,7 +119,7 @@ router.get( }, 'modelVisibilityList') ); router.post( - '/projects/:projectId/modelVisibility', + '/api/v1/db/meta/projects/:projectId/visibility-rules', ncMetaAclMw(xcVisibilityMetaSetAll, 'modelVisibilitySet') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/pluginApis.ts b/packages/nocodb/src/lib/noco/meta/api/pluginApis.ts index 2b3fd1657a..aff183d8b5 100644 --- a/packages/nocodb/src/lib/noco/meta/api/pluginApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/pluginApis.ts @@ -34,9 +34,21 @@ export async function isPluginActive(req: Request, res: Response) { } const router = Router({ mergeParams: true }); -router.get('/plugins', ncMetaAclMw(pluginList, 'pluginList')); -router.post('/plugins/test', ncMetaAclMw(pluginTest, 'pluginTest')); -router.get('/plugins/:pluginId', ncMetaAclMw(pluginRead, 'pluginRead')); -router.put('/plugins/:pluginId', ncMetaAclMw(pluginUpdate, 'pluginUpdate')); -router.get('/plugins/:pluginTitle/status', ncMetaAclMw(isPluginActive, 'isPluginActive')); +router.get('/api/v1/db/meta/plugins', ncMetaAclMw(pluginList, 'pluginList')); +router.post( + '/api/v1/db/meta/plugins/test', + ncMetaAclMw(pluginTest, 'pluginTest') +); +router.get( + '/api/v1/db/meta/plugins/:pluginId', + ncMetaAclMw(pluginRead, 'pluginRead') +); +router.patch( + '/api/v1/db/meta/plugins/:pluginId', + ncMetaAclMw(pluginUpdate, 'pluginUpdate') +); +router.get( + '/api/v1/db/meta/plugins/:pluginTitle/status', + ncMetaAclMw(isPluginActive, 'isPluginActive') +); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/projectApis.ts b/packages/nocodb/src/lib/noco/meta/api/projectApis.ts index 5323efd884..a35bba442a 100644 --- a/packages/nocodb/src/lib/noco/meta/api/projectApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/projectApis.ts @@ -392,14 +392,23 @@ export async function projectInfoGet(req, res) { export default router => { router.get( - '/projects/:projectId/info', + '/api/v1/db/meta/projects/:projectId/info', ncMetaAclMw(projectInfoGet, 'projectInfoGet') ); - router.get('/projects/:projectId', ncMetaAclMw(projectGet, 'projectGet')); + router.get( + '/api/v1/db/meta/projects/:projectId', + ncMetaAclMw(projectGet, 'projectGet') + ); router.delete( - '/projects/:projectId', + '/api/v1/db/meta/projects/:projectId', ncMetaAclMw(projectDelete, 'projectDelete') ); - router.post('/projects', ncMetaAclMw(projectCreate, 'projectCreate')); - router.get('/projects', ncMetaAclMw(projectList, 'projectList')); + router.post( + '/api/v1/db/meta/projects', + ncMetaAclMw(projectCreate, 'projectCreate') + ); + router.get( + '/api/v1/db/meta/projects', + ncMetaAclMw(projectList, 'projectList') + ); }; diff --git a/packages/nocodb/src/lib/noco/meta/api/projectUserApis.ts b/packages/nocodb/src/lib/noco/meta/api/projectUserApis.ts index 62c5f0b3ff..ecd05c3dc5 100644 --- a/packages/nocodb/src/lib/noco/meta/api/projectUserApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/projectUserApis.ts @@ -254,7 +254,7 @@ router.post( '/projects/:projectId/users', ncMetaAclMw(userInvite, 'userInvite') ); -router.put( +router.patch( '/projects/:projectId/users/:userId', ncMetaAclMw(projectUserUpdate, 'projectUserUpdate') ); diff --git a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts index b969de8934..b804b7b734 100644 --- a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts @@ -332,7 +332,7 @@ export async function publicHmList(req: Request, res: Response) { const router = Router({ mergeParams: true }); router.post('/public/data/:publicDataUuid/list', catchError(dataList)); router.post( - '/public/data/:publicDataUuid/relationTable/:columnId', + '/public/data/:publicDataUuid/nested/:columnId', catchError(relDataList) ); router.post( diff --git a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicMetaApis.ts b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicMetaApis.ts index 869deb951e..182495139d 100644 --- a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicMetaApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicMetaApis.ts @@ -6,12 +6,13 @@ import UITypes from '../../../../sqlUi/UITypes'; import { ErrorMessages, LinkToAnotherRecordType } from 'nocodb-sdk'; import Column from '../../../../noco-models/Column'; import Base from '../../../../noco-models/Base'; +import Project from '../../../../noco-models/Project'; export async function viewMetaGet(req: Request, res: Response) { const view: View & { relatedMetas?: { [ket: string]: Model }; client?: string; - } = await View.getByUUID(req.params.publicDataUuid); + } = await View.getByUUID(req.params.sharedViewUuids); if (!view) NcError.notFound('Not found'); @@ -66,7 +67,24 @@ export async function viewMetaGet(req: Request, res: Response) { res.json(view); } +async function publicSharedBaseGet(req, res): Promise { + const project = await Project.getByUuid(req.params.sharedBaseUuid); + + if (!project) { + NcError.notFound(); + } + + res.json({ project_id: project.id }); +} const router = Router({ mergeParams: true }); -router.post('/public/meta/:publicDataUuid/', catchError(viewMetaGet)); +router.post( + '/api/v1/db/meta/public/shared-view/:sharedViewUuid/meta', + catchError(viewMetaGet) +); + +router.get( + '/api/v1/db/meta/public/shared-base/:sharedBaseUuid/meta', + catchError(publicSharedBaseGet) +); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/sharedBaseApis.ts b/packages/nocodb/src/lib/noco/meta/api/sharedBaseApis.ts index df588e1ac6..1fa4be4508 100644 --- a/packages/nocodb/src/lib/noco/meta/api/sharedBaseApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/sharedBaseApis.ts @@ -3,7 +3,7 @@ import ncMetaAclMw from '../helpers/ncMetaAclMw'; import { v4 as uuidv4 } from 'uuid'; import { Tele } from 'nc-help'; import Project from '../../../noco-models/Project'; -import catchError, { NcError } from '../helpers/catchError'; +import { NcError } from '../helpers/catchError'; // todo: load from config const config = { dashboardPath: '/nc' @@ -88,32 +88,22 @@ async function getSharedBaseLink(req, res): Promise { res.json(data); } -async function publicSharedBaseGet(req, res): Promise { - const project = await Project.getByUuid(req.params.uuid); - - if (!project) { - NcError.notFound(); - } - - res.json({ project_id: project.id }); -} const router = Router({ mergeParams: true }); router.get( - '/projects/:projectId/sharedBase', + '/api/v1/db/meta/projects/:projectId/shared', ncMetaAclMw(getSharedBaseLink, 'getSharedBaseLink') ); router.post( - '/projects/:projectId/sharedBase', + '/api/v1/db/meta/projects/:projectId/shared', ncMetaAclMw(createSharedBaseLink, 'createSharedBaseLink') ); -router.put( - '/projects/:projectId/sharedBase', +router.patch( + '/api/v1/db/meta/projects/:projectId/shared', ncMetaAclMw(updateSharedBaseLink, 'updateSharedBaseLink') ); router.delete( - '/projects/:projectId/sharedBase', + '/api/v1/db/meta/projects/:projectId/shared', ncMetaAclMw(disableSharedBaseLink, 'disableSharedBaseLink') ); -router.get('/public/sharedBase/:uuid', catchError(publicSharedBaseGet)); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/sortApis.ts b/packages/nocodb/src/lib/noco/meta/api/sortApis.ts index 4ab4cfe0f0..26c2076c62 100644 --- a/packages/nocodb/src/lib/noco/meta/api/sortApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/sortApis.ts @@ -36,30 +36,34 @@ export async function sortCreate(req: Request, res) { res.json(sort); } -// @ts-ignore -export async function sortUpdate(req, res, next) { +export async function sortUpdate(req, res) { const sort = await Sort.update(req.params.sortId, req.body); Tele.emit('evt', { evt_type: 'sort:updated' }); res.json(sort); } -// @ts-ignore -export async function sortDelete(req: Request, res: Response, next) { +export async function sortDelete(req: Request, res: Response) { Tele.emit('evt', { evt_type: 'sort:deleted' }); const sort = await Sort.delete(req.params.sortId); res.json(sort); } const router = Router({ mergeParams: true }); -router.get('/views/:viewId/sorts/', ncMetaAclMw(sortList, 'sortList')); -router.post('/views/:viewId/sorts/', ncMetaAclMw(sortCreate, 'sortCreate')); -router.get('/views/:viewId/sorts/:sortId', ncMetaAclMw(sortGet, 'sortGet')); -router.put( - '/views/:viewId/sorts/:sortId', +router.get( + '/api/v1/db/meta/views/:viewId/sorts/', + ncMetaAclMw(sortList, 'sortList') +); +router.post( + '/api/v1/db/meta/views/:viewId/sorts/', + ncMetaAclMw(sortCreate, 'sortCreate') +); +router.get('/api/v1/db/meta/sorts/:sortId', ncMetaAclMw(sortGet, 'sortGet')); +router.patch( + '/api/v1/db/meta/sorts/:sortId', ncMetaAclMw(sortUpdate, 'sortUpdate') ); router.delete( - '/views/:viewId/sorts/:sortId', + '/api/v1/db/meta/sorts/:sortId', ncMetaAclMw(sortDelete, 'sortDelete') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/tableApis.ts b/packages/nocodb/src/lib/noco/meta/api/tableApis.ts index 58ee9686fa..ee5ab4ea9b 100644 --- a/packages/nocodb/src/lib/noco/meta/api/tableApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/tableApis.ts @@ -223,18 +223,27 @@ export async function tableDelete(req: Request, res: Response, next) { const router = Router({ mergeParams: true }); router.get( - '/projects/:projectId/:baseId/tables', + '/api/v1/db/meta/projects/:projectId/tables', ncMetaAclMw(tableList, 'tableList') ); router.post( - '/projects/:projectId/:baseId/tables', + '/api/v1/db/meta/projects/:projectId/tables', ncMetaAclMw(tableCreate, 'tableCreate') ); -router.get('/tables/:tableId', ncMetaAclMw(tableGet, 'tableGet')); -router.put('/tables/:tableId', ncMetaAclMw(tableUpdate, 'tableUpdate')); -router.delete('/tables/:tableId', ncMetaAclMw(tableDelete, 'tableDelete')); +router.get( + '/api/v1/db/meta/tables/:tableId', + ncMetaAclMw(tableGet, 'tableGet') +); +router.patch( + '/api/v1/db/meta/tables/:tableId', + ncMetaAclMw(tableUpdate, 'tableUpdate') +); +router.delete( + '/api/v1/db/meta/tables/:tableId', + ncMetaAclMw(tableDelete, 'tableDelete') +); router.post( - '/tables/:tableId/reorder', + '/api/v1/db/meta/tables/:tableId/reorder', ncMetaAclMw(tableReorder, 'tableReorder') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/userApi/initStrategies.ts b/packages/nocodb/src/lib/noco/meta/api/userApi/initStrategies.ts index 7de6638c19..83051b481a 100644 --- a/packages/nocodb/src/lib/noco/meta/api/userApi/initStrategies.ts +++ b/packages/nocodb/src/lib/noco/meta/api/userApi/initStrategies.ts @@ -10,9 +10,7 @@ import { Strategy as AuthTokenStrategy } from 'passport-auth-token'; const PassportLocalStrategy = require('passport-local').Strategy; -// todo: read from database const jwtOptions = { - secretOrKey: 'dkjfkdjfkjdfjdfjdkfjdkfjkdfkjdkfjdkjfkdk', expiresIn: process.env.NC_JWT_EXPIRES_IN ?? '10h', jwtFromRequest: ExtractJwt.fromHeader('xc-auth') }; @@ -22,6 +20,7 @@ import Project from '../../../../noco-models/Project'; import NocoCache from '../../../../noco-cache/NocoCache'; import { CacheGetType, CacheScope } from '../../../../utils/globals'; import ApiToken from '../../../../noco-models/ApiToken'; +import Noco from '../../../Noco'; export function initStrategies(router): void { passport.use( @@ -82,8 +81,10 @@ export function initStrategies(router): void { passport.use( new Strategy( { + secretOrKey: Noco.getConfig().auth.jwt.secret, ...jwtOptions, - passReqToCallback: true + passReqToCallback: true, + ...Noco.getConfig().auth.jwt.options }, async (req, jwtPayload, done) => { const keyVals = [jwtPayload?.email]; diff --git a/packages/nocodb/src/lib/noco/meta/api/userApi/userApis.ts b/packages/nocodb/src/lib/noco/meta/api/userApi/userApis.ts index d4bb10773c..b5096d3e52 100644 --- a/packages/nocodb/src/lib/noco/meta/api/userApi/userApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/userApi/userApis.ts @@ -15,10 +15,6 @@ import Audit from '../../../../noco-models/Audit'; import crypto from 'crypto'; import NcPluginMgrv2 from '../../helpers/NcPluginMgrv2'; -// todo: read from database -const secret = 'dkjfkdjfkjdfjdfjdkfjdkfjkdfkjdkfjdkjfkdk'; -const jwtConfig = {}; - import passport from 'passport'; import extractProjectIdAndAuthenticate from '../../helpers/extractProjectIdAndAuthenticate'; import ncMetaAclMw from '../../helpers/ncMetaAclMw'; @@ -154,7 +150,8 @@ export async function signup(req: Request, res: Response) { id: user.id, roles: user.roles }, - secret + Noco.getConfig().auth.jwt.secret, + Noco.getConfig().auth.jwt.options ) } as any); } @@ -200,8 +197,9 @@ async function signin(req, res, next) { id: user.id, roles: user.roles }, - secret, - jwtConfig + + Noco.getConfig().auth.jwt.secret, + Noco.getConfig().auth.jwt.options ) } as any); } catch (e) { @@ -392,6 +390,44 @@ async function emailVerification(req, res): Promise { res.json({ msg: 'Email verified successfully' }); } +async function refreshToken(req, res): Promise { + try { + if (!req?.cookies?.refresh_token) { + return res.status(400).json({ msg: 'Missing refresh token' }); + } + + const user = await User.getByRefreshToken(req.cookies.refresh_token); + + if (!user) { + return res.status(400).json({ msg: 'Invalid refresh token' }); + } + + const refreshToken = randomTokenString(); + + await User.update(user.id, { + refresh_token: refreshToken + }); + + setTokenCookie(res, refreshToken); + + res.json({ + token: jwt.sign( + { + email: user.email, + firstname: user.firstname, + lastname: user.lastname, + id: user.id, + roles: user.roles + }, + Noco.getConfig().auth.jwt.secret, + Noco.getConfig().auth.jwt.options + ) + } as any); + } catch (e) { + return res.status(400).json({ msg: e.message }); + } +} + const mapRoutes = router => { // todo: old api - /auth/signup?tool=1 router.post('/auth/user/signup', catchError(signup)); @@ -405,5 +441,6 @@ const mapRoutes = router => { '/user/password/change', ncMetaAclMw(passwordChange, 'passwordChange') ); + router.post('/auth/token/refresh', ncMetaAclMw(refreshToken, 'refreshToken')); }; export { mapRoutes as userApis }; diff --git a/packages/nocodb/src/lib/noco/meta/api/utilApis.ts b/packages/nocodb/src/lib/noco/meta/api/utilApis.ts index 12243fac73..a63a85d615 100644 --- a/packages/nocodb/src/lib/noco/meta/api/utilApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/utilApis.ts @@ -44,6 +44,9 @@ export async function appInfo(_req: Request, res: Response) { } export default router => { - router.post('/testConnection', ncMetaAclMw(testConnection, 'testConnection')); - router.get('/appInfo', catchError(appInfo)); + router.post( + '/api/v1/db/meta/connection/test', + ncMetaAclMw(testConnection, 'testConnection') + ); + router.get('/api/v1/db/meta/nocodb/info', catchError(appInfo)); }; diff --git a/packages/nocodb/src/lib/noco/meta/api/viewApis.ts b/packages/nocodb/src/lib/noco/meta/api/viewApis.ts index f61633cd8a..7602c999bf 100644 --- a/packages/nocodb/src/lib/noco/meta/api/viewApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/viewApis.ts @@ -101,29 +101,41 @@ async function shareViewList(req: Request, res) { } const router = Router({ mergeParams: true }); -router.get('/tables/:tableId/views', ncMetaAclMw(viewList, 'viewList')); -router.put('/views/:viewId', ncMetaAclMw(viewUpdate, 'viewUpdate')); -router.delete('/views/:viewId', ncMetaAclMw(viewDelete, 'viewDelete')); +router.get( + '/api/v1/db/meta/tables/:tableId/views', + ncMetaAclMw(viewList, 'viewList') +); +router.patch( + '/api/v1/db/meta/views/:viewId', + ncMetaAclMw(viewUpdate, 'viewUpdate') +); +router.delete( + '/api/v1/db/meta/views/:viewId', + ncMetaAclMw(viewDelete, 'viewDelete') +); router.post( - '/views/:viewId/showAll', + '/api/v1/db/meta/views/:viewId/showAll', ncMetaAclMw(showAllColumns, 'showAllColumns') ); router.post( - '/views/:viewId/hideAll', + '/api/v1/db/meta/views/:viewId/hideAll', ncMetaAclMw(hideAllColumns, 'hideAllColumns') ); router.get( - '/tables/:tableId/share', + '/api/v1/db/meta/tables/:tableId/share', ncMetaAclMw(shareViewList, 'shareViewList') ); -router.post('/views/:viewId/share', ncMetaAclMw(shareView, 'shareView')); -router.put( - '/views/:viewId/share', +router.post( + '/api/v1/db/meta/views/:viewId/share', + ncMetaAclMw(shareView, 'shareView') +); +router.patch( + '/api/v1/db/meta/views/:viewId/share', ncMetaAclMw(shareViewPasswordUpdate, 'shareViewPasswordUpdate') ); router.delete( - '/views/:viewId/share', + '/api/v1/db/meta/views/:viewId/share', ncMetaAclMw(shareViewDelete, 'shareViewDelete') ); diff --git a/packages/nocodb/src/lib/noco/meta/api/viewColumnApis.ts b/packages/nocodb/src/lib/noco/meta/api/viewColumnApis.ts index dc15c5669e..2a3588308c 100644 --- a/packages/nocodb/src/lib/noco/meta/api/viewColumnApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/viewColumnApis.ts @@ -31,10 +31,16 @@ export async function columnUpdate(req: Request, res: Response) { } const router = Router({ mergeParams: true }); -router.get('/views/:viewId/columns/', ncMetaAclMw(columnList, 'columnList')); -router.post('/views/:viewId/columns/', ncMetaAclMw(columnAdd, 'columnAdd')); -router.put( - '/views/:viewId/columns/:columnId', +router.get( + '/api/v1/db/meta/views/:viewId/columns/', + ncMetaAclMw(columnList, 'columnList') +); +router.post( + '/api/v1/db/meta/views/:viewId/columns/', + ncMetaAclMw(columnAdd, 'columnAdd') +); +router.patch( + '/api/v1/db/meta/views/:viewId/columns/:columnId', ncMetaAclMw(columnUpdate, 'viewColumnUpdate') ); export default router; diff --git a/scripts/sdk/swagger.json b/scripts/sdk/swagger.json index 11be38b85d..3ce5fd6828 100644 --- a/scripts/sdk/swagger.json +++ b/scripts/sdk/swagger.json @@ -276,40 +276,6 @@ } ] }, - "/auth/token/verify": { - "post": { - "summary": "Password Verify", - "operationId": "auth-token-verify", - "responses": { - "200": { - "description": "OK" - } - }, - "description": "", - "tags": [ - "Auth" - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "token": { - "type": "string" - }, - "email": { - "type": "string" - } - } - } - } - }, - "description": "" - } - }, - "parameters": [] - }, "/auth/token/refresh": { "post": { "summary": "Refresh Token", @@ -326,7 +292,8 @@ }, "parameters": [] }, - "/projects/{projectId}/users": { + + "/api/v1/db/meta/projects/{projectId}/users": { "get": { "summary": "Project Users", "operationId": "auth-project-user-list", @@ -404,7 +371,7 @@ ] } }, - "/projects/{projectId}/info": { + "/api/v1/db/meta/projects/{projectId}/info": { "parameters": [ { "schema": { @@ -461,7 +428,7 @@ ] } }, - "/projects/{projectId}/users/{userId}": { + "/api/v1/db/meta/projects/{projectId}/users/{userId}": { "parameters": [ { "schema": { @@ -480,7 +447,7 @@ "required": true } ], - "put": { + "patch": { "summary": "Project User Update", "operationId": "auth-project-user-update", "responses": { @@ -522,7 +489,7 @@ ] } }, - "/projects/{projectId}/modelVisibility": { + "/api/v1/db/meta/projects/{projectId}/visibility-rules": { "get": { "summary": "UI ACL", "operationId": "project-model-visibility-list", @@ -588,7 +555,7 @@ ] } }, - "/projects/": { + "/api/v1/db/meta/projects/": { "parameters": [], "get": { "summary": "", @@ -676,7 +643,7 @@ ] } }, - "/projects/{projectId}": { + "/api/v1/db/meta/projects/{projectId}": { "parameters": [ { "schema": { @@ -731,7 +698,7 @@ ] } }, - "/projects/{projectId}/sharedBase": { + "/api/v1/db/meta/projects/{projectId}/shared": { "parameters": [ { "schema": { @@ -836,7 +803,7 @@ } } }, - "put": { + "patch": { "summary": "", "operationId": "project-shared-base-update", "responses": { @@ -867,89 +834,7 @@ "description": "" } }, - "/public/sharedBase/{sharedBaseUuid}": { - "parameters": [ - { - "schema": { - "type": "string" - }, - "name": "sharedBaseUuid", - "in": "path", - "required": true - } - ], - "get": { - "summary": "", - "operationId": "public-shared-base-get", - "description": "Read project details", - "parameters": [], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "project_id": { - "type": "string" - } - } - } - } - } - } - }, - "tags": [ - "Public" - ] - } - }, - "/projects/{projectId}/views/{viewId}/upload": { - "post": { - "summary": "Attachment", - "operationId": "db-view-upload", - "responses": {}, - "tags": [ - "DB View" - ], - "requestBody": { - "content": { - "multipart/form-data": { - "schema": { - "type": "object", - "properties": { - "files": {}, - "json": { - "type": "string" - } - } - } - } - }, - "description": "" - } - }, - "parameters": [ - { - "schema": { - "type": "string" - }, - "name": "projectId", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "viewId", - "in": "path", - "required": true - } - ] - }, - "/projects/{projectId}/{baseId}/tables": { + "/api/v1/db/meta/projects/{projectId}/tables": { "parameters": [ { "schema": { @@ -958,14 +843,6 @@ "name": "projectId", "in": "path", "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "baseId", - "in": "path", - "required": true } ], "post": { @@ -1046,54 +923,7 @@ ] } }, - "/projects/{projectId}/metaDiff": { - "parameters": [ - { - "schema": { - "type": "string" - }, - "name": "projectId", - "in": "path", - "required": true - } - ], - "post": { - "summary": "", - "operationId": "project-meta-diff-sync", - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": {} - } - } - } - }, - "tags": [ - "Project" - ] - }, - "get": { - "summary": "", - "operationId": "project-meta-diff-get", - "parameters": [], - "tags": [ - "Project" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": {} - } - } - } - } - } - }, - "/tables/{tableId}": { + "/api/v1/db/meta/tables/{tableId}": { "parameters": [ { "schema": { @@ -1213,7 +1043,7 @@ "DB Table" ] }, - "put": { + "patch": { "summary": "", "operationId": "db-table-update", "responses": { @@ -1258,7 +1088,7 @@ "description": "" } }, - "/tables/{tableId}/reorder": { + "/api/v1/db/meta/tables/{tableId}/reorder": { "parameters": [ { "schema": { @@ -1296,7 +1126,7 @@ ] } }, - "/tables/{tableId}/columns": { + "/api/v1/db/meta/tables/{tableId}/columns": { "parameters": [ { "schema": { @@ -1352,7 +1182,7 @@ ] } }, - "/tables/{tableId}/columns/{columnId}": { + "/api/v1/db/meta/tables/{tableId}/columns/{columnId}": { "parameters": [ { "schema": { @@ -1391,7 +1221,7 @@ "DB Table column" ] }, - "put": { + "patch": { "summary": "Column Update", "operationId": "db-table-column-update", "responses": { @@ -1432,7 +1262,7 @@ ] } }, - "/tables/{tableId}/columns/{columnId}/primary": { + "/api/v1/db/meta/tables/{tableId}/columns/{columnId}/primary": { "parameters": [ { "schema": { @@ -1464,7 +1294,32 @@ ] } }, - "/views/{viewId}": { + "/api/v1/db/meta/tables/{tableId}/views": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "tableId", + "in": "path", + "required": true + } + ], + "get": { + "summary": "", + "operationId": "db-view-list", + "responses": { + "200": { + "$ref": "#/components/responses/ViewList" + } + }, + "tags": [ + "DB View" + ], + "description": "" + } + }, + "/api/v1/db/meta/views/{viewId}": { "parameters": [ { "schema": { @@ -1475,7 +1330,7 @@ "required": true } ], - "put": { + "patch": { "summary": "", "operationId": "db-view-update", "responses": { @@ -1528,47 +1383,7 @@ ] } }, - "/views/{viewId}/columns": { - "parameters": [ - { - "schema": { - "type": "string" - }, - "name": "viewId", - "in": "path", - "required": true - } - ], - "get": { - "summary": "", - "operationId": "db-view-column-list", - "responses": { - }, - "tags": [ - "DB View Column" - ] - }, - "post": { - "summary": "", - "operationId": "db-view-column-create", - "responses": { - "200": { - "description": "OK" - } - }, - "tags": [ - "DB View Column" - ], - "requestBody": { - "content": { - "application/json": { - "schema": {} - } - } - } - } - }, - "/views/{viewId}/showAll": { + "/api/v1/db/meta/views/{viewId}/showAll": { "parameters": [ { "schema": { @@ -1602,7 +1417,7 @@ ] } }, - "/views/{viewId}/hideAll": { + "/api/v1/db/meta/views/{viewId}/hideAll": { "parameters": [ { "schema": { @@ -1636,63 +1451,40 @@ "description": "" } }, - "/views/{viewId}/columns/{columnId}": { + "/api/v1/db/meta/tables/{tableId}/share": { "parameters": [ { "schema": { "type": "string" }, - "name": "viewId", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "columnId", + "name": "tableId", "in": "path", "required": true } ], "get": { - "summary": "", - "operationId": "db-view-column-read", + "summary": "Shared view list", + "operationId": "db-view-share-list", "responses": { "200": { "description": "OK", "content": { "application/json": { - "schema": {} + "schema": { + "type": "array", + "items": {} + } } } } }, + "description": "", "tags": [ - "DB View Column" + "DB View Share" ] - }, - "put": { - "summary": "", - "operationId": "db-view-column-update", - "responses": { - "200": { - "description": "OK" - } - }, - "tags": [ - "DB View Column" - ], - "requestBody": { - "content": { - "application/json": { - "schema": {} - } - } - } } }, - "/views/{viewId}/share": { + "/api/v1/db/meta/views/{viewId}/share": { "parameters": [ { "schema": { @@ -1727,7 +1519,7 @@ "DB View Share" ] }, - "put": { + "patch": { "summary": "", "operationId": "db-view-share-update", "responses": { @@ -1775,7 +1567,7 @@ ] } }, - "/tables/{viewId}/share": { + "/api/v1/db/meta/views/{viewId}/columns": { "parameters": [ { "schema": { @@ -1788,27 +1580,90 @@ ], "get": { "summary": "", - "operationId": "db-view-share-list", + "operationId": "db-view-column-list", + "responses": { + }, + "tags": [ + "DB View Column" + ] + }, + "post": { + "summary": "", + "operationId": "db-view-column-create", + "responses": { + "200": { + "description": "OK" + } + }, + "tags": [ + "DB View Column" + ], + "requestBody": { + "content": { + "application/json": { + "schema": {} + } + } + } + } + }, + "/api/v1/db/meta/views/{viewId}/columns/{columnId}": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "viewId", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "columnId", + "in": "path", + "required": true + } + ], + "get": { + "summary": "", + "operationId": "db-view-column-read", "responses": { "200": { "description": "OK", "content": { "application/json": { - "schema": { - "type": "array", - "items": {} - } + "schema": {} } } } }, - "description": "", "tags": [ - "DB View Share" + "DB View Column" ] + }, + "patch": { + "summary": "", + "operationId": "db-view-column-update", + "responses": { + "200": { + "description": "OK" + } + }, + "tags": [ + "DB View Column" + ], + "requestBody": { + "content": { + "application/json": { + "schema": {} + } + } + } } }, - "/views/{viewId}/sorts": { + "/api/v1/db/meta/views/{viewId}/sorts": { "parameters": [ { "schema": { @@ -1868,16 +1723,8 @@ } } }, - "/views/{viewId}/sorts/{sortId}": { + "/api/v1/db/meta/sorts/{sortId}": { "parameters": [ - { - "schema": { - "type": "string" - }, - "name": "viewId", - "in": "path", - "required": true - }, { "schema": { "type": "string" @@ -1906,7 +1753,7 @@ "DB Table Sort" ] }, - "put": { + "patch": { "summary": "", "operationId": "db-table-sort-update", "responses": { @@ -1940,7 +1787,7 @@ ] } }, - "/views/{viewId}/filters": { + "/api/v1/db/meta/views/{viewId}/filters": { "parameters": [ { "schema": { @@ -1985,16 +1832,53 @@ } } }, - "/views/{viewId}/filters/{filterId}": { + "/api/v1/db/meta/hooks/{hookId}/filters": { "parameters": [ { "schema": { "type": "string" }, - "name": "viewId", + "name": "hookId", "in": "path", "required": true + } + ], + "get": { + "summary": "", + "operationId": "db-table-webhook-filter-read", + "responses": { + "200": { + "$ref": "#/components/responses/FilterList" + } + }, + "tags": [ + "DB Table Webhook Filter" + ] + }, + "post": { + "summary": "", + "operationId": "db-table-webhook-filter-create", + "responses": { + "200": { + "description": "OK" + } }, + "tags": [ + "DB Table Webhook Filter" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Filter" + } + } + } + } + } + }, + "/api/v1/db/meta/filters/{filterId}": { + "parameters": [ { "schema": { "type": "string" @@ -2023,7 +1907,7 @@ "DB Table Filter" ] }, - "put": { + "patch": { "summary": "", "operationId": "db-table-filter-update", "responses": { @@ -2057,16 +1941,8 @@ ] } }, - "/views/{viewId}/filters/{filterParentId}/children": { + "/api/v1/db/meta/filters/{filterParentId}/children": { "parameters": [ - { - "schema": { - "type": "string" - }, - "name": "viewId", - "in": "path", - "required": true - }, { "schema": { "type": "string" @@ -2096,183 +1972,203 @@ ] } }, - "/hooks/{hookId}/filters": { + "/api/v1/db/meta/tables/{tableId}/grids": { "parameters": [ { "schema": { "type": "string" }, - "name": "hookId", + "name": "tableId", "in": "path", "required": true } ], - "get": { - "summary": "", - "operationId": "db-table-webhook-filter-read", - "responses": { - "200": { - "$ref": "#/components/responses/FilterList" - } - }, - "tags": [ - "DB Table Webhook Filter" - ] - }, "post": { "summary": "", - "operationId": "db-table-webhook-filter-create", + "operationId": "db-view-grid-create", "responses": { "200": { - "description": "OK" + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Grid" + } + } + } } }, "tags": [ - "DB Table Webhook Filter" + "DB View" ], "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Filter" + "$ref": "#/components/schemas/Grid" } } } } } }, - "/hooks/{viewId}/filters/{filterId}": { + "/api/v1/db/meta/tables/{tableId}/forms": { "parameters": [ { "schema": { "type": "string" }, - "name": "viewId", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "filterId", + "name": "tableId", "in": "path", "required": true } ], - "get": { + "post": { "summary": "", - "operationId": "db-table-webhook-filter-get", + "operationId": "db-view-form-create", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Filter" + "$ref": "#/components/schemas/Form" } } } } }, + "description": "", "tags": [ - "DB Table Webhook Filter" - ] - }, - "put": { + "DB View" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Form" + } + } + } + } + } + }, + "/api/v1/db/meta/forms/{formId}": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "formId", + "in": "path", + "required": true + } + ], + "patch": { "summary": "", - "operationId": "db-table-webhook-filter-update", + "operationId": "db-view-form-update", "responses": { "200": { "description": "OK" } }, "tags": [ - "DB Table Webhook Filter" + "DB View" ], "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Filter" + "$ref": "#/components/schemas/Form" } } } } }, - "delete": { + "get": { "summary": "", - "operationId": "db-table-webhook-filter-delete", + "operationId": "db-view-form-read", "responses": { "200": { - "description": "OK" + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Form" + } + } + } } }, "tags": [ - "DB Table Webhook Filter" + "DB View" ] } }, - "/hooks/{viewId}/filters/{filterParentId}/children": { + "/api/v1/db/meta/form/columns/{formViewColumnId}": { "parameters": [ { "schema": { "type": "string" }, - "name": "viewId", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "filterParentId", + "name": "formViewColumnId", "in": "path", "required": true } ], - "get": { + "patch": { "summary": "", - "operationId": "db-table-webhook-filter-children-read", + "operationId": "db-view-form-column-update", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Filter" + "$ref": "" } } } } }, "tags": [ - "DB Table Webhook Filter" - ] + "DB View" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FormColumn" + } + } + } + } } }, - "/tables/{tableId}/grids": { + "/api/v1/db/meta/grids/{gidId}/grid/columns": { "parameters": [ { "schema": { "type": "string" }, - "name": "tableId", + "name": "gidId", "in": "path", "required": true } ], - "post": { + "get": { "summary": "", - "operationId": "db-view-grid-create", + "operationId": "db-view-grid-columns-list", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Grid" + "type": "array", + "items": { + "$ref": "#/components/schemas/GridColumn" + } } } } @@ -2280,75 +2176,48 @@ }, "tags": [ "DB View" - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Grid" - } - } - } - } + ] } }, - "/tables/{tableId}/grids/{gridId}": { + "/api/v1/db/meta/grid/columns/{columnId}": { "parameters": [ { "schema": { "type": "string" }, - "name": "tableId", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "gridId", + "name": "columnId", "in": "path", "required": true } ], - "put": { - "summary": "", - "operationId": "db-view-grid-update", - "responses": { - "200": { - "description": "OK" - } - }, - "tags": [ - "DB View" - ] - }, - "delete": { + "patch": { "summary": "", - "operationId": "db-view-grid-delete", + "operationId": "db-view-grid-column-update", "responses": { "200": { - "description": "OK" + "description": "OK", + "content": { + "application/json": { + "schema": {} + } + } } }, "tags": [ "DB View" - ] - }, - "get": { - "summary": "", - "operationId": "db-view-grid-read", - "responses": { - "200": { - "description": "OK" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GridColumn" + } + } } - }, - "tags": [ - "DB View" - ] + } } }, - "/tables/{tableId}/forms": { + "/api/v1/db/meta/tables/{tableId}/galleries": { "parameters": [ { "schema": { @@ -2361,20 +2230,20 @@ ], "post": { "summary": "", - "operationId": "db-view-form-create", + "operationId": "db-view-gallery-create", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Form" + "type": "object", + "properties": {} } } } } }, - "description": "", "tags": [ "DB View" ], @@ -2382,27 +2251,27 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Form" + "$ref": "#/components/schemas/Gallery" } } } } } }, - "/forms/{formId}": { + "/api/v1/db/meta/galleries/{galleryId}": { "parameters": [ { "schema": { "type": "string" }, - "name": "formId", + "name": "galleryId", "in": "path", "required": true } ], - "put": { + "patch": { "summary": "", - "operationId": "db-view-form-update", + "operationId": "db-view-gallery-update", "responses": { "200": { "description": "OK" @@ -2415,7 +2284,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Form" + "$ref": "#/components/schemas/Gallery" } } } @@ -2423,14 +2292,14 @@ }, "get": { "summary": "", - "operationId": "db-view-form-read", + "operationId": "db-view-gallery-read", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Form" + "$ref": "#/components/schemas/Gallery" } } } @@ -2441,94 +2310,110 @@ ] } }, - "/formColumns/{columnId}": { + "/api/v1/db/meta/projects/{projectId}/meta-diff": { "parameters": [ { "schema": { "type": "string" }, - "name": "columnId", + "name": "projectId", "in": "path", "required": true } ], - "put": { + "post": { "summary": "", - "operationId": "db-view-form-column-update", + "operationId": "project-meta-diff-sync", "responses": { "200": { "description": "OK", "content": { "application/json": { - "schema": { - "$ref": "" - } + "schema": {} } } } }, "tags": [ - "DB View" + "Project" + ] + }, + "get": { + "summary": "", + "operationId": "project-meta-diff-get", + "parameters": [], + "tags": [ + "Project" ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/FormColumn" + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": {} } } } } } }, - "/grid/{gidId}/gridColumns": { + "/api/v1/db/data/{orgs}/{projectName}/{tableName}": { "parameters": [ { "schema": { "type": "string" }, - "name": "gidId", + "name": "orgs", "in": "path", "required": true - } - ], - "get": { - "summary": "", - "operationId": "db-view-grid-columns-list", - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/GridColumn" - } - } - } - } - } }, - "tags": [ - "DB View" - ] - } - }, - "/gridColumns/{columnId}": { - "parameters": [ { "schema": { "type": "string" }, - "name": "columnId", + "name": "projectName", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "tableName", "in": "path", "required": true } ], - "put": { + "get": { "summary": "", - "operationId": "db-view-grid-column-update", + "operationId": "db-table-row-list", + "description": "", + "tags": [ + "DB Table Row" + ], + "parameters": [ + { + "schema": { + "type": "array" + }, + "in": "query", + "name": "fields" + }, + { + "schema": { + "type": "array" + }, + "in": "query", + "name": "sort" + }, + { + "schema": { + "type": "string" + }, + "in": "query", + "name": "where" + } + ], "responses": { "200": { "description": "OK", @@ -2538,157 +2423,48 @@ } } } - }, - "tags": [ - "DB View" - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GridColumn" - } - } - } - } - } - }, - "/tables/{tableId}/galleries": { - "parameters": [ - { - "schema": { - "type": "string" - }, - "name": "tableId", - "in": "path", - "required": true } - ], + }, "post": { "summary": "", - "operationId": "db-view-gallery-create", + "operationId": "db-table-row-create", "responses": { "200": { "description": "OK", "content": { "application/json": { - "schema": { - "type": "object", - "properties": {} - } + "schema": {} } } } }, "tags": [ - "DB View" + "DB Table Row" ], "requestBody": { "content": { "application/json": { - "schema": { - "$ref": "#/components/schemas/Gallery" - } + "schema": {} } } } } }, - "/galleries/{galleryId}": { + "/api/v1/db/data/{orgs}/{projectName}/{tableName}/views/{viewName}": { "parameters": [ { "schema": { "type": "string" }, - "name": "galleryId", + "name": "orgs", "in": "path", "required": true - } - ], - "put": { - "summary": "", - "operationId": "db-view-gallery-update", - "responses": { - "200": { - "description": "OK" - } }, - "tags": [ - "DB View" - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Gallery" - } - } - } - } - }, - "delete": { - "summary": "", - "operationId": "db-view-gallery-delete", - "responses": { - "200": { - "description": "OK" - } - }, - "tags": [ - "DB View" - ] - }, - "get": { - "summary": "", - "operationId": "db-view-gallery-read", - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Gallery" - } - } - } - } - }, - "tags": [ - "DB View" - ] - } - }, - "/tables/{tableId}/kanbans": { - "parameters": [ - { - "schema": { - "type": "string" - }, - "name": "tableId", - "in": "path", - "required": true - } - ], - "post": { - "summary": "", - "operationId": "db-view-kanban-create", - "responses": { - "200": { - "description": "OK" - } - }, - "tags": [ - "DB View" - ] - } - }, - "/tables/{tableId}/kanbans/{kanbanId}": { - "parameters": [ { "schema": { "type": "string" }, - "name": "tableId", + "name": "projectName", "in": "path", "required": true }, @@ -2696,90 +2472,54 @@ "schema": { "type": "string" }, - "name": "kanbanId", + "name": "tableName", "in": "path", "required": true - } - ], - "put": { - "summary": "", - "operationId": "db-view-kanban-update", - "responses": { - "200": { - "description": "OK" - } - }, - "tags": [ - "DB View" - ] - }, - "delete": { - "summary": "", - "operationId": "db-view-kanban-delete", - "responses": { - "200": { - "description": "OK" - } - }, - "tags": [ - "DB View" - ] - }, - "get": { - "summary": "", - "operationId": "db-view-kanban-read", - "responses": { - "200": { - "description": "OK" - } }, - "tags": [ - "DB View" - ] - } - }, - "/tables/{tableId}/views": { - "parameters": [ { "schema": { "type": "string" }, - "name": "tableId", + "name": "viewName", "in": "path", "required": true } ], "get": { "summary": "", - "operationId": "db-view-list", - "responses": { - "200": { - "$ref": "#/components/responses/ViewList" - } - }, + "operationId": "db-view-row-list", + "description": "", "tags": [ - "DB View" + "DB View Row" ], - "description": "" - } - }, - "/data/{tableId}": { - "parameters": [ - { - "schema": { - "type": "string" + "parameters": [ + { + "schema": { + "type": "array" + }, + "in": "query", + "name": "fields" }, - "name": "tableId", - "in": "path", - "required": true - } - ], - "get": { - "summary": "", - "operationId": "data-list", - "description": "", - "tags": [ - "Data" + { + "schema": { + "type": "array" + }, + "in": "query", + "name": "sort" + }, + { + "schema": { + "type": "string" + }, + "in": "query", + "name": "where" + }, + { + "schema": {}, + "in": "query", + "name": "nested", + "description": "Query params for nested data" + } ], "responses": { "200": { @@ -2794,7 +2534,7 @@ }, "post": { "summary": "", - "operationId": "data-create", + "operationId": "db-view-row-create", "responses": { "200": { "description": "OK", @@ -2806,7 +2546,7 @@ } }, "tags": [ - "Data" + "DB View Row" ], "requestBody": { "content": { @@ -2817,65 +2557,29 @@ } } }, - "/data/{tableId}/export/{type}": { + "/api/v1/db/data/{orgs}/{projectName}/{tableName}/views/{viewName}/{rowId}": { "parameters": [ { "schema": { "type": "string" }, - "name": "tableId", + "name": "orgs", "in": "path", "required": true }, { "schema": { - "type": "string", - "enum": [ - "csv", - "excel" - ] + "type": "string" }, - "name": "type", + "name": "projectName", "in": "path", "required": true - } - ], - "get": { - "summary": "", - "operationId": "data-csv-export", - "description": "CSV or Excel export", - "tags": [ - "Data" - ], - "wrapped": true, - "responses": { - "200": { - "description": "OK", - "content": { - "application/octet-stream": { - "schema": {} - } - }, - "headers": { - "nc-export-offset": { - "schema": { - "type": "integer" - } - } - } - } }, - "parameters": [] - } - }, - - "/api/v1/db/data/{orgs}/{projectName}/{tableAlias}": { - "parameters": [ { "schema": { "type": "string" }, - "name": "orgs", + "name": "tableName", "in": "path", "required": true }, @@ -2883,7 +2587,7 @@ "schema": { "type": "string" }, - "name": "projectName", + "name": "viewName", "in": "path", "required": true }, @@ -2891,55 +2595,32 @@ "schema": { "type": "string" }, - "name": "tableAlias", + "name": "rowId", "in": "path", "required": true } ], "get": { "summary": "", - "operationId": "db-table-row-list", - "description": "", - "tags": [ - "DB Table Row" - ], - "parameters": [ - { - "schema": { - "type": "array" - }, - "in": "query", - "name": "fields" - }, - { - "schema": { - "type": "array" - }, - "in": "query", - "name": "sort" - }, - { - "schema": { - "type": "string" - }, - "in": "query", - "name": "where" - } - ], + "operationId": "db-view-row-read", "responses": { - "200": { - "description": "OK", + "201": { + "description": "Created", "content": { "application/json": { "schema": {} } } } - } + }, + "description": "", + "tags": [ + "DB View Row" + ] }, - "post": { + "patch": { "summary": "", - "operationId": "db-table-row-create", + "operationId": "db-view-row-update", "responses": { "200": { "description": "OK", @@ -2951,7 +2632,7 @@ } }, "tags": [ - "DB Table Row" + "DB View Row" ], "requestBody": { "content": { @@ -2960,9 +2641,22 @@ } } } + }, + "delete": { + "summary": "", + "operationId": "db-view-row-delete", + "responses": { + "200": { + "description": "OK" + } + }, + "tags": [ + "DB View Row" + ], + "description": "" } }, - "/api/v1/db/data/{orgs}/{projectName}/{tableAlias}/views/{viewName}": { + "/api/v1/db/data/{orgs}/{projectName}/{tableName}/{rowId}": { "parameters": [ { "schema": { @@ -2984,7 +2678,7 @@ "schema": { "type": "string" }, - "name": "tableAlias", + "name": "tableName", "in": "path", "required": true }, @@ -2992,61 +2686,32 @@ "schema": { "type": "string" }, - "name": "viewName", + "name": "rowId", "in": "path", "required": true } ], "get": { "summary": "", - "operationId": "db-view-row-list", - "description": "", - "tags": [ - "DB View Row" - ], - "parameters": [ - { - "schema": { - "type": "array" - }, - "in": "query", - "name": "fields" - }, - { - "schema": { - "type": "array" - }, - "in": "query", - "name": "sort" - }, - { - "schema": { - "type": "string" - }, - "in": "query", - "name": "where" - }, - { - "schema": {}, - "in": "query", - "name": "nested", - "description": "Query params for nested data" - } - ], + "operationId": "db-table-row-read", "responses": { - "200": { - "description": "OK", + "201": { + "description": "Created", "content": { "application/json": { "schema": {} } } } - } + }, + "description": "", + "tags": [ + "DB Table Row" + ] }, - "post": { + "patch": { "summary": "", - "operationId": "db-view-row-create", + "operationId": "db-table-row-update", "responses": { "200": { "description": "OK", @@ -3058,7 +2723,7 @@ } }, "tags": [ - "DB View Row" + "DB Table Row" ], "requestBody": { "content": { @@ -3067,9 +2732,22 @@ } } } + }, + "delete": { + "summary": "", + "operationId": "db-table-row-model-delete", + "responses": { + "200": { + "description": "OK" + } + }, + "tags": [ + "DB Table Row" + ], + "description": "" } }, - "/api/v1/db/data/{orgs}/{projectName}/{tableAlias}/views/{viewName}/{rowId}": { + "/api/v1/db/data/bulk/{orgs}/{projectName}/{tableName}": { "parameters": [ { "schema": { @@ -3091,33 +2769,17 @@ "schema": { "type": "string" }, - "name": "tableAlias", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "viewName", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "rowId", + "name": "tableName", "in": "path", "required": true } ], - "get": { + "post": { "summary": "", - "operationId": "db-view-row-read", + "operationId": "db-table-row-bulk-create", "responses": { - "201": { - "description": "Created", + "200": { + "description": "OK", "content": { "application/json": { "schema": {} @@ -3125,14 +2787,20 @@ } } }, - "description": "", "tags": [ - "DB View Row" - ] + "DB Table Row" + ], + "requestBody": { + "content": { + "application/json": { + "schema": {} + } + } + } }, - "put": { + "patch": { "summary": "", - "operationId": "db-view-row-update", + "operationId": "db-table-row-bulk-create", "responses": { "200": { "description": "OK", @@ -3144,7 +2812,7 @@ } }, "tags": [ - "DB View Row" + "DB Table Row" ], "requestBody": { "content": { @@ -3156,19 +2824,30 @@ }, "delete": { "summary": "", - "operationId": "db-view-row-delete", + "operationId": "db-table-row-bulk-create", "responses": { "200": { - "description": "OK" + "description": "OK", + "content": { + "application/json": { + "schema": {} + } + } } }, "tags": [ - "DB View Row" + "DB Table Row" ], - "description": "" + "requestBody": { + "content": { + "application/json": { + "schema": {} + } + } + } } }, - "/api/v1/db/data/{orgs}/{projectName}/{tableAlias}/{rowId}": { + "/api/v1/db/data/bulk/{orgs}/{projectName}/{tableName}/all": { "parameters": [ { "schema": { @@ -3190,25 +2869,17 @@ "schema": { "type": "string" }, - "name": "tableAlias", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "rowId", + "name": "tableName", "in": "path", "required": true } ], - "get": { + "patch": { "summary": "", - "operationId": "db-table-row-read", + "operationId": "db-table-row-create", "responses": { - "201": { - "description": "Created", + "200": { + "description": "OK", "content": { "application/json": { "schema": {} @@ -3216,14 +2887,20 @@ } } }, - "description": "", "tags": [ "DB Table Row" - ] + ], + "requestBody": { + "content": { + "application/json": { + "schema": {} + } + } + } }, - "put": { + "delete": { "summary": "", - "operationId": "db-table-row-update", + "operationId": "db-table-row-create", "responses": { "200": { "description": "OK", @@ -3243,23 +2920,10 @@ "schema": {} } } - } - }, - "delete": { - "summary": "", - "operationId": "db-table-row-model-delete", - "responses": { - "200": { - "description": "OK" - } - }, - "tags": [ - "DB Table Row" - ], - "description": "" + } } }, - "/api/v1/db/data/{orgs}/{projectName}/{tableAlias}/views/{viewName}/export/{type}": { + "/api/v1/db/data/{orgs}/{projectName}/{tableName}/views/{viewName}/export/{type}": { "parameters": [ { "schema": { @@ -3281,7 +2945,7 @@ "schema": { "type": "string" }, - "name": "tableAlias", + "name": "tableName", "in": "path", "required": true }, @@ -3334,7 +2998,7 @@ "parameters": [] } }, - "/api/v1/db/data/{orgs}/{projectName}/{tableAlias}/export/{type}": { + "/api/v1/db/data/{orgs}/{projectName}/{tableName}/export/{type}": { "parameters": [ { "schema": { @@ -3356,15 +3020,7 @@ "schema": { "type": "string" }, - "name": "tableAlias", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "viewName", + "name": "tableName", "in": "path", "required": true }, @@ -3409,22 +3065,63 @@ "parameters": [] } }, - - - "/public/data/{uuid}/list": { + "/api/v1/db/data/{orgs}/{projectName}/{tableName}/{rowId}/{relationType}/{columnName}": { "parameters": [ { "schema": { "type": "string" }, - "name": "uuid", + "name": "orgs", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "projectName", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "tableName", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "rowId", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string", + "enum": [ + "mm", + "hm" + ] + }, + "name": "relationType", + "in": "path", + "required": true + },{ + "schema": { + "type": "string" + }, + "name": "columnName", "in": "path", "required": true } ], - "post": { + "get": { "summary": "", - "operationId": "public-data-list", + "operationId": "data-nested-list", "responses": { "200": { "description": "OK", @@ -3438,33 +3135,6 @@ "tags": [ "Public" ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "password": { - "type": "string" - }, - "sorts": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Sort" - } - }, - "filters": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Filter" - } - } - } - } - } - }, - "description": "" - }, "parameters": [ { "schema": { @@ -3483,13 +3153,29 @@ ] } }, - "/public/data/{uuid}/{rowId}/{relationType}/{columnId}": { + "/api/v1/db/data/{orgs}/{projectName}/{tableName}/{rowId}/{relationType}/{columnName}/{refRowId}": { "parameters": [ { "schema": { "type": "string" }, - "name": "uuid", + "name": "orgs", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "projectName", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "tableName", "in": "path", "required": true }, @@ -3517,14 +3203,22 @@ "schema": { "type": "string" }, - "name": "columnId", + "name": "columnName", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "refRowId", "in": "path", "required": true } ], - "get": { + "post": { "summary": "", - "operationId": "public-data-nested-list", + "operationId": "data-nested-list", "responses": { "200": { "description": "OK", @@ -3556,13 +3250,29 @@ ] } }, - "/public/data/{uuid}/{rowId}/{relationType}/{columnId}/exclude": { + "/api/v1/db/data/{orgs}/{projectName}/{tableName}/{rowId}/{relationType}/{columnName}/exclude": { "parameters": [ { "schema": { "type": "string" }, - "name": "uuid", + "name": "orgs", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "projectName", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "tableName", "in": "path", "required": true }, @@ -3590,14 +3300,14 @@ "schema": { "type": "string" }, - "name": "columnId", + "name": "columnName", "in": "path", "required": true } ], "get": { "summary": "", - "operationId": "public-data-nested-excluded-list", + "operationId": "data-nested-excluded-children-list", "responses": { "200": { "description": "OK", @@ -3609,7 +3319,7 @@ } }, "tags": [ - "Public" + "DB Data" ], "parameters": [ { @@ -3629,32 +3339,14 @@ ] } }, - "/public/data/{uuid}/create": { - "parameters": [ - { - "schema": { - "type": "string" - }, - "name": "uuid", - "in": "path", - "required": true - } - ], + + "/projects/{projectId}/views/{viewId}/upload": { "post": { - "summary": "", - "operationId": "public-data-create", - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": {} - } - } - } - }, + "summary": "Attachment", + "operationId": "db-view-upload", + "responses": {}, "tags": [ - "Public" + "DB View" ], "requestBody": { "content": { @@ -3662,8 +3354,8 @@ "schema": { "type": "object", "properties": { - "data": {}, - "password": { + "files": {}, + "json": { "type": "string" } } @@ -3671,59 +3363,50 @@ } }, "description": "" - }, - "parameters": [ - { - "schema": { - "type": "string" - }, - "in": "header" - } - ] - } - }, - "/public/data/{uuid}/export/{type}": { + } + }, "parameters": [ { "schema": { "type": "string" }, - "name": "uuid", + "name": "projectId", "in": "path", "required": true }, { "schema": { - "type": "string", - "enum": [ - "csv", - "excel" - ] + "type": "string" }, - "name": "type", + "name": "viewId", + "in": "path", + "required": true + } + ] + }, + + + "/api/v1/db/public/shared-view/{sharedViewUuid}/rows": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "sharedViewUuid", "in": "path", "required": true } ], - "post": { + "get": { "summary": "", - "operationId": "public-csv-export", - "description": "", - "wrapped": true, + "operationId": "public-data-list", "responses": { "200": { "description": "OK", "content": { - "application/octet-stream": { + "application/json": { "schema": {} } - }, - "headers": { - "nc-export-offset": { - "schema": { - "type": "integer" - } - } } } }, @@ -3739,56 +3422,23 @@ "password": { "type": "string" }, - "filters": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Filter" - } - }, "sorts": { "type": "array", "items": { - "$ref": "#/components/schemas/Sort" - } - } - } - } - } - } - } - } - }, - "/public/data/{uuid}/relationTable/{relationColumnId}": { - "parameters": [ - { - "schema": { - "type": "string" - }, - "name": "uuid", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "relationColumnId", - "in": "path", - "required": true - } - ], - "post": { - "summary": "", - "operationId": "public-data-relation-list", - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": {} + "$ref": "#/components/schemas/Sort" + } + }, + "filters": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Filter" + } + } + } } } - } + }, + "description": "" }, "parameters": [ { @@ -3805,52 +3455,16 @@ "in": "query", "name": "offset" } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "password": { - "type": "string" - } - } - } - } - } - }, - "tags": [ - "Public" - ], - "description": "" - } - }, - "/public/meta/{uuid}": { - "parameters": [ - { - "schema": { - "type": "string" - }, - "name": "uuid", - "in": "path", - "required": true - } - ], + ] + }, "post": { "summary": "", - "operationId": "public-shared-view-meta-get", + "operationId": "public-shared-view-create", "responses": { "200": { "description": "OK", "content": { "application/json": { - "schema": { - "type": "object", - "properties": {} - } - }, - "application/xml": { "schema": {} } } @@ -3859,31 +3473,39 @@ "tags": [ "Public" ], - "description": "", - "parameters": [], "requestBody": { "content": { - "application/json": { + "multipart/form-data": { "schema": { "type": "object", "properties": { + "data": {}, "password": { "type": "string" } } } } + }, + "description": "" + }, + "parameters": [ + { + "schema": { + "type": "string" + }, + "in": "header" } - } + ] } }, - "/data/{tableId}/{rowId}/{relationType}/{colId}": { + "/api/v1/db/public/shared-view/{sharedViewUuid}/rows/{rowId}/{relationType}/{columnName}": { "parameters": [ { "schema": { "type": "string" }, - "name": "tableId", + "name": "sharedViewUuid", "in": "path", "required": true }, @@ -3897,9 +3519,13 @@ }, { "schema": { - "type": "string" + "type": "string", + "enum": [ + "mm", + "hm" + ] }, - "name": "colId", + "name": "relationType", "in": "path", "required": true }, @@ -3907,17 +3533,17 @@ "schema": { "type": "string" }, - "name": "relationType", + "name": "columnName", "in": "path", "required": true } ], "get": { "summary": "", - "operationId": "data-nested-list", + "operationId": "public-data-nested-list", "responses": { - "201": { - "description": "Created", + "200": { + "description": "OK", "content": { "application/json": { "schema": {} @@ -3925,19 +3551,34 @@ } } }, - "description": "", "tags": [ - "Data" + "Public" + ], + "parameters": [ + { + "schema": { + "type": "string" + }, + "in": "query", + "name": "limit" + }, + { + "schema": { + "type": "string" + }, + "in": "query", + "name": "offset" + } ] } }, - "/data/{tableId}/{rowId}/{relationType}/{colId}/exclude": { + "/api/v1/db/public/shared-view/{sharedViewUuid}/rows/{rowId}/{relationType}/{columnName}/exclude": { "parameters": [ { "schema": { "type": "string" }, - "name": "tableId", + "name": "sharedViewUuid", "in": "path", "required": true }, @@ -3951,9 +3592,13 @@ }, { "schema": { - "type": "string" + "type": "string", + "enum": [ + "mm", + "hm" + ] }, - "name": "colId", + "name": "relationType", "in": "path", "required": true }, @@ -3961,17 +3606,17 @@ "schema": { "type": "string" }, - "name": "relationType", + "name": "columnName", "in": "path", "required": true } ], "get": { "summary": "", - "operationId": "data-nested-excluded-list", + "operationId": "public-data-nested-excluded-list", "responses": { - "201": { - "description": "Created", + "200": { + "description": "OK", "content": { "application/json": { "schema": {} @@ -3979,43 +3624,110 @@ } } }, - "description": "", "tags": [ - "Data" + "Public" + ], + "parameters": [ + { + "schema": { + "type": "string" + }, + "in": "query", + "name": "limit" + }, + { + "schema": { + "type": "string" + }, + "in": "query", + "name": "offset" + } ] } }, - "/data/{tableId}/{rowId}/{relationType}/{colId}/{referenceTableRowId}": { + "/api/v1/db/public/shared-view/{sharedViewUuid}/rows/export/{type}": { "parameters": [ { "schema": { "type": "string" }, - "name": "tableId", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "rowId", + "name": "sharedViewUuid", "in": "path", "required": true }, { "schema": { - "type": "string" + "type": "string", + "enum": [ + "csv", + "excel" + ] }, - "name": "colId", + "name": "type", "in": "path", "required": true + } + ], + "post": { + "summary": "", + "operationId": "public-csv-export", + "description": "", + "wrapped": true, + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": {} + } + }, + "headers": { + "nc-export-offset": { + "schema": { + "type": "integer" + } + } + } + } }, + "tags": [ + "Public" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "password": { + "type": "string" + }, + "filters": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Filter" + } + }, + "sorts": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Sort" + } + } + } + } + } + } + } + } + }, + "/api/v1/db/public/shared-view/{sharedViewUuid}/rows/nested/{columnName}": { + "parameters": [ { "schema": { "type": "string" }, - "name": "relationType", + "name": "sharedViewUuid", "in": "path", "required": true }, @@ -4023,17 +3735,17 @@ "schema": { "type": "string" }, - "name": "referenceTableRowId", + "name": "columnName", "in": "path", "required": true } ], "post": { "summary": "", - "operationId": "data-nested-add", + "operationId": "public-data-relation-list", "responses": { - "201": { - "description": "Created", + "200": { + "description": "OK", "content": { "application/json": { "schema": {} @@ -4041,101 +3753,133 @@ } } }, - "description": "", - "tags": [ - "Data" - ] - }, - "delete": { - "summary": "", - "operationId": "data-nested-delete", - "responses": { - "200": { - "description": "OK" + "parameters": [ + { + "schema": { + "type": "string" + }, + "in": "query", + "name": "limit" + }, + { + "schema": { + "type": "string" + }, + "in": "query", + "name": "offset" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "password": { + "type": "string" + } + } + } + } } }, - "description": "", "tags": [ - "Data" - ] + "Public" + ], + "description": "" } }, - "/data/{tableId}/{rowId}": { + "/api/v1/db/public/shared-view/{sharedViewUuid}/meta": { "parameters": [ { "schema": { "type": "string" }, - "name": "tableId", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "rowId", + "name": "sharedViewUuid", "in": "path", "required": true } ], - "get": { - "summary": "", - "operationId": "data-read", - "responses": { - "201": { - "description": "Created", - "content": { - "application/json": { - "schema": {} - } - } - } - }, - "description": "", - "tags": [ - "Data" - ] - }, - "put": { + "post": { "summary": "", - "operationId": "data-update", + "operationId": "public-shared-view-meta-get", "responses": { "200": { "description": "OK", "content": { "application/json": { + "schema": { + "type": "object", + "properties": {} + } + }, + "application/xml": { "schema": {} } } } }, "tags": [ - "Data" + "Public" ], + "description": "", + "parameters": [], "requestBody": { "content": { "application/json": { - "schema": {} + "schema": { + "type": "object", + "properties": { + "password": { + "type": "string" + } + } + } } } } - }, - "delete": { + } + }, + "/api/v1/db/public/shared-base/{sharedBaseUuid}/meta": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "sharedBaseUuid", + "in": "path", + "required": true + } + ], + "get": { "summary": "", - "operationId": "data-delete", + "operationId": "public-shared-base-get", + "description": "Read project details", + "parameters": [], "responses": { "200": { - "description": "OK" + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "project_id": { + "type": "string" + } + } + } + } + } } }, "tags": [ - "Data" - ], - "description": "" + "Public" + ] } }, - "/audits/comments": { + + "/api/v1/db/meta/audits/comments": { "parameters": [], "get": { "summary": "", @@ -4218,7 +3962,7 @@ ] } }, - "/audits/comments/count": { + "/api/v1/db/meta/audits/comments/count": { "parameters": [], "get": { "summary": "", @@ -4257,7 +4001,7 @@ ] } }, - "project/{projectId}/audits": { + "/api/v1/db/meta/project/{projectId}/audits": { "parameters": [ { "schema": { @@ -4322,8 +4066,17 @@ ] } }, - "/audits/rowUpdate": { - "parameters": [], + "/api/v1/db/meta/audits/rows/{rowId}/update": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "rowId", + "in": "path", + "required": true + } + ], "post": { "summary": "", "operationId": "utils-audit-row-update", @@ -4363,7 +4116,8 @@ } } }, - "/tables/{tableId}/hooks": { + + "/api/v1/db/meta/tables/{tableId}/hooks": { "parameters": [ { "schema": { @@ -4442,7 +4196,7 @@ ] } }, - "/tables/{tableId}/hooks/test": { + "/api/v1/db/meta/tables/{tableId}/hooks/test": { "parameters": [ { "schema": { @@ -4492,7 +4246,75 @@ } } }, - "/hooks/{hookId}": { + "/api/v1/db/meta/tables/{tableId}/hooks/samplePayload/{operation}": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "tableId", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string", + "enum": [ + "update", + "delete", + "insert" + ] + }, + "name": "operation", + "in": "path", + "required": true + } + ], + "get": { + "summary": "", + "operationId": "db-table-webhook-sample-payload-get", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "plugins": { + "type": "object", + "properties": { + "list": { + "type": "array", + "uniqueItems": true, + "minItems": 1, + "items": { + "$ref": "#/components/schemas/Plugin" + } + }, + "pageInfo": { + "$ref": "#/components/schemas/Paginated" + } + }, + "required": [ + "list", + "pageInfo" + ] + } + } + } + } + } + } + }, + "description": "", + "parameters": [], + "tags": [ + "DB Table Webhook" + ] + } + }, + "/api/v1/db/meta/hooks/{hookId}": { "parameters": [ { "schema": { @@ -4503,7 +4325,7 @@ "required": true } ], - "put": { + "patch": { "summary": "", "operationId": "db-table-webhook-update", "responses": { @@ -4544,7 +4366,8 @@ ] } }, - "/plugins": { + + "/api/v1/db/meta/plugins": { "parameters": [], "get": { "summary": "", @@ -4581,7 +4404,7 @@ ] } }, - "/plugins/{pluginTitle}/status": { + "/api/v1/db/meta/plugins/{pluginTitle}/status": { "parameters": [ { "schema": { @@ -4614,75 +4437,7 @@ ] } }, - "/tables/{tableId}/hooks/samplePayload/{operation}": { - "parameters": [ - { - "schema": { - "type": "string" - }, - "name": "tableId", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string", - "enum": [ - "update", - "delete", - "insert" - ] - }, - "name": "operation", - "in": "path", - "required": true - } - ], - "get": { - "summary": "", - "operationId": "db-table-webhook-sample-payload-get", - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "plugins": { - "type": "object", - "properties": { - "list": { - "type": "array", - "uniqueItems": true, - "minItems": 1, - "items": { - "$ref": "#/components/schemas/Plugin" - } - }, - "pageInfo": { - "$ref": "#/components/schemas/Paginated" - } - }, - "required": [ - "list", - "pageInfo" - ] - } - } - } - } - } - } - }, - "description": "", - "parameters": [], - "tags": [ - "DB Table Webhook" - ] - } - }, - "/plugins/test": { + "/api/v1/db/meta/plugins/test": { "parameters": [], "post": { "summary": "", @@ -4731,7 +4486,7 @@ } } }, - "/plugins/{pluginId}": { + "/api/v1/db/meta/plugins/{pluginId}": { "parameters": [ { "schema": { @@ -4742,7 +4497,7 @@ "required": true } ], - "put": { + "patch": { "summary": "", "operationId": "plugin-update", "responses": { @@ -4790,7 +4545,8 @@ ] } }, - "/testConnection": { + + "/api/v1/db/meta/connection/test": { "parameters": [], "post": { "summary": "", @@ -4828,7 +4584,7 @@ "description": "" } }, - "/appInfo": { + "/api/v1/db/meta/nocodb/info": { "parameters": [], "get": { "summary": "", @@ -4849,7 +4605,7 @@ "description": "" } }, - "/cache": { + "/api/v1/db/meta/cache": { "get": { "summary": "Your GET endpoint", "tags": [ @@ -4874,7 +4630,8 @@ }, "parameters": [] }, - "/projects/{projectId}/apiTokens": { + + "/api/v1/db/meta/projects/{projectId}/apiTokens": { "get": { "summary": "Your GET endpoint", "tags": [ @@ -4944,7 +4701,7 @@ } ] }, - "/projects/{projectId}/apiTokens/{token}": { + "/api/v1/db/meta/projects/{projectId}/apiTokens/{token}": { "delete": { "summary": "", "operationId": "api-token-delete", @@ -4976,7 +4733,8 @@ } ] }, - "/bulkData/{orgs}/{projectName}/{tableAlias}/": { + + "/bulkData/{orgs}/{projectName}/{tableName}/": { "parameters": [ { "schema": { @@ -4998,7 +4756,7 @@ "schema": { "type": "string" }, - "name": "tableAlias", + "name": "tableName", "in": "path", "required": true } @@ -5079,7 +4837,7 @@ ] } }, - "/bulkData/{orgs}/{projectName}/{tableAlias}/all": { + "/bulkData/{orgs}/{projectName}/{tableName}/all": { "parameters": [ { "schema": { @@ -5101,7 +4859,7 @@ "schema": { "type": "string" }, - "name": "tableAlias", + "name": "tableName", "in": "path", "required": true } @@ -5227,6 +4985,30 @@ "email_verified" ] }, + "PageReqQueryParams": { + "title": "PageReqQueryParams", + "type": "object", + "description": "", + "x-internal": false, + "properties": { + "offset": { + "type": "integer" + }, + "limit": { + "type": "integer" + }, + "query": { + "type": "string" + } + }, + "required": [ + "id", + "firstname", + "lastname", + "email", + "email_verified" + ] + }, "UserList": { "description": "", "type": "object", From 55a19bdcab6ae4c128a5816dd8aa0361a9ba9354 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 09:42:57 +0530 Subject: [PATCH 29/81] refactor: ignore socket event emit if undefined Signed-off-by: Pranav C --- package.json | 4 ++-- packages/nc-gui/plugins/tele.js | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index aa3454b9e8..7783eef1cf 100644 --- a/package.json +++ b/package.json @@ -14,9 +14,9 @@ }, "scripts": { "build:common": "cd ./packages/nocodb-sdk; npm install; npm run build", - "start:api": "cd ./packages/nocodb; npm install; NC_DISABLE_CACHE=true NC_DISABLE_TELE=true npm run watch:run:cypress", + "start:api": "cd ./packages/nocodb; npm install; NC_DISABLE_CACHE=true NC_DISABLE_TELE=true npm run watch:run:cypress", "start:xcdb-api": "cd ./packages/nocodb; npm install; NC_DISABLE_CACHE=true NC_DISABLE_TELE=true NC_INFLECTION=camelize DATABASE_URL=sqlite:../../../scripts/cypress/fixtures/sqlite-sakila/sakila.db npm run watch:run:cypress", - "start:api:cache": "cd ./packages/nocodb; npm install; NC_DISABLE_TELE=true npm run watch:run:cypress", + "start:api:cache": "cd ./packages/nocodb; npm install; NC_DISABLE_TELE=true npm run watch:run:cypress", "start:xcdb-api:cache": "cd ./packages/nocodb; npm install; NC_DISABLE_TELE=true NC_INFLECTION=camelize DATABASE_URL=sqlite:../../../scripts/cypress/fixtures/sqlite-sakila/sakila.db npm run watch:run:cypress", "start:web": "cd ./packages/nc-gui; npm install; npm run dev", "cypress:run": "cypress run --config-file ./scripts/cypress/cypress.json", diff --git a/packages/nc-gui/plugins/tele.js b/packages/nc-gui/plugins/tele.js index 945c635751..113f52bad7 100644 --- a/packages/nc-gui/plugins/tele.js +++ b/packages/nc-gui/plugins/tele.js @@ -9,7 +9,7 @@ export default function({ }, inject) { let socket - const init = (token) => { + const init = async(token) => { if (socket) { socket.disconnect() } @@ -30,7 +30,7 @@ export default function({ app.router.onReady(() => { app.router.afterEach(function(to, from) { - if (socket || (to.path === from.path && (to.query && to.query.type) === (from.query && from.query.type))) { + if (!socket || (to.path === from.path && (to.query && to.query.type) === (from.query && from.query.type))) { return } socket.emit('page', { @@ -38,10 +38,12 @@ export default function({ path: to.matched[0].path + (to.query && to.query.type ? `?type=${to.query.type}` : '') }) }) - socket.emit('page', { - id: store.state.users.user && store.state.users.user.id, - path: route.matched[0].path + (route.query && route.query.type ? `?type=${route.query.type}` : '') - }) + if (socket) { + socket.emit('page', { + id: store.state.users.user && store.state.users.user.id, + path: route.matched[0].path + (route.query && route.query.type ? `?type=${route.query.type}` : '') + }) + } }) const tele = { @@ -61,11 +63,11 @@ export default function({ function getListener(binding) { return function(e) { + if (!socket) { return } const cat = window.location.hash.replace(/\d+\/(?=dashboard)/, '') const event = binding.value && binding.value[0] const data = binding.value && binding.value[1] const extra = binding.value && binding.value.slice(2) - tele.emit(event, { cat, @@ -87,14 +89,14 @@ export default function({ store.watch(state => state.project.projectInfo && state.project.projectInfo.teleEnabled && state.users.token, (token) => { if (token) { - init(token) + init(token).then(() => {}) } else if (socket) { socket.disconnect() socket = null } }) if (store.state.project.projectInfo && store.state.project.projectInfo.teleEnabled && store.state.users.token) { - init(store.state.users.token) + init(store.state.users.token).then(() => {}) } } From 2a58c82b808593d13451af2e86758ecff17d0bd4 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 09:51:41 +0530 Subject: [PATCH 30/81] refactor: project user api path correction Signed-off-by: Pranav C --- packages/nc-gui/plugins/tele.js | 4 ++-- .../nocodb/src/lib/noco/meta/api/projectUserApis.ts | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/nc-gui/plugins/tele.js b/packages/nc-gui/plugins/tele.js index 113f52bad7..1e63e1341a 100644 --- a/packages/nc-gui/plugins/tele.js +++ b/packages/nc-gui/plugins/tele.js @@ -14,8 +14,8 @@ export default function({ socket.disconnect() } const isUrl = $axios.defaults.baseURL.startsWith('http') - const url = isUrl ? $axios.defaults.baseURL : window.location.href.split(/[?#]/)[0] - const path = isUrl ? undefined : $axios.defaults.baseURL + const url = isUrl ? $axios.defaults.baseURL : window.location.origin + const path = isUrl ? undefined : ($axios.defaults.baseURL === '..' ? window.location.path.split('/').slice(0, -1).join('/') : $axios.defaults.baseURL) socket = io(url, { path, diff --git a/packages/nocodb/src/lib/noco/meta/api/projectUserApis.ts b/packages/nocodb/src/lib/noco/meta/api/projectUserApis.ts index ecd05c3dc5..ef49ce723e 100644 --- a/packages/nocodb/src/lib/noco/meta/api/projectUserApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/projectUserApis.ts @@ -249,17 +249,20 @@ async function resendInvite(req, res, next): Promise { } const router = Router({ mergeParams: true }); -router.get('/projects/:projectId/users', ncMetaAclMw(userList, 'userList')); +router.get( + '/api/v1/db/meta/projects/:projectId/users', + ncMetaAclMw(userList, 'userList') +); router.post( - '/projects/:projectId/users', + '/api/v1/db/meta/projects/:projectId/users', ncMetaAclMw(userInvite, 'userInvite') ); router.patch( - '/projects/:projectId/users/:userId', + '/api/v1/db/meta/projects/:projectId/users/:userId', ncMetaAclMw(projectUserUpdate, 'projectUserUpdate') ); router.delete( - '/projects/:projectId/users/:userId', + '/api/v1/db/meta/projects/:projectId/users/:userId', ncMetaAclMw(projectUserDelete, 'projectUserDelete') ); export default router; From ae2703e93d4fa82226158601c2874aa3af224142 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 10:18:45 +0530 Subject: [PATCH 31/81] refactor: shared grid view api corrections Signed-off-by: Pranav C --- .../nc-gui/components/project/appStore.vue | 7 - .../project/spreadsheet/public/xcTable.vue | 155 ++---------------- packages/nocodb-sdk/src/lib/Api.ts | 27 +-- .../lib/noco/meta/api/dataApis/dataApis.ts | 5 - .../meta/api/publicApis/publicDataApis.ts | 78 ++++----- .../api/publicApis/publicDataExportApis.ts | 2 +- .../meta/api/publicApis/publicMetaApis.ts | 10 +- scripts/sdk/swagger.json | 72 +++----- 8 files changed, 82 insertions(+), 274 deletions(-) diff --git a/packages/nc-gui/components/project/appStore.vue b/packages/nc-gui/components/project/appStore.vue index 82bfdb2efc..28df19a2ec 100644 --- a/packages/nc-gui/components/project/appStore.vue +++ b/packages/nc-gui/components/project/appStore.vue @@ -213,15 +213,8 @@ export default { }, async created() { await this.loadPluginList() - this.readPluginDefaults() }, methods: { - async readPluginDefaults() { - try { - this.defaultConfig = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcPluginDemoDefaults']) - } catch (e) { - } - }, async confirmResetPlugin() { try { await this.$api.plugin.update(this.resetPluginRef.id, { diff --git a/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue b/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue index f7d64780d8..5e16438a9b 100644 --- a/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue +++ b/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue @@ -22,74 +22,7 @@ class="nc-table-toolbar elevation-0 xc-toolbar xc-border-bottom" style="z-index: 7;border-radius: 4px" > - -
- -
-
- - -
@@ -223,14 +127,12 @@ import { ErrorMessages } from 'nocodb-sdk' import spreadsheet from '../mixins/spreadsheet' import ApiFactory from '../apis/apiFactory' -// import EditableCell from "../editableCell"; import FieldsMenu from '../components/fieldsMenu' import SortListMenu from '../components/sortListMenu' import ColumnFilterMenu from '../components/columnFilterMenu' import XcGridView from '../views/xcGridView' import { SqlUI } from '@/helpers/sqlUi' import CsvExportImport from '~/components/project/spreadsheet/components/moreActions' -// import ExpandedForm from "../expandedForm"; export default { name: 'XcTable', @@ -369,23 +271,6 @@ export default { edited() { return this.data && this.data.some(r => r.rowMeta && (r.rowMeta.new || r.rowMeta.changed)) }, - // hasMany() { - // return this.meta && this.meta.hasMany - // ? this.meta.hasMany.reduce((hm, o) => { - // hm[o.rcn] = hm[o.rcn] || [] - // hm[o.rcn].push(o) - // return hm - // }, {}) - // : {} - // }, - // belongsTo() { - // return this.meta && this.meta.belongsTo - // ? this.meta.belongsTo.reduce((bt, o) => { - // bt[o.title] = o - // return bt - // }, {}) - // : {} - // }, table() { if (this.relationType === 'hm') { return this.relation.table_name @@ -426,21 +311,6 @@ export default { this.searchField = this.primaryValueColumn }, created() { - /* if (this.relationType === 'hm') { - this.filters.push({ - field: this.relation.column_name, - op: 'is equal', - value: this.relationIdValue, - readOnly: true - }) - } else if (this.relationType === 'bt') { - this.filters.push({ - field: this.relation.rcn, - op: 'is equal', - value: this.relationIdValue, - readOnly: true - }) - } */ document.addEventListener('keydown', this.onKeyDown) }, beforeDestroy() { @@ -519,7 +389,9 @@ export default { this.loading = true try { this.viewMeta = (await this.$api.public.sharedViewMetaGet(this.$route.params.id, { - password: this.password + headers: { + 'xc-password': this.password + } })) this.meta = this.viewMeta.model this.metas = this.viewMeta.relatedMetas @@ -547,26 +419,21 @@ export default { list, pageInfo: { totalRows: count } } - } = (await this.$api.public.dataList(this.$route.params.id, { - password: this.password, - sorts: this.sorts && this.sorts.map(({ + } = (await this.$api.public.dataList(this.$route.params.id, {}, { + sortArrJson: JSON.stringify(this.sorts && this.sorts.map(({ fk_column_id, direction }) => ({ direction, fk_column_id - })), - filters: this.filters - }, this.queryParams + }))), + filterArrJson: JSON.stringify(this.filters), + ...this.queryParams + }, { + headers: { password: this.password } + } )) - // this.client = client - - // this.showFields = queryParams && queryParams.showFields - // this.meta = meta - // eslint-disable-next-line camelcase - // this.modelName = model_name - this.count = count this.data = list.map(row => ({ row, diff --git a/packages/nocodb-sdk/src/lib/Api.ts b/packages/nocodb-sdk/src/lib/Api.ts index 898fe65392..eeed576ac6 100644 --- a/packages/nocodb-sdk/src/lib/Api.ts +++ b/packages/nocodb-sdk/src/lib/Api.ts @@ -2843,16 +2843,10 @@ export class Api< * @request POST:/api/v1/db/public/shared-view/{sharedViewUuid}/rows * @response `200` `any` OK */ - sharedViewCreate: ( - sharedViewUuid: string, - data: { data?: any; password?: string }, - params: RequestParams = {} - ) => + sharedViewCreate: (sharedViewUuid: string, params: RequestParams = {}) => this.request({ path: `/api/v1/db/public/shared-view/${sharedViewUuid}/rows`, method: 'POST', - body: data, - type: ContentType.FormData, format: 'json', ...params, }), @@ -2941,7 +2935,6 @@ export class Api< dataRelationList: ( sharedViewUuid: string, columnName: string, - data: { password?: string }, query?: { limit?: string; offset?: string }, params: RequestParams = {} ) => @@ -2949,8 +2942,6 @@ export class Api< path: `/api/v1/db/public/shared-view/${sharedViewUuid}/rows/nested/${columnName}`, method: 'POST', query: query, - body: data, - type: ContentType.Json, format: 'json', ...params, }), @@ -2960,19 +2951,13 @@ export class Api< * * @tags Public * @name SharedViewMetaGet - * @request POST:/api/v1/db/public/shared-view/{sharedViewUuid}/meta + * @request GET:/api/v1/db/public/shared-view/{sharedViewUuid}/meta * @response `200` `object` OK */ - sharedViewMetaGet: ( - sharedViewUuid: string, - data: { password?: string }, - params: RequestParams = {} - ) => + sharedViewMetaGet: (sharedViewUuid: string, params: RequestParams = {}) => this.request({ path: `/api/v1/db/public/shared-view/${sharedViewUuid}/meta`, - method: 'POST', - body: data, - type: ContentType.Json, + method: 'GET', format: 'json', ...params, }), @@ -3066,7 +3051,7 @@ export class Api< * * @tags Utils * @name CommentCount - * @request GET:/api/v1/db/meta/meta/audits/comments/count + * @request GET:/api/v1/db/meta/audits/comments/count * @response `201` `any` Created */ commentCount: ( @@ -3074,7 +3059,7 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/api/v1/db/meta/meta/audits/comments/count`, + path: `/api/v1/db/meta/audits/comments/count`, method: 'GET', query: query, format: 'json', diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataApis.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataApis.ts index 8bcd0d6993..6acf1f70d3 100644 --- a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataApis.ts @@ -20,11 +20,6 @@ export async function dataList(req: Request, res: Response, next) { res.json(await getDataList(model, view, req)); } -// async function dataListNew(req: Request, res: Response) { -// const { model, view } = await getViewAndModelFromRequest(req); -// res.json(await getDataList(model, view, req)); -// } - export async function mmList(req: Request, res: Response, next) { const view = await View.get(req.params.viewId); diff --git a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts index b804b7b734..69fc83a5b8 100644 --- a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts @@ -18,12 +18,12 @@ import slash from 'slash'; export async function dataList(req: Request, res: Response) { try { - const view = await View.getByUUID(req.params.publicDataUuid); + const view = await View.getByUUID(req.params.sharedViewUuid); if (!view) NcError.notFound('Not found'); if (view.type !== ViewTypes.GRID) NcError.notFound('Not found'); - if (view.password && view.password !== req.body?.password) { + if (view.password && view.password !== req.headers?.['xc-password']) { return NcError.forbidden(ErrorMessages.INVALID_SHARED_VIEW_PASSWORD); } @@ -39,37 +39,22 @@ export async function dataList(req: Request, res: Response) { dbDriver: NcConnectionMgrv2.get(base) }); - const key = `${model.title}List`; - const requestObj = { - [key]: await baseModel.defaultResolverReq(req.query) - }; - - const data = ( - await nocoExecute( - requestObj, - { - [key]: async args => { - return await baseModel.list(args); - } - }, - {}, - - { - nested: { - [key]: { - ...req.query, - sortArr: req.body?.sorts, - filterArr: req.body?.filters - } - } - } - ) - )?.[key]; + const listArgs: any = { ...req.query }; + try { + listArgs.filterArr = JSON.parse(listArgs.filterArrJson); + } catch (e) {} + try { + listArgs.sortArr = JSON.parse(listArgs.sortArrJson); + } catch (e) {} + + const data = await nocoExecute( + await baseModel.defaultResolverReq(req.query), + await baseModel.list(listArgs), + {}, + listArgs + ); - const count = await baseModel.count({ - ...req.query, - filterArr: req.body?.filters - }); + const count = await baseModel.count(listArgs); res.json({ data: new PagedResponseImpl(data, { ...req.query, count }) @@ -85,12 +70,12 @@ async function dataInsert( res: Response, next ) { - const view = await View.getByUUID(req.params.publicDataUuid); + const view = await View.getByUUID(req.params.sharedViewUuid); if (!view) return next(new Error('Not found')); if (view.type !== ViewTypes.FORM) return next(new Error('Not found')); - if (view.password && view.password !== req.body?.password) { + if (view.password && view.password !== req.headers?.['xc-password']) { return res.status(403).json(ErrorMessages.INVALID_SHARED_VIEW_PASSWORD); } @@ -169,12 +154,12 @@ async function dataInsert( } async function relDataList(req, res) { - const view = await View.getByUUID(req.params.publicDataUuid); + const view = await View.getByUUID(req.params.sharedViewUuid); if (!view) NcError.notFound('Not found'); if (view.type !== ViewTypes.FORM) NcError.notFound('Not found'); - if (view.password && view.password !== req.body?.password) { + if (view.password && view.password !== req.headers?.['xc-password']) { NcError.forbidden(ErrorMessages.INVALID_SHARED_VIEW_PASSWORD); } @@ -215,12 +200,12 @@ async function relDataList(req, res) { } export async function publicMmList(req: Request, res: Response) { - const view = await View.getByUUID(req.params.publicDataUuid); + const view = await View.getByUUID(req.params.sharedViewUuid); if (!view) NcError.notFound('Not found'); if (view.type !== ViewTypes.GRID) NcError.notFound('Not found'); - if (view.password && view.password !== req.body?.password) { + if (view.password && view.password !== req.headers?.['xc-password']) { NcError.forbidden(ErrorMessages.INVALID_SHARED_VIEW_PASSWORD); } @@ -271,12 +256,12 @@ export async function publicMmList(req: Request, res: Response) { } export async function publicHmList(req: Request, res: Response) { - const view = await View.getByUUID(req.params.publicDataUuid); + const view = await View.getByUUID(req.params.sharedViewUuid); if (!view) NcError.notFound('Not found'); if (view.type !== ViewTypes.GRID) NcError.notFound('Not found'); - if (view.password && view.password !== req.body?.password) { + if (view.password && view.password !== req.headers?.['xc-password']) { NcError.forbidden(ErrorMessages.INVALID_SHARED_VIEW_PASSWORD); } @@ -330,13 +315,16 @@ export async function publicHmList(req: Request, res: Response) { } const router = Router({ mergeParams: true }); -router.post('/public/data/:publicDataUuid/list', catchError(dataList)); +router.get( + '/api/v1/db/public/shared-view/:sharedViewUuid/rows', + catchError(dataList) +); router.post( - '/public/data/:publicDataUuid/nested/:columnId', + '/api/v1/db/public/shared-view/:sharedViewUuid/nested/:columnId', catchError(relDataList) ); router.post( - '/public/data/:publicDataUuid/create', + '/api/v1/db/public/shared-view/:sharedViewUuid/create', multer({ storage: multer.diskStorage({}) }).any(), @@ -344,11 +332,11 @@ router.post( ); router.get( - '/public/data/:publicDataUuid/:rowId/mm/:colId', + '/api/v1/db/public/shared-view/:sharedViewUuid/:rowId/mm/:colId', catchError(publicMmList) ); router.get( - '/public/data/:publicDataUuid/:rowId/hm/:colId', + '/api/v1/db/public/shared-view/:sharedViewUuid/:rowId/hm/:colId', catchError(publicHmList) ); diff --git a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataExportApis.ts b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataExportApis.ts index 610ae41054..9a0434ec8e 100644 --- a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataExportApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataExportApis.ts @@ -17,7 +17,7 @@ async function exportCsv(req: Request, res: Response) { if (!view) NcError.notFound('Not found'); if (view.type !== ViewTypes.GRID) NcError.notFound('Not found'); - if (view.password && view.password !== req.body?.password) { + if (view.password && view.password !== req.headers?.['xc-password']) { NcError.forbidden(ErrorMessages.INVALID_SHARED_VIEW_PASSWORD); } diff --git a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicMetaApis.ts b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicMetaApis.ts index 182495139d..35a8f71c83 100644 --- a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicMetaApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicMetaApis.ts @@ -12,11 +12,11 @@ export async function viewMetaGet(req: Request, res: Response) { const view: View & { relatedMetas?: { [ket: string]: Model }; client?: string; - } = await View.getByUUID(req.params.sharedViewUuids); + } = await View.getByUUID(req.params.sharedViewUuid); if (!view) NcError.notFound('Not found'); - if (view.password && view.password !== req.body?.password) { + if (view.password && view.password !== req.headers?.['xc-password']) { NcError.forbidden(ErrorMessages.INVALID_SHARED_VIEW_PASSWORD); } @@ -78,13 +78,13 @@ async function publicSharedBaseGet(req, res): Promise { } const router = Router({ mergeParams: true }); -router.post( - '/api/v1/db/meta/public/shared-view/:sharedViewUuid/meta', +router.get( + '/api/v1/db/public/shared-view/:sharedViewUuid/meta', catchError(viewMetaGet) ); router.get( - '/api/v1/db/meta/public/shared-base/:sharedBaseUuid/meta', + '/api/v1/db/public/shared-base/:sharedBaseUuid/meta', catchError(publicSharedBaseGet) ); export default router; diff --git a/scripts/sdk/swagger.json b/scripts/sdk/swagger.json index 3ce5fd6828..2344a910a7 100644 --- a/scripts/sdk/swagger.json +++ b/scripts/sdk/swagger.json @@ -3395,6 +3395,14 @@ "name": "sharedViewUuid", "in": "path", "required": true + }, + { + "schema": { + "type": "string" + }, + "in": "header", + "name": "xc-password", + "description": "Shared view password" } ], "get": { @@ -3473,22 +3481,6 @@ "tags": [ "Public" ], - "requestBody": { - "content": { - "multipart/form-data": { - "schema": { - "type": "object", - "properties": { - "data": {}, - "password": { - "type": "string" - } - } - } - } - }, - "description": "" - }, "parameters": [ { "schema": { @@ -3738,6 +3730,14 @@ "name": "columnName", "in": "path", "required": true + }, + { + "schema": { + "type": "string" + }, + "in": "header", + "name": "xc-password", + "description": "Shared view password" } ], "post": { @@ -3769,20 +3769,6 @@ "name": "offset" } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "password": { - "type": "string" - } - } - } - } - } - }, "tags": [ "Public" ], @@ -3798,9 +3784,17 @@ "name": "sharedViewUuid", "in": "path", "required": true + }, + { + "schema": { + "type": "string" + }, + "in": "header", + "name": "xc-password", + "description": "Shared view password" } ], - "post": { + "get": { "summary": "", "operationId": "public-shared-view-meta-get", "responses": { @@ -3823,21 +3817,7 @@ "Public" ], "description": "", - "parameters": [], - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "password": { - "type": "string" - } - } - } - } - } - } + "parameters": [] } }, "/api/v1/db/public/shared-base/{sharedBaseUuid}/meta": { From 55248ec80e088089cc3979d278860534a18108f9 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 10:28:50 +0530 Subject: [PATCH 32/81] refactor: shared form view api corrections Signed-off-by: Pranav C --- .../project/spreadsheet/public/xcForm.vue | 75 +------------------ .../project/spreadsheet/public/xcTable.vue | 2 +- packages/nocodb-sdk/src/lib/Api.ts | 13 ++-- .../meta/api/publicApis/publicDataApis.ts | 2 +- scripts/sdk/swagger.json | 36 ++------- 5 files changed, 21 insertions(+), 107 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/public/xcForm.vue b/packages/nc-gui/components/project/spreadsheet/public/xcForm.vue index 1247a6b086..73d9929a68 100644 --- a/packages/nc-gui/components/project/spreadsheet/public/xcForm.vue +++ b/packages/nc-gui/components/project/spreadsheet/public/xcForm.vue @@ -298,7 +298,7 @@ export default { this.loading = true try { this.viewMeta = (await this.$api.public.sharedViewMetaGet(this.$route.params.id, { - password: this.password + headers: { 'xc-password': this.password } })) this.view = this.viewMeta.view @@ -306,66 +306,6 @@ export default { this.metas = this.viewMeta.relatedMetas this.columns = this.meta.columns.filter(c => c.show) this.client = this.viewMeta.client - // try { - // // eslint-disable-next-line camelcase - // const { - // meta, - // // model_name, - // client, - // query_params: qp, - // db_alias: dbAlias, - // relatedTableMetas - // } = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'sharedViewGet', { - // view_id: this.$route.params.id, - // password: this.password - // }]) - // this.client = client - // this.meta = meta - // this.query_params = qp - // this.dbAlias = dbAlias - // this.metas = relatedTableMetas - // - // const showFields = this.query_params.showFields || {} - // let fields = this.query_params.fieldsOrder || [] - // if (!fields.length) { - // fields = Object.keys(showFields) - // } - // // eslint-disable-next-line camelcase - // - // let columns = this.meta.columns - // if (this.meta && this.meta.v) { - // columns = [...columns, ...this.meta.v.map(v => ({ ...v, virtual: 1 }))] - // } - // - // { - // const _ref = {} - // columns.forEach((c) => { - // if (c.virtual && c.bt) { - // c.prop = `${c.bt.rtn}Read` - // } - // if (c.virtual && c.mm) { - // c.prop = `${c.mm.rtn}MMList` - // } - // if (c.virtual && c.hm) { - // c.prop = `${c.hm.table_name}List` - // } - // - // // if (c.virtual && c.lk) { - // // c.alias = `${c.lk._lcn} (from ${c.lk._ltn})` - // // } else { - // c.alias = c.title - // // } - // if (c.alias in _ref) { - // c.alias += _ref[c.alias]++ - // } else { - // _ref[c.alias] = 1 - // } - // }) - // } - // // this.modelName = model_name - // this.columns = columns.filter(c => showFields[c.alias]).sort((a, b) => fields.indexOf(a.alias) - fields.indexOf(b.alias)) - // - // this.localParams = (this.query_params.extraViewParams && this.query_params.extraViewParams.formParams) || {} } catch (e) { if (e.response && e.response.status === 404) { this.notFound = true @@ -385,16 +325,6 @@ export default { } this.submitting = true - // const id = this.meta.columns.filter(c => c.pk).map(c => this.localState[c.title]).join('___') - - // const updatedObj = Object.keys(this.changedColumns).reduce((obj, col) => { - // obj[col] = this.localState[col] - // return obj - // }, {}) - - // if (this.isNew) { - - // const formData = new FormData() const data = { ...this.localState, ...this.virtual } const attachment = {} @@ -407,8 +337,9 @@ export default { await this.$api.public.dataCreate(this.$route.params.id, { data, - password: this.password, ...attachment + }, { + headers: { 'xc-password': this.password } }) this.virtual = {} diff --git a/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue b/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue index 5e16438a9b..f418652b6a 100644 --- a/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue +++ b/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue @@ -430,7 +430,7 @@ export default { filterArrJson: JSON.stringify(this.filters), ...this.queryParams }, { - headers: { password: this.password } + headers: { 'xc-password': this.password } } )) diff --git a/packages/nocodb-sdk/src/lib/Api.ts b/packages/nocodb-sdk/src/lib/Api.ts index eeed576ac6..9fbcf09dc1 100644 --- a/packages/nocodb-sdk/src/lib/Api.ts +++ b/packages/nocodb-sdk/src/lib/Api.ts @@ -2821,7 +2821,6 @@ export class Api< */ dataList: ( sharedViewUuid: string, - data: { password?: string; sorts?: SortType[]; filters?: FilterType[] }, query?: { limit?: string; offset?: string }, params: RequestParams = {} ) => @@ -2829,8 +2828,6 @@ export class Api< path: `/api/v1/db/public/shared-view/${sharedViewUuid}/rows`, method: 'GET', query: query, - body: data, - type: ContentType.Json, format: 'json', ...params, }), @@ -2839,14 +2836,20 @@ export class Api< * No description * * @tags Public - * @name SharedViewCreate + * @name DataCreate * @request POST:/api/v1/db/public/shared-view/{sharedViewUuid}/rows * @response `200` `any` OK */ - sharedViewCreate: (sharedViewUuid: string, params: RequestParams = {}) => + dataCreate: ( + sharedViewUuid: string, + data: any, + params: RequestParams = {} + ) => this.request({ path: `/api/v1/db/public/shared-view/${sharedViewUuid}/rows`, method: 'POST', + body: data, + type: ContentType.Json, format: 'json', ...params, }), diff --git a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts index 69fc83a5b8..17de3870c9 100644 --- a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts @@ -324,7 +324,7 @@ router.post( catchError(relDataList) ); router.post( - '/api/v1/db/public/shared-view/:sharedViewUuid/create', + '/api/v1/db/public/shared-view/:sharedViewUuid/rows', multer({ storage: multer.diskStorage({}) }).any(), diff --git a/scripts/sdk/swagger.json b/scripts/sdk/swagger.json index 2344a910a7..e7f613b81a 100644 --- a/scripts/sdk/swagger.json +++ b/scripts/sdk/swagger.json @@ -3421,33 +3421,6 @@ "tags": [ "Public" ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "password": { - "type": "string" - }, - "sorts": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Sort" - } - }, - "filters": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Filter" - } - } - } - } - } - }, - "description": "" - }, "parameters": [ { "schema": { @@ -3467,7 +3440,7 @@ }, "post": { "summary": "", - "operationId": "public-shared-view-create", + "operationId": "public-data-create", "responses": { "200": { "description": "OK", @@ -3478,6 +3451,13 @@ } } }, + "requestBody": { + "content": { + "application/json": { + "schema": {} + } + } + }, "tags": [ "Public" ], From f156b636562f03c00dc7b0f1031c0bb818ac8245 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 11:22:52 +0530 Subject: [PATCH 33/81] refactor: nested data api corrections Signed-off-by: Pranav C --- .../components/virtualCell/belongsToCell.vue | 20 +- .../virtualCell/components/listChildItems.vue | 29 +- .../virtualCell/components/listItems.vue | 27 +- .../components/virtualCell/hasManyCell.vue | 8 +- .../components/virtualCell/manyToManyCell.vue | 24 +- packages/nocodb-sdk/src/lib/Api.ts | 287 ++++++++++-------- .../meta/api/dataApis/dataAliasNestedApis.ts | 68 ++--- .../src/lib/noco/meta/api/dataApis/index.ts | 9 +- .../nocodb/src/lib/noco/meta/api/index.ts | 2 + scripts/sdk/swagger.json | 38 ++- 10 files changed, 275 insertions(+), 237 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/belongsToCell.vue b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/belongsToCell.vue index e74b679e1d..39eb7a4ac9 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/belongsToCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/belongsToCell.vue @@ -34,6 +34,7 @@ :column="column" :primary-col="parentPrimaryCol" :primary-key="parentPrimaryKey" + :parent-meta="meta" :api="parentApi" :query-params="{ ...parentQueryParams, @@ -278,14 +279,18 @@ export default { return } const id = this.meta.columns.filter(c => c.pk).map(c => this.row[c.title]).join('___') + // todo: audit - await this.$api.data.nestedDelete( - this.meta.id, + await this.$api.dbTableRow.nestedDelete( + 'noco', + this.projectName, + this.meta.title, id, - this.column.id, 'bt', + this.column.title, parent[this.parentPrimaryKey] ) + this.$emit('loadTableData') if (this.isForm && this.$refs.childList) { this.$refs.childList.loadData() @@ -346,12 +351,13 @@ export default { this.newRecordModal = false return } - - await this.$api.data.nestedAdd( - this.meta.id, + await this.$api.dbTableRow.nestedAdd( + 'noco', + this.projectName, + this.meta.title, id, - this.column.id, 'bt', + this.column.title, pid ) diff --git a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/components/listChildItems.vue b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/components/listChildItems.vue index 23dc34f13b..896aafc495 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/components/listChildItems.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/components/listChildItems.vue @@ -179,7 +179,6 @@ export default { methods: { async loadData() { if ((!this.isForm && this.isPublic) && this.$route.params.id) { - if (this.column && this.column.colOptions && this.rowId) { this.data = (await this.$api.public.dataNestedList( this.$route.params.id, @@ -198,26 +197,24 @@ export default { return } if (this.column && this.column.colOptions) { - this.data = (await this.$api.data.nestedList( - this.column.fk_model_id, + this.data = (await this.$api.dbTableRow.nestedList( + 'noco', + this.projectName, + this.parentMeta.title, this.rowId, - this.column.id, this.column.colOptions.type, + this.column.title, { - query: { - limit: this.size, - offset: this.size * (this.page - 1) - // ...this.queryParams - } + limit: this.size, + offset: this.size * (this.page - 1) })) } else { - this.data = (await this.$api.data.list( - this.meta.id, { - query: { - limit: this.size, - offset: this.size * (this.page - 1), - ...this.queryParams - } + this.data = (await this.$api.dbTableRow.list( + 'noco', + this.projectName, this.meta.title, { + limit: this.size, + offset: this.size * (this.page - 1), + ...this.queryParams })) } } diff --git a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/components/listItems.vue b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/components/listItems.vue index af3673866a..5a4513a65b 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/components/listItems.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/components/listItems.vue @@ -144,7 +144,10 @@ export default { this.data = (await this.$api.public.dataRelationList( this.$route.params.id, this.column.id, - { password: this.password }, { + {}, { + headers: { + 'xc-password': this.password + }, query: { limit: this.size, offset: this.size * (this.page - 1), @@ -156,21 +159,23 @@ export default { // eslint-disable-next-line no-lonely-if if (this.column && this.column.colOptions && this.rowId) { - this.data = (await this.$api.data.nestedExcludedList( - this.column.fk_model_id, + this.data = (await this.$api.dbTableRow.nestedChildrenExcludedList( + 'noco', + this.projectName, + this.parentMeta.title, this.rowId, - this.column.id, this.column.colOptions.type, + this.column.title, { - query: { - limit: this.size, - offset: this.size * (this.page - 1), - where: this.query && `(${this.primaryCol},like,${this.query})` - } + limit: this.size, + offset: this.size * (this.page - 1), + where: this.query && `(${this.primaryCol},like,${this.query})` })) } else { - this.data = (await this.$api.data.list( - this.meta.id, { + this.data = (await this.$api.dbTableRow.list( + 'noco', + this.projectName, + this.meta.title, { query: { limit: this.size, offset: this.size * (this.page - 1), diff --git a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue index 2eefe4988f..71fe16590c 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue @@ -382,11 +382,13 @@ export default { const id = this.childMeta.columns.filter(c => c.pk).map(c => child[c.title]).join('___') this.newRecordModal = false - await this.$api.data.nestedAdd( - this.meta.id, + await this.$api.dbTableRow.nestedAdd( + 'noco', + this.projectName, + this.meta.title, this.parentId, - this.column.id, 'hm', + this.column.title, id ) diff --git a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue index 8329ada931..dfd5bf4d8b 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue @@ -44,6 +44,7 @@ :meta="childMeta" :primary-col="childPrimaryCol" :primary-key="childPrimaryKey" + :parent-meta="meta" :api="api" :mm="mm" :tn="mm && mm.rtn" @@ -316,13 +317,17 @@ export default { await Promise.all([this.loadChildMeta(), this.loadAssociateTableMeta()]) const cid = this.childMeta.columns.filter(c => c.pk).map(c => child[c.title]).join('___') const pid = this.meta.columns.filter(c => c.pk).map(c => this.row[c.title]).join('___') - await this.$api.data.nestedDelete( - this.meta.id, + + await this.$api.dbTableRow.nestedDelete( + 'noco', + this.projectName, + this.meta.title, pid, - this.column.id, 'mm', + this.column.title, cid ) + this.$emit('loadTableData') if ((this.childListModal || this.isForm) && this.$refs.childList) { this.$refs.childList.loadData() @@ -400,20 +405,17 @@ export default { // const vcidCol = this.assocMeta.columns.find(c => c.id === this.column.colOptions.fk_mm_parent_column_id).title // const vpidCol = this.assocMeta.columns.find(c => c.id === this.column.colOptions.fk_mm_child_column_id).title - await this.$api.data.nestedAdd( - this.meta.id, + await this.$api.dbTableRow.nestedAdd( + 'noco', + this.projectName, + this.meta.title, pid, - this.column.id, 'mm', + this.column.title, cid ) try { - // await this.$api.data.create(this.assocMeta.id, { - // [vcidCol]: parseIfInteger(cid), - // [vpidCol]: parseIfInteger(pid) - // }) - this.$emit('loadTableData') } catch (e) { // todo: handle diff --git a/packages/nocodb-sdk/src/lib/Api.ts b/packages/nocodb-sdk/src/lib/Api.ts index 9fbcf09dc1..83f83ba3a5 100644 --- a/packages/nocodb-sdk/src/lib/Api.ts +++ b/packages/nocodb-sdk/src/lib/Api.ts @@ -2467,6 +2467,157 @@ export class Api< ...params, }), + /** + * @description CSV or Excel export + * + * @tags DB table row + * @name CsvExport + * @request GET:/api/v1/db/data/{orgs}/{projectName}/{tableName}/views/{viewName}/export/{type} + * @response `200` `any` OK + */ + csvExport: ( + orgs: string, + projectName: string, + tableName: string, + viewName: string, + type: 'csv' | 'excel', + params: RequestParams = {} + ) => + this.request({ + path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/views/${viewName}/export/${type}`, + method: 'GET', + wrapped: true, + ...params, + }), + + /** + * @description CSV or Excel export + * + * @tags DB table row + * @name CsvExport2 + * @request GET:/api/v1/db/data/{orgs}/{projectName}/{tableName}/export/{type} + * @originalName csvExport + * @duplicate + * @response `200` `any` OK + */ + csvExport2: ( + orgs: string, + projectName: string, + tableName: string, + type: 'csv' | 'excel', + params: RequestParams = {} + ) => + this.request({ + path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/export/${type}`, + method: 'GET', + wrapped: true, + ...params, + }), + + /** + * No description + * + * @tags DB table row + * @name NestedList + * @request GET:/api/v1/db/data/{orgs}/{projectName}/{tableName}/{rowId}/{relationType}/{columnName} + * @response `200` `any` OK + */ + nestedList: ( + orgs: string, + projectName: string, + tableName: string, + rowId: string, + relationType: 'mm' | 'hm', + columnName: string, + query?: { limit?: string; offset?: string }, + params: RequestParams = {} + ) => + this.request({ + path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/${rowId}/${relationType}/${columnName}`, + method: 'GET', + query: query, + format: 'json', + ...params, + }), + + /** + * No description + * + * @tags DB table row + * @name NestedAdd + * @request POST:/api/v1/db/data/{orgs}/{projectName}/{tableName}/{rowId}/{relationType}/{columnName}/{refRowId} + * @response `200` `any` OK + */ + nestedAdd: ( + orgs: string, + projectName: string, + tableName: string, + rowId: string, + relationType: 'mm' | 'hm', + columnName: string, + refRowId: string, + query?: { limit?: string; offset?: string }, + params: RequestParams = {} + ) => + this.request({ + path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/${rowId}/${relationType}/${columnName}/${refRowId}`, + method: 'POST', + query: query, + format: 'json', + ...params, + }), + + /** + * No description + * + * @tags DB table row + * @name NestedDelete + * @request DELETE:/api/v1/db/data/{orgs}/{projectName}/{tableName}/{rowId}/{relationType}/{columnName}/{refRowId} + * @response `200` `any` OK + */ + nestedDelete: ( + orgs: string, + projectName: string, + tableName: string, + rowId: string, + relationType: 'mm' | 'hm', + columnName: string, + refRowId: string, + params: RequestParams = {} + ) => + this.request({ + path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/${rowId}/${relationType}/${columnName}/${refRowId}`, + method: 'DELETE', + format: 'json', + ...params, + }), + + /** + * No description + * + * @tags DB table row + * @name NestedChildrenExcludedList + * @request GET:/api/v1/db/data/{orgs}/{projectName}/{tableName}/{rowId}/{relationType}/{columnName}/exclude + * @response `200` `any` OK + */ + nestedChildrenExcludedList: ( + orgs: string, + projectName: string, + tableName: string, + rowId: string, + relationType: 'mm' | 'hm', + columnName: string, + query?: { limit?: string; offset?: string }, + params: RequestParams = {} + ) => + this.request({ + path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/${rowId}/${relationType}/${columnName}/exclude`, + method: 'GET', + query: query, + format: 'json', + ...params, + }), + /** * No description * @@ -2707,110 +2858,7 @@ export class Api< ...params, }), }; - data = { - /** - * @description CSV or Excel export - * - * @tags Data - * @name CsvExport - * @request GET:/api/v1/db/data/{orgs}/{projectName}/{tableName}/views/{viewName}/export/{type} - * @response `200` `any` OK - */ - csvExport: ( - orgs: string, - projectName: string, - tableName: string, - viewName: string, - type: 'csv' | 'excel', - params: RequestParams = {} - ) => - this.request({ - path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/views/${viewName}/export/${type}`, - method: 'GET', - wrapped: true, - ...params, - }), - - /** - * @description CSV or Excel export - * - * @tags Data - * @name CsvExport2 - * @request GET:/api/v1/db/data/{orgs}/{projectName}/{tableName}/export/{type} - * @originalName csvExport - * @duplicate - * @response `200` `any` OK - */ - csvExport2: ( - orgs: string, - projectName: string, - tableName: string, - type: 'csv' | 'excel', - params: RequestParams = {} - ) => - this.request({ - path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/export/${type}`, - method: 'GET', - wrapped: true, - ...params, - }), - }; public = { - /** - * No description - * - * @tags Public - * @name DataNestedList - * @request GET:/api/v1/db/data/{orgs}/{projectName}/{tableName}/{rowId}/{relationType}/{columnName} - * @response `200` `any` OK - */ - dataNestedList: ( - orgs: string, - projectName: string, - tableName: string, - rowId: string, - relationType: 'mm' | 'hm', - columnName: string, - query?: { limit?: string; offset?: string }, - params: RequestParams = {} - ) => - this.request({ - path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/${rowId}/${relationType}/${columnName}`, - method: 'GET', - query: query, - format: 'json', - ...params, - }), - - /** - * No description - * - * @tags Public - * @name DataNestedList2 - * @request POST:/api/v1/db/data/{orgs}/{projectName}/{tableName}/{rowId}/{relationType}/{columnName}/{refRowId} - * @originalName dataNestedList - * @duplicate - * @response `200` `any` OK - */ - dataNestedList2: ( - orgs: string, - projectName: string, - tableName: string, - rowId: string, - relationType: 'mm' | 'hm', - columnName: string, - refRowId: string, - query?: { limit?: string; offset?: string }, - params: RequestParams = {} - ) => - this.request({ - path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/${rowId}/${relationType}/${columnName}/${refRowId}`, - method: 'POST', - query: query, - format: 'json', - ...params, - }), - /** * No description * @@ -2858,13 +2906,11 @@ export class Api< * No description * * @tags Public - * @name DataNestedList3 + * @name DataNestedList * @request GET:/api/v1/db/public/shared-view/{sharedViewUuid}/rows/{rowId}/{relationType}/{columnName} - * @originalName dataNestedList - * @duplicate * @response `200` `any` OK */ - dataNestedList3: ( + dataNestedList: ( sharedViewUuid: string, rowId: string, relationType: 'mm' | 'hm', @@ -2981,33 +3027,6 @@ export class Api< ...params, }), }; - dbData = { - /** - * No description - * - * @tags DB Data - * @name DataNestedExcludedChildrenList - * @request GET:/api/v1/db/data/{orgs}/{projectName}/{tableName}/{rowId}/{relationType}/{columnName}/exclude - * @response `200` `any` OK - */ - dataNestedExcludedChildrenList: ( - orgs: string, - projectName: string, - tableName: string, - rowId: string, - relationType: 'mm' | 'hm', - columnName: string, - query?: { limit?: string; offset?: string }, - params: RequestParams = {} - ) => - this.request({ - path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/${rowId}/${relationType}/${columnName}/exclude`, - method: 'GET', - query: query, - format: 'json', - ...params, - }), - }; utils = { /** * No description diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasNestedApis.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasNestedApis.ts index 9d1c99f7f8..e8641fe556 100644 --- a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasNestedApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasNestedApis.ts @@ -3,7 +3,6 @@ import Model from '../../../../noco-models/Model'; import Base from '../../../../noco-models/Base'; import NcConnectionMgrv2 from '../../../common/NcConnectionMgrv2'; import { PagedResponseImpl } from '../../helpers/PagedResponse'; -import View from '../../../../noco-models/View'; import ncMetaAclMw from '../../helpers/ncMetaAclMw'; import { getViewAndModelFromRequestByAliasOrId } from './helpers'; import { NcError } from '../../helpers/catchError'; @@ -44,12 +43,7 @@ export async function mmList(req: Request, res: Response, next) { } export async function mmExcludedList(req: Request, res: Response, next) { - const view = await View.get(req.params.viewId); - - const model = await Model.getByIdOrName({ - id: view?.fk_model_id || req.params.viewId - }); - + const { model, view } = await getViewAndModelFromRequestByAliasOrId(req); if (!model) return next(new Error('Table not found')); const base = await Base.get(model.base_id); @@ -86,11 +80,7 @@ export async function mmExcludedList(req: Request, res: Response, next) { } export async function hmExcludedList(req: Request, res: Response, next) { - const view = await View.get(req.params.viewId); - - const model = await Model.getByIdOrName({ - id: view?.fk_model_id || req.params.viewId - }); + const { model, view } = await getViewAndModelFromRequestByAliasOrId(req); if (!model) return next(new Error('Table not found')); @@ -129,12 +119,7 @@ export async function hmExcludedList(req: Request, res: Response, next) { } export async function btExcludedList(req: Request, res: Response, next) { - const view = await View.get(req.params.viewId); - - const model = await Model.getByIdOrName({ - id: view?.fk_model_id || req.params.viewId - }); - + const { model, view } = await getViewAndModelFromRequestByAliasOrId(req); if (!model) return next(new Error('Table not found')); const base = await Base.get(model.base_id); @@ -172,12 +157,7 @@ export async function btExcludedList(req: Request, res: Response, next) { } export async function hmList(req: Request, res: Response, next) { - const view = await View.get(req.params.viewId); - - const model = await Model.getByIdOrName({ - id: view?.fk_model_id || req.params.viewId - }); - + const { model, view } = await getViewAndModelFromRequestByAliasOrId(req); if (!model) return next(new Error('Table not found')); const base = await Base.get(model.base_id); @@ -212,11 +192,7 @@ export async function hmList(req: Request, res: Response, next) { //@ts-ignore async function relationDataDelete(req, res) { - const view = await View.get(req.params.viewId); - - const model = await Model.getByIdOrName({ - id: view?.fk_model_id || req.params.viewId - }); + const { model, view } = await getViewAndModelFromRequestByAliasOrId(req); if (!model) NcError.notFound('Table not found'); @@ -232,7 +208,7 @@ async function relationDataDelete(req, res) { await baseModel.removeChild({ colId: column.id, - childId: req.params.childId, + childId: req.params.refRowId, rowId: req.params.rowId }); @@ -241,12 +217,7 @@ async function relationDataDelete(req, res) { //@ts-ignore async function relationDataAdd(req, res) { - const view = await View.get(req.params.viewId); - - const model = await Model.getByIdOrName({ - id: view?.fk_model_id || req.params.viewId - }); - + const { model, view } = await getViewAndModelFromRequestByAliasOrId(req); if (!model) NcError.notFound('Table not found'); const base = await Base.get(model.base_id); @@ -260,7 +231,7 @@ async function relationDataAdd(req, res) { const column = await getColumnByIdOrName(req.params.columnName, model); await baseModel.addChild({ colId: column.id, - childId: req.params.childId, + childId: req.params.refRowId, rowId: req.params.rowId }); @@ -270,9 +241,9 @@ async function relationDataAdd(req, res) { async function getColumnByIdOrName(columnNameOrId: string, model: Model) { const column = (await model.getColumns()).find( c => - column.title === columnNameOrId || + c.title === columnNameOrId || c.id === columnNameOrId || - column.column_name === columnNameOrId + c.column_name === columnNameOrId ); if (!column) @@ -284,25 +255,34 @@ async function getColumnByIdOrName(columnNameOrId: string, model: Model) { const router = Router({ mergeParams: true }); router.get( - '/api/v1/db/data/:orgs/:projectName/:tableName/mm/:columnName/exclude', + '/api/v1/db/data/:orgs/:projectName/:tableName/:rowId/mm/:columnName/exclude', ncMetaAclMw(mmExcludedList, 'mmExcludedList') ); router.get( - '/api/v1/db/data/:orgs/:projectName/:tableName/hm/:columnName/exclude', + '/api/v1/db/data/:orgs/:projectName/:tableName/:rowId/hm/:columnName/exclude', ncMetaAclMw(hmExcludedList, 'hmExcludedList') ); router.get( - '/api/v1/db/data/:orgs/:projectName/:tableName/bt/:columnName/exclude', + '/api/v1/db/data/:orgs/:projectName/:tableName/:rowId/bt/:columnName/exclude', ncMetaAclMw(btExcludedList, 'btExcludedList') ); router.post( - '/api/v1/db/data/:orgs/:projectName/:tableName/:relationType/:columnName/:refRowId', + '/api/v1/db/data/:orgs/:projectName/:tableName/:rowId/:relationType/:columnName/:refRowId', ncMetaAclMw(relationDataAdd, 'relationDataAdd') ); router.delete( - '/api/v1/db/data/:orgs/:projectName/:tableName/:relationType/:columnName/:refRowId', + '/api/v1/db/data/:orgs/:projectName/:tableName/:rowId/:relationType/:columnName/:refRowId', ncMetaAclMw(relationDataDelete, 'relationDataDelete') ); +router.get( + '/api/v1/db/data/:orgs/:projectName/:tableName/:rowId/mm/:columnName', + ncMetaAclMw(mmList, 'mmList') +); +router.get( + '/api/v1/db/data/:orgs/:projectName/:tableName/:rowId/hm/:columnName', + ncMetaAclMw(hmList, 'hmList') +); + export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/index.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/index.ts index 4c9c61b6ba..9db8249380 100644 --- a/packages/nocodb/src/lib/noco/meta/api/dataApis/index.ts +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/index.ts @@ -2,5 +2,12 @@ import dataApis from './dataApis'; import oldDataApis from './oldDataApis'; import dataAliasApis from './dataAliasApis'; import bulkDataAliasApis from './bulkDataAliasApis'; +import dataAliasNestedApis from './dataAliasNestedApis'; -export { dataApis, oldDataApis, dataAliasApis, bulkDataAliasApis }; +export { + dataApis, + oldDataApis, + dataAliasApis, + bulkDataAliasApis, + dataAliasNestedApis +}; diff --git a/packages/nocodb/src/lib/noco/meta/api/index.ts b/packages/nocodb/src/lib/noco/meta/api/index.ts index f243a8fcd7..3015dab98e 100644 --- a/packages/nocodb/src/lib/noco/meta/api/index.ts +++ b/packages/nocodb/src/lib/noco/meta/api/index.ts @@ -30,6 +30,7 @@ import hookFilterApis from './hookFilterApis'; import { bulkDataAliasApis, dataAliasApis, + dataAliasNestedApis, dataApis, oldDataApis } from './dataApis'; @@ -52,6 +53,7 @@ export default function(router: Router, server) { router.use(dataApis); router.use(bulkDataAliasApis); router.use(dataAliasApis); + router.use(dataAliasNestedApis); router.use(oldDataApis); router.use(sortApis); router.use(filterApis); diff --git a/scripts/sdk/swagger.json b/scripts/sdk/swagger.json index e7f613b81a..63c32b465b 100644 --- a/scripts/sdk/swagger.json +++ b/scripts/sdk/swagger.json @@ -2357,6 +2357,7 @@ } } }, + "/api/v1/db/data/{orgs}/{projectName}/{tableName}": { "parameters": [ { @@ -2972,10 +2973,10 @@ ], "get": { "summary": "", - "operationId": "data-csv-export", + "operationId": "db-table-row-csv-export", "description": "CSV or Excel export", "tags": [ - "Data" + "DB table row" ], "wrapped": true, "responses": { @@ -3039,10 +3040,10 @@ ], "get": { "summary": "", - "operationId": "data-csv-export", + "operationId": "db-table-row-csv-export", "description": "CSV or Excel export", "tags": [ - "Data" + "DB table row" ], "wrapped": true, "responses": { @@ -3121,7 +3122,7 @@ ], "get": { "summary": "", - "operationId": "data-nested-list", + "operationId": "db-table-row-nested-list", "responses": { "200": { "description": "OK", @@ -3133,7 +3134,7 @@ } }, "tags": [ - "Public" + "DB table row" ], "parameters": [ { @@ -3218,7 +3219,7 @@ ], "post": { "summary": "", - "operationId": "data-nested-list", + "operationId": "db-table-row-nested-add", "responses": { "200": { "description": "OK", @@ -3230,7 +3231,7 @@ } }, "tags": [ - "Public" + "DB table row" ], "parameters": [ { @@ -3248,6 +3249,23 @@ "name": "offset" } ] + }, + "delete": { + "summary": "", + "operationId": "db-table-row-nested-delete", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": {} + } + } + } + }, + "tags": [ + "DB table row" + ] } }, "/api/v1/db/data/{orgs}/{projectName}/{tableName}/{rowId}/{relationType}/{columnName}/exclude": { @@ -3307,7 +3325,7 @@ ], "get": { "summary": "", - "operationId": "data-nested-excluded-children-list", + "operationId": "db-table-row-nested-children-excluded-list", "responses": { "200": { "description": "OK", @@ -3319,7 +3337,7 @@ } }, "tags": [ - "DB Data" + "DB table row" ], "parameters": [ { From 30a075de23d3fc64bb8b0d464eed7dfed2b89f35 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 11:25:15 +0530 Subject: [PATCH 34/81] refactor: meta diff api corrections Signed-off-by: Pranav C --- packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts b/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts index 8324f4f2bf..1837a46d16 100644 --- a/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts @@ -827,11 +827,11 @@ export async function extractAndGenerateManyToManyRelations( const router = Router(); router.get( - '/api/v1/db/meta/projects/:projectId/metaDiff', + '/api/v1/db/meta/projects/:projectId/meta-diff', ncMetaAclMw(metaDiff, 'metaDiff') ); router.post( - '/api/v1/db/meta/projects/:projectId/metaDiff', + '/api/v1/db/meta/projects/:projectId/meta-diff', ncMetaAclMw(metaDiffSync, 'metaDiffSync') ); export default router; From 4e87678831006d1d9efc4d4cff567c9e493cf630 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 11:32:28 +0530 Subject: [PATCH 35/81] refactor: column delete api correction Signed-off-by: Pranav C --- .../spreadsheet/components/headerCell.vue | 2 +- packages/nocodb-sdk/src/lib/Api.ts | 27 ++++++++----------- .../extractProjectIdAndAuthenticate.ts | 4 +++ scripts/sdk/swagger.json | 20 ++------------ 4 files changed, 18 insertions(+), 35 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/components/headerCell.vue b/packages/nc-gui/components/project/spreadsheet/components/headerCell.vue index ad0f54430e..666e3d1b7b 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/headerCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/headerCell.vue @@ -184,7 +184,7 @@ export default { column.altered = 4 const columns = this.meta.columns.slice() columns[this.columnIndex] = column - await this.$api.dbTableColumn.delete(this.meta.id, column.id) + await this.$api.dbTableColumn.delete(column.id) this.$emit('colDelete') this.$emit('saved') diff --git a/packages/nocodb-sdk/src/lib/Api.ts b/packages/nocodb-sdk/src/lib/Api.ts index 83f83ba3a5..036932a35b 100644 --- a/packages/nocodb-sdk/src/lib/Api.ts +++ b/packages/nocodb-sdk/src/lib/Api.ts @@ -1494,12 +1494,12 @@ export class Api< * @tags DB Table column * @name Read * @summary Column Read - * @request GET:/api/v1/db/meta/tables/{tableId}/columns/{columnId} + * @request GET:/api/v1/db/meta/columns/{columnId} * @response `200` `ColumnType` OK */ - read: (tableId: string, columnId: string, params: RequestParams = {}) => + read: (columnId: string, params: RequestParams = {}) => this.request({ - path: `/api/v1/db/meta/tables/${tableId}/columns/${columnId}`, + path: `/api/v1/db/meta/columns/${columnId}`, method: 'GET', format: 'json', ...params, @@ -1511,17 +1511,16 @@ export class Api< * @tags DB Table column * @name Update * @summary Column Update - * @request PATCH:/api/v1/db/meta/tables/{tableId}/columns/{columnId} + * @request PATCH:/api/v1/db/meta/columns/{columnId} * @response `200` `ColumnType` OK */ update: ( - tableId: string, columnId: string, data: ColumnReqType, params: RequestParams = {} ) => this.request({ - path: `/api/v1/db/meta/tables/${tableId}/columns/${columnId}`, + path: `/api/v1/db/meta/columns/${columnId}`, method: 'PATCH', body: data, type: ContentType.Json, @@ -1534,12 +1533,12 @@ export class Api< * * @tags DB Table column * @name Delete - * @request DELETE:/api/v1/db/meta/tables/{tableId}/columns/{columnId} + * @request DELETE:/api/v1/db/meta/columns/{columnId} * @response `200` `void` OK */ - delete: (tableId: string, columnId: string, params: RequestParams = {}) => + delete: (columnId: string, params: RequestParams = {}) => this.request({ - path: `/api/v1/db/meta/tables/${tableId}/columns/${columnId}`, + path: `/api/v1/db/meta/columns/${columnId}`, method: 'DELETE', ...params, }), @@ -1549,16 +1548,12 @@ export class Api< * * @tags DB Table column * @name PrimaryColumnSet - * @request POST:/api/v1/db/meta/tables/{tableId}/columns/{columnId}/primary + * @request POST:/api/v1/db/meta/columns/{columnId}/primary * @response `200` `void` OK */ - primaryColumnSet: ( - tableId: string, - columnId: string, - params: RequestParams = {} - ) => + primaryColumnSet: (columnId: string, params: RequestParams = {}) => this.request({ - path: `/api/v1/db/meta/tables/${tableId}/columns/${columnId}/primary`, + path: `/api/v1/db/meta/columns/${columnId}/primary`, method: 'POST', ...params, }), diff --git a/packages/nocodb/src/lib/noco/meta/helpers/extractProjectIdAndAuthenticate.ts b/packages/nocodb/src/lib/noco/meta/helpers/extractProjectIdAndAuthenticate.ts index 686d0359ac..fa25b310e5 100644 --- a/packages/nocodb/src/lib/noco/meta/helpers/extractProjectIdAndAuthenticate.ts +++ b/packages/nocodb/src/lib/noco/meta/helpers/extractProjectIdAndAuthenticate.ts @@ -8,6 +8,7 @@ import GridViewColumn from '../../../noco-models/GridViewColumn'; import FormViewColumn from '../../../noco-models/FormViewColumn'; import GalleryViewColumn from '../../../noco-models/GalleryViewColumn'; import Project from '../../../noco-models/Project'; +import Column from '../../../noco-models/Column'; export default async (req, res, next) => { try { @@ -66,6 +67,9 @@ export default async (req, res, next) => { params.galleryViewColumnId ); req.ncProjectId = galleryViewColumn?.project_id; + } else if (params.columnId) { + const column = await Column.get({ colId: params.columnId }); + req.ncProjectId = column?.project_id; } const user = await new Promise((resolve, _reject) => { diff --git a/scripts/sdk/swagger.json b/scripts/sdk/swagger.json index 63c32b465b..ab3a587027 100644 --- a/scripts/sdk/swagger.json +++ b/scripts/sdk/swagger.json @@ -1182,16 +1182,8 @@ ] } }, - "/api/v1/db/meta/tables/{tableId}/columns/{columnId}": { + "/api/v1/db/meta/columns/{columnId}": { "parameters": [ - { - "schema": { - "type": "string" - }, - "name": "tableId", - "in": "path", - "required": true - }, { "schema": { "type": "string" @@ -1262,16 +1254,8 @@ ] } }, - "/api/v1/db/meta/tables/{tableId}/columns/{columnId}/primary": { + "/api/v1/db/meta/columns/{columnId}/primary": { "parameters": [ - { - "schema": { - "type": "string" - }, - "name": "tableId", - "in": "path", - "required": true - }, { "schema": { "type": "string" From 5683f4b4d27ee09d7a61c69fd6640294596de628 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 11:37:40 +0530 Subject: [PATCH 36/81] refactor: data update api correction Signed-off-by: Pranav C --- .../project/spreadsheet/rowsXcDataTable.vue | 15 +++++++++------ .../lib/noco/meta/api/dataApis/dataAliasApis.ts | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue b/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue index d4efdd8036..15c3814764 100644 --- a/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue +++ b/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue @@ -1115,14 +1115,17 @@ export default { this.$set(this.data[row], 'saving', true) // eslint-disable-next-line promise/param-names - const newData = (await this.$api.data.update(this.meta.id, id, { - [column.title]: rowObj[column.title] - }, { - query: { ignoreWebhook: !saved } - }))// { [column.title]: oldRow[column.title] }) + const newData = (await this.$api.dbTableRow.update( + 'noco', + this.projectName, + this.meta.title, id, { + [column.title]: rowObj[column.title] + }, { + query: { ignoreWebhook: !saved } + })) // audit - this.$api.utils.auditRowUpdate({ + this.$api.utils.auditRowUpdate(id, { fk_model_id: this.meta.id, column_name: column.title, row_id: id, diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasApis.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasApis.ts index 783741d76a..4feba487e1 100644 --- a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasApis.ts @@ -33,7 +33,7 @@ async function dataUpdate(req: Request, res: Response) { const baseModel = await Model.getBaseModelSQL({ id: model.id, - viewId: view.id, + viewId: view?.id, dbDriver: NcConnectionMgrv2.get(base) }); @@ -45,7 +45,7 @@ async function dataDelete(req: Request, res: Response) { const base = await Base.get(model.base_id); const baseModel = await Model.getBaseModelSQL({ id: model.id, - viewId: view.id, + viewId: view?.id, dbDriver: NcConnectionMgrv2.get(base) }); From 02811aefad3b45182888ed7d696d76f97680ee68 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 11:41:03 +0530 Subject: [PATCH 37/81] refactor: filter and sort api corrections Signed-off-by: Pranav C --- packages/nocodb/src/lib/noco-models/Filter.ts | 2 +- .../noco/meta/helpers/extractProjectIdAndAuthenticate.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/nocodb/src/lib/noco-models/Filter.ts b/packages/nocodb/src/lib/noco-models/Filter.ts index 8a220fce30..b9c2a95802 100644 --- a/packages/nocodb/src/lib/noco-models/Filter.ts +++ b/packages/nocodb/src/lib/noco-models/Filter.ts @@ -388,7 +388,7 @@ export default class Filter { await deleteRecursively(filter); } - private static async get(id: string, ncMeta = Noco.ncMeta) { + public static async get(id: string, ncMeta = Noco.ncMeta) { let filterObj = id && (await NocoCache.get( diff --git a/packages/nocodb/src/lib/noco/meta/helpers/extractProjectIdAndAuthenticate.ts b/packages/nocodb/src/lib/noco/meta/helpers/extractProjectIdAndAuthenticate.ts index fa25b310e5..b30e33bb83 100644 --- a/packages/nocodb/src/lib/noco/meta/helpers/extractProjectIdAndAuthenticate.ts +++ b/packages/nocodb/src/lib/noco/meta/helpers/extractProjectIdAndAuthenticate.ts @@ -9,6 +9,8 @@ import FormViewColumn from '../../../noco-models/FormViewColumn'; import GalleryViewColumn from '../../../noco-models/GalleryViewColumn'; import Project from '../../../noco-models/Project'; import Column from '../../../noco-models/Column'; +import Filter from '../../../noco-models/Filter'; +import Sort from '../../../noco-models/Sort'; export default async (req, res, next) => { try { @@ -70,6 +72,12 @@ export default async (req, res, next) => { } else if (params.columnId) { const column = await Column.get({ colId: params.columnId }); req.ncProjectId = column?.project_id; + } else if (params.filterId) { + const filter = await Filter.get(params.filterId); + req.ncProjectId = filter?.project_id; + } else if (params.sortId) { + const sort = await Sort.get(params.sortId); + req.ncProjectId = sort?.project_id; } const user = await new Promise((resolve, _reject) => { From f87db007d4a582867876983917dbbb26efaacf2d Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 11:53:29 +0530 Subject: [PATCH 38/81] refactor: export csv api corrections Signed-off-by: Pranav C --- .../spreadsheet/components/moreActions.vue | 19 ++++--- packages/nocodb-sdk/src/lib/Api.ts | 50 +++++++++---------- .../meta/api/dataApis/dataAliasExportApis.ts | 15 +----- .../src/lib/noco/meta/api/dataApis/helpers.ts | 32 ++++++++++-- .../src/lib/noco/meta/api/dataApis/index.ts | 4 +- .../src/lib/noco/meta/api/exportApis.ts | 30 +---------- .../nocodb/src/lib/noco/meta/api/index.ts | 2 + scripts/sdk/swagger.json | 4 +- 8 files changed, 75 insertions(+), 81 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/components/moreActions.vue b/packages/nc-gui/components/project/spreadsheet/components/moreActions.vue index b77b0fcd0b..898824d813 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/moreActions.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/moreActions.vue @@ -244,12 +244,17 @@ export default { } }) } else { - res = await this.$api.data.csvExport(this.selectedView.id, ExportTypes.CSV, { - responseType: 'blob', - query: { - offset - } - }) + res = await this.$api.dbViewRow.export( + 'noco', + this.projectName, + this.meta.title, + this.selectedView.title, + ExportTypes.CSV, { + responseType: 'blob', + query: { + offset + } + }) } const { data } = res @@ -289,7 +294,7 @@ export default { input = '1' } } else if (v.uidt === UITypes.Number) { - if (input == "") input = null + if (input == '') { input = null } } res[col.destCn] = input } diff --git a/packages/nocodb-sdk/src/lib/Api.ts b/packages/nocodb-sdk/src/lib/Api.ts index 036932a35b..13074b0e63 100644 --- a/packages/nocodb-sdk/src/lib/Api.ts +++ b/packages/nocodb-sdk/src/lib/Api.ts @@ -2467,35 +2467,10 @@ export class Api< * * @tags DB table row * @name CsvExport - * @request GET:/api/v1/db/data/{orgs}/{projectName}/{tableName}/views/{viewName}/export/{type} - * @response `200` `any` OK - */ - csvExport: ( - orgs: string, - projectName: string, - tableName: string, - viewName: string, - type: 'csv' | 'excel', - params: RequestParams = {} - ) => - this.request({ - path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/views/${viewName}/export/${type}`, - method: 'GET', - wrapped: true, - ...params, - }), - - /** - * @description CSV or Excel export - * - * @tags DB table row - * @name CsvExport2 * @request GET:/api/v1/db/data/{orgs}/{projectName}/{tableName}/export/{type} - * @originalName csvExport - * @duplicate * @response `200` `any` OK */ - csvExport2: ( + csvExport: ( orgs: string, projectName: string, tableName: string, @@ -2852,6 +2827,29 @@ export class Api< method: 'DELETE', ...params, }), + + /** + * @description CSV or Excel export + * + * @tags DB view row + * @name Export + * @request GET:/api/v1/db/data/{orgs}/{projectName}/{tableName}/views/{viewName}/export/{type} + * @response `200` `any` OK + */ + export: ( + orgs: string, + projectName: string, + tableName: string, + viewName: string, + type: 'csv' | 'excel', + params: RequestParams = {} + ) => + this.request({ + path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/views/${viewName}/export/${type}`, + method: 'GET', + wrapped: true, + ...params, + }), }; public = { /** diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasExportApis.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasExportApis.ts index 7f0ab6e9f7..03f1b4e857 100644 --- a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasExportApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasExportApis.ts @@ -4,22 +4,11 @@ import { extractCsvData, getViewAndModelFromRequestByAliasOrId } from './helpers'; -import papaparse from 'papaparse'; async function csvDataExport(req: Request, res: Response) { - const { model, view } = await getViewAndModelFromRequestByAliasOrId(req); + const { view } = await getViewAndModelFromRequestByAliasOrId(req); - const { offset, csvRows, elapsed } = await extractCsvData(model, view, req); - - const data = papaparse.unparse( - { - fields: model.columns.map(c => c.title), - data: csvRows - }, - { - escapeFormulae: true - } - ); + const { offset, elapsed, data } = await extractCsvData(view, req); res.set({ 'Access-Control-Expose-Headers': 'nc-export-offset', diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/helpers.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/helpers.ts index 1ec91fe880..75f689952e 100644 --- a/packages/nocodb/src/lib/noco/meta/api/dataApis/helpers.ts +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/helpers.ts @@ -12,6 +12,7 @@ import Column from '../../../../noco-models/Column'; import LookupColumn from '../../../../noco-models/LookupColumn'; import LinkToAnotherRecordColumn from '../../../../noco-models/LinkToAnotherRecordColumn'; +import papaparse from 'papaparse'; export async function getViewAndModelFromRequestByAliasOrId( req: | Request<{ projectName: string; tableName: string; viewName?: string }> @@ -38,10 +39,22 @@ export async function getViewAndModelFromRequestByAliasOrId( return { model, view }; } -export async function extractCsvData(model: Model, view: View, req: Request) { - const base = await Base.get(model.base_id); +export async function extractCsvData(view: View, req: Request) { + const base = await Base.get(view.base_id); + + await view.getModelWithInfo(); + await view.getColumns(); + + view.model.columns = view.columns + .filter(c => c.show) + .map( + c => + new Column({ ...c, ...view.model.columnsById[c.fk_column_id] } as any) + ) + .filter(column => !isSystemColumn(column) || view.show_system_fields); + const baseModel = await Model.getBaseModelSQL({ - id: model.id, + id: view.model.id, viewId: view?.id, dbDriver: NcConnectionMgrv2.get(base) }); @@ -86,7 +99,18 @@ export async function extractCsvData(model: Model, view: View, req: Request) { csvRows.push(csvRow); } } - return { offset, csvRows, elapsed }; + + const data = papaparse.unparse( + { + fields: view.model.columns.map(c => c.title), + data: csvRows + }, + { + escapeFormulae: true + } + ); + + return { offset, csvRows, elapsed, data }; } export async function serializeCellValue({ diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/index.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/index.ts index 9db8249380..4a337712db 100644 --- a/packages/nocodb/src/lib/noco/meta/api/dataApis/index.ts +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/index.ts @@ -3,11 +3,13 @@ import oldDataApis from './oldDataApis'; import dataAliasApis from './dataAliasApis'; import bulkDataAliasApis from './bulkDataAliasApis'; import dataAliasNestedApis from './dataAliasNestedApis'; +import dataAliasExportApis from './dataAliasExportApis'; export { dataApis, oldDataApis, dataAliasApis, bulkDataAliasApis, - dataAliasNestedApis + dataAliasNestedApis, + dataAliasExportApis }; diff --git a/packages/nocodb/src/lib/noco/meta/api/exportApis.ts b/packages/nocodb/src/lib/noco/meta/api/exportApis.ts index 0f2c2b14d9..9bbd8b2452 100644 --- a/packages/nocodb/src/lib/noco/meta/api/exportApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/exportApis.ts @@ -1,37 +1,11 @@ import { Request, Response, Router } from 'express'; import View from '../../../noco-models/View'; -import papaparse from 'papaparse'; -import { isSystemColumn } from 'nocodb-sdk'; -import Column from '../../../noco-models/Column'; import ncMetaAclMw from '../helpers/ncMetaAclMw'; import { extractCsvData } from './dataApis/helpers'; -async function exportCsv(req: Request, res: Response, next) { +async function exportCsv(req: Request, res: Response) { const view = await View.get(req.params.viewId); - - const model = await view.getModelWithInfo(); - await view.getColumns(); - - view.model.columns = view.columns - .filter(c => c.show) - .map( - c => - new Column({ ...c, ...view.model.columnsById[c.fk_column_id] } as any) - ) - .filter(column => !isSystemColumn(column) || view.show_system_fields); - - if (!model) return next(new Error('Table not found')); - const { offset, csvRows, elapsed } = await extractCsvData(model, view, req); - - const data = papaparse.unparse( - { - fields: model.columns.map(c => c.title), - data: csvRows - }, - { - escapeFormulae: true - } - ); + const { offset, elapsed, data } = await extractCsvData(view, req); res.set({ 'Access-Control-Expose-Headers': 'nc-export-offset', diff --git a/packages/nocodb/src/lib/noco/meta/api/index.ts b/packages/nocodb/src/lib/noco/meta/api/index.ts index 3015dab98e..3f72fdaa41 100644 --- a/packages/nocodb/src/lib/noco/meta/api/index.ts +++ b/packages/nocodb/src/lib/noco/meta/api/index.ts @@ -30,6 +30,7 @@ import hookFilterApis from './hookFilterApis'; import { bulkDataAliasApis, dataAliasApis, + dataAliasExportApis, dataAliasNestedApis, dataApis, oldDataApis @@ -54,6 +55,7 @@ export default function(router: Router, server) { router.use(bulkDataAliasApis); router.use(dataAliasApis); router.use(dataAliasNestedApis); + router.use(dataAliasExportApis); router.use(oldDataApis); router.use(sortApis); router.use(filterApis); diff --git a/scripts/sdk/swagger.json b/scripts/sdk/swagger.json index ab3a587027..c238d007ae 100644 --- a/scripts/sdk/swagger.json +++ b/scripts/sdk/swagger.json @@ -2957,10 +2957,10 @@ ], "get": { "summary": "", - "operationId": "db-table-row-csv-export", + "operationId": "db-view-row-export", "description": "CSV or Excel export", "tags": [ - "DB table row" + "DB view row" ], "wrapped": true, "responses": { From 8edde3dfc74b8d71b72dabc2f3edd6f7758d74d7 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 12:05:45 +0530 Subject: [PATCH 39/81] refactor: form view api corrections Signed-off-by: Pranav C --- .../project/spreadsheet/views/formView.vue | 22 +++++++++---------- .../lib/noco/meta/api/formViewColumnApis.ts | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/views/formView.vue b/packages/nc-gui/components/project/spreadsheet/views/formView.vue index 295d5a1e53..10452a72f0 100644 --- a/packages/nc-gui/components/project/spreadsheet/views/formView.vue +++ b/packages/nc-gui/components/project/spreadsheet/views/formView.vue @@ -575,13 +575,15 @@ export default { get() { return this.fields.filter(f => !f.show && !this.systemFieldsIds.includes(f.fk_column_id)) }, - set(v) {} + set(v) { + } }, columns: { get() { return this.fields.filter(f => f.show).sort((a, b) => a.order - b.order) }, - set(v) {} + set(v) { + } } }, watch: { @@ -850,18 +852,16 @@ export default { } this.loading = true - // const id = this.meta.columns.filter(c => c.pk).map(c => this.localState[c.title]).join('___') - - // const updatedObj = Object.keys(this.changedColumns).reduce((obj, col) => { - // obj[col] = this.localState[col] - // return obj - // }, {}) - - // if (this.isNew) { // todo: add params option in GraphQL // let data = await this.api.insert(this.localState, { params: { form: this.$route.query.view } }) - let data = await this.$api.data.create(this.meta.id, this.localState, { query: { form: this.$route.query.view } }) + let data = await this.$api.dbTableRow.create( + 'noco', + this.projectName, + this.meta.title, + this.localState, + { query: { form: this.$route.query.view } } + ) data = { ...this.localState, ...data } // save hasmany and manytomany relations from local state diff --git a/packages/nocodb/src/lib/noco/meta/api/formViewColumnApis.ts b/packages/nocodb/src/lib/noco/meta/api/formViewColumnApis.ts index acf4d11442..879ef33f56 100644 --- a/packages/nocodb/src/lib/noco/meta/api/formViewColumnApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/formViewColumnApis.ts @@ -10,7 +10,7 @@ export async function columnUpdate(req: Request, res: Response) { const router = Router({ mergeParams: true }); router.patch( - '/api/v1/db/meta/forms/columns/:formViewColumnId', + '/api/v1/db/meta/form/columns/:formViewColumnId', ncMetaAclMw(columnUpdate, 'columnUpdate') ); export default router; From 88509e4bd3d72e71b34f53db6abb74c0935fad81 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 12:09:10 +0530 Subject: [PATCH 40/81] refactor: expanded form view api integration corrections Signed-off-by: Pranav C --- .../spreadsheet/components/expandedForm.vue | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/components/expandedForm.vue b/packages/nc-gui/components/project/spreadsheet/components/expandedForm.vue index cd755ed0e0..0a29f9c675 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/expandedForm.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/expandedForm.vue @@ -430,7 +430,10 @@ export default { }, {}) if (this.isNew) { - const data = (await this.$api.data.create(this.viewId || this.meta.id, updatedObj)) + const data = (await this.$api.dbTableRow.create( + 'noco', + this.projectName, + this.meta.title, updatedObj)) this.localState = { ...this.localState, ...data } // save hasmany and manytomany relations from local state @@ -447,10 +450,16 @@ export default { if (!id) { return this.$toast.info('Update not allowed for table which doesn\'t have primary Key').goAway(3000) } - await this.$api.data.update(this.viewId || this.meta.id, id, updatedObj) + await this.$api.dbTableRow.update( + 'noco', + this.projectName, + this.meta.title, + id, + updatedObj + ) for (const key of Object.keys(updatedObj)) { // audit - this.$api.utils.auditRowUpdate({ + this.$api.utils.auditRowUpdate(id, { fk_model_id: this.meta.id, column_name: key, row_id: id, @@ -479,14 +488,16 @@ export default { async reload() { const id = this.meta.columns.filter(c => c.pk).map(c => this.localState[c.title]).join('___') this.$set(this, 'changedColumns', {}) - this.localState = (await this.$api.data.read(this.viewId || this.meta.id, id, { query: this.queryParams || {} })) + this.localState = (await this.$api.dbTableRow.read( + 'noco', + this.projectName, + this.meta.title, id, { query: this.queryParams || {} })) }, calculateDiff(date) { return dayjs.utc(date).fromNow() }, async saveComment() { try { - await this.$api.utils.commentRow({ fk_model_id: this.meta.id, row_id: this.meta.columns.filter(c => c.pk).map(c => this.localState[c.title]).join('___'), From 0b0c2b9b2833f83227516068ddcbbcbcc8e5c835 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 12:13:16 +0530 Subject: [PATCH 41/81] refactor: ui-acl api corrections Signed-off-by: Pranav C --- packages/nocodb/src/lib/noco/meta/api/modelVisibilityApis.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nocodb/src/lib/noco/meta/api/modelVisibilityApis.ts b/packages/nocodb/src/lib/noco/meta/api/modelVisibilityApis.ts index ae03abf9b2..cb7093b3e4 100644 --- a/packages/nocodb/src/lib/noco/meta/api/modelVisibilityApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/modelVisibilityApis.ts @@ -107,7 +107,7 @@ export async function xcVisibilityMetaGet( const router = Router({ mergeParams: true }); router.get( - '/projects/:projectId/modelVisibility', + '/api/v1/db/meta/projects/:projectId/visibility-rules', ncMetaAclMw(async (req, res) => { res.json( await xcVisibilityMetaGet( From 2bf954c2d4ad7815eac16d76a6b4139a2ca8e848 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 12:24:07 +0530 Subject: [PATCH 42/81] refactor: shared grid view api corrections Signed-off-by: Pranav C --- .../project/spreadsheet/public/xcTable.vue | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue b/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue index f418652b6a..5cdfd08bac 100644 --- a/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue +++ b/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue @@ -419,19 +419,21 @@ export default { list, pageInfo: { totalRows: count } } - } = (await this.$api.public.dataList(this.$route.params.id, {}, { - sortArrJson: JSON.stringify(this.sorts && this.sorts.map(({ - fk_column_id, - direction - }) => ({ - direction, - fk_column_id - }))), - filterArrJson: JSON.stringify(this.filters), - ...this.queryParams - }, { - headers: { 'xc-password': this.password } - } + } = (await this.$api.public.dataList( + this.$route.params.id, + { + sortArrJson: JSON.stringify(this.sorts && this.sorts.map(({ + fk_column_id, + direction + }) => ({ + direction, + fk_column_id + }))), + filterArrJson: JSON.stringify(this.filters), + ...this.queryParams + }, { + headers: { 'xc-password': this.password } + } )) this.count = count From b26cf35deab15b34d69d43c2348687d8d0eb0c2e Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 12:31:09 +0530 Subject: [PATCH 43/81] refactor: column update api corrections Signed-off-by: Pranav C --- .../components/project/spreadsheet/components/editColumn.vue | 2 +- .../project/spreadsheet/components/editVirtualColumn.vue | 2 +- packages/nocodb/src/lib/noco/meta/api/columnApis.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/components/editColumn.vue b/packages/nc-gui/components/project/spreadsheet/components/editColumn.vue index af6713b70e..6146b14737 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/editColumn.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/editColumn.vue @@ -565,7 +565,7 @@ export default { this.newColumn.title = this.newColumn.column_name if (this.editColumn) { - await this.$api.dbTableColumn.update(this.meta.id, this.column.id, this.newColumn) + await this.$api.dbTableColumn.update(this.column.id, this.newColumn) } else { await this.$api.dbTableColumn.create(this.meta.id, this.newColumn) } diff --git a/packages/nc-gui/components/project/spreadsheet/components/editVirtualColumn.vue b/packages/nc-gui/components/project/spreadsheet/components/editVirtualColumn.vue index e7c0700180..11a1157a34 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/editVirtualColumn.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/editVirtualColumn.vue @@ -113,7 +113,7 @@ export default { async save() { // todo: rollup update try { - await this.$api.dbTableColumn.update(this.meta.id, this.column.id, this.newColumn) + await this.$api.dbTableColumn.update(this.column.id, this.newColumn) } catch (e) { console.log(this._extractSdkResponseErrorMsg(e)) this.$toast.error('Failed to update column alias').goAway(3000) diff --git a/packages/nocodb/src/lib/noco/meta/api/columnApis.ts b/packages/nocodb/src/lib/noco/meta/api/columnApis.ts index 4a74d8c00c..04137359c0 100644 --- a/packages/nocodb/src/lib/noco/meta/api/columnApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/columnApis.ts @@ -514,7 +514,7 @@ export async function columnUpdate(req: Request, res: Response) { !isVirtualCol(req.body) && !(await Column.checkTitleAvailable({ column_name: req.body.column_name, - fk_model_id: req.params.tableId, + fk_model_id: column.fk_model_id, exclude_id: req.params.columnId })) ) { @@ -523,7 +523,7 @@ export async function columnUpdate(req: Request, res: Response) { if ( !(await Column.checkAliasAvailable({ title: req.body.title, - fk_model_id: req.params.tableId, + fk_model_id: column.fk_model_id, exclude_id: req.params.columnId })) ) { From adc6045c7a3b83bd2545d76e01ea3b824cc2c362 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 13:08:36 +0530 Subject: [PATCH 44/81] refactor(gui): hook filter api update Signed-off-by: Pranav C --- .../project/spreadsheet/components/columnFilter.vue | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/components/columnFilter.vue b/packages/nc-gui/components/project/spreadsheet/components/columnFilter.vue index d5d0310682..5d7eff0cf0 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/columnFilter.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/columnFilter.vue @@ -339,7 +339,7 @@ export default { }) } } else if (this.hookId || hookId) { - this.$set(this.filters, i, (await this.$api.dbTableFilter.create(this.hookId || hookId, { + this.$set(this.filters, i, (await this.$api.dbTableWebhookFilter.create(this.hookId || hookId, { ...filter, fk_parent_id: this.parentId }))) @@ -424,7 +424,6 @@ export default { async deleteFilter(filter, i) { if (this.shared || !this._isUIAllowed('filterSync')) { this.filters.splice(i, 1) - // this.$emit('input', this.filters.filter(f => f.fk_column_id && f.comparison_op)) this.$emit('updated') } else if (filter.id) { if (!this.autoApply) { @@ -438,7 +437,6 @@ export default { this.filters.splice(i, 1) this.$emit('updated') } - // this.$emit('input', this.filters.filter(f => f.fk_column_id && f.comparison_op)) this.$tele.emit('filter:delete') } } From 31d5236148a45c1ab5b56aad2b50cacceb8e68fa Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 13:20:50 +0530 Subject: [PATCH 45/81] refactor: apiToken path update Signed-off-by: Pranav C --- packages/nc-gui/layouts/default.vue | 2 +- packages/nocodb-sdk/src/lib/Api.ts | 12 ++++++------ .../nocodb/src/lib/noco/meta/api/apiTokenApis.ts | 6 +++--- scripts/sdk/swagger.json | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/nc-gui/layouts/default.vue b/packages/nc-gui/layouts/default.vue index d51a9038f6..6739f9fea5 100644 --- a/packages/nc-gui/layouts/default.vue +++ b/packages/nc-gui/layouts/default.vue @@ -657,7 +657,7 @@ export default { }, async copyProjectInfo() { try { - const data = (await this.$api.project.metaGet(this.$store.state.project.projectId))// await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'ncProjectInfo']) + const data = (await this.$api.project.metaGet(this.$store.state.project.projectId)) copyTextToClipboard(Object.entries(data).map(([k, v]) => `${k}: **${v}**`).join('\n')) this.$toast.info('Copied project info to clipboard').goAway(3000) } catch (e) { diff --git a/packages/nocodb-sdk/src/lib/Api.ts b/packages/nocodb-sdk/src/lib/Api.ts index 13074b0e63..42521f3deb 100644 --- a/packages/nocodb-sdk/src/lib/Api.ts +++ b/packages/nocodb-sdk/src/lib/Api.ts @@ -3382,12 +3382,12 @@ export class Api< * @tags Api token * @name List * @summary Your GET endpoint - * @request GET:/api/v1/db/meta/projects/{projectId}/apiTokens + * @request GET:/api/v1/db/meta/projects/{projectId}/api-tokens * @response `200` `(ApiTokenType)[]` OK */ list: (projectId: string, params: RequestParams = {}) => this.request({ - path: `/api/v1/db/meta/projects/${projectId}/apiTokens`, + path: `/api/v1/db/meta/projects/${projectId}/api-tokens`, method: 'GET', format: 'json', ...params, @@ -3398,7 +3398,7 @@ export class Api< * * @tags Api token * @name Create - * @request POST:/api/v1/db/meta/projects/{projectId}/apiTokens + * @request POST:/api/v1/db/meta/projects/{projectId}/api-tokens * @response `200` `void` OK * @response `201` `ApiTokenType` Created */ @@ -3408,7 +3408,7 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/api/v1/db/meta/projects/${projectId}/apiTokens`, + path: `/api/v1/db/meta/projects/${projectId}/api-tokens`, method: 'POST', body: data, type: ContentType.Json, @@ -3420,12 +3420,12 @@ export class Api< * * @tags Api token * @name Delete - * @request DELETE:/api/v1/db/meta/projects/{projectId}/apiTokens/{token} + * @request DELETE:/api/v1/db/meta/projects/{projectId}/api-tokens/{token} * @response `200` `void` OK */ delete: (projectId: string, token: string, params: RequestParams = {}) => this.request({ - path: `/api/v1/db/meta/projects/${projectId}/apiTokens/${token}`, + path: `/api/v1/db/meta/projects/${projectId}/api-tokens/${token}`, method: 'DELETE', ...params, }), diff --git a/packages/nocodb/src/lib/noco/meta/api/apiTokenApis.ts b/packages/nocodb/src/lib/noco/meta/api/apiTokenApis.ts index 5a02a8bed7..ede14d3686 100644 --- a/packages/nocodb/src/lib/noco/meta/api/apiTokenApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/apiTokenApis.ts @@ -18,15 +18,15 @@ export async function apiTokenDelete(req: Request, res: Response) { const router = Router({ mergeParams: true }); router.get( - '/api/v1/db/meta/projects/:projectId/apiTokens', + '/api/v1/db/meta/projects/:projectId/api-tokens', ncMetaAclMw(apiTokenList, 'apiTokenList') ); router.post( - '/api/v1/db/meta/projects/:projectId/apiTokens', + '/api/v1/db/meta/projects/:projectId/api-tokens', ncMetaAclMw(apiTokenCreate, 'apiTokenCreate') ); router.delete( - '/api/v1/db/meta/projects/:projectId/apiTokens/:token', + '/api/v1/db/meta/projects/:projectId/api-tokens/:token', ncMetaAclMw(apiTokenDelete, 'apiTokenDelete') ); diff --git a/scripts/sdk/swagger.json b/scripts/sdk/swagger.json index c238d007ae..d9c15aff1e 100644 --- a/scripts/sdk/swagger.json +++ b/scripts/sdk/swagger.json @@ -4593,7 +4593,7 @@ "parameters": [] }, - "/api/v1/db/meta/projects/{projectId}/apiTokens": { + "/api/v1/db/meta/projects/{projectId}/api-tokens": { "get": { "summary": "Your GET endpoint", "tags": [ @@ -4663,7 +4663,7 @@ } ] }, - "/api/v1/db/meta/projects/{projectId}/apiTokens/{token}": { + "/api/v1/db/meta/projects/{projectId}/api-tokens/{token}": { "delete": { "summary": "", "operationId": "api-token-delete", From 2eb354fb4a3ee076dd2cc61881d253ec879e4258 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 13:32:49 +0530 Subject: [PATCH 46/81] refactor: shared view nested list api corrections Signed-off-by: Pranav C --- .../components/virtualCell/components/listChildItems.vue | 3 ++- .../src/lib/noco/meta/api/publicApis/publicDataApis.ts | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/components/listChildItems.vue b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/components/listChildItems.vue index 896aafc495..3a9d8fb7b9 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/components/listChildItems.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/components/listChildItems.vue @@ -184,7 +184,8 @@ export default { this.$route.params.id, this.rowId, this.column.colOptions.type, - this.column.fk_column_id || this.column.id, { + this.column.fk_column_id || this.column.id, + { limit: this.size, offset: this.size * (this.page - 1) }, {})) diff --git a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts index 17de3870c9..9b88d1dde0 100644 --- a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts @@ -320,7 +320,7 @@ router.get( catchError(dataList) ); router.post( - '/api/v1/db/public/shared-view/:sharedViewUuid/nested/:columnId', + '/api/v1/db/public/shared-view/:sharedViewUuid/rows/nested/:columnId', catchError(relDataList) ); router.post( @@ -332,11 +332,11 @@ router.post( ); router.get( - '/api/v1/db/public/shared-view/:sharedViewUuid/:rowId/mm/:colId', + '/api/v1/db/public/shared-view/:sharedViewUuid/rows/:rowId/mm/:colId', catchError(publicMmList) ); router.get( - '/api/v1/db/public/shared-view/:sharedViewUuid/:rowId/hm/:colId', + '/api/v1/db/public/shared-view/:sharedViewUuid/rows/:rowId/hm/:colId', catchError(publicHmList) ); From 655c1cebd5f170eca1f835db1d807e1ece376ed8 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 13:42:18 +0530 Subject: [PATCH 47/81] refactor: shared form view nested list api corrections Signed-off-by: Pranav C --- packages/nocodb-sdk/src/lib/Api.ts | 6 +++--- .../src/lib/noco/meta/api/publicApis/publicDataApis.ts | 4 ++-- scripts/sdk/swagger.json | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/nocodb-sdk/src/lib/Api.ts b/packages/nocodb-sdk/src/lib/Api.ts index 42521f3deb..00c92097e7 100644 --- a/packages/nocodb-sdk/src/lib/Api.ts +++ b/packages/nocodb-sdk/src/lib/Api.ts @@ -2971,7 +2971,7 @@ export class Api< * * @tags Public * @name DataRelationList - * @request POST:/api/v1/db/public/shared-view/{sharedViewUuid}/rows/nested/{columnName} + * @request GET:/api/v1/db/public/shared-view/{sharedViewUuid}/nested/{columnName} * @response `200` `any` OK */ dataRelationList: ( @@ -2981,8 +2981,8 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/api/v1/db/public/shared-view/${sharedViewUuid}/rows/nested/${columnName}`, - method: 'POST', + path: `/api/v1/db/public/shared-view/${sharedViewUuid}/nested/${columnName}`, + method: 'GET', query: query, format: 'json', ...params, diff --git a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts index 9b88d1dde0..6e77eb92c4 100644 --- a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts @@ -319,8 +319,8 @@ router.get( '/api/v1/db/public/shared-view/:sharedViewUuid/rows', catchError(dataList) ); -router.post( - '/api/v1/db/public/shared-view/:sharedViewUuid/rows/nested/:columnId', +router.get( + '/api/v1/db/public/shared-view/:sharedViewUuid/nested/:columnId', catchError(relDataList) ); router.post( diff --git a/scripts/sdk/swagger.json b/scripts/sdk/swagger.json index d9c15aff1e..8b35affff3 100644 --- a/scripts/sdk/swagger.json +++ b/scripts/sdk/swagger.json @@ -3695,7 +3695,7 @@ } } }, - "/api/v1/db/public/shared-view/{sharedViewUuid}/rows/nested/{columnName}": { + "/api/v1/db/public/shared-view/{sharedViewUuid}/nested/{columnName}": { "parameters": [ { "schema": { @@ -3722,7 +3722,7 @@ "description": "Shared view password" } ], - "post": { + "get": { "summary": "", "operationId": "public-data-relation-list", "responses": { From 5781953da5308d96ea08e1dda4a11a0165384240 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 13:49:55 +0530 Subject: [PATCH 48/81] refactor: shared view csv download api corrections Signed-off-by: Pranav C --- .../spreadsheet/components/moreActions.vue | 5 +++- packages/nocodb-sdk/src/lib/Api.ts | 7 ++--- .../api/publicApis/publicDataExportApis.ts | 5 +++- scripts/sdk/swagger.json | 30 ++----------------- 4 files changed, 12 insertions(+), 35 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/components/moreActions.vue b/packages/nc-gui/components/project/spreadsheet/components/moreActions.vue index 898824d813..fe5ad1faff 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/moreActions.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/moreActions.vue @@ -237,10 +237,13 @@ export default { while (!isNaN(offset) && offset > -1) { let res if (this.publicViewId) { - res = await this.$api.public.csvExport(this.publicViewId, ExportTypes.CSV, this.reqPayload, { + res = await this.$api.public.csvExport(this.publicViewId, ExportTypes.CSV, { responseType: 'blob', query: { offset + }, + headers: { + 'xc-password': this.reqPayload && this.reqPayload.password } }) } else { diff --git a/packages/nocodb-sdk/src/lib/Api.ts b/packages/nocodb-sdk/src/lib/Api.ts index 00c92097e7..f9f805339d 100644 --- a/packages/nocodb-sdk/src/lib/Api.ts +++ b/packages/nocodb-sdk/src/lib/Api.ts @@ -2948,20 +2948,17 @@ export class Api< * * @tags Public * @name CsvExport - * @request POST:/api/v1/db/public/shared-view/{sharedViewUuid}/rows/export/{type} + * @request GET:/api/v1/db/public/shared-view/{sharedViewUuid}/rows/export/{type} * @response `200` `any` OK */ csvExport: ( sharedViewUuid: string, type: 'csv' | 'excel', - data: { password?: string; filters?: FilterType[]; sorts?: SortType[] }, params: RequestParams = {} ) => this.request({ path: `/api/v1/db/public/shared-view/${sharedViewUuid}/rows/export/${type}`, - method: 'POST', - body: data, - type: ContentType.Json, + method: 'GET', wrapped: true, ...params, }), diff --git a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataExportApis.ts b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataExportApis.ts index 9a0434ec8e..4ffce25ba8 100644 --- a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataExportApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataExportApis.ts @@ -188,5 +188,8 @@ async function serializeCellValue({ } const router = Router({ mergeParams: true }); -router.post('/public/data/:publicDataUuid/export/csv', catchError(exportCsv)); +router.get( + '/api/v1/db/public/shared-view/:publicDataUuid/rows/export/csv', + catchError(exportCsv) +); export default router; diff --git a/scripts/sdk/swagger.json b/scripts/sdk/swagger.json index 8b35affff3..a7d75bf5d0 100644 --- a/scripts/sdk/swagger.json +++ b/scripts/sdk/swagger.json @@ -3642,7 +3642,7 @@ "required": true } ], - "post": { + "get": { "summary": "", "operationId": "public-csv-export", "description": "", @@ -3666,33 +3666,7 @@ }, "tags": [ "Public" - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "password": { - "type": "string" - }, - "filters": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Filter" - } - }, - "sorts": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Sort" - } - } - } - } - } - } - } + ] } }, "/api/v1/db/public/shared-view/{sharedViewUuid}/nested/{columnName}": { From 771bccd12ace75f41bfe04aeb18a5480fddb7e7d Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 14:00:34 +0530 Subject: [PATCH 49/81] refactor: virtual column delete api corrections Signed-off-by: Pranav C --- .../components/virtualCell/components/listItems.vue | 10 ++++------ .../spreadsheet/components/virtualHeaderCell.vue | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/components/listItems.vue b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/components/listItems.vue index 5a4513a65b..d29d828550 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/components/listItems.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/components/listItems.vue @@ -176,12 +176,10 @@ export default { 'noco', this.projectName, this.meta.title, { - query: { - limit: this.size, - offset: this.size * (this.page - 1), - ...this.queryParams, - where - } + limit: this.size, + offset: this.size * (this.page - 1), + ...this.queryParams, + where })) } } diff --git a/packages/nc-gui/components/project/spreadsheet/components/virtualHeaderCell.vue b/packages/nc-gui/components/project/spreadsheet/components/virtualHeaderCell.vue index e2a7efb829..1f88b99743 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualHeaderCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualHeaderCell.vue @@ -235,7 +235,7 @@ export default { methods: { async deleteColumn() { try { - await this.$api.dbTableColumn.delete(this.meta.id, this.column.id) + await this.$api.dbTableColumn.delete(this.column.id) this.$emit('saved') this.columnDeleteDialog = false } catch (e) { From 6bec85ad68161229b98f4870a8a3dddfd79b2d41 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 14:03:23 +0530 Subject: [PATCH 50/81] refactor: primary column set api corrections Signed-off-by: Pranav C --- .../components/project/spreadsheet/components/headerCell.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nc-gui/components/project/spreadsheet/components/headerCell.vue b/packages/nc-gui/components/project/spreadsheet/components/headerCell.vue index 666e3d1b7b..199a09283d 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/headerCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/headerCell.vue @@ -196,7 +196,7 @@ export default { async setAsPrimaryValue() { // todo: pass only updated fields try { - await this.$api.dbTableColumn.primaryColumnSet(this.meta.id, this.column.id) + await this.$api.dbTableColumn.primaryColumnSet(this.column.id) this.$toast.success('Successfully updated as primary column').goAway(3000) } catch (e) { console.log(e) From ebdb37effbd2f95cdad985e5e165ed0a702d3983 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Tue, 12 Apr 2022 17:02:54 +0800 Subject: [PATCH 51/81] fix: wrong env name Signed-off-by: Wing-Kam Wong --- .run/build.run.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.run/build.run.xml b/.run/build.run.xml index 10e00dff5c..81aa853d99 100644 --- a/.run/build.run.xml +++ b/.run/build.run.xml @@ -7,7 +7,7 @@
- +
From f64ab47f7ea8b9d7ce25b26de737684d3325ea9b Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Tue, 12 Apr 2022 17:19:06 +0800 Subject: [PATCH 52/81] fix: delete row api - ref: #1656 Signed-off-by: Wing-Kam Wong --- .../nc-gui/components/project/spreadsheet/rowsXcDataTable.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue b/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue index 15c3814764..5a975d49c6 100644 --- a/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue +++ b/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue @@ -1160,7 +1160,7 @@ export default { if (!id) { return this.$toast.info('Delete not allowed for table which doesn\'t have primary Key').goAway(3000) } - await this.$api.data.delete(this.meta.id, id) + await this.$api.dbViewRow.delete('noco', this.projectName, this.meta.title, this.selectedView.title, id) } this.data.splice(this.rowContextMenu.index, 1) // this.$toast.success('Deleted row successfully').goAway(3000) @@ -1186,7 +1186,7 @@ export default { if (!id) { return this.$toast.info('Delete not allowed for table which doesn\'t have primary Key').goAway(3000) } - await this.$api.data.delete(this.meta.id, id) + await this.$api.dbViewRow.delete('noco', this.projectName, this.meta.title, this.selectedView.title, id) } this.data.splice(row, 1) } catch (e) { From e52a4420ab3cf6269bee7006f450b2028a2ded0c Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 14:49:30 +0530 Subject: [PATCH 53/81] refactor: code cleanup Signed-off-by: Pranav C --- .../project/spreadsheet/public/xcKanban.vue | 1 - .../project/spreadsheet/public/xcTable.vue | 1 - .../project/spreadsheet/rowsXcDataTable.vue | 36 ------------------- .../project/spreadsheet/views/formView.vue | 5 +-- .../project/spreadsheet/views/xcGridView.vue | 3 -- packages/nc-gui/components/project/table.vue | 1 - 6 files changed, 3 insertions(+), 44 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/public/xcKanban.vue b/packages/nc-gui/components/project/spreadsheet/public/xcKanban.vue index dc61ca282c..dad14f9ab0 100644 --- a/packages/nc-gui/components/project/spreadsheet/public/xcKanban.vue +++ b/packages/nc-gui/components/project/spreadsheet/public/xcKanban.vue @@ -74,7 +74,6 @@ export default { props: { env: String, nodes: Object, - addNewRelationTab: Function, relationType: String, relation: Object, relationIdValue: [String, Number], diff --git a/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue b/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue index 5cdfd08bac..b7a5020302 100644 --- a/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue +++ b/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue @@ -147,7 +147,6 @@ export default { props: { env: String, nodes: Object, - addNewRelationTab: Function, relationType: String, relation: Object, relationIdValue: [String, Number], diff --git a/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue b/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue index 5a975d49c6..aedf97c155 100644 --- a/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue +++ b/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue @@ -357,7 +357,6 @@ @onCellValueChange="onCellValueChange" @insertNewRow="insertNewRow" @showRowContextMenu="showRowContextMenu" - @addNewRelationTab="addNewRelationTab" @expandRow="expandRow" @onRelationDelete="loadMeta" @loadTableData="loadTableData" @@ -602,24 +601,6 @@ Set column value to null - - c.title)) }, async updateColMeta(col, i) { + // todo: introduce debounce to avoid consecutive api call if (col.id) { await this.$api.dbView.formColumnUpdate(col.id, col) } diff --git a/packages/nc-gui/components/project/spreadsheet/views/xcGridView.vue b/packages/nc-gui/components/project/spreadsheet/views/xcGridView.vue index 7ab5c85a12..7ad448d35a 100644 --- a/packages/nc-gui/components/project/spreadsheet/views/xcGridView.vue +++ b/packages/nc-gui/components/project/spreadsheet/views/xcGridView.vue @@ -659,9 +659,6 @@ export default { this.selected.row-- } }, - addNewRelationTab(...args) { - this.$emit('addNewRelationTab', ...args) - }, makeSelected(col, row) { if (this.selected.col !== col || this.selected.row !== row) { this.selected = { diff --git a/packages/nc-gui/components/project/table.vue b/packages/nc-gui/components/project/table.vue index f3336fd2aa..f6a9c863b7 100644 --- a/packages/nc-gui/components/project/table.vue +++ b/packages/nc-gui/components/project/table.vue @@ -35,7 +35,6 @@ :mtd-new-table-update="mtdNewTableUpdate" :delete-table="deleteTable" :is-meta-table="isMetaTable" - :add-new-relation-tab="addNewRelationTab" /> From 81502ff5ef1894fa132fe0fd7def5d536d3aef9d Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 14:52:35 +0530 Subject: [PATCH 54/81] refactor: show all hide all api path update Signed-off-by: Pranav C --- packages/nocodb/src/lib/noco/meta/api/viewApis.ts | 4 ++-- scripts/sdk/swagger.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/nocodb/src/lib/noco/meta/api/viewApis.ts b/packages/nocodb/src/lib/noco/meta/api/viewApis.ts index 7602c999bf..42107db222 100644 --- a/packages/nocodb/src/lib/noco/meta/api/viewApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/viewApis.ts @@ -114,11 +114,11 @@ router.delete( ncMetaAclMw(viewDelete, 'viewDelete') ); router.post( - '/api/v1/db/meta/views/:viewId/showAll', + '/api/v1/db/meta/views/:viewId/show-all', ncMetaAclMw(showAllColumns, 'showAllColumns') ); router.post( - '/api/v1/db/meta/views/:viewId/hideAll', + '/api/v1/db/meta/views/:viewId/hide-all', ncMetaAclMw(hideAllColumns, 'hideAllColumns') ); diff --git a/scripts/sdk/swagger.json b/scripts/sdk/swagger.json index a7d75bf5d0..c54d27fc45 100644 --- a/scripts/sdk/swagger.json +++ b/scripts/sdk/swagger.json @@ -1367,7 +1367,7 @@ ] } }, - "/api/v1/db/meta/views/{viewId}/showAll": { + "/api/v1/db/meta/views/{viewId}/show-all": { "parameters": [ { "schema": { @@ -1401,7 +1401,7 @@ ] } }, - "/api/v1/db/meta/views/{viewId}/hideAll": { + "/api/v1/db/meta/views/{viewId}/hide-all": { "parameters": [ { "schema": { From bfdec7f9672915efba0a48dfdeef6cea16daf8e0 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 15:31:48 +0530 Subject: [PATCH 55/81] refactor: use view data apis in gridview and formview Signed-off-by: Pranav C --- .../project/spreadsheet/rowsXcDataTable.vue | 27 ++-- .../project/spreadsheet/views/formView.vue | 23 +-- scripts/sdk/swagger.json | 133 ------------------ 3 files changed, 23 insertions(+), 160 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue b/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue index aedf97c155..a4c75a65d3 100644 --- a/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue +++ b/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue @@ -1013,11 +1013,12 @@ export default { }, {}) // const insertedData = await this.api.insert(insertObj) - const insertedData = (await this.$api.dbTableRow.create( + const insertedData = await this.$api.dbViewRow.create( 'noco', this.projectName, - this.meta.title, insertObj - )) + this.meta.title, + this.selectedView.title, insertObj + ) this.data.splice(row, 1, { row: insertedData, @@ -1054,7 +1055,9 @@ export default { return } const { row: rowObj, rowMeta, oldRow, saving, lastSave } = this.data[row] - if (!lastSave) { this.$set(this.data[row], 'lastSave', rowObj[column.title]) } + if (!lastSave) { + this.$set(this.data[row], 'lastSave', rowObj[column.title]) + } if (rowMeta.new) { // return if there is no change if ((column && oldRow[column.title] === rowObj[column.title]) || saving) { @@ -1070,7 +1073,9 @@ export default { if (!column || (oldRow[column.title] === rowObj[column.title] && ((lastSave || rowObj[column.title]) === rowObj[column.title]))) { return } - if (saved) { this.$set(this.data[row], 'lastSave', oldRow[column.title]) } + if (saved) { + this.$set(this.data[row], 'lastSave', oldRow[column.title]) + } const id = this.meta.columns.filter(c => c.pk).map(c => rowObj[c.title]).join('___') if (!id) { @@ -1079,10 +1084,12 @@ export default { this.$set(this.data[row], 'saving', true) // eslint-disable-next-line promise/param-names - const newData = (await this.$api.dbTableRow.update( + const newData = (await this.$api.dbViewRow.update( 'noco', this.projectName, - this.meta.title, id, { + this.meta.title, + this.selectedView.title, + id, { [column.title]: rowObj[column.title] }, { query: { ignoreWebhook: !saved } @@ -1279,7 +1286,11 @@ export default { const { list, pageInfo - } = (await this.$api.dbViewRow.list('noco', this.projectName, this.meta.title, this.selectedView.title, + } = (await this.$api.dbViewRow.list( + 'noco', + this.projectName, + this.meta.title, + this.selectedView.title, { ...this.queryParams, ...(this._isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(this.sortList) }), diff --git a/packages/nc-gui/components/project/spreadsheet/views/formView.vue b/packages/nc-gui/components/project/spreadsheet/views/formView.vue index 9114d86e38..43dd4d4e0a 100644 --- a/packages/nc-gui/components/project/spreadsheet/views/formView.vue +++ b/packages/nc-gui/components/project/spreadsheet/views/formView.vue @@ -715,20 +715,6 @@ export default { }) ).sort((a, b) => a.order - b.order) }, - // async loadFormColumns() { - // this.formColumns = (await this.$api.meta.viewColumnList(this.viewId)) - // let order = 1 - // const fieldById = this.formColumns.reduce((o, f) => ({ ...o, [f.fk_column_id]: f }), {}) - // this.fields = this.meta.columns.map(c => ({ - // _cn: c.title, - // uidt: c.uidt, - // alias: c.title, - // fk_column_id: c.id, - // ...(fieldById[c.id] ? fieldById[c.id] : {}), - // order: (fieldById[c.id] && fieldById[c.id].order) || order++ - // }) - // ).sort((a, b) => a.order - b.order) - // }, hideColumn(i) { if (this.isDbRequired(this.columns[i])) { this.$toast.info('Required field can\'t be removed').goAway(3000) @@ -854,15 +840,14 @@ export default { this.loading = true - // todo: add params option in GraphQL - // let data = await this.api.insert(this.localState, { params: { form: this.$route.query.view } }) - let data = await this.$api.dbTableRow.create( + let data = await this.$api.dbViewRow.create( 'noco', this.projectName, this.meta.title, - this.localState, - { query: { form: this.$route.query.view } } + this.selectedView.title, + this.localState ) + data = { ...this.localState, ...data } // save hasmany and manytomany relations from local state diff --git a/scripts/sdk/swagger.json b/scripts/sdk/swagger.json index c54d27fc45..c945c05408 100644 --- a/scripts/sdk/swagger.json +++ b/scripts/sdk/swagger.json @@ -1137,29 +1137,6 @@ "required": true } ], - "get": { - "summary": "Column List", - "operationId": "db-table-column-list", - "responses": { - "200": { - "$ref": "#/components/responses/ColumnList" - }, - "201": { - "description": "Created", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Column" - } - } - } - } - }, - "description": "Read project details", - "tags": [ - "DB Table column" - ] - }, "post": { "summary": "Column create", "operationId": "db-table-column-create", @@ -1193,26 +1170,6 @@ "required": true } ], - "get": { - "summary": "Column Read", - "operationId": "db-table-column-read", - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Column" - } - } - } - } - }, - "description": "Read project details", - "tags": [ - "DB Table column" - ] - }, "patch": { "summary": "Column Update", "operationId": "db-table-column-update", @@ -1610,23 +1567,6 @@ "required": true } ], - "get": { - "summary": "", - "operationId": "db-view-column-read", - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": {} - } - } - } - }, - "tags": [ - "DB View Column" - ] - }, "patch": { "summary": "", "operationId": "db-view-column-update", @@ -3546,79 +3486,6 @@ ] } }, - "/api/v1/db/public/shared-view/{sharedViewUuid}/rows/{rowId}/{relationType}/{columnName}/exclude": { - "parameters": [ - { - "schema": { - "type": "string" - }, - "name": "sharedViewUuid", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "rowId", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string", - "enum": [ - "mm", - "hm" - ] - }, - "name": "relationType", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "columnName", - "in": "path", - "required": true - } - ], - "get": { - "summary": "", - "operationId": "public-data-nested-excluded-list", - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": {} - } - } - } - }, - "tags": [ - "Public" - ], - "parameters": [ - { - "schema": { - "type": "string" - }, - "in": "query", - "name": "limit" - }, - { - "schema": { - "type": "string" - }, - "in": "query", - "name": "offset" - } - ] - } - }, "/api/v1/db/public/shared-view/{sharedViewUuid}/rows/export/{type}": { "parameters": [ { From 856d589240cb06e27d352add7dbdd6e01e3d3e1b Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Tue, 12 Apr 2022 18:16:34 +0800 Subject: [PATCH 56/81] fix: rm unncessary base id in model. ref: #1648, #1651 Signed-off-by: Wing-Kam Wong --- packages/nocodb/src/lib/noco-models/Model.ts | 28 ++++++-------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/packages/nocodb/src/lib/noco-models/Model.ts b/packages/nocodb/src/lib/noco-models/Model.ts index 0aa29efa19..5203e4aaec 100644 --- a/packages/nocodb/src/lib/noco-models/Model.ts +++ b/packages/nocodb/src/lib/noco-models/Model.ts @@ -130,7 +130,7 @@ export default class Model implements TableType { await NocoCache.appendToList( CacheScope.MODEL, - [projectId, baseId], + [projectId], `${CacheScope.MODEL}:${id}` ); @@ -163,10 +163,7 @@ export default class Model implements TableType { }, ncMeta = Noco.ncMeta ): Promise { - let modelList = await NocoCache.getList(CacheScope.MODEL, [ - project_id, - base_id - ]); + let modelList = await NocoCache.getList(CacheScope.MODEL, [project_id]); if (!modelList.length) { modelList = await ncMeta.metaList2( project_id, @@ -179,11 +176,7 @@ export default class Model implements TableType { } ); - await NocoCache.setList( - CacheScope.MODEL, - [project_id, base_id], - modelList - ); + await NocoCache.setList(CacheScope.MODEL, [project_id], modelList); } modelList.sort( (a, b) => @@ -214,11 +207,7 @@ export default class Model implements TableType { MetaTable.MODELS ); - await NocoCache.setList( - CacheScope.MODEL, - [project_id, db_alias], - modelList - ); + await NocoCache.setList(CacheScope.MODEL, [project_id], modelList); } return modelList.map(m => new Model(m)); @@ -437,10 +426,10 @@ export default class Model implements TableType { await ncMeta.metaDelete(null, null, MetaTable.MODELS, this.id); await NocoCache.del( - `${CacheScope.MODEL}:${this.project_id}:${this.base_id}:${this.id}` + `${CacheScope.MODEL}:${this.project_id}:${this.id}` ); await NocoCache.del( - `${CacheScope.MODEL}:${this.project_id}:${this.base_id}:${this.title}` + `${CacheScope.MODEL}:${this.project_id}:${this.title}` ); return true; } @@ -632,10 +621,9 @@ export default class Model implements TableType { ) { const modelId = project_id && - base_id && aliasOrId && (await NocoCache.get( - `${CacheScope.MODEL}:${project_id}:${base_id}:${aliasOrId}`, + `${CacheScope.MODEL}:${project_id}:${aliasOrId}`, CacheGetType.TYPE_OBJECT )); if (!modelId) { @@ -661,7 +649,7 @@ export default class Model implements TableType { } ); await NocoCache.set( - `${CacheScope.MODEL}:${project_id}:${base_id}:${aliasOrId}`, + `${CacheScope.MODEL}:${project_id}:${aliasOrId}`, model.id ); await NocoCache.set(`${CacheScope.MODEL}:${model.id}`, model); From 2edefd3c93da6f194591f387aeb5486e77aa3d82 Mon Sep 17 00:00:00 2001 From: Naveen MR Date: Tue, 12 Apr 2022 11:20:40 +0100 Subject: [PATCH 57/81] chore : build daily 4 times Signed-off-by: Naveen MR --- .github/workflows/release-nightly-dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-nightly-dev.yml b/.github/workflows/release-nightly-dev.yml index 8485655feb..f773437bb3 100644 --- a/.github/workflows/release-nightly-dev.yml +++ b/.github/workflows/release-nightly-dev.yml @@ -12,8 +12,8 @@ on: - DEV # - PROD schedule: - # at the end of every day - - cron: '0 0 * * *' + # every 6 hours + - cron: '0 */6 * * *' jobs: # enrich tag for nightly auto release From 24369efaab54869eb9ad7e9f83520ad5e5038b2c Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 16:19:53 +0530 Subject: [PATCH 58/81] refactor: update attachment apis Signed-off-by: Pranav C --- .../editableCell/editableAttachmentCell.vue | 13 +- packages/nocodb-sdk/src/lib/Api.ts | 132 ++++-------------- .../src/lib/noco/meta/api/attachmentApis.ts | 51 ++++--- .../meta/api/publicApis/publicDataApis.ts | 18 ++- scripts/sdk/swagger.json | 33 ++++- 5 files changed, 109 insertions(+), 138 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/components/editableCell/editableAttachmentCell.vue b/packages/nc-gui/components/project/spreadsheet/components/editableCell/editableAttachmentCell.vue index e35df9917d..e96d5f45fe 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/editableCell/editableAttachmentCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/editableCell/editableAttachmentCell.vue @@ -333,11 +333,14 @@ export default { this.uploading = true for (const file of this.$refs.file.files) { try { - - const data = await this.$api.dbView.upload(this.$store.state.project.projectId, this.viewId, { - files: file, - json: '{}' - }) + const data = await this.$api.dbViewRow.upload( + 'noco', + this.projectName, + this.meta.title, + this.column.title, { + files: file, + json: '{}' + }) this.localState.push(...data) } catch (e) { diff --git a/packages/nocodb-sdk/src/lib/Api.ts b/packages/nocodb-sdk/src/lib/Api.ts index f9f805339d..d3f6fcf87e 100644 --- a/packages/nocodb-sdk/src/lib/Api.ts +++ b/packages/nocodb-sdk/src/lib/Api.ts @@ -1449,23 +1449,6 @@ export class Api< }), }; dbTableColumn = { - /** - * @description Read project details - * - * @tags DB Table column - * @name List - * @summary Column List - * @request GET:/api/v1/db/meta/tables/{tableId}/columns - * @response `200` `ColumnListType` - * @response `201` `ColumnType` Created - */ - list: (tableId: string, params: RequestParams = {}) => - this.request({ - path: `/api/v1/db/meta/tables/${tableId}/columns`, - method: 'GET', - ...params, - }), - /** * No description * @@ -1488,23 +1471,6 @@ export class Api< ...params, }), - /** - * @description Read project details - * - * @tags DB Table column - * @name Read - * @summary Column Read - * @request GET:/api/v1/db/meta/columns/{columnId} - * @response `200` `ColumnType` OK - */ - read: (columnId: string, params: RequestParams = {}) => - this.request({ - path: `/api/v1/db/meta/columns/${columnId}`, - method: 'GET', - format: 'json', - ...params, - }), - /** * No description * @@ -1620,7 +1586,7 @@ export class Api< * * @tags DB View * @name ShowAllColumn - * @request POST:/api/v1/db/meta/views/{viewId}/showAll + * @request POST:/api/v1/db/meta/views/{viewId}/show-all * @response `200` `void` OK */ showAllColumn: ( @@ -1629,7 +1595,7 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/api/v1/db/meta/views/${viewId}/showAll`, + path: `/api/v1/db/meta/views/${viewId}/show-all`, method: 'POST', query: query, ...params, @@ -1640,7 +1606,7 @@ export class Api< * * @tags DB View * @name HideAllColumn - * @request POST:/api/v1/db/meta/views/{viewId}/hideAll + * @request POST:/api/v1/db/meta/views/{viewId}/hide-all * @response `200` `void` OK */ hideAllColumn: ( @@ -1649,7 +1615,7 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/api/v1/db/meta/views/${viewId}/hideAll`, + path: `/api/v1/db/meta/views/${viewId}/hide-all`, method: 'POST', query: query, ...params, @@ -1842,28 +1808,6 @@ export class Api< format: 'json', ...params, }), - - /** - * No description - * - * @tags DB View - * @name Upload - * @summary Attachment - * @request POST:/projects/{projectId}/views/{viewId}/upload - */ - upload: ( - projectId: string, - viewId: string, - data: { files?: any; json?: string }, - params: RequestParams = {} - ) => - this.request({ - path: `/projects/${projectId}/views/${viewId}/upload`, - method: 'POST', - body: data, - type: ContentType.FormData, - ...params, - }), }; dbViewShare = { /** @@ -1968,22 +1912,6 @@ export class Api< ...params, }), - /** - * No description - * - * @tags DB View Column - * @name Read - * @request GET:/api/v1/db/meta/views/{viewId}/columns/{columnId} - * @response `200` `any` OK - */ - read: (viewId: string, columnId: string, params: RequestParams = {}) => - this.request({ - path: `/api/v1/db/meta/views/${viewId}/columns/${columnId}`, - method: 'GET', - format: 'json', - ...params, - }), - /** * No description * @@ -2850,6 +2778,30 @@ export class Api< wrapped: true, ...params, }), + + /** + * No description + * + * @tags DB View row + * @name Upload + * @summary Attachment + * @request POST:/api/v1/db/data-attachment/{orgs}/{projectName}/{tableName}/{columnName} + */ + upload: ( + orgs: string, + projectName: string, + tableName: string, + columnName: string, + data: { files?: any; json?: string }, + params: RequestParams = {} + ) => + this.request({ + path: `/api/v1/db/data-attachment/${orgs}/${projectName}/${tableName}/${columnName}`, + method: 'POST', + body: data, + type: ContentType.FormData, + ...params, + }), }; public = { /** @@ -2883,14 +2835,14 @@ export class Api< */ dataCreate: ( sharedViewUuid: string, - data: any, + data: object, params: RequestParams = {} ) => this.request({ path: `/api/v1/db/public/shared-view/${sharedViewUuid}/rows`, method: 'POST', body: data, - type: ContentType.Json, + type: ContentType.FormData, format: 'json', ...params, }), @@ -2919,30 +2871,6 @@ export class Api< ...params, }), - /** - * No description - * - * @tags Public - * @name DataNestedExcludedList - * @request GET:/api/v1/db/public/shared-view/{sharedViewUuid}/rows/{rowId}/{relationType}/{columnName}/exclude - * @response `200` `any` OK - */ - dataNestedExcludedList: ( - sharedViewUuid: string, - rowId: string, - relationType: 'mm' | 'hm', - columnName: string, - query?: { limit?: string; offset?: string }, - params: RequestParams = {} - ) => - this.request({ - path: `/api/v1/db/public/shared-view/${sharedViewUuid}/rows/${rowId}/${relationType}/${columnName}/exclude`, - method: 'GET', - query: query, - format: 'json', - ...params, - }), - /** * No description * diff --git a/packages/nocodb/src/lib/noco/meta/api/attachmentApis.ts b/packages/nocodb/src/lib/noco/meta/api/attachmentApis.ts index b5604a2e21..386e59d0a6 100644 --- a/packages/nocodb/src/lib/noco/meta/api/attachmentApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/attachmentApis.ts @@ -12,12 +12,13 @@ import NcPluginMgrv2 from '../helpers/NcPluginMgrv2'; // const storageAdapter = new Local(); export async function upload(req: Request, res: Response) { - const destPath = path.join( - 'nc', - 'uploads', - req.params.projectId, - req.params.viewId - ); + const filePath = sanitizeUrlPath([ + req.params.orgs, + req.params.projectName, + req.params.tableName, + req.params.columnName + ]); + const destPath = path.join('nc', 'uploads', ...filePath); const storageAdapter = await NcPluginMgrv2.storageAdapter(); const attachments = await Promise.all( @@ -30,9 +31,9 @@ export async function upload(req: Request, res: Response) { ); if (!url) { - url = `${(req as any).ncSiteUrl}/download/${req.params.projectId}/${ - req.params.viewId - }/${fileName}`; + url = `${ + (req as any).ncSiteUrl + }/api/v1/db/data-attachment/${filePath.join('/')}/${fileName}`; } return { @@ -67,8 +68,10 @@ export async function fileRead(req, res) { path.join( 'nc', 'uploads', - req.params.projectId, - req.params.viewId, + req.params.orgs, + req.params.projectName, + req.params.tableName, + req.params.columnName, req.params.fileName ) ) @@ -82,15 +85,6 @@ export async function fileRead(req, res) { } const router = Router({ mergeParams: true }); -router.post( - '/projects/:projectId/views/:viewId/upload', - multer({ - storage: multer.diskStorage({}) - }).any(), - ncMetaAclMw(upload, 'upload') -); -router.get('/download/:projectId/:viewId/:fileName', catchError(fileRead)); - router.get(/^\/dl\/([^/]+)\/([^/]+)\/(.+)$/, async (req, res) => { try { // const type = mimetypes[path.extname(req.params.fileName).slice(1)] || 'text/plain'; @@ -122,4 +116,21 @@ router.get(/^\/dl\/([^/]+)\/([^/]+)\/(.+)$/, async (req, res) => { res.status(404).send('Not found'); } }); + +export function sanitizeUrlPath(paths) { + return paths.map(url => url.replace(/[/.?#]+/g, '_')); +} + +router.post( + '/api/v1/db/data-attachment/:orgs/:projectName/:tableName/:columnName', + multer({ + storage: multer.diskStorage({}) + }).any(), + ncMetaAclMw(upload, 'upload') +); +router.get( + '/api/v1/db/data-attachment/:orgs/:projectName/:tableName/:columnName/:fileName', + catchError(fileRead) +); + export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts index 6e77eb92c4..328ce70a8e 100644 --- a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts @@ -15,6 +15,7 @@ import path from 'path'; import { nanoid } from 'nanoid'; import { mimeIcons } from '../../../../utils/mimeTypes'; import slash from 'slash'; +import { sanitizeUrlPath } from '../attachmentApis'; export async function dataList(req: Request, res: Response) { try { @@ -83,6 +84,7 @@ async function dataInsert( id: view?.fk_model_id }); const base = await Base.get(model.base_id); + const project = await base.getProject(); const baseModel = await Model.getBaseModelSQL({ id: model.id, @@ -122,18 +124,26 @@ async function dataInsert( for (const file of req.files || []) { // remove `_` prefix and `[]` suffix const fieldName = file?.fieldname?.replace(/^_|\[\d*]$/g, ''); + + const filePath = sanitizeUrlPath([ + 'noco', + project.title, + model.title, + fieldName + ]); + if (fieldName in fields && fields[fieldName].uidt === UITypes.Attachment) { attachments[fieldName] = attachments[fieldName] || []; const fileName = `${nanoid(6)}_${file.originalname}`; let url = await storageAdapter.fileCreate( - slash(path.join('nc', 'uploads', base.project_id, view.id, fileName)), + slash(path.join('nc', 'uploads', ...filePath, fileName)), file ); if (!url) { - url = `${(req as any).ncSiteUrl}/download/${base.project_id}/${ - view.id - }/${fileName}`; + url = `${ + (req as any).ncSiteUrl + }/api/v1/db/data-attachment/${filePath.join('/')}/${fileName}`; } attachments[fieldName].push({ diff --git a/scripts/sdk/swagger.json b/scripts/sdk/swagger.json index c945c05408..6aca38d910 100644 --- a/scripts/sdk/swagger.json +++ b/scripts/sdk/swagger.json @@ -3282,13 +3282,13 @@ } }, - "/projects/{projectId}/views/{viewId}/upload": { + "/api/v1/db/data-attachment/{orgs}/{projectName}/{tableName}/{columnName}": { "post": { "summary": "Attachment", - "operationId": "db-view-upload", + "operationId": "db-view-row-upload", "responses": {}, "tags": [ - "DB View" + "DB View row" ], "requestBody": { "content": { @@ -3312,7 +3312,7 @@ "schema": { "type": "string" }, - "name": "projectId", + "name": "orgs", "in": "path", "required": true }, @@ -3320,7 +3320,23 @@ "schema": { "type": "string" }, - "name": "viewId", + "name": "projectName", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "tableName", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "columnName", "in": "path", "required": true } @@ -3395,8 +3411,11 @@ }, "requestBody": { "content": { - "application/json": { - "schema": {} + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { } + } } } }, From 7da6e5db345f4555124f4005305f9ba09b5f40ba Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Tue, 12 Apr 2022 19:05:30 +0800 Subject: [PATCH 59/81] fix: cache export Signed-off-by: Wing-Kam Wong --- .../components/project/spreadsheet/rowsXcDataTable.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue b/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue index a4c75a65d3..cbee6036fd 100644 --- a/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue +++ b/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue @@ -1497,13 +1497,13 @@ export default { async exportCache() { try { const data = (await this.$api.utils.cacheGet()) - if (!data.length) { + if (!data) { this.$toast.info('Cache is empty').goAway(3000) return } const blob = new Blob([JSON.stringify(data)], { type: 'text/plain;charset=utf-8' }) FileSaver.saveAs(blob, 'cache_exported.json') - this.$toast.info('Copied Cache to clipboard').goAway(3000) + this.$toast.info('Exported Cache Successfully').goAway(3000) } catch (e) { console.log(e) this.$toast.error(e.message).goAway(3000) @@ -1512,7 +1512,7 @@ export default { async deleteCache() { try { await this.$api.utils.cacheDelete() - this.$toast.info('Deleted Cache').goAway(3000) + this.$toast.info('Deleted Cache Successfully').goAway(3000) } catch (e) { console.log(e) this.$toast.error(e.message).goAway(3000) From c880e9012d8db5ba0f34fa01112862f4a3047d8a Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 17:19:00 +0530 Subject: [PATCH 60/81] fix: csv download with filter , sort and fields option re #1660 Signed-off-by: Pranav C --- .../spreadsheet/components/moreActions.vue | 11 ++++++- .../project/spreadsheet/public/xcTable.vue | 2 +- .../lib/dataMapper/lib/sql/BaseModelSqlv2.ts | 2 +- .../api/publicApis/publicDataExportApis.ts | 30 +++++++++++++------ 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/components/moreActions.vue b/packages/nc-gui/components/project/spreadsheet/components/moreActions.vue index fe5ad1faff..630f94eb7c 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/moreActions.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/moreActions.vue @@ -240,7 +240,16 @@ export default { res = await this.$api.public.csvExport(this.publicViewId, ExportTypes.CSV, { responseType: 'blob', query: { - offset + fields: this.queryParams && this.queryParams.fieldsOrder && this.queryParams.fieldsOrder.filter(c => this.queryParams.showFields[c]), + offset, + sortArrJson: JSON.stringify(this.reqPayload && this.reqPayload.sorts && this.reqPayload.sorts.map(({ + fk_column_id, + direction + }) => ({ + direction, + fk_column_id + }))), + filterArrJson: JSON.stringify(this.reqPayload && this.reqPayload.filters) }, headers: { 'xc-password': this.reqPayload && this.reqPayload.password diff --git a/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue b/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue index b7a5020302..fdbdd2ed5b 100644 --- a/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue +++ b/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue @@ -49,7 +49,7 @@ c.title), + fields: model.columns + .sort((c1, c2) => + Array.isArray(fields) + ? fields.indexOf(c1.title as any) - fields.indexOf(c2.title as any) + : 0 + ) + .filter( + c => + !fields || !Array.isArray(fields) || fields.includes(c.title as any) + ) + .map(c => c.title), data: csvRows }, { From 0efcc1b6f5d808d93a0a54bfce6fcd6802abea00 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Tue, 12 Apr 2022 19:49:49 +0800 Subject: [PATCH 61/81] fix: form issue Signed-off-by: Wing-Kam Wong --- .../components/project/spreadsheet/rowsXcDataTable.vue | 1 + .../components/project/spreadsheet/views/formView.vue | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue b/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue index cbee6036fd..5ce895da22 100644 --- a/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue +++ b/packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue @@ -438,6 +438,7 @@ :primary-value-column="primaryValueColumn" :form-params.sync="extraViewParams.formParams" :view.sync="selectedView" + :view-title="selectedView.title" @onNewColCreation="loadMeta(false)" /> diff --git a/packages/nc-gui/components/project/spreadsheet/views/formView.vue b/packages/nc-gui/components/project/spreadsheet/views/formView.vue index 43dd4d4e0a..a3b18c2b85 100644 --- a/packages/nc-gui/components/project/spreadsheet/views/formView.vue +++ b/packages/nc-gui/components/project/spreadsheet/views/formView.vue @@ -486,7 +486,7 @@ export default { 'meta', 'availableColumns', 'nodes', 'sqlUi', 'formParams', 'showFields', 'fieldsOrder', 'allColumns', 'dbAlias', - 'api', 'id', 'viewId' + 'api', 'id', 'viewId', 'viewTitle' ], data: () => ({ isVirtualCol, @@ -515,7 +515,7 @@ export default { if (!this.localParams || !this.localParams.fields || !this.localParams.fields[column.alias]) { continue } - if (!column.virtual && (((column.rqd || column.notnull) && !column.default) || (column.pk && !(column.ai || column.default)) || this.localParams.fields[column.alias].required)) { + if (!column.virtual && (((column.rqd || column.notnull) && !column.cdf) || (column.pk && !(column.ai || column.default)) || this.localParams.fields[column.alias].required)) { obj.localState[column.title] = { required } } else if (column.bt) { const col = this.meta.columns.find(c => c.column_name === column.bt.column_name) @@ -844,7 +844,7 @@ export default { 'noco', this.projectName, this.meta.title, - this.selectedView.title, + this.viewTitle, this.localState ) From c993058c74f8e597a488046e1a9225f7fbfa2184 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Tue, 12 Apr 2022 20:30:43 +0800 Subject: [PATCH 62/81] docs: update node version badge Signed-off-by: Wing-Kam Wong --- README.md | 2 +- scripts/markdown/readme/languages/chinese.md | 2 +- scripts/markdown/readme/languages/dutch.md | 2 +- scripts/markdown/readme/languages/french.md | 2 +- scripts/markdown/readme/languages/german.md | 2 +- scripts/markdown/readme/languages/indonesian.md | 2 +- scripts/markdown/readme/languages/italian.md | 2 +- scripts/markdown/readme/languages/japanese.md | 2 +- scripts/markdown/readme/languages/korean.md | 2 +- scripts/markdown/readme/languages/portuguese.md | 2 +- scripts/markdown/readme/languages/russian.md | 2 +- scripts/markdown/readme/languages/spanish.md | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 5fe00cd149..81a7be45ac 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Turns any MySQL, PostgreSQL, SQL Server, SQLite & MariaDB into a smart-spreadshe
[![Build Status](https://travis-ci.org/dwyl/esta.svg?branch=master)](https://travis-ci.com/github/NocoDB/NocoDB) -[![Node version](https://badgen.net/npm/node/next)](http://nodejs.org/download/) +[![Node version](https://img.shields.io/badge/node-%3E%3D%2014.18.0-brightgreen)](http://nodejs.org/download/) [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-green.svg)](https://conventionalcommits.org)
diff --git a/scripts/markdown/readme/languages/chinese.md b/scripts/markdown/readme/languages/chinese.md index 796a3888db..e324e52081 100644 --- a/scripts/markdown/readme/languages/chinese.md +++ b/scripts/markdown/readme/languages/chinese.md @@ -10,7 +10,7 @@
[![Build Status](https://travis-ci.org/dwyl/esta.svg?branch=master)](https://travis-ci.com/github/NocoDB/NocoDB) -[![Node version](https://badgen.net/npm/node/next)](http://nodejs.org/download/) +[![Node version](https://img.shields.io/badge/node-%3E%3D%2014.18.0-brightgreen)](http://nodejs.org/download/) [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-green.svg)](https://conventionalcommits.org)
diff --git a/scripts/markdown/readme/languages/dutch.md b/scripts/markdown/readme/languages/dutch.md index 19eece6b8e..d08f6fdf15 100644 --- a/scripts/markdown/readme/languages/dutch.md +++ b/scripts/markdown/readme/languages/dutch.md @@ -11,7 +11,7 @@ Draait elke MySQL, PostgreSQL, SQL Server, SQLITE & MARIADB in een Smart-Spreads
[![Build Status](https://travis-ci.org/dwyl/esta.svg?branch=master)](https://travis-ci.com/github/NocoDB/NocoDB) -[![Node version](https://badgen.net/npm/node/next)](http://nodejs.org/download/) +[![Node version](https://img.shields.io/badge/node-%3E%3D%2014.18.0-brightgreen)](http://nodejs.org/download/) [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-green.svg)](https://conventionalcommits.org)
diff --git a/scripts/markdown/readme/languages/french.md b/scripts/markdown/readme/languages/french.md index dc8f4e972a..2f6b14d089 100644 --- a/scripts/markdown/readme/languages/french.md +++ b/scripts/markdown/readme/languages/french.md @@ -11,7 +11,7 @@ Tournez n'importe quel MySQL, PostgreSQL, SQL Server, SQLite & Mariadb dans une
[![Build Status](https://travis-ci.org/dwyl/esta.svg?branch=master)](https://travis-ci.com/github/NocoDB/NocoDB) -[![Node version](https://badgen.net/npm/node/next)](http://nodejs.org/download/) +[![Node version](https://img.shields.io/badge/node-%3E%3D%2014.18.0-brightgreen)](http://nodejs.org/download/) [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-green.svg)](https://conventionalcommits.org)
diff --git a/scripts/markdown/readme/languages/german.md b/scripts/markdown/readme/languages/german.md index f7d6eefedf..c3decc7258 100644 --- a/scripts/markdown/readme/languages/german.md +++ b/scripts/markdown/readme/languages/german.md @@ -11,7 +11,7 @@ Verwandelt jeden MySQL, PostgreSQL, SQL Server, SQLite & MariaDB in eine Smart-T
[![Build Status](https://travis-ci.org/dwyl/esta.svg?branch=master)](https://travis-ci.com/github/NocoDB/NocoDB) -[![Node version](https://badgen.net/npm/node/next)](http://nodejs.org/download/) +[![Node version](https://img.shields.io/badge/node-%3E%3D%2014.18.0-brightgreen)](http://nodejs.org/download/) [![Twitter](https://img.shields.io/twitter/url/https/twitter.com/NocoDB.svg?style=social&label=Follow%20%40NocoDB)](https://twitter.com/NocoDB)
diff --git a/scripts/markdown/readme/languages/indonesian.md b/scripts/markdown/readme/languages/indonesian.md index 7a53acdcdd..8f0dfedd91 100644 --- a/scripts/markdown/readme/languages/indonesian.md +++ b/scripts/markdown/readme/languages/indonesian.md @@ -11,7 +11,7 @@ Mengubah MySQL, PostgreSQL, SQL Server, SQLite & MariaDB apapun menjadi spreadsh
[![Build Status](https://travis-ci.org/dwyl/esta.svg?branch=master)](https://travis-ci.com/github/NocoDB/NocoDB) -[![Node version](https://badgen.net/npm/node/next)](http://nodejs.org/download/) +[![Node version](https://img.shields.io/badge/node-%3E%3D%2014.18.0-brightgreen)](http://nodejs.org/download/) [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-green.svg)](https://conventionalcommits.org)
diff --git a/scripts/markdown/readme/languages/italian.md b/scripts/markdown/readme/languages/italian.md index 50b59880fd..f33566f054 100644 --- a/scripts/markdown/readme/languages/italian.md +++ b/scripts/markdown/readme/languages/italian.md @@ -11,7 +11,7 @@ Trasforma qualsiasi MySQL, PostgreSQL, SQL Server, SQLite & Mariadb in un foglio
[![Build Status](https://travis-ci.org/dwyl/esta.svg?branch=master)](https://travis-ci.com/github/NocoDB/NocoDB) -[![Node version](https://badgen.net/npm/node/next)](http://nodejs.org/download/) +[![Node version](https://img.shields.io/badge/node-%3E%3D%2014.18.0-brightgreen)](http://nodejs.org/download/) [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-green.svg)](https://conventionalcommits.org)
diff --git a/scripts/markdown/readme/languages/japanese.md b/scripts/markdown/readme/languages/japanese.md index 6852ec8172..03f1e32819 100644 --- a/scripts/markdown/readme/languages/japanese.md +++ b/scripts/markdown/readme/languages/japanese.md @@ -11,7 +11,7 @@ MySQL、PostgreSQL、SQL Server、SQLite&Mariadbをスマートスプレッド
[![Build Status](https://travis-ci.org/dwyl/esta.svg?branch=master)](https://travis-ci.com/github/NocoDB/NocoDB) -[![Node version](https://badgen.net/npm/node/next)](http://nodejs.org/download/) +[![Node version](https://img.shields.io/badge/node-%3E%3D%2014.18.0-brightgreen)](http://nodejs.org/download/) [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-green.svg)](https://conventionalcommits.org)
diff --git a/scripts/markdown/readme/languages/korean.md b/scripts/markdown/readme/languages/korean.md index 917ba3dc71..d424c22101 100644 --- a/scripts/markdown/readme/languages/korean.md +++ b/scripts/markdown/readme/languages/korean.md @@ -12,7 +12,7 @@ MySQL, PostgreSQL, SQL Server, SQLite, MariaDB를 똑똑한 스프레드시트
[![Build Status](https://travis-ci.org/dwyl/esta.svg?branch=master)](https://travis-ci.com/github/NocoDB/NocoDB) -[![Node version](https://badgen.net/npm/node/next)](http://nodejs.org/download/) +[![Node version](https://img.shields.io/badge/node-%3E%3D%2014.18.0-brightgreen)](http://nodejs.org/download/) [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-green.svg)](https://conventionalcommits.org)
diff --git a/scripts/markdown/readme/languages/portuguese.md b/scripts/markdown/readme/languages/portuguese.md index c09cc75823..b0af3efc3c 100644 --- a/scripts/markdown/readme/languages/portuguese.md +++ b/scripts/markdown/readme/languages/portuguese.md @@ -11,7 +11,7 @@ Transforma qualquer MySQL, PostgreSQL, SQL Server, Sqlite e MariaDB em uma plani
[![Build Status](https://travis-ci.org/dwyl/esta.svg?branch=master)](https://travis-ci.com/github/NocoDB/NocoDB) -[![Node version](https://badgen.net/npm/node/next)](http://nodejs.org/download/) +[![Node version](https://img.shields.io/badge/node-%3E%3D%2014.18.0-brightgreen)](http://nodejs.org/download/) [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-green.svg)](https://conventionalcommits.org)
diff --git a/scripts/markdown/readme/languages/russian.md b/scripts/markdown/readme/languages/russian.md index f8b4028d98..e1fe2cba40 100644 --- a/scripts/markdown/readme/languages/russian.md +++ b/scripts/markdown/readme/languages/russian.md @@ -11,7 +11,7 @@
[![Build Status](https://travis-ci.org/dwyl/esta.svg?branch=master)](https://travis-ci.com/github/NocoDB/NocoDB) -[![Node version](https://badgen.net/npm/node/next)](http://nodejs.org/download/) +[![Node version](https://img.shields.io/badge/node-%3E%3D%2014.18.0-brightgreen)](http://nodejs.org/download/) [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-green.svg)](https://conventionalcommits.org)
diff --git a/scripts/markdown/readme/languages/spanish.md b/scripts/markdown/readme/languages/spanish.md index 479fbb3f1e..a2c1e63822 100644 --- a/scripts/markdown/readme/languages/spanish.md +++ b/scripts/markdown/readme/languages/spanish.md @@ -11,7 +11,7 @@ Convierte cualquier MySQL, PostgreSQL, SQL Server, SQLite y Mariadb en una hoja
[![Build Status](https://travis-ci.org/dwyl/esta.svg?branch=master)](https://travis-ci.com/github/NocoDB/NocoDB) -[![Node version](https://badgen.net/npm/node/next)](http://nodejs.org/download/) +[![Node version](https://img.shields.io/badge/node-%3E%3D%2014.18.0-brightgreen)](http://nodejs.org/download/) [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-green.svg)](https://conventionalcommits.org)
From e9f730de15fdd58e85d745066b6998aba959de98 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 18:06:47 +0530 Subject: [PATCH 63/81] refactor: redesign update attachment api Signed-off-by: Pranav C --- .../editableCell/editableAttachmentCell.vue | 12 +-- packages/nocodb-sdk/src/lib/Api.ts | 47 +++++---- .../src/lib/noco/meta/api/attachmentApis.ts | 35 +++---- .../meta/api/publicApis/publicDataApis.ts | 6 +- packages/nocodb/src/lib/utils/projectAcl.ts | 2 + scripts/sdk/swagger.json | 99 +++++++------------ 6 files changed, 85 insertions(+), 116 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/components/editableCell/editableAttachmentCell.vue b/packages/nc-gui/components/project/spreadsheet/components/editableCell/editableAttachmentCell.vue index e96d5f45fe..ad4c439a74 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/editableCell/editableAttachmentCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/editableCell/editableAttachmentCell.vue @@ -333,14 +333,14 @@ export default { this.uploading = true for (const file of this.$refs.file.files) { try { - const data = await this.$api.dbViewRow.upload( - 'noco', - this.projectName, - this.meta.title, - this.column.title, { + const data = await this.$api.storage.upload( + { + path: ['noco', this.projectName, this.meta.title, this.column.title].join('/') + }, { files: file, json: '{}' - }) + } + ) this.localState.push(...data) } catch (e) { diff --git a/packages/nocodb-sdk/src/lib/Api.ts b/packages/nocodb-sdk/src/lib/Api.ts index d3f6fcf87e..d94d2297f3 100644 --- a/packages/nocodb-sdk/src/lib/Api.ts +++ b/packages/nocodb-sdk/src/lib/Api.ts @@ -2778,30 +2778,6 @@ export class Api< wrapped: true, ...params, }), - - /** - * No description - * - * @tags DB View row - * @name Upload - * @summary Attachment - * @request POST:/api/v1/db/data-attachment/{orgs}/{projectName}/{tableName}/{columnName} - */ - upload: ( - orgs: string, - projectName: string, - tableName: string, - columnName: string, - data: { files?: any; json?: string }, - params: RequestParams = {} - ) => - this.request({ - path: `/api/v1/db/data-attachment/${orgs}/${projectName}/${tableName}/${columnName}`, - method: 'POST', - body: data, - type: ContentType.FormData, - ...params, - }), }; public = { /** @@ -3355,4 +3331,27 @@ export class Api< ...params, }), }; + storage = { + /** + * No description + * + * @tags Storage + * @name Upload + * @summary Attachment + * @request POST:/api/v1/db/storage/upload + */ + upload: ( + query: { path: string }, + data: { files?: any; json?: string }, + params: RequestParams = {} + ) => + this.request({ + path: `/api/v1/db/storage/upload`, + method: 'POST', + query: query, + body: data, + type: ContentType.FormData, + ...params, + }), + }; } diff --git a/packages/nocodb/src/lib/noco/meta/api/attachmentApis.ts b/packages/nocodb/src/lib/noco/meta/api/attachmentApis.ts index 386e59d0a6..6464f4f7a6 100644 --- a/packages/nocodb/src/lib/noco/meta/api/attachmentApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/attachmentApis.ts @@ -12,12 +12,9 @@ import NcPluginMgrv2 from '../helpers/NcPluginMgrv2'; // const storageAdapter = new Local(); export async function upload(req: Request, res: Response) { - const filePath = sanitizeUrlPath([ - req.params.orgs, - req.params.projectName, - req.params.tableName, - req.params.columnName - ]); + const filePath = sanitizeUrlPath( + req.query?.path?.toString()?.split('/') || [''] + ); const destPath = path.join('nc', 'uploads', ...filePath); const storageAdapter = await NcPluginMgrv2.storageAdapter(); @@ -31,9 +28,9 @@ export async function upload(req: Request, res: Response) { ); if (!url) { - url = `${ - (req as any).ncSiteUrl - }/api/v1/db/data-attachment/${filePath.join('/')}/${fileName}`; + url = `${(req as any).ncSiteUrl}/download/${filePath.join( + '/' + )}/${fileName}`; } return { @@ -53,11 +50,11 @@ export async function upload(req: Request, res: Response) { export async function fileRead(req, res) { try { const storageAdapter = await NcPluginMgrv2.storageAdapter(); - // const type = mimetypes[path.extname(req.params.fileName).slice(1)] || 'text/plain'; + // const type = mimetypes[path.extname(req.s.fileName).slice(1)] || 'text/plain'; const type = mimetypes[ path - .extname(req.params.fileName) + .extname(req.params?.[0]) .split('/') .pop() .slice(1) @@ -68,11 +65,10 @@ export async function fileRead(req, res) { path.join( 'nc', 'uploads', - req.params.orgs, - req.params.projectName, - req.params.tableName, - req.params.columnName, - req.params.fileName + req.params?.[0] + ?.split('/') + .filter(p => p !== '..') + .join('/') ) ) ); @@ -122,15 +118,12 @@ export function sanitizeUrlPath(paths) { } router.post( - '/api/v1/db/data-attachment/:orgs/:projectName/:tableName/:columnName', + '/api/v1/db/storage/upload', multer({ storage: multer.diskStorage({}) }).any(), ncMetaAclMw(upload, 'upload') ); -router.get( - '/api/v1/db/data-attachment/:orgs/:projectName/:tableName/:columnName/:fileName', - catchError(fileRead) -); +router.get(/^\/download\/(.+)$/, catchError(fileRead)); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts index 328ce70a8e..6e00734fb5 100644 --- a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts @@ -141,9 +141,9 @@ async function dataInsert( ); if (!url) { - url = `${ - (req as any).ncSiteUrl - }/api/v1/db/data-attachment/${filePath.join('/')}/${fileName}`; + url = `${(req as any).ncSiteUrl}/download/${filePath.join( + '/' + )}/${fileName}`; } attachments[fieldName].push({ diff --git a/packages/nocodb/src/lib/utils/projectAcl.ts b/packages/nocodb/src/lib/utils/projectAcl.ts index a86c8818d1..9fac3569e0 100644 --- a/packages/nocodb/src/lib/utils/projectAcl.ts +++ b/packages/nocodb/src/lib/utils/projectAcl.ts @@ -208,7 +208,9 @@ export default { passwordChange: true, projectList: true }, + super: '*', user: { + upload: true, passwordChange: true, pluginList: true, pluginRead: true, diff --git a/scripts/sdk/swagger.json b/scripts/sdk/swagger.json index 6aca38d910..3f9a249878 100644 --- a/scripts/sdk/swagger.json +++ b/scripts/sdk/swagger.json @@ -3282,68 +3282,6 @@ } }, - "/api/v1/db/data-attachment/{orgs}/{projectName}/{tableName}/{columnName}": { - "post": { - "summary": "Attachment", - "operationId": "db-view-row-upload", - "responses": {}, - "tags": [ - "DB View row" - ], - "requestBody": { - "content": { - "multipart/form-data": { - "schema": { - "type": "object", - "properties": { - "files": {}, - "json": { - "type": "string" - } - } - } - } - }, - "description": "" - } - }, - "parameters": [ - { - "schema": { - "type": "string" - }, - "name": "orgs", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "projectName", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "tableName", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "columnName", - "in": "path", - "required": true - } - ] - }, - - "/api/v1/db/public/shared-view/{sharedViewUuid}/rows": { "parameters": [ { @@ -4749,6 +4687,43 @@ "DB Table Row" ] } + }, + + "/api/v1/db/storage/upload": { + "post": { + "summary": "Attachment", + "operationId": "storage-upload", + "responses": {}, + "tags": [ + "Storage" + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "files": {}, + "json": { + "type": "string" + } + } + } + } + }, + "description": "" + }, + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "path", + "in": "query", + "required": true + } + ] + } } }, "components": { From 1c4d470782acd9e635d4106d38bca04da6047c65 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 18:54:00 +0530 Subject: [PATCH 64/81] fix: hide relation column with associative table(mm) Signed-off-by: Pranav C --- packages/nocodb/src/lib/noco-models/Column.ts | 26 +++++++++++++++++++ .../src/lib/noco/meta/api/metaDiffApis.ts | 26 ++++++++++++++++++- scripts/sdk/swagger.json | 4 +-- 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/packages/nocodb/src/lib/noco-models/Column.ts b/packages/nocodb/src/lib/noco-models/Column.ts index d7f367877d..bd1b06f3c3 100644 --- a/packages/nocodb/src/lib/noco-models/Column.ts +++ b/packages/nocodb/src/lib/noco-models/Column.ts @@ -878,4 +878,30 @@ export default class Column implements ColumnType { exclude_id && { id: { neq: exclude_id } } )); } + + static async markAsSystemField( + colId: string, + system = true, + ncMeta = Noco.ncMeta + ) { + // get existing cache + const key = `${CacheScope.COLUMN}:${colId}`; + const o = await NocoCache.get(key, CacheGetType.TYPE_OBJECT); + if (o) { + // update data + o.system = system; + // set cache + await NocoCache.set(key, o); + } + // update system field in meta db + await ncMeta.metaUpdate( + null, + null, + MetaTable.COLUMNS, + { + system + }, + colId + ); + } } diff --git a/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts b/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts index 1837a46d16..c33b1cb920 100644 --- a/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts @@ -17,6 +17,7 @@ import UITypes from '../../../sqlUi/UITypes'; import mapDefaultPrimaryValue from '../helpers/mapDefaultPrimaryValue'; import { Tele } from 'nc-help'; import getColumnUiType from '../helpers/getColumnUiType'; + export enum MetaDiffType { TABLE_NEW = 'TABLE_NEW', TABLE_REMOVE = 'TABLE_REMOVE', @@ -730,6 +731,7 @@ async function isMMRelationAvailable( if (col.uidt === UITypes.LinkToAnotherRecord) { const colOpt = await col.getColOptions(); if ( + colOpt && colOpt.type === RelationTypes.MANY_TO_MANY && colOpt.fk_mm_model_id === assocModel.id && colOpt.fk_child_column_id === colChildOpt.fk_parent_column_id && @@ -761,7 +763,7 @@ export async function extractAndGenerateManyToManyRelations( } } - // todo: impl proper way to identify m2m relation + // todo: impl better method to identify m2m relation if (belongsToCols?.length === 2 && normalColumns.length < 5) { const modelA = await belongsToCols[0].colOptions.getRelatedTable(); const modelB = await belongsToCols[1].colOptions.getRelatedTable(); @@ -819,6 +821,28 @@ export async function extractAndGenerateManyToManyRelations( } await Model.markAsMmTable(assocModel.id, true); + + // mark has many relation associated with mm as system field in both table + for (const btCol of [belongsToCols[0], belongsToCols[1]]) { + const colOpt = await btCol.colOptions; + const model = await colOpt.getRelatedTable(); + + for (const col of await model.getColumns()) { + if (col.uidt !== UITypes.LinkToAnotherRecord) continue; + + const colOpt1 = await col.getColOptions(); + if (!colOpt1 || colOpt1.type !== RelationTypes.HAS_MANY) continue; + + if ( + colOpt1.fk_child_column_id !== colOpt.fk_child_column_id && + colOpt1.fk_parent_column_id !== colOpt.fk_parent_column_id + ) + continue; + + await Column.markAsSystemField(col.id); + break; + } + } } else { if (assocModel.mm) await Model.markAsMmTable(assocModel.id, false); } diff --git a/scripts/sdk/swagger.json b/scripts/sdk/swagger.json index 3f9a249878..ccb1286edd 100644 --- a/scripts/sdk/swagger.json +++ b/scripts/sdk/swagger.json @@ -1865,13 +1865,13 @@ ] } }, - "/api/v1/db/meta/filters/{filterParentId}/children": { + "/api/v1/db/meta/filters/{filterGroupId}/children": { "parameters": [ { "schema": { "type": "string" }, - "name": "filterParentId", + "name": "filterGroupId", "in": "path", "required": true } From a71819b06a0c0d8523212ebf44e57c0f3e2e52cc Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 19:08:18 +0530 Subject: [PATCH 65/81] refactor: api path params name update Signed-off-by: Pranav C --- packages/nocodb-sdk/src/lib/Api.ts | 20 +++++++++---------- .../meta/api/dataApis/bulkDataAliasApis.ts | 10 +++++----- .../lib/noco/meta/api/formViewColumnApis.ts | 2 +- .../lib/noco/meta/api/gridViewColumnApis.ts | 4 ++-- scripts/sdk/swagger.json | 12 +++++------ 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/packages/nocodb-sdk/src/lib/Api.ts b/packages/nocodb-sdk/src/lib/Api.ts index d94d2297f3..eac3945d1a 100644 --- a/packages/nocodb-sdk/src/lib/Api.ts +++ b/packages/nocodb-sdk/src/lib/Api.ts @@ -1695,7 +1695,7 @@ export class Api< * * @tags DB View * @name FormColumnUpdate - * @request PATCH:/api/v1/db/meta/form/columns/{formViewColumnId} + * @request PATCH:/api/v1/db/meta/form-columns/{formViewColumnId} * @response `200` `any` OK */ formColumnUpdate: ( @@ -1704,7 +1704,7 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/api/v1/db/meta/form/columns/${formViewColumnId}`, + path: `/api/v1/db/meta/form-columns/${formViewColumnId}`, method: 'PATCH', body: data, type: ContentType.Json, @@ -1717,12 +1717,12 @@ export class Api< * * @tags DB View * @name GridColumnsList - * @request GET:/api/v1/db/meta/grids/{gidId}/grid/columns + * @request GET:/api/v1/db/meta/grids/{gridId}/grid-columns * @response `200` `(GridColumnType)[]` OK */ - gridColumnsList: (gidId: string, params: RequestParams = {}) => + gridColumnsList: (gridId: string, params: RequestParams = {}) => this.request({ - path: `/api/v1/db/meta/grids/${gidId}/grid/columns`, + path: `/api/v1/db/meta/grids/${gridId}/grid-columns`, method: 'GET', format: 'json', ...params, @@ -1733,7 +1733,7 @@ export class Api< * * @tags DB View * @name GridColumnUpdate - * @request PATCH:/api/v1/db/meta/grid/columns/{columnId} + * @request PATCH:/api/v1/db/meta/grid-columns/{columnId} * @response `200` `any` OK */ gridColumnUpdate: ( @@ -1742,7 +1742,7 @@ export class Api< params: RequestParams = {} ) => this.request({ - path: `/api/v1/db/meta/grid/columns/${columnId}`, + path: `/api/v1/db/meta/grid-columns/${columnId}`, method: 'PATCH', body: data, type: ContentType.Json, @@ -2102,12 +2102,12 @@ export class Api< * * @tags DB Table Filter * @name ChildrenRead - * @request GET:/api/v1/db/meta/filters/{filterParentId}/children + * @request GET:/api/v1/db/meta/filters/{filterGroupId}/children * @response `200` `FilterType` OK */ - childrenRead: (filterParentId: string, params: RequestParams = {}) => + childrenRead: (filterGroupId: string, params: RequestParams = {}) => this.request({ - path: `/api/v1/db/meta/filters/${filterParentId}/children`, + path: `/api/v1/db/meta/filters/${filterGroupId}/children`, method: 'GET', format: 'json', ...params, diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/bulkDataAliasApis.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/bulkDataAliasApis.ts index da81a2df3e..18fe0b1434 100644 --- a/packages/nocodb/src/lib/noco/meta/api/dataApis/bulkDataAliasApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/bulkDataAliasApis.ts @@ -91,23 +91,23 @@ async function getViewAndModelFromRequest(req) { const router = Router({ mergeParams: true }); router.post( - '/bulkData/:orgs/:projectName/:tableAlias', + '/api/v1/db/bulkData/:orgs/:projectName/:tableAlias', ncMetaAclMw(bulkDataInsert, 'bulkDataInsert') ); router.patch( - '/bulkData/:orgs/:projectName/:tableAlias', + '/api/v1/db/bulkData/:orgs/:projectName/:tableAlias', ncMetaAclMw(bulkDataUpdate, 'bulkDataUpdate') ); router.patch( - '/bulkData/:orgs/:projectName/:tableAlias/all', + '/api/v1/db/bulkData/:orgs/:projectName/:tableAlias/all', ncMetaAclMw(bulkDataUpdateAll, 'bulkDataUpdateAll') ); router.delete( - '/bulkData/:orgs/:projectName/:tableAlias', + '/api/v1/db/bulkData/:orgs/:projectName/:tableAlias', ncMetaAclMw(bulkDataDelete, 'bulkDataDelete') ); router.delete( - '/bulkData/:orgs/:projectName/:tableAlias/all', + '/api/v1/db/bulkData/:orgs/:projectName/:tableAlias/all', ncMetaAclMw(bulkDataDeleteAll, 'bulkDataDeleteAll') ); diff --git a/packages/nocodb/src/lib/noco/meta/api/formViewColumnApis.ts b/packages/nocodb/src/lib/noco/meta/api/formViewColumnApis.ts index 879ef33f56..85fc44d8a3 100644 --- a/packages/nocodb/src/lib/noco/meta/api/formViewColumnApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/formViewColumnApis.ts @@ -10,7 +10,7 @@ export async function columnUpdate(req: Request, res: Response) { const router = Router({ mergeParams: true }); router.patch( - '/api/v1/db/meta/form/columns/:formViewColumnId', + '/api/v1/db/meta/form-columns/:formViewColumnId', ncMetaAclMw(columnUpdate, 'columnUpdate') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/gridViewColumnApis.ts b/packages/nocodb/src/lib/noco/meta/api/gridViewColumnApis.ts index e3463bac58..f845c09b57 100644 --- a/packages/nocodb/src/lib/noco/meta/api/gridViewColumnApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/gridViewColumnApis.ts @@ -14,11 +14,11 @@ export async function gridColumnUpdate(req: Request, res: Response) { const router = Router({ mergeParams: true }); router.get( - '/api/v1/db/meta/grids/:gridViewId/grid/columns', + '/api/v1/db/meta/grids/:gridViewId/grid-columns', ncMetaAclMw(columnList, 'columnList') ); router.patch( - '/api/v1/db/meta/grid/columns/:gridViewColumnId', + '/api/v1/db/meta/grid-columns/:gridViewColumnId', ncMetaAclMw(gridColumnUpdate, 'gridColumnUpdate') ); export default router; diff --git a/scripts/sdk/swagger.json b/scripts/sdk/swagger.json index ccb1286edd..690c7ab1a3 100644 --- a/scripts/sdk/swagger.json +++ b/scripts/sdk/swagger.json @@ -2029,7 +2029,7 @@ ] } }, - "/api/v1/db/meta/form/columns/{formViewColumnId}": { + "/api/v1/db/meta/form-columns/{formViewColumnId}": { "parameters": [ { "schema": { @@ -2069,13 +2069,13 @@ } } }, - "/api/v1/db/meta/grids/{gidId}/grid/columns": { + "/api/v1/db/meta/grids/{gridId}/grid-columns": { "parameters": [ { "schema": { "type": "string" }, - "name": "gidId", + "name": "gridId", "in": "path", "required": true } @@ -2103,7 +2103,7 @@ ] } }, - "/api/v1/db/meta/grid/columns/{columnId}": { + "/api/v1/db/meta/grid-columns/{columnId}": { "parameters": [ { "schema": { @@ -4494,7 +4494,7 @@ ] }, - "/bulkData/{orgs}/{projectName}/{tableName}/": { + "/api/v1/db/bulkData/{orgs}/{projectName}/{tableName}/": { "parameters": [ { "schema": { @@ -4597,7 +4597,7 @@ ] } }, - "/bulkData/{orgs}/{projectName}/{tableName}/all": { + "/api/v1/db/bulkData/{orgs}/{projectName}/{tableName}/all": { "parameters": [ { "schema": { From a81d975f18f0b4c4acffa58b9bcf59ebf24617df Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 19:15:24 +0530 Subject: [PATCH 66/81] fix: update csv download permission name re #1662 Signed-off-by: Pranav C --- .../src/lib/noco/meta/api/dataApis/dataAliasExportApis.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasExportApis.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasExportApis.ts index 03f1b4e857..ec62033258 100644 --- a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasExportApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasExportApis.ts @@ -23,11 +23,11 @@ const router = Router({ mergeParams: true }); router.get( '/api/v1/db/data/:orgs/:projectName/:tableName/export/csv', - ncMetaAclMw(csvDataExport, 'csvDataExport') + ncMetaAclMw(csvDataExport, 'exportCsv') ); router.get( '/api/v1/db/data/:orgs/:projectName/:tableName/views/:viewName/export/csv', - ncMetaAclMw(csvDataExport, 'csvDataExport') + ncMetaAclMw(csvDataExport, 'exportCsv') ); export default router; From 125ca8cab2a9d9a39e200f4e54952c7be3a11e64 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 19:42:02 +0530 Subject: [PATCH 67/81] fix: update wrong condition in marking hm relation associated to mm re #1663 Signed-off-by: Pranav C --- packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts b/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts index c33b1cb920..df0411c293 100644 --- a/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts @@ -834,7 +834,7 @@ export async function extractAndGenerateManyToManyRelations( if (!colOpt1 || colOpt1.type !== RelationTypes.HAS_MANY) continue; if ( - colOpt1.fk_child_column_id !== colOpt.fk_child_column_id && + colOpt1.fk_child_column_id !== colOpt.fk_child_column_id || colOpt1.fk_parent_column_id !== colOpt.fk_parent_column_id ) continue; From ef50b28f2c729a59d82161b9a334f11bea28aa54 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 20:06:44 +0530 Subject: [PATCH 68/81] chore(action): run screenshot step even if previous step failed Signed-off-by: Pranav C --- .github/workflows/ci-cd.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index b0bcbf5196..2d7cbace95 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -58,6 +58,7 @@ jobs: wait-on-timeout: 1200 config-file: scripts/cypress/cypress.json - name: Upload screenshots + if: always() uses: actions/upload-artifact@v2 with: name: restTableOps-snapshots @@ -102,6 +103,7 @@ jobs: wait-on-timeout: 1200 config-file: scripts/cypress/cypress.json - name: Upload screenshots + if: always() uses: actions/upload-artifact@v2 with: name: restTableOps-snapshots @@ -146,6 +148,7 @@ jobs: wait-on-timeout: 1200 config-file: scripts/cypress/cypress.json - name: Upload screenshots + if: always() uses: actions/upload-artifact@v2 with: name: restTableOps-snapshots @@ -190,6 +193,7 @@ jobs: wait-on-timeout: 1200 config-file: scripts/cypress/cypress.json - name: Upload screenshots + if: always() uses: actions/upload-artifact@v2 with: name: restTableOps-snapshots @@ -225,7 +229,7 @@ jobs: uses: cypress-io/github-action@v2 with: start: | - npm run build:common + npm run build:common npm run start:api:cache npm run start:web docker-compose -f ./scripts/docker-compose-cypress.yml up -d @@ -234,6 +238,7 @@ jobs: wait-on-timeout: 1200 config-file: scripts/cypress/cypress.json - name: Upload screenshots + if: always() uses: actions/upload-artifact@v2 with: name: restTableOps-snapshots @@ -278,6 +283,7 @@ jobs: wait-on-timeout: 1200 config-file: scripts/cypress/cypress.json - name: Upload screenshots + if: always() uses: actions/upload-artifact@v2 with: name: restTableOps-snapshots @@ -322,6 +328,7 @@ jobs: wait-on-timeout: 1200 config-file: scripts/cypress/cypress.json - name: Upload screenshots + if: always() uses: actions/upload-artifact@v2 with: name: restTableOps-snapshots @@ -366,6 +373,7 @@ jobs: wait-on-timeout: 1200 config-file: scripts/cypress/cypress.json - name: Upload screenshots + if: always() uses: actions/upload-artifact@v2 with: name: restTableOps-snapshots @@ -410,6 +418,7 @@ jobs: wait-on-timeout: 1200 config-file: scripts/cypress/cypress.json - name: Upload screenshots + if: always() uses: actions/upload-artifact@v2 with: name: restTableOps-snapshots @@ -454,6 +463,7 @@ jobs: wait-on-timeout: 1200 config-file: scripts/cypress/cypress.json - name: Upload screenshots + if: always() uses: actions/upload-artifact@v2 with: name: restTableOps-snapshots @@ -498,6 +508,7 @@ jobs: wait-on-timeout: 1200 config-file: scripts/cypress/cypress.json - name: Upload screenshots + if: always() uses: actions/upload-artifact@v2 with: name: restTableOps-snapshots @@ -542,6 +553,7 @@ jobs: wait-on-timeout: 1200 config-file: scripts/cypress/cypress.json - name: Upload screenshots + if: always() uses: actions/upload-artifact@v2 with: name: restTableOps-snapshots From 6ca3f4f96514326e99d528a3875a6642f343880f Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 20:07:24 +0530 Subject: [PATCH 69/81] refactor: in bulk data api path use snake case Signed-off-by: Pranav C --- .../lib/noco/meta/api/dataApis/bulkDataAliasApis.ts | 10 +++++----- scripts/sdk/swagger.json | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/bulkDataAliasApis.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/bulkDataAliasApis.ts index 18fe0b1434..f8d907fc9c 100644 --- a/packages/nocodb/src/lib/noco/meta/api/dataApis/bulkDataAliasApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/bulkDataAliasApis.ts @@ -91,23 +91,23 @@ async function getViewAndModelFromRequest(req) { const router = Router({ mergeParams: true }); router.post( - '/api/v1/db/bulkData/:orgs/:projectName/:tableAlias', + '/api/v1/db/bulk-data/:orgs/:projectName/:tableAlias', ncMetaAclMw(bulkDataInsert, 'bulkDataInsert') ); router.patch( - '/api/v1/db/bulkData/:orgs/:projectName/:tableAlias', + '/api/v1/db/bulk-data/:orgs/:projectName/:tableAlias', ncMetaAclMw(bulkDataUpdate, 'bulkDataUpdate') ); router.patch( - '/api/v1/db/bulkData/:orgs/:projectName/:tableAlias/all', + '/api/v1/db/bulk-data/:orgs/:projectName/:tableAlias/all', ncMetaAclMw(bulkDataUpdateAll, 'bulkDataUpdateAll') ); router.delete( - '/api/v1/db/bulkData/:orgs/:projectName/:tableAlias', + '/api/v1/db/bulk-data/:orgs/:projectName/:tableAlias', ncMetaAclMw(bulkDataDelete, 'bulkDataDelete') ); router.delete( - '/api/v1/db/bulkData/:orgs/:projectName/:tableAlias/all', + '/api/v1/db/bulk-data/:orgs/:projectName/:tableAlias/all', ncMetaAclMw(bulkDataDeleteAll, 'bulkDataDeleteAll') ); diff --git a/scripts/sdk/swagger.json b/scripts/sdk/swagger.json index 690c7ab1a3..6893abdd9b 100644 --- a/scripts/sdk/swagger.json +++ b/scripts/sdk/swagger.json @@ -4494,7 +4494,7 @@ ] }, - "/api/v1/db/bulkData/{orgs}/{projectName}/{tableName}/": { + "/api/v1/db/bulk-data/{orgs}/{projectName}/{tableName}/": { "parameters": [ { "schema": { @@ -4597,7 +4597,7 @@ ] } }, - "/api/v1/db/bulkData/{orgs}/{projectName}/{tableName}/all": { + "/api/v1/db/bulk-data/{orgs}/{projectName}/{tableName}/all": { "parameters": [ { "schema": { From d46dac26ca1c4a30b824e0308811ee264d80f0eb Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Tue, 12 Apr 2022 20:18:04 +0530 Subject: [PATCH 70/81] CI-CD: disable API tests (docker) --- .github/workflows/ci-cd.yml | 54 ++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 2d7cbace95..ce8c3e689d 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -559,33 +559,33 @@ jobs: name: restTableOps-snapshots path: scripts/cypress/screenshots retention-days: 2 - docker: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Check for update - run: | - echo "CHANGED=$([[ $(lerna ls --since ${{github.event.before}} | grep nocodb) = nocodb ]] && echo 'OK')" >> $GITHUB_ENV - - name: Test Mysql REST APIs - if: ${{ env.CHANGED == 'OK' }} - run: cd ./packages/nocodb/ && docker-compose run xc-test-mysql - - name: Test Mysql GraphQL APIs - if: ${{ env.CHANGED == 'OK' }} - run: cd ./packages/nocodb/ && docker-compose run xc-test-gql-mysql - - # - name: Test MSSQL REST APIs - # run: cd ./packages/nocodb/ && docker-compose run xc-test-mssql - # - name: Test MSSQL GraphQL APIs - # run: cd ./packages/nocodb/ && docker-compose run xc-test-gql-mssql - # - - name: Test PostgreSQL REST APIs - if: ${{ env.CHANGED == 'OK' }} - run: cd ./packages/nocodb/ && docker-compose run xc-test-pg - - name: Test PostgreSQL GraphQL APIs - if: ${{ env.CHANGED == 'OK' }} - run: cd ./packages/nocodb/ && docker-compose run xc-test-gql-pg +# docker: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# with: +# fetch-depth: 0 +# - name: Check for update +# run: | +# echo "CHANGED=$([[ $(lerna ls --since ${{github.event.before}} | grep nocodb) = nocodb ]] && echo 'OK')" >> $GITHUB_ENV +# - name: Test Mysql REST APIs +# if: ${{ env.CHANGED == 'OK' }} +# run: cd ./packages/nocodb/ && docker-compose run xc-test-mysql +# - name: Test Mysql GraphQL APIs +# if: ${{ env.CHANGED == 'OK' }} +# run: cd ./packages/nocodb/ && docker-compose run xc-test-gql-mysql +# +# # - name: Test MSSQL REST APIs +# # run: cd ./packages/nocodb/ && docker-compose run xc-test-mssql +# # - name: Test MSSQL GraphQL APIs +# # run: cd ./packages/nocodb/ && docker-compose run xc-test-gql-mssql +# # +# - name: Test PostgreSQL REST APIs +# if: ${{ env.CHANGED == 'OK' }} +# run: cd ./packages/nocodb/ && docker-compose run xc-test-pg +# - name: Test PostgreSQL GraphQL APIs +# if: ${{ env.CHANGED == 'OK' }} +# run: cd ./packages/nocodb/ && docker-compose run xc-test-gql-pg # # - name: Test SQLite3 REST APIs # run: cd ./packages/nocodb/ && docker-compose run xc-test-sqlite From 2e5053822081f00db8eff81daabd33710e7bca0c Mon Sep 17 00:00:00 2001 From: Naveen MR Date: Tue, 12 Apr 2022 17:56:22 +0100 Subject: [PATCH 71/81] fix : build daily 4 times Signed-off-by: Naveen MR --- .github/workflows/release-nightly-dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-nightly-dev.yml b/.github/workflows/release-nightly-dev.yml index f773437bb3..6cbbe5ab08 100644 --- a/.github/workflows/release-nightly-dev.yml +++ b/.github/workflows/release-nightly-dev.yml @@ -26,11 +26,11 @@ jobs: # Get current date CURRENT_DATE=$(date +"%Y%m%d") CURRENT_TIME=$(date +"%H%M") - TAG_NAME=${CURRENT_DATE} + TAG_NAME=${CURRENT_DATE}-${CURRENT_TIME} IS_DAILY='Y' # Set the tag if [[ ${{ github.event_name }} == 'workflow_dispatch' ]]; then - TAG_NAME=${TAG_NAME}-${CURRENT_TIME} + TAG_NAME=${TAG_NAME} IS_DAILY='N' fi echo "::set-output name=NIGHTLY_BUILD_TAG::${TAG_NAME}" From 35f8328ae5f0274380aaddd7e1c9af1558397179 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 22:26:20 +0530 Subject: [PATCH 72/81] refactor: update auth apis Signed-off-by: Pranav C --- .../src/lib/noco/meta/api/userApi/userApis.ts | 29 +++++++++++++++++++ scripts/sdk/swagger.json | 18 ++++++------ 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/packages/nocodb/src/lib/noco/meta/api/userApi/userApis.ts b/packages/nocodb/src/lib/noco/meta/api/userApi/userApis.ts index b5096d3e52..712862e018 100644 --- a/packages/nocodb/src/lib/noco/meta/api/userApi/userApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/userApi/userApis.ts @@ -442,5 +442,34 @@ const mapRoutes = router => { ncMetaAclMw(passwordChange, 'passwordChange') ); router.post('/auth/token/refresh', ncMetaAclMw(refreshToken, 'refreshToken')); + + router.post('/api/v1/db/auth/user/signup', catchError(signup)); + router.post('/api/v1/db/auth/user/signin', catchError(signin)); + router.get( + '/api/v1/db/auth/user/me', + extractProjectIdAndAuthenticate, + catchError(me) + ); + router.post('/api/v1/db/auth/password/forgot', catchError(passwordForgot)); + router.post( + '/api/v1/db/auth/token/validate/:tokenId', + catchError(tokenValidate) + ); + router.post( + '/api/v1/db/auth/password/reset/:tokenId', + catchError(passwordReset) + ); + router.post( + '/api/v1/db/auth/email/validate/:tokenId', + catchError(emailVerification) + ); + router.post( + '/user/password/change', + ncMetaAclMw(passwordChange, 'passwordChange') + ); + router.post( + '/api/v1/db/auth/token/refresh', + ncMetaAclMw(refreshToken, 'refreshToken') + ); }; export { mapRoutes as userApis }; diff --git a/scripts/sdk/swagger.json b/scripts/sdk/swagger.json index 6893abdd9b..321dac3b13 100644 --- a/scripts/sdk/swagger.json +++ b/scripts/sdk/swagger.json @@ -10,7 +10,7 @@ } ], "paths": { - "/auth/user/signup": { + "/api/v1/db/auth/user/signup": { "post": { "summary": "Signup", "operationId": "auth-signup", @@ -49,7 +49,7 @@ "description": "Create a new user with provided email and password and first user is marked as super admin. " } }, - "/auth/user/signin": { + "/api/v1/db/auth/user/signin": { "post": { "summary": "Signin", "operationId": "auth-signin", @@ -98,7 +98,7 @@ }, "parameters": [] }, - "/auth/user/me": { + "/api/v1/db/auth/user/me": { "parameters": [], "get": { "summary": "User Info", @@ -121,7 +121,7 @@ "description": "Returns authenticated user info" } }, - "/auth/password/forgot": { + "/api/v1/db/auth/password/forgot": { "post": { "summary": "Password Forgot", "operationId": "auth-password-forgot", @@ -151,7 +151,7 @@ }, "parameters": [] }, - "/auth/password/change": { + "/api/v1/db/auth/password/change": { "post": { "summary": "Password Change", "operationId": "auth-password-change", @@ -187,7 +187,7 @@ }, "parameters": [] }, - "/auth/token/validate/{token}": { + "/api/v1/db/auth/token/validate/{token}": { "post": { "summary": "Reset Token Verify", "operationId": "auth-password-reset-token-validate", @@ -212,7 +212,7 @@ } ] }, - "/auth/email/validate/{token}": { + "/api/v1/db/auth/email/validate/{token}": { "post": { "summary": "Verify Email", "operationId": "auth-email-validate", @@ -237,7 +237,7 @@ } ] }, - "/auth/password/reset/{token}": { + "/api/v1/db/auth/password/reset/{token}": { "post": { "summary": "Password Reset", "operationId": "auth-password-reset", @@ -276,7 +276,7 @@ } ] }, - "/auth/token/refresh": { + "/api/v1/db/auth/token/refresh": { "post": { "summary": "Refresh Token", "operationId": "auth-token-refresh", From 2445b181f9e53687b96766408ec7e32c4ef762db Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 22:39:25 +0530 Subject: [PATCH 73/81] fix: stay in same view even after view active name update re #1653 Signed-off-by: Pranav C --- .../components/spreadsheetNavDrawer.vue | 29 +++++-------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/components/spreadsheetNavDrawer.vue b/packages/nc-gui/components/project/spreadsheet/components/spreadsheetNavDrawer.vue index 5ea813c32b..a83074361c 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/spreadsheetNavDrawer.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/spreadsheetNavDrawer.vue @@ -767,22 +767,15 @@ export default { return } try { - if (this.selectedViewIdLocal === view.id) { - await this.$router.push({ - query: { - ...this.$route.query, - view: view.title_temp - } - }) - } + // if (this.selectedViewIdLocal === view.id) { + // await this.$router.push({ + // query: { + // ...this.$route.query, + // view: view.title_temp + // } + // }) + // } this.$set(view, 'title', view.title_temp) - // await this.sqlOp({ dbAlias: this.nodes.dbAlias }, 'xcVirtualTableRename', { - // id: view.id, - // old_title: oldTitle, - // title: view.title_temp, - // alias: view.alias, - // parent_model_title: this.meta.table_name - // }) await this.$api.dbView.update(view.id, { title: view.title, order: view.order @@ -804,12 +797,6 @@ export default { }, async deleteView(view) { try { - // await this.sqlOp({ dbAlias: this.nodes.dbAlias }, 'xcVirtualTableDelete', { - // id: view.id, - // title: view.alias || view.title, - // view_name: view.alias || view.title, - // parent_model_title: this.table - // }) await this.$api.dbView.delete(view.id) this.$toast.success('View deleted successfully').goAway(3000) await this.loadViews() From 72e15a5a2589cc6f90ab5523c4d68114886a5d02 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 23:05:52 +0530 Subject: [PATCH 74/81] fix: hide hidden columns from shared gridview field list re #1654 Signed-off-by: Pranav C --- .../project/spreadsheet/mixins/spreadsheet.js | 34 +--------------- .../project/spreadsheet/public/xcTable.vue | 3 ++ .../project/spreadsheet/views/formView.vue | 39 +++++++++---------- .../project/spreadsheet/views/galleryView.vue | 4 +- .../project/spreadsheet/views/kanbanView.vue | 6 +-- .../project/spreadsheet/views/xcGridView.vue | 16 ++++---- 6 files changed, 37 insertions(+), 65 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/mixins/spreadsheet.js b/packages/nc-gui/components/project/spreadsheet/mixins/spreadsheet.js index 06e8d6ac6b..232e44db7c 100644 --- a/packages/nc-gui/components/project/spreadsheet/mixins/spreadsheet.js +++ b/packages/nc-gui/components/project/spreadsheet/mixins/spreadsheet.js @@ -108,25 +108,12 @@ export default { } { - const _ref = {} columns.forEach((c) => { - // if (c.virtual && c.lk) { - // c.alias = `${c.lk._lcn} (from ${c.lk._ltn})` - // } else { c.alias = c.title - // } - if (c.alias in _ref) { - c.alias += _ref[c.alias]++ - } else { - _ref[c.alias] = 1 - } }) } return columns }, - // allColumnsNames() { - // return this.allColumns && this.allColumns.length ? this.allColumns.reduce((a, c) => [...a, c.column_name, c.title], []) : [] - // }, availableColumns() { let columns = [] @@ -140,32 +127,15 @@ export default { columns = filterOutSystemColumns(this.meta.columns) } - if (this.meta && this.meta.v) { - columns = [...columns, ...this.meta.v.map(v => ({ - ...v, - virtual: 1 - }))] - } - { - const _ref = {} columns.forEach((c) => { - // if (c.virtual && c.lk) { - // c.alias = `${c.lk._lcn} (from ${c.lk._ltn})` - // } else { c.alias = c.title - // } - if (c.alias in _ref) { - c.alias += _ref[c.alias]++ - } else { - _ref[c.alias] = 1 - } }) } if (this.fieldsOrder.length) { return [...columns].sort((c1, c2) => { - const i1 = this.fieldsOrder.indexOf(c1.alias) - const i2 = this.fieldsOrder.indexOf(c2.alias) + const i1 = this.fieldsOrder.indexOf(c1.title) + const i2 = this.fieldsOrder.indexOf(c2.title) return (i1 === -1 ? Infinity : i1) - (i2 === -1 ? Infinity : i2) }) } diff --git a/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue b/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue index fdbdd2ed5b..0b05d4eff0 100644 --- a/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue +++ b/packages/nc-gui/components/project/spreadsheet/public/xcTable.vue @@ -29,6 +29,7 @@ :fields-order.sync="fieldsOrder" is-public :meta="meta" + :show-system-fields="showSystemFields" /> c.show) this.metas = this.viewMeta.relatedMetas + this.showSystemFields = this.viewMeta.show_system_fields this.sorts = this.viewMeta.sorts this.viewName = this.viewMeta.title diff --git a/packages/nc-gui/components/project/spreadsheet/views/formView.vue b/packages/nc-gui/components/project/spreadsheet/views/formView.vue index a3b18c2b85..21bbe64419 100644 --- a/packages/nc-gui/components/project/spreadsheet/views/formView.vue +++ b/packages/nc-gui/components/project/spreadsheet/views/formView.vue @@ -56,7 +56,7 @@ >