@devopness/sdk-js 3.5.0 → 3.5.2
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/dist/api/generated/models/variable-application-create.d.ts +2 -2
- package/dist/api/generated/models/variable-create.d.ts +2 -2
- package/dist/api/generated/models/variable-relation.d.ts +2 -2
- package/dist/api/generated/models/variable-target.d.ts +1 -0
- package/dist/api/generated/models/variable-target.js +1 -0
- package/dist/api/generated/models/variable-type.d.ts +1 -0
- package/dist/api/generated/models/variable-type.js +1 -0
- package/dist/api/generated/models/variable-update.d.ts +2 -2
- package/dist/api/generated/models/variable.d.ts +2 -2
- package/dist/services/ApiBaseService.d.ts +5 -0
- package/dist/services/ApiBaseService.js +33 -2
- package/package.json +17 -7
|
@@ -18,13 +18,13 @@ import { VariableType } from './variable-type';
|
|
|
18
18
|
*/
|
|
19
19
|
export interface VariableApplicationCreate {
|
|
20
20
|
/**
|
|
21
|
-
* The unique key used to identify the variable on the target.
|
|
21
|
+
* The unique key used to identify the variable on the target. For `resource-config-file`, use a relative path such as `.env` or `storage/oauth-public.key`. For `resource-symlink`, `key` is the link path and `value` is the destination path, for example `node_modules` -> `${APP_SHARED_DIR}/node_modules`. Must not be greater than 100 characters.
|
|
22
22
|
* @type {string}
|
|
23
23
|
* @memberof VariableApplicationCreate
|
|
24
24
|
*/
|
|
25
25
|
key: string;
|
|
26
26
|
/**
|
|
27
|
-
* The value to be assigned to this variable when deployed to its target. When variable is of type `file`, this is the file content. Must not be greater than 21504 characters.
|
|
27
|
+
* The value to be assigned to this variable when deployed to its target. When variable is of type `file`, this is the file content. When variable is of type `symlink`, this is the destination path, for example `${APP_SHARED_DIR}/node_modules`. Must not be greater than 21504 characters.
|
|
28
28
|
* @type {string}
|
|
29
29
|
* @memberof VariableApplicationCreate
|
|
30
30
|
*/
|
|
@@ -18,13 +18,13 @@ import { VariableType } from './variable-type';
|
|
|
18
18
|
*/
|
|
19
19
|
export interface VariableCreate {
|
|
20
20
|
/**
|
|
21
|
-
* The unique key used to identify the variable on the target. Must not be greater than 100 characters.
|
|
21
|
+
* The unique key used to identify the variable on the target. For `resource-config-file`, use a relative path such as `.env` or `storage/oauth-public.key`. For `resource-symlink`, `key` is the link path and `value` is the destination path, for example `node_modules` -> `${APP_SHARED_DIR}/node_modules`. Must not be greater than 100 characters.
|
|
22
22
|
* @type {string}
|
|
23
23
|
* @memberof VariableCreate
|
|
24
24
|
*/
|
|
25
25
|
key: string;
|
|
26
26
|
/**
|
|
27
|
-
* The value to be assigned to this variable when deployed to its target. When variable is of type `file`, this is the file content. Must not be greater than 21504 characters.
|
|
27
|
+
* The value to be assigned to this variable when deployed to its target. When variable is of type `file`, this is the file content. When variable is of type `symlink`, this is the destination path, for example `${APP_SHARED_DIR}/node_modules`. Must not be greater than 21504 characters.
|
|
28
28
|
* @type {string}
|
|
29
29
|
* @memberof VariableCreate
|
|
30
30
|
*/
|
|
@@ -25,7 +25,7 @@ export interface VariableRelation {
|
|
|
25
25
|
*/
|
|
26
26
|
id: number;
|
|
27
27
|
/**
|
|
28
|
-
* The unique key used to identify the variable on the target
|
|
28
|
+
* The unique key used to identify the variable on the target, or the filesystem path for configuration files and symlinks
|
|
29
29
|
* @type {string}
|
|
30
30
|
* @memberof VariableRelation
|
|
31
31
|
*/
|
|
@@ -43,7 +43,7 @@ export interface VariableRelation {
|
|
|
43
43
|
*/
|
|
44
44
|
description: string | null;
|
|
45
45
|
/**
|
|
46
|
-
* The value to be assigned to this variable when deployed to its target
|
|
46
|
+
* The value to be assigned to this variable when deployed to its target. For configuration files this is the file content; for symlinks this is the symlink target path
|
|
47
47
|
* @type {string}
|
|
48
48
|
* @memberof VariableRelation
|
|
49
49
|
*/
|
|
@@ -27,6 +27,7 @@ export declare enum VariableTarget {
|
|
|
27
27
|
PhpFpmPoolDWwwConf = "php-fpm_pool-d-www-conf",
|
|
28
28
|
RedisConf = "redis-conf",
|
|
29
29
|
ResourceConfigFile = "resource-config-file",
|
|
30
|
+
ResourceSymlink = "resource-symlink",
|
|
30
31
|
SupervisordConf = "supervisord-conf",
|
|
31
32
|
SysctlConf = "sysctl-conf"
|
|
32
33
|
}
|
|
@@ -32,6 +32,7 @@ var VariableTarget;
|
|
|
32
32
|
VariableTarget["PhpFpmPoolDWwwConf"] = "php-fpm_pool-d-www-conf";
|
|
33
33
|
VariableTarget["RedisConf"] = "redis-conf";
|
|
34
34
|
VariableTarget["ResourceConfigFile"] = "resource-config-file";
|
|
35
|
+
VariableTarget["ResourceSymlink"] = "resource-symlink";
|
|
35
36
|
VariableTarget["SupervisordConf"] = "supervisord-conf";
|
|
36
37
|
VariableTarget["SysctlConf"] = "sysctl-conf";
|
|
37
38
|
})(VariableTarget || (exports.VariableTarget = VariableTarget = {}));
|
|
@@ -24,13 +24,13 @@ export interface VariableUpdate {
|
|
|
24
24
|
*/
|
|
25
25
|
id: number;
|
|
26
26
|
/**
|
|
27
|
-
* The unique key used to identify the variable on the target.
|
|
27
|
+
* The unique key used to identify the variable on the target. For `resource-config-file`, use a relative path such as `.env` or `storage/oauth-public.key`. For `resource-symlink`, `key` is the link path and `value` is the destination path, for example `node_modules` -> `${APP_SHARED_DIR}/node_modules`. Must not be greater than 100 characters.
|
|
28
28
|
* @type {string}
|
|
29
29
|
* @memberof VariableUpdate
|
|
30
30
|
*/
|
|
31
31
|
key: string;
|
|
32
32
|
/**
|
|
33
|
-
* The value to be assigned to this variable when deployed to its target. When variable is of type `file`, this is the file content. Must not be greater than 21504 characters.
|
|
33
|
+
* The value to be assigned to this variable when deployed to its target. When variable is of type `file`, this is the file content. When variable is of type `symlink`, this is the destination path, for example `${APP_SHARED_DIR}/node_modules`. Must not be greater than 21504 characters.
|
|
34
34
|
* @type {string}
|
|
35
35
|
* @memberof VariableUpdate
|
|
36
36
|
*/
|
|
@@ -25,7 +25,7 @@ export interface Variable {
|
|
|
25
25
|
*/
|
|
26
26
|
id: number;
|
|
27
27
|
/**
|
|
28
|
-
* The unique key used to identify the variable on the target
|
|
28
|
+
* The unique key used to identify the variable on the target, or the filesystem path for configuration files and symlinks
|
|
29
29
|
* @type {string}
|
|
30
30
|
* @memberof Variable
|
|
31
31
|
*/
|
|
@@ -43,7 +43,7 @@ export interface Variable {
|
|
|
43
43
|
*/
|
|
44
44
|
description: string | null;
|
|
45
45
|
/**
|
|
46
|
-
* The value to be assigned to this variable when deployed to its target
|
|
46
|
+
* The value to be assigned to this variable when deployed to its target. For configuration files this is the file content; for symlinks this is the symlink target path
|
|
47
47
|
* @type {string}
|
|
48
48
|
* @memberof Variable
|
|
49
49
|
*/
|
|
@@ -27,6 +27,11 @@ export declare class ApiBaseService {
|
|
|
27
27
|
static set accessToken(value: string);
|
|
28
28
|
static set onTokenExpired(callback: (accessToken: string) => void);
|
|
29
29
|
protected isTokenExpired(response: AxiosResponse | undefined): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Decode the JWT payload so we can inspect the `exp` claim in both browser and Node runtimes.
|
|
32
|
+
* This avoids relying on a Node-only JWT helper while still tolerating malformed tokens safely.
|
|
33
|
+
*/
|
|
34
|
+
private static decodeJwtPayload;
|
|
30
35
|
baseURL(): string;
|
|
31
36
|
protected post<T, B = undefined, R = AxiosResponse<T>>(endpoint: string, data?: B): Promise<R>;
|
|
32
37
|
protected put<T, B = undefined, R = AxiosResponse<T>>(endpoint: string, data?: B): Promise<R>;
|
|
@@ -121,13 +121,44 @@ class ApiBaseService {
|
|
|
121
121
|
ApiBaseService._onTokenExpired = callback;
|
|
122
122
|
}
|
|
123
123
|
isTokenExpired(response) {
|
|
124
|
-
var _a, _b;
|
|
125
124
|
if (!ApiBaseService.accessToken) {
|
|
126
125
|
return false;
|
|
127
126
|
}
|
|
128
|
-
|
|
127
|
+
let decodedToken;
|
|
128
|
+
try {
|
|
129
|
+
decodedToken = JSON.parse(ApiBaseService.decodeJwtPayload(ApiBaseService.accessToken));
|
|
130
|
+
}
|
|
131
|
+
catch (_a) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
129
134
|
return (response === null || response === void 0 ? void 0 : response.status) === 401 && decodedToken.exp < (new Date().getTime() / 1000);
|
|
130
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Decode the JWT payload so we can inspect the `exp` claim in both browser and Node runtimes.
|
|
138
|
+
* This avoids relying on a Node-only JWT helper while still tolerating malformed tokens safely.
|
|
139
|
+
*/
|
|
140
|
+
static decodeJwtPayload(token) {
|
|
141
|
+
var _a;
|
|
142
|
+
try {
|
|
143
|
+
const payload = (_a = token.split(".")) === null || _a === void 0 ? void 0 : _a[1];
|
|
144
|
+
if (!payload) {
|
|
145
|
+
return "{}";
|
|
146
|
+
}
|
|
147
|
+
const base64 = payload.replace(/-/g, "+").replace(/_/g, "/");
|
|
148
|
+
const paddingLength = (4 - (base64.length % 4)) % 4;
|
|
149
|
+
const paddedBase64 = base64 + "=".repeat(paddingLength);
|
|
150
|
+
const binary = atob(paddedBase64);
|
|
151
|
+
return decodeURIComponent(Array.from(binary, (character) => {
|
|
152
|
+
const hex = character.charCodeAt(0).toString(16);
|
|
153
|
+
return `%${hex.length === 1 ? `0${hex}` : hex}`;
|
|
154
|
+
}).join(""));
|
|
155
|
+
}
|
|
156
|
+
catch (_b) {
|
|
157
|
+
// Malformed or legacy token payloads should not break the axios error path.
|
|
158
|
+
// Treat undecodable tokens as empty payloads and let the 401 handling continue.
|
|
159
|
+
return "{}";
|
|
160
|
+
}
|
|
161
|
+
}
|
|
131
162
|
baseURL() {
|
|
132
163
|
return this.api.defaults.baseURL ? this.api.defaults.baseURL : "";
|
|
133
164
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@devopness/sdk-js",
|
|
4
|
-
"version": "3.5.
|
|
4
|
+
"version": "3.5.2",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
8
|
"description": "Devopness API JS/TS SDK - Painless essential DevOps to everyone",
|
|
9
9
|
"main": "dist/index.js",
|
|
10
10
|
"types": "dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
11
17
|
"files": [
|
|
12
18
|
"dist"
|
|
13
19
|
],
|
|
@@ -19,6 +25,7 @@
|
|
|
19
25
|
"docs-update-service-index": "npm run docs-remove-service-index && npm run docs-export-service-index",
|
|
20
26
|
"docs": "npm run docs-update-service-index && typedoc",
|
|
21
27
|
"lint": "eslint .",
|
|
28
|
+
"lint:fix": "eslint . --fix",
|
|
22
29
|
"prepublishOnly": "npm run lint && npm test && npm run build",
|
|
23
30
|
"test": "jest"
|
|
24
31
|
},
|
|
@@ -50,23 +57,26 @@
|
|
|
50
57
|
"url": "https://github.com/devopness/devopness/issues"
|
|
51
58
|
},
|
|
52
59
|
"homepage": "https://github.com/devopness/devopness#readme",
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": ">=16"
|
|
62
|
+
},
|
|
53
63
|
"devDependencies": {
|
|
54
64
|
"@eslint/js": "^10.0.1",
|
|
55
|
-
"@openapitools/openapi-generator-cli": "^2.39.
|
|
65
|
+
"@openapitools/openapi-generator-cli": "^2.39.1",
|
|
56
66
|
"@types/jest": "^30.0.0",
|
|
57
|
-
"@typescript-eslint/parser": "^8.
|
|
67
|
+
"@typescript-eslint/parser": "^8.62.1",
|
|
58
68
|
"axios-mock-adapter": "^2.1.0",
|
|
59
|
-
"eslint": "^10.
|
|
69
|
+
"eslint": "^10.6.0",
|
|
60
70
|
"eslint-import-resolver-typescript": "^4.4.5",
|
|
61
71
|
"eslint-plugin-import": "^2.32.0",
|
|
62
|
-
"eslint-plugin-n": "^18.1
|
|
72
|
+
"eslint-plugin-n": "^18.2.1",
|
|
63
73
|
"eslint-plugin-promise": "^7.3.0",
|
|
64
74
|
"husky": "9.1.7",
|
|
65
75
|
"jest": "^30.4.2",
|
|
66
76
|
"ts-jest": "^29.4.11",
|
|
67
77
|
"typedoc": "^0.28.19",
|
|
68
|
-
"typescript": "^
|
|
69
|
-
"typescript-eslint": "^8.
|
|
78
|
+
"typescript": "^6.0.3",
|
|
79
|
+
"typescript-eslint": "^8.62.1"
|
|
70
80
|
},
|
|
71
81
|
"dependencies": {
|
|
72
82
|
"@types/parse-link-header": "^2.0.3",
|