windmill-cli 1.835.0 → 1.837.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 +315 -73
  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.835.0",
16769
+ VERSION: "1.837.0",
16770
16770
  WITH_CREDENTIALS: true,
16771
16771
  interceptors: {
16772
16772
  request: new Interceptors,
@@ -20074,7 +20074,7 @@ var init_auth = __esm(async () => {
20074
20074
  });
20075
20075
 
20076
20076
  // src/core/constants.ts
20077
- var WM_FORK_PREFIX = "wm-fork", VERSION = "1.835.0";
20077
+ var WM_FORK_PREFIX = "wm-fork", VERSION = "1.837.0";
20078
20078
 
20079
20079
  // src/utils/resource_folders.ts
20080
20080
  import { existsSync } from "node:fs";
@@ -20867,9 +20867,9 @@ function gitSyncIncludePattern(pathType, path) {
20867
20867
  case "flow":
20868
20868
  return `${path}.flow/*,${path}__flow/*`;
20869
20869
  case "app":
20870
- return `${path}.app/*,${path}__app/*`;
20870
+ return `${path}.app/*,${path}__app/*,${path}.custom_path.*,${path}.*.custom_path.*`;
20871
20871
  case "raw_app":
20872
- return `${path}.raw_app/**,${path}__raw_app/**`;
20872
+ return `${path}.raw_app/**,${path}__raw_app/**,${path}.custom_path.*,${path}.*.custom_path.*`;
20873
20873
  case "folder":
20874
20874
  return `${path}/folder.meta.*`;
20875
20875
  case "resourcetype":
@@ -22132,15 +22132,23 @@ async function deployItem(provider, kind, path, workspaceFrom, workspaceTo, onBe
22132
22132
  workspace: workspaceFrom,
22133
22133
  path
22134
22134
  });
22135
+ let value = resource.value ?? "";
22136
+ const agent = resource.resource_type === "ai_agent" && typeof value === "object";
22137
+ if (agent) {
22138
+ const { on_behalf_of: _, ...rest } = value;
22139
+ value = onBehalfOf ? { ...rest, on_behalf_of: onBehalfOf } : rest;
22140
+ }
22141
+ const agentPreserve = agent ? { preserve_on_behalf_of: preserveOnBehalfOf } : {};
22135
22142
  if (alreadyExists) {
22136
22143
  await provider.updateResource({
22137
22144
  workspace: workspaceTo,
22138
22145
  path,
22139
22146
  requestBody: {
22140
22147
  path,
22141
- value: resource.value ?? "",
22148
+ value,
22142
22149
  description: resource.description ?? "",
22143
- labels: resource.labels
22150
+ labels: resource.labels,
22151
+ ...agentPreserve
22144
22152
  }
22145
22153
  });
22146
22154
  } else {
@@ -22148,10 +22156,11 @@ async function deployItem(provider, kind, path, workspaceFrom, workspaceTo, onBe
22148
22156
  workspace: workspaceTo,
22149
22157
  requestBody: {
22150
22158
  path,
22151
- value: resource.value ?? "",
22159
+ value,
22152
22160
  resource_type: resource.resource_type,
22153
22161
  description: resource.description ?? "",
22154
- labels: resource.labels
22162
+ labels: resource.labels,
22163
+ ...agentPreserve
22155
22164
  }
22156
22165
  });
22157
22166
  }
@@ -22331,6 +22340,9 @@ async function getOnBehalfOf(provider, kind, path, workspace) {
22331
22340
  } else if (kind === "app" || kind === "raw_app") {
22332
22341
  const app = await provider.getAppByPath({ workspace, path });
22333
22342
  return app.policy?.on_behalf_of_email;
22343
+ } else if (kind === "resource") {
22344
+ const resource = await provider.getResource({ workspace, path });
22345
+ return resource.resource_type === "ai_agent" ? resource.value?.on_behalf_of : undefined;
22334
22346
  } else if (kind === "schedule") {
22335
22347
  const schedule = await provider.getSchedule({ workspace, path });
22336
22348
  return schedule.permissioned_as;
@@ -58782,7 +58794,7 @@ var init_openflow = __esm(() => {
58782
58794
  openflow_default = {
58783
58795
  openapi: "3.0.3",
58784
58796
  info: {
58785
- version: "1.835.0",
58797
+ version: "1.837.0",
58786
58798
  title: "OpenFlow Spec",
58787
58799
  contact: {
58788
58800
  name: "Ruben Fiszel",
@@ -63126,6 +63138,14 @@ async function preCheckPermissionedAs(changes, userEmail, userIsAdminOrDeployer,
63126
63138
  if (match) {
63127
63139
  currentOwner = match[1];
63128
63140
  }
63141
+ } else if (typeStr === "resource") {
63142
+ if (/["']?resource_type["']?\s*:\s*["']?ai_agent\b/.test(beforeContent) && /["']?run_on_behalf_of["']?\s*:\s*true\b/.test(beforeContent)) {
63143
+ wouldChangeItems.push({
63144
+ path: change.path,
63145
+ currentOwner: "(agent owner)"
63146
+ });
63147
+ }
63148
+ continue;
63129
63149
  } else if (typeStr.endsWith("_trigger")) {
63130
63150
  wouldChangeItems.push({
63131
63151
  path: change.path,
@@ -63291,9 +63311,16 @@ function getWorkspaceSpecificTypeKinds() {
63291
63311
  "variable",
63292
63312
  "resource",
63293
63313
  "schedule",
63314
+ "custom_path",
63294
63315
  ...TRIGGER_TYPES.map((t) => `${t}_trigger`)
63295
63316
  ];
63296
63317
  }
63318
+ function isCustomPathFile(path) {
63319
+ const p = path.replaceAll("\\", "/");
63320
+ const slash = p.lastIndexOf("/");
63321
+ const parts = p.slice(slash + 1).split(".");
63322
+ return (parts.length == 3 || parts.length == 4) && parts[parts.length - 2] == "custom_path" && (parts[parts.length - 1] == "yaml" || parts[parts.length - 1] == "json") && !p.slice(0, slash + 1).includes(".") && !isFolderResourcePathAnyFormat(p) && !isScriptModulePath(p);
63323
+ }
63297
63324
  function isTriggerFile(path) {
63298
63325
  return TRIGGER_TYPES.some((type) => path.endsWith(`.${type}_trigger.yaml`) || path.endsWith(`.${type}_trigger.json`));
63299
63326
  }
@@ -63314,7 +63341,7 @@ function getFileTypeSuffix(path) {
63314
63341
  return null;
63315
63342
  }
63316
63343
  function buildItemTypePattern() {
63317
- const basicTypes = ["variable", "resource", "schedule"];
63344
+ const basicTypes = ["variable", "resource", "schedule", "custom_path"];
63318
63345
  const triggerTypes = TRIGGER_TYPES.map((t) => `${t}_trigger`);
63319
63346
  return `((${basicTypes.join("|")})|(${triggerTypes.join("|")}))`;
63320
63347
  }
@@ -63385,6 +63412,9 @@ function normalizeJsonToYaml(path) {
63385
63412
  return path.endsWith(".json") ? path.slice(0, -".json".length) + ".yaml" : path;
63386
63413
  }
63387
63414
  function isItemTypeConfigured(path, specificItems) {
63415
+ if (isCustomPathFile(path)) {
63416
+ return true;
63417
+ }
63388
63418
  if (!specificItems) {
63389
63419
  return false;
63390
63420
  }
@@ -63413,6 +63443,9 @@ function isItemTypeConfigured(path, specificItems) {
63413
63443
  return false;
63414
63444
  }
63415
63445
  function isSpecificItem(path, specificItems) {
63446
+ if (isCustomPathFile(path)) {
63447
+ return true;
63448
+ }
63416
63449
  if (!specificItems) {
63417
63450
  return false;
63418
63451
  }
@@ -63514,7 +63547,7 @@ function fromWorkspaceSpecificPath(workspaceSpecificPath, workspaceName) {
63514
63547
  return `${pathWithoutBranchAndExtension}${extension}`;
63515
63548
  }
63516
63549
  function getWorkspaceSpecificPath(basePath, specificItems, workspaceNameOverride) {
63517
- if (!specificItems) {
63550
+ if (!specificItems && !isCustomPathFile(basePath)) {
63518
63551
  return;
63519
63552
  }
63520
63553
  let currentWorkspace = null;
@@ -63532,7 +63565,7 @@ function getWorkspaceSpecificPath(basePath, specificItems, workspaceNameOverride
63532
63565
  return;
63533
63566
  }
63534
63567
  function isCurrentWorkspaceFile(path, workspaceNameOverride) {
63535
- if (isFilesetResource(path)) {
63568
+ if (isFilesetResource(path) || isFolderResourcePathAnyFormat(path)) {
63536
63569
  return false;
63537
63570
  }
63538
63571
  let currentWorkspace = null;
@@ -63554,7 +63587,7 @@ function isCurrentWorkspaceFile(path, workspaceNameOverride) {
63554
63587
  return pattern.test(path);
63555
63588
  }
63556
63589
  function isWorkspaceSpecificFile(path) {
63557
- if (isFilesetResource(path)) {
63590
+ if (isFilesetResource(path) || isFolderResourcePathAnyFormat(path)) {
63558
63591
  return false;
63559
63592
  }
63560
63593
  const typePattern = buildItemTypePattern();
@@ -63566,6 +63599,7 @@ var init_specific_items = __esm(async () => {
63566
63599
  await __promiseAll([
63567
63600
  init_git(),
63568
63601
  init_utils(),
63602
+ init_resource_folders(),
63569
63603
  init_conf(),
63570
63604
  init_types()
63571
63605
  ]);
@@ -65881,6 +65915,19 @@ async function track_job(workspace, id) {
65881
65915
  async function pollForJobResult(workspace, jobId) {
65882
65916
  return await pollJobWithQueueLogging(workspace, jobId);
65883
65917
  }
65918
+ async function ensurePreviewOnBehalfOfSupported(workspace, onBehalfOf) {
65919
+ if (!onBehalfOf)
65920
+ return;
65921
+ const probeId = await runScriptPreview({
65922
+ workspace,
65923
+ requestBody: { kind: "identity", args: {}, on_behalf_of: onBehalfOf }
65924
+ });
65925
+ const job = await getJob({ workspace, id: probeId });
65926
+ if (job.permissioned_as === onBehalfOf || job.email?.toLowerCase() === onBehalfOf.toLowerCase()) {
65927
+ return;
65928
+ }
65929
+ throw new Error(`The server does not support --on-behalf-of: it would run the preview as ${job.permissioned_as}, not ${onBehalfOf}. Upgrade the Windmill instance.`);
65930
+ }
65884
65931
  async function show(opts, path) {
65885
65932
  const workspace = await resolveWorkspace(opts);
65886
65933
  await requireLogin(opts);
@@ -66032,6 +66079,7 @@ async function preview(opts, filePath) {
66032
66079
  opts = await mergeConfigWithConfigFile(opts);
66033
66080
  const workspace = await resolveWorkspace(opts);
66034
66081
  await requireLogin(opts);
66082
+ await ensurePreviewOnBehalfOfSupported(workspace.workspaceId, opts.onBehalfOf);
66035
66083
  const argPath = filePath;
66036
66084
  filePath = toSyncRootRelativePath(filePath, cwdBeforeConfig);
66037
66085
  const remotePath = scriptPathToRemotePath(filePath);
@@ -66145,7 +66193,8 @@ async function preview(opts, filePath) {
66145
66193
  tag: opts.tag,
66146
66194
  kind: isTar ? "tarbundle" : "bundle",
66147
66195
  format: codebase?.format ?? "cjs",
66148
- temp_script_refs: tempScriptRefs
66196
+ temp_script_refs: tempScriptRefs,
66197
+ on_behalf_of: opts.onBehalfOf
66149
66198
  };
66150
66199
  form.append("preview", JSON.stringify(previewPayload));
66151
66200
  form.append("file", typeof bundledContent === "string" ? new Blob([bundledContent], { type: "application/javascript" }) : bundledContent);
@@ -66194,7 +66243,8 @@ async function preview(opts, filePath) {
66194
66243
  language,
66195
66244
  tag: opts.tag,
66196
66245
  modules: modules ?? undefined,
66197
- temp_script_refs: tempScriptRefs
66246
+ temp_script_refs: tempScriptRefs,
66247
+ on_behalf_of: opts.onBehalfOf
66198
66248
  }
66199
66249
  });
66200
66250
  const { result, success } = await pollForJobResult(workspace.workspaceId, jobId);
@@ -66333,7 +66383,7 @@ var init_script = __esm(async () => {
66333
66383
  languageAliases = {
66334
66384
  python: "python3"
66335
66385
  };
66336
- command7 = new Command().description("script related commands").option("--show-archived", "Show archived scripts instead of active ones").option("--json", "Output as JSON (for piping to jq)").action(list5).command("list", "list all scripts").option("--show-archived", "Show archived scripts instead of active ones").option("--json", "Output as JSON (for piping to jq)").action(list5).command("push", "push a local script spec. This overrides any remote versions. Use the script file (.ts, .js, .py, .sh)").arguments("<path:file>").option("--message <message:string>", "Deployment message").action(push3).command("get", "get a script's details").arguments("<path:file>").option("--json", "Output as JSON (for piping to jq)").action(get2).command("show", "show a script's content (alias for get)").arguments("<path:file>").action(show).command("run", "run a script by path").arguments("<path:file>").option("-d --data <data:file>", "Inputs specified as a JSON string or a file using @<filename> or stdin using @-. A resource argument is the bare string $res:<path> as its whole value, and a variable argument is the bare string $var:<path> — not an object wrapper keyed on $res/$var, and not a plain path.").option("-s --silent", "Do not output anything other then the final output. Useful for scripting.").option("--tag <tag:string>", "Override the worker tag the run is dispatched to (e.g. to route it to dev workers instead of the script's default tag).").action(run2).command("preview", "preview a local script without deploying it. Supports both regular and codebase scripts.").arguments("<path:file>").option("-d --data <data:file>", "Inputs specified as a JSON string or a file using @<filename> or stdin using @-. A resource argument is the bare string $res:<path> as its whole value, and a variable argument is the bare string $var:<path> — not an object wrapper keyed on $res/$var, and not a plain path.").option("-s --silent", "Do not output anything other than the final output. Useful for scripting.").option("--tag <tag:string>", "Override the worker tag the preview is dispatched to (e.g. to route it to dev workers instead of the script's default tag).").action(preview).command("new", "create a new script").arguments("<path:file> <language:string>").option("--summary <summary:string>", "script summary").option("--description <description:string>", "script description").action(bootstrap).command("bootstrap", "create a new script (alias for new)").arguments("<path:file> <language:string>").option("--summary <summary:string>", "script summary").option("--description <description:string>", "script description").action(bootstrap).command("generate-metadata", 'DEPRECATED: re-generate script metadata. Use top-level "wmill generate-metadata" instead.').arguments("[script:file]").option("--yes", "Skip confirmation prompt").option("--dry-run", "Perform a dry run without making changes").option("--lock-only", "re-generate only the lock").option("--schema-only", "re-generate only script schema").option("-i --includes <patterns:file[]>", "Comma separated patterns to specify which file to take into account (among files that are compatible with windmill). Patterns can include * (any string until '/') and ** (any string)").option("-e --excludes <patterns:file[]>", "Comma separated patterns to specify which file to NOT take into account.").action(generateMetadata2).command("set-permissioned-as", "Set the on_behalf_of_email for a script (requires admin or wm_deployers group)").arguments("<path:string> <email:string>").action(setPermissionedAs).command("history", "show version history for a script").arguments("<path:string>").option("--json", "Output as JSON (for piping to jq)").action(history);
66386
+ command7 = new Command().description("script related commands").option("--show-archived", "Show archived scripts instead of active ones").option("--json", "Output as JSON (for piping to jq)").action(list5).command("list", "list all scripts").option("--show-archived", "Show archived scripts instead of active ones").option("--json", "Output as JSON (for piping to jq)").action(list5).command("push", "push a local script spec. This overrides any remote versions. Use the script file (.ts, .js, .py, .sh)").arguments("<path:file>").option("--message <message:string>", "Deployment message").action(push3).command("get", "get a script's details").arguments("<path:file>").option("--json", "Output as JSON (for piping to jq)").action(get2).command("show", "show a script's content (alias for get)").arguments("<path:file>").action(show).command("run", "run a script by path").arguments("<path:file>").option("-d --data <data:file>", "Inputs specified as a JSON string or a file using @<filename> or stdin using @-. A resource argument is the bare string $res:<path> as its whole value, and a variable argument is the bare string $var:<path> — not an object wrapper keyed on $res/$var, and not a plain path.").option("-s --silent", "Do not output anything other then the final output. Useful for scripting.").option("--tag <tag:string>", "Override the worker tag the run is dispatched to (e.g. to route it to dev workers instead of the script's default tag).").action(run2).command("preview", "preview a local script without deploying it. Supports both regular and codebase scripts.").arguments("<path:file>").option("-d --data <data:file>", "Inputs specified as a JSON string or a file using @<filename> or stdin using @-. A resource argument is the bare string $res:<path> as its whole value, and a variable argument is the bare string $var:<path> — not an object wrapper keyed on $res/$var, and not a plain path.").option("-s --silent", "Do not output anything other than the final output. Useful for scripting.").option("--tag <tag:string>", "Override the worker tag the preview is dispatched to (e.g. to route it to dev workers instead of the script's default tag).").option("--on-behalf-of <identity:string>", "Run the preview as this user or group (an email, u/<username> or g/<group>) instead of yourself, e.g. to reproduce a run_on_behalf_of identity. Requires being an admin or a member of wm_deployers.").action(preview).command("new", "create a new script").arguments("<path:file> <language:string>").option("--summary <summary:string>", "script summary").option("--description <description:string>", "script description").action(bootstrap).command("bootstrap", "create a new script (alias for new)").arguments("<path:file> <language:string>").option("--summary <summary:string>", "script summary").option("--description <description:string>", "script description").action(bootstrap).command("generate-metadata", 'DEPRECATED: re-generate script metadata. Use top-level "wmill generate-metadata" instead.').arguments("[script:file]").option("--yes", "Skip confirmation prompt").option("--dry-run", "Perform a dry run without making changes").option("--lock-only", "re-generate only the lock").option("--schema-only", "re-generate only script schema").option("-i --includes <patterns:file[]>", "Comma separated patterns to specify which file to take into account (among files that are compatible with windmill). Patterns can include * (any string until '/') and ** (any string)").option("-e --excludes <patterns:file[]>", "Comma separated patterns to specify which file to NOT take into account.").action(generateMetadata2).command("set-permissioned-as", "Set the on_behalf_of_email for a script (requires admin or wm_deployers group)").arguments("<path:string> <email:string>").action(setPermissionedAs).command("history", "show version history for a script").arguments("<path:string>").option("--json", "Output as JSON (for piping to jq)").action(history);
66337
66387
  script_default = command7;
66338
66388
  });
66339
66389
 
@@ -67132,7 +67182,7 @@ function validateFilesetPointer(dirPath, remotePath) {
67132
67182
  throw new Error(`Resource ${remotePath.replaceAll(SEP8, "/")} uses '!inline_fileset ${dirPath}', ` + `but a fileset directory must live next to its resource file, at '${expected}'. ` + `Move the directory there (e.g. 'git mv ${pointer} ${expected}') and update the ` + `'!inline_fileset' value to match.`);
67133
67183
  }
67134
67184
  }
67135
- async function pushResource(workspace, remotePath, resource, localResource, originalLocalPath, wsSpecific, enforceCanonicalFileset) {
67185
+ async function pushResource(workspace, remotePath, resource, localResource, originalLocalPath, wsSpecific, enforceCanonicalFileset, permissionedAsContext) {
67136
67186
  remotePath = removeType(remotePath, "resource");
67137
67187
  try {
67138
67188
  resource = await getResource({
@@ -67140,6 +67190,7 @@ async function pushResource(workspace, remotePath, resource, localResource, orig
67140
67190
  path: remotePath.replaceAll(SEP8, "/")
67141
67191
  });
67142
67192
  } catch {}
67193
+ const claimed = agentOnBehalfOf(resource, localResource, permissionedAsContext);
67143
67194
  const resolveInlineContent = async () => {
67144
67195
  if (typeof localResource.value === "string" && localResource.value.startsWith("!inline_fileset ")) {
67145
67196
  const dirPath = localResource.value.split(" ")[1];
@@ -67169,10 +67220,20 @@ async function pushResource(workspace, remotePath, resource, localResource, orig
67169
67220
  return;
67170
67221
  }
67171
67222
  await resolveInlineContent();
67223
+ if (claimed) {
67224
+ info(`Preserving ${claimed} as permissioned_as for agent ${remotePath}`);
67225
+ }
67172
67226
  await updateResource({
67173
67227
  workspace,
67174
67228
  path: remotePath.replaceAll(SEP8, "/"),
67175
- requestBody: { ...localResource, ...wsSpecific !== undefined ? { ws_specific: wsSpecific } : {} }
67229
+ requestBody: {
67230
+ ...localResource,
67231
+ ...wsSpecific !== undefined ? { ws_specific: wsSpecific } : {},
67232
+ ...claimed ? {
67233
+ value: { ...localResource.value, on_behalf_of: claimed },
67234
+ preserve_on_behalf_of: true
67235
+ } : {}
67236
+ }
67176
67237
  });
67177
67238
  } else {
67178
67239
  await resolveInlineContent();
@@ -67190,6 +67251,25 @@ async function pushResource(workspace, remotePath, resource, localResource, orig
67190
67251
  });
67191
67252
  }
67192
67253
  }
67254
+ function agentOnBehalfOf(deployed, localResource, permissionedAsContext) {
67255
+ if (localResource.resource_type !== "ai_agent") {
67256
+ return;
67257
+ }
67258
+ const local = localResource.value;
67259
+ if (local && typeof local === "object") {
67260
+ delete local.on_behalf_of;
67261
+ }
67262
+ const value = deployed?.resource_type === "ai_agent" ? deployed.value : undefined;
67263
+ const onBehalfOf = value && typeof value === "object" ? value.on_behalf_of : undefined;
67264
+ if (deployed && onBehalfOf !== undefined) {
67265
+ const { on_behalf_of: _, ...rest } = value;
67266
+ deployed.value = rest;
67267
+ }
67268
+ if (!onBehalfOf || !permissionedAsContext?.userIsAdminOrDeployer) {
67269
+ return;
67270
+ }
67271
+ return onBehalfOf;
67272
+ }
67193
67273
  async function push4(opts, filePath, remotePath) {
67194
67274
  const workspace = await resolveWorkspace(opts);
67195
67275
  await requireLogin(opts);
@@ -67201,7 +67281,7 @@ async function push4(opts, filePath, remotePath) {
67201
67281
  throw new Error("file path must refer to a file.");
67202
67282
  }
67203
67283
  info(colors.bold.yellow("Pushing resource..."));
67204
- await pushResource(workspace.workspaceId, remotePath, undefined, parseFromFile(filePath), filePath);
67284
+ await pushResource(workspace.workspaceId, remotePath, undefined, parseFromFile(filePath), filePath, undefined, undefined, await buildPermissionedAsContext(workspace.workspaceId, await readEffectiveSyncBehavior(opts, workspace)));
67205
67285
  info(colors.bold.underline.green(`Resource ${remotePath} pushed`));
67206
67286
  }
67207
67287
  async function list6(opts) {
@@ -67285,7 +67365,9 @@ var init_resource = __esm(async () => {
67285
67365
  init_context(),
67286
67366
  init_utils(),
67287
67367
  init_specific_items(),
67288
- init_git()
67368
+ init_git(),
67369
+ init_permissioned_as(),
67370
+ init_conf()
67289
67371
  ]);
67290
67372
  import_yaml19 = __toESM(require_dist(), 1);
67291
67373
  command9 = new Command().description("resource related commands").option("--json", "Output as JSON (for piping to jq)").action(list6).command("list", "list all resources").option("--json", "Output as JSON (for piping to jq)").action(list6).command("get", "get a resource's details").arguments("<path:string>").option("--json", "Output as JSON (for piping to jq)").action(get3).command("new", "create a new resource locally").arguments("<path:string>").action(newResource).command("push", "push a local resource spec. This overrides any remote versions.").arguments("<file_path:string> <remote_path:string>").action(push4);
@@ -68142,7 +68224,7 @@ async function pushFilesetParentResource(childPath, workspaceId, alreadySynced,
68142
68224
  if (cachedWsName && isWorkspaceSpecificFile(resourceFilePath)) {
68143
68225
  serverPath = fromWorkspaceSpecificPath(resourceFilePath, cachedWsName);
68144
68226
  wsSpecific = true;
68145
- } else if (specificItems && isSpecificItem(childPath, specificItems)) {
68227
+ } else if (isSpecificItem(childPath, specificItems)) {
68146
68228
  wsSpecific = true;
68147
68229
  }
68148
68230
  await pushResource(workspaceId, serverPath, undefined, newObj, resourceFilePath, wsSpecific ? true : undefined, true);
@@ -68306,6 +68388,7 @@ function ZipFSElement(zip, useYaml, defaultTs, resourceTypeToFormatExtension, re
68306
68388
  markAccessFromPolicy(app);
68307
68389
  markIsolationFromPolicy(app, false);
68308
68390
  app.policy = undefined;
68391
+ delete app.custom_path;
68309
68392
  yield {
68310
68393
  isDirectory: false,
68311
68394
  path: path15.join(finalPath, "app.yaml"),
@@ -68344,7 +68427,7 @@ function ZipFSElement(zip, useYaml, defaultTs, resourceTypeToFormatExtension, re
68344
68427
  markAccessFromPolicy(rawApp);
68345
68428
  markIsolationFromPolicy(rawApp, true);
68346
68429
  rawApp.policy = undefined;
68347
- delete rawApp?.["custom_path"];
68430
+ delete rawApp.custom_path;
68348
68431
  let inlineScripts;
68349
68432
  const value = rawApp?.["value"];
68350
68433
  const runnables = value?.["runnables"] ?? {};
@@ -68643,6 +68726,21 @@ function ZipFSElement(zip, useYaml, defaultTs, resourceTypeToFormatExtension, re
68643
68726
  }
68644
68727
  }
68645
68728
  }
68729
+ if (kind == "app" || kind == "raw_app") {
68730
+ const customPath = JSON.parse(await f.async("text"))?.custom_path;
68731
+ if (customPath) {
68732
+ const appPath = removeSuffix(p, kind == "app" ? ".app.json" : ".raw_app.json");
68733
+ const obj = { custom_path: customPath };
68734
+ r.push({
68735
+ isDirectory: false,
68736
+ path: appPath + (useYaml ? ".custom_path.yaml" : ".custom_path.json"),
68737
+ async* getChildren() {},
68738
+ async getContentText() {
68739
+ return useYaml ? import_yaml22.stringify(obj, yamlOptions) : JSON.stringify(obj, null, 2);
68740
+ }
68741
+ });
68742
+ }
68743
+ }
68646
68744
  return r;
68647
68745
  }
68648
68746
  function _internal_folder(p, zip) {
@@ -68793,7 +68891,7 @@ async function elementsToMap(els, ignore, json, skips, specificItems, branchOver
68793
68891
  }
68794
68892
  if (skips.skipFlows && fileType === "flow")
68795
68893
  continue;
68796
- if (skips.skipApps && fileType === "app")
68894
+ if (skips.skipApps && (fileType === "app" || fileType === "custom_path"))
68797
68895
  continue;
68798
68896
  if (skips.skipFolders && fileType === "folder")
68799
68897
  continue;
@@ -69095,6 +69193,32 @@ function stripUnappliedSettingsFields(local, remote) {
69095
69193
  remoteInvite.instance_groups_roles ??= {};
69096
69194
  }
69097
69195
  }
69196
+ function liftInFileCustomPaths(localMap, json) {
69197
+ for (const key of Object.keys(localMap)) {
69198
+ const normalized = key.replaceAll(SEP9, "/");
69199
+ const type = isRawAppFolderMetadataFile(normalized) ? "raw_app" : isAppFolderMetadataFile(normalized) ? "app" : undefined;
69200
+ if (!type || normalized.endsWith(json ? ".yaml" : ".json"))
69201
+ continue;
69202
+ const appPath = extractResourceName(normalized, type);
69203
+ let obj;
69204
+ try {
69205
+ obj = json ? JSON.parse(localMap[key]) : yamlParseContent(key, localMap[key]);
69206
+ } catch {
69207
+ continue;
69208
+ }
69209
+ if (!appPath || !obj || typeof obj != "object" || !("custom_path" in obj)) {
69210
+ continue;
69211
+ }
69212
+ const customPath = obj.custom_path;
69213
+ delete obj.custom_path;
69214
+ localMap[key] = json ? JSON.stringify(obj, null, 2) : import_yaml22.stringify(obj, yamlOptions);
69215
+ const fileKey = appPath.replaceAll("/", SEP9) + (json ? ".custom_path.json" : ".custom_path.yaml");
69216
+ if (customPath && !(fileKey in localMap)) {
69217
+ const file = { custom_path: customPath };
69218
+ localMap[fileKey] = json ? JSON.stringify(file, null, 2) : import_yaml22.stringify(file, yamlOptions);
69219
+ }
69220
+ }
69221
+ }
69098
69222
  async function compareDynFSElement(els1, els2, ignore, json, skips, ignoreMetadataDeletion, codebases, ignoreCodebaseChanges, specificItems, branchOverride, isEls1Remote, caseInsensitiveFs, parentOwnsScheduleEnabled) {
69099
69223
  let [m1, m2] = els2 ? await Promise.all([
69100
69224
  elementsToMap(els1, ignore, json, skips, specificItems, branchOverride, isEls1Remote),
@@ -69138,6 +69262,21 @@ async function compareDynFSElement(els1, els2, ignore, json, skips, ignoreMetada
69138
69262
  depFiles: skips.skipWorkspaceDependencies ? Object.keys(await getRawWorkspaceDependencies(false)) : undefined
69139
69263
  }));
69140
69264
  }
69265
+ if (isEls1Remote === false) {
69266
+ liftInFileCustomPaths(m1, json);
69267
+ for (const [k, v] of Object.entries(m1)) {
69268
+ if (!isCustomPathFile(k) || k in m2)
69269
+ continue;
69270
+ let value;
69271
+ try {
69272
+ value = (json ? JSON.parse(v) : yamlParseContent(k, v))?.custom_path;
69273
+ } catch {
69274
+ continue;
69275
+ }
69276
+ if (!value)
69277
+ delete m1[k];
69278
+ }
69279
+ }
69141
69280
  const changes = [];
69142
69281
  function parseYaml(k, v) {
69143
69282
  if (k.endsWith(".script.yaml")) {
@@ -69265,6 +69404,9 @@ async function compareDynFSElement(els1, els2, ignore, json, skips, ignoreMetada
69265
69404
  const remoteCodebase = {};
69266
69405
  for (const [k] of Object.entries(m2)) {
69267
69406
  if (m1[k] === undefined) {
69407
+ if (isEls1Remote === false && isCustomPathFile(k)) {
69408
+ continue;
69409
+ }
69268
69410
  if (!ignoreMetadataDeletion || !k?.endsWith(".script.yaml") && !k?.endsWith(".script.json")) {
69269
69411
  changes.push({ name: "deleted", path: k });
69270
69412
  } else if (k?.endsWith(".script.yaml")) {
@@ -69348,12 +69490,14 @@ function getOrderFromPath(p) {
69348
69490
  return 11;
69349
69491
  } else if (typ == "app") {
69350
69492
  return 12;
69351
- } else if (typ == "schedule") {
69493
+ } else if (typ == "custom_path") {
69352
69494
  return 13;
69353
- } else if (typ == "http_trigger" || typ == "websocket_trigger" || typ == "kafka_trigger" || typ == "nats_trigger" || typ == "postgres_trigger" || typ == "mqtt_trigger" || typ == "amqp_trigger" || typ == "sqs_trigger" || typ == "gcp_trigger" || typ == "azure_trigger" || typ == "email_trigger" || typ == "native_trigger") {
69495
+ } else if (typ == "schedule") {
69354
69496
  return 14;
69355
- } else {
69497
+ } else if (typ == "http_trigger" || typ == "websocket_trigger" || typ == "kafka_trigger" || typ == "nats_trigger" || typ == "postgres_trigger" || typ == "mqtt_trigger" || typ == "amqp_trigger" || typ == "sqs_trigger" || typ == "gcp_trigger" || typ == "azure_trigger" || typ == "email_trigger" || typ == "native_trigger") {
69356
69498
  return 15;
69499
+ } else {
69500
+ return 16;
69357
69501
  }
69358
69502
  }
69359
69503
  async function ignoreF(wmillconf) {
@@ -69757,7 +69901,7 @@ async function pull(opts) {
69757
69901
  type: change.name,
69758
69902
  path: change.path,
69759
69903
  ...change.name === "edited" && change.codebase ? { codebase_changed: true } : {},
69760
- ...specificItems && isSpecificItem(change.path, specificItems) ? {
69904
+ ...isSpecificItem(change.path, specificItems) ? {
69761
69905
  workspace_specific: true,
69762
69906
  workspace_specific_path: getWorkspaceSpecificPath(change.path, specificItems, wsNameForFiles)
69763
69907
  } : {}
@@ -69787,7 +69931,7 @@ async function pull(opts) {
69787
69931
  for await (const rawChange of changes) {
69788
69932
  const change = rawChange;
69789
69933
  let targetPath = change.path;
69790
- if (specificItems && isSpecificItem(change.path, specificItems)) {
69934
+ if (isSpecificItem(change.path, specificItems)) {
69791
69935
  const workspaceSpecificPath = getWorkspaceSpecificPath(change.path, specificItems, wsNameForFiles);
69792
69936
  if (workspaceSpecificPath) {
69793
69937
  targetPath = workspaceSpecificPath;
@@ -69917,7 +70061,7 @@ Both local and remote have been modified.`));
69917
70061
  type: change.name,
69918
70062
  path: change.path,
69919
70063
  ...change.name === "edited" && change.codebase ? { codebase_changed: true } : {},
69920
- ...specificItems && isSpecificItem(change.path, specificItems) ? {
70064
+ ...isSpecificItem(change.path, specificItems) ? {
69921
70065
  workspace_specific: true,
69922
70066
  workspace_specific_path: getWorkspaceSpecificPath(change.path, specificItems, wsNameForFiles)
69923
70067
  } : {}
@@ -70037,7 +70181,7 @@ function prettyChanges(changes, specificItems, branchOverride, folderDefaultAnno
70037
70181
  for (const change of changes) {
70038
70182
  let displayPath = change.path;
70039
70183
  let wsNote = "";
70040
- if (specificItems && isSpecificItem(change.path, specificItems)) {
70184
+ if (isSpecificItem(change.path, specificItems)) {
70041
70185
  const workspaceSpecificPath = getWorkspaceSpecificPath(change.path, specificItems, branchOverride);
70042
70186
  if (workspaceSpecificPath) {
70043
70187
  displayPath = workspaceSpecificPath;
@@ -70590,7 +70734,7 @@ Run 'wmill folder add-missing' to create them locally, then push again.`;
70590
70734
  type: change.name,
70591
70735
  path: change.path,
70592
70736
  ...change.name === "edited" && change.codebase ? { codebase_changed: true } : {},
70593
- ...specificItems && isSpecificItem(change.path, specificItems) ? {
70737
+ ...isSpecificItem(change.path, specificItems) ? {
70594
70738
  workspace_specific: true,
70595
70739
  workspace_specific_path: getWorkspaceSpecificPath(change.path, specificItems, wsNameForFiles)
70596
70740
  } : {}
@@ -70690,7 +70834,7 @@ Run 'wmill folder add-missing' to create them locally, then push again.`;
70690
70834
  }
70691
70835
  const groupedChanges = new Map;
70692
70836
  for (const change of changes) {
70693
- const basePath = getScriptBasePathFromModulePath(change.path) ?? change.path.split(".")[0];
70837
+ const basePath = getScriptBasePathFromModulePath(change.path) ?? extractResourceName(change.path, "raw_app")?.replaceAll("/", SEP9) ?? extractResourceName(change.path, "app")?.replaceAll("/", SEP9) ?? change.path.split(".")[0];
70694
70838
  if (!groupedChanges.has(basePath)) {
70695
70839
  groupedChanges.set(basePath, []);
70696
70840
  }
@@ -70734,7 +70878,10 @@ Run 'wmill folder add-missing' to create them locally, then push again.`;
70734
70878
  if (deleteRawApp) {
70735
70879
  changes = [deleteRawApp];
70736
70880
  } else {
70737
- changes.splice(1, changes.length - 1);
70881
+ changes = [
70882
+ changes[0],
70883
+ ...changes.slice(1).filter((c) => isCustomPathFile(c.path))
70884
+ ];
70738
70885
  }
70739
70886
  }
70740
70887
  for await (const change of changes) {
@@ -70792,7 +70939,7 @@ Run 'wmill folder add-missing' to create them locally, then push again.`;
70792
70939
  } else if (specificItems && isSpecificItem(change.path, specificItems)) {
70793
70940
  isFileResWsSpecific = true;
70794
70941
  }
70795
- await pushResource(workspace.workspaceId, serverPath, undefined, newObj, resourceFilePath, isFileResWsSpecific ? true : undefined, true);
70942
+ await pushResource(workspace.workspaceId, serverPath, undefined, newObj, resourceFilePath, isFileResWsSpecific ? true : undefined, true, permissionedAsContext);
70796
70943
  }
70797
70944
  if (stateTarget) {
70798
70945
  await writeFile11(stateTarget, change.after, "utf-8");
@@ -70823,7 +70970,7 @@ Run 'wmill folder add-missing' to create them locally, then push again.`;
70823
70970
  const oldObj = parseFromPath(change.path, change.before);
70824
70971
  const newObj = parseFromPath(change.path, change.after);
70825
70972
  let originalWorkspaceSpecificPath;
70826
- const isWsSpecific = specificItems && isSpecificItem(change.path, specificItems);
70973
+ const isWsSpecific = isSpecificItem(change.path, specificItems);
70827
70974
  if (isWsSpecific) {
70828
70975
  originalWorkspaceSpecificPath = getWorkspaceSpecificPath(change.path, specificItems, wsNameForFiles);
70829
70976
  }
@@ -70881,7 +71028,7 @@ Run 'wmill folder add-missing' to create them locally, then push again.`;
70881
71028
  }
70882
71029
  const obj = parseFromPath(change.path, change.content);
70883
71030
  let localFilePath = change.path;
70884
- const isAddedWsSpecific = specificItems && isSpecificItem(change.path, specificItems);
71031
+ const isAddedWsSpecific = isSpecificItem(change.path, specificItems);
70885
71032
  if (isAddedWsSpecific) {
70886
71033
  const workspaceSpecificPath = getWorkspaceSpecificPath(change.path, specificItems, wsNameForFiles);
70887
71034
  if (workspaceSpecificPath) {
@@ -71258,7 +71405,7 @@ Run 'wmill folder add-missing' to create them locally, then push again.`;
71258
71405
  type: change.name,
71259
71406
  path: change.path,
71260
71407
  ...change.name === "edited" && change.codebase ? { codebase_changed: true } : {},
71261
- ...specificItems && isSpecificItem(change.path, specificItems) ? {
71408
+ ...isSpecificItem(change.path, specificItems) ? {
71262
71409
  workspace_specific: true,
71263
71410
  workspace_specific_path: getWorkspaceSpecificPath(change.path, specificItems, wsNameForFiles)
71264
71411
  } : {}
@@ -72610,7 +72757,7 @@ async function collectAppFiles(localPath) {
72610
72757
  await readDirRecursive(localPath);
72611
72758
  return files;
72612
72759
  }
72613
- async function pushRawApp(workspace, remotePath, localPath, message, defaultTs = "bun", permissionedAsContext) {
72760
+ async function pushRawApp(workspace, remotePath, localPath, message, defaultTs = "bun", permissionedAsContext, customPathFromFile = true) {
72614
72761
  if (alreadySynced.includes(localPath)) {
72615
72762
  return;
72616
72763
  }
@@ -72673,10 +72820,12 @@ async function pushRawApp(workspace, remotePath, localPath, message, defaultTs =
72673
72820
  extra_perms: localPerms,
72674
72821
  sandbox: _sandbox,
72675
72822
  frontend_api: _frontendApi,
72823
+ custom_path: localCustomPath,
72676
72824
  ...localAppNoPerms
72677
72825
  } = localApp;
72826
+ const customPath = customPathFromFile ? localCustomPath : undefined;
72678
72827
  if (app) {
72679
- const metadataUpToDate = isSuperset({ ...localAppNoPerms, runnables }, app) && isolationUpToDate(isolation, deployedPolicy, true);
72828
+ const metadataUpToDate = isSuperset({ ...localAppNoPerms, runnables }, app) && changedCustomPath(customPath, app) === undefined && isolationUpToDate(isolation, deployedPolicy, true);
72680
72829
  const filesUpToDate = deepEqual(files, app.value?.files);
72681
72830
  if (metadataUpToDate && filesUpToDate) {
72682
72831
  info(colors.green(`App ${remotePath} is up to date`));
@@ -72695,7 +72844,7 @@ async function pushRawApp(workspace, remotePath, localPath, message, defaultTs =
72695
72844
  ...preserveFields,
72696
72845
  deployment_message: message,
72697
72846
  skip_draft_deletion: true,
72698
- ...localApp.custom_path ? { custom_path: localApp.custom_path } : {}
72847
+ custom_path: changedCustomPath(customPath, app)
72699
72848
  },
72700
72849
  js,
72701
72850
  css
@@ -72714,7 +72863,7 @@ async function pushRawApp(workspace, remotePath, localPath, message, defaultTs =
72714
72863
  policy: appForPolicy.policy,
72715
72864
  deployment_message: message,
72716
72865
  skip_draft_deletion: true,
72717
- ...localApp.custom_path ? { custom_path: localApp.custom_path } : {}
72866
+ ...customPath ? { custom_path: customPath } : {}
72718
72867
  },
72719
72868
  js,
72720
72869
  css
@@ -74271,7 +74420,7 @@ data: reload
74271
74420
  if (!runnable) {
74272
74421
  throw new Error(`Runnable not found: ${runnableId}`);
74273
74422
  }
74274
- const uuid = await executeRunnable(runnable, workspaceId, appPath, runnableId, args, appTempRefs);
74423
+ const uuid = await executeRunnable(runnable, workspaceId, appPath, runnableId, args, appTempRefs, previewModules(runnables, runnableId));
74275
74424
  info(colors.gray(`[backend] Job started: ${uuid}`));
74276
74425
  const result = await waitForJob(workspaceId, uuid);
74277
74426
  return { uuid, result };
@@ -74296,7 +74445,7 @@ data: reload
74296
74445
  if (!runnable) {
74297
74446
  throw new Error(`Runnable not found: ${runnable_id}`);
74298
74447
  }
74299
- const uuid = await executeRunnable(runnable, workspaceId, appPath, runnable_id, v, appTempRefs);
74448
+ const uuid = await executeRunnable(runnable, workspaceId, appPath, runnable_id, v, appTempRefs, previewModules(runnables, runnable_id));
74300
74449
  info(colors.gray(`[backendAsync] Job started: ${uuid}`));
74301
74450
  respond("backendAsyncRes", uuid, false);
74302
74451
  waitForJob(workspaceId, uuid).then((result) => {
@@ -74612,7 +74761,43 @@ async function loadRunnables() {
74612
74761
  return {};
74613
74762
  }
74614
74763
  }
74615
- async function executeRunnable(runnable, workspace, appPath, runnableId, args, tempScriptRefs) {
74764
+ function moduleExtension(language) {
74765
+ if (language === "bun" || language === "bunnative")
74766
+ return "ts";
74767
+ if (language === "python3")
74768
+ return "py";
74769
+ return;
74770
+ }
74771
+ function siblingImports(content, ext) {
74772
+ const pattern = ext === "ts" ? /(?:from|import)\s*['"]\.\/([^'"/]+?)(?:\.ts)?['"]/g : /^\s*from\s+\.([A-Za-z_]\w*)\s+import\b/gm;
74773
+ return Array.from(content.matchAll(pattern), (m) => m[1]);
74774
+ }
74775
+ function previewModules(runnables, runnableId) {
74776
+ const inlineScriptOf = (r) => r && ("inlineScript" in r) ? r.inlineScript : undefined;
74777
+ const own = inlineScriptOf(runnables[runnableId]);
74778
+ const ext = moduleExtension(own?.language);
74779
+ if (!own || !ext)
74780
+ return;
74781
+ const modules = {};
74782
+ const queue = siblingImports(own.content, ext);
74783
+ while (queue.length > 0) {
74784
+ const id = queue.pop();
74785
+ const key = `${id}.${ext}`;
74786
+ const inlineScript = inlineScriptOf(runnables[id]);
74787
+ if (key in modules || key === "main.ts")
74788
+ continue;
74789
+ if (!inlineScript || moduleExtension(inlineScript.language) !== ext) {
74790
+ continue;
74791
+ }
74792
+ modules[key] = {
74793
+ content: inlineScript.content,
74794
+ language: inlineScript.language
74795
+ };
74796
+ queue.push(...siblingImports(inlineScript.content, ext));
74797
+ }
74798
+ return Object.keys(modules).length > 0 ? modules : undefined;
74799
+ }
74800
+ async function executeRunnable(runnable, workspace, appPath, runnableId, args, tempScriptRefs, modules) {
74616
74801
  const requestBody = {
74617
74802
  component: runnableId,
74618
74803
  args: args ?? {},
@@ -74637,12 +74822,14 @@ async function executeRunnable(runnable, workspace, appPath, runnableId, args, t
74637
74822
  if (inlineScript.id !== undefined) {
74638
74823
  requestBody.id = inlineScript.id;
74639
74824
  }
74825
+ const previewMods = inlineScript.id === undefined ? modules : undefined;
74640
74826
  requestBody.raw_code = {
74641
74827
  content: inlineScript.id === undefined ? inlineScript.content : "",
74642
74828
  language: inlineScript.language ?? "",
74643
74829
  path: `${appPath}/${runnableId}`,
74644
- lock: inlineScript.id === undefined ? inlineScript.lock : undefined,
74645
- cache_ttl: inlineScript.cache_ttl
74830
+ lock: inlineScript.id === undefined && !previewMods ? inlineScript.lock : undefined,
74831
+ cache_ttl: inlineScript.cache_ttl,
74832
+ ...previewMods ? { modules: previewMods } : {}
74646
74833
  };
74647
74834
  if (inlineScript.id === undefined && tempScriptRefs) {
74648
74835
  requestBody.temp_script_refs = tempScriptRefs;
@@ -75605,7 +75792,8 @@ CREATE SCHEMA IF NOT EXISTS ${schemaName};
75605
75792
  await mkdir10(path23.join(appDir, "backend"), { recursive: true });
75606
75793
  await mkdir10(path23.join(appDir, "sql_to_apply"), { recursive: true });
75607
75794
  const rawAppConfig = {
75608
- summary
75795
+ summary,
75796
+ sandbox: true
75609
75797
  };
75610
75798
  if (dataConfig.datatable) {
75611
75799
  rawAppConfig.data = dataConfig;
@@ -75987,6 +76175,23 @@ function stripEditorState(app) {
75987
76175
  delete app.value.parent_version;
75988
76176
  }
75989
76177
  }
76178
+ function changedCustomPath(local, deployed) {
76179
+ return (local ?? "") === (deployed?.custom_path ?? "") ? undefined : local;
76180
+ }
76181
+ async function pushAppCustomPath(workspace, remotePath, localFile) {
76182
+ remotePath = remotePath.replaceAll(SEP14, "/");
76183
+ const deployed = await getAppByPath({ workspace, path: remotePath });
76184
+ const customPath = changedCustomPath(localFile?.custom_path ?? "", deployed);
76185
+ if (customPath === undefined) {
76186
+ return;
76187
+ }
76188
+ info(colors.bold.yellow(`Setting custom path of app ${remotePath}...`));
76189
+ await updateApp({
76190
+ workspace,
76191
+ path: remotePath,
76192
+ requestBody: { custom_path: customPath, skip_draft_deletion: true }
76193
+ });
76194
+ }
75990
76195
  function isExecutionModeAnonymous(app) {
75991
76196
  return app?.["policy"]?.["execution_mode"] == "anonymous";
75992
76197
  }
@@ -76067,7 +76272,7 @@ function isolationUpToDate(isolation, deployedPolicy, rawApp) {
76067
76272
  const deployed = deployedPolicy?.frontend_sdk_scopes ?? [];
76068
76273
  return deployed.length === isolation.frontendApi.length && deployed.every((s, i) => s === isolation.frontendApi[i]);
76069
76274
  }
76070
- async function pushApp(workspace, remotePath, localPath, message, permissionedAsContext) {
76275
+ async function pushApp(workspace, remotePath, localPath, message, permissionedAsContext, customPathFromFile = true) {
76071
76276
  if (alreadySynced2.includes(localPath)) {
76072
76277
  return;
76073
76278
  }
@@ -76099,10 +76304,12 @@ async function pushApp(workspace, remotePath, localPath, message, permissionedAs
76099
76304
  extra_perms: localPerms,
76100
76305
  sandbox: _sandbox,
76101
76306
  frontend_api: _frontendApi,
76307
+ custom_path: localCustomPath,
76102
76308
  ...localAppBody
76103
76309
  } = localApp;
76310
+ const customPath = customPathFromFile ? localCustomPath : undefined;
76104
76311
  if (app) {
76105
- if (isSuperset(localAppBody, app) && isolationUpToDate(isolation, deployedPolicy, false)) {
76312
+ if (isSuperset(localAppBody, app) && changedCustomPath(customPath, app) === undefined && isolationUpToDate(isolation, deployedPolicy, false)) {
76106
76313
  info(colors.green(`App ${remotePath} is up to date`));
76107
76314
  } else {
76108
76315
  info(colors.bold.yellow(`Updating app ${remotePath}...`));
@@ -76112,6 +76319,7 @@ async function pushApp(workspace, remotePath, localPath, message, permissionedAs
76112
76319
  requestBody: {
76113
76320
  deployment_message: message,
76114
76321
  ...localAppBody,
76322
+ custom_path: changedCustomPath(customPath, app),
76115
76323
  ...preserveFields,
76116
76324
  skip_draft_deletion: true
76117
76325
  }
@@ -76125,6 +76333,7 @@ async function pushApp(workspace, remotePath, localPath, message, permissionedAs
76125
76333
  path: remotePath,
76126
76334
  deployment_message: message,
76127
76335
  ...localAppBody,
76336
+ ...customPath ? { custom_path: customPath } : {},
76128
76337
  ...preserveFields,
76129
76338
  skip_draft_deletion: true
76130
76339
  }
@@ -77717,13 +77926,15 @@ async function pushObj(workspace, p, befObj, newObj, plainSecrets, alreadySynced
77717
77926
  if (!appName) {
77718
77927
  throw new Error(`Could not extract app name from path: ${p}`);
77719
77928
  }
77720
- await pushApp(workspace, appName, buildFolderPath(appName, "app"), message, permissionedAsContext);
77929
+ await pushApp(workspace, appName, buildFolderPath(appName, "app"), message, permissionedAsContext, false);
77721
77930
  } else if (typeEnding === "raw_app") {
77722
77931
  const rawAppName = extractResourceName(p, "raw_app");
77723
77932
  if (!rawAppName) {
77724
77933
  throw new Error(`Could not extract raw app name from path: ${p}`);
77725
77934
  }
77726
- await pushRawApp(workspace, rawAppName, buildFolderPath(rawAppName, "raw_app"), message, defaultTs, permissionedAsContext);
77935
+ await pushRawApp(workspace, rawAppName, buildFolderPath(rawAppName, "raw_app"), message, defaultTs, permissionedAsContext, false);
77936
+ } else if (typeEnding === "custom_path") {
77937
+ await pushAppCustomPath(workspace, removeType(p, "custom_path"), newObj);
77727
77938
  } else if (typeEnding === "folder") {
77728
77939
  await pushFolder(workspace, p, befObj, newObj);
77729
77940
  } else if (typeEnding === "variable") {
@@ -77737,7 +77948,7 @@ async function pushObj(workspace, p, befObj, newObj, plainSecrets, alreadySynced
77737
77948
  } else if (typeEnding === "resource") {
77738
77949
  if (!alreadySynced.includes(p)) {
77739
77950
  alreadySynced.push(p);
77740
- await pushResource(workspace, p, befObj, newObj, originalLocalPath || p, wsSpecific, true);
77951
+ await pushResource(workspace, p, befObj, newObj, originalLocalPath || p, wsSpecific, true, permissionedAsContext);
77741
77952
  }
77742
77953
  } else if (typeEnding === "resource-type") {
77743
77954
  await pushResourceType(workspace, p, befObj, newObj);
@@ -77854,7 +78065,7 @@ function getTypeStrFromPath(p) {
77854
78065
  if (typeEnding?.endsWith("_native_trigger")) {
77855
78066
  return "native_trigger";
77856
78067
  }
77857
- if (typeEnding === "script" || typeEnding === "variable" || typeEnding === "resource" || typeEnding === "resource-type" || typeEnding === "app" || typeEnding === "schedule" || typeEnding === "http_trigger" || typeEnding === "websocket_trigger" || typeEnding === "kafka_trigger" || typeEnding === "nats_trigger" || typeEnding === "postgres_trigger" || typeEnding === "mqtt_trigger" || typeEnding === "amqp_trigger" || typeEnding === "sqs_trigger" || typeEnding === "gcp_trigger" || typeEnding === "azure_trigger" || typeEnding === "email_trigger" || typeEnding === "user" || typeEnding === "group" || typeEnding === "settings" || typeEnding === "encryption_key") {
78068
+ if (typeEnding === "script" || typeEnding === "variable" || typeEnding === "resource" || typeEnding === "resource-type" || typeEnding === "app" || typeEnding === "custom_path" || typeEnding === "schedule" || typeEnding === "http_trigger" || typeEnding === "websocket_trigger" || typeEnding === "kafka_trigger" || typeEnding === "nats_trigger" || typeEnding === "postgres_trigger" || typeEnding === "mqtt_trigger" || typeEnding === "amqp_trigger" || typeEnding === "sqs_trigger" || typeEnding === "gcp_trigger" || typeEnding === "azure_trigger" || typeEnding === "email_trigger" || typeEnding === "user" || typeEnding === "group" || typeEnding === "settings" || typeEnding === "encryption_key") {
77858
78069
  return typeEnding;
77859
78070
  } else {
77860
78071
  throw new Error("Could not infer type of path " + JSON.stringify(parsed));
@@ -78476,6 +78687,7 @@ async function preview2(opts, flowPath) {
78476
78687
  }
78477
78688
  const workspace = await resolveWorkspace(opts);
78478
78689
  await requireLogin(opts);
78690
+ await ensurePreviewOnBehalfOfSupported(workspace.workspaceId, opts.onBehalfOf);
78479
78691
  const codebases = useLocalPathScripts ? listSyncCodebases(opts) : [];
78480
78692
  const argPath = flowPath;
78481
78693
  flowPath = toSyncRootRelativePath(flowPath, cwdBeforeConfig);
@@ -78529,7 +78741,7 @@ async function preview2(opts, flowPath) {
78529
78741
  const input = opts.data ? await resolve9(opts.data) : {};
78530
78742
  debug(`Flow value: ${JSON.stringify(localFlow.value, null, 2)}`);
78531
78743
  if (opts.step) {
78532
- await previewStep(opts.step, localFlow, flowWmPath, workspace, input, tempScriptRefs, opts.silent, opts.tag);
78744
+ await previewStep(opts.step, localFlow, flowWmPath, workspace, input, tempScriptRefs, opts.silent, opts.tag, opts.onBehalfOf);
78533
78745
  return;
78534
78746
  }
78535
78747
  if (!opts.silent) {
@@ -78542,7 +78754,8 @@ async function preview2(opts, flowPath) {
78542
78754
  path: flowWmPath,
78543
78755
  args: input,
78544
78756
  tag: opts.tag,
78545
- temp_script_refs: tempScriptRefs
78757
+ temp_script_refs: tempScriptRefs,
78758
+ on_behalf_of: opts.onBehalfOf
78546
78759
  }
78547
78760
  });
78548
78761
  const { result, success } = await pollForJobResult(workspace.workspaceId, jobId);
@@ -78563,7 +78776,7 @@ async function preview2(opts, flowPath) {
78563
78776
  info(JSON.stringify(result, null, 2));
78564
78777
  }
78565
78778
  }
78566
- async function previewStep(stepId, localFlow, flowWmPath, workspace, baseArgs, tempScriptRefs, silent, tag) {
78779
+ async function previewStep(stepId, localFlow, flowWmPath, workspace, baseArgs, tempScriptRefs, silent, tag, onBehalfOf) {
78567
78780
  const module = findStepInFlowValue(localFlow.value, stepId);
78568
78781
  if (!module) {
78569
78782
  const available = collectStepIds(localFlow.value).join(", ") || "(none)";
@@ -78583,7 +78796,8 @@ async function previewStep(stepId, localFlow, flowWmPath, workspace, baseArgs, t
78583
78796
  flow_path: flowWmPath,
78584
78797
  args,
78585
78798
  tag,
78586
- temp_script_refs: tempScriptRefs
78799
+ temp_script_refs: tempScriptRefs,
78800
+ on_behalf_of: onBehalfOf
78587
78801
  }
78588
78802
  });
78589
78803
  } else if (moduleValue?.type === "script") {
@@ -78604,10 +78818,14 @@ async function previewStep(stepId, localFlow, flowWmPath, workspace, baseArgs, t
78604
78818
  flow_path: flowWmPath,
78605
78819
  args,
78606
78820
  tag,
78607
- temp_script_refs: tempScriptRefs
78821
+ temp_script_refs: tempScriptRefs,
78822
+ on_behalf_of: onBehalfOf
78608
78823
  }
78609
78824
  });
78610
78825
  } else if (moduleValue?.type === "flow") {
78826
+ if (onBehalfOf) {
78827
+ throw new Error(`--on-behalf-of does not apply to step '${stepId}': a flow step runs the deployed flow ${moduleValue.path} by path, and this flag cannot override its identity.`);
78828
+ }
78611
78829
  info(colors.yellow(`Previewing step '${stepId}' (flow ${moduleValue.path})...`));
78612
78830
  jobId = await runFlowByPath({
78613
78831
  workspace: workspace.workspaceId,
@@ -78848,7 +79066,7 @@ var init_flow = __esm(async () => {
78848
79066
  ]);
78849
79067
  import_yaml41 = __toESM(require_dist(), 1);
78850
79068
  alreadySynced3 = [];
78851
- command22 = new Command().description("flow related commands").option("--show-archived", "Enable archived flows in output").option("--json", "Output as JSON (for piping to jq)").action(list12).command("list", "list all flows").option("--show-archived", "Enable archived flows in output").option("--json", "Output as JSON (for piping to jq)").action(list12).command("get", "get a flow's details").arguments("<path:string>").option("--json", "Output as JSON (for piping to jq)").action(get9).command("push", "push a local flow spec. This overrides any remote versions.").arguments("<file_path:string> <remote_path:string>").option("--message <message:string>", "Deployment message").action(push11).command("run", "run a flow by path.").arguments("<path:string>").option("-d --data <data:string>", "Inputs specified as a JSON string or a file using @<filename> or stdin using @-. A resource argument is the bare string $res:<path> as its whole value, and a variable argument is the bare string $var:<path> — not an object wrapper keyed on $res/$var, and not a plain path.").option("-s --silent", "Do not ouput anything other then the final output. Useful for scripting.").option("--tag <tag:string>", "Override the worker tag the run is dispatched to (e.g. to route it to dev workers instead of the flow's default tag).").action(run3).command("preview", "preview a local flow without deploying it. Runs the flow definition from local files and uses local PathScripts by default. Pass --step <id> to run only one module in isolation (resolves nested steps inside branchone/branchall/forloopflow/whileloopflow plus the special preprocessor/failure modules; supported step types: rawscript, script, flow).").arguments("<flow_path:string>").option("-d --data <data:string>", "Inputs specified as a JSON string or a file using @<filename> or stdin using @-. A resource argument is the bare string $res:<path> as its whole value, and a variable argument is the bare string $var:<path> — not an object wrapper keyed on $res/$var, and not a plain path.").option("-s --silent", "Do not output anything other then the final output. Useful for scripting.").option("--remote", "Use deployed workspace scripts for PathScript steps instead of local files.").option("--step <step_id:string>", "Run only the named step instead of the whole flow. Honors --data as the step's args and --remote / local-PathScript resolution the same way the full-flow preview does.").option("--tag <tag:string>", "Override the worker tag the preview is dispatched to (e.g. to route it to dev workers instead of the flow's default tag).").action(preview2).command("generate-locks", 'DEPRECATED: re-generate flow lock files. Use "wmill generate-metadata" instead.').arguments("[flow:file]").option("--yes", "Skip confirmation prompt").option("--dry-run", "Perform a dry run without making changes").option("-i --includes <patterns:file[]>", "Comma separated patterns to specify which file to take into account (among files that are compatible with windmill). Patterns can include * (any string until '/') and ** (any string)").option("-e --excludes <patterns:file[]>", "Comma separated patterns to specify which file to NOT take into account.").action(generateLocks).command("new", "create a new empty flow").arguments("<flow_path:string>").option("--summary <summary:string>", "flow summary").option("--description <description:string>", "flow description").action(bootstrap2).command("bootstrap", "create a new empty flow (alias for new)").arguments("<flow_path:string>").option("--summary <summary:string>", "flow summary").option("--description <description:string>", "flow description").action(bootstrap2).command("history", "Show version history for a flow").arguments("<path:string>").option("--json", "Output as JSON (for piping to jq)").action(history2).command("show-version", "Show a specific version of a flow").arguments("<path:string> <version:string>").option("--json", "Output as JSON (for piping to jq)").action(showVersion).command("set-permissioned-as", "Set the on_behalf_of_email for a flow (requires admin or wm_deployers group)").arguments("<path:string> <email:string>").action(async (opts, flowPath, email) => {
79069
+ command22 = new Command().description("flow related commands").option("--show-archived", "Enable archived flows in output").option("--json", "Output as JSON (for piping to jq)").action(list12).command("list", "list all flows").option("--show-archived", "Enable archived flows in output").option("--json", "Output as JSON (for piping to jq)").action(list12).command("get", "get a flow's details").arguments("<path:string>").option("--json", "Output as JSON (for piping to jq)").action(get9).command("push", "push a local flow spec. This overrides any remote versions.").arguments("<file_path:string> <remote_path:string>").option("--message <message:string>", "Deployment message").action(push11).command("run", "run a flow by path.").arguments("<path:string>").option("-d --data <data:string>", "Inputs specified as a JSON string or a file using @<filename> or stdin using @-. A resource argument is the bare string $res:<path> as its whole value, and a variable argument is the bare string $var:<path> — not an object wrapper keyed on $res/$var, and not a plain path.").option("-s --silent", "Do not ouput anything other then the final output. Useful for scripting.").option("--tag <tag:string>", "Override the worker tag the run is dispatched to (e.g. to route it to dev workers instead of the flow's default tag).").action(run3).command("preview", "preview a local flow without deploying it. Runs the flow definition from local files and uses local PathScripts by default. Pass --step <id> to run only one module in isolation (resolves nested steps inside branchone/branchall/forloopflow/whileloopflow plus the special preprocessor/failure modules; supported step types: rawscript, script, flow).").arguments("<flow_path:string>").option("-d --data <data:string>", "Inputs specified as a JSON string or a file using @<filename> or stdin using @-. A resource argument is the bare string $res:<path> as its whole value, and a variable argument is the bare string $var:<path> — not an object wrapper keyed on $res/$var, and not a plain path.").option("-s --silent", "Do not output anything other then the final output. Useful for scripting.").option("--remote", "Use deployed workspace scripts for PathScript steps instead of local files.").option("--step <step_id:string>", "Run only the named step instead of the whole flow. Honors --data as the step's args and --remote / local-PathScript resolution the same way the full-flow preview does.").option("--tag <tag:string>", "Override the worker tag the preview is dispatched to (e.g. to route it to dev workers instead of the flow's default tag).").option("--on-behalf-of <identity:string>", "Run the preview as this user or group (an email, u/<username> or g/<group>) instead of yourself, e.g. to reproduce a run_on_behalf_of identity. Requires being an admin or a member of wm_deployers.").action(preview2).command("generate-locks", 'DEPRECATED: re-generate flow lock files. Use "wmill generate-metadata" instead.').arguments("[flow:file]").option("--yes", "Skip confirmation prompt").option("--dry-run", "Perform a dry run without making changes").option("-i --includes <patterns:file[]>", "Comma separated patterns to specify which file to take into account (among files that are compatible with windmill). Patterns can include * (any string until '/') and ** (any string)").option("-e --excludes <patterns:file[]>", "Comma separated patterns to specify which file to NOT take into account.").action(generateLocks).command("new", "create a new empty flow").arguments("<flow_path:string>").option("--summary <summary:string>", "flow summary").option("--description <description:string>", "flow description").action(bootstrap2).command("bootstrap", "create a new empty flow (alias for new)").arguments("<flow_path:string>").option("--summary <summary:string>", "flow summary").option("--description <description:string>", "flow description").action(bootstrap2).command("history", "Show version history for a flow").arguments("<path:string>").option("--json", "Output as JSON (for piping to jq)").action(history2).command("show-version", "Show a specific version of a flow").arguments("<path:string> <version:string>").option("--json", "Output as JSON (for piping to jq)").action(showVersion).command("set-permissioned-as", "Set the on_behalf_of_email for a flow (requires admin or wm_deployers group)").arguments("<path:string> <email:string>").action(async (opts, flowPath, email) => {
78852
79070
  const workspace = await resolveWorkspace(opts);
78853
79071
  await requireLogin(opts);
78854
79072
  const remote = await getFlowByPath({
@@ -86913,6 +87131,10 @@ def main(user_id: str):
86913
87131
  return user
86914
87132
  \`\`\`
86915
87133
 
87134
+ #### Sharing code between runnables
87135
+
87136
+ An inline runnable can import another inline runnable of the same app by its id, as a relative import: \`import { getDb } from './shared'\` (TypeScript, Bun) or \`from .shared import get_db\` (Python). This works across TypeScript (Bun) runnables and across Python runnables, not between the two. The imported runnable's own dependencies are picked up, and it can import further runnables in turn. A runnable that only holds helpers needs no \`main\`; the frontend just never calls it. A TypeScript runnable whose id is \`main\` cannot be imported, because that name is taken by the entrypoint file of every TypeScript job: give shared code any other id.
87137
+
86916
87138
  #### The \`wmill\` client is already authenticated
86917
87139
 
86918
87140
  An inline runnable runs as an ordinary Windmill job. \`import * as wmill from 'windmill-client'\` (TypeScript) and \`import wmill\` (Python) are already pointed at this instance and this workspace — there is nothing to configure.
@@ -86956,14 +87178,18 @@ A draft app is reachable by nobody; deploying is what exposes it, and its backen
86956
87178
  Either one lets those people run the app's backend runnables, so never open an app up unless the user asks.
86957
87179
  \`public: true\` in \`raw_app.yaml\` deploys the app for anonymous users, and \`guests: true\` for guests. Remove the line and the next push closes the app again.
86958
87180
 
87181
+ An app's custom URL is not in \`raw_app.yaml\`: each workspace has its own file next to the app folder, \`<app path>.<workspace>.custom_path.yaml\` (for example \`f/sales/dashboard.prod.custom_path.yaml\` holding \`custom_path: dashboard\`), where \`<workspace>\` is the workspace's name in \`wmill.yaml\`, or its id. A push applies only the target workspace's file and leaves the deployed custom URL alone when there is none, so deleting the file does not remove the URL: \`custom_path: ''\` does. Setting or clearing one takes a workspace admin.
87182
+
86959
87183
  ## Sandbox isolation and frontend API access
86960
87184
 
86961
- By default a deployed app's frontend runs with the viewer's own Windmill session. A sandboxed app is isolated from it: the frontend reaches Windmill only through its backend runnables, plus whatever frontend API scopes the app declares, which each viewer approves before the app runs. The scopes are \`jobs:run\`, \`jobs:read\`, \`users:read\`, \`resources:read\`, \`variables:read\`, \`flow_conversations:read\` and \`flow_conversations:write\`; grant only the ones the frontend calls.
87185
+ New apps are sandboxed: the frontend is isolated from the viewer's own Windmill session and reaches Windmill only through its backend runnables, plus whatever frontend API scopes the app declares, which each viewer approves before the app runs. With isolation turned off, the frontend runs with the viewer's full session. The scopes are \`jobs:run\`, \`jobs:read\`, \`resources:read\`, \`variables:read\`, \`flow_conversations:read\` and \`flow_conversations:write\`; grant only the ones the frontend calls. The viewer's identity needs no scope: it is in \`window.ctx\`, and whoami works with any of them.
87186
+
87187
+ Inside the sandbox, IndexedDB is unavailable, third-party sign-in and OAuth redirects fail, and requests to other services carry \`Origin: null\`, which an API that checks the origin rejects. Work around these first: call the service from a backend runnable, keep state in a data table or \`localStorage\`, or grant the frontend API scope the code needs. Suggest turning isolation off only when none of that works, and say plainly that it is a security risk: the app's code, and any XSS bug in it, then runs with the full Windmill permissions of everyone who opens the app.
86962
87188
  In \`raw_app.yaml\`:
86963
87189
 
86964
87190
  \`\`\`yaml
86965
87191
  sandbox: true
86966
- frontend_api: [jobs:run, users:read]
87192
+ frontend_api: [jobs:run]
86967
87193
  \`\`\`
86968
87194
 
86969
87195
  A file with a \`sandbox\` key states both settings: \`sandbox: false\` turns isolation off, and a missing \`frontend_api\` means no scopes. A file without the key leaves the deployed app's isolation and scopes as they are, so removing \`sandbox: true\` does not unsandbox it. \`frontend_api\` needs \`sandbox: true\`; the push fails otherwise.
@@ -88578,6 +88804,7 @@ flow related commands
88578
88804
  - \`--remote\` - Use deployed workspace scripts for PathScript steps instead of local files.
88579
88805
  - \`--step <step_id:string>\` - Run only the named step instead of the whole flow. Honors --data as the step's args and --remote / local-PathScript resolution the same way the full-flow preview does.
88580
88806
  - \`--tag <tag:string>\` - Override the worker tag the preview is dispatched to (e.g. to route it to dev workers instead of the flow's default tag).
88807
+ - \`--on-behalf-of <identity:string>\` - Run the preview as this user or group (an email, u/<username> or g/<group>) instead of yourself, e.g. to reproduce a run_on_behalf_of identity. Requires being an admin or a member of wm_deployers.
88581
88808
  - \`flow new <flow_path:string>\` - create a new empty flow
88582
88809
  - \`--summary <summary:string>\` - flow summary
88583
88810
  - \`--description <description:string>\` - flow description
@@ -88976,6 +89203,7 @@ script related commands
88976
89203
  - \`-d --data <data:file>\` - Inputs specified as a JSON string or a file using @<filename> or stdin using @-. A resource argument is the bare string $res:<path> as its whole value, and a variable argument is the bare string $var:<path> — not an object wrapper keyed on $res/$var, and not a plain path.
88977
89204
  - \`-s --silent\` - Do not output anything other than the final output. Useful for scripting.
88978
89205
  - \`--tag <tag:string>\` - Override the worker tag the preview is dispatched to (e.g. to route it to dev workers instead of the script's default tag).
89206
+ - \`--on-behalf-of <identity:string>\` - Run the preview as this user or group (an email, u/<username> or g/<group>) instead of yourself, e.g. to reproduce a run_on_behalf_of identity. Requires being an admin or a member of wm_deployers.
88979
89207
  - \`script new <path:file> <language:string>\` - create a new script
88980
89208
  - \`--summary <summary:string>\` - script summary
88981
89209
  - \`--description <description:string>\` - script description
@@ -93465,6 +93693,17 @@ async function listWorkspacePaths() {
93465
93693
  items.push({ path: stripFolderSuffix(childRel, APP_SUFFIXES), kind: "raw_app" });
93466
93694
  continue;
93467
93695
  }
93696
+ if (entry.name.endsWith(getModuleFolderSuffix())) {
93697
+ const files = await readdir10(childAbs).catch(() => []);
93698
+ if (files.some((f) => f.startsWith("script.") && hasScriptExt(f))) {
93699
+ items.push({
93700
+ path: childRel.slice(0, -getModuleFolderSuffix().length),
93701
+ kind: "script",
93702
+ _metaPath: path25.join(childAbs, "script.yaml")
93703
+ });
93704
+ }
93705
+ continue;
93706
+ }
93468
93707
  if (entry.name.endsWith(DBT_MODULE_SUFFIX)) {
93469
93708
  const base = childRel.slice(0, -DBT_MODULE_SUFFIX.length);
93470
93709
  items.push({
@@ -93576,19 +93815,19 @@ async function dev2(opts) {
93576
93815
  const flowMetadataFile = getMetadataFileName("flow", "yaml");
93577
93816
  async function loadPaths(pathsToLoad) {
93578
93817
  const rest = [];
93579
- const dbtProjects = new Set;
93818
+ const scriptsWithModules = new Set;
93580
93819
  for (const raw of pathsToLoad) {
93581
93820
  const rel = (await realpath(raw).catch(() => raw)).replace(base + SEP22, "").replaceAll("\\", "/");
93582
- const wmPath = isDbtModulePath(rel) ? getScriptBasePathFromModulePath(rel) : undefined;
93821
+ const wmPath = getScriptBasePathFromModulePath(rel);
93583
93822
  if (wmPath)
93584
- dbtProjects.add(wmPath);
93823
+ scriptsWithModules.add(wmPath);
93585
93824
  else
93586
93825
  rest.push(raw);
93587
93826
  }
93588
- for (const wmPath of dbtProjects) {
93827
+ for (const wmPath of scriptsWithModules) {
93589
93828
  const edit = await loadWmPath(wmPath);
93590
93829
  if (edit) {
93591
- info("Updated " + wmPath + " (dbt project)");
93830
+ info("Updated " + wmPath + " (script modules)");
93592
93831
  broadcastChanges(edit);
93593
93832
  }
93594
93833
  }
@@ -93635,8 +93874,7 @@ async function dev2(opts) {
93635
93874
  info("Updated " + wmFlowPath);
93636
93875
  broadcastChanges(currentLastEdit);
93637
93876
  } else if (typ == "script") {
93638
- const splitted = cpath.split(".");
93639
- const wmPath = splitted[0];
93877
+ const wmPath = removeExtensionToPath(cpath);
93640
93878
  const content = await readTextFile(cpath);
93641
93879
  const lang = inferContentTypeFromFilePath(cpath, opts.defaultTs);
93642
93880
  const typed = (await parseMetadataFile(removeExtensionToPath(cpath), undefined))?.payload;
@@ -93647,7 +93885,8 @@ async function dev2(opts) {
93647
93885
  language: lang,
93648
93886
  tag: typed?.tag,
93649
93887
  lock: typed?.lock,
93650
- temp_script_refs: tempScriptRefs
93888
+ temp_script_refs: tempScriptRefs,
93889
+ modules: await readModulesFromDisk(wmPath + getModuleFolderSuffix(lang), opts.defaultTs, lang === "dbt", lang === "dbt")
93651
93890
  };
93652
93891
  info("Updated " + wmPath);
93653
93892
  broadcastChanges(currentLastEdit);
@@ -93690,8 +93929,11 @@ async function dev2(opts) {
93690
93929
  currentLastEdit = edit;
93691
93930
  return edit;
93692
93931
  } catch {}
93693
- for (const ext of exts) {
93694
- const filePath = wmPath + ext;
93932
+ const candidates = [
93933
+ ...exts.map((ext) => ({ ext, filePath: wmPath + ext, folderLayout: false })),
93934
+ ...exts.filter((ext) => !ext.includes("/")).map((ext) => ({ ext, filePath: wmPath + getModuleFolderSuffix() + "/script" + ext, folderLayout: true }))
93935
+ ];
93936
+ for (const { ext, filePath, folderLayout } of candidates) {
93695
93937
  try {
93696
93938
  const isAbsentDbtDescriptor = ext === "__dbt/" + DBT_DESCRIPTOR_NAME && !await access(filePath).then(() => true, () => false) && await access(wmPath + DBT_MODULE_SUFFIX + "/dbt_project.yml").then(() => true, () => false);
93697
93939
  if (!isAbsentDbtDescriptor) {
@@ -93699,7 +93941,7 @@ async function dev2(opts) {
93699
93941
  }
93700
93942
  const content = isAbsentDbtDescriptor ? "" : await readTextFile(filePath);
93701
93943
  const lang = inferContentTypeFromFilePath(filePath, opts.defaultTs);
93702
- const typed = (await parseMetadataFile(removeExtensionToPath(filePath), undefined))?.payload;
93944
+ const typed = (await parseMetadataFile(wmPath, undefined))?.payload;
93703
93945
  const edit = {
93704
93946
  type: "script",
93705
93947
  content,
@@ -93708,7 +93950,7 @@ async function dev2(opts) {
93708
93950
  tag: typed?.tag,
93709
93951
  lock: typed?.lock,
93710
93952
  temp_script_refs: tempScriptRefs,
93711
- modules: lang === "dbt" ? await readModulesFromDisk(wmPath + DBT_MODULE_SUFFIX, opts.defaultTs, true, true) : undefined
93953
+ modules: await readModulesFromDisk(wmPath + getModuleFolderSuffix(lang), opts.defaultTs, folderLayout || lang === "dbt", lang === "dbt")
93712
93954
  };
93713
93955
  currentLastEdit = edit;
93714
93956
  return edit;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windmill-cli",
3
- "version": "1.835.0",
3
+ "version": "1.837.0",
4
4
  "description": "CLI for Windmill",
5
5
  "license": "Apache 2.0",
6
6
  "type": "module",