Skip to content
Open
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
4 changes: 2 additions & 2 deletions bun.lock

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"dependencies": {
"@ai-sdk/svelte": "^1.1.24",
"@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@1a5604f",
"@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@16caf4e",
"@appwrite.io/pink-icons": "0.25.0",
"@appwrite.io/pink-icons-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-icons-svelte@bfe7ce3",
"@appwrite.io/pink-legacy": "^1.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,30 @@ import type { LayoutLoad } from './$types';
export const load: LayoutLoad = async ({ depends, params }) => {
depends(Dependencies.FUNCTION_INSTALLATIONS);

const [runtimesList, installations, specificationsList] = await Promise.all([
sdk.forProject(params.region, params.project).functions.listRuntimes(),
sdk
.forProject(params.region, params.project)
.vcs.listInstallations({ queries: [Query.limit(100)] }),
isCloud
? sdk.forProject(params.region, params.project).functions.listSpecifications()
: Promise.resolve({ specifications: [], total: 0 })
]);
const [runtimesList, installations, buildSpecificationsList, runtimeSpecificationsList] =
await Promise.all([
sdk.forProject(params.region, params.project).functions.listRuntimes(),
sdk
.forProject(params.region, params.project)
.vcs.listInstallations({ queries: [Query.limit(100)] }),
isCloud
? sdk
.forProject(params.region, params.project)
.functions.listSpecifications({ type: 'builds' })
: Promise.resolve({ specifications: [], total: 0 }),
isCloud
? sdk
.forProject(params.region, params.project)
.functions.listSpecifications({ type: 'runtimes' })
: Promise.resolve({ specifications: [], total: 0 })
]);

return {
header: Header,
breadcrumbs: Breadcrumbs,
runtimesList,
installations,
specificationsList
specificationsList: buildSpecificationsList,
runtimeSpecificationsList
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@

<UpdatePermissions />
{#if isCloud}
<UpdateResourceLimits func={data.function} specs={data.specificationsList} />
<UpdateResourceLimits
func={data.function}
buildSpecs={data.specificationsList}
runtimeSpecs={data.runtimeSpecificationsList} />
{/if}
<UpdateEvents />
<UpdateSchedule />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@ export const load = async ({ params, depends, parent }) => {
const limit = PAGE_LIMIT;
const variablesOffset = 0;

const { runtimesList, specificationsList, function: fn } = await parent();
const {
runtimesList,
specificationsList,
runtimeSpecificationsList,
function: fn
} = await parent();

const enabledSpecs = specificationsList?.specifications?.filter((s) => s.enabled) ?? [];
if (!enabledSpecs.some((s) => s.slug === fn.buildSpecification)) {
fn.buildSpecification = enabledSpecs[0]?.slug;
const buildEnabledSpecs = specificationsList?.specifications?.filter((s) => s.enabled) ?? [];
const runtimeEnabledSpecs =
runtimeSpecificationsList?.specifications?.filter((s) => s.enabled) ?? [];
if (!buildEnabledSpecs.some((s) => s.slug === fn.buildSpecification)) {
fn.buildSpecification = buildEnabledSpecs[0]?.slug;
}
if (!enabledSpecs.some((s) => s.slug === fn.runtimeSpecification)) {
fn.runtimeSpecification = enabledSpecs[0]?.slug;
if (!runtimeEnabledSpecs.some((s) => s.slug === fn.runtimeSpecification)) {
fn.runtimeSpecification = runtimeEnabledSpecs[0]?.slug;
}
Comment thread
TorstenDittmann marked this conversation as resolved.

const [globalVariables, variables] = await Promise.all([
Expand Down Expand Up @@ -56,6 +63,7 @@ export const load = async ({ params, depends, parent }) => {
variablesOffset,
runtimesList,
specificationsList,
runtimeSpecificationsList,
function: fn
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
import { page } from '$app/state';

export let func: Models.Function;
export let specs: Models.SpecificationList;
export let buildSpecs: Models.SpecificationList;
export let runtimeSpecs: Models.SpecificationList;

let buildSpecification = func.buildSpecification;
let runtimeSpecification = func.runtimeSpecification;
Expand Down Expand Up @@ -79,7 +80,12 @@
}
}

const options = (specs?.specifications ?? []).map((spec) => ({
const buildOptions = buildSpecs.specifications.map((spec) => ({
label: `${spec.cpus} CPU, ${spec.memory} MB RAM`,
value: spec.slug,
disabled: !spec.enabled
}));
const runtimeOptions = runtimeSpecs.specifications.map((spec) => ({
label: `${spec.cpus} CPU, ${spec.memory} MB RAM`,
value: spec.slug,
disabled: !spec.enabled
Expand All @@ -100,9 +106,9 @@
label="Build specification"
id="build-specification"
required
disabled={options.length < 1}
disabled={buildOptions.length < 1}
bind:value={buildSpecification}
{options}>
options={buildOptions}>
<Tooltip slot="info">
<Icon icon={IconInfo} size="s" />
<span slot="tooltip">
Expand All @@ -114,9 +120,9 @@
label="Runtime specification"
id="runtime-specification"
required
disabled={options.length < 1}
disabled={runtimeOptions.length < 1}
bind:value={runtimeSpecification}
{options}>
options={runtimeOptions}>
<Tooltip slot="info">
<Icon icon={IconInfo} size="s" />
<span slot="tooltip">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
<UpdateBuildSettings
site={data.site}
frameworks={data.frameworks.frameworks}
specs={data.specificationsList} />
buildSpecs={data.buildSpecificationsList}
runtimeSpecs={data.runtimeSpecificationsList} />
<UpdateRuntimeSettings site={data.site} frameworks={data.frameworks.frameworks} />
<UpdateVariables
{sdkCreateVariable}
Expand All @@ -95,7 +96,10 @@
product="site"
analyticsSource="site_settings" />
{#if isCloud}
<UpdateResourceLimits site={data.site} specs={data.specificationsList} />
<UpdateResourceLimits
site={data.site}
buildSpecs={data.buildSpecificationsList}
runtimeSpecs={data.runtimeSpecificationsList} />
{/if}
<UpdateDeploymentRetention site={data.site} />
<UpdateTimeout site={data.site} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,34 @@ export const load = async ({ params, depends, parent }) => {
const variablesOffset = 0;
const { site } = await parent();

const [globalVariables, variables, frameworks, installations, specificationsList] =
await Promise.all([
sdk.forProject(params.region, params.project).projectApi.listVariables({
queries: [Query.limit(VARIABLES_LIMIT)]
}),
sdk.forProject(params.region, params.project).sites.listVariables({
siteId: params.site,
queries: [Query.limit(limit), Query.offset(variablesOffset)]
}),
sdk.forProject(params.region, params.project).sites.listFrameworks(),
sdk.forProject(params.region, params.project).vcs.listInstallations(),
isCloud
? sdk.forProject(params.region, params.project).sites.listSpecifications()
: Promise.resolve({ specifications: [], total: 0 })
]);
const [
globalVariables,
variables,
frameworks,
installations,
buildSpecificationsList,
runtimeSpecificationsList
] = await Promise.all([
sdk.forProject(params.region, params.project).projectApi.listVariables({
queries: [Query.limit(VARIABLES_LIMIT)]
}),
sdk.forProject(params.region, params.project).sites.listVariables({
siteId: params.site,
queries: [Query.limit(limit), Query.offset(variablesOffset)]
}),
sdk.forProject(params.region, params.project).sites.listFrameworks(),
sdk.forProject(params.region, params.project).vcs.listInstallations(),
isCloud
? sdk
.forProject(params.region, params.project)
.sites.listSpecifications({ type: 'builds' })
: Promise.resolve({ specifications: [], total: 0 }),
isCloud
? sdk
.forProject(params.region, params.project)
.sites.listSpecifications({ type: 'runtimes' })
: Promise.resolve({ specifications: [], total: 0 })
]);

// Conflicting variables first
variables.variables = variables.variables.sort((var1, var2) => {
Expand All @@ -46,12 +59,19 @@ export const load = async ({ params, depends, parent }) => {
}
});

const enabledSpecs = specificationsList?.specifications?.filter((s) => s.enabled) ?? [];
if (!enabledSpecs.some((s) => s.slug === site.buildSpecification)) {
site.buildSpecification = enabledSpecs[0]?.slug;
const buildEnabledSpecs = buildSpecificationsList.specifications.filter((s) => s.enabled);
const runtimeEnabledSpecs = runtimeSpecificationsList.specifications.filter((s) => s.enabled);
if (
buildEnabledSpecs.length &&
!buildEnabledSpecs.some((s) => s.slug === site.buildSpecification)
) {
site.buildSpecification = buildEnabledSpecs[0]?.slug;
}
if (!enabledSpecs.some((s) => s.slug === site.runtimeSpecification)) {
site.runtimeSpecification = enabledSpecs[0]?.slug;
if (
runtimeEnabledSpecs.length &&
!runtimeEnabledSpecs.some((s) => s.slug === site.runtimeSpecification)
) {
site.runtimeSpecification = runtimeEnabledSpecs[0]?.slug;
}

return {
Expand All @@ -62,6 +82,7 @@ export const load = async ({ params, depends, parent }) => {
limit,
variablesOffset,
installations,
specificationsList
buildSpecificationsList,
runtimeSpecificationsList
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
let {
site,
frameworks,
specs
buildSpecs,
runtimeSpecs
}: {
site: Models.Site;
frameworks: Models.Framework[];
specs: Models.SpecificationList;
buildSpecs: Models.SpecificationList;
runtimeSpecs: Models.SpecificationList;
} = $props();

let frameworkKey = $state(site.framework);
Expand Down Expand Up @@ -124,14 +126,20 @@
adapter = selectedFramework.adapters[0].key as Adapter;
site.adapter = adapter;
}
if (specs && specs.specifications?.length) {
const enabledSpecs = specs.specifications.filter((s) => s.enabled);
const fallbackSlug = enabledSpecs[0]?.slug ?? specs.specifications[0]?.slug;
if (!enabledSpecs.some((s) => s.slug === site.buildSpecification)) {
site.buildSpecification = fallbackSlug;
if (buildSpecs.specifications.length || runtimeSpecs.specifications.length) {
const buildEnabledSpecs = buildSpecs.specifications.filter((s) => s.enabled);
const runtimeEnabledSpecs = runtimeSpecs.specifications.filter((s) => s.enabled);
if (
buildEnabledSpecs.length &&
!buildEnabledSpecs.some((s) => s.slug === site.buildSpecification)
) {
site.buildSpecification = buildEnabledSpecs[0]?.slug;
}
if (!enabledSpecs.some((s) => s.slug === site.runtimeSpecification)) {
site.runtimeSpecification = fallbackSlug;
if (
runtimeEnabledSpecs.length &&
!runtimeEnabledSpecs.some((s) => s.slug === site.runtimeSpecification)
) {
site.runtimeSpecification = runtimeEnabledSpecs[0]?.slug;
}
}
}
Expand All @@ -144,14 +152,16 @@
adptr = selectedFramework.adapters[0];
site.adapter = adapter;
}
// only allow enabled specsification for it
const enabledSpecs = specs?.specifications?.filter((s) => s.enabled) ?? [];
const specToSend = enabledSpecs.some((s) => s.slug === site.buildSpecification)
const buildEnabledSpecs = buildSpecs.specifications.filter((s) => s.enabled);
const runtimeEnabledSpecs = runtimeSpecs.specifications.filter((s) => s.enabled);
const specToSend = buildEnabledSpecs.some((s) => s.slug === site.buildSpecification)
? site.buildSpecification
: enabledSpecs[0]?.slug;
const runtimeSpecToSend = enabledSpecs.some((s) => s.slug === site.runtimeSpecification)
: (buildEnabledSpecs[0]?.slug ?? site.buildSpecification);
const runtimeSpecToSend = runtimeEnabledSpecs.some(
(s) => s.slug === site.runtimeSpecification
)
? site.runtimeSpecification
: enabledSpecs[0]?.slug;
: (runtimeEnabledSpecs[0]?.slug ?? site.runtimeSpecification);
try {
await sdk.forProject(page.params.region, page.params.project).sites.update({
siteId: site.$id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
import { page } from '$app/state';

export let site: Models.Site;
export let specs: Models.SpecificationList;
export let buildSpecs: Models.SpecificationList;
export let runtimeSpecs: Models.SpecificationList;

let buildSpecification = site.buildSpecification;
let runtimeSpecification = site.runtimeSpecification;
Expand Down Expand Up @@ -75,7 +76,14 @@
}
}

const options = (specs?.specifications ?? []).map((spec) => ({
const buildEnabledSpecs = buildSpecs.specifications.filter((spec) => spec.enabled);
const runtimeEnabledSpecs = runtimeSpecs.specifications.filter((spec) => spec.enabled);
const buildOptions = buildSpecs.specifications.map((spec) => ({
label: `${spec.cpus} CPU, ${spec.memory} MB RAM`,
value: spec.slug,
disabled: !spec.enabled
}));
const runtimeOptions = runtimeSpecs.specifications.map((spec) => ({
label: `${spec.cpus} CPU, ${spec.memory} MB RAM`,
value: spec.slug,
disabled: !spec.enabled
Expand All @@ -94,9 +102,9 @@
label="Build specification"
id="build-specification"
required
disabled={options.length < 1}
disabled={buildEnabledSpecs.length < 1}
bind:value={buildSpecification}
{options}>
options={buildOptions}>
<Tooltip slot="info">
<Icon icon={IconInfo} size="s" />
<span slot="tooltip">
Expand All @@ -109,9 +117,9 @@
label="Runtime specification"
id="runtime-specification"
required
disabled={options.length < 1}
disabled={runtimeEnabledSpecs.length < 1}
bind:value={runtimeSpecification}
{options}>
options={runtimeOptions}>
<Tooltip slot="info">
<Icon icon={IconInfo} size="s" />
<span slot="tooltip">
Expand Down