windmill-components 1.394.8 → 1.405.5

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 (305) hide show
  1. package/package/assets/app.css +20 -0
  2. package/package/ata/edgeCases.d.ts +0 -1
  3. package/package/ata/edgeCases.js +2 -8
  4. package/package/ata/index.js +4 -3
  5. package/package/common.d.ts +1 -1
  6. package/package/common.js +2 -2
  7. package/package/components/ApiConnectForm.svelte +33 -7
  8. package/package/components/AppConnectLightweightResourcePicker.svelte +66 -0
  9. package/package/components/AppConnectLightweightResourcePicker.svelte.d.ts +21 -0
  10. package/package/components/ArgInput.svelte +10 -4
  11. package/package/components/ArgInput.svelte.d.ts +1 -0
  12. package/package/components/CenteredModal.svelte +4 -1
  13. package/package/components/CenteredModal.svelte.d.ts +1 -0
  14. package/package/components/CustomPopover.svelte +1 -1
  15. package/package/components/DateInput.svelte +2 -0
  16. package/package/components/DateInput.svelte.d.ts +1 -0
  17. package/package/components/DefaultScripts.svelte +8 -3
  18. package/package/components/DefaultScripts.svelte.d.ts +5 -1
  19. package/package/components/DefaultScriptsInner.svelte +16 -7
  20. package/package/components/DefaultScriptsInner.svelte.d.ts +3 -1
  21. package/package/components/Dev.svelte +68 -11
  22. package/package/components/DisplayResult.svelte +1 -1
  23. package/package/components/DropdownV2.svelte.d.ts +3 -3
  24. package/package/components/DropdownV2Inner.svelte.d.ts +3 -3
  25. package/package/components/EditableSchemaForm.svelte +1 -0
  26. package/package/components/Editor.svelte +3 -2
  27. package/package/components/Editor.svelte.d.ts +1 -1
  28. package/package/components/ExecutionDuration.svelte +44 -0
  29. package/package/components/ExecutionDuration.svelte.d.ts +24 -0
  30. package/package/components/FlowBuilder.svelte +22 -12
  31. package/package/components/FlowBuilder.svelte.d.ts +1 -0
  32. package/package/components/FlowGraphViewer.svelte +9 -2
  33. package/package/components/FlowGraphViewerStep.svelte +23 -10
  34. package/package/components/FlowInputViewer.svelte +25 -0
  35. package/package/components/FlowInputViewer.svelte.d.ts +19 -0
  36. package/package/components/FlowJobResult.svelte +8 -2
  37. package/package/components/FlowJobResult.svelte.d.ts +1 -0
  38. package/package/components/FlowMetadata.svelte +2 -2
  39. package/package/components/FlowStatusViewer.svelte +3 -1
  40. package/package/components/FlowStatusViewer.svelte.d.ts +1 -0
  41. package/package/components/FlowStatusViewerInner.svelte +21 -5
  42. package/package/components/FlowTimeline.svelte +3 -3
  43. package/package/components/FlowViewer.svelte +2 -21
  44. package/package/components/HighlightCode.svelte +3 -0
  45. package/package/components/IconedResourceType.svelte +17 -10
  46. package/package/components/IconedResourceType.svelte.d.ts +2 -0
  47. package/package/components/IdEditorInput.svelte +0 -1
  48. package/package/components/InstanceSettings.svelte +247 -129
  49. package/package/components/InstanceSettings.svelte.d.ts +2 -0
  50. package/package/components/JobArgs.svelte +3 -1
  51. package/package/components/LightweightArgInput.svelte +35 -10
  52. package/package/components/LightweightArgInput.svelte.d.ts +1 -0
  53. package/package/components/LightweightObjectResourceInput.svelte +2 -0
  54. package/package/components/LightweightObjectResourceInput.svelte.d.ts +1 -0
  55. package/package/components/LightweightResourcePicker.svelte +34 -30
  56. package/package/components/LightweightSchemaForm.svelte +2 -0
  57. package/package/components/LightweightSchemaForm.svelte.d.ts +1 -0
  58. package/package/components/LogViewer.svelte +4 -3
  59. package/package/components/LogViewer.svelte.d.ts +1 -0
  60. package/package/components/Login.svelte +10 -5
  61. package/package/components/Login.svelte.d.ts +1 -0
  62. package/package/components/ManualPopover.svelte +1 -1
  63. package/package/components/ModulePreview.svelte +21 -2
  64. package/package/components/ModuleStatus.svelte +3 -0
  65. package/package/components/ModuleStatus.svelte.d.ts +1 -0
  66. package/package/components/OAuthSetting.svelte +40 -15
  67. package/package/components/ObjectResourceInput.svelte +5 -2
  68. package/package/components/ObjectResourceInput.svelte.d.ts +2 -0
  69. package/package/components/ObjectStoreConfigSettings.svelte +78 -76
  70. package/package/components/ParqetCsvTableRenderer.svelte +25 -3
  71. package/package/components/Password.svelte.d.ts +1 -1
  72. package/package/components/Path.svelte +74 -54
  73. package/package/components/Path.svelte.d.ts +2 -1
  74. package/package/components/Popover.svelte +1 -1
  75. package/package/components/Portal.svelte +7 -8
  76. package/package/components/Portal.svelte.d.ts +3 -7
  77. package/package/components/QueueMetricsDrawer.svelte +368 -3
  78. package/package/components/QueueMetricsDrawer.svelte.d.ts +2 -0
  79. package/package/components/ResourceEditor.svelte +38 -10
  80. package/package/components/ResourcePicker.svelte +14 -9
  81. package/package/components/ResourcePicker.svelte.d.ts +1 -0
  82. package/package/components/ResultJobLoader.svelte +6 -3
  83. package/package/components/ResultJobLoader.svelte.d.ts +1 -1
  84. package/package/components/RunForm.svelte +1 -1
  85. package/package/components/SavedInputs.svelte +2 -2
  86. package/package/components/ScheduleEditorInner.svelte +2 -2
  87. package/package/components/SchemaForm.svelte +6 -1
  88. package/package/components/ScriptBuilder.svelte +12 -5
  89. package/package/components/ScriptEditor.svelte +33 -3
  90. package/package/components/ScriptEditor.svelte.d.ts +1 -1
  91. package/package/components/ScriptVersionHistory.svelte +54 -59
  92. package/package/components/Scrollable.svelte +47 -0
  93. package/package/components/Scrollable.svelte.d.ts +21 -0
  94. package/package/components/ShareModal.svelte.d.ts +2 -2
  95. package/package/components/SuperadminSettings.svelte +5 -7
  96. package/package/components/TestConnection.svelte +1 -0
  97. package/package/components/TestJobLoader.svelte +46 -5
  98. package/package/components/TestJobLoader.svelte.d.ts +2 -1
  99. package/package/components/TimeAgo.svelte +5 -6
  100. package/package/components/TimeAgo.svelte.d.ts +1 -1
  101. package/package/components/ToggleHubWorkspaceQuick.svelte +14 -0
  102. package/package/components/ToggleHubWorkspaceQuick.svelte.d.ts +16 -0
  103. package/package/components/WorkspaceGroup.svelte +3 -2
  104. package/package/components/apps/components/buttons/AppButton.svelte +1 -1
  105. package/package/components/apps/components/display/dbtable/AppDbExplorer.svelte +1 -1
  106. package/package/components/apps/components/helpers/DebouncedInput.svelte +9 -1
  107. package/package/components/apps/components/inputs/AppMultiSelect.svelte +1 -1
  108. package/package/components/apps/components/inputs/AppMultiSelectV2.svelte +1 -1
  109. package/package/components/apps/components/inputs/AppSelect.svelte +1 -1
  110. package/package/components/apps/components/layout/AppDrawer.svelte +1 -1
  111. package/package/components/apps/components/layout/AppModal.svelte +1 -1
  112. package/package/components/apps/editor/AppEditor.svelte +11 -3
  113. package/package/components/apps/editor/GridEditor.svelte +57 -4
  114. package/package/components/apps/editor/GridEditor.svelte.d.ts +8 -0
  115. package/package/components/apps/editor/GridEditorMenu.svelte +1 -1
  116. package/package/components/apps/editor/SubGridEditor.svelte +82 -3
  117. package/package/components/apps/editor/SubGridEditor.svelte.d.ts +16 -0
  118. package/package/components/apps/editor/appUtils.d.ts +19 -2
  119. package/package/components/apps/editor/appUtils.js +103 -7
  120. package/package/components/apps/editor/component/Component.svelte +36 -8
  121. package/package/components/apps/editor/component/Component.svelte.d.ts +3 -1
  122. package/package/components/apps/editor/component/components.d.ts +79 -79
  123. package/package/components/apps/editor/contextPanel/components/OutputHeader.svelte +1 -1
  124. package/package/components/apps/svelte-grid/Grid.svelte +235 -12
  125. package/package/components/apps/svelte-grid/Grid.svelte.d.ts +7 -7
  126. package/package/components/apps/svelte-grid/MoveResize.svelte +104 -11
  127. package/package/components/apps/svelte-grid/MoveResize.svelte.d.ts +7 -0
  128. package/package/components/apps/svelte-grid/utils/item.d.ts +4 -1
  129. package/package/components/apps/svelte-grid/utils/item.js +2 -3
  130. package/package/components/apps/svelte-select/lib/ConditionalPortal.svelte +1 -1
  131. package/package/components/apps/svelte-select/lib/ConditionalPortalGlobal.svelte +1 -1
  132. package/package/components/apps/svelte-select/lib/Select.svelte +1 -1
  133. package/package/components/common/button/ButtonDropdown.svelte +1 -1
  134. package/package/components/common/drawer/ConditionalPortal.svelte +1 -1
  135. package/package/components/common/fileUpload/FileUpload.svelte +1 -1
  136. package/package/components/common/languageIcons/LanguageIcon.svelte +5 -2
  137. package/package/components/common/menu/Menu.svelte +2 -1
  138. package/package/components/common/menu/MenuV2.svelte +4 -2
  139. package/package/components/common/menu/MenuV2.svelte.d.ts +1 -0
  140. package/package/components/common/modal/AlwaysMountedModal.svelte +1 -1
  141. package/package/components/common/popup/Popup.svelte +22 -12
  142. package/package/components/common/popup/Popup.svelte.d.ts +2 -0
  143. package/package/components/common/popup/PopupV2.svelte +58 -0
  144. package/package/components/common/popup/PopupV2.svelte.d.ts +27 -0
  145. package/package/components/copilot/CronGen.svelte +1 -1
  146. package/package/components/copilot/RegexGen.svelte +4 -4
  147. package/package/components/copilot/StepGen.svelte +6 -6
  148. package/package/components/copilot/StepGenQuick.svelte +58 -0
  149. package/package/components/copilot/StepGenQuick.svelte.d.ts +24 -0
  150. package/package/components/copilot/flow.d.ts +2 -0
  151. package/package/components/copilot/flow.js +55 -0
  152. package/package/components/details/DetailPageDetailPanel.svelte +9 -1
  153. package/package/components/details/DetailPageDetailPanel.svelte.d.ts +2 -1
  154. package/package/components/details/DetailPageLayout.svelte +2 -0
  155. package/package/components/details/DetailPageLayout.svelte.d.ts +3 -0
  156. package/package/components/details/Menu.svelte +1 -1
  157. package/package/components/details/utils.d.ts +0 -1
  158. package/package/components/details/utils.js +1 -12
  159. package/package/components/flows/CreateActionsApp.svelte +1 -1
  160. package/package/components/flows/FlowEditor.svelte +4 -2
  161. package/package/components/flows/FlowEditor.svelte.d.ts +1 -0
  162. package/package/components/flows/FlowHistory.svelte +10 -195
  163. package/package/components/flows/FlowHistory.svelte.d.ts +0 -1
  164. package/package/components/flows/FlowHistoryInner.svelte +200 -0
  165. package/package/components/flows/FlowHistoryInner.svelte.d.ts +19 -0
  166. package/package/components/flows/FlowProgressBar.svelte +16 -1
  167. package/package/components/flows/FlowProgressBar.svelte.d.ts +1 -0
  168. package/package/components/flows/content/FlowBranchesAllWrapper.svelte +8 -0
  169. package/package/components/flows/content/FlowBranchesAllWrapper.svelte.d.ts +1 -0
  170. package/package/components/flows/content/FlowBranchesOneWrapper.svelte +8 -0
  171. package/package/components/flows/content/FlowBranchesOneWrapper.svelte.d.ts +1 -0
  172. package/package/components/flows/content/FlowConstants.svelte +1 -1
  173. package/package/components/flows/content/FlowEditorPanel.svelte +5 -1
  174. package/package/components/flows/content/FlowEditorPanel.svelte.d.ts +1 -0
  175. package/package/components/flows/content/FlowInput.svelte +66 -58
  176. package/package/components/flows/content/FlowInput.svelte.d.ts +1 -0
  177. package/package/components/flows/content/FlowInputs.svelte +7 -6
  178. package/package/components/flows/content/FlowInputs.svelte.d.ts +1 -0
  179. package/package/components/flows/content/FlowInputsFlowQuick.svelte +65 -0
  180. package/package/components/flows/content/FlowInputsFlowQuick.svelte.d.ts +19 -0
  181. package/package/components/flows/content/FlowInputsQuick.svelte +419 -0
  182. package/package/components/flows/content/FlowInputsQuick.svelte.d.ts +33 -0
  183. package/package/components/flows/content/FlowLoop.svelte +7 -1
  184. package/package/components/flows/content/FlowModuleComponent.svelte +12 -3
  185. package/package/components/flows/content/FlowModuleComponent.svelte.d.ts +1 -0
  186. package/package/components/flows/content/FlowModuleScript.svelte +1 -1
  187. package/package/components/flows/content/FlowModuleSkip.svelte +69 -0
  188. package/package/components/flows/content/FlowModuleSkip.svelte.d.ts +20 -0
  189. package/package/components/flows/content/FlowModuleWrapper.svelte +17 -4
  190. package/package/components/flows/content/FlowPreprocessorModule.svelte +16 -0
  191. package/package/components/flows/content/FlowPreprocessorModule.svelte.d.ts +16 -0
  192. package/package/components/flows/content/FlowWhileLoop.svelte +9 -0
  193. package/package/components/flows/content/FlowWhileLoop.svelte.d.ts +1 -0
  194. package/package/components/flows/content/GenAiQuick.svelte +30 -0
  195. package/package/components/flows/content/GenAiQuick.svelte.d.ts +20 -0
  196. package/package/components/flows/content/ScriptEditorDrawer.svelte +3 -2
  197. package/package/components/flows/flowInfers.js +1 -1
  198. package/package/components/flows/header/FlowPreviewButtons.svelte +1 -0
  199. package/package/components/flows/idUtils.js +3 -1
  200. package/package/components/flows/map/FlowCopilotButton.svelte +55 -0
  201. package/package/components/flows/map/FlowCopilotButton.svelte.d.ts +16 -0
  202. package/package/components/flows/map/FlowErrorHandlerItem.svelte +77 -47
  203. package/package/components/flows/map/FlowJobsMenu.svelte +1 -1
  204. package/package/components/flows/map/FlowModuleSchemaItem.svelte +25 -12
  205. package/package/components/flows/map/FlowModuleSchemaItem.svelte.d.ts +1 -0
  206. package/package/components/flows/map/FlowModuleSchemaMap.svelte +64 -20
  207. package/package/components/flows/map/InsertModuleButton.svelte +161 -138
  208. package/package/components/flows/map/InsertModuleButton.svelte.d.ts +7 -4
  209. package/package/components/flows/map/MapItem.svelte +11 -0
  210. package/package/components/flows/map/MapItem.svelte.d.ts +1 -0
  211. package/package/components/flows/pickers/FlowScriptPickerQuick.svelte +48 -0
  212. package/package/components/flows/pickers/FlowScriptPickerQuick.svelte.d.ts +23 -0
  213. package/package/components/flows/pickers/FlowToplevelNode.svelte +19 -0
  214. package/package/components/flows/pickers/FlowToplevelNode.svelte.d.ts +19 -0
  215. package/package/components/flows/pickers/PickHubScriptQuick.svelte +138 -0
  216. package/package/components/flows/pickers/PickHubScriptQuick.svelte.d.ts +33 -0
  217. package/package/components/flows/pickers/TopLevelNode.svelte +58 -0
  218. package/package/components/flows/pickers/TopLevelNode.svelte.d.ts +21 -0
  219. package/package/components/flows/pickers/WorkspaceScriptPickerQuick.svelte +120 -0
  220. package/package/components/flows/pickers/WorkspaceScriptPickerQuick.svelte.d.ts +35 -0
  221. package/package/components/flows/types.d.ts +1 -0
  222. package/package/components/graph/FlowGraphV2.svelte +93 -58
  223. package/package/components/graph/FlowGraphV2.svelte.d.ts +2 -1
  224. package/package/components/graph/graphBuilder.d.ts +2 -1
  225. package/package/components/graph/graphBuilder.js +345 -280
  226. package/package/components/graph/model.d.ts +2 -0
  227. package/package/components/graph/renderers/edges/BaseEdge.svelte +36 -14
  228. package/package/components/graph/renderers/nodes/BranchOneStart.svelte +1 -1
  229. package/package/components/graph/renderers/nodes/InputNode.svelte +31 -51
  230. package/package/components/graph/renderers/nodes/InputNode.svelte.d.ts +6 -1
  231. package/package/components/graph/renderers/nodes/ModuleNode.svelte +2 -1
  232. package/package/components/graph/util.d.ts +1 -1
  233. package/package/components/graph/util.js +7 -2
  234. package/package/components/home/ListFiltersQuick.svelte +51 -0
  235. package/package/components/home/ListFiltersQuick.svelte.d.ts +23 -0
  236. package/package/components/icons/AnsibleIcon.svelte +42 -0
  237. package/package/components/icons/AnsibleIcon.svelte.d.ts +25 -0
  238. package/package/components/icons/WindmillIcon.svelte +119 -105
  239. package/package/components/icons/WindmillIcon2.svelte +141 -0
  240. package/package/components/icons/WindmillIcon2.svelte.d.ts +20 -0
  241. package/package/components/icons/index.d.ts +2 -1
  242. package/package/components/icons/index.js +2 -1
  243. package/package/components/icons/store.d.ts +4 -0
  244. package/package/components/icons/store.js +1 -0
  245. package/package/components/instanceSettings.d.ts +2 -2
  246. package/package/components/instanceSettings.js +25 -58
  247. package/package/components/jobs/JobProgressBar.svelte +52 -0
  248. package/package/components/jobs/JobProgressBar.svelte.d.ts +23 -0
  249. package/package/components/multiselect/MultiSelectWrapper.svelte +1 -1
  250. package/package/components/progressBar/ProgressBar.svelte +18 -1
  251. package/package/components/progressBar/ProgressBar.svelte.d.ts +3 -0
  252. package/package/components/propertyPicker/ObjectViewer.svelte +1 -1
  253. package/package/components/runs/JobPreview.svelte +1 -0
  254. package/package/components/runs/PreprocessedArgsDisplay.svelte +71 -0
  255. package/package/components/runs/PreprocessedArgsDisplay.svelte.d.ts +16 -0
  256. package/package/components/runs/RunRow.svelte +3 -7
  257. package/package/components/schema/AddProperty.svelte +1 -0
  258. package/package/components/schema/EditableSchemaWrapper.svelte +142 -19
  259. package/package/components/schema/EditableSchemaWrapper.svelte.d.ts +1 -0
  260. package/package/components/schema/FlowPropertyEditor.svelte +13 -0
  261. package/package/components/schema/FlowPropertyEditor.svelte.d.ts +1 -0
  262. package/package/components/scriptEditor/LogPanel.svelte +1 -0
  263. package/package/components/scriptEditor/LogPanel.svelte.d.ts +3 -1
  264. package/package/components/search/GlobalSearchModal.svelte +3 -2
  265. package/package/components/sidebar/SidebarContent.svelte +69 -8
  266. package/package/components/sidebar/changelogs.js +10 -0
  267. package/package/components/triggers/RouteEditor.svelte +19 -0
  268. package/package/components/triggers/RouteEditor.svelte.d.ts +21 -0
  269. package/package/components/triggers/RouteEditorInner.svelte +327 -0
  270. package/package/components/triggers/RouteEditorInner.svelte.d.ts +21 -0
  271. package/package/components/triggers/RoutesPanel.svelte +74 -0
  272. package/package/components/triggers/RoutesPanel.svelte.d.ts +17 -0
  273. package/package/editorUtils.js +2 -0
  274. package/package/gen/core/OpenAPI.js +1 -1
  275. package/package/gen/schemas.gen.d.ts +159 -8
  276. package/package/gen/schemas.gen.js +161 -8
  277. package/package/gen/services.gen.d.ts +139 -1
  278. package/package/gen/services.gen.js +282 -1
  279. package/package/gen/types.gen.d.ts +455 -12
  280. package/package/hubPaths.json +6 -8
  281. package/package/infer.d.ts +4 -2
  282. package/package/infer.js +25 -23
  283. package/package/inferArgSig.js +8 -2
  284. package/package/monaco_workers/graphql.worker.bundle.js +45440 -174
  285. package/package/relative_imports.d.ts +3 -0
  286. package/package/relative_imports.js +25 -0
  287. package/package/script_helpers.d.ts +38 -34
  288. package/package/script_helpers.js +245 -35
  289. package/package/scripts.d.ts +1 -1
  290. package/package/scripts.js +5 -1
  291. package/package/stores.d.ts +1 -0
  292. package/package/stores.js +1 -0
  293. package/package/utils.d.ts +1 -0
  294. package/package/utils.js +4 -0
  295. package/package.json +38 -7
  296. package/package/components/flows/map/InsertTriggerButton.svelte +0 -48
  297. package/package/components/flows/map/InsertTriggerButton.svelte.d.ts +0 -24
  298. package/package/init_scripts/python_failure_module.d.ts +0 -2
  299. package/package/init_scripts/python_failure_module.js +0 -8
  300. package/package/init_scripts/python_init_code.d.ts +0 -2
  301. package/package/init_scripts/python_init_code.js +0 -40
  302. package/package/init_scripts/python_init_code_clear.d.ts +0 -2
  303. package/package/init_scripts/python_init_code_clear.js +0 -5
  304. package/package/init_scripts/python_init_code_trigger.d.ts +0 -2
  305. package/package/init_scripts/python_init_code_trigger.js +0 -14
@@ -0,0 +1,3 @@
1
+ export declare function parseTypescriptDeps(code: string): string[];
2
+ export declare function isTypescriptRelativePath(d: string): boolean;
3
+ export declare function approximateFindPythonRelativePath(code: string): [number, string][];
@@ -0,0 +1,25 @@
1
+ import { parse_ts_imports } from 'windmill-parser-wasm-ts';
2
+ export function parseTypescriptDeps(code) {
3
+ let r = JSON.parse(parse_ts_imports(code));
4
+ if (r.error) {
5
+ console.error(r.error);
6
+ return [];
7
+ }
8
+ else {
9
+ return r.imports;
10
+ }
11
+ }
12
+ export function isTypescriptRelativePath(d) {
13
+ return (d.startsWith('./') ||
14
+ d.startsWith('../') ||
15
+ d.startsWith('/') ||
16
+ d.startsWith('.../') ||
17
+ d.startsWith('/'));
18
+ }
19
+ export function approximateFindPythonRelativePath(code) {
20
+ // Define the regular expression for finding relative imports
21
+ const regex = /^\s*from\s+(\.+)\w*\s+import\s+.+$/gm;
22
+ // Use match to find all matches in the code
23
+ const matches = code.match(regex);
24
+ return [...(matches?.entries() ?? [])] || [];
25
+ }
@@ -1,38 +1,42 @@
1
1
  import { type Script } from './gen';
2
- import PYTHON_INIT_CODE from './init_scripts/python_init_code';
3
- import PYTHON_INIT_CODE_CLEAR from './init_scripts/python_init_code_clear';
4
- import PYTHON_INIT_CODE_TRIGGER from './init_scripts/python_init_code_trigger';
5
- import PYTHON_FAILURE_MODULE_CODE from './init_scripts/python_failure_module';
6
2
  import type { SupportedLanguage } from './common';
7
- export { PYTHON_INIT_CODE, PYTHON_INIT_CODE_CLEAR, PYTHON_INIT_CODE_TRIGGER, PYTHON_FAILURE_MODULE_CODE };
8
- export declare const NATIVETS_INIT_CODE = "// Fetch-only script, no imports allowed (except windmill) but benefits from a dedicated highly efficient runtime\n//import * as wmill from './windmill.ts'\n\nexport async function main(example_input: number = 3) {\n // \"3\" is the default value of example_input, it can be overriden with code or using the UI\n const res = await fetch(`https://jsonplaceholder.typicode.com/todos/${example_input}`, {\n headers: { \"Content-Type\": \"application/json\" },\n });\n return res.json();\n}\n";
9
- export declare const BUNNATIVE_INIT_CODE = "//native\n//you can add proxy support using //proxy http(s)://host:port\n\n// native scripts are bun scripts that are executed on native workers and can be parallelized\n// only fetch is allowed, but imports will work as long as they also use only fetch and the standard lib\n\n//import * as wmill from \"windmill-client\"\n\nexport async function main(example_input: number = 3) {\n // \"3\" is the default value of example_input, it can be overriden with code or using the UI\n const res = await fetch(`https://jsonplaceholder.typicode.com/todos/${example_input}`, {\n headers: { \"Content-Type\": \"application/json\" },\n });\n return res.json();\n}\n";
10
- export declare const NATIVETS_INIT_CODE_CLEAR = "// Fetch-only script, no imports allowed (except windmill) but benefits from a dedicated highly efficient runtime\n//import * as wmill from './windmill.ts'\n\nexport async function main() {\n const res = await fetch(\"https://jsonplaceholder.typicode.com/todos/1\", {\n headers: { \"Content-Type\": \"application/json\" },\n });\n return res.json();\n}\n";
11
- export declare const DENO_INIT_CODE: string;
12
- export declare const BUN_INIT_CODE = "// there are multiple modes to add as header: //nobundling //native //npm //nodejs\n// https://www.windmill.dev/docs/getting_started/scripts_quickstart/typescript#modes\n\n// import { toWords } from \"number-to-words@1\"\nimport * as wmill from \"windmill-client\"\n\n// fill the type, or use the +Resource type to get a type-safe reference to a resource\n// type Postgresql = object\n\n\nexport async function main(\n a: number,\n b: \"my\" | \"enum\",\n //c: Postgresql,\n //d: wmill.S3Object, // https://www.windmill.dev/docs/core_concepts/persistent_storage/large_data_files \n //d: DynSelect_foo, // https://www.windmill.dev/docs/core_concepts/json_schema_and_parsing#dynamic-select\n e = \"inferred type string from default arg\",\n f = { nested: \"object\" },\n g: {\n label: \"Variant 1\",\n foo: string\n } | {\n label: \"Variant 2\",\n bar: number\n }\n) {\n // let x = await wmill.getVariable('u/user/foo')\n return { foo: a };\n}\n";
13
- export declare const GO_INIT_CODE = "package inner\n\nimport (\n\t\"fmt\"\n\t\"rsc.io/quote\"\n\t// wmill \"github.com/windmill-labs/windmill-go-client\"\n)\n\n// Pin dependencies partially in go.mod with a comment starting with \"//require\":\n//require rsc.io/quote v1.5.1\n\n// the main must return (interface{}, error)\n\nfunc main(x string, nested struct {\n\tFoo string `json:\"foo\"`\n}) (interface{}, error) {\n\tfmt.Println(\"Hello, World\")\n\tfmt.Println(nested.Foo)\n\tfmt.Println(quote.Opt())\n\t// v, _ := wmill.GetVariable(\"f/examples/secret\")\n\treturn x, nil\n}\n";
14
- export declare const GO_FAILURE_MODULE_CODE = "package inner\n\nimport (\n\t\"fmt\"\n \"os\"\n)\n\n// connect the error parameter to 'previous_result.error'\n\nfunc main(message string, name string) (interface{}, error) {\n\tfmt.Println(message)\n\tfmt.Println(name)\n\tfmt.Println(\"flow id that failed\", os.Getenv(\"WM_FLOW_JOB_ID\"))\n return message, nil\n}\n";
15
- export declare const DENO_INIT_CODE_CLEAR: string;
16
- export declare const BUN_INIT_CODE_CLEAR = "// import * as wmill from \"windmill-client\"\n\nexport async function main(x: string) {\n return x\n}\n";
17
- export declare const DENO_FAILURE_MODULE_CODE = "\nexport async function main(message: string, name: string, step_id: string) {\n const flow_id = Deno.env.get(\"WM_ROOT_FLOW_JOB_ID\")\n console.log(\"message\", message)\n console.log(\"name\",name)\n console.log(\"step_id\", step_id)\n return { message, flow_id, step_id, recover: false }\n}\n";
18
- export declare const BUN_FAILURE_MODULE_CODE = "\nexport async function main(message: string, name: string, step_id: string) {\n const flow_id = process.env.WM_ROOT_FLOW_JOB_ID\n console.log(\"message\", message)\n console.log(\"name\",name)\n console.log(\"step_id\", step_id)\n return { message, flow_id, step_id, recover: false }\n}\n";
19
- export declare const POSTGRES_INIT_CODE = "-- to pin the database use '-- database f/your/path'\n-- $1 name1 = default arg\n-- $2 name2\n-- $3 name3\n-- $4 name4\nINSERT INTO demo VALUES ($1::TEXT, $2::INT, $3::TEXT[]) RETURNING *;\nUPDATE demo SET col2 = $4::INT WHERE col2 = $2::INT;\n";
20
- export declare const MYSQL_INIT_CODE = "-- to pin the database use '-- database f/your/path'\n-- :name1 (text) = default arg\n-- :name2 (int)\n-- :name3 (int)\nINSERT INTO demo VALUES (:name1, :name2);\nUPDATE demo SET col2 = :name3 WHERE col2 = :name2;\n";
21
- export declare const BIGQUERY_INIT_CODE = "-- to pin the database use '-- database f/your/path'\n-- @name1 (string) = default arg\n-- @name2 (integer)\n-- @name3 (string[])\n-- @name4 (integer)\nINSERT INTO `demodb.demo` VALUES (@name1, @name2, @name3);\nUPDATE `demodb.demo` SET col2 = @name4 WHERE col2 = @name2;\n";
22
- export declare const SNOWFLAKE_INIT_CODE = "-- to pin the database use '-- database f/your/path'\n-- ? name1 (varchar) = default arg\n-- ? name2 (int)\nINSERT INTO demo VALUES (?, ?);\n-- ? name3 (int)\n-- ? name2 (int)\nUPDATE demo SET col2 = ? WHERE col2 = ?;\n";
23
- export declare const MSSQL_INIT_CODE = "-- to pin the database use '-- database f/your/path'\n-- @p1 name1 (varchar) = default arg\n-- @p2 name2 (int)\n-- @p3 name3 (int)\nINSERT INTO demo VALUES (@p1, @p2);\nUPDATE demo SET col2 = @p3 WHERE col2 = @p2;\n";
24
- export declare const GRAPHQL_INIT_CODE = "query($name4: String, $name2: Int, $name3: [String]) {\n\tdemo(name1: $name1, name2: $name2, name3: $name3) {\n\t\tname1,\n\t\tname2,\n\t\tname3\n\t}\n}\n";
25
- export declare const PHP_INIT_CODE = "<?php\n\n// remove the first // of the following lines to specify packages to install using composer\n// // require:\n// // monolog/monolog@3.6.0\n// // stripe/stripe-php\n\nfunction main(\n // Postgresql $a,\n // array $b,\n // object $c,\n int $d = 123,\n string $e = \"default value\",\n float $f = 3.5,\n bool $g = true,\n) {\n return $d;\n}\n";
26
- export declare const RUST_INIT_CODE = "//! Add dependencies in the following partial Cargo.toml manifest\n//!\n//! ```cargo\n//! [dependencies]\n//! anyhow = \"1.0.86\"\n//! rand = \"0.7.2\"\n//! ```\n//!\n//! Note that serde is used by default with the `derive` feature.\n//! You can still reimport it if you need additional features.\n\nuse anyhow::anyhow;\nuse rand::seq::SliceRandom;\nuse serde::Serialize;\n\n#[derive(Serialize, Debug)]\nstruct Ret {\n msg: String,\n number: i8,\n}\n\nfn main(who_to_greet: String, numbers: Vec<i8>) -> anyhow::Result<Ret> {\n println!(\n \"Person to greet: {} - numbers to choose: {:?}\",\n who_to_greet, numbers\n );\n Ok(Ret {\n msg: format!(\"Greetings {}!\", who_to_greet),\n number: *numbers\n .choose(&mut rand::thread_rng())\n .ok_or(anyhow!(\"There should be some numbers to choose from\"))?,\n })\n}\n";
27
- export declare const FETCH_INIT_CODE = "export async function main(\n\turl: string | undefined,\n\tmethod: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' = 'GET',\n\tbody: Object = {},\n\theaders: Record<string, string> = {}\n): Promise<Response | null> {\n\tif (!url) {\n\t\tconsole.error('Error: URL is undefined')\n\t\treturn null\n\t}\n\n\tconst requestOptions: RequestInit = {\n\t\tmethod: method || 'GET',\n\t\theaders: headers || {}\n\t}\n\n\tif (requestOptions.method !== 'GET' && requestOptions.method !== 'HEAD' && body !== undefined) {\n\t\trequestOptions.body = JSON.stringify(body)\n\t\trequestOptions.headers = {\n\t\t\t'Content-Type': 'application/json',\n\t\t\t...requestOptions.headers\n\t\t}\n\t}\n\n\treturn await fetch(url, requestOptions)\n\t\t.then((res) => res.json())\n\t\t.catch(() => {\n\t\t\tthrow new Error('An error occured')\n\t\t})\n}";
28
- export declare const BASH_INIT_CODE = "# shellcheck shell=bash\n# arguments of the form X=\"$I\" are parsed as parameters X of type string\nmsg=\"$1\"\ndflt=\"${2:-default value}\"\n\n# the last line of the stdout is the return value\n# unless you write json to './result.json' or a string to './result.out'\necho \"Hello $msg\"\n";
29
- export declare const DENO_INIT_CODE_TRIGGER: string;
30
- export declare const GO_INIT_CODE_TRIGGER = "package inner\n\nimport (\n\twmill \"github.com/windmill-labs/windmill-go-client\"\n)\n\nfunc main() (interface{}, error) {\n\n\t// A common trigger script would follow this pattern:\n\t// 1. Get the last saved state\n\tstate, _ := wmill.GetState()\n\t// 2. Get the actual state from the external service\n\t// newState := ...\n\t// 3. Compare the two states and update the internal state\n\twmill.SetState(4)\n\t// 4. Return the new rows\n\n\treturn state, nil\n\n\t// In subsequent scripts, you may refer to each row/value returned by the trigger script using\n\t// 'flow_input.iter.value'\n}\n";
31
- export declare const DENO_INIT_CODE_APPROVAL = "import * as wmill from \"npm:windmill-client@^1.158.2\"\n\nexport async function main(approver?: string) {\n const urls = await wmill.getResumeUrls(approver)\n // send the urls to their intended recipients\n\n return {\n // if the resumeUrls are part of the response, they will be available to any persons having access\n // to the run page and allowed to be approved from there, even from non owners of the flow\n // self-approval is disableable in the suspend options\n \t...urls,\n\n // to have prompts (self-approvable steps), clude instead the resume url in the returned payload of the step\n // the UX will automatically adapt and show the prompt to the operator when running the flow. e.g:\n // resume: urls['resume'],\n\n\t\tdefault_args: {},\n\t\tenums: {},\n\t\tdescription: undefined\n\t\t// supports all formats from rich display rendering such as simple strings,\n\t\t// but also markdown, html, images, tables, maps, render_all, etc...\n\t\t// https://www.windmill.dev/docs/core_concepts/rich_display_rendering\n }\n}\n\n// add a form in Advanced - Suspend\n// all on approval steps: https://www.windmill.dev/docs/flows/flow_approval";
32
- export declare const BUN_INIT_CODE_APPROVAL = "import * as wmill from \"windmill-client@^1.158.2\"\n\nexport async function main(approver?: string) {\n const urls = await wmill.getResumeUrls(approver)\n // send the urls to their intended recipients\n\n return {\n // if the resumeUrls are part of the response, they will be available to any persons having access\n // to the run page and allowed to be approved from there, even from non owners of the flow\n // self-approval is disableable in the suspend options\n \t...urls,\n\n // to have prompts (self-approvable steps), clude instead the resume url in the returned payload of the step\n // the UX will automatically adapt and show the prompt to the operator when running the flow. e.g:\n // resume: urls['resume'],\n\n\t\tdefault_args: {},\n\t\tenums: {},\n\t\tdescription: undefined\n\t\t// supports all formats from rich display rendering such as simple strings,\n\t\t// but also markdown, html, images, tables, maps, render_all, etc...\n\t\t// https://www.windmill.dev/docs/core_concepts/rich_display_rendering\n }\n}\n\n// add a form in Advanced - Suspend\n// all on approval steps: https://www.windmill.dev/docs/flows/flow_approval";
33
- export declare const PYTHON_INIT_CODE_APPROVAL = "import wmill\n\ndef main():\n urls = wmill.get_resume_urls()\n # send the urls to their intended recipients\n\n return {\n # if the get_resume_urls are part of the response, they will be available to any persons having access\n # to the run page and allowed to be approved from there, even from non owners of the flow\n # self-approval is disableable in the suspend options\n **urls,\n\n # to have prompts (self-approvable steps), clude instead the resume url in the returned payload of the step\n # the UX will automatically adapt and show the prompt to the operator when running the flow. e.g:\n # \"resume\": urls[\"resume\"],\n\n \"default_args\": {},\n \"enums\": {},\n \"description\": None,\n # supports all formats from rich display rendering such as simple strings,\n # but also markdown, html, images, tables, maps, render_all, etc...\n # https://www.windmill.dev/docs/core_concepts/rich_display_rendering\n }\n\n# add a form in Advanced - Suspend\n# all on approval steps: https://www.windmill.dev/docs/flows/flow_approval";
34
- export declare const DOCKER_INIT_CODE = "# shellcheck shell=bash\n# Bash script that calls docker as a client to the host daemon\n# See documentation: https://www.windmill.dev/docs/advanced/docker\nmsg=\"${1:-world}\"\n\nIMAGE=\"alpine:latest\"\nCOMMAND=\"/bin/echo Hello $msg\"\n\n# ensure that the image is up-to-date\ndocker pull $IMAGE\ndocker run --rm $IMAGE $COMMAND\n";
35
- export declare const POWERSHELL_INIT_CODE = "param($Msg, $Dflt = \"default value\", [int]$Nb = 3)\n\n# Import-Module MyModule\n\n# Import-Module WindmillClient\n# Connect-Windmill\n# Get-WindmillVariable -Path 'u/user/foo'\n\n# the last line of the stdout is the return value\nWrite-Output \"Hello $Msg\"";
3
+ export declare let PYTHON_FAILURE_MODULE_CODE: string;
4
+ export declare let PYTHON_INIT_CODE_CLEAR: string;
5
+ export declare let PYTHON_INIT_CODE_TRIGGER: string;
6
+ export declare let PYTHON_INIT_CODE: string;
7
+ export declare let NATIVETS_INIT_CODE: string;
8
+ export declare let BUNNATIVE_INIT_CODE: string;
9
+ export declare let NATIVETS_INIT_CODE_CLEAR: string;
10
+ export declare let DENO_INIT_CODE: string;
11
+ export declare let BUN_INIT_CODE: string;
12
+ export declare let GO_INIT_CODE: string;
13
+ export declare let GO_FAILURE_MODULE_CODE: string;
14
+ export declare let DENO_INIT_CODE_CLEAR: string;
15
+ export declare let BUN_INIT_CODE_CLEAR: string;
16
+ export declare let DENO_FAILURE_MODULE_CODE: string;
17
+ export declare let BUN_FAILURE_MODULE_CODE: string;
18
+ export declare let POSTGRES_INIT_CODE: string;
19
+ export declare let MYSQL_INIT_CODE: string;
20
+ export declare let BIGQUERY_INIT_CODE: string;
21
+ export declare let SNOWFLAKE_INIT_CODE: string;
22
+ export declare let MSSQL_INIT_CODE: string;
23
+ export declare let GRAPHQL_INIT_CODE: string;
24
+ export declare let PHP_INIT_CODE: string;
25
+ export declare let RUST_INIT_CODE: string;
26
+ export declare let FETCH_INIT_CODE: string;
27
+ export declare let BASH_INIT_CODE: string;
28
+ export declare let DENO_INIT_CODE_TRIGGER: string;
29
+ export declare let BUN_INIT_CODE_TRIGGER: string;
30
+ export declare let GO_INIT_CODE_TRIGGER: string;
31
+ export declare let DENO_INIT_CODE_APPROVAL: string;
32
+ export declare let BUN_INIT_CODE_APPROVAL: string;
33
+ export declare let BUN_PREPROCESSOR_MODULE_CODE: string;
34
+ export declare let DENO_PREPROCESSOR_MODULE_CODE: string;
35
+ export declare let PYTHON_INIT_CODE_APPROVAL: string;
36
+ export declare let PYTHON_PREPROCESSOR_MODULE_CODE: string;
37
+ export declare let DOCKER_INIT_CODE: string;
38
+ export declare let POWERSHELL_INIT_CODE: string;
39
+ export declare let ANSIBLE_PLAYBOOK_INIT_CODE: string;
36
40
  export declare function isInitialCode(content: string): boolean;
37
- export declare function initialCode(language: SupportedLanguage | 'bunnative' | undefined, kind: Script['kind'] | undefined, subkind: 'pgsql' | 'mysql' | 'flow' | 'script' | 'fetch' | 'docker' | 'powershell' | 'bunnative' | undefined): string;
41
+ export declare function initialCode(language: SupportedLanguage | 'bunnative' | undefined, kind: Script['kind'] | undefined, subkind: 'pgsql' | 'mysql' | 'flow' | 'script' | 'fetch' | 'docker' | 'powershell' | 'bunnative' | 'preprocessor' | undefined): string;
38
42
  export declare function getResetCode(language: SupportedLanguage | 'bunnative' | undefined, kind: Script['kind'] | undefined, subkind: 'pgsql' | 'mysql' | 'flow' | 'script' | 'fetch' | 'docker' | 'powershell' | 'bunnative' | undefined): string;
@@ -1,10 +1,72 @@
1
1
  import {} from './gen';
2
- import PYTHON_INIT_CODE from './init_scripts/python_init_code';
3
- import PYTHON_INIT_CODE_CLEAR from './init_scripts/python_init_code_clear';
4
- import PYTHON_INIT_CODE_TRIGGER from './init_scripts/python_init_code_trigger';
5
- import PYTHON_FAILURE_MODULE_CODE from './init_scripts/python_failure_module';
6
- export { PYTHON_INIT_CODE, PYTHON_INIT_CODE_CLEAR, PYTHON_INIT_CODE_TRIGGER, PYTHON_FAILURE_MODULE_CODE };
7
- export const NATIVETS_INIT_CODE = `// Fetch-only script, no imports allowed (except windmill) but benefits from a dedicated highly efficient runtime
2
+ export let PYTHON_FAILURE_MODULE_CODE = `import os
3
+
4
+ def main(message: str, name: str, step_id: str):
5
+ flow_id = os.environ.get("WM_ROOT_FLOW_JOB_ID")
6
+ print("message", message)
7
+ print("name", name)
8
+ print("step_id", step_id)
9
+ return { "message": message, "flow_id": flow_id, "step_id": step_id, "recover": False }`;
10
+ export let PYTHON_INIT_CODE_CLEAR = `# import wmill
11
+
12
+
13
+ def main(x: str):
14
+ return x`;
15
+ export let PYTHON_INIT_CODE_TRIGGER = `import wmill
16
+
17
+
18
+ def main():
19
+ # A common trigger script would follow this pattern:
20
+ # 1. Get the last saved state
21
+ # state = wmill.get_state()
22
+ # 2. Get the actual state from the external service
23
+ # newState = ...
24
+ # 3. Compare the two states and update the internal state
25
+ # wmill.setState(newState)
26
+ # 4. Return the new rows
27
+ # return range from (state to newState)
28
+ return [1, 2, 3]`;
29
+ export let PYTHON_INIT_CODE = `import os
30
+ import wmill
31
+
32
+ # You can import any PyPi package.
33
+ # See here for more info: https://www.windmill.dev/docs/advanced/dependencies_in_python
34
+
35
+ # you can use typed resources by doing a type alias to dict
36
+ #postgresql = dict
37
+
38
+ def main(
39
+ no_default: str,
40
+ #db: postgresql,
41
+ name="Nicolas Bourbaki",
42
+ age=42,
43
+ obj: dict = {"even": "dicts"},
44
+ l: list = ["or", "lists!"],
45
+ file_: bytes = bytes(0),
46
+ ):
47
+
48
+ print(f"Hello World and a warm welcome especially to {name}")
49
+ print("and its acolytes..", age, obj, l, len(file_))
50
+
51
+ # retrieve variables, resources, states using the wmill client
52
+ try:
53
+ secret = wmill.get_variable("f/examples/secret")
54
+ except:
55
+ secret = "No secret yet at f/examples/secret !"
56
+ print(f"The variable at \`f/examples/secret\`: {secret}")
57
+
58
+ # Get last state of this script execution by the same trigger/user
59
+ last_state = wmill.get_state()
60
+ new_state = {"foo": 42} if last_state is None else last_state
61
+ new_state["foo"] += 1
62
+ wmill.set_state(new_state)
63
+
64
+ # fetch context variables
65
+ user = os.environ.get("WM_USERNAME")
66
+
67
+ # return value is converted to JSON
68
+ return {"splitted": name.split(), "user": user, "state": new_state}`;
69
+ export let NATIVETS_INIT_CODE = `// Fetch-only script, no imports allowed (except windmill) but benefits from a dedicated highly efficient runtime
8
70
  //import * as wmill from './windmill.ts'
9
71
 
10
72
  export async function main(example_input: number = 3) {
@@ -15,7 +77,7 @@ export async function main(example_input: number = 3) {
15
77
  return res.json();
16
78
  }
17
79
  `;
18
- export const BUNNATIVE_INIT_CODE = `//native
80
+ export let BUNNATIVE_INIT_CODE = `//native
19
81
  //you can add proxy support using //proxy http(s)://host:port
20
82
 
21
83
  // native scripts are bun scripts that are executed on native workers and can be parallelized
@@ -31,7 +93,7 @@ export async function main(example_input: number = 3) {
31
93
  return res.json();
32
94
  }
33
95
  `;
34
- export const NATIVETS_INIT_CODE_CLEAR = `// Fetch-only script, no imports allowed (except windmill) but benefits from a dedicated highly efficient runtime
96
+ export let NATIVETS_INIT_CODE_CLEAR = `// Fetch-only script, no imports allowed (except windmill) but benefits from a dedicated highly efficient runtime
35
97
  //import * as wmill from './windmill.ts'
36
98
 
37
99
  export async function main() {
@@ -41,7 +103,7 @@ export async function main() {
41
103
  return res.json();
42
104
  }
43
105
  `;
44
- export const DENO_INIT_CODE = `// Ctrl/CMD+. to cache dependencies on imports hover.
106
+ export let DENO_INIT_CODE = `// Ctrl/CMD+. to cache dependencies on imports hover.
45
107
 
46
108
  // Deno uses "npm:" prefix to import from npm (https://deno.land/manual@v1.36.3/node/npm_specifiers)
47
109
  // import * as wmill from "npm:windmill-client@${__pkg__.version}"
@@ -61,7 +123,7 @@ export async function main(
61
123
  return { foo: a };
62
124
  }
63
125
  `;
64
- export const BUN_INIT_CODE = `// there are multiple modes to add as header: //nobundling //native //npm //nodejs
126
+ export let BUN_INIT_CODE = `// there are multiple modes to add as header: //nobundling //native //npm //nodejs
65
127
  // https://www.windmill.dev/docs/getting_started/scripts_quickstart/typescript#modes
66
128
 
67
129
  // import { toWords } from "number-to-words@1"
@@ -91,7 +153,7 @@ export async function main(
91
153
  return { foo: a };
92
154
  }
93
155
  `;
94
- export const GO_INIT_CODE = `package inner
156
+ export let GO_INIT_CODE = `package inner
95
157
 
96
158
  import (
97
159
  "fmt"
@@ -114,7 +176,7 @@ func main(x string, nested struct {
114
176
  return x, nil
115
177
  }
116
178
  `;
117
- export const GO_FAILURE_MODULE_CODE = `package inner
179
+ export let GO_FAILURE_MODULE_CODE = `package inner
118
180
 
119
181
  import (
120
182
  "fmt"
@@ -130,19 +192,19 @@ func main(message string, name string) (interface{}, error) {
130
192
  return message, nil
131
193
  }
132
194
  `;
133
- export const DENO_INIT_CODE_CLEAR = `// import * as wmill from "npm:windmill-client@${__pkg__.version}"
195
+ export let DENO_INIT_CODE_CLEAR = `// import * as wmill from "npm:windmill-client@${__pkg__.version}"
134
196
 
135
197
  export async function main(x: string) {
136
198
  return x
137
199
  }
138
200
  `;
139
- export const BUN_INIT_CODE_CLEAR = `// import * as wmill from "windmill-client"
201
+ export let BUN_INIT_CODE_CLEAR = `// import * as wmill from "windmill-client"
140
202
 
141
203
  export async function main(x: string) {
142
204
  return x
143
205
  }
144
206
  `;
145
- export const DENO_FAILURE_MODULE_CODE = `
207
+ export let DENO_FAILURE_MODULE_CODE = `
146
208
  export async function main(message: string, name: string, step_id: string) {
147
209
  const flow_id = Deno.env.get("WM_ROOT_FLOW_JOB_ID")
148
210
  console.log("message", message)
@@ -151,7 +213,7 @@ export async function main(message: string, name: string, step_id: string) {
151
213
  return { message, flow_id, step_id, recover: false }
152
214
  }
153
215
  `;
154
- export const BUN_FAILURE_MODULE_CODE = `
216
+ export let BUN_FAILURE_MODULE_CODE = `
155
217
  export async function main(message: string, name: string, step_id: string) {
156
218
  const flow_id = process.env.WM_ROOT_FLOW_JOB_ID
157
219
  console.log("message", message)
@@ -160,7 +222,7 @@ export async function main(message: string, name: string, step_id: string) {
160
222
  return { message, flow_id, step_id, recover: false }
161
223
  }
162
224
  `;
163
- export const POSTGRES_INIT_CODE = `-- to pin the database use '-- database f/your/path'
225
+ export let POSTGRES_INIT_CODE = `-- to pin the database use '-- database f/your/path'
164
226
  -- $1 name1 = default arg
165
227
  -- $2 name2
166
228
  -- $3 name3
@@ -168,14 +230,14 @@ export const POSTGRES_INIT_CODE = `-- to pin the database use '-- database f/you
168
230
  INSERT INTO demo VALUES (\$1::TEXT, \$2::INT, \$3::TEXT[]) RETURNING *;
169
231
  UPDATE demo SET col2 = \$4::INT WHERE col2 = \$2::INT;
170
232
  `;
171
- export const MYSQL_INIT_CODE = `-- to pin the database use '-- database f/your/path'
233
+ export let MYSQL_INIT_CODE = `-- to pin the database use '-- database f/your/path'
172
234
  -- :name1 (text) = default arg
173
235
  -- :name2 (int)
174
236
  -- :name3 (int)
175
237
  INSERT INTO demo VALUES (:name1, :name2);
176
238
  UPDATE demo SET col2 = :name3 WHERE col2 = :name2;
177
239
  `;
178
- export const BIGQUERY_INIT_CODE = `-- to pin the database use '-- database f/your/path'
240
+ export let BIGQUERY_INIT_CODE = `-- to pin the database use '-- database f/your/path'
179
241
  -- @name1 (string) = default arg
180
242
  -- @name2 (integer)
181
243
  -- @name3 (string[])
@@ -183,7 +245,7 @@ export const BIGQUERY_INIT_CODE = `-- to pin the database use '-- database f/you
183
245
  INSERT INTO \`demodb.demo\` VALUES (@name1, @name2, @name3);
184
246
  UPDATE \`demodb.demo\` SET col2 = @name4 WHERE col2 = @name2;
185
247
  `;
186
- export const SNOWFLAKE_INIT_CODE = `-- to pin the database use '-- database f/your/path'
248
+ export let SNOWFLAKE_INIT_CODE = `-- to pin the database use '-- database f/your/path'
187
249
  -- ? name1 (varchar) = default arg
188
250
  -- ? name2 (int)
189
251
  INSERT INTO demo VALUES (?, ?);
@@ -191,14 +253,15 @@ INSERT INTO demo VALUES (?, ?);
191
253
  -- ? name2 (int)
192
254
  UPDATE demo SET col2 = ? WHERE col2 = ?;
193
255
  `;
194
- export const MSSQL_INIT_CODE = `-- to pin the database use '-- database f/your/path'
256
+ export let MSSQL_INIT_CODE = `-- return_last_result
257
+ -- to pin the database use '-- database f/your/path'
195
258
  -- @p1 name1 (varchar) = default arg
196
259
  -- @p2 name2 (int)
197
260
  -- @p3 name3 (int)
198
261
  INSERT INTO demo VALUES (@p1, @p2);
199
262
  UPDATE demo SET col2 = @p3 WHERE col2 = @p2;
200
263
  `;
201
- export const GRAPHQL_INIT_CODE = `query($name4: String, $name2: Int, $name3: [String]) {
264
+ export let GRAPHQL_INIT_CODE = `query($name4: String, $name2: Int, $name3: [String]) {
202
265
  demo(name1: $name1, name2: $name2, name3: $name3) {
203
266
  name1,
204
267
  name2,
@@ -206,7 +269,7 @@ export const GRAPHQL_INIT_CODE = `query($name4: String, $name2: Int, $name3: [St
206
269
  }
207
270
  }
208
271
  `;
209
- export const PHP_INIT_CODE = `<?php
272
+ export let PHP_INIT_CODE = `<?php
210
273
 
211
274
  // remove the first // of the following lines to specify packages to install using composer
212
275
  // // require:
@@ -225,7 +288,7 @@ function main(
225
288
  return $d;
226
289
  }
227
290
  `;
228
- export const RUST_INIT_CODE = `//! Add dependencies in the following partial Cargo.toml manifest
291
+ export let RUST_INIT_CODE = `//! Add dependencies in the following partial Cargo.toml manifest
229
292
  //!
230
293
  //! \`\`\`cargo
231
294
  //! [dependencies]
@@ -259,7 +322,7 @@ fn main(who_to_greet: String, numbers: Vec<i8>) -> anyhow::Result<Ret> {
259
322
  })
260
323
  }
261
324
  `;
262
- export const FETCH_INIT_CODE = `export async function main(
325
+ export let FETCH_INIT_CODE = `export async function main(
263
326
  url: string | undefined,
264
327
  method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' = 'GET',
265
328
  body: Object = {},
@@ -289,7 +352,7 @@ export const FETCH_INIT_CODE = `export async function main(
289
352
  throw new Error('An error occured')
290
353
  })
291
354
  }`;
292
- export const BASH_INIT_CODE = `# shellcheck shell=bash
355
+ export let BASH_INIT_CODE = `# shellcheck shell=bash
293
356
  # arguments of the form X="$I" are parsed as parameters X of type string
294
357
  msg="$1"
295
358
  dflt="\${2:-default value}"
@@ -298,7 +361,27 @@ dflt="\${2:-default value}"
298
361
  # unless you write json to './result.json' or a string to './result.out'
299
362
  echo "Hello $msg"
300
363
  `;
301
- export const DENO_INIT_CODE_TRIGGER = `import * as wmill from "npm:windmill-client@${__pkg__.version}"
364
+ export let DENO_INIT_CODE_TRIGGER = `import * as wmill from "npm:windmill-client@${__pkg__.version}"
365
+
366
+ export async function main() {
367
+
368
+ // A common trigger script would follow this pattern:
369
+ // 1. Get the last saved state
370
+ // const state = await wmill.getState()
371
+ // 2. Get the actual state from the external service
372
+ // const newState = await (await fetch('https://hacker-news.firebaseio.com/v0/topstories.json')).json()
373
+ // 3. Compare the two states and update the internal state
374
+ // await wmill.setState(newState)
375
+ // 4. Return the new rows
376
+ // return range from (state to newState)
377
+
378
+ return [1,2,3]
379
+
380
+ // In subsequent scripts, you may refer to each row/value returned by the trigger script using
381
+ // 'flow_input.iter.value'
382
+ }
383
+ `;
384
+ export let BUN_INIT_CODE_TRIGGER = `import * as wmill from "windmill-client"
302
385
 
303
386
  export async function main() {
304
387
 
@@ -318,7 +401,7 @@ export async function main() {
318
401
  // 'flow_input.iter.value'
319
402
  }
320
403
  `;
321
- export const GO_INIT_CODE_TRIGGER = `package inner
404
+ export let GO_INIT_CODE_TRIGGER = `package inner
322
405
 
323
406
  import (
324
407
  wmill "github.com/windmill-labs/windmill-go-client"
@@ -341,7 +424,7 @@ func main() (interface{}, error) {
341
424
  // 'flow_input.iter.value'
342
425
  }
343
426
  `;
344
- export const DENO_INIT_CODE_APPROVAL = `import * as wmill from "npm:windmill-client@^1.158.2"
427
+ export let DENO_INIT_CODE_APPROVAL = `import * as wmill from "npm:windmill-client@^1.158.2"
345
428
 
346
429
  export async function main(approver?: string) {
347
430
  const urls = await wmill.getResumeUrls(approver)
@@ -368,7 +451,7 @@ export async function main(approver?: string) {
368
451
 
369
452
  // add a form in Advanced - Suspend
370
453
  // all on approval steps: https://www.windmill.dev/docs/flows/flow_approval`;
371
- export const BUN_INIT_CODE_APPROVAL = `import * as wmill from "windmill-client@^1.158.2"
454
+ export let BUN_INIT_CODE_APPROVAL = `import * as wmill from "windmill-client@^1.158.2"
372
455
 
373
456
  export async function main(approver?: string) {
374
457
  const urls = await wmill.getResumeUrls(approver)
@@ -395,7 +478,47 @@ export async function main(approver?: string) {
395
478
 
396
479
  // add a form in Advanced - Suspend
397
480
  // all on approval steps: https://www.windmill.dev/docs/flows/flow_approval`;
398
- export const PYTHON_INIT_CODE_APPROVAL = `import wmill
481
+ export let BUN_PREPROCESSOR_MODULE_CODE = `
482
+ export async function preprocessor(
483
+ wm_trigger: {
484
+ kind: 'http' | 'email' | 'webhook',
485
+ http?: {
486
+ route: string // The route path, e.g. "/users/:id"
487
+ path: string // The actual path called, e.g. "/users/123"
488
+ method: string
489
+ params: Record<string, string>
490
+ query: Record<string, string>
491
+ headers: Record<string, string>
492
+ }
493
+ },
494
+ /* your other args */
495
+ ) {
496
+ return {
497
+ // return the args to be passed to the flow
498
+ }
499
+ }
500
+ `;
501
+ export let DENO_PREPROCESSOR_MODULE_CODE = `
502
+ export async function preprocessor(
503
+ wm_trigger: {
504
+ kind: 'http' | 'email' | 'wehbook',
505
+ http?: {
506
+ route: string // The route path, e.g. "/users/:id"
507
+ path: string // The actual path called, e.g. "/users/123"
508
+ method: string
509
+ params: Record<string, string>
510
+ query: Record<string, string>
511
+ headers: Record<string, string>
512
+ }
513
+ },
514
+ /* your other args */
515
+ ) {
516
+ return {
517
+ // return the args to be passed to the flow
518
+ }
519
+ }
520
+ `;
521
+ export let PYTHON_INIT_CODE_APPROVAL = `import wmill
399
522
 
400
523
  def main():
401
524
  urls = wmill.get_resume_urls()
@@ -421,7 +544,29 @@ def main():
421
544
 
422
545
  # add a form in Advanced - Suspend
423
546
  # all on approval steps: https://www.windmill.dev/docs/flows/flow_approval`;
424
- export const DOCKER_INIT_CODE = `# shellcheck shell=bash
547
+ export let PYTHON_PREPROCESSOR_MODULE_CODE = `from typing import TypedDict, Literal
548
+
549
+ class Http(TypedDict):
550
+ route: str # The route path, e.g. "/users/:id"
551
+ path: str # The actual path called, e.g. "/users/123"
552
+ method: str
553
+ params: dict[str, str]
554
+ query: dict[str, str]
555
+ headers: dict[str, str]
556
+
557
+ class WmTrigger(TypedDict):
558
+ kind: Literal["http", "email", "webhook"]
559
+ http: Http | None
560
+
561
+ def preprocessor(
562
+ wm_trigger: WmTrigger,
563
+ # your other args
564
+ ):
565
+ return {
566
+ # return the args to be passed to the flow
567
+ }
568
+ `;
569
+ export let DOCKER_INIT_CODE = `# shellcheck shell=bash
425
570
  # Bash script that calls docker as a client to the host daemon
426
571
  # See documentation: https://www.windmill.dev/docs/advanced/docker
427
572
  msg="\${1:-world}"
@@ -433,7 +578,7 @@ COMMAND="/bin/echo Hello $msg"
433
578
  docker pull $IMAGE
434
579
  docker run --rm $IMAGE $COMMAND
435
580
  `;
436
- export const POWERSHELL_INIT_CODE = `param($Msg, $Dflt = "default value", [int]$Nb = 3)
581
+ export let POWERSHELL_INIT_CODE = `param($Msg, $Dflt = "default value", [int]$Nb = 3)
437
582
 
438
583
  # Import-Module MyModule
439
584
 
@@ -443,6 +588,50 @@ export const POWERSHELL_INIT_CODE = `param($Msg, $Dflt = "default value", [int]$
443
588
 
444
589
  # the last line of the stdout is the return value
445
590
  Write-Output "Hello $Msg"`;
591
+ export let ANSIBLE_PLAYBOOK_INIT_CODE = `---
592
+ inventory:
593
+ - resource_type: ansible_inventory
594
+ # You can pin an inventory to this script by hardcoding the resource path:
595
+ # resource: u/user/your_resource
596
+
597
+ # File resources will be written in the relative \`target\` location before
598
+ # running the playbook
599
+ # file_resources:
600
+ # - resource: u/user/fabulous_jinja_template
601
+ # target: ./config_template.j2
602
+
603
+ # Define the arguments of the windmill script
604
+ extra_vars:
605
+ world_qualifier:
606
+ type: string
607
+
608
+ dependencies:
609
+ galaxy:
610
+ collections:
611
+ - name: community.general
612
+ - name: community.vmware
613
+ python:
614
+ - jmespath
615
+ ---
616
+ - name: Echo
617
+ hosts: 127.0.0.1
618
+ connection: local
619
+ vars:
620
+ my_result:
621
+ a: 2
622
+ b: true
623
+ c: "Hello"
624
+
625
+ tasks:
626
+ - name: Print debug message
627
+ debug:
628
+ msg: "Hello, {{world_qualifier}} world!"
629
+ - name: Write variable my_result to result.json
630
+ delegate_to: localhost
631
+ copy:
632
+ content: "{{ my_result | to_json }}"
633
+ dest: result.json
634
+ `;
446
635
  const ALL_INITIAL_CODE = [
447
636
  PYTHON_INIT_CODE,
448
637
  PYTHON_INIT_CODE_TRIGGER,
@@ -456,15 +645,21 @@ const ALL_INITIAL_CODE = [
456
645
  DENO_INIT_CODE_TRIGGER,
457
646
  DENO_INIT_CODE_CLEAR,
458
647
  PYTHON_INIT_CODE_CLEAR,
648
+ PYTHON_FAILURE_MODULE_CODE,
649
+ PYTHON_PREPROCESSOR_MODULE_CODE,
459
650
  DENO_INIT_CODE_APPROVAL,
460
651
  DENO_FAILURE_MODULE_CODE,
652
+ DENO_PREPROCESSOR_MODULE_CODE,
461
653
  BUN_INIT_CODE,
462
654
  BUN_INIT_CODE_CLEAR,
463
655
  BUN_INIT_CODE_APPROVAL,
656
+ BUN_FAILURE_MODULE_CODE,
657
+ BUN_PREPROCESSOR_MODULE_CODE,
464
658
  BASH_INIT_CODE,
465
659
  POWERSHELL_INIT_CODE,
466
660
  PHP_INIT_CODE,
467
661
  RUST_INIT_CODE,
662
+ ANSIBLE_PLAYBOOK_INIT_CODE
468
663
  ];
469
664
  export function isInitialCode(content) {
470
665
  for (const code of ALL_INITIAL_CODE) {
@@ -495,6 +690,9 @@ export function initialCode(language, kind, subkind) {
495
690
  else if (subkind === 'fetch') {
496
691
  return FETCH_INIT_CODE;
497
692
  }
693
+ else if (subkind === 'preprocessor') {
694
+ return DENO_PREPROCESSOR_MODULE_CODE;
695
+ }
498
696
  else {
499
697
  return DENO_INIT_CODE;
500
698
  }
@@ -522,6 +720,9 @@ export function initialCode(language, kind, subkind) {
522
720
  else if (subkind === 'flow') {
523
721
  return PYTHON_INIT_CODE_CLEAR;
524
722
  }
723
+ else if (subkind === 'preprocessor') {
724
+ return PYTHON_PREPROCESSOR_MODULE_CODE;
725
+ }
525
726
  else {
526
727
  return PYTHON_INIT_CODE;
527
728
  }
@@ -564,8 +765,14 @@ export function initialCode(language, kind, subkind) {
564
765
  else if (language == 'rust') {
565
766
  return RUST_INIT_CODE;
566
767
  }
768
+ else if (language == 'ansible') {
769
+ return ANSIBLE_PLAYBOOK_INIT_CODE;
770
+ }
567
771
  else if (language == 'bun' || language == 'bunnative') {
568
- if (language == 'bunnative' || subkind === 'bunnative') {
772
+ if (kind == 'trigger') {
773
+ return BUN_INIT_CODE_TRIGGER;
774
+ }
775
+ else if (language == 'bunnative' || subkind === 'bunnative') {
569
776
  return BUNNATIVE_INIT_CODE;
570
777
  }
571
778
  else if (kind === 'approval') {
@@ -574,7 +781,10 @@ export function initialCode(language, kind, subkind) {
574
781
  else if (kind === 'failure') {
575
782
  return BUN_FAILURE_MODULE_CODE;
576
783
  }
577
- if (subkind === 'flow') {
784
+ else if (subkind === 'preprocessor') {
785
+ return BUN_PREPROCESSOR_MODULE_CODE;
786
+ }
787
+ else if (subkind === 'flow') {
578
788
  return BUN_INIT_CODE_CLEAR;
579
789
  }
580
790
  return BUN_INIT_CODE;
@@ -1,6 +1,6 @@
1
1
  import type { Schema, SupportedLanguage } from './common';
2
2
  import { type Script } from './gen';
3
- export declare function scriptLangToEditorLang(lang: Script['language'] | 'bunnative' | 'frontend' | undefined): "go" | "powershell" | "graphql" | "php" | "rust" | "sql" | "typescript" | "python" | "shell";
3
+ export declare function scriptLangToEditorLang(lang: Script['language'] | 'bunnative' | 'frontend' | undefined): "go" | "powershell" | "graphql" | "php" | "rust" | "sql" | "yaml" | "typescript" | "python" | "shell";
4
4
  export type ScriptSchedule = {
5
5
  summary: string | undefined;
6
6
  args: Record<string, any>;