diff --git a/packages/builder/src/stores/portal/backups.js b/packages/builder/src/stores/portal/backups.js new file mode 100644 index 0000000000..70b973a3e8 --- /dev/null +++ b/packages/builder/src/stores/portal/backups.js @@ -0,0 +1,40 @@ +import { writable } from "svelte/store" +import { API } from "api" + +export function createBackupsStore() { + const { subscribe, set } = writable([]) + + async function load() { + set([ + { + trigger: "PUBLISH", + name: "A Backup", + date: "1665407451", + userId: "Peter Clement", + contents: [ + { datasources: ["datasource1", "datasource2"] }, + { screens: ["screen1", "screen2"] }, + { automations: ["automation1", "automation2"] }, + ], + }, + ]) + } + + async function searchBackups(appId) { + return API.searchBackups(appId) + } + + async function createManualBackup(appId, name) { + let resp = API.createManualBackup(appId, name) + return resp + } + + return { + subscribe, + load, + createManualBackup, + searchBackups, + } +} + +export const backups = createBackupsStore() diff --git a/packages/builder/src/stores/portal/index.js b/packages/builder/src/stores/portal/index.js index fa7aa7e3cf..5406ddc3dc 100644 --- a/packages/builder/src/stores/portal/index.js +++ b/packages/builder/src/stores/portal/index.js @@ -9,3 +9,4 @@ export { templates } from "./templates" export { licensing } from "./licensing" export { groups } from "./groups" export { plugins } from "./plugins" +export { backups } from "./backups" diff --git a/packages/frontend-core/src/api/backups.js b/packages/frontend-core/src/api/backups.js new file mode 100644 index 0000000000..45079e3e7e --- /dev/null +++ b/packages/frontend-core/src/api/backups.js @@ -0,0 +1,20 @@ +export const buildBackupsEndpoints = API => ({ + /** + * Gets a list of users in the current tenant. + */ + searchBackups: async appId => { + return await API.post({ + url: `/api/apps/${appId}/backups/search`, + body: { + trigger: "MANUAL", + }, + }) + }, + + createManualBackup: async ({ appId, name }) => { + return await API.post({ + url: `/api/apps/${appId}/backups`, + body: { name }, + }) + }, +}) diff --git a/packages/frontend-core/src/api/index.js b/packages/frontend-core/src/api/index.js index 3b9bb5b57e..9a40b21351 100644 --- a/packages/frontend-core/src/api/index.js +++ b/packages/frontend-core/src/api/index.js @@ -25,6 +25,7 @@ import { buildViewEndpoints } from "./views" import { buildLicensingEndpoints } from "./licensing" import { buildGroupsEndpoints } from "./groups" import { buildPluginEndpoints } from "./plugins" +import { buildBackupsEndpoints } from "./backups" const defaultAPIClientConfig = { /** @@ -245,5 +246,6 @@ export const createAPIClient = config => { ...buildLicensingEndpoints(API), ...buildGroupsEndpoints(API), ...buildPluginEndpoints(API), + ...buildBackupsEndpoints(API), } }