Skip to content

Commit 9c5993f

Browse files
committed
Pass all tests
1 parent eb33d83 commit 9c5993f

File tree

82 files changed

+1382
-863
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1382
-863
lines changed

src/SDK/Language/KMP.php

Lines changed: 51 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,22 @@ public function getName(): string
1616

1717
public function getFilters(): array
1818
{
19-
$filters = parent::getFilters();
19+
$filters = array_filter(parent::getFilters(), function ($filter) {
20+
return $filter->getName() !== 'propertyType';
21+
});
22+
23+
$filters[] = new TwigFilter('propertyType', function (array $property, array $spec, string $generic = 'T', $contextual = false) {
24+
return $this->getPropertyType($property, $spec, $generic, $contextual);
25+
});
2026

2127
$filters[] = new TwigFilter('webAuthServices', function (array $spec) {
2228
return $this->findWebAuthServices($spec);
2329
});
30+
31+
$filters[] = new TwigFilter('propertySerializerName', function (array $property) {
32+
return $this->getPropertySerializerName($property);
33+
});
34+
2435
return $filters;
2536
}
2637

@@ -67,6 +78,34 @@ protected function getPropertyType(array $property, array $spec, string $generic
6778
return $type;
6879
}
6980

81+
protected function getPropertySerializerName(array $property): string
82+
{
83+
if (isset($property['enumName'])) {
84+
return 'io.appwrite.enums.' . \ucfirst($property['enumName']) . 'Serializer';
85+
}
86+
if (!empty($property['enumValues'])) {
87+
return 'io.appwrite.enums.' . \ucfirst($property['name']) . 'Serializer';
88+
}
89+
if (isset($property['items'])) {
90+
$property['array'] = $property['items'];
91+
}
92+
93+
$name = match ($property['type']) {
94+
self::TYPE_INTEGER => 'Long.serializer()',
95+
self::TYPE_NUMBER => 'Double.serializer()',
96+
self::TYPE_STRING => 'String.serializer()',
97+
self::TYPE_BOOLEAN => 'Boolean.serializer()',
98+
self::TYPE_ARRAY => (!empty(($property['array'] ?? [])['type']) && !\is_array($property['array']['type']))
99+
? 'ListSerializer(' . $this->getPropertySerializerName($property['array']) . ')'
100+
: 'ListSerializer(DynamicLookupSerializer)',
101+
self::TYPE_OBJECT => 'DynamicLookupSerializer',
102+
default => $property['type'] . 'Serializer',
103+
};
104+
105+
return $name;
106+
}
107+
108+
70109
public function getFiles(): array
71110
{
72111
return [
@@ -150,6 +189,11 @@ public function getFiles(): array
150189
'destination' => 'gradle.properties',
151190
'template' => '/kmp/gradle.properties',
152191
],
192+
[
193+
'scope' => 'default',
194+
'destination' => 'local.properties',
195+
'template' => '/kmp/local.properties',
196+
],
153197

154198
// Shared module
155199
[
@@ -238,6 +282,11 @@ public function getFiles(): array
238282
'destination' => 'shared/src/commonMain/kotlin/{{ sdk.namespace | caseSlash }}/extensions/TypeExtensions.kt',
239283
'template' => '/kmp/shared/src/commonMain/kotlin/io/package/extensions/TypeExtensions.kt.twig',
240284
],
285+
[
286+
'scope' => 'default',
287+
'destination' => 'shared/src/commonMain/kotlin/{{ sdk.namespace | caseSlash }}/extensions/JsonObjectBuilderExtensions.kt',
288+
'template' => '/kmp/shared/src/commonMain/kotlin/io/package/extensions/JsonObjectBuilderExtensions.kt.twig',
289+
],
241290

242291
// File Operations
243292
[
@@ -269,11 +318,6 @@ public function getFiles(): array
269318
],
270319

271320
// Serializers
272-
[
273-
'scope' => 'default',
274-
'destination' => 'shared/src/commonMain/kotlin/{{ sdk.namespace | caseSlash }}/serializers/DocumentSerializer.kt',
275-
'template' => '/kmp/shared/src/commonMain/kotlin/io/package/serializers/DocumentSerializer.kt.twig',
276-
],
277321
[
278322
'scope' => 'default',
279323
'destination' => 'shared/src/commonMain/kotlin/{{ sdk.namespace | caseSlash }}/serializers/DynamicLookupSerializer.kt',
@@ -284,7 +328,7 @@ public function getFiles(): array
284328
'destination' => 'shared/src/commonMain/kotlin/{{ sdk.namespace | caseSlash }}/serializers/StringCollectionSeriailizer.kt',
285329
'template' => '/kmp/shared/src/commonMain/kotlin/io/package/serializers/StringCollectionSeriailizer.kt.twig',
286330
],
287-
331+
288332
// Services
289333
[
290334
'scope' => 'default',
@@ -372,13 +416,6 @@ public function getFiles(): array
372416
'template' => '/kmp/shared/src/androidMain/kotlin/io/package/extensions/OAuth2Extensions.kt.twig',
373417
],
374418

375-
// File Operations
376-
[
377-
'scope' => 'default',
378-
'destination' => 'shared/src/androidMain/kotlin/{{ sdk.namespace | caseSlash }}/fileOperations/FileOperations.android.kt',
379-
'template' => '/kmp/shared/src/androidMain/kotlin/io/package/fileOperations/FileOperations.android.kt.twig',
380-
],
381-
382419
// Models
383420
[
384421
'scope' => 'default',
@@ -437,13 +474,6 @@ public function getFiles(): array
437474
'template' => '/kmp/shared/src/iosMain/kotlin/io/package/extensions/OAuth2Extensions.kt.twig',
438475
],
439476

440-
// File Operations
441-
[
442-
'scope' => 'default',
443-
'destination' => 'shared/src/iosMain/kotlin/{{ sdk.namespace | caseSlash }}/fileOperations/FileOperations.ios.kt',
444-
'template' => '/kmp/shared/src/iosMain/kotlin/io/package/fileOperations/FileOperations.ios.kt.twig',
445-
],
446-
447477
// Models
448478
[
449479
'scope' => 'default',
@@ -494,13 +524,6 @@ public function getFiles(): array
494524
'template' => '/kmp/shared/src/jvmMain/kotlin/io/package/extensions/OAuth2Extensions.kt.twig',
495525
],
496526

497-
// File Operations
498-
[
499-
'scope' => 'default',
500-
'destination' => 'shared/src/jvmMain/kotlin/{{ sdk.namespace | caseSlash }}/fileOperations/FileOperations.jvm.kt',
501-
'template' => '/kmp/shared/src/jvmMain/kotlin/io/package/fileOperations/FileOperations.jvm.kt.twig',
502-
],
503-
504527
// Models
505528
[
506529
'scope' => 'default',
Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
{
2-
"$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json",
3-
"version": "{{ sdk.version }}",
4-
"description": "The Appwrite CLI is a command-line application that allows you to interact with Appwrite and perform server-side tasks using your terminal.",
5-
"homepage": "https://github.com/{{ sdk.gitUserName|url_encode }}/{{ sdk.gitRepoName|url_encode }}",
6-
"license": "BSD-3-Clause",
7-
"architecture": {
8-
"64bit": {
9-
"url": "https://github.com/{{ sdk.gitUserName }}/{{ sdk.gitRepoName | caseDash }}/releases/download/{{ sdk.version }}/{{ language.params.executableName }}-cli-win-x64.exe",
10-
"bin": [
11-
[
12-
"{{ language.params.executableName }}-cli-win-x64.exe",
13-
"{{ language.params.executableName|caseLower }}"
14-
]
15-
]
16-
},
17-
"arm64": {
18-
"url": "https://github.com/{{ sdk.gitUserName }}/{{ sdk.gitRepoName | caseDash }}/releases/download/{{ sdk.version }}/{{ language.params.executableName }}-cli-win-arm64.exe",
19-
"bin": [
20-
[
21-
"{{ language.params.executableName }}-cli-win-arm64.exe",
22-
"{{ language.params.executableName|caseLower }}"
23-
]
24-
]
25-
}
26-
},
27-
"checkver": {
28-
"github": "https://github.com/{{ sdk.gitUserName|url_encode }}/{{ sdk.gitRepoName|url_encode }}"
29-
}
1+
{
2+
"$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json",
3+
"version": "{{ sdk.version }}",
4+
"description": "The Appwrite CLI is a command-line application that allows you to interact with Appwrite and perform server-side tasks using your terminal.",
5+
"homepage": "https://github.com/{{ sdk.gitUserName|url_encode }}/{{ sdk.gitRepoName|url_encode }}",
6+
"license": "BSD-3-Clause",
7+
"architecture": {
8+
"64bit": {
9+
"url": "https://github.com/{{ sdk.gitUserName }}/{{ sdk.gitRepoName | caseDash }}/releases/download/{{ sdk.version }}/{{ language.params.executableName }}-cli-win-x64.exe",
10+
"bin": [
11+
[
12+
"{{ language.params.executableName }}-cli-win-x64.exe",
13+
"{{ language.params.executableName|caseLower }}"
14+
]
15+
]
16+
},
17+
"arm64": {
18+
"url": "https://github.com/{{ sdk.gitUserName }}/{{ sdk.gitRepoName | caseDash }}/releases/download/{{ sdk.version }}/{{ language.params.executableName }}-cli-win-arm64.exe",
19+
"bin": [
20+
[
21+
"{{ language.params.executableName }}-cli-win-arm64.exe",
22+
"{{ language.params.executableName|caseLower }}"
23+
]
24+
]
25+
}
26+
},
27+
"checkver": {
28+
"github": "https://github.com/{{ sdk.gitUserName|url_encode }}/{{ sdk.gitRepoName|url_encode }}"
29+
}
3030
}

templates/dotnet/Package/Extensions/Extensions.cs.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Newtonsoft.Json;
1+
using Newtonsoft.Json;
22
using System;
33
using System.Collections;
44
using System.Collections.Generic;

templates/kmp/.github/workflows/autoclose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ jobs:
88
auto_close:
99
uses: appwrite/.github/.github/workflows/autoclose.yml@main
1010
secrets:
11-
GH_AUTO_CLOSE_PR_TOKEN: ${{ secrets.GH_AUTO_CLOSE_PR_TOKEN }}
11+
GH_AUTO_CLOSE_PR_TOKEN: ${{ secrets.GH_AUTO_CLOSE_PR_TOKEN }}

templates/kmp/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ captures
77
.externalNativeBuild
88
.cxx
99
local.properties
10-
xcuserdata
10+
xcuserdata

templates/kmp/CHANGELOG.md.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{sdk.changelog}}
1+
{{sdk.changelog}}

templates/kmp/LICENSE.md.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{sdk.licenseContent | raw}}
1+
{{sdk.licenseContent | raw}}

templates/kmp/README.md.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,4 @@ This library is auto-generated by Appwrite custom [SDK Generator](https://github
7373

7474
## License
7575

76-
Please see the [{{spec.licenseName}} license]({{spec.licenseURL}}) file for more information.
76+
Please see the [{{spec.licenseName}} license]({{spec.licenseURL}}) file for more information.

templates/kmp/androidApp/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ dependencies {
4444
implementation(libs.compose.material3)
4545
implementation(libs.androidx.activity.compose)
4646
debugImplementation(libs.compose.ui.tooling)
47-
}
47+
}

templates/kmp/androidApp/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@
3535

3636
</application>
3737

38-
</manifest>
38+
</manifest>

0 commit comments

Comments
 (0)