Skip to content

Commit

Permalink
Merge branch 'master' into maintenance-upgrade-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
lohanidamodar authored Jul 11, 2023
2 parents 2d2a0c2 + 72bc680 commit 578aa35
Show file tree
Hide file tree
Showing 60 changed files with 1,414 additions and 147 deletions.
160 changes: 73 additions & 87 deletions composer.lock

Large diffs are not rendered by default.

55 changes: 55 additions & 0 deletions src/SDK/Language/Dart.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,61 @@ public function getFiles(): array
'destination' => 'docs/examples/{{service.name | caseLower}}/{{method.name | caseDash}}.md',
'template' => 'dart/docs/example.md.twig',
],
[
'scope' => 'service',
'destination' => '/test/services/{{service.name | caseDash}}_test.dart',
'template' => 'dart/test/services/service_test.dart.twig',
],
[
'scope' => 'definition',
'destination' => '/test/src/models/{{definition.name | caseSnake }}_test.dart',
'template' => 'dart/test/src/models/model_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/id_test.dart',
'template' => 'dart/test/id_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/permission_test.dart',
'template' => 'dart/test/permission_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/query_test.dart',
'template' => 'dart/test/query_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/role_test.dart',
'template' => 'dart/test/role_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/src/enums_test.dart',
'template' => 'dart/test/src/enums_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/src/upload_progress_test.dart',
'template' => 'dart/test/src/upload_progress_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/src/exception_test.dart',
'template' => 'dart/test/src/exception_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/src/input_file_test.dart',
'template' => 'dart/test/src/input_file_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/src/response_test.dart',
'template' => 'dart/test/src/response_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '.travis.yml',
Expand Down
2 changes: 1 addition & 1 deletion src/SDK/Language/DotNet.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public function getParamExample(array $param): string
if (empty($example) && $example !== 0 && $example !== false) {
switch ($type) {
case self::TYPE_FILE:
$output .= 'new File("./path-to-files/image.jpg")';
$output .= 'InputFile.FromPath("./path-to-files/image.jpg")';
break;
case self::TYPE_NUMBER:
case self::TYPE_INTEGER:
Expand Down
80 changes: 80 additions & 0 deletions src/SDK/Language/Flutter.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,86 @@ public function getFiles(): array
'destination' => '/lib/services/{{service.name | caseDash}}.dart',
'template' => 'flutter/lib/services/service.dart.twig',
],
[
'scope' => 'service',
'destination' => '/test/services/{{service.name | caseDash}}_test.dart',
'template' => 'dart/test/services/service_test.dart.twig',
],
[
'scope' => 'definition',
'destination' => '/test/src/models/{{definition.name | caseSnake }}_test.dart',
'template' => 'dart/test/src/models/model_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/id_test.dart',
'template' => 'dart/test/id_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/permission_test.dart',
'template' => 'dart/test/permission_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/query_test.dart',
'template' => 'dart/test/query_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/role_test.dart',
'template' => 'dart/test/role_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/src/cookie_manager_test.dart',
'template' => 'flutter/test/src/cookie_manager_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/src/interceptor_test.dart',
'template' => 'flutter/test/src/interceptor_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/src/realtime_response_test.dart',
'template' => 'flutter/test/src/realtime_response_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/src/realtime_response_connected_test.dart',
'template' => 'flutter/test/src/realtime_response_connected_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/src/realtime_subscription_test.dart',
'template' => 'flutter/test/src/realtime_subscription_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/src/enums_test.dart',
'template' => 'dart/test/src/enums_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/src/upload_progress_test.dart',
'template' => 'dart/test/src/upload_progress_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/src/input_file_test.dart',
'template' => 'dart/test/src/input_file_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/src/exception_test.dart',
'template' => 'dart/test/src/exception_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/src/response_test.dart',
'template' => 'dart/test/src/response_test.dart.twig',
],
[
'scope' => 'method',
'destination' => 'docs/examples/{{service.name | caseLower}}/{{method.name | caseDash}}.md',
Expand Down
1 change: 1 addition & 0 deletions src/Spec/Swagger2.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ public function getDefinitions()
foreach ($sch['properties'] as $name => $def) {
$sch['properties'][$name]['name'] = $name;
$sch['properties'][$name]['description'] = $def['description'];
$sch['properties'][$name]['example'] = $def['x-example'];
$sch['properties'][$name]['required'] = in_array($name, $sch['required']);
if (isset($def['items']['$ref'])) {
//nested model
Expand Down
1 change: 1 addition & 0 deletions templates/cli/lib/commands/generic.js.twig
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const client = new Command("client")
}

let client = new Client().setEndpoint(endpoint);
client.setProject('console');
if (selfSigned || globalConfig.getSelfSigned()) {
client.setSelfSigned(true);
}
Expand Down
2 changes: 1 addition & 1 deletion templates/dart/README.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![pub package](https://img.shields.io/pub/v/{{ language.params.packageName }}.svg?style=flat-square)](https://pub.dartlang.org/packages/{{ language.params.packageName }})
![License](https://img.shields.io/github/license/{{ sdk.gitUserName|url_encode }}/{{ sdk.gitRepoName|url_encode }}.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-{{ spec.version|url_encode }}-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-{{spec.version | split('.') | slice(0,2) | join('.') ~ '.x' | url_encode}}-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)
{% if sdk.twitterHandle %}
[![Twitter Account](https://img.shields.io/twitter/follow/{{ sdk.twitterHandle }}?color=00acee&label=twitter&style=flat-square)](https://twitter.com/{{ sdk.twitterHandle }})
Expand Down
19 changes: 11 additions & 8 deletions templates/dart/lib/id.dart.twig
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
part of {{ language.params.packageName }};

/// Helper class to generate ID strings for resources.
class ID {
ID._();

static String unique() {
return 'unique()';
}
ID._();

static String custom(String id) {
return id;
}
/// Have Appwrite generate a unique ID for you.
static String unique() {
return 'unique()';
}

/// Uses [id] as the ID for the resource.
static String custom(String id) {
return id;
}
}
1 change: 1 addition & 0 deletions templates/dart/lib/models.dart.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// {{spec.title | caseUcfirst}} Models
library {{ language.params.packageName }}.models;

part 'src/models/model.dart';
Expand Down
5 changes: 5 additions & 0 deletions templates/dart/lib/package.dart.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/// {{spec.title | caseUcfirst}} {{sdk.name}} SDK
///
/// This SDK is compatible with Appwrite server version {{spec.version | split('.') | slice(0,2) | join('.') ~ '.x' }}.
/// For older versions, please check
/// [previous releases](https://github.com/{{sdk.gitUserName}}/{{sdk.gitRepoName}}/releases).
library {{ language.params.packageName }};

import 'dart:async';
Expand Down
45 changes: 29 additions & 16 deletions templates/dart/lib/permission.dart.twig
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
part of {{ language.params.packageName }};

/// Helper class to generate permission strings for resources.
class Permission {
Permission._();
Permission._();

static String read(String role) {
return 'read("$role")';
}
static String write(String role) {
return 'write("$role")';
}
static String create(String role) {
return 'create("$role")';
}
static String update(String role) {
return 'update("$role")';
}
static String delete(String role) {
return 'delete("$role")';
}
/// Read permission for provided [role]
static String read(String role) {
return 'read("$role")';
}

/// Write permission for provided [role]
///
/// This is an alias of update, delete, and possibly create.
/// Don't use write in combination with update, delete, or create.
static String write(String role) {
return 'write("$role")';
}

/// Create permission for provided [role]
static String create(String role) {
return 'create("$role")';
}

/// Update permission for provided [role]
static String update(String role) {
return 'update("$role")';
}

/// Delete permission for provided [role]
static String delete(String role) {
return 'delete("$role")';
}
}
52 changes: 45 additions & 7 deletions templates/dart/lib/query.dart.twig
Original file line number Diff line number Diff line change
@@ -1,61 +1,99 @@
part of {{ language.params.packageName }};

/// Helper class to generate query strings.
class Query {
Query._();

Query._();

/// Filter resources where [attribute] is equal to [value].
///
/// [value] can be a single value or a list. If a list is used
/// the query will return resources where [attribute] is equal
/// to any of the values in the list.
static String equal(String attribute, dynamic value) =>
_addQuery(attribute, 'equal', value);

/// Filter resources where [attribute] is not equal to [value].
///
/// [value] can be a single value or a list. If a list is used
/// the query will return resources where [attribute] is equal
/// to any of the values in the list.
static String notEqual(String attribute, dynamic value) =>
_addQuery(attribute, 'notEqual', value);

/// Filter resources where [attribute] is less than [value].
static String lessThan(String attribute, dynamic value) =>
_addQuery(attribute, 'lessThan', value);

/// Filter resources where [attribute] is less than or equal to [value].
static String lessThanEqual(String attribute, dynamic value) =>
_addQuery(attribute, 'lessThanEqual', value);

/// Filter resources where [attribute] is greater than [value].
static String greaterThan(String attribute, dynamic value) =>
_addQuery(attribute, 'greaterThan', value);

/// Filter resources where [attribute] is greater than or equal to [value].
static String greaterThanEqual(String attribute, dynamic value) =>
_addQuery(attribute, 'greaterThanEqual', value);

/// Filter resources where by searching [attribute] for [value].
static String search(String attribute, String value) =>
_addQuery(attribute, 'search', value);

/// Filter resources where [attribute] is null.
static String isNull(String attribute) => 'isNull("$attribute")';

/// Filter resources where [attribute] is not null.
static String isNotNull(String attribute) => 'isNotNull("$attribute")';

/// Filter resources where [attribute] is between [start] and [end] (inclusive).
static String between(String attribute, dynamic start, dynamic end) =>
_addQuery(attribute, 'between', [start, end]);

/// Filter resources where [attribute] starts with [value].
static String startsWith(String attribute, String value) =>
_addQuery(attribute, 'startsWith', value);

/// Filter resources where [attribute] ends with [value].
static String endsWith(String attribute, String value) =>
_addQuery(attribute, 'endsWith', value);

static String select(List<String> attributes) => 'select([${attributes.map((attr) => "\"$attr\"").join(",")}])';
/// Specify which attributes should be returned by the API call.
static String select(List<String> attributes) =>
'select([${attributes.map((attr) => "\"$attr\"").join(",")}])';

/// Sort results by [attribute] ascending.
static String orderAsc(String attribute) => 'orderAsc("$attribute")';

/// Sort results by [attribute] descending.
static String orderDesc(String attribute) => 'orderDesc("$attribute")';

/// Return results before [id].
///
/// Refer to the [Cursor Based Pagination]({{sdk.url}}/docs/pagination#cursor-pagination)
/// docs for more information.
static String cursorBefore(String id) => 'cursorBefore("$id")';

/// Return results after [id].
///
/// Refer to the [Cursor Based Pagination]({{sdk.url}}/docs/pagination#cursor-pagination)
/// docs for more information.
static String cursorAfter(String id) => 'cursorAfter("$id")';

/// Return only [limit] results.
static String limit(int limit) => 'limit($limit)';

/// Return results from [offset].
///
/// Refer to the [Offset Pagination]({{sdk.url}}/docs/pagination#offset-pagination)
/// docs for more information.
static String offset(int offset) => 'offset($offset)';

static String _addQuery(String attribute, String method, dynamic value) => (value
is List)
? '$method("$attribute", [${value.map((item) => parseValues(item)).join(",")}])'
: '$method("$attribute", [${parseValues(value)}])';
? '$method("$attribute", [${value.map((item) => _parseValues(item)).join(",")}])'
: '$method("$attribute", [${_parseValues(value)}])';

static String parseValues(dynamic value) =>
static String _parseValues(dynamic value) =>
(value is String) ? '"$value"' : '$value';
}
}
Loading

0 comments on commit 578aa35

Please sign in to comment.