windmill-client 0.3.5 → 0.3.6

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 (151) hide show
  1. package/package.json +9 -2
  2. package/build.sh +0 -8
  3. package/client.ts +0 -364
  4. package/publish.sh +0 -5
  5. package/src/client.ts +0 -364
  6. package/src/core/ApiError.ts +0 -25
  7. package/src/core/ApiRequestOptions.ts +0 -17
  8. package/src/core/ApiResult.ts +0 -11
  9. package/src/core/CancelablePromise.ts +0 -131
  10. package/src/core/OpenAPI.ts +0 -32
  11. package/src/core/request.ts +0 -322
  12. package/src/index.ts +0 -148
  13. package/src/models/AccountId.ts +0 -6
  14. package/src/models/ActionKind.ts +0 -14
  15. package/src/models/After.ts +0 -9
  16. package/src/models/AppWithLastVersion.ts +0 -32
  17. package/src/models/AppWithLastVersionWDraft.ts +0 -12
  18. package/src/models/ArgsFilter.ts +0 -9
  19. package/src/models/AuditLog.ts +0 -43
  20. package/src/models/Before.ts +0 -9
  21. package/src/models/BranchAll.ts +0 -17
  22. package/src/models/BranchOne.ts +0 -17
  23. package/src/models/ClientName.ts +0 -6
  24. package/src/models/CompletedJob.ts +0 -73
  25. package/src/models/ContextualVariable.ts +0 -11
  26. package/src/models/CreateInput.ts +0 -10
  27. package/src/models/CreateResource.ts +0 -12
  28. package/src/models/CreateVariable.ts +0 -14
  29. package/src/models/CreateWorkspace.ts +0 -11
  30. package/src/models/CreatedBy.ts +0 -9
  31. package/src/models/EditResource.ts +0 -11
  32. package/src/models/EditResourceType.ts +0 -10
  33. package/src/models/EditSchedule.ts +0 -14
  34. package/src/models/EditVariable.ts +0 -12
  35. package/src/models/EditWorkspaceUser.ts +0 -11
  36. package/src/models/Flow.ts +0 -10
  37. package/src/models/FlowMetadata.ts +0 -17
  38. package/src/models/FlowModule.ts +0 -33
  39. package/src/models/FlowModuleValue.ts +0 -17
  40. package/src/models/FlowPreview.ts +0 -14
  41. package/src/models/FlowStatus.ts +0 -19
  42. package/src/models/FlowStatusModule.ts +0 -44
  43. package/src/models/FlowValue.ts +0 -13
  44. package/src/models/Folder.ts +0 -11
  45. package/src/models/ForloopFlow.ts +0 -16
  46. package/src/models/GlobalUserInfo.ts +0 -24
  47. package/src/models/Graphql.ts +0 -9
  48. package/src/models/Group.ts +0 -12
  49. package/src/models/Http.ts +0 -9
  50. package/src/models/Identity.ts +0 -10
  51. package/src/models/IncludeHeader.ts +0 -11
  52. package/src/models/Input.ts +0 -14
  53. package/src/models/InputId.ts +0 -6
  54. package/src/models/InputTransform.ts +0 -10
  55. package/src/models/JavascriptTransform.ts +0 -10
  56. package/src/models/Job.ts +0 -22
  57. package/src/models/JobId.ts +0 -6
  58. package/src/models/JobKinds.ts +0 -9
  59. package/src/models/ListableApp.ts +0 -28
  60. package/src/models/ListableRawApp.ts +0 -15
  61. package/src/models/ListableResource.ts +0 -20
  62. package/src/models/ListableVariable.ts +0 -20
  63. package/src/models/Login.ts +0 -10
  64. package/src/models/MainArgSignature.ts +0 -43
  65. package/src/models/Name.ts +0 -6
  66. package/src/models/NewJobId.ts +0 -9
  67. package/src/models/NewSchedule.ts +0 -18
  68. package/src/models/NewScript.ts +0 -44
  69. package/src/models/NewScriptWithDraft.ts +0 -12
  70. package/src/models/NewToken.ts +0 -11
  71. package/src/models/NewTokenImpersonate.ts +0 -11
  72. package/src/models/NewUser.ts +0 -11
  73. package/src/models/OpenFlow.ts +0 -14
  74. package/src/models/OpenFlowWPath.ts +0 -11
  75. package/src/models/Operation.ts +0 -9
  76. package/src/models/OrderDesc.ts +0 -9
  77. package/src/models/Page.ts +0 -9
  78. package/src/models/ParentJob.ts +0 -9
  79. package/src/models/Path.ts +0 -6
  80. package/src/models/PathFlow.ts +0 -13
  81. package/src/models/PathId.ts +0 -6
  82. package/src/models/PathScript.ts +0 -14
  83. package/src/models/Payload.ts +0 -11
  84. package/src/models/PerPage.ts +0 -9
  85. package/src/models/Policy.ts +0 -23
  86. package/src/models/Preview.ts +0 -37
  87. package/src/models/QueueLimit.ts +0 -10
  88. package/src/models/QueuedJob.ts +0 -71
  89. package/src/models/RawScript.ts +0 -31
  90. package/src/models/Resource.ts +0 -15
  91. package/src/models/ResourceName.ts +0 -9
  92. package/src/models/ResourceType.ts +0 -12
  93. package/src/models/ResultFilter.ts +0 -9
  94. package/src/models/Retry.ts +0 -17
  95. package/src/models/RunnableId.ts +0 -6
  96. package/src/models/RunnableType.ts +0 -10
  97. package/src/models/RunnableTypeQuery.ts +0 -8
  98. package/src/models/Running.ts +0 -9
  99. package/src/models/Schedule.ts +0 -23
  100. package/src/models/SchedulePath.ts +0 -9
  101. package/src/models/ScheduleWJobs.ts +0 -15
  102. package/src/models/Script.ts +0 -58
  103. package/src/models/ScriptArgs.ts +0 -6
  104. package/src/models/ScriptExactHash.ts +0 -9
  105. package/src/models/ScriptExactPath.ts +0 -9
  106. package/src/models/ScriptHash.ts +0 -6
  107. package/src/models/ScriptPath.ts +0 -6
  108. package/src/models/ScriptStartPath.ts +0 -9
  109. package/src/models/SlackToken.ts +0 -14
  110. package/src/models/StartedAfter.ts +0 -9
  111. package/src/models/StartedBefore.ts +0 -9
  112. package/src/models/StaticTransform.ts +0 -10
  113. package/src/models/Success.ts +0 -9
  114. package/src/models/Suspended.ts +0 -9
  115. package/src/models/Tag.ts +0 -9
  116. package/src/models/Token.ts +0 -6
  117. package/src/models/TokenResponse.ts +0 -12
  118. package/src/models/TruncatedToken.ts +0 -14
  119. package/src/models/UpdateInput.ts +0 -11
  120. package/src/models/Usage.ts +0 -9
  121. package/src/models/User.ts +0 -21
  122. package/src/models/UserWorkspaceList.ts +0 -14
  123. package/src/models/Username.ts +0 -9
  124. package/src/models/VersionId.ts +0 -6
  125. package/src/models/WorkerPing.ts +0 -14
  126. package/src/models/Workspace.ts +0 -12
  127. package/src/models/WorkspaceId.ts +0 -6
  128. package/src/models/WorkspaceInvite.ts +0 -12
  129. package/src/services/AdminService.ts +0 -91
  130. package/src/services/AppService.ts +0 -385
  131. package/src/services/AuditService.ts +0 -104
  132. package/src/services/CaptureService.ts +0 -80
  133. package/src/services/DraftService.ts +0 -63
  134. package/src/services/FavoriteService.ts +0 -63
  135. package/src/services/FlowService.ts +0 -369
  136. package/src/services/FolderService.ts +0 -270
  137. package/src/services/GranularAclService.ts +0 -105
  138. package/src/services/GroupService.ts +0 -239
  139. package/src/services/InputService.ts +0 -176
  140. package/src/services/JobService.ts +0 -1471
  141. package/src/services/OauthService.ts +0 -198
  142. package/src/services/RawAppService.ts +0 -210
  143. package/src/services/ResourceService.ts +0 -401
  144. package/src/services/ScheduleService.ts +0 -258
  145. package/src/services/ScriptService.ts +0 -517
  146. package/src/services/SettingsService.ts +0 -59
  147. package/src/services/UserService.ts +0 -614
  148. package/src/services/VariableService.ts +0 -221
  149. package/src/services/WorkerService.ts +0 -53
  150. package/src/services/WorkspaceService.ts +0 -494
  151. package/tsconfig.json +0 -110
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "windmill-client",
3
3
  "description": "Windmill SDK client for browsers and Node.js",
4
- "version": "0.3.5",
4
+ "version": "0.3.6",
5
5
  "author": "Ruben Fiszel",
6
6
  "license": "Apache 2.0",
7
7
  "devDependencies": {
@@ -9,5 +9,12 @@
9
9
  },
10
10
  "main": "dist/index.js",
11
11
  "types": "dist/index.d.ts",
12
- "prepublish": "tsc"
12
+ "prepublish": "tsc",
13
+ "files": [
14
+ "dist",
15
+ "LICENSE",
16
+ "README.md",
17
+ "package.json"
18
+ ],
19
+ "type": "module"
13
20
  }
package/build.sh DELETED
@@ -1,8 +0,0 @@
1
- #!/bin/bash
2
- set -e
3
-
4
- npx --yes openapi-typescript-codegen --input ../backend/windmill-api/openapi.yaml \
5
- --output ./src --useOptions \
6
- && sed -i '213 i \\ request.referrerPolicy = \"no-referrer\"\n' src/core/request.ts
7
-
8
- cp client.ts src/
package/client.ts DELETED
@@ -1,364 +0,0 @@
1
- import { JobService, ResourceService, VariableService } from "./index";
2
- import { OpenAPI } from "./index";
3
-
4
- export {
5
- AdminService,
6
- AuditService,
7
- FlowService,
8
- GranularAclService,
9
- GroupService,
10
- JobService,
11
- ResourceService,
12
- VariableService,
13
- ScriptService,
14
- ScheduleService,
15
- SettingsService,
16
- UserService,
17
- WorkspaceService,
18
- } from "./index";
19
-
20
- export type Sql = string;
21
- export type Email = string;
22
- export type Base64 = string;
23
- export type Resource<S extends string> = any;
24
-
25
- export const SHARED_FOLDER = "/shared";
26
-
27
- export function setClient(token?: string, baseUrl?: string) {
28
- if (baseUrl === undefined) {
29
- baseUrl =
30
- getEnv("BASE_INTERNAL_URL") ??
31
- getEnv("BASE_URL") ??
32
- "http://localhost:8000";
33
- }
34
- if (token === undefined) {
35
- baseUrl = getEnv("WM_TOKEN") ?? "no_token";
36
- }
37
- OpenAPI.WITH_CREDENTIALS = true;
38
- OpenAPI.TOKEN = token;
39
- OpenAPI.BASE = baseUrl + "/api";
40
- }
41
-
42
- const getEnv = (key: string) => {
43
- if (typeof window === "undefined") {
44
- // node
45
- return process.env[key];
46
- }
47
- // browser
48
- return window.process.env[key];
49
- };
50
-
51
- /**
52
- * Create a client configuration from env variables
53
- * @returns client configuration
54
- */
55
- export function getWorkspace(): string {
56
- return getEnv("WM_WORKSPACE") ?? "no_workspace";
57
- }
58
-
59
- /**
60
- * Get a resource value by path
61
- * @param path path of the resource, default to internal state path
62
- * @param undefinedIfEmpty if the resource does not exist, return undefined instead of throwing an error
63
- * @returns resource value
64
- */
65
- export async function getResource(
66
- path?: string,
67
- undefinedIfEmpty?: boolean
68
- ): Promise<any> {
69
- const workspace = getWorkspace();
70
- path = path ?? getStatePath();
71
- try {
72
- const resource = await ResourceService.getResource({ workspace, path });
73
- return await _transformLeaf(resource.value);
74
- } catch (e: any) {
75
- if (undefinedIfEmpty && e.status === 404) {
76
- return undefined;
77
- } else {
78
- throw Error(`Resource not found at ${path} or not visible to you`);
79
- }
80
- }
81
- }
82
-
83
- /**
84
- * Resolve a resource value in case the default value was picked because the input payload was undefined
85
- * @param obj resource value or path of the resource under the format `$res:path`
86
- * @returns resource value
87
- */
88
- export async function resolveDefaultResource(obj: any): Promise<any> {
89
- if (typeof obj === "string" && obj.startsWith("$res:")) {
90
- return await getResource(obj.substring(5), true);
91
- } else {
92
- return obj;
93
- }
94
- }
95
-
96
- /**
97
- * Get the full resource value by path
98
- * @param path path of the resource, default to internal state path
99
- * @param undefinedIfEmpty if the resource does not exist, return undefined instead of throwing an error
100
- * @returns full resource
101
- */
102
- export async function getFullResource(
103
- path?: string,
104
- undefinedIfEmpty?: boolean
105
- ): Promise<any> {
106
- const workspace = getWorkspace();
107
- path = path ?? getStatePath();
108
- try {
109
- const resource = await ResourceService.getResource({ workspace, path });
110
- const value = await _transformLeaf(resource.value);
111
- return { ...resource, value };
112
- } catch (e: any) {
113
- if (undefinedIfEmpty && e.status === 404) {
114
- return undefined;
115
- } else {
116
- throw Error(`Resource not found at ${path} or not visible to you`);
117
- }
118
- }
119
- }
120
-
121
- export function getStatePath(): string {
122
- const state_path = getEnv("WM_STATE_PATH");
123
- if (state_path === undefined) {
124
- throw Error("State path not set");
125
- }
126
- return state_path;
127
- }
128
-
129
- /**
130
- * Set a resource value by path
131
- * @param path path of the resource to set, default to state path
132
- * @param value new value of the resource to set
133
- * @param initializeToTypeIfNotExist if the resource does not exist, initialize it with this type
134
- */
135
- export async function setResource(
136
- value: any,
137
- path?: string,
138
- initializeToTypeIfNotExist?: string
139
- ): Promise<void> {
140
- path = path ?? getStatePath();
141
- const workspace = getWorkspace();
142
- if (await ResourceService.existsResource({ workspace, path })) {
143
- await ResourceService.updateResourceValue({
144
- workspace,
145
- path,
146
- requestBody: { value },
147
- });
148
- } else if (initializeToTypeIfNotExist) {
149
- await ResourceService.createResource({
150
- workspace,
151
- requestBody: { path, value, resource_type: initializeToTypeIfNotExist },
152
- });
153
- } else {
154
- throw Error(
155
- `Resource at path ${path} does not exist and no type was provided to initialize it`
156
- );
157
- }
158
- }
159
-
160
- /**
161
- * Set the state
162
- * @param state state to set
163
- * @deprecated use setState instead
164
- */
165
- export async function setInternalState(state: any): Promise<void> {
166
- await setResource(state, undefined, "state");
167
- }
168
-
169
- /**
170
- * Set the state
171
- * @param state state to set
172
- */
173
- export async function setState(state: any): Promise<void> {
174
- await setResource(state, undefined, "state");
175
- }
176
-
177
- // /**
178
- // * Set the shared state
179
- // * @param state state to set
180
- // */
181
- // export async function setSharedState(
182
- // state: any,
183
- // path = "state.json"
184
- // ): Promise<void> {
185
- // await Deno.writeTextFile(SHARED_FOLDER + "/" + path, JSON.stringify(state));
186
- // }
187
-
188
- // /**
189
- // * Get the shared state
190
- // * @param state state to set
191
- // */
192
- // export async function getSharedState(path = "state.json"): Promise<any> {
193
- // return JSON.parse(await Deno.readTextFile(SHARED_FOLDER + "/" + path));
194
- // }
195
-
196
- /**
197
- * Get the internal state
198
- * @deprecated use getState instead
199
- */
200
- export async function getInternalState(): Promise<any> {
201
- return await getResource(getStatePath(), true);
202
- }
203
-
204
- /**
205
- * Get the state shared across executions
206
- */
207
- export async function getState(): Promise<any> {
208
- return await getResource(getStatePath(), true);
209
- }
210
-
211
- /**
212
- * Get a variable by path
213
- * @param path path of the variable
214
- * @returns variable value
215
- */
216
- export async function getVariable(path: string): Promise<string | undefined> {
217
- const workspace = getWorkspace();
218
- try {
219
- const variable = await VariableService.getVariable({ workspace, path });
220
- return variable.value;
221
- } catch (e: any) {
222
- throw Error(`Variable not found at ${path} or not visible to you`);
223
- }
224
- }
225
-
226
- /**
227
- * Set a variable by path, create if not exist
228
- * @param path path of the variable
229
- * @param value value of the variable
230
- * @param isSecretIfNotExist if the variable does not exist, create it as secret or not (default: false)
231
- * @param descriptionIfNotExist if the variable does not exist, create it with this description (default: "")
232
- */
233
- export async function setVariable(
234
- path: string,
235
- value: string,
236
- isSecretIfNotExist?: boolean,
237
- descriptionIfNotExist?: string
238
- ): Promise<void> {
239
- const workspace = getWorkspace();
240
- if (await VariableService.existsVariable({ workspace, path })) {
241
- await VariableService.updateVariable({
242
- workspace,
243
- path,
244
- requestBody: { value },
245
- });
246
- } else {
247
- await VariableService.createVariable({
248
- workspace,
249
- requestBody: {
250
- path,
251
- value,
252
- is_secret: isSecretIfNotExist ?? false,
253
- description: descriptionIfNotExist ?? "",
254
- },
255
- });
256
- }
257
- }
258
-
259
- async function transformLeaves(d: {
260
- [key: string]: any;
261
- }): Promise<{ [key: string]: any }> {
262
- for (const k in d) {
263
- d[k] = await _transformLeaf(d[k]);
264
- }
265
- return d;
266
- }
267
-
268
- const VAR_RESOURCE_PREFIX = "$var:";
269
- const RES_RESOURCE_PREFIX = "$res:";
270
- async function _transformLeaf(v: any): Promise<any> {
271
- if (typeof v === "object") {
272
- return transformLeaves(v);
273
- } else if (typeof v === "string" && v.startsWith(VAR_RESOURCE_PREFIX)) {
274
- const varName = v.substring(VAR_RESOURCE_PREFIX.length);
275
- return await getVariable(varName);
276
- } else if (typeof v === "string" && v.startsWith(RES_RESOURCE_PREFIX)) {
277
- const resName = v.substring(RES_RESOURCE_PREFIX.length);
278
- return await getResource(resName);
279
- } else {
280
- return v;
281
- }
282
- }
283
-
284
- export async function databaseUrlFromResource(path: string): Promise<string> {
285
- const resource = await getResource(path);
286
- return `postgresql://${resource.user}:${resource.password}@${resource.host}:${resource.port}/${resource.dbname}?sslmode=${resource.sslmode}`;
287
- }
288
-
289
- // /**
290
- // * Get URLs needed for resuming a flow after this step
291
- // * @param approver approver name
292
- // * @returns approval page UI URL, resume and cancel API URLs for resumeing the flow
293
- // */
294
- // export async function getResumeUrls(approver?: string): Promise<{
295
- // approvalPage: string;
296
- // resume: string;
297
- // cancel: string;
298
- // }> {
299
- // const nonce = Math.floor(Math.random() * 4294967295);
300
- // const workspace = getWorkspace();
301
- // return await JobService.getResumeUrls({
302
- // workspace,
303
- // resumeId: nonce,
304
- // approver,
305
- // id: process.env.get("WM_JOB_ID") ?? "NO_JOB_ID",
306
- // });
307
- // }
308
-
309
- export function base64ToUint8Array(data: string): Uint8Array {
310
- return Uint8Array.from(atob(data), (c) => c.charCodeAt(0));
311
- }
312
-
313
- export function uint8ArrayToBase64(arrayBuffer: Uint8Array): string {
314
- let base64 = "";
315
- const encodings =
316
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
317
-
318
- const bytes = new Uint8Array(arrayBuffer);
319
- const byteLength = bytes.byteLength;
320
- const byteRemainder = byteLength % 3;
321
- const mainLength = byteLength - byteRemainder;
322
-
323
- let a, b, c, d;
324
- let chunk;
325
-
326
- // Main loop deals with bytes in chunks of 3
327
- for (let i = 0; i < mainLength; i = i + 3) {
328
- // Combine the three bytes into a single integer
329
- chunk = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];
330
-
331
- // Use bitmasks to extract 6-bit segments from the triplet
332
- a = (chunk & 16515072) >> 18; // 16515072 = (2^6 - 1) << 18
333
- b = (chunk & 258048) >> 12; // 258048 = (2^6 - 1) << 12
334
- c = (chunk & 4032) >> 6; // 4032 = (2^6 - 1) << 6
335
- d = chunk & 63; // 63 = 2^6 - 1
336
-
337
- // Convert the raw binary segments to the appropriate ASCII encoding
338
- base64 += encodings[a] + encodings[b] + encodings[c] + encodings[d];
339
- }
340
-
341
- // Deal with the remaining bytes and padding
342
- if (byteRemainder == 1) {
343
- chunk = bytes[mainLength];
344
-
345
- a = (chunk & 252) >> 2; // 252 = (2^6 - 1) << 2
346
-
347
- // Set the 4 least significant bits to zero
348
- b = (chunk & 3) << 4; // 3 = 2^2 - 1
349
-
350
- base64 += encodings[a] + encodings[b] + "==";
351
- } else if (byteRemainder == 2) {
352
- chunk = (bytes[mainLength] << 8) | bytes[mainLength + 1];
353
-
354
- a = (chunk & 64512) >> 10; // 64512 = (2^6 - 1) << 10
355
- b = (chunk & 1008) >> 4; // 1008 = (2^6 - 1) << 4
356
-
357
- // Set the 2 least significant bits to zero
358
- c = (chunk & 15) << 2; // 15 = 2^4 - 1
359
-
360
- base64 += encodings[a] + encodings[b] + encodings[c] + "=";
361
- }
362
-
363
- return base64;
364
- }
package/publish.sh DELETED
@@ -1,5 +0,0 @@
1
- ./build.sh
2
- rm client.ts
3
- tsc
4
- cp src/client.ts .
5
- npm publish