From 24dd99bbd2abfba1c495f4fd90157dfb557ed260 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 31 Jan 2023 20:21:28 +1300 Subject: [PATCH] Fix oauth --- LICENSE | 2 +- README.md | 4 +-- docs/examples/functions/retry-build.md | 23 +++++++++++++ docs/examples/graphql/63a0228e7e93a.md | 21 ++++++++++++ docs/examples/graphql/63a025ceb6ac4.md | 21 ++++++++++++ docs/examples/graphql/get.md | 21 ++++++++++++ lib/id.dart | 2 ++ lib/permission.dart | 2 ++ lib/query.dart | 2 ++ lib/role.dart | 2 ++ lib/services/graph-q-l.dart | 47 ++++++++++++++++++++++++++ lib/src/client_browser.dart | 4 +-- lib/src/client_io.dart | 2 +- pubspec.yaml | 2 +- 14 files changed, 148 insertions(+), 7 deletions(-) create mode 100644 docs/examples/functions/retry-build.md create mode 100644 docs/examples/graphql/63a0228e7e93a.md create mode 100644 docs/examples/graphql/63a025ceb6ac4.md create mode 100644 docs/examples/graphql/get.md create mode 100644 lib/services/graph-q-l.dart diff --git a/LICENSE b/LICENSE index 90528c4..47cfdfb 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2022 Appwrite (https://appwrite.io) and individual contributors. +Copyright (c) 2023 Appwrite (https://appwrite.io) and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/README.md b/README.md index ee2e55a..245d1ae 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Add this to your package's `pubspec.yaml` file: ```yml dependencies: - appwrite: ^8.2.0 + appwrite: ^8.2.1 ``` You can install packages from the command line: @@ -91,7 +91,7 @@ For web in order to capture the OAuth2 callback URL and send it to the applicati close the window. diff --git a/docs/examples/functions/retry-build.md b/docs/examples/functions/retry-build.md new file mode 100644 index 0000000..1e6c174 --- /dev/null +++ b/docs/examples/functions/retry-build.md @@ -0,0 +1,23 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Functions functions = Functions(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + Future result = functions.retryBuild( + functionId: '[FUNCTION_ID]', + deploymentId: '[DEPLOYMENT_ID]', + buildId: '[BUILD_ID]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} diff --git a/docs/examples/graphql/63a0228e7e93a.md b/docs/examples/graphql/63a0228e7e93a.md new file mode 100644 index 0000000..35ebafc --- /dev/null +++ b/docs/examples/graphql/63a0228e7e93a.md @@ -0,0 +1,21 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Graphql graphql = Graphql(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + Future result = graphql.63a0228e7e93a( + query: '[QUERY]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} diff --git a/docs/examples/graphql/63a025ceb6ac4.md b/docs/examples/graphql/63a025ceb6ac4.md new file mode 100644 index 0000000..1ef1965 --- /dev/null +++ b/docs/examples/graphql/63a025ceb6ac4.md @@ -0,0 +1,21 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Graphql graphql = Graphql(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + Future result = graphql.63a025ceb6ac4( + query: '[QUERY]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} diff --git a/docs/examples/graphql/get.md b/docs/examples/graphql/get.md new file mode 100644 index 0000000..59cee1a --- /dev/null +++ b/docs/examples/graphql/get.md @@ -0,0 +1,21 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Graphql graphql = Graphql(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + Future result = graphql.get( + query: '[QUERY]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} diff --git a/lib/id.dart b/lib/id.dart index 257a4f7..e32f001 100644 --- a/lib/id.dart +++ b/lib/id.dart @@ -1,6 +1,8 @@ part of appwrite; class ID { + ID._(); + static String unique() { return 'unique()'; } diff --git a/lib/permission.dart b/lib/permission.dart index 330be95..5bc0cfd 100644 --- a/lib/permission.dart +++ b/lib/permission.dart @@ -1,6 +1,8 @@ part of appwrite; class Permission { + Permission._(); + static String read(String role) { return 'read("$role")'; } diff --git a/lib/query.dart b/lib/query.dart index 41a4449..14bf1b7 100644 --- a/lib/query.dart +++ b/lib/query.dart @@ -1,6 +1,8 @@ part of appwrite; class Query { + Query._(); + static equal(String attribute, dynamic value) => _addQuery(attribute, 'equal', value); diff --git a/lib/role.dart b/lib/role.dart index 9d72db7..445579e 100644 --- a/lib/role.dart +++ b/lib/role.dart @@ -1,6 +1,8 @@ part of appwrite; class Role { + Role._(); + static String any() { return 'any'; } diff --git a/lib/services/graph-q-l.dart b/lib/services/graph-q-l.dart new file mode 100644 index 0000000..d1f0569 --- /dev/null +++ b/lib/services/graph-q-l.dart @@ -0,0 +1,47 @@ +part of appwrite; + +class GraphQL extends Service { + GraphQL(super.client); + + /// GraphQL Endpoint + /// + /// Execute a GraphQL mutation. + /// + Future query({required Map query}) async { + const String path = '/graphql'; + + final Map params = { + 'query': query, + }; + + final Map headers = { + 'x-sdk-graphql': 'true', 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + + return res.data; + + } + + /// GraphQL Endpoint + /// + /// Execute a GraphQL mutation. + /// + Future mutation({required Map query}) async { + const String path = '/graphql/mutation'; + + final Map params = { + 'query': query, + }; + + final Map headers = { + 'x-sdk-graphql': 'true', 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + + return res.data; + + } +} \ No newline at end of file diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index 4e7461c..9734609 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -43,7 +43,7 @@ class ClientBrowser extends ClientBase with ClientMixin { 'x-sdk-name': 'Flutter', 'x-sdk-platform': 'client', 'x-sdk-language': 'flutter', - 'x-sdk-version': '8.2.0', + 'x-sdk-version': '8.2.1', 'X-Appwrite-Response-Format' : '1.0.0', }; @@ -221,7 +221,7 @@ class ClientBrowser extends ClientBase with ClientMixin { Future webAuth(Uri url, {String? callbackUrlScheme}) { return FlutterWebAuth2.authenticate( url: url.toString(), - callbackUrlScheme: callbackUrlScheme ?? "appwrite-callback-" + config['project']!, + callbackUrlScheme: "appwrite-callback-" + config['project']!, ); } } diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index 6f5f877..40f556b 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -64,7 +64,7 @@ class ClientIO extends ClientBase with ClientMixin { 'x-sdk-name': 'Flutter', 'x-sdk-platform': 'client', 'x-sdk-language': 'flutter', - 'x-sdk-version': '8.2.0', + 'x-sdk-version': '8.2.1', 'X-Appwrite-Response-Format' : '1.0.0', }; diff --git a/pubspec.yaml b/pubspec.yaml index b42465d..9302c4a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: appwrite -version: 8.2.0 +version: 8.2.1 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-flutter