windmill-components 1.22.42 → 1.28.1

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 (248) hide show
  1. package/components/AppConnect.svelte +93 -47
  2. package/components/AppConnect.svelte.d.ts +2 -2
  3. package/components/ArgInfo.svelte +0 -5
  4. package/components/ArgInput.svelte +91 -64
  5. package/components/ArgInput.svelte.d.ts +8 -3
  6. package/components/Button.svelte +4 -4
  7. package/components/CenteredPage.svelte +1 -1
  8. package/components/CollapseLink.svelte +12 -0
  9. package/components/CollapseLink.svelte.d.ts +19 -0
  10. package/components/CronInput.svelte +84 -0
  11. package/components/CronInput.svelte.d.ts +18 -0
  12. package/components/DisplayResult.svelte +23 -7
  13. package/components/Editor.svelte +136 -66
  14. package/components/Editor.svelte.d.ts +2 -0
  15. package/components/EditorBar.svelte +56 -45
  16. package/components/FlowBuilder.svelte +150 -71
  17. package/components/FlowEditor.svelte +75 -200
  18. package/components/FlowEditor.svelte.d.ts +3 -2
  19. package/components/FlowJobResult.svelte +1 -1
  20. package/components/FlowPreview.svelte +18 -24
  21. package/components/FlowPreviewContent.svelte +68 -0
  22. package/components/FlowPreviewContent.svelte.d.ts +21 -0
  23. package/components/FlowStatusViewer.svelte +85 -37
  24. package/components/FlowStatusViewer.svelte.d.ts +3 -2
  25. package/components/FlowViewer.svelte +77 -45
  26. package/components/FlowViewer.svelte.d.ts +1 -1
  27. package/components/IconedResourceType.svelte +30 -5
  28. package/components/InputTransformForm.svelte +209 -0
  29. package/components/InputTransformForm.svelte.d.ts +26 -0
  30. package/components/InviteGlobalUser.svelte +2 -2
  31. package/components/InviteUser.svelte +2 -2
  32. package/components/JobStatus.svelte +32 -25
  33. package/components/Modal.svelte +44 -42
  34. package/components/ModuleStep.svelte +94 -79
  35. package/components/ObjectResourceInput.svelte +58 -38
  36. package/components/ObjectTypeNarrowing.svelte +4 -19
  37. package/components/Path.svelte +1 -0
  38. package/components/Path.svelte.d.ts +1 -1
  39. package/components/RadioButton.svelte +11 -96
  40. package/components/RadioButton.svelte.d.ts +4 -2
  41. package/components/ResourceEditor.svelte +4 -5
  42. package/components/ResourceEditor.svelte.d.ts +2 -2
  43. package/components/ResourcePicker.svelte +25 -2
  44. package/components/ResourcePicker.svelte.d.ts +3 -0
  45. package/components/ResourceTypePicker.svelte +17 -29
  46. package/components/ResourceTypePicker.svelte.d.ts +1 -0
  47. package/components/RunForm.svelte +14 -15
  48. package/components/RunForm.svelte.d.ts +1 -1
  49. package/components/SchemaEditor.svelte +87 -71
  50. package/components/SchemaEditor.svelte.d.ts +2 -0
  51. package/components/SchemaEditorProperty.svelte +11 -0
  52. package/components/SchemaEditorProperty.svelte.d.ts +17 -0
  53. package/components/SchemaForm.svelte +21 -127
  54. package/components/SchemaForm.svelte.d.ts +3 -4
  55. package/components/SchemaModal.svelte +20 -33
  56. package/components/SchemaModal.svelte.d.ts +1 -1
  57. package/components/SchemaViewer.svelte +4 -6
  58. package/components/ScriptBuilder.svelte +40 -43
  59. package/components/ScriptEditor.svelte +71 -66
  60. package/components/ScriptPicker.svelte +10 -12
  61. package/components/ScriptPicker.svelte.d.ts +1 -1
  62. package/components/ScriptSchema.svelte +0 -5
  63. package/components/ShareModal.svelte +1 -1
  64. package/components/SharedBadge.svelte +12 -10
  65. package/components/StringTypeNarrowing.svelte +8 -4
  66. package/components/StringTypeNarrowing.svelte.d.ts +1 -0
  67. package/components/TableCustom.svelte +7 -9
  68. package/components/TableSimple.svelte +1 -1
  69. package/components/Toggle.svelte +8 -10
  70. package/components/Toggle.svelte.d.ts +5 -11
  71. package/components/Tooltip.svelte +3 -2
  72. package/components/VariableEditor.svelte +21 -6
  73. package/components/flows/CopyFirstStepSchema.svelte +7 -5
  74. package/components/flows/DynamicInputHelpBox.svelte +1 -1
  75. package/components/flows/FlowBox.svelte +3 -0
  76. package/components/flows/FlowBox.svelte.d.ts +23 -0
  77. package/components/flows/FlowBoxHeader.svelte +9 -0
  78. package/components/flows/FlowBoxHeader.svelte.d.ts +18 -0
  79. package/components/flows/FlowInput.svelte +20 -0
  80. package/components/flows/FlowInput.svelte.d.ts +14 -0
  81. package/components/flows/FlowInputs.svelte +7 -3
  82. package/components/flows/FlowModuleHeader.svelte +42 -40
  83. package/components/flows/FlowModuleHeader.svelte.d.ts +1 -1
  84. package/components/flows/FlowSettings.svelte +174 -0
  85. package/components/flows/FlowSettings.svelte.d.ts +21 -0
  86. package/components/flows/flowStore.d.ts +5 -2
  87. package/components/flows/flowStore.js +65 -9
  88. package/components/flows/pickers/FlowScriptPicker.svelte +6 -1
  89. package/components/flows/pickers/FlowScriptPicker.svelte.d.ts +1 -0
  90. package/components/flows/utils.d.ts +11 -7
  91. package/components/flows/utils.js +104 -43
  92. package/components/icons/AirtableIcon.svelte +17 -0
  93. package/components/icons/AirtableIcon.svelte.d.ts +17 -0
  94. package/components/icons/GCloudIcon.svelte +16 -0
  95. package/components/icons/GCloudIcon.svelte.d.ts +17 -0
  96. package/components/icons/GItlabIcon.svelte +16 -0
  97. package/components/icons/GItlabIcon.svelte.d.ts +17 -0
  98. package/components/icons/GSheetsIcon.svelte +16 -0
  99. package/components/icons/GSheetsIcon.svelte.d.ts +17 -0
  100. package/components/icons/GcalIcon.svelte +16 -0
  101. package/components/icons/GcalIcon.svelte.d.ts +17 -0
  102. package/components/icons/GdriveIcon.svelte +16 -0
  103. package/components/icons/GdriveIcon.svelte.d.ts +17 -0
  104. package/components/icons/GmailIcon.svelte +16 -0
  105. package/components/icons/GmailIcon.svelte.d.ts +17 -0
  106. package/components/icons/PostgresIcon.svelte +8 -49
  107. package/components/icons/Slack.svelte +9 -18
  108. package/components/icons/TogglIcon.svelte +59 -0
  109. package/components/icons/TogglIcon.svelte.d.ts +17 -0
  110. package/components/propertyPicker/ObjectViewer.svelte +35 -37
  111. package/components/propertyPicker/ObjectViewer.svelte.d.ts +1 -0
  112. package/components/propertyPicker/OverlayPropertyPicker.svelte +53 -53
  113. package/components/propertyPicker/OverlayPropertyPicker.svelte.d.ts +5 -2
  114. package/components/propertyPicker/PropPicker.svelte +13 -15
  115. package/components/propertyPicker/PropPicker.svelte.d.ts +1 -1
  116. package/components/propertyPicker/WarningMessage.svelte +14 -41
  117. package/components/propertyPicker/WarningMessage.svelte.d.ts +11 -8
  118. package/components/propertyPicker/utils.d.ts +1 -0
  119. package/components/propertyPicker/utils.js +25 -0
  120. package/gen/core/OpenAPI.js +1 -1
  121. package/gen/index.d.ts +11 -2
  122. package/gen/index.js +1 -2
  123. package/gen/models/CompletedJob.d.ts +1 -1
  124. package/gen/models/Flow.d.ts +3 -13
  125. package/gen/models/FlowMetadata.d.ts +9 -0
  126. package/gen/models/FlowMetadata.js +4 -0
  127. package/gen/models/FlowModuleValue.d.ts +5 -22
  128. package/gen/models/FlowModuleValue.js +1 -15
  129. package/gen/models/ForloopFlow.d.ts +8 -0
  130. package/gen/models/ForloopFlow.js +4 -0
  131. package/gen/models/InputTransform.d.ts +3 -12
  132. package/gen/models/InputTransform.js +1 -8
  133. package/gen/models/JavascriptTransform.d.ts +4 -0
  134. package/gen/models/JavascriptTransform.js +4 -0
  135. package/gen/models/MainArgSignature.d.ts +1 -1
  136. package/gen/models/NewSchedule.d.ts +1 -0
  137. package/gen/models/OpenFlowWPath.d.ts +4 -0
  138. package/gen/models/OpenFlowWPath.js +4 -0
  139. package/gen/models/PathFlow.d.ts +4 -0
  140. package/gen/models/PathFlow.js +4 -0
  141. package/gen/models/PathScript.d.ts +4 -0
  142. package/gen/models/PathScript.js +4 -0
  143. package/gen/models/RawScript.d.ts +12 -0
  144. package/gen/models/RawScript.js +11 -0
  145. package/gen/models/Schedule.d.ts +1 -1
  146. package/gen/models/StaticTransform.d.ts +4 -0
  147. package/gen/models/StaticTransform.js +4 -0
  148. package/gen/models/TokenResponse.d.ts +3 -3
  149. package/gen/models/Usage.d.ts +5 -0
  150. package/gen/models/Usage.js +4 -0
  151. package/gen/models/User.d.ts +2 -0
  152. package/gen/schemas/$AuditLog.d.ts +32 -0
  153. package/gen/schemas/$AuditLog.js +35 -0
  154. package/gen/schemas/$CompletedJob.d.ts +98 -0
  155. package/gen/schemas/$CompletedJob.js +103 -0
  156. package/gen/schemas/$ContextualVariable.d.ts +16 -0
  157. package/gen/schemas/$ContextualVariable.js +19 -0
  158. package/gen/schemas/$CreateResource.d.ts +22 -0
  159. package/gen/schemas/$CreateResource.js +25 -0
  160. package/gen/schemas/$CreateVariable.d.ts +26 -0
  161. package/gen/schemas/$CreateVariable.js +29 -0
  162. package/gen/schemas/$CreateWorkspace.d.ts +20 -0
  163. package/gen/schemas/$CreateWorkspace.js +23 -0
  164. package/gen/schemas/$EditResource.d.ts +13 -0
  165. package/gen/schemas/$EditResource.js +16 -0
  166. package/gen/schemas/$EditResourceType.d.ts +10 -0
  167. package/gen/schemas/$EditResourceType.js +13 -0
  168. package/gen/schemas/$EditSchedule.d.ts +20 -0
  169. package/gen/schemas/$EditSchedule.js +23 -0
  170. package/gen/schemas/$EditVariable.d.ts +16 -0
  171. package/gen/schemas/$EditVariable.js +19 -0
  172. package/gen/schemas/$EditWorkspaceUser.d.ts +7 -0
  173. package/gen/schemas/$EditWorkspaceUser.js +10 -0
  174. package/gen/schemas/$Flow.d.ts +23 -0
  175. package/gen/schemas/$Flow.js +26 -0
  176. package/gen/schemas/$FlowMetadata.d.ts +31 -0
  177. package/gen/schemas/$FlowMetadata.js +34 -0
  178. package/gen/schemas/$FlowPreview.d.ts +80 -0
  179. package/gen/schemas/$FlowPreview.js +83 -0
  180. package/gen/schemas/$GlobalUserInfo.d.ts +26 -0
  181. package/gen/schemas/$GlobalUserInfo.js +29 -0
  182. package/gen/schemas/$Group.d.ts +23 -0
  183. package/gen/schemas/$Group.js +26 -0
  184. package/gen/schemas/$Job.d.ts +17 -0
  185. package/gen/schemas/$Job.js +20 -0
  186. package/gen/schemas/$ListableVariable.d.ts +35 -0
  187. package/gen/schemas/$ListableVariable.js +38 -0
  188. package/gen/schemas/$Login.d.ts +12 -0
  189. package/gen/schemas/$Login.js +15 -0
  190. package/gen/schemas/$MainArgSignature.d.ts +50 -0
  191. package/gen/schemas/$MainArgSignature.js +53 -0
  192. package/gen/schemas/$NewSchedule.d.ts +30 -0
  193. package/gen/schemas/$NewSchedule.js +33 -0
  194. package/gen/schemas/$NewToken.d.ts +11 -0
  195. package/gen/schemas/$NewToken.js +14 -0
  196. package/gen/schemas/$NewUser.d.ts +16 -0
  197. package/gen/schemas/$NewUser.js +19 -0
  198. package/gen/schemas/$Preview.d.ts +19 -0
  199. package/gen/schemas/$Preview.js +22 -0
  200. package/gen/schemas/$QueuedJob.d.ts +139 -0
  201. package/gen/schemas/$QueuedJob.js +144 -0
  202. package/gen/schemas/$Resource.d.ts +31 -0
  203. package/gen/schemas/$Resource.js +34 -0
  204. package/gen/schemas/$ResourceType.d.ts +17 -0
  205. package/gen/schemas/$ResourceType.js +20 -0
  206. package/gen/schemas/$Schedule.d.ts +47 -0
  207. package/gen/schemas/$Schedule.js +50 -0
  208. package/gen/schemas/$Script.d.ts +77 -0
  209. package/gen/schemas/$Script.js +80 -0
  210. package/gen/schemas/$ScriptArgs.d.ts +6 -0
  211. package/gen/schemas/$ScriptArgs.js +9 -0
  212. package/gen/schemas/$SlackToken.d.ts +24 -0
  213. package/gen/schemas/$SlackToken.js +27 -0
  214. package/gen/schemas/$TokenResponse.d.ts +23 -0
  215. package/gen/schemas/$TokenResponse.js +26 -0
  216. package/gen/schemas/$TruncatedToken.d.ts +25 -0
  217. package/gen/schemas/$TruncatedToken.js +28 -0
  218. package/gen/schemas/$Usage.d.ts +13 -0
  219. package/gen/schemas/$Usage.js +16 -0
  220. package/gen/schemas/$User.d.ts +42 -0
  221. package/gen/schemas/$User.js +45 -0
  222. package/gen/schemas/$UserWorkspaceList.d.ts +28 -0
  223. package/gen/schemas/$UserWorkspaceList.js +31 -0
  224. package/gen/schemas/$WorkerPing.d.ts +31 -0
  225. package/gen/schemas/$WorkerPing.js +34 -0
  226. package/gen/schemas/$Workspace.d.ts +19 -0
  227. package/gen/schemas/$Workspace.js +22 -0
  228. package/gen/schemas/$WorkspaceInvite.d.ts +16 -0
  229. package/gen/schemas/$WorkspaceInvite.js +19 -0
  230. package/gen/services/FlowService.d.ts +24 -23
  231. package/gen/services/FlowService.js +14 -0
  232. package/gen/services/JobService.d.ts +1 -1
  233. package/gen/services/ScriptService.d.ts +13 -19
  234. package/gen/services/ScriptService.js +0 -14
  235. package/gen/services/WorkspaceService.d.ts +1 -1
  236. package/gen/services/WorkspaceService.js +1 -1
  237. package/infer.js +8 -1
  238. package/package.json +83 -15
  239. package/script_helpers.d.ts +1 -1
  240. package/script_helpers.js +7 -6
  241. package/sql.d.ts +89 -0
  242. package/sql.js +817 -0
  243. package/stores.d.ts +0 -1
  244. package/stores.js +0 -6
  245. package/utils.d.ts +12 -5
  246. package/utils.js +55 -9
  247. package/components/RadioButtonV2.svelte +0 -33
  248. package/components/RadioButtonV2.svelte.d.ts +0 -20
package/stores.d.ts CHANGED
@@ -23,4 +23,3 @@ export declare const hubScripts: import("svelte/store").Writable<{
23
23
  export declare function clearStores(): void;
24
24
  export declare const previewResults: import("svelte/store").Writable<Record<number, Object>>;
25
25
  export declare function clearPreviewResults(): void;
26
- export declare function addPreviewResult(res: Object, index: number): void;
package/stores.js CHANGED
@@ -30,9 +30,3 @@ export const previewResults = writable({});
30
30
  export function clearPreviewResults() {
31
31
  previewResults.set({});
32
32
  }
33
- export function addPreviewResult(res, index) {
34
- previewResults.update((rec) => {
35
- rec[index] = res;
36
- return rec;
37
- });
38
- }
package/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type User } from './gen';
1
+ import { type Flow, type User } from './gen';
2
2
  import type { Schema } from './common';
3
3
  import { type UserExt } from './stores';
4
4
  export declare function isToday(someDate: Date): boolean;
@@ -6,6 +6,7 @@ export declare function daysAgo(someDate: Date): number;
6
6
  export declare function secondsAgo(date: Date): number;
7
7
  export declare function displayDaysAgo(dateString: string): string;
8
8
  export declare function displayDate(dateString: string | undefined): string;
9
+ export declare function msToSec(ms: number | undefined): string;
9
10
  export declare function getToday(): Date;
10
11
  export declare function sendUserToast(message: string, error?: boolean): void;
11
12
  export declare function truncateHash(hash: string): string;
@@ -43,6 +44,7 @@ export declare function simpleSchema(): {
43
44
  };
44
45
  export declare function removeItemAll<T>(arr: T[], value: T): T[];
45
46
  export declare function canWrite(path: string, extra_perms: Record<string, boolean>, user?: UserExt): boolean;
47
+ export declare function defaultIfEmptyString(str: string | undefined, dflt: string): string;
46
48
  export declare function removeKeysWithEmptyValues(obj: any): any;
47
49
  export declare function allTrue(dict: {
48
50
  [id: string]: boolean;
@@ -50,19 +52,21 @@ export declare function allTrue(dict: {
50
52
  export declare function forLater(scheduledString: string): boolean;
51
53
  export declare function elapsedSinceSecs(date: string): number;
52
54
  export declare function pathIsEmpty(path: string): boolean;
55
+ export declare function encodeState(state: any): string;
56
+ export declare function decodeState(query: string): any;
53
57
  export declare function setQuery(url: URL, key: string, value: string): Promise<void>;
54
- export declare function setQueryWithoutLoad(url: URL, key: string, value: string): Promise<void>;
58
+ export declare function setQueryWithoutLoad(url: URL, key: string, value: string): void;
55
59
  export declare function groupBy<T>(scripts: T[], toGroup: (t: T) => string, dflts?: string[]): [string, T[]][];
56
60
  export declare function truncate(s: string, n: number, suffix?: string): string;
57
61
  export declare function truncateRev(s: string, n: number, prefix?: string): string;
58
62
  export declare function isString(value: any): boolean;
59
63
  export declare function mapUserToUserExt(user: User): UserExt;
60
- export declare function buildExtraLib(previousResultType?: string): string;
64
+ export declare function buildExtraLib(flowInput: string, previousResultType?: string): string;
61
65
  export declare function schemaToTsType(schema: Schema): string;
62
- export declare function schemaToObject(schema: Schema): Object;
66
+ export declare function schemaToObject(schema: Schema, args: Record<string, any>): Object;
63
67
  export declare function valueToTsType(value: any): string;
64
68
  export declare function objectToTsType(object: Object): string;
65
- export declare type InputCat = "string" | "number" | "boolean" | "list" | "resource-object" | "enum" | "date" | "base64" | "resource-string" | "object";
69
+ export declare type InputCat = "string" | "number" | "boolean" | "list" | "resource-object" | "enum" | "date" | "base64" | "resource-string" | "object" | "sql";
66
70
  export declare function setInputCat(type: string | undefined, format: string | undefined, itemsType: string | undefined, enum_: any, contentEncoding: string | undefined): InputCat;
67
71
  export declare function scriptPathToHref(path: string): string;
68
72
  export declare function getScriptByPath(path: string): Promise<{
@@ -78,3 +82,6 @@ export declare function loadHubFlows(): Promise<{
78
82
  approved: boolean;
79
83
  votes: number;
80
84
  }[]>;
85
+ export declare function formatCron(inp: string): string;
86
+ export declare function flowToHubUrl(flow: Flow): URL;
87
+ export declare function scriptToHubUrl(content: string, summary: string, description: string, trigger: boolean): URL;
package/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
2
2
  import { goto } from '$app/navigation';
3
- import { FlowService, Script, ScriptService } from './gen';
3
+ import { FlowService, ScriptService } from './gen';
4
4
  import { toast } from '@zerodevx/svelte-toast';
5
5
  import { get } from 'svelte/store';
6
6
  import { hubScripts, workspaceStore } from './stores';
@@ -39,6 +39,11 @@ export function displayDate(dateString) {
39
39
  return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()} at ${date.toLocaleTimeString()}`;
40
40
  }
41
41
  }
42
+ export function msToSec(ms) {
43
+ if (ms === undefined)
44
+ return '?';
45
+ return (ms / 1000).toLocaleString(undefined, { maximumFractionDigits: 3 });
46
+ }
42
47
  export function getToday() {
43
48
  var today = new Date();
44
49
  return today;
@@ -137,6 +142,9 @@ export function canWrite(path, extra_perms, user) {
137
142
  }
138
143
  return false;
139
144
  }
145
+ export function defaultIfEmptyString(str, dflt) {
146
+ return str == undefined || str == '' ? dflt : str;
147
+ }
140
148
  export function removeKeysWithEmptyValues(obj) {
141
149
  Object.keys(obj).forEach((key) => (obj[key] === undefined ? delete obj[key] : {}));
142
150
  }
@@ -152,11 +160,17 @@ export function elapsedSinceSecs(date) {
152
160
  export function pathIsEmpty(path) {
153
161
  return path == undefined || path.split('/')[2] == '';
154
162
  }
163
+ export function encodeState(state) {
164
+ return btoa(encodeURIComponent(JSON.stringify(state)));
165
+ }
166
+ export function decodeState(query) {
167
+ return JSON.parse(decodeURIComponent(atob(query)));
168
+ }
155
169
  export async function setQuery(url, key, value) {
156
170
  url.searchParams.set(key, value);
157
171
  await goto(`?${url.searchParams.toString()}`);
158
172
  }
159
- export async function setQueryWithoutLoad(url, key, value) {
173
+ export function setQueryWithoutLoad(url, key, value) {
160
174
  const nurl = new URL(url.toString());
161
175
  nurl.searchParams.set(key, value);
162
176
  history.replaceState(null, '', nurl.toString());
@@ -215,7 +229,7 @@ export function mapUserToUserExt(user) {
215
229
  pgroups: user.groups.map((x) => `g/${x}`)
216
230
  };
217
231
  }
218
- export function buildExtraLib(previousResultType) {
232
+ export function buildExtraLib(flowInput, previousResultType) {
219
233
  return `
220
234
  /**
221
235
  * get variable (including secret) at path
@@ -240,7 +254,7 @@ export function step(n: number): any;
240
254
  /**
241
255
  * flow input as an object
242
256
  */
243
- export const flow_input: any;
257
+ export const flow_input: ${flowInput};
244
258
 
245
259
  /**
246
260
  * previous result as an object
@@ -284,15 +298,14 @@ export function schemaToTsType(schema) {
284
298
  .join(';');
285
299
  return `{ ${types} }`;
286
300
  }
287
- export function schemaToObject(schema) {
301
+ export function schemaToObject(schema, args) {
288
302
  const object = {};
289
303
  if (!schema) {
290
304
  return object;
291
305
  }
292
306
  const propKeys = Object.keys(schema.properties);
293
307
  propKeys.forEach((key) => {
294
- const prop = schema.properties[key];
295
- object[key] = prop.type;
308
+ object[key] = args[key] ?? null;
296
309
  });
297
310
  return object;
298
311
  }
@@ -342,6 +355,9 @@ export function setInputCat(type, format, itemsType, enum_, contentEncoding) {
342
355
  else if (type == 'string' && format == 'date-time') {
343
356
  return 'date';
344
357
  }
358
+ else if (type == 'string' && format == 'sql') {
359
+ return 'sql';
360
+ }
345
361
  else if (type == 'string' && contentEncoding == 'base64') {
346
362
  return 'base64';
347
363
  }
@@ -380,7 +396,7 @@ export async function getScriptByPath(path) {
380
396
  }
381
397
  }
382
398
  export async function loadHubScripts() {
383
- const scripts = await ScriptService.listHubScripts();
399
+ const scripts = (await ScriptService.listHubScripts()).asks ?? [];
384
400
  const processed = scripts.map((x) => ({
385
401
  path: `hub/${x.id}/${x.summary.toLowerCase().replaceAll(/\s+/g, '_')}`,
386
402
  summary: `${x.summary} (${x.app}) ${x.views} uses`,
@@ -394,7 +410,37 @@ export async function loadHubScripts() {
394
410
  hubScripts.set(processed);
395
411
  }
396
412
  export async function loadHubFlows() {
397
- const flows = await FlowService.listHubFlows();
413
+ const flows = (await FlowService.listHubFlows()).flows ?? [];
398
414
  const processed = flows.sort((a, b) => b.votes - a.votes);
399
415
  return processed;
400
416
  }
417
+ export function formatCron(inp) {
418
+ // Allow for cron expressions inputted by the user to omit month and year
419
+ let splitted = inp.split(' ');
420
+ splitted = splitted.filter(String); //remove empty string elements
421
+ if (6 - splitted.length > 0) {
422
+ return splitted.concat(Array(6 - splitted.length).fill('*')).join(' ');
423
+ }
424
+ else {
425
+ return inp;
426
+ }
427
+ }
428
+ export function flowToHubUrl(flow) {
429
+ const url = new URL('https://hub.windmill.dev/flows/add');
430
+ const openFlow = {
431
+ value: flow.value,
432
+ summary: flow.summary,
433
+ description: flow.description,
434
+ schema: flow.schema
435
+ };
436
+ url.searchParams.append('flow', encodeState(openFlow));
437
+ return url;
438
+ }
439
+ export function scriptToHubUrl(content, summary, description, trigger) {
440
+ const url = new URL('https://hub.windmill.dev/scripts/add');
441
+ url.searchParams.append('content', content);
442
+ url.searchParams.append('summary', summary);
443
+ url.searchParams.append('description', description);
444
+ url.searchParams.append('trigger', trigger.toString());
445
+ return url;
446
+ }
@@ -1,33 +0,0 @@
1
- <script>export let options;
2
- export let value;
3
- import { createEventDispatcher } from 'svelte';
4
- import Tooltip from './Tooltip.svelte';
5
- $: dispatch('change', value);
6
- const dispatch = createEventDispatcher();
7
- </script>
8
-
9
- <div class="flex flex-row gap-x-4 m-4 reveal flex-wrap ">
10
- {#each options as [label, val]}
11
- <button
12
- type="button"
13
- on:click={() => {
14
- value = val
15
- }}
16
- class="flex flex-col default-secondary-button-v2 mb-2 grow"
17
- class:selected={value == val}
18
- >
19
- <h2 class="mb-2 whitespace-nowrap">{label.title} <Tooltip>{label.desc}</Tooltip></h2>
20
- </button>
21
- {/each}
22
- </div>
23
-
24
- <style>
25
- .selected {
26
- background-color: rgb(59 130 246 / 0.7);
27
- --tw-text-opacity: 1;
28
- color: rgb(255 255 255 / var(--tw-text-opacity))
29
- }
30
- .selected > h2 {
31
- --tw-text-opacity: 1;
32
- color: rgb(255 255 255 / var(--tw-text-opacity))
33
- }</style>
@@ -1,20 +0,0 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- options: [{
5
- title: string;
6
- desc?: string;
7
- }, string][];
8
- value: any;
9
- };
10
- events: {
11
- [evt: string]: CustomEvent<any>;
12
- };
13
- slots: {};
14
- };
15
- export declare type RadioButtonV2Props = typeof __propDef.props;
16
- export declare type RadioButtonV2Events = typeof __propDef.events;
17
- export declare type RadioButtonV2Slots = typeof __propDef.slots;
18
- export default class RadioButtonV2 extends SvelteComponentTyped<RadioButtonV2Props, RadioButtonV2Events, RadioButtonV2Slots> {
19
- }
20
- export {};