windmill-client 1.450.0 → 1.451.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.js +72 -1
- package/dist/core/OpenAPI.js +1 -1
- package/package.json +2 -2
package/dist/client.js
CHANGED
|
@@ -64,6 +64,7 @@ Object.defineProperty(exports, "SettingsService", { enumerable: true, get: funct
|
|
|
64
64
|
Object.defineProperty(exports, "UserService", { enumerable: true, get: function () { return index_3.UserService; } });
|
|
65
65
|
Object.defineProperty(exports, "WorkspaceService", { enumerable: true, get: function () { return index_3.WorkspaceService; } });
|
|
66
66
|
exports.SHARED_FOLDER = "/shared";
|
|
67
|
+
let mockedApi = undefined;
|
|
67
68
|
function setClient(token, baseUrl) {
|
|
68
69
|
var _a, _b, _c;
|
|
69
70
|
if (baseUrl === undefined) {
|
|
@@ -102,8 +103,17 @@ function getWorkspace() {
|
|
|
102
103
|
*/
|
|
103
104
|
function getResource(path, undefinedIfEmpty) {
|
|
104
105
|
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
-
const workspace = getWorkspace();
|
|
106
106
|
path = path !== null && path !== void 0 ? path : getStatePath();
|
|
107
|
+
const mockedApi = yield getMockedApi();
|
|
108
|
+
if (mockedApi) {
|
|
109
|
+
if (mockedApi.resources[path]) {
|
|
110
|
+
return mockedApi.resources[path];
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
console.log(`MockedAPI present, but resource not found at ${path}, falling back to real API`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const workspace = getWorkspace();
|
|
107
117
|
try {
|
|
108
118
|
return yield index_1.ResourceService.getResourceValueInterpolated({
|
|
109
119
|
workspace,
|
|
@@ -340,6 +350,11 @@ function getStatePath() {
|
|
|
340
350
|
function setResource(value, path, initializeToTypeIfNotExist) {
|
|
341
351
|
return __awaiter(this, void 0, void 0, function* () {
|
|
342
352
|
path = path !== null && path !== void 0 ? path : getStatePath();
|
|
353
|
+
const mockedApi = yield getMockedApi();
|
|
354
|
+
if (mockedApi) {
|
|
355
|
+
mockedApi.resources[path] = value;
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
343
358
|
const workspace = getWorkspace();
|
|
344
359
|
if (yield index_1.ResourceService.existsResource({ workspace, path })) {
|
|
345
360
|
yield index_1.ResourceService.updateResourceValue({
|
|
@@ -521,6 +536,15 @@ function getState() {
|
|
|
521
536
|
*/
|
|
522
537
|
function getVariable(path) {
|
|
523
538
|
return __awaiter(this, void 0, void 0, function* () {
|
|
539
|
+
const mockedApi = yield getMockedApi();
|
|
540
|
+
if (mockedApi) {
|
|
541
|
+
if (mockedApi.variables[path]) {
|
|
542
|
+
return mockedApi.variables[path];
|
|
543
|
+
}
|
|
544
|
+
else {
|
|
545
|
+
console.log(`MockedAPI present, but variable not found at ${path}, falling back to real API`);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
524
548
|
const workspace = getWorkspace();
|
|
525
549
|
try {
|
|
526
550
|
return yield index_1.VariableService.getVariableValue({ workspace, path });
|
|
@@ -539,6 +563,11 @@ function getVariable(path) {
|
|
|
539
563
|
*/
|
|
540
564
|
function setVariable(path, value, isSecretIfNotExist, descriptionIfNotExist) {
|
|
541
565
|
return __awaiter(this, void 0, void 0, function* () {
|
|
566
|
+
const mockedApi = yield getMockedApi();
|
|
567
|
+
if (mockedApi) {
|
|
568
|
+
mockedApi.variables[path] = value;
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
542
571
|
const workspace = getWorkspace();
|
|
543
572
|
if (yield index_1.VariableService.existsVariable({ workspace, path })) {
|
|
544
573
|
yield index_1.VariableService.updateVariable({
|
|
@@ -861,3 +890,45 @@ function requestInteractiveSlackApproval(_a) {
|
|
|
861
890
|
yield index_1.JobService.getSlackApprovalPayload(Object.assign(Object.assign({ workspace }, params), { id: (_b = getEnv("WM_JOB_ID")) !== null && _b !== void 0 ? _b : "NO_JOB_ID" }));
|
|
862
891
|
});
|
|
863
892
|
}
|
|
893
|
+
function getMockedApi() {
|
|
894
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
895
|
+
const mockedPath = getEnv("WM_MOCKED_API_FILE");
|
|
896
|
+
if (mockedApi) {
|
|
897
|
+
return mockedApi;
|
|
898
|
+
}
|
|
899
|
+
if (mockedPath) {
|
|
900
|
+
console.info("Using mocked API from", mockedPath);
|
|
901
|
+
}
|
|
902
|
+
const path = getEnv("WM_MOCKED_API_FILE");
|
|
903
|
+
if (!path) {
|
|
904
|
+
console.warn("No mocked API file path provided at env variable WM_MOCKED_API_FILE. Using empty mocked API.");
|
|
905
|
+
mockedApi = {
|
|
906
|
+
variables: {},
|
|
907
|
+
resources: {},
|
|
908
|
+
};
|
|
909
|
+
return mockedApi;
|
|
910
|
+
}
|
|
911
|
+
try {
|
|
912
|
+
const fs = yield Promise.resolve().then(() => require("node:fs/promises"));
|
|
913
|
+
const file = yield fs.readFile(path, "utf-8");
|
|
914
|
+
try {
|
|
915
|
+
mockedApi = JSON.parse(file);
|
|
916
|
+
if (!mockedApi.variables) {
|
|
917
|
+
mockedApi.variables = {};
|
|
918
|
+
}
|
|
919
|
+
if (!mockedApi.resources) {
|
|
920
|
+
mockedApi.resources = {};
|
|
921
|
+
}
|
|
922
|
+
return mockedApi;
|
|
923
|
+
}
|
|
924
|
+
catch (_a) {
|
|
925
|
+
console.warn("Error parsing mocked API file at path", path);
|
|
926
|
+
return undefined;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
catch (_b) {
|
|
930
|
+
console.warn("Error reading mocked API file at path", path);
|
|
931
|
+
return undefined;
|
|
932
|
+
}
|
|
933
|
+
});
|
|
934
|
+
}
|
package/dist/core/OpenAPI.js
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "windmill-client",
|
|
3
3
|
"description": "Windmill SDK client for browsers and Node.js",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.451.0",
|
|
5
5
|
"author": "Ruben Fiszel",
|
|
6
6
|
"license": "Apache 2.0",
|
|
7
7
|
"devDependencies": {
|
|
8
|
-
"@types/node": "^20.
|
|
8
|
+
"@types/node": "^20.17.16",
|
|
9
9
|
"dts-bundle-generator": "^9.5.1",
|
|
10
10
|
"esbuild": "^0.21.1",
|
|
11
11
|
"typescript": "^5.4.5"
|