mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
update: api method updates.
This commit is contained in:
1 parent
204df6550d
commit
bf4d225c0b
77 files changed
+701
-684
No files matched your search
+1
-1
@@ -22,7 +22,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@ai-sdk/svelte": "^1.1.24",
|
||||
"@appwrite.io/console": "https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@fcbaa54",
|
||||
"@appwrite.io/console": "https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@c0da899",
|
||||
"@appwrite.io/pink-icons": "0.25.0",
|
||||
"@appwrite.io/pink-icons-svelte": "^2.0.0-RC.1",
|
||||
"@appwrite.io/pink-legacy": "^1.0.3",
|
||||
|
||||
Generated
+5
-5
@@ -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@fcbaa54
|
||||
version: https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@fcbaa54
|
||||
specifier: https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@c0da899
|
||||
version: https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@c0da899
|
||||
'@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.pr.new/appwrite-labs/cloud/@appwrite.io/console@fcbaa54':
|
||||
resolution: {tarball: https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@fcbaa54}
|
||||
'@appwrite.io/console@https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@c0da899':
|
||||
resolution: {tarball: https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@c0da899}
|
||||
version: 1.10.0
|
||||
|
||||
'@appwrite.io/pink-icons-svelte@2.0.0-RC.1':
|
||||
@@ -3696,7 +3696,7 @@ snapshots:
|
||||
|
||||
'@analytics/type-utils@0.6.2': {}
|
||||
|
||||
'@appwrite.io/console@https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@fcbaa54': {}
|
||||
'@appwrite.io/console@https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@c0da899': {}
|
||||
|
||||
'@appwrite.io/pink-icons-svelte@2.0.0-RC.1(svelte@5.25.3)':
|
||||
dependencies:
|
||||
|
||||
@@ -38,11 +38,11 @@
|
||||
success = '';
|
||||
|
||||
try {
|
||||
await vcs.updateExternalDeployments(
|
||||
await vcs.updateExternalDeployments({
|
||||
installationId,
|
||||
repositoryId,
|
||||
providerPullRequestId
|
||||
);
|
||||
});
|
||||
success = 'Deployment approved successfully! Build will start soon.';
|
||||
} catch (e) {
|
||||
error = e.message;
|
||||
|
||||
@@ -34,10 +34,9 @@ export const load: LayoutLoad = async ({ depends, parent }) => {
|
||||
if (currentOrgId) {
|
||||
try {
|
||||
projectsCount = (
|
||||
await sdk.forConsole.projects.list([
|
||||
Query.equal('teamId', currentOrgId),
|
||||
Query.limit(1)
|
||||
])
|
||||
await sdk.forConsole.projects.list({
|
||||
queries: [Query.equal('teamId', currentOrgId), Query.limit(1)]
|
||||
})
|
||||
).total;
|
||||
} catch (e) {
|
||||
projectsCount = 0;
|
||||
|
||||
@@ -9,7 +9,7 @@ export const load: LayoutLoad = async ({ depends }) => {
|
||||
depends(Dependencies.IDENTITIES);
|
||||
|
||||
const [factors, identities] = await Promise.all([
|
||||
sdk.forConsole.account.listMfaFactors(),
|
||||
sdk.forConsole.account.listMFAFactors(),
|
||||
sdk.forConsole.account.listIdentities()
|
||||
]);
|
||||
|
||||
|
||||
@@ -38,12 +38,12 @@
|
||||
|
||||
try {
|
||||
const teamId = data.organization.$id;
|
||||
const project = await sdk.forConsole.projects.create(
|
||||
id ?? ID.unique(),
|
||||
projectName,
|
||||
const project = await sdk.forConsole.projects.create({
|
||||
projectId: id ?? ID.unique(),
|
||||
name: projectName,
|
||||
teamId,
|
||||
isCloud ? region : undefined
|
||||
);
|
||||
region: isCloud ? region : undefined
|
||||
});
|
||||
|
||||
markOnboardingComplete();
|
||||
|
||||
|
||||
@@ -52,10 +52,10 @@ export const load: PageLoad = async ({ parent }) => {
|
||||
} else {
|
||||
return {
|
||||
accountPrefs,
|
||||
organization: await sdk.forConsole.teams.create(
|
||||
ID.unique(),
|
||||
'Personal projects'
|
||||
)
|
||||
organization: await sdk.forConsole.teams.create({
|
||||
teamId: ID.unique(),
|
||||
name: 'Personal projects'
|
||||
})
|
||||
};
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
@@ -98,12 +98,12 @@
|
||||
const importProject = async () => {
|
||||
try {
|
||||
loading.set(true);
|
||||
const project = await sdk.forConsole.projects.create(
|
||||
ID.unique(),
|
||||
`Imported project ${new Date().toISOString()}`,
|
||||
page.params.organization,
|
||||
Region.Fra // default
|
||||
);
|
||||
const project = await sdk.forConsole.projects.create({
|
||||
projectId: ID.unique(),
|
||||
name: `Imported project ${new Date().toISOString()}`,
|
||||
teamId: page.params.organization,
|
||||
region: Region.Fra
|
||||
});
|
||||
trackEvent(Submit.ProjectCreate, {
|
||||
teamId: page.params.organization
|
||||
});
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
|
||||
async function addDomain() {
|
||||
try {
|
||||
domain = await sdk.forConsole.domains.create(
|
||||
page.params.organization,
|
||||
domainName.toLocaleLowerCase()
|
||||
);
|
||||
domain = await sdk.forConsole.domains.create({
|
||||
teamId: page.params.organization,
|
||||
domain: domainName.toLocaleLowerCase()
|
||||
});
|
||||
invalidate(Dependencies.DOMAINS);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
|
||||
@@ -7,8 +7,10 @@ export const load = async ({ depends, params }) => {
|
||||
depends(Dependencies.DOMAIN);
|
||||
|
||||
return {
|
||||
domain: await sdk.forConsole.domains.get(params.domain),
|
||||
header: Header,
|
||||
breadcrumbs: Breadcrumbs
|
||||
breadcrumbs: Breadcrumbs,
|
||||
domain: await sdk.forConsole.domains.get({
|
||||
domainId: params.domain
|
||||
})
|
||||
};
|
||||
};
|
||||
+3
-1
@@ -37,7 +37,9 @@
|
||||
|
||||
async function downloadRecords() {
|
||||
try {
|
||||
const zone = await sdk.forConsole.domains.getZone(data.domain.$id);
|
||||
const zone = await sdk.forConsole.domains.getZone({
|
||||
domainId: data.domain.$id
|
||||
});
|
||||
|
||||
if ('message' in zone) {
|
||||
const blob = new Blob([zone.message as string], { type: 'text/plain' });
|
||||
|
||||
@@ -53,15 +53,14 @@
|
||||
|
||||
const resend = async (member: Models.Membership) => {
|
||||
try {
|
||||
await sdk.forConsole.teams.createMembership(
|
||||
$organization.$id,
|
||||
member.roles,
|
||||
member.userEmail,
|
||||
undefined,
|
||||
undefined,
|
||||
`${page.url.origin}${base}/invite`,
|
||||
member.userName || undefined
|
||||
);
|
||||
await sdk.forConsole.teams.createMembership({
|
||||
teamId: $organization.$id,
|
||||
roles: member.roles,
|
||||
email: member.userEmail,
|
||||
url: `${page.url.origin}${base}/invite`,
|
||||
name: member.userName || undefined
|
||||
});
|
||||
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `Invite has been sent to ${member.userEmail}`
|
||||
|
||||
+5
-7
@@ -17,12 +17,10 @@ export const load: PageLoad = async ({ params, depends, url, route }) => {
|
||||
offset,
|
||||
search,
|
||||
limit,
|
||||
memberships: await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.teams.listMemberships(
|
||||
teamId,
|
||||
[Query.limit(limit), Query.offset(offset), Query.orderDesc('')],
|
||||
search
|
||||
)
|
||||
memberships: await sdk.forProject(params.region, params.project).teams.listMemberships({
|
||||
teamId,
|
||||
queries: [Query.limit(limit), Query.offset(offset), Query.orderDesc('')],
|
||||
search
|
||||
})
|
||||
};
|
||||
};
|
||||
@@ -1,22 +1,25 @@
|
||||
<script context="module" lang="ts">
|
||||
import type {
|
||||
SmsTemplateLocale,
|
||||
SmsTemplateType,
|
||||
import {
|
||||
EmailTemplateLocale,
|
||||
EmailTemplateType,
|
||||
EmailTemplateLocale
|
||||
SmsTemplateLocale,
|
||||
SmsTemplateType
|
||||
} from '@appwrite.io/console';
|
||||
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
|
||||
export async function loadEmailTemplate(projectId: string, type: string, locale: string) {
|
||||
export async function loadEmailTemplate(
|
||||
projectId: string,
|
||||
type: EmailTemplateType,
|
||||
locale: EmailTemplateLocale
|
||||
) {
|
||||
try {
|
||||
// TODO: fix TemplateType and TemplateLocale typing once SDK is updated
|
||||
return await sdk.forConsole.projects.getEmailTemplate(
|
||||
return await sdk.forConsole.projects.getEmailTemplate({
|
||||
projectId,
|
||||
type as EmailTemplateType,
|
||||
locale as EmailTemplateLocale
|
||||
);
|
||||
type: type,
|
||||
locale: locale
|
||||
});
|
||||
} catch (e) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
@@ -24,14 +27,17 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
export async function loadSmsTemplate(projectId: string, type: string, locale: string) {
|
||||
export async function loadSmsTemplate(
|
||||
projectId: string,
|
||||
type: SmsTemplateType,
|
||||
locale: SmsTemplateLocale
|
||||
) {
|
||||
try {
|
||||
// TODO: fix TemplateType and TemplateLocale typing once SDK is updated
|
||||
return await sdk.forConsole.projects.getSmsTemplate(
|
||||
return await sdk.forConsole.projects.getSMSTemplate({
|
||||
projectId,
|
||||
type as SmsTemplateType,
|
||||
locale as SmsTemplateLocale
|
||||
);
|
||||
type,
|
||||
locale
|
||||
});
|
||||
} catch (e) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
@@ -59,22 +65,22 @@
|
||||
let isTemplateLoading = false;
|
||||
let openStates = Object.fromEntries(templates.map(({ key }) => [key, false]));
|
||||
|
||||
loadTemplateFor('verification');
|
||||
loadTemplateFor(EmailTemplateType.Verification);
|
||||
|
||||
async function loadTemplateFor(type: string) {
|
||||
async function loadTemplateFor(type: EmailTemplateType) {
|
||||
// return, already loaded!
|
||||
if (templateType === type) return;
|
||||
|
||||
templateType = type;
|
||||
isTemplateLoading = true;
|
||||
|
||||
$emailTemplate = await loadEmailTemplate(page.params.project, type, 'en');
|
||||
$emailTemplate = await loadEmailTemplate(page.params.project, type, EmailTemplateLocale.En);
|
||||
$baseEmailTemplate = { ...$emailTemplate };
|
||||
|
||||
isTemplateLoading = false;
|
||||
}
|
||||
|
||||
function toggleAccordion(type: string) {
|
||||
function toggleAccordion(type: EmailTemplateType) {
|
||||
for (const key in openStates) {
|
||||
openStates[key] = false;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { page } from '$app/stores';
|
||||
import { derived, writable } from 'svelte/store';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { EmailTemplateType, type Models } from '@appwrite.io/console';
|
||||
|
||||
// component imports
|
||||
import Email2FaTemplate from './email2FATemplate.svelte';
|
||||
@@ -47,44 +47,44 @@ export const baseSmsTemplate = writable<Models.SmsTemplate>({
|
||||
|
||||
export const templates = [
|
||||
{
|
||||
key: 'verification',
|
||||
key: EmailTemplateType.Verification,
|
||||
title: 'Verification',
|
||||
description:
|
||||
'Send a verification email to users that sign in with their email and password.',
|
||||
component: EmailVerificationTemplate
|
||||
},
|
||||
{
|
||||
key: 'magicSession',
|
||||
key: EmailTemplateType.Magicsession,
|
||||
title: 'Magic URL',
|
||||
description: 'Send an email to users that sign in with a magic URL.',
|
||||
component: EmailMagicUrlTemplate
|
||||
},
|
||||
{
|
||||
key: 'otpSession',
|
||||
key: EmailTemplateType.Otpsession,
|
||||
title: 'OTP session',
|
||||
description: 'Send an email to users that sign in with a email OTP.',
|
||||
component: EmailOtpSessionTemplate
|
||||
},
|
||||
{
|
||||
key: 'recovery',
|
||||
key: EmailTemplateType.Recovery,
|
||||
title: 'Reset password',
|
||||
description: 'Send a recovery email to users that forget their password.',
|
||||
component: EmailRecoveryTemplate
|
||||
},
|
||||
{
|
||||
key: 'invitation',
|
||||
key: EmailTemplateType.Invitation,
|
||||
title: 'Invite user',
|
||||
description: 'Send an invitation email to become a member of your project.',
|
||||
component: EmailInviteTemplate
|
||||
},
|
||||
{
|
||||
key: 'mfaChallenge',
|
||||
key: EmailTemplateType.Mfachallenge,
|
||||
title: '2FA verification',
|
||||
description: 'Send a two-factor authentication email to a user.',
|
||||
component: Email2FaTemplate
|
||||
},
|
||||
{
|
||||
key: 'sessionAlert',
|
||||
key: EmailTemplateType.Sessionalert,
|
||||
title: 'Session alert',
|
||||
description: 'Send an email to users when a new session is created.',
|
||||
component: EmailSessionAlertTemplate,
|
||||
|
||||
@@ -9,7 +9,7 @@ export const load: LayoutLoad = async ({ params, depends }) => {
|
||||
|
||||
const [user, userFactors] = await Promise.all([
|
||||
sdk.forProject(params.region, params.project).users.get({ userId: params.user }),
|
||||
sdk.forProject(params.region, params.project).users.listMfaFactors({ userId: params.user })
|
||||
sdk.forProject(params.region, params.project).users.listMFAFactors({ userId: params.user })
|
||||
]);
|
||||
|
||||
return {
|
||||
|
||||
+10
-12
@@ -17,18 +17,16 @@ export const load: PageLoad = async ({ params, url, route, depends }) => {
|
||||
const parsedQueries = queryParamToMap(query || '[]');
|
||||
queries.set(parsedQueries);
|
||||
|
||||
const identities = await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.users.listIdentities(
|
||||
[
|
||||
Query.equal('userId', params.user),
|
||||
Query.limit(limit),
|
||||
Query.offset(offset),
|
||||
Query.orderDesc(''),
|
||||
...parsedQueries.values()
|
||||
],
|
||||
search
|
||||
);
|
||||
const identities = await sdk.forProject(params.region, params.project).users.listIdentities({
|
||||
queries: [
|
||||
Query.equal('userId', params.user),
|
||||
Query.limit(limit),
|
||||
Query.offset(offset),
|
||||
Query.orderDesc(''),
|
||||
...parsedQueries.values()
|
||||
],
|
||||
search
|
||||
});
|
||||
|
||||
return {
|
||||
offset,
|
||||
|
||||
@@ -31,7 +31,7 @@ export const load: PageLoad = async ({ params, url, route, depends }) => {
|
||||
if (target.providerId && !promisesById[target.providerId]) {
|
||||
promisesById[target.providerId] = sdk
|
||||
.forProject(params.region, params.project)
|
||||
.messaging.getProvider(target.providerId);
|
||||
.messaging.getProvider({ providerId: target.providerId });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -13,12 +13,10 @@ export const load = async ({ url, depends, route, params }) => {
|
||||
return {
|
||||
offset,
|
||||
limit,
|
||||
functions: await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.functions.list(
|
||||
[Query.limit(limit), Query.offset(offset), Query.orderDesc('')],
|
||||
search
|
||||
),
|
||||
functions: await sdk.forProject(params.region, params.project).functions.list({
|
||||
queries: [Query.limit(limit), Query.offset(offset), Query.orderDesc('')],
|
||||
search
|
||||
}),
|
||||
search
|
||||
};
|
||||
};
|
||||
@@ -3,9 +3,7 @@ import { sdk } from '$lib/stores/sdk';
|
||||
export const load = async ({ parent, url, params }) => {
|
||||
const [{ installations }, { templates }] = await Promise.all([
|
||||
parent(),
|
||||
sdk
|
||||
.forProject(params.region, params.project)
|
||||
.functions.listTemplates(undefined, undefined, 100)
|
||||
sdk.forProject(params.region, params.project).functions.listTemplates({ limit: 100 })
|
||||
]);
|
||||
|
||||
return {
|
||||
|
||||
+17
-31
@@ -64,45 +64,31 @@
|
||||
try {
|
||||
const func = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.functions.create(
|
||||
id || ID.unique(),
|
||||
.functions.create({
|
||||
functionId: id || ID.unique(),
|
||||
name,
|
||||
runtime,
|
||||
roles?.length ? roles : undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
true,
|
||||
undefined,
|
||||
execute: roles?.length ? roles : undefined,
|
||||
enabled: true,
|
||||
entrypoint,
|
||||
buildCommand,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
specification || undefined
|
||||
);
|
||||
commands: buildCommand,
|
||||
specification: specification || undefined
|
||||
});
|
||||
|
||||
// Add domain
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.proxy.createFunctionRule(
|
||||
`${ID.unique()}.${$regionalConsoleVariables._APP_DOMAIN_FUNCTIONS}`,
|
||||
func.$id
|
||||
);
|
||||
await sdk.forProject(page.params.region, page.params.project).proxy.createFunctionRule({
|
||||
domain: `${ID.unique()}.${$regionalConsoleVariables._APP_DOMAIN_FUNCTIONS}`,
|
||||
functionId: func.$id
|
||||
});
|
||||
|
||||
//Add variables
|
||||
const promises = variables.map((variable) =>
|
||||
sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.functions.createVariable(
|
||||
func.$id,
|
||||
variable.key,
|
||||
variable.value,
|
||||
variable?.secret ?? false
|
||||
)
|
||||
sdk.forProject(page.params.region, page.params.project).functions.createVariable({
|
||||
functionId: func.$id,
|
||||
key: variable.key,
|
||||
value: variable.value,
|
||||
secret: variable?.secret ?? false
|
||||
})
|
||||
);
|
||||
await Promise.all(promises);
|
||||
|
||||
|
||||
+33
-37
@@ -73,11 +73,11 @@
|
||||
|
||||
const detections = (await sdk
|
||||
.forProject(page.params.regionn, page.params.project)
|
||||
.vcs.createRepositoryDetection(
|
||||
data.installation.$id,
|
||||
page.params.repository,
|
||||
VCSDetectionType.Runtime
|
||||
)) as unknown as Models.DetectionRuntime; /* SDK return type is wrong atm */
|
||||
.vcs.createRepositoryDetection({
|
||||
installationId: data.installation.$id,
|
||||
providerRepositoryId: page.params.repository,
|
||||
type: VCSDetectionType.Runtime
|
||||
})) as unknown as Models.DetectionRuntime; /* SDK return type is wrong atm */
|
||||
|
||||
entrypoint = detections.entrypoint;
|
||||
buildCommand = detections.commands;
|
||||
@@ -95,51 +95,47 @@
|
||||
try {
|
||||
const func = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.functions.create(
|
||||
id || ID.unique(),
|
||||
.functions.create({
|
||||
functionId: id || ID.unique(),
|
||||
name,
|
||||
runtime,
|
||||
roles?.length ? roles : undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
true,
|
||||
undefined,
|
||||
execute: roles?.length ? roles : undefined,
|
||||
enabled: true,
|
||||
entrypoint,
|
||||
buildCommand,
|
||||
undefined,
|
||||
$installation.$id,
|
||||
$repository.id,
|
||||
branch,
|
||||
silentMode,
|
||||
rootDir,
|
||||
specification || undefined
|
||||
);
|
||||
commands: buildCommand,
|
||||
installationId: $installation.$id,
|
||||
providerRepositoryId: $repository.id,
|
||||
providerBranch: branch,
|
||||
providerSilentMode: silentMode,
|
||||
providerRootDirectory: rootDir,
|
||||
specification: specification || undefined
|
||||
});
|
||||
|
||||
// Add domain
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.proxy.createFunctionRule(
|
||||
`${ID.unique()}.${$regionalConsoleVariables._APP_DOMAIN_FUNCTIONS}`,
|
||||
func.$id
|
||||
);
|
||||
await sdk.forProject(page.params.region, page.params.project).proxy.createFunctionRule({
|
||||
domain: `${ID.unique()}.${$regionalConsoleVariables._APP_DOMAIN_FUNCTIONS}`,
|
||||
functionId: func.$id
|
||||
});
|
||||
|
||||
//Add variables
|
||||
const promises = variables.map((variable) =>
|
||||
sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.functions.createVariable(
|
||||
func.$id,
|
||||
variable.key,
|
||||
variable.value,
|
||||
variable?.secret ?? false
|
||||
)
|
||||
sdk.forProject(page.params.region, page.params.project).functions.createVariable({
|
||||
functionId: func.$id,
|
||||
key: variable.key,
|
||||
value: variable.value,
|
||||
secret: variable?.secret ?? false
|
||||
})
|
||||
);
|
||||
await Promise.all(promises);
|
||||
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.functions.createVcsDeployment(func.$id, VCSDeploymentType.Branch, branch, true);
|
||||
.functions.createVcsDeployment({
|
||||
functionId: func.$id,
|
||||
type: VCSDeploymentType.Branch,
|
||||
reference: branch,
|
||||
activate: true
|
||||
});
|
||||
|
||||
trackEvent(Submit.FunctionCreate, {
|
||||
source: 'repository',
|
||||
|
||||
+45
-40
@@ -96,7 +96,11 @@
|
||||
isCreatingRepository = true;
|
||||
const repo = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.vcs.createRepository($installation.$id, repositoryName, repositoryPrivate);
|
||||
.vcs.createRepository({
|
||||
installationId: $installation.$id,
|
||||
name: repositoryName,
|
||||
xprivate: repositoryPrivate
|
||||
});
|
||||
repository.set(repo);
|
||||
selectedRepository = repo.id;
|
||||
showConfig = true;
|
||||
@@ -123,60 +127,61 @@
|
||||
|
||||
const func = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.functions.create(
|
||||
id || ID.unique(),
|
||||
.functions.create({
|
||||
functionId: id || ID.unique(),
|
||||
name,
|
||||
runtime as Runtime,
|
||||
execute && data.template.permissions?.length
|
||||
? data.template.permissions
|
||||
: undefined,
|
||||
data.template.events?.length ? data.template.events : undefined,
|
||||
data.template.cron || undefined,
|
||||
data.template.timeout ? data.template.timeout : undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
entrypoint || rt?.entrypoint || undefined,
|
||||
rt?.commands || undefined,
|
||||
selectedScopes?.length ? selectedScopes : undefined,
|
||||
connectBehaviour === 'later' ? undefined : $installation?.$id || undefined,
|
||||
connectBehaviour === 'later' ? undefined : $repository?.id || undefined,
|
||||
branch,
|
||||
silentMode,
|
||||
rootDir,
|
||||
specification || undefined
|
||||
);
|
||||
runtime: runtime as Runtime,
|
||||
execute:
|
||||
execute && data.template.permissions?.length
|
||||
? data.template.permissions
|
||||
: undefined,
|
||||
events: data.template.events?.length ? data.template.events : undefined,
|
||||
schedule: data.template.cron || undefined,
|
||||
timeout: data.template.timeout || undefined,
|
||||
entrypoint: entrypoint || rt?.entrypoint || undefined,
|
||||
commands: rt?.commands || undefined,
|
||||
scopes: selectedScopes?.length ? selectedScopes : undefined,
|
||||
installationId:
|
||||
connectBehaviour === 'later' ? undefined : $installation?.$id,
|
||||
providerRepositoryId:
|
||||
connectBehaviour === 'later' ? undefined : $repository?.id,
|
||||
providerBranch: branch,
|
||||
providerSilentMode: silentMode,
|
||||
providerRootDirectory: rootDir,
|
||||
specification: specification || undefined
|
||||
});
|
||||
|
||||
// Add domain
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.proxy.createFunctionRule(
|
||||
`${ID.unique()}.${$regionalConsoleVariables._APP_DOMAIN_FUNCTIONS}`,
|
||||
func.$id
|
||||
);
|
||||
.proxy.createFunctionRule({
|
||||
domain: `${ID.unique()}.${$regionalConsoleVariables._APP_DOMAIN_FUNCTIONS}`,
|
||||
functionId: func.$id
|
||||
});
|
||||
|
||||
// Add variables
|
||||
const promises = variables.map((variable) =>
|
||||
sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.functions.createVariable(
|
||||
func.$id,
|
||||
variable.name,
|
||||
variable.value,
|
||||
variable?.secret ?? false
|
||||
)
|
||||
.functions.createVariable({
|
||||
functionId: func.$id,
|
||||
key: variable.name,
|
||||
value: variable.value,
|
||||
secret: variable?.secret ?? false
|
||||
})
|
||||
);
|
||||
await Promise.all(promises);
|
||||
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.functions.createTemplateDeployment(
|
||||
func.$id,
|
||||
data.template.providerRepositoryId || undefined,
|
||||
data.template.providerOwner || undefined,
|
||||
rt?.providerRootDirectory || undefined,
|
||||
data.template.providerVersion || undefined,
|
||||
true
|
||||
);
|
||||
.functions.createTemplateDeployment({
|
||||
functionId: func.$id,
|
||||
repository: data.template.providerRepositoryId || undefined,
|
||||
owner: data.template.providerOwner || undefined,
|
||||
rootDirectory: rt?.providerRootDirectory || undefined,
|
||||
version: data.template.providerVersion || undefined,
|
||||
activate: true
|
||||
});
|
||||
|
||||
trackEvent(Submit.FunctionCreate, {
|
||||
runtime: runtime,
|
||||
|
||||
+13
-9
@@ -21,17 +21,21 @@ export const load: PageLoad = async ({ params, depends, url, route, parent }) =>
|
||||
query,
|
||||
installations: data.installations,
|
||||
activeDeployment: data.function.deploymentId
|
||||
? await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.functions.getDeployment(params.function, data.function.deploymentId)
|
||||
? await sdk.forProject(params.region, params.project).functions.getDeployment({
|
||||
functionId: params.function,
|
||||
deploymentId: data.function.deploymentId
|
||||
})
|
||||
: null,
|
||||
deploymentList: await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.functions.listDeployments(params.function, [
|
||||
Query.limit(limit),
|
||||
Query.offset(offset),
|
||||
Query.orderDesc(''),
|
||||
...parsedQueries.values()
|
||||
])
|
||||
.functions.listDeployments({
|
||||
functionId: params.function,
|
||||
queries: [
|
||||
Query.limit(limit),
|
||||
Query.offset(offset),
|
||||
Query.orderDesc(''),
|
||||
...parsedQueries.values()
|
||||
]
|
||||
})
|
||||
};
|
||||
};
|
||||
+4
-1
@@ -8,7 +8,10 @@ export const load: PageLoad = async ({ params, depends, parent }) => {
|
||||
|
||||
const deployment = await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.functions.getDeployment(params.function, params.deployment);
|
||||
.functions.getDeployment({
|
||||
functionId: params.function,
|
||||
deploymentId: params.deployment
|
||||
});
|
||||
|
||||
return {
|
||||
func,
|
||||
|
||||
+13
-15
@@ -26,20 +26,18 @@ export const load: PageLoad = async ({ depends, params, url, route }) => {
|
||||
limit,
|
||||
query,
|
||||
search,
|
||||
proxyRules: await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.proxy.listRules(
|
||||
[
|
||||
Query.equal('type', [RuleType.DEPLOYMENT, RuleType.REDIRECT]),
|
||||
Query.equal('deploymentResourceType', DeploymentResourceType.FUNCTION),
|
||||
Query.equal('deploymentResourceId', params.function),
|
||||
Query.equal('trigger', RuleTrigger.MANUAL),
|
||||
Query.limit(limit),
|
||||
Query.offset(offset),
|
||||
Query.orderDesc(''),
|
||||
...parsedQueries.values()
|
||||
],
|
||||
search || undefined
|
||||
)
|
||||
proxyRules: await sdk.forProject(params.region, params.project).proxy.listRules({
|
||||
queries: [
|
||||
Query.equal('type', [RuleType.DEPLOYMENT, RuleType.REDIRECT]),
|
||||
Query.equal('deploymentResourceType', DeploymentResourceType.FUNCTION),
|
||||
Query.equal('deploymentResourceId', params.function),
|
||||
Query.equal('trigger', RuleTrigger.MANUAL),
|
||||
Query.limit(limit),
|
||||
Query.offset(offset),
|
||||
Query.orderDesc(''),
|
||||
...parsedQueries.values()
|
||||
],
|
||||
search: search || undefined
|
||||
})
|
||||
};
|
||||
};
|
||||
+33
-30
@@ -74,21 +74,28 @@
|
||||
if (behaviour === 'BRANCH') {
|
||||
rule = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.proxy.createFunctionRule(domainName, page.params.function, branch);
|
||||
.proxy.createFunctionRule({
|
||||
domain: domainName,
|
||||
functionId: page.params.function,
|
||||
branch
|
||||
});
|
||||
} else if (behaviour === 'REDIRECT') {
|
||||
rule = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.proxy.createRedirectRule(
|
||||
domainName,
|
||||
redirect,
|
||||
.proxy.createRedirectRule({
|
||||
domain: domainName,
|
||||
url: redirect,
|
||||
statusCode,
|
||||
page.params.function,
|
||||
ProxyResourceType.Function
|
||||
);
|
||||
resourceId: page.params.function,
|
||||
resourceType: ProxyResourceType.Function
|
||||
});
|
||||
} else if (behaviour === 'ACTIVE') {
|
||||
rule = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.proxy.createFunctionRule(domainName, page.params.function);
|
||||
.proxy.createFunctionRule({
|
||||
domain: domainName,
|
||||
functionId: page.params.function
|
||||
});
|
||||
}
|
||||
if (rule?.status === 'verified') {
|
||||
await goto(routeBase);
|
||||
@@ -112,28 +119,24 @@
|
||||
if (!isValueOfStringEnum(Runtime, data.func.runtime)) {
|
||||
throw new Error(`Invalid runtime: ${data.func.runtime}`);
|
||||
}
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.functions.update(
|
||||
data.func.$id,
|
||||
data.func.name,
|
||||
data.func.runtime as Runtime,
|
||||
data.func.execute || undefined,
|
||||
data.func.events || undefined,
|
||||
data.func.schedule || undefined,
|
||||
data.func.timeout || undefined,
|
||||
data.func.enabled || undefined,
|
||||
data.func.logging || undefined,
|
||||
data.func.entrypoint,
|
||||
data.func.commands || undefined,
|
||||
data.func.scopes || undefined,
|
||||
selectedInstallationId,
|
||||
selectedRepository,
|
||||
'main',
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
);
|
||||
|
||||
await sdk.forProject(page.params.region, page.params.project).functions.update({
|
||||
functionId: data.func.$id,
|
||||
name: data.func.name,
|
||||
runtime: data.func.runtime as Runtime,
|
||||
execute: data.func.execute || undefined,
|
||||
events: data.func.events || undefined,
|
||||
schedule: data.func.schedule || undefined,
|
||||
timeout: data.func.timeout || undefined,
|
||||
enabled: data.func.enabled || undefined,
|
||||
logging: data.func.logging || undefined,
|
||||
entrypoint: data.func.entrypoint,
|
||||
commands: data.func.commands || undefined,
|
||||
scopes: data.func.scopes || undefined,
|
||||
installationId: selectedInstallationId,
|
||||
providerRepositoryId: selectedRepository,
|
||||
providerBranch: 'main'
|
||||
});
|
||||
await invalidate(Dependencies.FUNCTION);
|
||||
} catch {
|
||||
return;
|
||||
|
||||
+8
-7
@@ -9,12 +9,12 @@ export const load = async ({ parent, depends, params }) => {
|
||||
depends(Dependencies.DOMAINS, Dependencies.FUNCTION_DOMAINS);
|
||||
|
||||
const [rules, installations, domains] = await Promise.all([
|
||||
sdk
|
||||
.forProject(params.region, params.project)
|
||||
.proxy.listRules([
|
||||
sdk.forProject(params.region, params.project).proxy.listRules({
|
||||
queries: [
|
||||
Query.equal('type', RuleType.DEPLOYMENT),
|
||||
Query.equal('trigger', RuleTrigger.MANUAL)
|
||||
]),
|
||||
]
|
||||
}),
|
||||
sdk.forProject(params.region, params.project).vcs.listInstallations(),
|
||||
isCloud
|
||||
? sdk.forConsole.domains.list({ queries: [Query.equal('teamId', organization.$id)] })
|
||||
@@ -28,9 +28,10 @@ export const load = async ({ parent, depends, params }) => {
|
||||
installations,
|
||||
branches:
|
||||
func?.installationId && func?.providerRepositoryId
|
||||
? await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.vcs.listRepositoryBranches(func.installationId, func.providerRepositoryId)
|
||||
? await sdk.forProject(params.region, params.project).vcs.listRepositoryBranches({
|
||||
installationId: func.installationId,
|
||||
providerRepositoryId: func.providerRepositoryId
|
||||
})
|
||||
: undefined
|
||||
};
|
||||
};
|
||||
+6
-6
@@ -56,16 +56,16 @@
|
||||
if (selectedTab !== 'nameserver') {
|
||||
const ruleData = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.proxy.updateRuleVerification(ruleId);
|
||||
.proxy.updateRuleVerification({ ruleId });
|
||||
verified = ruleData.status === 'verified';
|
||||
} else if (isNewDomain && isCloud) {
|
||||
const domainData = await sdk.forConsole.domains.create(
|
||||
$organization.$id,
|
||||
page.params.domain
|
||||
);
|
||||
const domainData = await sdk.forConsole.domains.create({
|
||||
teamId: $organization.$id,
|
||||
domain: page.params.domain
|
||||
});
|
||||
verified = domainData.nameservers.toLowerCase() === 'appwrite';
|
||||
} else if (!isNewDomain && isCloud) {
|
||||
const domain = await sdk.forConsole.domains.updateNameservers(domainId);
|
||||
const domain = await sdk.forConsole.domains.updateNameservers({ domainId });
|
||||
verified = domain.nameservers.toLowerCase() === 'appwrite';
|
||||
if (!verified)
|
||||
throw new Error(
|
||||
|
||||
+3
-1
@@ -9,7 +9,9 @@ export const load = async ({ depends, parent }) => {
|
||||
|
||||
let domainsList: Models.DomainsList;
|
||||
if (isCloud) {
|
||||
domainsList = await sdk.forConsole.domains.list([Query.equal('teamId', organization.$id)]);
|
||||
domainsList = await sdk.forConsole.domains.list({
|
||||
queries: [Query.equal('teamId', organization.$id)]
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
+5
-4
@@ -22,13 +22,14 @@ export const load: PageLoad = async ({ params, depends, url, route, parent }) =>
|
||||
limit,
|
||||
query,
|
||||
func,
|
||||
executions: await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.functions.listExecutions(params.function, [
|
||||
executions: await sdk.forProject(params.region, params.project).functions.listExecutions({
|
||||
functionId: params.function,
|
||||
queries: [
|
||||
Query.limit(limit),
|
||||
Query.offset(offset),
|
||||
Query.orderDesc(''),
|
||||
...parsedQueries.values()
|
||||
])
|
||||
]
|
||||
})
|
||||
};
|
||||
};
|
||||
+7
-7
@@ -97,15 +97,15 @@
|
||||
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.functions.createExecution(
|
||||
func.$id,
|
||||
.functions.createExecution({
|
||||
functionId: func.$id,
|
||||
body,
|
||||
true,
|
||||
path,
|
||||
async: true,
|
||||
xpath: path,
|
||||
method,
|
||||
headersObject,
|
||||
isScheduled ? dateTime.toISOString() : undefined
|
||||
);
|
||||
headers: headersObject,
|
||||
scheduledAt: isScheduled ? dateTime.toISOString() : undefined
|
||||
});
|
||||
await goto(
|
||||
`${base}/project-${page.params.region}-${page.params.project}/functions/function-${func.$id}/executions`
|
||||
);
|
||||
|
||||
+4
-3
@@ -9,9 +9,10 @@ export const load: PageLoad = async ({ params, depends, parent }) => {
|
||||
return {
|
||||
func: data.function,
|
||||
activeDeployment: data.function.deploymentId
|
||||
? await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.functions.getDeployment(params.function, data.function.deploymentId)
|
||||
? await sdk.forProject(params.region, params.project).functions.getDeployment({
|
||||
functionId: params.function,
|
||||
deploymentId: data.function.deploymentId
|
||||
})
|
||||
: null,
|
||||
proxyRuleList: data.proxyRuleList
|
||||
};
|
||||
|
||||
+14
-7
@@ -28,9 +28,12 @@
|
||||
let showAlert = true;
|
||||
|
||||
const sdkCreateVariable = async (key: string, value: string, secret?: boolean) => {
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.functions.createVariable(data.function.$id, key, value, secret);
|
||||
await sdk.forProject(page.params.region, page.params.project).functions.createVariable({
|
||||
functionId: data.function.$id,
|
||||
key,
|
||||
value,
|
||||
secret
|
||||
});
|
||||
await Promise.all([invalidate(Dependencies.VARIABLES), invalidate(Dependencies.FUNCTION)]);
|
||||
};
|
||||
|
||||
@@ -40,16 +43,20 @@
|
||||
value: string,
|
||||
secret?: boolean
|
||||
) => {
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.functions.updateVariable(data.function.$id, variableId, key, value, secret);
|
||||
await sdk.forProject(page.params.region, page.params.project).functions.updateVariable({
|
||||
functionId: data.function.$id,
|
||||
variableId,
|
||||
key,
|
||||
value,
|
||||
secret
|
||||
});
|
||||
await Promise.all([invalidate(Dependencies.VARIABLES), invalidate(Dependencies.FUNCTION)]);
|
||||
};
|
||||
|
||||
const sdkDeleteVariable = async (variableId: string) => {
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.functions.deleteVariable(data.function.$id, variableId);
|
||||
.functions.deleteVariable({ functionId: data.function.$id, variableId });
|
||||
await Promise.all([invalidate(Dependencies.VARIABLES), invalidate(Dependencies.FUNCTION)]);
|
||||
};
|
||||
</script>
|
||||
|
||||
+3
-3
@@ -10,8 +10,8 @@ export const load: LayoutLoad = async ({ params, depends }) => {
|
||||
return {
|
||||
header: Header,
|
||||
breadcrumbs: Breadcrumbs,
|
||||
provider: await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.messaging.getProvider(params.provider)
|
||||
provider: await sdk.forProject(params.region, params.project).messaging.getProvider({
|
||||
providerId: params.provider
|
||||
})
|
||||
};
|
||||
};
|
||||
@@ -5,6 +5,6 @@ import { Dependencies } from '$lib/constants';
|
||||
export const load: PageLoad = async ({ params, depends }) => {
|
||||
depends(Dependencies.DEV_KEYS);
|
||||
return {
|
||||
devKeys: await sdk.forConsole.projects.listDevKeys(params.project)
|
||||
devKeys: await sdk.forConsole.projects.listDevKeys({ projectId: params.project })
|
||||
};
|
||||
};
|
||||
@@ -7,7 +7,10 @@ import type { PageLoad } from './$types';
|
||||
export const load: PageLoad = async ({ params, depends }) => {
|
||||
depends(Dependencies.DEV_KEY);
|
||||
|
||||
const key = await sdk.forConsole.projects.getDevKey(params.project, params.key);
|
||||
const key = await sdk.forConsole.projects.getDevKey({
|
||||
projectId: params.project,
|
||||
keyId: params.key
|
||||
});
|
||||
if (key.expire) {
|
||||
key.expire = new Date(key.expire).toISOString().slice(0, 23);
|
||||
} else {
|
||||
|
||||
@@ -5,6 +5,6 @@ import { Dependencies } from '$lib/constants';
|
||||
export const load: PageLoad = async ({ params, depends }) => {
|
||||
depends(Dependencies.PLATFORMS);
|
||||
return {
|
||||
platforms: await sdk.forConsole.projects.listPlatforms(params.project)
|
||||
platforms: await sdk.forConsole.projects.listPlatforms({ projectId: params.project })
|
||||
};
|
||||
};
|
||||
+4
-1
@@ -10,6 +10,9 @@ export const load: PageLoad = async ({ params, depends }) => {
|
||||
return {
|
||||
header: Header,
|
||||
breadcrumbs: Breadcrumbs,
|
||||
platform: await sdk.forConsole.projects.getPlatform(params.project, params.platform)
|
||||
platform: await sdk.forConsole.projects.getPlatform({
|
||||
projectId: params.project,
|
||||
platformId: params.platform
|
||||
})
|
||||
};
|
||||
};
|
||||
@@ -58,7 +58,7 @@
|
||||
async function sdkCreateVariable(key: string, value: string, secret: boolean) {
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.projectApi.createVariable(key, value, secret);
|
||||
.projectApi.createVariable({ key, value, secret });
|
||||
await invalidate(Dependencies.PROJECT_VARIABLES);
|
||||
}
|
||||
|
||||
@@ -70,14 +70,14 @@
|
||||
) {
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.projectApi.updateVariable(variableId, key, value, secret);
|
||||
.projectApi.updateVariable({ variableId, key, value, secret });
|
||||
await invalidate(Dependencies.PROJECT_VARIABLES);
|
||||
}
|
||||
|
||||
async function sdkDeleteVariable(variableId: string) {
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.projectApi.deleteVariable(variableId);
|
||||
.projectApi.deleteVariable({ variableId });
|
||||
await invalidate(Dependencies.PROJECT_VARIABLES);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -11,9 +11,9 @@ export const load: PageLoad = async ({ depends, url, params }) => {
|
||||
|
||||
const [variables, installations] = await Promise.all([
|
||||
sdk.forProject(params.region, params.project).projectApi.listVariables(),
|
||||
sdk
|
||||
.forProject(params.region, params.project)
|
||||
.vcs.listInstallations([Query.limit(limit), Query.offset(offset)])
|
||||
sdk.forProject(params.region, params.project).vcs.listInstallations({
|
||||
queries: [Query.limit(limit), Query.offset(offset)]
|
||||
})
|
||||
]);
|
||||
|
||||
return {
|
||||
|
||||
@@ -23,12 +23,13 @@ export const load: PageLoad = async ({ depends, url, route, params }) => {
|
||||
queries.set(parsedQueries);
|
||||
|
||||
return {
|
||||
rules: await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.proxy.listRules(
|
||||
[Query.equal('type', RuleType.API), Query.equal('trigger', RuleTrigger.MANUAL)],
|
||||
search || undefined
|
||||
),
|
||||
rules: await sdk.forProject(params.region, params.project).proxy.listRules({
|
||||
queries: [
|
||||
Query.equal('type', RuleType.API),
|
||||
Query.equal('trigger', RuleTrigger.MANUAL)
|
||||
],
|
||||
search: search || undefined
|
||||
}),
|
||||
offset,
|
||||
limit,
|
||||
query,
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@
|
||||
try {
|
||||
const rule = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.proxy.createAPIRule(domainName.toLocaleLowerCase());
|
||||
.proxy.createAPIRule({ domain: domainName.toLocaleLowerCase() });
|
||||
if (rule?.status === 'verified') {
|
||||
await goto(routeBase);
|
||||
await invalidate(Dependencies.DOMAINS);
|
||||
|
||||
+6
-4
@@ -11,10 +11,12 @@ export const load = async ({ depends, params, parent }) => {
|
||||
const [rules, domains] = await Promise.all([
|
||||
sdk
|
||||
.forProject(params.region, params.project)
|
||||
.proxy.listRules([
|
||||
Query.equal('type', RuleType.API),
|
||||
Query.equal('trigger', RuleTrigger.MANUAL)
|
||||
]),
|
||||
.proxy.listRules({
|
||||
queries: [
|
||||
Query.equal('type', RuleType.API),
|
||||
Query.equal('trigger', RuleTrigger.MANUAL)
|
||||
]
|
||||
}),
|
||||
isCloud
|
||||
? sdk.forConsole.domains.list({ queries: [Query.equal('teamId', organization.$id)] })
|
||||
: Promise.resolve(null)
|
||||
|
||||
+5
-5
@@ -57,13 +57,13 @@
|
||||
if (selectedTab !== 'nameserver') {
|
||||
const ruleData = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.proxy.updateRuleVerification(ruleId);
|
||||
.proxy.updateRuleVerification({ ruleId });
|
||||
verified = ruleData.status === 'verified';
|
||||
} else if (isNewDomain && isCloud) {
|
||||
const domainData = await sdk.forConsole.domains.create(
|
||||
$organization.$id,
|
||||
page.params.domain
|
||||
);
|
||||
const domainData = await sdk.forConsole.domains.create({
|
||||
teamId: $organization.$id,
|
||||
domain: page.params.domain
|
||||
});
|
||||
verified = domainData.nameservers.toLowerCase() === 'appwrite';
|
||||
} else if (!isNewDomain && isCloud) {
|
||||
const domain = await sdk.forConsole.domains.updateNameservers({
|
||||
|
||||
@@ -88,10 +88,10 @@
|
||||
const deployToCloud = async () => {
|
||||
const currEndpoint = getCurrentEndpoint();
|
||||
// Create API key
|
||||
const { secret } = await sdk.forConsole.projects.createKey(
|
||||
$project.$id,
|
||||
`[AUTO-GENERATED] Migration ${new Date().toISOString()}`,
|
||||
[
|
||||
const { secret } = await sdk.forConsole.projects.createKey({
|
||||
projectId: $project.$id,
|
||||
name: `[AUTO-GENERATED] Migration ${new Date().toISOString()}`,
|
||||
scopes: [
|
||||
'users.read',
|
||||
'teams.read',
|
||||
'databases.read',
|
||||
@@ -109,9 +109,8 @@
|
||||
'locale.read',
|
||||
'avatars.read',
|
||||
'health.read'
|
||||
],
|
||||
undefined
|
||||
);
|
||||
]
|
||||
});
|
||||
|
||||
const migrationData = {
|
||||
endpoint: currEndpoint,
|
||||
|
||||
@@ -60,18 +60,18 @@
|
||||
password = undefined;
|
||||
}
|
||||
|
||||
await sdk.forConsole.projects.updateSmtp(
|
||||
$project.$id,
|
||||
await sdk.forConsole.projects.updateSMTP({
|
||||
projectId: $project.$id,
|
||||
enabled,
|
||||
senderName ? senderName : undefined,
|
||||
senderEmail ? senderEmail : undefined,
|
||||
replyTo ? replyTo : undefined,
|
||||
host ? host : undefined,
|
||||
port ? port : undefined,
|
||||
username ? username : undefined,
|
||||
password ? password : undefined,
|
||||
secure ? (secure as SMTPSecure) : undefined
|
||||
);
|
||||
senderName: senderName || undefined,
|
||||
senderEmail: senderEmail || undefined,
|
||||
replyTo: replyTo || undefined,
|
||||
host: host || undefined,
|
||||
port: port || undefined,
|
||||
username: username || undefined,
|
||||
password: password || undefined,
|
||||
secure: secure ? (secure as SMTPSecure) : undefined
|
||||
});
|
||||
|
||||
invalidate(Dependencies.PROJECT);
|
||||
addNotification({
|
||||
|
||||
@@ -10,6 +10,6 @@ export const load: PageLoad = async ({ params, url, depends }) => {
|
||||
|
||||
return {
|
||||
page,
|
||||
webhooks: await sdk.forConsole.projects.listWebhooks(params.project)
|
||||
webhooks: await sdk.forConsole.projects.listWebhooks({ projectId: params.project })
|
||||
};
|
||||
};
|
||||
+4
-1
@@ -10,6 +10,9 @@ export const load: LayoutLoad = async ({ params, depends }) => {
|
||||
return {
|
||||
header: Header,
|
||||
breadcrumbs: Breadcrumbs,
|
||||
webhook: await sdk.forConsole.projects.getWebhook(params.project, params.webhook)
|
||||
webhook: await sdk.forConsole.projects.getWebhook({
|
||||
projectId: params.project,
|
||||
webhookId: params.webhook
|
||||
})
|
||||
};
|
||||
};
|
||||
+6
-6
@@ -25,16 +25,16 @@
|
||||
export let data;
|
||||
async function create() {
|
||||
try {
|
||||
const webhook = await sdk.forConsole.projects.createWebhook(
|
||||
data.project.$id,
|
||||
const webhook = await sdk.forConsole.projects.createWebhook({
|
||||
projectId: data.project.$id,
|
||||
name,
|
||||
events,
|
||||
url,
|
||||
security,
|
||||
true,
|
||||
httpUser || undefined,
|
||||
httpPass || undefined
|
||||
);
|
||||
enabled: true,
|
||||
httpUser: httpUser || undefined,
|
||||
httpPass: httpPass || undefined
|
||||
});
|
||||
addNotification({
|
||||
message: 'Webhook has been created',
|
||||
type: 'success'
|
||||
|
||||
@@ -33,12 +33,10 @@ export const load = async ({ url, depends, route, params, parent }) => {
|
||||
offset,
|
||||
limit,
|
||||
search,
|
||||
siteList: await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.sites.list(
|
||||
[Query.limit(limit), Query.offset(offset), Query.orderDesc('')],
|
||||
search || undefined
|
||||
),
|
||||
siteList: await sdk.forProject(params.region, params.project).sites.list({
|
||||
queries: [Query.limit(limit), Query.offset(offset), Query.orderDesc('')],
|
||||
search: search || undefined
|
||||
}),
|
||||
view
|
||||
};
|
||||
};
|
||||
+8
-7
@@ -19,15 +19,15 @@ export const load: PageLoad = async ({ url, depends, params }) => {
|
||||
siteId,
|
||||
deploymentId
|
||||
}),
|
||||
sdk
|
||||
.forProject(params.region, params.project)
|
||||
.proxy.listRules([
|
||||
sdk.forProject(params.region, params.project).proxy.listRules({
|
||||
queries: [
|
||||
Query.equal('type', RuleType.DEPLOYMENT),
|
||||
Query.equal('deploymentResourceType', DeploymentResourceType.SITE),
|
||||
Query.equal('deploymentResourceId', siteId),
|
||||
Query.equal('deploymentId', deploymentId),
|
||||
Query.equal('trigger', RuleTrigger.MANUAL)
|
||||
])
|
||||
]
|
||||
})
|
||||
]);
|
||||
|
||||
return {
|
||||
@@ -35,9 +35,10 @@ export const load: PageLoad = async ({ url, depends, params }) => {
|
||||
deployment,
|
||||
proxyRuleList,
|
||||
repository: site?.installationId
|
||||
? await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.vcs.getRepository(site.installationId, site.providerRepositoryId)
|
||||
? await sdk.forProject(params.region, params.project).vcs.getRepository({
|
||||
installationId: site.installationId,
|
||||
providerRepositoryId: site.providerRepositoryId
|
||||
})
|
||||
: undefined
|
||||
};
|
||||
};
|
||||
+17
-22
@@ -37,28 +37,23 @@
|
||||
|
||||
async function connect(selectedInstallationId: string, selectedRepository: string) {
|
||||
try {
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.sites.update(
|
||||
data.site.$id,
|
||||
data.site.name,
|
||||
data.site.framework as Framework,
|
||||
data.site.enabled,
|
||||
data.site.logging || undefined,
|
||||
data.site.timeout,
|
||||
data.site.installCommand,
|
||||
data.site.buildCommand,
|
||||
data.site.outputDirectory,
|
||||
data.site.buildRuntime as BuildRuntime,
|
||||
data.site.adapter as Adapter,
|
||||
data.site.fallbackFile,
|
||||
selectedInstallationId,
|
||||
selectedRepository,
|
||||
'main',
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
);
|
||||
await sdk.forProject(page.params.region, page.params.project).sites.update({
|
||||
siteId: data.site.$id,
|
||||
name: data.site.name,
|
||||
framework: data.site.framework as Framework,
|
||||
enabled: data.site.enabled,
|
||||
logging: data.site.logging || undefined,
|
||||
timeout: data.site.timeout,
|
||||
installCommand: data.site.installCommand,
|
||||
buildCommand: data.site.buildCommand,
|
||||
outputDirectory: data.site.outputDirectory,
|
||||
buildRuntime: data.site.buildRuntime as BuildRuntime,
|
||||
adapter: data.site.adapter as Adapter,
|
||||
fallbackFile: data.site.fallbackFile,
|
||||
installationId: selectedInstallationId,
|
||||
providerRepositoryId: selectedRepository,
|
||||
providerBranch: 'main'
|
||||
});
|
||||
invalidate(Dependencies.SITE);
|
||||
} catch {
|
||||
return;
|
||||
|
||||
+27
-43
@@ -63,59 +63,43 @@
|
||||
const buildRuntime = Object.values(BuildRuntime).find(
|
||||
(f) => f === framework.buildRuntime
|
||||
);
|
||||
let site = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.sites.create(
|
||||
id || ID.unique(),
|
||||
name,
|
||||
fr,
|
||||
buildRuntime,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
installCommand || undefined,
|
||||
buildCommand || undefined,
|
||||
outputDirectory || undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
);
|
||||
let site = await sdk.forProject(page.params.region, page.params.project).sites.create({
|
||||
siteId: id || ID.unique(),
|
||||
name,
|
||||
framework: fr,
|
||||
buildRuntime,
|
||||
installCommand: installCommand || undefined,
|
||||
buildCommand: buildCommand || undefined,
|
||||
outputDirectory: outputDirectory || undefined
|
||||
});
|
||||
|
||||
// Add domain
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.proxy.createSiteRule(
|
||||
`${domain}.${$regionalConsoleVariables._APP_DOMAIN_SITES}`,
|
||||
site.$id
|
||||
);
|
||||
await sdk.forProject(page.params.region, page.params.project).proxy.createSiteRule({
|
||||
domain: `${domain}.${$regionalConsoleVariables._APP_DOMAIN_SITES}`,
|
||||
siteId: site.$id
|
||||
});
|
||||
|
||||
//Add variables
|
||||
const promises = variables.map((variable) =>
|
||||
sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.sites.createVariable(
|
||||
site.$id,
|
||||
variable.key,
|
||||
variable.value,
|
||||
variable?.secret ?? false
|
||||
)
|
||||
sdk.forProject(page.params.region, page.params.project).sites.createVariable({
|
||||
siteId: site.$id,
|
||||
key: variable.key,
|
||||
value: variable.value,
|
||||
secret: variable?.secret ?? false
|
||||
})
|
||||
);
|
||||
await Promise.all(promises);
|
||||
|
||||
const deployment = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.sites.createDeployment(
|
||||
site.$id,
|
||||
files[0],
|
||||
true,
|
||||
installCommand || undefined,
|
||||
buildCommand || undefined,
|
||||
outputDirectory || undefined
|
||||
);
|
||||
.sites.createDeployment({
|
||||
siteId: site.$id,
|
||||
code: files[0],
|
||||
activate: true,
|
||||
installCommand: installCommand || undefined,
|
||||
buildCommand: buildCommand || undefined,
|
||||
outputDirectory: outputDirectory || undefined
|
||||
});
|
||||
|
||||
trackEvent(Submit.SiteCreate, {
|
||||
source: 'manual',
|
||||
|
||||
@@ -18,6 +18,6 @@ export const load = async ({ parent, params }) => {
|
||||
frameworks,
|
||||
template: await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.sites.getTemplate('starter-for-js')
|
||||
.sites.getTemplate({ templateId: 'starter-for-js' })
|
||||
};
|
||||
};
|
||||
+32
-42
@@ -60,12 +60,12 @@
|
||||
try {
|
||||
const response = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.vcs.createRepositoryDetection(
|
||||
$installation.$id,
|
||||
page.params.repository,
|
||||
VCSDetectionType.Framework,
|
||||
rootDir
|
||||
);
|
||||
.vcs.createRepositoryDetection({
|
||||
installationId: $installation.$id,
|
||||
providerRepositoryId: page.params.repository,
|
||||
type: VCSDetectionType.Framework,
|
||||
providerRootDirectory: rootDir
|
||||
});
|
||||
framework = data.frameworks.frameworks.find((f) => f.key === response.framework);
|
||||
adapter = framework?.adapters[0];
|
||||
installCommand = adapter?.installCommand;
|
||||
@@ -94,47 +94,37 @@
|
||||
const buildRuntime = Object.values(BuildRuntime).find(
|
||||
(f) => f === framework.buildRuntime
|
||||
);
|
||||
let site = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.sites.create(
|
||||
id || ID.unique(),
|
||||
name,
|
||||
fr,
|
||||
buildRuntime,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
installCommand,
|
||||
buildCommand,
|
||||
outputDirectory,
|
||||
undefined,
|
||||
data.installation.$id,
|
||||
undefined,
|
||||
data.repository.id,
|
||||
branch,
|
||||
silentMode,
|
||||
rootDir
|
||||
);
|
||||
let site = await sdk.forProject(page.params.region, page.params.project).sites.create({
|
||||
siteId: id || ID.unique(),
|
||||
name,
|
||||
framework: fr,
|
||||
buildRuntime,
|
||||
installCommand,
|
||||
buildCommand,
|
||||
outputDirectory,
|
||||
installationId: data.installation.$id,
|
||||
providerRepositoryId: data.repository.id,
|
||||
providerBranch: branch,
|
||||
providerSilentMode: silentMode,
|
||||
providerRootDirectory: rootDir
|
||||
});
|
||||
|
||||
// Add domain
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.proxy.createSiteRule(
|
||||
`${domain}.${$regionalConsoleVariables._APP_DOMAIN_SITES}`,
|
||||
site.$id
|
||||
);
|
||||
await sdk.forProject(page.params.region, page.params.project).proxy.createSiteRule({
|
||||
domain: `${domain}.${$regionalConsoleVariables._APP_DOMAIN_SITES}`,
|
||||
siteId: site.$id
|
||||
});
|
||||
|
||||
//Add variables
|
||||
// Add variables
|
||||
const promises = variables.map((variable) =>
|
||||
sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.sites.createVariable(
|
||||
site.$id,
|
||||
variable.key,
|
||||
variable.value,
|
||||
variable?.secret ?? false
|
||||
)
|
||||
sdk.forProject(page.params.region, page.params.project).sites.createVariable({
|
||||
siteId: site.$id,
|
||||
key: variable.key,
|
||||
value: variable.value,
|
||||
secret: variable?.secret ?? false
|
||||
})
|
||||
);
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
const deployment = await sdk
|
||||
|
||||
+40
-43
@@ -77,7 +77,11 @@
|
||||
isCreatingRepository = true;
|
||||
const repo = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.vcs.createRepository($installation.$id, repositoryName, repositoryPrivate);
|
||||
.vcs.createRepository({
|
||||
installationId: $installation.$id,
|
||||
name: repositoryName,
|
||||
xprivate: repositoryPrivate
|
||||
});
|
||||
repository.set(repo);
|
||||
selectedRepository = repo.id;
|
||||
showSiteConfig = true;
|
||||
@@ -112,59 +116,52 @@
|
||||
);
|
||||
let site = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.sites.create(
|
||||
id || ID.unique(),
|
||||
.sites.create({
|
||||
siteId: id || ID.unique(),
|
||||
name,
|
||||
fr,
|
||||
framework: fr,
|
||||
buildRuntime,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
framework.installCommand,
|
||||
framework.buildCommand,
|
||||
framework.outputDirectory,
|
||||
framework.adapter as unknown as Adapter,
|
||||
connectBehaviour === 'later'
|
||||
? undefined
|
||||
: selectedInstallationId || undefined,
|
||||
framework?.fallbackFile || undefined,
|
||||
selectedRepository || undefined,
|
||||
branch || undefined,
|
||||
selectedRepository ? silentMode : undefined,
|
||||
rootDir || undefined
|
||||
);
|
||||
installCommand: framework.installCommand,
|
||||
buildCommand: framework.buildCommand,
|
||||
outputDirectory: framework.outputDirectory,
|
||||
adapter: framework.adapter as unknown as Adapter,
|
||||
installationId:
|
||||
connectBehaviour === 'later' ? undefined : selectedInstallationId,
|
||||
fallbackFile: framework?.fallbackFile,
|
||||
providerRepositoryId: selectedRepository,
|
||||
providerBranch: branch,
|
||||
providerSilentMode: selectedRepository ? silentMode : undefined,
|
||||
providerRootDirectory: rootDir
|
||||
});
|
||||
|
||||
// Add domain
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.proxy.createSiteRule(
|
||||
`${domain}.${$regionalConsoleVariables._APP_DOMAIN_SITES}`,
|
||||
site.$id
|
||||
);
|
||||
await sdk.forProject(page.params.region, page.params.project).proxy.createSiteRule({
|
||||
domain: `${domain}.${$regionalConsoleVariables._APP_DOMAIN_SITES}`,
|
||||
siteId: site.$id
|
||||
});
|
||||
|
||||
//Add variables
|
||||
// Add variables
|
||||
const promises = variables.map((variable) =>
|
||||
sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.sites.createVariable(
|
||||
site.$id,
|
||||
variable.name,
|
||||
variable.value,
|
||||
variable?.secret ?? false
|
||||
)
|
||||
sdk.forProject(page.params.region, page.params.project).sites.createVariable({
|
||||
siteId: site.$id,
|
||||
key: variable.name,
|
||||
value: variable.value,
|
||||
secret: variable?.secret ?? false
|
||||
})
|
||||
);
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
const deployment = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.sites.createTemplateDeployment(
|
||||
site.$id,
|
||||
data.template.providerRepositoryId || undefined,
|
||||
data.template.providerOwner || undefined,
|
||||
framework.providerRootDirectory || undefined,
|
||||
data.template.providerVersion || undefined,
|
||||
true
|
||||
);
|
||||
.sites.createTemplateDeployment({
|
||||
siteId: site.$id,
|
||||
repository: data.template.providerRepositoryId,
|
||||
owner: data.template.providerOwner,
|
||||
rootDirectory: framework.providerRootDirectory,
|
||||
version: data.template.providerVersion,
|
||||
activate: true
|
||||
});
|
||||
|
||||
trackEvent(Submit.SiteCreate, {
|
||||
source: 'template',
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ export const load = async ({ parent, params }) => {
|
||||
await parent();
|
||||
const template = await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.sites.getTemplate(params.template);
|
||||
.sites.getTemplate({ templateId: params.template });
|
||||
const domain = await buildVerboseDomain(
|
||||
regionalConsoleVariables._APP_DOMAIN_SITES,
|
||||
template.name,
|
||||
|
||||
@@ -10,31 +10,35 @@ export const load = async ({ params, depends, parent }) => {
|
||||
const { site } = await parent();
|
||||
|
||||
const [deploymentList, prodReadyDeployments, proxyRuleList] = await Promise.all([
|
||||
sdk
|
||||
.forProject(params.region, params.project)
|
||||
.sites.listDeployments(params.site, [Query.limit(4), Query.orderDesc('')]),
|
||||
sdk
|
||||
.forProject(params.region, params.project)
|
||||
.sites.listDeployments(params.site, [
|
||||
sdk.forProject(params.region, params.project).sites.listDeployments({
|
||||
siteId: params.site,
|
||||
queries: [Query.limit(4), Query.orderDesc('')]
|
||||
}),
|
||||
sdk.forProject(params.region, params.project).sites.listDeployments({
|
||||
siteId: params.site,
|
||||
queries: [
|
||||
Query.equal('status', 'ready'),
|
||||
Query.equal('activate', true),
|
||||
Query.orderDesc('')
|
||||
]),
|
||||
]
|
||||
}),
|
||||
sdk
|
||||
.forProject(params.region, params.project)
|
||||
.proxy.listRules([
|
||||
Query.equal('type', RuleType.DEPLOYMENT),
|
||||
Query.equal('deploymentResourceType', DeploymentResourceType.SITE),
|
||||
Query.equal('deploymentResourceId', site.$id),
|
||||
Query.equal('deploymentId', site.deploymentId),
|
||||
Query.orderDesc('')
|
||||
])
|
||||
.proxy.listRules({
|
||||
queries: [
|
||||
Query.equal('type', RuleType.DEPLOYMENT),
|
||||
Query.equal('deploymentResourceType', DeploymentResourceType.SITE),
|
||||
Query.equal('deploymentResourceId', site.$id),
|
||||
Query.equal('deploymentId', site.deploymentId),
|
||||
Query.orderDesc('')
|
||||
]
|
||||
})
|
||||
]);
|
||||
|
||||
const deployment = deploymentList?.total
|
||||
? await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.sites.getDeployment(params.site, site.deploymentId)
|
||||
.sites.getDeployment({ siteId: params.site, deploymentId: site.deploymentId })
|
||||
: null;
|
||||
return {
|
||||
site,
|
||||
|
||||
+17
-22
@@ -45,28 +45,23 @@
|
||||
|
||||
async function connect(selectedInstallationId: string, selectedRepository: string) {
|
||||
try {
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.sites.update(
|
||||
data.site.$id,
|
||||
data.site.name,
|
||||
data.site.framework as Framework,
|
||||
data.site.enabled,
|
||||
data.site.logging || undefined,
|
||||
data.site.timeout,
|
||||
data.site.installCommand,
|
||||
data.site.buildCommand,
|
||||
data.site.outputDirectory,
|
||||
data.site.buildRuntime as BuildRuntime,
|
||||
data.site.adapter as Adapter,
|
||||
data.site.fallbackFile,
|
||||
selectedInstallationId,
|
||||
selectedRepository,
|
||||
'main',
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
);
|
||||
await sdk.forProject(page.params.region, page.params.project).sites.update({
|
||||
siteId: data.site.$id,
|
||||
name: data.site.name,
|
||||
framework: data.site.framework as Framework,
|
||||
enabled: data.site.enabled,
|
||||
logging: data.site.logging || undefined,
|
||||
timeout: data.site.timeout,
|
||||
installCommand: data.site.installCommand,
|
||||
buildCommand: data.site.buildCommand,
|
||||
outputDirectory: data.site.outputDirectory,
|
||||
buildRuntime: data.site.buildRuntime as BuildRuntime,
|
||||
adapter: data.site.adapter as Adapter,
|
||||
fallbackFile: data.site.fallbackFile,
|
||||
installationId: selectedInstallationId,
|
||||
providerRepositoryId: selectedRepository,
|
||||
providerBranch: 'main'
|
||||
});
|
||||
invalidate(Dependencies.SITE);
|
||||
} catch {
|
||||
return;
|
||||
|
||||
+6
-5
@@ -16,14 +16,15 @@ export const load = async ({ params, depends, url, route, parent }) => {
|
||||
queries.set(parsedQueries);
|
||||
|
||||
const [deploymentList, installations] = await Promise.all([
|
||||
sdk
|
||||
.forProject(params.region, params.project)
|
||||
.sites.listDeployments(params.site, [
|
||||
sdk.forProject(params.region, params.project).sites.listDeployments({
|
||||
siteId: params.site,
|
||||
queries: [
|
||||
Query.limit(limit),
|
||||
Query.offset(offset),
|
||||
Query.orderDesc(''),
|
||||
...parsedQueries.values()
|
||||
]),
|
||||
]
|
||||
}),
|
||||
sdk.forProject(params.region, params.project).vcs.listInstallations()
|
||||
]);
|
||||
|
||||
@@ -36,7 +37,7 @@ export const load = async ({ params, depends, url, route, parent }) => {
|
||||
site.deploymentId && deploymentList?.total
|
||||
? await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.sites.getDeployment(params.site, site.deploymentId)
|
||||
.sites.getDeployment({ siteId: params.site, deploymentId: site.deploymentId })
|
||||
: null,
|
||||
installations
|
||||
};
|
||||
|
||||
+8
-7
@@ -11,17 +11,18 @@ export const load: PageLoad = async ({ params, depends, parent }) => {
|
||||
const { site } = await parent();
|
||||
|
||||
const [deployment, proxyRuleList] = await Promise.all([
|
||||
sdk
|
||||
.forProject(params.region, params.project)
|
||||
.sites.getDeployment(params.site, params.deployment),
|
||||
sdk
|
||||
.forProject(params.region, params.project)
|
||||
.proxy.listRules([
|
||||
sdk.forProject(params.region, params.project).sites.getDeployment({
|
||||
siteId: params.site,
|
||||
deploymentId: params.deployment
|
||||
}),
|
||||
sdk.forProject(params.region, params.project).proxy.listRules({
|
||||
queries: [
|
||||
Query.equal('type', RuleType.DEPLOYMENT),
|
||||
Query.equal('deploymentId', params.deployment),
|
||||
Query.equal('deploymentResourceType', DeploymentResourceType.SITE),
|
||||
Query.equal('deploymentResourceId', params.site)
|
||||
])
|
||||
]
|
||||
})
|
||||
]);
|
||||
|
||||
return {
|
||||
|
||||
+13
-15
@@ -22,20 +22,18 @@ export const load = async ({ params, depends, url, route }) => {
|
||||
limit,
|
||||
query,
|
||||
search,
|
||||
proxyRules: await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.proxy.listRules(
|
||||
[
|
||||
Query.equal('type', [RuleType.DEPLOYMENT, RuleType.REDIRECT]),
|
||||
Query.equal('deploymentResourceType', DeploymentResourceType.SITE),
|
||||
Query.equal('deploymentResourceId', params.site),
|
||||
Query.equal('trigger', RuleTrigger.MANUAL),
|
||||
Query.limit(limit),
|
||||
Query.offset(offset),
|
||||
Query.orderDesc(''),
|
||||
...parsedQueries.values()
|
||||
],
|
||||
search || undefined
|
||||
)
|
||||
proxyRules: await sdk.forProject(params.region, params.project).proxy.listRules({
|
||||
queries: [
|
||||
Query.equal('type', [RuleType.DEPLOYMENT, RuleType.REDIRECT]),
|
||||
Query.equal('deploymentResourceType', DeploymentResourceType.SITE),
|
||||
Query.equal('deploymentResourceId', params.site),
|
||||
Query.equal('trigger', RuleTrigger.MANUAL),
|
||||
Query.limit(limit),
|
||||
Query.offset(offset),
|
||||
Query.orderDesc(''),
|
||||
...parsedQueries.values()
|
||||
],
|
||||
search: search || undefined
|
||||
})
|
||||
};
|
||||
};
|
||||
+33
-30
@@ -85,21 +85,28 @@
|
||||
if (behaviour === 'BRANCH') {
|
||||
rule = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.proxy.createSiteRule(domainName, page.params.site, branch);
|
||||
.proxy.createSiteRule({
|
||||
domain: domainName,
|
||||
siteId: page.params.site,
|
||||
branch
|
||||
});
|
||||
} else if (behaviour === 'REDIRECT') {
|
||||
rule = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.proxy.createRedirectRule(
|
||||
domainName,
|
||||
redirect,
|
||||
.proxy.createRedirectRule({
|
||||
domain: domainName,
|
||||
url: redirect,
|
||||
statusCode,
|
||||
page.params.site,
|
||||
ProxyResourceType.Site
|
||||
);
|
||||
resourceId: page.params.site,
|
||||
resourceType: ProxyResourceType.Site
|
||||
});
|
||||
} else if (behaviour === 'ACTIVE') {
|
||||
rule = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.proxy.createSiteRule(domainName, page.params.site);
|
||||
.proxy.createSiteRule({
|
||||
domain: domainName,
|
||||
siteId: page.params.site
|
||||
});
|
||||
}
|
||||
if (rule?.status === 'verified') {
|
||||
await goto(routeBase);
|
||||
@@ -118,28 +125,24 @@
|
||||
|
||||
async function connect(selectedInstallationId: string, selectedRepository: string) {
|
||||
try {
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.sites.update(
|
||||
data.site.$id,
|
||||
data.site.name,
|
||||
data.site.framework as Framework,
|
||||
data.site.enabled,
|
||||
data.site.logging || undefined,
|
||||
data.site.timeout,
|
||||
data.site.installCommand,
|
||||
data.site.buildCommand,
|
||||
data.site.outputDirectory,
|
||||
data.site.buildRuntime as BuildRuntime,
|
||||
data.site.adapter as Adapter,
|
||||
data.site.fallbackFile,
|
||||
selectedInstallationId,
|
||||
selectedRepository,
|
||||
'main',
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
);
|
||||
await sdk.forProject(page.params.region, page.params.project).sites.update({
|
||||
siteId: data.site.$id,
|
||||
name: data.site.name,
|
||||
framework: data.site.framework as Framework,
|
||||
enabled: data.site.enabled,
|
||||
logging: data.site.logging || undefined,
|
||||
timeout: data.site.timeout,
|
||||
installCommand: data.site.installCommand,
|
||||
buildCommand: data.site.buildCommand,
|
||||
outputDirectory: data.site.outputDirectory,
|
||||
buildRuntime: data.site.buildRuntime as BuildRuntime,
|
||||
adapter: data.site.adapter as Adapter,
|
||||
fallbackFile: data.site.fallbackFile,
|
||||
installationId: selectedInstallationId,
|
||||
providerRepositoryId: selectedRepository,
|
||||
providerBranch: 'main'
|
||||
});
|
||||
|
||||
invalidate(Dependencies.SITE);
|
||||
} catch {
|
||||
return;
|
||||
|
||||
+11
-6
@@ -9,15 +9,17 @@ export const load = async ({ parent, depends, params }) => {
|
||||
depends(Dependencies.DOMAINS, Dependencies.SITES_DOMAINS);
|
||||
|
||||
const [rules, installations, domains] = await Promise.all([
|
||||
sdk
|
||||
.forProject(params.region, params.project)
|
||||
.proxy.listRules([
|
||||
sdk.forProject(params.region, params.project).proxy.listRules({
|
||||
queries: [
|
||||
Query.equal('type', RuleType.DEPLOYMENT),
|
||||
Query.equal('trigger', RuleTrigger.MANUAL)
|
||||
]),
|
||||
]
|
||||
}),
|
||||
sdk.forProject(params.region, params.project).vcs.listInstallations(),
|
||||
isCloud
|
||||
? sdk.forConsole.domains.list([Query.equal('teamId', organization.$id)])
|
||||
? sdk.forConsole.domains.list({
|
||||
queries: [Query.equal('teamId', organization.$id)]
|
||||
})
|
||||
: Promise.resolve(null)
|
||||
]);
|
||||
|
||||
@@ -30,7 +32,10 @@ export const load = async ({ parent, depends, params }) => {
|
||||
site?.installationId && site?.providerRepositoryId
|
||||
? await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.vcs.listRepositoryBranches(site.installationId, site.providerRepositoryId)
|
||||
.vcs.listRepositoryBranches({
|
||||
installationId: site.installationId,
|
||||
providerRepositoryId: site.providerRepositoryId
|
||||
})
|
||||
: undefined
|
||||
};
|
||||
};
|
||||
+5
-5
@@ -56,16 +56,16 @@
|
||||
if (selectedTab !== 'nameserver') {
|
||||
const ruleData = await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.proxy.updateRuleVerification(ruleId);
|
||||
.proxy.updateRuleVerification({ ruleId });
|
||||
verified = ruleData.status === 'verified';
|
||||
throw new Error(
|
||||
'Domain verification failed. Please check your domain settings or try again later'
|
||||
);
|
||||
} else if (isNewDomain && isCloud) {
|
||||
const domainData = await sdk.forConsole.domains.create(
|
||||
$organization.$id,
|
||||
page.params.domain
|
||||
);
|
||||
const domainData = await sdk.forConsole.domains.create({
|
||||
teamId: $organization.$id,
|
||||
domain: page.params.domain
|
||||
});
|
||||
verified = domainData.nameservers.toLowerCase() === 'appwrite';
|
||||
throw new Error(
|
||||
'Domain verification failed. Please check your domain settings or try again later'
|
||||
|
||||
+3
-1
@@ -9,7 +9,9 @@ export const load = async ({ parent, depends }) => {
|
||||
|
||||
let domainsList: Models.DomainsList;
|
||||
if (isCloud) {
|
||||
domainsList = await sdk.forConsole.domains.list([Query.equal('teamId', organization.$id)]);
|
||||
domainsList = await sdk.forConsole.domains.list({
|
||||
queries: [Query.equal('teamId', organization.$id)]
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -20,13 +20,14 @@ export const load = async ({ params, depends, url, route, parent }) => {
|
||||
limit,
|
||||
query,
|
||||
site,
|
||||
logs: await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.sites.listLogs(params.site, [
|
||||
logs: await sdk.forProject(params.region, params.project).sites.listLogs({
|
||||
siteId: params.site,
|
||||
queries: [
|
||||
Query.limit(limit),
|
||||
Query.offset(offset),
|
||||
Query.orderDesc(''),
|
||||
...parsedQueries.values()
|
||||
])
|
||||
]
|
||||
})
|
||||
};
|
||||
};
|
||||
+8
-5
@@ -20,9 +20,12 @@
|
||||
export let data;
|
||||
|
||||
const sdkCreateVariable = async (key: string, value: string, secret: boolean) => {
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.sites.createVariable(page.params.site, key, value, secret);
|
||||
await sdk.forProject(page.params.region, page.params.project).sites.createVariable({
|
||||
siteId: page.params.site,
|
||||
key,
|
||||
value,
|
||||
secret
|
||||
});
|
||||
await Promise.all([invalidate(Dependencies.VARIABLES), invalidate(Dependencies.SITE)]);
|
||||
};
|
||||
|
||||
@@ -34,14 +37,14 @@
|
||||
) => {
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.sites.updateVariable(page.params.site, variableId, key, value, secret);
|
||||
.sites.updateVariable({ siteId: page.params.site, variableId, key, value, secret });
|
||||
await Promise.all([invalidate(Dependencies.VARIABLES), invalidate(Dependencies.SITE)]);
|
||||
};
|
||||
|
||||
const sdkDeleteVariable = async (variableId: string) => {
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.sites.deleteVariable(page.params.site, variableId);
|
||||
.sites.deleteVariable({ siteId: page.params.site, variableId });
|
||||
await Promise.all([invalidate(Dependencies.VARIABLES), invalidate(Dependencies.SITE)]);
|
||||
};
|
||||
|
||||
|
||||
+7
-2
@@ -35,7 +35,12 @@
|
||||
return (
|
||||
sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.storage.getFilePreview(bucketId, fileId, 128, 128)
|
||||
.storage.getFilePreview({
|
||||
bucketId,
|
||||
fileId,
|
||||
height: 128,
|
||||
width: 128
|
||||
})
|
||||
.toString() + '&mode=admin'
|
||||
);
|
||||
}
|
||||
@@ -50,7 +55,7 @@
|
||||
try {
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.storage.deleteFile(file.bucketId, file.$id);
|
||||
.storage.deleteFile({ bucketId: file.bucketId, fileId: file.$id });
|
||||
await invalidate(Dependencies.FILES);
|
||||
await uploader.removeFile(file);
|
||||
trackEvent(Submit.FileDelete);
|
||||
|
||||
+21
-10
@@ -53,12 +53,17 @@
|
||||
const getPreview = (fileId: string) =>
|
||||
sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.storage.getFilePreview($file.bucketId, fileId, 640, 300)
|
||||
.storage.getFilePreview({
|
||||
bucketId: $file.bucketId,
|
||||
fileId,
|
||||
width: 640,
|
||||
height: 300
|
||||
})
|
||||
.toString() + '&mode=admin';
|
||||
const getView = (fileId: string) =>
|
||||
sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.storage.getFileView($file.bucketId, fileId)
|
||||
.storage.getFileView({ bucketId: $file.bucketId, fileId })
|
||||
.toString() + '&mode=admin';
|
||||
|
||||
$: if (filePermissions) {
|
||||
@@ -69,16 +74,20 @@
|
||||
return (
|
||||
sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.storage.getFileDownload($file.bucketId, $file.$id)
|
||||
.storage.getFileDownload({ bucketId: $file.bucketId, fileId: $file.$id })
|
||||
.toString() + '&mode=admin'
|
||||
);
|
||||
}
|
||||
|
||||
async function updatePermissions() {
|
||||
try {
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.storage.updateFile($file.bucketId, $file.$id, $file.name, filePermissions);
|
||||
await sdk.forProject(page.params.region, page.params.project).storage.updateFile({
|
||||
bucketId: $file.bucketId,
|
||||
fileId: $file.$id,
|
||||
name: $file.name,
|
||||
permissions: filePermissions
|
||||
});
|
||||
|
||||
await invalidate(Dependencies.FILE);
|
||||
arePermsDisabled = true;
|
||||
addNotification({
|
||||
@@ -119,11 +128,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function createFileToken(expiry: string) {
|
||||
async function createFileToken(expire: string) {
|
||||
try {
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.tokens.createFileToken($file.bucketId, $file.$id, expiry);
|
||||
await sdk.forProject(page.params.region, page.params.project).tokens.createFileToken({
|
||||
bucketId: $file.bucketId,
|
||||
fileId: $file.$id,
|
||||
expire
|
||||
});
|
||||
|
||||
await invalidate(Dependencies.FILE_TOKENS);
|
||||
addNotification({
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
|
||||
function onGithubLogin() {
|
||||
localStorage.setItem('githubEducationProgram', 'true');
|
||||
sdk.forConsole.account.createOAuth2Session(
|
||||
OAuthProvider.Github,
|
||||
window.location.origin + '/console/education?success',
|
||||
window.location.origin + '/console/education?failure',
|
||||
['read:user', 'user:email']
|
||||
);
|
||||
sdk.forConsole.account.createOAuth2Session({
|
||||
provider: OAuthProvider.Github,
|
||||
success: window.location.origin + '/console/education?success',
|
||||
failure: window.location.origin + '/console/education?failure',
|
||||
scopes: ['read:user', 'user:email']
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -76,12 +76,12 @@
|
||||
url = `${base}${page.url.search ?? ''}`;
|
||||
}
|
||||
}
|
||||
sdk.forConsole.account.createOAuth2Session(
|
||||
OAuthProvider.Github,
|
||||
window.location.origin + url,
|
||||
window.location.origin,
|
||||
['read:user', 'user:email']
|
||||
);
|
||||
sdk.forConsole.account.createOAuth2Session({
|
||||
provider: OAuthProvider.Github,
|
||||
success: window.location.origin + url,
|
||||
failure: window.location.origin,
|
||||
scopes: ['read:user', 'user:email']
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -81,12 +81,12 @@
|
||||
}
|
||||
|
||||
function onGithubLogin() {
|
||||
sdk.forConsole.account.createOAuth2Session(
|
||||
OAuthProvider.Github,
|
||||
window.location.origin,
|
||||
window.location.origin,
|
||||
['read:user', 'user:email']
|
||||
);
|
||||
sdk.forConsole.account.createOAuth2Session({
|
||||
provider: OAuthProvider.Github,
|
||||
success: window.location.origin,
|
||||
failure: window.location.origin,
|
||||
scopes: ['read:user', 'user:email']
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -16,7 +16,12 @@
|
||||
const userId = page.url.searchParams.get('userId');
|
||||
const secret = page.url.searchParams.get('secret');
|
||||
|
||||
await account.updateMagicURLSession(userId, secret);
|
||||
// what's the replacement?
|
||||
await account.updateMagicURLSession({
|
||||
userId,
|
||||
secret
|
||||
});
|
||||
|
||||
window.location.href = `appwrite-callback-${projectId}://${page.url.search}`;
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -98,12 +98,12 @@
|
||||
url = `${base}${page.url.search ?? ''}`;
|
||||
}
|
||||
}
|
||||
sdk.forConsole.account.createOAuth2Session(
|
||||
OAuthProvider.Github,
|
||||
window.location.origin + url,
|
||||
window.location.origin,
|
||||
['read:user', 'user:email']
|
||||
);
|
||||
sdk.forConsole.account.createOAuth2Session({
|
||||
provider: OAuthProvider.Github,
|
||||
success: window.location.origin + url,
|
||||
failure: window.location.origin,
|
||||
scopes: ['read:user', 'user:email']
|
||||
});
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
|
||||
@@ -45,12 +45,12 @@
|
||||
}
|
||||
|
||||
function onGithubLogin() {
|
||||
sdk.forConsole.account.createOAuth2Session(
|
||||
OAuthProvider.Github,
|
||||
window.location.origin,
|
||||
window.location.origin,
|
||||
['read:user', 'user:email']
|
||||
);
|
||||
sdk.forConsole.account.createOAuth2Session({
|
||||
provider: OAuthProvider.Github,
|
||||
success: window.location.origin,
|
||||
failure: window.location.origin,
|
||||
scopes: ['read:user', 'user:email']
|
||||
});
|
||||
}
|
||||
|
||||
async function fetchProjects() {
|
||||
@@ -71,12 +71,12 @@
|
||||
async function handleSubmit() {
|
||||
if (selectedProject === null) {
|
||||
try {
|
||||
const p = await sdk.forConsole.projects.create(
|
||||
id ?? ID.unique(),
|
||||
projectName,
|
||||
selectedOrg,
|
||||
isCloud ? (region as Region) : undefined
|
||||
);
|
||||
const p = await sdk.forConsole.projects.create({
|
||||
projectId: id ?? ID.unique(),
|
||||
name: projectName,
|
||||
teamId: selectedOrg,
|
||||
region: isCloud ? (region as Region) : undefined
|
||||
});
|
||||
trackEvent(Submit.ProjectCreate, {
|
||||
customId: !!id,
|
||||
selectedOrg,
|
||||
|
||||
Reference in new issue
Block a user