windmill-cli 1.396.1 → 1.397.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/esm/apps.js +6 -5
  2. package/esm/bootstrap/script_bootstrap.js +18 -0
  3. package/esm/context.js +4 -3
  4. package/esm/deps.js +19 -2
  5. package/esm/flow.js +9 -8
  6. package/esm/folder.js +6 -5
  7. package/esm/gen/core/ApiError.js +41 -0
  8. package/esm/gen/core/ApiRequestOptions.js +1 -0
  9. package/esm/gen/core/ApiResult.js +1 -0
  10. package/esm/gen/core/CancelablePromise.js +130 -0
  11. package/esm/gen/core/OpenAPI.js +41 -0
  12. package/esm/gen/core/request.js +305 -0
  13. package/esm/gen/index.js +6 -0
  14. package/esm/gen/services.gen.js +6782 -0
  15. package/esm/gen/types.gen.js +2 -0
  16. package/esm/hub.js +5 -4
  17. package/esm/instance.js +5 -4
  18. package/esm/main.js +5 -3
  19. package/esm/metadata.js +1 -1
  20. package/esm/resource-type.js +6 -5
  21. package/esm/resource.js +11 -5
  22. package/esm/schedule.js +6 -5
  23. package/esm/script.js +42 -10
  24. package/esm/script_common.js +6 -0
  25. package/esm/settings.js +28 -27
  26. package/esm/sync.js +89 -23
  27. package/esm/types.js +9 -3
  28. package/esm/user.js +27 -27
  29. package/esm/utils.js +7 -0
  30. package/esm/variable.js +7 -6
  31. package/esm/workspace.js +7 -6
  32. package/package.json +1 -2
  33. package/types/apps.d.ts +2 -1
  34. package/types/apps.d.ts.map +1 -1
  35. package/types/bootstrap/script_bootstrap.d.ts +2 -0
  36. package/types/bootstrap/script_bootstrap.d.ts.map +1 -1
  37. package/types/context.d.ts +1 -1
  38. package/types/context.d.ts.map +1 -1
  39. package/types/deps.d.ts +1 -1
  40. package/types/deps.d.ts.map +1 -1
  41. package/types/flow.d.ts +2 -1
  42. package/types/flow.d.ts.map +1 -1
  43. package/types/folder.d.ts +5 -2
  44. package/types/folder.d.ts.map +1 -1
  45. package/types/gen/core/ApiError.d.ts +11 -0
  46. package/types/gen/core/ApiError.d.ts.map +1 -0
  47. package/types/gen/core/ApiRequestOptions.d.ts +15 -0
  48. package/types/gen/core/ApiRequestOptions.d.ts.map +1 -0
  49. package/types/gen/core/ApiResult.d.ts +8 -0
  50. package/types/gen/core/ApiResult.d.ts.map +1 -0
  51. package/types/gen/core/CancelablePromise.d.ts +27 -0
  52. package/types/gen/core/CancelablePromise.d.ts.map +1 -0
  53. package/types/gen/core/OpenAPI.d.ts +28 -0
  54. package/types/gen/core/OpenAPI.d.ts.map +1 -0
  55. package/types/gen/core/request.d.ts +30 -0
  56. package/types/gen/core/request.d.ts.map +1 -0
  57. package/types/gen/index.d.ts +6 -0
  58. package/types/gen/index.d.ts.map +1 -0
  59. package/types/gen/services.gen.d.ts +3339 -0
  60. package/types/gen/services.gen.d.ts.map +1 -0
  61. package/types/gen/types.gen.d.ts +4831 -0
  62. package/types/gen/types.gen.d.ts.map +1 -0
  63. package/types/hub.d.ts.map +1 -1
  64. package/types/instance.d.ts.map +1 -1
  65. package/types/main.d.ts +1 -1
  66. package/types/main.d.ts.map +1 -1
  67. package/types/metadata.d.ts +1 -1
  68. package/types/metadata.d.ts.map +1 -1
  69. package/types/resource-type.d.ts +2 -1
  70. package/types/resource-type.d.ts.map +1 -1
  71. package/types/resource.d.ts +2 -1
  72. package/types/resource.d.ts.map +1 -1
  73. package/types/schedule.d.ts +2 -1
  74. package/types/schedule.d.ts.map +1 -1
  75. package/types/script.d.ts +1 -0
  76. package/types/script.d.ts.map +1 -1
  77. package/types/script_common.d.ts +1 -1
  78. package/types/script_common.d.ts.map +1 -1
  79. package/types/settings.d.ts.map +1 -1
  80. package/types/sync.d.ts +2 -1
  81. package/types/sync.d.ts.map +1 -1
  82. package/types/types.d.ts +1 -1
  83. package/types/types.d.ts.map +1 -1
  84. package/types/user.d.ts.map +1 -1
  85. package/types/utils.d.ts +1 -0
  86. package/types/utils.d.ts.map +1 -1
  87. package/types/variable.d.ts +2 -1
  88. package/types/variable.d.ts.map +1 -1
  89. package/types/workspace.d.ts.map +1 -1
package/esm/apps.js CHANGED
@@ -1,7 +1,8 @@
1
1
  // deno-lint-ignore-file no-explicit-any
2
2
  import * as dntShim from "./_dnt.shims.js";
3
3
  import { requireLogin, resolveWorkspace, validatePath } from "./context.js";
4
- import { AppService, colors, Command, log, SEP, Table, yamlParse, } from "./deps.js";
4
+ import { colors, Command, log, SEP, Table, yamlParse } from "./deps.js";
5
+ import * as wmill from "./gen/services.gen.js";
5
6
  import { isSuperset } from "./types.js";
6
7
  import { readInlinePathSync } from "./utils.js";
7
8
  const alreadySynced = [];
@@ -14,7 +15,7 @@ export async function pushApp(workspace, remotePath, localPath, message) {
14
15
  let app = undefined;
15
16
  // deleting old app if it exists in raw mode
16
17
  try {
17
- app = await AppService.getAppByPath({
18
+ app = await wmill.getAppByPath({
18
19
  workspace,
19
20
  path: remotePath,
20
21
  });
@@ -58,7 +59,7 @@ export async function pushApp(workspace, remotePath, localPath, message) {
58
59
  return;
59
60
  }
60
61
  log.info(colors.bold.yellow(`Updating app ${remotePath}...`));
61
- await AppService.updateApp({
62
+ await wmill.updateApp({
62
63
  workspace,
63
64
  path: remotePath,
64
65
  requestBody: {
@@ -69,7 +70,7 @@ export async function pushApp(workspace, remotePath, localPath, message) {
69
70
  }
70
71
  else {
71
72
  log.info(colors.yellow.bold("Creating new app..."));
72
- await AppService.createApp({
73
+ await wmill.createApp({
73
74
  workspace,
74
75
  requestBody: {
75
76
  path: remotePath,
@@ -86,7 +87,7 @@ async function list(opts) {
86
87
  const perPage = 10;
87
88
  const total = [];
88
89
  while (true) {
89
- const res = await AppService.listApps({
90
+ const res = await wmill.listApps({
90
91
  workspace: workspace.workspaceId,
91
92
  page,
92
93
  perPage,
@@ -54,4 +54,22 @@ function main() {
54
54
  return "Hello world";
55
55
  }
56
56
  `,
57
+ rust: `fn main() -> Result<(), String> {
58
+ println!("Hello World");
59
+ Ok(())
60
+ }
61
+ `,
62
+ ansible: `---
63
+ inventory:
64
+ - resource_type: ansible_inventory
65
+ ---
66
+ - name: Echo
67
+ hosts: 127.0.0.1
68
+ connection: local
69
+
70
+ tasks:
71
+ - name: Print debug message
72
+ debug:
73
+ msg: "Hello, world!"
74
+ `
57
75
  };
package/esm/context.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // deno-lint-ignore-file no-explicit-any
2
2
  import * as dntShim from "./_dnt.shims.js";
3
- import { colors, log, setClient, UserService } from "./deps.js";
3
+ import { colors, log, setClient } from "./deps.js";
4
+ import * as wmill from "./gen/services.gen.js";
4
5
  import { loginInteractive, tryGetLoginInfo } from "./login.js";
5
6
  import { getHeaders } from "./utils.js";
6
7
  import { addWorkspace, getActiveWorkspace, getWorkspaceByName, removeWorkspace, } from "./workspace.js";
@@ -60,7 +61,7 @@ export async function requireLogin(opts) {
60
61
  }
61
62
  setClient(token, workspace.remote.substring(0, workspace.remote.length - 1));
62
63
  try {
63
- return await UserService.globalWhoami();
64
+ return await wmill.globalWhoami();
64
65
  }
65
66
  catch {
66
67
  log.info("! Could not reach API given existing credentials. Attempting to reauth...");
@@ -72,7 +73,7 @@ export async function requireLogin(opts) {
72
73
  workspace.token = newToken;
73
74
  addWorkspace(workspace, opts);
74
75
  setClient(token, workspace.remote.substring(0, workspace.remote.length - 1));
75
- return await UserService.globalWhoami();
76
+ return await wmill.globalWhoami();
76
77
  }
77
78
  }
78
79
  export async function fetchVersion(baseUrl) {
package/esm/deps.js CHANGED
@@ -1,6 +1,5 @@
1
- // windmill
2
- export * from "windmill-client";
3
1
  // cliffy
2
+ import * as dntShim from "./_dnt.shims.js";
4
3
  export { Command } from "./deps/jsr.io/@windmill-labs/cliffy-command/1.0.0-rc.5/mod.js";
5
4
  export { Table } from "./deps/jsr.io/@windmill-labs/cliffy-table/1.0.0-rc.5/mod.js";
6
5
  export { colors } from "./deps/jsr.io/@windmill-labs/cliffy-ansi/1.0.0-rc.5/colors.js";
@@ -32,3 +31,21 @@ export { WebSocketServer, WebSocket } from "ws";
32
31
  export * as getPort from "get-port";
33
32
  export * as open from "open";
34
33
  export * as esMain from "es-main";
34
+ import { OpenAPI } from "./gen/index.js";
35
+ export function setClient(token, baseUrl) {
36
+ if (baseUrl === undefined) {
37
+ baseUrl =
38
+ getEnv("BASE_INTERNAL_URL") ??
39
+ getEnv("BASE_URL") ??
40
+ "http://localhost:8000";
41
+ }
42
+ if (token === undefined) {
43
+ token = getEnv("WM_TOKEN") ?? "no_token";
44
+ }
45
+ OpenAPI.WITH_CREDENTIALS = true;
46
+ OpenAPI.TOKEN = token;
47
+ OpenAPI.BASE = baseUrl + "/api";
48
+ }
49
+ const getEnv = (key) => {
50
+ return dntShim.Deno.env.get(key);
51
+ };
package/esm/flow.js CHANGED
@@ -2,7 +2,8 @@
2
2
  import * as dntShim from "./_dnt.shims.js";
3
3
  import { isSuperset } from "./types.js";
4
4
  import { Confirm, SEP, log, yamlStringify } from "./deps.js";
5
- import { colors, Command, FlowService, JobService, Table, yamlParse, } from "./deps.js";
5
+ import { colors, Command, Table, yamlParse } from "./deps.js";
6
+ import * as wmill from "./gen/services.gen.js";
6
7
  import { requireLogin, resolveWorkspace, validatePath } from "./context.js";
7
8
  import { resolve, track_job } from "./script.js";
8
9
  import { defaultFlowDefinition } from "./bootstrap/flow_bootstrap.js";
@@ -55,7 +56,7 @@ export async function pushFlow(workspace, remotePath, localPath, message) {
55
56
  remotePath = remotePath.replaceAll(SEP, "/");
56
57
  let flow = undefined;
57
58
  try {
58
- flow = await FlowService.getFlowByPath({
59
+ flow = await wmill.getFlowByPath({
59
60
  workspace: workspace,
60
61
  path: remotePath,
61
62
  });
@@ -75,7 +76,7 @@ export async function pushFlow(workspace, remotePath, localPath, message) {
75
76
  return;
76
77
  }
77
78
  log.info(colors.bold.yellow(`Updating flow ${remotePath}...`));
78
- await FlowService.updateFlow({
79
+ await wmill.updateFlow({
79
80
  workspace: workspace,
80
81
  path: remotePath.replaceAll(SEP, "/"),
81
82
  requestBody: {
@@ -88,7 +89,7 @@ export async function pushFlow(workspace, remotePath, localPath, message) {
88
89
  else {
89
90
  log.info(colors.bold.yellow("Creating new flow..."));
90
91
  try {
91
- await FlowService.createFlow({
92
+ await wmill.createFlow({
92
93
  workspace: workspace,
93
94
  requestBody: {
94
95
  path: remotePath.replaceAll(SEP, "/"),
@@ -118,7 +119,7 @@ async function list(opts) {
118
119
  const perPage = 10;
119
120
  const total = [];
120
121
  while (true) {
121
- const res = await FlowService.listFlows({
122
+ const res = await wmill.listFlows({
122
123
  workspace: workspace.workspaceId,
123
124
  page,
124
125
  perPage,
@@ -142,14 +143,14 @@ async function run(opts, path) {
142
143
  const workspace = await resolveWorkspace(opts);
143
144
  await requireLogin(opts);
144
145
  const input = opts.data ? await resolve(opts.data) : {};
145
- const id = await JobService.runFlowByPath({
146
+ const id = await wmill.runFlowByPath({
146
147
  workspace: workspace.workspaceId,
147
148
  path,
148
149
  requestBody: input,
149
150
  });
150
151
  let i = 0;
151
152
  while (true) {
152
- const jobInfo = await JobService.getJob({
153
+ const jobInfo = await wmill.getJob({
153
154
  workspace: workspace.workspaceId,
154
155
  id,
155
156
  });
@@ -176,7 +177,7 @@ async function run(opts, path) {
176
177
  log.info(colors.green.underline.bold("Flow ran to completion"));
177
178
  log.info("\n");
178
179
  }
179
- const jobInfo = await JobService.getCompletedJob({
180
+ const jobInfo = await wmill.getCompletedJob({
180
181
  workspace: workspace.workspaceId,
181
182
  id,
182
183
  });
package/esm/folder.js CHANGED
@@ -1,12 +1,13 @@
1
1
  // deno-lint-ignore-file no-explicit-any
2
2
  import * as dntShim from "./_dnt.shims.js";
3
- import { colors, Command, FolderService, log, SEP, Table, } from "./deps.js";
3
+ import { colors, Command, log, SEP, Table } from "./deps.js";
4
+ import * as wmill from "./gen/services.gen.js";
4
5
  import { requireLogin, resolveWorkspace, validatePath } from "./context.js";
5
6
  import { isSuperset, parseFromFile } from "./types.js";
6
7
  async function list(opts) {
7
8
  const workspace = await resolveWorkspace(opts);
8
9
  await requireLogin(opts);
9
- const folders = await FolderService.listFolders({
10
+ const folders = await wmill.listFolders({
10
11
  workspace: workspace.workspaceId,
11
12
  });
12
13
  new Table()
@@ -31,7 +32,7 @@ export async function pushFolder(workspace, name, folder, localFolder) {
31
32
  log.debug(`Processing local folder ${name}`);
32
33
  // deleting old app if it exists in raw mode
33
34
  try {
34
- folder = await FolderService.getFolder({ workspace, name });
35
+ folder = await wmill.getFolder({ workspace, name });
35
36
  log.debug(`Folder ${name} exists on remote`);
36
37
  }
37
38
  catch {
@@ -45,7 +46,7 @@ export async function pushFolder(workspace, name, folder, localFolder) {
45
46
  }
46
47
  log.debug(`Folder ${name} is not up-to-date, updating...`);
47
48
  try {
48
- await FolderService.updateFolder({
49
+ await wmill.updateFolder({
49
50
  workspace: workspace,
50
51
  name: name,
51
52
  requestBody: {
@@ -61,7 +62,7 @@ export async function pushFolder(workspace, name, folder, localFolder) {
61
62
  else {
62
63
  console.log(colors.bold.yellow("Creating new folder: " + name));
63
64
  try {
64
- await FolderService.createFolder({
65
+ await wmill.createFolder({
65
66
  workspace: workspace,
66
67
  requestBody: {
67
68
  name: name,
@@ -0,0 +1,41 @@
1
+ export class ApiError extends Error {
2
+ constructor(request, response, message) {
3
+ super(message);
4
+ Object.defineProperty(this, "url", {
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true,
8
+ value: void 0
9
+ });
10
+ Object.defineProperty(this, "status", {
11
+ enumerable: true,
12
+ configurable: true,
13
+ writable: true,
14
+ value: void 0
15
+ });
16
+ Object.defineProperty(this, "statusText", {
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true,
20
+ value: void 0
21
+ });
22
+ Object.defineProperty(this, "body", {
23
+ enumerable: true,
24
+ configurable: true,
25
+ writable: true,
26
+ value: void 0
27
+ });
28
+ Object.defineProperty(this, "request", {
29
+ enumerable: true,
30
+ configurable: true,
31
+ writable: true,
32
+ value: void 0
33
+ });
34
+ this.name = 'ApiError';
35
+ this.url = response.url;
36
+ this.status = response.status;
37
+ this.statusText = response.statusText;
38
+ this.body = response.body;
39
+ this.request = request;
40
+ }
41
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,130 @@
1
+ export class CancelError extends Error {
2
+ constructor(message) {
3
+ super(message);
4
+ this.name = 'CancelError';
5
+ }
6
+ get isCancelled() {
7
+ return true;
8
+ }
9
+ }
10
+ export class CancelablePromise {
11
+ constructor(executor) {
12
+ Object.defineProperty(this, "_isResolved", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: void 0
17
+ });
18
+ Object.defineProperty(this, "_isRejected", {
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true,
22
+ value: void 0
23
+ });
24
+ Object.defineProperty(this, "_isCancelled", {
25
+ enumerable: true,
26
+ configurable: true,
27
+ writable: true,
28
+ value: void 0
29
+ });
30
+ Object.defineProperty(this, "cancelHandlers", {
31
+ enumerable: true,
32
+ configurable: true,
33
+ writable: true,
34
+ value: void 0
35
+ });
36
+ Object.defineProperty(this, "promise", {
37
+ enumerable: true,
38
+ configurable: true,
39
+ writable: true,
40
+ value: void 0
41
+ });
42
+ Object.defineProperty(this, "_resolve", {
43
+ enumerable: true,
44
+ configurable: true,
45
+ writable: true,
46
+ value: void 0
47
+ });
48
+ Object.defineProperty(this, "_reject", {
49
+ enumerable: true,
50
+ configurable: true,
51
+ writable: true,
52
+ value: void 0
53
+ });
54
+ this._isResolved = false;
55
+ this._isRejected = false;
56
+ this._isCancelled = false;
57
+ this.cancelHandlers = [];
58
+ this.promise = new Promise((resolve, reject) => {
59
+ this._resolve = resolve;
60
+ this._reject = reject;
61
+ const onResolve = (value) => {
62
+ if (this._isResolved || this._isRejected || this._isCancelled) {
63
+ return;
64
+ }
65
+ this._isResolved = true;
66
+ if (this._resolve)
67
+ this._resolve(value);
68
+ };
69
+ const onReject = (reason) => {
70
+ if (this._isResolved || this._isRejected || this._isCancelled) {
71
+ return;
72
+ }
73
+ this._isRejected = true;
74
+ if (this._reject)
75
+ this._reject(reason);
76
+ };
77
+ const onCancel = (cancelHandler) => {
78
+ if (this._isResolved || this._isRejected || this._isCancelled) {
79
+ return;
80
+ }
81
+ this.cancelHandlers.push(cancelHandler);
82
+ };
83
+ Object.defineProperty(onCancel, 'isResolved', {
84
+ get: () => this._isResolved,
85
+ });
86
+ Object.defineProperty(onCancel, 'isRejected', {
87
+ get: () => this._isRejected,
88
+ });
89
+ Object.defineProperty(onCancel, 'isCancelled', {
90
+ get: () => this._isCancelled,
91
+ });
92
+ return executor(onResolve, onReject, onCancel);
93
+ });
94
+ }
95
+ get [Symbol.toStringTag]() {
96
+ return "Cancellable Promise";
97
+ }
98
+ then(onFulfilled, onRejected) {
99
+ return this.promise.then(onFulfilled, onRejected);
100
+ }
101
+ catch(onRejected) {
102
+ return this.promise.catch(onRejected);
103
+ }
104
+ finally(onFinally) {
105
+ return this.promise.finally(onFinally);
106
+ }
107
+ cancel() {
108
+ if (this._isResolved || this._isRejected || this._isCancelled) {
109
+ return;
110
+ }
111
+ this._isCancelled = true;
112
+ if (this.cancelHandlers.length) {
113
+ try {
114
+ for (const cancelHandler of this.cancelHandlers) {
115
+ cancelHandler();
116
+ }
117
+ }
118
+ catch (error) {
119
+ console.warn('Cancellation threw an error', error);
120
+ return;
121
+ }
122
+ }
123
+ this.cancelHandlers.length = 0;
124
+ if (this._reject)
125
+ this._reject(new CancelError('Request aborted'));
126
+ }
127
+ get isCancelled() {
128
+ return this._isCancelled;
129
+ }
130
+ }
@@ -0,0 +1,41 @@
1
+ import * as dntShim from "../../_dnt.shims.js";
2
+ const getEnv = (key) => {
3
+ return dntShim.Deno.env.get(key);
4
+ };
5
+ const baseUrl = getEnv("BASE_INTERNAL_URL") ?? getEnv("BASE_URL") ?? "http://localhost:8000";
6
+ const baseUrlApi = (baseUrl ?? '') + "/api";
7
+ export class Interceptors {
8
+ constructor() {
9
+ Object.defineProperty(this, "_fns", {
10
+ enumerable: true,
11
+ configurable: true,
12
+ writable: true,
13
+ value: void 0
14
+ });
15
+ this._fns = [];
16
+ }
17
+ eject(fn) {
18
+ const index = this._fns.indexOf(fn);
19
+ if (index !== -1) {
20
+ this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)];
21
+ }
22
+ }
23
+ use(fn) {
24
+ this._fns = [...this._fns, fn];
25
+ }
26
+ }
27
+ export const OpenAPI = {
28
+ BASE: baseUrlApi,
29
+ CREDENTIALS: 'include',
30
+ ENCODE_PATH: undefined,
31
+ HEADERS: undefined,
32
+ PASSWORD: undefined,
33
+ TOKEN: getEnv("WM_TOKEN"),
34
+ USERNAME: undefined,
35
+ VERSION: '1.397.3',
36
+ WITH_CREDENTIALS: true,
37
+ interceptors: {
38
+ request: new Interceptors(),
39
+ response: new Interceptors(),
40
+ },
41
+ };