-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from appwrite/feat-js-to-web
Changed all refs from JS to Web
- Loading branch information
Showing
11 changed files
with
138 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<?php | ||
|
||
namespace Appwrite\SDK\Language; | ||
|
||
class Web extends JS { | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName() | ||
{ | ||
return 'Web'; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getFiles() | ||
{ | ||
return [ | ||
[ | ||
'scope' => 'default', | ||
'destination' => 'src/sdk.js', | ||
'template' => '/web/src/sdk.js.twig', | ||
'minify' => false, | ||
], | ||
[ | ||
'scope' => 'default', | ||
'destination' => 'src/sdk.min.js', | ||
'template' => '/web/src/sdk.js.twig', | ||
'minify' => true, | ||
], | ||
[ | ||
'scope' => 'default', | ||
'destination' => 'README.md', | ||
'template' => '/web/README.md.twig', | ||
'minify' => false, | ||
], | ||
[ | ||
'scope' => 'default', | ||
'destination' => 'CHANGELOG.md', | ||
'template' => '/web/CHANGELOG.md.twig', | ||
'minify' => false, | ||
], | ||
[ | ||
'scope' => 'default', | ||
'destination' => 'LICENSE', | ||
'template' => '/web/LICENSE.twig', | ||
'minify' => false, | ||
], | ||
[ | ||
'scope' => 'default', | ||
'destination' => 'package.json', | ||
'template' => '/web/package.json.twig', | ||
'minify' => false, | ||
], | ||
[ | ||
'scope' => 'method', | ||
'destination' => 'docs/examples/{{service.name | caseLower}}/{{method.name | caseDash}}.md', | ||
'template' => '/web/docs/example.md.twig', | ||
'minify' => false, | ||
], | ||
[ | ||
'scope' => 'default', | ||
'destination' => 'types/index.d.ts', | ||
'template' => '/web/types/index.d.ts.twig', | ||
'minify' => false, | ||
], | ||
[ | ||
'scope' => 'default', | ||
'destination' => 'tsconfig.json', | ||
'template' => '/web/tsconfig.json.twig', | ||
'minify' => false, | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* @param array $param | ||
* @return string | ||
*/ | ||
public function getParamExample(array $param) | ||
{ | ||
$type = $param['type'] ?? ''; | ||
$example = $param['example'] ?? ''; | ||
|
||
$output = ''; | ||
|
||
if(empty($example) && $example !== 0 && $example !== false) { | ||
switch ($type) { | ||
case self::TYPE_NUMBER: | ||
case self::TYPE_INTEGER: | ||
case self::TYPE_BOOLEAN: | ||
$output .= 'null'; | ||
break; | ||
case self::TYPE_STRING: | ||
$output .= "''"; | ||
break; | ||
case self::TYPE_ARRAY: | ||
$output .= '[]'; | ||
break; | ||
case self::TYPE_OBJECT: | ||
$output .= '{}'; | ||
break; | ||
case self::TYPE_FILE: | ||
$output .= "document.getElementById('uploader').files[0]"; | ||
break; | ||
} | ||
} | ||
else { | ||
switch ($type) { | ||
case self::TYPE_NUMBER: | ||
case self::TYPE_INTEGER: | ||
case self::TYPE_ARRAY: | ||
case self::TYPE_OBJECT: | ||
$output .= $example; | ||
break; | ||
case self::TYPE_BOOLEAN: | ||
$output .= ($example) ? 'true' : 'false'; | ||
break; | ||
case self::TYPE_STRING: | ||
$output .= "'{$example}'"; | ||
break; | ||
case self::TYPE_FILE: | ||
$output .= "document.getElementById('uploader').files[0]"; | ||
break; | ||
} | ||
} | ||
|
||
return $output; | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.