windmill-client 1.148.0 → 1.150.0
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/client.d.ts +1 -8
- package/dist/client.js +6 -59
- package/dist/core/OpenAPI.js +1 -1
- package/dist/services/ResourceService.d.ts +9 -0
- package/dist/services/ResourceService.js +15 -0
- package/dist/services/VariableService.d.ts +9 -0
- package/dist/services/VariableService.js +15 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -23,13 +23,6 @@ export declare function getResource(path?: string, undefinedIfEmpty?: boolean):
|
|
|
23
23
|
* @returns resource value
|
|
24
24
|
*/
|
|
25
25
|
export declare function resolveDefaultResource(obj: any): Promise<any>;
|
|
26
|
-
/**
|
|
27
|
-
* Get the full resource value by path
|
|
28
|
-
* @param path path of the resource, default to internal state path
|
|
29
|
-
* @param undefinedIfEmpty if the resource does not exist, return undefined instead of throwing an error
|
|
30
|
-
* @returns full resource
|
|
31
|
-
*/
|
|
32
|
-
export declare function getFullResource(path?: string, undefinedIfEmpty?: boolean): Promise<any>;
|
|
33
26
|
export declare function getStatePath(): string;
|
|
34
27
|
/**
|
|
35
28
|
* Set a resource value by path
|
|
@@ -63,7 +56,7 @@ export declare function getState(): Promise<any>;
|
|
|
63
56
|
* @param path path of the variable
|
|
64
57
|
* @returns variable value
|
|
65
58
|
*/
|
|
66
|
-
export declare function getVariable(path: string): Promise<string
|
|
59
|
+
export declare function getVariable(path: string): Promise<string>;
|
|
67
60
|
/**
|
|
68
61
|
* Set a variable by path, create if not exist
|
|
69
62
|
* @param path path of the variable
|
package/dist/client.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.uint8ArrayToBase64 = exports.base64ToUint8Array = exports.databaseUrlFromResource = exports.setVariable = exports.getVariable = exports.getState = exports.getInternalState = exports.setState = exports.setInternalState = exports.setResource = exports.getStatePath = exports.
|
|
12
|
+
exports.uint8ArrayToBase64 = exports.base64ToUint8Array = exports.databaseUrlFromResource = exports.setVariable = exports.getVariable = exports.getState = exports.getInternalState = exports.setState = exports.setInternalState = exports.setResource = exports.getStatePath = exports.resolveDefaultResource = exports.getResource = exports.getWorkspace = exports.setClient = exports.SHARED_FOLDER = exports.WorkspaceService = exports.UserService = exports.SettingsService = exports.ScheduleService = exports.ScriptService = exports.VariableService = exports.ResourceService = exports.JobService = exports.GroupService = exports.GranularAclService = exports.FlowService = exports.AuditService = exports.AdminService = void 0;
|
|
13
13
|
const index_1 = require("./index");
|
|
14
14
|
const index_2 = require("./index");
|
|
15
15
|
var index_3 = require("./index");
|
|
@@ -72,8 +72,10 @@ function getResource(path, undefinedIfEmpty) {
|
|
|
72
72
|
const workspace = getWorkspace();
|
|
73
73
|
path = path !== null && path !== void 0 ? path : getStatePath();
|
|
74
74
|
try {
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
return yield index_1.ResourceService.getResourceValueInterpolated({
|
|
76
|
+
workspace,
|
|
77
|
+
path,
|
|
78
|
+
});
|
|
77
79
|
}
|
|
78
80
|
catch (e) {
|
|
79
81
|
if (undefinedIfEmpty && e.status === 404) {
|
|
@@ -102,32 +104,6 @@ function resolveDefaultResource(obj) {
|
|
|
102
104
|
});
|
|
103
105
|
}
|
|
104
106
|
exports.resolveDefaultResource = resolveDefaultResource;
|
|
105
|
-
/**
|
|
106
|
-
* Get the full resource value by path
|
|
107
|
-
* @param path path of the resource, default to internal state path
|
|
108
|
-
* @param undefinedIfEmpty if the resource does not exist, return undefined instead of throwing an error
|
|
109
|
-
* @returns full resource
|
|
110
|
-
*/
|
|
111
|
-
function getFullResource(path, undefinedIfEmpty) {
|
|
112
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
const workspace = getWorkspace();
|
|
114
|
-
path = path !== null && path !== void 0 ? path : getStatePath();
|
|
115
|
-
try {
|
|
116
|
-
const resource = yield index_1.ResourceService.getResource({ workspace, path });
|
|
117
|
-
const value = yield _transformLeaf(resource.value);
|
|
118
|
-
return Object.assign(Object.assign({}, resource), { value });
|
|
119
|
-
}
|
|
120
|
-
catch (e) {
|
|
121
|
-
if (undefinedIfEmpty && e.status === 404) {
|
|
122
|
-
return undefined;
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
throw Error(`Resource not found at ${path} or not visible to you`);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
exports.getFullResource = getFullResource;
|
|
131
107
|
function getStatePath() {
|
|
132
108
|
const state_path = getEnv("WM_STATE_PATH_NEW");
|
|
133
109
|
if (state_path === undefined) {
|
|
@@ -233,8 +209,7 @@ function getVariable(path) {
|
|
|
233
209
|
!clientSet && setClient();
|
|
234
210
|
const workspace = getWorkspace();
|
|
235
211
|
try {
|
|
236
|
-
|
|
237
|
-
return variable.value;
|
|
212
|
+
return yield index_1.VariableService.getVariableValue({ workspace, path });
|
|
238
213
|
}
|
|
239
214
|
catch (e) {
|
|
240
215
|
throw Error(`Variable not found at ${path} or not visible to you`);
|
|
@@ -274,34 +249,6 @@ function setVariable(path, value, isSecretIfNotExist, descriptionIfNotExist) {
|
|
|
274
249
|
});
|
|
275
250
|
}
|
|
276
251
|
exports.setVariable = setVariable;
|
|
277
|
-
function transformLeaves(d) {
|
|
278
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
279
|
-
for (const k in d) {
|
|
280
|
-
d[k] = yield _transformLeaf(d[k]);
|
|
281
|
-
}
|
|
282
|
-
return d;
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
const VAR_RESOURCE_PREFIX = "$var:";
|
|
286
|
-
const RES_RESOURCE_PREFIX = "$res:";
|
|
287
|
-
function _transformLeaf(v) {
|
|
288
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
289
|
-
if (typeof v === "object") {
|
|
290
|
-
return transformLeaves(v);
|
|
291
|
-
}
|
|
292
|
-
else if (typeof v === "string" && v.startsWith(VAR_RESOURCE_PREFIX)) {
|
|
293
|
-
const varName = v.substring(VAR_RESOURCE_PREFIX.length);
|
|
294
|
-
return yield getVariable(varName);
|
|
295
|
-
}
|
|
296
|
-
else if (typeof v === "string" && v.startsWith(RES_RESOURCE_PREFIX)) {
|
|
297
|
-
const resName = v.substring(RES_RESOURCE_PREFIX.length);
|
|
298
|
-
return yield getResource(resName);
|
|
299
|
-
}
|
|
300
|
-
else {
|
|
301
|
-
return v;
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
252
|
function databaseUrlFromResource(path) {
|
|
306
253
|
return __awaiter(this, void 0, void 0, function* () {
|
|
307
254
|
const resource = yield getResource(path);
|
package/dist/core/OpenAPI.js
CHANGED
|
@@ -65,6 +65,15 @@ export declare class ResourceService {
|
|
|
65
65
|
workspace: string;
|
|
66
66
|
path: string;
|
|
67
67
|
}): CancelablePromise<Resource>;
|
|
68
|
+
/**
|
|
69
|
+
* get resource interpolated (variables and resources are fully unrolled)
|
|
70
|
+
* @returns any resource value
|
|
71
|
+
* @throws ApiError
|
|
72
|
+
*/
|
|
73
|
+
static getResourceValueInterpolated({ workspace, path, }: {
|
|
74
|
+
workspace: string;
|
|
75
|
+
path: string;
|
|
76
|
+
}): CancelablePromise<any>;
|
|
68
77
|
/**
|
|
69
78
|
* get resource value
|
|
70
79
|
* @returns any resource value
|
|
@@ -87,6 +87,21 @@ class ResourceService {
|
|
|
87
87
|
},
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* get resource interpolated (variables and resources are fully unrolled)
|
|
92
|
+
* @returns any resource value
|
|
93
|
+
* @throws ApiError
|
|
94
|
+
*/
|
|
95
|
+
static getResourceValueInterpolated({ workspace, path, }) {
|
|
96
|
+
return (0, request_1.request)(OpenAPI_1.OpenAPI, {
|
|
97
|
+
method: 'GET',
|
|
98
|
+
url: '/w/{workspace}/resources/get_value_interpolated/{path}',
|
|
99
|
+
path: {
|
|
100
|
+
'workspace': workspace,
|
|
101
|
+
'path': path,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
}
|
|
90
105
|
/**
|
|
91
106
|
* get resource value
|
|
92
107
|
* @returns any resource value
|
|
@@ -67,6 +67,15 @@ export declare class VariableService {
|
|
|
67
67
|
*/
|
|
68
68
|
decryptSecret?: boolean;
|
|
69
69
|
}): CancelablePromise<ListableVariable>;
|
|
70
|
+
/**
|
|
71
|
+
* get variable value
|
|
72
|
+
* @returns string variable
|
|
73
|
+
* @throws ApiError
|
|
74
|
+
*/
|
|
75
|
+
static getVariableValue({ workspace, path, }: {
|
|
76
|
+
workspace: string;
|
|
77
|
+
path: string;
|
|
78
|
+
}): CancelablePromise<string>;
|
|
70
79
|
/**
|
|
71
80
|
* does variable exists at path
|
|
72
81
|
* @returns boolean variable
|
|
@@ -92,6 +92,21 @@ class VariableService {
|
|
|
92
92
|
},
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* get variable value
|
|
97
|
+
* @returns string variable
|
|
98
|
+
* @throws ApiError
|
|
99
|
+
*/
|
|
100
|
+
static getVariableValue({ workspace, path, }) {
|
|
101
|
+
return (0, request_1.request)(OpenAPI_1.OpenAPI, {
|
|
102
|
+
method: 'GET',
|
|
103
|
+
url: '/w/{workspace}/variables/get_value/{path}',
|
|
104
|
+
path: {
|
|
105
|
+
'workspace': workspace,
|
|
106
|
+
'path': path,
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
}
|
|
95
110
|
/**
|
|
96
111
|
* does variable exists at path
|
|
97
112
|
* @returns boolean variable
|