Skip to content

Commit 85f2215

Browse files
committed
chore: add conditonal rendering when since and replacwith not present
1 parent 101f47b commit 85f2215

File tree

16 files changed

+70
-7
lines changed

16 files changed

+70
-7
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class {{ service.name | caseUcfirst }}(client: Client) : Service(client) {
4747
)
4848
{%~ else %}
4949
@Deprecated(
50-
message = "This API is deprecated and uses outdated terminologies.",
50+
message = "This API is deprecated.",
5151
)
5252
{%~ endif %}
5353
{%~ endif %}
@@ -214,7 +214,7 @@ class {{ service.name | caseUcfirst }}(client: Client) : Service(client) {
214214
)
215215
{%~ else %}
216216
@Deprecated(
217-
message = "This API is deprecated and uses outdated terminologies."
217+
message = "This API is deprecated."
218218
)
219219
{%~ endif %}
220220
{%~ endif %}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ 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+
{%~ if method.since and method.replaceWith %}
2728
@available(*, deprecated, message: "This API is deprecated since {{ method.since }} and uses outdated terminologies. Please use `{{ method.replaceWith | capitalizeFirst }}` instead.")
29+
{%~ else %}
30+
@available(*, deprecated, message: "This API is deprecated.")
31+
{%~ endif %}
2832
{%~ endif %}
2933
open func {{ method.name | caseCamel | overrideIdentifier }}{% if method.responseModel | hasGenericType(spec) %}<T>{% endif %}(
3034
{%~ for parameter in method.parameters.all %}
@@ -91,7 +95,11 @@ open class {{ service.name | caseUcfirst | overrideIdentifier }}: Service {
9195
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
9296
{%~ endif %}
9397
{%~ if method.deprecated %}
98+
{%~ if method.since and method.replaceWith %}
9499
@available(*, deprecated, message: "This API is deprecated since {{ method.since }} and uses outdated terminologies. Please use `{{ method.replaceWith | capitalizeFirst }}` instead.")
100+
{%~ else %}
101+
@available(*, deprecated, message: "This API is deprecated.")
102+
{%~ endif %}
95103
{%~ endif %}
96104
open func {{ method.name | caseCamel }}(
97105
{%~ for parameter in method.parameters.all %}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ const {{ service.name | caseLower }}{{ method.name | caseUcfirst }} = async ({
7373
{% if hasConsolePreview(method.name,service.name) %}, console{%- endif -%}
7474
}) => {
7575
{% if method.deprecated %}
76+
{% if method.since and method.replaceWith %}
7677
console.warn('Warning: This command is deprecated since {{ method.since }}.{% if method.replaceWith %} Please use "{{ method.replaceWith | replace({'.': ' '}) }}" instead.{% endif %}');
78+
{% else %}
79+
console.warn('Warning: This command is deprecated.');
80+
{% endif %}
7781
{% endif %}
7882
let client = !sdk ? await {% if service.name == "projects" %}sdkForConsole(){% else %}sdkForProject(){% endif %} :
7983
sdk;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ class {{ service.name | caseUcfirst }} extends Service {
1818
{{ method.description | dartComment }}
1919
{% endif %}
2020
{%~ if method.deprecated %}
21+
{%~ if method.since and method.replaceWith %}
2122
@Deprecated('This API is deprecated since {{ method.since }} and uses outdated terminologies. Please use `{{ method.replaceWith | capitalizeFirst }}` instead.')
23+
{%~ else %}
24+
@Deprecated('This API is deprecated.')
25+
{%~ endif %}
2226
{%~ endif %}
2327
{% 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 {
2428
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ export class {{ service.name | caseUcfirst }} extends Service {
7878
* @throws {AppwriteException}
7979
* @returns {Promise}
8080
{%~ if method.deprecated %}
81+
{%~ if method.since and method.replaceWith %}
8182
* @deprecated This API is deprecated since {{ method.since }} and uses outdated terminologies.{% if method.replaceWith %} Please use `{{ method.replaceWith | capitalizeFirst }}` instead.{% endif %}
83+
{%~ else %}
84+
* @deprecated This API is deprecated.
85+
{%~ endif %}
8286
{%~ endif %}
8387
*/
8488
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ namespace {{ spec.title | caseUcfirst }}.Services
2727
{%~ endif %}
2828
/// </summary>
2929
{%~ if method.deprecated %}
30+
{%~ if method.since and method.replaceWith %}
3031
[Obsolete("This API is deprecated since {{ method.since }} and uses outdated terminologies. Please use `{{ method.replaceWith | capitalizeFirst }}` instead.")]
32+
{%~ else %}
33+
[Obsolete("This API is deprecated.")]
34+
{%~ endif %}
3135
{%~ endif %}
3236
public Task{% if method.type == "webAuth" %}<String>{% else %}<{{ utils.resultType(spec.title, method) }}>{% endif %} {{ method.name | caseUcfirst }}({{ utils.method_parameters(method.parameters, method.consumes) }})
3337
{

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ class {{ service.name | caseUcfirst }} extends Service {
1919
{{ method.description|dartComment }}
2020
{% endif %}
2121
{%~ if method.deprecated %}
22+
{%~ if method.since and method.replaceWith %}
2223
@Deprecated('This API is deprecated since {{ method.since }} and uses outdated terminologies. Please use `{{ method.replaceWith | capitalizeFirst }}` instead.')
24+
{%~ else %}
25+
@Deprecated('This API is deprecated.')
26+
{%~ endif %}
2327
{%~ endif %}
2428
{% 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 {
2529
{% 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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ func (srv *{{ service.name | caseUcfirst }}) With{{ method.name | caseUcfirst }}
8989
{% endif %}
9090
{% if method.deprecated %}
9191
//
92+
{%~ if method.since and method.replaceWith %}
9293
// Deprecated: This API is deprecated since {{ method.since }} and uses outdated terminologies. Please use `{{ method.replaceWith | capitalizeFirst }}` instead.
94+
{%~ else %}
95+
// Deprecated: This API is deprecated.
96+
{%~ endif %}
9397
{% endif %}
9498
func (srv *{{ service.name | caseUcfirst }}) {{ method.name | caseUcfirst }}({{ params }})(*{{ method | returnType(spec, spec.title | caseLower) }}, error) {
9599
{% if method.parameters.path|length > 0 %}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class {{ service.name | caseUcfirst }}(client: Client) : Service(client) {
3939
)
4040
{%~ else %}
4141
@Deprecated(
42-
message = "This API is deprecated and uses outdated terminologies."
42+
message = "This API is deprecated."
4343
)
4444
{%~ endif %}
4545
{%~ endif %}
@@ -113,7 +113,7 @@ class {{ service.name | caseUcfirst }}(client: Client) : Service(client) {
113113
)
114114
{%~ else %}
115115
@Deprecated(
116-
message = "This API is deprecated and uses outdated terminologies."
116+
message = "This API is deprecated."
117117
)
118118
{%~ endif %}
119119
{%~ endif %}

templates/node/src/services/template.ts.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ export class {{ service.name | caseUcfirst }} {
3636
* @throws {{ '{' }}{{ spec.title | caseUcfirst}}Exception}
3737
* @returns {{ '{' }}{{ method | getReturn(spec) | raw }}{{ '}' }}
3838
{%~ if method.deprecated %}
39+
{%~ if method.since and method.replaceWith %}
3940
* @deprecated This API is deprecated since {{ method.since }} and uses outdated terminologies.{% if method.replaceWith %} Please use `{{ method.replaceWith | capitalizeFirst }}` instead.{% endif %}
41+
{%~ else %}
42+
* @deprecated This API is deprecated.
43+
{%~ endif %}
4044
{%~ endif %}
4145
*/
4246
{{ method.name | caseCamel }}{{ method.responseModel | getGenerics(spec) | raw }}({% for parameter in method.parameters.all %}{{ parameter.name | caseCamel | escapeKeyword }}{% if not parameter.required or parameter.nullable %}?{% endif %}: {{ parameter | getPropertyType(method) | raw }}{% if not loop.last %}, {% endif %}{% endfor %}{% if 'multipart/form-data' in method.consumes %}, onProgress = (progress: UploadProgress) => {}{% endif %}): {{ method | getReturn(spec) | raw }} {

0 commit comments

Comments
 (0)