Skip to content

Commit 6147647

Browse files
committed
fix: problems with missing type imports in .d.ts files with using option --js
1 parent 95102f9 commit 6147647

37 files changed

+3427
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# next release
22

3+
fix: problems with missing type imports in `.d.ts` files with using option `--js`
4+
35
# 11.1.1
46
fix: `--api-class-name` option has no default value (#433)
57

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"test:--enum-names-as-values": "node tests/spec/enumNamesAsValues/test.js",
4040
"test:--default-response": "node tests/spec/defaultResponse/test.js",
4141
"test:--js": "node tests/spec/js/test.js",
42+
"test:jsSingleHttpClientModular": "node tests/spec/jsSingleHttpClientModular/test.js",
4243
"test:--js--axios": "node tests/spec/jsAxios/test.js",
4344
"test:--axios": "node tests/spec/axios/test.js",
4445
"test:--another-array-type": "node tests/spec/another-array-type/test.js",

src/translators/JavaScript.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,21 @@ module.exports = {
4040

4141
const sourceFileName = fileName.replace(ts.Extension.Ts, ts.Extension.Js);
4242
const declarationFileName = fileName.replace(ts.Extension.Ts, ts.Extension.Dts);
43+
const sourceContent = translated[sourceFileName];
44+
const tsImportRows = sourceTypeScript.split("\n").filter((line) => line.startsWith("import "));
45+
const declarationContent = translated[declarationFileName]
46+
.split("\n")
47+
.map((line) => {
48+
if (line.startsWith("import ")) {
49+
return tsImportRows.shift();
50+
}
51+
return line;
52+
})
53+
.join("\n");
4354

4455
return {
45-
sourceContent: translated[sourceFileName],
46-
declarationContent: translated[declarationFileName],
56+
sourceContent: sourceContent,
57+
declarationContent: declarationContent,
4758
};
4859
},
4960
};
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
/* eslint-disable */
2+
/* tslint:disable */
3+
/*
4+
* ---------------------------------------------------------------
5+
* ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
6+
* ## ##
7+
* ## AUTHOR: acacode ##
8+
* ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
9+
* ---------------------------------------------------------------
10+
*/
11+
12+
import { AuthentiqID, Error } from "./data-contracts";
13+
import { HttpClient, HttpResponse, RequestParams } from "./http-client";
14+
export declare class Key<SecurityDataType = unknown> {
15+
http: HttpClient<SecurityDataType>;
16+
constructor(http: HttpClient<SecurityDataType>);
17+
/**
18+
* @description Revoke an Authentiq ID using email & phone. If called with `email` and `phone` only, a verification code will be sent by email. Do a second call adding `code` to complete the revocation.
19+
*
20+
* @tags key, delete
21+
* @name KeyRevokeNosecret
22+
* @request DELETE:/key
23+
*/
24+
keyRevokeNosecret: (
25+
query: {
26+
/** primary email associated to Key (ID) */
27+
email: string;
28+
/** primary phone number, international representation */
29+
phone: string;
30+
/** verification code sent by email */
31+
code?: string;
32+
},
33+
params?: RequestParams,
34+
) => Promise<
35+
HttpResponse<
36+
{
37+
/** pending or done */
38+
status?: string;
39+
},
40+
Error
41+
>
42+
>;
43+
/**
44+
* @description Register a new ID `JWT(sub, devtoken)` v5: `JWT(sub, pk, devtoken, ...)` See: https://github.com/skion/authentiq/wiki/JWT-Examples
45+
*
46+
* @tags key, post
47+
* @name KeyRegister
48+
* @request POST:/key
49+
*/
50+
keyRegister: (
51+
body: AuthentiqID,
52+
params?: RequestParams,
53+
) => Promise<
54+
HttpResponse<
55+
{
56+
/** revoke key */
57+
secret?: string;
58+
/** registered */
59+
status?: string;
60+
},
61+
Error
62+
>
63+
>;
64+
/**
65+
* @description Revoke an Identity (Key) with a revocation secret
66+
*
67+
* @tags key, delete
68+
* @name KeyRevoke
69+
* @request DELETE:/key/{PK}
70+
*/
71+
keyRevoke: (
72+
pk: string,
73+
query: {
74+
/** revokation secret */
75+
secret: string;
76+
},
77+
params?: RequestParams,
78+
) => Promise<
79+
HttpResponse<
80+
{
81+
/** done */
82+
status?: string;
83+
},
84+
Error
85+
>
86+
>;
87+
/**
88+
* @description Get public details of an Authentiq ID.
89+
*
90+
* @tags key, get
91+
* @name GetKey
92+
* @request GET:/key/{PK}
93+
*/
94+
getKey: (
95+
pk: string,
96+
params?: RequestParams,
97+
) => Promise<
98+
HttpResponse<
99+
{
100+
/** @format date-time */
101+
since?: string;
102+
status?: string;
103+
/** base64safe encoded public signing key */
104+
sub?: string;
105+
},
106+
Error
107+
>
108+
>;
109+
/**
110+
* @description HEAD info on Authentiq ID
111+
*
112+
* @tags key, head
113+
* @name HeadKey
114+
* @request HEAD:/key/{PK}
115+
*/
116+
headKey: (pk: string, params?: RequestParams) => Promise<HttpResponse<void, Error>>;
117+
/**
118+
* @description update properties of an Authentiq ID. (not operational in v4; use PUT for now) v5: POST issuer-signed email & phone scopes in a self-signed JWT See: https://github.com/skion/authentiq/wiki/JWT-Examples
119+
*
120+
* @tags key, post
121+
* @name KeyUpdate
122+
* @request POST:/key/{PK}
123+
*/
124+
keyUpdate: (
125+
pk: string,
126+
body: AuthentiqID,
127+
params?: RequestParams,
128+
) => Promise<
129+
HttpResponse<
130+
{
131+
/** confirmed */
132+
status?: string;
133+
},
134+
Error
135+
>
136+
>;
137+
/**
138+
* @description Update Authentiq ID by replacing the object. v4: `JWT(sub,email,phone)` to bind email/phone hash; v5: POST issuer-signed email & phone scopes and PUT to update registration `JWT(sub, pk, devtoken, ...)` See: https://github.com/skion/authentiq/wiki/JWT-Examples
139+
*
140+
* @tags key, put
141+
* @name KeyBind
142+
* @request PUT:/key/{PK}
143+
*/
144+
keyBind: (
145+
pk: string,
146+
body: AuthentiqID,
147+
params?: RequestParams,
148+
) => Promise<
149+
HttpResponse<
150+
{
151+
/** confirmed */
152+
status?: string;
153+
},
154+
Error
155+
>
156+
>;
157+
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/* eslint-disable */
2+
/* tslint:disable */
3+
/*
4+
* ---------------------------------------------------------------
5+
* ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
6+
* ## ##
7+
* ## AUTHOR: acacode ##
8+
* ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
9+
* ---------------------------------------------------------------
10+
*/
11+
12+
export class Key {
13+
http;
14+
constructor(http) {
15+
this.http = http;
16+
}
17+
/**
18+
* @description Revoke an Authentiq ID using email & phone. If called with `email` and `phone` only, a verification code will be sent by email. Do a second call adding `code` to complete the revocation.
19+
*
20+
* @tags key, delete
21+
* @name KeyRevokeNosecret
22+
* @request DELETE:/key
23+
*/
24+
keyRevokeNosecret = (query, params = {}) =>
25+
this.http.request({
26+
path: `/key`,
27+
method: "DELETE",
28+
query: query,
29+
format: "json",
30+
...params,
31+
});
32+
/**
33+
* @description Register a new ID `JWT(sub, devtoken)` v5: `JWT(sub, pk, devtoken, ...)` See: https://github.com/skion/authentiq/wiki/JWT-Examples
34+
*
35+
* @tags key, post
36+
* @name KeyRegister
37+
* @request POST:/key
38+
*/
39+
keyRegister = (body, params = {}) =>
40+
this.http.request({
41+
path: `/key`,
42+
method: "POST",
43+
body: body,
44+
format: "json",
45+
...params,
46+
});
47+
/**
48+
* @description Revoke an Identity (Key) with a revocation secret
49+
*
50+
* @tags key, delete
51+
* @name KeyRevoke
52+
* @request DELETE:/key/{PK}
53+
*/
54+
keyRevoke = (pk, query, params = {}) =>
55+
this.http.request({
56+
path: `/key/${pk}`,
57+
method: "DELETE",
58+
query: query,
59+
format: "json",
60+
...params,
61+
});
62+
/**
63+
* @description Get public details of an Authentiq ID.
64+
*
65+
* @tags key, get
66+
* @name GetKey
67+
* @request GET:/key/{PK}
68+
*/
69+
getKey = (pk, params = {}) =>
70+
this.http.request({
71+
path: `/key/${pk}`,
72+
method: "GET",
73+
format: "json",
74+
...params,
75+
});
76+
/**
77+
* @description HEAD info on Authentiq ID
78+
*
79+
* @tags key, head
80+
* @name HeadKey
81+
* @request HEAD:/key/{PK}
82+
*/
83+
headKey = (pk, params = {}) =>
84+
this.http.request({
85+
path: `/key/${pk}`,
86+
method: "HEAD",
87+
...params,
88+
});
89+
/**
90+
* @description update properties of an Authentiq ID. (not operational in v4; use PUT for now) v5: POST issuer-signed email & phone scopes in a self-signed JWT See: https://github.com/skion/authentiq/wiki/JWT-Examples
91+
*
92+
* @tags key, post
93+
* @name KeyUpdate
94+
* @request POST:/key/{PK}
95+
*/
96+
keyUpdate = (pk, body, params = {}) =>
97+
this.http.request({
98+
path: `/key/${pk}`,
99+
method: "POST",
100+
body: body,
101+
format: "json",
102+
...params,
103+
});
104+
/**
105+
* @description Update Authentiq ID by replacing the object. v4: `JWT(sub,email,phone)` to bind email/phone hash; v5: POST issuer-signed email & phone scopes and PUT to update registration `JWT(sub, pk, devtoken, ...)` See: https://github.com/skion/authentiq/wiki/JWT-Examples
106+
*
107+
* @tags key, put
108+
* @name KeyBind
109+
* @request PUT:/key/{PK}
110+
*/
111+
keyBind = (pk, body, params = {}) =>
112+
this.http.request({
113+
path: `/key/${pk}`,
114+
method: "PUT",
115+
body: body,
116+
format: "json",
117+
...params,
118+
});
119+
}

0 commit comments

Comments
 (0)