@akanjs/devkit 2.1.1-rc.0 → 2.1.1-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cloud/cloudApi.ts +18 -17
- package/package.json +3 -2
package/cloud/cloudApi.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import dayjs, { type Dayjs } from "dayjs";
|
|
2
|
+
|
|
3
|
+
interface AccessTokenDto {
|
|
4
|
+
jwt: string;
|
|
5
|
+
refreshToken: string | null;
|
|
6
|
+
expiresAt: string | null;
|
|
7
|
+
}
|
|
1
8
|
interface AccessToken {
|
|
2
9
|
jwt: string;
|
|
3
|
-
refreshToken: string;
|
|
4
|
-
expiresAt:
|
|
10
|
+
refreshToken: string | null;
|
|
11
|
+
expiresAt: Dayjs | null;
|
|
5
12
|
}
|
|
6
13
|
|
|
7
14
|
class HttpClient {
|
|
@@ -46,13 +53,10 @@ export class CloudApi {
|
|
|
46
53
|
this.#accessToken = accessToken ?? null;
|
|
47
54
|
}
|
|
48
55
|
|
|
49
|
-
async uploadEnv(
|
|
50
|
-
devProjectId: string,
|
|
51
|
-
fileStream: ReadableStream,
|
|
52
|
-
): Promise<boolean> {
|
|
56
|
+
async uploadEnv(devProjectId: string, file: File): Promise<boolean> {
|
|
53
57
|
const formData = new FormData();
|
|
54
58
|
formData.append("devProjectId", devProjectId);
|
|
55
|
-
formData.append("
|
|
59
|
+
formData.append("file", file);
|
|
56
60
|
const response = await this.api.post<{ success: boolean }>(
|
|
57
61
|
`/uploadEnv/${devProjectId}`,
|
|
58
62
|
formData,
|
|
@@ -68,18 +72,18 @@ export class CloudApi {
|
|
|
68
72
|
async getRemoteAuthToken(remoteId: string): Promise<AccessToken> {
|
|
69
73
|
if (this.#needRefreshToken()) return await this.refreshAuthToken();
|
|
70
74
|
else if (this.#accessToken) return this.#accessToken;
|
|
71
|
-
const accessToken = await this.api.get<
|
|
75
|
+
const accessToken = await this.api.get<AccessTokenDto>(
|
|
72
76
|
`/getRemoteAuthToken/${remoteId}`,
|
|
73
77
|
);
|
|
74
78
|
this.#accessToken = {
|
|
75
79
|
jwt: accessToken.jwt,
|
|
76
80
|
refreshToken: accessToken.refreshToken,
|
|
77
|
-
expiresAt:
|
|
81
|
+
expiresAt: accessToken.expiresAt ? dayjs(accessToken.expiresAt) : null,
|
|
78
82
|
};
|
|
79
|
-
return accessToken;
|
|
83
|
+
return this.#accessToken;
|
|
80
84
|
}
|
|
81
85
|
async refreshAuthToken(): Promise<AccessToken> {
|
|
82
|
-
const response = await this.api.post<
|
|
86
|
+
const response = await this.api.post<AccessTokenDto>(
|
|
83
87
|
`/refreshRemoteAuthToken`,
|
|
84
88
|
{
|
|
85
89
|
refreshToken: this.#accessToken?.refreshToken,
|
|
@@ -88,14 +92,11 @@ export class CloudApi {
|
|
|
88
92
|
this.#accessToken = {
|
|
89
93
|
jwt: response.jwt,
|
|
90
94
|
refreshToken: response.refreshToken,
|
|
91
|
-
expiresAt:
|
|
95
|
+
expiresAt: response.expiresAt ? dayjs(response.expiresAt) : null,
|
|
92
96
|
};
|
|
93
|
-
return
|
|
97
|
+
return this.#accessToken;
|
|
94
98
|
}
|
|
95
99
|
#needRefreshToken(): boolean {
|
|
96
|
-
return !!(
|
|
97
|
-
this.#accessToken?.expiresAt &&
|
|
98
|
-
this.#accessToken.expiresAt.getTime() < Date.now() - 1000 * 60 * 60
|
|
99
|
-
);
|
|
100
|
+
return !!this.#accessToken?.expiresAt?.isBefore(dayjs().add(1, "hour"));
|
|
100
101
|
}
|
|
101
102
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/devkit",
|
|
3
|
-
"version": "2.1.1-rc.
|
|
3
|
+
"version": "2.1.1-rc.1",
|
|
4
4
|
"sourceType": "module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -32,10 +32,11 @@
|
|
|
32
32
|
"@langchain/openai": "^1.4.6",
|
|
33
33
|
"@tailwindcss/node": "^4.3.0",
|
|
34
34
|
"@trapezedev/project": "^7.1.4",
|
|
35
|
-
"akanjs": "2.1.1-rc.
|
|
35
|
+
"akanjs": "2.1.1-rc.1",
|
|
36
36
|
"chalk": "^5.6.2",
|
|
37
37
|
"commander": "^14.0.3",
|
|
38
38
|
"daisyui": "^5.5.20",
|
|
39
|
+
"dayjs": "^1.11.20",
|
|
39
40
|
"fontaine": "^0.8.0",
|
|
40
41
|
"fonteditor-core": "^2.6.3",
|
|
41
42
|
"ignore": "^7.0.5",
|