diff --git a/src/routes/console/[project]/__layout.svelte b/src/routes/console/[project]/__layout.svelte index 09d3c3a5ec..d6da7f61b4 100644 --- a/src/routes/console/[project]/__layout.svelte +++ b/src/routes/console/[project]/__layout.svelte @@ -26,18 +26,22 @@ } if (browser) { sdkForConsole.subscribe('console', (message) => { - switch (message.event) { - case 'database.attributes.create': - collection.addAttribute(message.payload); - break; - - case 'database.attributes.update': - collection.updateAttribute(message.payload); - break; - - case 'database.attributes.delete': - collection.removeAttribute(message.payload); - break; + if (message.events.includes('collections.*.attributes.*.create')) { + collection.addAttribute(message.payload); + + return; + } + + if (message.events.includes('collections.*.attributes.*.update')) { + collection.updateAttribute(message.payload); + + return; + } + + if (message.events.includes('collections.*.attributes.*.delete')) { + collection.removeAttribute(message.payload); + + return; } }); } diff --git a/src/routes/console/[project]/settings/members.svelte b/src/routes/console/[project]/settings/members.svelte index 0f5568182c..1673ad1896 100644 --- a/src/routes/console/[project]/settings/members.svelte +++ b/src/routes/console/[project]/settings/members.svelte @@ -19,12 +19,12 @@ {#each response.memberships as membership}

- {membership.name} + {membership.userName}

{#each membership.roles as role} @@ -35,7 +35,7 @@ {/if}
- {membership.email} + {membership.userEmail} diff --git a/src/routes/console/[project]/users/teams/[team]/index.svelte b/src/routes/console/[project]/users/teams/[team]/index.svelte index ba1cff53c5..adb6b52a57 100644 --- a/src/routes/console/[project]/users/teams/[team]/index.svelte +++ b/src/routes/console/[project]/users/teams/[team]/index.svelte @@ -44,8 +44,8 @@ {#each members.memberships as membership}

- {membership.name} - {membership.email} + {membership.userName} + {membership.userEmail}

diff --git a/src/sdk.ts b/src/sdk.ts index ec2e7779dd..5c6dc1b337 100644 --- a/src/sdk.ts +++ b/src/sdk.ts @@ -1130,18 +1130,22 @@ namespace Models { * User ID. */ userId: string; - /** - * Team ID. - */ - teamId: string; /** * User name. */ - name: string; + userName: string; /** * User email address. */ - email: string; + userEmail: string; + /** + * Team ID. + */ + teamId: string; + /** + * Team name. + */ + 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 = { - 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 (): Promise< + Models.User + > => { + 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 => { 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 => { - 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 => { 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 => { + 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 => { + 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