windmill-cli 1.812.0 → 1.813.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 +139 -47
  2. package/package.json +1 -1
package/esm/main.js CHANGED
@@ -16766,7 +16766,7 @@ var init_OpenAPI = __esm(() => {
16766
16766
  PASSWORD: undefined,
16767
16767
  TOKEN: getEnv3("WM_TOKEN"),
16768
16768
  USERNAME: undefined,
16769
- VERSION: "1.812.0",
16769
+ VERSION: "1.813.0",
16770
16770
  WITH_CREDENTIALS: true,
16771
16771
  interceptors: {
16772
16772
  request: new Interceptors,
@@ -20002,7 +20002,7 @@ var init_auth = __esm(async () => {
20002
20002
  });
20003
20003
 
20004
20004
  // src/core/constants.ts
20005
- var WM_FORK_PREFIX = "wm-fork", VERSION = "1.812.0";
20005
+ var WM_FORK_PREFIX = "wm-fork", VERSION = "1.813.0";
20006
20006
 
20007
20007
  // src/utils/resource_folders.ts
20008
20008
  import { existsSync } from "node:fs";
@@ -56422,7 +56422,7 @@ var init_openflow = __esm(() => {
56422
56422
  openflow_default = {
56423
56423
  openapi: "3.0.3",
56424
56424
  info: {
56425
- version: "1.812.0",
56425
+ version: "1.813.0",
56426
56426
  title: "OpenFlow Spec",
56427
56427
  contact: {
56428
56428
  name: "Ruben Fiszel",
@@ -60841,7 +60841,55 @@ var init_tar = __esm(() => {
60841
60841
  init_tar_stream();
60842
60842
  });
60843
60843
 
60844
+ // src/utils/relative_imports.ts
60845
+ async function extractRelativeImports(code, scriptPath, language) {
60846
+ try {
60847
+ switch (language) {
60848
+ case "bun":
60849
+ case "nativets":
60850
+ case "deno": {
60851
+ const { parse_ts_relative_imports } = await loadParser("windmill-parser-wasm-ts");
60852
+ return parse_ts_relative_imports(code, scriptPath);
60853
+ }
60854
+ case "python3": {
60855
+ const { parse_py_relative_imports } = await loadParser("windmill-parser-wasm-py-imports");
60856
+ return parse_py_relative_imports(code, scriptPath);
60857
+ }
60858
+ default:
60859
+ return [];
60860
+ }
60861
+ } catch (e) {
60862
+ warn(`Failed to parse relative imports for ${scriptPath}: ${e}. Dependency tracking for relative imports will be disabled.`);
60863
+ return [];
60864
+ }
60865
+ }
60866
+ var init_relative_imports = __esm(async () => {
60867
+ init_log();
60868
+ await init_metadata();
60869
+ });
60870
+
60844
60871
  // src/utils/dependency_tree.ts
60872
+ async function resolvePlaceholdersFromLocal(tree, localScripts, defaultTs) {
60873
+ for (;; ) {
60874
+ let resolved = false;
60875
+ for (const remotePath of tree.placeholderPaths()) {
60876
+ const local = localScripts.get(remotePath);
60877
+ if (!local)
60878
+ continue;
60879
+ let language;
60880
+ try {
60881
+ language = inferContentTypeFromFilePath(local.localPath, defaultTs);
60882
+ } catch {
60883
+ continue;
60884
+ }
60885
+ const imports = await extractRelativeImports(local.content, remotePath, language);
60886
+ await tree.addNode(remotePath, local.content, language, "", imports, "script", remotePath, local.localPath, false);
60887
+ resolved = true;
60888
+ }
60889
+ if (!resolved)
60890
+ break;
60891
+ }
60892
+ }
60845
60893
  async function uploadScripts(tree, workspace) {
60846
60894
  const scriptHashes = {};
60847
60895
  const workspaceDeps = [];
@@ -60910,10 +60958,12 @@ class DoubleLinkedDependencyTree {
60910
60958
  itemType: "script",
60911
60959
  folder: "",
60912
60960
  originalPath: "",
60913
- isDirectlyStale: false
60961
+ isDirectlyStale: false,
60962
+ isPlaceholder: true
60914
60963
  });
60915
60964
  }
60916
60965
  const node = this.nodes.get(path);
60966
+ node.isPlaceholder = false;
60917
60967
  node.content = content;
60918
60968
  node.stalenessHash = stalenessHash;
60919
60969
  node.language = language;
@@ -60939,7 +60989,8 @@ class DoubleLinkedDependencyTree {
60939
60989
  itemType: "dependencies",
60940
60990
  folder: "",
60941
60991
  originalPath: depsPath,
60942
- isDirectlyStale: !isUpToDate
60992
+ isDirectlyStale: !isUpToDate,
60993
+ isPlaceholder: false
60943
60994
  });
60944
60995
  }
60945
60996
  }
@@ -60957,7 +61008,8 @@ class DoubleLinkedDependencyTree {
60957
61008
  itemType: "script",
60958
61009
  folder: "",
60959
61010
  originalPath: "",
60960
- isDirectlyStale: false
61011
+ isDirectlyStale: false,
61012
+ isPlaceholder: true
60961
61013
  });
60962
61014
  }
60963
61015
  this.nodes.get(importPath).importedBy.add(path);
@@ -61063,6 +61115,14 @@ class DoubleLinkedDependencyTree {
61063
61115
  allPaths() {
61064
61116
  return this.nodes.keys();
61065
61117
  }
61118
+ placeholderPaths() {
61119
+ const result = [];
61120
+ for (const [path, node] of this.nodes.entries()) {
61121
+ if (node.isPlaceholder)
61122
+ result.push(path);
61123
+ }
61124
+ return result;
61125
+ }
61066
61126
  *stalePaths() {
61067
61127
  for (const [path, node] of this.nodes.entries()) {
61068
61128
  if (node.staleReason) {
@@ -61116,38 +61176,13 @@ class DoubleLinkedDependencyTree {
61116
61176
  var init_dependency_tree = __esm(async () => {
61117
61177
  init_services_gen();
61118
61178
  await __promiseAll([
61179
+ init_script_common(),
61119
61180
  init_metadata(),
61120
- init_utils()
61181
+ init_utils(),
61182
+ init_relative_imports()
61121
61183
  ]);
61122
61184
  });
61123
61185
 
61124
- // src/utils/relative_imports.ts
61125
- async function extractRelativeImports(code, scriptPath, language) {
61126
- try {
61127
- switch (language) {
61128
- case "bun":
61129
- case "nativets":
61130
- case "deno": {
61131
- const { parse_ts_relative_imports } = await loadParser("windmill-parser-wasm-ts");
61132
- return parse_ts_relative_imports(code, scriptPath);
61133
- }
61134
- case "python3": {
61135
- const { parse_py_relative_imports } = await loadParser("windmill-parser-wasm-py-imports");
61136
- return parse_py_relative_imports(code, scriptPath);
61137
- }
61138
- default:
61139
- return [];
61140
- }
61141
- } catch (e) {
61142
- warn(`Failed to parse relative imports for ${scriptPath}: ${e}. Dependency tracking for relative imports will be disabled.`);
61143
- return [];
61144
- }
61145
- }
61146
- var init_relative_imports = __esm(async () => {
61147
- init_log();
61148
- await init_metadata();
61149
- });
61150
-
61151
61186
  // windmill-utils-internal/src/path-utils/path-assigner.ts
61152
61187
  function getLanguageExtension(language, defaultTs = "bun") {
61153
61188
  if (language === defaultTs || language === "bunnative") {
@@ -66265,6 +66300,14 @@ function preservePendingScriptLocks(remote, local) {
66265
66300
  remote[lockKey] = local[lockKey];
66266
66301
  }
66267
66302
  }
66303
+ function stripUnappliedSettingsFields(local, remote) {
66304
+ delete local?.name;
66305
+ delete remote?.name;
66306
+ if (local?.color == null) {
66307
+ delete local?.color;
66308
+ delete remote?.color;
66309
+ }
66310
+ }
66268
66311
  async function compareDynFSElement(els1, els2, ignore, json, skips, ignoreMetadataDeletion, codebases, ignoreCodebaseChanges, specificItems, branchOverride, isEls1Remote, caseInsensitiveFs, parentOwnsScheduleEnabled) {
66269
66312
  let [m1, m2] = els2 ? await Promise.all([
66270
66313
  elementsToMap(els1, ignore, json, skips, specificItems, branchOverride, isEls1Remote),
@@ -66380,6 +66423,9 @@ async function compareDynFSElement(els1, els2, ignore, json, skips, ignoreMetada
66380
66423
  delete parsedV?.enabled;
66381
66424
  delete parsedM2?.enabled;
66382
66425
  }
66426
+ if (isEls1Remote === false && isWorkspaceSettingsFile(k)) {
66427
+ stripUnappliedSettingsFields(parsedV, parsedM2);
66428
+ }
66383
66429
  if (deepEqual(parsedV, parsedM2)) {
66384
66430
  continue;
66385
66431
  }
@@ -66390,6 +66436,9 @@ async function compareDynFSElement(els1, els2, ignore, json, skips, ignoreMetada
66390
66436
  delete before?.enabled;
66391
66437
  delete after?.enabled;
66392
66438
  }
66439
+ if (isEls1Remote === false && isWorkspaceSettingsFile(k)) {
66440
+ stripUnappliedSettingsFields(after, before);
66441
+ }
66393
66442
  if (deepEqual(before, after)) {
66394
66443
  continue;
66395
66444
  }
@@ -66696,6 +66745,19 @@ async function addToChangedIfNotExists(p, tracker) {
66696
66745
  } catch {}
66697
66746
  }
66698
66747
  }
66748
+ function localScriptsByRemotePath(localMap) {
66749
+ const byRemotePath = new Map;
66750
+ for (const [p, content] of Object.entries(localMap)) {
66751
+ if (isScriptModulePath(p)) {
66752
+ if (!isModuleEntryPoint(p))
66753
+ continue;
66754
+ } else if (!hasScriptExt(p) || isDatatableMigrationPath(p) || isFileResource(p) || isFilesetResource(p) || isFlowPath(p) || isAppPath(p) || isRawAppPath(p)) {
66755
+ continue;
66756
+ }
66757
+ byRemotePath.set(scriptPathToRemotePath(p), { localPath: p, content });
66758
+ }
66759
+ return byRemotePath;
66760
+ }
66699
66761
  async function buildTracker(changes) {
66700
66762
  const tracker = {
66701
66763
  scripts: [],
@@ -67478,6 +67540,7 @@ Push aborted: ${lockIssues.length} script(s) missing locks.`));
67478
67540
  }
67479
67541
  }
67480
67542
  if (autoRegenerate && tree) {
67543
+ await resolvePlaceholdersFromLocal(tree, localScriptsByRemotePath(localMap), opts.defaultTs);
67481
67544
  tree.propagateStaleness();
67482
67545
  try {
67483
67546
  await uploadScripts(tree, workspace);
@@ -68436,7 +68499,7 @@ Done! All ${changes.length} changes pushed to the remote workspace ${workspace.w
68436
68499
  }
68437
68500
  }
68438
68501
  }
68439
- var import_yaml14, branchDeprecationWarned = false, yamlOptions, _caseInsensitiveFsCache, isNotWmillFile = (p, isDirectory) => {
68502
+ var import_yaml14, branchDeprecationWarned = false, yamlOptions, _caseInsensitiveFsCache, isWorkspaceSettingsFile = (p) => /^settings(\.[^./\\]+)?\.(yaml|json)$/.test(p), isNotWmillFile = (p, isDirectory) => {
68440
68503
  if (p.endsWith(SEP9)) {
68441
68504
  return false;
68442
68505
  }
@@ -74259,6 +74322,11 @@ async function pushWorkspaceSettings(workspace, _path, settings, localSettings)
74259
74322
  }
74260
74323
  const { slack_team_id: _lst, slack_name: _lsn, name: _ln, ...comparableLocal } = localSettings;
74261
74324
  const { slack_team_id: _rst, slack_name: _rsn, name: _rn, ...comparableRemote } = settings;
74325
+ const colorManaged = localSettings.color != null;
74326
+ if (!colorManaged) {
74327
+ delete comparableLocal.color;
74328
+ delete comparableRemote.color;
74329
+ }
74262
74330
  if (isSuperset(comparableLocal, comparableRemote)) {
74263
74331
  debug(`Workspace settings are up to date`);
74264
74332
  return;
@@ -74374,7 +74442,7 @@ async function pushWorkspaceSettings(workspace, _path, settings, localSettings)
74374
74442
  }
74375
74443
  });
74376
74444
  }
74377
- if (localSettings.color != settings.color) {
74445
+ if (colorManaged && localSettings.color != settings.color) {
74378
74446
  debug(`Updating workspace color...`);
74379
74447
  await changeWorkspaceColor({
74380
74448
  workspace,
@@ -83146,6 +83214,14 @@ def parse_sql_client_name(name: str) -> tuple[str, Optional[str]]
83146
83214
  # it grows with both the width of the fan-out and \`\`attempts\`\`. Retries with
83147
83215
  # no \`\`delay\`\` all go out in a single round.
83148
83216
  #
83217
+ # \`\`cache_ttl\`\` serves a previous result of the task for that many seconds
83218
+ # instead of running it again. A task is keyed on its step key (its name and
83219
+ # call order) and the workflow's input, not on the arguments it is called
83220
+ # with, so cache one only when whether it runs, and what it receives, follow
83221
+ # from the workflow's input alone. A \`\`task_script\`\` target is keyed on the
83222
+ # arguments it is called with. It has no effect on a \`\`task_flow\`\` target,
83223
+ # which keeps its flow's own cache policy.
83224
+ #
83149
83225
  # Usage::
83150
83226
  #
83151
83227
  # @task
@@ -84550,8 +84626,8 @@ export async function main(user_id: string) {
84550
84626
  const users = await sql\`SELECT * FROM users WHERE active = \${true}\`.fetch();
84551
84627
 
84552
84628
  // Insert/Update
84553
- await sql\`INSERT INTO users (name, email) VALUES (\${name}, \${email})\`;
84554
- await sql\`UPDATE users SET name = \${newName} WHERE id = \${user_id}\`;
84629
+ await sql\`INSERT INTO users (name, email) VALUES (\${name}, \${email})\`.execute();
84630
+ await sql\`UPDATE users SET name = \${newName} WHERE id = \${user_id}\`.execute();
84555
84631
 
84556
84632
  return user;
84557
84633
  }
@@ -84570,8 +84646,8 @@ def main(user_id: str):
84570
84646
  users = db.query('SELECT * FROM users WHERE active = $1', True).fetch()
84571
84647
 
84572
84648
  # Insert/Update
84573
- db.query('INSERT INTO users (name, email) VALUES ($1, $2)', name, email)
84574
- db.query('UPDATE users SET name = $1 WHERE id = $2', new_name, user_id)
84649
+ db.query('INSERT INTO users (name, email) VALUES ($1, $2)', name, email).execute()
84650
+ db.query('UPDATE users SET name = $1 WHERE id = $2', new_name, user_id).execute()
84575
84651
 
84576
84652
  return user
84577
84653
  \`\`\`
@@ -84580,13 +84656,14 @@ def main(user_id: str):
84580
84656
 
84581
84657
  1. **Check existing tables** before creating new ones — reuse beats schema growth.
84582
84658
  2. **Use parameterized queries** — never concatenate user input into SQL.
84583
- 3. **Keep runnables focused** — one function per runnable; small surface area.
84584
- 4. **Use descriptive keys** — \`get_user\`, not \`a\`.
84585
- 5. **Always whitelist tables** — adding a runnable that queries a new table requires the table to be in \`data.tables\` first.
84586
- 6. **Mark sensitive UI with \`data-wm-no-record\`** — it is what keeps that data out of a recorded demo; passwords are handled for you.
84587
- 7. **Reach for \`backendAsync\` + \`waitJob\`** for long work — never a hand-written job-polling runnable.
84588
- 8. **Deploy what a path runnable points at** — a path runnable aimed at a draft fails at runtime; tell the user what needs deploying.
84589
- 9. **Use \`windmill-chat\` for a chat over a chat-mode flow** — never a runnable that runs the flow and polls its stream.
84659
+ 3. **Terminate every datatable statement** — the tagged template and \`db.query(...)\` only build a statement. It runs when you call \`fetch\` / \`fetchOne\` / \`fetchOneScalar\` / \`execute\` (\`fetch\` / \`fetch_one\` / \`fetch_one_scalar\` / \`execute\` in Python). An INSERT or UPDATE without one writes nothing and raises nothing. Awaiting the statement itself is a no-op — it is not a promise.
84660
+ 4. **Keep runnables focused** — one function per runnable; small surface area.
84661
+ 5. **Use descriptive keys** — \`get_user\`, not \`a\`.
84662
+ 6. **Always whitelist tables** — adding a runnable that queries a new table requires the table to be in \`data.tables\` first.
84663
+ 7. **Mark sensitive UI with \`data-wm-no-record\`** — it is what keeps that data out of a recorded demo; passwords are handled for you.
84664
+ 8. **Reach for \`backendAsync\` + \`waitJob\`** for long work — never a hand-written job-polling runnable.
84665
+ 9. **Deploy what a path runnable points at** — a path runnable aimed at a draft fails at runtime; tell the user what needs deploying.
84666
+ 10. **Use \`windmill-chat\` for a chat over a chat-mode flow** — never a runnable that runs the flow and polls its stream.
84590
84667
  `,
84591
84668
  triggers: `---
84592
84669
  name: triggers
@@ -85279,6 +85356,13 @@ export interface TaskRetry {
85279
85356
  export interface TaskOptions {
85280
85357
  timeout?: number;
85281
85358
  tag?: string;
85359
+ /** Seconds during which a previous result of this task is served instead of
85360
+ * running it again. A task written inline in the workflow is keyed on its
85361
+ * step key (its name and call order) and the workflow's input, not on the
85362
+ * arguments it is called with, so cache one only when whether it runs, and
85363
+ * what it receives, follow from the workflow's input alone. A \`taskScript\`
85364
+ * target is keyed on the arguments it is called with. It has no effect on a
85365
+ * \`taskFlow\` target, which keeps its flow's own cache policy. */
85282
85366
  cache_ttl?: number;
85283
85367
  priority?: number;
85284
85368
  concurrency_limit?: number;
@@ -85470,6 +85554,14 @@ def get_resume_urls(approver: str = None, flow_level: bool = None) -> dict
85470
85554
  # it grows with both the width of the fan-out and \`\`attempts\`\`. Retries with
85471
85555
  # no \`\`delay\`\` all go out in a single round.
85472
85556
  #
85557
+ # \`\`cache_ttl\`\` serves a previous result of the task for that many seconds
85558
+ # instead of running it again. A task is keyed on its step key (its name and
85559
+ # call order) and the workflow's input, not on the arguments it is called
85560
+ # with, so cache one only when whether it runs, and what it receives, follow
85561
+ # from the workflow's input alone. A \`\`task_script\`\` target is keyed on the
85562
+ # arguments it is called with. It has no effect on a \`\`task_flow\`\` target,
85563
+ # which keeps its flow's own cache policy.
85564
+ #
85473
85565
  # Usage::
85474
85566
  #
85475
85567
  # @task
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windmill-cli",
3
- "version": "1.812.0",
3
+ "version": "1.813.0",
4
4
  "description": "CLI for Windmill",
5
5
  "license": "Apache 2.0",
6
6
  "type": "module",