windmill-cli 1.680.1 → 1.682.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.
Files changed (2) hide show
  1. package/esm/main.js +350 -296
  2. package/package.json +1 -1
package/esm/main.js CHANGED
@@ -5,25 +5,43 @@ var __getProtoOf = Object.getPrototypeOf;
5
5
  var __defProp = Object.defineProperty;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ function __accessProp(key) {
9
+ return this[key];
10
+ }
11
+ var __toESMCache_node;
12
+ var __toESMCache_esm;
8
13
  var __toESM = (mod, isNodeMode, target) => {
14
+ var canCache = mod != null && typeof mod === "object";
15
+ if (canCache) {
16
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
17
+ var cached = cache.get(mod);
18
+ if (cached)
19
+ return cached;
20
+ }
9
21
  target = mod != null ? __create(__getProtoOf(mod)) : {};
10
22
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
11
23
  for (let key of __getOwnPropNames(mod))
12
24
  if (!__hasOwnProp.call(to, key))
13
25
  __defProp(to, key, {
14
- get: () => mod[key],
26
+ get: __accessProp.bind(mod, key),
15
27
  enumerable: true
16
28
  });
29
+ if (canCache)
30
+ cache.set(mod, to);
17
31
  return to;
18
32
  };
19
33
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
34
+ var __returnValue = (v) => v;
35
+ function __exportSetter(name, newValue) {
36
+ this[name] = __returnValue.bind(null, newValue);
37
+ }
20
38
  var __export = (target, all) => {
21
39
  for (var name in all)
22
40
  __defProp(target, name, {
23
41
  get: all[name],
24
42
  enumerable: true,
25
43
  configurable: true,
26
- set: (newValue) => all[name] = () => newValue
44
+ set: __exportSetter.bind(all, name)
27
45
  });
28
46
  };
29
47
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
@@ -11794,7 +11812,7 @@ var init_OpenAPI = __esm(() => {
11794
11812
  PASSWORD: undefined,
11795
11813
  TOKEN: getEnv2("WM_TOKEN"),
11796
11814
  USERNAME: undefined,
11797
- VERSION: "1.680.0",
11815
+ VERSION: "1.682.0",
11798
11816
  WITH_CREDENTIALS: true,
11799
11817
  interceptors: {
11800
11818
  request: new Interceptors,
@@ -12329,6 +12347,7 @@ __export(exports_services_gen, {
12329
12347
  listFilteredJobsUuids: () => listFilteredJobsUuids,
12330
12348
  listFavoriteAssets: () => listFavoriteAssets,
12331
12349
  listExtendedJobs: () => listExtendedJobs,
12350
+ listExtJwtTokens: () => listExtJwtTokens,
12332
12351
  listEmailTriggers: () => listEmailTriggers,
12333
12352
  listDucklakes: () => listDucklakes,
12334
12353
  listDedicatedWithDeps: () => listDedicatedWithDeps,
@@ -12972,6 +12991,16 @@ var backendVersion = () => {
12972
12991
  method: "GET",
12973
12992
  url: "/users/export"
12974
12993
  });
12994
+ }, listExtJwtTokens = (data2 = {}) => {
12995
+ return request(OpenAPI, {
12996
+ method: "GET",
12997
+ url: "/users/ext_jwt_tokens",
12998
+ query: {
12999
+ page: data2.page,
13000
+ per_page: data2.perPage,
13001
+ active_only: data2.activeOnly
13002
+ }
13003
+ });
12975
13004
  }, submitOnboardingData = (data2) => {
12976
13005
  return request(OpenAPI, {
12977
13006
  method: "POST",
@@ -22053,7 +22082,7 @@ function sameValueZero(a, b) {
22053
22082
  }
22054
22083
  function equal(a, b) {
22055
22084
  const seen = new Map;
22056
- return function compare(a2, b2) {
22085
+ return function compare3(a2, b2) {
22057
22086
  if (sameValueZero(a2, b2))
22058
22087
  return true;
22059
22088
  if (isPrimitive(a2) || isPrimitive(b2))
@@ -22078,7 +22107,7 @@ function equal(a, b) {
22078
22107
  throw new TypeError("Cannot compare WeakSet instances");
22079
22108
  }
22080
22109
  if (a2 instanceof WeakRef) {
22081
- return compare(a2.deref(), b2.deref());
22110
+ return compare3(a2.deref(), b2.deref());
22082
22111
  }
22083
22112
  if (seen.get(a2) === b2) {
22084
22113
  return true;
@@ -22100,7 +22129,7 @@ function equal(a, b) {
22100
22129
  return a2.symmetricDifference(b2).size === 0;
22101
22130
  }
22102
22131
  for (const key of aKeys) {
22103
- if (!b2.has(key) || !compare(a2.get(key), b2.get(key))) {
22132
+ if (!b2.has(key) || !compare3(a2.get(key), b2.get(key))) {
22104
22133
  return false;
22105
22134
  }
22106
22135
  }
@@ -22109,9 +22138,9 @@ function equal(a, b) {
22109
22138
  let unmatchedEntries = a2.size;
22110
22139
  for (const [aKey, aValue] of a2.entries()) {
22111
22140
  for (const [bKey, bValue] of b2.entries()) {
22112
- if (!compare(aKey, bKey))
22141
+ if (!compare3(aKey, bKey))
22113
22142
  continue;
22114
- if (aKey === aValue && bKey === bValue || compare(aValue, bValue)) {
22143
+ if (aKey === aValue && bKey === bValue || compare3(aValue, bValue)) {
22115
22144
  unmatchedEntries--;
22116
22145
  break;
22117
22146
  }
@@ -22131,7 +22160,7 @@ function equal(a, b) {
22131
22160
  keys = getKeysDeep(a2).union(getKeysDeep(b2));
22132
22161
  }
22133
22162
  for (const key of keys) {
22134
- if (!compare(a2[key], b2[key])) {
22163
+ if (!compare3(a2[key], b2[key])) {
22135
22164
  return false;
22136
22165
  }
22137
22166
  if (key in a2 && !(key in b2) || key in b2 && !(key in a2)) {
@@ -27082,8 +27111,7 @@ async function remove(_opts, name) {
27082
27111
  await removeWorkspace(name, false, _opts);
27083
27112
  }
27084
27113
  async function whoami2(_opts) {
27085
- await requireLogin(_opts);
27086
- const whoamiInfo = await globalWhoami();
27114
+ const whoamiInfo = await requireLogin(_opts);
27087
27115
  info(JSON.stringify(whoamiInfo, null, 2));
27088
27116
  const activeName = await getActiveWorkspaceName(_opts);
27089
27117
  const { getCurrentGitBranch: getCurrentGitBranch2, getOriginalBranchForWorkspaceForks: getOriginalBranchForWorkspaceForks2 } = await Promise.resolve().then(() => (init_git(), exports_git));
@@ -27823,6 +27851,31 @@ var init_context = __esm(async () => {
27823
27851
  });
27824
27852
 
27825
27853
  // src/core/auth.ts
27854
+ async function fetchWhoami(workspaceId) {
27855
+ try {
27856
+ return await globalWhoami();
27857
+ } catch (error2) {
27858
+ if (error2 && typeof error2 === "object" && "name" in error2 && error2.name === "ApiError" && error2.status === 401) {
27859
+ const user = await whoami({ workspace: workspaceId });
27860
+ return workspaceUserToGlobalUserInfo(user);
27861
+ }
27862
+ throw error2;
27863
+ }
27864
+ }
27865
+ function workspaceUserToGlobalUserInfo(user) {
27866
+ return {
27867
+ email: user.email,
27868
+ login_type: "password",
27869
+ super_admin: user.is_super_admin,
27870
+ verified: true,
27871
+ name: user.name,
27872
+ username: user.username,
27873
+ operator_only: user.operator,
27874
+ first_time_user: false,
27875
+ role_source: "manual",
27876
+ disabled: user.disabled
27877
+ };
27878
+ }
27826
27879
  async function requireLogin(opts) {
27827
27880
  const { resolveWorkspace: resolveWorkspace2 } = await init_context().then(() => exports_context);
27828
27881
  const workspace = await resolveWorkspace2(opts);
@@ -27832,7 +27885,7 @@ async function requireLogin(opts) {
27832
27885
  }
27833
27886
  setClient(token, workspace.remote.substring(0, workspace.remote.length - 1));
27834
27887
  try {
27835
- return await globalWhoami();
27888
+ return await fetchWhoami(workspace.workspaceId);
27836
27889
  } catch (error2) {
27837
27890
  const errorMsg = error2 instanceof Error ? error2.message : String(error2);
27838
27891
  if (errorMsg.includes("fetch") || errorMsg.includes("connection") || errorMsg.includes("ECONNREFUSED") || errorMsg.includes("refused")) {
@@ -27852,7 +27905,7 @@ async function requireLogin(opts) {
27852
27905
  workspace.token = newToken;
27853
27906
  addWorkspace2(workspace, opts);
27854
27907
  setClient(newToken, workspace.remote.substring(0, workspace.remote.length - 1));
27855
- return await globalWhoami();
27908
+ return await fetchWhoami(workspace.workspaceId);
27856
27909
  }
27857
27910
  }
27858
27911
  var init_auth = __esm(async () => {
@@ -29787,7 +29840,7 @@ var require_stream = __commonJS((exports, module) => {
29787
29840
  if (!duplex.push(data3))
29788
29841
  ws.pause();
29789
29842
  });
29790
- ws.once("error", function error(err) {
29843
+ ws.once("error", function error2(err) {
29791
29844
  if (duplex.destroyed)
29792
29845
  return;
29793
29846
  terminateOnDestroy = false;
@@ -29805,7 +29858,7 @@ var require_stream = __commonJS((exports, module) => {
29805
29858
  return;
29806
29859
  }
29807
29860
  let called = false;
29808
- ws.once("error", function error(err2) {
29861
+ ws.once("error", function error2(err2) {
29809
29862
  called = true;
29810
29863
  callback(err2);
29811
29864
  });
@@ -34768,7 +34821,7 @@ var require_BufferList = __commonJS((exports, module) => {
34768
34821
  this.tail = null;
34769
34822
  this.length = 0;
34770
34823
  }
34771
- BufferList.prototype.push = function push(v) {
34824
+ BufferList.prototype.push = function push2(v) {
34772
34825
  var entry = { data: v, next: null };
34773
34826
  if (this.length > 0)
34774
34827
  this.tail.next = entry;
@@ -34799,7 +34852,7 @@ var require_BufferList = __commonJS((exports, module) => {
34799
34852
  this.head = this.tail = null;
34800
34853
  this.length = 0;
34801
34854
  };
34802
- BufferList.prototype.join = function join(s) {
34855
+ BufferList.prototype.join = function join9(s) {
34803
34856
  if (this.length === 0)
34804
34857
  return "";
34805
34858
  var p = this.head;
@@ -36734,7 +36787,7 @@ var require_nodejsUtils = __commonJS((exports, module) => {
36734
36787
 
36735
36788
  // node_modules/set-immediate-shim/index.js
36736
36789
  var require_set_immediate_shim = __commonJS((exports, module) => {
36737
- module.exports = typeof setImmediate === "function" ? setImmediate : function setImmediate() {
36790
+ module.exports = typeof setImmediate === "function" ? setImmediate : function setImmediate2() {
36738
36791
  var args = [].slice.apply(arguments);
36739
36792
  args.splice(1, 0, 0);
36740
36793
  setTimeout.apply(null, args);
@@ -45089,7 +45142,7 @@ var require_headers = __commonJS((exports) => {
45089
45142
  }
45090
45143
  return result;
45091
45144
  };
45092
- exports.encode = function encode(opts) {
45145
+ exports.encode = function encode2(opts) {
45093
45146
  const buf = b4a.alloc(512);
45094
45147
  let name = opts.name;
45095
45148
  let prefix = "";
@@ -45130,7 +45183,7 @@ var require_headers = __commonJS((exports) => {
45130
45183
  b4a.write(buf, encodeOct(cksum(buf), 6), 148);
45131
45184
  return buf;
45132
45185
  };
45133
- exports.decode = function decode(buf, filenameEncoding, allowUnknownFormat) {
45186
+ exports.decode = function decode2(buf, filenameEncoding, allowUnknownFormat) {
45134
45187
  let typeflag = buf[156] === 0 ? 0 : buf[156] - ZERO_OFFSET;
45135
45188
  let name = decodeStr(buf, 0, 100, filenameEncoding);
45136
45189
  const mode = decodeOct(buf, 100, 8);
@@ -48041,7 +48094,7 @@ var require_subschema = __commonJS((exports) => {
48041
48094
 
48042
48095
  // node_modules/fast-deep-equal/index.js
48043
48096
  var require_fast_deep_equal = __commonJS((exports, module) => {
48044
- module.exports = function equal(a, b) {
48097
+ module.exports = function equal2(a, b) {
48045
48098
  if (a === b)
48046
48099
  return true;
48047
48100
  if (a && b && typeof a == "object" && typeof b == "object") {
@@ -48053,7 +48106,7 @@ var require_fast_deep_equal = __commonJS((exports, module) => {
48053
48106
  if (length != b.length)
48054
48107
  return false;
48055
48108
  for (i = length;i-- !== 0; )
48056
- if (!equal(a[i], b[i]))
48109
+ if (!equal2(a[i], b[i]))
48057
48110
  return false;
48058
48111
  return true;
48059
48112
  }
@@ -48072,7 +48125,7 @@ var require_fast_deep_equal = __commonJS((exports, module) => {
48072
48125
  return false;
48073
48126
  for (i = length;i-- !== 0; ) {
48074
48127
  var key = keys[i];
48075
- if (!equal(a[key], b[key]))
48128
+ if (!equal2(a[key], b[key]))
48076
48129
  return false;
48077
48130
  }
48078
48131
  return true;
@@ -73944,6 +73997,277 @@ var init_gitsync_settings = __esm(async () => {
73944
73997
  gitsync_settings_default = command22;
73945
73998
  });
73946
73999
 
74000
+ // src/utils/dependency_tree.ts
74001
+ async function uploadScripts(tree, workspace) {
74002
+ const scriptHashes = {};
74003
+ const workspaceDeps = [];
74004
+ for (const path19 of tree.allPaths()) {
74005
+ const content = tree.getContent(path19);
74006
+ const itemType = tree.getItemType(path19);
74007
+ if (itemType === "dependencies") {
74008
+ if (content === undefined)
74009
+ continue;
74010
+ const info2 = workspaceDependenciesPathToLanguageAndFilename(path19);
74011
+ if (info2) {
74012
+ const hash2 = await generateHash(content);
74013
+ workspaceDeps.push({ path: path19, language: info2.language, name: info2.name, hash: hash2 });
74014
+ }
74015
+ } else if (itemType === "script") {
74016
+ if (!content)
74017
+ continue;
74018
+ const hash2 = await generateHash(content);
74019
+ scriptHashes[path19] = hash2;
74020
+ }
74021
+ }
74022
+ if (Object.keys(scriptHashes).length === 0 && workspaceDeps.length === 0)
74023
+ return;
74024
+ const mismatched = await diffRawScriptsWithDeployed({
74025
+ workspace: workspace.workspaceId,
74026
+ requestBody: {
74027
+ scripts: scriptHashes,
74028
+ workspace_deps: workspaceDeps
74029
+ }
74030
+ });
74031
+ for (const path19 of mismatched) {
74032
+ const content = tree.getContent(path19);
74033
+ const itemType = tree.getItemType(path19);
74034
+ if (itemType === "dependencies") {
74035
+ if (content !== undefined) {
74036
+ tree.setContentHash(path19, "mismatched");
74037
+ }
74038
+ } else if (content) {
74039
+ const hash2 = await storeRawScriptTemp({
74040
+ workspace: workspace.workspaceId,
74041
+ requestBody: content
74042
+ });
74043
+ tree.setContentHash(path19, hash2);
74044
+ }
74045
+ }
74046
+ }
74047
+
74048
+ class DoubleLinkedDependencyTree {
74049
+ nodes = new Map;
74050
+ workspaceDeps = {};
74051
+ setWorkspaceDeps(deps) {
74052
+ this.workspaceDeps = deps;
74053
+ }
74054
+ async addNode(path19, content, language, metadata, imports, itemType, folder, originalPath, isDirectlyStale, isRawApp) {
74055
+ const hasWorkspaceDeps = itemType === "script" || itemType === "inline_script";
74056
+ const filteredDeps = hasWorkspaceDeps ? filterWorkspaceDependencies(this.workspaceDeps, content, language) : {};
74057
+ const stalenessHash = await generateScriptHash({}, content, metadata);
74058
+ if (!this.nodes.has(path19)) {
74059
+ this.nodes.set(path19, {
74060
+ content: "",
74061
+ stalenessHash: "",
74062
+ language: "deno",
74063
+ metadata: "",
74064
+ imports: new Set,
74065
+ importedBy: new Set,
74066
+ itemType: "script",
74067
+ folder: "",
74068
+ originalPath: "",
74069
+ isDirectlyStale: false
74070
+ });
74071
+ }
74072
+ const node = this.nodes.get(path19);
74073
+ node.content = content;
74074
+ node.stalenessHash = stalenessHash;
74075
+ node.language = language;
74076
+ node.metadata = metadata;
74077
+ node.itemType = itemType;
74078
+ node.folder = folder;
74079
+ node.originalPath = originalPath;
74080
+ node.isDirectlyStale = isDirectlyStale;
74081
+ node.isRawApp = isRawApp;
74082
+ const filteredDepsPaths = Object.keys(filteredDeps);
74083
+ for (const depsPath of filteredDepsPaths) {
74084
+ if (!this.nodes.has(depsPath)) {
74085
+ const depsInfo = workspaceDependenciesPathToLanguageAndFilename(depsPath);
74086
+ const contentHash = await generateHash(filteredDeps[depsPath] + depsPath);
74087
+ const isUpToDate = await checkifMetadataUptodate(depsPath, contentHash, undefined);
74088
+ this.nodes.set(depsPath, {
74089
+ content: filteredDeps[depsPath],
74090
+ stalenessHash: "",
74091
+ language: depsInfo?.language ?? "deno",
74092
+ metadata: "",
74093
+ imports: new Set,
74094
+ importedBy: new Set,
74095
+ itemType: "dependencies",
74096
+ folder: "",
74097
+ originalPath: depsPath,
74098
+ isDirectlyStale: !isUpToDate
74099
+ });
74100
+ }
74101
+ }
74102
+ const allImports = [...imports, ...filteredDepsPaths];
74103
+ for (const importPath of allImports) {
74104
+ node.imports.add(importPath);
74105
+ if (!this.nodes.has(importPath)) {
74106
+ this.nodes.set(importPath, {
74107
+ content: "",
74108
+ stalenessHash: "",
74109
+ language: "deno",
74110
+ metadata: "",
74111
+ imports: new Set,
74112
+ importedBy: new Set,
74113
+ itemType: "script",
74114
+ folder: "",
74115
+ originalPath: "",
74116
+ isDirectlyStale: false
74117
+ });
74118
+ }
74119
+ this.nodes.get(importPath).importedBy.add(path19);
74120
+ }
74121
+ }
74122
+ getContent(path19) {
74123
+ return this.nodes.get(path19)?.content;
74124
+ }
74125
+ getStalenessHash(path19) {
74126
+ return this.nodes.get(path19)?.stalenessHash;
74127
+ }
74128
+ getContentHash(path19) {
74129
+ return this.nodes.get(path19)?.contentHash;
74130
+ }
74131
+ setContentHash(path19, hash2) {
74132
+ const node = this.nodes.get(path19);
74133
+ if (node) {
74134
+ node.contentHash = hash2;
74135
+ }
74136
+ }
74137
+ getLanguage(path19) {
74138
+ return this.nodes.get(path19)?.language;
74139
+ }
74140
+ getMetadata(path19) {
74141
+ return this.nodes.get(path19)?.metadata;
74142
+ }
74143
+ getStaleReason(path19) {
74144
+ return this.nodes.get(path19)?.staleReason;
74145
+ }
74146
+ getItemType(path19) {
74147
+ return this.nodes.get(path19)?.itemType;
74148
+ }
74149
+ getFolder(path19) {
74150
+ return this.nodes.get(path19)?.folder;
74151
+ }
74152
+ getIsRawApp(path19) {
74153
+ return this.nodes.get(path19)?.isRawApp;
74154
+ }
74155
+ getIsDirectlyStale(path19) {
74156
+ return this.nodes.get(path19)?.isDirectlyStale ?? false;
74157
+ }
74158
+ getOriginalPath(path19) {
74159
+ return this.nodes.get(path19)?.originalPath;
74160
+ }
74161
+ getImports(path19) {
74162
+ return this.nodes.get(path19)?.imports;
74163
+ }
74164
+ isStale(path19) {
74165
+ return this.nodes.get(path19)?.staleReason !== undefined;
74166
+ }
74167
+ propagateStaleness() {
74168
+ const directlyStale = new Set;
74169
+ for (const [path19, node] of this.nodes.entries()) {
74170
+ if (node.isDirectlyStale) {
74171
+ directlyStale.add(path19);
74172
+ node.staleReason = "content changed";
74173
+ }
74174
+ }
74175
+ const allStale = new Set(directlyStale);
74176
+ const queue = [...directlyStale];
74177
+ const visited = new Set;
74178
+ while (queue.length > 0) {
74179
+ const scriptPath = queue.shift();
74180
+ if (visited.has(scriptPath))
74181
+ continue;
74182
+ visited.add(scriptPath);
74183
+ const node = this.nodes.get(scriptPath);
74184
+ if (!node)
74185
+ continue;
74186
+ for (const importer of node.importedBy) {
74187
+ if (!allStale.has(importer)) {
74188
+ allStale.add(importer);
74189
+ queue.push(importer);
74190
+ const importerNode = this.nodes.get(importer);
74191
+ if (importerNode)
74192
+ importerNode.staleReason = `depends on ${scriptPath}`;
74193
+ }
74194
+ }
74195
+ }
74196
+ }
74197
+ traverseTransitive(scriptPath, callback) {
74198
+ const queue = [scriptPath];
74199
+ const visited = new Set;
74200
+ while (queue.length > 0) {
74201
+ const current = queue.shift();
74202
+ if (visited.has(current))
74203
+ continue;
74204
+ visited.add(current);
74205
+ const node = this.nodes.get(current);
74206
+ if (!node)
74207
+ continue;
74208
+ for (const importPath of node.imports) {
74209
+ const importNode = this.nodes.get(importPath);
74210
+ if (importNode) {
74211
+ const stop = callback(importPath, importNode);
74212
+ if (!stop) {
74213
+ queue.push(importPath);
74214
+ }
74215
+ }
74216
+ }
74217
+ }
74218
+ }
74219
+ allPaths() {
74220
+ return this.nodes.keys();
74221
+ }
74222
+ *stalePaths() {
74223
+ for (const [path19, node] of this.nodes.entries()) {
74224
+ if (node.staleReason) {
74225
+ yield path19;
74226
+ }
74227
+ }
74228
+ }
74229
+ has(path19) {
74230
+ return this.nodes.has(path19);
74231
+ }
74232
+ getMismatchedWorkspaceDeps() {
74233
+ const result2 = {};
74234
+ for (const [path19, node] of this.nodes.entries()) {
74235
+ if (node.itemType === "dependencies" && node.contentHash && node.content !== undefined) {
74236
+ result2[path19] = node.content;
74237
+ }
74238
+ }
74239
+ return result2;
74240
+ }
74241
+ getTempScriptRefs(scriptPath) {
74242
+ const result2 = {};
74243
+ this.traverseTransitive(scriptPath, (_path, node) => {
74244
+ if (node.contentHash) {
74245
+ result2[_path] = node.contentHash;
74246
+ }
74247
+ });
74248
+ return result2;
74249
+ }
74250
+ async persistDepsHashes(depsPaths) {
74251
+ for (const path19 of depsPaths) {
74252
+ const node = this.nodes.get(path19);
74253
+ if (node?.itemType === "dependencies" && node.content !== undefined) {
74254
+ const hash2 = await generateHash(node.content + path19);
74255
+ await updateMetadataGlobalLock(path19, hash2);
74256
+ }
74257
+ }
74258
+ }
74259
+ get size() {
74260
+ return this.nodes.size;
74261
+ }
74262
+ }
74263
+ var init_dependency_tree = __esm(async () => {
74264
+ init_services_gen();
74265
+ await __promiseAll([
74266
+ init_metadata(),
74267
+ init_utils()
74268
+ ]);
74269
+ });
74270
+
73947
74271
  // src/main.ts
73948
74272
  init_mod3();
73949
74273
 
@@ -83774,280 +84098,10 @@ await __promiseAll([
83774
84098
  init_app_metadata(),
83775
84099
  init_sync(),
83776
84100
  init_script(),
83777
- init_codebase()
84101
+ init_codebase(),
84102
+ init_dependency_tree()
83778
84103
  ]);
83779
84104
  import { sep as SEP21 } from "node:path";
83780
-
83781
- // src/utils/dependency_tree.ts
83782
- init_services_gen();
83783
- await __promiseAll([
83784
- init_metadata(),
83785
- init_utils()
83786
- ]);
83787
- async function uploadScripts(tree, workspace) {
83788
- const scriptHashes = {};
83789
- const workspaceDeps = [];
83790
- for (const path19 of tree.allPaths()) {
83791
- const content = tree.getContent(path19);
83792
- const itemType = tree.getItemType(path19);
83793
- if (itemType === "dependencies") {
83794
- if (content === undefined)
83795
- continue;
83796
- const info2 = workspaceDependenciesPathToLanguageAndFilename(path19);
83797
- if (info2) {
83798
- const hash2 = await generateHash(content);
83799
- workspaceDeps.push({ path: path19, language: info2.language, name: info2.name, hash: hash2 });
83800
- }
83801
- } else if (itemType === "script") {
83802
- if (!content)
83803
- continue;
83804
- const hash2 = await generateHash(content);
83805
- scriptHashes[path19] = hash2;
83806
- }
83807
- }
83808
- if (Object.keys(scriptHashes).length === 0 && workspaceDeps.length === 0)
83809
- return;
83810
- const mismatched = await diffRawScriptsWithDeployed({
83811
- workspace: workspace.workspaceId,
83812
- requestBody: {
83813
- scripts: scriptHashes,
83814
- workspace_deps: workspaceDeps
83815
- }
83816
- });
83817
- for (const path19 of mismatched) {
83818
- const content = tree.getContent(path19);
83819
- const itemType = tree.getItemType(path19);
83820
- if (itemType === "dependencies") {
83821
- if (content !== undefined) {
83822
- tree.setContentHash(path19, "mismatched");
83823
- }
83824
- } else if (content) {
83825
- const hash2 = await storeRawScriptTemp({
83826
- workspace: workspace.workspaceId,
83827
- requestBody: content
83828
- });
83829
- tree.setContentHash(path19, hash2);
83830
- }
83831
- }
83832
- }
83833
-
83834
- class DoubleLinkedDependencyTree {
83835
- nodes = new Map;
83836
- workspaceDeps = {};
83837
- setWorkspaceDeps(deps) {
83838
- this.workspaceDeps = deps;
83839
- }
83840
- async addNode(path19, content, language, metadata, imports, itemType, folder, originalPath, isDirectlyStale, isRawApp) {
83841
- const hasWorkspaceDeps = itemType === "script" || itemType === "inline_script";
83842
- const filteredDeps = hasWorkspaceDeps ? filterWorkspaceDependencies(this.workspaceDeps, content, language) : {};
83843
- const stalenessHash = await generateScriptHash({}, content, metadata);
83844
- if (!this.nodes.has(path19)) {
83845
- this.nodes.set(path19, {
83846
- content: "",
83847
- stalenessHash: "",
83848
- language: "deno",
83849
- metadata: "",
83850
- imports: new Set,
83851
- importedBy: new Set,
83852
- itemType: "script",
83853
- folder: "",
83854
- originalPath: "",
83855
- isDirectlyStale: false
83856
- });
83857
- }
83858
- const node = this.nodes.get(path19);
83859
- node.content = content;
83860
- node.stalenessHash = stalenessHash;
83861
- node.language = language;
83862
- node.metadata = metadata;
83863
- node.itemType = itemType;
83864
- node.folder = folder;
83865
- node.originalPath = originalPath;
83866
- node.isDirectlyStale = isDirectlyStale;
83867
- node.isRawApp = isRawApp;
83868
- const filteredDepsPaths = Object.keys(filteredDeps);
83869
- for (const depsPath of filteredDepsPaths) {
83870
- if (!this.nodes.has(depsPath)) {
83871
- const depsInfo = workspaceDependenciesPathToLanguageAndFilename(depsPath);
83872
- const contentHash = await generateHash(filteredDeps[depsPath] + depsPath);
83873
- const isUpToDate = await checkifMetadataUptodate(depsPath, contentHash, undefined);
83874
- this.nodes.set(depsPath, {
83875
- content: filteredDeps[depsPath],
83876
- stalenessHash: "",
83877
- language: depsInfo?.language ?? "deno",
83878
- metadata: "",
83879
- imports: new Set,
83880
- importedBy: new Set,
83881
- itemType: "dependencies",
83882
- folder: "",
83883
- originalPath: depsPath,
83884
- isDirectlyStale: !isUpToDate
83885
- });
83886
- }
83887
- }
83888
- const allImports = [...imports, ...filteredDepsPaths];
83889
- for (const importPath of allImports) {
83890
- node.imports.add(importPath);
83891
- if (!this.nodes.has(importPath)) {
83892
- this.nodes.set(importPath, {
83893
- content: "",
83894
- stalenessHash: "",
83895
- language: "deno",
83896
- metadata: "",
83897
- imports: new Set,
83898
- importedBy: new Set,
83899
- itemType: "script",
83900
- folder: "",
83901
- originalPath: "",
83902
- isDirectlyStale: false
83903
- });
83904
- }
83905
- this.nodes.get(importPath).importedBy.add(path19);
83906
- }
83907
- }
83908
- getContent(path19) {
83909
- return this.nodes.get(path19)?.content;
83910
- }
83911
- getStalenessHash(path19) {
83912
- return this.nodes.get(path19)?.stalenessHash;
83913
- }
83914
- getContentHash(path19) {
83915
- return this.nodes.get(path19)?.contentHash;
83916
- }
83917
- setContentHash(path19, hash2) {
83918
- const node = this.nodes.get(path19);
83919
- if (node) {
83920
- node.contentHash = hash2;
83921
- }
83922
- }
83923
- getLanguage(path19) {
83924
- return this.nodes.get(path19)?.language;
83925
- }
83926
- getMetadata(path19) {
83927
- return this.nodes.get(path19)?.metadata;
83928
- }
83929
- getStaleReason(path19) {
83930
- return this.nodes.get(path19)?.staleReason;
83931
- }
83932
- getItemType(path19) {
83933
- return this.nodes.get(path19)?.itemType;
83934
- }
83935
- getFolder(path19) {
83936
- return this.nodes.get(path19)?.folder;
83937
- }
83938
- getIsRawApp(path19) {
83939
- return this.nodes.get(path19)?.isRawApp;
83940
- }
83941
- getIsDirectlyStale(path19) {
83942
- return this.nodes.get(path19)?.isDirectlyStale ?? false;
83943
- }
83944
- getOriginalPath(path19) {
83945
- return this.nodes.get(path19)?.originalPath;
83946
- }
83947
- getImports(path19) {
83948
- return this.nodes.get(path19)?.imports;
83949
- }
83950
- isStale(path19) {
83951
- return this.nodes.get(path19)?.staleReason !== undefined;
83952
- }
83953
- propagateStaleness() {
83954
- const directlyStale = new Set;
83955
- for (const [path19, node] of this.nodes.entries()) {
83956
- if (node.isDirectlyStale) {
83957
- directlyStale.add(path19);
83958
- node.staleReason = "content changed";
83959
- }
83960
- }
83961
- const allStale = new Set(directlyStale);
83962
- const queue = [...directlyStale];
83963
- const visited = new Set;
83964
- while (queue.length > 0) {
83965
- const scriptPath = queue.shift();
83966
- if (visited.has(scriptPath))
83967
- continue;
83968
- visited.add(scriptPath);
83969
- const node = this.nodes.get(scriptPath);
83970
- if (!node)
83971
- continue;
83972
- for (const importer of node.importedBy) {
83973
- if (!allStale.has(importer)) {
83974
- allStale.add(importer);
83975
- queue.push(importer);
83976
- const importerNode = this.nodes.get(importer);
83977
- if (importerNode)
83978
- importerNode.staleReason = `depends on ${scriptPath}`;
83979
- }
83980
- }
83981
- }
83982
- }
83983
- traverseTransitive(scriptPath, callback) {
83984
- const queue = [scriptPath];
83985
- const visited = new Set;
83986
- while (queue.length > 0) {
83987
- const current = queue.shift();
83988
- if (visited.has(current))
83989
- continue;
83990
- visited.add(current);
83991
- const node = this.nodes.get(current);
83992
- if (!node)
83993
- continue;
83994
- for (const importPath of node.imports) {
83995
- const importNode = this.nodes.get(importPath);
83996
- if (importNode) {
83997
- const stop = callback(importPath, importNode);
83998
- if (!stop) {
83999
- queue.push(importPath);
84000
- }
84001
- }
84002
- }
84003
- }
84004
- }
84005
- allPaths() {
84006
- return this.nodes.keys();
84007
- }
84008
- *stalePaths() {
84009
- for (const [path19, node] of this.nodes.entries()) {
84010
- if (node.staleReason) {
84011
- yield path19;
84012
- }
84013
- }
84014
- }
84015
- has(path19) {
84016
- return this.nodes.has(path19);
84017
- }
84018
- getMismatchedWorkspaceDeps() {
84019
- const result2 = {};
84020
- for (const [path19, node] of this.nodes.entries()) {
84021
- if (node.itemType === "dependencies" && node.contentHash && node.content !== undefined) {
84022
- result2[path19] = node.content;
84023
- }
84024
- }
84025
- return result2;
84026
- }
84027
- getTempScriptRefs(scriptPath) {
84028
- const result2 = {};
84029
- this.traverseTransitive(scriptPath, (_path, node) => {
84030
- if (node.contentHash) {
84031
- result2[_path] = node.contentHash;
84032
- }
84033
- });
84034
- return result2;
84035
- }
84036
- async persistDepsHashes(depsPaths) {
84037
- for (const path19 of depsPaths) {
84038
- const node = this.nodes.get(path19);
84039
- if (node?.itemType === "dependencies" && node.content !== undefined) {
84040
- const hash2 = await generateHash(node.content + path19);
84041
- await updateMetadataGlobalLock(path19, hash2);
84042
- }
84043
- }
84044
- }
84045
- get size() {
84046
- return this.nodes.size;
84047
- }
84048
- }
84049
-
84050
- // src/commands/generate-metadata/generate-metadata.ts
84051
84105
  async function generateMetadata2(opts, folder) {
84052
84106
  if (folder === "") {
84053
84107
  folder = undefined;
@@ -84418,7 +84472,7 @@ var config_default = command35;
84418
84472
 
84419
84473
  // src/main.ts
84420
84474
  await init_context();
84421
- var VERSION = "1.680.0";
84475
+ var VERSION = "1.682.0";
84422
84476
  var command36 = new Command().name("wmill").action(() => info(`Welcome to Windmill CLI ${VERSION}. Use -h for help.`)).description("Windmill CLI").globalOption("--workspace <workspace:string>", "Specify the target workspace. This overrides the default workspace.").globalOption("--debug --verbose", "Show debug/verbose logs").globalOption("--show-diffs", "Show diff informations when syncing (may show sensitive informations)").globalOption("--token <token:string>", "Specify an API token. This will override any stored token.").globalOption("--base-url <baseUrl:string>", "Specify the base URL of the API. If used, --token and --workspace are required and no local remote/workspace already set will be used.").globalOption("--config-dir <configDir:string>", "Specify a custom config directory. Overrides WMILL_CONFIG_DIR environment variable and default ~/.config location.").env("HEADERS <headers:string>", `Specify headers to use for all requests. e.g: "HEADERS='h1: v1, h2: v2'"`).version(VERSION).versionOption(false).command("init", init_default).command("app", app_default).command("flow", flow_default).command("script", script_default).command("workspace", workspace_default).command("resource", resource_default).command("resource-type", resource_type_default).command("user", user_default).command("variable", variable_default).command("hub", hub_default).command("folder", folder_default).command("schedule", schedule_default).command("trigger", trigger_default).command("dev", dev_default2).command("sync", sync_default).command("lint", lint_default).command("gitsync-settings", gitsync_settings_default).command("instance", instance_default).command("worker-groups", worker_groups_default).command("workers", workers_default).command("queues", queues_default).command("dependencies", dependencies_default).command("jobs", jobs_default).command("job", job_default).command("group", group_default).command("audit", audit_default).command("token", token_default).command("generate-metadata", generate_metadata_default).command("docs", docs_default).command("config", config_default).command("version --version", "Show version information").action(async (opts) => {
84423
84477
  console.log("CLI version: " + VERSION);
84424
84478
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windmill-cli",
3
- "version": "1.680.1",
3
+ "version": "1.682.0",
4
4
  "description": "CLI for Windmill",
5
5
  "license": "Apache 2.0",
6
6
  "type": "module",