Merge branch 'main' of https://github.com/appwrite/appwrite-console-poc into feat-route-transition

This commit is contained in:
Torsten Dittmann
2022-05-18 23:06:58 +02:00
6 changed files with 219 additions and 104 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en" data-theme="light">
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="description" content="" />
+10 -1
View File
@@ -29,7 +29,16 @@
$: {
if (browser) {
document.body.setAttribute('class', `theme-${$app.theme}`);
if ($app.theme === 'auto') {
const darkThemeMq = window.matchMedia('(prefers-color-scheme: dark)');
if (darkThemeMq.matches) {
document.body.setAttribute('class', `theme-dark`);
} else {
document.body.setAttribute('class', `theme-light`);
}
} else {
document.body.setAttribute('class', `theme-${$app.theme}`);
}
}
}
</script>
+14 -10
View File
@@ -26,18 +26,22 @@
}
if (browser) {
sdkForConsole.subscribe<Attributes | Models.Index>('console', (message) => {
switch (message.event) {
case 'database.attributes.create':
collection.addAttribute(<Attributes>message.payload);
break;
if (message.events.includes('collections.*.attributes.*.create')) {
collection.addAttribute(<Attributes>message.payload);
case 'database.attributes.update':
collection.updateAttribute(<Attributes>message.payload);
break;
return;
}
case 'database.attributes.delete':
collection.removeAttribute(<Attributes>message.payload);
break;
if (message.events.includes('collections.*.attributes.*.update')) {
collection.updateAttribute(<Attributes>message.payload);
return;
}
if (message.events.includes('collections.*.attributes.*.delete')) {
collection.removeAttribute(<Attributes>message.payload);
return;
}
});
}
@@ -19,12 +19,12 @@
{#each response.memberships as membership}
<ListItem
avatar={sdkForConsole.avatars
.getInitials(membership.name, 64, 64)
.getInitials(membership.userName, 64, 64)
.toString()}>
<svelte:fragment slot="header">
<h2 class="sessions-item-title">
<span class="text">
{membership.name}
{membership.userName}
</span>
</h2>
{#each membership.roles as role}
@@ -35,7 +35,7 @@
{/if}
</svelte:fragment>
<svelte:fragment slot="info">
{membership.email}
{membership.userEmail}
</svelte:fragment>
<svelte:fragment slot="action">
<Button danger>Remove</Button>
@@ -44,8 +44,8 @@
<Card>
{#each members.memberships as membership}
<p>
{membership.name}
{membership.email}
{membership.userName}
{membership.userEmail}
<Button on:click={() => deleteMembership(membership.$id)}>Remove</Button>
</p>
<p>
+189 -87
View File
@@ -1130,18 +1130,22 @@ namespace Models {
* User ID.
*/
userId: string;
/**
* User name.
*/
userName: string;
/**
* User email address.
*/
userEmail: string;
/**
* Team ID.
*/
teamId: string;
/**
* User name.
* Team name.
*/
name: string;
/**
* User email address.
*/
email: string;
teamName: string;
/**
* Date, the user has been invited to join the team in Unix timestamp.
*/
@@ -1335,9 +1339,9 @@ namespace Models {
*/
statusCode: number;
/**
* The script stdout output string. Logs the last 4,000 characters of the execution stdout output.
* The script response output string. Logs the last 4,000 characters of the execution response output.
*/
stdout: string;
response: string;
/**
* The script stderr output string. Logs the last 4,000 characters of the execution stderr output
*/
@@ -1435,6 +1439,14 @@ namespace Models {
* Apple OAuth secret ID.
*/
providerAppleSecret: string;
/**
* Auth0 OAuth app ID.
*/
providerAuth0Appid: string;
/**
* Auth0 OAuth secret ID.
*/
providerAuth0Secret: string;
/**
* BitBucket OAuth app ID.
*/
@@ -1531,6 +1543,14 @@ namespace Models {
* Notion OAuth secret ID.
*/
providerNotionSecret: string;
/**
* Okta OAuth app ID.
*/
providerOktaAppid: string;
/**
* Okta OAuth secret ID.
*/
providerOktaSecret: string;
/**
* PayPal OAuth app ID.
*/
@@ -1596,13 +1616,13 @@ namespace Models {
*/
providerTwitchSecret: string;
/**
* VK OAuth app ID.
* Zoom OAuth app ID.
*/
providerVkAppid: string;
providerZoomAppid: string;
/**
* VK OAuth secret ID.
* Zoom OAuth secret ID.
*/
providerVkSecret: string;
providerZoomSecret: string;
/**
* Yahoo OAuth app ID.
*/
@@ -2231,31 +2251,31 @@ namespace Models {
/**
* Aggregated stats for number of requests.
*/
requests: any[];
requests: MetricList[];
/**
* Aggregated stats for consumed bandwidth.
*/
network: any[];
network: MetricList[];
/**
* Aggregated stats for function executions.
*/
functions: any[];
functions: MetricList[];
/**
* Aggregated stats for number of documents.
*/
documents: any[];
documents: MetricList[];
/**
* Aggregated stats for number of collections.
*/
collections: any[];
collections: MetricList[];
/**
* Aggregated stats for number of users.
*/
users: any[];
users: MetricList[];
/**
* Aggregated stats for the occupied storage size (in bytes).
*/
storage: any[];
storage: MetricList[];
};
}
@@ -2282,7 +2302,7 @@ type RealtimeRequest = {
};
export type RealtimeResponseEvent<T extends unknown> = {
event: string;
events: string[];
channels: string[];
timestamp: number;
payload: T;
@@ -2367,7 +2387,7 @@ class Appwrite {
};
headers: Headers = {
'x-sdk-version': 'appwrite:web:5.0.0',
'X-Appwrite-Response-Format': '0.13.0'
'X-Appwrite-Response-Format': '0.14.0'
};
/**
@@ -2860,33 +2880,6 @@ class Appwrite {
);
},
/**
* Delete Account
*
* Delete a currently logged in user account. Behind the scene, the user
* record is not deleted but permanently blocked from any access. This is done
* to avoid deleted accounts being overtaken by new users with the same email
* address. Any user-related resources like documents or storage files should
* be deleted separately.
*
* @throws {AppwriteException}
* @returns {Promise}
*/
delete: async (): Promise<{}> => {
let path = '/account';
let payload: Payload = {};
const uri = new URL(this.config.endpoint + path);
return await this.call(
'delete',
uri,
{
'content-type': 'application/json'
},
payload
);
},
/**
* Update Account Email
*
@@ -3038,7 +3031,7 @@ class Appwrite {
*
* Update currently logged in user password. For validation, user is required
* to pass in the new password, and the old password. For users created with
* OAuth and Team Invites, oldPassword is optional.
* OAuth, Team Invites and Magic URL, oldPassword is optional.
*
* @param {string} password
* @param {string} oldPassword
@@ -3575,6 +3568,9 @@ class Appwrite {
/**
* Update Session (Refresh Tokens)
*
* Access tokens have limited lifespan and expire to mitigate security risks.
* If session was created using an OAuth provider, this route can be used to
* "refresh" the access token.
*
* @param {string} sessionId
* @throws {AppwriteException}
@@ -3630,6 +3626,33 @@ class Appwrite {
);
},
/**
* Update Account Status
*
* Block the currently logged in user account. Behind the scene, the user
* record is not deleted but permanently blocked from any access. To
* completely delete a user, use the Users API instead.
*
* @throws {AppwriteException}
* @returns {Promise}
*/
updateStatus: async <Preferences extends Models.Preferences>(): Promise<
Models.User<Preferences>
> => {
let path = '/account/status';
let payload: Payload = {};
const uri = new URL(this.config.endpoint + path);
return await this.call(
'patch',
uri,
{
'content-type': 'application/json'
},
payload
);
},
/**
* Create Email Verification
*
@@ -3726,9 +3749,14 @@ class Appwrite {
* Get Browser Icon
*
* You can use this endpoint to show different browser icons to your users.
* The code argument receives the browser code as it appears in your user
* /account/sessions endpoint. Use width, height and quality arguments to
* change the output settings.
* The code argument receives the browser code as it appears in your user [GET
* /account/sessions](/docs/client/account#accountGetSessions) endpoint. Use
* width, height and quality arguments to change the output settings.
*
* When one dimension is specified and the other is 0, the image is scaled
* with preserved aspect ratio. If both dimensions are 0, the API provides an
* image at source quality. If dimensions are not specified, the default size
* of image returned is 100x100px.
*
* @param {string} code
* @param {number} width
@@ -3773,6 +3801,12 @@ class Appwrite {
* provider you need. Use width, height and quality arguments to change the
* output settings.
*
* When one dimension is specified and the other is 0, the image is scaled
* with preserved aspect ratio. If both dimensions are 0, the API provides an
* image at source quality. If dimensions are not specified, the default size
* of image returned is 100x100px.
*
*
* @param {string} code
* @param {number} width
* @param {number} height
@@ -3848,6 +3882,12 @@ class Appwrite {
* users. The code argument receives the 2 letter country code. Use width,
* height and quality arguments to change the output settings.
*
* When one dimension is specified and the other is 0, the image is scaled
* with preserved aspect ratio. If both dimensions are 0, the API provides an
* image at source quality. If dimensions are not specified, the default size
* of image returned is 100x100px.
*
*
* @param {string} code
* @param {number} width
* @param {number} height
@@ -3892,6 +3932,12 @@ class Appwrite {
* remote images in your app or in case you want to make sure a 3rd party
* image is properly served using a TLS protocol.
*
* When one dimension is specified and the other is 0, the image is scaled
* with preserved aspect ratio. If both dimensions are 0, the API provides an
* image at source quality. If dimensions are not specified, the default size
* of image returned is 400x400px.
*
*
* @param {string} url
* @param {number} width
* @param {number} height
@@ -3941,6 +3987,12 @@ class Appwrite {
* the user's initials when reloading the same theme will always return for
* the same initials.
*
* When one dimension is specified and the other is 0, the image is scaled
* with preserved aspect ratio. If both dimensions are 0, the API provides an
* image at source quality. If dimensions are not specified, the default size
* of image returned is 100x100px.
*
*
* @param {string} name
* @param {number} width
* @param {number} height
@@ -3994,6 +4046,7 @@ class Appwrite {
* Converts a given plain text to a QR code image. You can use the query
* parameters to change the size and style of the resulting image.
*
*
* @param {string} text
* @param {number} size
* @param {number} margin
@@ -5227,9 +5280,7 @@ class Appwrite {
/**
* Delete Document
*
* Delete a document by its unique ID. This endpoint deletes only the parent
* documents, its attributes and relations to other documents. Child documents
* **will not** be deleted.
* Delete a document by its unique ID.
*
* @param {string} collectionId
* @param {string} documentId
@@ -5983,7 +6034,7 @@ class Appwrite {
entrypoint: string,
code: File,
activate: boolean,
onProgress?: (progress: UploadProgress) => UploadProgress
onProgress = (_progress: UploadProgress) => {}
): Promise<Models.Deployment> => {
if (typeof functionId === 'undefined') {
throw new AppwriteException('Missing required parameter: "functionId"');
@@ -6062,8 +6113,8 @@ class Appwrite {
onProgress({
$id: response.$id,
progress:
(Math.min((counter + 1) * Appwrite.CHUNK_SIZE, size) / size) * 100,
sizeUploaded: end + 1,
(Math.min((counter + 1) * Appwrite.CHUNK_SIZE - 1, size) / size) * 100,
sizeUploaded: end,
chunksTotal: response.chunksTotal,
chunksUploaded: response.chunksUploaded
});
@@ -6574,30 +6625,6 @@ class Appwrite {
);
},
/**
* Get Usage Queue
*
* Get the number of usage stats that are waiting to be processed in the
* Appwrite internal queue server.
*
* @throws {AppwriteException}
* @returns {Promise}
*/
getQueueUsage: async (): Promise<Models.HealthQueue> => {
let path = '/health/queue/usage';
let payload: Payload = {};
const uri = new URL(this.config.endpoint + path);
return await this.call(
'get',
uri,
{
'content-type': 'application/json'
},
payload
);
},
/**
* Get Webhooks Queue
*
@@ -8661,7 +8688,7 @@ class Appwrite {
file: File,
read?: string[],
write?: string[],
onProgress?: (progress: UploadProgress) => UploadProgress
onProgress = (_progress: UploadProgress) => {}
): Promise<Models.File> => {
if (typeof bucketId === 'undefined') {
throw new AppwriteException('Missing required parameter: "bucketId"');
@@ -8750,8 +8777,8 @@ class Appwrite {
onProgress({
$id: response.$id,
progress:
(Math.min((counter + 1) * Appwrite.CHUNK_SIZE, size) / size) * 100,
sizeUploaded: end + 1,
(Math.min((counter + 1) * Appwrite.CHUNK_SIZE - 1, size) / size) * 100,
sizeUploaded: end,
chunksTotal: response.chunksTotal,
chunksUploaded: response.chunksUploaded
});
@@ -9328,6 +9355,48 @@ class Appwrite {
);
},
/**
* List Team Logs
*
* Get the team activity logs list by its unique ID.
*
* @param {string} teamId
* @param {number} limit
* @param {number} offset
* @throws {AppwriteException}
* @returns {Promise}
*/
listLogs: async (
teamId: string,
limit?: number,
offset?: number
): Promise<Models.LogList> => {
if (typeof teamId === 'undefined') {
throw new AppwriteException('Missing required parameter: "teamId"');
}
let path = '/teams/{teamId}/logs'.replace('{teamId}', teamId);
let payload: Payload = {};
if (typeof limit !== 'undefined') {
payload['limit'] = limit;
}
if (typeof offset !== 'undefined') {
payload['offset'] = offset;
}
const uri = new URL(this.config.endpoint + path);
return await this.call(
'get',
uri,
{
'content-type': 'application/json'
},
payload
);
},
/**
* Get Team Memberships
*
@@ -9853,7 +9922,11 @@ class Appwrite {
/**
* Delete User
*
* Delete a user by its unique ID.
* Delete a user by its unique ID, thereby releasing it's ID. Since ID is
* released and can be reused, all user-related resources like documents or
* storage files should be deleted before user deletion. If you want to keep
* ID reserved, use the [updateStatus](/docs/server/users#usersUpdateStatus)
* endpoint instead.
*
* @param {string} userId
* @throws {AppwriteException}
@@ -9960,6 +10033,34 @@ class Appwrite {
);
},
/**
* Get User Memberships
*
* Get the user membership list by its unique ID.
*
* @param {string} userId
* @throws {AppwriteException}
* @returns {Promise}
*/
getMemberships: async (userId: string): Promise<Models.MembershipList> => {
if (typeof userId === 'undefined') {
throw new AppwriteException('Missing required parameter: "userId"');
}
let path = '/users/{userId}/memberships'.replace('{userId}', userId);
let payload: Payload = {};
const uri = new URL(this.config.endpoint + path);
return await this.call(
'get',
uri,
{
'content-type': 'application/json'
},
payload
);
},
/**
* Update Name
*
@@ -10206,7 +10307,8 @@ class Appwrite {
/**
* Update User Status
*
* Update the user status by its unique ID.
* Update the user status by its unique ID. Use this endpoint as an
* alternative to deleting a user if you want to keep user's ID reserved.
*
* @param {string} userId
* @param {boolean} status