Skip to content

Commit 86b2092

Browse files
committed
chore: use since instead
1 parent e15149f commit 86b2092

File tree

18 files changed

+38
-41
lines changed

18 files changed

+38
-41
lines changed

src/SDK/SDK.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -164,18 +164,8 @@ public function __construct(Language $language, Spec $spec)
164164
}, ['is_safe' => ['html']]));
165165
$this->twig->addFilter(new TwigFilter('comment1', function ($value) {
166166
$value = explode("\n", $value);
167-
$prefix = " * ";
168-
$prefixLength = strlen($prefix);
169-
$maxLineLength = 75 - $prefixLength;
170-
171167
foreach ($value as $key => $line) {
172-
if (empty(trim($line))) {
173-
$value[$key] = $prefix;
174-
continue;
175-
}
176-
177-
$wrapped = wordwrap($line, $maxLineLength, "\n" . $prefix, true);
178-
$value[$key] = $prefix . $wrapped;
168+
$value[$key] = " * " . wordwrap($line, 75, "\n * ");
179169
}
180170
return implode("\n", $value);
181171
}, ['is_safe' => ['html']]));

src/Spec/Swagger2.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,6 @@ protected function parseMethod(string $methodName, string $pathName, array $meth
176176
'consumes' => $method['consumes'] ?? [],
177177
'cookies' => $method['x-appwrite']['cookies'] ?? false,
178178
'type' => $method['x-appwrite']['type'] ?? false,
179-
'deprecated' => $method['x-appwrite']['deprecated'] ?? false,
180-
'deprecatedMessage' => $method['x-appwrite']['deprecatedMessage'] ?? '',
181-
'deprecatedVersion' => $method['x-appwrite']['deprecatedVersion'] ?? '',
182-
'replaceWith' => $method['x-appwrite']['replaceWith'] ?? '',
183179
'headers' => [],
184180
'parameters' => [
185181
'all' => [],
@@ -192,6 +188,17 @@ protected function parseMethod(string $methodName, string $pathName, array $meth
192188
'responseModel' => $responseModel,
193189
];
194190

191+
if (($method['x-appwrite']['deprecated'] ?? false) !== false) {
192+
$output['deprecated'] = true;
193+
if (is_array($method['x-appwrite']['deprecated'])) {
194+
$output['since'] = $method['x-appwrite']['deprecated']['since'] ?? '';
195+
$output['replaceWith'] = $method['x-appwrite']['deprecated']['replaceWith'] ?? '';
196+
} else {
197+
$output['since'] = '';
198+
$output['replaceWith'] = '';
199+
}
200+
}
201+
195202
if ($output['type'] == 'graphql') {
196203
$output['headers']['x-sdk-graphql'] = "true";
197204
}

templates/android/library/src/main/java/io/package/services/Service.kt.twig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ class {{ service.name | caseUcfirst }}(client: Client) : Service(client) {
3939
{%~ endif %}
4040
*/
4141
{%~ if method.deprecated %}
42-
{% set deprecated_message = "This API is deprecated since " ~ method.deprecatedVersion ~ " and uses outdated terminologies." %}
42+
{% set deprecated_message = "This API is deprecated since " ~ method.since ~ " and uses outdated terminologies." %}
4343
{% if method.replaceWith %}
4444
{% set deprecated_message = deprecated_message ~ ' Please use `' ~ (method.replaceWith | capitalizeFirst) ~ '` instead.' %}
4545
@Deprecated(
4646
message = "{{ deprecated_message }}",
4747
replaceWith = ReplaceWith("{{ sdk.namespace | caseDot }}.services.{{ method.replaceWith | capitalizeFirst }}"),
48-
since = "{{ method.deprecatedVersion }}"
48+
since = "{{ method.since }}"
4949
)
5050
{% else %}
5151
@Deprecated("{{ deprecated_message }}")
@@ -206,13 +206,13 @@ class {{ service.name | caseUcfirst }}(client: Client) : Service(client) {
206206
{%~ endif %}
207207
*/
208208
{%~ if method.deprecated %}
209-
{% set deprecated_message = "This API is deprecated since " ~ method.deprecatedVersion ~ " and uses outdated terminologies." %}
209+
{% set deprecated_message = "This API is deprecated since " ~ method.since ~ " and uses outdated terminologies." %}
210210
{% if method.replaceWith %}
211211
{% set deprecated_message = deprecated_message ~ ' Please use `' ~ (method.replaceWith | capitalizeFirst) ~ '` instead.' %}
212212
@Deprecated(
213213
message = "{{ deprecated_message }}",
214214
replaceWith = ReplaceWith("{{ sdk.namespace | caseDot }}.services.{{ method.replaceWith | capitalizeFirst }}"),
215-
since = "{{ method.deprecatedVersion }}"
215+
since = "{{ method.since }}"
216216
)
217217
{% else %}
218218
@Deprecated("{{ deprecated_message }}")

templates/apple/Sources/Services/Service.swift.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ open class {{ service.name | caseUcfirst | overrideIdentifier }}: Service {
2424
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
2525
{%~ endif %}
2626
{%~ if method.deprecated %}
27-
@available(*, deprecated, message: "This API is deprecated since {{ method.deprecatedVersion }} and uses outdated terminologies. Please use `{{ method.replaceWith | capitalizeFirst }}` instead.")
27+
@available(*, deprecated, message: "This API is deprecated since {{ method.since }} and uses outdated terminologies. Please use `{{ method.replaceWith | capitalizeFirst }}` instead.")
2828
{%~ endif %}
2929
open func {{ method.name | caseCamel | overrideIdentifier }}{% if method.responseModel | hasGenericType(spec) %}<T>{% endif %}(
3030
{%~ for parameter in method.parameters.all %}
@@ -91,7 +91,7 @@ open class {{ service.name | caseUcfirst | overrideIdentifier }}: Service {
9191
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
9292
{%~ endif %}
9393
{%~ if method.deprecated %}
94-
@available(*, deprecated, message: "This API is deprecated since {{ method.deprecatedVersion }} and uses outdated terminologies. Please use `{{ method.replaceWith | capitalizeFirst }}` instead.")
94+
@available(*, deprecated, message: "This API is deprecated since {{ method.since }} and uses outdated terminologies. Please use `{{ method.replaceWith | capitalizeFirst }}` instead.")
9595
{%~ endif %}
9696
open func {{ method.name | caseCamel }}(
9797
{%~ for parameter in method.parameters.all %}

templates/cli/lib/commands/command.js.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const {{ service.name | caseLower }}{{ method.name | caseUcfirst }} = async ({
7373
{% if hasConsolePreview(method.name,service.name) %}, console{%- endif -%}
7474
}) => {
7575
{% if method.deprecated %}
76-
console.warn('Warning: This command is deprecated since {{ method.deprecatedVersion }}.{% if method.replaceWith %} Please use "{{ method.replaceWith | replace({'.': ' '}) }}" instead.{% endif %}');
76+
console.warn('Warning: This command is deprecated since {{ method.since }}.{% if method.replaceWith %} Please use "{{ method.replaceWith | replace({'.': ' '}) }}" instead.{% endif %}');
7777
{% endif %}
7878
let client = !sdk ? await {% if service.name == "projects" %}sdkForConsole(){% else %}sdkForProject(){% endif %} :
7979
sdk;

templates/dart/lib/services/service.dart.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class {{ service.name | caseUcfirst }} extends Service {
1818
{{ method.description | dartComment }}
1919
{% endif %}
2020
{%~ if method.deprecated %}
21-
@Deprecated('This API is deprecated since {{ method.deprecatedVersion }} and uses outdated terminologies. Please use `{{ method.replaceWith | capitalizeFirst }}` instead.')
21+
@Deprecated('This API is deprecated since {{ method.since }} and uses outdated terminologies. Please use `{{ method.replaceWith | capitalizeFirst }}` instead.')
2222
{%~ endif %}
2323
{% if method.type == 'location' %}Future<Uint8List>{% else %}{% if method.responseModel and method.responseModel != 'any' %}Future<models.{{method.responseModel | caseUcfirst | overrideIdentifier}}>{% else %}Future{% endif %}{% endif %} {{ method.name | caseCamel | overrideIdentifier }}({{ _self.method_parameters(method.parameters.all, method.consumes) }}) async {
2424
final String apiPath = '{{ method.path }}'{% for parameter in method.parameters.path %}.replaceAll('{{ '{' }}{{ parameter.name | caseCamel }}{{ '}' }}', {{ parameter.name | caseCamel | overrideIdentifier }}{% if parameter.enumValues | length > 0 %}.value{% endif %}){% endfor %};

templates/deno/src/services/service.ts.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export class {{ service.name | caseUcfirst }} extends Service {
7878
* @throws {AppwriteException}
7979
* @returns {Promise}
8080
{%~ if method.deprecated %}
81-
* @deprecated This API is deprecated since {{ method.deprecatedVersion }} and uses outdated terminologies.{% if method.replaceWith %} Please use `{{ method.replaceWith | capitalizeFirst }}` instead.{% endif %}
81+
* @deprecated This API is deprecated since {{ method.since }} and uses outdated terminologies.{% if method.replaceWith %} Please use `{{ method.replaceWith | capitalizeFirst }}` instead.{% endif %}
8282
{%~ endif %}
8383
*/
8484
async {{ method.name | caseCamel }}{% if generics %}<{{generics}}>{% endif %}({% for parameter in method.parameters.all %}{{ parameter.name | caseCamel | escapeKeyword }}{% if not parameter.required or parameter.nullable %}?{% endif %}: {{ parameter | typeName }}{% if not loop.last %}, {% endif %}{% endfor %}{% if 'multipart/form-data' in method.consumes %}, onProgress = (progress: UploadProgress) => {}{% endif %}): Promise<{% if method.type == 'webAuth' %}string{% elseif method.type == 'location' %}ArrayBuffer{% else %}{% if method.responseModel and method.responseModel != 'any' %}{% if not spec.definitions[method.responseModel].additionalProperties %}Models.{% endif %}{{method.responseModel | caseUcfirst}}{% if generics_return %}<{{generics_return}}>{% endif %}{% else %}Response{% endif %}{% endif %}> {

templates/dotnet/Package/Services/ServiceTemplate.cs.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace {{ spec.title | caseUcfirst }}.Services
2727
{%~ endif %}
2828
/// </summary>
2929
{%~ if method.deprecated %}
30-
[Obsolete("This API is deprecated since {{ method.deprecatedVersion }} and uses outdated terminologies. Please use `{{ method.replaceWith | capitalizeFirst }}` instead.")]
30+
[Obsolete("This API is deprecated since {{ method.since }} and uses outdated terminologies. Please use `{{ method.replaceWith | capitalizeFirst }}` instead.")]
3131
{%~ endif %}
3232
public Task{% if method.type == "webAuth" %}<String>{% else %}<{{ utils.resultType(spec.title, method) }}>{% endif %} {{ method.name | caseUcfirst }}({{ utils.method_parameters(method.parameters, method.consumes) }})
3333
{

templates/flutter/lib/services/service.dart.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class {{ service.name | caseUcfirst }} extends Service {
1919
{{ method.description|dartComment }}
2020
{% endif %}
2121
{%~ if method.deprecated %}
22-
@Deprecated('This API is deprecated since {{ method.deprecatedVersion }} and uses outdated terminologies. Please use `{{ method.replaceWith | capitalizeFirst }}` instead.')
22+
@Deprecated('This API is deprecated since {{ method.since }} and uses outdated terminologies. Please use `{{ method.replaceWith | capitalizeFirst }}` instead.')
2323
{%~ endif %}
2424
{% if method.type == 'webAuth' %}Future{% elseif method.type == 'location' %}Future<Uint8List>{% else %}{% if method.responseModel and method.responseModel != 'any' %}Future<models.{{method.responseModel | caseUcfirst | overrideIdentifier}}>{% else %}Future{% endif %}{% endif %} {{ method.name | caseCamel | overrideIdentifier }}({{ _self.method_parameters(method.parameters.all, method.consumes) }}) async {
2525
{% if method.parameters.path | length > 0 %}final{% else %}const{% endif %} String apiPath = '{{ method.path }}'{% for parameter in method.parameters.path %}.replaceAll('{{ '{' }}{{ parameter.name | caseCamel }}{{ '}' }}', {{ parameter.name | caseCamel | overrideIdentifier }}{% if parameter.enumValues | length > 0 %}.value{% endif %}){% endfor %};

templates/go/services/service.go.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (srv *{{ service.name | caseUcfirst }}) With{{ method.name | caseUcfirst }}
8989
{% endif %}
9090
{% if method.deprecated %}
9191
//
92-
// Deprecated: This API is deprecated since {{ method.deprecatedVersion }} and uses outdated terminologies. Please use `{{ method.replaceWith | capitalizeFirst }}` instead.
92+
// Deprecated: This API is deprecated since {{ method.since }} and uses outdated terminologies. Please use `{{ method.replaceWith | capitalizeFirst }}` instead.
9393
{% endif %}
9494
func (srv *{{ service.name | caseUcfirst }}) {{ method.name | caseUcfirst }}({{ params }})(*{{ method | returnType(spec, spec.title | caseLower) }}, error) {
9595
{% if method.parameters.path|length > 0 %}

0 commit comments

Comments
 (0)