Skip to content

Commit 6b564fe

Browse files
authored
Merge pull request #72 from appwrite/feat-js-to-web
Changed all refs from JS to Web
2 parents 21f3254 + bc6c15e commit 6b564fe

File tree

11 files changed

+138
-132
lines changed

11 files changed

+138
-132
lines changed

example.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Appwrite\Spec\Swagger2;
66
use Appwrite\SDK\SDK;
7-
use Appwrite\SDK\Language\JS;
7+
use Appwrite\SDK\Language\Web;
88
use Appwrite\SDK\Language\Node;
99
use Appwrite\SDK\Language\PHP;
1010
use Appwrite\SDK\Language\Python;
@@ -19,7 +19,7 @@
1919
use Appwrite\SDK\Language\CSharp;
2020
use Appwrite\SDK\Language\Flutter;
2121

22-
$languages = ['js', 'node', 'php', 'python', 'ruby', 'dart', 'go', 'java', 'swift', 'typescript', 'deno', 'http', 'csharp'];
22+
$languages = ['web', 'node', 'php', 'python', 'ruby', 'dart', 'go', 'java', 'swift', 'typescript', 'deno', 'http', 'csharp'];
2323

2424
try {
2525

@@ -63,8 +63,8 @@ function getSSLPage($url) {
6363

6464
$sdk->generate(__DIR__ . '/examples/php');
6565

66-
// JS
67-
$sdk = new SDK(new JS(), new Swagger2($spec));
66+
// Web
67+
$sdk = new SDK(new Web(), new Swagger2($spec));
6868

6969
$sdk
7070
->setName('NAME')
@@ -81,7 +81,7 @@ function getSSLPage($url) {
8181
->setGitRepoName('reponame')
8282
;
8383

84-
$sdk->generate(__DIR__ . '/examples/js');
84+
$sdk->generate(__DIR__ . '/examples/web');
8585

8686
// TypeScript
8787
$sdk = new SDK(new Typescript(), new Swagger2($spec));

src/SDK/Language/JS.php

Lines changed: 1 addition & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Appwrite\SDK\Language;
66

7-
class JS extends Language {
7+
abstract class JS extends Language {
88

99
protected $params = [
1010
'npmPackage' => 'packageName',
@@ -33,14 +33,6 @@ public function setBowerPackage($name)
3333
return $this;
3434
}
3535

36-
/**
37-
* @return string
38-
*/
39-
public function getName()
40-
{
41-
return 'JavaScript';
42-
}
43-
4436
/**
4537
* Get Language Keywords List
4638
*
@@ -116,69 +108,6 @@ public function getKeywords()
116108
];
117109
}
118110

119-
/**
120-
* @return array
121-
*/
122-
public function getFiles()
123-
{
124-
return [
125-
[
126-
'scope' => 'default',
127-
'destination' => 'src/sdk.js',
128-
'template' => '/js/src/sdk.js.twig',
129-
'minify' => false,
130-
],
131-
[
132-
'scope' => 'default',
133-
'destination' => 'src/sdk.min.js',
134-
'template' => '/js/src/sdk.js.twig',
135-
'minify' => true,
136-
],
137-
[
138-
'scope' => 'default',
139-
'destination' => 'README.md',
140-
'template' => '/js/README.md.twig',
141-
'minify' => false,
142-
],
143-
[
144-
'scope' => 'default',
145-
'destination' => 'CHANGELOG.md',
146-
'template' => '/js/CHANGELOG.md.twig',
147-
'minify' => false,
148-
],
149-
[
150-
'scope' => 'default',
151-
'destination' => 'LICENSE',
152-
'template' => '/js/LICENSE.twig',
153-
'minify' => false,
154-
],
155-
[
156-
'scope' => 'default',
157-
'destination' => 'package.json',
158-
'template' => '/js/package.json.twig',
159-
'minify' => false,
160-
],
161-
[
162-
'scope' => 'method',
163-
'destination' => 'docs/examples/{{service.name | caseLower}}/{{method.name | caseDash}}.md',
164-
'template' => '/js/docs/example.md.twig',
165-
'minify' => false,
166-
],
167-
[
168-
'scope' => 'default',
169-
'destination' => 'types/index.d.ts',
170-
'template' => '/js/types/index.d.ts.twig',
171-
'minify' => false,
172-
],
173-
[
174-
'scope' => 'default',
175-
'destination' => 'tsconfig.json',
176-
'template' => '/js/tsconfig.json.twig',
177-
'minify' => false,
178-
],
179-
];
180-
}
181-
182111
/**
183112
* @param $type
184113
* @return string
@@ -253,59 +182,4 @@ public function getParamDefault(array $param)
253182

254183
return $output;
255184
}
256-
257-
/**
258-
* @param array $param
259-
* @return string
260-
*/
261-
public function getParamExample(array $param)
262-
{
263-
$type = $param['type'] ?? '';
264-
$example = $param['example'] ?? '';
265-
266-
$output = '';
267-
268-
if(empty($example) && $example !== 0 && $example !== false) {
269-
switch ($type) {
270-
case self::TYPE_NUMBER:
271-
case self::TYPE_INTEGER:
272-
case self::TYPE_BOOLEAN:
273-
$output .= 'null';
274-
break;
275-
case self::TYPE_STRING:
276-
$output .= "''";
277-
break;
278-
case self::TYPE_ARRAY:
279-
$output .= '[]';
280-
break;
281-
case self::TYPE_OBJECT:
282-
$output .= '{}';
283-
break;
284-
case self::TYPE_FILE:
285-
$output .= "document.getElementById('uploader').files[0]";
286-
break;
287-
}
288-
}
289-
else {
290-
switch ($type) {
291-
case self::TYPE_NUMBER:
292-
case self::TYPE_INTEGER:
293-
case self::TYPE_ARRAY:
294-
case self::TYPE_OBJECT:
295-
$output .= $example;
296-
break;
297-
case self::TYPE_BOOLEAN:
298-
$output .= ($example) ? 'true' : 'false';
299-
break;
300-
case self::TYPE_STRING:
301-
$output .= "'{$example}'";
302-
break;
303-
case self::TYPE_FILE:
304-
$output .= "document.getElementById('uploader').files[0]";
305-
break;
306-
}
307-
}
308-
309-
return $output;
310-
}
311185
}

src/SDK/Language/Web.php

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<?php
2+
3+
namespace Appwrite\SDK\Language;
4+
5+
class Web extends JS {
6+
7+
/**
8+
* @return string
9+
*/
10+
public function getName()
11+
{
12+
return 'Web';
13+
}
14+
15+
/**
16+
* @return array
17+
*/
18+
public function getFiles()
19+
{
20+
return [
21+
[
22+
'scope' => 'default',
23+
'destination' => 'src/sdk.js',
24+
'template' => '/web/src/sdk.js.twig',
25+
'minify' => false,
26+
],
27+
[
28+
'scope' => 'default',
29+
'destination' => 'src/sdk.min.js',
30+
'template' => '/web/src/sdk.js.twig',
31+
'minify' => true,
32+
],
33+
[
34+
'scope' => 'default',
35+
'destination' => 'README.md',
36+
'template' => '/web/README.md.twig',
37+
'minify' => false,
38+
],
39+
[
40+
'scope' => 'default',
41+
'destination' => 'CHANGELOG.md',
42+
'template' => '/web/CHANGELOG.md.twig',
43+
'minify' => false,
44+
],
45+
[
46+
'scope' => 'default',
47+
'destination' => 'LICENSE',
48+
'template' => '/web/LICENSE.twig',
49+
'minify' => false,
50+
],
51+
[
52+
'scope' => 'default',
53+
'destination' => 'package.json',
54+
'template' => '/web/package.json.twig',
55+
'minify' => false,
56+
],
57+
[
58+
'scope' => 'method',
59+
'destination' => 'docs/examples/{{service.name | caseLower}}/{{method.name | caseDash}}.md',
60+
'template' => '/web/docs/example.md.twig',
61+
'minify' => false,
62+
],
63+
[
64+
'scope' => 'default',
65+
'destination' => 'types/index.d.ts',
66+
'template' => '/web/types/index.d.ts.twig',
67+
'minify' => false,
68+
],
69+
[
70+
'scope' => 'default',
71+
'destination' => 'tsconfig.json',
72+
'template' => '/web/tsconfig.json.twig',
73+
'minify' => false,
74+
],
75+
];
76+
}
77+
78+
/**
79+
* @param array $param
80+
* @return string
81+
*/
82+
public function getParamExample(array $param)
83+
{
84+
$type = $param['type'] ?? '';
85+
$example = $param['example'] ?? '';
86+
87+
$output = '';
88+
89+
if(empty($example) && $example !== 0 && $example !== false) {
90+
switch ($type) {
91+
case self::TYPE_NUMBER:
92+
case self::TYPE_INTEGER:
93+
case self::TYPE_BOOLEAN:
94+
$output .= 'null';
95+
break;
96+
case self::TYPE_STRING:
97+
$output .= "''";
98+
break;
99+
case self::TYPE_ARRAY:
100+
$output .= '[]';
101+
break;
102+
case self::TYPE_OBJECT:
103+
$output .= '{}';
104+
break;
105+
case self::TYPE_FILE:
106+
$output .= "document.getElementById('uploader').files[0]";
107+
break;
108+
}
109+
}
110+
else {
111+
switch ($type) {
112+
case self::TYPE_NUMBER:
113+
case self::TYPE_INTEGER:
114+
case self::TYPE_ARRAY:
115+
case self::TYPE_OBJECT:
116+
$output .= $example;
117+
break;
118+
case self::TYPE_BOOLEAN:
119+
$output .= ($example) ? 'true' : 'false';
120+
break;
121+
case self::TYPE_STRING:
122+
$output .= "'{$example}'";
123+
break;
124+
case self::TYPE_FILE:
125+
$output .= "document.getElementById('uploader').files[0]";
126+
break;
127+
}
128+
}
129+
130+
return $output;
131+
}
132+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)