Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V3 UI #14556

Merged
merged 724 commits into from
Nov 3, 2024
Merged

V3 UI #14556

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
724 commits
Select commit Hold shift + click to select a range
4947733
Fix broken frontend test.
samwho Oct 21, 2024
db2001b
Merge branch 'v3-ui' of github.com:Budibase/budibase into view-calcul…
aptkingston Oct 21, 2024
21c580e
Lint
aptkingston Oct 21, 2024
87dbe66
Update user column data on import
adrinr Oct 22, 2024
cb5082a
Fix check
adrinr Oct 22, 2024
b4f5e35
Merge branch 'master' into v3-ui
adrinr Oct 22, 2024
50c3f2c
Merge branches 'queryui-default' and 'master' of github.com:budibase/…
samwho Oct 22, 2024
2cd3ab6
Respond to PR comments.
samwho Oct 22, 2024
8dee7b2
Remove obsolete templateString
adrinr Oct 22, 2024
ea1d893
Remove unused fields
adrinr Oct 22, 2024
5fe2a1d
Rename and pass just required data
adrinr Oct 22, 2024
77c4140
Type useTemplate as bool
adrinr Oct 22, 2024
838d11e
Update only for templates
adrinr Oct 22, 2024
020927a
Fix types
adrinr Oct 22, 2024
69969e8
Merge branch 'v3-ui' of github.com:Budibase/budibase into new-rbac-ui
aptkingston Oct 22, 2024
e1640cc
Change api type back
adrinr Oct 22, 2024
00fe28e
Simplifying retrieval of role hierarchy for accessible endpoint.
mike12345567 Oct 22, 2024
86620b9
Remove permissionId when creating roles and ensure all roles inherit …
aptkingston Oct 22, 2024
f3d54f1
Adding test cases.
mike12345567 Oct 22, 2024
cf3ef64
Clean up role header implementation in currentapp.ts
mike12345567 Oct 22, 2024
ebc440a
Another test case.
mike12345567 Oct 22, 2024
fe35ef7
final test case.
mike12345567 Oct 22, 2024
eb349b5
Linting.
mike12345567 Oct 22, 2024
3ae5ce9
Use role display names for picking preview roles
aptkingston Oct 22, 2024
b85a28f
Fixes
adrinr Oct 22, 2024
1e4f105
Fix labels and add colours to access level selctor for queries
aptkingston Oct 22, 2024
62d87da
Fix role colours in user app list portal page
aptkingston Oct 22, 2024
80e532f
Fix app count in groups list
aptkingston Oct 22, 2024
f07cb6b
Fix test
adrinr Oct 22, 2024
4129169
Lint
aptkingston Oct 22, 2024
7487066
Addressing PR comments.
mike12345567 Oct 22, 2024
99d867f
Updating test case.
mike12345567 Oct 22, 2024
f91e039
Adding test with invalid role IDs.#
mike12345567 Oct 22, 2024
9d4cbaa
Merge pull request #14839 from Budibase/BUDI-8766/default-user-column…
adrinr Oct 22, 2024
0b2ac57
linting.
mike12345567 Oct 22, 2024
9575095
Merge pull request #14844 from Budibase/fix/multi-inheritance-preview…
mike12345567 Oct 22, 2024
23cf44b
Merge branch 'master' into v3-ui
adrinr Oct 22, 2024
807ecf6
BB AI QA testing fixes
shogunpurple Oct 22, 2024
29ab9be
fix lint
shogunpurple Oct 22, 2024
4f5e831
PR comments
shogunpurple Oct 22, 2024
6541f6d
update pro ref
shogunpurple Oct 22, 2024
d56ca8e
Merge branches 'master' and 'queryui-default' of github.com:budibase/…
samwho Oct 23, 2024
07312b9
Revert testing stuff
aptkingston Oct 23, 2024
0a14075
Merge branch 'new-rbac-ui' of github.com:Budibase/budibase into new-r…
aptkingston Oct 23, 2024
8f0a234
fix tests
shogunpurple Oct 23, 2024
713500f
Add sdk.automation.find
adrinr Oct 23, 2024
1f01277
Clean code
adrinr Oct 23, 2024
076f211
Remove unnecessary row action update endpoint
adrinr Oct 23, 2024
6f4e1dd
Respond to PR comment.
samwho Oct 23, 2024
7781e75
Simplify row action permissions response
adrinr Oct 23, 2024
e938a41
Merge pull request #14846 from Budibase/ai-fixes-3.0
shogunpurple Oct 23, 2024
015854f
Dont persist row action name
adrinr Oct 23, 2024
dab3826
Allow renaming row actions
adrinr Oct 23, 2024
2868c84
Remove duplicated modals
adrinr Oct 23, 2024
022ec12
Clean
adrinr Oct 23, 2024
8f99072
Reuse
adrinr Oct 23, 2024
b4a979e
Fix get names
adrinr Oct 23, 2024
1fef783
Check names properly
adrinr Oct 23, 2024
732d701
Remove row action update tests
adrinr Oct 23, 2024
46a7f15
Fix name checks
adrinr Oct 23, 2024
45dbfd2
Merge pull request #14577 from Budibase/new-rbac-ui
aptkingston Oct 23, 2024
63daa6b
Remove obsolete test
adrinr Oct 23, 2024
612bd51
update pro ref
shogunpurple Oct 23, 2024
da2b2e5
Merge v3-ui.
samwho Oct 23, 2024
17c9d9f
Merge branch 'v3-ui' into queryui-default
samwho Oct 23, 2024
64db4db
Merge pull request #14849 from Budibase/BUDI-8770/row-action-automati…
adrinr Oct 23, 2024
470ace7
Merge branch 'v3-ui' of github.com:Budibase/budibase into view-calcul…
aptkingston Oct 23, 2024
ff48773
Update frontend type names to match changes I've made.
samwho Oct 23, 2024
8f80d8e
Merge branch 'v3-ui' of github.com:Budibase/budibase into view-calcul…
aptkingston Oct 23, 2024
ad475be
Merge pull request #14818 from Budibase/queryui-default
samwho Oct 23, 2024
c6a413f
Quick fix for role validation, permissionId is no longer required.
mike12345567 Oct 23, 2024
4eda072
Add view name to queryUI error
aptkingston Oct 23, 2024
77bb3cf
Increase width of create table modal
aptkingston Oct 23, 2024
cb4b798
Update usages of queryUI and ensure processSearchFilters isn't called…
aptkingston Oct 23, 2024
de26d15
Remove log
aptkingston Oct 23, 2024
8f21802
Refactor, correct to the BuiltinPermissionID rather than PermissionLe…
mike12345567 Oct 23, 2024
ca0dc03
Make sure processSearchFilters handles an undefined input.
samwho Oct 23, 2024
3ddd8e1
Comment and test case.
mike12345567 Oct 23, 2024
9ebd890
Handle empty arrays too.
samwho Oct 23, 2024
e28357c
Linting.
mike12345567 Oct 23, 2024
f2a844c
Fix test.
samwho Oct 23, 2024
a247283
Trigger info data in the frontend
adrinr Oct 23, 2024
8ebb02e
Test fix.
mike12345567 Oct 23, 2024
f7b84ca
Fix some type skullduggery.
samwho Oct 23, 2024
7901c2d
Remove builderData usage
adrinr Oct 23, 2024
11b2e40
Remove
adrinr Oct 23, 2024
e67352d
Remove api flag
adrinr Oct 23, 2024
9d05f32
Merge pull request #14853 from Budibase/fix/role-validation
mike12345567 Oct 23, 2024
998d000
Cleanup dead code
adrinr Oct 23, 2024
685d8cf
Merge pull request #14852 from Budibase/fix-processSearchFilters
samwho Oct 23, 2024
67cc35e
Merge branch 'v3-ui' of github.com:Budibase/budibase into query-ui-fo…
aptkingston Oct 23, 2024
6ac6db7
Revert default param
aptkingston Oct 23, 2024
b6dbe54
Remove old reference to deleted code
aptkingston Oct 23, 2024
8466f88
Merge pull request #14854 from Budibase/chore/simplify-automation-data
adrinr Oct 23, 2024
c8c5cbe
Update more usages of processing search filters
aptkingston Oct 23, 2024
13d0c0f
Remove log
aptkingston Oct 23, 2024
9c7e3cd
Reset filters when reopening table filter button
aptkingston Oct 24, 2024
8a0193c
Fix typo
aptkingston Oct 24, 2024
247d578
Remove lightest and dark themes, use enums for themes, standardise na…
aptkingston Oct 24, 2024
4c112d5
Move themes to shared core, add enum and type
aptkingston Oct 24, 2024
ab0f818
Update to use new shared-core location for theme utils
aptkingston Oct 24, 2024
d7ad035
Lint
aptkingston Oct 24, 2024
27d42a9
Fix theme of in builder preview
aptkingston Oct 24, 2024
90fb363
Add client feature to ensure full backwards compatibility with themes
aptkingston Oct 24, 2024
a38ae93
Lint
aptkingston Oct 24, 2024
249f44d
Use new default app theme constant when creating apps
aptkingston Oct 24, 2024
9c9d256
Remove fetchEnriched
adrinr Oct 24, 2024
889b216
Add theme tests
aptkingston Oct 24, 2024
6879962
Revert change to view error message
aptkingston Oct 24, 2024
ccdb032
Move sdk rowaction code
adrinr Oct 24, 2024
389251c
Merge pull request #14857 from Budibase/query-ui-frontend
aptkingston Oct 24, 2024
7464f5e
Merge branch 'v3-ui' of github.com:Budibase/budibase into view-calcul…
aptkingston Oct 24, 2024
f2e4686
Add test deleting external ds
adrinr Oct 24, 2024
a1fbd3e
Try to fix pro
aptkingston Oct 24, 2024
7b04197
Implement deletion
adrinr Oct 24, 2024
bbc9a27
Add test for internal
adrinr Oct 24, 2024
ae6f2f9
Fix test
adrinr Oct 24, 2024
7bbe1c2
Merge pull request #14778 from Budibase/view-calculation-ui
aptkingston Oct 24, 2024
a8264aa
Merge branch 'master' of github.com:Budibase/budibase into v3-ui
aptkingston Oct 24, 2024
8dda1a5
Remove row actions when unfetching tables
adrinr Oct 24, 2024
47e16dd
Typing emitter
adrinr Oct 24, 2024
342d70b
Proper typing
adrinr Oct 24, 2024
637c13c
Proper typing for emitTable
adrinr Oct 24, 2024
4dedde5
Add missing rowaction
adrinr Oct 24, 2024
ef24656
Merge pull request #14862 from Budibase/BUDI-8749/missing-old-row-on-…
adrinr Oct 24, 2024
f279a17
Allow overriding the min version where we stop serving the power role
adrinr Oct 24, 2024
288517d
Fix frontend issues due power role missing
adrinr Oct 24, 2024
08ee84c
Merge pull request #14864 from Budibase/chore/allow-overriding-minver…
adrinr Oct 24, 2024
c8a7837
Skip access API request if unchanged
aptkingston Oct 24, 2024
be55646
Add info display in user side panel to warn builders if they haven't …
aptkingston Oct 24, 2024
2dec33c
Revert info display changes
aptkingston Oct 24, 2024
15336d6
Merge pull request #14865 from Budibase/cheeks-fixes
aptkingston Oct 24, 2024
b05f35f
Merge pull request #14859 from Budibase/BUDI-8774/row-actions-dont-ge…
adrinr Oct 24, 2024
c13613f
Merge pull request #14860 from Budibase/BUDI-8774/delete-row-actions-…
adrinr Oct 24, 2024
7ee72b6
Merge master.
samwho Oct 25, 2024
5e4cfaf
Expose bigints as a column to do calculations on.
samwho Oct 25, 2024
f46a668
Allow bigints to be used in view calculations, and make sure they're …
samwho Oct 25, 2024
c110cb6
Merge pull request #14858 from Budibase/remove-lightest-and-dark-themes
aptkingston Oct 25, 2024
dae550c
Tidy up import data modal and change to be a detail popover
aptkingston Oct 25, 2024
c5f1e3a
Merge branch 'v3-ui' of github.com:budibase/budibase into allow-bigin…
samwho Oct 25, 2024
9ab266a
Fix lint.
samwho Oct 25, 2024
2710238
Tidy up export modal and update to be a detail popover
aptkingston Oct 25, 2024
a9279b3
Merge branch 'master' of github.com:Budibase/budibase into v3-ui
mike12345567 Oct 25, 2024
c2108ac
Merge pull request #14878 from Budibase/allow-bigints-in-calculations
samwho Oct 28, 2024
199c447
Merge branch 'master' into v3-ui
samwho Oct 28, 2024
d461dcd
Merge branch 'master' into v3-ui
adrinr Oct 28, 2024
1813072
Remove old files
aptkingston Oct 28, 2024
4979cce
Udpate sort button to be a detail popover
aptkingston Oct 28, 2024
83eed81
Update size button to be a detail popover
aptkingston Oct 28, 2024
76ccdba
Remove styles
aptkingston Oct 28, 2024
67c5cc4
Update column settings button to be a detail popover
aptkingston Oct 28, 2024
3ad913a
Reorder buttons to access is always first
aptkingston Oct 28, 2024
27c1788
Update view calculation button to be a detail popover
aptkingston Oct 28, 2024
5156749
Update table filter button to be a detail popover
aptkingston Oct 28, 2024
293368e
Update titles
aptkingston Oct 28, 2024
8f94e35
Shrink size button popover
aptkingston Oct 28, 2024
6e021e6
lint
aptkingston Oct 28, 2024
5cf0e33
Merge branch 'master' into v3-ui
adrinr Oct 28, 2024
c5c17cd
Reduce size of sorting popover
aptkingston Oct 29, 2024
d5aed43
Fix z-index issue with detail popovers and bindings
aptkingston Oct 29, 2024
b9b4f88
Fix default values when using multi-option column and supplying empty…
samwho Oct 29, 2024
67fea78
Support boolean and bigint fields having default values.
samwho Oct 29, 2024
0c8590b
Fix lint.
samwho Oct 29, 2024
b58fd7d
Fix OSS build.
samwho Oct 29, 2024
8254e89
Merge branch 'master' into v3-ui
adrinr Oct 29, 2024
aab5256
Fix frontend filtering
adrinr Oct 29, 2024
32ad21d
Fix forms always requesting table schema and cache view definitions
aptkingston Oct 29, 2024
d8ff150
Merge branch 'v3-ui' into fix-default-values-multi
samwho Oct 29, 2024
7cce68f
Provide fetchDatasourceDefinition via SDK
aptkingston Oct 29, 2024
b6b66d7
Merge pull request #14896 from Budibase/fix-default-values-multi
samwho Oct 29, 2024
fc3fcb5
Lint
aptkingston Oct 29, 2024
edfe3b9
Merge branch 'v3-ui' into form-schema-changes
aptkingston Oct 29, 2024
5bda7da
Merge branch 'v3-ui' of github.com:Budibase/budibase into data-tidy-up
aptkingston Oct 29, 2024
8b5dc8c
Merge branch 'v3-ui' into budi-8792-bigint-and-boolean-fields-dont-su…
adrinr Oct 29, 2024
3f00655
Merge branch 'master' into v3-ui
adrinr Oct 29, 2024
22ae19a
Merge branch 'v3-ui' into budi-8792-bigint-and-boolean-fields-dont-su…
samwho Oct 29, 2024
6a25804
Merge branch 'master' of github.com:budibase/budibase into v3-ui
samwho Oct 29, 2024
fa99c07
Merge branch 'v3-ui' of github.com:budibase/budibase into budi-8792-b…
samwho Oct 29, 2024
8d76526
Merge branch 'budi-8792-bigint-and-boolean-fields-dont-support-defaul…
samwho Oct 29, 2024
b8f27b9
Fix table imports
aptkingston Oct 29, 2024
d530078
Merge branch 'v3-ui' into data-tidy-up
aptkingston Oct 29, 2024
f94d8ba
Fixing merge artifact
mike12345567 Oct 29, 2024
32dcc9f
Merge branch 'v3-ui' of github.com:budibase/budibase into budi-8792-b…
samwho Oct 29, 2024
336bd97
Merge pull request #14897 from Budibase/budi-8792-bigint-and-boolean-…
samwho Oct 29, 2024
721b3ab
Account for logicalOperator inside UISearchFilter groups
aptkingston Oct 29, 2024
0962e52
Merge branch 'v3-ui' into form-schema-changes
aptkingston Oct 29, 2024
ca125ca
Merge branch 'v3-ui' into data-tidy-up
aptkingston Oct 29, 2024
c6855f1
Merge pull request #14899 from Budibase/form-schema-changes
aptkingston Oct 29, 2024
a8a488d
Merge branch 'v3-ui' into BUDI-8775/new-filtering-doesnt-work-with-qu…
adrinr Oct 29, 2024
a1e4b6c
Merge pull request #14871 from Budibase/BUDI-8775/new-filtering-doesn…
adrinr Oct 29, 2024
765b3d2
Add tests for handling logical operators in UISearchFilter
aptkingston Oct 29, 2024
37ca13e
Merge branch 'v3-ui' into data-tidy-up
aptkingston Oct 29, 2024
871997b
Merge pull request #14888 from Budibase/data-tidy-up
aptkingston Oct 29, 2024
599370b
Update tests
aptkingston Oct 29, 2024
66e3db6
Merge branch 'v3-ui' into fix-filter-query-conversion
aptkingston Oct 29, 2024
7d7dd31
Merge pull request #14904 from Budibase/fix-filter-query-conversion
aptkingston Oct 29, 2024
ff4d919
Merge branch 'master' of github.com:Budibase/budibase into v3-ui
aptkingston Oct 30, 2024
313bd9b
add AI column from import if already defined
shogunpurple Oct 30, 2024
b060741
unit test to cover
shogunpurple Oct 30, 2024
d9b6858
lint
shogunpurple Oct 30, 2024
45dd00f
Merge branch 'master' into v3-ui
adrinr Oct 30, 2024
53fc45f
make ai columns respect feature flags
shogunpurple Oct 30, 2024
3f3160a
default store values for AI features
shogunpurple Oct 30, 2024
15ebfdf
Fix settings added and removed by conditions not triggering component…
aptkingston Oct 30, 2024
67a988a
Automatically refresh datasources after executing row actions via a b…
aptkingston Oct 30, 2024
587aba8
Merge branch 'v3-ui' into cheeks-fixes
aptkingston Oct 30, 2024
7731aa4
Merge pull request #14921 from Budibase/cheeks-fixes
aptkingston Oct 30, 2024
62caef1
Merge branch 'v3-ui' of github.com:Budibase/budibase into ai-fixes
shogunpurple Oct 30, 2024
8478c3f
adding assertion for AI
shogunpurple Oct 30, 2024
b504f77
Fix view calculations when relationships are present.
samwho Oct 30, 2024
3f62f19
Merge branch 'v3-ui' of github.com:budibase/budibase into fix-view-ca…
samwho Oct 30, 2024
e06c062
Respond to PR comments.
samwho Oct 30, 2024
40cbcff
Merge pull request #14924 from Budibase/fix-view-calculations-with-re…
samwho Oct 30, 2024
920953a
Throw an error when attempting to bulkImport a relationship field int…
samwho Oct 30, 2024
20ed18a
Merge branch 'master' into v3-ui
adrinr Oct 31, 2024
945cf52
Allow fields on count calculations.
samwho Oct 31, 2024
0b8199b
Use existing _id values for non DS+ in tables, trusting that they are…
aptkingston Oct 31, 2024
afbec93
Clean table data before using it as additional data context to better…
aptkingston Oct 31, 2024
b9ba76f
Avoid creating new function every iteration of array.map
aptkingston Oct 31, 2024
3b31559
Merge branch 'v3-ui' into ai-fixes
shogunpurple Oct 31, 2024
e3b4998
Merge pull request #14928 from Budibase/allow-fields-on-counts
samwho Oct 31, 2024
0bc6647
fix AI tests
shogunpurple Oct 31, 2024
cb2f2a1
Merge branch 'ai-fixes' of github.com:Budibase/budibase into ai-fixes
shogunpurple Oct 31, 2024
c85dd1f
Allow counting on non-numeric fields
aptkingston Oct 31, 2024
986cef6
Update view calculation explanation text
aptkingston Oct 31, 2024
ee9a39a
Merge branch 'v3-ui' into error-on-bulkimporting-relationship-fields
mike12345567 Oct 31, 2024
df8ec41
Merge pull request #14918 from Budibase/ai-fixes
shogunpurple Oct 31, 2024
f58fbc3
Merge branch 'v3-ui' into error-on-bulkimporting-relationship-fields
samwho Oct 31, 2024
1f2301c
Merge pull request #14925 from Budibase/error-on-bulkimporting-relati…
samwho Oct 31, 2024
a8ef64b
Merge branch 'v3-ui' into view-calc-count-non-numeric
aptkingston Oct 31, 2024
b816cd9
Merge branch 'v3-ui' into use-existing-ids-non-ds-plus
aptkingston Oct 31, 2024
3477fa3
Merge pull request #14929 from Budibase/use-existing-ids-non-ds-plus
aptkingston Oct 31, 2024
53caa7b
Merge branch 'v3-ui' into view-calc-count-non-numeric
aptkingston Oct 31, 2024
d9b7e3e
Merge pull request #14930 from Budibase/view-calc-count-non-numeric
aptkingston Oct 31, 2024
25a0bd2
Merge branch 'master' into v3-ui
aptkingston Oct 31, 2024
78554bd
Fix flaky export test.
samwho Oct 31, 2024
b4e758d
No longer using the csv package.
samwho Oct 31, 2024
6f92b39
Merge branch 'v3-ui' into fix-flaky-export-test
samwho Oct 31, 2024
8c09ff8
Merge pull request #14932 from Budibase/fix-flaky-export-test
samwho Oct 31, 2024
c72ca65
Fixing an issue with sample data being added to an app due to the cha…
mike12345567 Nov 1, 2024
23f2df9
Removing un-necessary statement.
mike12345567 Nov 1, 2024
c40cb15
Merge pull request #14937 from Budibase/fix/sample-data-add
mike12345567 Nov 1, 2024
f9c98d8
Fix datasource renames being reverted when changing schema
aptkingston Nov 1, 2024
be27bdb
Merge branch 'v3-ui' of github.com:Budibase/budibase into v3-ui
aptkingston Nov 1, 2024
dc7cc49
Fix multiplayer collab for data
aptkingston Nov 1, 2024
792d891
Some openAPI changes, fixing defaults for app ID, role endpoint permi…
mike12345567 Nov 1, 2024
228a752
Merge branch 'v3-ui' into fix/openapi-changes
mike12345567 Nov 1, 2024
6f1b120
Merge pull request #14939 from Budibase/fix/openapi-changes
mike12345567 Nov 1, 2024
a605fb1
Merge branch 'master' into v3-ui
shogunpurple Nov 3, 2024
fd51188
Update deploy-qa.yml
shogunpurple Nov 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/deploy-qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Deploy QA
on:
push:
branches:
- v3-ui
- master
workflow_dispatch:

jobs:
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ packages/server/runtime_apps/
.idea/
bb-airgapped.tar.gz
*.iml

packages/server/build/oldClientVersions/**/*
packages/builder/src/components/deploy/clientVersions.json

packages/server/src/integrations/tests/utils/*.lock
packages/builder/vite.config.mjs.timestamp*

# Logs
logs
Expand Down
1 change: 1 addition & 0 deletions packages/backend-core/src/constants/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export enum Config {
OIDC = "oidc",
OIDC_LOGOS = "logos_oidc",
SCIM = "scim",
AI = "AI",
}

export const MIN_VALID_DATE = new Date(-2147483647000)
Expand Down
2 changes: 2 additions & 0 deletions packages/backend-core/src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ const environment = {
BB_ADMIN_USER_EMAIL: process.env.BB_ADMIN_USER_EMAIL,
BB_ADMIN_USER_PASSWORD: process.env.BB_ADMIN_USER_PASSWORD,
OPENAI_API_KEY: process.env.OPENAI_API_KEY,
MIN_VERSION_WITHOUT_POWER_ROLE:
process.env.MIN_VERSION_WITHOUT_POWER_ROLE || "3.0.0",
}

export function setEnv(newEnvVars: Partial<typeof environment>): () => void {
Expand Down
14 changes: 5 additions & 9 deletions packages/backend-core/src/security/permissions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { PermissionLevel, PermissionType } from "@budibase/types"
import {
PermissionLevel,
PermissionType,
BuiltinPermissionID,
} from "@budibase/types"
import flatten from "lodash/flatten"
import cloneDeep from "lodash/fp/cloneDeep"

Expand Down Expand Up @@ -57,14 +61,6 @@ export function getAllowedLevels(userPermLevel: PermissionLevel): string[] {
}
}

export enum BuiltinPermissionID {
PUBLIC = "public",
READ_ONLY = "read_only",
WRITE = "write",
ADMIN = "admin",
POWER = "power",
}

export const BUILTIN_PERMISSIONS: {
[key in keyof typeof BuiltinPermissionID]: {
_id: (typeof BuiltinPermissionID)[key]
Expand Down
51 changes: 36 additions & 15 deletions packages/backend-core/src/security/roles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import semver from "semver"
import { BuiltinPermissionID, PermissionLevel } from "./permissions"
import {
prefixRoleID,
getRoleParams,
Expand All @@ -14,10 +13,13 @@ import {
RoleUIMetadata,
Database,
App,
BuiltinPermissionID,
PermissionLevel,
} from "@budibase/types"
import cloneDeep from "lodash/fp/cloneDeep"
import { RoleColor, helpers } from "@budibase/shared-core"
import { uniqBy } from "lodash"
import { default as env } from "../environment"

export const BUILTIN_ROLE_IDS = {
ADMIN: "ADMIN",
Expand Down Expand Up @@ -50,7 +52,7 @@ export class Role implements RoleDoc {
_id: string
_rev?: string
name: string
permissionId: string
permissionId: BuiltinPermissionID
inherits?: string | string[]
version?: string
permissions: Record<string, PermissionLevel[]> = {}
Expand All @@ -59,7 +61,7 @@ export class Role implements RoleDoc {
constructor(
id: string,
name: string,
permissionId: string,
permissionId: BuiltinPermissionID,
uiMetadata?: RoleUIMetadata
) {
this._id = id
Expand Down Expand Up @@ -213,15 +215,31 @@ export function getBuiltinRole(roleId: string): Role | undefined {
return cloneDeep(role)
}

export function validInherits(
allRoles: RoleDoc[],
inherits?: string | string[]
): boolean {
if (!inherits) {
return false
}
const find = (id: string) => allRoles.find(r => roleIDsAreEqual(r._id!, id))
if (Array.isArray(inherits)) {
const filtered = inherits.filter(roleId => find(roleId))
return inherits.length !== 0 && filtered.length === inherits.length
} else {
return !!find(inherits)
}
}

/**
* Works through the inheritance ranks to see how far up the builtin stack this ID is.
*/
export function builtinRoleToNumber(id: string) {
const builtins = getBuiltinRoles()
const MAX = Object.values(builtins).length + 1
if (
compareRoleIds(id, BUILTIN_IDS.ADMIN) ||
compareRoleIds(id, BUILTIN_IDS.BUILDER)
roleIDsAreEqual(id, BUILTIN_IDS.ADMIN) ||
roleIDsAreEqual(id, BUILTIN_IDS.BUILDER)
) {
return MAX
}
Expand Down Expand Up @@ -260,7 +278,7 @@ export async function roleToNumber(id: string) {
const highestBuiltin: number | undefined = role.inherits
.map(roleId => {
const foundRole = hierarchy.find(role =>
compareRoleIds(role._id!, roleId)
roleIDsAreEqual(role._id!, roleId)
)
if (foundRole) {
return findNumber(foundRole) + 1
Expand Down Expand Up @@ -295,7 +313,7 @@ export function lowerBuiltinRoleID(roleId1?: string, roleId2?: string): string {
: roleId1
}

export function compareRoleIds(roleId1: string, roleId2: string) {
export function roleIDsAreEqual(roleId1: string, roleId2: string) {
// make sure both role IDs are prefixed correctly
return prefixRoleID(roleId1) === prefixRoleID(roleId2)
}
Expand Down Expand Up @@ -328,7 +346,7 @@ export function findRole(
roleId = prefixRoleID(roleId)
}
const dbRole = roles.find(
role => role._id && compareRoleIds(role._id, roleId)
role => role._id && roleIDsAreEqual(role._id, roleId)
)
if (!dbRole && !isBuiltin(roleId) && opts?.defaultPublic) {
return cloneDeep(BUILTIN_ROLES.PUBLIC)
Expand Down Expand Up @@ -385,7 +403,7 @@ async function getAllUserRoles(
): Promise<RoleDoc[]> {
const allRoles = await getAllRoles()
// admins have access to all roles
if (compareRoleIds(userRoleId, BUILTIN_IDS.ADMIN)) {
if (roleIDsAreEqual(userRoleId, BUILTIN_IDS.ADMIN)) {
return allRoles
}

Expand Down Expand Up @@ -497,7 +515,7 @@ export async function getAllRoles(appId?: string): Promise<RoleDoc[]> {
for (let builtinRoleId of externalBuiltinRoles) {
const builtinRole = builtinRoles[builtinRoleId]
const dbBuiltin = roles.filter(dbRole =>
compareRoleIds(dbRole._id!, builtinRoleId)
roleIDsAreEqual(dbRole._id!, builtinRoleId)
)[0]
if (dbBuiltin == null) {
roles.push(builtinRole || builtinRoles.BASIC)
Expand Down Expand Up @@ -537,7 +555,10 @@ async function shouldIncludePowerRole(db: Database) {
return true
}

const isGreaterThan3x = semver.gte(creationVersion, "3.0.0")
const isGreaterThan3x = semver.gte(
creationVersion,
env.MIN_VERSION_WITHOUT_POWER_ROLE
)
return !isGreaterThan3x
}

Expand All @@ -553,9 +574,9 @@ export class AccessController {
if (
tryingRoleId == null ||
tryingRoleId === "" ||
compareRoleIds(tryingRoleId, BUILTIN_IDS.BUILDER) ||
compareRoleIds(userRoleId!, tryingRoleId) ||
compareRoleIds(userRoleId!, BUILTIN_IDS.BUILDER)
roleIDsAreEqual(tryingRoleId, BUILTIN_IDS.BUILDER) ||
roleIDsAreEqual(userRoleId!, tryingRoleId) ||
roleIDsAreEqual(userRoleId!, BUILTIN_IDS.BUILDER)
) {
return true
}
Expand All @@ -566,7 +587,7 @@ export class AccessController {
}

return (
roleIds?.find(roleId => compareRoleIds(roleId, tryingRoleId)) !==
roleIds?.find(roleId => roleIDsAreEqual(roleId, tryingRoleId)) !==
undefined
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import cloneDeep from "lodash/cloneDeep"
import * as permissions from "../permissions"
import { BUILTIN_ROLE_IDS } from "../roles"
import { BuiltinPermissionID } from "@budibase/types"

describe("levelToNumber", () => {
it("should return 0 for EXECUTE", () => {
Expand Down Expand Up @@ -77,7 +78,7 @@ describe("doesHaveBasePermission", () => {
const rolesHierarchy = [
{
roleId: BUILTIN_ROLE_IDS.ADMIN,
permissionId: permissions.BuiltinPermissionID.ADMIN,
permissionId: BuiltinPermissionID.ADMIN,
},
]
expect(
Expand All @@ -91,7 +92,7 @@ describe("doesHaveBasePermission", () => {
const rolesHierarchy = [
{
roleId: BUILTIN_ROLE_IDS.PUBLIC,
permissionId: permissions.BuiltinPermissionID.PUBLIC,
permissionId: BuiltinPermissionID.PUBLIC,
},
]
expect(
Expand Down Expand Up @@ -129,7 +130,7 @@ describe("getBuiltinPermissions", () => {
describe("getBuiltinPermissionByID", () => {
it("returns correct permission object for valid ID", () => {
const expectedPermission = {
_id: permissions.BuiltinPermissionID.PUBLIC,
_id: BuiltinPermissionID.PUBLIC,
name: "Public",
permissions: [
new permissions.Permission(
Expand Down
87 changes: 57 additions & 30 deletions packages/backend-core/src/sql/sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,6 @@ class InternalBuilder {
return this.table.schema[column]
}

private supportsILike(): boolean {
return !(
this.client === SqlClient.ORACLE || this.client === SqlClient.SQL_LITE
)
}

private quoteChars(): [string, string] {
const wrapped = this.knexClient.wrapIdentifier("foo", {})
return [wrapped[0], wrapped[wrapped.length - 1]]
Expand Down Expand Up @@ -216,8 +210,30 @@ class InternalBuilder {
return formatter.wrap(value, false)
}

private rawQuotedValue(value: string): Knex.Raw {
return this.knex.raw(this.quotedValue(value))
private castIntToString(identifier: string | Knex.Raw): Knex.Raw {
switch (this.client) {
case SqlClient.ORACLE: {
return this.knex.raw("to_char(??)", [identifier])
}
case SqlClient.POSTGRES: {
return this.knex.raw("??::TEXT", [identifier])
}
case SqlClient.MY_SQL:
case SqlClient.MARIADB: {
return this.knex.raw("CAST(?? AS CHAR)", [identifier])
}
case SqlClient.SQL_LITE: {
// Technically sqlite can actually represent numbers larger than a 64bit
// int as a string, but it does it using scientific notation (e.g.
// "1e+20") which is not what we want. Given that the external SQL
// databases are limited to supporting only 64bit ints, we settle for
// that here.
return this.knex.raw("printf('%d', ??)", [identifier])
}
case SqlClient.MS_SQL: {
return this.knex.raw("CONVERT(NVARCHAR, ??)", [identifier])
}
}
}

// Unfortuantely we cannot rely on knex's identifier escaping because it trims
Expand Down Expand Up @@ -512,7 +528,7 @@ class InternalBuilder {
if (!matchesTableName) {
updatedKey = filterKey.replace(
new RegExp(`^${relationship.column}.`),
`${aliases![relationship.tableName]}.`
`${aliases?.[relationship.tableName] || relationship.tableName}.`
)
} else {
updatedKey = filterKey
Expand Down Expand Up @@ -1074,24 +1090,36 @@ class InternalBuilder {
)
}
} else {
query = query.count(`* as ${aggregation.name}`)
if (this.client === SqlClient.ORACLE) {
const field = this.convertClobs(`${tableName}.${aggregation.field}`)
query = query.select(
this.knex.raw(`COUNT(??) as ??`, [field, aggregation.name])
)
} else {
query = query.count(`${aggregation.field} as ${aggregation.name}`)
}
}
} else {
const field = `${tableName}.${aggregation.field} as ${aggregation.name}`
switch (op) {
case CalculationType.SUM:
query = query.sum(field)
break
case CalculationType.AVG:
query = query.avg(field)
break
case CalculationType.MIN:
query = query.min(field)
break
case CalculationType.MAX:
query = query.max(field)
break
const fieldSchema = this.getFieldSchema(aggregation.field)
if (!fieldSchema) {
// This should not happen in practice.
throw new Error(
`field schema missing for aggregation target: ${aggregation.field}`
)
}

let aggregate = this.knex.raw("??(??)", [
this.knex.raw(op),
this.rawQuotedIdentifier(`${tableName}.${aggregation.field}`),
])

if (fieldSchema.type === FieldType.BIGINT) {
aggregate = this.castIntToString(aggregate)
}

query = query.select(
this.knex.raw("?? as ??", [aggregate, aggregation.name])
)
}
}
return query
Expand Down Expand Up @@ -1434,7 +1462,8 @@ class InternalBuilder {
schema.constraints?.presence === true ||
schema.type === FieldType.FORMULA ||
schema.type === FieldType.AUTO ||
schema.type === FieldType.LINK
schema.type === FieldType.LINK ||
schema.type === FieldType.AI
) {
continue
}
Expand Down Expand Up @@ -1556,7 +1585,7 @@ class InternalBuilder {
query = this.addFilters(query, filters, { relationship: true })

// handle relationships with a CTE for all others
if (relationships?.length) {
if (relationships?.length && aggregations.length === 0) {
const mainTable =
this.query.tableAliases?.[this.query.endpoint.entityId] ||
this.query.endpoint.entityId
Expand All @@ -1571,10 +1600,8 @@ class InternalBuilder {
// add JSON aggregations attached to the CTE
return this.addJsonRelationships(cte, tableName, relationships)
}
// no relationships found - return query
else {
return query
}

return query
}

update(opts: QueryOptions): Knex.QueryBuilder {
Expand Down
Loading
Loading