windmill-components 1.13.25 → 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/common.js +1 -5
  2. package/components/AppConnect.svelte +281 -0
  3. package/components/AppConnect.svelte.d.ts +22 -0
  4. package/components/ArgInfo.svelte +11 -16
  5. package/components/ArgInput.svelte +73 -70
  6. package/components/ArgInput.svelte.d.ts +6 -1
  7. package/components/AutosizedTextarea.svelte +6 -8
  8. package/components/Badge.svelte +4 -10
  9. package/components/Button.svelte +22 -18
  10. package/components/ButtonAndDropdown.svelte +6 -12
  11. package/components/CenteredModal.svelte +30 -0
  12. package/components/CenteredModal.svelte.d.ts +19 -0
  13. package/components/ChevronButton.svelte +4 -9
  14. package/components/DisplayResult.svelte +58 -57
  15. package/components/Dropdown.svelte +8 -13
  16. package/components/Editor.svelte +108 -149
  17. package/components/Editor.svelte.d.ts +3 -1
  18. package/components/FieldHeader.svelte +7 -12
  19. package/components/FlowBuilder.svelte +72 -121
  20. package/components/FlowBuilder.svelte.d.ts +0 -2
  21. package/components/FlowEditor.svelte +185 -73
  22. package/components/FlowEditor.svelte.d.ts +4 -4
  23. package/components/FlowJobResult.svelte +23 -0
  24. package/components/FlowJobResult.svelte.d.ts +17 -0
  25. package/components/FlowPreview.svelte +36 -51
  26. package/components/FlowPreview.svelte.d.ts +7 -1
  27. package/components/FlowStatusViewer.svelte +66 -40
  28. package/components/FlowStatusViewer.svelte.d.ts +1 -1
  29. package/components/FlowViewer.svelte +100 -0
  30. package/components/FlowViewer.svelte.d.ts +24 -0
  31. package/components/GroupModal.svelte +13 -20
  32. package/components/IconedResourceType.svelte +15 -18
  33. package/components/InviteGlobalUser.svelte +8 -15
  34. package/components/InviteUser.svelte +9 -16
  35. package/components/ItemPicker.svelte +11 -14
  36. package/components/JobStatus.svelte +6 -11
  37. package/components/Modal.svelte +14 -17
  38. package/components/ModuleStep.svelte +125 -64
  39. package/components/ModuleStep.svelte.d.ts +4 -8
  40. package/components/ObjectResourceInput.svelte +15 -20
  41. package/components/ObjectTypeNarrowing.svelte +7 -12
  42. package/components/PageHeader.svelte +4 -9
  43. package/components/Password.svelte +6 -8
  44. package/components/Path.svelte +78 -38
  45. package/components/Path.svelte.d.ts +2 -0
  46. package/components/RadioButton.svelte +7 -8
  47. package/components/RadioButtonV2.svelte +33 -0
  48. package/components/RadioButtonV2.svelte.d.ts +20 -0
  49. package/components/Required.svelte +2 -4
  50. package/components/ResourceEditor.svelte +44 -48
  51. package/components/ResourcePicker.svelte +6 -7
  52. package/components/ResourcePicker.svelte.d.ts +2 -2
  53. package/components/ResourceTypePicker.svelte +8 -13
  54. package/components/RunForm.svelte +15 -20
  55. package/components/SchemaEditor.svelte +31 -61
  56. package/components/SchemaForm.svelte +126 -134
  57. package/components/SchemaForm.svelte.d.ts +6 -4
  58. package/components/SchemaModal.svelte +25 -40
  59. package/components/SchemaModal.svelte.d.ts +1 -1
  60. package/components/SchemaViewer.svelte +6 -12
  61. package/components/ScriptBuilder.svelte +76 -101
  62. package/components/ScriptEditor.svelte +55 -60
  63. package/components/ScriptPicker.svelte +28 -34
  64. package/components/ScriptPicker.svelte.d.ts +1 -0
  65. package/components/ScriptSchema.svelte +13 -17
  66. package/components/ShareModal.svelte +23 -29
  67. package/components/SharedBadge.svelte +11 -16
  68. package/components/StringTypeNarrowing.svelte +8 -11
  69. package/components/Switch.svelte.d.ts +2 -2
  70. package/components/TableCustom.svelte +5 -8
  71. package/components/TableSimple.svelte +9 -8
  72. package/components/Tabs.svelte +6 -8
  73. package/components/Toggle.svelte +34 -0
  74. package/components/Toggle.svelte.d.ts +28 -0
  75. package/components/Tooltip.svelte +56 -89
  76. package/components/Tooltip.svelte.d.ts +1 -5
  77. package/components/VariableEditor.svelte +30 -29
  78. package/components/flows/CopyFirstStepSchema.svelte +10 -0
  79. package/components/flows/CopyFirstStepSchema.svelte.d.ts +14 -0
  80. package/components/flows/DynamicInputHelpBox.svelte +72 -0
  81. package/components/flows/DynamicInputHelpBox.svelte.d.ts +14 -0
  82. package/components/flows/FlowInputs.svelte +27 -0
  83. package/components/flows/FlowInputs.svelte.d.ts +19 -0
  84. package/components/flows/FlowModuleHeader.svelte +91 -0
  85. package/components/flows/FlowModuleHeader.svelte.d.ts +22 -0
  86. package/components/flows/flowStore.d.ts +17 -0
  87. package/components/flows/flowStore.js +161 -0
  88. package/components/flows/pickers/FlowScriptPicker.svelte +11 -0
  89. package/components/flows/pickers/FlowScriptPicker.svelte.d.ts +22 -0
  90. package/components/flows/pickers/PickHubScript.svelte +30 -0
  91. package/components/flows/pickers/PickHubScript.svelte.d.ts +18 -0
  92. package/components/flows/pickers/PickScript.svelte +38 -0
  93. package/components/flows/pickers/PickScript.svelte.d.ts +18 -0
  94. package/components/flows/utils.d.ts +21 -0
  95. package/components/flows/utils.js +164 -0
  96. package/components/icons/DbIcon.svelte +2 -5
  97. package/components/icons/Mail.svelte +2 -5
  98. package/components/icons/Mysql.svelte +2 -5
  99. package/components/icons/PostgresIcon.svelte +2 -5
  100. package/components/icons/Slack.svelte +2 -5
  101. package/components/propertyPicker/ObjectViewer.svelte +113 -0
  102. package/components/propertyPicker/ObjectViewer.svelte.d.ts +21 -0
  103. package/components/propertyPicker/OverlayPropertyPicker.svelte +69 -0
  104. package/components/propertyPicker/OverlayPropertyPicker.svelte.d.ts +21 -0
  105. package/components/propertyPicker/PropPicker.svelte +24 -0
  106. package/components/propertyPicker/PropPicker.svelte.d.ts +18 -0
  107. package/components/propertyPicker/WarningMessage.svelte +43 -0
  108. package/components/propertyPicker/WarningMessage.svelte.d.ts +16 -0
  109. package/components/propertyPicker/utils.d.ts +2 -0
  110. package/components/propertyPicker/utils.js +40 -0
  111. package/gen/core/ApiError.d.ts +3 -1
  112. package/gen/core/ApiError.js +4 -6
  113. package/gen/core/ApiRequestOptions.js +1 -2
  114. package/gen/core/ApiResult.js +1 -2
  115. package/gen/core/CancelablePromise.js +2 -7
  116. package/gen/core/OpenAPI.js +2 -5
  117. package/gen/core/request.js +8 -13
  118. package/gen/index.d.ts +3 -0
  119. package/gen/index.js +28 -58
  120. package/gen/models/AuditLog.js +2 -5
  121. package/gen/models/CompletedJob.d.ts +3 -1
  122. package/gen/models/CompletedJob.js +3 -5
  123. package/gen/models/ContextualVariable.js +1 -2
  124. package/gen/models/CreateResource.d.ts +1 -0
  125. package/gen/models/CreateResource.js +1 -2
  126. package/gen/models/CreateVariable.d.ts +2 -0
  127. package/gen/models/CreateVariable.js +1 -2
  128. package/gen/models/CreateWorkspace.js +1 -2
  129. package/gen/models/EditResource.js +1 -2
  130. package/gen/models/EditResourceType.js +1 -2
  131. package/gen/models/EditSchedule.js +1 -2
  132. package/gen/models/EditVariable.js +1 -2
  133. package/gen/models/EditWorkspaceUser.js +1 -2
  134. package/gen/models/Flow.js +1 -2
  135. package/gen/models/FlowModule.d.ts +2 -0
  136. package/gen/models/FlowModule.js +1 -2
  137. package/gen/models/FlowModuleValue.d.ts +14 -2
  138. package/gen/models/FlowModuleValue.js +9 -5
  139. package/gen/models/FlowPreview.js +1 -2
  140. package/gen/models/FlowStatus.js +1 -2
  141. package/gen/models/FlowStatusModule.d.ts +6 -0
  142. package/gen/models/FlowStatusModule.js +2 -5
  143. package/gen/models/FlowValue.js +1 -2
  144. package/gen/models/GlobalUserInfo.js +2 -5
  145. package/gen/models/Group.js +1 -2
  146. package/gen/models/InputTransform.js +2 -5
  147. package/gen/models/Job.js +2 -5
  148. package/gen/models/ListableVariable.d.ts +2 -0
  149. package/gen/models/ListableVariable.js +1 -2
  150. package/gen/models/Login.js +1 -2
  151. package/gen/models/MainArgSignature.js +1 -2
  152. package/gen/models/NewSchedule.js +1 -2
  153. package/gen/models/NewToken.js +1 -2
  154. package/gen/models/NewUser.js +1 -2
  155. package/gen/models/Preview.js +2 -5
  156. package/gen/models/QueuedJob.d.ts +2 -1
  157. package/gen/models/QueuedJob.js +3 -5
  158. package/gen/models/Resource.d.ts +1 -0
  159. package/gen/models/Resource.js +1 -2
  160. package/gen/models/ResourceType.js +1 -2
  161. package/gen/models/Schedule.js +1 -2
  162. package/gen/models/Script.d.ts +1 -0
  163. package/gen/models/Script.js +2 -5
  164. package/gen/models/ScriptArgs.js +1 -2
  165. package/gen/models/SlackToken.d.ts +8 -0
  166. package/gen/models/SlackToken.js +4 -0
  167. package/gen/models/TokenResponse.d.ts +6 -0
  168. package/gen/models/TokenResponse.js +4 -0
  169. package/gen/models/TruncatedToken.js +1 -2
  170. package/gen/models/User.js +1 -2
  171. package/gen/models/UserWorkspaceList.js +1 -2
  172. package/gen/models/WorkerPing.js +1 -2
  173. package/gen/models/Workspace.js +1 -2
  174. package/gen/models/WorkspaceInvite.js +1 -2
  175. package/gen/services/AdminService.d.ts +6 -2
  176. package/gen/services/AdminService.js +6 -10
  177. package/gen/services/AuditService.d.ts +24 -8
  178. package/gen/services/AuditService.js +5 -9
  179. package/gen/services/FlowService.d.ts +37 -10
  180. package/gen/services/FlowService.js +23 -12
  181. package/gen/services/GranularAclService.d.ts +6 -2
  182. package/gen/services/GranularAclService.js +6 -10
  183. package/gen/services/GroupService.d.ts +18 -6
  184. package/gen/services/GroupService.js +11 -15
  185. package/gen/services/JobService.d.ts +167 -46
  186. package/gen/services/JobService.js +42 -22
  187. package/gen/services/OauthService.d.ts +104 -0
  188. package/gen/services/OauthService.js +133 -0
  189. package/gen/services/ResourceService.d.ts +39 -7
  190. package/gen/services/ResourceService.js +44 -18
  191. package/gen/services/ScheduleService.d.ts +36 -6
  192. package/gen/services/ScheduleService.js +39 -13
  193. package/gen/services/ScriptService.d.ts +66 -19
  194. package/gen/services/ScriptService.js +32 -20
  195. package/gen/services/SettingsService.js +5 -9
  196. package/gen/services/UserService.d.ts +49 -11
  197. package/gen/services/UserService.js +42 -29
  198. package/gen/services/VariableService.d.ts +19 -4
  199. package/gen/services/VariableService.js +24 -13
  200. package/gen/services/WorkerService.d.ts +6 -2
  201. package/gen/services/WorkerService.js +4 -8
  202. package/gen/services/WorkspaceService.d.ts +29 -24
  203. package/gen/services/WorkspaceService.js +23 -42
  204. package/infer.js +5 -9
  205. package/logout.js +20 -18
  206. package/package.json +51 -24
  207. package/script_helpers.d.ts +4 -0
  208. package/script_helpers.js +70 -0
  209. package/scripts.d.ts +2 -1
  210. package/scripts.js +11 -15
  211. package/stores.d.ts +6 -0
  212. package/stores.js +30 -22
  213. package/user.js +10 -15
  214. package/utils.d.ts +15 -1
  215. package/utils.js +191 -52
@@ -1,57 +1,68 @@
1
- <script>"use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.initialPath = exports.flow = void 0;
7
- const gen_1 = require("$lib/gen");
8
- const utils_1 = require("$lib/utils");
9
- const stores_1 = require("$app/stores");
10
- const navigation_1 = require("$app/navigation");
11
- const Path_svelte_1 = __importDefault(require("./Path.svelte"));
12
- const svelte_markdown_1 = __importDefault(require("svelte-markdown"));
13
- const stores_2 = require("$lib/stores");
14
- const ScriptSchema_svelte_1 = __importDefault(require("./ScriptSchema.svelte"));
15
- const Required_svelte_1 = __importDefault(require("./Required.svelte"));
16
- const FlowEditor_svelte_1 = __importDefault(require("./FlowEditor.svelte"));
17
- exports.initialPath = '';
1
+ <script>import { goto } from '$app/navigation';
2
+ import { page } from '$app/stores';
3
+ import { FlowService, ScriptService } from '../gen';
4
+ import { clearPreviewResults, hubScripts, workspaceStore } from '../stores';
5
+ import { sendUserToast, setQueryWithoutLoad } from '../utils';
6
+ import { faFileExport, faFileImport } from '@fortawesome/free-solid-svg-icons';
7
+ import { onMount } from 'svelte';
8
+ import Icon from 'svelte-awesome';
9
+ import FlowEditor from './FlowEditor.svelte';
10
+ import { flowStore } from './flows/flowStore';
11
+ import { flowToMode } from './flows/utils';
12
+ import ScriptSchema from './ScriptSchema.svelte';
13
+ export let initialPath = '';
14
+ let pathError = '';
15
+ let mode;
18
16
  $: step = Number($page.url.searchParams.get('step')) || 1;
17
+ async function loadSearchData() {
18
+ const scripts = await ScriptService.listHubScripts();
19
+ $hubScripts = scripts.map((x) => ({
20
+ path: `hub/${x.id}/${x.summary.toLowerCase().replaceAll(/\s+/g, '_')}`,
21
+ summary: `${x.summary} (${x.app})`,
22
+ approved: x.approved,
23
+ is_trigger: x.is_trigger
24
+ }));
25
+ }
19
26
  async function saveFlow() {
20
- if (exports.initialPath == '') {
21
- await gen_1.FlowService.createFlow({
27
+ const newFlow = flowToMode($flowStore, mode);
28
+ if (initialPath === '') {
29
+ await FlowService.createFlow({
22
30
  workspace: $workspaceStore,
23
31
  requestBody: {
24
- path: exports.flow.path,
25
- summary: exports.flow.summary,
26
- description: exports.flow.description ?? '',
27
- value: exports.flow.value,
28
- schema: exports.flow.schema
32
+ path: newFlow.path,
33
+ summary: newFlow.summary,
34
+ description: newFlow.description ?? '',
35
+ value: newFlow.value,
36
+ schema: newFlow.schema
29
37
  }
30
38
  });
31
39
  }
32
40
  else {
33
- await gen_1.FlowService.updateFlow({
41
+ await FlowService.updateFlow({
34
42
  workspace: $workspaceStore,
35
- path: exports.initialPath,
43
+ path: newFlow.path,
36
44
  requestBody: {
37
- path: exports.flow.path,
38
- summary: exports.flow.summary,
39
- description: exports.flow.description ?? '',
40
- value: exports.flow.value,
41
- schema: exports.flow.schema
45
+ path: newFlow.path,
46
+ summary: newFlow.summary,
47
+ description: newFlow.description ?? '',
48
+ value: newFlow.value,
49
+ schema: newFlow.schema
42
50
  }
43
51
  });
44
52
  }
45
- (0, utils_1.sendUserToast)(`Success! flow saved at ${exports.flow.path}`);
46
- (0, navigation_1.goto)(`/flows/get/${exports.flow.path}`);
53
+ sendUserToast(`Success! flow saved at ${$flowStore.path}`);
54
+ goto(`/flows/get/${$flowStore.path}`);
47
55
  }
48
56
  async function changeStep(step) {
49
- (0, navigation_1.goto)(`?step=${step}`);
50
- }
51
- $: {
52
- $page.url.searchParams.set('state', btoa(JSON.stringify(exports.flow)));
53
- history.replaceState({}, '', $page.url);
57
+ goto(`?step=${step}`);
54
58
  }
59
+ flowStore.subscribe((flow) => {
60
+ setQueryWithoutLoad($page.url, 'state', btoa(JSON.stringify(flowToMode(flow, mode))));
61
+ });
62
+ onMount(() => {
63
+ loadSearchData();
64
+ clearPreviewResults();
65
+ });
55
66
  </script>
56
67
 
57
68
  <div class="flex flex-col h-screen max-w-screen-lg xl:-ml-20 xl:pl-4 w-full -mt-4 pt-4 md:mx-10 ">
@@ -60,45 +71,42 @@ $: {
60
71
  <div class="justify-between flex flex-row drop-shadow-sm w-full">
61
72
  <div class="wizard-nav flex flex-row w-full">
62
73
  <button
74
+ disabled={pathError != ''}
63
75
  class="{step === 1
64
76
  ? 'default-button-disabled text-gray-700'
65
77
  : 'default-button-secondary'} min-w-max ml-2"
66
78
  on:click={() => {
67
79
  changeStep(1)
68
- }}>Step 1: Metadata</button
80
+ }}>Step 1: Flow</button
69
81
  >
70
82
  <button
83
+ disabled={pathError != ''}
71
84
  class="{step === 2
72
85
  ? 'default-button-disabled text-gray-700'
73
86
  : 'default-button-secondary'} min-w-max ml-2"
74
87
  on:click={() => {
75
88
  changeStep(2)
76
- }}>Step 2: Flow</button
77
- >
78
- <button
79
- class="{step === 3
80
- ? 'default-button-disabled text-gray-700'
81
- : 'default-button-secondary'} min-w-max ml-2"
82
- on:click={() => {
83
- changeStep(3)
84
- }}>Step 3: UI customisation</button
89
+ }}>Step 2: UI customisation</button
85
90
  >
86
91
  </div>
87
92
  <div class="flex flex-row-reverse ml-2">
88
- {#if step != 3}
93
+ {#if step == 1}
89
94
  <button
90
- disabled={step == 1 &&
91
- (flow.path == undefined || flow.path == '' || flow.path.split('/')[2] == '')}
95
+ disabled={pathError != ''}
92
96
  class="default-button px-6 max-h-8"
93
97
  on:click={() => {
94
98
  changeStep(step + 1)
95
- }}>Next</button
99
+ }}
96
100
  >
97
- {#if step == 2}
98
- <button class="default-button-secondary px-6 max-h-8 mr-2" on:click={saveFlow}
99
- >Save</button
100
- >
101
- {/if}
101
+ Next
102
+ </button>
103
+ <button
104
+ disabled={pathError != ''}
105
+ class="default-button-secondary px-6 max-h-8 mr-2"
106
+ on:click={saveFlow}
107
+ >
108
+ Save
109
+ </button>
102
110
  {:else}
103
111
  <button class="default-button px-6 self-end" on:click={saveFlow}>Save</button>
104
112
  {/if}
@@ -106,79 +114,22 @@ $: {
106
114
  </div>
107
115
  <div class="flex flex-row-reverse">
108
116
  <span class="my-1 text-sm text-gray-500 italic">
109
- {#if initialPath && initialPath != flow.path} {initialPath} &rightarrow; {/if}
110
- {flow.path}
117
+ {#if initialPath && initialPath != $flowStore.path} {initialPath} &rightarrow; {/if}
118
+ {$flowStore.path}
111
119
  </span>
112
120
  </div>
113
121
  </div>
114
122
 
115
123
  <!-- metadata -->
116
- {#if step === 1}
117
- <div class="grid grid-cols-1 gap-6 max-w-7xl">
118
- <Path bind:path={flow.path} {initialPath} namePlaceholder="example/my/flow">
119
- <div slot="ownerToolkit" class="text-gray-700 text-2xs">
120
- Flow permissions depend on their path. Select the group <span class="font-mono">all</span>
121
- to share your flow, and <span class="font-mono">user</span> to keep it private.
122
- <a href="https://docs.windmill.dev/docs/reference/namespaces">docs</a>
123
- </div>
124
- </Path>
125
- <h3 class="text-gray-700 pb-1 border-b">Metadata</h3>
126
124
 
127
- <label class="block ">
128
- <span class="text-gray-700">Summary <Required required={false} /></span>
129
- <textarea
130
- bind:value={flow.summary}
131
- class="
132
- mt-1
133
- block
134
- w-full
135
- rounded-md
136
- border-gray-300
137
- shadow-sm
138
- focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50
139
- "
140
- placeholder="A very short summary of the flow displayed when the flow is listed"
141
- rows="1"
142
- />
143
- </label>
144
- <label class="block ">
145
- <span class="text-gray-700"
146
- >Description<Required required={false} detail="accept markdown formatting" />
147
- <textarea
148
- bind:value={flow.description}
149
- class="
150
- mt-1
151
- block
152
- w-full
153
- rounded-md
154
- border-gray-300
155
- shadow-sm
156
- focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50
157
- "
158
- placeholder="A description to help users understand what this flow does and how to use it."
159
- rows="3"
160
- />
161
- </span></label
162
- >
163
-
164
- <div>
165
- <h3 class="text-gray-700 ">Description rendered</h3>
166
- <div
167
- class="prose mt-5 text-xs shadow-inner shadow-blue p-4 overflow-auto"
168
- style="max-height: 200px;"
169
- >
170
- <SvelteMarkdown source={flow.description ?? ''} />
171
- </div>
172
- </div>
173
- </div>
125
+ {#if step === 1}
126
+ <FlowEditor bind:mode bind:pathError bind:initialPath />
174
127
  {:else if step === 2}
175
- <FlowEditor bind:flow />
176
- {:else if step === 3}
177
128
  <ScriptSchema
178
129
  synchronizedHeader={false}
179
- bind:summary={flow.summary}
180
- bind:description={flow.description}
181
- bind:schema={flow.schema}
130
+ bind:summary={$flowStore.summary}
131
+ bind:description={$flowStore.description}
132
+ bind:schema={$flowStore.schema}
182
133
  />
183
134
  {/if}
184
135
  </div>
@@ -1,8 +1,6 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- import { type Flow } from '../gen';
3
2
  declare const __propDef: {
4
3
  props: {
5
- flow: Flow;
6
4
  initialPath?: string | undefined;
7
5
  };
8
6
  events: {
@@ -1,102 +1,214 @@
1
- <script>"use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.loadSchemas = exports.flow = void 0;
7
- const free_solid_svg_icons_1 = require("@fortawesome/free-solid-svg-icons");
8
- const utils_1 = require("$lib/utils");
9
- const svelte_awesome_1 = __importDefault(require("svelte-awesome"));
10
- const gen_1 = require("$lib/gen");
11
- const SchemaEditor_svelte_1 = __importDefault(require("./SchemaEditor.svelte"));
12
- const stores_1 = require("$lib/stores");
13
- const ModuleStep_svelte_1 = __importDefault(require("./ModuleStep.svelte"));
14
- const FlowPreview_svelte_1 = __importDefault(require("./FlowPreview.svelte"));
15
- const scripts_1 = require("$lib/scripts");
1
+ <script>import { FlowModuleValue } from '../gen';
2
+ import { faFileExport, faFileImport, faGlobe, faPlus } from '@fortawesome/free-solid-svg-icons';
3
+ import Icon from 'svelte-awesome';
4
+ import FlowPreview from './FlowPreview.svelte';
5
+ import CopyFirstStepSchema from './flows/CopyFirstStepSchema.svelte';
6
+ import { addModule, flowStore } from './flows/flowStore';
7
+ import ModuleStep from './ModuleStep.svelte';
8
+ import Path from './Path.svelte';
9
+ import RadioButtonV2 from './RadioButtonV2.svelte';
10
+ import SchemaEditor from './SchemaEditor.svelte';
11
+ import Required from './Required.svelte';
12
+ import { pathIsEmpty, sendUserToast } from '../utils';
13
+ import Dropdown from './Dropdown.svelte';
14
+ import Editor from './Editor.svelte';
15
+ import Modal from './Modal.svelte';
16
+ import FlowViewer from './FlowViewer.svelte';
17
+ import { flowToMode } from './flows/utils';
18
+ export let pathError = '';
19
+ export let initialPath = '';
20
+ let jsonSetter;
21
+ let jsonViewer;
22
+ let jsonValue = '';
23
+ let open = 0;
16
24
  let args = {};
17
- let schemas = [];
18
- let schemaForms = [];
19
- async function loadSchemas() {
20
- await Promise.all(exports.flow.value.modules.map(async (x, i) => {
21
- if (x.value.path) {
22
- const schema = await (0, scripts_1.loadSchema)(x.value.path ?? '');
23
- if (JSON.stringify(Object.keys(schema?.properties ?? {}).sort()) !=
24
- JSON.stringify(Object.keys(x.input_transform).sort())) {
25
- let it = {};
26
- Object.keys(schema?.properties ?? {}).map((x) => (it[x] = {
27
- type: 'static',
28
- value: ''
29
- }));
30
- schemaForms[i]?.setArgs(it);
31
- }
32
- schemas[i] = schema ?? (0, utils_1.emptySchema)();
33
- }
34
- else {
35
- schemaForms[i]?.setArgs({});
36
- schemas[i] = (0, utils_1.emptySchema)();
37
- }
38
- }));
39
- schemas = schemas;
40
- if (exports.flow.value.modules.length == 0) {
41
- addModule();
42
- }
43
- }
44
- exports.loadSchemas = loadSchemas;
45
- function addModule() {
46
- schemaForms.push(undefined);
47
- let newModule = {
48
- value: { type: gen_1.FlowModuleValue.type.SCRIPT, path: '' },
49
- input_transform: {}
50
- };
51
- exports.flow.value.modules = exports.flow.value.modules.concat(newModule);
52
- schemas.push((0, utils_1.emptySchema)());
53
- }
54
- $: $workspaceStore && loadSchemas();
25
+ export let mode = $flowStore?.value.modules[1]?.value.type == FlowModuleValue.type.FORLOOPFLOW ? 'pull' : 'push';
26
+ $: numberOfSteps = $flowStore?.value.modules.length - 1;
55
27
  </script>
56
28
 
57
- <!-- <PageHeader title="Flow" /> -->
29
+ <Modal bind:this={jsonSetter}>
30
+ <div slot="title">Import JSON</div>
31
+ <div slot="content" class="h-full">
32
+ <Editor bind:code={jsonValue} lang={'json'} class="h-full" />
33
+ </div>
34
+ <div slot="submission">
35
+ <button
36
+ class="default-button px-4 py-2 font-semibold"
37
+ on:click={() => {
38
+ Object.assign($flowStore, JSON.parse(jsonValue))
39
+ $flowStore = $flowStore
40
+ open = -1
41
+ sendUserToast('Flow imported from JSON')
42
+ jsonSetter.closeModal()
43
+ }}
44
+ >
45
+ Import
46
+ </button>
47
+ </div></Modal
48
+ >
49
+
50
+ <Modal bind:this={jsonViewer}>
51
+ <div slot="title">See JSON</div>
52
+ <div slot="content" class="h-full">
53
+ <FlowViewer flow={flowToMode($flowStore, mode)} tab="json" />
54
+ </div>
55
+ </Modal>
56
+
58
57
  <div class="flow-root bg-gray-50 rounded-xl border border-gray-200">
59
58
  <ul class="relative -mt-10">
60
59
  <span class="absolute top-0 left-1/2 h-full w-1 bg-gray-400" aria-hidden="true" />
61
60
  <div class="relative">
62
- <li class="flex flex-row flex-shrink max-w-full mx-auto mt-20">
61
+ <li class="flex flex-row flex-shrink max-w-full mx-auto mt-20">
62
+ <div
63
+ class="bg-white border border-gray xl-rounded shadow-lg w-full max-w-4xl mx-4 md:mx-auto p-4"
64
+ >
65
+ <div class="flex flex-row-reverse mr-4">
66
+ <Dropdown
67
+ dropdownItems={[
68
+ {
69
+ displayName: 'Import from JSON',
70
+ icon: faFileImport,
71
+ action: () => {
72
+ jsonSetter.openModal()
73
+ }
74
+ },
75
+ {
76
+ displayName: 'Export to JSON',
77
+ icon: faFileExport,
78
+ action: () => {
79
+ jsonViewer.openModal()
80
+ }
81
+ },
82
+ {
83
+ displayName: 'Publish to Hub',
84
+ icon: faGlobe,
85
+ action: () => {
86
+ const url = new URL('https://hub.windmill.dev/flows/add')
87
+ url.searchParams.append(
88
+ 'flow',
89
+ btoa(JSON.stringify(flowToMode($flowStore, mode).value))
90
+ )
91
+ url.searchParams.append('schema', btoa(JSON.stringify($flowStore.schema)))
92
+ url.searchParams.append('description', $flowStore.description ?? '')
93
+ url.searchParams.append('summary', $flowStore.summary)
94
+ window.open(url, '_blank')?.focus()
95
+ }
96
+ }
97
+ ]}
98
+ relative={false}
99
+ />
100
+ </div>
101
+ <div class="mb-8 p-4">
102
+ <Path
103
+ bind:error={pathError}
104
+ bind:path={$flowStore.path}
105
+ {initialPath}
106
+ namePlaceholder="my_flow"
107
+ kind="flow"
108
+ >
109
+ <div slot="ownerToolkit">
110
+ Flow permissions depend on their path. Select the group <span class="font-mono"
111
+ >all</span
112
+ >
113
+ to share your flow, and <span class="font-mono">user</span> to keep it private.
114
+ <a href="https://docs.windmill.dev/docs/reference/namespaces">docs</a>
115
+ </div>
116
+ </Path>
117
+
118
+ <label class="block mt-4">
119
+ <span class="text-gray-700">Summary <Required required={false} /></span>
120
+ <textarea
121
+ bind:value={$flowStore.summary}
122
+ class="
123
+ mt-1
124
+ block
125
+ w-full
126
+ rounded-md
127
+ border-gray-300
128
+ shadow-sm
129
+ focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50
130
+ "
131
+ placeholder="A very short summary of the flow displayed when the flow is listed"
132
+ rows="1"
133
+ />
134
+ </label>
135
+ </div>
136
+ <RadioButtonV2
137
+ options={[
138
+ [
139
+ {
140
+ title: 'Push',
141
+ desc: 'Trigger this flow through the generated UI, a manual schedule or by calling the associated webhook'
142
+ },
143
+ 'push'
144
+ ],
145
+ [
146
+ {
147
+ title: 'Pull',
148
+ desc: 'The first module of this flow is a trigger script whose purpose is to pull data from an external source and return all new items since last run. This flow is meant to be scheduled very regularly to reduce latency to react to new events. It will trigger the rest of the flow once per item. If no new items, the flow will be skipped.'
149
+ },
150
+ 'pull'
151
+ ]
152
+ ]}
153
+ bind:value={mode}
154
+ />
155
+ </div>
156
+ </li>
157
+ <li class="flex flex-row flex-shrink max-w-full mx-auto mt-20">
63
158
  <div class="bg-white border border-gray xl-rounded shadow-lg w-full mx-4 xl:mx-20">
64
159
  <div
65
160
  class="flex items-center justify-between flex-wra px-4 py-5 border-b border-gray-200 sm:px-6"
66
161
  >
67
162
  <h3 class="text-lg leading-6 font-medium text-gray-900">Flow Input</h3>
68
- <button
69
- class="text-xs default-button-secondary max-h-6 place-self-end"
70
- disabled={flow.value.modules.length == 0 ||
71
- flow.value.modules[0].value.path == undefined}
72
- on:click={async () => {
73
- flow.schema = await loadSchema(flow.value.modules[0].value.path ?? '')
74
- }}
75
- >Copy from step 1's schema
76
- </button>
163
+ <CopyFirstStepSchema />
77
164
  </div>
78
165
  <div class="p-4">
79
- <SchemaEditor bind:schema={flow.schema} />
166
+ <SchemaEditor schema={$flowStore.schema} />
80
167
  <div class="my-4" />
81
- <FlowPreview {flow} i={flow.value.modules.length - 1} bind:args />
168
+ <FlowPreview {mode} flow={$flowStore} i={numberOfSteps} bind:args />
82
169
  </div>
83
170
  </div>
84
171
  </li>
85
- {#each flow.value.modules as mod, i}
86
- <ModuleStep bind:flow bind:mod bind:schemas bind:schemaForms bind:args {i} />
172
+ {#each $flowStore?.value.modules as mod, i}
173
+ <li class="relative mt-16">
174
+ <div class="relative flex justify-center">
175
+ <button
176
+ class="default-button h-10 w-10 shadow-blue-600/40 border-blue-600 shadow"
177
+ on:click={() => {
178
+ addModule(i)
179
+ open = i
180
+ }}
181
+ >
182
+ <Icon class="text-white mb-1" data={faPlus} />
183
+ </button>
184
+ </div>
185
+ </li>
186
+ <ModuleStep bind:open bind:mod bind:args {i} {mode} />
87
187
  {/each}
88
188
  <li class="relative m-20 ">
89
- <div class="absolute inset-0 flex items-center" aria-hidden="true">
90
- <div class="w-full border-t border-gray-300" />
91
- </div>
92
189
  <div class="relative flex justify-center">
93
190
  <button
94
- class="default-button h-10 w-10 shadow-blue-600/40 border-blue-600 shadow"
95
- on:click={addModule}><Icon class="text-white mb-1" data={faPlus} scale={0.9} /></button
191
+ disabled={pathIsEmpty($flowStore.path)}
192
+ class="default-button h-10 w-10 shadow"
193
+ on:click={() => {
194
+ addModule()
195
+ open = $flowStore?.value.modules.length - 1
196
+ }}
96
197
  >
198
+ <Icon class="text-white mb-1" data={faPlus} />
199
+ Add step {pathIsEmpty($flowStore.path) ? '(pick a name first!)' : ''}
200
+ </button>
97
201
  </div>
98
202
  </li>
99
203
  </div>
100
204
  </ul>
101
205
  </div>
102
206
  <div class="py-10 bg-white" />
207
+
208
+ <style>
209
+ .shadow:not([disabled]) {
210
+ --tw-border-opacity: 1;
211
+ border-color: rgb(37 99 235 / var(--tw-border-opacity));
212
+ --tw-shadow-color: rgb(37 99 235 / 0.4);
213
+ --tw-shadow: var(--tw-shadow-colored)
214
+ }</style>
@@ -1,9 +1,10 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- import { type Flow } from '../gen';
2
+ import { type FlowMode } from './flows/flowStore';
3
3
  declare const __propDef: {
4
4
  props: {
5
- flow: Flow;
6
- loadSchemas?: (() => Promise<void>) | undefined;
5
+ pathError?: string | undefined;
6
+ initialPath?: string | undefined;
7
+ mode?: FlowMode | undefined;
7
8
  };
8
9
  events: {
9
10
  [evt: string]: CustomEvent<any>;
@@ -14,6 +15,5 @@ export declare type FlowEditorProps = typeof __propDef.props;
14
15
  export declare type FlowEditorEvents = typeof __propDef.events;
15
16
  export declare type FlowEditorSlots = typeof __propDef.slots;
16
17
  export default class FlowEditor extends SvelteComponentTyped<FlowEditorProps, FlowEditorEvents, FlowEditorSlots> {
17
- get loadSchemas(): () => Promise<void>;
18
18
  }
19
19
  export {};
@@ -0,0 +1,23 @@
1
+ <script>import ChevronButton from './ChevronButton.svelte';
2
+ import DisplayResult from './DisplayResult.svelte';
3
+ export let job;
4
+ </script>
5
+
6
+ {#if job}
7
+ <div class="flex flex-col ml-10">
8
+ <div>
9
+ <ChevronButton text="result" viewOptions={true}>
10
+ <div class="text-xs">
11
+ <DisplayResult result={job.result} />
12
+ </div>
13
+ </ChevronButton>
14
+ </div>
15
+ <div>
16
+ <ChevronButton text="logs" viewOptions={true}>
17
+ <div class="text-xs p-4 bg-gray-50 overflow-auto max-h-lg">
18
+ <pre class="w-full">{job.logs}</pre>
19
+ </div>
20
+ </ChevronButton>
21
+ </div>
22
+ </div>
23
+ {/if}
@@ -0,0 +1,17 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { CompletedJob } from '../gen';
3
+ declare const __propDef: {
4
+ props: {
5
+ job: CompletedJob | undefined;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {};
11
+ };
12
+ export declare type FlowJobResultProps = typeof __propDef.props;
13
+ export declare type FlowJobResultEvents = typeof __propDef.events;
14
+ export declare type FlowJobResultSlots = typeof __propDef.slots;
15
+ export default class FlowJobResult extends SvelteComponentTyped<FlowJobResultProps, FlowJobResultEvents, FlowJobResultSlots> {
16
+ }
17
+ export {};