From 3ce90545a809e469db3846f7974fa3fed4667bdd Mon Sep 17 00:00:00 2001 From: Darshan Date: Thu, 27 Nov 2025 13:37:46 +0530 Subject: [PATCH 1/2] update: filtering. --- package.json | 2 +- pnpm-lock.yaml | 10 +++++----- src/lib/stores/billing.ts | 4 ++-- src/routes/(console)/account/organizations/+page.ts | 4 ++-- .../domains/domain-[domain]/settings/+page.ts | 6 ++++-- src/routes/(public)/functions/deploy/+page.ts | 6 +++--- src/routes/(public)/sites/deploy/+page.ts | 6 +++--- src/routes/(public)/template-[template]/+page.ts | 6 ++++-- src/routes/+layout.ts | 4 ++-- 9 files changed, 26 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index 1c916e1814..3b93e02b5a 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@acef319", + "@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@406d8be", "@appwrite.io/pink-icons": "0.25.0", "@appwrite.io/pink-icons-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-icons-svelte@6916470", "@appwrite.io/pink-legacy": "^1.0.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1724be8386..c83e8b3c49 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@acef319 - version: https://pkg.vc/-/@appwrite/@appwrite.io/console@acef319 + specifier: https://pkg.vc/-/@appwrite/@appwrite.io/console@406d8be + version: https://pkg.vc/-/@appwrite/@appwrite.io/console@406d8be '@appwrite.io/pink-icons': specifier: 0.25.0 version: 0.25.0 @@ -260,8 +260,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@acef319': - resolution: {tarball: https://pkg.vc/-/@appwrite/@appwrite.io/console@acef319} + '@appwrite.io/console@https://pkg.vc/-/@appwrite/@appwrite.io/console@406d8be': + resolution: {tarball: https://pkg.vc/-/@appwrite/@appwrite.io/console@406d8be} version: 1.10.0 '@appwrite.io/pink-icons-svelte@2.0.0-RC.1': @@ -3703,7 +3703,7 @@ snapshots: '@analytics/type-utils@0.6.2': {} - '@appwrite.io/console@https://pkg.vc/-/@appwrite/@appwrite.io/console@acef319': {} + '@appwrite.io/console@https://pkg.vc/-/@appwrite/@appwrite.io/console@406d8be': {} '@appwrite.io/pink-icons-svelte@2.0.0-RC.1(svelte@5.25.3)': dependencies: diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index e2016b8c0c..695ef874c7 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -24,7 +24,7 @@ import type { } from '$lib/sdk/billing'; import { isCloud } from '$lib/system'; import { activeHeaderAlert, orgMissingPaymentMethod } from '$routes/(console)/store'; -import { AppwriteException, Query } from '@appwrite.io/console'; +import { AppwriteException, Query, Platform } from '@appwrite.io/console'; import { derived, get, writable } from 'svelte/store'; import { headerAlert } from './headerAlert'; import { addNotification, notifications } from './notifications'; @@ -558,7 +558,7 @@ export async function checkForMissingPaymentMethod() { Query.notEqual('billingPlan', BillingPlan.FREE), Query.isNull('paymentMethodId'), Query.isNull('backupPaymentMethodId'), - Query.equal('platform', 'appwrite') + Query.equal('platform', Platform.Appwrite) ]); if (orgs?.total) { orgMissingPaymentMethod.set(orgs.teams[0]); diff --git a/src/routes/(console)/account/organizations/+page.ts b/src/routes/(console)/account/organizations/+page.ts index 220e70a5da..c498951d75 100644 --- a/src/routes/(console)/account/organizations/+page.ts +++ b/src/routes/(console)/account/organizations/+page.ts @@ -1,4 +1,4 @@ -import { Query } from '@appwrite.io/console'; +import { Query, Platform } from '@appwrite.io/console'; import { sdk } from '$lib/stores/sdk'; import { getLimit, getPage, pageToOffset } from '$lib/helpers/load'; import { CARD_LIMIT } from '$lib/constants'; @@ -14,7 +14,7 @@ export const load: PageLoad = async ({ url, route }) => { Query.offset(offset), Query.limit(limit), Query.orderDesc(''), - Query.equal('platform', 'appwrite') + Query.equal('platform', Platform.Appwrite) ]; const organizations = !isCloud 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 8040bcca79..fda7fb6a2a 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,14 +1,16 @@ import { Dependencies } from '$lib/constants'; import { sdk } from '$lib/stores/sdk'; import { isCloud } from '$lib/system'; -import { Query } from '@appwrite.io/console'; +import { Query, Platform } from '@appwrite.io/console'; export const load = async ({ parent, depends }) => { depends(Dependencies.DOMAINS); const organizations = !isCloud ? await sdk.forConsole.teams.list() - : await sdk.forConsole.billing.listOrganization([Query.equal('platform', 'appwrite')]); + : await sdk.forConsole.billing.listOrganization([ + Query.equal('platform', Platform.Appwrite) + ]); const { domain } = await parent(); return { diff --git a/src/routes/(public)/functions/deploy/+page.ts b/src/routes/(public)/functions/deploy/+page.ts index 669756550f..d91d084ff8 100644 --- a/src/routes/(public)/functions/deploy/+page.ts +++ b/src/routes/(public)/functions/deploy/+page.ts @@ -3,7 +3,7 @@ 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 } from '@appwrite.io/console'; +import { ID, type Models, Query, Platform } from '@appwrite.io/console'; import type { OrganizationList } from '$lib/stores/organization'; import { redirectTo } from '$routes/store'; import type { PageLoad } from './$types'; @@ -67,7 +67,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', 'appwrite') + Query.equal('platform', Platform.Appwrite) ]); } else { organizations = await sdk.forConsole.teams.list(); @@ -91,7 +91,7 @@ export const load: PageLoad = async ({ parent, url }) => { if (isCloud) { organizations = await sdk.forConsole.billing.listOrganization([ - Query.equal('platform', 'appwrite') + Query.equal('platform', Platform.Appwrite) ]); } else { organizations = await sdk.forConsole.teams.list(); diff --git a/src/routes/(public)/sites/deploy/+page.ts b/src/routes/(public)/sites/deploy/+page.ts index 666c809e93..ca57d36e34 100644 --- a/src/routes/(public)/sites/deploy/+page.ts +++ b/src/routes/(public)/sites/deploy/+page.ts @@ -3,7 +3,7 @@ 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 } from '@appwrite.io/console'; +import { ID, type Models, Query, Platform } from '@appwrite.io/console'; import type { OrganizationList } from '$lib/stores/organization'; import { redirectTo } from '$routes/store'; import type { PageLoad } from './$types'; @@ -84,7 +84,7 @@ export const load: PageLoad = async ({ parent, url }) => { if (isCloud) { organizations = await sdk.forConsole.billing.listOrganization([ - Query.equal('platform', 'appwrite') + Query.equal('platform', Platform.Appwrite) ]); } else { organizations = await sdk.forConsole.teams.list(); @@ -109,7 +109,7 @@ export const load: PageLoad = async ({ parent, url }) => { // Refetch organizations after creation if (isCloud) { organizations = await sdk.forConsole.billing.listOrganization([ - Query.equal('platform', 'appwrite') + Query.equal('platform', Platform.Appwrite) ]); } else { organizations = await sdk.forConsole.teams.list(); diff --git a/src/routes/(public)/template-[template]/+page.ts b/src/routes/(public)/template-[template]/+page.ts index 2c4c6a5bbd..e2dac3adfa 100644 --- a/src/routes/(public)/template-[template]/+page.ts +++ b/src/routes/(public)/template-[template]/+page.ts @@ -1,6 +1,6 @@ import { BillingPlan } from '$lib/constants.js'; import { sdk } from '$lib/stores/sdk.js'; -import { ID, type Models, Query } from '@appwrite.io/console'; +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'; @@ -40,7 +40,9 @@ export const load = async ({ parent, url, params }) => { let organizations: Models.TeamList> | OrganizationList | undefined; if (isCloud) { organizations = account?.$id - ? await sdk.forConsole.billing.listOrganization([Query.equal('platform', 'appwrite')]) + ? await sdk.forConsole.billing.listOrganization([ + Query.equal('platform', Platform.Appwrite) + ]) : undefined; } else { organizations = account?.$id ? await sdk.forConsole.teams.list() : undefined; diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts index b8cc5ce030..bcd3e307ff 100644 --- a/src/routes/+layout.ts +++ b/src/routes/+layout.ts @@ -8,7 +8,7 @@ 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 } from '@appwrite.io/console'; +import { type AppwriteException, Query, Platform } from '@appwrite.io/console'; import { isCloud, VARS } from '$lib/system'; import { checkPricingRefAndRedirect } from '$lib/helpers/pricingRedirect'; @@ -43,7 +43,7 @@ export const load: LayoutLoad = async ({ depends, url, route }) => { organizations: !isCloud ? await sdk.forConsole.teams.list() : await sdk.forConsole.billing.listOrganization([ - Query.equal('platform', 'appwrite') + Query.equal('platform', Platform.Appwrite) ]) }; } From 71cad9b05949d6737b807054e7b62ec6e95b5d26 Mon Sep 17 00:00:00 2001 From: Darshan Date: Thu, 27 Nov 2025 13:45:05 +0530 Subject: [PATCH 2/2] fix: plan getter. --- .../project-[region]-[project]/+layout.ts | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/routes/(console)/project-[region]-[project]/+layout.ts b/src/routes/(console)/project-[region]-[project]/+layout.ts index 2c5c14ab86..abd85588a8 100644 --- a/src/routes/(console)/project-[region]-[project]/+layout.ts +++ b/src/routes/(console)/project-[region]-[project]/+layout.ts @@ -23,27 +23,29 @@ export const load: LayoutLoad = async ({ params, depends, parent }) => { (org) => org.$id === project.teamId ); - const includedInBasePlans = plansInfo.has(organization.billingPlan); + // organization can be null if not in the filtered list! + const includedInBasePlans = plansInfo.has(organization?.billingPlan); - const [org, regionalConsoleVariables, rolesResult, organizationPlan] = await Promise.all([ + const [org, regionalConsoleVariables, rolesResult] = await Promise.all([ !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, - // fetch if not available in `plansInfo` - includedInBasePlans - ? plansInfo.get(organization.billingPlan) - : isCloud - ? sdk.forConsole.billing.getOrganizationPlan(organization.$id) - : null, - loadAvailableRegions(project.teamId) ]); if (!organization) organization = org; + // fetch if not available in `plansInfo`. + // out of promise.all because we filter orgs based on platform now! + const organizationPlan = includedInBasePlans + ? plansInfo.get(organization?.billingPlan) + : isCloud + ? await sdk.forConsole.billing.getOrganizationPlan(organization?.$id) + : null; + const roles = rolesResult?.roles ?? defaultRoles; const scopes = rolesResult?.scopes ?? defaultScopes;