windmill-components 1.406.5 → 1.407.2

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.
@@ -320,7 +320,7 @@ onDestroy(() => {
320
320
  }
321
321
 
322
322
  dispatch('new', {
323
- kind: 'script',
323
+ kind: selectedKind,
324
324
  inlineScript: {
325
325
  language: lang == 'docker' ? 'bash' : lang,
326
326
  kind: selectedKind,
@@ -324,7 +324,7 @@ function setFlowInput(argName) {
324
324
  class={advancedSelected === 'runtime' ? 'h-[calc(100%-68px)]' : 'h-[calc(100%-34px)]'}
325
325
  >
326
326
  {#if selected === 'inputs' && (flowModule.value.type == 'rawscript' || flowModule.value.type == 'script' || flowModule.value.type == 'flow')}
327
- <div class="h-full overflow-auto" id="flow-editor-step-input">
327
+ <div class="h-full overflow-auto px-2" id="flow-editor-step-input">
328
328
  <PropPickerWrapper
329
329
  pickableProperties={stepPropPicker.pickableProperties}
330
330
  error={failureModule}
@@ -54,20 +54,25 @@ async function insertNewModuleAtIndex(modules, index, kind, wsScript, wsFlow, in
54
54
  [module, state] = await createBranchAll(module.id);
55
55
  }
56
56
  $flowStateStore[module.id] = state;
57
- if (kind == 'trigger') {
58
- module.summary = 'Trigger';
59
- }
60
- else if (kind == 'approval') {
61
- module.summary = 'Approval';
62
- }
63
- else if (kind == 'end') {
64
- module.summary = 'Terminate flow';
65
- module.stop_after_if = { skip_if_stopped: false, expr: 'true' };
66
- }
67
57
  if (inlineScript) {
68
58
  const { language, kind, subkind } = inlineScript;
69
59
  [module, state] = await createInlineScriptModule(language, kind, subkind, module.id, module.summary);
70
60
  $flowStateStore[module.id] = state;
61
+ if (kind == 'trigger') {
62
+ module.summary = 'Trigger';
63
+ }
64
+ else if (kind == 'approval') {
65
+ module.summary = 'Approval';
66
+ }
67
+ }
68
+ if (kind == 'approval') {
69
+ module.suspend = { required_events: 1 };
70
+ }
71
+ else if (kind == 'trigger') {
72
+ module.stop_after_if = {
73
+ expr: '!result || (Array.isArray(result) && result.length == 0)',
74
+ skip_if_stopped: true
75
+ };
71
76
  }
72
77
  if (!modules)
73
78
  return [module];
@@ -180,6 +185,12 @@ async function updateFlowInputsStore() {
180
185
  };
181
186
  }
182
187
  }
188
+ function setExpr(module, expr) {
189
+ if (module.value.type == 'forloopflow') {
190
+ module.value.iterator = { type: 'javascript', expr };
191
+ module.value.parallel = true;
192
+ }
193
+ }
183
194
  </script>
184
195
 
185
196
  <Portal name="flow-module">
@@ -275,7 +286,7 @@ async function updateFlowInputsStore() {
275
286
  } else if (shouldRunTutorial('branchall', detail.detail, 3)) {
276
287
  flowTutorials?.runTutorialById('branchall')
277
288
  } else {
278
- if (detail.modules) {
289
+ if (detail.modules && Array.isArray(detail.modules)) {
279
290
  await tick()
280
291
  if ($moving) {
281
292
  push(history, $flowStore)
@@ -289,19 +300,33 @@ async function updateFlowInputsStore() {
289
300
  insertNewPreprocessorModule(detail.inlineScript, detail.script)
290
301
  $selectedId = 'preprocessor'
291
302
  } else {
303
+ const index = detail.index ?? 0
292
304
  await insertNewModuleAtIndex(
293
305
  detail.modules,
294
- detail.index ?? 0,
306
+ index,
295
307
  detail.kind,
296
308
  detail.script,
297
309
  detail.flow,
298
310
  detail.inlineScript
299
311
  )
300
- $selectedId = detail.modules[detail.index ?? 0].id
312
+ const id = detail.modules[detail.index ?? 0].id
313
+ $selectedId = id
314
+
315
+ if (detail.kind == 'trigger') {
316
+ await insertNewModuleAtIndex(
317
+ detail.modules,
318
+ index + 1,
319
+ 'forloop',
320
+ undefined,
321
+ undefined,
322
+ undefined
323
+ )
324
+ setExpr(detail.modules[index + 1], `results.${id}`)
325
+ }
301
326
  }
302
327
  }
303
328
 
304
- if (['branchone', 'branchall'].includes(detail.detail)) {
329
+ if (['branchone', 'branchall'].includes(detail.kind)) {
305
330
  await addBranch(detail.modules[detail.index ?? 0])
306
331
  }
307
332
  $flowStateStore = $flowStateStore
@@ -58,7 +58,7 @@ function onKeyDown(e) {
58
58
  dispatch('pickFlow', { path: item.path });
59
59
  }
60
60
  else {
61
- dispatch('pickScript', { path: item.path, hash: lockHash ? item.hash : undefined });
61
+ dispatch('pickScript', { path: item.path, hash: lockHash ? item.hash : undefined, kind });
62
62
  }
63
63
  }
64
64
  }
@@ -90,7 +90,7 @@ function onKeyDown(e) {
90
90
  if (kind == 'flow') {
91
91
  dispatch('pickFlow', { path: path })
92
92
  } else {
93
- dispatch('pickScript', { path: path, hash: lockHash ? hash : undefined })
93
+ dispatch('pickScript', { path: path, hash: lockHash ? hash : undefined, kind })
94
94
  }
95
95
  }}
96
96
  >
@@ -40,7 +40,6 @@ const { useDataflow } = getContext('FlowGraphContext');
40
40
  allowTrigger={data.enableTrigger}
41
41
  modules={data?.modules ?? []}
42
42
  on:new={(e) => {
43
- // console.log('new', e)
44
43
  data?.eventHandlers.insert({
45
44
  modules: data.modules,
46
45
  index: data.index,
@@ -53,7 +52,8 @@ const { useDataflow } = getContext('FlowGraphContext');
53
52
  data?.eventHandlers.insert({
54
53
  modules: data.modules,
55
54
  index: data.index,
56
- script: e.detail
55
+ script: e.detail,
56
+ kind: e.detail.kind
57
57
  })
58
58
  }}
59
59
  on:pickFlow={(e) => {
@@ -87,7 +87,8 @@ const { useDataflow } = getContext('FlowGraphContext');
87
87
  data?.eventHandlers.insert({
88
88
  modules: data.modules,
89
89
  index: data.index,
90
- script: e.detail
90
+ script: e.detail,
91
+ kind: e.detail.kind
91
92
  })
92
93
  }}
93
94
  on:pickFlow={(e) => {
@@ -7,6 +7,7 @@ export declare const INITIAL_CODE: {
7
7
  approval: string;
8
8
  failure: string;
9
9
  preprocessor: string;
10
+ clear: string;
10
11
  };
11
12
  python3: {
12
13
  script: string;
@@ -14,6 +15,7 @@ export declare const INITIAL_CODE: {
14
15
  approval: string;
15
16
  failure: string;
16
17
  preprocessor: string;
18
+ clear: string;
17
19
  };
18
20
  deno: {
19
21
  script: string;
@@ -22,6 +24,7 @@ export declare const INITIAL_CODE: {
22
24
  failure: string;
23
25
  preprocessor: string;
24
26
  fetch: string;
27
+ clear: string;
25
28
  };
26
29
  go: {
27
30
  script: string;
@@ -638,14 +638,16 @@ export const INITIAL_CODE = {
638
638
  trigger: BUN_INIT_CODE_TRIGGER,
639
639
  approval: BUN_INIT_CODE_APPROVAL,
640
640
  failure: BUN_FAILURE_MODULE_CODE,
641
- preprocessor: BUN_PREPROCESSOR_MODULE_CODE
641
+ preprocessor: BUN_PREPROCESSOR_MODULE_CODE,
642
+ clear: BUN_INIT_CODE_CLEAR
642
643
  },
643
644
  python3: {
644
645
  script: PYTHON_INIT_CODE,
645
646
  trigger: PYTHON_INIT_CODE_TRIGGER,
646
647
  approval: PYTHON_INIT_CODE_APPROVAL,
647
648
  failure: PYTHON_FAILURE_MODULE_CODE,
648
- preprocessor: PYTHON_PREPROCESSOR_MODULE_CODE
649
+ preprocessor: PYTHON_PREPROCESSOR_MODULE_CODE,
650
+ clear: PYTHON_INIT_CODE_CLEAR
649
651
  },
650
652
  deno: {
651
653
  script: DENO_INIT_CODE,
@@ -653,7 +655,8 @@ export const INITIAL_CODE = {
653
655
  approval: DENO_INIT_CODE_APPROVAL,
654
656
  failure: DENO_FAILURE_MODULE_CODE,
655
657
  preprocessor: DENO_PREPROCESSOR_MODULE_CODE,
656
- fetch: FETCH_INIT_CODE
658
+ fetch: FETCH_INIT_CODE,
659
+ clear: DENO_INIT_CODE_CLEAR
657
660
  },
658
661
  go: {
659
662
  script: GO_INIT_CODE,
@@ -723,7 +726,7 @@ export function initialCode(language, kind, subkind) {
723
726
  }
724
727
  else if (kind === 'script') {
725
728
  if (subkind === 'flow') {
726
- return INITIAL_CODE.deno.script;
729
+ return INITIAL_CODE.deno.clear;
727
730
  }
728
731
  else if (subkind === 'pgsql') {
729
732
  return INITIAL_CODE.postgresql.script;
@@ -762,7 +765,7 @@ export function initialCode(language, kind, subkind) {
762
765
  return INITIAL_CODE.python3.failure;
763
766
  }
764
767
  else if (subkind === 'flow') {
765
- return INITIAL_CODE.python3.script;
768
+ return INITIAL_CODE.python3.clear;
766
769
  }
767
770
  else if (subkind === 'preprocessor') {
768
771
  return INITIAL_CODE.python3.preprocessor;
@@ -829,7 +832,7 @@ export function initialCode(language, kind, subkind) {
829
832
  return INITIAL_CODE.bun.preprocessor;
830
833
  }
831
834
  else if (subkind === 'flow') {
832
- return INITIAL_CODE.bun.script;
835
+ return INITIAL_CODE.bun.clear;
833
836
  }
834
837
  return INITIAL_CODE.bun.script;
835
838
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windmill-components",
3
- "version": "1.406.5",
3
+ "version": "1.407.2",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build",