Skip to content

Commit aa584c4

Browse files
authored
Merge branch 'master' into patch-1
2 parents b9ca47c + d69be8d commit aa584c4

File tree

266 files changed

+9631
-1596
lines changed

Some content is hidden

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

266 files changed

+9631
-1596
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
Deno1303,
2525
DotNet60,
2626
DotNet80,
27+
DotNet90,
2728
FlutterStable,
2829
FlutterBeta,
2930
Go112,

composer.lock

Lines changed: 263 additions & 165 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ function getSSLPage($url) {
3838
}
3939

4040
// Leave the platform you want uncommented
41-
// $platform = 'client';
42-
$platform = 'console';
41+
// $platform = 'client';
42+
$platform = 'console';
4343
// $platform = 'server';
4444

45-
$spec = getSSLPage("https://raw.githubusercontent.com/appwrite/appwrite/1.6.x/app/config/specs/swagger2-latest-{$platform}.json");
45+
$version = '1.8.x';
46+
$spec = getSSLPage("https://raw.githubusercontent.com/appwrite/appwrite/{$version}/app/config/specs/swagger2-{$version}-{$platform}.json");
4647

4748
if(empty($spec)) {
4849
throw new Exception('Failed to fetch spec from Appwrite server');
@@ -75,7 +76,7 @@ function getSSLPage($url) {
7576

7677
$sdk->generate(__DIR__ . '/examples/php');
7778

78-
// // Web
79+
// Web
7980
$sdk = new SDK(new Web(), new Swagger2($spec));
8081

8182
$sdk
@@ -186,7 +187,13 @@ function getSSLPage($url) {
186187
->setTwitter('appwrite_io')
187188
->setDiscord('564160730845151244', 'https://appwrite.io/discord')
188189
->setDefaultHeaders([
189-
'X-Appwrite-Response-Format' => '1.6.0',
190+
'X-Appwrite-Response-Format' => '1.7.0',
191+
])
192+
->setExclude([
193+
'services' => [
194+
['name' => 'assistant'],
195+
['name' => 'avatars'],
196+
],
190197
])
191198
;
192199

@@ -322,7 +329,6 @@ function getSSLPage($url) {
322329
$sdk->generate(__DIR__ . '/examples/react-native');
323330

324331
// GO
325-
326332
$sdk = new SDK(new Go(), new Swagger2($spec));
327333

328334
$sdk
@@ -347,7 +353,7 @@ function getSSLPage($url) {
347353
$sdk->generate(__DIR__ . '/examples/go');
348354

349355

350-
// Swift (Server)
356+
// Swift
351357
$sdk = new SDK(new Swift(), new Swagger2($spec));
352358

353359
$sdk
@@ -371,7 +377,7 @@ function getSSLPage($url) {
371377

372378
$sdk->generate(__DIR__ . '/examples/swift');
373379

374-
// Swift (Client)
380+
// Apple
375381
$sdk = new SDK(new Apple(), new Swagger2($spec));
376382

377383
$sdk
@@ -441,7 +447,6 @@ function getSSLPage($url) {
441447
$sdk->generate(__DIR__ . '/examples/REST');
442448

443449
// Android
444-
445450
$sdk = new SDK(new Android(), new Swagger2($spec));
446451

447452
$sdk

mock-server/src/Utopia/Exception.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
],
7070
Exception::GENERAL_ROUTE_NOT_FOUND => [
7171
'name' => Exception::GENERAL_ROUTE_NOT_FOUND,
72-
'description' => 'The requested route was not found. Please refer to the API docs and try again.',
72+
'description' => 'Route not found. Please ensure the endpoint is configured correctly and that the API route is valid for this SDK version. Refer to the API docs for more details.',
7373
'code' => 404,
7474
],
7575
Exception::GENERAL_CURSOR_NOT_FOUND => [

src/SDK/Language/Android.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ public function getFiles(): array
2626
],
2727
[
2828
'scope' => 'method',
29-
'destination' => 'docs/examples/kotlin/{{service.name | caseLower}}/{{method.name | caseDash}}.md',
29+
'destination' => 'docs/examples/kotlin/{{service.name | caseLower}}/{{method.name | caseKebab}}.md',
3030
'template' => '/android/docs/kotlin/example.md.twig',
3131
],
3232
[
3333
'scope' => 'method',
34-
'destination' => 'docs/examples/java/{{service.name | caseLower}}/{{method.name | caseDash}}.md',
34+
'destination' => 'docs/examples/java/{{service.name | caseLower}}/{{method.name | caseKebab}}.md',
3535
'template' => '/android/docs/java/example.md.twig',
3636
],
3737
[

src/SDK/Language/Apple.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function getFiles(): array
3737
],
3838
[
3939
'scope' => 'method',
40-
'destination' => 'docs/examples/{{service.name | caseLower}}/{{method.name | caseDash}}.md',
40+
'destination' => 'docs/examples/{{service.name | caseLower}}/{{method.name | caseKebab}}.md',
4141
'template' => 'swift/docs/example.md.twig',
4242
],
4343
[

src/SDK/Language/CLI.php

Lines changed: 70 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,20 @@ public function getFiles(): array
125125
'destination' => 'README.md',
126126
'template' => 'cli/README.md.twig',
127127
],
128+
[
129+
'scope' => 'default',
130+
'destination' => 'CHANGELOG.md',
131+
'template' => 'cli/CHANGELOG.md.twig',
132+
],
128133
[
129134
'scope' => 'default',
130135
'destination' => 'package.json',
131136
'template' => 'cli/package.json.twig',
132137
],
133138
[
134139
'scope' => 'default',
135-
'destination' => 'scoop/appwrite.json',
136-
'template' => 'cli/scoop/appwrite.json.twig',
140+
'destination' => 'scoop/appwrite.config.json',
141+
'template' => 'cli/scoop/appwrite.config.json.twig',
137142
'minify' => false,
138143
],
139144
[
@@ -158,7 +163,7 @@ public function getFiles(): array
158163
],
159164
[
160165
'scope' => 'method',
161-
'destination' => 'docs/examples/{{service.name | caseLower}}/{{method.name | caseDash}}.md',
166+
'destination' => 'docs/examples/{{service.name | caseLower}}/{{method.name | caseKebab}}.md',
162167
'template' => 'cli/docs/example.md.twig',
163168
],
164169
[
@@ -181,6 +186,56 @@ public function getFiles(): array
181186
'destination' => 'lib/sdks.js',
182187
'template' => 'cli/lib/sdks.js.twig',
183188
],
189+
[
190+
'scope' => 'default',
191+
'destination' => 'lib/type-generation/attribute.js',
192+
'template' => 'cli/lib/type-generation/attribute.js.twig',
193+
],
194+
[
195+
'scope' => 'default',
196+
'destination' => 'lib/type-generation/languages/language.js',
197+
'template' => 'cli/lib/type-generation/languages/language.js.twig',
198+
],
199+
[
200+
'scope' => 'default',
201+
'destination' => 'lib/type-generation/languages/php.js',
202+
'template' => 'cli/lib/type-generation/languages/php.js.twig',
203+
],
204+
[
205+
'scope' => 'default',
206+
'destination' => 'lib/type-generation/languages/typescript.js',
207+
'template' => 'cli/lib/type-generation/languages/typescript.js.twig',
208+
],
209+
[
210+
'scope' => 'default',
211+
'destination' => 'lib/type-generation/languages/javascript.js',
212+
'template' => 'cli/lib/type-generation/languages/javascript.js.twig',
213+
],
214+
[
215+
'scope' => 'default',
216+
'destination' => 'lib/type-generation/languages/kotlin.js',
217+
'template' => 'cli/lib/type-generation/languages/kotlin.js.twig',
218+
],
219+
[
220+
'scope' => 'default',
221+
'destination' => 'lib/type-generation/languages/swift.js',
222+
'template' => 'cli/lib/type-generation/languages/swift.js.twig',
223+
],
224+
[
225+
'scope' => 'default',
226+
'destination' => 'lib/type-generation/languages/java.js',
227+
'template' => 'cli/lib/type-generation/languages/java.js.twig',
228+
],
229+
[
230+
'scope' => 'default',
231+
'destination' => 'lib/type-generation/languages/dart.js',
232+
'template' => 'cli/lib/type-generation/languages/dart.js.twig',
233+
],
234+
[
235+
'scope' => 'default',
236+
'destination' => 'lib/type-generation/languages/csharp.js',
237+
'template' => 'cli/lib/type-generation/languages/csharp.js.twig',
238+
],
184239
[
185240
'scope' => 'default',
186241
'destination' => 'lib/questions.js',
@@ -263,7 +318,7 @@ public function getFiles(): array
263318
],
264319
[
265320
'scope' => 'service',
266-
'destination' => '/lib/commands/{{service.name | caseDash}}.js',
321+
'destination' => '/lib/commands/{{service.name | caseKebab}}.js',
267322
'template' => 'cli/lib/commands/command.js.twig',
268323
],
269324
[
@@ -275,6 +330,16 @@ public function getFiles(): array
275330
'scope' => 'default',
276331
'destination' => 'lib/commands/organizations.js',
277332
'template' => 'cli/lib/commands/organizations.js.twig',
333+
],
334+
[
335+
'scope' => 'default',
336+
'destination' => 'lib/commands/types.js',
337+
'template' => 'cli/lib/commands/types.js.twig',
338+
],
339+
[
340+
'scope' => 'default',
341+
'destination' => 'lib/commands/update.js',
342+
'template' => 'cli/lib/commands/update.js.twig',
278343
]
279344
];
280345
}
@@ -305,7 +370,7 @@ public function getTypeName(array $parameter, array $spec = []): string
305370
self::TYPE_OBJECT => 'object',
306371
self::TYPE_ARRAY => (!empty(($parameter['array'] ?? [])['type']) && !\is_array($parameter['array']['type']))
307372
? $this->getTypeName($parameter['array']) . '[]'
308-
: 'string[]',
373+
: 'any[]',
309374
default => $parameter['type'],
310375
};
311376
}
@@ -374,14 +439,6 @@ public function getParamExample(array $param): string
374439
return $output;
375440
}
376441

377-
public function getFilters(): array
378-
{
379-
return array_merge(parent::getFilters(), [
380-
new TwigFilter('caseKebab', function ($value) {
381-
return strtolower(preg_replace('/(?<!^)([A-Z][a-z]|(?<=[a-z])[^a-z]|(?<=[A-Z])[0-9_])/', '-$1', $value));
382-
})
383-
]);
384-
}
385442
/**
386443
* Language specific filters.
387444
* @return array

src/SDK/Language/Dart.php

Lines changed: 34 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -226,49 +226,29 @@ public function getParamExample(array $param): string
226226
$type = $param['type'] ?? '';
227227
$example = $param['example'] ?? '';
228228

229-
$output = '';
229+
$hasExample = !empty($example) || $example === 0 || $example === false;
230230

231-
if (empty($example) && $example !== 0 && $example !== false) {
232-
switch ($type) {
233-
case self::TYPE_FILE:
234-
$output .= 'InputFile(path: \'./path-to-files/image.jpg\', filename: \'image.jpg\')';
235-
break;
236-
case self::TYPE_NUMBER:
237-
case self::TYPE_INTEGER:
238-
$output .= '0';
239-
break;
240-
case self::TYPE_BOOLEAN:
241-
$output .= 'false';
242-
break;
243-
case self::TYPE_STRING:
244-
$output .= "''";
245-
break;
246-
case self::TYPE_OBJECT:
247-
$output .= '{}';
248-
break;
249-
case self::TYPE_ARRAY:
250-
$output .= '[]';
251-
break;
252-
}
253-
} else {
254-
switch ($type) {
255-
case self::TYPE_OBJECT:
256-
case self::TYPE_FILE:
257-
case self::TYPE_NUMBER:
258-
case self::TYPE_INTEGER:
259-
case self::TYPE_ARRAY:
260-
$output .= $example;
261-
break;
262-
case self::TYPE_BOOLEAN:
263-
$output .= ($example) ? 'true' : 'false';
264-
break;
265-
case self::TYPE_STRING:
266-
$output .= "'{$example}'";
267-
break;
268-
}
231+
if (!$hasExample) {
232+
return match ($type) {
233+
self::TYPE_OBJECT => '{}',
234+
self::TYPE_ARRAY => '[]',
235+
self::TYPE_BOOLEAN => 'false',
236+
self::TYPE_FILE => 'InputFile(path: \'./path-to-files/image.jpg\', filename: \'image.jpg\')',
237+
self::TYPE_INTEGER, self::TYPE_NUMBER => '0',
238+
self::TYPE_STRING => "''",
239+
};
269240
}
270241

271-
return $output;
242+
return match ($type) {
243+
self::TYPE_ARRAY, self::TYPE_FILE, self::TYPE_INTEGER, self::TYPE_NUMBER => $example,
244+
self::TYPE_BOOLEAN => ($example) ? 'true' : 'false',
245+
self::TYPE_OBJECT => ($decoded = json_decode($example, true)) !== null
246+
? (empty($decoded) && $example === '{}'
247+
? '{}'
248+
: preg_replace('/\n/', "\n ", json_encode($decoded, JSON_PRETTY_PRINT)))
249+
: $example,
250+
self::TYPE_STRING => "'{$example}'",
251+
};
272252
}
273253

274254
/**
@@ -372,6 +352,11 @@ public function getFiles(): array
372352
'destination' => '/pubspec.yaml',
373353
'template' => 'dart/pubspec.yaml.twig',
374354
],
355+
[
356+
'scope' => 'default',
357+
'destination' => '/analysis_options.yaml',
358+
'template' => 'dart/analysis_options.yaml.twig',
359+
],
375360
[
376361
'scope' => 'default',
377362
'destination' => '/lib/client_io.dart',
@@ -409,7 +394,7 @@ public function getFiles(): array
409394
],
410395
[
411396
'scope' => 'service',
412-
'destination' => '/lib/services/{{service.name | caseDash}}.dart',
397+
'destination' => '/lib/services/{{service.name | caseSnake}}.dart',
413398
'template' => 'dart/lib/services/service.dart.twig',
414399
],
415400
[
@@ -419,12 +404,12 @@ public function getFiles(): array
419404
],
420405
[
421406
'scope' => 'method',
422-
'destination' => 'docs/examples/{{service.name | caseLower}}/{{method.name | caseDash}}.md',
407+
'destination' => 'docs/examples/{{service.name | caseLower}}/{{method.name | caseKebab}}.md',
423408
'template' => 'dart/docs/example.md.twig',
424409
],
425410
[
426411
'scope' => 'service',
427-
'destination' => '/test/services/{{service.name | caseDash}}_test.dart',
412+
'destination' => '/test/services/{{service.name | caseSnake}}_test.dart',
428413
'template' => 'dart/test/services/service_test.dart.twig',
429414
],
430415
[
@@ -487,6 +472,11 @@ public function getFiles(): array
487472
'destination' => '.github/workflows/format.yml',
488473
'template' => 'dart/.github/workflows/format.yml.twig',
489474
],
475+
[
476+
'scope' => 'default',
477+
'destination' => '.github/workflows/test.yml',
478+
'template' => 'dart/.github/workflows/test.yml',
479+
],
490480
[
491481
'scope' => 'default',
492482
'destination' => 'lib/src/input_file.dart',
@@ -506,7 +496,7 @@ public function getFilters(): array
506496
new TwigFilter('dartComment', function ($value) {
507497
$value = explode("\n", $value);
508498
foreach ($value as $key => $line) {
509-
$value[$key] = " /// " . wordwrap($value[$key], 75, "\n /// ");
499+
$value[$key] = " /// " . wordwrap($value[$key], 75, "\n /// ");
510500
}
511501
return implode("\n", $value);
512502
}, ['is_safe' => ['html']]),

0 commit comments

Comments
 (0)