windmill-cli 1.396.0 → 1.397.3
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/esm/apps.js +6 -5
- package/esm/bootstrap/script_bootstrap.js +18 -0
- package/esm/context.js +4 -3
- package/esm/deps.js +19 -2
- package/esm/flow.js +9 -8
- package/esm/folder.js +6 -5
- package/esm/gen/core/ApiError.js +41 -0
- package/esm/gen/core/ApiRequestOptions.js +1 -0
- package/esm/gen/core/ApiResult.js +1 -0
- package/esm/gen/core/CancelablePromise.js +130 -0
- package/esm/gen/core/OpenAPI.js +41 -0
- package/esm/gen/core/request.js +305 -0
- package/esm/gen/index.js +6 -0
- package/esm/gen/services.gen.js +6782 -0
- package/esm/gen/types.gen.js +2 -0
- package/esm/hub.js +5 -4
- package/esm/instance.js +5 -4
- package/esm/main.js +5 -3
- package/esm/metadata.js +1 -1
- package/esm/resource-type.js +6 -5
- package/esm/resource.js +11 -5
- package/esm/schedule.js +6 -5
- package/esm/script.js +42 -10
- package/esm/script_common.js +6 -0
- package/esm/settings.js +28 -27
- package/esm/sync.js +89 -23
- package/esm/types.js +9 -3
- package/esm/user.js +27 -27
- package/esm/utils.js +7 -0
- package/esm/variable.js +7 -6
- package/esm/workspace.js +7 -6
- package/package.json +1 -2
- package/types/apps.d.ts +2 -1
- package/types/apps.d.ts.map +1 -1
- package/types/bootstrap/script_bootstrap.d.ts +2 -0
- package/types/bootstrap/script_bootstrap.d.ts.map +1 -1
- package/types/context.d.ts +1 -1
- package/types/context.d.ts.map +1 -1
- package/types/deps.d.ts +1 -1
- package/types/deps.d.ts.map +1 -1
- package/types/flow.d.ts +2 -1
- package/types/flow.d.ts.map +1 -1
- package/types/folder.d.ts +5 -2
- package/types/folder.d.ts.map +1 -1
- package/types/gen/core/ApiError.d.ts +11 -0
- package/types/gen/core/ApiError.d.ts.map +1 -0
- package/types/gen/core/ApiRequestOptions.d.ts +15 -0
- package/types/gen/core/ApiRequestOptions.d.ts.map +1 -0
- package/types/gen/core/ApiResult.d.ts +8 -0
- package/types/gen/core/ApiResult.d.ts.map +1 -0
- package/types/gen/core/CancelablePromise.d.ts +27 -0
- package/types/gen/core/CancelablePromise.d.ts.map +1 -0
- package/types/gen/core/OpenAPI.d.ts +28 -0
- package/types/gen/core/OpenAPI.d.ts.map +1 -0
- package/types/gen/core/request.d.ts +30 -0
- package/types/gen/core/request.d.ts.map +1 -0
- package/types/gen/index.d.ts +6 -0
- package/types/gen/index.d.ts.map +1 -0
- package/types/gen/services.gen.d.ts +3339 -0
- package/types/gen/services.gen.d.ts.map +1 -0
- package/types/gen/types.gen.d.ts +4831 -0
- package/types/gen/types.gen.d.ts.map +1 -0
- package/types/hub.d.ts.map +1 -1
- package/types/instance.d.ts.map +1 -1
- package/types/main.d.ts +1 -1
- package/types/main.d.ts.map +1 -1
- package/types/metadata.d.ts +1 -1
- package/types/metadata.d.ts.map +1 -1
- package/types/resource-type.d.ts +2 -1
- package/types/resource-type.d.ts.map +1 -1
- package/types/resource.d.ts +2 -1
- package/types/resource.d.ts.map +1 -1
- package/types/schedule.d.ts +2 -1
- package/types/schedule.d.ts.map +1 -1
- package/types/script.d.ts +1 -0
- package/types/script.d.ts.map +1 -1
- package/types/script_common.d.ts +1 -1
- package/types/script_common.d.ts.map +1 -1
- package/types/settings.d.ts.map +1 -1
- package/types/sync.d.ts +2 -1
- package/types/sync.d.ts.map +1 -1
- package/types/types.d.ts +1 -1
- package/types/types.d.ts.map +1 -1
- package/types/user.d.ts.map +1 -1
- package/types/utils.d.ts +1 -0
- package/types/utils.d.ts.map +1 -1
- package/types/variable.d.ts +2 -1
- package/types/variable.d.ts.map +1 -1
- package/types/workspace.d.ts.map +1 -1
package/esm/sync.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import * as dntShim from "./_dnt.shims.js";
|
|
2
2
|
import { fetchVersion, requireLogin, resolveWorkspace } from "./context.js";
|
|
3
|
-
import { colors, Command, Confirm, ensureDir, minimatch, path,
|
|
3
|
+
import { colors, Command, Confirm, ensureDir, minimatch, path, log, yamlStringify, yamlParse, SEP, } from "./deps.js";
|
|
4
|
+
import * as wmill from "./gen/services.gen.js";
|
|
4
5
|
import { getTypeStrFromPath, parseFromPath, pushObj, showConflict, showDiff, } from "./types.js";
|
|
5
6
|
import { downloadZip } from "./pull.js";
|
|
6
|
-
import { exts, findContentFile, findGlobalDeps, handleScriptMetadata, removeExtensionToPath, } from "./script.js";
|
|
7
|
+
import { exts, findContentFile, findGlobalDeps, findResourceFile, handleScriptMetadata, removeExtensionToPath, } from "./script.js";
|
|
7
8
|
import { handleFile } from "./script.js";
|
|
8
|
-
import { deepEqual } from "./utils.js";
|
|
9
|
+
import { deepEqual, isFileResource } from "./utils.js";
|
|
9
10
|
import { mergeConfigWithConfigFile } from "./conf.js";
|
|
10
11
|
import { removePathPrefix } from "./types.js";
|
|
11
12
|
import { listSyncCodebases } from "./codebase.js";
|
|
12
13
|
import { generateFlowLockInternal, generateScriptMetadataInternal, } from "./metadata.js";
|
|
14
|
+
import { pushResource } from "./resource.js";
|
|
13
15
|
export function findCodebase(path, codebases) {
|
|
14
16
|
if (!path.endsWith(".ts")) {
|
|
15
17
|
return;
|
|
@@ -262,13 +264,17 @@ export function newPathAssigner(defaultTs) {
|
|
|
262
264
|
ext = "frontend.js";
|
|
263
265
|
else if (language == "php")
|
|
264
266
|
ext = "php";
|
|
267
|
+
else if (language == "rust")
|
|
268
|
+
ext = "rs";
|
|
269
|
+
else if (language == "ansible")
|
|
270
|
+
ext = "playbook.yml";
|
|
265
271
|
else
|
|
266
272
|
ext = "no_ext";
|
|
267
273
|
return [`${name}.inline_script.`, ext];
|
|
268
274
|
}
|
|
269
275
|
return { assignPath };
|
|
270
276
|
}
|
|
271
|
-
function ZipFSElement(zip, useYaml, defaultTs) {
|
|
277
|
+
function ZipFSElement(zip, useYaml, defaultTs, resourceTypeToFormatExtension) {
|
|
272
278
|
async function _internal_file(p, f) {
|
|
273
279
|
const kind = p.endsWith("flow.json")
|
|
274
280
|
? "flow"
|
|
@@ -276,7 +282,9 @@ function ZipFSElement(zip, useYaml, defaultTs) {
|
|
|
276
282
|
? "app"
|
|
277
283
|
: p.endsWith("script.json")
|
|
278
284
|
? "script"
|
|
279
|
-
: "
|
|
285
|
+
: p.endsWith("resource.json")
|
|
286
|
+
? "resource"
|
|
287
|
+
: "other";
|
|
280
288
|
const isJson = p.endsWith(".json");
|
|
281
289
|
function transformPath() {
|
|
282
290
|
if (kind == "flow") {
|
|
@@ -366,6 +374,21 @@ function ZipFSElement(zip, useYaml, defaultTs) {
|
|
|
366
374
|
? yamlStringify(parsed, yamlOptions)
|
|
367
375
|
: JSON.stringify(parsed, null, 2);
|
|
368
376
|
}
|
|
377
|
+
if (kind == "resource") {
|
|
378
|
+
const content = await f.async("text");
|
|
379
|
+
const parsed = JSON.parse(content);
|
|
380
|
+
const formatExtension = resourceTypeToFormatExtension[parsed["resource_type"]];
|
|
381
|
+
if (formatExtension) {
|
|
382
|
+
parsed["value"]["content"] =
|
|
383
|
+
"!inline " +
|
|
384
|
+
removeSuffix(p.replaceAll(SEP, "/"), ".resource.json") +
|
|
385
|
+
".resource.file." +
|
|
386
|
+
formatExtension;
|
|
387
|
+
}
|
|
388
|
+
return useYaml
|
|
389
|
+
? yamlStringify(parsed, yamlOptions)
|
|
390
|
+
: JSON.stringify(parsed, null, 2);
|
|
391
|
+
}
|
|
369
392
|
return useYaml && isJson
|
|
370
393
|
? yamlStringify(JSON.parse(content), yamlOptions)
|
|
371
394
|
: content;
|
|
@@ -388,6 +411,25 @@ function ZipFSElement(zip, useYaml, defaultTs) {
|
|
|
388
411
|
});
|
|
389
412
|
}
|
|
390
413
|
}
|
|
414
|
+
if (kind == "resource") {
|
|
415
|
+
const content = await f.async("text");
|
|
416
|
+
const parsed = JSON.parse(content);
|
|
417
|
+
const formatExtension = resourceTypeToFormatExtension[parsed["resource_type"]];
|
|
418
|
+
if (formatExtension) {
|
|
419
|
+
const fileContent = parsed["value"]["content"];
|
|
420
|
+
r.push({
|
|
421
|
+
isDirectory: false,
|
|
422
|
+
path: removeSuffix(finalPath, ".resource.json") +
|
|
423
|
+
".resource.file." +
|
|
424
|
+
formatExtension,
|
|
425
|
+
async *getChildren() { },
|
|
426
|
+
// deno-lint-ignore require-await
|
|
427
|
+
async getContentText() {
|
|
428
|
+
return fileContent;
|
|
429
|
+
},
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
}
|
|
391
433
|
return r;
|
|
392
434
|
}
|
|
393
435
|
function _internal_folder(p, zip) {
|
|
@@ -479,6 +521,8 @@ export async function elementsToMap(els, ignore, json, skips) {
|
|
|
479
521
|
continue;
|
|
480
522
|
if (skips.skipResources && path.endsWith(".resource" + ext))
|
|
481
523
|
continue;
|
|
524
|
+
if (skips.skipResources && isFileResource(path))
|
|
525
|
+
continue;
|
|
482
526
|
if (![
|
|
483
527
|
"json",
|
|
484
528
|
"yaml",
|
|
@@ -492,7 +536,10 @@ export async function elementsToMap(els, ignore, json, skips) {
|
|
|
492
536
|
"php",
|
|
493
537
|
"js",
|
|
494
538
|
"lock",
|
|
495
|
-
|
|
539
|
+
"rs",
|
|
540
|
+
"yml",
|
|
541
|
+
].includes(path.split(".").pop() ?? "") &&
|
|
542
|
+
!isFileResource(path))
|
|
496
543
|
continue;
|
|
497
544
|
const content = await entry.getContentText();
|
|
498
545
|
if (skips.skipSecrets && path.endsWith(".variable" + ext)) {
|
|
@@ -695,7 +742,10 @@ export async function pull(opts) {
|
|
|
695
742
|
await requireLogin(opts);
|
|
696
743
|
const codebases = await listSyncCodebases(opts);
|
|
697
744
|
log.info(colors.gray("Computing the files to update locally to match remote (taking wmill.yaml into account)"));
|
|
698
|
-
const
|
|
745
|
+
const resourceTypeToFormatExtension = (await wmill.fileResourceTypeToFileExtMap({
|
|
746
|
+
workspace: workspace.workspaceId,
|
|
747
|
+
}));
|
|
748
|
+
const remote = ZipFSElement((await downloadZip(workspace, opts.plainSecrets, opts.skipVariables, opts.skipResources, opts.skipSecrets, opts.includeSchedules, opts.includeUsers, opts.includeGroups, opts.includeSettings, opts.includeKey, opts.defaultTs)), !opts.json, opts.defaultTs ?? "bun", resourceTypeToFormatExtension);
|
|
699
749
|
const local = !opts.stateful
|
|
700
750
|
? await FSFSElement(dntShim.Deno.cwd(), codebases)
|
|
701
751
|
: await FSFSElement(path.join(dntShim.Deno.cwd(), ".wmill"), []);
|
|
@@ -910,7 +960,10 @@ export async function push(opts) {
|
|
|
910
960
|
const workspace = await resolveWorkspace(opts);
|
|
911
961
|
await requireLogin(opts);
|
|
912
962
|
log.info(colors.gray("Computing the files to update on the remote to match local (taking wmill.yaml includes/excludes into account)"));
|
|
913
|
-
const
|
|
963
|
+
const resourceTypeToFormatExtension = (await wmill.fileResourceTypeToFileExtMap({
|
|
964
|
+
workspace: workspace.workspaceId,
|
|
965
|
+
}));
|
|
966
|
+
const remote = ZipFSElement((await downloadZip(workspace, opts.plainSecrets, opts.skipVariables, opts.skipResources, opts.skipSecrets, opts.includeSchedules, opts.includeUsers, opts.includeGroups, opts.includeSettings, opts.includeKey, opts.defaultTs)), !opts.json, opts.defaultTs ?? "bun", resourceTypeToFormatExtension);
|
|
914
967
|
const local = await FSFSElement(path.join(dntShim.Deno.cwd(), ""), codebases);
|
|
915
968
|
const changes = await compareDynFSElement(local, remote, await ignoreF(opts), opts.json ?? false, opts, true);
|
|
916
969
|
const version = await fetchVersion(workspace.remote);
|
|
@@ -954,9 +1007,21 @@ export async function push(opts) {
|
|
|
954
1007
|
await ensureDir(path.dirname(stateTarget));
|
|
955
1008
|
log.info(`Editing ${getTypeStrFromPath(change.path)} ${change.path}`);
|
|
956
1009
|
}
|
|
1010
|
+
if (isFileResource(change.path)) {
|
|
1011
|
+
const resourceFilePath = await findResourceFile(change.path);
|
|
1012
|
+
if (!alreadySynced.includes(resourceFilePath)) {
|
|
1013
|
+
alreadySynced.push(resourceFilePath);
|
|
1014
|
+
const newObj = parseFromPath(resourceFilePath, await dntShim.Deno.readTextFile(resourceFilePath));
|
|
1015
|
+
await pushResource(workspace.workspaceId, resourceFilePath, undefined, newObj);
|
|
1016
|
+
if (opts.stateful && stateExists) {
|
|
1017
|
+
await dntShim.Deno.writeTextFile(stateTarget, change.after);
|
|
1018
|
+
}
|
|
1019
|
+
continue;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
957
1022
|
const oldObj = parseFromPath(change.path, change.before);
|
|
958
1023
|
const newObj = parseFromPath(change.path, change.after);
|
|
959
|
-
await pushObj(workspace.workspaceId, change.path, oldObj, newObj, opts.plainSecrets ?? false, opts.message);
|
|
1024
|
+
await pushObj(workspace.workspaceId, change.path, oldObj, newObj, opts.plainSecrets ?? false, alreadySynced, opts.message);
|
|
960
1025
|
if (opts.stateful && stateExists) {
|
|
961
1026
|
await dntShim.Deno.writeTextFile(stateTarget, change.after);
|
|
962
1027
|
}
|
|
@@ -964,7 +1029,8 @@ export async function push(opts) {
|
|
|
964
1029
|
else if (change.name === "added") {
|
|
965
1030
|
if (change.path.endsWith(".script.json") ||
|
|
966
1031
|
change.path.endsWith(".script.yaml") ||
|
|
967
|
-
change.path.endsWith(".lock")
|
|
1032
|
+
change.path.endsWith(".lock") ||
|
|
1033
|
+
isFileResource(change.path)) {
|
|
968
1034
|
continue;
|
|
969
1035
|
}
|
|
970
1036
|
else if (await handleFile(change.path, workspace, alreadySynced, opts.message, opts, globalDeps, codebases)) {
|
|
@@ -975,7 +1041,7 @@ export async function push(opts) {
|
|
|
975
1041
|
log.info(`Adding ${getTypeStrFromPath(change.path)} ${change.path}`);
|
|
976
1042
|
}
|
|
977
1043
|
const obj = parseFromPath(change.path, change.content);
|
|
978
|
-
await pushObj(workspace.workspaceId, change.path, undefined, obj, opts.plainSecrets ?? false, opts.message);
|
|
1044
|
+
await pushObj(workspace.workspaceId, change.path, undefined, obj, opts.plainSecrets ?? false, [], opts.message);
|
|
979
1045
|
if (opts.stateful && stateExists) {
|
|
980
1046
|
await dntShim.Deno.writeTextFile(stateTarget, change.content);
|
|
981
1047
|
}
|
|
@@ -994,60 +1060,60 @@ export async function push(opts) {
|
|
|
994
1060
|
const workspaceId = workspace.workspaceId;
|
|
995
1061
|
switch (typ) {
|
|
996
1062
|
case "script": {
|
|
997
|
-
const script = await
|
|
1063
|
+
const script = await wmill.getScriptByPath({
|
|
998
1064
|
workspace: workspaceId,
|
|
999
1065
|
path: removeExtensionToPath(change.path),
|
|
1000
1066
|
});
|
|
1001
|
-
await
|
|
1067
|
+
await wmill.archiveScriptByHash({
|
|
1002
1068
|
workspace: workspaceId,
|
|
1003
1069
|
hash: script.hash,
|
|
1004
1070
|
});
|
|
1005
1071
|
break;
|
|
1006
1072
|
}
|
|
1007
1073
|
case "folder":
|
|
1008
|
-
await
|
|
1074
|
+
await wmill.deleteFolder({
|
|
1009
1075
|
workspace: workspaceId,
|
|
1010
1076
|
name: change.path.split(SEP)[1],
|
|
1011
1077
|
});
|
|
1012
1078
|
break;
|
|
1013
1079
|
case "resource":
|
|
1014
|
-
await
|
|
1080
|
+
await wmill.deleteResource({
|
|
1015
1081
|
workspace: workspaceId,
|
|
1016
1082
|
path: removeSuffix(change.path, ".resource.json"),
|
|
1017
1083
|
});
|
|
1018
1084
|
break;
|
|
1019
1085
|
case "resource-type":
|
|
1020
|
-
await
|
|
1086
|
+
await wmill.deleteResourceType({
|
|
1021
1087
|
workspace: workspaceId,
|
|
1022
1088
|
path: removeSuffix(change.path, ".resource-type.json"),
|
|
1023
1089
|
});
|
|
1024
1090
|
break;
|
|
1025
1091
|
case "flow":
|
|
1026
|
-
await
|
|
1092
|
+
await wmill.deleteFlowByPath({
|
|
1027
1093
|
workspace: workspaceId,
|
|
1028
1094
|
path: removeSuffix(change.path, ".flow/flow.json"),
|
|
1029
1095
|
});
|
|
1030
1096
|
break;
|
|
1031
1097
|
case "app":
|
|
1032
|
-
await
|
|
1098
|
+
await wmill.deleteApp({
|
|
1033
1099
|
workspace: workspaceId,
|
|
1034
1100
|
path: removeSuffix(change.path, ".app/app.json"),
|
|
1035
1101
|
});
|
|
1036
1102
|
break;
|
|
1037
1103
|
case "schedule":
|
|
1038
|
-
await
|
|
1104
|
+
await wmill.deleteSchedule({
|
|
1039
1105
|
workspace: workspaceId,
|
|
1040
1106
|
path: removeSuffix(change.path, ".schedule.json"),
|
|
1041
1107
|
});
|
|
1042
1108
|
break;
|
|
1043
1109
|
case "variable":
|
|
1044
|
-
await
|
|
1110
|
+
await wmill.deleteVariable({
|
|
1045
1111
|
workspace: workspaceId,
|
|
1046
1112
|
path: removeSuffix(change.path, ".variable.json"),
|
|
1047
1113
|
});
|
|
1048
1114
|
break;
|
|
1049
1115
|
case "user": {
|
|
1050
|
-
const users = await
|
|
1116
|
+
const users = await wmill.listUsers({
|
|
1051
1117
|
workspace: workspaceId,
|
|
1052
1118
|
});
|
|
1053
1119
|
const email = removeSuffix(removePathPrefix(change.path, "users"), ".user.json");
|
|
@@ -1055,14 +1121,14 @@ export async function push(opts) {
|
|
|
1055
1121
|
if (!user) {
|
|
1056
1122
|
throw new Error(`User ${email} not found`);
|
|
1057
1123
|
}
|
|
1058
|
-
await
|
|
1124
|
+
await wmill.deleteUser({
|
|
1059
1125
|
workspace: workspaceId,
|
|
1060
1126
|
username: user.username,
|
|
1061
1127
|
});
|
|
1062
1128
|
break;
|
|
1063
1129
|
}
|
|
1064
1130
|
case "group":
|
|
1065
|
-
await
|
|
1131
|
+
await wmill.deleteGroup({
|
|
1066
1132
|
workspace: workspaceId,
|
|
1067
1133
|
name: removeSuffix(removePathPrefix(change.path, "groups"), ".group.json"),
|
|
1068
1134
|
});
|
package/esm/types.js
CHANGED
|
@@ -9,7 +9,7 @@ import { pushResourceType } from "./resource-type.js";
|
|
|
9
9
|
import { pushVariable } from "./variable.js";
|
|
10
10
|
import { yamlOptions } from "./sync.js";
|
|
11
11
|
import { showDiffs } from "./main.js";
|
|
12
|
-
import { deepEqual } from "./utils.js";
|
|
12
|
+
import { deepEqual, isFileResource } from "./utils.js";
|
|
13
13
|
import { pushSchedule } from "./schedule.js";
|
|
14
14
|
import { pushWorkspaceUser } from "./user.js";
|
|
15
15
|
import { pushGroup } from "./user.js";
|
|
@@ -65,7 +65,7 @@ export function showConflict(path, local, remote) {
|
|
|
65
65
|
log.info("\x1b[31mlocal\x1b[31m - \x1b[32mremote\x1b[32m");
|
|
66
66
|
log.info("\n");
|
|
67
67
|
}
|
|
68
|
-
export async function pushObj(workspace, p, befObj, newObj, plainSecrets, message) {
|
|
68
|
+
export async function pushObj(workspace, p, befObj, newObj, plainSecrets, alreadySynced, message) {
|
|
69
69
|
const typeEnding = getTypeStrFromPath(p);
|
|
70
70
|
if (typeEnding === "app") {
|
|
71
71
|
const appName = p.split(".app" + SEP)[0];
|
|
@@ -82,7 +82,10 @@ export async function pushObj(workspace, p, befObj, newObj, plainSecrets, messag
|
|
|
82
82
|
await pushFlow(workspace, flowName, flowName + ".flow", message);
|
|
83
83
|
}
|
|
84
84
|
else if (typeEnding === "resource") {
|
|
85
|
-
|
|
85
|
+
if (!alreadySynced.includes(p)) {
|
|
86
|
+
alreadySynced.push(p);
|
|
87
|
+
await pushResource(workspace, p, befObj, newObj);
|
|
88
|
+
}
|
|
86
89
|
}
|
|
87
90
|
else if (typeEnding === "resource-type") {
|
|
88
91
|
await pushResourceType(workspace, p, befObj, newObj);
|
|
@@ -160,6 +163,9 @@ export function getTypeStrFromPath(p) {
|
|
|
160
163
|
return typeEnding;
|
|
161
164
|
}
|
|
162
165
|
else {
|
|
166
|
+
if (isFileResource(p)) {
|
|
167
|
+
return "resource";
|
|
168
|
+
}
|
|
163
169
|
throw new Error("Could not infer type of path " + JSON.stringify(parsed));
|
|
164
170
|
}
|
|
165
171
|
}
|
package/esm/user.js
CHANGED
|
@@ -3,15 +3,15 @@ import * as dntShim from "./_dnt.shims.js";
|
|
|
3
3
|
import { requireLogin } from "./context.js";
|
|
4
4
|
import { isSuperset, removeType, removePathPrefix, } from "./types.js";
|
|
5
5
|
import { compareInstanceObjects } from "./instance.js";
|
|
6
|
-
import { colors, Command, log, Table,
|
|
7
|
-
import
|
|
6
|
+
import { colors, Command, log, Table, yamlStringify, yamlParse, } from "./deps.js";
|
|
7
|
+
import * as wmill from "./gen/services.gen.js";
|
|
8
8
|
async function list(opts) {
|
|
9
9
|
await requireLogin(opts);
|
|
10
10
|
const perPage = 10;
|
|
11
11
|
let page = 0;
|
|
12
12
|
const total = [];
|
|
13
13
|
while (true) {
|
|
14
|
-
const res = await
|
|
14
|
+
const res = await wmill.listUsersAsSuperAdmin({ page, perPage });
|
|
15
15
|
total.push(...res);
|
|
16
16
|
page += 1;
|
|
17
17
|
if (res.length < perPage) {
|
|
@@ -37,7 +37,7 @@ function rdString() {
|
|
|
37
37
|
async function add(opts, email, password) {
|
|
38
38
|
await requireLogin(opts);
|
|
39
39
|
const password_final = password ?? rdString();
|
|
40
|
-
await
|
|
40
|
+
await wmill.createUserGlobally({
|
|
41
41
|
requestBody: {
|
|
42
42
|
email,
|
|
43
43
|
password: password_final,
|
|
@@ -53,13 +53,13 @@ async function add(opts, email, password) {
|
|
|
53
53
|
}
|
|
54
54
|
async function remove(opts, email) {
|
|
55
55
|
await requireLogin(opts);
|
|
56
|
-
await
|
|
56
|
+
await wmill.globalUserDelete({ email });
|
|
57
57
|
log.info(colors.green("Deleted User " + email));
|
|
58
58
|
}
|
|
59
59
|
async function createToken(opts) {
|
|
60
60
|
if (opts.email && opts.password) {
|
|
61
61
|
log.info("Token: " +
|
|
62
|
-
(await
|
|
62
|
+
(await wmill.login({
|
|
63
63
|
requestBody: {
|
|
64
64
|
email: opts.email,
|
|
65
65
|
password: opts.password,
|
|
@@ -67,7 +67,7 @@ async function createToken(opts) {
|
|
|
67
67
|
})));
|
|
68
68
|
}
|
|
69
69
|
await requireLogin(opts);
|
|
70
|
-
log.info("Token: " + (await
|
|
70
|
+
log.info("Token: " + (await wmill.createToken({ requestBody: {} })));
|
|
71
71
|
}
|
|
72
72
|
export async function pushWorkspaceUser(workspace, path, user, localUser) {
|
|
73
73
|
const email = removePathPrefix(removeType(path, "user"), "users");
|
|
@@ -76,7 +76,7 @@ export async function pushWorkspaceUser(workspace, path, user, localUser) {
|
|
|
76
76
|
throw new Error(`Invalid role for user ${email}: ${localUser.role}`);
|
|
77
77
|
}
|
|
78
78
|
try {
|
|
79
|
-
const remoteUser = await
|
|
79
|
+
const remoteUser = await wmill.getUser({
|
|
80
80
|
workspace,
|
|
81
81
|
username: localUser.username,
|
|
82
82
|
});
|
|
@@ -105,7 +105,7 @@ export async function pushWorkspaceUser(workspace, path, user, localUser) {
|
|
|
105
105
|
}
|
|
106
106
|
log.debug(`User ${email} is not up-to-date, updating...`);
|
|
107
107
|
try {
|
|
108
|
-
await
|
|
108
|
+
await wmill.updateUser({
|
|
109
109
|
workspace: workspace,
|
|
110
110
|
username: localUser.username,
|
|
111
111
|
requestBody: {
|
|
@@ -123,10 +123,10 @@ export async function pushWorkspaceUser(workspace, path, user, localUser) {
|
|
|
123
123
|
else {
|
|
124
124
|
console.log(colors.bold.yellow("Creating new user: " + email));
|
|
125
125
|
try {
|
|
126
|
-
const automatedUsernameCreation = (await
|
|
126
|
+
const automatedUsernameCreation = (await wmill.getGlobal({
|
|
127
127
|
key: "automate_username_creation",
|
|
128
128
|
}));
|
|
129
|
-
await
|
|
129
|
+
await wmill.addUser({
|
|
130
130
|
workspace: workspace,
|
|
131
131
|
requestBody: {
|
|
132
132
|
email: email,
|
|
@@ -146,7 +146,7 @@ export async function pushGroup(workspace, path, group, localGroup) {
|
|
|
146
146
|
const name = removePathPrefix(removeType(path, "group"), "groups");
|
|
147
147
|
log.debug(`Processing local group ${name}`);
|
|
148
148
|
try {
|
|
149
|
-
const remoteGroup = await
|
|
149
|
+
const remoteGroup = await wmill.getGroup({
|
|
150
150
|
workspace,
|
|
151
151
|
name,
|
|
152
152
|
});
|
|
@@ -176,7 +176,7 @@ export async function pushGroup(workspace, path, group, localGroup) {
|
|
|
176
176
|
}
|
|
177
177
|
log.debug(`Group ${name} is not up-to-date, updating...`);
|
|
178
178
|
try {
|
|
179
|
-
await
|
|
179
|
+
await wmill.updateGroup({
|
|
180
180
|
workspace: workspace,
|
|
181
181
|
name,
|
|
182
182
|
requestBody: {
|
|
@@ -195,7 +195,7 @@ export async function pushGroup(workspace, path, group, localGroup) {
|
|
|
195
195
|
}
|
|
196
196
|
else {
|
|
197
197
|
log.debug(`Adding ${member} to group ${name}`);
|
|
198
|
-
await
|
|
198
|
+
await wmill.addUserToGroup({
|
|
199
199
|
workspace: workspace,
|
|
200
200
|
name,
|
|
201
201
|
requestBody: {
|
|
@@ -206,7 +206,7 @@ export async function pushGroup(workspace, path, group, localGroup) {
|
|
|
206
206
|
if (localGroup.admins.includes(member) &&
|
|
207
207
|
!group.admins.includes(member)) {
|
|
208
208
|
log.debug(`Setting role of ${member} as admin in group ${name}`);
|
|
209
|
-
await
|
|
209
|
+
await wmill.addGranularAcls({
|
|
210
210
|
workspace: workspace,
|
|
211
211
|
kind: "group_",
|
|
212
212
|
path: name,
|
|
@@ -219,7 +219,7 @@ export async function pushGroup(workspace, path, group, localGroup) {
|
|
|
219
219
|
if (localGroup.members.includes(member) &&
|
|
220
220
|
!group.members.includes(member)) {
|
|
221
221
|
log.debug(`Setting role of ${member} as member in group ${name}`);
|
|
222
|
-
await
|
|
222
|
+
await wmill.addGranularAcls({
|
|
223
223
|
workspace: workspace,
|
|
224
224
|
kind: "group_",
|
|
225
225
|
path: name,
|
|
@@ -239,14 +239,14 @@ export async function pushGroup(workspace, path, group, localGroup) {
|
|
|
239
239
|
if (![...localGroup.members, ...localGroup.admins].includes(member)) {
|
|
240
240
|
log.debug(`Removing ${member} and any associated role from group ${name}`);
|
|
241
241
|
try {
|
|
242
|
-
await
|
|
242
|
+
await wmill.removeUserToGroup({
|
|
243
243
|
workspace: workspace,
|
|
244
244
|
name,
|
|
245
245
|
requestBody: {
|
|
246
246
|
username: member.slice(2),
|
|
247
247
|
},
|
|
248
248
|
});
|
|
249
|
-
await
|
|
249
|
+
await wmill.removeGranularAcls({
|
|
250
250
|
workspace: workspace,
|
|
251
251
|
kind: "group_",
|
|
252
252
|
path: name,
|
|
@@ -265,7 +265,7 @@ export async function pushGroup(workspace, path, group, localGroup) {
|
|
|
265
265
|
else {
|
|
266
266
|
console.log(colors.bold.yellow("Creating new user: " + name));
|
|
267
267
|
try {
|
|
268
|
-
await
|
|
268
|
+
await wmill.createGroup({
|
|
269
269
|
workspace: workspace,
|
|
270
270
|
requestBody: {
|
|
271
271
|
name,
|
|
@@ -275,7 +275,7 @@ export async function pushGroup(workspace, path, group, localGroup) {
|
|
|
275
275
|
for (const member of [...localGroup.members, ...localGroup.admins]) {
|
|
276
276
|
log.debug(`Adding user ${member} to group ${name}`);
|
|
277
277
|
try {
|
|
278
|
-
await
|
|
278
|
+
await wmill.addUserToGroup({
|
|
279
279
|
workspace: workspace,
|
|
280
280
|
name,
|
|
281
281
|
requestBody: {
|
|
@@ -284,7 +284,7 @@ export async function pushGroup(workspace, path, group, localGroup) {
|
|
|
284
284
|
});
|
|
285
285
|
if (localGroup.admins.includes(member)) {
|
|
286
286
|
log.debug(`Setting role of ${member} as admin in group ${name}`);
|
|
287
|
-
await
|
|
287
|
+
await wmill.addGranularAcls({
|
|
288
288
|
workspace: workspace,
|
|
289
289
|
kind: "group_",
|
|
290
290
|
path: name,
|
|
@@ -308,7 +308,7 @@ export async function pushGroup(workspace, path, group, localGroup) {
|
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
export async function pullInstanceUsers(preview = false) {
|
|
311
|
-
const remoteUsers = await
|
|
311
|
+
const remoteUsers = await wmill.globalUsersExport();
|
|
312
312
|
if (preview) {
|
|
313
313
|
let localUsers = [];
|
|
314
314
|
try {
|
|
@@ -325,7 +325,7 @@ export async function pullInstanceUsers(preview = false) {
|
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
327
|
export async function pushInstanceUsers(preview = false) {
|
|
328
|
-
const remoteUsers = await
|
|
328
|
+
const remoteUsers = await wmill.globalUsersExport();
|
|
329
329
|
const localUsers = (await dntShim.Deno.readTextFile("instance_users.yaml")
|
|
330
330
|
.then((raw) => yamlParse(raw))
|
|
331
331
|
.catch(() => []));
|
|
@@ -334,14 +334,14 @@ export async function pushInstanceUsers(preview = false) {
|
|
|
334
334
|
}
|
|
335
335
|
else {
|
|
336
336
|
log.info("Pushing users to instance...");
|
|
337
|
-
await
|
|
337
|
+
await wmill.globalUsersOverwrite({
|
|
338
338
|
requestBody: localUsers,
|
|
339
339
|
});
|
|
340
340
|
log.info(colors.green("Users pushed to the instance"));
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
343
|
export async function pullInstanceGroups(preview = false) {
|
|
344
|
-
const remoteGroups = await
|
|
344
|
+
const remoteGroups = await wmill.exportInstanceGroups();
|
|
345
345
|
if (preview) {
|
|
346
346
|
let localGroups = [];
|
|
347
347
|
try {
|
|
@@ -358,7 +358,7 @@ export async function pullInstanceGroups(preview = false) {
|
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
export async function pushInstanceGroups(preview = false) {
|
|
361
|
-
const remoteGroups = await
|
|
361
|
+
const remoteGroups = await wmill.exportInstanceGroups();
|
|
362
362
|
const localGroups = (await dntShim.Deno.readTextFile("instance_groups.yaml")
|
|
363
363
|
.then((raw) => yamlParse(raw))
|
|
364
364
|
.catch(() => []));
|
|
@@ -367,7 +367,7 @@ export async function pushInstanceGroups(preview = false) {
|
|
|
367
367
|
}
|
|
368
368
|
else {
|
|
369
369
|
log.info("Pushing groups to instance...");
|
|
370
|
-
await
|
|
370
|
+
await wmill.overwriteInstanceGroups({
|
|
371
371
|
requestBody: localGroups,
|
|
372
372
|
});
|
|
373
373
|
log.info(colors.green("Groups pushed to the instance"));
|
package/esm/utils.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import * as dntShim from "./_dnt.shims.js";
|
|
4
4
|
// @ts-nocheck This file is copied from a JS project, so it's not type-safe.
|
|
5
5
|
import { log, encodeHex, SEP } from "./deps.js";
|
|
6
|
+
import crypto from "node:crypto";
|
|
6
7
|
export function deepEqual(a, b) {
|
|
7
8
|
if (a === b)
|
|
8
9
|
return true;
|
|
@@ -120,3 +121,9 @@ export function readInlinePathSync(path) {
|
|
|
120
121
|
export function sleep(ms) {
|
|
121
122
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
122
123
|
}
|
|
124
|
+
export function isFileResource(path) {
|
|
125
|
+
const splitPath = path.split(".");
|
|
126
|
+
return (splitPath.length >= 4 &&
|
|
127
|
+
splitPath[1] == "resource" &&
|
|
128
|
+
splitPath[2] == "file");
|
|
129
|
+
}
|
package/esm/variable.js
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
import * as dntShim from "./_dnt.shims.js";
|
|
3
3
|
import { requireLogin, resolveWorkspace, validatePath } from "./context.js";
|
|
4
4
|
import { isSuperset, parseFromFile, removeType, } from "./types.js";
|
|
5
|
-
import { colors, Command, Confirm, log, SEP, Table
|
|
5
|
+
import { colors, Command, Confirm, log, SEP, Table } from "./deps.js";
|
|
6
|
+
import * as wmill from "./gen/services.gen.js";
|
|
6
7
|
async function list(opts) {
|
|
7
8
|
const workspace = await resolveWorkspace(opts);
|
|
8
9
|
await requireLogin(opts);
|
|
9
|
-
const variables = await
|
|
10
|
+
const variables = await wmill.listVariable({
|
|
10
11
|
workspace: workspace.workspaceId,
|
|
11
12
|
});
|
|
12
13
|
new Table()
|
|
@@ -25,7 +26,7 @@ export async function pushVariable(workspace, remotePath, variable, localVariabl
|
|
|
25
26
|
remotePath = removeType(remotePath, "variable");
|
|
26
27
|
log.debug(`Processing local variable ${remotePath}`);
|
|
27
28
|
try {
|
|
28
|
-
variable = await
|
|
29
|
+
variable = await wmill.getVariable({
|
|
29
30
|
workspace: workspace,
|
|
30
31
|
path: remotePath.replaceAll(SEP, "/"),
|
|
31
32
|
decryptSecret: plainSecrets,
|
|
@@ -42,7 +43,7 @@ export async function pushVariable(workspace, remotePath, variable, localVariabl
|
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
44
45
|
log.debug(`Variable ${remotePath} is not up-to-date, updating`);
|
|
45
|
-
await
|
|
46
|
+
await wmill.updateVariable({
|
|
46
47
|
workspace,
|
|
47
48
|
path: remotePath.replaceAll(SEP, "/"),
|
|
48
49
|
alreadyEncrypted: !plainSecrets,
|
|
@@ -54,7 +55,7 @@ export async function pushVariable(workspace, remotePath, variable, localVariabl
|
|
|
54
55
|
}
|
|
55
56
|
else {
|
|
56
57
|
log.info(colors.yellow.bold(`Creating new variable ${remotePath}...`));
|
|
57
|
-
await
|
|
58
|
+
await wmill.createVariable({
|
|
58
59
|
workspace,
|
|
59
60
|
alreadyEncrypted: !plainSecrets,
|
|
60
61
|
requestBody: {
|
|
@@ -84,7 +85,7 @@ async function add(opts, value, remotePath) {
|
|
|
84
85
|
if (!validatePath(remotePath)) {
|
|
85
86
|
return;
|
|
86
87
|
}
|
|
87
|
-
if (await
|
|
88
|
+
if (await wmill.existsVariable({
|
|
88
89
|
workspace: workspace.workspaceId,
|
|
89
90
|
path: remotePath,
|
|
90
91
|
})) {
|
package/esm/workspace.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import * as dntShim from "./_dnt.shims.js";
|
|
3
3
|
import { getRootStore } from "./store.js";
|
|
4
4
|
import { loginInteractive, tryGetLoginInfo } from "./login.js";
|
|
5
|
-
import { colors, Command, Input, log, setClient, Table
|
|
5
|
+
import { colors, Command, Input, log, setClient, Table } from "./deps.js";
|
|
6
|
+
import * as wmill from "./gen/services.gen.js";
|
|
6
7
|
import { requireLogin } from "./context.js";
|
|
7
8
|
export async function allWorkspaces() {
|
|
8
9
|
try {
|
|
@@ -130,7 +131,7 @@ export async function add(opts, workspaceName, workspaceId, remote) {
|
|
|
130
131
|
setClient(token, remote.endsWith("/") ? remote.substring(0, remote.length - 1) : remote);
|
|
131
132
|
let alreadyExists = false;
|
|
132
133
|
try {
|
|
133
|
-
alreadyExists = await
|
|
134
|
+
alreadyExists = await wmill.existsWorkspace({
|
|
134
135
|
requestBody: { id: workspaceId },
|
|
135
136
|
});
|
|
136
137
|
}
|
|
@@ -141,10 +142,10 @@ export async function add(opts, workspaceName, workspaceId, remote) {
|
|
|
141
142
|
if (opts.create) {
|
|
142
143
|
if (!alreadyExists) {
|
|
143
144
|
log.info(colors.yellow(`Workspace at id ${workspaceId} on ${remote} does not exist. Creating...`));
|
|
144
|
-
const automateUsernameCreation = (await
|
|
145
|
+
const automateUsernameCreation = (await wmill.getGlobal({
|
|
145
146
|
key: "automate_username_creation",
|
|
146
147
|
})) ?? false;
|
|
147
|
-
await
|
|
148
|
+
await wmill.createWorkspace({
|
|
148
149
|
requestBody: {
|
|
149
150
|
id: workspaceId,
|
|
150
151
|
name: opts.createWorkspaceName ?? workspaceName,
|
|
@@ -156,7 +157,7 @@ export async function add(opts, workspaceName, workspaceId, remote) {
|
|
|
156
157
|
else if (!alreadyExists) {
|
|
157
158
|
log.info(colors.red.bold(`! Workspace at id ${workspaceId} on ${remote} does not exist. Re-run with --create to create it. Aborting.`));
|
|
158
159
|
log.info("On that instance and with those credentials, the workspaces that you can access are:");
|
|
159
|
-
const workspaces = await
|
|
160
|
+
const workspaces = await wmill.listWorkspaces();
|
|
160
161
|
for (const workspace of workspaces) {
|
|
161
162
|
log.info(`- ${workspace.id} (name: ${workspace.name})`);
|
|
162
163
|
}
|
|
@@ -209,7 +210,7 @@ async function remove(_opts, name) {
|
|
|
209
210
|
}
|
|
210
211
|
async function whoami(_opts) {
|
|
211
212
|
await requireLogin(_opts);
|
|
212
|
-
log.info(await
|
|
213
|
+
log.info(await wmill.globalWhoami());
|
|
213
214
|
const activeName = await getActiveWorkspaceName(_opts);
|
|
214
215
|
log.info("Active: " + colors.green.bold(activeName || "none"));
|
|
215
216
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "windmill-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.397.3",
|
|
4
4
|
"description": "CLI for Windmill",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
"jszip": "3.7.1",
|
|
38
38
|
"minimatch": "*",
|
|
39
39
|
"open": "*",
|
|
40
|
-
"windmill-client": "1.364.0",
|
|
41
40
|
"ws": "*",
|
|
42
41
|
"@deno/shim-deno": "~0.18.0"
|
|
43
42
|
},
|