fetch roles and store

This commit is contained in:
Damodar Lohani committed 2024-09-02 07:05:55 +00:00
1 parent bdcbf841fc
commit 903f721bcd
2 files changed
+25

No files matched your search

+17
View File
@@ -272,6 +272,11 @@ export type PlansInfo = {
export type PlansMap = Map<Tier, Plan>;
export type Roles = {
scopes: string[],
roles: string[],
}
export class Billing {
client: Client;
@@ -353,6 +358,18 @@ export class Billing {
);
}
async getScopes(organizationId: string): Promise<Roles> {
const path = `/organizations/${organizationId}/roles`;
const uri = new URL(this.client.config.endpoint + path);
return await this.client.call(
'get',
uri,
{
'content-type': 'application/json'
}
);
}
async updatePlan(
organizationId: string,
billingPlan: string,
+8
View File
@@ -0,0 +1,8 @@
import { page } from "$app/stores";
import { derived } from "svelte/store";
export const roles = derived(page, ($page) => $page.data.roles);
export const scopes = derived(page, ($page) => $page.data.scopes);
export const isDeveloper = derived(roles, ($roles) => $roles.includes("developer"));
export const canSeeDatabases = derived(scopes, ($scopes) => $scopes.includes("databases.read"));