windmill-cli 1.820.0 → 1.821.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/main.js +89 -10
- 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.
|
|
16769
|
+
VERSION: "1.821.0",
|
|
16770
16770
|
WITH_CREDENTIALS: true,
|
|
16771
16771
|
interceptors: {
|
|
16772
16772
|
request: new Interceptors,
|
|
@@ -17526,6 +17526,15 @@ var getAuditLog = (data) => {
|
|
|
17526
17526
|
workspace: data.workspace
|
|
17527
17527
|
}
|
|
17528
17528
|
});
|
|
17529
|
+
}, getDatatableMigrationsStatus = (data) => {
|
|
17530
|
+
return request(OpenAPI, {
|
|
17531
|
+
method: "GET",
|
|
17532
|
+
url: "/w/{workspace}/workspaces/datatable_migrations_status/{datatable_name}",
|
|
17533
|
+
path: {
|
|
17534
|
+
workspace: data.workspace,
|
|
17535
|
+
datatable_name: data.datatableName
|
|
17536
|
+
}
|
|
17537
|
+
});
|
|
17529
17538
|
}, deleteDatatableMigration = (data) => {
|
|
17530
17539
|
return request(OpenAPI, {
|
|
17531
17540
|
method: "DELETE",
|
|
@@ -20041,7 +20050,7 @@ var init_auth = __esm(async () => {
|
|
|
20041
20050
|
});
|
|
20042
20051
|
|
|
20043
20052
|
// src/core/constants.ts
|
|
20044
|
-
var WM_FORK_PREFIX = "wm-fork", VERSION = "1.
|
|
20053
|
+
var WM_FORK_PREFIX = "wm-fork", VERSION = "1.821.0";
|
|
20045
20054
|
|
|
20046
20055
|
// src/utils/resource_folders.ts
|
|
20047
20056
|
import { existsSync } from "node:fs";
|
|
@@ -21318,6 +21327,16 @@ function inferWsNameFromProfile(opts, profile) {
|
|
|
21318
21327
|
}
|
|
21319
21328
|
return;
|
|
21320
21329
|
}
|
|
21330
|
+
function inferWsNameFromForkBranch(opts, workspaceId) {
|
|
21331
|
+
if (!opts.workspaces || !isGitRepository())
|
|
21332
|
+
return;
|
|
21333
|
+
const branch = getCurrentGitBranch();
|
|
21334
|
+
const baseBranch = getOriginalBranchForWorkspaceForks(branch);
|
|
21335
|
+
if (!branch || !baseBranch || getWorkspaceIdForWorkspaceForkFromBranchName(branch) !== workspaceId) {
|
|
21336
|
+
return;
|
|
21337
|
+
}
|
|
21338
|
+
return findWorkspaceByGitBranch(opts.workspaces, baseBranch)?.[0];
|
|
21339
|
+
}
|
|
21321
21340
|
async function readEffectiveSyncBehavior(opts, profile) {
|
|
21322
21341
|
const config = await readConfigFile({ warnIfMissing: false });
|
|
21323
21342
|
const named = resolveWsNameForConfigFromFlags({ ...config, ...opts });
|
|
@@ -22463,16 +22482,21 @@ async function pushMigrationFromDisk(workspace, m) {
|
|
|
22463
22482
|
}
|
|
22464
22483
|
});
|
|
22465
22484
|
}
|
|
22466
|
-
|
|
22485
|
+
function listLocalMigrations(datatableName) {
|
|
22467
22486
|
const dir = path3.join(process.cwd(), MIGRATIONS_DIR, datatableName);
|
|
22468
22487
|
if (!fs7.existsSync(dir))
|
|
22469
|
-
return;
|
|
22488
|
+
return [];
|
|
22470
22489
|
const local = [];
|
|
22471
22490
|
for (const file of fs7.readdirSync(dir)) {
|
|
22472
22491
|
const m = file.match(/^(\d+)_(.*)\.up\.sql$/);
|
|
22473
22492
|
if (m)
|
|
22474
22493
|
local.push({ timestamp: Number(m[1]), name: m[2] });
|
|
22475
22494
|
}
|
|
22495
|
+
return local;
|
|
22496
|
+
}
|
|
22497
|
+
async function pushLocalMigrations(workspace, datatableName) {
|
|
22498
|
+
const dir = path3.join(process.cwd(), MIGRATIONS_DIR, datatableName);
|
|
22499
|
+
const local = listLocalMigrations(datatableName);
|
|
22476
22500
|
if (local.length === 0)
|
|
22477
22501
|
return;
|
|
22478
22502
|
const remote = await listDatatableMigrations({ workspace });
|
|
@@ -57033,7 +57057,7 @@ var init_openflow = __esm(() => {
|
|
|
57033
57057
|
openflow_default = {
|
|
57034
57058
|
openapi: "3.0.3",
|
|
57035
57059
|
info: {
|
|
57036
|
-
version: "1.
|
|
57060
|
+
version: "1.821.0",
|
|
57037
57061
|
title: "OpenFlow Spec",
|
|
57038
57062
|
contact: {
|
|
57039
57063
|
name: "Ruben Fiszel",
|
|
@@ -67841,7 +67865,7 @@ async function pull(opts) {
|
|
|
67841
67865
|
}
|
|
67842
67866
|
}
|
|
67843
67867
|
if (!wsNameForConfig) {
|
|
67844
|
-
wsNameForConfig = inferWsNameFromProfile(opts, workspace);
|
|
67868
|
+
wsNameForConfig = inferWsNameFromProfile(opts, workspace) ?? inferWsNameFromForkBranch(opts, workspace.workspaceId);
|
|
67845
67869
|
}
|
|
67846
67870
|
const effectiveOpts = await resolveEffectiveSyncOptions(workspace, opts, opts.promotion, wsNameForConfig);
|
|
67847
67871
|
let specificItems = getSpecificItemsForCurrentBranch(opts, wsNameForConfig);
|
|
@@ -68320,7 +68344,7 @@ async function push4(opts) {
|
|
|
68320
68344
|
const workspace = await resolveWorkspace(opts, wsNameForConfig);
|
|
68321
68345
|
await requireLogin(opts);
|
|
68322
68346
|
if (!wsNameForConfig) {
|
|
68323
|
-
wsNameForConfig = inferWsNameFromProfile(opts, workspace);
|
|
68347
|
+
wsNameForConfig = inferWsNameFromProfile(opts, workspace) ?? inferWsNameFromForkBranch(opts, workspace.workspaceId);
|
|
68324
68348
|
}
|
|
68325
68349
|
const effectiveOpts = await resolveEffectiveSyncOptions(workspace, opts, opts.promotion, wsNameForConfig);
|
|
68326
68350
|
let specificItems = getSpecificItemsForCurrentBranch(opts, wsNameForConfig);
|
|
@@ -75405,7 +75429,7 @@ async function pushWorkspaceSettings(workspace, _path, settings, localSettings)
|
|
|
75405
75429
|
const localOperatorSettings = localSettings.operator_settings && {
|
|
75406
75430
|
...localSettings.operator_settings
|
|
75407
75431
|
};
|
|
75408
|
-
for (const key of ["manage_schedules", "manage_triggers"]) {
|
|
75432
|
+
for (const key of ["builder_flows", "manage_schedules", "manage_triggers"]) {
|
|
75409
75433
|
const remote = settings.operator_settings?.[key];
|
|
75410
75434
|
if (localOperatorSettings && localOperatorSettings[key] === undefined && remote !== undefined) {
|
|
75411
75435
|
localOperatorSettings[key] = remote;
|
|
@@ -80956,6 +80980,18 @@ export async function main(url: string) {
|
|
|
80956
80980
|
}
|
|
80957
80981
|
\`\`\`
|
|
80958
80982
|
|
|
80983
|
+
## Pure computation: \`//no_network\`
|
|
80984
|
+
|
|
80985
|
+
A native script that only transforms its inputs can declare \`//no_network\` in its leading comment block (right after \`//native\`). The runtime then refuses every connection the script attempts: \`fetch\` to any host, the Windmill API (so \`windmill-client\` calls fail too), raw sockets and unix sockets, and \`WM_TOKEN\` is not set. It only takes effect on native scripts: without \`//native\` it is ignored. Use it only when the script needs no external data beyond its arguments:
|
|
80986
|
+
|
|
80987
|
+
\`\`\`typescript
|
|
80988
|
+
//native
|
|
80989
|
+
//no_network
|
|
80990
|
+
export async function main(items: { price: number; qty: number }[]) {
|
|
80991
|
+
return items.reduce((sum, i) => sum + i.price * i.qty, 0);
|
|
80992
|
+
}
|
|
80993
|
+
\`\`\`
|
|
80994
|
+
|
|
80959
80995
|
## Windmill Client
|
|
80960
80996
|
|
|
80961
80997
|
\`windmill-client\` works on the native worker (its calls go over \`fetch\`), so use it as the **preferred way to talk to Windmill** — reading resources/variables/states, running scripts and flows, and the S3 helpers below (\`loadS3File\`, \`loadS3FileStream\`, \`writeS3File\`, \`S3Object\`). It handles auth, the workspace, and the base URL for you. Reserve raw \`fetch\` for calling *external* HTTP APIs that aren't Windmill.
|
|
@@ -85362,7 +85398,7 @@ needs becomes unreachable.
|
|
|
85362
85398
|
},
|
|
85363
85399
|
"user_message": { "type": "javascript", "expr": "flow_input.user_message" },
|
|
85364
85400
|
"user_attachments": { "type": "javascript", "expr": "flow_input.files" },
|
|
85365
|
-
"memory": { "type": "static", "value": { "kind": "
|
|
85401
|
+
"memory": { "type": "static", "value": { "kind": "compaction" } },
|
|
85366
85402
|
"streaming": { "type": "static", "value": true },
|
|
85367
85403
|
"output_type": { "type": "static", "value": "text" }
|
|
85368
85404
|
},
|
|
@@ -87478,6 +87514,9 @@ datatable related commands
|
|
|
87478
87514
|
- \`-d --datatable <datatable:string>\` - Target datatable (default: main)
|
|
87479
87515
|
- \`datatable migrate down\` - roll back the most recent migration on the main datatable (or one via --datatable)
|
|
87480
87516
|
- \`-d --datatable <datatable:string>\` - Target datatable (default: main)
|
|
87517
|
+
- \`datatable migrate status\` - show applied and pending migrations on the main datatable (or one via --datatable)
|
|
87518
|
+
- \`-d --datatable <datatable:string>\` - Target datatable (default: main)
|
|
87519
|
+
- \`--json\` - Output as JSON (for piping to jq)
|
|
87481
87520
|
- \`datatable create [name:string]\` - register a datatable database in the workspace (default: instance-backed 'main') so scripts can use datatable://<name>
|
|
87482
87521
|
- \`--resource <resource:string>\` - Back the datatable with an existing postgresql resource path instead of the instance database
|
|
87483
87522
|
- \`--force\` - Allow adding to a workspace that already has datatables (fork metadata on existing ones is not preserved)
|
|
@@ -97071,7 +97110,47 @@ async function migrateDown(opts) {
|
|
|
97071
97110
|
const dt = opts.datatable ?? DEFAULT_DATATABLE_NAME2;
|
|
97072
97111
|
await rollbackMigrations(workspace.workspaceId, dt);
|
|
97073
97112
|
}
|
|
97074
|
-
|
|
97113
|
+
async function migrateStatus(opts) {
|
|
97114
|
+
if (opts.json)
|
|
97115
|
+
setSilent(true);
|
|
97116
|
+
const workspace = await resolveWorkspace(opts);
|
|
97117
|
+
await requireLogin(opts);
|
|
97118
|
+
const dt = opts.datatable ?? DEFAULT_DATATABLE_NAME2;
|
|
97119
|
+
const status = await getDatatableMigrationsStatus({
|
|
97120
|
+
workspace: workspace.workspaceId,
|
|
97121
|
+
datatableName: dt
|
|
97122
|
+
});
|
|
97123
|
+
const remote = new Set(status.migrations.map((m) => m.timestamp));
|
|
97124
|
+
const migrations = [
|
|
97125
|
+
...status.migrations,
|
|
97126
|
+
...listLocalMigrations(dt).filter((m) => !remote.has(m.timestamp)).map((m) => ({ ...m, status: "local" }))
|
|
97127
|
+
].sort((a, b) => a.timestamp - b.timestamp);
|
|
97128
|
+
if (opts.json) {
|
|
97129
|
+
console.log(JSON.stringify({ ...status, migrations }));
|
|
97130
|
+
return;
|
|
97131
|
+
}
|
|
97132
|
+
if (!status.enabled) {
|
|
97133
|
+
info(`Migrations are not enabled on datatable '${dt}'`);
|
|
97134
|
+
return;
|
|
97135
|
+
}
|
|
97136
|
+
if (status.error) {
|
|
97137
|
+
warn(`Could not read applied migrations on '${dt}': ${status.error}`);
|
|
97138
|
+
}
|
|
97139
|
+
if (migrations.length === 0) {
|
|
97140
|
+
info(`No migrations on datatable '${dt}'`);
|
|
97141
|
+
return;
|
|
97142
|
+
}
|
|
97143
|
+
const label = {
|
|
97144
|
+
not_run: "pending",
|
|
97145
|
+
local: "pending (not pushed)"
|
|
97146
|
+
};
|
|
97147
|
+
new Table2().header(["Timestamp", "Name", "Status"]).padding(2).border(true).body(migrations.map((m) => [
|
|
97148
|
+
String(m.timestamp),
|
|
97149
|
+
m.name,
|
|
97150
|
+
label[m.status] ?? m.status
|
|
97151
|
+
])).render();
|
|
97152
|
+
}
|
|
97153
|
+
var migrateCommand = new Command().description("manage datatable migrations").command("new", "scaffold a new migration (.up.sql / .down.sql files)").arguments("<name:string>").option("-d --datatable <datatable:string>", "Target datatable (default: main)").action(migrateNew).command("up", "apply all pending migrations to the main datatable (or one via --datatable)").option("-d --datatable <datatable:string>", "Target datatable (default: main)").action(migrateUp).command("down", "roll back the most recent migration on the main datatable (or one via --datatable)").option("-d --datatable <datatable:string>", "Target datatable (default: main)").action(migrateDown).command("status", "show applied and pending migrations on the main datatable (or one via --datatable)").option("-d --datatable <datatable:string>", "Target datatable (default: main)").option("--json", "Output as JSON (for piping to jq)").action(migrateStatus);
|
|
97075
97154
|
async function create3(opts, name) {
|
|
97076
97155
|
const workspace = await resolveWorkspace(opts);
|
|
97077
97156
|
await requireLogin(opts);
|