Skip to content

Commit a4b3ff0

Browse files
committed
(fix): merge main into feat-documentsdb, resolve conflicts
2 parents 55be875 + 1e7e199 commit a4b3ff0

9 files changed

Lines changed: 143 additions & 43 deletions

File tree

bun.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"dayjs": "^1.11.13",
5050
"deep-equal": "^2.2.3",
5151
"echarts": "^5.6.0",
52+
"flatted": "^3.4.2",
5253
"ignore": "^6.0.2",
5354
"json5": "^2.2.3",
5455
"nanoid": "^5.1.5",

src/lib/actions/analytics.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ export enum Submit {
329329
FunctionUpdateSchedule = 'submit_function_update_schedule',
330330
FunctionUpdateConfiguration = 'submit_function_update_configuration',
331331
FunctionUpdateLogging = 'submit_function_update_logging',
332+
FunctionUpdateResourceLimits = 'submit_function_update_resource_limits',
332333
FunctionUpdateTimeout = 'submit_function_update_timeout',
333334
FunctionUpdateEvents = 'submit_function_update_events',
334335
FunctionUpdateScopes = 'submit_function_key_update_scopes',
@@ -453,6 +454,7 @@ export enum Submit {
453454
SiteUpdateEvents = 'submit_site_update_events',
454455
SiteUpdateScopes = 'submit_site_key_update_scopes',
455456
SiteUpdateBuildSettings = 'submit_site_update_build_settings',
457+
SiteUpdateResourceLimits = 'submit_site_update_resource_limits',
456458
SiteUpdateSinglePageApplication = 'submit_site_update_single_page_application',
457459
SiteConnectRepo = 'submit_site_connect_repo',
458460
SiteRedeploy = 'submit_site_redeploy',

src/lib/stores/sdk.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ import {
2424
TablesDB,
2525
Domains,
2626
DocumentsDB,
27+
Webhooks,
2728
Realtime,
2829
Organizations,
29-
VectorsDB,
30-
Webhooks
30+
VectorsDB
3131
} from '@appwrite.io/console';
3232
import { Sources } from '$lib/sdk/sources';
3333
import {

src/routes/(console)/project-[region]-[project]/functions/function-[function]/settings/+page.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ export const load = async ({ params, depends, parent }) => {
55
depends(Dependencies.VARIABLES);
66
depends(Dependencies.FUNCTION);
77

8-
const { runtimesList, specificationsList } = await parent();
8+
const { runtimesList, specificationsList, function: fn } = await parent();
9+
10+
const enabledSpecs = specificationsList?.specifications?.filter((s) => s.enabled) ?? [];
11+
if (!enabledSpecs.some((s) => s.slug === fn.buildSpecification)) {
12+
fn.buildSpecification = enabledSpecs[0]?.slug;
13+
}
14+
if (!enabledSpecs.some((s) => s.slug === fn.runtimeSpecification)) {
15+
fn.runtimeSpecification = enabledSpecs[0]?.slug;
16+
}
917

1018
const [globalVariables, variables] = await Promise.all([
1119
sdk.forProject(params.region, params.project).projectApi.listVariables(),
@@ -36,6 +44,7 @@ export const load = async ({ params, depends, parent }) => {
3644
variables,
3745
globalVariables,
3846
runtimesList,
39-
specificationsList
47+
specificationsList,
48+
function: fn
4049
};
4150
};

src/routes/(console)/project-[region]-[project]/functions/function-[function]/settings/updateResourceLimits.svelte

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
import { isValueOfStringEnum } from '$lib/helpers/types';
1010
import { Runtime, type Models, type Scopes } from '@appwrite.io/console';
1111
import Link from '$lib/elements/link.svelte';
12-
import { Alert } from '@appwrite.io/pink-svelte';
12+
import { Alert, Icon, Tooltip } from '@appwrite.io/pink-svelte';
13+
import { IconInfo } from '@appwrite.io/pink-icons-svelte';
1314
import { isStarterPlan, getChangePlanUrl } from '$lib/stores/billing';
1415
import { isCloud } from '$lib/system';
1516
import { organization } from '$lib/stores/organization';
@@ -18,11 +19,23 @@
1819
export let func: Models.Function;
1920
export let specs: Models.SpecificationList;
2021
21-
let specification = func.buildSpecification;
22-
let originalSpecification = func.buildSpecification;
23-
$: originalSpecification = func.buildSpecification;
22+
let buildSpecification = func.buildSpecification;
23+
let runtimeSpecification = func.runtimeSpecification;
24+
let originalBuild = func.buildSpecification;
25+
let originalRuntime = func.runtimeSpecification;
2426
25-
async function updateLogging() {
27+
let functionId: string | undefined = undefined;
28+
$: if (func.$id !== functionId) {
29+
functionId = func.$id;
30+
buildSpecification = func.buildSpecification;
31+
runtimeSpecification = func.runtimeSpecification;
32+
}
33+
$: {
34+
originalBuild = func.buildSpecification;
35+
originalRuntime = func.runtimeSpecification;
36+
}
37+
38+
async function updateResourceLimits() {
2639
try {
2740
if (!isValueOfStringEnum(Runtime, func.runtime)) {
2841
throw new Error(`Invalid runtime: ${func.runtime}`);
@@ -45,24 +58,23 @@
4558
providerBranch: func.providerBranch || undefined,
4659
providerSilentMode: func.providerSilentMode || undefined,
4760
providerRootDirectory: func.providerRootDirectory || undefined,
48-
buildSpecification: specification || undefined
61+
buildSpecification: buildSpecification || undefined,
62+
runtimeSpecification: runtimeSpecification || undefined
4963
});
5064
5165
await invalidate(Dependencies.FUNCTION);
5266
53-
originalSpecification = specification;
54-
5567
addNotification({
5668
type: 'success',
5769
message: 'Resource limits have been updated'
5870
});
59-
trackEvent(Submit.FunctionUpdateLogging);
71+
trackEvent(Submit.FunctionUpdateResourceLimits);
6072
} catch (error) {
6173
addNotification({
6274
type: 'error',
6375
message: error.message
6476
});
65-
trackError(error, Submit.FunctionUpdateLogging);
77+
trackError(error, Submit.FunctionUpdateResourceLimits);
6678
}
6779
}
6880
@@ -73,7 +85,7 @@
7385
}));
7486
</script>
7587

76-
<Form onSubmit={updateLogging}>
88+
<Form onSubmit={updateResourceLimits}>
7789
<CardGrid>
7890
<svelte:fragment slot="title">Resource limits</svelte:fragment>
7991
Define your function's compute specifications, including CPU and memory, to optimize performance
@@ -84,12 +96,33 @@
8496
</Link>.
8597
<svelte:fragment slot="aside">
8698
<InputSelect
87-
label="CPU and memory"
88-
id="resources"
99+
label="Build specification"
100+
id="build-specification"
101+
required
102+
disabled={options.length < 1}
103+
bind:value={buildSpecification}
104+
{options}>
105+
<Tooltip slot="info">
106+
<Icon icon={IconInfo} size="s" />
107+
<span slot="tooltip">
108+
CPU and memory used when building and packaging your function deployment.
109+
</span>
110+
</Tooltip>
111+
</InputSelect>
112+
<InputSelect
113+
label="Runtime specification"
114+
id="runtime-specification"
89115
required
90116
disabled={options.length < 1}
91-
bind:value={specification}
92-
{options} />
117+
bind:value={runtimeSpecification}
118+
{options}>
119+
<Tooltip slot="info">
120+
<Icon icon={IconInfo} size="s" />
121+
<span slot="tooltip">
122+
CPU and memory available to each function execution at runtime.
123+
</span>
124+
</Tooltip>
125+
</InputSelect>
93126

94127
<!-- always show upgrade on starters -->
95128
{@const isStarter = isStarterPlan($organization.billingPlanId)}
@@ -104,7 +137,10 @@
104137
</svelte:fragment>
105138

106139
<svelte:fragment slot="actions">
107-
<Button disabled={originalSpecification === specification} submit>Update</Button>
140+
<Button
141+
disabled={originalBuild === buildSpecification &&
142+
originalRuntime === runtimeSpecification}
143+
submit>Update</Button>
108144
</svelte:fragment>
109145
</CardGrid>
110146
</Form>

src/routes/(console)/project-[region]-[project]/sites/site-[site]/settings/+page.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ export const load = async ({ params, depends, parent }) => {
4242
if (!enabledSpecs.some((s) => s.slug === site.buildSpecification)) {
4343
site.buildSpecification = enabledSpecs[0]?.slug;
4444
}
45+
if (!enabledSpecs.some((s) => s.slug === site.runtimeSpecification)) {
46+
site.runtimeSpecification = enabledSpecs[0]?.slug;
47+
}
4548

4649
return {
4750
site,

src/routes/(console)/project-[region]-[project]/sites/site-[site]/settings/updateBuildSettings.svelte

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,13 @@
112112
site.adapter = adapter;
113113
}
114114
if (specs && specs.specifications?.length) {
115-
if (!specs.specifications.some((s) => s.slug === site.buildSpecification)) {
116-
site.buildSpecification = specs.specifications[0].slug;
115+
const enabledSpecs = specs.specifications.filter((s) => s.enabled);
116+
const fallbackSlug = enabledSpecs[0]?.slug ?? specs.specifications[0]?.slug;
117+
if (!enabledSpecs.some((s) => s.slug === site.buildSpecification)) {
118+
site.buildSpecification = fallbackSlug;
119+
}
120+
if (!enabledSpecs.some((s) => s.slug === site.runtimeSpecification)) {
121+
site.runtimeSpecification = fallbackSlug;
117122
}
118123
}
119124
}
@@ -128,10 +133,12 @@
128133
}
129134
// only allow enabled specsification for it
130135
const enabledSpecs = specs?.specifications?.filter((s) => s.enabled) ?? [];
131-
let specToSend = enabledSpecs.some((s) => s.slug === site.buildSpecification)
136+
const specToSend = enabledSpecs.some((s) => s.slug === site.buildSpecification)
132137
? site.buildSpecification
133138
: enabledSpecs[0]?.slug;
134-
site.buildSpecification = specToSend;
139+
const runtimeSpecToSend = enabledSpecs.some((s) => s.slug === site.runtimeSpecification)
140+
? site.runtimeSpecification
141+
: enabledSpecs[0]?.slug;
135142
try {
136143
await sdk.forProject(page.params.region, page.params.project).sites.update({
137144
siteId: site.$id,
@@ -151,8 +158,11 @@
151158
providerBranch: site.providerBranch || undefined,
152159
providerSilentMode: site.providerSilentMode || undefined,
153160
providerRootDirectory: site.providerRootDirectory || undefined,
154-
buildSpecification: specToSend || undefined
161+
buildSpecification: specToSend || undefined,
162+
runtimeSpecification: runtimeSpecToSend || undefined
155163
});
164+
site.buildSpecification = specToSend;
165+
site.runtimeSpecification = runtimeSpecToSend;
156166
await invalidate(Dependencies.SITE);
157167
addNotification({
158168
message: 'Build settings have been updated',

src/routes/(console)/project-[region]-[project]/sites/site-[site]/settings/updateResourceLimits.svelte

Lines changed: 56 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
import { sdk } from '$lib/stores/sdk';
99
import { Adapter, BuildRuntime, Framework, type Models } from '@appwrite.io/console';
1010
import Link from '$lib/elements/link.svelte';
11-
import { Alert } from '@appwrite.io/pink-svelte';
11+
import { Alert, Icon, Tooltip } from '@appwrite.io/pink-svelte';
12+
import { IconInfo } from '@appwrite.io/pink-icons-svelte';
1213
import { getChangePlanUrl, isStarterPlan } from '$lib/stores/billing';
1314
import { isCloud } from '$lib/system';
1415
import { organization } from '$lib/stores/organization';
@@ -17,10 +18,23 @@
1718
export let site: Models.Site;
1819
export let specs: Models.SpecificationList;
1920
20-
let specification = site.buildSpecification;
21-
let originalSpecification = site.buildSpecification;
21+
let buildSpecification = site.buildSpecification;
22+
let runtimeSpecification = site.runtimeSpecification;
23+
let originalBuild = site.buildSpecification;
24+
let originalRuntime = site.runtimeSpecification;
2225
23-
async function updateLogging() {
26+
let siteId: string | undefined = undefined;
27+
$: if (site.$id !== siteId) {
28+
siteId = site.$id;
29+
buildSpecification = site.buildSpecification;
30+
runtimeSpecification = site.runtimeSpecification;
31+
}
32+
$: {
33+
originalBuild = site.buildSpecification;
34+
originalRuntime = site.runtimeSpecification;
35+
}
36+
37+
async function updateResourceLimits() {
2438
try {
2539
await sdk.forProject(page.params.region, page.params.project).sites.update({
2640
siteId: site.$id,
@@ -40,22 +54,22 @@
4054
providerBranch: site?.providerBranch || undefined,
4155
providerSilentMode: site?.providerSilentMode || undefined,
4256
providerRootDirectory: site?.providerRootDirectory || undefined,
43-
buildSpecification: specification || undefined
57+
buildSpecification: buildSpecification || undefined,
58+
runtimeSpecification: runtimeSpecification || undefined
4459
});
4560
await invalidate(Dependencies.SITE);
46-
originalSpecification = specification;
4761
4862
addNotification({
4963
type: 'success',
5064
message: 'Resource limits have been updated'
5165
});
52-
trackEvent(Submit.FunctionUpdateLogging);
66+
trackEvent(Submit.SiteUpdateResourceLimits);
5367
} catch (error) {
5468
addNotification({
5569
type: 'error',
5670
message: error.message
5771
});
58-
trackError(error, Submit.FunctionUpdateLogging);
72+
trackError(error, Submit.SiteUpdateResourceLimits);
5973
}
6074
}
6175
@@ -66,23 +80,44 @@
6680
}));
6781
</script>
6882

69-
<Form onSubmit={updateLogging}>
83+
<Form onSubmit={updateResourceLimits}>
7084
<CardGrid>
7185
<svelte:fragment slot="title">Resource limits</svelte:fragment>
72-
Define your sites's compute specifications, including CPU and memory, to optimize performance
73-
for your workloads. <Link
74-
href="https://appwrite.io/docs/advanced/platform/compute"
75-
external>
86+
Define your site's compute specifications, including CPU and memory, to optimize performance for
87+
your workloads. <Link href="https://appwrite.io/docs/advanced/platform/compute" external>
7688
Learn more
7789
</Link>.
7890
<svelte:fragment slot="aside">
7991
<InputSelect
80-
label="CPU and memory"
81-
id="resources"
92+
label="Build specification"
93+
id="build-specification"
94+
required
95+
disabled={options.length < 1}
96+
bind:value={buildSpecification}
97+
{options}>
98+
<Tooltip slot="info">
99+
<Icon icon={IconInfo} size="s" />
100+
<span slot="tooltip">
101+
CPU and memory used when installing dependencies and building your site for
102+
deployment.
103+
</span>
104+
</Tooltip>
105+
</InputSelect>
106+
<InputSelect
107+
label="Runtime specification"
108+
id="runtime-specification"
82109
required
83110
disabled={options.length < 1}
84-
bind:value={specification}
85-
{options} />
111+
bind:value={runtimeSpecification}
112+
{options}>
113+
<Tooltip slot="info">
114+
<Icon icon={IconInfo} size="s" />
115+
<span slot="tooltip">
116+
CPU and memory used when your site serves traffic, including server-side
117+
rendering (SSR).
118+
</span>
119+
</Tooltip>
120+
</InputSelect>
86121

87122
<!-- always show upgrade on starters -->
88123
{@const isStarter = isStarterPlan($organization.billingPlanId)}
@@ -97,7 +132,10 @@
97132
</svelte:fragment>
98133

99134
<svelte:fragment slot="actions">
100-
<Button disabled={originalSpecification === specification} submit>Update</Button>
135+
<Button
136+
disabled={originalBuild === buildSpecification &&
137+
originalRuntime === runtimeSpecification}
138+
submit>Update</Button>
101139
</svelte:fragment>
102140
</CardGrid>
103141
</Form>

0 commit comments

Comments
 (0)