windmill-components 1.56.5 → 1.57.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/assets/app.css +5 -1
  2. package/components/ArgInput.svelte +6 -6
  3. package/components/DisplayResult.svelte +1 -1
  4. package/components/Dropdown.svelte +1 -1
  5. package/components/Dropdown.svelte.d.ts +1 -0
  6. package/components/Editor.svelte +5 -3
  7. package/components/Editor.svelte.d.ts +2 -0
  8. package/components/EditorBar.svelte +15 -1
  9. package/components/FlowBuilder.svelte +18 -10
  10. package/components/GroupEditor.svelte +1 -0
  11. package/components/IconedResourceType.svelte +2 -2
  12. package/components/InputTransformForm.svelte +7 -5
  13. package/components/ItemPicker.svelte +63 -57
  14. package/components/ItemPicker.svelte.d.ts +1 -2
  15. package/components/LogViewer.svelte +7 -9
  16. package/components/ModulePreview.svelte +4 -13
  17. package/components/MoveDrawer.svelte +40 -16
  18. package/components/MoveDrawer.svelte.d.ts +2 -2
  19. package/components/PageHeader.svelte +1 -1
  20. package/components/Path.svelte +5 -2
  21. package/components/Popover.svelte +6 -4
  22. package/components/Popover.svelte.d.ts +2 -0
  23. package/components/ResourcePicker.svelte +1 -0
  24. package/components/RunChart.svelte +0 -1
  25. package/components/SchemaForm.svelte +2 -1
  26. package/components/SchemaForm.svelte.d.ts +1 -0
  27. package/components/ScriptBuilder.svelte +2 -1
  28. package/components/ScriptEditor.svelte +86 -80
  29. package/components/ShareModal.svelte.d.ts +2 -2
  30. package/components/SimpleEditor.svelte +17 -0
  31. package/components/StringTypeNarrowing.svelte +30 -8
  32. package/components/TemplateEditor.svelte +18 -2
  33. package/components/TestJobLoader.svelte +83 -74
  34. package/components/VariableEditor.svelte +4 -3
  35. package/components/VariableEditor.svelte.d.ts +2 -2
  36. package/components/apps/components/DisplayComponent.svelte +1 -1
  37. package/components/apps/components/buttons/AppButton.svelte +3 -7
  38. package/components/apps/components/dataDisplay/AppBarChart.svelte +10 -6
  39. package/components/apps/components/dataDisplay/AppHtml.svelte +23 -0
  40. package/components/apps/components/dataDisplay/AppHtml.svelte.d.ts +23 -0
  41. package/components/apps/components/dataDisplay/AppPieChart.svelte +10 -6
  42. package/components/apps/components/dataDisplay/AppScatterChart.svelte +46 -0
  43. package/components/apps/components/dataDisplay/AppScatterChart.svelte.d.ts +21 -0
  44. package/components/apps/components/dataDisplay/AppText.svelte +44 -7
  45. package/components/apps/components/dataDisplay/AppText.svelte.d.ts +1 -0
  46. package/components/apps/components/dataDisplay/AppTimeseries.svelte +57 -0
  47. package/components/apps/components/dataDisplay/AppTimeseries.svelte.d.ts +22 -0
  48. package/components/apps/components/form/AppForm.svelte +32 -22
  49. package/components/apps/components/helpers/InputValue.svelte +10 -16
  50. package/components/apps/components/helpers/InputValue.svelte.d.ts +2 -0
  51. package/components/apps/components/helpers/NonRunnableComponent.svelte +4 -6
  52. package/components/apps/components/helpers/NonRunnableComponent.svelte.d.ts +1 -1
  53. package/components/apps/components/helpers/RefreshButton.svelte +1 -1
  54. package/components/apps/components/helpers/RunnableComponent.svelte +111 -119
  55. package/components/apps/components/helpers/RunnableWrapper.svelte +6 -1
  56. package/components/apps/components/selectInputs/AppSelect.svelte +2 -0
  57. package/components/apps/components/table/AppTable.svelte +22 -17
  58. package/components/apps/components/table/AppTableFooter.svelte +2 -1
  59. package/components/apps/components/table/tableOptions.d.ts +2 -9
  60. package/components/apps/components/table/tableOptions.js +5 -2
  61. package/components/apps/components/textInputs/AppTextInput.svelte +0 -1
  62. package/components/apps/editor/AppEditor.svelte +131 -102
  63. package/components/apps/editor/AppEditor.svelte.d.ts +1 -0
  64. package/components/apps/editor/AppEditorHeader.svelte +346 -51
  65. package/components/apps/editor/AppEditorHeader.svelte.d.ts +2 -4
  66. package/components/apps/editor/AppExportButton.svelte +34 -0
  67. package/components/apps/editor/AppExportButton.svelte.d.ts +17 -0
  68. package/components/apps/editor/AppPreview.svelte +17 -6
  69. package/components/apps/editor/AppPreview.svelte.d.ts +4 -0
  70. package/components/apps/editor/AppPublishButton.svelte +53 -0
  71. package/components/apps/editor/AppPublishButton.svelte.d.ts +18 -0
  72. package/components/apps/editor/ComponentEditor.svelte +35 -3
  73. package/components/apps/editor/ComponentHeader.svelte +20 -13
  74. package/components/apps/editor/ComponentHeader.svelte.d.ts +1 -0
  75. package/components/apps/editor/GridEditor.svelte +69 -47
  76. package/components/apps/editor/RecomputeAllComponents.svelte +80 -13
  77. package/components/apps/editor/componentsPanel/ComponentList.svelte +29 -27
  78. package/components/apps/editor/componentsPanel/componentStaticValues.d.ts +2 -1
  79. package/components/apps/editor/componentsPanel/componentStaticValues.js +3 -2
  80. package/components/apps/editor/componentsPanel/data.js +191 -77
  81. package/components/apps/editor/contextPanel/ContextPanel.svelte +60 -41
  82. package/components/apps/editor/inlineScriptsPanel/EmptyInlineScript.svelte +6 -2
  83. package/components/apps/editor/inlineScriptsPanel/EmptyInlineScript.svelte.d.ts +1 -0
  84. package/components/apps/editor/inlineScriptsPanel/InlineScriptEditor.svelte +47 -10
  85. package/components/apps/editor/inlineScriptsPanel/InlineScriptEditor.svelte.d.ts +1 -0
  86. package/components/apps/editor/inlineScriptsPanel/InlineScriptEditorPanel.svelte +11 -4
  87. package/components/apps/editor/inlineScriptsPanel/InlineScriptEditorPanel.svelte.d.ts +1 -0
  88. package/components/apps/editor/inlineScriptsPanel/InlineScriptsPanel.svelte +29 -21
  89. package/components/apps/editor/inlineScriptsPanel/InlineScriptsPanelList.svelte +10 -6
  90. package/components/apps/editor/settingsPanel/AlignmentEditor.svelte +38 -33
  91. package/components/apps/editor/settingsPanel/ArrayStaticInputEditor.svelte +3 -2
  92. package/components/apps/editor/settingsPanel/ArrayStaticInputEditor.svelte.d.ts +1 -10
  93. package/components/apps/editor/settingsPanel/ComponentInputTypeEditor.svelte +27 -9
  94. package/components/apps/editor/settingsPanel/ComponentPanel.svelte +8 -6
  95. package/components/apps/editor/settingsPanel/InputsSpecEditor.svelte +6 -16
  96. package/components/apps/editor/settingsPanel/InputsSpecEditor.svelte.d.ts +0 -1
  97. package/components/apps/editor/settingsPanel/InputsSpecsEditor.svelte +46 -21
  98. package/components/apps/editor/settingsPanel/InputsSpecsEditor.svelte.d.ts +3 -1
  99. package/components/apps/editor/settingsPanel/Recompute.svelte +1 -1
  100. package/components/apps/editor/settingsPanel/SelectedRunnable.svelte +2 -2
  101. package/components/apps/editor/settingsPanel/TableActions.svelte +10 -10
  102. package/components/apps/editor/settingsPanel/common/PanelSection.svelte +1 -0
  103. package/components/apps/editor/settingsPanel/common/PanelSection.svelte.d.ts +1 -0
  104. package/components/apps/editor/settingsPanel/inputEditor/ConnectedInputEditor.svelte +6 -4
  105. package/components/apps/editor/settingsPanel/inputEditor/JsonEditor.svelte +24 -0
  106. package/components/apps/editor/settingsPanel/inputEditor/JsonEditor.svelte.d.ts +17 -0
  107. package/components/apps/editor/settingsPanel/inputEditor/StaticInputEditor.svelte +9 -14
  108. package/components/apps/editor/settingsPanel/mainInput/RunnableSelector.svelte +35 -7
  109. package/components/apps/editorUtils.d.ts +1 -0
  110. package/components/apps/editorUtils.js +11 -0
  111. package/components/apps/gridUtils.js +1 -1
  112. package/components/apps/inputType.d.ts +4 -4
  113. package/components/apps/rx.d.ts +1 -1
  114. package/components/apps/rx.js +6 -2
  115. package/components/apps/store.d.ts +2 -0
  116. package/components/apps/store.js +2 -0
  117. package/components/apps/types.d.ts +18 -3
  118. package/components/apps/utils.d.ts +2 -2
  119. package/components/apps/utils.js +22 -8
  120. package/components/common/button/Button.svelte +6 -8
  121. package/components/common/button/Button.svelte.d.ts +1 -0
  122. package/components/common/confirmationModal/UnsavedConfirmationModal.svelte +4 -1
  123. package/components/common/popup/Popup.svelte +1 -1
  124. package/components/common/table/AppRow.svelte +26 -3
  125. package/components/common/table/AppRow.svelte.d.ts +4 -0
  126. package/components/common/table/FlowRow.svelte +4 -4
  127. package/components/common/table/ScriptRow.svelte +2 -2
  128. package/components/common/tabs/Tabs.svelte +1 -1
  129. package/components/common/toggleButton/ToggleButton.svelte +2 -0
  130. package/components/common/toggleButton/ToggleButton.svelte.d.ts +1 -0
  131. package/components/flows/CreateActionsApp.svelte +43 -0
  132. package/components/flows/CreateActionsApp.svelte.d.ts +14 -0
  133. package/components/flows/CreateActionsFlow.svelte +6 -1
  134. package/components/flows/content/DynamicInputHelpBox.svelte +1 -1
  135. package/components/flows/content/FlowConstants.svelte +23 -9
  136. package/components/flows/content/FlowInputs.svelte +2 -2
  137. package/components/flows/content/FlowModuleHeader.svelte +6 -5
  138. package/components/flows/content/FlowSettings.svelte +1 -1
  139. package/components/flows/header/FlowImportExportMenu.svelte +1 -1
  140. package/components/flows/map/FlowConstantsItem.svelte +5 -7
  141. package/components/flows/map/FlowModuleSchemaMap.svelte +1 -5
  142. package/components/flows/map/FlowSettingsItem.svelte +5 -7
  143. package/components/flows/propPicker/PropPickerWrapper.svelte +42 -31
  144. package/components/home/ItemsList.svelte +6 -4
  145. package/components/icons/ClickhouseIcon.svelte +22 -0
  146. package/components/icons/ClickhouseIcon.svelte.d.ts +17 -0
  147. package/components/icons/FaunadbIcon.svelte +19 -0
  148. package/components/icons/FaunadbIcon.svelte.d.ts +17 -0
  149. package/components/icons/OpenaiIcon.svelte +18 -0
  150. package/components/icons/OpenaiIcon.svelte.d.ts +17 -0
  151. package/components/icons/index.d.ts +7 -1
  152. package/components/icons/index.js +8 -2
  153. package/components/propertyPicker/ObjectViewer.svelte +11 -4
  154. package/components/propertyPicker/PropPicker.svelte +1 -1
  155. package/components/scriptEditor/LogPanel.svelte +26 -22
  156. package/components/sidebar/WorkspaceMenu.svelte +2 -3
  157. package/components/splitPanes/SplitPanesWrapper.svelte +1 -5
  158. package/components/splitPanes/SplitPanesWrapper.svelte.d.ts +0 -1
  159. package/editorUtils.js +2 -0
  160. package/gen/core/OpenAPI.js +1 -1
  161. package/gen/models/Policy.d.ts +1 -0
  162. package/gen/services/AppService.d.ts +18 -0
  163. package/gen/services/AppService.js +30 -0
  164. package/gen/services/GranularAclService.d.ts +3 -3
  165. package/gen/services/ResourceService.d.ts +15 -0
  166. package/gen/services/ResourceService.js +17 -0
  167. package/infer.js +4 -0
  168. package/package.json +502 -492
  169. package/stores.d.ts +1 -0
  170. package/stores.js +13 -5
  171. package/utils.d.ts +1 -1
  172. package/utils.js +17 -10
  173. package/components/apps/CreateApp.svelte +0 -68
  174. package/components/apps/CreateApp.svelte.d.ts +0 -14
@@ -46,28 +46,38 @@ $: loading = isLoading && ownClick;
46
46
  forceSchemaDisplay={true}
47
47
  >
48
48
  <AlignWrapper {horizontalAlignment}>
49
- <Button
50
- on:pointerdown={(e) => {
51
- e?.stopPropagation()
52
- window.dispatchEvent(new Event('pointerup'))
53
- }}
54
- on:click={() => {
55
- runnableComponent?.runComponent()
49
+ <div class="flex flex-col gap-2 px-4 w-full">
50
+ <div>
51
+ {#if componentInput?.type != 'runnable' || Object.values(componentInput?.fields ?? {}).filter((x) => x.type == 'user').length == 0}
52
+ <span class="text-gray-600 italic text-sm py-2"
53
+ >Run forms are meant to be associated with a runnable with some user inputs. Pick a
54
+ runnable and set some 'Runnable Inputs' to 'User Input'</span
55
+ >
56
+ {/if}
57
+ </div>
58
+ <div class="flex justify-end">
59
+ <Button
60
+ {loading}
61
+ btnClasses="mt-1"
62
+ on:pointerdown={(e) => {
63
+ e?.stopPropagation()
64
+ window.dispatchEvent(new Event('pointerup'))
65
+ }}
66
+ on:click={() => {
67
+ runnableComponent?.runComponent()
56
68
 
57
- if (recomputeIds) {
58
- recomputeIds.forEach((id) => {
59
- $runnableComponents[id]?.()
60
- })
61
- }
62
- }}
63
- {size}
64
- {color}
65
- endIcon={{
66
- icon: loading ? faRefresh : faArrowRight,
67
- classes: loading ? 'animate-spin w-4' : 'w-4'
68
- }}
69
- >
70
- {labelValue}
71
- </Button>
69
+ if (recomputeIds) {
70
+ recomputeIds.forEach((id) => {
71
+ $runnableComponents[id]?.()
72
+ })
73
+ }
74
+ }}
75
+ {size}
76
+ {color}
77
+ >
78
+ {labelValue}
79
+ </Button>
80
+ </div>
81
+ </div>
72
82
  </AlignWrapper>
73
83
  </RunnableWrapper>
@@ -1,32 +1,26 @@
1
1
  <script>import { isCodeInjection } from '../../../flows/utils';
2
- import { getContext } from 'svelte';
2
+ import { createEventDispatcher, getContext, onMount } from 'svelte';
3
3
  import { accessPropertyByPath } from '../../utils';
4
4
  export let input;
5
5
  export let value;
6
6
  export let id = undefined;
7
7
  export let row = {};
8
8
  const { worldStore } = getContext('AppEditorContext');
9
- $: input && setDefault();
10
9
  $: state = $worldStore?.state;
11
10
  $: input && $worldStore && row && handleConnection();
12
- $: input && $state && input.type == 'template' && setValue();
13
- function setDefault() {
14
- if (!value && input.defaultValue) {
15
- value = input.defaultValue;
16
- }
17
- }
11
+ $: input && $state && input.type == 'template' && (value = getValue(input));
18
12
  function handleConnection() {
19
13
  if (input.type === 'connected') {
20
14
  $worldStore?.connect(input, onValueChange);
21
15
  }
22
16
  else if (input.type === 'row') {
23
- value = row[input.column];
17
+ setTimeout(() => (value = row[input['column']]), 0);
24
18
  }
25
19
  else if (input.type === 'static' || input.type == 'template') {
26
- setValue();
20
+ setTimeout(() => (value = getValue(input)), 0);
27
21
  }
28
22
  else {
29
- value = undefined;
23
+ setTimeout(() => (value = undefined), 0);
30
24
  }
31
25
  }
32
26
  function computeGlobalContext() {
@@ -39,20 +33,20 @@ function computeGlobalContext() {
39
33
  ];
40
34
  }));
41
35
  }
42
- function setValue() {
36
+ export function getValue(input) {
43
37
  if (input.type === 'template' && isCodeInjection(input.eval)) {
44
38
  try {
45
- value = eval_like('`' + input.eval + '`', computeGlobalContext());
39
+ return eval_like('`' + input.eval + '`', computeGlobalContext());
46
40
  }
47
41
  catch (e) {
48
- value = e.message;
42
+ return e.message;
49
43
  }
50
44
  }
51
45
  else if (input.type === 'static') {
52
- value = input.value;
46
+ return input.value;
53
47
  }
54
48
  else if (input.type === 'template') {
55
- value = input.eval;
49
+ return input.eval;
56
50
  }
57
51
  }
58
52
  function create_context_function_template(eval_string, context) {
@@ -6,6 +6,7 @@ declare const __propDef: {
6
6
  value: string | number | boolean | Record<string | number, any> | undefined;
7
7
  id?: string | undefined;
8
8
  row?: Record<string, any> | undefined;
9
+ getValue?: ((input: AppInput) => any) | undefined;
9
10
  };
10
11
  events: {
11
12
  [evt: string]: CustomEvent<any>;
@@ -16,5 +17,6 @@ export type InputValueProps = typeof __propDef.props;
16
17
  export type InputValueEvents = typeof __propDef.events;
17
18
  export type InputValueSlots = typeof __propDef.slots;
18
19
  export default class InputValue extends SvelteComponentTyped<InputValueProps, InputValueEvents, InputValueSlots> {
20
+ get getValue(): (input: AppInput) => any;
19
21
  }
20
22
  export {};
@@ -1,20 +1,18 @@
1
1
  <script>import { getContext } from 'svelte';
2
2
  import InputValue from './InputValue.svelte';
3
- export let result = undefined;
4
3
  export let componentInput;
5
4
  export let id;
5
+ export let result;
6
6
  // Sync the result to the output
7
7
  const { worldStore } = getContext('AppEditorContext');
8
8
  $: outputs = $worldStore?.outputsById[id];
9
9
  $: if (outputs?.loading != undefined) {
10
10
  outputs.loading.set(false, true);
11
11
  }
12
- function setOutput() {
13
- if (outputs) {
14
- outputs.result?.set(result);
15
- }
12
+ function setOutput(v) {
13
+ outputs.result?.set(v, true);
16
14
  }
17
- $: result !== undefined && setOutput();
15
+ $: result && outputs && setOutput(result);
18
16
  </script>
19
17
 
20
18
  {#if componentInput.type !== 'runnable'}
@@ -2,9 +2,9 @@ import { SvelteComponentTyped } from "svelte";
2
2
  import type { AppInput } from '../../inputType';
3
3
  declare const __propDef: {
4
4
  props: {
5
- result?: any;
6
5
  componentInput: AppInput;
7
6
  id: string;
7
+ result: any;
8
8
  };
9
9
  events: {
10
10
  [evt: string]: CustomEvent<any>;
@@ -19,7 +19,7 @@ $: $worldStore?.outputsById[componentId]?.['loading']?.subscribe({
19
19
  <button
20
20
  on:pointerdown|preventDefault|stopPropagation
21
21
  on:click|preventDefault|stopPropagation={refresh}
22
- class="center-center p-1 rounded border bg-white/60 z-40"
22
+ class="center-center p-1 rounded border bg-white/60 hover:bg-gray-200 z-10"
23
23
  >
24
24
  <RefreshCw class={loading ? 'animate-spin' : ''} size={16} />
25
25
  </button>
@@ -1,14 +1,11 @@
1
- <script>import { page } from '$app/stores';
2
- import Alert from '../../../common/alert/Alert.svelte';
1
+ <script>import Alert from '../../../common/alert/Alert.svelte';
3
2
  import SchemaForm from '../../../SchemaForm.svelte';
4
3
  import TestJobLoader from '../../../TestJobLoader.svelte';
5
4
  import { AppService } from '../../../../gen';
6
- import { workspaceStore } from '../../../../stores';
7
- import { emptySchema } from '../../../../utils';
5
+ import { defaultIfEmptyString, emptySchema } from '../../../../utils';
8
6
  import { getContext, onMount } from 'svelte';
9
- import { fieldTypeToTsType, loadSchema, schemaToInputsSpec } from '../../utils';
7
+ import { fieldTypeToTsType, schemaToInputsSpec } from '../../utils';
10
8
  import InputValue from './InputValue.svelte';
11
- import MissingConnectionWarning from './MissingConnectionWarning.svelte';
12
9
  import RefreshButton from './RefreshButton.svelte';
13
10
  // Component props
14
11
  export let id;
@@ -18,48 +15,46 @@ export let extraQueryParams = {};
18
15
  export let autoRefresh = true;
19
16
  export let result = undefined;
20
17
  export let forceSchemaDisplay = false;
21
- const { worldStore, runnableComponents } = getContext('AppEditorContext');
18
+ const { worldStore, runnableComponents, workspace, appPath, isEditor, jobs } = getContext('AppEditorContext');
22
19
  onMount(() => {
23
20
  if (autoRefresh) {
24
21
  $runnableComponents[id] = async () => {
25
22
  await executeComponent();
26
23
  };
27
24
  }
25
+ executeComponent();
28
26
  });
29
- let pagePath = $page.params.path;
30
27
  let args = {};
31
- let schema = undefined;
32
28
  let testIsLoading = false;
33
29
  let runnableInputValues = {};
34
- function setStaticInputsToArgs() {
35
- let nargs = {};
36
- Object.entries(fields ?? {}).forEach(([key, value]) => {
37
- if (value.type === 'static') {
38
- nargs[key] = value.value;
39
- }
30
+ let executeTimeout = undefined;
31
+ function setDebouncedExecute() {
32
+ executeTimeout && clearTimeout(executeTimeout);
33
+ executeTimeout = setTimeout(() => {
34
+ executeComponent();
35
+ }, 200);
36
+ }
37
+ function computeStaticValues() {
38
+ return Object.entries(fields ?? {})
39
+ .filter(([k, v]) => v.type == 'static')
40
+ .map(([name, field]) => {
41
+ return [name, field['value']];
40
42
  });
41
- if (JSON.stringify(args) != JSON.stringify(nargs)) {
42
- args = nargs;
43
- }
44
43
  }
45
- $: fields && setStaticInputsToArgs();
46
- function argMergedArgsValid(mergedArgs, testJobLoader) {
47
- if (!fields) {
48
- return false;
49
- }
50
- if (Object.keys(fields).length !==
51
- Object.keys(mergedArgs).length - Object.keys(extraQueryParams).length) {
52
- return false;
53
- }
54
- const areAllArgsValid = Object.values(mergedArgs).every((arg) => arg !== undefined && arg !== null);
55
- if (areAllArgsValid && autoRefresh && testJobLoader) {
56
- executeComponent();
57
- }
58
- return areAllArgsValid;
44
+ let lazyStaticValues = computeStaticValues();
45
+ let currentStaticValues = lazyStaticValues;
46
+ $: fields && (currentStaticValues = computeStaticValues());
47
+ $: if (JSON.stringify(currentStaticValues) != JSON.stringify(lazyStaticValues)) {
48
+ lazyStaticValues = currentStaticValues;
49
+ setDebouncedExecute();
59
50
  }
60
- $: isValid =
61
- Object.keys(fields ?? {}).length == 0 ||
62
- argMergedArgsValid({ ...extraQueryParams, ...runnableInputValues, ...args }, testJobLoader);
51
+ $: fields && (lazyStaticValues = computeStaticValues());
52
+ $: runnableInputValues &&
53
+ extraQueryParams &&
54
+ args &&
55
+ autoRefresh &&
56
+ testJobLoader &&
57
+ setDebouncedExecute();
63
58
  // Test job internal state
64
59
  let testJob = undefined;
65
60
  let testJobLoader = undefined;
@@ -67,21 +62,16 @@ $: outputs = $worldStore?.outputsById[id];
67
62
  $: if (outputs?.loading != undefined) {
68
63
  outputs.loading.set(false, true);
69
64
  }
70
- async function loadSchemaFromTriggerable(workspace, path, runType) {
71
- return loadSchema(workspace, path, runType) ?? emptySchema();
72
- }
65
+ $: outputs?.loading?.set(testIsLoading);
73
66
  $: runnable?.type === 'runnableByName' && loadSchemaAndInputsByName();
74
- $: !schema && runnable?.type === 'runnableByPath' && loadSchemaAndInputsByPath();
75
67
  async function loadSchemaAndInputsByName() {
76
68
  if (runnable?.type === 'runnableByName') {
77
69
  const { inlineScript } = runnable;
78
70
  // Inline scripts directly provide the schema
79
71
  if (inlineScript) {
80
72
  const newSchema = inlineScript.schema;
81
- schema = newSchema;
82
73
  const newFields = reloadInputs(newSchema);
83
74
  if (JSON.stringify(newFields) !== JSON.stringify(fields)) {
84
- fields = newFields;
85
75
  setTimeout(() => {
86
76
  fields = newFields;
87
77
  }, 0);
@@ -89,30 +79,12 @@ async function loadSchemaAndInputsByName() {
89
79
  }
90
80
  }
91
81
  }
92
- async function loadSchemaAndInputsByPath() {
93
- if ($workspaceStore && runnable?.type === 'runnableByPath') {
94
- // Remote schema needs to be loaded
95
- const { path, runType } = runnable;
96
- const newSchema = await loadSchemaFromTriggerable($workspaceStore, path, runType);
97
- schema = newSchema;
98
- let schemaWithoutExtraQueries = JSON.parse(JSON.stringify(schema));
99
- // Remove extra query params from the schema, which are not directly configurable by the user
100
- Object.keys(extraQueryParams).forEach((key) => {
101
- delete schemaWithoutExtraQueries.properties[key];
102
- });
103
- fields = schemaToInputsSpec(schemaWithoutExtraQueries);
104
- }
105
- }
106
82
  // When the schema is loaded, we need to update the inputs spec
107
83
  // in order to render the inputs the component panel
108
84
  function reloadInputs(schema) {
109
- let schemaWithoutExtraQueries = JSON.parse(JSON.stringify(schema));
110
- // Remove extra query params from the schema, which are not directly configurable by the user
111
- Object.keys(extraQueryParams).forEach((key) => {
112
- delete schemaWithoutExtraQueries.properties[key];
113
- });
85
+ let schemaCopy = JSON.parse(JSON.stringify(schema));
114
86
  const result = {};
115
- const newInputs = schemaToInputsSpec(schemaWithoutExtraQueries);
87
+ const newInputs = schemaToInputsSpec(schemaCopy);
116
88
  if (!fields) {
117
89
  return newInputs;
118
90
  }
@@ -134,9 +106,16 @@ function reloadInputs(schema) {
134
106
  });
135
107
  return result;
136
108
  }
137
- let schemaStripped = undefined;
138
- function stripSchema(schema, inputs) {
139
- schemaStripped = JSON.parse(JSON.stringify(schema));
109
+ $: schemaStripped = runnable && stripSchema(fields);
110
+ function stripSchema(inputs) {
111
+ let schema = runnable?.type == 'runnableByName' ? runnable.inlineScript?.schema : runnable?.schema;
112
+ try {
113
+ schemaStripped = JSON.parse(JSON.stringify(schema));
114
+ }
115
+ catch (e) {
116
+ console.warn('Error loading schema');
117
+ return emptySchema();
118
+ }
140
119
  // Remove hidden static inputs
141
120
  Object.keys(inputs ?? {}).forEach((key) => {
142
121
  const input = inputs[key];
@@ -147,14 +126,8 @@ function stripSchema(schema, inputs) {
147
126
  delete schemaStripped.properties[key];
148
127
  }
149
128
  });
150
- // Remove extra query params from schema
151
- Object.keys(extraQueryParams).forEach((key) => {
152
- if (schemaStripped !== undefined) {
153
- delete schemaStripped.properties[key];
154
- }
155
- });
129
+ return schemaStripped;
156
130
  }
157
- $: schema && fields && stripSchema(schema, fields);
158
131
  $: disabledArgs = Object.keys(fields ?? {}).reduce((disabledArgsAccumulator, inputName) => {
159
132
  if (fields[inputName].type === 'static') {
160
133
  disabledArgsAccumulator = [...disabledArgsAccumulator, inputName];
@@ -162,17 +135,28 @@ $: disabledArgs = Object.keys(fields ?? {}).reduce((disabledArgsAccumulator, inp
162
135
  return disabledArgsAccumulator;
163
136
  }, []);
164
137
  async function executeComponent() {
165
- if (!schema) {
166
- return;
167
- }
168
- if (outputs?.loading.peak() === true) {
138
+ if (runnable?.type === 'runnableByName' && !runnable.inlineScript) {
169
139
  return;
170
140
  }
171
141
  outputs?.loading?.set(true);
172
- await testJobLoader?.abstractRun(() => {
142
+ let njob = await testJobLoader?.abstractRun(() => {
143
+ const nonStaticRunnableInputs = {};
144
+ const staticRunnableInputs = {};
145
+ Object.keys(fields ?? {}).forEach((k) => {
146
+ let field = fields[k];
147
+ if (field?.type == 'static' && fields[k]) {
148
+ staticRunnableInputs[k] = field.value;
149
+ }
150
+ else if (field?.type == 'user') {
151
+ nonStaticRunnableInputs[k] = args[k];
152
+ }
153
+ else {
154
+ nonStaticRunnableInputs[k] = runnableInputValues[k];
155
+ }
156
+ });
173
157
  const requestBody = {
174
- args: { ...extraQueryParams, ...args, ...runnableInputValues },
175
- force_viewer_static_fields: {}
158
+ args: nonStaticRunnableInputs,
159
+ force_viewer_static_fields: !isEditor ? undefined : staticRunnableInputs
176
160
  };
177
161
  if (runnable?.type === 'runnableByName') {
178
162
  const { inlineScript } = runnable;
@@ -189,32 +173,42 @@ async function executeComponent() {
189
173
  requestBody['path'] = runType !== 'hubscript' ? `${runType}/${path}` : `script/${path}`;
190
174
  }
191
175
  return AppService.executeComponent({
192
- workspace: $workspaceStore,
193
- path: pagePath,
176
+ workspace,
177
+ path: defaultIfEmptyString(appPath, 'newapp'),
194
178
  requestBody
195
179
  });
196
180
  });
181
+ if (njob) {
182
+ $jobs = [...$jobs, { job: njob, component: id }];
183
+ }
197
184
  }
198
185
  export async function runComponent() {
199
186
  await executeComponent();
200
187
  }
188
+ let lastStartedAt = Date.now();
201
189
  </script>
202
190
 
203
- {#each Object.keys(fields ?? {}) as key}
204
- <InputValue
205
- {id}
206
- input={fields[key]}
207
- bind:value={runnableInputValues[key]}
208
- row={extraQueryParams['row'] ?? {}}
209
- />
191
+ {#each Object.entries(fields ?? {}) as [key, v]}
192
+ {#if v.type != 'static' && v.type != 'user'}
193
+ <InputValue
194
+ {id}
195
+ input={fields[key]}
196
+ bind:value={runnableInputValues[key]}
197
+ row={extraQueryParams['row'] ?? {}}
198
+ />
199
+ {/if}
210
200
  {/each}
211
201
 
212
202
  <TestJobLoader
213
- on:done={() => {
203
+ workspaceOverride={workspace}
204
+ on:done={(e) => {
214
205
  if (testJob && outputs) {
215
- outputs.result?.set(testJob?.result)
216
- outputs.loading?.set(false)
217
- result = testJob.result
206
+ const startedAt = new Date(testJob.started_at).getTime()
207
+ if (startedAt > lastStartedAt) {
208
+ lastStartedAt = startedAt
209
+ outputs.result?.set(testJob?.result)
210
+ result = testJob.result
211
+ }
218
212
  }
219
213
  }}
220
214
  bind:isLoading={testIsLoading}
@@ -222,41 +216,39 @@ export async function runComponent() {
222
216
  bind:this={testJobLoader}
223
217
  />
224
218
 
225
- <div class="h-full flex flex-col">
226
- {#if schemaStripped !== undefined && (autoRefresh || forceSchemaDisplay)}
227
- <SchemaForm
228
- schema={schemaStripped}
229
- bind:args
230
- {isValid}
231
- {disabledArgs}
232
- shouldHideNoInputs
233
- noVariablePicker
234
- />
219
+ <div class="h-full flex relative flex-row flex-wrap">
220
+ {#if autoRefresh === true}
221
+ <div class="flex absolute top-1 right-1">
222
+ <RefreshButton componentId={id} />
223
+ </div>
224
+ {/if}
225
+ {#if schemaStripped && Object.keys(schemaStripped?.properties ?? {}).length > 0 && (autoRefresh || forceSchemaDisplay)}
226
+ <div class="px-2 h-fit min-h-0">
227
+ <SchemaForm
228
+ compact
229
+ flexWrap
230
+ schema={schemaStripped}
231
+ bind:args
232
+ {disabledArgs}
233
+ shouldHideNoInputs
234
+ noVariablePicker
235
+ />
236
+ </div>
235
237
  {/if}
236
238
 
237
239
  {#if !runnable && autoRefresh}
238
240
  <Alert type="warning" size="xs" class="mt-2 px-1" title="Missing runnable">
239
241
  Please select a runnable
240
242
  </Alert>
241
- {:else if autoRefresh === true}
242
- <div class="flex absolute top-1 right-1">
243
- <RefreshButton componentId={id} />
244
- </div>
245
-
246
- {#if isValid}
247
- <slot />
248
- {:else}
249
- <Alert type="info" size="xs" class="mt-2 px-1" title="Missing inputs">
250
- Please fill in all the inputs
251
-
252
- {#each Object.keys(fields ?? {}) as key}
253
- {#if fields[key].type === 'connected'}
254
- <MissingConnectionWarning input={fields[key]} />
255
- {/if}
256
- {/each}
243
+ {:else if result?.error}
244
+ <div class="p-2">
245
+ <Alert type="error" title="Error during execution">
246
+ <pre title={result.error} class="text-2xs whitespace-pre-wrap">{result.error}</pre>
257
247
  </Alert>
258
- {/if}
248
+ </div>
259
249
  {:else}
260
- <slot />
250
+ <div class="grow min-w-1/2 min-h-[66%]">
251
+ <slot />
252
+ </div>
261
253
  {/if}
262
254
  </div>
@@ -1,4 +1,5 @@
1
- <script>import { isScriptByNameDefined, isScriptByPathDefined } from '../../utils';
1
+ <script>import { getContext, onMount } from 'svelte';
2
+ import { isScriptByNameDefined, isScriptByPathDefined } from '../../utils';
2
3
  import NonRunnableComponent from './NonRunnableComponent.svelte';
3
4
  import RunnableComponent from './RunnableComponent.svelte';
4
5
  export let componentInput;
@@ -8,6 +9,10 @@ export let extraQueryParams = {};
8
9
  export let autoRefresh = true;
9
10
  export let runnableComponent = undefined;
10
11
  export let forceSchemaDisplay = false;
12
+ const { staticExporter } = getContext('AppEditorContext');
13
+ onMount(() => {
14
+ $staticExporter[id] = () => result;
15
+ });
11
16
  function isRunnableDefined() {
12
17
  return isScriptByNameDefined(componentInput) || isScriptByPathDefined(componentInput);
13
18
  }
@@ -24,6 +24,8 @@ const dispatch = createEventDispatcher();
24
24
 
25
25
  <AlignWrapper {horizontalAlignment} {verticalAlignment}>
26
26
  <Select
27
+ --height="34px"
28
+ class="select"
27
29
  on:clear={onChange}
28
30
  on:change={onChange}
29
31
  {items}
@@ -7,23 +7,25 @@ import AppButton from '../buttons/AppButton.svelte';
7
7
  import { classNames, isObject } from '../../../../utils';
8
8
  import DebouncedInput from '../helpers/DebouncedInput.svelte';
9
9
  import AppTableFooter from './AppTableFooter.svelte';
10
- import RefreshButton from '../helpers/RefreshButton.svelte';
11
10
  import { tableOptions } from './tableOptions';
12
11
  import Alert from '../../../common/alert/Alert.svelte';
13
12
  export let id;
14
13
  export let componentInput;
15
14
  export let configuration;
16
15
  export let actionButtons;
17
- export const staticOutputs = ['selectedRow', 'loading', 'result'];
16
+ export const staticOutputs = ['selectedRow', 'loading', 'result', 'search'];
18
17
  $: result = [];
19
18
  let search = undefined;
20
19
  let searchValue = '';
21
- let pagination = undefined;
22
- let page = 1;
20
+ let pagination = true;
21
+ $: setSearch(searchValue);
22
+ function setSearch(srch) {
23
+ outputs?.search?.set(srch);
24
+ }
23
25
  const options = writable({
26
+ ...tableOptions,
24
27
  data: [],
25
- columns: [],
26
- ...tableOptions
28
+ columns: []
27
29
  });
28
30
  let table = createSvelteTable(options);
29
31
  const { worldStore, staticOutputs: staticOutputsStore } = getContext('AppEditorContext');
@@ -44,21 +46,21 @@ function setOptions(filteredResult) {
44
46
  }
45
47
  const headers = Array.from(new Set(result.flatMap((row) => Object.keys(row))));
46
48
  $options = {
49
+ ...tableOptions,
47
50
  data: filteredResult,
48
51
  columns: headers.map((header) => {
49
52
  return {
50
53
  accessorKey: header,
51
54
  cell: (info) => info.getValue()
52
55
  };
53
- }),
54
- ...tableOptions
56
+ })
55
57
  };
56
58
  }
57
59
  function searchInResult(result, searchValue) {
58
60
  if (searchValue === '') {
59
61
  return result;
60
62
  }
61
- return result.filter((row) => Object.values(row).some((value) => value.toString().includes(searchValue)));
63
+ return result.filter((row) => Object.values(row).some((value) => value?.toString()?.includes(searchValue)));
62
64
  }
63
65
  function renderCell(x, props) {
64
66
  try {
@@ -68,11 +70,13 @@ function renderCell(x, props) {
68
70
  return undefined;
69
71
  }
70
72
  }
73
+ function cellIsObject(x, props) {
74
+ return typeof x != 'string' && typeof x(props) == 'object';
75
+ }
71
76
  let filteredResult = [];
72
77
  $: filteredResult && setOptions(filteredResult);
73
- $: extraQueryParams = search === 'Runnable' ? { search: searchValue, page } : { page, search: '' };
74
- $: search === 'Runnable' && (filteredResult = searchInResult(result, searchValue));
75
- $: (search === 'Runnable' || search === 'Disabled') && (filteredResult = result);
78
+ $: search === 'By Component' && (filteredResult = searchInResult(result, searchValue));
79
+ $: (search === 'By Runnable' || search === 'Disabled') && (filteredResult = result);
76
80
  $: outputs = $worldStore?.outputsById[id];
77
81
  function rerender() {
78
82
  table = createSvelteTable(options);
@@ -81,9 +85,8 @@ $: result && rerender();
81
85
  </script>
82
86
 
83
87
  <InputValue {id} input={configuration.search} bind:value={search} />
84
- <InputValue {id} input={configuration.pagination} bind:value={pagination} />
85
88
 
86
- <RunnableWrapper bind:componentInput {id} bind:result {extraQueryParams}>
89
+ <RunnableWrapper bind:componentInput {id} bind:result>
87
90
  {#if Array.isArray(result) && result.every(isObject)}
88
91
  <div class="border border-gray-300 shadow-sm divide-y divide-gray-300 flex flex-col h-full">
89
92
  {#if search !== 'Disabled'}
@@ -135,15 +138,17 @@ $: result && rerender();
135
138
  )}
136
139
  >
137
140
  {#each row.getVisibleCells() as cell, index (index)}
138
- {#if cell?.column?.columnDef?.header}
141
+ {#if cell?.column?.columnDef?.cell}
139
142
  {@const context = cell?.getContext()}
140
143
  {#if context}
141
144
  {@const component = renderCell(cell.column.columnDef.cell, context)}
142
145
  <td
143
146
  on:click={() => toggleRow(row, rowIndex)}
144
- class="p-4 whitespace-nowrap text-xs text-gray-900"
147
+ class="p-4 whitespace-pre-wrap truncate text-xs text-gray-900"
145
148
  >
146
- {#if component != undefined}
149
+ {#if typeof cell.column.columnDef.cell != 'string' && cellIsObject(cell.column.columnDef.cell, context)}
150
+ {JSON.stringify(cell.column.columnDef.cell(context), null, 4)}
151
+ {:else if component != undefined}
147
152
  <svelte:component this={component} />
148
153
  {/if}
149
154
  </td>