From 9e2067f226070e827995b442ba4208d902214775 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 17 Aug 2024 08:50:42 +0000 Subject: [PATCH] chore: release rc --- README.md | 4 +- .../account/delete-mfa-authenticator.md | 1 - docs/examples/functions/create.md | 2 +- ...ployment.md => get-deployment-download.md} | 4 +- docs/examples/functions/get-template.md | 11 ++ docs/examples/functions/list-templates.md | 14 +++ lib/dart_appwrite.dart | 2 +- lib/models.dart | 4 + lib/services/account.dart | 11 +- lib/services/avatars.dart | 2 + lib/services/functions.dart | 78 +++++++++++-- lib/src/client_browser.dart | 4 +- lib/src/client_io.dart | 6 +- lib/src/models/execution.dart | 5 + lib/src/models/runtime.dart | 5 + lib/src/models/template_function.dart | 103 ++++++++++++++++++ lib/src/models/template_function_list.dart | 28 +++++ lib/src/models/template_runtime.dart | 38 +++++++ lib/src/models/template_variable.dart | 48 ++++++++ pubspec.yaml | 2 +- test/services/account_test.dart | 1 - test/services/functions_test.dart | 62 ++++++++++- test/src/models/runtime_test.dart | 2 + .../models/template_function_list_test.dart | 20 ++++ test/src/models/template_function_test.dart | 50 +++++++++ test/src/models/template_runtime_test.dart | 24 ++++ test/src/models/template_variable_test.dart | 28 +++++ 27 files changed, 526 insertions(+), 33 deletions(-) rename docs/examples/functions/{download-deployment.md => get-deployment-download.md} (73%) create mode 100644 docs/examples/functions/get-template.md create mode 100644 docs/examples/functions/list-templates.md create mode 100644 lib/src/models/template_function.dart create mode 100644 lib/src/models/template_function_list.dart create mode 100644 lib/src/models/template_runtime.dart create mode 100644 lib/src/models/template_variable.dart create mode 100644 test/src/models/template_function_list_test.dart create mode 100644 test/src/models/template_function_test.dart create mode 100644 test/src/models/template_runtime_test.dart create mode 100644 test/src/models/template_variable_test.dart diff --git a/README.md b/README.md index 33cda81f..0b63b3c8 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![pub package](https://img.shields.io/pub/v/dart_appwrite.svg?style=flat-square)](https://pub.dartlang.org/packages/dart_appwrite) ![License](https://img.shields.io/github/license/appwrite/sdk-for-dart.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.5.x-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.6.x-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) @@ -23,7 +23,7 @@ Add this to your package's `pubspec.yaml` file: ```yml dependencies: - dart_appwrite: ^12.0.0-rc.1 + dart_appwrite: ^12.0.0-rc.2 ``` You can install packages from the command line: diff --git a/docs/examples/account/delete-mfa-authenticator.md b/docs/examples/account/delete-mfa-authenticator.md index f65636bf..1a5903f1 100644 --- a/docs/examples/account/delete-mfa-authenticator.md +++ b/docs/examples/account/delete-mfa-authenticator.md @@ -9,5 +9,4 @@ Account account = Account(client); await account.deleteMfaAuthenticator( type: AuthenticatorType.totp, - otp: '', ); diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 8991cbca..8d6ca90e 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -28,5 +28,5 @@ Func result = await functions.create( templateRepository: '', // (optional) templateOwner: '', // (optional) templateRootDirectory: '', // (optional) - templateBranch: '', // (optional) + templateVersion: '', // (optional) ); diff --git a/docs/examples/functions/download-deployment.md b/docs/examples/functions/get-deployment-download.md similarity index 73% rename from docs/examples/functions/download-deployment.md rename to docs/examples/functions/get-deployment-download.md index e5d5de36..e79d1f17 100644 --- a/docs/examples/functions/download-deployment.md +++ b/docs/examples/functions/get-deployment-download.md @@ -3,11 +3,11 @@ import 'package:dart_appwrite/dart_appwrite.dart'; Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('<YOUR_PROJECT_ID>') // Your project ID - .setKey('<YOUR_API_KEY>'); // Your secret API key + .setSession(''); // The user session to authenticate with Functions functions = Functions(client); -UInt8List result = await functions.downloadDeployment( +UInt8List result = await functions.getDeploymentDownload( functionId: '', deploymentId: '', ); diff --git a/docs/examples/functions/get-template.md b/docs/examples/functions/get-template.md new file mode 100644 index 00000000..c13c72cd --- /dev/null +++ b/docs/examples/functions/get-template.md @@ -0,0 +1,11 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +Functions functions = Functions(client); + +TemplateFunction result = await functions.getTemplate( + templateId: '', +); diff --git a/docs/examples/functions/list-templates.md b/docs/examples/functions/list-templates.md new file mode 100644 index 00000000..2a5d86c4 --- /dev/null +++ b/docs/examples/functions/list-templates.md @@ -0,0 +1,14 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +Functions functions = Functions(client); + +TemplateFunctionList result = await functions.listTemplates( + runtimes: [], // (optional) + useCases: [], // (optional) + limit: 1, // (optional) + offset: 0, // (optional) +); diff --git a/lib/dart_appwrite.dart b/lib/dart_appwrite.dart index 79604965..21865e2e 100644 --- a/lib/dart_appwrite.dart +++ b/lib/dart_appwrite.dart @@ -1,6 +1,6 @@ /// Appwrite Dart SDK /// -/// This SDK is compatible with Appwrite server version 1.5.x. +/// This SDK is compatible with Appwrite server version 1.6.x. /// For older versions, please check /// [previous releases](https://github.com/appwrite/sdk-for-dart/releases). library dart_appwrite; diff --git a/lib/models.dart b/lib/models.dart index 77aafe99..755f5145 100644 --- a/lib/models.dart +++ b/lib/models.dart @@ -15,6 +15,7 @@ part 'src/models/bucket_list.dart'; part 'src/models/team_list.dart'; part 'src/models/membership_list.dart'; part 'src/models/function_list.dart'; +part 'src/models/template_function_list.dart'; part 'src/models/runtime_list.dart'; part 'src/models/deployment_list.dart'; part 'src/models/execution_list.dart'; @@ -66,6 +67,9 @@ part 'src/models/bucket.dart'; part 'src/models/team.dart'; part 'src/models/membership.dart'; part 'src/models/function.dart'; +part 'src/models/template_function.dart'; +part 'src/models/template_runtime.dart'; +part 'src/models/template_variable.dart'; part 'src/models/runtime.dart'; part 'src/models/deployment.dart'; part 'src/models/execution.dart'; diff --git a/lib/services/account.dart b/lib/services/account.dart index 11f81f17..93c16e2d 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -207,7 +207,7 @@ class Account extends Service { } - /// Add Authenticator + /// Create Authenticator /// /// Add an authenticator app to be used as an MFA factor. Verify the /// authenticator using the [verify @@ -260,13 +260,12 @@ class Account extends Service { /// Delete Authenticator /// /// Delete an authenticator for a user by ID. - Future deleteMfaAuthenticator({required enums.AuthenticatorType type, required String otp}) async { + Future deleteMfaAuthenticator({required enums.AuthenticatorType type}) async { final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); final Map apiParams = { - 'otp': otp, - + }; final Map apiHeaders = { @@ -280,7 +279,7 @@ class Account extends Service { } - /// Create 2FA Challenge + /// Create MFA Challenge /// /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) @@ -1150,7 +1149,7 @@ class Account extends Service { } - /// Create phone verification (confirmation) + /// Update phone verification (confirmation) /// /// Use this endpoint to complete the user phone verification process. Use the /// **userId** and **secret** that were sent to your user's phone number to diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index 7e0d8f66..4609b00b 100644 --- a/lib/services/avatars.dart +++ b/lib/services/avatars.dart @@ -67,6 +67,7 @@ class Avatars extends Service { /// Use this endpoint to fetch the favorite icon (AKA favicon) of any remote /// website URL. /// + /// This endpoint does not follow HTTP redirects. Future getFavicon({required String url}) async { final String apiPath = '/avatars/favicon'; @@ -123,6 +124,7 @@ class Avatars extends Service { /// image at source quality. If dimensions are not specified, the default size /// of image returned is 400x400px. /// + /// This endpoint does not follow HTTP redirects. Future getImage({required String url, int? width, int? height}) async { final String apiPath = '/avatars/image'; diff --git a/lib/services/functions.dart b/lib/services/functions.dart index 4cd462a6..3cf75a96 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -36,7 +36,7 @@ class Functions extends Service { /// [permissions](https://appwrite.io/docs/permissions) to allow different /// project users or team with access to execute the function using the client /// API. - Future create({required String functionId, required String name, required enums.Runtime runtime, List? execute, List? events, String? schedule, int? timeout, bool? enabled, bool? logging, String? entrypoint, String? commands, List? scopes, String? installationId, String? providerRepositoryId, String? providerBranch, bool? providerSilentMode, String? providerRootDirectory, String? templateRepository, String? templateOwner, String? templateRootDirectory, String? templateBranch}) async { + Future create({required String functionId, required String name, required enums.Runtime runtime, List? execute, List? events, String? schedule, int? timeout, bool? enabled, bool? logging, String? entrypoint, String? commands, List? scopes, String? installationId, String? providerRepositoryId, String? providerBranch, bool? providerSilentMode, String? providerRootDirectory, String? templateRepository, String? templateOwner, String? templateRootDirectory, String? templateVersion}) async { final String apiPath = '/functions'; final Map apiParams = { @@ -61,7 +61,7 @@ class Functions extends Service { 'templateRepository': templateRepository, 'templateOwner': templateOwner, 'templateRootDirectory': templateRootDirectory, -'templateBranch': templateBranch, +'templateVersion': templateVersion, }; @@ -98,6 +98,58 @@ class Functions extends Service { } + /// List function templates + /// + /// List available function templates. You can use template details in + /// [createFunction](/docs/references/cloud/server-nodejs/functions#create) + /// method. + Future listTemplates({List? runtimes, List? useCases, int? limit, int? offset}) async { + final String apiPath = '/functions/templates'; + + final Map apiParams = { + 'runtimes': runtimes, +'useCases': useCases, +'limit': limit, +'offset': offset, + + + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.TemplateFunctionList.fromMap(res.data); + + } + + /// Get function template + /// + /// Get a function template using ID. You can use template details in + /// [createFunction](/docs/references/cloud/server-nodejs/functions#create) + /// method. + Future getTemplate({required String templateId}) async { + final String apiPath = '/functions/templates/{templateId}'.replaceAll('{templateId}', templateId); + + final Map apiParams = { + + + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.TemplateFunction.fromMap(res.data); + + } + /// Get function /// /// Get a function by its unique ID. @@ -271,7 +323,7 @@ class Functions extends Service { } - /// Update function deployment + /// Update deployment /// /// Update the function code deployment ID using the unique function ID. Use /// this endpoint to switch the code deployment that should be executed by the @@ -360,18 +412,18 @@ class Functions extends Service { } - /// Download Deployment + /// Download deployment /// /// Get a Deployment's contents by its unique ID. This endpoint supports range /// requests for partial or streaming file download. - Future downloadDeployment({required String functionId, required String deploymentId}) async { + Future getDeploymentDownload({required String functionId, required String deploymentId}) async { final String apiPath = '/functions/{functionId}/deployments/{deploymentId}/download'.replaceAll('{functionId}', functionId).replaceAll('{deploymentId}', deploymentId); final Map params = { 'project': client.config['project'], - 'key': client.config['key'], + 'session': client.config['session'], }; final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); @@ -409,7 +461,7 @@ class Functions extends Service { /// current execution status. You can ping the `Get Execution` endpoint to get /// updates on the current execution status. Once this endpoint is called, your /// function execution process will start asynchronously. - Future createExecution({required String functionId, String? body, bool? xasync, String? path, enums.ExecutionMethod? method, Map? headers, String? scheduledAt}) async { + Future createExecution({required String functionId, String? body, bool? xasync, String? path, enums.ExecutionMethod? method, Map? headers, String? scheduledAt, Function(UploadProgress)? onProgress}) async { final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); final Map apiParams = { @@ -424,11 +476,19 @@ class Functions extends Service { }; final Map apiHeaders = { - 'content-type': 'application/json', + 'content-type': 'multipart/form-data', }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + String idParamName = ''; + final res = await client.chunkedUpload( + path: apiPath, + params: apiParams, + paramName: paramName, + idParamName: idParamName, + headers: apiHeaders, + onProgress: onProgress, + ); return models.Execution.fromMap(res.data); diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index 6a6fa575..c73987ad 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -33,8 +33,8 @@ class ClientBrowser extends ClientBase with ClientMixin { 'x-sdk-name': 'Dart', 'x-sdk-platform': 'server', 'x-sdk-language': 'dart', - 'x-sdk-version': '12.0.0-rc.1', - 'X-Appwrite-Response-Format' : '1.5.0', + 'x-sdk-version': '12.0.0-rc.2', + 'X-Appwrite-Response-Format' : '1.6.0', }; config = {}; diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index bac64021..1e38e3f4 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -42,9 +42,9 @@ class ClientIO extends ClientBase with ClientMixin { 'x-sdk-name': 'Dart', 'x-sdk-platform': 'server', 'x-sdk-language': 'dart', - 'x-sdk-version': '12.0.0-rc.1', - 'user-agent' : 'AppwriteDartSDK/12.0.0-rc.1 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})', - 'X-Appwrite-Response-Format' : '1.5.0', + 'x-sdk-version': '12.0.0-rc.2', + 'user-agent' : 'AppwriteDartSDK/12.0.0-rc.2 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})', + 'X-Appwrite-Response-Format' : '1.6.0', }; config = {}; diff --git a/lib/src/models/execution.dart b/lib/src/models/execution.dart index d56dc167..96548ef2 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -34,6 +34,8 @@ class Execution implements Model { final String errors; /// Function execution duration in seconds. final double duration; + /// The scheduled time for execution. If left empty, execution will be queued immediately. + final String? scheduledAt; Execution({ required this.$id, @@ -52,6 +54,7 @@ class Execution implements Model { required this.logs, required this.errors, required this.duration, + this.scheduledAt, }); factory Execution.fromMap(Map map) { @@ -72,6 +75,7 @@ class Execution implements Model { logs: map['logs'].toString(), errors: map['errors'].toString(), duration: map['duration'].toDouble(), + scheduledAt: map['scheduledAt']?.toString(), ); } @@ -93,6 +97,7 @@ class Execution implements Model { "logs": logs, "errors": errors, "duration": duration, + "scheduledAt": scheduledAt, }; } } diff --git a/lib/src/models/runtime.dart b/lib/src/models/runtime.dart index 96f8864e..acda5a4f 100644 --- a/lib/src/models/runtime.dart +++ b/lib/src/models/runtime.dart @@ -4,6 +4,8 @@ part of '../../models.dart'; class Runtime implements Model { /// Runtime ID. final String $id; + /// Parent runtime key. + final String key; /// Runtime Name. final String name; /// Runtime version. @@ -19,6 +21,7 @@ class Runtime implements Model { Runtime({ required this.$id, + required this.key, required this.name, required this.version, required this.base, @@ -30,6 +33,7 @@ class Runtime implements Model { factory Runtime.fromMap(Map map) { return Runtime( $id: map['\$id'].toString(), + key: map['key'].toString(), name: map['name'].toString(), version: map['version'].toString(), base: map['base'].toString(), @@ -42,6 +46,7 @@ class Runtime implements Model { Map toMap() { return { "\$id": $id, + "key": key, "name": name, "version": version, "base": base, diff --git a/lib/src/models/template_function.dart b/lib/src/models/template_function.dart new file mode 100644 index 00000000..c3fcbe40 --- /dev/null +++ b/lib/src/models/template_function.dart @@ -0,0 +1,103 @@ +part of '../../models.dart'; + +/// Template Function +class TemplateFunction implements Model { + /// Function Template Icon. + final String icon; + /// Function Template ID. + final String id; + /// Function Template Name. + final String name; + /// Function Template Tagline. + final String tagline; + /// Execution permissions. + final List permissions; + /// Function trigger events. + final List events; + /// Function execution schedult in CRON format. + final String cron; + /// Function execution timeout in seconds. + final int timeout; + /// Function use cases. + final List useCases; + /// List of runtimes that can be used with this template. + final List runtimes; + /// Function Template Instructions. + final String instructions; + /// VCS (Version Control System) Provider. + final String vcsProvider; + /// VCS (Version Control System) Repository ID + final String providerRepositoryId; + /// VCS (Version Control System) Owner. + final String providerOwner; + /// VCS (Version Control System) branch version (tag). + final String providerVersion; + /// Function variables. + final List variables; + /// Function scopes. + final List scopes; + + TemplateFunction({ + required this.icon, + required this.id, + required this.name, + required this.tagline, + required this.permissions, + required this.events, + required this.cron, + required this.timeout, + required this.useCases, + required this.runtimes, + required this.instructions, + required this.vcsProvider, + required this.providerRepositoryId, + required this.providerOwner, + required this.providerVersion, + required this.variables, + required this.scopes, + }); + + factory TemplateFunction.fromMap(Map map) { + return TemplateFunction( + icon: map['icon'].toString(), + id: map['id'].toString(), + name: map['name'].toString(), + tagline: map['tagline'].toString(), + permissions: map['permissions'] ?? [], + events: map['events'] ?? [], + cron: map['cron'].toString(), + timeout: map['timeout'], + useCases: map['useCases'] ?? [], + runtimes: List.from(map['runtimes'].map((p) => TemplateRuntime.fromMap(p))), + instructions: map['instructions'].toString(), + vcsProvider: map['vcsProvider'].toString(), + providerRepositoryId: map['providerRepositoryId'].toString(), + providerOwner: map['providerOwner'].toString(), + providerVersion: map['providerVersion'].toString(), + variables: List.from(map['variables'].map((p) => TemplateVariable.fromMap(p))), + scopes: map['scopes'] ?? [], + ); + } + + Map toMap() { + return { + "icon": icon, + "id": id, + "name": name, + "tagline": tagline, + "permissions": permissions, + "events": events, + "cron": cron, + "timeout": timeout, + "useCases": useCases, + "runtimes": runtimes.map((p) => p.toMap()).toList(), + "instructions": instructions, + "vcsProvider": vcsProvider, + "providerRepositoryId": providerRepositoryId, + "providerOwner": providerOwner, + "providerVersion": providerVersion, + "variables": variables.map((p) => p.toMap()).toList(), + "scopes": scopes, + }; + } +} diff --git a/lib/src/models/template_function_list.dart b/lib/src/models/template_function_list.dart new file mode 100644 index 00000000..dddb2c94 --- /dev/null +++ b/lib/src/models/template_function_list.dart @@ -0,0 +1,28 @@ +part of '../../models.dart'; + +/// Function Templates List +class TemplateFunctionList implements Model { + /// Total number of templates documents that matched your query. + final int total; + /// List of templates. + final List templates; + + TemplateFunctionList({ + required this.total, + required this.templates, + }); + + factory TemplateFunctionList.fromMap(Map map) { + return TemplateFunctionList( + total: map['total'], + templates: List.from(map['templates'].map((p) => TemplateFunction.fromMap(p))), + ); + } + + Map toMap() { + return { + "total": total, + "templates": templates.map((p) => p.toMap()).toList(), + }; + } +} diff --git a/lib/src/models/template_runtime.dart b/lib/src/models/template_runtime.dart new file mode 100644 index 00000000..34209d13 --- /dev/null +++ b/lib/src/models/template_runtime.dart @@ -0,0 +1,38 @@ +part of '../../models.dart'; + +/// Template Runtime +class TemplateRuntime implements Model { + /// Runtime Name. + final String name; + /// The build command used to build the deployment. + final String commands; + /// The entrypoint file used to execute the deployment. + final String entrypoint; + /// Path to function in VCS (Version Control System) repository + final String providerRootDirectory; + + TemplateRuntime({ + required this.name, + required this.commands, + required this.entrypoint, + required this.providerRootDirectory, + }); + + factory TemplateRuntime.fromMap(Map map) { + return TemplateRuntime( + name: map['name'].toString(), + commands: map['commands'].toString(), + entrypoint: map['entrypoint'].toString(), + providerRootDirectory: map['providerRootDirectory'].toString(), + ); + } + + Map toMap() { + return { + "name": name, + "commands": commands, + "entrypoint": entrypoint, + "providerRootDirectory": providerRootDirectory, + }; + } +} diff --git a/lib/src/models/template_variable.dart b/lib/src/models/template_variable.dart new file mode 100644 index 00000000..df3982c7 --- /dev/null +++ b/lib/src/models/template_variable.dart @@ -0,0 +1,48 @@ +part of '../../models.dart'; + +/// Template Variable +class TemplateVariable implements Model { + /// Variable Name. + final String name; + /// Variable Description. + final String description; + /// Variable Value. + final String value; + /// Variable Placeholder. + final String placeholder; + /// Is the variable required? + final bool xrequired; + /// Variable Type. + final String type; + + TemplateVariable({ + required this.name, + required this.description, + required this.value, + required this.placeholder, + required this.xrequired, + required this.type, + }); + + factory TemplateVariable.fromMap(Map map) { + return TemplateVariable( + name: map['name'].toString(), + description: map['description'].toString(), + value: map['value'].toString(), + placeholder: map['placeholder'].toString(), + xrequired: map['required'], + type: map['type'].toString(), + ); + } + + Map toMap() { + return { + "name": name, + "description": description, + "value": value, + "placeholder": placeholder, + "required": xrequired, + "type": type, + }; + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 8eb7d9d8..27e2be87 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: dart_appwrite -version: 12.0.0-rc.1 +version: 12.0.0-rc.2 description: Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API homepage: https://appwrite.io repository: https://github.com/appwrite/sdk-for-dart diff --git a/test/services/account_test.dart b/test/services/account_test.dart index a7c4bda5..67144409 100644 --- a/test/services/account_test.dart +++ b/test/services/account_test.dart @@ -308,7 +308,6 @@ void main() { final response = await account.deleteMfaAuthenticator( type: 'totp', - otp: '', ); }); diff --git a/test/services/functions_test.dart b/test/services/functions_test.dart index 251ca674..50ef952e 100644 --- a/test/services/functions_test.dart +++ b/test/services/functions_test.dart @@ -129,6 +129,56 @@ void main() { }); + test('test method listTemplates()', () async { + final Map data = { + 'total': 5, + 'templates': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.listTemplates( + ); + expect(response, isA()); + + }); + + test('test method getTemplate()', () async { + final Map data = { + 'icon': 'icon-lightning-bolt', + 'id': 'starter', + 'name': 'Starter function', + 'tagline': 'A simple function to get started.', + 'permissions': [], + 'events': [], + 'cron': '0 0 * * *', + 'timeout': 300, + 'useCases': [], + 'runtimes': [], + 'instructions': 'For documentation and instructions check out .', + 'vcsProvider': 'github', + 'providerRepositoryId': 'templates', + 'providerOwner': 'appwrite', + 'providerVersion': 'main', + 'variables': [], + 'scopes': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.getTemplate( + templateId: '', + ); + expect(response, isA()); + + }); + test('test method get()', () async { final Map data = { '\$id': '5e5ea5c16897e', @@ -418,14 +468,14 @@ void main() { }); - test('test method downloadDeployment()', () async {final Uint8List data = Uint8List.fromList([]); + test('test method getDeploymentDownload()', () async {final Uint8List data = Uint8List.fromList([]); when(client.call( HttpMethod.get, )).thenAnswer((_) async => Response(data: data)); - final response = await functions.downloadDeployment( + final response = await functions.getDeploymentDownload( functionId: '', deploymentId: '', ); @@ -471,8 +521,12 @@ void main() { 'duration': 0.4,}; - when(client.call( - HttpMethod.post, + when(client.chunkedUpload( + path: argThat(isNotNull), + params: argThat(isNotNull), + paramName: argThat(isNotNull), + idParamName: argThat(isNotNull), + headers: argThat(isNotNull), )).thenAnswer((_) async => Response(data: data)); diff --git a/test/src/models/runtime_test.dart b/test/src/models/runtime_test.dart index 9f53b2b4..47b66744 100644 --- a/test/src/models/runtime_test.dart +++ b/test/src/models/runtime_test.dart @@ -7,6 +7,7 @@ void main() { test('model', () { final model = Runtime( $id: 'python-3.8', + key: 'python', name: 'Python', version: '3.8', base: 'python:3.8-alpine', @@ -19,6 +20,7 @@ void main() { final result = Runtime.fromMap(map); expect(result.$id, 'python-3.8'); + expect(result.key, 'python'); expect(result.name, 'Python'); expect(result.version, '3.8'); expect(result.base, 'python:3.8-alpine'); diff --git a/test/src/models/template_function_list_test.dart b/test/src/models/template_function_list_test.dart new file mode 100644 index 00000000..98dd3cd8 --- /dev/null +++ b/test/src/models/template_function_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('TemplateFunctionList', () { + + test('model', () { + final model = TemplateFunctionList( + total: 5, + templates: [], + ); + + final map = model.toMap(); + final result = TemplateFunctionList.fromMap(map); + + expect(result.total, 5); + expect(result.templates, []); + }); + }); +} diff --git a/test/src/models/template_function_test.dart b/test/src/models/template_function_test.dart new file mode 100644 index 00000000..a835597f --- /dev/null +++ b/test/src/models/template_function_test.dart @@ -0,0 +1,50 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('TemplateFunction', () { + + test('model', () { + final model = TemplateFunction( + icon: 'icon-lightning-bolt', + id: 'starter', + name: 'Starter function', + tagline: 'A simple function to get started.', + permissions: [], + events: [], + cron: '0 0 * * *', + timeout: 300, + useCases: [], + runtimes: [], + instructions: 'For documentation and instructions check out .', + vcsProvider: 'github', + providerRepositoryId: 'templates', + providerOwner: 'appwrite', + providerVersion: 'main', + variables: [], + scopes: [], + ); + + final map = model.toMap(); + final result = TemplateFunction.fromMap(map); + + expect(result.icon, 'icon-lightning-bolt'); + expect(result.id, 'starter'); + expect(result.name, 'Starter function'); + expect(result.tagline, 'A simple function to get started.'); + expect(result.permissions, []); + expect(result.events, []); + expect(result.cron, '0 0 * * *'); + expect(result.timeout, 300); + expect(result.useCases, []); + expect(result.runtimes, []); + expect(result.instructions, 'For documentation and instructions check out .'); + expect(result.vcsProvider, 'github'); + expect(result.providerRepositoryId, 'templates'); + expect(result.providerOwner, 'appwrite'); + expect(result.providerVersion, 'main'); + expect(result.variables, []); + expect(result.scopes, []); + }); + }); +} diff --git a/test/src/models/template_runtime_test.dart b/test/src/models/template_runtime_test.dart new file mode 100644 index 00000000..f749e783 --- /dev/null +++ b/test/src/models/template_runtime_test.dart @@ -0,0 +1,24 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('TemplateRuntime', () { + + test('model', () { + final model = TemplateRuntime( + name: 'node-19.0', + commands: 'npm install', + entrypoint: 'index.js', + providerRootDirectory: 'node/starter', + ); + + final map = model.toMap(); + final result = TemplateRuntime.fromMap(map); + + expect(result.name, 'node-19.0'); + expect(result.commands, 'npm install'); + expect(result.entrypoint, 'index.js'); + expect(result.providerRootDirectory, 'node/starter'); + }); + }); +} diff --git a/test/src/models/template_variable_test.dart b/test/src/models/template_variable_test.dart new file mode 100644 index 00000000..75827a6f --- /dev/null +++ b/test/src/models/template_variable_test.dart @@ -0,0 +1,28 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('TemplateVariable', () { + + test('model', () { + final model = TemplateVariable( + name: 'APPWRITE_DATABASE_ID', + description: 'The ID of the Appwrite database that contains the collection to sync.', + value: '512', + placeholder: '64a55...7b912', + xrequired: true, + type: 'password', + ); + + final map = model.toMap(); + final result = TemplateVariable.fromMap(map); + + expect(result.name, 'APPWRITE_DATABASE_ID'); + expect(result.description, 'The ID of the Appwrite database that contains the collection to sync.'); + expect(result.value, '512'); + expect(result.placeholder, '64a55...7b912'); + expect(result.xrequired, true); + expect(result.type, 'password'); + }); + }); +}