From ef1435cdb4402b14cca805219d2efd4934337662 Mon Sep 17 00:00:00 2001
From: Darshan
Date: Thu, 18 Dec 2025 13:05:32 +0530
Subject: [PATCH 01/27] remove: hardcoded `Plan` type and use billing models
from sdk.
---
package.json | 2 +-
pnpm-lock.yaml | 10 +-
src/lib/components/archiveProject.svelte | 3 +-
.../components/billing/planSelection.svelte | 6 +-
src/lib/sdk/billing.ts | 94 +------------------
src/lib/stores/billing.ts | 15 +--
src/lib/stores/organization.ts | 3 +-
src/routes/(console)/+layout.svelte | 3 +-
src/routes/(console)/+layout.ts | 7 +-
.../account/organizations/+page.svelte | 4 +-
.../(console)/apply-credit/+page.svelte | 6 +-
.../organization-[organization]/+layout.ts | 5 +-
.../billing/budgetAlert.svelte | 9 +-
.../billing/budgetCap.svelte | 7 +-
.../billing/planSummary.svelte | 9 +-
.../billing/planSummaryOld.svelte | 10 +-
.../organization-[organization]/header.svelte | 10 +-
.../databases/+page.ts | 3 +-
.../settings/updateMaxFileSize.svelte | 3 +-
19 files changed, 60 insertions(+), 149 deletions(-)
diff --git a/package.json b/package.json
index 15cb88fa7f..971f912a30 100644
--- a/package.json
+++ b/package.json
@@ -22,7 +22,7 @@
},
"dependencies": {
"@ai-sdk/svelte": "^1.1.24",
- "@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@9b32107",
+ "@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@49ffd53",
"@appwrite.io/pink-icons": "0.25.0",
"@appwrite.io/pink-icons-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-icons-svelte@865e2fc",
"@appwrite.io/pink-legacy": "^1.0.3",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index f7492f49f0..d38362e774 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -12,8 +12,8 @@ importers:
specifier: ^1.1.24
version: 1.1.24(svelte@5.25.3)(zod@3.24.3)
'@appwrite.io/console':
- specifier: https://pkg.vc/-/@appwrite/@appwrite.io/console@9b32107
- version: https://pkg.vc/-/@appwrite/@appwrite.io/console@9b32107
+ specifier: https://pkg.vc/-/@appwrite/@appwrite.io/console@49ffd53
+ version: https://pkg.vc/-/@appwrite/@appwrite.io/console@49ffd53
'@appwrite.io/pink-icons':
specifier: 0.25.0
version: 0.25.0
@@ -272,8 +272,8 @@ packages:
'@analytics/type-utils@0.6.2':
resolution: {integrity: sha512-TD+xbmsBLyYy/IxFimW/YL/9L2IEnM7/EoV9Aeh56U64Ify8o27HJcKjo38XY9Tcn0uOq1AX3thkKgvtWvwFQg==}
- '@appwrite.io/console@https://pkg.vc/-/@appwrite/@appwrite.io/console@9b32107':
- resolution: {tarball: https://pkg.vc/-/@appwrite/@appwrite.io/console@9b32107}
+ '@appwrite.io/console@https://pkg.vc/-/@appwrite/@appwrite.io/console@49ffd53':
+ resolution: {tarball: https://pkg.vc/-/@appwrite/@appwrite.io/console@49ffd53}
version: 1.10.0
'@appwrite.io/pink-icons-svelte@2.0.0-RC.1':
@@ -3823,7 +3823,7 @@ snapshots:
'@analytics/type-utils@0.6.2': {}
- '@appwrite.io/console@https://pkg.vc/-/@appwrite/@appwrite.io/console@9b32107': {}
+ '@appwrite.io/console@https://pkg.vc/-/@appwrite/@appwrite.io/console@49ffd53': {}
'@appwrite.io/pink-icons-svelte@2.0.0-RC.1(svelte@5.25.3)':
dependencies:
diff --git a/src/lib/components/archiveProject.svelte b/src/lib/components/archiveProject.svelte
index 8a9797ca09..9fa20fc5b0 100644
--- a/src/lib/components/archiveProject.svelte
+++ b/src/lib/components/archiveProject.svelte
@@ -38,13 +38,12 @@
import { isCloud } from '$lib/system';
import { regions as regionsStore } from '$lib/stores/organization';
import type { Organization } from '$lib/stores/organization';
- import type { Plan } from '$lib/sdk/billing';
// props
interface Props {
projectsToArchive: Models.Project[];
organization: Organization;
- currentPlan: Plan;
+ currentPlan: Models.BillingPlan;
}
let { projectsToArchive, organization, currentPlan }: Props = $props();
diff --git a/src/lib/components/billing/planSelection.svelte b/src/lib/components/billing/planSelection.svelte
index 6499a47c0b..6d8d4a562b 100644
--- a/src/lib/components/billing/planSelection.svelte
+++ b/src/lib/components/billing/planSelection.svelte
@@ -4,21 +4,21 @@
import { currentPlan, organization } from '$lib/stores/organization';
import { Badge, Layout, Tooltip, Typography } from '@appwrite.io/pink-svelte';
import { LabelCard } from '..';
- import type { Plan } from '$lib/sdk/billing';
import { page } from '$app/state';
+ import type { Models } from '@appwrite.io/console';
export let billingPlan: BillingPlan;
export let isNewOrg = false;
export let selfService = true;
export let anyOrgFree = false;
- $: plans = Object.values(page.data.plans.plans) as Plan[];
+ $: plans = Object.values(page.data.plans.plans) as Models.BillingPlan[];
$: currentPlanInList = plans.some((plan) => plan.$id === $currentPlan?.$id);
// experiment to remove scale plan temporarily
$: plansWithoutScale = plans.filter((plan) => plan.$id != BillingPlan.SCALE);
- function shouldShowTooltip(plan: Plan) {
+ function shouldShowTooltip(plan: Models.BillingPlan) {
if (plan.$id !== BillingPlan.FREE) return true;
else return !anyOrgFree;
}
diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts
index f728ca5e84..2cf540d92e 100644
--- a/src/lib/sdk/billing.ts
+++ b/src/lib/sdk/billing.ts
@@ -354,91 +354,7 @@ export type AddressesList = {
total: number;
};
-export type AdditionalResource = {
- name: string;
- currency: string;
- invoiceDesc: string;
- price: number;
- unit: string;
- value: number;
- multiplier?: number;
-};
-
-export type PlanAddon = {
- supported: boolean;
- currency: string;
- invoiceDesc: string;
- price: number;
- limit: number;
- value: number;
- type: string;
- planIncluded: number;
-};
-
-export type Plan = {
- $id: string;
- name: string;
- desc: string;
- price: number;
- order: number;
- bandwidth: number;
- storage: number;
- imageTransformations: number;
- webhooks: number;
- users: number;
- teams: number;
- projects: number;
- databases: number;
- databasesAllowEncrypt: boolean;
- databasesReads: number;
- databasesWrites: number;
- buckets: number;
- fileSize: number;
- functions: number;
- executions: number;
- GBHours: number;
- realtime: number;
- logs: number;
- authPhone: number;
- usage: {
- bandwidth: AdditionalResource;
- executions: AdditionalResource;
- member: AdditionalResource;
- realtime: AdditionalResource;
- storage: AdditionalResource;
- users: AdditionalResource;
- databasesReads: AdditionalResource;
- databasesWrites: AdditionalResource;
- GBHours: AdditionalResource;
- imageTransformations: AdditionalResource;
- };
- addons: {
- seats: PlanAddon;
- projects: PlanAddon;
- };
- trialDays: number;
- budgetCapEnabled: boolean;
- isAvailable: boolean;
- selfService: boolean;
- premiumSupport: boolean;
- budgeting: boolean;
- supportsMockNumbers: boolean;
- backupsEnabled: boolean;
- backupPolicies: number;
- emailBranding: boolean;
- supportsCredits: boolean;
- supportsOrganizationRoles: boolean;
- buildSize: number; // in MB
- deploymentSize: number; // in MB
- usagePerProject: boolean;
-};
-
-export type PlanList = {
- plans: Plan[];
- total: number;
-};
-
-export type PlansMap = Map;
+export type BillingPlansMap = Map;
export type Roles = {
scopes: string[];
@@ -567,7 +483,7 @@ export class Billing {
});
}
- async getOrganizationPlan(organizationId: string): Promise {
+ async getOrganizationPlan(organizationId: string): Promise {
const path = `/organizations/${organizationId}/plan`;
const uri = new URL(this.client.config.endpoint + path);
return await this.client.call('get', uri, {
@@ -575,7 +491,7 @@ export class Billing {
});
}
- async listPlans(queries: string[] = []): Promise {
+ async listPlans(queries: string[] = []): Promise {
const path = `/console/plans`;
const uri = new URL(this.client.config.endpoint + path);
const params = {
@@ -591,7 +507,7 @@ export class Billing {
);
}
- async getPlan(planId: string): Promise {
+ async getPlan(planId: string): Promise {
const path = `/console/plans/${planId}`;
const uri = new URL(this.client.config.endpoint + path);
return await this.client.call('get', uri, {
@@ -1440,7 +1356,7 @@ export class Billing {
);
}
- async getPlansInfo(): Promise {
+ async getPlansInfo(): Promise {
const path = `/console/plans`;
const params = {};
const uri = new URL(this.client.config.endpoint + path);
diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts
index 695ef874c7..5c7305125f 100644
--- a/src/lib/stores/billing.ts
+++ b/src/lib/stores/billing.ts
@@ -19,12 +19,11 @@ import type {
InvoiceList,
PaymentList,
PaymentMethodData,
- Plan,
- PlansMap
+ BillingPlansMap
} from '$lib/sdk/billing';
import { isCloud } from '$lib/system';
import { activeHeaderAlert, orgMissingPaymentMethod } from '$routes/(console)/store';
-import { AppwriteException, Query, Platform } from '@appwrite.io/console';
+import { AppwriteException, Query, Platform, type Models } from '@appwrite.io/console';
import { derived, get, writable } from 'svelte/store';
import { headerAlert } from './headerAlert';
import { addNotification, notifications } from './notifications';
@@ -72,7 +71,7 @@ export const billingLimitOutstandingInvoice = 'outstanding_invoice';
export const paymentMethods = derived(page, ($page) => $page.data.paymentMethods as PaymentList);
export const addressList = derived(page, ($page) => $page.data.addressList as AddressesList);
-export const plansInfo = derived(page, ($page) => $page.data.plansInfo as PlansMap);
+export const plansInfo = derived(page, ($page) => $page.data.plansInfo as BillingPlansMap);
export const daysLeftInTrial = writable(0);
export const readOnly = writable(false);
@@ -152,7 +151,11 @@ export type PlanServices =
| 'authPhone'
| 'imageTransformations';
-export function getServiceLimit(serviceId: PlanServices, tier: Tier = null, plan?: Plan): number {
+export function getServiceLimit(
+ serviceId: PlanServices,
+ tier: Tier = null,
+ plan?: Models.BillingPlan
+): number {
if (!isCloud) return 0;
if (!serviceId) return 0;
@@ -626,7 +629,7 @@ export const billingURL = derived(
export const hideBillingHeaderRoutes = [base + '/create-organization', base + '/account'];
-export function calculateExcess(addon: AggregationTeam, plan: Plan) {
+export function calculateExcess(addon: AggregationTeam, plan: Models.BillingPlan) {
return {
bandwidth: calculateResourceSurplus(addon.usageBandwidth, plan.bandwidth),
storage: calculateResourceSurplus(addon.usageStorage, plan.storage, 'GB'),
diff --git a/src/lib/stores/organization.ts b/src/lib/stores/organization.ts
index 7393c6ed65..43b6074880 100644
--- a/src/lib/stores/organization.ts
+++ b/src/lib/stores/organization.ts
@@ -1,6 +1,5 @@
import { page } from '$app/stores';
import type { Tier } from './billing';
-import type { Plan } from '$lib/sdk/billing';
import { derived, writable } from 'svelte/store';
import { type Models, Platform } from '@appwrite.io/console';
@@ -61,6 +60,6 @@ export const organizationList = derived(
);
export const organization = derived(page, ($page) => $page.data?.organization as Organization);
-export const currentPlan = derived(page, ($page) => $page.data?.currentPlan as Plan);
+export const currentPlan = derived(page, ($page) => $page.data?.currentPlan as Models.BillingPlan);
export const members = derived(page, ($page) => $page.data.members as Models.MembershipList);
export const regions = writable({ total: 0, regions: [] });
diff --git a/src/routes/(console)/+layout.svelte b/src/routes/(console)/+layout.svelte
index 109bdabb3a..be3539bf44 100644
--- a/src/routes/(console)/+layout.svelte
+++ b/src/routes/(console)/+layout.svelte
@@ -23,7 +23,6 @@
checkForUsageLimit,
checkPaymentAuthorizationRequired,
paymentExpired,
- plansInfo,
showUsageRatesModal
} from '$lib/stores/billing';
import { goto } from '$app/navigation';
@@ -310,7 +309,7 @@
await checkPaymentAuthorizationRequired(org);
await checkForMandate(org);
- if ($plansInfo.get(org.billingPlan)?.trialDays) {
+ if (org?.billingTrialDays) {
calculateTrialDay(org);
}
}
diff --git a/src/routes/(console)/+layout.ts b/src/routes/(console)/+layout.ts
index 3cf1478a3a..5ad9ebcbd1 100644
--- a/src/routes/(console)/+layout.ts
+++ b/src/routes/(console)/+layout.ts
@@ -3,8 +3,7 @@ import { sdk } from '$lib/stores/sdk';
import { isCloud } from '$lib/system';
import type { LayoutLoad } from './$types';
import type { Tier } from '$lib/stores/billing';
-import type { Plan, PlanList } from '$lib/sdk/billing';
-import { Query } from '@appwrite.io/console';
+import { type Models, Query } from '@appwrite.io/console';
export const load: LayoutLoad = async ({ depends, parent }) => {
const { organizations } = await parent();
@@ -56,8 +55,8 @@ export const load: LayoutLoad = async ({ depends, parent }) => {
};
};
-function toPlanMap(plansArray: PlanList | null): Map {
- const map = new Map();
+function toPlanMap(plansArray: Models.BillingPlanList | null): Map {
+ const map = new Map();
if (!plansArray?.plans.length) return map;
const plans = plansArray.plans;
diff --git a/src/routes/(console)/account/organizations/+page.svelte b/src/routes/(console)/account/organizations/+page.svelte
index 2d16680439..22396b6dd6 100644
--- a/src/routes/(console)/account/organizations/+page.svelte
+++ b/src/routes/(console)/account/organizations/+page.svelte
@@ -16,7 +16,7 @@
import { Badge, Skeleton } from '@appwrite.io/pink-svelte';
import type { Models } from '@appwrite.io/console';
import type { Organization } from '$lib/stores/organization';
- import { daysLeftInTrial, plansInfo, tierToPlan, type Tier } from '$lib/stores/billing';
+ import { daysLeftInTrial, tierToPlan, type Tier } from '$lib/stores/billing';
import { toLocaleDate } from '$lib/helpers/date';
import { BillingPlan } from '$lib/constants';
import { goto } from '$app/navigation';
@@ -62,7 +62,7 @@
if ($daysLeftInTrial <= 0) return false;
if (organization.billingPlan === BillingPlan.FREE) return false;
- return !!$plansInfo.get(organization.billingPlan)?.trialDays;
+ return !!organization?.billingTrialDays;
}
function isNonPayingOrganization(organization: Organization): boolean {
diff --git a/src/routes/(console)/apply-credit/+page.svelte b/src/routes/(console)/apply-credit/+page.svelte
index db9dbc0387..b7226b3e77 100644
--- a/src/routes/(console)/apply-credit/+page.svelte
+++ b/src/routes/(console)/apply-credit/+page.svelte
@@ -8,7 +8,7 @@
import { Button, Form, InputSelect, InputTags, InputText } from '$lib/elements/forms';
import { toLocaleDate } from '$lib/helpers/date';
import { Wizard } from '$lib/layout';
- import type { PaymentList, Plan } from '$lib/sdk/billing';
+ import type { PaymentList } from '$lib/sdk/billing';
import { addNotification } from '$lib/stores/notifications';
import {
organizationList,
@@ -17,7 +17,7 @@
} from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
import { confirmPayment } from '$lib/stores/stripe.js';
- import { ID } from '@appwrite.io/console';
+ import { ID, type Models } from '@appwrite.io/console';
import { onMount } from 'svelte';
import { writable } from 'svelte/store';
import { isOrganization, plansInfo, type Tier } from '$lib/stores/billing';
@@ -70,7 +70,7 @@
let campaign = data?.campaign;
let billingPlan: Tier = BillingPlan.PRO;
let tempOrgId = null;
- let currentPlan: Plan;
+ let currentPlan: Models.BillingPlan;
$: onlyNewOrgs = campaign?.onlyNewOrgs || couponData?.onlyNewOrgs;
diff --git a/src/routes/(console)/organization-[organization]/+layout.ts b/src/routes/(console)/organization-[organization]/+layout.ts
index ef77274e81..39893dbd45 100644
--- a/src/routes/(console)/organization-[organization]/+layout.ts
+++ b/src/routes/(console)/organization-[organization]/+layout.ts
@@ -11,10 +11,9 @@ import ProjectsAtRisk from '$lib/components/billing/alerts/projectsAtRisk.svelte
import { get } from 'svelte/store';
import { preferences } from '$lib/stores/preferences';
import { defaultRoles, defaultScopes } from '$lib/constants';
-import type { Plan } from '$lib/sdk/billing';
import { loadAvailableRegions } from '$routes/(console)/regions';
import type { Organization } from '$lib/stores/organization';
-import { Platform } from '@appwrite.io/console';
+import { type Models, Platform } from '@appwrite.io/console';
import { resolve } from '$app/paths';
export const load: LayoutLoad = async ({ params, depends, parent }) => {
@@ -28,7 +27,7 @@ export const load: LayoutLoad = async ({ params, depends, parent }) => {
let roles = isCloud ? [] : defaultRoles;
let scopes = isCloud ? [] : defaultScopes;
- let currentPlan: Plan = null;
+ let currentPlan: Models.BillingPlan | null = null;
try {
if (isCloud) {
diff --git a/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte b/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte
index 5743273b94..ad5b178684 100644
--- a/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte
@@ -12,11 +12,11 @@
import { Alert, Icon, Table } from '@appwrite.io/pink-svelte';
import { IconTrash } from '@appwrite.io/pink-icons-svelte';
import InputSelect from '$lib/elements/forms/inputSelect.svelte';
- import type { Plan } from '$lib/sdk/billing';
+ import type { Models } from '@appwrite.io/console';
- export let organization: Organization;
- export let currentPlan: Plan;
export let alertsEnabled = false;
+ export let organization: Organization;
+ export let currentPlan: Models.BillingPlan;
let search: string;
let selectedAlert: number;
@@ -53,13 +53,14 @@
alerts
);
- invalidate(Dependencies.ORGANIZATION);
+ await invalidate(Dependencies.ORGANIZATION);
addNotification({
type: 'success',
isHtml: true,
message: ` ${alerts.length === 0 ? 'Budget alerts removed from' : alerts.length > 1 ? `Budget alerts added to` : 'A budget alert has been added to'} ${organization.name} `
});
+
trackEvent(Submit.BudgetAlertsUpdate, {
alerts
});
diff --git a/src/routes/(console)/organization-[organization]/billing/budgetCap.svelte b/src/routes/(console)/organization-[organization]/billing/budgetCap.svelte
index bd08a88ca7..65062307b6 100644
--- a/src/routes/(console)/organization-[organization]/billing/budgetCap.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/budgetCap.svelte
@@ -10,12 +10,13 @@
import { sdk } from '$lib/stores/sdk';
import { Alert, Link } from '@appwrite.io/pink-svelte';
import BudgetAlert from './budgetAlert.svelte';
- import type { Plan } from '$lib/sdk/billing';
+ import type { Models } from '@appwrite.io/console';
- export let currentPlan: Plan;
export let organization: Organization;
- let capActive = organization?.billingBudget !== null;
+ export let currentPlan: Models.BillingPlan;
+
let budget = organization.billingBudget;
+ let capActive = organization?.billingBudget !== null;
async function updateBudget() {
try {
diff --git a/src/routes/(console)/organization-[organization]/billing/planSummary.svelte b/src/routes/(console)/organization-[organization]/billing/planSummary.svelte
index fb3df8a608..fe6b28b852 100644
--- a/src/routes/(console)/organization-[organization]/billing/planSummary.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/planSummary.svelte
@@ -5,7 +5,7 @@
import { toLocaleDate } from '$lib/helpers/date';
import { upgradeURL } from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
- import type { AggregationTeam, InvoiceUsage, Plan } from '$lib/sdk/billing';
+ import type { AggregationTeam, InvoiceUsage } from '$lib/sdk/billing';
import { formatCurrency } from '$lib/helpers/numbers';
import { BillingPlan, DEFAULT_BILLING_PROJECTS_LIMIT } from '$lib/constants';
import { Click, trackEvent } from '$lib/actions/analytics';
@@ -25,6 +25,7 @@
import { IconTag } from '@appwrite.io/pink-icons-svelte';
import { page } from '$app/state';
import type { RowFactoryOptions } from '$routes/(console)/organization-[organization]/billing/store';
+ import type { Models } from '@appwrite.io/console';
let {
currentPlan,
@@ -34,8 +35,8 @@
limit = undefined,
offset = undefined
}: {
- currentPlan: Plan;
- nextPlan?: Plan | null;
+ currentPlan: Models.BillingPlan;
+ nextPlan?: Models.BillingPlan | null;
availableCredit?: number | undefined;
currentAggregation?: AggregationTeam | undefined;
limit?: number | undefined;
@@ -229,7 +230,7 @@
}
function getBillingData(
- currentPlan: Plan,
+ currentPlan: Models.BillingPlan,
currentAggregation: AggregationTeam | undefined,
isSmallViewport: boolean
) {
diff --git a/src/routes/(console)/organization-[organization]/billing/planSummaryOld.svelte b/src/routes/(console)/organization-[organization]/billing/planSummaryOld.svelte
index 083aff4445..301792d33a 100644
--- a/src/routes/(console)/organization-[organization]/billing/planSummaryOld.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/planSummaryOld.svelte
@@ -3,9 +3,9 @@
import { CardGrid } from '$lib/components';
import { Button } from '$lib/elements/forms';
import { toLocaleDate } from '$lib/helpers/date';
- import { plansInfo, upgradeURL } from '$lib/stores/billing';
+ import { upgradeURL } from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
- import type { Aggregation, Invoice, Plan } from '$lib/sdk/billing';
+ import type { Aggregation, Invoice } from '$lib/sdk/billing';
import { abbreviateNumber, formatCurrency, formatNumberWithCommas } from '$lib/helpers/numbers';
import { BillingPlan } from '$lib/constants';
import { Click, trackEvent } from '$lib/actions/analytics';
@@ -20,8 +20,9 @@
} from '@appwrite.io/pink-svelte';
import { IconInfo, IconTag } from '@appwrite.io/pink-icons-svelte';
import CancelDowngradeModel from './cancelDowngradeModal.svelte';
+ import type { Models } from '@appwrite.io/console';
- export let currentPlan: Plan;
+ export let currentPlan: Models.BillingPlan;
export let currentInvoice: Invoice | undefined = undefined;
export let availableCredit: number | undefined = undefined;
export let currentAggregation: Aggregation | undefined = undefined;
@@ -31,7 +32,8 @@
const today = new Date();
const isTrial =
new Date($organization?.billingStartDate).getTime() - today.getTime() > 0 &&
- $plansInfo.get($organization.billingPlan)?.trialDays;
+ $organization?.billingTrialDays; /* number of trial days. */
+
const extraUsage = currentInvoice ? currentInvoice.amount - currentPlan?.price : 0;
diff --git a/src/routes/(console)/organization-[organization]/header.svelte b/src/routes/(console)/organization-[organization]/header.svelte
index 191131ae49..f35b360dcd 100644
--- a/src/routes/(console)/organization-[organization]/header.svelte
+++ b/src/routes/(console)/organization-[organization]/header.svelte
@@ -8,13 +8,7 @@
import { toLocaleDate } from '$lib/helpers/date';
import { isTabSelected } from '$lib/helpers/load';
import { Cover } from '$lib/layout';
- import {
- daysLeftInTrial,
- getServiceLimit,
- plansInfo,
- readOnly,
- tierToPlan
- } from '$lib/stores/billing';
+ import { daysLeftInTrial, getServiceLimit, readOnly, tierToPlan } from '$lib/stores/billing';
import {
members,
newMemberModal,
@@ -110,7 +104,7 @@
{:else if isCloud && organization?.billingPlan === BillingPlan.FREE}
{/if}
- {#if isCloud && organization?.billingTrialStartDate && $daysLeftInTrial > 0 && organization.billingPlan !== BillingPlan.FREE && $plansInfo.get(organization.billingPlan)?.trialDays}
+ {#if isCloud && organization?.billingTrialStartDate && $daysLeftInTrial > 0 && organization.billingPlan !== BillingPlan.FREE && organization?.billingTrialDays}
diff --git a/src/routes/(console)/project-[region]-[project]/databases/+page.ts b/src/routes/(console)/project-[region]-[project]/databases/+page.ts
index fcb828ff80..6c3719f61e 100644
--- a/src/routes/(console)/project-[region]-[project]/databases/+page.ts
+++ b/src/routes/(console)/project-[region]-[project]/databases/+page.ts
@@ -7,7 +7,6 @@ import type { PageLoad, RouteParams } from './$types';
import type { BackupPolicy } from '$lib/sdk/backups';
import { isSelfHosted } from '$lib/system';
import { isCloud } from '$lib/system';
-import type { Plan } from '$lib/sdk/billing';
export const load: PageLoad = async ({ url, route, depends, params, parent }) => {
depends(Dependencies.DATABASES);
@@ -46,7 +45,7 @@ async function fetchDatabasesAndBackups(
offset: number,
params: RouteParams,
search?: string | undefined,
- currentPlan?: Plan
+ currentPlan?: Models.BillingPlan
) {
const backupsEnabled = currentPlan?.backupsEnabled ?? true;
diff --git a/src/routes/(console)/project-[region]-[project]/storage/bucket-[bucket]/settings/updateMaxFileSize.svelte b/src/routes/(console)/project-[region]-[project]/storage/bucket-[bucket]/settings/updateMaxFileSize.svelte
index 6e8b681dce..a58dbc1743 100644
--- a/src/routes/(console)/project-[region]-[project]/storage/bucket-[bucket]/settings/updateMaxFileSize.svelte
+++ b/src/routes/(console)/project-[region]-[project]/storage/bucket-[bucket]/settings/updateMaxFileSize.svelte
@@ -10,11 +10,10 @@
import { organization } from '$lib/stores/organization';
import { GRACE_PERIOD_OVERRIDE, isCloud } from '$lib/system';
import { updateBucket } from './+page.svelte';
- import type { Plan } from '$lib/sdk/billing';
import type { Models } from '@appwrite.io/console';
export let bucket: Models.Bucket;
- export let currentPlan: Plan | null;
+ export let currentPlan: Models.BillingPlan | null;
const service = currentPlan ? currentPlan['fileSize'] : null;
const { value, unit, baseValue, units } = createByteUnitPair(bucket.maximumFileSize, 1000);
From c462360681ec2e902bd503a70e6fdce30c7352b2 Mon Sep 17 00:00:00 2001
From: Darshan
Date: Thu, 18 Dec 2025 13:09:25 +0530
Subject: [PATCH 02/27] remove: credits manual type.
---
src/lib/sdk/billing.ts | 55 +------------------
.../billing/availableCredit.svelte | 15 ++---
2 files changed, 11 insertions(+), 59 deletions(-)
diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts
index 2cf540d92e..d195898758 100644
--- a/src/lib/sdk/billing.ts
+++ b/src/lib/sdk/billing.ts
@@ -102,55 +102,6 @@ export type Coupon = {
onlyNewOrgs?: boolean;
};
-export type Credit = {
- /**
- * Credit ID.
- */
- $id: string;
- /**
- * Credit creation time in ISO 8601 format.
- */
- $createdAt: string;
- /**
- * Credit update date in ISO 8601 format.
- */
- $updatedAt: string;
- /**
- * coupon ID
- */
- couponId: string;
- /**
- * ID of the User.
- */
- userId: string;
- /**
- * ID of the Team.
- */
- teamId: string;
- /**
- * Provided credit amount
- */
- total: number;
- /**
- * Remaining credit amount
- */
- credits: number;
- /**
- * Credit expiration time in ISO 8601 format.
- */
- expiration: string;
- /**
- * Status of the credit. Can be one of `disabled`, `active` or `expired`.
- */
- status: string;
-};
-
-export type CreditList = {
- available: number;
- credits: Credit[];
- total: number;
-};
-
export type AggregationTeam = {
$id: string;
/**
@@ -880,7 +831,7 @@ export class Billing {
);
}
- async addCredit(organizationId: string, couponId: string): Promise {
+ async addCredit(organizationId: string, couponId: string): Promise {
const path = `/organizations/${organizationId}/credits`;
const params = {
couponId
@@ -895,7 +846,7 @@ export class Billing {
params
);
}
- async listCredits(organizationId: string, queries = []): Promise {
+ async listCredits(organizationId: string, queries = []): Promise {
const path = `/organizations/${organizationId}/credits`;
const params = {
queries
@@ -925,7 +876,7 @@ export class Billing {
);
}
- async getCredit(organizationId: string, creditId: string): Promise {
+ async getCredit(organizationId: string, creditId: string): Promise {
const path = `/organizations/${organizationId}/credits/${creditId}`;
const params = {
creditId
diff --git a/src/routes/(console)/organization-[organization]/billing/availableCredit.svelte b/src/routes/(console)/organization-[organization]/billing/availableCredit.svelte
index 52bc768599..0744f5e653 100644
--- a/src/routes/(console)/organization-[organization]/billing/availableCredit.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/availableCredit.svelte
@@ -1,11 +1,10 @@
diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts
index d195898758..c52e2ed18a 100644
--- a/src/lib/sdk/billing.ts
+++ b/src/lib/sdk/billing.ts
@@ -4,31 +4,6 @@ import type { Client, Models } from '@appwrite.io/console';
import type { PaymentMethod } from '@stripe/stripe-js';
import type { Organization, OrganizationError, OrganizationList } from '../stores/organization';
-export type PaymentMethodData = {
- $id: string;
- $createdAt: string;
- $updatedAt: string;
- providerMethodId: string;
- providerUserId: string;
- userId: string;
- expiryMonth: number;
- expiryYear: number;
- expired: boolean;
- last4: string;
- country: string;
- brand: string;
- clientSecret: string;
- failed: boolean;
- name: string;
- mandateId?: string;
- lastError?: string;
-};
-
-export type PaymentList = {
- paymentMethods: PaymentMethodData[];
- total: number;
-};
-
export type Invoice = {
$id: string;
$createdAt: Date;
@@ -1002,7 +977,7 @@ export class Billing {
async getOrganizationPaymentMethod(
organizationId: string,
paymentMethodId: string
- ): Promise {
+ ): Promise {
const path = `/organizations/${organizationId}/payment-methods/${paymentMethodId}`;
const params = {
organizationId,
@@ -1041,7 +1016,7 @@ export class Billing {
//ACCOUNT
- async listPaymentMethods(queries: [] = []): Promise {
+ async listPaymentMethods(queries: [] = []): Promise {
const path = `/account/payment-methods`;
const params = {
queries
@@ -1057,7 +1032,7 @@ export class Billing {
);
}
- async getPaymentMethod(paymentMethodId: string): Promise {
+ async getPaymentMethod(paymentMethodId: string): Promise {
const path = `/account/payment-methods/${paymentMethodId}`;
const params = {
paymentMethodId
@@ -1073,7 +1048,7 @@ export class Billing {
);
}
- async createPaymentMethod(): Promise {
+ async createPaymentMethod(): Promise {
const path = `/account/payment-methods`;
const params = {};
const uri = new URL(this.client.config.endpoint + path);
@@ -1092,7 +1067,7 @@ export class Billing {
providerMethodId: string | PaymentMethod,
name: string,
state: string | undefined = undefined
- ): Promise {
+ ): Promise {
const path = `/account/payment-methods/${paymentMethodId}/provider`;
const params = {
paymentMethodId,
@@ -1118,7 +1093,7 @@ export class Billing {
paymentMethodId: string,
expiryMonth: string,
expiryYear: string
- ): Promise {
+ ): Promise {
const path = `/account/payment-methods/${paymentMethodId}`;
const params = {
paymentMethodId,
@@ -1136,7 +1111,7 @@ export class Billing {
);
}
- async deletePaymentMethod(paymentMethodId: string): Promise {
+ async deletePaymentMethod(paymentMethodId: string): Promise {
const path = `/account/payment-methods/${paymentMethodId}`;
const params = {
paymentMethodId
@@ -1151,7 +1126,7 @@ export class Billing {
params
);
}
- async setDefaultPaymentMethod(paymentMethodId: string): Promise {
+ async setDefaultPaymentMethod(paymentMethodId: string): Promise {
const path = `/account/payment-methods/${paymentMethodId}/default`;
const params = {
paymentMethodId
@@ -1170,7 +1145,7 @@ export class Billing {
async setupPaymentMandate(
organizationId: string,
paymentMethodId: string
- ): Promise {
+ ): Promise {
const path = `/account/payment-methods/${paymentMethodId}/setup`;
const params = {
organizationId,
diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts
index 5c7305125f..60746241d8 100644
--- a/src/lib/stores/billing.ts
+++ b/src/lib/stores/billing.ts
@@ -17,8 +17,6 @@ import type {
AggregationTeam,
Invoice,
InvoiceList,
- PaymentList,
- PaymentMethodData,
BillingPlansMap
} from '$lib/sdk/billing';
import { isCloud } from '$lib/system';
@@ -69,7 +67,10 @@ export const roles = [
export const teamStatusReadonly = 'readonly';
export const billingLimitOutstandingInvoice = 'outstanding_invoice';
-export const paymentMethods = derived(page, ($page) => $page.data.paymentMethods as PaymentList);
+export const paymentMethods = derived(
+ page,
+ ($page) => $page.data.paymentMethods as Models.PaymentMethodList
+);
export const addressList = derived(page, ($page) => $page.data.addressList as AddressesList);
export const plansInfo = derived(page, ($page) => $page.data.plansInfo as BillingPlansMap);
export const daysLeftInTrial = writable(0);
@@ -538,7 +539,7 @@ export function checkForMarkedForDeletion(org: Organization) {
}
}
-export const paymentMissingMandate = writable(null);
+export const paymentMissingMandate = writable(null);
export async function checkForMandate(org: Organization) {
const paymentId = org.paymentMethodId ?? org.backupPaymentMethodId;
diff --git a/src/lib/stores/stripe.ts b/src/lib/stores/stripe.ts
index 9f4bc727bc..cda0bf776c 100644
--- a/src/lib/stores/stripe.ts
+++ b/src/lib/stores/stripe.ts
@@ -1,6 +1,6 @@
import type {
Appearance,
- PaymentMethod,
+ PaymentMethod as StripePaymentMethod,
Stripe,
StripeElement,
StripeElements
@@ -8,21 +8,21 @@ import type {
import { sdk } from './sdk';
import { app } from './app';
import { get, writable } from 'svelte/store';
-import type { PaymentMethodData } from '$lib/sdk/billing';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { addNotification } from './notifications';
import { organization } from './organization';
import { base } from '$app/paths';
import { ThemeDarkCloud, ThemeLightCloud } from '$themes';
import Color from 'color';
+import type { Models } from '@appwrite.io/console';
export const stripe = writable();
-let paymentMethod: PaymentMethodData;
+export const isStripeInitialized = writable(false);
+
let clientSecret: string;
let elements: StripeElements;
let paymentElement: StripeElement;
-
-export const isStripeInitialized = writable(false);
+let paymentMethod: Models.PaymentMethod;
export async function initializeStripe(node: HTMLElement) {
if (!get(stripe)) return;
@@ -116,12 +116,12 @@ export async function submitStripeCard(name: string, organizationId?: string) {
}
if (setupIntent && setupIntent.status === 'succeeded') {
- const pm = setupIntent.payment_method as PaymentMethod | string | undefined;
+ const pm = setupIntent.payment_method as StripePaymentMethod | string | undefined;
// If Stripe returned an expanded PaymentMethod object, check the card country.
// If it returned a string id (common), `typeof pm === 'string'` and we skip this.
if (typeof pm !== 'string' && pm?.card?.country === 'US') {
// need to get state
- return pm as PaymentMethod;
+ return pm as StripePaymentMethod;
}
// The backend expects a provider method ID (string). Extract the id
@@ -130,7 +130,7 @@ export async function submitStripeCard(name: string, organizationId?: string) {
if (typeof pm === 'string') {
providerId = pm;
} else {
- providerId = (pm as PaymentMethod)?.id;
+ providerId = (pm as StripePaymentMethod)?.id;
}
if (!providerId) {
diff --git a/src/routes/(console)/account/payments/editPaymentModal.svelte b/src/routes/(console)/account/payments/editPaymentModal.svelte
index 7850cdea9a..5b1145f686 100644
--- a/src/routes/(console)/account/payments/editPaymentModal.svelte
+++ b/src/routes/(console)/account/payments/editPaymentModal.svelte
@@ -5,12 +5,12 @@
import { Dependencies } from '$lib/constants';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
- import type { PaymentMethodData } from '$lib/sdk/billing';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { Alert } from '@appwrite.io/pink-svelte';
+ import type { Models } from '@appwrite.io/console';
export let show = false;
- export let selectedPaymentMethod: PaymentMethodData;
+ export let selectedPaymentMethod: Models.PaymentMethod;
export let isLinked = false;
const currentYear = new Date().getFullYear();
let error: string;
diff --git a/src/routes/(console)/account/payments/paymentMethods.svelte b/src/routes/(console)/account/payments/paymentMethods.svelte
index 8e53a8d3da..53d3b270a5 100644
--- a/src/routes/(console)/account/payments/paymentMethods.svelte
+++ b/src/routes/(console)/account/payments/paymentMethods.svelte
@@ -2,7 +2,6 @@
import { CardGrid, CreditCardInfo, Empty } from '$lib/components';
import { Button } from '$lib/elements/forms';
import { paymentMethods } from '$lib/stores/billing';
- import type { PaymentMethodData } from '$lib/sdk/billing';
import { organizationList, type Organization } from '$lib/stores/organization';
import { base } from '$app/paths';
import EditPaymentModal from './editPaymentModal.svelte';
@@ -26,10 +25,11 @@
Tag,
Typography
} from '@appwrite.io/pink-svelte';
+ import type { Models } from '@appwrite.io/console';
export let showPayment = false;
let showDropdown = [];
- let selectedMethod: PaymentMethodData;
+ let selectedMethod: Models.PaymentMethod;
let selectedLinkedOrgs: Organization[] = [];
let showDelete = false;
let showEdit = false;
@@ -37,9 +37,7 @@
$: orgList = $organizationList.teams as unknown as Organization[];
- $: filteredMethods = $paymentMethods?.paymentMethods.filter(
- (method: PaymentMethodData) => !!method?.last4
- );
+ $: filteredMethods = $paymentMethods?.paymentMethods.filter((method) => !!method?.last4);
const isMethodLinkedToOrg = (methodId: string, org: Organization) =>
methodId === org.paymentMethodId || methodId === org.backupPaymentMethodId;
diff --git a/src/routes/(console)/apply-credit/+page.svelte b/src/routes/(console)/apply-credit/+page.svelte
index b7226b3e77..29b8c85df7 100644
--- a/src/routes/(console)/apply-credit/+page.svelte
+++ b/src/routes/(console)/apply-credit/+page.svelte
@@ -8,7 +8,6 @@
import { Button, Form, InputSelect, InputTags, InputText } from '$lib/elements/forms';
import { toLocaleDate } from '$lib/helpers/date';
import { Wizard } from '$lib/layout';
- import type { PaymentList } from '$lib/sdk/billing';
import { addNotification } from '$lib/stores/notifications';
import {
organizationList,
@@ -48,7 +47,7 @@
let formComponent: Form;
let couponForm: Form;
let isSubmitting = writable(false);
- let methods: PaymentList;
+ let methods: Models.PaymentMethodList;
let paymentMethodId: string;
let collaborators: string[];
let taxId: string;
diff --git a/src/routes/(console)/organization-[organization]/billing/+page.svelte b/src/routes/(console)/organization-[organization]/billing/+page.svelte
index 99729b8e9a..271912fd04 100644
--- a/src/routes/(console)/organization-[organization]/billing/+page.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/+page.svelte
@@ -9,7 +9,6 @@
import PaymentHistory from './paymentHistory.svelte';
import TaxId from './taxId.svelte';
import { failedInvoice, tierToPlan, upgradeURL, useNewPricingModal } from '$lib/stores/billing';
- import type { PaymentMethodData } from '$lib/sdk/billing';
import { onMount } from 'svelte';
import { page } from '$app/state';
import { confirmPayment } from '$lib/stores/stripe';
@@ -31,11 +30,11 @@
// why are these reactive?
$: defaultPaymentMethod = data?.paymentMethods?.paymentMethods?.find(
- (method: PaymentMethodData) => method.$id === organization?.paymentMethodId
+ (method) => method.$id === organization?.paymentMethodId
);
$: backupPaymentMethod = data?.paymentMethods?.paymentMethods?.find(
- (method: PaymentMethodData) => method.$id === organization?.backupPaymentMethodId
+ (method) => method.$id === organization?.backupPaymentMethodId
);
onMount(async () => {
diff --git a/src/routes/(console)/organization-[organization]/billing/paymentMethods.svelte b/src/routes/(console)/organization-[organization]/billing/paymentMethods.svelte
index 124518f1e3..6f45b4b94c 100644
--- a/src/routes/(console)/organization-[organization]/billing/paymentMethods.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/paymentMethods.svelte
@@ -8,7 +8,6 @@
import { type Organization } from '$lib/stores/organization';
import { Button } from '$lib/elements/forms';
import { hasStripePublicKey, isCloud } from '$lib/system';
- import type { PaymentList, PaymentMethodData } from '$lib/sdk/billing';
import DeleteOrgPayment from './deleteOrgPayment.svelte';
import ReplaceCard from './replaceCard.svelte';
import EditPaymentModal from '$routes/(console)/account/payments/editPaymentModal.svelte';
@@ -33,17 +32,18 @@
IconSwitchHorizontal,
IconTrash
} from '@appwrite.io/pink-icons-svelte';
+ import type { Models } from '@appwrite.io/console';
export let organization: Organization;
- export let methods: PaymentList;
+ export let methods: Models.PaymentMethodList;
- let showPayment = false;
let showEdit = false;
let showDelete = false;
+ let showPayment = false;
let showReplace = false;
let isSelectedBackup = false;
- let backupPaymentMethod: PaymentMethodData;
- let defaultPaymentMethod: PaymentMethodData;
+ let backupPaymentMethod: Models.PaymentMethod;
+ let defaultPaymentMethod: Models.PaymentMethod;
async function addPaymentMethod(paymentMethodId: string) {
try {
diff --git a/src/routes/(console)/organization-[organization]/billing/replaceCard.svelte b/src/routes/(console)/organization-[organization]/billing/replaceCard.svelte
index ea4cc7d267..05551918fb 100644
--- a/src/routes/(console)/organization-[organization]/billing/replaceCard.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/replaceCard.svelte
@@ -7,23 +7,23 @@
import { Dependencies } from '$lib/constants';
import { setPaymentMethod, submitStripeCard } from '$lib/stores/stripe';
import { onMount } from 'svelte';
- import type { PaymentList, PaymentMethodData } from '$lib/sdk/billing';
import { addNotification } from '$lib/stores/notifications';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { PaymentBoxes } from '$lib/components/billing';
- import type { PaymentMethod } from '@stripe/stripe-js';
+ import type { PaymentMethod as StripePaymentMethod } from '@stripe/stripe-js';
+ import type { Models } from '@appwrite.io/console';
export let organization: Organization;
export let show = false;
export let isBackup = false;
- export let methods: PaymentList;
+ export let methods: Models.PaymentMethodList;
let name: string;
let error: string = null;
let selectedPaymentMethodId: string;
let showState: boolean = false;
let state: string = '';
- let paymentMethod: PaymentMethod | null = null;
+ let paymentMethod: StripePaymentMethod | null = null;
onMount(async () => {
if (!organization.paymentMethodId && !organization.backupPaymentMethodId) {
@@ -48,19 +48,19 @@
if (showState && !state) {
throw Error('Please select a state');
}
- let method: PaymentMethodData;
+ let method: Models.PaymentMethod;
if (showState) {
method = await setPaymentMethod(paymentMethod.id, name, state);
} else {
const card = await submitStripeCard(name, organization.$id);
if (card && Object.hasOwn(card, 'id')) {
- if ((card as PaymentMethod).card?.country === 'US') {
- paymentMethod = card as PaymentMethod;
+ if ((card as StripePaymentMethod).card?.country === 'US') {
+ paymentMethod = card as StripePaymentMethod;
showState = true;
return;
}
} else if (card && Object.hasOwn(card, '$id')) {
- method = card as PaymentMethodData;
+ method = card as Models.PaymentMethod;
}
}
selectedPaymentMethodId = method.$id;
diff --git a/src/routes/(console)/organization-[organization]/billing/retryPaymentModal.svelte b/src/routes/(console)/organization-[organization]/billing/retryPaymentModal.svelte
index 65e217d2c6..ab7384d568 100644
--- a/src/routes/(console)/organization-[organization]/billing/retryPaymentModal.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/retryPaymentModal.svelte
@@ -3,7 +3,7 @@
import { FakeModal } from '$lib/components';
import { Button } from '$lib/elements/forms';
import { Dependencies } from '$lib/constants';
- import type { Invoice, PaymentMethodData } from '$lib/sdk/billing';
+ import type { Invoice } from '$lib/sdk/billing';
import { addNotification } from '$lib/stores/notifications';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { page } from '$app/state';
@@ -21,18 +21,21 @@
import { getApiEndpoint, sdk } from '$lib/stores/sdk';
import { formatCurrency } from '$lib/helpers/numbers';
import { base } from '$app/paths';
- import type { PaymentMethod } from '@stripe/stripe-js';
+ import type { PaymentMethod as StripePaymentMethod } from '@stripe/stripe-js';
+ import type { Models } from '@appwrite.io/console';
export let show = false;
export let invoice: Invoice;
+
+ let name: string;
+ let state: string = '';
let error: string = null;
+ let setAsDefault = false;
let isButtonDisabled = false;
- let name: string;
let paymentMethodId: string;
- let setAsDefault = false;
let showState: boolean = false;
- let state: string = '';
- let paymentMethod: PaymentMethod | null = null;
+ let paymentMethod: StripePaymentMethod | null = null;
+
const endpoint = getApiEndpoint();
onMount(async () => {
@@ -60,15 +63,15 @@
if (showState && !state) {
throw Error('Please select a state');
}
- let method: PaymentMethodData;
+ let method: Models.PaymentMethod;
if (showState) {
method = await setPaymentMethod(paymentMethod.id, name, state);
} else {
const card = await submitStripeCard(name, $organization.$id);
// When Stripe returns an expanded PaymentMethod for US cards, we need state.
- if (Object.hasOwn(card, 'id') && (card as PaymentMethod)?.card) {
- if ((card as PaymentMethod).card?.country === 'US') {
- paymentMethod = card as PaymentMethod;
+ if (Object.hasOwn(card, 'id') && (card as StripePaymentMethod)?.card) {
+ if ((card as StripePaymentMethod).card?.country === 'US') {
+ paymentMethod = card as StripePaymentMethod;
showState = true;
return;
}
@@ -76,7 +79,7 @@
// Otherwise, we expect an Appwrite PaymentMethodData with `$id`.
if (Object.hasOwn(card, '$id')) {
- method = card as PaymentMethodData;
+ method = card as Models.PaymentMethod;
}
}
const card = await sdk.forConsole.billing.getPaymentMethod(method.$id);
diff --git a/src/routes/(console)/organization-[organization]/billing/wizard/paymentDetails.svelte b/src/routes/(console)/organization-[organization]/billing/wizard/paymentDetails.svelte
index fd27def7e0..7ee8a49b65 100644
--- a/src/routes/(console)/organization-[organization]/billing/wizard/paymentDetails.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/wizard/paymentDetails.svelte
@@ -1,7 +1,6 @@
{#if estimation}
diff --git a/src/routes/(console)/organization-[organization]/settings/deleteOrganizationModal.svelte b/src/routes/(console)/organization-[organization]/settings/deleteOrganizationModal.svelte
index dab95d83a3..25a97956de 100644
--- a/src/routes/(console)/organization-[organization]/settings/deleteOrganizationModal.svelte
+++ b/src/routes/(console)/organization-[organization]/settings/deleteOrganizationModal.svelte
@@ -15,15 +15,15 @@
import { tierToPlan } from '$lib/stores/billing';
import { Table, Tabs, Alert } from '@appwrite.io/pink-svelte';
import DeleteOrganizationEstimation from './deleteOrganizationEstimation.svelte';
- import type { EstimationDeleteOrganization, InvoiceList } from '$lib/sdk/billing';
+ import type { Models } from '@appwrite.io/console';
export let showDelete = false;
- export let invoices: InvoiceList;
- let error: string = null;
+ export let invoices: Models.InvoiceList;
+ let error: string = null;
let selectedTab = 'projects';
let organizationName: string = null;
- let estimation: EstimationDeleteOrganization;
+ let estimation: Models.EstimationDeleteOrganization;
async function deleteOrg() {
try {
@@ -112,7 +112,8 @@
This action is irreversible .
{/if}
- {#if estimation && (estimation.unpaidInvoices.length > 0 || estimation.grossAmount > 0)}
+
+ {#if estimation && (estimation.unpaidInvoices.length > 0 || estimation.unpaidInvoices.some((invoice) => invoice.grossAmount > 0))}
{:else}
{#if $projects.total > 0}
diff --git a/src/routes/(console)/organization-[organization]/settings/invoicesTable.svelte b/src/routes/(console)/organization-[organization]/settings/invoicesTable.svelte
index 84b7ca6093..514e8a575a 100644
--- a/src/routes/(console)/organization-[organization]/settings/invoicesTable.svelte
+++ b/src/routes/(console)/organization-[organization]/settings/invoicesTable.svelte
@@ -1,5 +1,4 @@
{#if $organization?.$id && $organization?.billingPlan === BillingPlan.FREE && $readOnly && !hideBillingHeaderRoutes.includes(page.url.pathname)}
+ title={`${$organization.name} usage has reached the ${billingIdToPlan($organization.billingPlan).name} plan limit`}>
- Usage for the {$organization.name} organization has reached the limits of the {tierToPlan(
+ Usage for the {$organization.name} organization has reached the limits of the {billingIdToPlan(
$organization.billingPlan
).name}
plan. Consider upgrading to increase your resource usage.
diff --git a/src/lib/components/billing/emptyCardCloud.svelte b/src/lib/components/billing/emptyCardCloud.svelte
index b83676f28d..0ca7071967 100644
--- a/src/lib/components/billing/emptyCardCloud.svelte
+++ b/src/lib/components/billing/emptyCardCloud.svelte
@@ -1,21 +1,33 @@
-
+ {#if children}
+ {@render children()}
+ {:else}
Upgrade to add {service}
- Upgrade to a {tierToPlan(BillingPlan.PRO).name} plan to add {service} to your organization
+ Upgrade to a {proPlanName} plan to add {service} to your organization
-
+ {/if}
diff --git a/src/lib/components/billing/estimatedTotalBox.svelte b/src/lib/components/billing/estimatedTotalBox.svelte
index dd78788903..b03ab42cc5 100644
--- a/src/lib/components/billing/estimatedTotalBox.svelte
+++ b/src/lib/components/billing/estimatedTotalBox.svelte
@@ -2,14 +2,13 @@
import { InputChoice, InputNumber } from '$lib/elements/forms';
import { formatCurrency } from '$lib/helpers/numbers';
import type { Coupon, Estimation } from '$lib/sdk/billing';
- import { type Tier } from '$lib/stores/billing';
import { Card, Divider, Layout, Typography } from '@appwrite.io/pink-svelte';
import { CreditsApplied } from '.';
import { sdk } from '$lib/stores/sdk';
import { AppwriteException } from '@appwrite.io/console';
import DiscountsApplied from './discountsApplied.svelte';
- export let billingPlan: Tier;
+ export let billingPlan: string;
export let collaborators: string[];
export let couponData: Partial;
export let billingBudget: number;
diff --git a/src/lib/components/billing/planComparisonBox.svelte b/src/lib/components/billing/planComparisonBox.svelte
index 4379cc6f88..80ae87f25e 100644
--- a/src/lib/components/billing/planComparisonBox.svelte
+++ b/src/lib/components/billing/planComparisonBox.svelte
@@ -1,103 +1,131 @@
- {#each visibleTiers as tier}
+ {#each uniquePlans as plan}
(selectedTab = tier)}>
- {tierToPlan(tier).name}
+ active={selectedTab === plan.$id}
+ on:click={() => (selectedTab = plan.$id)}>
+ {plan.name}
{/each}
- {plan.name} plan
- {#if selectedTab === BillingPlan.FREE}
- {#if downgrade}
-
-
-
-
- Limited to {plan.databases} Database, {plan.buckets} Buckets, {plan.functions}
- Functions per project
-
-
-
-
- Limited to 1 organization member
-
-
-
-
- {plan.bandwidth}GB bandwidth
-
-
-
-
-
- {plan.storage}GB storage
-
-
-
-
-
- {formatNum(plan.executions)} executions
-
-
-
- {:else}
-
-
- Limited to {plan.databases} Database, {plan.buckets} Buckets, {plan.functions}
- Functions per project
-
- Limited to 1 organization member
-
- Limited to {plan.bandwidth}GB bandwidth
-
-
- Limited to {plan.storage}GB storage
-
-
- Limited to {formatNum(plan.executions)} executions
-
-
- {/if}
- {:else if selectedTab === BillingPlan.PRO}
- Everything in the Free plan, plus:
-
- Unlimited databases, buckets, functions
- Unlimited seats
- {plan.bandwidth}GB bandwidth
- {plan.storage}GB storage
- {formatNum(plan.executions)} executions
- Email support
+ {currentPlan.name} plan
+
+ {@render appwritePlanView()}
+
+
+
+{#snippet appwritePlanView()}
+ {#if planHasGroup(selectedTab, BillingPlanGroup.Starter)}
+ {#if downgrade}
+
+
+
+
+ Limited to {currentPlan.databases}
+ {pluralize(currentPlan.databases, 'Database')}, {currentPlan.buckets}
+ {pluralize(currentPlan.buckets, 'Bucket')}, {currentPlan.functions}
+ {pluralize(currentPlan.functions, 'Function')} per project
+
+
+
+
+ Limited to 1 organization member
+
+
+
+
+ {currentPlan.bandwidth}GB bandwidth
+
+
+
+
+
+ {currentPlan.storage}GB storage
+
+
+
+
+
+ {formatNum(currentPlan.executions)} executions
+
+
- {:else if selectedTab === BillingPlan.SCALE}
- Everything in the Pro plan, plus:
+ {:else}
- Unlimited seats
- Organization roles
- SOC-2, HIPAA compliance
- SSO Coming soon
- Priority support
+
+ Limited to {currentPlan.databases}
+ {pluralize(currentPlan.databases, 'Database')}, {currentPlan.buckets}
+ {pluralize(currentPlan.buckets, 'Bucket')}, {currentPlan.functions}
+ {pluralize(currentPlan.functions, 'Function')} per project
+
+ Limited to 1 organization member
+
+ Limited to {currentPlan.bandwidth}GB bandwidth
+
+
+ Limited to {currentPlan.storage}GB storage
+
+
+ Limited to {formatNum(currentPlan.executions)} executions
+
{/if}
-
-
+ {:else if planHasGroup(selectedTab, BillingPlanGroup.Pro)}
+ Everything in the Free plan, plus:
+
+ Unlimited databases, buckets, functions
+ Unlimited seats
+ {currentPlan.bandwidth}GB bandwidth
+ {currentPlan.storage}GB storage
+ {formatNum(currentPlan.executions)} executions
+ Email support
+
+ {:else if planHasGroup(selectedTab, BillingPlanGroup.Scale)}
+ Everything in the Pro plan, plus:
+
+ Unlimited seats
+ Organization roles
+ SOC-2, HIPAA compliance
+ SSO Coming soon
+ Priority support
+
+ {/if}
+{/snippet}
diff --git a/src/lib/components/billing/planExcess.svelte b/src/lib/components/billing/planExcess.svelte
deleted file mode 100644
index 7bdf28e3f8..0000000000
--- a/src/lib/components/billing/planExcess.svelte
+++ /dev/null
@@ -1,131 +0,0 @@
-
-
-{#if showExcess}
-
- You will retain access to {tierToPlan($organization.billingPlan).name} plan features until your
- billing period ends. After that,
- {#if excess?.members > 0}
- all team members except the owner will be removed,
- {:else}
- your organization will be limited to Free plan resources,
- {/if} and service disruptions may occur if usage exceeds Free plan limits.
-
-
-
-
- Resource
- Free limit
-
- Excess usage
- Metrics are estimates updated every 24 hours
-
-
-
- {#if excess?.members}
-
- Organization members
- {getServiceLimit('members', tier)} members
-
-
-
- {excess?.members} members
-
-
-
- {/if}
- {#if excess?.storage}
-
- Storage
- {plan.storage} GB
-
-
-
- {humanFileSize(excess?.storage).value}
- {humanFileSize(excess?.storage).unit}
-
-
-
- {/if}
- {#if excess?.executions}
-
- Function executions
-
- {abbreviateNumber(plan.executions)} executions
-
-
-
-
-
- {formatNum(excess?.executions)} executions
-
-
-
-
- {/if}
- {#if excess?.users}
-
- Users
-
- {abbreviateNumber(plan.users)} users
-
-
-
-
-
- {formatNum(excess?.users)} users
-
-
-
-
- {/if}
-
-{/if}
diff --git a/src/lib/components/emptyCardImageCloud.svelte b/src/lib/components/emptyCardImageCloud.svelte
index 0f4c234504..870edc4889 100644
--- a/src/lib/components/emptyCardImageCloud.svelte
+++ b/src/lib/components/emptyCardImageCloud.svelte
@@ -1,8 +1,8 @@
@@ -24,7 +26,7 @@
-
+
diff --git a/src/lib/layout/containerButton.svelte b/src/lib/layout/containerButton.svelte
index 53cfc35bf1..de3f0024cf 100644
--- a/src/lib/layout/containerButton.svelte
+++ b/src/lib/layout/containerButton.svelte
@@ -1,7 +1,7 @@
From ce1c0889952de1e1fdbd22c0e721d10528aa164b Mon Sep 17 00:00:00 2001
From: Darshan
Date: Thu, 18 Dec 2025 16:11:39 +0530
Subject: [PATCH 06/27] remove: `Estimation` type!
---
.../billing/estimatedTotalBox.svelte | 6 +++---
src/lib/sdk/billing.ts | 21 ++-----------------
2 files changed, 5 insertions(+), 22 deletions(-)
diff --git a/src/lib/components/billing/estimatedTotalBox.svelte b/src/lib/components/billing/estimatedTotalBox.svelte
index b03ab42cc5..aa38bc8669 100644
--- a/src/lib/components/billing/estimatedTotalBox.svelte
+++ b/src/lib/components/billing/estimatedTotalBox.svelte
@@ -1,11 +1,11 @@
diff --git a/src/routes/(console)/account/payments/deleteAddressModal.svelte b/src/routes/(console)/account/payments/deleteAddressModal.svelte
index ee6a810fb2..e90c240607 100644
--- a/src/routes/(console)/account/payments/deleteAddressModal.svelte
+++ b/src/routes/(console)/account/payments/deleteAddressModal.svelte
@@ -5,13 +5,12 @@
import Confirm from '$lib/components/confirm.svelte';
import { Dependencies } from '$lib/constants';
import { addNotification } from '$lib/stores/notifications';
- import type { Organization } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
import { Layout, Link } from '@appwrite.io/pink-svelte';
import type { Models } from '@appwrite.io/console';
export let showDelete = false;
- export let linkedOrgs: Organization[] = [];
+ export let linkedOrgs: Array = [];
export let selectedAddress: Models.BillingAddress;
let error: string = null;
diff --git a/src/routes/(console)/account/payments/deletePaymentModal.svelte b/src/routes/(console)/account/payments/deletePaymentModal.svelte
index 50406a32f5..d5e8e01f22 100644
--- a/src/routes/(console)/account/payments/deletePaymentModal.svelte
+++ b/src/routes/(console)/account/payments/deletePaymentModal.svelte
@@ -5,13 +5,13 @@
import Confirm from '$lib/components/confirm.svelte';
import { Dependencies } from '$lib/constants';
import { addNotification } from '$lib/stores/notifications';
- import type { Organization } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
import { Layout, Link, Typography } from '@appwrite.io/pink-svelte';
+ import type { Models } from '@appwrite.io/console';
- export let linkedOrgs: Organization[] = [];
- export let showDelete = false;
export let method: string;
+ export let showDelete = false;
+ export let linkedOrgs: Array = [];
let error: string;
diff --git a/src/routes/(console)/account/payments/paymentMethods.svelte b/src/routes/(console)/account/payments/paymentMethods.svelte
index 53d3b270a5..05f866bfb6 100644
--- a/src/routes/(console)/account/payments/paymentMethods.svelte
+++ b/src/routes/(console)/account/payments/paymentMethods.svelte
@@ -2,7 +2,7 @@
import { CardGrid, CreditCardInfo, Empty } from '$lib/components';
import { Button } from '$lib/elements/forms';
import { paymentMethods } from '$lib/stores/billing';
- import { organizationList, type Organization } from '$lib/stores/organization';
+ import { organizationList } from '$lib/stores/organization';
import { base } from '$app/paths';
import EditPaymentModal from './editPaymentModal.svelte';
import DeletePaymentModal from './deletePaymentModal.svelte';
@@ -30,16 +30,16 @@
export let showPayment = false;
let showDropdown = [];
let selectedMethod: Models.PaymentMethod;
- let selectedLinkedOrgs: Organization[] = [];
+ let selectedLinkedOrgs: Array = [];
let showDelete = false;
let showEdit = false;
let isLinked = false;
- $: orgList = $organizationList.teams as unknown as Organization[];
+ $: orgList = $organizationList.teams as unknown as Array;
$: filteredMethods = $paymentMethods?.paymentMethods.filter((method) => !!method?.last4);
- const isMethodLinkedToOrg = (methodId: string, org: Organization) =>
+ const isMethodLinkedToOrg = (methodId: string, org: Models.Organization) =>
methodId === org.paymentMethodId || methodId === org.backupPaymentMethodId;
$: linkedMethodIds = new Set(
diff --git a/src/routes/(console)/apply-credit/+page.svelte b/src/routes/(console)/apply-credit/+page.svelte
index 314e804201..c11e41b75e 100644
--- a/src/routes/(console)/apply-credit/+page.svelte
+++ b/src/routes/(console)/apply-credit/+page.svelte
@@ -9,11 +9,7 @@
import { toLocaleDate } from '$lib/helpers/date';
import { Wizard } from '$lib/layout';
import { addNotification } from '$lib/stores/notifications';
- import {
- type Organization,
- type OrganizationError,
- organizationList
- } from '$lib/stores/organization';
+ import { type OrganizationError, organizationList } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
import { confirmPayment } from '$lib/stores/stripe.js';
import { BillingPlanGroup, ID, type Models } from '@appwrite.io/console';
@@ -127,7 +123,7 @@
if (couponForm && !couponForm.checkValidity()) return;
isSubmitting.set(true);
try {
- let org: Organization | OrganizationError;
+ let org: Models.Organization | OrganizationError;
// Create new org
if (selectedOrgId === newOrgId) {
org = await sdk.forConsole.billing.createOrganization(
@@ -223,7 +219,7 @@
$: selectedOrg = $organizationList?.teams?.find(
(team) => team.$id === selectedOrgId
- ) as Organization;
+ ) as Models.Organization;
function getBillingPlan(): string | undefined {
const campaignPlan =
diff --git a/src/routes/(console)/create-organization/+page.svelte b/src/routes/(console)/create-organization/+page.svelte
index d6d54b141c..3056c4bd82 100644
--- a/src/routes/(console)/create-organization/+page.svelte
+++ b/src/routes/(console)/create-organization/+page.svelte
@@ -10,7 +10,7 @@
import { Wizard } from '$lib/layout';
import { isOrganization, billingIdToPlan } from '$lib/stores/billing';
import { addNotification } from '$lib/stores/notifications';
- import type { OrganizationError, Organization } from '$lib/stores/organization';
+ import type { OrganizationError } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
import { confirmPayment } from '$lib/stores/stripe';
import { ID, type Models } from '@appwrite.io/console';
@@ -104,7 +104,7 @@
async function create() {
try {
- let org: Organization | OrganizationError;
+ let org: Models.Organization | OrganizationError;
if (selectedPlan === BillingPlan.FREE) {
org = await sdk.forConsole.billing.createOrganization(
diff --git a/src/routes/(console)/create-organization/+page.ts b/src/routes/(console)/create-organization/+page.ts
index fe94df98c5..4dc0c4927c 100644
--- a/src/routes/(console)/create-organization/+page.ts
+++ b/src/routes/(console)/create-organization/+page.ts
@@ -1,7 +1,6 @@
import { sdk } from '$lib/stores/sdk';
import type { PageLoad } from './$types';
import type { Models } from '@appwrite.io/console';
-import type { Organization } from '$lib/stores/organization';
import { BillingPlan, Dependencies } from '$lib/constants';
export const load: PageLoad = async ({ url, parent, depends }) => {
@@ -14,7 +13,7 @@ export const load: PageLoad = async ({ url, parent, depends }) => {
]);
let plan = getPlanFromUrl(url);
const hasFreeOrganizations = organizations.teams?.some(
- (org) => (org as Organization)?.billingPlan === BillingPlan.FREE
+ (org) => (org as Models.Organization)?.billingPlan === BillingPlan.FREE
);
if (plan === BillingPlan.FREE && hasFreeOrganizations) {
diff --git a/src/routes/(console)/organization-[organization]/+layout.ts b/src/routes/(console)/organization-[organization]/+layout.ts
index 39893dbd45..f8e3d13888 100644
--- a/src/routes/(console)/organization-[organization]/+layout.ts
+++ b/src/routes/(console)/organization-[organization]/+layout.ts
@@ -12,7 +12,6 @@ import { get } from 'svelte/store';
import { preferences } from '$lib/stores/preferences';
import { defaultRoles, defaultScopes } from '$lib/constants';
import { loadAvailableRegions } from '$routes/(console)/regions';
-import type { Organization } from '$lib/stores/organization';
import { type Models, Platform } from '@appwrite.io/console';
import { resolve } from '$app/paths';
@@ -46,9 +45,11 @@ export const load: LayoutLoad = async ({ params, depends, parent }) => {
}
// fetch org only if we haven't already fetched it for platform check
- const orgPromise: Promise = requestedOrg
+ const orgPromise: Promise = requestedOrg
? Promise.resolve(requestedOrg)
- : (sdk.forConsole.teams.get({ teamId: params.organization }) as Promise);
+ : (sdk.forConsole.teams.get({
+ teamId: params.organization
+ }) as Promise);
const [org, members, countryList, locale] = await Promise.all([
orgPromise,
@@ -95,10 +96,10 @@ async function checkPlatformAndRedirect(
params: { organization: string },
organizations: { teams: Array<{ $id: string; platform?: string }> },
prefs: Record
-): Promise {
+): Promise {
// check if preloaded
let requestedOrg = organizations.teams.find((team) => team.$id === params.organization) as
- | Organization
+ | Models.Organization
| undefined;
// not found, load!
@@ -106,7 +107,7 @@ async function checkPlatformAndRedirect(
try {
requestedOrg = (await sdk.forConsole.teams.get({
teamId: params.organization
- })) as Organization;
+ })) as Models.Organization;
} catch (e) {
return null;
}
@@ -137,7 +138,7 @@ async function checkPlatformAndRedirect(
// check if exists and is valid
const orgFromPrefs = (await sdk.forConsole.teams.get({
teamId: orgIdInPrefs
- })) as Organization;
+ })) as Models.Organization;
// exists and is valid, redirect
redirect(
diff --git a/src/routes/(console)/organization-[organization]/billing/+page.ts b/src/routes/(console)/organization-[organization]/billing/+page.ts
index 0a2dd5f572..f9266a2265 100644
--- a/src/routes/(console)/organization-[organization]/billing/+page.ts
+++ b/src/routes/(console)/organization-[organization]/billing/+page.ts
@@ -3,7 +3,6 @@ import { isCloud } from '$lib/system';
import { sdk } from '$lib/stores/sdk';
import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types';
-import { type Organization } from '$lib/stores/organization';
import { BillingPlan, DEFAULT_BILLING_PROJECTS_LIMIT, Dependencies } from '$lib/constants';
import type { Models } from '@appwrite.io/console';
@@ -29,7 +28,7 @@ export const load: PageLoad = async ({ parent, depends, url, route }) => {
//aggregation reloads on page param changes
depends(Dependencies.BILLING_AGGREGATION);
- const billingAddressId = (organization as Organization)?.billingAddressId;
+ const billingAddressId = (organization as Models.Organization)?.billingAddressId;
const billingAddressPromise: Promise = billingAddressId
? sdk.forConsole.billing
.getOrganizationBillingAddress(organization.$id, billingAddressId)
@@ -48,7 +47,7 @@ export const load: PageLoad = async ({ parent, depends, url, route }) => {
const offset = pageToOffset(currentPage, limit);
billingAggregation = await sdk.forConsole.billing.getAggregation(
organization.$id,
- (organization as Organization)?.billingAggregationId,
+ (organization as Models.Organization)?.billingAggregationId,
limit,
offset
);
@@ -60,7 +59,7 @@ export const load: PageLoad = async ({ parent, depends, url, route }) => {
try {
billingInvoice = await sdk.forConsole.billing.getInvoice(
organization.$id,
- (organization as Organization)?.billingInvoiceId
+ (organization as Models.Organization)?.billingInvoiceId
);
} catch (e) {
// ignore error
diff --git a/src/routes/(console)/organization-[organization]/billing/billingAddress.svelte b/src/routes/(console)/organization-[organization]/billing/billingAddress.svelte
index b69576d214..59f96534ed 100644
--- a/src/routes/(console)/organization-[organization]/billing/billingAddress.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/billingAddress.svelte
@@ -6,7 +6,6 @@
import { Button } from '$lib/elements/forms';
import { addressList } from '$lib/stores/billing';
import { addNotification } from '$lib/stores/notifications';
- import { type Organization } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
import RemoveAddress from './removeAddress.svelte';
import { user } from '$lib/stores/user';
@@ -24,8 +23,8 @@
import type { Models } from '@appwrite.io/console';
export let locale: Models.Locale;
- export let organization: Organization;
export let countryList: Models.CountryList;
+ export let organization: Models.Organization;
export let billingAddress: Models.BillingAddress;
let showCreate = false;
diff --git a/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte b/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte
index 90b77db7dd..7c8a1b3c82 100644
--- a/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte
@@ -7,7 +7,6 @@
import { Button, Form } from '$lib/elements/forms';
import { symmetricDifference } from '$lib/helpers/array';
import { addNotification } from '$lib/stores/notifications';
- import { type Organization } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
import { Alert, Icon, Table } from '@appwrite.io/pink-svelte';
import { IconTrash } from '@appwrite.io/pink-icons-svelte';
@@ -15,8 +14,8 @@
import type { Models } from '@appwrite.io/console';
export let alertsEnabled = false;
- export let organization: Organization;
export let currentPlan: Models.BillingPlan;
+ export let organization: Models.Organization;
let search: string;
let selectedAlert: number;
diff --git a/src/routes/(console)/organization-[organization]/billing/budgetCap.svelte b/src/routes/(console)/organization-[organization]/billing/budgetCap.svelte
index 65062307b6..05986cb6f7 100644
--- a/src/routes/(console)/organization-[organization]/billing/budgetCap.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/budgetCap.svelte
@@ -6,14 +6,13 @@
import { Button, Form, InputNumber, InputSwitch } from '$lib/elements/forms';
import { showUsageRatesModal, upgradeURL } from '$lib/stores/billing';
import { addNotification } from '$lib/stores/notifications';
- import { type Organization } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
import { Alert, Link } from '@appwrite.io/pink-svelte';
import BudgetAlert from './budgetAlert.svelte';
import type { Models } from '@appwrite.io/console';
- export let organization: Organization;
export let currentPlan: Models.BillingPlan;
+ export let organization: Models.Organization;
let budget = organization.billingBudget;
let capActive = organization?.billingBudget !== null;
diff --git a/src/routes/(console)/organization-[organization]/billing/paymentMethods.svelte b/src/routes/(console)/organization-[organization]/billing/paymentMethods.svelte
index 6f45b4b94c..fef8e09165 100644
--- a/src/routes/(console)/organization-[organization]/billing/paymentMethods.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/paymentMethods.svelte
@@ -5,7 +5,6 @@
import { CardGrid, CreditCardBrandImage, CreditCardInfo } from '$lib/components';
import { BillingPlan, Dependencies } from '$lib/constants';
import { addNotification } from '$lib/stores/notifications';
- import { type Organization } from '$lib/stores/organization';
import { Button } from '$lib/elements/forms';
import { hasStripePublicKey, isCloud } from '$lib/system';
import DeleteOrgPayment from './deleteOrgPayment.svelte';
@@ -34,7 +33,7 @@
} from '@appwrite.io/pink-icons-svelte';
import type { Models } from '@appwrite.io/console';
- export let organization: Organization;
+ export let organization: Models.Organization;
export let methods: Models.PaymentMethodList;
let showEdit = false;
diff --git a/src/routes/(console)/organization-[organization]/billing/replaceCard.svelte b/src/routes/(console)/organization-[organization]/billing/replaceCard.svelte
index 05551918fb..9be786bfc7 100644
--- a/src/routes/(console)/organization-[organization]/billing/replaceCard.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/replaceCard.svelte
@@ -3,7 +3,6 @@
import { FakeModal } from '$lib/components';
import { Button } from '$lib/elements/forms';
import { sdk } from '$lib/stores/sdk';
- import type { Organization } from '$lib/stores/organization';
import { Dependencies } from '$lib/constants';
import { setPaymentMethod, submitStripeCard } from '$lib/stores/stripe';
import { onMount } from 'svelte';
@@ -13,9 +12,9 @@
import type { PaymentMethod as StripePaymentMethod } from '@stripe/stripe-js';
import type { Models } from '@appwrite.io/console';
- export let organization: Organization;
export let show = false;
export let isBackup = false;
+ export let organization: Models.Organization;
export let methods: Models.PaymentMethodList;
let name: string;
diff --git a/src/routes/(console)/organization-[organization]/change-plan/+page.ts b/src/routes/(console)/organization-[organization]/change-plan/+page.ts
index c6a137f96a..b872fa3231 100644
--- a/src/routes/(console)/organization-[organization]/change-plan/+page.ts
+++ b/src/routes/(console)/organization-[organization]/change-plan/+page.ts
@@ -1,31 +1,43 @@
import type { PageLoad } from './$types';
-import type { Organization } from '$lib/stores/organization';
import { BillingPlan, Dependencies } from '$lib/constants';
import { sdk } from '$lib/stores/sdk';
+import { BillingPlanGroup, type Models } from '@appwrite.io/console';
+import { getBasePlanFromGroup } from '$lib/stores/billing';
export const load: PageLoad = async ({ depends, parent }) => {
const { members, currentPlan, organizations } = await parent();
+
depends(Dependencies.UPGRADE_PLAN);
- let plans;
+ let plans: Models.BillingPlanList;
+
try {
plans = await sdk.forConsole.billing.listPlans();
} catch (error) {
console.error('Failed to load billing plans:', error);
- plans = { plans: {} };
+ plans = {
+ total: 0,
+ plans: []
+ };
}
let plan: BillingPlan;
- if (currentPlan?.$id === BillingPlan.SCALE) {
- plan = BillingPlan.SCALE;
+ const pro = getBasePlanFromGroup(BillingPlanGroup.Pro);
+ const scale = getBasePlanFromGroup(BillingPlanGroup.Scale);
+
+ // TODO: why not just use the current id as is?
+ if (currentPlan?.$id === scale.$id) {
+ plan = scale.$id;
} else {
- plan = BillingPlan.PRO;
+ plan = pro.$id;
}
const selfService = currentPlan?.selfService ?? true;
const hasFreeOrgs = organizations.teams?.some(
- (org) => (org as Organization)?.billingPlan === BillingPlan.FREE
+ (org) =>
+ (org as Models.Organization)?.billingPlan ===
+ getBasePlanFromGroup(BillingPlanGroup.Starter).$id
);
return {
diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/+page.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/+page.svelte
index fc70514a72..fb630bac94 100644
--- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/+page.svelte
+++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/+page.svelte
@@ -1,15 +1,15 @@
-
+
+
diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/+page.ts b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/+page.ts
index fda7fb6a2a..3cdcd64f48 100644
--- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/+page.ts
+++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/+page.ts
@@ -1,18 +1,26 @@
-import { Dependencies } from '$lib/constants';
-import { sdk } from '$lib/stores/sdk';
import { isCloud } from '$lib/system';
-import { Query, Platform } from '@appwrite.io/console';
+import { redirect } from '@sveltejs/kit';
+import { base, resolve } from '$app/paths';
+import { Dependencies } from '$lib/constants';
+import type { Models } from '@appwrite.io/console';
+import { getTeamOrOrganizationList } from '$lib/stores/organization';
-export const load = async ({ parent, depends }) => {
- depends(Dependencies.DOMAINS);
+export const load = async ({ params, parent, depends }) => {
+ if (!isCloud) {
+ redirect(
+ 303,
+ resolve('/(console)/organization-[organization]', {
+ organization: params.organization
+ })
+ );
+ }
- const organizations = !isCloud
- ? await sdk.forConsole.teams.list()
- : await sdk.forConsole.billing.listOrganization([
- Query.equal('platform', Platform.Appwrite)
- ]);
+ depends(Dependencies.DOMAINS);
const { domain } = await parent();
+
+ const organizations = (await getTeamOrOrganizationList()) as Models.OrganizationList;
+
return {
domain,
organizations
diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/changeOrganization.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/changeOrganization.svelte
index 542ea62ad1..0ecaa38cb8 100644
--- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/changeOrganization.svelte
+++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/changeOrganization.svelte
@@ -6,12 +6,12 @@
import { Dependencies } from '$lib/constants';
import { Button, InputSelect } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
- import type { OrganizationList } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
import type { Models } from '@appwrite.io/console';
export let domain: Models.Domain;
- export let organizations: OrganizationList;
+ export let organizations: Models.OrganizationList;
+
let selectedOrg: string = null;
async function moveDomain() {
diff --git a/src/routes/(console)/organization-[organization]/header.svelte b/src/routes/(console)/organization-[organization]/header.svelte
index ab2db544ca..ba61eccca1 100644
--- a/src/routes/(console)/organization-[organization]/header.svelte
+++ b/src/routes/(console)/organization-[organization]/header.svelte
@@ -14,12 +14,7 @@
readOnly,
billingIdToPlan
} from '$lib/stores/billing';
- import {
- members,
- newMemberModal,
- newOrgModal,
- type Organization
- } from '$lib/stores/organization';
+ import { members, newMemberModal, newOrgModal } from '$lib/stores/organization';
import {
canSeeBilling,
canSeeProjects,
@@ -30,6 +25,7 @@
import { GRACE_PERIOD_OVERRIDE, isCloud } from '$lib/system';
import { IconGithub, IconPlus, IconPlusSm } from '@appwrite.io/pink-icons-svelte';
import { Badge, Icon, Layout, Tooltip, Typography } from '@appwrite.io/pink-svelte';
+ import type { Models } from '@appwrite.io/console';
let areMembersLimited: boolean = $state(false);
@@ -41,7 +37,7 @@
(($readOnly && !GRACE_PERIOD_OVERRIDE) || (isLimited && $members?.total >= limit));
});
- const organization = $derived(page.data.organization as Organization);
+ const organization = $derived(page.data.organization as Models.Organization);
const path = $derived(`${base}/organization-${organization.$id}`);
const tabs = $derived(
diff --git a/src/routes/(console)/project-[region]-[project]/+layout.ts b/src/routes/(console)/project-[region]-[project]/+layout.ts
index e45017ad88..818eba1a84 100644
--- a/src/routes/(console)/project-[region]-[project]/+layout.ts
+++ b/src/routes/(console)/project-[region]-[project]/+layout.ts
@@ -8,8 +8,7 @@ import { get } from 'svelte/store';
import { headerAlert } from '$lib/stores/headerAlert';
import PaymentFailed from '$lib/components/billing/alerts/paymentFailed.svelte';
import { loadAvailableRegions } from '$routes/(console)/regions';
-import type { Organization, OrganizationList } from '$lib/stores/organization';
-import { Platform } from '@appwrite.io/console';
+import { type Models, Platform } from '@appwrite.io/console';
import { redirect } from '@sveltejs/kit';
import { resolve } from '$app/paths';
@@ -21,7 +20,7 @@ export const load: LayoutLoad = async ({ params, depends, parent }) => {
project.region ??= 'default';
// fast path without a network call!
- let organization = (organizations as OrganizationList)?.teams?.find(
+ let organization = (organizations as Models.OrganizationList)?.teams?.find(
(org) => org.$id === project.teamId
);
@@ -30,7 +29,8 @@ export const load: LayoutLoad = async ({ params, depends, parent }) => {
const [org, regionalConsoleVariables, rolesResult] = await Promise.all([
!organization
- ? (sdk.forConsole.teams.get({ teamId: project.teamId }) as Promise)
+ ? // TODO: @itznotabug - teams.get with Models.Organization?
+ (sdk.forConsole.teams.get({ teamId: project.teamId }) as Promise)
: organization,
sdk.forConsoleIn(project.region).console.variables(),
isCloud ? sdk.forConsole.billing.getRoles(project.teamId) : null,
diff --git a/src/routes/(console)/store.ts b/src/routes/(console)/store.ts
index 359a71b30f..a21c994510 100644
--- a/src/routes/(console)/store.ts
+++ b/src/routes/(console)/store.ts
@@ -1,6 +1,5 @@
import { page } from '$app/stores';
import type { HeaderAlert } from '$lib/stores/headerAlert';
-import type { Organization } from '$lib/stores/organization';
import type { Models } from '@appwrite.io/console';
import { derived, writable } from 'svelte/store';
@@ -16,4 +15,4 @@ export const protocol = derived(consoleVariables, ($vars) =>
);
export const activeHeaderAlert = writable(null);
-export const orgMissingPaymentMethod = writable(null);
+export const orgMissingPaymentMethod = writable(null);
diff --git a/src/routes/(public)/functions/deploy/+page.ts b/src/routes/(public)/functions/deploy/+page.ts
index d91d084ff8..404d3ae47e 100644
--- a/src/routes/(public)/functions/deploy/+page.ts
+++ b/src/routes/(public)/functions/deploy/+page.ts
@@ -3,8 +3,8 @@ import { redirect } from '@sveltejs/kit';
import { base } from '$app/paths';
import { isCloud } from '$lib/system';
import { BillingPlan } from '$lib/constants';
-import { ID, type Models, Query, Platform } from '@appwrite.io/console';
-import type { OrganizationList } from '$lib/stores/organization';
+import { ID } from '@appwrite.io/console';
+import { getTeamOrOrganizationList } from '$lib/stores/organization';
import { redirectTo } from '$routes/store';
import type { PageLoad } from './$types';
import { getRepositoryInfo } from '$lib/helpers/github';
@@ -64,14 +64,7 @@ export const load: PageLoad = async ({ parent, url }) => {
deploymentData.repository.owner = info.owner;
// Get organizations
- let organizations: Models.TeamList> | OrganizationList | undefined;
- if (isCloud) {
- organizations = await sdk.forConsole.billing.listOrganization([
- Query.equal('platform', Platform.Appwrite)
- ]);
- } else {
- organizations = await sdk.forConsole.teams.list();
- }
+ let organizations = await getTeamOrOrganizationList();
if (!organizations?.total) {
try {
@@ -89,13 +82,7 @@ export const load: PageLoad = async ({ parent, url }) => {
});
}
- if (isCloud) {
- organizations = await sdk.forConsole.billing.listOrganization([
- Query.equal('platform', Platform.Appwrite)
- ]);
- } else {
- organizations = await sdk.forConsole.teams.list();
- }
+ organizations = await getTeamOrOrganizationList();
} catch (e) {
console.error('Failed to create default organization:', e);
}
diff --git a/src/routes/(public)/sites/deploy/+page.ts b/src/routes/(public)/sites/deploy/+page.ts
index ca57d36e34..79bea62d31 100644
--- a/src/routes/(public)/sites/deploy/+page.ts
+++ b/src/routes/(public)/sites/deploy/+page.ts
@@ -3,8 +3,8 @@ import { redirect, error } from '@sveltejs/kit';
import { base } from '$app/paths';
import { isCloud } from '$lib/system';
import { BillingPlan } from '$lib/constants';
-import { ID, type Models, Query, Platform } from '@appwrite.io/console';
-import type { OrganizationList } from '$lib/stores/organization';
+import { ID, type Models } from '@appwrite.io/console';
+import { getTeamOrOrganizationList } from '$lib/stores/organization';
import { redirectTo } from '$routes/store';
import type { PageLoad } from './$types';
import { getRepositoryInfo } from '$lib/helpers/github';
@@ -80,15 +80,7 @@ export const load: PageLoad = async ({ parent, url }) => {
};
}
- let organizations: Models.TeamList> | OrganizationList | undefined;
-
- if (isCloud) {
- organizations = await sdk.forConsole.billing.listOrganization([
- Query.equal('platform', Platform.Appwrite)
- ]);
- } else {
- organizations = await sdk.forConsole.teams.list();
- }
+ let organizations = await getTeamOrOrganizationList();
if (!organizations?.total) {
try {
@@ -107,13 +99,7 @@ export const load: PageLoad = async ({ parent, url }) => {
}
// Refetch organizations after creation
- if (isCloud) {
- organizations = await sdk.forConsole.billing.listOrganization([
- Query.equal('platform', Platform.Appwrite)
- ]);
- } else {
- organizations = await sdk.forConsole.teams.list();
- }
+ organizations = await getTeamOrOrganizationList();
} catch (e) {
console.error('Failed to create default organization:', e);
}
diff --git a/src/routes/(public)/template-[template]/+page.ts b/src/routes/(public)/template-[template]/+page.ts
index e2dac3adfa..92890ff1cf 100644
--- a/src/routes/(public)/template-[template]/+page.ts
+++ b/src/routes/(public)/template-[template]/+page.ts
@@ -1,11 +1,11 @@
-import { BillingPlan } from '$lib/constants.js';
+import { base } from '$app/paths';
import { sdk } from '$lib/stores/sdk.js';
-import { ID, type Models, Query, Platform } from '@appwrite.io/console';
import { isCloud } from '$lib/system.js';
-import { error, redirect } from '@sveltejs/kit';
-import type { OrganizationList } from '$lib/stores/organization.js';
import { redirectTo } from '$routes/store.js';
-import { base } from '$app/paths';
+import { error, redirect } from '@sveltejs/kit';
+import { getBasePlanFromGroup } from '$lib/stores/billing';
+import { getTeamOrOrganizationList } from '$lib/stores/organization.js';
+import { BillingPlanGroup, ID, type Models } from '@appwrite.io/console';
export const load = async ({ parent, url, params }) => {
const { account } = await parent();
@@ -37,22 +37,13 @@ export const load = async ({ parent, url, params }) => {
error(404, 'Type is not valid');
}
- let organizations: Models.TeamList> | OrganizationList | undefined;
- if (isCloud) {
- organizations = account?.$id
- ? await sdk.forConsole.billing.listOrganization([
- Query.equal('platform', Platform.Appwrite)
- ])
- : undefined;
- } else {
- organizations = account?.$id ? await sdk.forConsole.teams.list() : undefined;
- }
+ const organizations = account?.$id ? await getTeamOrOrganizationList() : undefined;
if (!organizations?.total && account?.$id) {
await sdk.forConsole.billing.createOrganization(
ID.unique(),
'Personal project',
- BillingPlan.FREE,
+ getBasePlanFromGroup(BillingPlanGroup.Starter).$id,
null
);
}
diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts
index bcd3e307ff..a80e909b98 100644
--- a/src/routes/+layout.ts
+++ b/src/routes/+layout.ts
@@ -8,9 +8,10 @@ import type { LayoutLoad } from './$types';
import { redirectTo } from './store';
import { base, resolve } from '$app/paths';
import type { Account } from '$lib/stores/user';
-import { type AppwriteException, Query, Platform } from '@appwrite.io/console';
+import { type AppwriteException } from '@appwrite.io/console';
import { isCloud, VARS } from '$lib/system';
import { checkPricingRefAndRedirect } from '$lib/helpers/pricingRedirect';
+import { getTeamOrOrganizationList } from '$lib/stores/organization';
export const ssr = false;
@@ -40,11 +41,7 @@ export const load: LayoutLoad = async ({ depends, url, route }) => {
return {
account: account,
- organizations: !isCloud
- ? await sdk.forConsole.teams.list()
- : await sdk.forConsole.billing.listOrganization([
- Query.equal('platform', Platform.Appwrite)
- ])
+ organizations: await getTeamOrOrganizationList()
};
}
From 67dff4346150ac2cec2f5b628d81ce86720c7cf6 Mon Sep 17 00:00:00 2001
From: Darshan
Date: Thu, 18 Dec 2025 19:55:49 +0530
Subject: [PATCH 15/27] clear: tests.
---
package.json | 2 +-
pnpm-lock.yaml | 10 +++++-----
src/lib/layout/containerHeader.svelte | 5 +----
src/lib/stores/billing.ts | 3 +--
src/lib/stores/organization.ts | 12 +-----------
.../organization-[organization]/change-plan/+page.ts | 4 ++--
.../domains/domain-[domain]/settings/+page.ts | 2 +-
7 files changed, 12 insertions(+), 26 deletions(-)
diff --git a/package.json b/package.json
index 5d66906f46..625bf9cb03 100644
--- a/package.json
+++ b/package.json
@@ -22,7 +22,7 @@
},
"dependencies": {
"@ai-sdk/svelte": "^1.1.24",
- "@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@364749d",
+ "@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@707fe80",
"@appwrite.io/pink-icons": "0.25.0",
"@appwrite.io/pink-icons-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-icons-svelte@865e2fc",
"@appwrite.io/pink-legacy": "^1.0.3",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a936f9bcd0..4dcf57af7a 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -12,8 +12,8 @@ importers:
specifier: ^1.1.24
version: 1.1.24(svelte@5.25.3)(zod@3.24.3)
'@appwrite.io/console':
- specifier: https://pkg.vc/-/@appwrite/@appwrite.io/console@364749d
- version: https://pkg.vc/-/@appwrite/@appwrite.io/console@364749d
+ specifier: https://pkg.vc/-/@appwrite/@appwrite.io/console@707fe80
+ version: https://pkg.vc/-/@appwrite/@appwrite.io/console@707fe80
'@appwrite.io/pink-icons':
specifier: 0.25.0
version: 0.25.0
@@ -272,8 +272,8 @@ packages:
'@analytics/type-utils@0.6.2':
resolution: {integrity: sha512-TD+xbmsBLyYy/IxFimW/YL/9L2IEnM7/EoV9Aeh56U64Ify8o27HJcKjo38XY9Tcn0uOq1AX3thkKgvtWvwFQg==}
- '@appwrite.io/console@https://pkg.vc/-/@appwrite/@appwrite.io/console@364749d':
- resolution: {tarball: https://pkg.vc/-/@appwrite/@appwrite.io/console@364749d}
+ '@appwrite.io/console@https://pkg.vc/-/@appwrite/@appwrite.io/console@707fe80':
+ resolution: {tarball: https://pkg.vc/-/@appwrite/@appwrite.io/console@707fe80}
version: 1.10.0
'@appwrite.io/pink-icons-svelte@2.0.0-RC.1':
@@ -3823,7 +3823,7 @@ snapshots:
'@analytics/type-utils@0.6.2': {}
- '@appwrite.io/console@https://pkg.vc/-/@appwrite/@appwrite.io/console@364749d': {}
+ '@appwrite.io/console@https://pkg.vc/-/@appwrite/@appwrite.io/console@707fe80': {}
'@appwrite.io/pink-icons-svelte@2.0.0-RC.1(svelte@5.25.3)':
dependencies:
diff --git a/src/lib/layout/containerHeader.svelte b/src/lib/layout/containerHeader.svelte
index 08a1e37392..1847c23d10 100644
--- a/src/lib/layout/containerHeader.svelte
+++ b/src/lib/layout/containerHeader.svelte
@@ -38,18 +38,15 @@
let showDropdown = false;
// TODO: remove the default billing limits when backend is updated with billing code
- const { bandwidth, documents, storage, users, executions } = $organization?.billingLimits ?? {
+ const { bandwidth, storage, users, executions } = $organization?.billingLimits ?? {
bandwidth: 1,
- documents: 1,
storage: 1,
users: 1,
executions: 1
};
- // TODO: @itznotabug - check with @abnegate, what do we do here? this is billing!
const limitedServices = [
{ name: 'bandwidth', value: bandwidth },
- { name: 'documents', value: documents },
{ name: 'storage', value: storage },
{ name: 'users', value: users },
{ name: 'executions', value: executions }
diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts
index 15e9456b1a..45d8340f8f 100644
--- a/src/lib/stores/billing.ts
+++ b/src/lib/stores/billing.ts
@@ -370,10 +370,9 @@ export async function checkForUsageLimit(org: Models.Organization) {
}
// TODO: @itznotabug - check with @abnegate, what do we do here? this is billing!
- const { bandwidth, documents, executions, storage, users } = org?.billingLimits ?? {};
+ const { bandwidth, executions, storage, users } = org?.billingLimits ?? {};
const resources = [
{ value: bandwidth, name: 'bandwidth' },
- { value: documents, name: 'documents' },
{ value: executions, name: 'executions' },
{ value: storage, name: 'storage' },
{ value: users, name: 'users' }
diff --git a/src/lib/stores/organization.ts b/src/lib/stores/organization.ts
index ca4375d959..f0e15a0acf 100644
--- a/src/lib/stores/organization.ts
+++ b/src/lib/stores/organization.ts
@@ -13,16 +13,6 @@ export type OrganizationError = {
type: string;
};
-// TODO: @itznotabug - check with @abnegate, what do we do here? this is billing!
-export type BillingLimits = {
- bandwidth: number;
- documents: number;
- executions: number;
- storage: number;
- users: number;
- budgetLimit: number;
-};
-
export const newOrgModal = writable(false);
export const newMemberModal = writable(false);
export const organizationList = derived(
@@ -40,7 +30,7 @@ export const regions = writable({ total: 0, regions: [
export async function getTeamOrOrganizationList(
queries: string[] = []
-): Models.TeamList | Models.OrganizationList {
+): Promise {
let organizations: Models.TeamList | Models.OrganizationList;
if (isCloud) {
diff --git a/src/routes/(console)/organization-[organization]/change-plan/+page.ts b/src/routes/(console)/organization-[organization]/change-plan/+page.ts
index b872fa3231..30c441a038 100644
--- a/src/routes/(console)/organization-[organization]/change-plan/+page.ts
+++ b/src/routes/(console)/organization-[organization]/change-plan/+page.ts
@@ -28,9 +28,9 @@ export const load: PageLoad = async ({ depends, parent }) => {
// TODO: why not just use the current id as is?
if (currentPlan?.$id === scale.$id) {
- plan = scale.$id;
+ plan = scale.$id as BillingPlan /* temp */;
} else {
- plan = pro.$id;
+ plan = pro.$id as BillingPlan /* temp */;
}
const selfService = currentPlan?.selfService ?? true;
diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/+page.ts b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/+page.ts
index 3cdcd64f48..2ed1fc7d71 100644
--- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/+page.ts
+++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/+page.ts
@@ -1,6 +1,6 @@
import { isCloud } from '$lib/system';
import { redirect } from '@sveltejs/kit';
-import { base, resolve } from '$app/paths';
+import { resolve } from '$app/paths';
import { Dependencies } from '$lib/constants';
import type { Models } from '@appwrite.io/console';
import { getTeamOrOrganizationList } from '$lib/stores/organization';
From a7b7b7777ba7dbb12601eda25448e6f798d31746 Mon Sep 17 00:00:00 2001
From: Darshan
Date: Thu, 18 Dec 2025 19:59:07 +0530
Subject: [PATCH 16/27] remove: `validateOrganization`.
---
src/lib/sdk/billing.ts | 20 -------------------
.../(console)/apply-credit/+page.svelte | 11 ++++++++--
.../create-organization/+page.svelte | 6 +++++-
.../change-plan/+page.svelte | 6 +++++-
4 files changed, 19 insertions(+), 24 deletions(-)
diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts
index a9cab3648e..65ead67fa4 100644
--- a/src/lib/sdk/billing.ts
+++ b/src/lib/sdk/billing.ts
@@ -23,26 +23,6 @@ export class Billing {
this.client = client;
}
- async validateOrganization(
- organizationId: string,
- invites: string[]
- ): Promise {
- const path = `/organizations/${organizationId}/validate`;
- const params = {
- organizationId,
- invites
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'PATCH',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
async createOrganization(
organizationId: string,
name: string,
diff --git a/src/routes/(console)/apply-credit/+page.svelte b/src/routes/(console)/apply-credit/+page.svelte
index c11e41b75e..e844835208 100644
--- a/src/routes/(console)/apply-credit/+page.svelte
+++ b/src/routes/(console)/apply-credit/+page.svelte
@@ -100,7 +100,10 @@
const organizationId = page.url.searchParams.get('id');
collaborators = page.url.searchParams.get('invites').split(',');
- await sdk.forConsole.billing.validateOrganization(organizationId, collaborators);
+ await sdk.forConsole.organizations.validatePayment({
+ organizationId,
+ invites: collaborators
+ });
}
}
@@ -173,7 +176,11 @@
paymentMethodId,
`${base}/apply-credit?${params}`
);
- org = await sdk.forConsole.billing.validateOrganization(org.teamId, collaborators);
+
+ org = await sdk.forConsole.organizations.validatePayment({
+ organizationId: org.teamId,
+ invites: collaborators
+ });
}
if (isOrganization(org)) {
diff --git a/src/routes/(console)/create-organization/+page.svelte b/src/routes/(console)/create-organization/+page.svelte
index 3056c4bd82..549275b47c 100644
--- a/src/routes/(console)/create-organization/+page.svelte
+++ b/src/routes/(console)/create-organization/+page.svelte
@@ -84,7 +84,11 @@
async function validate(organizationId: string, invites: string[]) {
try {
- const org = await sdk.forConsole.billing.validateOrganization(organizationId, invites);
+ const org = await sdk.forConsole.organizations.validatePayment({
+ organizationId,
+ invites
+ });
+
if (isOrganization(org)) {
await preloadData(`${base}/console/organization-${org.$id}`);
await goto(`${base}/console/organization-${org.$id}`);
diff --git a/src/routes/(console)/organization-[organization]/change-plan/+page.svelte b/src/routes/(console)/organization-[organization]/change-plan/+page.svelte
index f72814a1a8..6c9df9d337 100644
--- a/src/routes/(console)/organization-[organization]/change-plan/+page.svelte
+++ b/src/routes/(console)/organization-[organization]/change-plan/+page.svelte
@@ -197,7 +197,11 @@
async function validate(organizationId: string, invites: string[]) {
try {
- let org = await sdk.forConsole.billing.validateOrganization(organizationId, invites);
+ let org = await sdk.forConsole.organizations.validatePayment({
+ organizationId,
+ invites
+ });
+
if (isOrganization(org)) {
await invalidate(Dependencies.ACCOUNT);
await invalidate(Dependencies.ORGANIZATION);
From b4e08b56c88cc59ab5a4006daee884354c91cafe Mon Sep 17 00:00:00 2001
From: Darshan
Date: Thu, 18 Dec 2025 20:09:50 +0530
Subject: [PATCH 17/27] remove: `estimationCreateOrganization`,
`deleteOrganization`, `estimationDeleteOrganization`, `getOrganizationPlan`
and `getRoles`.
---
.../billing/estimatedTotalBox.svelte | 15 +++--
src/lib/sdk/billing.ts | 64 -------------------
src/lib/stores/billing.ts | 4 +-
.../(console)/apply-credit/+page.svelte | 4 +-
.../organization-[organization]/+layout.ts | 9 ++-
.../settings/deleteOrganizationModal.svelte | 10 +--
.../project-[region]-[project]/+layout.ts | 10 ++-
7 files changed, 36 insertions(+), 80 deletions(-)
diff --git a/src/lib/components/billing/estimatedTotalBox.svelte b/src/lib/components/billing/estimatedTotalBox.svelte
index a6610f513d..6eb33f57c0 100644
--- a/src/lib/components/billing/estimatedTotalBox.svelte
+++ b/src/lib/components/billing/estimatedTotalBox.svelte
@@ -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 (
diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts
index 65ead67fa4..6b969ed608 100644
--- a/src/lib/sdk/billing.ts
+++ b/src/lib/sdk/billing.ts
@@ -57,62 +57,6 @@ export class Billing {
);
}
- async estimationCreateOrganization(
- billingPlan: string,
- couponId: string = null,
- invites: Array = []
- ): Promise {
- 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 {
- 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 {
- 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 {
- 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 {
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 {
- 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,
diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts
index 45d8340f8f..7f84d72c78 100644
--- a/src/lib/stores/billing.ts
+++ b/src/lib/stores/billing.ts
@@ -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;
diff --git a/src/routes/(console)/apply-credit/+page.svelte b/src/routes/(console)/apply-credit/+page.svelte
index e844835208..1e07158597 100644
--- a/src/routes/(console)/apply-credit/+page.svelte
+++ b/src/routes/(console)/apply-credit/+page.svelte
@@ -254,7 +254,9 @@
$: if (!isNewOrg) {
(async () => {
- currentPlan = await sdk.forConsole.billing.getOrganizationPlan(selectedOrgId);
+ currentPlan = await sdk.forConsole.organizations.getPlan({
+ organizationId: selectedOrgId
+ });
})();
loadPaymentMethods();
}
diff --git a/src/routes/(console)/organization-[organization]/+layout.ts b/src/routes/(console)/organization-[organization]/+layout.ts
index f8e3d13888..7b63473f18 100644
--- a/src/routes/(console)/organization-[organization]/+layout.ts
+++ b/src/routes/(console)/organization-[organization]/+layout.ts
@@ -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')) {
diff --git a/src/routes/(console)/organization-[organization]/settings/deleteOrganizationModal.svelte b/src/routes/(console)/organization-[organization]/settings/deleteOrganizationModal.svelte
index ae22262f4d..51a1d483aa 100644
--- a/src/routes/(console)/organization-[organization]/settings/deleteOrganizationModal.svelte
+++ b/src/routes/(console)/organization-[organization]/settings/deleteOrganizationModal.svelte
@@ -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;
}
diff --git a/src/routes/(console)/project-[region]-[project]/+layout.ts b/src/routes/(console)/project-[region]-[project]/+layout.ts
index 818eba1a84..4db871851f 100644
--- a/src/routes/(console)/project-[region]-[project]/+layout.ts
+++ b/src/routes/(console)/project-[region]-[project]/+layout.ts
@@ -33,7 +33,11 @@ export const load: LayoutLoad = async ({ params, depends, parent }) => {
(sdk.forConsole.teams.get({ teamId: project.teamId }) as Promise)
: 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;
From 83829116dbe276c5a91268c68f9a530046f580fc Mon Sep 17 00:00:00 2001
From: Darshan
Date: Fri, 19 Dec 2025 12:58:43 +0530
Subject: [PATCH 18/27] remove: `listPlans`.
---
src/lib/sdk/billing.ts | 16 ----------------
.../(console)/create-organization/+page.ts | 6 ++++--
.../change-plan/+page.ts | 6 ++++--
3 files changed, 8 insertions(+), 20 deletions(-)
diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts
index 6b969ed608..ea71bec9d7 100644
--- a/src/lib/sdk/billing.ts
+++ b/src/lib/sdk/billing.ts
@@ -57,22 +57,6 @@ export class Billing {
);
}
- async listPlans(queries: string[] = []): Promise {
- const path = `/console/plans`;
- const uri = new URL(this.client.config.endpoint + path);
- const params = {
- queries
- };
- return await this.client.call(
- 'get',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
async getPlan(planId: string): Promise {
const path = `/console/plans/${planId}`;
const uri = new URL(this.client.config.endpoint + path);
diff --git a/src/routes/(console)/create-organization/+page.ts b/src/routes/(console)/create-organization/+page.ts
index 4dc0c4927c..d21e0e4c57 100644
--- a/src/routes/(console)/create-organization/+page.ts
+++ b/src/routes/(console)/create-organization/+page.ts
@@ -1,6 +1,6 @@
import { sdk } from '$lib/stores/sdk';
import type { PageLoad } from './$types';
-import type { Models } from '@appwrite.io/console';
+import { type Models, Platform } from '@appwrite.io/console';
import { BillingPlan, Dependencies } from '$lib/constants';
export const load: PageLoad = async ({ url, parent, depends }) => {
@@ -9,7 +9,9 @@ export const load: PageLoad = async ({ url, parent, depends }) => {
const [coupon, paymentMethods, plans] = await Promise.all([
getCoupon(url),
sdk.forConsole.billing.listPaymentMethods(),
- sdk.forConsole.billing.listPlans()
+ sdk.forConsole.console.plans({
+ platform: Platform.Appwrite
+ })
]);
let plan = getPlanFromUrl(url);
const hasFreeOrganizations = organizations.teams?.some(
diff --git a/src/routes/(console)/organization-[organization]/change-plan/+page.ts b/src/routes/(console)/organization-[organization]/change-plan/+page.ts
index 30c441a038..9387618079 100644
--- a/src/routes/(console)/organization-[organization]/change-plan/+page.ts
+++ b/src/routes/(console)/organization-[organization]/change-plan/+page.ts
@@ -1,7 +1,7 @@
import type { PageLoad } from './$types';
import { BillingPlan, Dependencies } from '$lib/constants';
import { sdk } from '$lib/stores/sdk';
-import { BillingPlanGroup, type Models } from '@appwrite.io/console';
+import { BillingPlanGroup, type Models, Platform } from '@appwrite.io/console';
import { getBasePlanFromGroup } from '$lib/stores/billing';
export const load: PageLoad = async ({ depends, parent }) => {
@@ -12,7 +12,9 @@ export const load: PageLoad = async ({ depends, parent }) => {
let plans: Models.BillingPlanList;
try {
- plans = await sdk.forConsole.billing.listPlans();
+ plans = await sdk.forConsole.console.plans({
+ platform: Platform.Appwrite,
+ });
} catch (error) {
console.error('Failed to load billing plans:', error);
plans = {
From 60af8297d5432e8a8639017afffc9f69d7717581 Mon Sep 17 00:00:00 2001
From: Darshan
Date: Fri, 19 Dec 2025 13:22:33 +0530
Subject: [PATCH 19/27] remove: `getPlan`.
---
package.json | 2 +-
pnpm-lock.yaml | 10 +++++-----
src/lib/sdk/billing.ts | 8 --------
.../(console)/account/organizations/+page.svelte | 4 +++-
.../organization-[organization]/billing/+page.ts | 4 +++-
5 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/package.json b/package.json
index 625bf9cb03..a82b6d54d0 100644
--- a/package.json
+++ b/package.json
@@ -22,7 +22,7 @@
},
"dependencies": {
"@ai-sdk/svelte": "^1.1.24",
- "@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@707fe80",
+ "@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@18b170d",
"@appwrite.io/pink-icons": "0.25.0",
"@appwrite.io/pink-icons-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-icons-svelte@865e2fc",
"@appwrite.io/pink-legacy": "^1.0.3",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 4dcf57af7a..241ef357a7 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -12,8 +12,8 @@ importers:
specifier: ^1.1.24
version: 1.1.24(svelte@5.25.3)(zod@3.24.3)
'@appwrite.io/console':
- specifier: https://pkg.vc/-/@appwrite/@appwrite.io/console@707fe80
- version: https://pkg.vc/-/@appwrite/@appwrite.io/console@707fe80
+ specifier: https://pkg.vc/-/@appwrite/@appwrite.io/console@18b170d
+ version: https://pkg.vc/-/@appwrite/@appwrite.io/console@18b170d
'@appwrite.io/pink-icons':
specifier: 0.25.0
version: 0.25.0
@@ -272,8 +272,8 @@ packages:
'@analytics/type-utils@0.6.2':
resolution: {integrity: sha512-TD+xbmsBLyYy/IxFimW/YL/9L2IEnM7/EoV9Aeh56U64Ify8o27HJcKjo38XY9Tcn0uOq1AX3thkKgvtWvwFQg==}
- '@appwrite.io/console@https://pkg.vc/-/@appwrite/@appwrite.io/console@707fe80':
- resolution: {tarball: https://pkg.vc/-/@appwrite/@appwrite.io/console@707fe80}
+ '@appwrite.io/console@https://pkg.vc/-/@appwrite/@appwrite.io/console@18b170d':
+ resolution: {tarball: https://pkg.vc/-/@appwrite/@appwrite.io/console@18b170d}
version: 1.10.0
'@appwrite.io/pink-icons-svelte@2.0.0-RC.1':
@@ -3823,7 +3823,7 @@ snapshots:
'@analytics/type-utils@0.6.2': {}
- '@appwrite.io/console@https://pkg.vc/-/@appwrite/@appwrite.io/console@707fe80': {}
+ '@appwrite.io/console@https://pkg.vc/-/@appwrite/@appwrite.io/console@18b170d': {}
'@appwrite.io/pink-icons-svelte@2.0.0-RC.1(svelte@5.25.3)':
dependencies:
diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts
index ea71bec9d7..16ce46ec28 100644
--- a/src/lib/sdk/billing.ts
+++ b/src/lib/sdk/billing.ts
@@ -57,14 +57,6 @@ export class Billing {
);
}
- async getPlan(planId: string): Promise {
- const path = `/console/plans/${planId}`;
- 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,
diff --git a/src/routes/(console)/account/organizations/+page.svelte b/src/routes/(console)/account/organizations/+page.svelte
index 2d8e6d0453..4a74a13f2a 100644
--- a/src/routes/(console)/account/organizations/+page.svelte
+++ b/src/routes/(console)/account/organizations/+page.svelte
@@ -48,7 +48,9 @@
// For custom plans, fetch from API
try {
- const plan = await sdk.forConsole.billing.getPlan(billingPlan);
+ const plan = await sdk.forConsole.console.getPlan({
+ planId: billingPlan
+ });
return plan.name;
} catch (error) {
// Fallback to 'Custom' if fetch fails
diff --git a/src/routes/(console)/organization-[organization]/billing/+page.ts b/src/routes/(console)/organization-[organization]/billing/+page.ts
index f9266a2265..8fdf1e810c 100644
--- a/src/routes/(console)/organization-[organization]/billing/+page.ts
+++ b/src/routes/(console)/organization-[organization]/billing/+page.ts
@@ -80,7 +80,9 @@ export const load: PageLoad = async ({ parent, depends, url, route }) => {
? sdk.forConsole.billing.getAvailableCredit(organization.$id)
: null,
organization.billingPlanDowngrade
- ? sdk.forConsole.billing.getPlan(organization.billingPlanDowngrade)
+ ? sdk.forConsole.console.getPlan({
+ planId: organization.billingPlanDowngrade
+ })
: null
]);
From dddadc3e424a65df4a1a90d2cc01c7865f0f8181 Mon Sep 17 00:00:00 2001
From: Darshan
Date: Fri, 19 Dec 2025 13:32:44 +0530
Subject: [PATCH 20/27] remove: projects, plans, payment methods hardcoded
methods.
---
.../billing/alerts/selectProjectCloud.svelte | 8 +-
.../billing/estimatedTotalBox.svelte | 10 +-
src/lib/sdk/billing.ts | 136 ------------------
.../(console)/create-organization/+page.ts | 2 +-
.../billing/addCreditWizard.svelte | 8 +-
.../billing/budgetAlert.svelte | 8 +-
.../billing/budgetCap.svelte | 8 +-
.../billing/deleteOrgPayment.svelte | 15 +-
.../billing/paymentMethods.svelte | 12 +-
.../billing/replaceCard.svelte | 12 +-
.../change-plan/+page.svelte | 8 +-
.../change-plan/+page.ts | 4 +-
12 files changed, 50 insertions(+), 181 deletions(-)
diff --git a/src/lib/components/billing/alerts/selectProjectCloud.svelte b/src/lib/components/billing/alerts/selectProjectCloud.svelte
index 510334aa2e..192cf92db9 100644
--- a/src/lib/components/billing/alerts/selectProjectCloud.svelte
+++ b/src/lib/components/billing/alerts/selectProjectCloud.svelte
@@ -31,10 +31,10 @@
async function updateSelected() {
try {
- await sdk.forConsole.billing.updateSelectedProjects(
- projects[0].teamId,
- selectedProjects
- );
+ await sdk.forConsole.organizations.updateProjects({
+ organizationId: projects[0].teamId,
+ projects: selectedProjects
+ });
showSelectProject = false;
invalidate(Dependencies.ORGANIZATION);
diff --git a/src/lib/components/billing/estimatedTotalBox.svelte b/src/lib/components/billing/estimatedTotalBox.svelte
index 6eb33f57c0..d5bf80dc7d 100644
--- a/src/lib/components/billing/estimatedTotalBox.svelte
+++ b/src/lib/components/billing/estimatedTotalBox.svelte
@@ -57,12 +57,12 @@
couponId: string | undefined
) {
try {
- estimation = await sdk.forConsole.billing.estimationUpdatePlan(
+ estimation = await sdk.forConsole.organizations.estimationUpdatePlan({
organizationId,
- billingPlan,
- couponId && couponId.length > 0 ? couponId : null,
- collaborators ?? []
- );
+ billingPlan: billingPlan as BillingPlan,
+ invites: collaborators ?? [],
+ couponId: couponId && couponId.length > 0 ? couponId : null
+ });
} catch (e) {
if (e instanceof AppwriteException) {
if (
diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts
index 16ce46ec28..70c1ba47ce 100644
--- a/src/lib/sdk/billing.ts
+++ b/src/lib/sdk/billing.ts
@@ -90,29 +90,6 @@ export class Billing {
);
}
- async estimationUpdatePlan(
- organizationId: string,
- billingPlan: string,
- couponId: string = null,
- invites: Array = []
- ): Promise {
- const path = `/organizations/${organizationId}/estimations/update-plan`;
- 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 cancelDowngrade(
organizationId: string
): Promise {
@@ -123,119 +100,6 @@ export class Billing {
});
}
- async updateBudget(
- organizationId: string,
- budget: number,
- alerts: number[]
- ): Promise {
- const path = `/organizations/${organizationId}/budget`;
- const params = {
- organizationId,
- budget,
- alerts
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'patch',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async updateSelectedProjects(
- organizationId: string,
- projects: string[]
- ): Promise {
- const path = `/organizations/${organizationId}/projects`;
- const params = {
- projects
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'patch',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async setOrganizationPaymentMethod(
- organizationId: string,
- paymentMethodId: string
- ): Promise {
- const path = `/organizations/${organizationId}/payment-method`;
- const params = {
- organizationId,
- paymentMethodId
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'patch',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async setOrganizationPaymentMethodBackup(
- organizationId: string,
- paymentMethodId: string
- ): Promise {
- const path = `/organizations/${organizationId}/payment-method/backup`;
- const params = {
- organizationId,
- paymentMethodId
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'patch',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
- async removeOrganizationPaymentMethod(organizationId: string): Promise {
- const path = `/organizations/${organizationId}/payment-method`;
- 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 removeOrganizationPaymentMethodBackup(
- organizationId: string
- ): Promise {
- const path = `/organizations/${organizationId}/payment-method/backup`;
- 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 listInvoices(
organizationId: string,
queries: string[] = []
diff --git a/src/routes/(console)/create-organization/+page.ts b/src/routes/(console)/create-organization/+page.ts
index d21e0e4c57..e227824765 100644
--- a/src/routes/(console)/create-organization/+page.ts
+++ b/src/routes/(console)/create-organization/+page.ts
@@ -9,7 +9,7 @@ export const load: PageLoad = async ({ url, parent, depends }) => {
const [coupon, paymentMethods, plans] = await Promise.all([
getCoupon(url),
sdk.forConsole.billing.listPaymentMethods(),
- sdk.forConsole.console.plans({
+ sdk.forConsole.console.getPlans({
platform: Platform.Appwrite
})
]);
diff --git a/src/routes/(console)/organization-[organization]/billing/addCreditWizard.svelte b/src/routes/(console)/organization-[organization]/billing/addCreditWizard.svelte
index 3ae09404f6..41c369b6f5 100644
--- a/src/routes/(console)/organization-[organization]/billing/addCreditWizard.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/addCreditWizard.svelte
@@ -18,10 +18,10 @@
async function create() {
try {
- await sdk.forConsole.billing.setOrganizationPaymentMethod(
- $organization.$id,
- $addCreditWizardStore.paymentMethodId
- );
+ await sdk.forConsole.organizations.setDefaultPaymentMethod({
+ organizationId: $organization.$id,
+ paymentMethodId: $addCreditWizardStore.paymentMethodId
+ });
await sdk.forConsole.billing.addCredit($organization.$id, $addCreditWizardStore.coupon);
addNotification({
diff --git a/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte b/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte
index 7c8a1b3c82..42dd040096 100644
--- a/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte
@@ -46,11 +46,11 @@
async function updateBudget() {
try {
- await sdk.forConsole.billing.updateBudget(
- organization.$id,
- organization.billingBudget,
+ await sdk.forConsole.organizations.updateBudget({
+ organizationId: organization.$id,
+ budget: organization.billingBudget,
alerts
- );
+ });
await invalidate(Dependencies.ORGANIZATION);
diff --git a/src/routes/(console)/organization-[organization]/billing/budgetCap.svelte b/src/routes/(console)/organization-[organization]/billing/budgetCap.svelte
index 05986cb6f7..8a829e6a56 100644
--- a/src/routes/(console)/organization-[organization]/billing/budgetCap.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/budgetCap.svelte
@@ -19,11 +19,11 @@
async function updateBudget() {
try {
- await sdk.forConsole.billing.updateBudget(
- organization.$id,
+ await sdk.forConsole.organizations.updateBudget({
+ organizationId: organization.$id,
budget,
- organization.budgetAlerts
- );
+ alerts: organization.budgetAlerts
+ });
await invalidate(Dependencies.ORGANIZATION);
addNotification({
type: 'success',
diff --git a/src/routes/(console)/organization-[organization]/billing/deleteOrgPayment.svelte b/src/routes/(console)/organization-[organization]/billing/deleteOrgPayment.svelte
index 8f66251797..014cf9fc50 100644
--- a/src/routes/(console)/organization-[organization]/billing/deleteOrgPayment.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/deleteOrgPayment.svelte
@@ -19,7 +19,9 @@
if ($organization?.billingPlan !== BillingPlan.FREE && !hasOtherMethod) return;
try {
- await sdk.forConsole.billing.removeOrganizationPaymentMethod($organization.$id);
+ await sdk.forConsole.organizations.deleteDefaultPaymentMethod({
+ organizationId: $organization.$id
+ });
addNotification({
type: 'success',
message: `The payment method has been removed from ${$organization.name}`
@@ -34,18 +36,21 @@
showDelete = false;
}
}
- async function removeBackuptMethod() {
+
+ async function removeBackupMethod() {
if ($organization?.billingPlan !== BillingPlan.FREE && !hasOtherMethod) return;
showDelete = false;
try {
- await sdk.forConsole.billing.removeOrganizationPaymentMethodBackup($organization.$id);
+ await sdk.forConsole.organizations.deleteBackupPaymentMethod({
+ organizationId: $organization.$id
+ });
addNotification({
type: 'success',
message: `The payment method has been removed from ${$organization.name}`
});
trackEvent(Submit.OrganizationBackupPaymentDelete);
- invalidate(Dependencies.ORGANIZATION);
+ await invalidate(Dependencies.ORGANIZATION);
showDelete = false;
} catch (e) {
error = e.message;
@@ -65,7 +70,7 @@
{:else}
diff --git a/src/routes/(console)/organization-[organization]/billing/paymentMethods.svelte b/src/routes/(console)/organization-[organization]/billing/paymentMethods.svelte
index fef8e09165..76de7a5d55 100644
--- a/src/routes/(console)/organization-[organization]/billing/paymentMethods.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/paymentMethods.svelte
@@ -46,10 +46,10 @@
async function addPaymentMethod(paymentMethodId: string) {
try {
- await sdk.forConsole.billing.setOrganizationPaymentMethod(
- organization.$id,
+ await sdk.forConsole.organizations.setDefaultPaymentMethod({
+ organizationId: organization.$id,
paymentMethodId
- );
+ });
addNotification({
type: 'success',
message: `A new payment method has been added to ${organization.name}`
@@ -67,10 +67,10 @@
async function addBackupPaymentMethod(paymentMethodId: string) {
try {
- await sdk.forConsole.billing.setOrganizationPaymentMethodBackup(
- organization.$id,
+ await sdk.forConsole.organizations.setBackupPaymentMethod({
+ organizationId: organization.$id,
paymentMethodId
- );
+ });
addNotification({
type: 'success',
message: `A new payment method has been added to ${organization.name}`
diff --git a/src/routes/(console)/organization-[organization]/billing/replaceCard.svelte b/src/routes/(console)/organization-[organization]/billing/replaceCard.svelte
index 9be786bfc7..edb71a016a 100644
--- a/src/routes/(console)/organization-[organization]/billing/replaceCard.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/replaceCard.svelte
@@ -88,10 +88,10 @@
async function addPaymentMethod(paymentMethodId: string) {
try {
- await sdk.forConsole.billing.setOrganizationPaymentMethod(
- organization.$id,
+ await sdk.forConsole.organizations.setDefaultPaymentMethod({
+ organizationId: organization.$id,
paymentMethodId
- );
+ });
} catch (e) {
error = e.message;
}
@@ -99,10 +99,10 @@
async function addBackupPaymentMethod(paymentMethodId: string) {
try {
- await sdk.forConsole.billing.setOrganizationPaymentMethodBackup(
- organization.$id,
+ await sdk.forConsole.organizations.setBackupPaymentMethod({
+ organizationId: organization.$id,
paymentMethodId
- );
+ });
} catch (e) {
error = e.message;
}
diff --git a/src/routes/(console)/organization-[organization]/change-plan/+page.svelte b/src/routes/(console)/organization-[organization]/change-plan/+page.svelte
index 6c9df9d337..f4eb34b3eb 100644
--- a/src/routes/(console)/organization-[organization]/change-plan/+page.svelte
+++ b/src/routes/(console)/organization-[organization]/change-plan/+page.svelte
@@ -164,10 +164,10 @@
const selected = usageLimitsComponent.getSelectedProjects();
if (selected?.length) {
try {
- await sdk.forConsole.billing.updateSelectedProjects(
- data.organization.$id,
- selected
- );
+ await sdk.forConsole.organizations.updateProjects({
+ organizationId: data.organization.$id,
+ projects: selected
+ });
} catch (projectError) {
console.warn('Project selection failed after plan update:', projectError);
}
diff --git a/src/routes/(console)/organization-[organization]/change-plan/+page.ts b/src/routes/(console)/organization-[organization]/change-plan/+page.ts
index 9387618079..99ec002d28 100644
--- a/src/routes/(console)/organization-[organization]/change-plan/+page.ts
+++ b/src/routes/(console)/organization-[organization]/change-plan/+page.ts
@@ -12,8 +12,8 @@ export const load: PageLoad = async ({ depends, parent }) => {
let plans: Models.BillingPlanList;
try {
- plans = await sdk.forConsole.console.plans({
- platform: Platform.Appwrite,
+ plans = await sdk.forConsole.console.getPlans({
+ platform: Platform.Appwrite
});
} catch (error) {
console.error('Failed to load billing plans:', error);
From 91aaa3441aac0a35bb0507d1b70d1f6398c7a059 Mon Sep 17 00:00:00 2001
From: Darshan
Date: Fri, 19 Dec 2025 13:53:54 +0530
Subject: [PATCH 21/27] remove: invoices, payments, usage, aggregation
hardcoded methods.
---
src/lib/sdk/billing.ts | 185 ------------------
src/lib/stores/billing.ts | 14 +-
.../billing/+page.svelte | 17 +-
.../billing/+page.ts | 16 +-
.../billing/paymentHistory.svelte | 17 +-
.../billing/retryPaymentModal.svelte | 16 +-
.../change-plan/+page.svelte | 11 +-
.../invoices/[invoiceId]/download/+page.ts | 5 +-
.../invoices/[invoiceId]/view/+page.ts | 6 +-
.../settings/+page.ts | 6 +-
.../usage/[[invoice]]/+page.ts | 16 +-
.../settings/usage/[[invoice]]/+page.ts | 30 +--
12 files changed, 96 insertions(+), 243 deletions(-)
diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts
index 70c1ba47ce..8c7be72ca5 100644
--- a/src/lib/sdk/billing.ts
+++ b/src/lib/sdk/billing.ts
@@ -100,191 +100,6 @@ export class Billing {
});
}
- async listInvoices(
- organizationId: string,
- queries: string[] = []
- ): Promise {
- const path = `/organizations/${organizationId}/invoices`;
- const params = {
- organizationId,
- queries
- };
-
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'get',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async getInvoice(organizationId: string, invoiceId: string): Promise {
- const path = `/organizations/${organizationId}/invoices/${invoiceId}`;
- const params = {
- organizationId,
- invoiceId
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'get',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async getInvoiceView(
- organizationId: string,
- invoiceId: string
- ): Promise> {
- const path = `/organizations/${organizationId}/invoices/${invoiceId}/view`;
- const params = {
- organizationId,
- invoiceId
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'get',
- uri,
- {
- 'content-type': 'application/pdf'
- },
- params
- );
- }
-
- async downloadInvoice(
- organizationId: string,
- invoiceId: string
- ): Promise> {
- const path = `/organizations/${organizationId}/invoices/${invoiceId}/download`;
- const params = {
- organizationId,
- invoiceId
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'get',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async updateInvoiceStatus(organizationId: string, invoiceId: string): Promise {
- const path = `/organizations/${organizationId}/invoices/${invoiceId}/status`;
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call('PATCH', uri, {
- 'content-type': 'application/json'
- });
- }
-
- async retryPayment(
- organizationId: string,
- invoiceId: string,
- paymentMethodId: string
- ): Promise {
- const path = `/organizations/${organizationId}/invoices/${invoiceId}/payments`;
- const params = {
- organizationId,
- invoiceId,
- paymentMethodId
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'post',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async listUsage(
- organizationId: string,
- startDate: string = undefined,
- endDate: string = undefined
- ): Promise {
- const path = `/organizations/${organizationId}/usage`;
- const params = {
- organizationId
- };
-
- if (startDate !== undefined) {
- params['startDate'] = startDate;
- }
- if (endDate !== undefined) {
- params['endDate'] = endDate;
- }
-
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'get',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async listAggregation(
- organizationId: string,
- queries: string[] = []
- ): Promise {
- const path = `/organizations/${organizationId}/aggregations`;
- const params = {
- organizationId,
- queries
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'get',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async getAggregation(
- organizationId: string,
- aggregationId: string,
- limit?: number,
- offset?: number
- ): Promise {
- const path = `/organizations/${organizationId}/aggregations/${aggregationId}`;
- const params: {
- organizationId: string;
- aggregationId: string;
- limit?: number;
- offset?: number;
- } = {
- organizationId,
- aggregationId
- };
- if (typeof limit === 'number') params.limit = limit;
- if (typeof offset === 'number') params.offset = offset;
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'get',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
async addCredit(organizationId: string, couponId: string): Promise {
const path = `/organizations/${organizationId}/credits`;
const params = {
diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts
index 7f84d72c78..aa392813c1 100644
--- a/src/lib/stores/billing.ts
+++ b/src/lib/stores/billing.ts
@@ -202,9 +202,10 @@ export const failedInvoice = cachedStore<
load: async (orgId) => {
if (!isCloud) set(null);
if (!get(canSeeBilling)) set(null);
- const failedInvoices = await sdk.forConsole.billing.listInvoices(orgId, [
- Query.equal('status', 'failed')
- ]);
+ const failedInvoices = await sdk.forConsole.organizations.listInvoices({
+ organizationId: orgId,
+ queries: [Query.equal('status', 'failed')]
+ });
// const failedInvoices = invoices.invoices;
if (failedInvoices?.invoices?.length > 0) {
const firstFailed = failedInvoices.invoices[0];
@@ -443,9 +444,10 @@ export async function checkForUsageLimit(org: Models.Organization) {
export async function checkPaymentAuthorizationRequired(org: Models.Organization) {
if (org.billingPlan === BillingPlan.FREE) return;
- const invoices = await sdk.forConsole.billing.listInvoices(org.$id, [
- Query.equal('status', 'requires_authentication')
- ]);
+ const invoices = await sdk.forConsole.organizations.listInvoices({
+ organizationId: org.$id,
+ queries: [Query.equal('status', 'requires_authentication')]
+ });
if (invoices?.invoices?.length > 0) {
headerAlert.add({
diff --git a/src/routes/(console)/organization-[organization]/billing/+page.svelte b/src/routes/(console)/organization-[organization]/billing/+page.svelte
index 851a9ba007..797584f7e2 100644
--- a/src/routes/(console)/organization-[organization]/billing/+page.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/+page.svelte
@@ -53,10 +53,10 @@
page.url.searchParams.get('type') === 'confirmation'
) {
const invoiceId = page.url.searchParams.get('invoice');
- const invoice = await sdk.forConsole.billing.getInvoice(
- page.params.organization,
+ const invoice = await sdk.forConsole.organizations.getInvoice({
+ organizationId: page.params.organization,
invoiceId
- );
+ });
await confirmPayment(
organization.$id,
@@ -71,7 +71,10 @@
page.url.searchParams.get('type') === 'validate-invoice'
) {
const invoiceId = page.url.searchParams.get('invoice');
- await sdk.forConsole.billing.updateInvoiceStatus(organization.$id, invoiceId);
+ await sdk.forConsole.organizations.validateInvoice({
+ organizationId: organization.$id,
+ invoiceId
+ });
invalidate(Dependencies.INVOICES);
invalidate(Dependencies.ORGANIZATION);
}
@@ -81,10 +84,10 @@
page.url.searchParams.get('type') === 'retry'
) {
const invoiceId = page.url.searchParams.get('invoice');
- const invoice = await sdk.forConsole.billing.getInvoice(
- page.params.organization,
+ const invoice = await sdk.forConsole.organizations.getInvoice({
+ organizationId: page.params.organization,
invoiceId
- );
+ });
selectedInvoice.set(invoice);
showRetryModal.set(true);
}
diff --git a/src/routes/(console)/organization-[organization]/billing/+page.ts b/src/routes/(console)/organization-[organization]/billing/+page.ts
index 8fdf1e810c..f16095df10 100644
--- a/src/routes/(console)/organization-[organization]/billing/+page.ts
+++ b/src/routes/(console)/organization-[organization]/billing/+page.ts
@@ -45,22 +45,22 @@ export const load: PageLoad = async ({ parent, depends, url, route }) => {
const currentPage = getPage(url) || 1;
const limit = getLimit(url, route, DEFAULT_BILLING_PROJECTS_LIMIT);
const offset = pageToOffset(currentPage, limit);
- billingAggregation = await sdk.forConsole.billing.getAggregation(
- organization.$id,
- (organization as Models.Organization)?.billingAggregationId,
+ billingAggregation = await sdk.forConsole.organizations.getAggregation({
+ organizationId: organization.$id,
+ aggregationId: (organization as Models.Organization)?.billingAggregationId,
limit,
offset
- );
+ });
} catch (e) {
// ignore error
}
let billingInvoice = null;
try {
- billingInvoice = await sdk.forConsole.billing.getInvoice(
- organization.$id,
- (organization as Models.Organization)?.billingInvoiceId
- );
+ billingInvoice = await sdk.forConsole.organizations.getInvoice({
+ organizationId: organization.$id,
+ invoiceId: (organization as Models.Organization)?.billingInvoiceId
+ });
} catch (e) {
// ignore error
}
diff --git a/src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte b/src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte
index 77a4d19525..e9bf2ebb08 100644
--- a/src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte
@@ -51,15 +51,18 @@
async function request(patchQuery: boolean = false) {
isLoadingInvoices = true;
- invoiceList = await sdk.forConsole.billing.listInvoices(page.params.organization, [
- Query.orderDesc('$createdAt'),
+ invoiceList = await sdk.forConsole.organizations.listInvoices({
+ organizationId: page.params.organization,
+ queries: [
+ Query.orderDesc('$createdAt'),
- // first page extra must have an extra limit!
- Query.limit(patchQuery ? limit + 1 : limit),
+ // first page extra must have an extra limit!
+ Query.limit(patchQuery ? limit + 1 : limit),
- // so an invoice isn't repeated on 2nd page!
- Query.offset(patchQuery ? offset : offset + 1)
- ]);
+ // so an invoice isn't repeated on 2nd page!
+ Query.offset(patchQuery ? offset : offset + 1)
+ ]
+ });
isLoadingInvoices = false;
}
diff --git a/src/routes/(console)/organization-[organization]/billing/retryPaymentModal.svelte b/src/routes/(console)/organization-[organization]/billing/retryPaymentModal.svelte
index 5bdbdbc025..a13e7c31c7 100644
--- a/src/routes/(console)/organization-[organization]/billing/retryPaymentModal.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/retryPaymentModal.svelte
@@ -98,11 +98,12 @@
if (setAsDefault) {
await sdk.forConsole.billing.setDefaultPaymentMethod(paymentMethodId);
}
- const { clientSecret, status } = await sdk.forConsole.billing.retryPayment(
- $organization.$id,
- invoice.$id,
- paymentMethodId
- );
+ const { clientSecret, status } =
+ await sdk.forConsole.organizations.createInvoicePayment({
+ organizationId: $organization.$id,
+ invoiceId: invoice.$id,
+ paymentMethodId
+ });
if (status !== 'succeeded' && status !== 'cancelled') {
// probably still pending, confirm via stripe!
@@ -113,7 +114,10 @@
`${base}/organization-${$organization.$id}/billing?type=validate-invoice&invoice=${invoice.$id}`
);
- await sdk.forConsole.billing.updateInvoiceStatus($organization.$id, invoice.$id);
+ await sdk.forConsole.organizations.validateInvoice({
+ organizationId: $organization.$id,
+ invoiceId: invoice.$id
+ });
}
invalidate(Dependencies.ORGANIZATION);
diff --git a/src/routes/(console)/organization-[organization]/change-plan/+page.svelte b/src/routes/(console)/organization-[organization]/change-plan/+page.svelte
index f4eb34b3eb..19aecaa2b4 100644
--- a/src/routes/(console)/organization-[organization]/change-plan/+page.svelte
+++ b/src/routes/(console)/organization-[organization]/change-plan/+page.svelte
@@ -99,16 +99,17 @@
$currentPlan?.$id === BillingPlan.SCALE ? BillingPlan.SCALE : BillingPlan.PRO;
try {
- orgUsage = await sdk.forConsole.billing.listUsage(data.organization.$id);
+ orgUsage = await sdk.forConsole.organizations.getUsage({
+ organizationId: data.organization.$id
+ });
} catch {
orgUsage = undefined;
}
try {
- allProjects = await sdk.forConsole.projects.list([
- Query.equal('teamId', data.organization.$id),
- Query.limit(1000)
- ]);
+ allProjects = await sdk.forConsole.projects.list({
+ queries: [Query.equal('teamId', data.organization.$id), Query.limit(1000)]
+ });
} catch {
allProjects = { projects: [] };
}
diff --git a/src/routes/(console)/organization-[organization]/invoices/[invoiceId]/download/+page.ts b/src/routes/(console)/organization-[organization]/invoices/[invoiceId]/download/+page.ts
index de6e172699..3a0e31cbd3 100644
--- a/src/routes/(console)/organization-[organization]/invoices/[invoiceId]/download/+page.ts
+++ b/src/routes/(console)/organization-[organization]/invoices/[invoiceId]/download/+page.ts
@@ -4,7 +4,10 @@ import type { PageLoad } from './$types';
export const load: PageLoad = async ({ params }) => {
// verify invoice exists
- const invoice = await sdk.forConsole.billing.getInvoice(params.organization, params.invoiceId);
+ const invoice = await sdk.forConsole.organizations.getInvoice({
+ organizationId: params.organization,
+ invoiceId: params.invoiceId
+ });
const endpoint = getApiEndpoint();
return redirect(
diff --git a/src/routes/(console)/organization-[organization]/invoices/[invoiceId]/view/+page.ts b/src/routes/(console)/organization-[organization]/invoices/[invoiceId]/view/+page.ts
index bfd0e5b082..3a4576785e 100644
--- a/src/routes/(console)/organization-[organization]/invoices/[invoiceId]/view/+page.ts
+++ b/src/routes/(console)/organization-[organization]/invoices/[invoiceId]/view/+page.ts
@@ -4,7 +4,11 @@ import type { PageLoad } from './$types';
export const load: PageLoad = async ({ params }) => {
// verify invoice exists
- const invoice = await sdk.forConsole.billing.getInvoice(params.organization, params.invoiceId);
+ const invoice = await sdk.forConsole.organizations.getInvoice({
+ organizationId: params.organization,
+ invoiceId: params.invoiceId
+ });
+
const endpoint = getApiEndpoint();
return redirect(
diff --git a/src/routes/(console)/organization-[organization]/settings/+page.ts b/src/routes/(console)/organization-[organization]/settings/+page.ts
index ffecda25ac..776ea7fcb1 100644
--- a/src/routes/(console)/organization-[organization]/settings/+page.ts
+++ b/src/routes/(console)/organization-[organization]/settings/+page.ts
@@ -10,7 +10,11 @@ export const load: PageLoad = async ({ depends, params, parent }) => {
const [projects, invoices] = await Promise.all([
sdk.forConsole.projects.list({ queries: [Query.equal('teamId', params.organization)] }),
- isCloud ? sdk.forConsole.billing.listInvoices(params.organization) : undefined
+ isCloud
+ ? sdk.forConsole.organizations.listInvoices({
+ organizationId: params.organization
+ })
+ : undefined
]);
return {
diff --git a/src/routes/(console)/organization-[organization]/usage/[[invoice]]/+page.ts b/src/routes/(console)/organization-[organization]/usage/[[invoice]]/+page.ts
index 14ce1fbbe9..98cc1da679 100644
--- a/src/routes/(console)/organization-[organization]/usage/[[invoice]]/+page.ts
+++ b/src/routes/(console)/organization-[organization]/usage/[[invoice]]/+page.ts
@@ -4,7 +4,7 @@ import { type Models, Query } from '@appwrite.io/console';
import type { UsageProjectInfo } from '../../store';
export const load: PageLoad = async ({ params, parent }) => {
- const { invoice } = params;
+ const { invoice: invoiceId } = params;
const { organization: org, currentPlan: plan } = await parent();
/**
@@ -42,14 +42,22 @@ export const load: PageLoad = async ({ params, parent }) => {
let endDate: string = org.billingNextInvoiceDate;
let currentInvoice: Models.Invoice = undefined;
- if (invoice) {
- currentInvoice = await sdk.forConsole.billing.getInvoice(org.$id, invoice);
+ if (invoiceId) {
+ currentInvoice = await sdk.forConsole.organizations.getInvoice({
+ organizationId: org.$id,
+ invoiceId
+ });
startDate = currentInvoice.from;
endDate = currentInvoice.to;
}
const [usage, organizationMembers] = await Promise.all([
- sdk.forConsole.billing.listUsage(org.$id, startDate, endDate),
+ sdk.forConsole.organizations.getUsage({
+ organizationId: org.$id,
+ startDate,
+ endDate
+ }),
+
// this section is cloud only,
// so it is fine to use this check and fetch memberships conditionally!
!plan?.addons?.seats?.supported
diff --git a/src/routes/(console)/project-[region]-[project]/settings/usage/[[invoice]]/+page.ts b/src/routes/(console)/project-[region]-[project]/settings/usage/[[invoice]]/+page.ts
index 9b6908acd2..0efb7c6020 100644
--- a/src/routes/(console)/project-[region]-[project]/settings/usage/[[invoice]]/+page.ts
+++ b/src/routes/(console)/project-[region]-[project]/settings/usage/[[invoice]]/+page.ts
@@ -4,7 +4,7 @@ import { accumulateUsage } from '$lib/sdk/usage';
import { type Models, Query } from '@appwrite.io/console';
export const load: PageLoad = async ({ params, parent }) => {
- const { invoice, project, region } = params;
+ const { invoice: invoiceId, project, region } = params;
const { organization } = await parent();
let startDate: string = organization.billingCurrentInvoiceDate;
@@ -12,28 +12,34 @@ export const load: PageLoad = async ({ params, parent }) => {
let currentInvoice: Models.Invoice = undefined;
let currentAggregation: Models.AggregationTeam = undefined;
- if (invoice) {
- currentInvoice = await sdk.forConsole.billing.getInvoice(organization.$id, invoice);
- currentAggregation = await sdk.forConsole.billing.getAggregation(
- organization.$id,
- currentInvoice.aggregationId
- );
+ if (invoiceId) {
+ currentInvoice = await sdk.forConsole.organizations.getInvoice({
+ organizationId: organization.$id,
+ invoiceId
+ });
+ currentAggregation = await sdk.forConsole.organizations.getAggregation({
+ organizationId: organization.$id,
+ aggregationId: currentInvoice.aggregationId
+ });
startDate = currentInvoice.from;
endDate = currentInvoice.to;
} else {
try {
- currentAggregation = await sdk.forConsole.billing.getAggregation(
- organization.$id,
- organization.billingAggregationId
- );
+ currentAggregation = await sdk.forConsole.organizations.getAggregation({
+ organizationId: organization.$id,
+ aggregationId: organization.billingAggregationId
+ });
} catch (e) {
// ignore error if no aggregation found
}
}
const [invoices, usage] = await Promise.all([
- sdk.forConsole.billing.listInvoices(organization.$id, [Query.orderDesc('from')]),
+ sdk.forConsole.organizations.listInvoices({
+ organizationId: organization.$id,
+ queries: [Query.orderDesc('from')]
+ }),
sdk.forProject(region, project).project.getUsage({ startDate, endDate })
]);
From 9a0059c080a5fe6e7a6006dcea6081d192afca38 Mon Sep 17 00:00:00 2001
From: Darshan
Date: Fri, 19 Dec 2025 14:01:58 +0530
Subject: [PATCH 22/27] remove: credits hardcoded methods.
---
src/lib/sdk/billing.ts | 61 -------------------
.../(console)/apply-credit/+page.svelte | 5 +-
.../billing/+page.ts | 4 +-
.../billing/addCreditModal.svelte | 5 +-
.../billing/addCreditWizard.svelte | 5 +-
.../billing/availableCredit.svelte | 11 ++--
6 files changed, 22 insertions(+), 69 deletions(-)
diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts
index 8c7be72ca5..f98a11cf9f 100644
--- a/src/lib/sdk/billing.ts
+++ b/src/lib/sdk/billing.ts
@@ -100,67 +100,6 @@ export class Billing {
});
}
- async addCredit(organizationId: string, couponId: string): Promise {
- const path = `/organizations/${organizationId}/credits`;
- const params = {
- couponId
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'POST',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
- async listCredits(organizationId: string, queries = []): Promise {
- const path = `/organizations/${organizationId}/credits`;
- const params = {
- queries
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'get',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async getAvailableCredit(organizationId: string): Promise {
- const path = `/organizations/${organizationId}/credits/available`;
- const params = {};
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'GET',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async getCredit(organizationId: string, creditId: string): Promise {
- const path = `/organizations/${organizationId}/credits/${creditId}`;
- const params = {
- creditId
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'GET',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
async getCampaign(campaignId: string): Promise {
const path = `/console/campaigns/${campaignId}`;
const uri = new URL(this.client.config.endpoint + path);
diff --git a/src/routes/(console)/apply-credit/+page.svelte b/src/routes/(console)/apply-credit/+page.svelte
index 1e07158597..8826df7032 100644
--- a/src/routes/(console)/apply-credit/+page.svelte
+++ b/src/routes/(console)/apply-credit/+page.svelte
@@ -156,7 +156,10 @@
// Existing pro org, apply credits
else {
org = selectedOrg;
- await sdk.forConsole.billing.addCredit(org.$id, couponData.code);
+ await sdk.forConsole.organizations.addCredit({
+ organizationId: org.$id,
+ couponId: couponData.code
+ });
}
if (!isOrganization(org) && org.status === 402) {
diff --git a/src/routes/(console)/organization-[organization]/billing/+page.ts b/src/routes/(console)/organization-[organization]/billing/+page.ts
index f16095df10..a787a678f5 100644
--- a/src/routes/(console)/organization-[organization]/billing/+page.ts
+++ b/src/routes/(console)/organization-[organization]/billing/+page.ts
@@ -77,7 +77,9 @@ export const load: PageLoad = async ({ parent, depends, url, route }) => {
sdk.forConsole.billing.listAddresses(),
billingAddressPromise,
areCreditsSupported
- ? sdk.forConsole.billing.getAvailableCredit(organization.$id)
+ ? sdk.forConsole.organizations.getAvailableCredits({
+ organizationId: organization.$id
+ })
: null,
organization.billingPlanDowngrade
? sdk.forConsole.console.getPlan({
diff --git a/src/routes/(console)/organization-[organization]/billing/addCreditModal.svelte b/src/routes/(console)/organization-[organization]/billing/addCreditModal.svelte
index 263e9a737a..be8a77303f 100644
--- a/src/routes/(console)/organization-[organization]/billing/addCreditModal.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/addCreditModal.svelte
@@ -16,7 +16,10 @@
async function redeem() {
try {
- await sdk.forConsole.billing.addCredit($organization.$id, coupon);
+ await sdk.forConsole.organizations.addCredit({
+ organizationId: $organization.$id,
+ couponId: coupon
+ });
show = false;
await invalidate(Dependencies.CREDIT);
await invalidate(Dependencies.ORGANIZATION);
diff --git a/src/routes/(console)/organization-[organization]/billing/addCreditWizard.svelte b/src/routes/(console)/organization-[organization]/billing/addCreditWizard.svelte
index 41c369b6f5..cff0627255 100644
--- a/src/routes/(console)/organization-[organization]/billing/addCreditWizard.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/addCreditWizard.svelte
@@ -23,7 +23,10 @@
paymentMethodId: $addCreditWizardStore.paymentMethodId
});
- await sdk.forConsole.billing.addCredit($organization.$id, $addCreditWizardStore.coupon);
+ await sdk.forConsole.organizations.addCredit({
+ organizationId: $organization.$id,
+ couponId: $addCreditWizardStore.coupon
+ });
addNotification({
type: 'success',
message: `Credit has been added to ${$organization.name}`
diff --git a/src/routes/(console)/organization-[organization]/billing/availableCredit.svelte b/src/routes/(console)/organization-[organization]/billing/availableCredit.svelte
index 0744f5e653..e0727141f6 100644
--- a/src/routes/(console)/organization-[organization]/billing/availableCredit.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/availableCredit.svelte
@@ -45,10 +45,13 @@
* Technically, we could reuse that for offsets < 25 (i.e., the first 5 pages with limit = 5)
* to avoid an extra request. But for now, we always fetch fresh data.
*/
- creditList = await sdk.forConsole.billing.listCredits($organization.$id, [
- Query.limit(limit),
- Query.offset(offset)
- ]);
+ creditList = await sdk.forConsole.organizations.listCredits({
+ organizationId: $organization.$id,
+ queries: [
+ Query.limit(limit),
+ Query.offset(offset)
+ ]
+ });
creditList = {
...creditList,
From 3b14de3be6bfc4724db5675aa1d9984fe8922445 Mon Sep 17 00:00:00 2001
From: Darshan
Date: Fri, 19 Dec 2025 14:06:04 +0530
Subject: [PATCH 23/27] remove: campaigns hardcoded methods.
---
src/lib/sdk/billing.ts | 8 --------
src/routes/(console)/apply-credit/+page.ts | 6 ++++--
.../billing/availableCredit.svelte | 5 +----
src/routes/(public)/(guest)/login/+page.ts | 12 +++++++++---
src/routes/(public)/(guest)/register/+page.ts | 12 +++++++++---
src/routes/+layout.svelte | 10 ++++++----
6 files changed, 29 insertions(+), 24 deletions(-)
diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts
index f98a11cf9f..7cd5be8a75 100644
--- a/src/lib/sdk/billing.ts
+++ b/src/lib/sdk/billing.ts
@@ -100,14 +100,6 @@ export class Billing {
});
}
- async getCampaign(campaignId: string): Promise {
- const path = `/console/campaigns/${campaignId}`;
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call('GET', uri, {
- 'content-type': 'application/json'
- });
- }
-
async setMembership(
programId: string
): Promise<{ $createdAt: string } | { error: { code: number; message: string } }> {
diff --git a/src/routes/(console)/apply-credit/+page.ts b/src/routes/(console)/apply-credit/+page.ts
index 504d62c524..b0af3755b8 100644
--- a/src/routes/(console)/apply-credit/+page.ts
+++ b/src/routes/(console)/apply-credit/+page.ts
@@ -12,7 +12,9 @@ export const load = async ({ url }) => {
try {
couponData = await sdk.forConsole.billing.getCouponAccount(code);
if (couponData.campaign) {
- campaign = await sdk.forConsole.billing.getCampaign(couponData.campaign);
+ campaign = await sdk.forConsole.console.getCampaign({
+ campaignId: couponData.campaign
+ });
}
return { couponData, campaign };
} catch (e) {
@@ -24,7 +26,7 @@ export const load = async ({ url }) => {
const campaignId = url.searchParams.get('campaign');
let campaign: Models.Campaign;
try {
- campaign = await sdk.forConsole.billing.getCampaign(campaignId);
+ campaign = await sdk.forConsole.console.getCampaign({ campaignId });
return { campaign };
} catch (e) {
redirect(303, resolve('/'));
diff --git a/src/routes/(console)/organization-[organization]/billing/availableCredit.svelte b/src/routes/(console)/organization-[organization]/billing/availableCredit.svelte
index e0727141f6..a655313277 100644
--- a/src/routes/(console)/organization-[organization]/billing/availableCredit.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/availableCredit.svelte
@@ -47,10 +47,7 @@
*/
creditList = await sdk.forConsole.organizations.listCredits({
organizationId: $organization.$id,
- queries: [
- Query.limit(limit),
- Query.offset(offset)
- ]
+ queries: [Query.limit(limit), Query.offset(offset)]
});
creditList = {
diff --git a/src/routes/(public)/(guest)/login/+page.ts b/src/routes/(public)/(guest)/login/+page.ts
index 267ded5255..5aac9163a0 100644
--- a/src/routes/(public)/(guest)/login/+page.ts
+++ b/src/routes/(public)/(guest)/login/+page.ts
@@ -9,9 +9,14 @@ export const load: PageLoad = async ({ url }) => {
const code = url.searchParams.get('code');
let campaign: Models.Campaign;
try {
- const couponData = await sdk.forConsole.billing.getCoupon(code);
+ const couponData = await sdk.forConsole.console.getCoupon({
+ couponId: code
+ });
+
if (couponData.campaign) {
- campaign = await sdk.forConsole.billing.getCampaign(couponData.campaign);
+ campaign = await sdk.forConsole.console.getCampaign({
+ campaignId: couponData.campaign
+ });
return {
couponData,
campaign
@@ -21,11 +26,12 @@ export const load: PageLoad = async ({ url }) => {
redirect(303, resolve('/login'));
}
}
+
if (url.searchParams.has('campaign')) {
const campaignId = url.searchParams.get('campaign');
let campaign: Models.Campaign;
try {
- campaign = await sdk.forConsole.billing.getCampaign(campaignId);
+ campaign = await sdk.forConsole.console.getCampaign({ campaignId });
return { campaign };
} catch (e) {
redirect(303, resolve('/login'));
diff --git a/src/routes/(public)/(guest)/register/+page.ts b/src/routes/(public)/(guest)/register/+page.ts
index da2c7cd502..6f3dfe81ef 100644
--- a/src/routes/(public)/(guest)/register/+page.ts
+++ b/src/routes/(public)/(guest)/register/+page.ts
@@ -9,9 +9,14 @@ export const load: PageLoad = async ({ url }) => {
const code = url.searchParams.get('code');
let campaign: Models.Campaign;
try {
- const couponData = await sdk.forConsole.billing.getCoupon(code);
+ const couponData = await sdk.forConsole.console.getCoupon({
+ couponId: code
+ });
+
if (couponData.campaign) {
- campaign = await sdk.forConsole.billing.getCampaign(couponData.campaign);
+ campaign = await sdk.forConsole.console.getCampaign({
+ campaignId: couponData.campaign
+ });
return {
couponData,
campaign
@@ -21,11 +26,12 @@ export const load: PageLoad = async ({ url }) => {
redirect(303, resolve('/register'));
}
}
+
if (url.searchParams.has('campaign')) {
const campaignId = url.searchParams.get('campaign');
let campaign: Models.Campaign;
try {
- campaign = await sdk.forConsole.billing.getCampaign(campaignId);
+ campaign = await sdk.forConsole.console.getCampaign({ campaignId });
return { campaign };
} catch (e) {
redirect(303, resolve('/register'));
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index 571542d06f..67ff7e955d 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -70,9 +70,10 @@
const code = page.url.searchParams.get('code');
const coupon = await sdk.forConsole.billing.getCoupon(code).catch(() => null);
if (coupon?.campaign) {
- const campaign = await sdk.forConsole.billing
- .getCampaign(coupon.campaign)
+ const campaign = await sdk.forConsole.console
+ .getCampaign({ campaignId: coupon.campaign })
.catch(() => null);
+
if (campaign && $user) {
goto(`${base}/apply-credit?${page.url.searchParams}`);
loading.set(false);
@@ -83,9 +84,10 @@
if ($user && page.url.searchParams.has('campaign')) {
const campaignId = page.url.searchParams.get('campaign');
- const campaign = await sdk.forConsole.billing
- .getCampaign(campaignId)
+ const campaign = await sdk.forConsole.console
+ .getCampaign({ campaignId })
.catch(() => null);
+
if (campaign) {
goto(`${base}/apply-credit?${page.url.searchParams}`);
From 4216f3b07ed9a15d595940488f63864a19b0a557 Mon Sep 17 00:00:00 2001
From: Darshan
Date: Fri, 19 Dec 2025 14:14:33 +0530
Subject: [PATCH 24/27] remove: `setMembership` hardcoded methods.
---
src/lib/sdk/billing.ts | 14 --------------
src/routes/+page.ts | 25 +++++++++++++------------
2 files changed, 13 insertions(+), 26 deletions(-)
diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts
index 7cd5be8a75..b062e1eb83 100644
--- a/src/lib/sdk/billing.ts
+++ b/src/lib/sdk/billing.ts
@@ -100,20 +100,6 @@ export class Billing {
});
}
- async setMembership(
- programId: string
- ): Promise<{ $createdAt: string } | { error: { code: number; message: string } }> {
- const path = `/console/programs/${programId}/memberships`;
- const uri = new URL(this.client.config.endpoint + path);
- try {
- return await this.client.call('POST', uri, {
- 'content-type': 'application/json'
- });
- } catch (e) {
- return { error: { code: e.code, message: e.message } };
- }
- }
-
async getCouponAccount(couponId: string): Promise {
const path = `/account/coupons/${couponId}`;
const params = {
diff --git a/src/routes/+page.ts b/src/routes/+page.ts
index ea9e97cb82..e9600a4267 100644
--- a/src/routes/+page.ts
+++ b/src/routes/+page.ts
@@ -1,23 +1,24 @@
import { redirect } from '@sveltejs/kit';
-import { base } from '$app/paths';
+import { base, resolve } from '$app/paths';
import type { PageLoad } from './$types';
import { sdk } from '$lib/stores/sdk';
import { VARS } from '$lib/system';
const handleGithubEducationMembership = async (name: string, email: string) => {
- const result = await sdk.forConsole.billing.setMembership('github-student-developer');
- if (result && 'error' in result) {
- if (result.error.code === 409) {
- redirect(303, `${base}/account/organizations`);
+ try {
+ await sdk.forConsole.console.createProgramMembership({
+ programId: 'github-student-developer'
+ });
+
+ await setToGhStudentMailingList(name, email);
+ } catch (error) {
+ if (error.code === 409) {
+ redirect(303, resolve('/(console)/account/organizations'));
} else {
await sdk.forConsole.account.deleteSession({ sessionId: 'current' });
- redirect(
- 303,
- `${base}/education/error?message=${result.error.message}&code=${result.error.code}`
- );
+ const errorUrl = resolve('/(public)/(guest)/education/error');
+ redirect(303, `${errorUrl}?message=${error.message}&code=${error.code}`);
}
- } else if (result && '$createdAt' in result) {
- setToGhStudentMailingList(name, email);
}
};
@@ -35,7 +36,7 @@ export const load: PageLoad = async ({ parent, url }) => {
if (userVisitedEducationPage()) {
await handleGithubEducationMembership(account.name, account.email);
- redirect(303, base);
+ redirect(303, resolve('/'));
} else if (organizations.total && !isApplyingCredit) {
const teamId = account.prefs.organization ?? organizations.teams[0].$id;
if (!teamId) {
From 0597d21c62c427e368c0a8b80635b0e6fa67c34b Mon Sep 17 00:00:00 2001
From: Darshan
Date: Fri, 19 Dec 2025 14:22:55 +0530
Subject: [PATCH 25/27] refactor: remove `getCouponAccount` hardcoded method
and its usages.
---
src/lib/components/billing/couponInput.svelte | 5 ++-
.../billing/validateCreditModal.svelte | 6 ++--
src/lib/sdk/billing.ts | 32 -------------------
src/lib/stores/billing.ts | 4 ++-
.../(console)/apply-credit/+page.svelte | 6 ++--
src/routes/(console)/apply-credit/+page.ts | 4 ++-
.../create-organization/+page.svelte | 4 ++-
.../(console)/create-organization/+page.ts | 4 ++-
.../billing/wizard/addCredit.svelte | 8 +++--
.../change-plan/+page.svelte | 4 ++-
src/routes/+layout.svelte | 6 +++-
11 files changed, 37 insertions(+), 46 deletions(-)
diff --git a/src/lib/components/billing/couponInput.svelte b/src/lib/components/billing/couponInput.svelte
index ccf72e53bb..fc33df37df 100644
--- a/src/lib/components/billing/couponInput.svelte
+++ b/src/lib/components/billing/couponInput.svelte
@@ -18,7 +18,10 @@
async function addCoupon() {
try {
- couponData = await sdk.forConsole.billing.getCouponAccount(coupon);
+ couponData = await sdk.forConsole.account.getCoupon({
+ couponId: coupon
+ });
+
dispatch('validation', couponData);
coupon = null;
} catch (error) {
diff --git a/src/lib/components/billing/validateCreditModal.svelte b/src/lib/components/billing/validateCreditModal.svelte
index 3226ee2097..6e41448354 100644
--- a/src/lib/components/billing/validateCreditModal.svelte
+++ b/src/lib/components/billing/validateCreditModal.svelte
@@ -13,14 +13,16 @@
status: null,
credits: null
};
+
let error: string = null;
let coupon: string = '';
const dispatch = createEventDispatcher();
async function addCoupon() {
try {
- // const response = await sdk.forConsole.billing.getCoupon(coupon);
- const response = await sdk.forConsole.billing.getCouponAccount(coupon); //TODO: double check that this is the correct method
+ const response = await sdk.forConsole.account.getCoupon({
+ couponId: coupon
+ });
if (response.onlyNewOrgs && !isNewOrg) {
show = false;
diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts
index b062e1eb83..5dc2004946 100644
--- a/src/lib/sdk/billing.ts
+++ b/src/lib/sdk/billing.ts
@@ -100,38 +100,6 @@ export class Billing {
});
}
- async getCouponAccount(couponId: string): Promise {
- const path = `/account/coupons/${couponId}`;
- const params = {
- couponId
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'GET',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async getCoupon(couponId: string): Promise {
- const path = `/console/coupons/${couponId}`;
- const params = {
- couponId
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'GET',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
async setBillingAddress(
organizationId: string,
billingAddressId: string
diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts
index aa392813c1..a3e2d5ae9f 100644
--- a/src/lib/stores/billing.ts
+++ b/src/lib/stores/billing.ts
@@ -588,7 +588,9 @@ export async function checkForNewDevUpgradePro(org: Models.Organization) {
if (organizations?.total) return;
try {
- await sdk.forConsole.billing.getCouponAccount(NEW_DEV_PRO_UPGRADE_COUPON);
+ await sdk.forConsole.console.getCoupon({
+ couponId: NEW_DEV_PRO_UPGRADE_COUPON
+ });
} catch (error) {
if (
// already utilized if error is 409
diff --git a/src/routes/(console)/apply-credit/+page.svelte b/src/routes/(console)/apply-credit/+page.svelte
index 8826df7032..a21b284472 100644
--- a/src/routes/(console)/apply-credit/+page.svelte
+++ b/src/routes/(console)/apply-credit/+page.svelte
@@ -212,8 +212,10 @@
async function addCoupon() {
try {
- const response = await sdk.forConsole.billing.getCouponAccount(coupon);
- couponData = response;
+ couponData = await sdk.forConsole.console.getCoupon({
+ couponId: coupon
+ });
+
coupon = null;
addNotification({
type: 'success',
diff --git a/src/routes/(console)/apply-credit/+page.ts b/src/routes/(console)/apply-credit/+page.ts
index b0af3755b8..998895e60c 100644
--- a/src/routes/(console)/apply-credit/+page.ts
+++ b/src/routes/(console)/apply-credit/+page.ts
@@ -10,7 +10,9 @@ export const load = async ({ url }) => {
let campaign: Models.Campaign;
const code = url.searchParams.get('code');
try {
- couponData = await sdk.forConsole.billing.getCouponAccount(code);
+ couponData = await sdk.forConsole.console.getCoupon({
+ couponId: code
+ });
if (couponData.campaign) {
campaign = await sdk.forConsole.console.getCampaign({
campaignId: couponData.campaign
diff --git a/src/routes/(console)/create-organization/+page.svelte b/src/routes/(console)/create-organization/+page.svelte
index 549275b47c..565b2a7ac7 100644
--- a/src/routes/(console)/create-organization/+page.svelte
+++ b/src/routes/(console)/create-organization/+page.svelte
@@ -48,7 +48,9 @@
if (page.url.searchParams.has('coupon')) {
const coupon = page.url.searchParams.get('coupon');
try {
- selectedCoupon = await sdk.forConsole.billing.getCouponAccount(coupon);
+ selectedCoupon = await sdk.forConsole.console.getCoupon({
+ couponId: coupon
+ });
} catch (e) {
selectedCoupon = {
code: null,
diff --git a/src/routes/(console)/create-organization/+page.ts b/src/routes/(console)/create-organization/+page.ts
index e227824765..cef662708f 100644
--- a/src/routes/(console)/create-organization/+page.ts
+++ b/src/routes/(console)/create-organization/+page.ts
@@ -46,7 +46,9 @@ async function getCoupon(url: URL): Promise {
if (url.searchParams.has('code')) {
const coupon = url.searchParams.get('code');
try {
- return sdk.forConsole.billing.getCouponAccount(coupon);
+ return sdk.forConsole.account.getCoupon({
+ couponId: coupon
+ });
} catch (e) {
return null;
}
diff --git a/src/routes/(console)/organization-[organization]/billing/wizard/addCredit.svelte b/src/routes/(console)/organization-[organization]/billing/wizard/addCredit.svelte
index a742291477..99ece582a8 100644
--- a/src/routes/(console)/organization-[organization]/billing/wizard/addCredit.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/wizard/addCredit.svelte
@@ -7,18 +7,20 @@
import { addCreditWizardStore } from '../store';
import type { Models } from '@appwrite.io/console';
- let coupon: string;
export let couponData: Partial = {
code: null,
status: null,
credits: null
};
+ let coupon: string;
+
async function validateCoupon() {
if (couponData?.status === 'active') return;
try {
- const response = await sdk.forConsole.billing.getCouponAccount(coupon);
- couponData = response;
+ couponData = await sdk.forConsole.account.getCoupon({
+ couponId: coupon
+ });
$addCreditWizardStore.coupon = coupon;
coupon = null;
} catch (error) {
diff --git a/src/routes/(console)/organization-[organization]/change-plan/+page.svelte b/src/routes/(console)/organization-[organization]/change-plan/+page.svelte
index 19aecaa2b4..af6a48b78f 100644
--- a/src/routes/(console)/organization-[organization]/change-plan/+page.svelte
+++ b/src/routes/(console)/organization-[organization]/change-plan/+page.svelte
@@ -78,7 +78,9 @@
const couponCode = params.get('code');
if (couponCode) {
try {
- selectedCoupon = await sdk.forConsole.billing.getCouponAccount(couponCode);
+ selectedCoupon = await sdk.forConsole.account.getCoupon({
+ couponId: couponCode
+ });
} catch {
selectedCoupon = { code: null, status: null, credits: null };
}
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index 67ff7e955d..ce32145cf5 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -68,7 +68,11 @@
if (page.url.searchParams.has('code')) {
const code = page.url.searchParams.get('code');
- const coupon = await sdk.forConsole.billing.getCoupon(code).catch(() => null);
+ const coupon = await sdk.forConsole.console
+ .getCoupon({
+ couponId: code
+ })
+ .catch(() => null);
if (coupon?.campaign) {
const campaign = await sdk.forConsole.console
.getCampaign({ campaignId: coupon.campaign })
From 7fc29aefcc39132ce33df6c222f0a14fc735782f Mon Sep 17 00:00:00 2001
From: Darshan
Date: Fri, 19 Dec 2025 14:32:51 +0530
Subject: [PATCH 26/27] refactor: remove `billingAddress`, `tax`, `orgPayment`
hardcoded method and its usages.
---
src/lib/sdk/billing.ts | 93 -------------------
src/lib/stores/billing.ts | 9 +-
.../account/payments/addressModal.svelte | 6 +-
.../billing/+page.ts | 7 +-
.../billing/billingAddress.svelte | 5 +-
.../billing/paymentMethods.svelte | 14 ++-
.../billing/removeAddress.svelte | 5 +-
.../billing/replaceAddress.svelte | 11 ++-
.../billing/taxId.svelte | 5 +-
9 files changed, 46 insertions(+), 109 deletions(-)
diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts
index 5dc2004946..69c69f12f7 100644
--- a/src/lib/sdk/billing.ts
+++ b/src/lib/sdk/billing.ts
@@ -100,99 +100,6 @@ export class Billing {
});
}
- async setBillingAddress(
- organizationId: string,
- billingAddressId: string
- ): Promise {
- const path = `/organizations/${organizationId}/billing-address`;
- const params = {
- organizationId,
- billingAddressId
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'PATCH',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async removeBillingAddress(organizationId: string): Promise {
- const path = `/organizations/${organizationId}/billing-address`;
- 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 updateTaxId(organizationId: string, taxId: string): Promise {
- const path = `/organizations/${organizationId}/taxId`;
- const params = {
- organizationId,
- taxId
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'PATCH',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async getOrganizationPaymentMethod(
- organizationId: string,
- paymentMethodId: string
- ): Promise {
- const path = `/organizations/${organizationId}/payment-methods/${paymentMethodId}`;
- const params = {
- organizationId,
- paymentMethodId
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'GET',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async getOrganizationBillingAddress(
- organizationId: string,
- billingAddressId: string
- ): Promise {
- const path = `/organizations/${organizationId}/billing-addresses/${billingAddressId}`;
- const params = {
- organizationId,
- billingAddressId
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'GET',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
//ACCOUNT
async listPaymentMethods(queries: [] = []): Promise {
diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts
index a3e2d5ae9f..e3f373699c 100644
--- a/src/lib/stores/billing.ts
+++ b/src/lib/stores/billing.ts
@@ -464,10 +464,11 @@ export async function checkPaymentAuthorizationRequired(org: Models.Organization
export async function paymentExpired(org: Models.Organization) {
if (!org?.paymentMethodId) return;
- const payment = await sdk.forConsole.billing.getOrganizationPaymentMethod(
- org.$id,
- org.paymentMethodId
- );
+ const payment = await sdk.forConsole.organizations.getPaymentMethod({
+ organizationId: org.$id,
+ paymentMethodId: org.paymentMethodId
+ });
+
if (!payment?.expiryYear) return;
const sessionStorageNotification = sessionStorage.getItem('expiredPaymentNotification');
if (sessionStorageNotification === 'true') return;
diff --git a/src/routes/(console)/account/payments/addressModal.svelte b/src/routes/(console)/account/payments/addressModal.svelte
index 4749c3bae3..eea85847c3 100644
--- a/src/routes/(console)/account/payments/addressModal.svelte
+++ b/src/routes/(console)/account/payments/addressModal.svelte
@@ -50,10 +50,14 @@
zip ? zip : undefined,
address2 ? address2 : undefined
);
+
trackEvent(Submit.BillingAddressCreate);
let org: Models.Organization = null;
if (organization) {
- org = await sdk.forConsole.billing.setBillingAddress(organization, response.$id);
+ org = await sdk.forConsole.organizations.setBillingAddress({
+ organizationId: organization,
+ billingAddressId: response.$id
+ });
trackEvent(Submit.OrganizationBillingAddressUpdate);
await invalidate(Dependencies.ORGANIZATIONS);
}
diff --git a/src/routes/(console)/organization-[organization]/billing/+page.ts b/src/routes/(console)/organization-[organization]/billing/+page.ts
index a787a678f5..d343e4076b 100644
--- a/src/routes/(console)/organization-[organization]/billing/+page.ts
+++ b/src/routes/(console)/organization-[organization]/billing/+page.ts
@@ -30,8 +30,11 @@ export const load: PageLoad = async ({ parent, depends, url, route }) => {
const billingAddressId = (organization as Models.Organization)?.billingAddressId;
const billingAddressPromise: Promise = billingAddressId
- ? sdk.forConsole.billing
- .getOrganizationBillingAddress(organization.$id, billingAddressId)
+ ? sdk.forConsole.organizations
+ .getBillingAddress({
+ organizationId: organization.$id,
+ billingAddressId
+ })
.catch(() => null)
: null;
diff --git a/src/routes/(console)/organization-[organization]/billing/billingAddress.svelte b/src/routes/(console)/organization-[organization]/billing/billingAddress.svelte
index 59f96534ed..ebecd52319 100644
--- a/src/routes/(console)/organization-[organization]/billing/billingAddress.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/billingAddress.svelte
@@ -34,7 +34,10 @@
async function addAddress(addressId: string) {
try {
- await sdk.forConsole.billing.setBillingAddress(organization.$id, addressId);
+ await sdk.forConsole.organizations.setBillingAddress({
+ organizationId: organization.$id,
+ billingAddressId: addressId
+ });
addNotification({
type: 'success',
diff --git a/src/routes/(console)/organization-[organization]/billing/paymentMethods.svelte b/src/routes/(console)/organization-[organization]/billing/paymentMethods.svelte
index 76de7a5d55..82f9df979e 100644
--- a/src/routes/(console)/organization-[organization]/billing/paymentMethods.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/paymentMethods.svelte
@@ -86,14 +86,20 @@
}
$: if (organization?.backupPaymentMethodId) {
- sdk.forConsole.billing
- .getOrganizationPaymentMethod(organization.$id, organization.backupPaymentMethodId)
+ sdk.forConsole.organizations
+ .getPaymentMethod({
+ organizationId: organization.$id,
+ paymentMethodId: organization.backupPaymentMethodId
+ })
.then((res) => (backupPaymentMethod = res));
}
$: if (organization?.paymentMethodId) {
- sdk.forConsole.billing
- .getOrganizationPaymentMethod(organization.$id, organization.paymentMethodId)
+ sdk.forConsole.organizations
+ .getPaymentMethod({
+ organizationId: organization.$id,
+ paymentMethodId: organization.paymentMethodId
+ })
.then((res) => (defaultPaymentMethod = res));
}
diff --git a/src/routes/(console)/organization-[organization]/billing/removeAddress.svelte b/src/routes/(console)/organization-[organization]/billing/removeAddress.svelte
index 0a913b851b..52359ad2c1 100644
--- a/src/routes/(console)/organization-[organization]/billing/removeAddress.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/removeAddress.svelte
@@ -14,7 +14,10 @@
async function removeAddress() {
try {
- await sdk.forConsole.billing.removeBillingAddress($organization.$id);
+ await sdk.forConsole.organizations.deleteBillingAddress({
+ organizationId: $organization.$id
+ });
+
addNotification({
type: 'success',
message: `The billing address has been removed from ${$organization.name}`
diff --git a/src/routes/(console)/organization-[organization]/billing/replaceAddress.svelte b/src/routes/(console)/organization-[organization]/billing/replaceAddress.svelte
index 46e3df440b..470f2dbdf9 100644
--- a/src/routes/(console)/organization-[organization]/billing/replaceAddress.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/replaceAddress.svelte
@@ -71,7 +71,11 @@
postalCode ? postalCode : undefined,
addressLine2 ? postalCode : undefined
);
- await sdk.forConsole.billing.setBillingAddress($organization.$id, address.$id);
+
+ await sdk.forConsole.organizations.setBillingAddress({
+ organizationId: $organization.$id,
+ billingAddressId: address.$id
+ });
invalidate(Dependencies.ORGANIZATION);
invalidate(Dependencies.ADDRESS);
@@ -86,7 +90,10 @@
message: `Your billing address has been updated`
});
} else {
- await sdk.forConsole.billing.setBillingAddress($organization.$id, selectedAddress);
+ await sdk.forConsole.organizations.setBillingAddress({
+ organizationId: $organization.$id,
+ billingAddressId: selectedAddress
+ });
invalidate(Dependencies.ORGANIZATION);
invalidate(Dependencies.ADDRESS);
diff --git a/src/routes/(console)/organization-[organization]/billing/taxId.svelte b/src/routes/(console)/organization-[organization]/billing/taxId.svelte
index bbdb664796..bef6cc8444 100644
--- a/src/routes/(console)/organization-[organization]/billing/taxId.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/taxId.svelte
@@ -17,7 +17,10 @@
async function updateTaxId() {
try {
- await sdk.forConsole.billing.updateTaxId($organization.$id, taxId);
+ await sdk.forConsole.organizations.setBillingTaxId({
+ organizationId: $organization.$id,
+ taxId
+ });
await invalidate(Dependencies.ORGANIZATION);
addNotification({
type: 'success',
From b3e040bec8be4759dc4561c20949fd2a32f0806b Mon Sep 17 00:00:00 2001
From: Darshan
Date: Fri, 19 Dec 2025 15:33:25 +0530
Subject: [PATCH 27/27] refactor: remove `accounts`, `console`, `regions` based
hardcoded methods and its usages.
---
package.json | 2 +-
pnpm-lock.yaml | 10 +-
.../billing/alerts/paymentMandate.svelte | 7 +-
src/lib/sdk/billing.ts | 283 ------------------
src/lib/stores/billing.ts | 6 +-
src/lib/stores/stripe.ts | 25 +-
src/routes/(console)/+layout.ts | 8 +-
.../(console)/account/payments/+page.ts | 4 +-
.../account/payments/addressModal.svelte | 10 +-
.../payments/deleteAddressModal.svelte | 5 +-
.../payments/deletePaymentModal.svelte | 4 +-
.../account/payments/editAddressModal.svelte | 20 +-
.../account/payments/editPaymentModal.svelte | 15 +-
.../(console)/apply-credit/+page.svelte | 2 +-
.../(console)/create-organization/+page.ts | 2 +-
.../billing/+page.ts | 4 +-
.../billing/replaceAddress.svelte | 10 +-
.../billing/retryPaymentModal.svelte | 16 +-
.../billing/wizard/paymentDetails.svelte | 2 +-
.../change-plan/+page.svelte | 2 +-
src/routes/(console)/regions.ts | 7 +-
21 files changed, 95 insertions(+), 349 deletions(-)
diff --git a/package.json b/package.json
index a82b6d54d0..50b4029dce 100644
--- a/package.json
+++ b/package.json
@@ -22,7 +22,7 @@
},
"dependencies": {
"@ai-sdk/svelte": "^1.1.24",
- "@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@18b170d",
+ "@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@7a147b9",
"@appwrite.io/pink-icons": "0.25.0",
"@appwrite.io/pink-icons-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-icons-svelte@865e2fc",
"@appwrite.io/pink-legacy": "^1.0.3",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 241ef357a7..ce01083e0f 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -12,8 +12,8 @@ importers:
specifier: ^1.1.24
version: 1.1.24(svelte@5.25.3)(zod@3.24.3)
'@appwrite.io/console':
- specifier: https://pkg.vc/-/@appwrite/@appwrite.io/console@18b170d
- version: https://pkg.vc/-/@appwrite/@appwrite.io/console@18b170d
+ specifier: https://pkg.vc/-/@appwrite/@appwrite.io/console@7a147b9
+ version: https://pkg.vc/-/@appwrite/@appwrite.io/console@7a147b9
'@appwrite.io/pink-icons':
specifier: 0.25.0
version: 0.25.0
@@ -272,8 +272,8 @@ packages:
'@analytics/type-utils@0.6.2':
resolution: {integrity: sha512-TD+xbmsBLyYy/IxFimW/YL/9L2IEnM7/EoV9Aeh56U64Ify8o27HJcKjo38XY9Tcn0uOq1AX3thkKgvtWvwFQg==}
- '@appwrite.io/console@https://pkg.vc/-/@appwrite/@appwrite.io/console@18b170d':
- resolution: {tarball: https://pkg.vc/-/@appwrite/@appwrite.io/console@18b170d}
+ '@appwrite.io/console@https://pkg.vc/-/@appwrite/@appwrite.io/console@7a147b9':
+ resolution: {tarball: https://pkg.vc/-/@appwrite/@appwrite.io/console@7a147b9}
version: 1.10.0
'@appwrite.io/pink-icons-svelte@2.0.0-RC.1':
@@ -3823,7 +3823,7 @@ snapshots:
'@analytics/type-utils@0.6.2': {}
- '@appwrite.io/console@https://pkg.vc/-/@appwrite/@appwrite.io/console@18b170d': {}
+ '@appwrite.io/console@https://pkg.vc/-/@appwrite/@appwrite.io/console@7a147b9': {}
'@appwrite.io/pink-icons-svelte@2.0.0-RC.1(svelte@5.25.3)':
dependencies:
diff --git a/src/lib/components/billing/alerts/paymentMandate.svelte b/src/lib/components/billing/alerts/paymentMandate.svelte
index 08d9207d73..0126f2f9a0 100644
--- a/src/lib/components/billing/alerts/paymentMandate.svelte
+++ b/src/lib/components/billing/alerts/paymentMandate.svelte
@@ -8,10 +8,9 @@
import { confirmSetup } from '$lib/stores/stripe';
async function verifyPaymentMethod() {
- const method = await sdk.forConsole.billing.setupPaymentMandate(
- $organization.$id,
- $paymentMissingMandate.$id
- );
+ const method = await sdk.forConsole.account.updatePaymentMethodMandateOptions({
+ paymentMethodId: $paymentMissingMandate.$id
+ });
await confirmSetup(method.clientSecret, method.providerMethodId);
}
diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts
index 69c69f12f7..aa2422bc95 100644
--- a/src/lib/sdk/billing.ts
+++ b/src/lib/sdk/billing.ts
@@ -1,6 +1,5 @@
import type { Client, Models } from '@appwrite.io/console';
import type { OrganizationError } from '../stores/organization';
-import type { PaymentMethod as StripePaymentMethod } from '@stripe/stripe-js';
export type AllowedRegions =
| 'fra'
@@ -99,286 +98,4 @@ export class Billing {
'content-type': 'application/json'
});
}
-
- //ACCOUNT
-
- async listPaymentMethods(queries: [] = []): Promise {
- const path = `/account/payment-methods`;
- const params = {
- queries
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'GET',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async getPaymentMethod(paymentMethodId: string): Promise {
- const path = `/account/payment-methods/${paymentMethodId}`;
- const params = {
- paymentMethodId
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'GET',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async createPaymentMethod(): Promise {
- const path = `/account/payment-methods`;
- const params = {};
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'POST',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async setPaymentMethod(
- paymentMethodId: string,
- providerMethodId: string | StripePaymentMethod,
- name: string,
- state: string | undefined = undefined
- ): Promise {
- const path = `/account/payment-methods/${paymentMethodId}/provider`;
- const params = {
- paymentMethodId,
- providerMethodId,
- name
- };
-
- if (state !== undefined) {
- params['state'] = state;
- }
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'patch',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async updatePaymentMethod(
- paymentMethodId: string,
- expiryMonth: string,
- expiryYear: string
- ): Promise {
- const path = `/account/payment-methods/${paymentMethodId}`;
- const params = {
- paymentMethodId,
- expiryMonth,
- expiryYear
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'patch',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async deletePaymentMethod(paymentMethodId: string): Promise {
- const path = `/account/payment-methods/${paymentMethodId}`;
- const params = {
- paymentMethodId
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'delete',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
- async setDefaultPaymentMethod(paymentMethodId: string): Promise {
- const path = `/account/payment-methods/${paymentMethodId}/default`;
- const params = {
- paymentMethodId
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'patch',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async setupPaymentMandate(
- organizationId: string,
- paymentMethodId: string
- ): Promise {
- const path = `/account/payment-methods/${paymentMethodId}/setup`;
- const params = {
- organizationId,
- paymentMethodId
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'patch',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async listAddresses(queries: string[] = []): Promise {
- const path = `/account/billing-addresses`;
- const params = {
- queries
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'get',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async getAddress(billingAddressId: string): Promise {
- const path = `/account/billing-addresses/${billingAddressId}`;
- const params = {
- billingAddressId
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'get',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async createAddress(
- country: string,
- streetAddress: string,
- city: string,
- state: string,
- postalCode: string,
- addressLine2?: string
- ): Promise {
- const path = `/account/billing-addresses`;
- const params = {
- country,
- streetAddress,
- city,
- state,
- postalCode,
- addressLine2
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'POST',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
- async updateAddress(
- billingAddressId: string,
- country: string,
- streetAddress: string,
- city: string,
- state: string,
- postalCode: string,
- addressLine2?: string
- ): Promise {
- const path = `/account/billing-addresses/${billingAddressId}`;
- const params = {
- billingAddressId,
- country,
- streetAddress,
- city,
- state,
- postalCode,
- addressLine2
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'PUT',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
- async deleteAddress(billingAddressId: string): Promise {
- const path = `/account/billing-addresses/${billingAddressId}`;
- const params = {
- billingAddressId
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'delete',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async listRegions(teamId: string): Promise {
- const path = `/console/regions`;
- const params = {
- teamId
- };
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'GET',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
-
- async getPlansInfo(): Promise {
- const path = `/console/plans`;
- const params = {};
- const uri = new URL(this.client.config.endpoint + path);
- return await this.client.call(
- 'GET',
- uri,
- {
- 'content-type': 'application/json'
- },
- params
- );
- }
}
diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts
index e3f373699c..06c4d13fdd 100644
--- a/src/lib/stores/billing.ts
+++ b/src/lib/stores/billing.ts
@@ -531,7 +531,11 @@ export const paymentMissingMandate = writable(null);
export async function checkForMandate(org: Models.Organization) {
const paymentId = org.paymentMethodId ?? org.backupPaymentMethodId;
if (!paymentId) return;
- const paymentMethod = await sdk.forConsole.billing.getPaymentMethod(paymentId);
+
+ const paymentMethod = await sdk.forConsole.account.getPaymentMethod({
+ paymentMethodId: paymentId
+ });
+
if (paymentMethod?.mandateId === null && paymentMethod?.country.toLowerCase() === 'in') {
headerAlert.add({
id: 'paymentMandate',
diff --git a/src/lib/stores/stripe.ts b/src/lib/stores/stripe.ts
index cda0bf776c..11797553bf 100644
--- a/src/lib/stores/stripe.ts
+++ b/src/lib/stores/stripe.ts
@@ -32,7 +32,7 @@ export async function initializeStripe(node: HTMLElement) {
isStripeInitialized.set(true);
- const methods = await sdk.forConsole.billing.listPaymentMethods();
+ const methods = await sdk.forConsole.account.listPaymentMethods();
// Get the client secret from empty payment method if available
clientSecret = methods.paymentMethods?.filter(
@@ -41,7 +41,7 @@ export async function initializeStripe(node: HTMLElement) {
// If there is no payment method, create an empty one and get the client secret
if (!clientSecret) {
- paymentMethod = await sdk.forConsole.billing.createPaymentMethod();
+ paymentMethod = await sdk.forConsole.account.createPaymentMethod();
clientSecret = paymentMethod.clientSecret;
}
@@ -78,7 +78,7 @@ export async function submitStripeCard(name: string, organizationId?: string) {
try {
// If a payment method was created during initialization, use it, otherwise create a new one
if (!paymentMethod) {
- paymentMethod = await sdk.forConsole.billing.createPaymentMethod();
+ paymentMethod = await sdk.forConsole.account.createPaymentMethod();
clientSecret = paymentMethod.clientSecret;
}
@@ -139,11 +139,12 @@ export async function submitStripeCard(name: string, organizationId?: string) {
throw e;
}
- const method = await sdk.forConsole.billing.setPaymentMethod(
- paymentMethod.$id,
- providerId,
+ const method = await sdk.forConsole.account.updatePaymentMethodProvider({
+ paymentMethodId: paymentMethod.$id,
+ providerMethodId: providerId,
name
- );
+ });
+
paymentElement.destroy();
isStripeInitialized.set(false);
trackEvent(Submit.PaymentMethodCreate);
@@ -169,12 +170,12 @@ export async function setPaymentMethod(providerMethodId: string, name: string, s
return;
}
try {
- const method = await sdk.forConsole.billing.setPaymentMethod(
- paymentMethod.$id,
- providerMethodId,
+ const method = await sdk.forConsole.account.updatePaymentMethodProvider({
+ paymentMethodId: paymentMethod.$id,
+ providerMethodId: providerMethodId,
name,
state
- );
+ });
paymentElement.destroy();
isStripeInitialized.set(false);
trackEvent(Submit.PaymentMethodCreate);
@@ -195,7 +196,7 @@ export async function confirmPayment(
const url =
window.location.origin + (route ? route : `${base}/organization-${orgId}/billing`);
- const paymentMethod = await sdk.forConsole.billing.getPaymentMethod(paymentMethodId);
+ const paymentMethod = await sdk.forConsole.account.getPaymentMethod({ paymentMethodId });
const { error } = await get(stripe).confirmPayment({
clientSecret: clientSecret,
diff --git a/src/routes/(console)/+layout.ts b/src/routes/(console)/+layout.ts
index 5ce52a00cb..a17602f259 100644
--- a/src/routes/(console)/+layout.ts
+++ b/src/routes/(console)/+layout.ts
@@ -2,7 +2,7 @@ import { sdk } from '$lib/stores/sdk';
import { isCloud } from '$lib/system';
import type { LayoutLoad } from './$types';
import { Dependencies } from '$lib/constants';
-import { type Models, Query } from '@appwrite.io/console';
+import { type Models, Platform, Query } from '@appwrite.io/console';
export const load: LayoutLoad = async ({ depends, parent }) => {
const { organizations } = await parent();
@@ -14,7 +14,11 @@ export const load: LayoutLoad = async ({ depends, parent }) => {
const { endpoint, project } = sdk.forConsole.client.config;
const [preferences, plansArray, versionData, consoleVariables] = await Promise.all([
sdk.forConsole.account.getPrefs(),
- isCloud ? sdk.forConsole.billing.getPlansInfo() : null,
+ isCloud
+ ? sdk.forConsole.console.getPlans({
+ platform: Platform.Appwrite
+ })
+ : null,
fetch(`${endpoint}/health/version`, {
headers: { 'X-Appwrite-Project': project }
}).then((response) => response.json() as { version?: string }),
diff --git a/src/routes/(console)/account/payments/+page.ts b/src/routes/(console)/account/payments/+page.ts
index b275a6e9b5..fb0cb2d96d 100644
--- a/src/routes/(console)/account/payments/+page.ts
+++ b/src/routes/(console)/account/payments/+page.ts
@@ -7,8 +7,8 @@ export const load: PageLoad = async ({ depends }) => {
depends(Dependencies.ADDRESS);
const [paymentMethods, addressList, countryList, locale] = await Promise.all([
- sdk.forConsole.billing.listPaymentMethods(),
- sdk.forConsole.billing.listAddresses(),
+ sdk.forConsole.account.listPaymentMethods(),
+ sdk.forConsole.account.listBillingAddresses(),
sdk.forConsole.locale.listCountries(),
sdk.forConsole.locale.get()
]);
diff --git a/src/routes/(console)/account/payments/addressModal.svelte b/src/routes/(console)/account/payments/addressModal.svelte
index eea85847c3..57ea22c101 100644
--- a/src/routes/(console)/account/payments/addressModal.svelte
+++ b/src/routes/(console)/account/payments/addressModal.svelte
@@ -42,14 +42,14 @@
async function handleSubmit() {
try {
- const response = await sdk.forConsole.billing.createAddress(
+ const response = await sdk.forConsole.account.createBillingAddress({
country,
- address,
+ streetAddress: address,
city,
state,
- zip ? zip : undefined,
- address2 ? address2 : undefined
- );
+ postalCode: zip ? zip : undefined,
+ addressLine2: address2 ? address2 : undefined
+ });
trackEvent(Submit.BillingAddressCreate);
let org: Models.Organization = null;
diff --git a/src/routes/(console)/account/payments/deleteAddressModal.svelte b/src/routes/(console)/account/payments/deleteAddressModal.svelte
index e90c240607..9f267daabb 100644
--- a/src/routes/(console)/account/payments/deleteAddressModal.svelte
+++ b/src/routes/(console)/account/payments/deleteAddressModal.svelte
@@ -17,7 +17,10 @@
async function handleDelete() {
try {
- await sdk.forConsole.billing.deleteAddress(selectedAddress.$id);
+ await sdk.forConsole.account.deleteBillingAddress({
+ billingAddressId: selectedAddress.$id
+ });
+
await invalidate(Dependencies.PAYMENT_METHODS);
showDelete = false;
addNotification({
diff --git a/src/routes/(console)/account/payments/deletePaymentModal.svelte b/src/routes/(console)/account/payments/deletePaymentModal.svelte
index d5e8e01f22..613db91617 100644
--- a/src/routes/(console)/account/payments/deletePaymentModal.svelte
+++ b/src/routes/(console)/account/payments/deletePaymentModal.svelte
@@ -17,7 +17,9 @@
async function handleDelete() {
try {
- await sdk.forConsole.billing.deletePaymentMethod(method);
+ await sdk.forConsole.account.deletePaymentMethod({
+ paymentMethodId: method
+ });
await invalidate(Dependencies.PAYMENT_METHODS);
showDelete = false;
addNotification({
diff --git a/src/routes/(console)/account/payments/editAddressModal.svelte b/src/routes/(console)/account/payments/editAddressModal.svelte
index 1a12a54d66..c77d0224a6 100644
--- a/src/routes/(console)/account/payments/editAddressModal.svelte
+++ b/src/routes/(console)/account/payments/editAddressModal.svelte
@@ -33,15 +33,17 @@
async function handleSubmit() {
try {
- await sdk.forConsole.billing.updateAddress(
- selectedAddress.$id,
- selectedAddress.country,
- selectedAddress.streetAddress,
- selectedAddress.city,
- selectedAddress.state,
- selectedAddress.postalCode ? selectedAddress.postalCode : undefined,
- selectedAddress.addressLine2 ? selectedAddress.addressLine2 : undefined
- );
+ await sdk.forConsole.account.updateBillingAddress({
+ billingAddressId: selectedAddress.$id,
+ country: selectedAddress.country,
+ streetAddress: selectedAddress.streetAddress,
+ city: selectedAddress.city,
+ state: selectedAddress.state,
+ postalCode: selectedAddress.postalCode ? selectedAddress.postalCode : undefined,
+ addressLine2: selectedAddress.addressLine2
+ ? selectedAddress.addressLine2
+ : undefined
+ });
await invalidate(Dependencies.ADDRESS);
show = false;
addNotification({
diff --git a/src/routes/(console)/account/payments/editPaymentModal.svelte b/src/routes/(console)/account/payments/editPaymentModal.svelte
index 5b1145f686..fd63c1e1d5 100644
--- a/src/routes/(console)/account/payments/editPaymentModal.svelte
+++ b/src/routes/(console)/account/payments/editPaymentModal.svelte
@@ -10,20 +10,23 @@
import type { Models } from '@appwrite.io/console';
export let show = false;
- export let selectedPaymentMethod: Models.PaymentMethod;
export let isLinked = false;
+ export let selectedPaymentMethod: Models.PaymentMethod;
+
const currentYear = new Date().getFullYear();
+
let error: string;
let month: string;
let year: number;
async function handleSubmit() {
try {
- await sdk.forConsole.billing.updatePaymentMethod(
- selectedPaymentMethod.$id,
- month,
- year?.toString()
- );
+ await sdk.forConsole.account.updatePaymentMethod({
+ paymentMethodId: selectedPaymentMethod.$id,
+ expiryMonth: parseInt(month),
+ expiryYear: year
+ });
+
trackEvent(Submit.PaymentMethodUpdate);
invalidate(Dependencies.PAYMENT_METHODS);
show = false;
diff --git a/src/routes/(console)/apply-credit/+page.svelte b/src/routes/(console)/apply-credit/+page.svelte
index a21b284472..a033dbc44a 100644
--- a/src/routes/(console)/apply-credit/+page.svelte
+++ b/src/routes/(console)/apply-credit/+page.svelte
@@ -113,7 +113,7 @@
});
async function loadPaymentMethods() {
- const methodList = await sdk.forConsole.billing.listPaymentMethods();
+ const methodList = await sdk.forConsole.account.listPaymentMethods();
const filteredMethods = methodList.paymentMethods.filter((method) => !!method?.last4);
methods = { paymentMethods: filteredMethods, total: filteredMethods.length };
paymentMethodId =
diff --git a/src/routes/(console)/create-organization/+page.ts b/src/routes/(console)/create-organization/+page.ts
index cef662708f..2f780b2859 100644
--- a/src/routes/(console)/create-organization/+page.ts
+++ b/src/routes/(console)/create-organization/+page.ts
@@ -8,7 +8,7 @@ export const load: PageLoad = async ({ url, parent, depends }) => {
depends(Dependencies.ORGANIZATIONS);
const [coupon, paymentMethods, plans] = await Promise.all([
getCoupon(url),
- sdk.forConsole.billing.listPaymentMethods(),
+ sdk.forConsole.account.listPaymentMethods(),
sdk.forConsole.console.getPlans({
platform: Platform.Appwrite
})
diff --git a/src/routes/(console)/organization-[organization]/billing/+page.ts b/src/routes/(console)/organization-[organization]/billing/+page.ts
index d343e4076b..bbc531fe16 100644
--- a/src/routes/(console)/organization-[organization]/billing/+page.ts
+++ b/src/routes/(console)/organization-[organization]/billing/+page.ts
@@ -76,8 +76,8 @@ export const load: PageLoad = async ({ parent, depends, url, route }) => {
const [paymentMethods, addressList, billingAddress, availableCredit, billingPlanDowngrade] =
await Promise.all([
- sdk.forConsole.billing.listPaymentMethods(),
- sdk.forConsole.billing.listAddresses(),
+ sdk.forConsole.account.listPaymentMethods(),
+ sdk.forConsole.account.listBillingAddresses(),
billingAddressPromise,
areCreditsSupported
? sdk.forConsole.organizations.getAvailableCredits({
diff --git a/src/routes/(console)/organization-[organization]/billing/replaceAddress.svelte b/src/routes/(console)/organization-[organization]/billing/replaceAddress.svelte
index 470f2dbdf9..9fd9c7ff69 100644
--- a/src/routes/(console)/organization-[organization]/billing/replaceAddress.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/replaceAddress.svelte
@@ -35,7 +35,7 @@
onMount(async () => {
loading = true;
- addresses = await sdk.forConsole.billing.listAddresses();
+ addresses = await sdk.forConsole.account.listBillingAddresses();
const firstNonCurrentAddress = addresses?.billingAddresses?.find(
(address) => address.$id !== $organization?.billingAddressId
@@ -63,14 +63,14 @@
if (selectedAddress === $organization.billingAddressId) {
show = false;
} else if (selectedAddress === '$new') {
- const address = await sdk.forConsole.billing.createAddress(
+ const address = await sdk.forConsole.account.createBillingAddress({
country,
streetAddress,
city,
state,
- postalCode ? postalCode : undefined,
- addressLine2 ? postalCode : undefined
- );
+ postalCode: postalCode ? postalCode : undefined,
+ addressLine2: addressLine2 ? postalCode : undefined
+ });
await sdk.forConsole.organizations.setBillingAddress({
organizationId: $organization.$id,
diff --git a/src/routes/(console)/organization-[organization]/billing/retryPaymentModal.svelte b/src/routes/(console)/organization-[organization]/billing/retryPaymentModal.svelte
index a13e7c31c7..13cbf9fd0f 100644
--- a/src/routes/(console)/organization-[organization]/billing/retryPaymentModal.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/retryPaymentModal.svelte
@@ -81,7 +81,11 @@
method = card as Models.PaymentMethod;
}
}
- const card = await sdk.forConsole.billing.getPaymentMethod(method.$id);
+
+ const card = await sdk.forConsole.account.getPaymentMethod({
+ paymentMethodId: method.$id
+ });
+
if (card?.last4) {
paymentMethodId = card.$id;
} else {
@@ -89,15 +93,21 @@
'The payment method you selected is not valid. Please select a different one.'
);
}
- invalidate(Dependencies.PAYMENT_METHODS);
+
+ await invalidate(Dependencies.PAYMENT_METHODS);
} catch (e) {
paymentMethodId = $organization.paymentMethodId;
error = e.message;
}
}
+
if (setAsDefault) {
- await sdk.forConsole.billing.setDefaultPaymentMethod(paymentMethodId);
+ await sdk.forConsole.organizations.setDefaultPaymentMethod({
+ organizationId: $organization.$id,
+ paymentMethodId
+ });
}
+
const { clientSecret, status } =
await sdk.forConsole.organizations.createInvoicePayment({
organizationId: $organization.$id,
diff --git a/src/routes/(console)/organization-[organization]/billing/wizard/paymentDetails.svelte b/src/routes/(console)/organization-[organization]/billing/wizard/paymentDetails.svelte
index 7ee8a49b65..b81384e00a 100644
--- a/src/routes/(console)/organization-[organization]/billing/wizard/paymentDetails.svelte
+++ b/src/routes/(console)/organization-[organization]/billing/wizard/paymentDetails.svelte
@@ -18,7 +18,7 @@
let paymentMethod: StripePaymentMethod | null = null;
onMount(async () => {
- methods = await sdk.forConsole.billing.listPaymentMethods();
+ methods = await sdk.forConsole.account.listPaymentMethods();
$addCreditWizardStore.paymentMethodId =
methods.paymentMethods.find((method) => !!method?.last4)?.$id ?? null;
});
diff --git a/src/routes/(console)/organization-[organization]/change-plan/+page.svelte b/src/routes/(console)/organization-[organization]/change-plan/+page.svelte
index af6a48b78f..6e70d3f830 100644
--- a/src/routes/(console)/organization-[organization]/change-plan/+page.svelte
+++ b/src/routes/(console)/organization-[organization]/change-plan/+page.svelte
@@ -118,7 +118,7 @@
});
async function loadPaymentMethods() {
- paymentMethods = await sdk.forConsole.billing.listPaymentMethods();
+ paymentMethods = await sdk.forConsole.account.listPaymentMethods();
return paymentMethods;
}
diff --git a/src/routes/(console)/regions.ts b/src/routes/(console)/regions.ts
index 32dbd0308e..404ee92096 100644
--- a/src/routes/(console)/regions.ts
+++ b/src/routes/(console)/regions.ts
@@ -21,10 +21,11 @@ export async function loadAvailableRegions(orgId: string, force: boolean = false
return;
}
- // TODO: @itznotabug, @torstendittmann we need a better way for this!
- const availableRegions = await sdk.forConsole.billing.listRegions(orgId);
- regions.set(availableRegions);
+ const availableRegions = await sdk.forConsole.console.getRegions({
+ organizationId: orgId
+ });
+ regions.set(availableRegions);
lastLoadedOrganization = orgId;
} catch (error) {
console.error(`Failed to load regions for teamId: ${orgId}`, error);