Skip to content

Commit 1e44565

Browse files
committed
Merge remote-tracking branch 'origin/master' into feat-android-updates
# Conflicts: # templates/kotlin/src/main/kotlin/io/appwrite/services/ServiceTemplate.kt.twig
2 parents c76540f + 263ecd9 commit 1e44565

File tree

15 files changed

+109
-70
lines changed

15 files changed

+109
-70
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ env:
2929
- SDK=DartStable
3030
- SDK=Deno1171
3131
- SDK=FlutterStable
32+
- SDK=FlutterBeta
3233
- SDK=Go112
3334
- SDK=Go118
34-
# - SDK=FlutterBeta
3535
- SDK=KotlinJava8
3636
- SDK=KotlinJava11
3737
- SDK=KotlinJava17

CONTRIBUTING.md

Lines changed: 42 additions & 42 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
**WORK IN PROGRESS - NOT READY FOR GENERAL USAGE**
1010

11-
[Appwrite](https://appwrite.io) SDK generator is a PHP library for auto generating SDK libraries for multiple languages and platforms.
11+
[Appwrite](https://appwrite.io) SDK generator is a PHP library for auto-generating SDK libraries for multiple languages and platforms.
1212

1313
The SDK Generator uses predefined language settings as [Twig templates](https://twig.symfony.com/) to generate codebases based on different API specs.
1414

15-
Currently, the only spec supported is Swagger 2.0, but we intend to add support for more specifications in the near future. This generator is still lacking support for any definition/models specs.
15+
Currently, the only spec supported is Swagger 2.0, but we intend to add support for more specifications in the near future. This generator is still lacking support for any definition/model specs.
1616

1717
## Getting Started
1818

@@ -134,7 +134,7 @@ $sdk->generate(__DIR__ . '/examples/php'); // Generate source code
134134

135135
## Contributing
136136

137-
All code contributions - including those of people having commit access - must go through a pull request and approved by a core developer before being merged. This is to ensure proper review of all the code.
137+
All code contributions, including those by people with commit access, must go through a pull request and be approved by a core developer before being merged. This is to ensure proper review of all the code.
138138

139139
We truly ❤️ pull requests! If you wish to help, you can learn more about how you can contribute to this project in the [contribution guide](CONTRIBUTING.md).
140140

src/SDK/Language/Swift.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ public function getFiles(): array
176176
],
177177
[
178178
'scope' => 'default',
179-
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/Extensions/Codable+JSON.swift',
180-
'template' => 'swift/Sources/Extensions/Codable+JSON.swift.twig',
179+
'destination' => '/Sources/JSONCodable/Codable+JSON.swift',
180+
'template' => 'swift/Sources/JSONCodable/Codable+JSON.swift.twig',
181181
],
182182
[
183183
'scope' => 'default',

templates/android/library/src/main/java/io/appwrite/services/ServiceTemplate.kt.twig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ class {{ service.name | caseUcfirst }} : Service {
6262
{%~ for parameter in method.parameters.query | merge(method.parameters.body) %}
6363
"{{ parameter.name }}" to {{ parameter.name | caseCamel }},
6464
{%~ endfor %}
65+
{%~ if method.auth | length > 0 %}
66+
{%~ for node in method.auth %}
67+
{%~ for key,header in node | keys %}
68+
"{{ header | caseLower }}" to client.config["{{ header | caseLower }}"],
69+
{%~ endfor %}
70+
{%~ endfor %}
71+
{%~ endif %}
6572
)
6673
{%~ if method.type == 'webAuth' %}
6774
val query = mutableListOf<String>()

templates/flutter/lib/src/client_io.dart.twig

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,18 @@ class ClientIO extends ClientBase with ClientMixin {
133133
Future init() async {
134134
if(_initProgress) return;
135135
_initProgress = true;
136-
// if web skip cookie implementation and origin header as those are automatically handled by browsers
137136
final Directory cookieDir = await _getCookiePath();
138137
_cookieJar = PersistCookieJar(storage: FileStorage(cookieDir.path));
139138
_interceptors.add(CookieManager(_cookieJar));
140-
PackageInfo packageInfo = await PackageInfo.fromPlatform();
141-
addHeader('Origin',
142-
'appwrite-${Platform.operatingSystem}://${packageInfo.packageName}');
143139

144-
//creating custom user agent
145-
DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
146140
var device = '';
147141
try {
142+
PackageInfo packageInfo = await PackageInfo.fromPlatform();
143+
addHeader('Origin',
144+
'appwrite-${Platform.operatingSystem}://${packageInfo.packageName}');
145+
146+
//creating custom user agent
147+
DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
148148
if (Platform.isAndroid) {
149149
final andinfo = await deviceInfoPlugin.androidInfo;
150150
device =
@@ -167,12 +167,14 @@ class ClientIO extends ClientBase with ClientMixin {
167167
final macinfo = await deviceInfoPlugin.macOsInfo;
168168
device = '(Macintosh; ${macinfo.model})';
169169
}
170+
addHeader(
171+
'user-agent', '${packageInfo.packageName}/${packageInfo.version} $device');
170172
} catch (e) {
171173
debugPrint('Error getting device info: $e');
172174
device = Platform.operatingSystem;
175+
addHeader(
176+
'user-agent', '$device');
173177
}
174-
addHeader(
175-
'user-agent', '${packageInfo.packageName}/${packageInfo.version} $device');
176178

177179
_initialized = true;
178180
_initProgress = false;

templates/flutter/lib/src/cookie_manager.dart.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ class CookieManager extends Interceptor {
2323
}
2424
return request;
2525
}).catchError((e, stackTrace) {
26-
// throw AppwriteException(e.message);
26+
return request;
2727
});
2828
return request;
2929
}
3030

3131
@override
3232
FutureOr<http.Response> onResponse(http.Response response) {
3333
_saveCookies(response).then((_) => response).catchError((e, stackTrace) {
34-
// throw AppwriteException(e.message);
34+
return response;
3535
});
3636
return response;
3737
}

templates/flutter/pubspec.yaml.twig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ dependencies:
1616
flutter_web_auth_2: ^2.0.2
1717
http: ^0.13.5
1818
package_info_plus: ^3.0.2
19-
path_provider: ^2.0.11
19+
path_provider: ^2.0.12
2020
web_socket_channel: ^2.2.0
2121
universal_html: ^2.0.8
2222
2323
dev_dependencies:
24+
path_provider_platform_interface: ^2.0.5
2425
flutter_lints: ^2.0.1
2526
flutter_test:
2627
sdk: flutter

templates/kotlin/src/main/kotlin/io/appwrite/services/ServiceTemplate.kt.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class {{ service.name | caseUcfirst }} : Service {
7272
{%~ if method.responseModel == 'any' %}
7373
it
7474
{%~ else %}
75-
{{sdk.namespace | caseDot}}.models.{{ method.responseModel | caseUcfirst }}.from(map = it as Map<String, Any>{% if method.responseModel | hasGenericType(spec) %}, nestedType{% endif %})
75+
{{ sdk.namespace | caseDot }}.models.{{ method.responseModel | caseUcfirst }}.from(map = it as Map<String, Any>{% if method.responseModel | hasGenericType(spec) %}, nestedType{% endif %})
7676
{%~ endif %}
7777
}
7878
{%~ endif %}

templates/swift/Package.swift.twig

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ let package = Package(
1313
products: [
1414
.library(
1515
name: "{{spec.title | caseUcfirst}}",
16-
targets: ["{{spec.title | caseUcfirst}}", "{{spec.title | caseUcfirst}}Models"]
16+
targets: ["{{spec.title | caseUcfirst}}", "{{spec.title | caseUcfirst}}Models", "JSONCodable"]
1717
),
1818
],
1919
dependencies: [
@@ -26,11 +26,18 @@ let package = Package(
2626
dependencies: [
2727
.product(name: "AsyncHTTPClient", package: "async-http-client"),
2828
.product(name: "NIOWebSocket", package: "swift-nio"),
29-
"{{spec.title | caseUcfirst}}Models"
29+
"{{spec.title | caseUcfirst}}Models",
30+
"JSONCodable"
3031
]
3132
),
3233
.target(
33-
name: "{{spec.title | caseUcfirst}}Models"
34+
name: "{{spec.title | caseUcfirst}}Models",
35+
dependencies: [
36+
"JSONCodable"
37+
]
38+
),
39+
.target(
40+
name: "JSONCodable"
3441
),
3542
.testTarget(
3643
name: "{{spec.title | caseUcfirst}}Tests",

0 commit comments

Comments
 (0)