Skip to content

Commit eb98294

Browse files
authored
Merge branch 'master' into fix/app-list-layout
2 parents 99019a7 + 9aae6cf commit eb98294

File tree

8 files changed

+94
-61
lines changed

8 files changed

+94
-61
lines changed

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
3-
"version": "3.16.1",
3+
"version": "3.17.1",
44
"npmClient": "yarn",
55
"concurrency": 20,
66
"command": {

packages/backend-core/src/constants/db.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { prefixed, DocumentType } from "@budibase/types"
1+
import {
2+
prefixed,
3+
DocumentType,
4+
SEPARATOR,
5+
InternalTable,
6+
} from "@budibase/types"
27

38
export {
49
SEPARATOR,
@@ -78,6 +83,7 @@ export const DEFAULT_INVENTORY_TABLE_ID = "ta_bb_inventory"
7883
export const DEFAULT_EXPENSES_TABLE_ID = "ta_bb_expenses"
7984
export const DEFAULT_EMPLOYEE_TABLE_ID = "ta_bb_employee"
8085
export { DEFAULT_BB_DATASOURCE_ID } from "@budibase/shared-core"
86+
export const USER_METADATA_PREFIX = `${DocumentType.ROW}${SEPARATOR}${InternalTable.USER_METADATA}${SEPARATOR}`
8187

8288
export const enum DesignDocuments {
8389
SQLITE = SQLITE_DESIGN_DOC_ID,

packages/backend-core/src/db/Replication.ts

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import PouchDB from "pouchdb"
2-
import { getPouchDB, closePouchDB } from "./couch"
3-
import { DocumentType, Document } from "@budibase/types"
4-
import { DesignDocuments } from "../constants"
2+
import { closePouchDB, getPouchDB } from "./couch"
3+
import { Document, DocumentType } from "@budibase/types"
4+
import { DesignDocuments, SEPARATOR, USER_METADATA_PREFIX } from "../constants"
55

66
enum ReplicationDirection {
77
TO_PRODUCTION = "toProduction",
88
TO_DEV = "toDev",
99
}
1010

11+
type DocumentWithID = Omit<Document, "_id"> & { _id: string }
12+
1113
class Replication {
1214
source: PouchDB.Database
1315
target: PouchDB.Database
@@ -78,33 +80,38 @@ class Replication {
7880
tableSyncList = tablesToSync
7981
}
8082

81-
const isData = (_id?: string) =>
82-
_id?.startsWith(DocumentType.ROW) || _id?.startsWith(DocumentType.LINK)
83+
const startsWithID = (_id: string, documentType: string) => {
84+
return _id?.startsWith(documentType + SEPARATOR)
85+
}
86+
87+
const isData = (_id: string) =>
88+
startsWithID(_id, DocumentType.ROW) ||
89+
startsWithID(_id, DocumentType.LINK)
8390

8491
return {
8592
...opts,
86-
filter: (doc: Document, params: any) => {
93+
filter: (doc: DocumentWithID, params: any) => {
8794
if (!isCreation && doc._id === DesignDocuments.MIGRATIONS) {
8895
return false
8996
}
9097
// don't sync design documents
91-
if (toDev && doc._id?.startsWith("_design")) {
98+
if (toDev && doc._id.startsWith("_design")) {
9299
return false
93100
}
94101
// always replicate deleted documents
95102
if (doc._deleted) {
96103
return true
97104
}
98-
if (
99-
isData(doc._id) &&
100-
(tableSyncList?.find(id => doc._id?.includes(id)) || syncAllTables)
101-
) {
105+
// always sync users from dev
106+
if (startsWithID(doc._id, USER_METADATA_PREFIX)) {
102107
return true
103108
}
104109
if (isData(doc._id)) {
105-
return false
110+
return (
111+
!!tableSyncList?.find(id => doc._id.includes(id)) || syncAllTables
112+
)
106113
}
107-
if (doc._id?.startsWith(DocumentType.AUTOMATION_LOG)) {
114+
if (startsWithID(doc._id, DocumentType.AUTOMATION_LOG)) {
108115
return false
109116
}
110117
if (doc._id === DocumentType.APP_METADATA) {

packages/server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
"google-spreadsheet": "npm:@budibase/[email protected]",
8989
"http-graceful-shutdown": "^3.1.12",
9090
"ioredis": "5.3.2",
91-
"isolated-vm": "^5.0.1",
91+
"isolated-vm": "^6.0.1",
9292
"jimp": "1.1.4",
9393
"joi": "17.6.0",
9494
"js-yaml": "4.1.0",

packages/server/src/api/controllers/deploy/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ export const publishApp = async function (
251251
replication.appReplicateOpts({
252252
isCreation: !isPublished,
253253
tablesToSync,
254+
// don't use checkpoints, this can stop data that was previous ignored
255+
// getting written - if not seeding tables we don't need to worry about it
256+
checkpoint: !seedProductionTables,
254257
})
255258
)
256259
// app metadata is excluded as it is likely to be in conflict

packages/server/src/api/routes/tests/application.spec.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import env from "../../../environment"
1717
import {
1818
type App,
1919
BuiltinPermissionID,
20+
PermissionLevel,
2021
Screen,
2122
WorkspaceApp,
2223
} from "@budibase/types"
@@ -1101,6 +1102,47 @@ describe.each([false, true])(
11011102
).toBeUndefined()
11021103
})
11031104
})
1105+
1106+
it("should publish table permissions for custom roles correctly", async () => {
1107+
// Create a table for testing permissions
1108+
const table = await config.api.table.save(basicTable())
1109+
expect(table._id).toBeDefined()
1110+
1111+
// Create a custom role
1112+
const customRole = await config.api.roles.save({
1113+
name: "TestRole",
1114+
inherits: "PUBLIC",
1115+
permissionId: BuiltinPermissionID.READ_ONLY,
1116+
version: "name",
1117+
})
1118+
expect(customRole._id).toBeDefined()
1119+
1120+
// Add READ permission for the custom role on the table
1121+
await config.api.permission.add({
1122+
roleId: customRole._id!,
1123+
resourceId: table._id!,
1124+
level: PermissionLevel.READ,
1125+
})
1126+
1127+
// Verify permissions exist in development
1128+
const devPermissions = await config.api.permission.get(table._id!)
1129+
expect(devPermissions.permissions.read.role).toBe(customRole.name)
1130+
1131+
// Publish the application
1132+
await config.publish()
1133+
1134+
// Verify permissions are correctly published to production
1135+
await config.withProdApp(async () => {
1136+
const prodPermissions = await config.api.permission.get(table._id!)
1137+
expect(prodPermissions.permissions.read.role).toBe(customRole.name)
1138+
1139+
// Also verify the role itself exists in production
1140+
const roles = await config.api.roles.fetch()
1141+
const prodRole = roles.find(r => r.name === customRole.name)
1142+
expect(prodRole).toBeDefined()
1143+
expect(prodRole!.name).toBe("TestRole")
1144+
})
1145+
})
11041146
})
11051147

11061148
describe("manage client library version", () => {

packages/server/src/jsRunner/vm/isolated-vm.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ export class IsolatedVM implements VM {
7171
})
7272

7373
this.addToContext({
74-
helpersStripProtocol: new ivm.Callback((str: string) => {
74+
helpersStripProtocol: (str: string) => {
7575
let parsed = url.parse(str) as any
7676
parsed.protocol = ""
7777
return parsed.format()
78-
}),
78+
},
7979
})
8080

8181
const injectedRequire = `require=function req(val) {
@@ -222,7 +222,7 @@ export class IsolatedVM implements VM {
222222
x[funcName] = key
223223

224224
this.addToContext({
225-
[key]: new ivm.Callback((...params: any[]) => (func as any)(...params)),
225+
[key]: (...params: any[]) => (func as any)(...params),
226226
})
227227
}
228228

yarn.lock

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13474,12 +13474,12 @@ isobject@^4.0.0:
1347413474
resolved "https://registry.yarnpkg.com/isobject/-/isobject-4.0.0.tgz#3f1c9155e73b192022a80819bacd0343711697b0"
1347513475
integrity sha512-S/2fF5wH8SJA/kmwr6HYhK/RI/OkhD84k8ntalo0iJjZikgq1XFvR5M8NPT1x5F7fBwCG3qHfnzeP/Vh/ZxCUA==
1347613476

13477-
isolated-vm@^5.0.1:
13478-
version "5.0.1"
13479-
resolved "https://registry.yarnpkg.com/isolated-vm/-/isolated-vm-5.0.1.tgz#d87b12cf8889e351cb1598a4aeea00bb458bf20c"
13480-
integrity sha512-hs7+ff59Z2zDvavfcjuot/r1gm6Bmpt+GoZxmVfxUmXaX5scOvUq/Rnme+mUtSh5lW41hH8gAuvk/yTJDYO8Fg==
13477+
isolated-vm@^6.0.1:
13478+
version "6.0.1"
13479+
resolved "https://registry.yarnpkg.com/isolated-vm/-/isolated-vm-6.0.1.tgz#37da98080f859ac9b2176d4f9b95c0dd896c9d9c"
13480+
integrity sha512-rcnfMOYIbRdChFnQbMYsSx/cSfmLJRiw+MlPyz6WdwhaPDB/mfib0pSK+D2COW+KNZKGOGeW6a+qVksL6+X/Bg==
1348113481
dependencies:
13482-
prebuild-install "^7.1.1"
13482+
prebuild-install "^7.1.3"
1348313483

1348413484
isstream@~0.1.2:
1348513485
version "0.1.2"
@@ -15985,10 +15985,10 @@ nanoid@^3.3.7:
1598515985
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.7.tgz#d0c301a691bc8d54efa0a2226ccf3fe2fd656bd8"
1598615986
integrity sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==
1598715987

15988-
napi-build-utils@^1.0.1:
15989-
version "1.0.2"
15990-
resolved "https://registry.yarnpkg.com/napi-build-utils/-/napi-build-utils-1.0.2.tgz#b1fddc0b2c46e380a0b7a76f984dd47c41a13806"
15991-
integrity sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==
15988+
napi-build-utils@^2.0.0:
15989+
version "2.0.0"
15990+
resolved "https://registry.yarnpkg.com/napi-build-utils/-/napi-build-utils-2.0.0.tgz#13c22c0187fcfccce1461844136372a47ddc027e"
15991+
integrity sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==
1599215992

1599315993
napi-macros@~2.0.0:
1599415994
version "2.0.0"
@@ -17890,17 +17890,17 @@ preact@^10.19.3:
1789017890
resolved "https://registry.yarnpkg.com/preact/-/preact-10.20.1.tgz#1bc598ab630d8612978f7533da45809a8298542b"
1789117891
integrity sha512-JIFjgFg9B2qnOoGiYMVBtrcFxHqn+dNXbq76bVmcaHYJFYR4lW67AOcXgAYQQTDYXDOg/kTZrKPNCdRgJ2UJmw==
1789217892

17893-
prebuild-install@^7.1.1:
17894-
version "7.1.1"
17895-
resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-7.1.1.tgz#de97d5b34a70a0c81334fd24641f2a1702352e45"
17896-
integrity sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==
17893+
prebuild-install@^7.1.3:
17894+
version "7.1.3"
17895+
resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-7.1.3.tgz#d630abad2b147443f20a212917beae68b8092eec"
17896+
integrity sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==
1789717897
dependencies:
1789817898
detect-libc "^2.0.0"
1789917899
expand-template "^2.0.3"
1790017900
github-from-package "0.0.0"
1790117901
minimist "^1.2.3"
1790217902
mkdirp-classic "^0.5.3"
17903-
napi-build-utils "^1.0.1"
17903+
napi-build-utils "^2.0.0"
1790417904
node-abi "^3.3.0"
1790517905
pump "^3.0.0"
1790617906
rc "^1.2.7"
@@ -19925,16 +19925,7 @@ string-length@^4.0.1:
1992519925
char-regex "^1.0.2"
1992619926
strip-ansi "^6.0.0"
1992719927

19928-
"string-width-cjs@npm:string-width@^4.2.0":
19929-
version "4.2.3"
19930-
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
19931-
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
19932-
dependencies:
19933-
emoji-regex "^8.0.0"
19934-
is-fullwidth-code-point "^3.0.0"
19935-
strip-ansi "^6.0.1"
19936-
19937-
"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
19928+
"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
1993819929
version "4.2.3"
1993919930
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
1994019931
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -20026,7 +20017,7 @@ stringify-object@^3.2.1:
2002620017
is-obj "^1.0.1"
2002720018
is-regexp "^1.0.0"
2002820019

20029-
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
20020+
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
2003020021
version "6.0.1"
2003120022
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
2003220023
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -20040,13 +20031,6 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0:
2004020031
dependencies:
2004120032
ansi-regex "^4.1.0"
2004220033

20043-
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
20044-
version "6.0.1"
20045-
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
20046-
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
20047-
dependencies:
20048-
ansi-regex "^5.0.1"
20049-
2005020034
strip-ansi@^7.0.1:
2005120035
version "7.0.1"
2005220036
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.0.1.tgz#61740a08ce36b61e50e65653f07060d000975fb2"
@@ -21899,7 +21883,7 @@ [email protected]:
2189921883
dependencies:
2190021884
errno "~0.1.7"
2190121885

21902-
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
21886+
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
2190321887
version "7.0.0"
2190421888
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
2190521889
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
@@ -21917,15 +21901,6 @@ wrap-ansi@^5.1.0:
2191721901
string-width "^3.0.0"
2191821902
strip-ansi "^5.0.0"
2191921903

21920-
wrap-ansi@^7.0.0:
21921-
version "7.0.0"
21922-
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
21923-
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
21924-
dependencies:
21925-
ansi-styles "^4.0.0"
21926-
string-width "^4.1.0"
21927-
strip-ansi "^6.0.0"
21928-
2192921904
wrap-ansi@^8.1.0:
2193021905
version "8.1.0"
2193121906
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"

0 commit comments

Comments
 (0)