windmill-utils-internal 1.0.0 → 1.1.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/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Windmill Utils Internal
2
+
3
+ Internal TypeScript utility package for Windmill development tools and scripts.
4
+
5
+ ## What this package contains
6
+
7
+ This package provides internal utilities and tools used by the Windmill CLI, the VS CODE extension, and the frontend.
8
+
9
+ ## Development
10
+
11
+ To work on this package we need to generate the windmill client, and remove .ts extensions to the imports and exports (added by default for deno compatibility, so that the CLI can use this package).
12
+
13
+ You just need to run this before working on the package:
14
+
15
+ ```bash
16
+ npm run dev
17
+ ```
18
+
19
+ After you are done with your modifications, add back the .ts extensions:
20
+
21
+ ```bash
22
+ ./remove-ts-ext.sh -r
23
+ ```
24
+
25
+ ### Building
26
+
27
+ To build the package for production:
28
+
29
+ ```bash
30
+ npm run build
31
+ ```
32
+
33
+ ### Publishing
34
+
35
+ To publish the package:
36
+
37
+ ```bash
38
+ ./publish.sh
39
+ ```
@@ -0,0 +1,11 @@
1
+ export declare const WINDMILL_CONFIG_DIR = "windmill";
2
+ export declare const WINDMILL_ACTIVE_WORKSPACE_FILE = "activeWorkspace";
3
+ export declare const WINDMILL_WORKSPACE_CONFIG_FILE = "remotes.ndjson";
4
+ export declare const INSTANCES_CONFIG_FILE = "instances.ndjson";
5
+ export declare const WINDMILL_ACTIVE_INSTANCE_FILE = "activeInstance";
6
+ export declare function getBaseConfigDir(configDirOverride?: string): Promise<string>;
7
+ export declare function getConfigDirPath(configDirOverride?: string): Promise<string>;
8
+ export declare function getWorkspaceConfigFilePath(configDirOverride?: string): Promise<string>;
9
+ export declare function getActiveWorkspaceConfigFilePath(configDirOverride?: string): Promise<string>;
10
+ export declare function getInstancesConfigFilePath(configDirOverride?: string): Promise<string>;
11
+ export declare function getActiveInstanceFilePath(configDirOverride?: string): Promise<string>;
@@ -0,0 +1,231 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.WINDMILL_ACTIVE_INSTANCE_FILE = exports.INSTANCES_CONFIG_FILE = exports.WINDMILL_WORKSPACE_CONFIG_FILE = exports.WINDMILL_ACTIVE_WORKSPACE_FILE = exports.WINDMILL_CONFIG_DIR = void 0;
37
+ exports.getBaseConfigDir = getBaseConfigDir;
38
+ exports.getConfigDirPath = getConfigDirPath;
39
+ exports.getWorkspaceConfigFilePath = getWorkspaceConfigFilePath;
40
+ exports.getActiveWorkspaceConfigFilePath = getActiveWorkspaceConfigFilePath;
41
+ exports.getInstancesConfigFilePath = getInstancesConfigFilePath;
42
+ exports.getActiveInstanceFilePath = getActiveInstanceFilePath;
43
+ // Runtime detection
44
+ // @ts-ignore - Cross-platform runtime detection
45
+ const isDeno = typeof Deno !== "undefined";
46
+ // @ts-ignore - Cross-platform runtime detection
47
+ const isNode = typeof process !== "undefined" && process.versions?.node;
48
+ exports.WINDMILL_CONFIG_DIR = "windmill";
49
+ exports.WINDMILL_ACTIVE_WORKSPACE_FILE = "activeWorkspace";
50
+ exports.WINDMILL_WORKSPACE_CONFIG_FILE = "remotes.ndjson";
51
+ exports.INSTANCES_CONFIG_FILE = "instances.ndjson";
52
+ exports.WINDMILL_ACTIVE_INSTANCE_FILE = "activeInstance";
53
+ // Cross-platform environment variable access
54
+ function getEnv(key) {
55
+ if (isDeno) {
56
+ // @ts-ignore - Deno API
57
+ return Deno.env.get(key);
58
+ }
59
+ else {
60
+ // @ts-ignore - Node API
61
+ return process.env[key];
62
+ }
63
+ }
64
+ // Cross-platform OS detection with normalization
65
+ function getOS() {
66
+ if (isDeno) {
67
+ // @ts-ignore - Deno API
68
+ return Deno.build.os;
69
+ }
70
+ else if (isNode) {
71
+ // @ts-ignore - Node API
72
+ const platform = process.platform;
73
+ switch (platform) {
74
+ case "linux": return "linux";
75
+ case "darwin": return "darwin";
76
+ case "win32": return "windows"; // Normalize win32 to windows
77
+ default: return null;
78
+ }
79
+ }
80
+ return null;
81
+ }
82
+ // Cross-platform file system operations
83
+ async function stat(path) {
84
+ if (isDeno) {
85
+ // @ts-ignore - Deno API
86
+ return await Deno.stat(path);
87
+ }
88
+ else {
89
+ // @ts-ignore - Node API
90
+ const fs = await Promise.resolve().then(() => __importStar(require('fs/promises')));
91
+ return await fs.stat(path);
92
+ }
93
+ }
94
+ async function mkdir(path, options) {
95
+ if (isDeno) {
96
+ // @ts-ignore - Deno API
97
+ await Deno.mkdir(path, options);
98
+ }
99
+ else {
100
+ // @ts-ignore - Node API
101
+ const fs = await Promise.resolve().then(() => __importStar(require('fs/promises')));
102
+ await fs.mkdir(path, options);
103
+ }
104
+ }
105
+ function throwIfNotDirectory(fileInfo) {
106
+ if (!fileInfo.isDirectory) {
107
+ throw new Error("Path is not a directory");
108
+ }
109
+ }
110
+ function config_dir() {
111
+ const os = getOS();
112
+ switch (os) {
113
+ case "linux": {
114
+ const xdg = getEnv("XDG_CONFIG_HOME");
115
+ if (xdg)
116
+ return xdg;
117
+ const home = getEnv("HOME");
118
+ if (home)
119
+ return `${home}/.config`;
120
+ break;
121
+ }
122
+ case "darwin": {
123
+ const home = getEnv("HOME");
124
+ if (home)
125
+ return `${home}/Library/Preferences`;
126
+ break;
127
+ }
128
+ case "windows":
129
+ return getEnv("APPDATA") ?? null;
130
+ }
131
+ return null;
132
+ }
133
+ function tmp_dir() {
134
+ const os = getOS();
135
+ switch (os) {
136
+ case "linux": {
137
+ const xdg = getEnv("XDG_RUNTIME_DIR");
138
+ if (xdg)
139
+ return `${xdg}-/tmp`;
140
+ const tmpDir = getEnv("TMPDIR");
141
+ if (tmpDir)
142
+ return tmpDir;
143
+ const tempDir = getEnv("TEMP");
144
+ if (tempDir)
145
+ return tempDir;
146
+ const tmp = getEnv("TMP");
147
+ if (tmp)
148
+ return tmp;
149
+ return "/var/tmp";
150
+ }
151
+ case "darwin":
152
+ return getEnv("TMPDIR") ?? null;
153
+ case "windows":
154
+ return getEnv("TMP") ?? getEnv("TEMP") ?? null;
155
+ }
156
+ return null;
157
+ }
158
+ async function ensureDir(dir) {
159
+ try {
160
+ const fileInfo = await stat(dir);
161
+ throwIfNotDirectory(fileInfo);
162
+ return;
163
+ }
164
+ catch (err) {
165
+ // Check for file not found error in cross-platform way
166
+ if (isDeno) {
167
+ // @ts-ignore - Deno API
168
+ if (!(err instanceof Deno.errors.NotFound)) {
169
+ throw err;
170
+ }
171
+ }
172
+ else {
173
+ // Node.js error codes
174
+ if (err.code !== 'ENOENT') {
175
+ throw err;
176
+ }
177
+ }
178
+ }
179
+ // The dir doesn't exist. Create it.
180
+ // This can be racy. So we catch AlreadyExists and check stat again.
181
+ try {
182
+ await mkdir(dir, { recursive: true });
183
+ }
184
+ catch (err) {
185
+ // Check for already exists error in cross-platform way
186
+ if (isDeno) {
187
+ // @ts-ignore - Deno API
188
+ if (!(err instanceof Deno.errors.AlreadyExists)) {
189
+ throw err;
190
+ }
191
+ }
192
+ else {
193
+ // Node.js error codes
194
+ if (err.code !== 'EEXIST') {
195
+ throw err;
196
+ }
197
+ }
198
+ const fileInfo = await stat(dir);
199
+ throwIfNotDirectory(fileInfo);
200
+ }
201
+ }
202
+ async function getBaseConfigDir(configDirOverride) {
203
+ const baseDir = configDirOverride ??
204
+ getEnv("WMILL_CONFIG_DIR") ??
205
+ config_dir() ??
206
+ tmp_dir() ??
207
+ "/tmp/";
208
+ return baseDir;
209
+ }
210
+ async function getConfigDirPath(configDirOverride) {
211
+ const baseDir = await getBaseConfigDir(configDirOverride);
212
+ const store = baseDir + `/${exports.WINDMILL_CONFIG_DIR}/`;
213
+ await ensureDir(store);
214
+ return store;
215
+ }
216
+ async function getWorkspaceConfigFilePath(configDirOverride) {
217
+ const configDir = await getConfigDirPath(configDirOverride);
218
+ return `${configDir}/${exports.WINDMILL_WORKSPACE_CONFIG_FILE}`;
219
+ }
220
+ async function getActiveWorkspaceConfigFilePath(configDirOverride) {
221
+ const configDir = await getConfigDirPath(configDirOverride);
222
+ return `${configDir}/${exports.WINDMILL_ACTIVE_WORKSPACE_FILE}`;
223
+ }
224
+ async function getInstancesConfigFilePath(configDirOverride) {
225
+ const configDir = await getConfigDirPath(configDirOverride);
226
+ return `${configDir}/${exports.INSTANCES_CONFIG_FILE}`;
227
+ }
228
+ async function getActiveInstanceFilePath(configDirOverride) {
229
+ const configDir = await getConfigDirPath(configDirOverride);
230
+ return `${configDir}/${exports.WINDMILL_ACTIVE_INSTANCE_FILE}`;
231
+ }
@@ -0,0 +1 @@
1
+ export * from "./config";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./config"), exports);
@@ -30,7 +30,7 @@ exports.OpenAPI = {
30
30
  PASSWORD: undefined,
31
31
  TOKEN: getEnv("WM_TOKEN"),
32
32
  USERNAME: undefined,
33
- VERSION: '1.516.0',
33
+ VERSION: '1.538.0',
34
34
  WITH_CREDENTIALS: true,
35
35
  interceptors: {
36
36
  request: new Interceptors(),