diff --git a/package.json b/package.json index 99a3e173f2..d1ae6b6ad6 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ }, "dependencies": { "@ai-sdk/svelte": "^1.1.24", - "@appwrite.io/console": "https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@1959", + "@appwrite.io/console": "https://try-module.cloud/module/@appwrite/%40appwrite.io%2Fconsole@e50c8d0b7", "@appwrite.io/pink": "0.25.0", "@appwrite.io/pink-icons": "0.25.0", "@appwrite.io/pink-icons-svelte": "^2.0.0-RC.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8ceb043ad3..2bb3573a2e 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.pr.new/appwrite-labs/cloud/@appwrite.io/console@1959 - version: https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@1959 + specifier: https://try-module.cloud/module/@appwrite/%40appwrite.io%2Fconsole@e50c8d0b7 + version: https://try-module.cloud/module/@appwrite/%40appwrite.io%2Fconsole@e50c8d0b7 '@appwrite.io/pink': specifier: 0.25.0 version: 0.25.0 @@ -254,8 +254,8 @@ packages: '@analytics/type-utils@0.6.2': resolution: {integrity: sha512-TD+xbmsBLyYy/IxFimW/YL/9L2IEnM7/EoV9Aeh56U64Ify8o27HJcKjo38XY9Tcn0uOq1AX3thkKgvtWvwFQg==} - '@appwrite.io/console@https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@1959': - resolution: {tarball: https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@1959} + '@appwrite.io/console@https://try-module.cloud/module/@appwrite/%40appwrite.io%2Fconsole@e50c8d0b7': + resolution: {tarball: https://try-module.cloud/module/@appwrite/%40appwrite.io%2Fconsole@e50c8d0b7} version: 1.5.2 '@appwrite.io/pink-icons-svelte@2.0.0-RC.1': @@ -3615,7 +3615,7 @@ snapshots: '@analytics/type-utils@0.6.2': {} - '@appwrite.io/console@https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@1959': {} + '@appwrite.io/console@https://try-module.cloud/module/@appwrite/%40appwrite.io%2Fconsole@e50c8d0b7': {} '@appwrite.io/pink-icons-svelte@2.0.0-RC.1(svelte@5.25.3)': dependencies: diff --git a/src/lib/commandCenter/searchers/organizations.ts b/src/lib/commandCenter/searchers/organizations.ts index 1d959e9921..2a333d6cd5 100644 --- a/src/lib/commandCenter/searchers/organizations.ts +++ b/src/lib/commandCenter/searchers/organizations.ts @@ -7,7 +7,7 @@ import { isCloud } from '$lib/system'; export const orgSearcher = (async (query: string) => { const { teams } = !isCloud ? await sdk.forConsole.teams.list() - : await sdk.forConsole.billing.listOrganization(); + : await sdk.forConsole.organizations.list(); return teams .filter((organization) => organization.name.toLowerCase().includes(query.toLowerCase())) diff --git a/src/lib/components/billing/alerts/paymentMandate.svelte b/src/lib/components/billing/alerts/paymentMandate.svelte index b55f5d20bf..c38027920c 100644 --- a/src/lib/components/billing/alerts/paymentMandate.svelte +++ b/src/lib/components/billing/alerts/paymentMandate.svelte @@ -8,8 +8,7 @@ import { confirmSetup } from '$lib/stores/stripe'; async function verifyPaymentMethod() { - const method = await sdk.forConsole.billing.setupPaymentMandate( - $organization.$id, + const method = await sdk.forConsole.account.updatePaymentMethodMandateOptions( $paymentMissingMandate.$id ); await confirmSetup(method.clientSecret, method.$id); diff --git a/src/lib/components/billing/couponInput.svelte b/src/lib/components/billing/couponInput.svelte index 85e73411c0..60dcadfe0e 100644 --- a/src/lib/components/billing/couponInput.svelte +++ b/src/lib/components/billing/couponInput.svelte @@ -18,7 +18,7 @@ async function addCoupon() { try { - const response = await sdk.forConsole.billing.getCouponAccount(coupon); + const response = await sdk.forConsole.account.getCoupon(coupon); couponData = response; dispatch('validation', couponData); coupon = null; diff --git a/src/lib/components/billing/estimatedTotalBox.svelte b/src/lib/components/billing/estimatedTotalBox.svelte index 112d506c19..5e66057ad7 100644 --- a/src/lib/components/billing/estimatedTotalBox.svelte +++ b/src/lib/components/billing/estimatedTotalBox.svelte @@ -2,15 +2,16 @@ import { InputChoice, InputNumber } from '$lib/elements/forms'; import { toLocaleDate } from '$lib/helpers/date'; import { formatCurrency } from '$lib/helpers/numbers'; - import type { Coupon, PlansMap } from '$lib/sdk/billing'; + import type { Coupon } 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 type { Models } from '@appwrite.io/console'; export let billingPlan: Tier; export let collaborators: string[]; export let couponData: Partial; - export let plans: PlansMap; + export let plans: Map; export let billingBudget: number; export let fixedCoupon = false; // If true, the coupon cannot be removed export let isDowngrade = false; @@ -29,9 +30,7 @@ ? grossCost - couponData.credits : 0 : grossCost; - $: trialEndDate = new Date( - billingPayDate.getTime() + currentPlan.trialDays * 24 * 60 * 60 * 1000 - ); + $: trialEndDate = new Date(billingPayDate.getTime() + currentPlan.trial * 24 * 60 * 60 * 1000); @@ -54,7 +53,7 @@ Upcoming charge
- Due on {!currentPlan.trialDays + Due on {!currentPlan.trial ? toLocaleDate(billingPayDate.toString()) : toLocaleDate(trialEndDate.toString())}
{formatCurrency(estimatedTotal)} @@ -64,7 +63,7 @@ You'll pay {formatCurrency(estimatedTotal)} now, with your first billing cycle starting on {!currentPlan.trialDays + >{!currentPlan.trial ? toLocaleDate(billingPayDate.toString()) : toLocaleDate(trialEndDate.toString())}. {#if couponData?.status === 'active'}Once your credits run out, you'll be charged diff --git a/src/lib/components/billing/planComparisonBox.svelte b/src/lib/components/billing/planComparisonBox.svelte index 9d7443df43..c3e1e3dbf4 100644 --- a/src/lib/components/billing/planComparisonBox.svelte +++ b/src/lib/components/billing/planComparisonBox.svelte @@ -1,12 +1,12 @@ diff --git a/src/lib/components/billing/planExcess.svelte b/src/lib/components/billing/planExcess.svelte index 02793dc708..63dca3e889 100644 --- a/src/lib/components/billing/planExcess.svelte +++ b/src/lib/components/billing/planExcess.svelte @@ -1,18 +1,18 @@ diff --git a/src/routes/(console)/project-[region]-[project]/+layout.ts b/src/routes/(console)/project-[region]-[project]/+layout.ts index f90abed153..7317c0f9bd 100644 --- a/src/routes/(console)/project-[region]-[project]/+layout.ts +++ b/src/routes/(console)/project-[region]-[project]/+layout.ts @@ -6,16 +6,16 @@ import { preferences } from '$lib/stores/preferences'; import { failedInvoice } from '$lib/stores/billing'; import { isCloud } from '$lib/system'; import { defaultRoles, defaultScopes } from '$lib/constants'; -import type { Plan } from '$lib/sdk/billing'; 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 } from '$lib/stores/organization'; +import type { Models } from '@appwrite.io/console'; export const load: LayoutLoad = async ({ params, depends }) => { depends(Dependencies.PROJECT); - let currentPlan: Plan = null; + let currentPlan: Models.BillingPlan = null; try { const project = await sdk.forConsole.projects.get(params.project); @@ -34,8 +34,8 @@ export const load: LayoutLoad = async ({ params, depends }) => { let roles = isCloud ? [] : defaultRoles; let scopes = isCloud ? [] : defaultScopes; if (isCloud) { - currentPlan = await sdk.forConsole.billing.getOrganizationPlan(project.teamId); - const res = await sdk.forConsole.billing.getRoles(project.teamId); + currentPlan = await sdk.forConsole.organizations.getPlan(project.teamId); + const res = await sdk.forConsole.organizations.getScopes(project.teamId); roles = res.roles; scopes = res.scopes; if (scopes.includes('billing.read')) { diff --git a/src/routes/(console)/project-[region]-[project]/databases/+page.ts b/src/routes/(console)/project-[region]-[project]/databases/+page.ts index 6abcffdc5a..9c0ede9ade 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); @@ -45,7 +44,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]/functions/templates/template-[template]/+page.svelte b/src/routes/(console)/project-[region]-[project]/functions/templates/template-[template]/+page.svelte index 4f5ca68a10..9d4fe43593 100644 --- a/src/routes/(console)/project-[region]-[project]/functions/templates/template-[template]/+page.svelte +++ b/src/routes/(console)/project-[region]-[project]/functions/templates/template-[template]/+page.svelte @@ -24,9 +24,15 @@ import { page } from '$app/state'; import { capitalize } from '$lib/helpers/string'; import { IconExternalLink } from '@appwrite.io/pink-icons-svelte'; + import type { BillingPlan } from '$lib/constants'; $: buttonDisabled = - isCloud && isServiceLimited('functions', $organization?.billingPlan, $functionsList?.total); + isCloud && + isServiceLimited( + 'functions', + $organization?.billingPlan as BillingPlan, + $functionsList?.total + ); 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 c432d29b86..5432891845 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 @@ -1,7 +1,7 @@ -import type { Aggregation, Invoice } from '$lib/sdk/billing'; +import type { Aggregation } from '$lib/sdk/billing'; import { accumulateUsage } from '$lib/sdk/usage'; import { sdk } from '$lib/stores/sdk'; -import { Query } from '@appwrite.io/console'; +import { Query, type Models } from '@appwrite.io/console'; import type { PageLoad } from './$types'; export const load: PageLoad = async ({ params, parent }) => { @@ -10,11 +10,11 @@ export const load: PageLoad = async ({ params, parent }) => { let startDate: string = organization.billingCurrentInvoiceDate; let endDate: string = organization.billingNextInvoiceDate; - let currentInvoice: Invoice = undefined; + let currentInvoice: Models.Invoice = undefined; let currentAggregation: Aggregation = undefined; if (invoice) { - currentInvoice = await sdk.forConsole.billing.getInvoice(organization.$id, invoice); + currentInvoice = await sdk.forConsole.organizations.getInvoice(organization.$id, invoice); currentAggregation = await sdk.forConsole.billing.getAggregation( organization.$id, currentInvoice.aggregationId @@ -25,7 +25,7 @@ export const load: PageLoad = async ({ params, parent }) => { } const [invoices, usage] = await Promise.all([ - sdk.forConsole.billing.listInvoices(organization.$id, [Query.orderDesc('from')]), + sdk.forConsole.organizations.listInvoices(organization.$id, [Query.orderDesc('from')]), sdk.forProject(region, project).project.getUsage(startDate, endDate) ]); diff --git a/src/routes/(console)/project-[region]-[project]/sites/+page.svelte b/src/routes/(console)/project-[region]-[project]/sites/+page.svelte index 855274fa47..fd6f9e0017 100644 --- a/src/routes/(console)/project-[region]-[project]/sites/+page.svelte +++ b/src/routes/(console)/project-[region]-[project]/sites/+page.svelte @@ -24,7 +24,7 @@ import Table from './table.svelte'; import { onMount } from 'svelte'; import { invalidate } from '$app/navigation'; - import { Dependencies } from '$lib/constants'; + import { BillingPlan, Dependencies } from '$lib/constants'; import { sdk } from '$lib/stores/sdk'; export let data; let show = false; @@ -37,8 +37,11 @@ }, keys: ['c'], disabled: - isServiceLimited('sites', $organization?.billingPlan, data.siteList?.total) || - !$canWriteSites, + isServiceLimited( + 'sites', + $organization?.billingPlan as BillingPlan, + data.siteList?.total + ) || !$canWriteSites, icon: IconPlus, group: 'sites' } 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 62bbb8c4bd..ad9b426003 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 @@ -9,11 +9,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); diff --git a/src/routes/(console)/store.ts b/src/routes/(console)/store.ts index 7735d4c298..146a8e00e1 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(page, ($page) => ); export const activeHeaderAlert = writable(null); -export const orgMissingPaymentMethod = writable(null); +export const orgMissingPaymentMethod = writable>>(null); diff --git a/src/routes/(public)/(guest)/login/+page.ts b/src/routes/(public)/(guest)/login/+page.ts index 33d808b7e5..4a48303d13 100644 --- a/src/routes/(public)/(guest)/login/+page.ts +++ b/src/routes/(public)/(guest)/login/+page.ts @@ -1,17 +1,17 @@ import { base } from '$app/paths'; -import type { Campaign } from '$lib/stores/campaigns'; import { sdk } from '$lib/stores/sdk'; import { redirect } from '@sveltejs/kit'; import type { PageLoad } from './$types'; +import type { Models } from '@appwrite.io/console'; export const load: PageLoad = async ({ url }) => { if (url.searchParams.has('code')) { const code = url.searchParams.get('code'); - let campaign: Campaign; + let campaign: Models.Campaign; try { - const couponData = await sdk.forConsole.billing.getCoupon(code); + const couponData = await sdk.forConsole.console.getCoupon(code); if (couponData.campaign) { - campaign = await sdk.forConsole.billing.getCampaign(couponData.campaign); + campaign = await sdk.forConsole.console.getCampaign(couponData.campaign); return { couponData, campaign @@ -23,9 +23,9 @@ export const load: PageLoad = async ({ url }) => { } if (url.searchParams.has('campaign')) { const campaignId = url.searchParams.get('campaign'); - let campaign: 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, `${base}/login`); diff --git a/src/routes/(public)/(guest)/register/+page.ts b/src/routes/(public)/(guest)/register/+page.ts index 1fa2e79de8..852e7d0c9f 100644 --- a/src/routes/(public)/(guest)/register/+page.ts +++ b/src/routes/(public)/(guest)/register/+page.ts @@ -1,17 +1,17 @@ import { base } from '$app/paths'; -import type { Campaign } from '$lib/stores/campaigns.js'; import { sdk } from '$lib/stores/sdk'; import { redirect } from '@sveltejs/kit'; import type { PageLoad } from './$types'; +import type { Models } from '@appwrite.io/console'; export const load: PageLoad = async ({ url }) => { if (url.searchParams.has('code')) { const code = url.searchParams.get('code'); - let campaign: Campaign; + let campaign: Models.Campaign; try { - const couponData = await sdk.forConsole.billing.getCoupon(code); + const couponData = await sdk.forConsole.console.getCoupon(code); if (couponData.campaign) { - campaign = await sdk.forConsole.billing.getCampaign(couponData.campaign); + campaign = await sdk.forConsole.console.getCampaign(couponData.campaign); return { couponData, campaign @@ -23,9 +23,9 @@ export const load: PageLoad = async ({ url }) => { } if (url.searchParams.has('campaign')) { const campaignId = url.searchParams.get('campaign'); - let campaign: 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, `${base}/register`); diff --git a/src/routes/(public)/template-[template]/+page.ts b/src/routes/(public)/template-[template]/+page.ts index dad1d1a067..f706267f81 100644 --- a/src/routes/(public)/template-[template]/+page.ts +++ b/src/routes/(public)/template-[template]/+page.ts @@ -1,6 +1,5 @@ -import { BillingPlan } from '$lib/constants.js'; import { sdk } from '$lib/stores/sdk.js'; -import { ID, type Models } from '@appwrite.io/console'; +import { BillingPlan, ID, type Models } from '@appwrite.io/console'; import { isCloud } from '$lib/system.js'; import { error, redirect } from '@sveltejs/kit'; import type { OrganizationList } from '$lib/stores/organization.js'; @@ -34,16 +33,16 @@ export const load = async ({ parent, url, params }) => { let organizations: Models.TeamList> | OrganizationList | undefined; if (isCloud) { - organizations = account?.$id ? await sdk.forConsole.billing.listOrganization() : undefined; + organizations = account?.$id ? await sdk.forConsole.organizations.list() : undefined; } else { organizations = account?.$id ? await sdk.forConsole.teams.list() : undefined; } if (!organizations?.total && account?.$id) { - await sdk.forConsole.billing.createOrganization( + await sdk.forConsole.organizations.create( ID.unique(), 'Personal project', - BillingPlan.FREE, + BillingPlan.Tier0, null, null ); diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index f5bed4b866..852a19037e 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -68,7 +68,7 @@ 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(code).catch(() => null); if (coupon?.campaign) { const campaign = await sdk.forConsole.billing .getCampaign(coupon.campaign) diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts index 78d86d2e47..ebe0dfeff6 100644 --- a/src/routes/+layout.ts +++ b/src/routes/+layout.ts @@ -32,7 +32,7 @@ export const load: LayoutLoad = async ({ depends, url, route }) => { account: account, organizations: !isCloud ? await sdk.forConsole.teams.list() - : await sdk.forConsole.billing.listOrganization() + : await sdk.forConsole.organizations.list() }; }