Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/lib/stores/billing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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]);
Expand Down
4 changes: 2 additions & 2 deletions src/routes/(console)/account/organizations/+page.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
20 changes: 11 additions & 9 deletions src/routes/(console)/project-[region]-[project]/+layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>)
: 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;

Expand Down
6 changes: 3 additions & 3 deletions src/routes/(public)/functions/deploy/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -67,7 +67,7 @@ export const load: PageLoad = async ({ parent, url }) => {
let organizations: Models.TeamList<Record<string, unknown>> | 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();
Expand All @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/routes/(public)/sites/deploy/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down
6 changes: 4 additions & 2 deletions src/routes/(public)/template-[template]/+page.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -40,7 +40,9 @@ export const load = async ({ parent, url, params }) => {
let organizations: Models.TeamList<Record<string, unknown>> | 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;
Expand Down
4 changes: 2 additions & 2 deletions src/routes/+layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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)
])
};
}
Expand Down