Skip to content

Commit 6851ae2

Browse files
committed
fix: types
1 parent 55cf935 commit 6851ae2

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

src/SDK/Language/Web.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,11 @@ public function getGenerics(string $model, array $spec, bool $skipFirst = false)
252252
public function getReturn(array $method, array $spec): string
253253
{
254254
if ($method['type'] === 'webAuth') {
255-
return 'void | URL';
256-
} elseif ($method['type'] === 'location') {
257-
return 'URL';
255+
return 'Promise<void | string>';
256+
}
257+
258+
if ($method['type'] === 'location') {
259+
return 'string';
258260
}
259261

260262
if (array_key_exists('responseModel', $method) && !empty($method['responseModel']) && $method['responseModel'] !== 'any') {

templates/web/src/client.ts.twig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ type RealtimeRequest = {
4747
/**
4848
* Realtime event response structure with generic payload type.
4949
*/
50-
export type RealtimeResponseEvent<T extends unknown> = {
50+
type RealtimeResponseEvent<T extends unknown> = {
5151
/**
5252
* List of event names associated with the response.
5353
*/
@@ -214,7 +214,7 @@ type Realtime = {
214214
/**
215215
* Type representing upload progress information.
216216
*/
217-
export type UploadProgress = {
217+
type UploadProgress = {
218218
/**
219219
* Identifier for the upload progress.
220220
*/
@@ -696,4 +696,5 @@ class Client {
696696
export { Client, {{spec.title | caseUcfirst}}Exception };
697697
export { Query } from './query';
698698
export type { Models, Payload, UploadProgress };
699+
export type { RealtimeResponseEvent };
699700
export type { QueryTypes, QueryTypesList } from './query';

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class {{ service.name | caseUcfirst }} {
3838
* @throws {{ '{' }}{{ spec.title | caseUcfirst}}Exception}
3939
* @returns {{ '{' }}{{ method | getReturn(spec) | raw }}{{ '}' }}
4040
*/
41-
{% 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 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 }} {
41+
{% if method.type != 'location' %}async {% endif %}{{ 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 }} {
4242
{%~ for parameter in method.parameters.all %}
4343
{%~ if parameter.required %}
4444
if (typeof {{ parameter.name | caseCamel | escapeKeyword }} === 'undefined') {
@@ -78,9 +78,8 @@ export class {{ service.name | caseUcfirst }} {
7878
);
7979
if (typeof window !== 'undefined') {
8080
window.location.href = location;
81-
} else {
82-
return location;
8381
}
82+
return location.toString();
8483
{%~ elseif method.type == 'location' %}
8584
{%~ for node in method.auth %}
8685
{%~ for key, header in node|keys %}

0 commit comments

Comments
 (0)