Merge branch 'master' of github.com:Budibase/budibase into develop

This commit is contained in:
mike12345567 2023-03-07 17:49:44 +00:00
commit ae3671ea42
26 changed files with 132 additions and 128 deletions

View File

@ -1,5 +1,5 @@
{
"version": "2.4.4-alpha.0",
"version": "2.4.4",
"npmClient": "yarn",
"packages": [
"packages/*"

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/backend-core",
"version": "2.4.4-alpha.0",
"version": "2.4.4",
"description": "Budibase backend core libraries used in server and worker",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
@ -24,7 +24,7 @@
"dependencies": {
"@budibase/nano": "10.1.2",
"@budibase/pouchdb-replication-stream": "1.2.10",
"@budibase/types": "2.4.4-alpha.0",
"@budibase/types": "^2.4.4",
"@shopify/jest-koa-mocks": "5.0.1",
"@techpass/passport-openidconnect": "0.3.2",
"aws-cloudfront-sign": "2.2.0",

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/bbui",
"description": "A UI solution used in the different Budibase projects.",
"version": "2.4.4-alpha.0",
"version": "2.4.4",
"license": "MPL-2.0",
"svelte": "src/index.js",
"module": "dist/bbui.es.js",
@ -38,7 +38,7 @@
],
"dependencies": {
"@adobe/spectrum-css-workflow-icons": "1.2.1",
"@budibase/string-templates": "2.4.4-alpha.0",
"@budibase/string-templates": "^2.4.4",
"@spectrum-css/accordion": "3.0.24",
"@spectrum-css/actionbutton": "1.0.1",
"@spectrum-css/actiongroup": "1.0.1",

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/builder",
"version": "2.4.4-alpha.0",
"version": "2.4.4",
"license": "GPL-3.0",
"private": true,
"scripts": {
@ -58,10 +58,10 @@
}
},
"dependencies": {
"@budibase/bbui": "2.4.4-alpha.0",
"@budibase/client": "2.4.4-alpha.0",
"@budibase/frontend-core": "2.4.4-alpha.0",
"@budibase/string-templates": "2.4.4-alpha.0",
"@budibase/bbui": "^2.4.4",
"@budibase/client": "^2.4.4",
"@budibase/frontend-core": "^2.4.4",
"@budibase/string-templates": "^2.4.4",
"@fortawesome/fontawesome-svg-core": "^6.2.1",
"@fortawesome/free-brands-svg-icons": "^6.2.1",
"@fortawesome/free-solid-svg-icons": "^6.2.1",

View File

@ -1,8 +1,9 @@
import { get } from "svelte/store"
import { store } from "builderStore"
import { users, auth } from "stores/portal"
import { auth } from "stores/portal"
import analytics from "analytics"
import { OnboardingData, OnboardingDesign, OnboardingPublish } from "./steps"
import { API } from "api"
const ONBOARDING_EVENT_PREFIX = "onboarding"
export const TOUR_STEP_KEYS = {
@ -83,8 +84,7 @@ const getTours = () => {
// Mark the users onboarding as complete
// Clear all tour related state
if (get(auth).user) {
await users.save({
...get(auth).user,
await API.updateSelf({
onboardedAt: new Date().toISOString(),
})
@ -114,8 +114,7 @@ const getTours = () => {
onComplete: async () => {
// Push the onboarding forward
if (get(auth).user) {
await users.save({
...get(auth).user,
await API.updateSelf({
onboardedAt: new Date().toISOString(),
})

View File

@ -13,6 +13,7 @@
await auth.updateSelf($values)
notifications.success("Information updated successfully")
} catch (error) {
console.error(error)
notifications.error("Failed to update information")
}
}

View File

@ -154,9 +154,14 @@ export function createAuthStore() {
await setInitInfo({})
},
updateSelf: async fields => {
const newUser = { ...get(auth).user, ...fields }
await API.updateSelf(newUser)
setUser(newUser)
await API.updateSelf({ ...fields })
// Refetch to enrich after update.
try {
const user = await API.fetchBuilderSelf()
setUser(user)
} catch (error) {
setUser(null)
}
},
forgotPassword: async email => {
const tenantId = get(store).tenantId

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/cli",
"version": "2.4.4-alpha.0",
"version": "2.4.4",
"description": "Budibase CLI, for developers, self hosting and migrations.",
"main": "dist/index.js",
"bin": {
@ -29,9 +29,9 @@
"outputPath": "build"
},
"dependencies": {
"@budibase/backend-core": "2.4.4-alpha.0",
"@budibase/string-templates": "2.4.4-alpha.0",
"@budibase/types": "2.4.4-alpha.0",
"@budibase/backend-core": "^2.4.4",
"@budibase/string-templates": "^2.4.4",
"@budibase/types": "^2.4.4",
"axios": "0.21.2",
"chalk": "4.1.0",
"cli-progress": "3.11.2",

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/client",
"version": "2.4.4-alpha.0",
"version": "2.4.4",
"license": "MPL-2.0",
"module": "dist/budibase-client.js",
"main": "dist/budibase-client.js",
@ -19,9 +19,9 @@
"dev:builder": "rollup -cw"
},
"dependencies": {
"@budibase/bbui": "2.4.4-alpha.0",
"@budibase/frontend-core": "2.4.4-alpha.0",
"@budibase/string-templates": "2.4.4-alpha.0",
"@budibase/bbui": "^2.4.4",
"@budibase/frontend-core": "^2.4.4",
"@budibase/string-templates": "^2.4.4",
"@spectrum-css/button": "^3.0.3",
"@spectrum-css/card": "^3.0.3",
"@spectrum-css/divider": "^1.0.3",

View File

@ -1,12 +1,12 @@
{
"name": "@budibase/frontend-core",
"version": "2.4.4-alpha.0",
"version": "2.4.4",
"description": "Budibase frontend core libraries used in builder and client",
"author": "Budibase",
"license": "MPL-2.0",
"svelte": "src/index.js",
"dependencies": {
"@budibase/bbui": "2.4.4-alpha.0",
"@budibase/bbui": "^2.4.4",
"lodash": "^4.17.21",
"svelte": "^3.46.2"
}

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/sdk",
"version": "2.4.4-alpha.0",
"version": "2.4.4",
"description": "Budibase Public API SDK",
"author": "Budibase",
"license": "MPL-2.0",

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/server",
"email": "hi@budibase.com",
"version": "2.4.4-alpha.0",
"version": "2.4.4",
"description": "Budibase Web Server",
"main": "src/index.ts",
"repository": {
@ -43,11 +43,11 @@
"license": "GPL-3.0",
"dependencies": {
"@apidevtools/swagger-parser": "10.0.3",
"@budibase/backend-core": "2.4.4-alpha.0",
"@budibase/client": "2.4.4-alpha.0",
"@budibase/pro": "2.4.4-alpha.0",
"@budibase/string-templates": "2.4.4-alpha.0",
"@budibase/types": "2.4.4-alpha.0",
"@budibase/backend-core": "^2.4.4",
"@budibase/client": "^2.4.4",
"@budibase/pro": "2.4.4",
"@budibase/string-templates": "^2.4.4",
"@budibase/types": "^2.4.4",
"@bull-board/api": "3.7.0",
"@bull-board/koa": "3.9.4",
"@elastic/elasticsearch": "7.10.0",

View File

@ -1278,14 +1278,14 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@2.4.4-alpha.0":
version "2.4.4-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.4.4-alpha.0.tgz#851515fec84676c2f1f07e7e2b521133f0de90ee"
integrity sha512-IAypJ0s1+2ZOKmJrBlByOksBY/rFd2Q0gyG19UGvkZez24suq8iTYC3s0DrzJUG2NnwZSjbO80aZJzrG6bvdSw==
"@budibase/backend-core@2.4.4":
version "2.4.4"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.4.4.tgz#a9f0b97543f0464d9f79cad3429e4a382e5fcdd7"
integrity sha512-ETTHUgmpEmkpLR+I7xTjXGIxaqMxeyuKkaWF8l0LVqRukKuZ9dNtAUZAWAGvoL4J6Y+Q4ymKofwy1Ep5MYbVog==
dependencies:
"@budibase/nano" "10.1.2"
"@budibase/pouchdb-replication-stream" "1.2.10"
"@budibase/types" "2.4.4-alpha.0"
"@budibase/types" "^2.4.4"
"@shopify/jest-koa-mocks" "5.0.1"
"@techpass/passport-openidconnect" "0.3.2"
aws-cloudfront-sign "2.2.0"
@ -1417,14 +1417,14 @@
pouchdb-promise "^6.0.4"
through2 "^2.0.0"
"@budibase/pro@2.4.4-alpha.0":
version "2.4.4-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.4.4-alpha.0.tgz#5d6d881b9e315cbd1c69ad3dbfb8f2f8a9252f18"
integrity sha512-kUDy2aB6mT2kQPBVqd3yPnreqPUltxNsfztfcP7K3RBO2/f5qtSS60vi2A1NlNW5yKBKUu6w+uN0Kc9T5v9DRg==
"@budibase/pro@2.4.4":
version "2.4.4"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.4.4.tgz#b790ea89d230b2cbcf63a4f5a41669849ba537d7"
integrity sha512-E2TEnu9dHXV/O61KgxgADOKoW6oxrd2mI1l9i4YAc4AigNDSiW3sWMPmrg3IxZVs24WDPz1mrjzRI60gvAIugQ==
dependencies:
"@budibase/backend-core" "2.4.4-alpha.0"
"@budibase/backend-core" "2.4.4"
"@budibase/string-templates" "2.3.20"
"@budibase/types" "2.4.4-alpha.0"
"@budibase/types" "2.4.4"
"@koa/router" "8.0.8"
bull "4.10.1"
joi "17.6.0"
@ -1463,10 +1463,10 @@
lodash "^4.17.20"
vm2 "^3.9.4"
"@budibase/types@2.4.4-alpha.0":
version "2.4.4-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.4.4-alpha.0.tgz#23d1223fc0621b25ac8e86c5c57cf39d1e9c899b"
integrity sha512-dVRLM0Qtsl27v6Q2pLlClmzV63+gV8UpiEUoyt87UrF/6X3JUmkHo0LXSamdW6Y+nVQM5nMKGDvyA9vzvPOZZQ==
"@budibase/types@2.4.4", "@budibase/types@^2.4.4":
version "2.4.4"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.4.4.tgz#e4532ca337cc5ee318a7c3ee8f496d8de72890e2"
integrity sha512-6S07bTt4shJsM7D5lm1MJBbJf1Z1N+tBxu+DeJUw9UpGJql3mh3gHEVeNwLJkXxIiwbP2M6a+RjhVAFpj6IuSQ==
"@bull-board/api@3.7.0":
version "3.7.0"

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/string-templates",
"version": "2.4.4-alpha.0",
"version": "2.4.4",
"description": "Handlebars wrapper for Budibase templating.",
"main": "src/index.cjs",
"module": "dist/bundle.mjs",

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/types",
"version": "2.4.4-alpha.0",
"version": "2.4.4",
"description": "Budibase types",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View File

@ -17,6 +17,7 @@ export interface UpdateSelfRequest {
lastName?: string
password?: string
forceResetPassword?: boolean
onboardedAt?: string
}
export interface UpdateSelfResponse {

View File

@ -1,10 +1,3 @@
export interface UpdateSelf {
firstName?: string
lastName?: string
password?: string
forceResetPassword?: boolean
}
export interface SaveUserOpts {
hashPassword?: boolean
requirePassword?: boolean

View File

@ -1,8 +1,7 @@
{
"name": "@budibase/worker",
"email": "hi@budibase.com",
"version": "2.4.4-alpha.0",
"description": "Budibase background service",
"version": "2.4.4",
"main": "src/index.ts",
"repository": {
"type": "git",
@ -36,10 +35,10 @@
"author": "Budibase",
"license": "GPL-3.0",
"dependencies": {
"@budibase/backend-core": "2.4.4-alpha.0",
"@budibase/pro": "2.4.4-alpha.0",
"@budibase/string-templates": "2.4.4-alpha.0",
"@budibase/types": "2.4.4-alpha.0",
"@budibase/backend-core": "^2.4.4",
"@budibase/pro": "2.4.4",
"@budibase/string-templates": "^2.4.4",
"@budibase/types": "^2.4.4",
"@koa/router": "8.0.8",
"@sentry/node": "6.17.7",
"@techpass/passport-openidconnect": "0.3.2",

View File

@ -10,12 +10,7 @@ import {
} from "@budibase/backend-core"
import env from "../../../environment"
import { groups } from "@budibase/pro"
import {
UpdateSelfRequest,
UpdateSelfResponse,
UpdateSelf,
UserCtx,
} from "@budibase/types"
import { UpdateSelfRequest, UpdateSelfResponse, UserCtx } from "@budibase/types"
const { getCookie, clearCookie, newid } = utils
function newTestApiKey() {
@ -122,15 +117,14 @@ export async function getSelf(ctx: any) {
export async function updateSelf(
ctx: UserCtx<UpdateSelfRequest, UpdateSelfResponse>
) {
const body = ctx.request.body
const update: UpdateSelf = {
firstName: body.firstName,
lastName: body.lastName,
password: body.password,
forceResetPassword: body.forceResetPassword,
}
const update = ctx.request.body
const user = await userSdk.updateSelf(ctx.user._id!, update)
let user = await userSdk.getUser(ctx.user._id!)
user = {
...user,
...update,
}
user = await userSdk.save(user, { requirePassword: false })
if (update.password) {
// Log all other sessions out apart from the current one

View File

@ -11,7 +11,7 @@ router
.get("/api/global/self", controller.getSelf)
.post(
"/api/global/self",
users.buildUserSaveValidation(true),
users.buildSelfSaveValidation(),
controller.updateSelf
)

View File

@ -18,30 +18,26 @@ describe("/api/global/self", () => {
})
describe("update", () => {
it("should update self", async () => {
it("should reject updates with forbidden keys", async () => {
const user = await config.createUser()
await config.createSession(user)
delete user.password
const res = await config.api.self.updateSelf(user)
const dbUser = await config.getUser(user.email)
user._rev = dbUser._rev
user.dayPassRecordedAt = mocks.date.MOCK_DATE.toISOString()
expect(res.body._id).toBe(user._id)
expect(events.user.updated).toBeCalledTimes(1)
expect(events.user.updated).toBeCalledWith(dbUser)
expect(events.user.passwordUpdated).not.toBeCalled()
await config.api.self.updateSelf(user, user).expect(400)
})
it("should update password", async () => {
const user = await config.createUser()
await config.createSession(user)
user.password = "newPassword"
const res = await config.api.self.updateSelf(user)
const res = await config.api.self
.updateSelf(user, {
password: "newPassword",
})
.expect(200)
const dbUser = await config.getUser(user.email)
user._rev = dbUser._rev
user.dayPassRecordedAt = mocks.date.MOCK_DATE.toISOString()
expect(res.body._id).toBe(user._id)
@ -51,4 +47,22 @@ describe("/api/global/self", () => {
expect(events.user.passwordUpdated).toBeCalledWith(dbUser)
})
})
it("should update onboarding", async () => {
const user = await config.createUser()
await config.createSession(user)
const res = await config.api.self
.updateSelf(user, {
onboardedAt: "2023-03-07T14:10:54.869Z",
})
.expect(200)
const dbUser = await config.getUser(user.email)
user._rev = dbUser._rev
user.dayPassRecordedAt = mocks.date.MOCK_DATE.toISOString()
expect(dbUser.onboardedAt).toBe("2023-03-07T14:10:54.869Z")
expect(res.body._id).toBe(user._id)
})
})

View File

@ -128,7 +128,7 @@ router
.get("/api/global/users/self", selfController.getSelf)
.post(
"/api/global/users/self",
users.buildUserSaveValidation(true),
users.buildUserSaveValidation(),
selfController.updateSelf
)

View File

@ -17,13 +17,22 @@ let schema: any = {
roles: Joi.object().pattern(/.*/, Joi.string()).required().unknown(true),
}
export const buildUserSaveValidation = (isSelf = false) => {
if (!isSelf) {
schema = {
...schema,
_id: Joi.string(),
_rev: Joi.string(),
}
export const buildSelfSaveValidation = () => {
schema = {
password: Joi.string().optional(),
forceResetPassword: Joi.boolean().optional(),
firstName: Joi.string().allow("").optional(),
lastName: Joi.string().allow("").optional(),
onboardedAt: Joi.string().optional(),
}
return auth.joiValidator.body(Joi.object(schema).required().unknown(false))
}
export const buildUserSaveValidation = () => {
schema = {
...schema,
_id: Joi.string(),
_rev: Joi.string(),
}
return auth.joiValidator.body(Joi.object(schema).required().unknown(true))
}

View File

@ -29,7 +29,6 @@ import {
PlatformUserByEmail,
RowResponse,
SearchUsersRequest,
UpdateSelf,
User,
SaveUserOpts,
} from "@budibase/types"
@ -227,15 +226,6 @@ export async function isPreventPasswordActions(user: User) {
return !!(account && isSSOAccount(account))
}
export async function updateSelf(id: string, data: UpdateSelf) {
let user = await getUser(id)
user = {
...user,
...data,
}
return save(user)
}
export const save = async (
user: User,
opts: SaveUserOpts = {}

View File

@ -7,13 +7,12 @@ export class SelfAPI extends TestAPI {
super(config)
}
updateSelf = (user: User) => {
updateSelf = (user: User, update: any) => {
return this.request
.post(`/api/global/self`)
.send(user)
.send(update)
.set(this.config.authHeaders(user))
.expect("Content-Type", /json/)
.expect(200)
}
getSelf = (user: User) => {

View File

@ -475,14 +475,14 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@2.4.4-alpha.0":
version "2.4.4-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.4.4-alpha.0.tgz#851515fec84676c2f1f07e7e2b521133f0de90ee"
integrity sha512-IAypJ0s1+2ZOKmJrBlByOksBY/rFd2Q0gyG19UGvkZez24suq8iTYC3s0DrzJUG2NnwZSjbO80aZJzrG6bvdSw==
"@budibase/backend-core@2.4.4":
version "2.4.4"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.4.4.tgz#a9f0b97543f0464d9f79cad3429e4a382e5fcdd7"
integrity sha512-ETTHUgmpEmkpLR+I7xTjXGIxaqMxeyuKkaWF8l0LVqRukKuZ9dNtAUZAWAGvoL4J6Y+Q4ymKofwy1Ep5MYbVog==
dependencies:
"@budibase/nano" "10.1.2"
"@budibase/pouchdb-replication-stream" "1.2.10"
"@budibase/types" "2.4.4-alpha.0"
"@budibase/types" "^2.4.4"
"@shopify/jest-koa-mocks" "5.0.1"
"@techpass/passport-openidconnect" "0.3.2"
aws-cloudfront-sign "2.2.0"
@ -564,14 +564,14 @@
pouchdb-promise "^6.0.4"
through2 "^2.0.0"
"@budibase/pro@2.4.4-alpha.0":
version "2.4.4-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.4.4-alpha.0.tgz#5d6d881b9e315cbd1c69ad3dbfb8f2f8a9252f18"
integrity sha512-kUDy2aB6mT2kQPBVqd3yPnreqPUltxNsfztfcP7K3RBO2/f5qtSS60vi2A1NlNW5yKBKUu6w+uN0Kc9T5v9DRg==
"@budibase/pro@2.4.4":
version "2.4.4"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.4.4.tgz#b790ea89d230b2cbcf63a4f5a41669849ba537d7"
integrity sha512-E2TEnu9dHXV/O61KgxgADOKoW6oxrd2mI1l9i4YAc4AigNDSiW3sWMPmrg3IxZVs24WDPz1mrjzRI60gvAIugQ==
dependencies:
"@budibase/backend-core" "2.4.4-alpha.0"
"@budibase/backend-core" "2.4.4"
"@budibase/string-templates" "2.3.20"
"@budibase/types" "2.4.4-alpha.0"
"@budibase/types" "2.4.4"
"@koa/router" "8.0.8"
bull "4.10.1"
joi "17.6.0"
@ -592,10 +592,10 @@
lodash "^4.17.20"
vm2 "^3.9.4"
"@budibase/types@2.4.4-alpha.0":
version "2.4.4-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.4.4-alpha.0.tgz#23d1223fc0621b25ac8e86c5c57cf39d1e9c899b"
integrity sha512-dVRLM0Qtsl27v6Q2pLlClmzV63+gV8UpiEUoyt87UrF/6X3JUmkHo0LXSamdW6Y+nVQM5nMKGDvyA9vzvPOZZQ==
"@budibase/types@2.4.4", "@budibase/types@^2.4.4":
version "2.4.4"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.4.4.tgz#e4532ca337cc5ee318a7c3ee8f496d8de72890e2"
integrity sha512-6S07bTt4shJsM7D5lm1MJBbJf1Z1N+tBxu+DeJUw9UpGJql3mh3gHEVeNwLJkXxIiwbP2M6a+RjhVAFpj6IuSQ==
"@cspotcode/source-map-support@^0.8.0":
version "0.8.1"