Browse Source

Merge branch 'api-redesign' into develop

Signed-off-by: Pranav C <pranavxc@gmail.com>

# Conflicts:
#	packages/nc-gui/plugins/tele.js
pull/1668/head
Pranav C 3 years ago
parent
commit
a50e59b39d
  1. 16
      packages/nc-gui/components/project/spreadsheet/components/columnFilter.vue
  2. 4
      packages/nc-gui/components/project/spreadsheet/components/sortListMenu.vue
  3. 11
      packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue
  4. 4
      packages/nc-gui/mixins/device.js
  5. 79
      packages/nc-gui/package-lock.json
  6. 2
      packages/nc-gui/package.json
  7. 13
      packages/nc-gui/plugins/tele.js
  8. 8
      packages/nc-gui/store/project.js
  9. 2018
      packages/nocodb-sdk/src/lib/Api.ts
  10. 79
      packages/nocodb/package-lock.json
  11. 2
      packages/nocodb/package.json
  12. 7
      packages/nocodb/src/lib/noco-models/User.ts
  13. 6
      packages/nocodb/src/lib/noco/meta/api/apiTokenApis.ts
  14. 24
      packages/nocodb/src/lib/noco/meta/api/auditApis.ts
  15. 4
      packages/nocodb/src/lib/noco/meta/api/cacheApis.ts
  16. 29
      packages/nocodb/src/lib/noco/meta/api/columnApis.ts
  17. 72
      packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasApis.ts
  18. 44
      packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasExportApis.ts
  19. 308
      packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasNestedApis.ts
  20. 4
      packages/nocodb/src/lib/noco/meta/api/dataApis/dataApis.ts
  21. 155
      packages/nocodb/src/lib/noco/meta/api/dataApis/helpers.ts
  22. 2
      packages/nocodb/src/lib/noco/meta/api/dataApis/oldDataApis.ts
  23. 136
      packages/nocodb/src/lib/noco/meta/api/exportApis.ts
  24. 52
      packages/nocodb/src/lib/noco/meta/api/filterApis.ts
  25. 14
      packages/nocodb/src/lib/noco/meta/api/formViewApis.ts
  26. 4
      packages/nocodb/src/lib/noco/meta/api/formViewColumnApis.ts
  27. 33
      packages/nocodb/src/lib/noco/meta/api/galleryViewApis.ts
  28. 2
      packages/nocodb/src/lib/noco/meta/api/gridViewApis.ts
  29. 6
      packages/nocodb/src/lib/noco/meta/api/gridViewColumnApis.ts
  30. 27
      packages/nocodb/src/lib/noco/meta/api/hookApis.ts
  31. 2
      packages/nocodb/src/lib/noco/meta/api/hookFilterApis.ts
  32. 7
      packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts
  33. 2
      packages/nocodb/src/lib/noco/meta/api/modelVisibilityApis.ts
  34. 22
      packages/nocodb/src/lib/noco/meta/api/pluginApis.ts
  35. 19
      packages/nocodb/src/lib/noco/meta/api/projectApis.ts
  36. 2
      packages/nocodb/src/lib/noco/meta/api/projectUserApis.ts
  37. 2
      packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts
  38. 22
      packages/nocodb/src/lib/noco/meta/api/publicApis/publicMetaApis.ts
  39. 22
      packages/nocodb/src/lib/noco/meta/api/sharedBaseApis.ts
  40. 24
      packages/nocodb/src/lib/noco/meta/api/sortApis.ts
  41. 21
      packages/nocodb/src/lib/noco/meta/api/tableApis.ts
  42. 7
      packages/nocodb/src/lib/noco/meta/api/userApi/initStrategies.ts
  43. 51
      packages/nocodb/src/lib/noco/meta/api/userApi/userApis.ts
  44. 7
      packages/nocodb/src/lib/noco/meta/api/utilApis.ts
  45. 32
      packages/nocodb/src/lib/noco/meta/api/viewApis.ts
  46. 14
      packages/nocodb/src/lib/noco/meta/api/viewColumnApis.ts
  47. 2369
      scripts/sdk/swagger.json

16
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')
}

4
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)

11
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) }),

4
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() {

79
packages/nc-gui/package-lock.json generated

@ -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": {

2
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",

13
packages/nc-gui/plugins/tele.js

@ -22,9 +22,15 @@ export default function({
extraHeaders: { 'xc-auth': token }
})
socket.on('connect_error', () => {
socket.disconnect()
socket = null
})
}
app.router.onReady(() => {
app.router.afterEach(function(to, from) {
if (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,11 +44,6 @@ export default function({
})
})
socket.on('connect_error', () => {
socket.disconnect()
socket = null
})
}
const tele = {
emit(evt, data) {
if (socket) {

8
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

2018
packages/nocodb-sdk/src/lib/Api.ts

File diff suppressed because it is too large Load Diff

79
packages/nocodb/package-lock.json generated

@ -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": {

2
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",

7
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;
}
}

6
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')
);

24
packages/nocodb/src/lib/noco/meta/api/auditApis.ts

@ -20,7 +20,7 @@ export async function auditRowUpdate(req: Request<any, any>, 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<any, any, any>, 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;

4
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;

29
packages/nocodb/src/lib/noco/meta/api/columnApis.ts

@ -498,14 +498,15 @@ export async function columnAdd(req: Request, res: Response<TableType>) {
}
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<TableType>) {
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<TableType>) {
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<TableType>) {
}
export async function columnDelete(req: Request, res: Response<TableType>) {
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<TableType>) {
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;

72
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);
async function dataList(req: Request, res: Response) {
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,53 @@ async function dataRead(req: Request, res: Response) {
const router = Router({ mergeParams: true });
router.get('/data/:orgs/:projectName/:tableName', ncMetaAclMw(dataList, 'dataList'));
// 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(
'/data/:orgs/:projectName/:tableName/views/:viewName',
'/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',
ncMetaAclMw(dataInsert, 'dataInsert')
);
router.post(
'/api/v1/db/data/:orgs/:projectName/:tableName/views/:viewName',
ncMetaAclMw(dataInsert, 'dataInsert')
);
router.put(
'/data/:orgs/:projectName/:tableName/views/:viewName/:rowId',
router.patch(
'/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')
);

44
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;

308
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;

4
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'));

155
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<LookupColumn>();
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;
}
}

2
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')
);

136
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<LookupColumn>();
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;

52
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<any, any, any, TableListParams>,
res: Response
) {
const filter = await Filter.rootFilterListByHook({
hookId: req.params.hookId
});
res.json(filter);
}
export async function hookFilterCreate(req: Request<any, any, TableReq>, 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;

14
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;

4
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;

33
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<GalleryType>) {
res.json(await GalleryView.get(req.params.galleryViewId));
}
// @ts-ignore
export async function galleyViewList(
_req: Request<any, any, any>,
_res: Response<TableListType>
) {}
// @ts-ignore
export async function galleryViewCreate(req: Request<any, any>, 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<any, any>, 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;

2
packages/nocodb/src/lib/noco/meta/api/gridViewApis.ts

@ -26,7 +26,7 @@ export async function gridViewCreate(req: Request<any, any>, res) {
const router = Router({ mergeParams: true });
router.post(
'/tables/:tableId/grids/',
'/api/v1/db/meta/tables/:tableId/grids/',
ncMetaAclMw(gridViewCreate, 'gridViewCreate')
);
export default router;

6
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;

27
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;

2
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')
);

7
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;

2
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;

22
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;

19
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')
);
};

2
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')
);

2
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(

22
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<any> {
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;

22
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<any> {
res.json(data);
}
async function publicSharedBaseGet(req, res): Promise<any> {
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;

24
packages/nocodb/src/lib/noco/meta/api/sortApis.ts

@ -36,30 +36,34 @@ export async function sortCreate(req: Request<any, any, TableReqType>, 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;

21
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;

7
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];

51
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<TableType>) {
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<any> {
res.json({ msg: 'Email verified successfully' });
}
async function refreshToken(req, res): Promise<any> {
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 };

7
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));
};

32
packages/nocodb/src/lib/noco/meta/api/viewApis.ts

@ -101,29 +101,41 @@ async function shareViewList(req: Request<any, any>, 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')
);

14
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;

2369
scripts/sdk/swagger.json

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save