mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
remove: estimationCreateOrganization, deleteOrganization, estimationDeleteOrganization, getOrganizationPlan and getRoles.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
import { Card, Divider, Layout, Typography } from '@appwrite.io/pink-svelte';
|
||||
import { CreditsApplied } from '.';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { AppwriteException, type Models } from '@appwrite.io/console';
|
||||
import { AppwriteException, BillingPlan, type Models } from '@appwrite.io/console';
|
||||
import DiscountsApplied from './discountsApplied.svelte';
|
||||
|
||||
export let billingPlan: string;
|
||||
@@ -23,12 +23,15 @@
|
||||
collaborators: string[],
|
||||
couponId: string | undefined
|
||||
) {
|
||||
/* TODO: @itznotabug - temporary fix */
|
||||
const billingPlanTyped = billingPlan as BillingPlan;
|
||||
|
||||
try {
|
||||
estimation = await sdk.forConsole.billing.estimationCreateOrganization(
|
||||
billingPlan,
|
||||
couponId === '' ? null : couponId,
|
||||
collaborators ?? []
|
||||
);
|
||||
estimation = await sdk.forConsole.organizations.estimationCreateOrganization({
|
||||
billingPlan: billingPlanTyped,
|
||||
invites: collaborators ?? [],
|
||||
couponId: couponId === '' ? null : couponId
|
||||
});
|
||||
} catch (e) {
|
||||
if (e instanceof AppwriteException) {
|
||||
if (
|
||||
|
||||
@@ -57,62 +57,6 @@ export class Billing {
|
||||
);
|
||||
}
|
||||
|
||||
async estimationCreateOrganization(
|
||||
billingPlan: string,
|
||||
couponId: string = null,
|
||||
invites: Array<string> = []
|
||||
): Promise<Models.Estimation> {
|
||||
const path = `/organizations/estimations/create-organization`;
|
||||
const params = {
|
||||
billingPlan,
|
||||
couponId,
|
||||
invites
|
||||
};
|
||||
const uri = new URL(this.client.config.endpoint + path);
|
||||
return await this.client.call(
|
||||
'patch',
|
||||
uri,
|
||||
{
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
params
|
||||
);
|
||||
}
|
||||
|
||||
async deleteOrganization(organizationId: string): Promise<Models.Organization> {
|
||||
const path = `/organizations/${organizationId}`;
|
||||
const params = {
|
||||
organizationId
|
||||
};
|
||||
const uri = new URL(this.client.config.endpoint + path);
|
||||
return await this.client.call(
|
||||
'DELETE',
|
||||
uri,
|
||||
{
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
params
|
||||
);
|
||||
}
|
||||
|
||||
async estimationDeleteOrganization(
|
||||
organizationId: string
|
||||
): Promise<Models.EstimationDeleteOrganization> {
|
||||
const path = `/organizations/${organizationId}/estimations/delete-organization`;
|
||||
const uri = new URL(this.client.config.endpoint + path);
|
||||
return await this.client.call('patch', uri, {
|
||||
'content-type': 'application/json'
|
||||
});
|
||||
}
|
||||
|
||||
async getOrganizationPlan(organizationId: string): Promise<Models.BillingPlan> {
|
||||
const path = `/organizations/${organizationId}/plan`;
|
||||
const uri = new URL(this.client.config.endpoint + path);
|
||||
return await this.client.call('get', uri, {
|
||||
'content-type': 'application/json'
|
||||
});
|
||||
}
|
||||
|
||||
async listPlans(queries: string[] = []): Promise<Models.BillingPlanList> {
|
||||
const path = `/console/plans`;
|
||||
const uri = new URL(this.client.config.endpoint + path);
|
||||
@@ -137,14 +81,6 @@ export class Billing {
|
||||
});
|
||||
}
|
||||
|
||||
async getRoles(organizationId: string): Promise<Models.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,
|
||||
|
||||
@@ -317,7 +317,9 @@ export async function checkForProjectsLimit(org: Models.Organization, orgProject
|
||||
if (!isCloud) return;
|
||||
if (!org) return;
|
||||
|
||||
const plan = await sdk.forConsole.billing.getOrganizationPlan(org.$id);
|
||||
const plan = await sdk.forConsole.organizations.getPlan({
|
||||
organizationId: org.$id
|
||||
});
|
||||
if (!plan) return;
|
||||
|
||||
if (plan.$id !== BillingPlan.FREE) return;
|
||||
|
||||
@@ -254,7 +254,9 @@
|
||||
|
||||
$: if (!isNewOrg) {
|
||||
(async () => {
|
||||
currentPlan = await sdk.forConsole.billing.getOrganizationPlan(selectedOrgId);
|
||||
currentPlan = await sdk.forConsole.organizations.getPlan({
|
||||
organizationId: selectedOrgId
|
||||
});
|
||||
})();
|
||||
loadPaymentMethods();
|
||||
}
|
||||
|
||||
@@ -31,8 +31,13 @@ export const load: LayoutLoad = async ({ params, depends, parent }) => {
|
||||
try {
|
||||
if (isCloud) {
|
||||
[{ roles, scopes }, currentPlan] = await Promise.all([
|
||||
sdk.forConsole.billing.getRoles(params.organization),
|
||||
sdk.forConsole.billing.getOrganizationPlan(params.organization)
|
||||
sdk.forConsole.organizations.getScopes({
|
||||
organizationId: params.organization
|
||||
}),
|
||||
|
||||
sdk.forConsole.organizations.getPlan({
|
||||
organizationId: params.organization
|
||||
})
|
||||
]);
|
||||
|
||||
if (scopes.includes('billing.read')) {
|
||||
|
||||
+6
-4
@@ -28,7 +28,9 @@
|
||||
async function deleteOrg() {
|
||||
try {
|
||||
if (isCloud) {
|
||||
await sdk.forConsole.billing.deleteOrganization($organization.$id);
|
||||
await sdk.forConsole.organizations.delete({
|
||||
organizationId: $organization.$id
|
||||
});
|
||||
} else {
|
||||
await sdk.forConsole.teams.delete({
|
||||
teamId: $organization.$id
|
||||
@@ -82,9 +84,9 @@
|
||||
if (isCloud) {
|
||||
try {
|
||||
error = '';
|
||||
estimation = await sdk.forConsole.billing.estimationDeleteOrganization(
|
||||
$organization.$id
|
||||
);
|
||||
estimation = await sdk.forConsole.organizations.estimationDeleteOrganization({
|
||||
organizationId: $organization.$id
|
||||
});
|
||||
} catch (e) {
|
||||
error = e.message;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,11 @@ export const load: LayoutLoad = async ({ params, depends, parent }) => {
|
||||
(sdk.forConsole.teams.get({ teamId: project.teamId }) as Promise<Models.Organization>)
|
||||
: organization,
|
||||
sdk.forConsoleIn(project.region).console.variables(),
|
||||
isCloud ? sdk.forConsole.billing.getRoles(project.teamId) : null,
|
||||
isCloud
|
||||
? sdk.forConsole.organizations.getScopes({
|
||||
organizationId: project.teamId
|
||||
})
|
||||
: null,
|
||||
|
||||
loadAvailableRegions(project.teamId)
|
||||
]);
|
||||
@@ -56,7 +60,9 @@ export const load: LayoutLoad = async ({ params, depends, parent }) => {
|
||||
const organizationPlan = includedInBasePlans
|
||||
? plansInfo.get(organization?.billingPlan)
|
||||
: isCloud
|
||||
? await sdk.forConsole.billing.getOrganizationPlan(organization?.$id)
|
||||
? await sdk.forConsole.organizations.getPlan({
|
||||
organizationId: organization?.$id
|
||||
})
|
||||
: null;
|
||||
|
||||
const roles = rolesResult?.roles ?? defaultRoles;
|
||||
|
||||
Reference in New Issue
Block a user