Merge branch 'master' into grid-conflict-improvements
This commit is contained in:
commit
48ffb62c1d
|
@ -53,6 +53,11 @@ done
|
||||||
if [[ -z "${COUCH_DB_URL}" ]]; then
|
if [[ -z "${COUCH_DB_URL}" ]]; then
|
||||||
export COUCH_DB_URL=http://$COUCHDB_USER:$COUCHDB_PASSWORD@127.0.0.1:5984
|
export COUCH_DB_URL=http://$COUCHDB_USER:$COUCHDB_PASSWORD@127.0.0.1:5984
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${COUCH_DB_SQL_URL}" ]]; then
|
||||||
|
export COUCH_DB_SQL_URL=http://127.0.0.1:4984
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -f "${DATA_DIR}/.env" ]; then
|
if [ ! -f "${DATA_DIR}/.env" ]; then
|
||||||
touch ${DATA_DIR}/.env
|
touch ${DATA_DIR}/.env
|
||||||
for ENV_VAR in "${ENV_VARS[@]}"
|
for ENV_VAR in "${ENV_VARS[@]}"
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
"build:oss": "NODE_OPTIONS=--max-old-space-size=1500 lerna run build --stream --ignore @budibase/account-portal --ignore @budibase/account-portal-server --ignore @budibase/account-portal-ui",
|
"build:oss": "NODE_OPTIONS=--max-old-space-size=1500 lerna run build --stream --ignore @budibase/account-portal --ignore @budibase/account-portal-server --ignore @budibase/account-portal-ui",
|
||||||
"build:account-portal": "NODE_OPTIONS=--max-old-space-size=1500 lerna run build --stream --scope @budibase/account-portal --scope @budibase/account-portal-server --scope @budibase/account-portal-ui",
|
"build:account-portal": "NODE_OPTIONS=--max-old-space-size=1500 lerna run build --stream --scope @budibase/account-portal --scope @budibase/account-portal-server --scope @budibase/account-portal-ui",
|
||||||
"build:dev": "lerna run --stream prebuild && yarn nx run-many --target=build --output-style=dynamic --watch --preserveWatchOutput",
|
"build:dev": "lerna run --stream prebuild && yarn nx run-many --target=build --output-style=dynamic --watch --preserveWatchOutput",
|
||||||
"check:types": "lerna run check:types",
|
"check:types": "lerna run --concurrency 2 check:types",
|
||||||
"build:sdk": "lerna run --stream build:sdk",
|
"build:sdk": "lerna run --stream build:sdk",
|
||||||
"deps:circular": "madge packages/server/dist/index.js packages/worker/src/index.ts packages/backend-core/dist/src/index.js packages/cli/src/index.js --circular",
|
"deps:circular": "madge packages/server/dist/index.js packages/worker/src/index.ts packages/backend-core/dist/src/index.js packages/cli/src/index.js --circular",
|
||||||
"release": "lerna publish from-package --yes --force-publish --no-git-tag-version --no-push --no-git-reset",
|
"release": "lerna publish from-package --yes --force-publish --no-git-tag-version --no-push --no-git-reset",
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit c167c331ff9b8161fc18e2ecbaaf1ea5815ba964
|
Subproject commit 39acfff42a063e5a8a7d58d36721ec3103e16348
|
|
@ -1,6 +1,11 @@
|
||||||
import { Knex, knex } from "knex"
|
import { Knex, knex } from "knex"
|
||||||
import * as dbCore from "../db"
|
import * as dbCore from "../db"
|
||||||
import { isIsoDateString, isValidFilter, getNativeSql } from "./utils"
|
import {
|
||||||
|
isIsoDateString,
|
||||||
|
isValidFilter,
|
||||||
|
getNativeSql,
|
||||||
|
isExternalTable,
|
||||||
|
} from "./utils"
|
||||||
import { SqlStatements } from "./sqlStatements"
|
import { SqlStatements } from "./sqlStatements"
|
||||||
import SqlTableQueryBuilder from "./sqlTable"
|
import SqlTableQueryBuilder from "./sqlTable"
|
||||||
import {
|
import {
|
||||||
|
@ -21,6 +26,7 @@ import {
|
||||||
SqlClient,
|
SqlClient,
|
||||||
QueryOptions,
|
QueryOptions,
|
||||||
JsonTypes,
|
JsonTypes,
|
||||||
|
prefixed,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import environment from "../environment"
|
import environment from "../environment"
|
||||||
import { helpers } from "@budibase/shared-core"
|
import { helpers } from "@budibase/shared-core"
|
||||||
|
@ -391,6 +397,16 @@ class InternalBuilder {
|
||||||
contains(filters.containsAny, true)
|
contains(filters.containsAny, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// when searching internal tables make sure long looking for rows
|
||||||
|
if (filters.documentType && !isExternalTable(table)) {
|
||||||
|
const tableRef = opts?.aliases?.[table._id!] || table._id
|
||||||
|
// has to be its own option, must always be AND onto the search
|
||||||
|
query.andWhereLike(
|
||||||
|
`${tableRef}._id`,
|
||||||
|
`${prefixed(filters.documentType)}%`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return query
|
return query
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -592,6 +608,7 @@ class InternalBuilder {
|
||||||
query = this.addFilters(query, filters, json.meta.table, {
|
query = this.addFilters(query, filters, json.meta.table, {
|
||||||
aliases: tableAliases,
|
aliases: tableAliases,
|
||||||
})
|
})
|
||||||
|
|
||||||
// add sorting to pre-query
|
// add sorting to pre-query
|
||||||
query = this.addSorting(query, json)
|
query = this.addSorting(query, json)
|
||||||
const alias = tableAliases?.[tableName] || tableName
|
const alias = tableAliases?.[tableName] || tableName
|
||||||
|
|
|
@ -106,6 +106,10 @@ export const useViewPermissions = () => {
|
||||||
return useFeature(Feature.VIEW_PERMISSIONS)
|
return useFeature(Feature.VIEW_PERMISSIONS)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const useViewReadonlyColumns = () => {
|
||||||
|
return useFeature(Feature.VIEW_READONLY_COLUMNS)
|
||||||
|
}
|
||||||
|
|
||||||
// QUOTAS
|
// QUOTAS
|
||||||
|
|
||||||
export const setAutomationLogsQuota = (value: number) => {
|
export const setAutomationLogsQuota = (value: number) => {
|
||||||
|
|
|
@ -32,8 +32,14 @@
|
||||||
onboarding = true
|
onboarding = true
|
||||||
try {
|
try {
|
||||||
const { password, firstName, lastName } = formData
|
const { password, firstName, lastName } = formData
|
||||||
await users.acceptInvite(inviteCode, password, firstName, lastName)
|
const user = await users.acceptInvite(
|
||||||
|
inviteCode,
|
||||||
|
password,
|
||||||
|
firstName,
|
||||||
|
lastName
|
||||||
|
)
|
||||||
notifications.success("Invitation accepted successfully")
|
notifications.success("Invitation accepted successfully")
|
||||||
|
auth.setOrg(user.tenantId)
|
||||||
await login()
|
await login()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
notifications.error(error.message)
|
notifications.error(error.message)
|
||||||
|
@ -66,7 +72,7 @@
|
||||||
notifications.success("Logged in successfully")
|
notifications.success("Logged in successfully")
|
||||||
$goto("../portal")
|
$goto("../portal")
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
notifications.error(err.message ? err.message : "Invalid credentials") //not likely, considering.
|
notifications.error(err.message ? err.message : "Something went wrong")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,12 +147,19 @@
|
||||||
password: e.detail,
|
password: e.detail,
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
validateOn="blur"
|
||||||
validate={() => {
|
validate={() => {
|
||||||
let fieldError = {}
|
let fieldError = {}
|
||||||
|
|
||||||
fieldError["password"] = !formData.password
|
function validatePassword() {
|
||||||
? "Please enter a password"
|
if (!formData.password) {
|
||||||
: undefined
|
return "Please enter a password"
|
||||||
|
} else if (formData.password.length < 8) {
|
||||||
|
return "Please enter at least 8 characters"
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
fieldError["password"] = validatePassword()
|
||||||
|
|
||||||
fieldError["confirmationPassword"] =
|
fieldError["confirmationPassword"] =
|
||||||
!passwordsMatch(
|
!passwordsMatch(
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 1879d8686b1d9392707595a02cdd4981923e7f99
|
Subproject commit 5189b83bea1868574ff7f4c51fe5db38a11badb8
|
|
@ -3,7 +3,7 @@ import {
|
||||||
CreateViewRequest,
|
CreateViewRequest,
|
||||||
Ctx,
|
Ctx,
|
||||||
RequiredKeys,
|
RequiredKeys,
|
||||||
UIFieldMetadata,
|
ViewUIFieldMetadata,
|
||||||
UpdateViewRequest,
|
UpdateViewRequest,
|
||||||
ViewResponse,
|
ViewResponse,
|
||||||
ViewResponseEnriched,
|
ViewResponseEnriched,
|
||||||
|
@ -18,22 +18,23 @@ async function parseSchema(view: CreateViewRequest) {
|
||||||
const finalViewSchema =
|
const finalViewSchema =
|
||||||
view.schema &&
|
view.schema &&
|
||||||
Object.entries(view.schema).reduce((p, [fieldName, schemaValue]) => {
|
Object.entries(view.schema).reduce((p, [fieldName, schemaValue]) => {
|
||||||
const fieldSchema: RequiredKeys<UIFieldMetadata> = {
|
const fieldSchema: RequiredKeys<ViewUIFieldMetadata> = {
|
||||||
order: schemaValue.order,
|
order: schemaValue.order,
|
||||||
width: schemaValue.width,
|
width: schemaValue.width,
|
||||||
visible: schemaValue.visible,
|
visible: schemaValue.visible,
|
||||||
|
readonly: schemaValue.readonly,
|
||||||
icon: schemaValue.icon,
|
icon: schemaValue.icon,
|
||||||
}
|
}
|
||||||
Object.entries(fieldSchema)
|
Object.entries(fieldSchema)
|
||||||
.filter(([, val]) => val === undefined)
|
.filter(([, val]) => val === undefined)
|
||||||
.forEach(([key]) => {
|
.forEach(([key]) => {
|
||||||
delete fieldSchema[key as keyof UIFieldMetadata]
|
delete fieldSchema[key as keyof ViewUIFieldMetadata]
|
||||||
})
|
})
|
||||||
p[fieldName] = fieldSchema
|
p[fieldName] = fieldSchema
|
||||||
return p
|
return p
|
||||||
}, {} as Record<string, RequiredKeys<UIFieldMetadata>>)
|
}, {} as Record<string, RequiredKeys<ViewUIFieldMetadata>>)
|
||||||
for (let [key, column] of Object.entries(finalViewSchema)) {
|
for (let [key, column] of Object.entries(finalViewSchema)) {
|
||||||
if (!column.visible) {
|
if (!column.visible && !column.readonly) {
|
||||||
delete finalViewSchema[key]
|
delete finalViewSchema[key]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,8 @@ import {
|
||||||
StaticQuotaName,
|
StaticQuotaName,
|
||||||
Table,
|
Table,
|
||||||
TableSourceType,
|
TableSourceType,
|
||||||
UIFieldMetadata,
|
|
||||||
UpdateViewRequest,
|
UpdateViewRequest,
|
||||||
|
ViewUIFieldMetadata,
|
||||||
ViewV2,
|
ViewV2,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { generator, mocks } from "@budibase/backend-core/tests"
|
import { generator, mocks } from "@budibase/backend-core/tests"
|
||||||
|
@ -23,6 +23,9 @@ import { DatabaseName, getDatasource } from "../../../integrations/tests/utils"
|
||||||
import merge from "lodash/merge"
|
import merge from "lodash/merge"
|
||||||
import { quotas } from "@budibase/pro"
|
import { quotas } from "@budibase/pro"
|
||||||
import { roles } from "@budibase/backend-core"
|
import { roles } from "@budibase/backend-core"
|
||||||
|
import * as schemaUtils from "../../../utilities/schema"
|
||||||
|
|
||||||
|
jest.mock("../../../utilities/schema")
|
||||||
|
|
||||||
describe.each([
|
describe.each([
|
||||||
["internal", undefined],
|
["internal", undefined],
|
||||||
|
@ -96,6 +99,10 @@ describe.each([
|
||||||
setup.afterAll()
|
setup.afterAll()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
mocks.licenses.useCloudFree()
|
||||||
|
})
|
||||||
|
|
||||||
const getRowUsage = async () => {
|
const getRowUsage = async () => {
|
||||||
const { total } = await config.doInContext(undefined, () =>
|
const { total } = await config.doInContext(undefined, () =>
|
||||||
quotas.getCurrentUsageValues(QuotaUsageType.STATIC, StaticQuotaName.ROWS)
|
quotas.getCurrentUsageValues(QuotaUsageType.STATIC, StaticQuotaName.ROWS)
|
||||||
|
@ -141,7 +148,7 @@ describe.each([
|
||||||
type: SortType.STRING,
|
type: SortType.STRING,
|
||||||
},
|
},
|
||||||
schema: {
|
schema: {
|
||||||
name: {
|
Price: {
|
||||||
visible: true,
|
visible: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -150,7 +157,11 @@ describe.each([
|
||||||
|
|
||||||
expect(res).toEqual({
|
expect(res).toEqual({
|
||||||
...newView,
|
...newView,
|
||||||
schema: newView.schema,
|
schema: {
|
||||||
|
Price: {
|
||||||
|
visible: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
version: 2,
|
version: 2,
|
||||||
})
|
})
|
||||||
|
@ -214,6 +225,211 @@ describe.each([
|
||||||
status: 201,
|
status: 201,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("does not persist non-visible fields", async () => {
|
||||||
|
const newView: CreateViewRequest = {
|
||||||
|
name: generator.name(),
|
||||||
|
tableId: table._id!,
|
||||||
|
primaryDisplay: generator.word(),
|
||||||
|
schema: {
|
||||||
|
Price: { visible: true },
|
||||||
|
Category: { visible: false },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
const res = await config.api.viewV2.create(newView)
|
||||||
|
|
||||||
|
expect(res).toEqual({
|
||||||
|
...newView,
|
||||||
|
schema: {
|
||||||
|
Price: {
|
||||||
|
visible: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
id: expect.any(String),
|
||||||
|
version: 2,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it("throws bad request when the schema fields are not valid", async () => {
|
||||||
|
const newView: CreateViewRequest = {
|
||||||
|
name: generator.name(),
|
||||||
|
tableId: table._id!,
|
||||||
|
schema: {
|
||||||
|
nonExisting: {
|
||||||
|
visible: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
await config.api.viewV2.create(newView, {
|
||||||
|
status: 400,
|
||||||
|
body: {
|
||||||
|
message: 'Field "nonExisting" is not valid for the requested table',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("readonly fields", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
mocks.licenses.useViewReadonlyColumns()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("readonly fields are persisted", async () => {
|
||||||
|
const table = await config.api.table.save(
|
||||||
|
saveTableRequest({
|
||||||
|
schema: {
|
||||||
|
name: {
|
||||||
|
name: "name",
|
||||||
|
type: FieldType.STRING,
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
name: "description",
|
||||||
|
type: FieldType.STRING,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
const newView: CreateViewRequest = {
|
||||||
|
name: generator.name(),
|
||||||
|
tableId: table._id!,
|
||||||
|
schema: {
|
||||||
|
name: {
|
||||||
|
visible: true,
|
||||||
|
readonly: true,
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
visible: true,
|
||||||
|
readonly: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await config.api.viewV2.create(newView)
|
||||||
|
expect(res.schema).toEqual({
|
||||||
|
name: {
|
||||||
|
visible: true,
|
||||||
|
readonly: true,
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
visible: true,
|
||||||
|
readonly: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it("required fields cannot be marked as readonly", async () => {
|
||||||
|
const isRequiredSpy = jest.spyOn(schemaUtils, "isRequired")
|
||||||
|
isRequiredSpy.mockReturnValueOnce(true)
|
||||||
|
|
||||||
|
const table = await config.api.table.save(
|
||||||
|
saveTableRequest({
|
||||||
|
schema: {
|
||||||
|
name: {
|
||||||
|
name: "name",
|
||||||
|
type: FieldType.STRING,
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
name: "description",
|
||||||
|
type: FieldType.STRING,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
const newView: CreateViewRequest = {
|
||||||
|
name: generator.name(),
|
||||||
|
tableId: table._id!,
|
||||||
|
schema: {
|
||||||
|
name: {
|
||||||
|
readonly: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
await config.api.viewV2.create(newView, {
|
||||||
|
status: 400,
|
||||||
|
body: {
|
||||||
|
message:
|
||||||
|
'Field "name" cannot be readonly as it is a required field',
|
||||||
|
status: 400,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it("readonly fields must be visible", async () => {
|
||||||
|
const table = await config.api.table.save(
|
||||||
|
saveTableRequest({
|
||||||
|
schema: {
|
||||||
|
name: {
|
||||||
|
name: "name",
|
||||||
|
type: FieldType.STRING,
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
name: "description",
|
||||||
|
type: FieldType.STRING,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
const newView: CreateViewRequest = {
|
||||||
|
name: generator.name(),
|
||||||
|
tableId: table._id!,
|
||||||
|
schema: {
|
||||||
|
name: {
|
||||||
|
visible: false,
|
||||||
|
readonly: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
await config.api.viewV2.create(newView, {
|
||||||
|
status: 400,
|
||||||
|
body: {
|
||||||
|
message:
|
||||||
|
'Field "name" must be visible if you want to make it readonly',
|
||||||
|
status: 400,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it("readonly fields cannot be used on free license", async () => {
|
||||||
|
mocks.licenses.useCloudFree()
|
||||||
|
const table = await config.api.table.save(
|
||||||
|
saveTableRequest({
|
||||||
|
schema: {
|
||||||
|
name: {
|
||||||
|
name: "name",
|
||||||
|
type: FieldType.STRING,
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
name: "description",
|
||||||
|
type: FieldType.STRING,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
const newView: CreateViewRequest = {
|
||||||
|
name: generator.name(),
|
||||||
|
tableId: table._id!,
|
||||||
|
schema: {
|
||||||
|
name: {
|
||||||
|
visible: true,
|
||||||
|
readonly: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
await config.api.viewV2.create(newView, {
|
||||||
|
status: 400,
|
||||||
|
body: {
|
||||||
|
message: "Readonly fields are not enabled for your tenant",
|
||||||
|
status: 400,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("update", () => {
|
describe("update", () => {
|
||||||
|
@ -251,6 +467,7 @@ describe.each([
|
||||||
})
|
})
|
||||||
|
|
||||||
it("can update all fields", async () => {
|
it("can update all fields", async () => {
|
||||||
|
mocks.licenses.useViewReadonlyColumns()
|
||||||
const tableId = table._id!
|
const tableId = table._id!
|
||||||
|
|
||||||
const updatedData: Required<UpdateViewRequest> = {
|
const updatedData: Required<UpdateViewRequest> = {
|
||||||
|
@ -275,6 +492,10 @@ describe.each([
|
||||||
Category: {
|
Category: {
|
||||||
visible: false,
|
visible: false,
|
||||||
},
|
},
|
||||||
|
Price: {
|
||||||
|
visible: true,
|
||||||
|
readonly: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
await config.api.viewV2.update(updatedData)
|
await config.api.viewV2.update(updatedData)
|
||||||
|
@ -291,7 +512,8 @@ describe.each([
|
||||||
visible: false,
|
visible: false,
|
||||||
}),
|
}),
|
||||||
Price: expect.objectContaining({
|
Price: expect.objectContaining({
|
||||||
visible: false,
|
visible: true,
|
||||||
|
readonly: true,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -450,6 +672,67 @@ describe.each([
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("cannot update views with readonly on on free license", async () => {
|
||||||
|
mocks.licenses.useViewReadonlyColumns()
|
||||||
|
|
||||||
|
view = await config.api.viewV2.update({
|
||||||
|
...view,
|
||||||
|
schema: {
|
||||||
|
Price: {
|
||||||
|
visible: true,
|
||||||
|
readonly: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
mocks.licenses.useCloudFree()
|
||||||
|
await config.api.viewV2.update(view, {
|
||||||
|
status: 400,
|
||||||
|
body: {
|
||||||
|
message: "Readonly fields are not enabled for your tenant",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it("can remove readonly config after license downgrade", async () => {
|
||||||
|
mocks.licenses.useViewReadonlyColumns()
|
||||||
|
|
||||||
|
view = await config.api.viewV2.update({
|
||||||
|
...view,
|
||||||
|
schema: {
|
||||||
|
Price: {
|
||||||
|
visible: true,
|
||||||
|
readonly: true,
|
||||||
|
},
|
||||||
|
Category: {
|
||||||
|
visible: true,
|
||||||
|
readonly: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
mocks.licenses.useCloudFree()
|
||||||
|
const res = await config.api.viewV2.update({
|
||||||
|
...view,
|
||||||
|
schema: {
|
||||||
|
Price: {
|
||||||
|
visible: true,
|
||||||
|
readonly: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
expect(res).toEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
...view,
|
||||||
|
schema: {
|
||||||
|
Price: {
|
||||||
|
visible: true,
|
||||||
|
readonly: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("delete", () => {
|
describe("delete", () => {
|
||||||
|
@ -491,15 +774,35 @@ describe.each([
|
||||||
const updatedTable = await config.api.table.get(table._id!)
|
const updatedTable = await config.api.table.get(table._id!)
|
||||||
const viewSchema = updatedTable.views![view!.name!].schema as Record<
|
const viewSchema = updatedTable.views![view!.name!].schema as Record<
|
||||||
string,
|
string,
|
||||||
UIFieldMetadata
|
ViewUIFieldMetadata
|
||||||
>
|
>
|
||||||
expect(viewSchema.Price?.visible).toEqual(false)
|
expect(viewSchema.Price?.visible).toEqual(false)
|
||||||
|
expect(viewSchema.Category?.visible).toEqual(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should be able to fetch readonly config after downgrades", async () => {
|
||||||
|
mocks.licenses.useViewReadonlyColumns()
|
||||||
|
const res = await config.api.viewV2.create({
|
||||||
|
name: generator.name(),
|
||||||
|
tableId: table._id!,
|
||||||
|
schema: {
|
||||||
|
Price: { visible: true, readonly: true },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
mocks.licenses.useCloudFree()
|
||||||
|
const view = await config.api.viewV2.get(res.id)
|
||||||
|
expect(view.schema?.Price).toEqual(
|
||||||
|
expect.objectContaining({ visible: true, readonly: true })
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("read", () => {
|
describe("read", () => {
|
||||||
it("views have extra data trimmed", async () => {
|
let view: ViewV2
|
||||||
const table = await config.api.table.save(
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
table = await config.api.table.save(
|
||||||
saveTableRequest({
|
saveTableRequest({
|
||||||
schema: {
|
schema: {
|
||||||
Country: {
|
Country: {
|
||||||
|
@ -514,7 +817,7 @@ describe.each([
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
const view = await config.api.viewV2.create({
|
view = await config.api.viewV2.create({
|
||||||
tableId: table._id!,
|
tableId: table._id!,
|
||||||
name: generator.guid(),
|
name: generator.guid(),
|
||||||
schema: {
|
schema: {
|
||||||
|
@ -523,7 +826,9 @@ describe.each([
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it("views have extra data trimmed", async () => {
|
||||||
let row = await config.api.row.save(view.id, {
|
let row = await config.api.row.save(view.id, {
|
||||||
Country: "Aussy",
|
Country: "Aussy",
|
||||||
Story: "aaaaa",
|
Story: "aaaaa",
|
||||||
|
@ -568,6 +873,27 @@ describe.each([
|
||||||
expect(row.one).toBeUndefined()
|
expect(row.one).toBeUndefined()
|
||||||
expect(row.two).toEqual("bar")
|
expect(row.two).toEqual("bar")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("can't persist readonly columns", async () => {
|
||||||
|
mocks.licenses.useViewReadonlyColumns()
|
||||||
|
const view = await config.api.viewV2.create({
|
||||||
|
tableId: table._id!,
|
||||||
|
name: generator.guid(),
|
||||||
|
schema: {
|
||||||
|
one: { visible: true, readonly: true },
|
||||||
|
two: { visible: true },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const row = await config.api.row.save(view.id, {
|
||||||
|
tableId: table!._id,
|
||||||
|
_viewId: view.id,
|
||||||
|
one: "foo",
|
||||||
|
two: "bar",
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(row.one).toBeUndefined()
|
||||||
|
expect(row.two).toEqual("bar")
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("patch", () => {
|
describe("patch", () => {
|
||||||
|
@ -588,6 +914,33 @@ describe.each([
|
||||||
expect(row.one).toEqual("foo")
|
expect(row.one).toEqual("foo")
|
||||||
expect(row.two).toEqual("newBar")
|
expect(row.two).toEqual("newBar")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("can't update readonly columns", async () => {
|
||||||
|
mocks.licenses.useViewReadonlyColumns()
|
||||||
|
const view = await config.api.viewV2.create({
|
||||||
|
tableId: table._id!,
|
||||||
|
name: generator.guid(),
|
||||||
|
schema: {
|
||||||
|
one: { visible: true, readonly: true },
|
||||||
|
two: { visible: true },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const newRow = await config.api.row.save(table._id!, {
|
||||||
|
one: "foo",
|
||||||
|
two: "bar",
|
||||||
|
})
|
||||||
|
await config.api.row.patch(view.id, {
|
||||||
|
tableId: table._id!,
|
||||||
|
_id: newRow._id!,
|
||||||
|
_rev: newRow._rev!,
|
||||||
|
one: "newFoo",
|
||||||
|
two: "newBar",
|
||||||
|
})
|
||||||
|
|
||||||
|
const row = await config.api.row.get(table._id!, newRow._id!)
|
||||||
|
expect(row.one).toEqual("foo")
|
||||||
|
expect(row.two).toEqual("newBar")
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("destroy", () => {
|
describe("destroy", () => {
|
||||||
|
|
|
@ -144,8 +144,12 @@ describe("trimViewRowInfo middleware", () => {
|
||||||
name: generator.guid(),
|
name: generator.guid(),
|
||||||
tableId: table._id!,
|
tableId: table._id!,
|
||||||
schema: {
|
schema: {
|
||||||
name: {},
|
name: {
|
||||||
address: {},
|
visible: true,
|
||||||
|
},
|
||||||
|
address: {
|
||||||
|
visible: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import {
|
import {
|
||||||
|
DocumentType,
|
||||||
FieldType,
|
FieldType,
|
||||||
Operation,
|
Operation,
|
||||||
QueryJson,
|
QueryJson,
|
||||||
|
@ -148,7 +149,10 @@ export async function search(
|
||||||
entityId: table._id!,
|
entityId: table._id!,
|
||||||
operation: Operation.READ,
|
operation: Operation.READ,
|
||||||
},
|
},
|
||||||
filters: cleanupFilters(query, allTables),
|
filters: {
|
||||||
|
...cleanupFilters(query, allTables),
|
||||||
|
documentType: DocumentType.ROW,
|
||||||
|
},
|
||||||
table,
|
table,
|
||||||
meta: {
|
meta: {
|
||||||
table,
|
table,
|
||||||
|
|
|
@ -2,10 +2,12 @@ import {
|
||||||
RenameColumn,
|
RenameColumn,
|
||||||
TableSchema,
|
TableSchema,
|
||||||
View,
|
View,
|
||||||
|
ViewUIFieldMetadata,
|
||||||
ViewV2,
|
ViewV2,
|
||||||
ViewV2Enriched,
|
ViewV2Enriched,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { db as dbCore } from "@budibase/backend-core"
|
import { HTTPError, db as dbCore } from "@budibase/backend-core"
|
||||||
|
import { features } from "@budibase/pro"
|
||||||
import { cloneDeep } from "lodash"
|
import { cloneDeep } from "lodash"
|
||||||
|
|
||||||
import * as utils from "../../../db/utils"
|
import * as utils from "../../../db/utils"
|
||||||
|
@ -13,6 +15,8 @@ import { isExternalTableID } from "../../../integrations/utils"
|
||||||
|
|
||||||
import * as internal from "./internal"
|
import * as internal from "./internal"
|
||||||
import * as external from "./external"
|
import * as external from "./external"
|
||||||
|
import sdk from "../../../sdk"
|
||||||
|
import { isRequired } from "../../../utilities/schema"
|
||||||
|
|
||||||
function pickApi(tableId: any) {
|
function pickApi(tableId: any) {
|
||||||
if (isExternalTableID(tableId)) {
|
if (isExternalTableID(tableId)) {
|
||||||
|
@ -31,14 +35,61 @@ export async function getEnriched(viewId: string): Promise<ViewV2Enriched> {
|
||||||
return pickApi(tableId).getEnriched(viewId)
|
return pickApi(tableId).getEnriched(viewId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function guardViewSchema(
|
||||||
|
tableId: string,
|
||||||
|
viewSchema?: Record<string, ViewUIFieldMetadata>
|
||||||
|
) {
|
||||||
|
if (!viewSchema || !Object.keys(viewSchema).length) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const table = await sdk.tables.getTable(tableId)
|
||||||
|
|
||||||
|
for (const field of Object.keys(viewSchema)) {
|
||||||
|
const tableSchemaField = table.schema[field]
|
||||||
|
if (!tableSchemaField) {
|
||||||
|
throw new HTTPError(
|
||||||
|
`Field "${field}" is not valid for the requested table`,
|
||||||
|
400
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (viewSchema[field].readonly) {
|
||||||
|
if (!(await features.isViewReadonlyColumnsEnabled())) {
|
||||||
|
throw new HTTPError(
|
||||||
|
`Readonly fields are not enabled for your tenant`,
|
||||||
|
400
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isRequired(tableSchemaField.constraints)) {
|
||||||
|
throw new HTTPError(
|
||||||
|
`Field "${field}" cannot be readonly as it is a required field`,
|
||||||
|
400
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!viewSchema[field].visible) {
|
||||||
|
throw new HTTPError(
|
||||||
|
`Field "${field}" must be visible if you want to make it readonly`,
|
||||||
|
400
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function create(
|
export async function create(
|
||||||
tableId: string,
|
tableId: string,
|
||||||
viewRequest: Omit<ViewV2, "id" | "version">
|
viewRequest: Omit<ViewV2, "id" | "version">
|
||||||
): Promise<ViewV2> {
|
): Promise<ViewV2> {
|
||||||
|
await guardViewSchema(tableId, viewRequest.schema)
|
||||||
|
|
||||||
return pickApi(tableId).create(tableId, viewRequest)
|
return pickApi(tableId).create(tableId, viewRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function update(tableId: string, view: ViewV2): Promise<ViewV2> {
|
export async function update(tableId: string, view: ViewV2): Promise<ViewV2> {
|
||||||
|
await guardViewSchema(tableId, view.schema)
|
||||||
|
|
||||||
return pickApi(tableId).update(tableId, view)
|
return pickApi(tableId).update(tableId, view)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +104,13 @@ export async function remove(viewId: string): Promise<ViewV2> {
|
||||||
|
|
||||||
export function allowedFields(view: View | ViewV2) {
|
export function allowedFields(view: View | ViewV2) {
|
||||||
return [
|
return [
|
||||||
...Object.keys(view?.schema || {}),
|
...Object.keys(view?.schema || {}).filter(key => {
|
||||||
|
if (!isV2(view)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
const fieldSchema = view.schema![key]
|
||||||
|
return fieldSchema.visible && !fieldSchema.readonly
|
||||||
|
}),
|
||||||
...dbCore.CONSTANT_EXTERNAL_ROW_COLS,
|
...dbCore.CONSTANT_EXTERNAL_ROW_COLS,
|
||||||
...dbCore.CONSTANT_INTERNAL_ROW_COLS,
|
...dbCore.CONSTANT_INTERNAL_ROW_COLS,
|
||||||
]
|
]
|
||||||
|
|
|
@ -4,6 +4,7 @@ import {
|
||||||
TableSchema,
|
TableSchema,
|
||||||
FieldSchema,
|
FieldSchema,
|
||||||
Row,
|
Row,
|
||||||
|
FieldConstraints,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { ValidColumnNameRegex, utils } from "@budibase/shared-core"
|
import { ValidColumnNameRegex, utils } from "@budibase/shared-core"
|
||||||
import { db } from "@budibase/backend-core"
|
import { db } from "@budibase/backend-core"
|
||||||
|
@ -40,6 +41,15 @@ export function isRows(rows: any): rows is Rows {
|
||||||
return Array.isArray(rows) && rows.every(row => typeof row === "object")
|
return Array.isArray(rows) && rows.every(row => typeof row === "object")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isRequired(constraints: FieldConstraints | undefined) {
|
||||||
|
const isRequired =
|
||||||
|
!!constraints &&
|
||||||
|
((typeof constraints.presence !== "boolean" &&
|
||||||
|
constraints.presence?.allowEmpty === false) ||
|
||||||
|
constraints.presence === true)
|
||||||
|
return isRequired
|
||||||
|
}
|
||||||
|
|
||||||
export function validate(rows: Rows, schema: TableSchema): ValidationResults {
|
export function validate(rows: Rows, schema: TableSchema): ValidationResults {
|
||||||
const results: ValidationResults = {
|
const results: ValidationResults = {
|
||||||
schemaValidation: {},
|
schemaValidation: {},
|
||||||
|
@ -62,12 +72,6 @@ export function validate(rows: Rows, schema: TableSchema): ValidationResults {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const isRequired =
|
|
||||||
!!constraints &&
|
|
||||||
((typeof constraints.presence !== "boolean" &&
|
|
||||||
!constraints.presence?.allowEmpty) ||
|
|
||||||
constraints.presence === true)
|
|
||||||
|
|
||||||
// If the columnType is not a string, then it's not present in the schema, and should be added to the invalid columns array
|
// If the columnType is not a string, then it's not present in the schema, and should be added to the invalid columns array
|
||||||
if (typeof columnType !== "string") {
|
if (typeof columnType !== "string") {
|
||||||
results.invalidColumns.push(columnName)
|
results.invalidColumns.push(columnName)
|
||||||
|
@ -101,7 +105,12 @@ export function validate(rows: Rows, schema: TableSchema): ValidationResults {
|
||||||
} else if (
|
} else if (
|
||||||
(columnType === FieldType.BB_REFERENCE ||
|
(columnType === FieldType.BB_REFERENCE ||
|
||||||
columnType === FieldType.BB_REFERENCE_SINGLE) &&
|
columnType === FieldType.BB_REFERENCE_SINGLE) &&
|
||||||
!isValidBBReference(columnData, columnType, columnSubtype, isRequired)
|
!isValidBBReference(
|
||||||
|
columnData,
|
||||||
|
columnType,
|
||||||
|
columnSubtype,
|
||||||
|
isRequired(constraints)
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
results.schemaValidation[columnName] = false
|
results.schemaValidation[columnName] = false
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
import { isRequired } from "../schema"
|
||||||
|
|
||||||
|
describe("schema utilities", () => {
|
||||||
|
describe("isRequired", () => {
|
||||||
|
it("not required by default", () => {
|
||||||
|
const result = isRequired(undefined)
|
||||||
|
expect(result).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("required when presence is true", () => {
|
||||||
|
const result = isRequired({ presence: true })
|
||||||
|
expect(result).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("not required when presence is false", () => {
|
||||||
|
const result = isRequired({ presence: false })
|
||||||
|
expect(result).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("not required when presence is an empty object", () => {
|
||||||
|
const result = isRequired({ presence: {} })
|
||||||
|
expect(result).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("not required when allowEmpty is true", () => {
|
||||||
|
const result = isRequired({ presence: { allowEmpty: true } })
|
||||||
|
expect(result).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("required when allowEmpty is false", () => {
|
||||||
|
const result = isRequired({ presence: { allowEmpty: false } })
|
||||||
|
expect(result).toBe(true)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
|
@ -1,10 +1,5 @@
|
||||||
import {
|
import { Row, Table, TableRequest, View } from "../../../documents"
|
||||||
Row,
|
import { ViewV2Enriched } from "../../../sdk"
|
||||||
Table,
|
|
||||||
TableRequest,
|
|
||||||
View,
|
|
||||||
ViewV2Enriched,
|
|
||||||
} from "../../../documents"
|
|
||||||
|
|
||||||
export type TableViewsResponse = { [key: string]: View | ViewV2Enriched }
|
export type TableViewsResponse = { [key: string]: View | ViewV2Enriched }
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { ViewV2, ViewV2Enriched } from "../../../documents"
|
import { ViewV2 } from "../../../documents"
|
||||||
|
import { ViewV2Enriched } from "../../../sdk/view"
|
||||||
|
|
||||||
export interface ViewResponse {
|
export interface ViewResponse {
|
||||||
data: ViewV2
|
data: ViewV2
|
||||||
|
|
|
@ -92,6 +92,7 @@ export interface AcceptUserInviteResponse {
|
||||||
_id: string
|
_id: string
|
||||||
_rev: string
|
_rev: string
|
||||||
email: string
|
email: string
|
||||||
|
tenantId: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SyncUserRequest {
|
export interface SyncUserRequest {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { SearchFilter, SortOrder, SortType } from "../../api"
|
import { SearchFilter, SortOrder, SortType } from "../../api"
|
||||||
import { TableSchema, UIFieldMetadata } from "./table"
|
import { UIFieldMetadata } from "./table"
|
||||||
import { Document } from "../document"
|
import { Document } from "../document"
|
||||||
import { DBView } from "../../sdk"
|
import { DBView } from "../../sdk"
|
||||||
|
|
||||||
|
@ -33,6 +33,10 @@ export interface View {
|
||||||
groupBy?: string
|
groupBy?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ViewUIFieldMetadata = UIFieldMetadata & {
|
||||||
|
readonly?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
export interface ViewV2 {
|
export interface ViewV2 {
|
||||||
version: 2
|
version: 2
|
||||||
id: string
|
id: string
|
||||||
|
@ -45,11 +49,7 @@ export interface ViewV2 {
|
||||||
order?: SortOrder
|
order?: SortOrder
|
||||||
type?: SortType
|
type?: SortType
|
||||||
}
|
}
|
||||||
schema?: Record<string, UIFieldMetadata>
|
schema?: Record<string, ViewUIFieldMetadata>
|
||||||
}
|
|
||||||
|
|
||||||
export interface ViewV2Enriched extends ViewV2 {
|
|
||||||
schema?: TableSchema
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ViewSchema = ViewCountOrSumSchema | ViewStatisticsSchema
|
export type ViewSchema = ViewCountOrSumSchema | ViewStatisticsSchema
|
||||||
|
|
|
@ -21,3 +21,4 @@ export * from "./websocket"
|
||||||
export * from "./permissions"
|
export * from "./permissions"
|
||||||
export * from "./row"
|
export * from "./row"
|
||||||
export * from "./vm"
|
export * from "./vm"
|
||||||
|
export * from "./view"
|
||||||
|
|
|
@ -14,6 +14,7 @@ export enum Feature {
|
||||||
OFFLINE = "offline",
|
OFFLINE = "offline",
|
||||||
EXPANDED_PUBLIC_API = "expandedPublicApi",
|
EXPANDED_PUBLIC_API = "expandedPublicApi",
|
||||||
VIEW_PERMISSIONS = "viewPermissions",
|
VIEW_PERMISSIONS = "viewPermissions",
|
||||||
|
VIEW_READONLY_COLUMNS = "viewReadonlyColumns",
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PlanFeatures = { [key in PlanType]: Feature[] | undefined }
|
export type PlanFeatures = { [key in PlanType]: Feature[] | undefined }
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Operation, SortDirection } from "./datasources"
|
import { Operation, SortDirection } from "./datasources"
|
||||||
import { Row, Table } from "../documents"
|
import { Row, Table, DocumentType } from "../documents"
|
||||||
import { SortType } from "../api"
|
import { SortType } from "../api"
|
||||||
import { Knex } from "knex"
|
import { Knex } from "knex"
|
||||||
|
|
||||||
|
@ -62,11 +62,15 @@ export interface SearchFilters {
|
||||||
[SearchFilterOperator.CONTAINS_ANY]?: {
|
[SearchFilterOperator.CONTAINS_ANY]?: {
|
||||||
[key: string]: any[]
|
[key: string]: any[]
|
||||||
}
|
}
|
||||||
|
// specific to SQS/SQLite search on internal tables this can be used
|
||||||
|
// to make sure the documents returned are always filtered down to a
|
||||||
|
// specific document type (such as just rows)
|
||||||
|
documentType?: DocumentType
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SearchFilterKey = keyof Omit<
|
export type SearchFilterKey = keyof Omit<
|
||||||
SearchFilters,
|
SearchFilters,
|
||||||
"allOr" | "onEmptyFilter" | "fuzzyOr"
|
"allOr" | "onEmptyFilter" | "fuzzyOr" | "documentType"
|
||||||
>
|
>
|
||||||
|
|
||||||
export type SearchQueryFields = Omit<SearchFilters, "allOr" | "onEmptyFilter">
|
export type SearchQueryFields = Omit<SearchFilters, "allOr" | "onEmptyFilter">
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
import { TableSchema, ViewV2 } from "../documents"
|
||||||
|
|
||||||
|
export interface ViewV2Enriched extends ViewV2 {
|
||||||
|
schema?: TableSchema
|
||||||
|
}
|
|
@ -35,6 +35,7 @@ import {
|
||||||
} from "@budibase/backend-core"
|
} from "@budibase/backend-core"
|
||||||
import { checkAnyUserExists } from "../../../utilities/users"
|
import { checkAnyUserExists } from "../../../utilities/users"
|
||||||
import { isEmailConfigured } from "../../../utilities/email"
|
import { isEmailConfigured } from "../../../utilities/email"
|
||||||
|
import { BpmStatusKey, BpmStatusValue } from "@budibase/shared-core"
|
||||||
|
|
||||||
const MAX_USERS_UPLOAD_LIMIT = 1000
|
const MAX_USERS_UPLOAD_LIMIT = 1000
|
||||||
|
|
||||||
|
@ -444,10 +445,16 @@ export const inviteAccept = async (
|
||||||
|
|
||||||
await cache.invite.deleteCode(inviteCode)
|
await cache.invite.deleteCode(inviteCode)
|
||||||
|
|
||||||
|
// make sure onboarding flow is cleared
|
||||||
|
ctx.cookies.set(BpmStatusKey.ONBOARDING, BpmStatusValue.COMPLETED, {
|
||||||
|
expires: new Date(0),
|
||||||
|
})
|
||||||
|
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
_id: user._id!,
|
_id: user._id!,
|
||||||
_rev: user._rev!,
|
_rev: user._rev!,
|
||||||
email: user.email,
|
email: user.email,
|
||||||
|
tenantId: user.tenantId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -105,11 +105,6 @@ const NO_TENANCY_ENDPOINTS = [
|
||||||
route: "/api/admin/auth/oidc/callback",
|
route: "/api/admin/auth/oidc/callback",
|
||||||
method: "GET",
|
method: "GET",
|
||||||
},
|
},
|
||||||
// tenant is determined from code in redis
|
|
||||||
{
|
|
||||||
route: "/api/global/users/invite/accept",
|
|
||||||
method: "POST",
|
|
||||||
},
|
|
||||||
// global user search - no tenancy
|
// global user search - no tenancy
|
||||||
// :id is user id
|
// :id is user id
|
||||||
// TODO: this should really be `/api/system/users/:id`
|
// TODO: this should really be `/api/system/users/:id`
|
||||||
|
@ -117,6 +112,15 @@ const NO_TENANCY_ENDPOINTS = [
|
||||||
route: "/api/global/users/tenant/:id",
|
route: "/api/global/users/tenant/:id",
|
||||||
method: "GET",
|
method: "GET",
|
||||||
},
|
},
|
||||||
|
// tenant is determined from code in redis
|
||||||
|
{
|
||||||
|
route: "/api/global/users/invite/accept",
|
||||||
|
method: "POST",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
route: "/api/global/users/invite/:code",
|
||||||
|
method: "GET",
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
// most public endpoints are gets, but some are posts
|
// most public endpoints are gets, but some are posts
|
||||||
|
|
Loading…
Reference in New Issue