Skip to content

Commit af7dd08

Browse files
Merge pull request #501 from appwrite/remove-web-global-params
fix: web SDK removing global params
2 parents 2dfc5f7 + e1b8419 commit af7dd08

File tree

7 files changed

+55
-76
lines changed

7 files changed

+55
-76
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
"ext-curl": "*",
2424
"ext-mbstring": "*",
2525
"ext-json": "*",
26-
"twig/twig": "^3.3",
27-
"matthiasmullie/minify": "^1.3"
26+
"twig/twig": "^3.4.1",
27+
"matthiasmullie/minify": "^1.3.68"
2828
},
2929
"require-dev": {
30-
"phpunit/phpunit": "^9.5.13",
30+
"phpunit/phpunit": "^9.5.21",
3131
"brianium/paratest": "^6.4"
3232
},
3333
"minimum-stability": "dev",

composer.lock

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

specs/swagger2-latest-console.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

templates/web/src/models.ts.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export namespace Models {
88
/**
99
* {{ property.description }}
1010
*/
11-
{{ property.name | escapeKeyword }}{% if not property.required %}?{% endif %}: {{ property | getSubSchema(spec) | raw }};
11+
{{ property.name }}{% if not property.required %}?{% endif %}: {{ property | getSubSchema(spec) | raw }};
1212
{% endfor %}
1313
{% if definition.additionalProperties %} [key: string]: any;
1414
{% endif %}

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

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,13 @@
11
import { Service } from '../service';
22
import { {{ spec.title | caseUcfirst}}Exception, Client } from '../client';
33
import type { Models } from '../models';
4-
import type { UploadProgress } from '../client';
5-
6-
type Payload = {
7-
[key: string]: any;
8-
}
4+
import type { UploadProgress, Payload } from '../client';
95

106
export class {{ service.name | caseUcfirst }} extends Service {
11-
{% if service.globalParams | length %}
12-
{% for parameter in service.globalParams %}
13-
protected {{ parameter.name | caseCamel | escapeKeyword }}: {{ parameter.type | typeName }};
14-
public set{{ parameter.name | caseUcfirst | escapeKeyword }}({{ parameter.name | caseCamel | escapeKeyword }}: {{ parameter.type | typeName }}): void
15-
{
16-
this.{{ parameter.name | caseCamel | escapeKeyword }} = {{ parameter.name | caseCamel | escapeKeyword }};
17-
}
18-
public get{{ parameter.name | caseUcfirst | escapeKeyword }}(): {{ parameter.type | typeName }}
19-
{
20-
return this.{{ parameter.name | caseCamel | escapeKeyword }};
21-
}
22-
{% endfor %}
23-
constructor(client: Client, {% for parameter in service.globalParams %} {{ parameter.name | caseCamel | escapeKeyword }}:{{ parameter.type | typeName }}{% if not parameter.required %}|null = null{% endif %}{% if not loop.last %}, {% endif %}{% endfor %})
7+
constructor(client: Client)
248
{
259
super(client);
26-
27-
{% for parameter in service.globalParams %}
28-
this.{{ parameter.name | caseCamel | escapeKeyword }} = {{ parameter.name | caseCamel | escapeKeyword }};
29-
{% endfor %}
3010
}
31-
{% endif %}
3211
{% for method in service.methods %}
3312

3413
/**
@@ -38,34 +17,34 @@ export class {{ service.name | caseUcfirst }} extends Service {
3817
{{ method.description|comment3 }}
3918
{% endif %}
4019
*
41-
{% for parameter in method.parameters.all | filter((param) => not param.isGlobal) %}
20+
{% for parameter in method.parameters.all %}
4221
* @param {{ '{' }}{{ parameter.type | getPropertyType(method) | raw }}{{ '}' }} {{ parameter.name | caseCamel | escapeKeyword }}
4322
{% endfor %}
4423
* @throws {{ '{' }}{{ spec.title | caseUcfirst}}Exception}
4524
* @returns {% if method.type == 'webAuth' %}{void|string}{% elseif method.type == 'location' %}{URL}{% else %}{Promise}{% endif %}
4625

4726
*/
48-
{% if method.type != 'location' and method.type != 'webAuth'%}async {% endif %}{{ method.name | caseCamel }}{{ method.responseModel | getGenerics(spec) | raw }}({% for parameter in method.parameters.all | filter((param) => not param.isGlobal) %}{{ parameter.name | caseCamel | escapeKeyword }}{% if not parameter.required %}?{% endif %}: {{ parameter.type | getPropertyType(method) | raw }}{% if not loop.last %}, {% endif %}{% endfor %}{% if 'multipart/form-data' in method.consumes %}, onProgress = (progress: UploadProgress) => {}{% endif %}): {{ method | getReturn(spec) | raw }} {
49-
{% for parameter in method.parameters.all | filter((param) => not param.isGlobal) %}
27+
{% if method.type != 'location' and method.type != 'webAuth'%}async {% endif %}{{ method.name | caseCamel }}{{ method.responseModel | getGenerics(spec) | raw }}({% for parameter in method.parameters.all %}{{ parameter.name | caseCamel | escapeKeyword }}{% if not parameter.required %}?{% endif %}: {{ parameter.type | getPropertyType(method) | raw }}{% if not loop.last %}, {% endif %}{% endfor %}{% if 'multipart/form-data' in method.consumes %}, onProgress = (progress: UploadProgress) => {}{% endif %}): {{ method | getReturn(spec) | raw }} {
28+
{% for parameter in method.parameters.all %}
5029
{% if parameter.required %}
5130
if (typeof {{ parameter.name | caseCamel | escapeKeyword }} === 'undefined') {
5231
throw new {{spec.title | caseUcfirst}}Exception('Missing required parameter: "{{ parameter.name | caseCamel | escapeKeyword }}"');
5332
}
5433

5534
{% endif %}
5635
{% endfor %}
57-
let path = '{{ method.path }}'{% for parameter in method.parameters.path %}.replace('{{ '{' }}{{ parameter.name | caseCamel | escapeKeyword }}{{ '}' }}', {% if parameter.isGlobal %}this.{% endif %}{{ parameter.name | caseCamel | escapeKeyword }}){% endfor %};
36+
let path = '{{ method.path }}'{% for parameter in method.parameters.path %}.replace('{{ '{' }}{{ parameter.name | caseCamel | escapeKeyword }}{{ '}' }}', {{ parameter.name | caseCamel | escapeKeyword }}){% endfor %};
5837
let payload: Payload = {};
5938

6039
{% for parameter in method.parameters.query %}
61-
if (typeof {% if parameter.isGlobal %}this.{% endif %}{{ parameter.name | caseCamel | escapeKeyword }} !== 'undefined') {
62-
payload['{{ parameter.name }}'] = {% if parameter.isGlobal %}this.{% endif %}{{ parameter.name | caseCamel | escapeKeyword }};
40+
if (typeof {{ parameter.name | caseCamel | escapeKeyword }} !== 'undefined') {
41+
payload['{{ parameter.name }}'] = {{ parameter.name | caseCamel | escapeKeyword }};
6342
}
6443

6544
{% endfor %}
6645
{% for parameter in method.parameters.body %}
67-
if (typeof {% if parameter.isGlobal %}this.{% endif %}{{ parameter.name | caseCamel | escapeKeyword }} !== 'undefined') {
68-
payload['{{ parameter.name }}'] = {% if parameter.isGlobal %}this.{% endif %}{{ parameter.name | caseCamel | escapeKeyword }};
46+
if (typeof {{ parameter.name | caseCamel | escapeKeyword }} !== 'undefined') {
47+
payload['{{ parameter.name }}'] = {{ parameter.name | caseCamel | escapeKeyword }};
6948
}
7049

7150
{% endfor %}

tests/languages/web/index.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
// Init SDK
2323
const { Client, Foo, Bar, General } = Appwrite;
2424
const client = new Client();
25-
const foo = new Foo(client, 'string');
25+
const foo = new Foo(client);
2626
const bar = new Bar(client);
2727
const general = new General(client);
2828

@@ -34,19 +34,19 @@
3434
});
3535

3636
// Foo
37-
response = await foo.get(123, ["string in array"]);
37+
response = await foo.get('string', 123, ["string in array"]);
3838
console.log(response.result);
3939

40-
response = await foo.post(123, ["string in array"]);
40+
response = await foo.post('string', 123, ["string in array"]);
4141
console.log(response.result);
4242

43-
response = await foo.put(123, ["string in array"]);
43+
response = await foo.put('string', 123, ["string in array"]);
4444
console.log(response.result);
4545

46-
response = await foo.patch(123, ["string in array"]);
46+
response = await foo.patch('string', 123, ["string in array"]);
4747
console.log(response.result);
4848

49-
response = await foo.delete(123, ["string in array"]);
49+
response = await foo.delete('string', 123, ["string in array"]);
5050
console.log(response.result);
5151

5252
// Bar

tests/languages/web/node.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ async function start() {
55

66
console.log('\nTest Started');
77
const client = new Client();
8-
const foo = new Foo(client, 'string');
8+
const foo = new Foo(client);
99
const bar = new Bar(client);
1010
const general = new General(client);
1111
// Foo
12-
response = await foo.get(123, ['string in array']);
12+
response = await foo.get('string', 123, ['string in array']);
1313
console.log(response.result);
1414

15-
response = await foo.post(123, ['string in array']);
15+
response = await foo.post('string', 123, ['string in array']);
1616
console.log(response.result);
1717

18-
response = await foo.put(123, ['string in array']);
18+
response = await foo.put('string', 123, ['string in array']);
1919
console.log(response.result);
2020

21-
response = await foo.patch(123, ['string in array']);
21+
response = await foo.patch('string', 123, ['string in array']);
2222
console.log(response.result);
2323

24-
response = await foo.delete(123, ['string in array']);
24+
response = await foo.delete('string', 123, ['string in array']);
2525
console.log(response.result);
2626

2727
// Bar

0 commit comments

Comments
 (0)