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

Convert frontend-core API client to Typescript #15096

Merged
merged 142 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
fdc6e53
Improve typing of core API client functions
aptkingston Nov 25, 2024
6776a55
Update lock
aptkingston Nov 25, 2024
a26eb57
Type frontend core app endpoints
aptkingston Nov 26, 2024
a7873ca
Update usages of app metadata calls
aptkingston Nov 26, 2024
785938b
Improve typing of API client callback functions
aptkingston Nov 26, 2024
bac341f
Merge branch 'master' of github.com:Budibase/budibase into frontend-c…
aptkingston Nov 26, 2024
2c40b9a
Add better typing for headers
aptkingston Nov 26, 2024
d50df9a
Merge branch 'master' of github.com:Budibase/budibase into frontend-c…
aptkingston Nov 26, 2024
1e535d3
Update AI and analytics endpoints to TS
aptkingston Nov 26, 2024
9c35a77
Update attachment endpoints to use TS
aptkingston Nov 27, 2024
544e3a9
Update audit logs endpoints to use TS
aptkingston Nov 27, 2024
679f08d
Update auth endpoints to use TS
aptkingston Nov 27, 2024
7ab6a1b
Update automation endpoints to use TS
aptkingston Nov 27, 2024
fd19986
Update backups endpoints to use TS
aptkingston Nov 27, 2024
aeb0af6
Standardise plurality and comments for untyped endpoints
aptkingston Nov 27, 2024
c9daead
Update frontend-core constants to TS
aptkingston Nov 27, 2024
6b0b7fe
Merge branch 'master' of github.com:Budibase/budibase into frontend-c…
aptkingston Nov 29, 2024
152cc38
Fix import of frontend-core constants from client
aptkingston Nov 29, 2024
07afd92
Resolve frontend-core to local path from server and update nodemon to…
aptkingston Nov 29, 2024
5f9eb04
Merge branch 'master' into frontend-core-ts-2
aptkingston Nov 29, 2024
6d67a10
Convert config endpoints to TS
aptkingston Nov 29, 2024
6d50f70
Flatten some config endpoint params
aptkingston Nov 29, 2024
417040f
Add optional stronger typing of requests and responses to ensure conf…
aptkingston Dec 2, 2024
00359d8
Strengthen types of some endpoints
aptkingston Dec 2, 2024
accd21d
Merge branch 'frontend-core-ts-2' of github.com:Budibase/budibase int…
aptkingston Dec 2, 2024
e2ea52d
Merge branch 'master' into frontend-core-ts-2
aptkingston Dec 2, 2024
dedd5f2
Type env variable endpoints
aptkingston Dec 2, 2024
417286b
Type event endpoints
aptkingston Dec 2, 2024
1b6e6ed
Type flag endpoints
aptkingston Dec 2, 2024
1620564
Type group endpoints
aptkingston Dec 2, 2024
d36122b
Remove deprecated hosting endpoints
aptkingston Dec 2, 2024
b2b2648
Type layout endpoints
aptkingston Dec 2, 2024
85e8690
Type licensing endpoints
aptkingston Dec 2, 2024
7a437aa
Merge branch 'frontend-core-ts-2' of github.com:Budibase/budibase int…
aptkingston Dec 2, 2024
2038467
Fix some TS errors and type API errors
aptkingston Dec 3, 2024
99c3955
Type logs, migrations and other endpoints
aptkingston Dec 3, 2024
d59a3a0
Type permission endpoints
aptkingston Dec 3, 2024
c6f5287
Type plugin endpoints
aptkingston Dec 3, 2024
ac8c2cc
Merge branch 'master' into frontend-core-ts-2
aptkingston Dec 3, 2024
abddbde
Add plugin endpoint interface into API client union type
aptkingston Dec 3, 2024
ac05ccd
Type query endpoints
aptkingston Dec 3, 2024
e938fdd
Type relationship endpoints
aptkingston Dec 3, 2024
2a7c0ca
Type role endpoints
aptkingston Dec 3, 2024
0e8c89d
Merge branch 'frontend-core-ts-2' of github.com:Budibase/budibase int…
aptkingston Dec 3, 2024
9926e8d
Type route endpoints
aptkingston Dec 3, 2024
ea84af7
Type row action endpoints
aptkingston Dec 3, 2024
b546512
Fix TS errors
aptkingston Dec 3, 2024
86c34cc
Fix types
aptkingston Dec 3, 2024
2361155
Lint
aptkingston Dec 3, 2024
5ea8e0d
Merge branch 'master' of github.com:Budibase/budibase into frontend-c…
aptkingston Dec 3, 2024
7100b4b
Merge branch 'master' into frontend-core-ts-2
aptkingston Dec 3, 2024
4565b2d
Merge branch 'frontend-core-ts-2' of github.com:Budibase/budibase int…
aptkingston Dec 3, 2024
c4caa89
Update lock after removing account portal
aptkingston Dec 3, 2024
c6bad69
Fix tests
aptkingston Dec 3, 2024
2d46939
Type row endpoints
aptkingston Dec 3, 2024
9b16849
Type screen endpoints
aptkingston Dec 3, 2024
a585ba1
Type self endpoints
aptkingston Dec 3, 2024
63790e0
Merge branch 'master' into frontend-core-ts-2
aptkingston Dec 3, 2024
3f15216
Lint
aptkingston Dec 3, 2024
66d7fb2
Fix TS error
aptkingston Dec 3, 2024
b329187
Type table endpoints
aptkingston Dec 3, 2024
ef28b03
Merge branch 'master' into frontend-core-ts-2
aptkingston Dec 3, 2024
edbcc1f
Type template endpoints
aptkingston Dec 3, 2024
a469e1c
Merge branch 'master' into frontend-core-ts-2
aptkingston Dec 3, 2024
170d453
Type user endpoints
aptkingston Dec 4, 2024
1b467f2
Type view endpoints
aptkingston Dec 4, 2024
50fd530
Type view V2 endpoints
aptkingston Dec 4, 2024
fc463ed
Merge branch 'frontend-core-ts-2' of github.com:Budibase/budibase int…
aptkingston Dec 4, 2024
f57dbfa
Merge branch 'master' of github.com:Budibase/budibase into frontend-c…
aptkingston Dec 4, 2024
a85a7a6
Fix TS errors
aptkingston Dec 4, 2024
92f8d79
Merge branch 'master' into frontend-core-ts-2
aptkingston Dec 4, 2024
a528743
Merge branch 'master' into frontend-core-ts-2
aptkingston Dec 5, 2024
de97219
Merge branch 'master' of github.com:Budibase/budibase into frontend-c…
aptkingston Dec 5, 2024
739cab0
Update typing of app and analytics endpoints
aptkingston Dec 5, 2024
f8f81fd
update attachment endpoint with new types
aptkingston Dec 5, 2024
dcb9fd2
Update auth endpoints
aptkingston Dec 5, 2024
0da9ad0
Update automation endpoints with new types
aptkingston Dec 5, 2024
29a1df7
Update types for backup endpoints
aptkingston Dec 5, 2024
f99372a
Fix raw OK response when checking license
aptkingston Dec 5, 2024
29aa2cc
Update backup endpoints and fix some errors
aptkingston Dec 5, 2024
e1178ea
Merge branch 'master' into frontend-core-ts-2
aptkingston Dec 5, 2024
42c3a54
Clean audit log endpoint code
aptkingston Dec 5, 2024
315d284
Tidy audit log searching
aptkingston Dec 5, 2024
7d4974a
Clarify missing types in config endpoints
aptkingston Dec 5, 2024
78f1690
Update types for datasource endpoints
aptkingston Dec 5, 2024
2b06a7d
Update flag endpoints
aptkingston Dec 5, 2024
4c80d9e
Update layout endpoints
aptkingston Dec 5, 2024
ca10a21
Update migration endpoints
aptkingston Dec 5, 2024
7806eeb
Update other endpoints
aptkingston Dec 5, 2024
8992a1d
Update plugin endpoints
aptkingston Dec 5, 2024
feee403
Update query endpoints
aptkingston Dec 5, 2024
9877caf
Update relationship endpoints
aptkingston Dec 5, 2024
fe91639
Update role endpoints
aptkingston Dec 5, 2024
dd9cd6d
Merge branch 'frontend-core-ts-2' of github.com:Budibase/budibase int…
aptkingston Dec 5, 2024
b025878
Update routing endpoints
aptkingston Dec 5, 2024
923859b
Update row endpoints
aptkingston Dec 5, 2024
a42fd87
Upate screen endpoints
aptkingston Dec 5, 2024
100efef
Update table endpoints
aptkingston Dec 5, 2024
00cbee5
Update template endpoints
aptkingston Dec 5, 2024
557406a
Update user endpoints
aptkingston Dec 5, 2024
5c08b6d
Update view endpoints
aptkingston Dec 5, 2024
e44ce7e
Fix TS errors
aptkingston Dec 5, 2024
32bb912
Lint
aptkingston Dec 5, 2024
fccfaeb
Merge branch 'master' into frontend-core-ts-2
aptkingston Dec 5, 2024
d0b3c9d
Merge branch 'master' of github.com:Budibase/budibase into frontend-c…
aptkingston Dec 9, 2024
65f37e0
Merge branch 'master' of github.com:Budibase/budibase into frontend-c…
aptkingston Dec 10, 2024
f20c07a
Update attachment and auth endpoints
aptkingston Dec 10, 2024
7b01d3c
Update config endpoints
aptkingston Dec 10, 2024
6862730
Update flag endpoints
aptkingston Dec 10, 2024
cee5354
Update other endpoints
aptkingston Dec 10, 2024
6101335
Update self endpoints
aptkingston Dec 10, 2024
f93f278
Update template endpoints
aptkingston Dec 10, 2024
7ea9478
Update user endpoints
aptkingston Dec 10, 2024
6463b1c
Lint
aptkingston Dec 10, 2024
8efb2d7
Fix TS errors
aptkingston Dec 10, 2024
d0ebb6a
Merge branch 'master' into frontend-core-ts-2
aptkingston Dec 10, 2024
4f3a3aa
Merge branch 'master' into frontend-core-ts-2
aptkingston Dec 10, 2024
eb0a475
Try to support endpoints which conditionally return 204s
aptkingston Dec 10, 2024
9495a90
Merge branch 'frontend-core-ts-2' of github.com:Budibase/budibase int…
aptkingston Dec 10, 2024
bcfe3d2
lint
aptkingston Dec 10, 2024
a781800
Merge branch 'master' into frontend-core-ts-2
aptkingston Dec 10, 2024
4c5bfa5
Fix login response not being handled due to not being JSON
aptkingston Dec 11, 2024
28f895f
Update user endpoints
aptkingston Dec 11, 2024
31b696d
Merge branch 'frontend-core-ts-2' of github.com:Budibase/budibase int…
aptkingston Dec 11, 2024
31a8d85
Merge branch 'master' into frontend-core-ts-2
aptkingston Dec 11, 2024
7be2d9e
Merge branch 'master' into frontend-core-ts-2
aptkingston Dec 11, 2024
a706a76
Merge branch 'master' of github.com:Budibase/budibase into frontend-c…
aptkingston Dec 12, 2024
0cbf0a7
Update builder plugin store with new types
aptkingston Dec 12, 2024
61b42d3
Update naming of builder navigation store type
aptkingston Dec 12, 2024
3a51a81
Remove redundant typing in builder API client
aptkingston Dec 12, 2024
ea444a9
Merge branch 'master' of github.com:Budibase/budibase into frontend-c…
aptkingston Dec 12, 2024
c5407d3
Update to account for type fixes
aptkingston Dec 12, 2024
cb8f052
Merge branch 'master' of github.com:Budibase/budibase into frontend-c…
aptkingston Dec 13, 2024
e77a029
Merge branch 'master' into frontend-core-ts-2
aptkingston Dec 16, 2024
cb88f1f
Merge branch 'master' of github.com:Budibase/budibase into frontend-c…
aptkingston Dec 16, 2024
8c4bb89
Update type casting
aptkingston Dec 16, 2024
4fd47b5
Update auth endpoints to account for new JSON responses
aptkingston Dec 16, 2024
d5eaa6e
Fix duplicating apps
aptkingston Dec 16, 2024
22d8994
Account for responses from app endpoints
aptkingston Dec 16, 2024
4b499ca
Update more endpoints with new response messages
aptkingston Dec 16, 2024
c883f0d
Merge branch 'frontend-core-ts-2' of github.com:Budibase/budibase int…
aptkingston Dec 16, 2024
287f8ce
Merge branch 'master' of github.com:Budibase/budibase into frontend-c…
aptkingston Dec 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/builder/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { get } from "svelte/store"
import { auth, navigation } from "./stores/portal"

export const API = createAPIClient({
attachHeaders: (headers: Record<string, string>) => {
attachHeaders: headers => {
// Attach app ID header from store
let appId = get(appStore).appId
if (appId) {
Expand All @@ -22,7 +22,7 @@ export const API = createAPIClient({
}
},

onError: (error: any) => {
onError: error => {
const { url, message, status, method, handled } = error || {}

// Log any errors that we haven't manually handled
Expand All @@ -45,7 +45,7 @@ export const API = createAPIClient({
}
}
},
onMigrationDetected: (appId: string) => {
onMigrationDetected: appId => {
const updatingUrl = `/builder/app/updating/${appId}`

if (window.location.pathname === updatingUrl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@
async function generateAICronExpression() {
loadingAICronExpression = true
try {
const response = await API.generateCronExpression({
prompt: aiCronPrompt,
})
const response = await API.generateCronExpression(aiCronPrompt)
cronExpression = response.message
dispatch("change", response.message)
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,19 @@
}

const exportAllData = async () => {
return await API.exportView({
viewName: view,
format: exportFormat,
})
return await API.exportView(view, exportFormat)
}

const exportFilteredData = async () => {
let payload = {
tableId: view,
format: exportFormat,
search: {
paginate: false,
},
}
let payload = {}
if (selectedRows?.length) {
payload.rows = selectedRows.map(row => row._id)
}
if (sorting) {
payload.search.sort = sorting.sortColumn
payload.search.sortOrder = sorting.sortOrder
payload.sort = sorting.sortColumn
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️
I guess this was broken? Or were we supporting both formats?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't broken, but I've just flattened the structure a little to make it simpler. We used to do this logic inside the API client code, but there was no point in wrapping things in a search object just to pull them out again later. So the result sent to the API is identical but it's a bit simpler to use it now :)

payload.sortOrder = sorting.sortOrder
}
return await API.exportRows(payload)
return await API.exportRows(view, exportFormat, payload)
}

const exportData = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@
const importData = async () => {
try {
loading = true
await API.importTableData({
tableId,
rows,
identifierFields,
})
await API.importTableData(tableId, rows, identifierFields)
notifications.success("Rows successfully imported")
popover.hide()
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@

const toggleAction = async (action, enabled) => {
if (enabled) {
await rowActions.enableView(tableId, viewId, action.id)
await rowActions.enableView(tableId, action.id, viewId)
} else {
await rowActions.disableView(tableId, viewId, action.id)
await rowActions.disableView(tableId, action.id, viewId)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,7 @@
allValid = false

if (rows.length > 0) {
const response = await API.validateExistingTableImport({
rows,
tableId,
})

const response = await API.validateExistingTableImport(rows, tableId)
validation = response.schemaValidation
invalidColumns = response.invalidColumns
allValid = response.allValid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
loading = true
try {
if (rows.length > 0) {
const response = await API.validateNewTableImport({ rows, schema })
const response = await API.validateNewTableImport(rows, schema)
validation = response.schemaValidation
allValid = response.allValid
errors = response.errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
}

try {
const app = await API.duplicateApp(data, appId)
const app = await API.duplicateApp(appId, data)
appsStore.load()
if (!sdk.users.isBuilder($auth.user, app?.duplicateAppId)) {
// Refresh for access to created applications
Expand Down
8 changes: 0 additions & 8 deletions packages/builder/src/index.d.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@
if (!hasSynced && application) {
try {
await API.syncApp(application)
// check if user has beta access
// const betaResponse = await API.checkBetaAccess($auth?.user?.email)
// betaAccess = betaResponse.access
} catch (error) {
notifications.error("Failed to sync with production database")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
return
}
try {
data = await API.fetchViewData({
name,
data = await API.fetchViewData(name, {
calculation,
field,
groupBy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,18 @@
}

async function fetchBackups(filters, page, dateRange = []) {
const body = {
appId: $appStore.appId,
const opts = {
...filters,
page,
}

const [startDate, endDate] = dateRange
if (startDate) {
body.startDate = startDate
opts.startDate = startDate
}
if (endDate) {
body.endDate = endDate
opts.endDate = endDate
}

const response = await backups.searchBackups(body)
const response = await backups.searchBackups($appStore.appId, opts)
pageInfo.fetched(response.hasNextPage, response.nextPage)

// flatten so we have an easier structure to use for the table schema
Expand All @@ -123,9 +120,7 @@
async function createManualBackup() {
try {
loading = true
let response = await backups.createManualBackup({
appId: $appStore.appId,
})
let response = await backups.createManualBackup($appStore.appId)
await fetchBackups(filterOpt, page)
notifications.success(response.message)
} catch (err) {
Expand All @@ -149,24 +144,14 @@

async function handleButtonClick({ detail }) {
if (detail.type === "backupDelete") {
await backups.deleteBackup({
appId: $appStore.appId,
backupId: detail.backupId,
})
await backups.deleteBackup($appStore.appId, detail.backupId)
await fetchBackups(filterOpt, page)
} else if (detail.type === "backupRestore") {
await backups.restoreBackup({
appId: $appStore.appId,
backupId: detail.backupId,
name: detail.restoreBackupName,
})
await fetchBackups(filterOpt, page)
} else if (detail.type === "backupUpdate") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the backup update no longer required?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope I believe we actually stopped using and allowing custom naming of backups a while ago, so this code existed but was never used. So just pruning dead code with this.

await backups.updateBackup({
appId: $appStore.appId,
backupId: detail.backupId,
name: detail.name,
})
await backups.restoreBackup(
$appStore.appId,
detail.backupId,
detail.restoreBackupName
)
await fetchBackups(filterOpt, page)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@
logsPageInfo.loading()
await auditLogs.search({
bookmark: logsPage,
startDate: dateRange[0],
endDate: dateRange[1],
startDate: dateRange[0] || undefined,
endDate: dateRange[1] || undefined,
fullSearch: logSearchTerm,
userIds: selectedUsers,
appIds: selectedApps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

const activateLicenseKey = async () => {
try {
await API.activateLicenseKey({ licenseKey })
await API.activateLicenseKey(licenseKey)
await auth.getSelf()
await getLicenseKey()
notifications.success("Successfully activated")
Expand Down Expand Up @@ -119,7 +119,7 @@

async function activateOfflineLicense(offlineLicenseToken) {
try {
await API.activateOfflineLicense({ offlineLicenseToken })
await API.activateOfflineLicense(offlineLicenseToken)
await auth.getSelf()
await getOfflineLicense()
notifications.success("Successfully activated")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,7 @@
if (image) {
let data = new FormData()
data.append("file", image)
await API.uploadOIDCLogo({
name: image.name,
data,
})
await API.uploadOIDCLogo(image.name, data)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@
async function deleteSmtp() {
// Delete the SMTP config
try {
await API.deleteConfig({
id: smtpConfig._id,
rev: smtpConfig._rev,
})
await API.deleteConfig(smtpConfig._id, smtpConfig._rev)
smtpConfig = {
type: ConfigTypes.SMTP,
config: {
Expand Down
15 changes: 3 additions & 12 deletions packages/builder/src/stores/builder/automations.js
Original file line number Diff line number Diff line change
Expand Up @@ -751,10 +751,7 @@ const automationActions = store => ({
automation.definition.trigger.inputs.rowActionId
)
} else {
await API.deleteAutomation({
automationId: automation?._id,
automationRev: automation?._rev,
})
await API.deleteAutomation(automation?._id, automation?._rev)
}

store.update(state => {
Expand Down Expand Up @@ -836,10 +833,7 @@ const automationActions = store => ({
test: async (automation, testData) => {
let result
try {
result = await API.testAutomation({
automationId: automation?._id,
testData,
})
result = await API.testAutomation(automation?._id, testData)
} catch (err) {
const message = err.message || err.status || JSON.stringify(err)
throw `Automation test failed - ${message}`
Expand Down Expand Up @@ -893,10 +887,7 @@ const automationActions = store => ({
})
},
clearLogErrors: async ({ automationId, appId } = {}) => {
return await API.clearAutomationLogErrors({
automationId,
appId,
})
return await API.clearAutomationLogErrors(automationId, appId)
},
addTestDataToAutomation: data => {
let newAutomation = cloneDeep(get(selectedAutomation).data)
Expand Down
7 changes: 2 additions & 5 deletions packages/builder/src/stores/builder/flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ export function createFlagsStore() {
set(flags)
},
updateFlag: async (flag, value) => {
await API.updateFlag({
flag,
value,
})
await API.updateFlag(flag, value)
await actions.fetch()
},
toggleUiFeature: async feature => {
await API.toggleUiFeature({ value: feature })
await API.toggleUiFeature(feature)
},
}

Expand Down
5 changes: 1 addition & 4 deletions packages/builder/src/stores/builder/layouts.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ export class LayoutStore extends BudiStore {
if (!layout?._id) {
return
}
await API.deleteLayout({
layoutId: layout._id,
layoutRev: layout._rev,
})
await API.deleteLayout(layout._id, layout._rev)
this.update(state => {
state.layouts = state.layouts.filter(x => x._id !== layout._id)
return state
Expand Down
5 changes: 1 addition & 4 deletions packages/builder/src/stores/builder/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ export class NavigationStore extends BudiStore {

async save(navigation) {
const appId = get(appStore).appId
const app = await API.saveAppMetadata({
appId,
metadata: { navigation },
})
const app = await API.saveAppMetadata(appId, { navigation })
this.syncAppNavigation(app.navigation)
}

Expand Down
12 changes: 2 additions & 10 deletions packages/builder/src/stores/builder/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,10 @@ export function createPermissionStore() {
return {
subscribe,
save: async ({ level, role, resource }) => {
return await API.updatePermissionForResource({
resourceId: resource,
roleId: role,
level,
})
return await API.updatePermissionForResource(resource, role, level)
},
remove: async ({ level, role, resource }) => {
return await API.removePermissionFromResource({
resourceId: resource,
roleId: role,
level,
})
return await API.removePermissionFromResource(resource, role, level)
},
forResource: async resourceId => {
return (await API.getPermissionForResource(resourceId)).permissions
Expand Down
10 changes: 2 additions & 8 deletions packages/builder/src/stores/builder/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ export function createQueriesStore() {
}

const importQueries = async ({ data, datasourceId }) => {
return await API.importQueries({
datasourceId,
data,
})
return await API.importQueries(datasourceId, data)
}

const select = id => {
Expand All @@ -87,10 +84,7 @@ export function createQueriesStore() {
}

const deleteQuery = async query => {
await API.deleteQuery({
queryId: query?._id,
queryRev: query?._rev,
})
await API.deleteQuery(query._id, query._rev)
store.update(state => {
state.list = state.list.filter(existing => existing._id !== query._id)
return state
Expand Down
Loading
Loading