Merge branch 'develop' into chore/remove_old_zlib_ref

This commit is contained in:
adrinr 2023-04-17 11:28:43 +01:00
commit 33c3b67f8c
23 changed files with 235 additions and 81 deletions

View File

@ -1,5 +1,5 @@
{
"version": "2.5.5-alpha.0",
"version": "2.5.5-alpha.2",
"npmClient": "yarn",
"useWorkspaces": true,
"packages": ["packages/*"],

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/backend-core",
"version": "2.5.5-alpha.0",
"version": "2.5.5-alpha.2",
"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.5.5-alpha.0",
"@budibase/types": "2.5.5-alpha.2",
"@shopify/jest-koa-mocks": "5.0.1",
"@techpass/passport-openidconnect": "0.3.2",
"aws-cloudfront-sign": "2.2.0",

View File

@ -24,7 +24,7 @@ export enum PermissionType {
QUERY = "query",
}
class Permission {
export class Permission {
type: PermissionType
level: PermissionLevel
@ -34,7 +34,7 @@ class Permission {
}
}
function levelToNumber(perm: PermissionLevel) {
export function levelToNumber(perm: PermissionLevel) {
switch (perm) {
// not everything has execute privileges
case PermissionLevel.EXECUTE:
@ -55,7 +55,7 @@ function levelToNumber(perm: PermissionLevel) {
* @param {string} userPermLevel The permission level of the user.
* @return {string[]} All the permission levels this user is allowed to carry out.
*/
function getAllowedLevels(userPermLevel: PermissionLevel) {
export function getAllowedLevels(userPermLevel: PermissionLevel): string[] {
switch (userPermLevel) {
case PermissionLevel.EXECUTE:
return [PermissionLevel.EXECUTE]
@ -64,9 +64,9 @@ function getAllowedLevels(userPermLevel: PermissionLevel) {
case PermissionLevel.WRITE:
case PermissionLevel.ADMIN:
return [
PermissionLevel.EXECUTE,
PermissionLevel.READ,
PermissionLevel.WRITE,
PermissionLevel.EXECUTE,
]
default:
return []
@ -81,7 +81,7 @@ export enum BuiltinPermissionID {
POWER = "power",
}
const BUILTIN_PERMISSIONS = {
export const BUILTIN_PERMISSIONS = {
PUBLIC: {
_id: BuiltinPermissionID.PUBLIC,
name: "Public",

View File

@ -0,0 +1,145 @@
import { cloneDeep } from "lodash"
import * as permissions from "../permissions"
import { BUILTIN_ROLE_IDS } from "../roles"
describe("levelToNumber", () => {
it("should return 0 for EXECUTE", () => {
expect(permissions.levelToNumber(permissions.PermissionLevel.EXECUTE)).toBe(
0
)
})
it("should return 1 for READ", () => {
expect(permissions.levelToNumber(permissions.PermissionLevel.READ)).toBe(1)
})
it("should return 2 for WRITE", () => {
expect(permissions.levelToNumber(permissions.PermissionLevel.WRITE)).toBe(2)
})
it("should return 3 for ADMIN", () => {
expect(permissions.levelToNumber(permissions.PermissionLevel.ADMIN)).toBe(3)
})
it("should return -1 for an unknown permission level", () => {
expect(
permissions.levelToNumber("unknown" as permissions.PermissionLevel)
).toBe(-1)
})
})
describe("getAllowedLevels", () => {
it('should return ["execute"] for EXECUTE', () => {
expect(
permissions.getAllowedLevels(permissions.PermissionLevel.EXECUTE)
).toEqual([permissions.PermissionLevel.EXECUTE])
})
it('should return ["execute", "read"] for READ', () => {
expect(
permissions.getAllowedLevels(permissions.PermissionLevel.READ)
).toEqual([
permissions.PermissionLevel.EXECUTE,
permissions.PermissionLevel.READ,
])
})
it('should return ["execute", "read", "write"] for WRITE', () => {
expect(
permissions.getAllowedLevels(permissions.PermissionLevel.WRITE)
).toEqual([
permissions.PermissionLevel.EXECUTE,
permissions.PermissionLevel.READ,
permissions.PermissionLevel.WRITE,
])
})
it('should return ["execute", "read", "write"] for ADMIN', () => {
expect(
permissions.getAllowedLevels(permissions.PermissionLevel.ADMIN)
).toEqual([
permissions.PermissionLevel.EXECUTE,
permissions.PermissionLevel.READ,
permissions.PermissionLevel.WRITE,
])
})
it("should return [] for an unknown permission level", () => {
expect(
permissions.getAllowedLevels("unknown" as permissions.PermissionLevel)
).toEqual([])
})
})
describe("doesHaveBasePermission", () => {
it("should return true if base permission has the required level", () => {
const permType = permissions.PermissionType.USER
const permLevel = permissions.PermissionLevel.READ
const rolesHierarchy = [
{
roleId: BUILTIN_ROLE_IDS.ADMIN,
permissionId: permissions.BuiltinPermissionID.ADMIN,
},
]
expect(
permissions.doesHaveBasePermission(permType, permLevel, rolesHierarchy)
).toBe(true)
})
it("should return false if base permission does not have the required level", () => {
const permType = permissions.PermissionType.APP
const permLevel = permissions.PermissionLevel.READ
const rolesHierarchy = [
{
roleId: BUILTIN_ROLE_IDS.PUBLIC,
permissionId: permissions.BuiltinPermissionID.PUBLIC,
},
]
expect(
permissions.doesHaveBasePermission(permType, permLevel, rolesHierarchy)
).toBe(false)
})
})
describe("isPermissionLevelHigherThanRead", () => {
it("should return true if level is higher than read", () => {
expect(
permissions.isPermissionLevelHigherThanRead(
permissions.PermissionLevel.WRITE
)
).toBe(true)
})
it("should return false if level is read or lower", () => {
expect(
permissions.isPermissionLevelHigherThanRead(
permissions.PermissionLevel.READ
)
).toBe(false)
})
})
describe("getBuiltinPermissions", () => {
it("returns a clone of the builtin permissions", () => {
const builtins = permissions.getBuiltinPermissions()
expect(builtins).toEqual(cloneDeep(permissions.BUILTIN_PERMISSIONS))
expect(builtins).not.toBe(permissions.BUILTIN_PERMISSIONS)
})
})
describe("getBuiltinPermissionByID", () => {
it("returns correct permission object for valid ID", () => {
const expectedPermission = {
_id: permissions.BuiltinPermissionID.PUBLIC,
name: "Public",
permissions: [
new permissions.Permission(
permissions.PermissionType.WEBHOOK,
permissions.PermissionLevel.EXECUTE
),
],
}
expect(permissions.getBuiltinPermissionByID("public")).toEqual(
expectedPermission
)
})
})

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/bbui",
"description": "A UI solution used in the different Budibase projects.",
"version": "2.5.5-alpha.0",
"version": "2.5.5-alpha.2",
"license": "MPL-2.0",
"svelte": "src/index.js",
"module": "dist/bbui.es.js",
@ -38,8 +38,8 @@
],
"dependencies": {
"@adobe/spectrum-css-workflow-icons": "1.2.1",
"@budibase/shared-core": "2.5.5-alpha.0",
"@budibase/string-templates": "2.5.5-alpha.0",
"@budibase/shared-core": "2.5.5-alpha.2",
"@budibase/string-templates": "2.5.5-alpha.2",
"@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.5.5-alpha.0",
"version": "2.5.5-alpha.2",
"license": "GPL-3.0",
"private": true,
"scripts": {
@ -58,11 +58,11 @@
}
},
"dependencies": {
"@budibase/bbui": "2.5.5-alpha.0",
"@budibase/client": "2.5.5-alpha.0",
"@budibase/frontend-core": "2.5.5-alpha.0",
"@budibase/shared-core": "2.5.5-alpha.0",
"@budibase/string-templates": "2.5.5-alpha.0",
"@budibase/bbui": "2.5.5-alpha.2",
"@budibase/client": "2.5.5-alpha.2",
"@budibase/frontend-core": "2.5.5-alpha.2",
"@budibase/shared-core": "2.5.5-alpha.2",
"@budibase/string-templates": "2.5.5-alpha.2",
"@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,6 +1,6 @@
{
"name": "@budibase/cli",
"version": "2.5.5-alpha.0",
"version": "2.5.5-alpha.2",
"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.5.5-alpha.0",
"@budibase/string-templates": "2.5.5-alpha.0",
"@budibase/types": "2.5.5-alpha.0",
"@budibase/backend-core": "2.5.5-alpha.2",
"@budibase/string-templates": "2.5.5-alpha.2",
"@budibase/types": "2.5.5-alpha.2",
"axios": "0.21.2",
"chalk": "4.1.0",
"cli-progress": "3.11.2",

View File

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

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/sdk",
"version": "2.5.5-alpha.0",
"version": "2.5.5-alpha.2",
"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.5.5-alpha.0",
"version": "2.5.5-alpha.2",
"description": "Budibase Web Server",
"main": "src/index.ts",
"repository": {
@ -45,12 +45,12 @@
"license": "GPL-3.0",
"dependencies": {
"@apidevtools/swagger-parser": "10.0.3",
"@budibase/backend-core": "2.5.5-alpha.0",
"@budibase/client": "2.5.5-alpha.0",
"@budibase/pro": "2.5.5-alpha.0",
"@budibase/shared-core": "2.5.5-alpha.0",
"@budibase/string-templates": "2.5.5-alpha.0",
"@budibase/types": "2.5.5-alpha.0",
"@budibase/backend-core": "2.5.5-alpha.2",
"@budibase/client": "2.5.5-alpha.2",
"@budibase/pro": "2.5.5-alpha.2",
"@budibase/shared-core": "2.5.5-alpha.2",
"@budibase/string-templates": "2.5.5-alpha.2",
"@budibase/types": "2.5.5-alpha.2",
"@bull-board/api": "3.7.0",
"@bull-board/koa": "3.9.4",
"@elastic/elasticsearch": "7.10.0",

View File

@ -11,6 +11,7 @@ if [ "$1" = '/opt/mssql/bin/sqlservr' ]; then
echo "RUNNING BUDIBASE SETUP"
cat setup.sql
#run the setup script to create the DB and the schema in the DB
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Passw0rd -i setup.sql

View File

@ -34,7 +34,7 @@ GO
CREATE TABLE people
(
name varchar(30) NOT NULL,
age varchar(20),
age int default 20 NOT NULL,
CONSTRAINT pk_people PRIMARY KEY NONCLUSTERED (name, age)
);
@ -50,22 +50,22 @@ VALUES
('Processing', 1);
INSERT INTO people (name, age)
VALUES ('Bob', '30'),
('Bert', '10'),
('Jack', '12'),
('Mike', '31'),
('Dave', '44'),
('Jim', '43'),
('Kerry', '32'),
('Julie', '12'),
('Kim', '55'),
('Andy', '33'),
('John', '22'),
('Ruth', '66'),
('Robert', '88'),
('Bobert', '99'),
('Jan', '22'),
('Megan', '11');
VALUES ('Bob', 30),
('Bert', 10),
('Jack', 12),
('Mike', 31),
('Dave', 44),
('Jim', 43),
('Kerry', 32),
('Julie', 12),
('Kim', 55),
('Andy', 33),
('John', 22),
('Ruth', 66),
('Robert', 88),
('Bobert', 99),
('Jan', 22),
('Megan', 11);
IF OBJECT_ID ('Chains.sizes', 'U') IS NOT NULL

View File

@ -3,7 +3,7 @@ USE main;
CREATE TABLE Persons (
PersonID int NOT NULL AUTO_INCREMENT,
CreatedAt datetime,
Age float,
Age float DEFAULT 20 NOT NULL,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),

View File

@ -8,6 +8,7 @@ CREATE TABLE Persons (
FirstName varchar(255),
Address varchar(255),
City varchar(255) DEFAULT 'Belfast',
Age INTEGER DEFAULT 20 NOT NULL,
Type person_job
);
CREATE TABLE Tasks (

View File

@ -243,11 +243,14 @@ class SqlServerIntegration extends Sql implements DatasourcePlus {
if (typeof name !== "string") {
continue
}
const hasDefault = def.COLUMN_DEFAULT
const isAuto = !!autoColumns.find(col => col === name)
const required = !!requiredColumns.find(col => col === name)
schema[name] = {
autocolumn: !!autoColumns.find(col => col === name),
autocolumn: isAuto,
name: name,
constraints: {
presence: requiredColumns.find(col => col === name),
presence: required && !isAuto && !hasDefault,
},
...convertSqlType(def.DATA_TYPE),
externalType: def.DATA_TYPE,

View File

@ -229,13 +229,15 @@ class MySQLIntegration extends Sql implements DatasourcePlus {
if (column.Key === "PRI" && primaryKeys.indexOf(column.Key) === -1) {
primaryKeys.push(columnName)
}
const constraints = {
presence: column.Null !== "YES",
}
const hasDefault = column.Default != null
const isAuto: boolean =
typeof column.Extra === "string" &&
(column.Extra === "auto_increment" ||
column.Extra.toLowerCase().includes("generated"))
const required = column.Null !== "YES"
const constraints = {
presence: required && !isAuto && !hasDefault,
}
schema[columnName] = {
name: columnName,
autocolumn: isAuto,

View File

@ -262,15 +262,17 @@ class PostgresIntegration extends Sql implements DatasourcePlus {
column.identity_start ||
column.identity_increment
)
const constraints = {
presence: column.is_nullable === "NO",
}
const hasDefault =
const hasDefault = column.column_default != null
const hasNextVal =
typeof column.column_default === "string" &&
column.column_default.startsWith("nextval")
const isGenerated =
column.is_generated && column.is_generated !== "NEVER"
const isAuto: boolean = hasDefault || identity || isGenerated
const isAuto: boolean = hasNextVal || identity || isGenerated
const required = column.is_nullable === "NO"
const constraints = {
presence: required && !hasDefault && !isGenerated,
}
tables[tableName].schema[columnName] = {
autocolumn: isAuto,
name: columnName,

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/shared-core",
"version": "2.5.5-alpha.0",
"version": "2.5.5-alpha.2",
"description": "Shared data utils",
"main": "dist/cjs/src/index.js",
"types": "dist/mjs/src/index.d.ts",
@ -20,7 +20,7 @@
"dev:builder": "yarn prebuild && concurrently \"tsc -p tsconfig.build.json --watch\" \"tsc -p tsconfig-cjs.build.json --watch\""
},
"dependencies": {
"@budibase/types": "2.5.5-alpha.0"
"@budibase/types": "2.5.5-alpha.2"
},
"devDependencies": {
"concurrently": "^7.6.0",

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/string-templates",
"version": "2.5.5-alpha.0",
"version": "2.5.5-alpha.2",
"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.5.5-alpha.0",
"version": "2.5.5-alpha.2",
"description": "Budibase types",
"main": "dist/cjs/index.js",
"types": "dist/mjs/index.d.ts",

View File

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

View File

@ -1486,15 +1486,15 @@
pouchdb-promise "^6.0.4"
through2 "^2.0.0"
"@budibase/pro@2.5.5-alpha.0":
version "2.5.5-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.5.5-alpha.0.tgz#28b075a96efb564328a4972cae9ea6c9a5f3aabc"
integrity sha512-98fLnvHWVy7ASEFC98bo6Qdd55SjC7yrJNuf7FUYZbeFwpmwwRxlWnWFTa0ctKWB5p2LToARWBns3TqgnUr/zQ==
"@budibase/pro@2.5.5-alpha.2":
version "2.5.5-alpha.2"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.5.5-alpha.2.tgz#dd3ec237997f1be5064ab931569c3621b7836b8b"
integrity sha512-pXB2BTA0/uXkZ3aCHjF06u/kxSx/mZ55T06nUAQR+64eXJ1D2BRKAqrkqjBnzXne9RGV/qEJtCu+xp8wNXII5A==
dependencies:
"@budibase/backend-core" "2.5.5-alpha.0"
"@budibase/backend-core" "2.5.5-alpha.2"
"@budibase/shared-core" "2.4.44-alpha.1"
"@budibase/string-templates" "2.4.44-alpha.1"
"@budibase/types" "2.5.5-alpha.0"
"@budibase/types" "2.5.5-alpha.2"
"@koa/router" "8.0.8"
bull "4.10.1"
joi "17.6.0"