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.
- package/common.js +1 -5
- package/components/AppConnect.svelte +281 -0
- package/components/AppConnect.svelte.d.ts +22 -0
- package/components/ArgInfo.svelte +11 -16
- package/components/ArgInput.svelte +73 -70
- package/components/ArgInput.svelte.d.ts +6 -1
- package/components/AutosizedTextarea.svelte +6 -8
- package/components/Badge.svelte +4 -10
- package/components/Button.svelte +22 -18
- package/components/ButtonAndDropdown.svelte +6 -12
- package/components/CenteredModal.svelte +30 -0
- package/components/CenteredModal.svelte.d.ts +19 -0
- package/components/ChevronButton.svelte +4 -9
- package/components/DisplayResult.svelte +58 -57
- package/components/Dropdown.svelte +8 -13
- package/components/Editor.svelte +108 -149
- package/components/Editor.svelte.d.ts +3 -1
- package/components/FieldHeader.svelte +7 -12
- package/components/FlowBuilder.svelte +72 -121
- package/components/FlowBuilder.svelte.d.ts +0 -2
- package/components/FlowEditor.svelte +185 -73
- package/components/FlowEditor.svelte.d.ts +4 -4
- package/components/FlowJobResult.svelte +23 -0
- package/components/FlowJobResult.svelte.d.ts +17 -0
- package/components/FlowPreview.svelte +36 -51
- package/components/FlowPreview.svelte.d.ts +7 -1
- package/components/FlowStatusViewer.svelte +66 -40
- package/components/FlowStatusViewer.svelte.d.ts +1 -1
- package/components/FlowViewer.svelte +100 -0
- package/components/FlowViewer.svelte.d.ts +24 -0
- package/components/GroupModal.svelte +13 -20
- package/components/IconedResourceType.svelte +15 -18
- package/components/InviteGlobalUser.svelte +8 -15
- package/components/InviteUser.svelte +9 -16
- package/components/ItemPicker.svelte +11 -14
- package/components/JobStatus.svelte +6 -11
- package/components/Modal.svelte +14 -17
- package/components/ModuleStep.svelte +125 -64
- package/components/ModuleStep.svelte.d.ts +4 -8
- package/components/ObjectResourceInput.svelte +15 -20
- package/components/ObjectTypeNarrowing.svelte +7 -12
- package/components/PageHeader.svelte +4 -9
- package/components/Password.svelte +6 -8
- package/components/Path.svelte +78 -38
- package/components/Path.svelte.d.ts +2 -0
- package/components/RadioButton.svelte +7 -8
- package/components/RadioButtonV2.svelte +33 -0
- package/components/RadioButtonV2.svelte.d.ts +20 -0
- package/components/Required.svelte +2 -4
- package/components/ResourceEditor.svelte +44 -48
- package/components/ResourcePicker.svelte +6 -7
- package/components/ResourcePicker.svelte.d.ts +2 -2
- package/components/ResourceTypePicker.svelte +8 -13
- package/components/RunForm.svelte +15 -20
- package/components/SchemaEditor.svelte +31 -61
- package/components/SchemaForm.svelte +126 -134
- package/components/SchemaForm.svelte.d.ts +6 -4
- package/components/SchemaModal.svelte +25 -40
- package/components/SchemaModal.svelte.d.ts +1 -1
- package/components/SchemaViewer.svelte +6 -12
- package/components/ScriptBuilder.svelte +76 -101
- package/components/ScriptEditor.svelte +55 -60
- package/components/ScriptPicker.svelte +28 -34
- package/components/ScriptPicker.svelte.d.ts +1 -0
- package/components/ScriptSchema.svelte +13 -17
- package/components/ShareModal.svelte +23 -29
- package/components/SharedBadge.svelte +11 -16
- package/components/StringTypeNarrowing.svelte +8 -11
- package/components/Switch.svelte.d.ts +2 -2
- package/components/TableCustom.svelte +5 -8
- package/components/TableSimple.svelte +9 -8
- package/components/Tabs.svelte +6 -8
- package/components/Toggle.svelte +34 -0
- package/components/Toggle.svelte.d.ts +28 -0
- package/components/Tooltip.svelte +56 -89
- package/components/Tooltip.svelte.d.ts +1 -5
- package/components/VariableEditor.svelte +30 -29
- package/components/flows/CopyFirstStepSchema.svelte +10 -0
- package/components/flows/CopyFirstStepSchema.svelte.d.ts +14 -0
- package/components/flows/DynamicInputHelpBox.svelte +72 -0
- package/components/flows/DynamicInputHelpBox.svelte.d.ts +14 -0
- package/components/flows/FlowInputs.svelte +27 -0
- package/components/flows/FlowInputs.svelte.d.ts +19 -0
- package/components/flows/FlowModuleHeader.svelte +91 -0
- package/components/flows/FlowModuleHeader.svelte.d.ts +22 -0
- package/components/flows/flowStore.d.ts +17 -0
- package/components/flows/flowStore.js +161 -0
- package/components/flows/pickers/FlowScriptPicker.svelte +11 -0
- package/components/flows/pickers/FlowScriptPicker.svelte.d.ts +22 -0
- package/components/flows/pickers/PickHubScript.svelte +30 -0
- package/components/flows/pickers/PickHubScript.svelte.d.ts +18 -0
- package/components/flows/pickers/PickScript.svelte +38 -0
- package/components/flows/pickers/PickScript.svelte.d.ts +18 -0
- package/components/flows/utils.d.ts +21 -0
- package/components/flows/utils.js +164 -0
- package/components/icons/DbIcon.svelte +2 -5
- package/components/icons/Mail.svelte +2 -5
- package/components/icons/Mysql.svelte +2 -5
- package/components/icons/PostgresIcon.svelte +2 -5
- package/components/icons/Slack.svelte +2 -5
- package/components/propertyPicker/ObjectViewer.svelte +113 -0
- package/components/propertyPicker/ObjectViewer.svelte.d.ts +21 -0
- package/components/propertyPicker/OverlayPropertyPicker.svelte +69 -0
- package/components/propertyPicker/OverlayPropertyPicker.svelte.d.ts +21 -0
- package/components/propertyPicker/PropPicker.svelte +24 -0
- package/components/propertyPicker/PropPicker.svelte.d.ts +18 -0
- package/components/propertyPicker/WarningMessage.svelte +43 -0
- package/components/propertyPicker/WarningMessage.svelte.d.ts +16 -0
- package/components/propertyPicker/utils.d.ts +2 -0
- package/components/propertyPicker/utils.js +40 -0
- package/gen/core/ApiError.d.ts +3 -1
- package/gen/core/ApiError.js +4 -6
- package/gen/core/ApiRequestOptions.js +1 -2
- package/gen/core/ApiResult.js +1 -2
- package/gen/core/CancelablePromise.js +2 -7
- package/gen/core/OpenAPI.js +2 -5
- package/gen/core/request.js +8 -13
- package/gen/index.d.ts +3 -0
- package/gen/index.js +28 -58
- package/gen/models/AuditLog.js +2 -5
- package/gen/models/CompletedJob.d.ts +3 -1
- package/gen/models/CompletedJob.js +3 -5
- package/gen/models/ContextualVariable.js +1 -2
- package/gen/models/CreateResource.d.ts +1 -0
- package/gen/models/CreateResource.js +1 -2
- package/gen/models/CreateVariable.d.ts +2 -0
- package/gen/models/CreateVariable.js +1 -2
- package/gen/models/CreateWorkspace.js +1 -2
- package/gen/models/EditResource.js +1 -2
- package/gen/models/EditResourceType.js +1 -2
- package/gen/models/EditSchedule.js +1 -2
- package/gen/models/EditVariable.js +1 -2
- package/gen/models/EditWorkspaceUser.js +1 -2
- package/gen/models/Flow.js +1 -2
- package/gen/models/FlowModule.d.ts +2 -0
- package/gen/models/FlowModule.js +1 -2
- package/gen/models/FlowModuleValue.d.ts +14 -2
- package/gen/models/FlowModuleValue.js +9 -5
- package/gen/models/FlowPreview.js +1 -2
- package/gen/models/FlowStatus.js +1 -2
- package/gen/models/FlowStatusModule.d.ts +6 -0
- package/gen/models/FlowStatusModule.js +2 -5
- package/gen/models/FlowValue.js +1 -2
- package/gen/models/GlobalUserInfo.js +2 -5
- package/gen/models/Group.js +1 -2
- package/gen/models/InputTransform.js +2 -5
- package/gen/models/Job.js +2 -5
- package/gen/models/ListableVariable.d.ts +2 -0
- package/gen/models/ListableVariable.js +1 -2
- package/gen/models/Login.js +1 -2
- package/gen/models/MainArgSignature.js +1 -2
- package/gen/models/NewSchedule.js +1 -2
- package/gen/models/NewToken.js +1 -2
- package/gen/models/NewUser.js +1 -2
- package/gen/models/Preview.js +2 -5
- package/gen/models/QueuedJob.d.ts +2 -1
- package/gen/models/QueuedJob.js +3 -5
- package/gen/models/Resource.d.ts +1 -0
- package/gen/models/Resource.js +1 -2
- package/gen/models/ResourceType.js +1 -2
- package/gen/models/Schedule.js +1 -2
- package/gen/models/Script.d.ts +1 -0
- package/gen/models/Script.js +2 -5
- package/gen/models/ScriptArgs.js +1 -2
- package/gen/models/SlackToken.d.ts +8 -0
- package/gen/models/SlackToken.js +4 -0
- package/gen/models/TokenResponse.d.ts +6 -0
- package/gen/models/TokenResponse.js +4 -0
- package/gen/models/TruncatedToken.js +1 -2
- package/gen/models/User.js +1 -2
- package/gen/models/UserWorkspaceList.js +1 -2
- package/gen/models/WorkerPing.js +1 -2
- package/gen/models/Workspace.js +1 -2
- package/gen/models/WorkspaceInvite.js +1 -2
- package/gen/services/AdminService.d.ts +6 -2
- package/gen/services/AdminService.js +6 -10
- package/gen/services/AuditService.d.ts +24 -8
- package/gen/services/AuditService.js +5 -9
- package/gen/services/FlowService.d.ts +37 -10
- package/gen/services/FlowService.js +23 -12
- package/gen/services/GranularAclService.d.ts +6 -2
- package/gen/services/GranularAclService.js +6 -10
- package/gen/services/GroupService.d.ts +18 -6
- package/gen/services/GroupService.js +11 -15
- package/gen/services/JobService.d.ts +167 -46
- package/gen/services/JobService.js +42 -22
- package/gen/services/OauthService.d.ts +104 -0
- package/gen/services/OauthService.js +133 -0
- package/gen/services/ResourceService.d.ts +39 -7
- package/gen/services/ResourceService.js +44 -18
- package/gen/services/ScheduleService.d.ts +36 -6
- package/gen/services/ScheduleService.js +39 -13
- package/gen/services/ScriptService.d.ts +66 -19
- package/gen/services/ScriptService.js +32 -20
- package/gen/services/SettingsService.js +5 -9
- package/gen/services/UserService.d.ts +49 -11
- package/gen/services/UserService.js +42 -29
- package/gen/services/VariableService.d.ts +19 -4
- package/gen/services/VariableService.js +24 -13
- package/gen/services/WorkerService.d.ts +6 -2
- package/gen/services/WorkerService.js +4 -8
- package/gen/services/WorkspaceService.d.ts +29 -24
- package/gen/services/WorkspaceService.js +23 -42
- package/infer.js +5 -9
- package/logout.js +20 -18
- package/package.json +51 -24
- package/script_helpers.d.ts +4 -0
- package/script_helpers.js +70 -0
- package/scripts.d.ts +2 -1
- package/scripts.js +11 -15
- package/stores.d.ts +6 -0
- package/stores.js +30 -22
- package/user.js +10 -15
- package/utils.d.ts +15 -1
- package/utils.js +191 -52
package/common.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pathToMeta = void 0;
|
|
4
|
-
function pathToMeta(path) {
|
|
1
|
+
export function pathToMeta(path) {
|
|
5
2
|
const splitted = path.split('/');
|
|
6
3
|
let ownerKind;
|
|
7
4
|
if (splitted[0] == 'g') {
|
|
@@ -24,4 +21,3 @@ function pathToMeta(path) {
|
|
|
24
21
|
name: splitted.slice(2).join('/')
|
|
25
22
|
};
|
|
26
23
|
}
|
|
27
|
-
exports.pathToMeta = pathToMeta;
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
<script context="module">"use strict";
|
|
2
|
+
const apiTokenApps = {
|
|
3
|
+
airtable: {
|
|
4
|
+
img: 'airtable_connect.png',
|
|
5
|
+
instructions: 'Click on the top-right avatar -> Account -> Api'
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<script>import IconedResourceType from './IconedResourceType.svelte';
|
|
11
|
+
import PageHeader from './PageHeader.svelte';
|
|
12
|
+
import { workspaceStore, userStore, oauthStore } from '../stores';
|
|
13
|
+
import { faMinus, faPlus } from '@fortawesome/free-solid-svg-icons';
|
|
14
|
+
import { OauthService, ResourceService, VariableService } from '../gen';
|
|
15
|
+
import { createEventDispatcher, onMount } from 'svelte';
|
|
16
|
+
import Modal from './Modal.svelte';
|
|
17
|
+
import Icon from 'svelte-awesome';
|
|
18
|
+
import Path from './Path.svelte';
|
|
19
|
+
import Password from './Password.svelte';
|
|
20
|
+
import { sendUserToast, truncateRev } from '../utils';
|
|
21
|
+
let manual = false;
|
|
22
|
+
let value = '';
|
|
23
|
+
let valueToken;
|
|
24
|
+
let connects = {};
|
|
25
|
+
let connectsManual = [];
|
|
26
|
+
let scopes = [];
|
|
27
|
+
let path;
|
|
28
|
+
let modal;
|
|
29
|
+
let resource_type = '';
|
|
30
|
+
let step = 1;
|
|
31
|
+
let no_back = false;
|
|
32
|
+
let pathError = '';
|
|
33
|
+
export function open() {
|
|
34
|
+
step = 1;
|
|
35
|
+
value = '';
|
|
36
|
+
resource_type = '';
|
|
37
|
+
no_back = false;
|
|
38
|
+
modal.openModal();
|
|
39
|
+
}
|
|
40
|
+
export function openFromOauth(rt) {
|
|
41
|
+
resource_type = rt;
|
|
42
|
+
value = $oauthStore?.access_token;
|
|
43
|
+
valueToken = $oauthStore;
|
|
44
|
+
$oauthStore = undefined;
|
|
45
|
+
manual = false;
|
|
46
|
+
step = 3;
|
|
47
|
+
no_back = true;
|
|
48
|
+
modal.openModal();
|
|
49
|
+
}
|
|
50
|
+
async function loadConnects() {
|
|
51
|
+
connects = await OauthService.listOAuthConnects();
|
|
52
|
+
}
|
|
53
|
+
async function loadResources() {
|
|
54
|
+
const availableRts = await ResourceService.listResourceTypeNames({
|
|
55
|
+
workspace: $workspaceStore
|
|
56
|
+
});
|
|
57
|
+
connectsManual = Object.entries(apiTokenApps).filter(([key, _]) => availableRts.includes(key));
|
|
58
|
+
}
|
|
59
|
+
async function next() {
|
|
60
|
+
if (step < 3 && manual) {
|
|
61
|
+
step += 1;
|
|
62
|
+
}
|
|
63
|
+
else if (step == 1 && !manual) {
|
|
64
|
+
window.location.href = `/api/oauth/connect/${resource_type}?scopes=${scopes.join('+')}`;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
let exists = await VariableService.existsVariable({
|
|
68
|
+
workspace: $workspaceStore,
|
|
69
|
+
path
|
|
70
|
+
});
|
|
71
|
+
if (exists) {
|
|
72
|
+
throw Error(`Variable at path ${path} already exists. Delete it or pick another path`);
|
|
73
|
+
}
|
|
74
|
+
exists = await ResourceService.existsResource({
|
|
75
|
+
workspace: $workspaceStore,
|
|
76
|
+
path
|
|
77
|
+
});
|
|
78
|
+
if (exists) {
|
|
79
|
+
throw Error(`Resource at path ${path} already exists. Delete it or pick another path`);
|
|
80
|
+
}
|
|
81
|
+
let account = undefined;
|
|
82
|
+
if (valueToken.refresh_token != undefined && valueToken.expires_in != undefined) {
|
|
83
|
+
account = Number(await OauthService.createAccount({
|
|
84
|
+
workspace: $workspaceStore,
|
|
85
|
+
requestBody: {
|
|
86
|
+
refresh_token: valueToken.refresh_token,
|
|
87
|
+
expires_in: valueToken.expires_in,
|
|
88
|
+
owner: path.split('/').slice(0, 2).join('/'),
|
|
89
|
+
client: resource_type
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
await VariableService.createVariable({
|
|
94
|
+
workspace: $workspaceStore,
|
|
95
|
+
requestBody: {
|
|
96
|
+
path,
|
|
97
|
+
value,
|
|
98
|
+
is_secret: true,
|
|
99
|
+
description: `OAuth token for ${resource_type}`,
|
|
100
|
+
is_oauth: true,
|
|
101
|
+
account: account
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
await ResourceService.createResource({
|
|
105
|
+
workspace: $workspaceStore,
|
|
106
|
+
requestBody: {
|
|
107
|
+
resource_type,
|
|
108
|
+
path,
|
|
109
|
+
value: { token: `$var:${path}` },
|
|
110
|
+
description: `OAuth token for ${resource_type}`,
|
|
111
|
+
is_oauth: true
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
dispatch('refresh');
|
|
115
|
+
sendUserToast(`App token set at resource and variable path: ${path}`);
|
|
116
|
+
modal.closeModal();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async function back() {
|
|
120
|
+
if (step > 1) {
|
|
121
|
+
step -= 1;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const dispatch = createEventDispatcher();
|
|
125
|
+
$: {
|
|
126
|
+
if ($workspaceStore) {
|
|
127
|
+
loadResources();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
onMount(() => {
|
|
131
|
+
loadConnects();
|
|
132
|
+
});
|
|
133
|
+
</script>
|
|
134
|
+
|
|
135
|
+
<Modal
|
|
136
|
+
bind:this={modal}
|
|
137
|
+
on:close={() => {
|
|
138
|
+
dispatch('close')
|
|
139
|
+
}}
|
|
140
|
+
>
|
|
141
|
+
<div slot="title">Connect an app</div>
|
|
142
|
+
<div slot="content">
|
|
143
|
+
{#if step == 1}
|
|
144
|
+
<PageHeader title="OAuth apps" />
|
|
145
|
+
<div class="grid sm:grid-cols-2 md:grid-cols-3 gap-x-2 gap-y-1 items-center mb-2">
|
|
146
|
+
{#each Object.entries(connects) as [key, values]}
|
|
147
|
+
<button
|
|
148
|
+
class="px-4 h-8 {key == resource_type ? 'item-button-selected' : 'item-button'}"
|
|
149
|
+
on:click={() => {
|
|
150
|
+
manual = false
|
|
151
|
+
resource_type = key
|
|
152
|
+
scopes = values
|
|
153
|
+
dispatch('click')
|
|
154
|
+
}}
|
|
155
|
+
>
|
|
156
|
+
<IconedResourceType name={key} after={true} />
|
|
157
|
+
</button>
|
|
158
|
+
{/each}
|
|
159
|
+
</div>
|
|
160
|
+
<PageHeader title="scopes" primary={false} />
|
|
161
|
+
{#if !manual && resource_type != ''}
|
|
162
|
+
{#each scopes as v}
|
|
163
|
+
<div class="flex flex-row max-w-md">
|
|
164
|
+
<input type="text" bind:value={v} />
|
|
165
|
+
<button
|
|
166
|
+
class="default-button-secondary mx-6"
|
|
167
|
+
on:click={() => {
|
|
168
|
+
scopes = scopes.filter((el) => el != v)
|
|
169
|
+
}}><Icon data={faMinus} class="mb-1" /></button
|
|
170
|
+
>
|
|
171
|
+
</div>
|
|
172
|
+
{/each}
|
|
173
|
+
<button
|
|
174
|
+
class="default-button-secondary mt-1"
|
|
175
|
+
on:click={() => {
|
|
176
|
+
scopes = scopes.concat('')
|
|
177
|
+
}}>Add item <Icon data={faPlus} class="mb-1" /></button
|
|
178
|
+
><span class="ml-2">{(scopes ?? []).length} item(s)</span>
|
|
179
|
+
{:else}
|
|
180
|
+
<p class="italic text-sm">Pick an oauth app and customize the scopes here</p>
|
|
181
|
+
{/if}
|
|
182
|
+
<PageHeader title="API token apps" />
|
|
183
|
+
<div class="grid sm:grid-cols-2 md:grid-cols-3 gap-x-2 gap-y-1 items-center mb-2">
|
|
184
|
+
{#each connectsManual as [key, instructions]}
|
|
185
|
+
<button
|
|
186
|
+
class="px-4 h-8 {key == resource_type ? 'item-button-selected' : 'item-button'}"
|
|
187
|
+
on:click={() => {
|
|
188
|
+
manual = true
|
|
189
|
+
resource_type = key
|
|
190
|
+
dispatch('click')
|
|
191
|
+
}}
|
|
192
|
+
>
|
|
193
|
+
<IconedResourceType name={key} after={true} />
|
|
194
|
+
</button>
|
|
195
|
+
{/each}
|
|
196
|
+
</div>
|
|
197
|
+
{:else if step == 2}
|
|
198
|
+
{#if manual}
|
|
199
|
+
<PageHeader title="Instructions" />
|
|
200
|
+
<div>
|
|
201
|
+
{apiTokenApps[resource_type].instructions}
|
|
202
|
+
</div>
|
|
203
|
+
{#if apiTokenApps[resource_type].img}
|
|
204
|
+
<div class="mt-4">
|
|
205
|
+
<img alt="connect" src={apiTokenApps[resource_type].img} />
|
|
206
|
+
</div>
|
|
207
|
+
{/if}
|
|
208
|
+
<div class="mt-4">
|
|
209
|
+
<Password bind:password={value} label="Paste token here" />
|
|
210
|
+
</div>
|
|
211
|
+
{/if}
|
|
212
|
+
{:else}
|
|
213
|
+
<Path
|
|
214
|
+
bind:error={pathError}
|
|
215
|
+
bind:path
|
|
216
|
+
initialPath={`u/${$userStore?.username ?? ''}/my_${resource_type}`}
|
|
217
|
+
kind="resource"
|
|
218
|
+
/>
|
|
219
|
+
<ul class="mt-10 bg-white">
|
|
220
|
+
<li>
|
|
221
|
+
1. A secret variable containing the token <span class="font-bold"
|
|
222
|
+
>{truncateRev(value, 5, '*****')}</span
|
|
223
|
+
>
|
|
224
|
+
will be stored at
|
|
225
|
+
<span class="font-mono">{path}</span>. You can refer to this variable anywhere this token
|
|
226
|
+
is required.
|
|
227
|
+
</li>
|
|
228
|
+
<li class="mt-4">
|
|
229
|
+
2. A resource with a unique token field will be stored at <span class="font-mono"
|
|
230
|
+
>{path}</span
|
|
231
|
+
>
|
|
232
|
+
and refer to the secret variable <span class="font-mono">{path}</span> as its token (using
|
|
233
|
+
variable templating
|
|
234
|
+
<span class="font-mono">`$var:${path}`</span>). You can refer to this resource anywhere
|
|
235
|
+
this token is required. A script can use the resource type
|
|
236
|
+
<span class="font-mono">{resource_type}</span> as a type parameter to restrict the kind of
|
|
237
|
+
tokens it accepts to this app.
|
|
238
|
+
</li>
|
|
239
|
+
</ul>
|
|
240
|
+
{/if}
|
|
241
|
+
</div>
|
|
242
|
+
<div slot="submission">
|
|
243
|
+
{#if step > 1 && !no_back}
|
|
244
|
+
<button class="default-button px-4 py-2 font-semibold" on:click={back}>Back</button>
|
|
245
|
+
{/if}
|
|
246
|
+
<button
|
|
247
|
+
class="default-button px-4 py-2 font-semibold"
|
|
248
|
+
class:default-button-disabled={(step == 1 && resource_type == '') ||
|
|
249
|
+
(step == 2 && value == '') ||
|
|
250
|
+
(step == 3 && pathError != '')}
|
|
251
|
+
on:click={next}
|
|
252
|
+
>
|
|
253
|
+
{step == 3 ? 'Connect' : 'Next'}
|
|
254
|
+
</button>
|
|
255
|
+
</div>
|
|
256
|
+
</Modal>
|
|
257
|
+
|
|
258
|
+
<style>
|
|
259
|
+
.item-button {
|
|
260
|
+
padding-top: 0.25rem;
|
|
261
|
+
padding-bottom: 0.25rem;
|
|
262
|
+
border-width: 1px;
|
|
263
|
+
border-radius: 0.125rem
|
|
264
|
+
}
|
|
265
|
+
.item-button-selected {
|
|
266
|
+
padding-top: 0.25rem;
|
|
267
|
+
padding-bottom: 0.25rem;
|
|
268
|
+
border-width: 1px;
|
|
269
|
+
--tw-border-opacity: 1;
|
|
270
|
+
border-color: rgb(59 130 246 / var(--tw-border-opacity));
|
|
271
|
+
--tw-bg-opacity: 1;
|
|
272
|
+
background-color: rgb(239 246 255 / var(--tw-bg-opacity));
|
|
273
|
+
border-radius: 0.125rem
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.selected:hover {
|
|
277
|
+
border-radius: 0.375rem;
|
|
278
|
+
border-width: 1px;
|
|
279
|
+
border-color: rgb(156 163 175 / var(--tw-border-opacity));
|
|
280
|
+
--tw-border-opacity: 0.5
|
|
281
|
+
}</style>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
open?: (() => void) | undefined;
|
|
5
|
+
openFromOauth?: ((rt: string) => void) | undefined;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
close: CustomEvent<any>;
|
|
9
|
+
click: CustomEvent<any>;
|
|
10
|
+
} & {
|
|
11
|
+
[evt: string]: CustomEvent<any>;
|
|
12
|
+
};
|
|
13
|
+
slots: {};
|
|
14
|
+
};
|
|
15
|
+
export declare type AppConnectProps = typeof __propDef.props;
|
|
16
|
+
export declare type AppConnectEvents = typeof __propDef.events;
|
|
17
|
+
export declare type AppConnectSlots = typeof __propDef.slots;
|
|
18
|
+
export default class AppConnect extends SvelteComponentTyped<AppConnectProps, AppConnectEvents, AppConnectSlots> {
|
|
19
|
+
get open(): () => void;
|
|
20
|
+
get openFromOauth(): (rt: string) => void;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const json_1 = __importDefault(require("svelte-highlight/languages/json"));
|
|
11
|
-
const github_1 = __importDefault(require("svelte-highlight/styles/github"));
|
|
12
|
-
const svelte_highlight_1 = require("svelte-highlight");
|
|
13
|
-
const gen_1 = require("$lib/gen");
|
|
14
|
-
const stores_1 = require("$lib/stores");
|
|
1
|
+
<script>import { truncate } from '../utils';
|
|
2
|
+
import Modal from './Modal.svelte';
|
|
3
|
+
import Tooltip from './Tooltip.svelte';
|
|
4
|
+
import json from 'svelte-highlight/languages/json';
|
|
5
|
+
import github from 'svelte-highlight/styles/github';
|
|
6
|
+
import { Highlight } from 'svelte-highlight';
|
|
7
|
+
import { ResourceService } from '../gen';
|
|
8
|
+
import { workspaceStore } from '../stores';
|
|
9
|
+
export let value;
|
|
15
10
|
let resourceViewer;
|
|
16
11
|
let resource;
|
|
17
12
|
function isString(value) {
|
|
18
13
|
return typeof value === 'string' || value instanceof String;
|
|
19
14
|
}
|
|
20
15
|
async function getResource(path) {
|
|
21
|
-
resource = await
|
|
16
|
+
resource = await ResourceService.getResource({ workspace: $workspaceStore, path });
|
|
22
17
|
}
|
|
23
|
-
let asJson = JSON.stringify(
|
|
18
|
+
let asJson = JSON.stringify(value, null, 4);
|
|
24
19
|
</script>
|
|
25
20
|
|
|
26
21
|
<svelte:head>
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
$: minHeight = `${1 +
|
|
33
|
-
$: maxHeight =
|
|
34
|
-
$: validateInput(
|
|
1
|
+
<script>import Tooltip from './Tooltip.svelte';
|
|
2
|
+
import { slide } from 'svelte/transition';
|
|
3
|
+
import { faChevronDown, faChevronUp, faMinus, faPlus } from '@fortawesome/free-solid-svg-icons';
|
|
4
|
+
import StringTypeNarrowing from './StringTypeNarrowing.svelte';
|
|
5
|
+
import Icon from 'svelte-awesome';
|
|
6
|
+
import ResourcePicker from './ResourcePicker.svelte';
|
|
7
|
+
import ObjectTypeNarrowing from './ObjectTypeNarrowing.svelte';
|
|
8
|
+
import ObjectResourceInput from './ObjectResourceInput.svelte';
|
|
9
|
+
import FieldHeader from './FieldHeader.svelte';
|
|
10
|
+
import { createEventDispatcher } from 'svelte';
|
|
11
|
+
import { setInputCat as computeInputCat } from '../utils';
|
|
12
|
+
export let label = '';
|
|
13
|
+
export let value;
|
|
14
|
+
export let defaultValue = undefined;
|
|
15
|
+
export let description = '';
|
|
16
|
+
export let format = '';
|
|
17
|
+
export let contentEncoding = '';
|
|
18
|
+
export let type = undefined;
|
|
19
|
+
export let required = false;
|
|
20
|
+
export let pattern = undefined;
|
|
21
|
+
export let valid = required ? false : true;
|
|
22
|
+
export let minRows = 1;
|
|
23
|
+
export let maxRows = 10;
|
|
24
|
+
export let enum_ = undefined;
|
|
25
|
+
export let disabled = false;
|
|
26
|
+
export let editableSchema = false;
|
|
27
|
+
export let itemsType = undefined;
|
|
28
|
+
export let displayHeader = true;
|
|
29
|
+
export let numberAsString = false;
|
|
30
|
+
let seeEditable = enum_ != undefined || pattern != undefined;
|
|
31
|
+
const dispatch = createEventDispatcher();
|
|
32
|
+
$: minHeight = `${1 + minRows * 1.2}em`;
|
|
33
|
+
$: maxHeight = maxRows ? `${1 + maxRows * 1.2}em` : `auto`;
|
|
34
|
+
$: validateInput(pattern, value);
|
|
35
35
|
let error = '';
|
|
36
|
-
let rawValue;
|
|
36
|
+
let rawValue = undefined;
|
|
37
37
|
$: {
|
|
38
38
|
if (rawValue) {
|
|
39
39
|
try {
|
|
40
|
-
|
|
40
|
+
value = JSON.parse(rawValue);
|
|
41
41
|
}
|
|
42
42
|
catch (err) {
|
|
43
43
|
error = err.toString();
|
|
@@ -45,23 +45,25 @@ $: {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
$: {
|
|
48
|
-
if (
|
|
48
|
+
if (inputCat === 'object') {
|
|
49
49
|
evalValueToRaw();
|
|
50
|
+
validateInput(pattern, value);
|
|
50
51
|
}
|
|
51
|
-
if (
|
|
52
|
-
let stringified = JSON.stringify(
|
|
52
|
+
if (defaultValue) {
|
|
53
|
+
let stringified = JSON.stringify(defaultValue, null, 4);
|
|
53
54
|
if (stringified.length > 50) {
|
|
54
|
-
|
|
55
|
+
minRows = 3;
|
|
55
56
|
}
|
|
56
|
-
if (
|
|
57
|
-
|
|
57
|
+
if (type != 'string') {
|
|
58
|
+
minRows = Math.max(minRows, Math.min(stringified.split(/\r\n|\r|\n/).length + 1, maxRows));
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
|
-
function evalValueToRaw() {
|
|
62
|
-
|
|
62
|
+
export function evalValueToRaw() {
|
|
63
|
+
if (value) {
|
|
64
|
+
rawValue = JSON.stringify(value, null, 4);
|
|
65
|
+
}
|
|
63
66
|
}
|
|
64
|
-
exports.evalValueToRaw = evalValueToRaw;
|
|
65
67
|
function fileChanged(e, cb) {
|
|
66
68
|
let t = e.target;
|
|
67
69
|
if (t && 'files' in t && t.files.length > 0) {
|
|
@@ -76,18 +78,18 @@ function fileChanged(e, cb) {
|
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
80
|
function validateInput(pattern, v) {
|
|
79
|
-
if (
|
|
81
|
+
if (required && (v == undefined || v == null)) {
|
|
80
82
|
error = 'This field is required';
|
|
81
|
-
|
|
83
|
+
valid = false;
|
|
82
84
|
}
|
|
83
85
|
else {
|
|
84
86
|
if (pattern && !testRegex(pattern, v)) {
|
|
85
87
|
error = `Should match ${pattern}`;
|
|
86
|
-
|
|
88
|
+
valid = false;
|
|
87
89
|
}
|
|
88
90
|
else {
|
|
89
91
|
error = '';
|
|
90
|
-
|
|
92
|
+
valid = true;
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
95
|
}
|
|
@@ -101,10 +103,11 @@ function testRegex(pattern, value) {
|
|
|
101
103
|
}
|
|
102
104
|
}
|
|
103
105
|
$: {
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
+
if (value == undefined) {
|
|
107
|
+
value = defaultValue;
|
|
106
108
|
}
|
|
107
109
|
}
|
|
110
|
+
export let inputCat = computeInputCat(type, format, itemsType?.type, enum_, contentEncoding);
|
|
108
111
|
</script>
|
|
109
112
|
|
|
110
113
|
<div class="flex flex-col w-full">
|
|
@@ -161,17 +164,18 @@ $: {
|
|
|
161
164
|
</div>
|
|
162
165
|
</div>
|
|
163
166
|
<div class="container">
|
|
164
|
-
{#if
|
|
167
|
+
{#if inputCat == 'number' && !numberAsString}
|
|
165
168
|
<input
|
|
166
169
|
{disabled}
|
|
167
170
|
type="number"
|
|
168
171
|
class={valid
|
|
169
172
|
? ''
|
|
170
173
|
: 'border border-red-700 border-opacity-30 focus:border-red-700 focus:border-opacity-30 bg-red-100'}
|
|
171
|
-
placeholder={defaultValue}
|
|
174
|
+
placeholder={defaultValue ?? ''}
|
|
172
175
|
bind:value
|
|
176
|
+
on:input={() => dispatch('input', { value, isRaw: true })}
|
|
173
177
|
/>
|
|
174
|
-
{:else if
|
|
178
|
+
{:else if inputCat == 'boolean'}
|
|
175
179
|
<input
|
|
176
180
|
{disabled}
|
|
177
181
|
type="checkbox"
|
|
@@ -183,12 +187,12 @@ $: {
|
|
|
183
187
|
{#if type == 'boolean' && value == undefined}
|
|
184
188
|
<span> Not set</span>
|
|
185
189
|
{/if}
|
|
186
|
-
{:else if
|
|
190
|
+
{:else if inputCat == 'list'}
|
|
187
191
|
{#each value ?? [] as v}
|
|
188
192
|
<div class="flex flex-row max-w-md">
|
|
189
|
-
{#if itemsType
|
|
193
|
+
{#if itemsType?.type == 'number'}
|
|
190
194
|
<input type="number" bind:value={v} />
|
|
191
|
-
{:else if itemsType
|
|
195
|
+
{:else if itemsType?.type == 'string' && itemsType?.contentEncoding == 'base64'}
|
|
192
196
|
<input
|
|
193
197
|
type="file"
|
|
194
198
|
class="my-6"
|
|
@@ -218,49 +222,50 @@ $: {
|
|
|
218
222
|
value = value.concat('')
|
|
219
223
|
}}>Add item <Icon data={faPlus} class="mb-1" /></button
|
|
220
224
|
><span class="ml-2">{(value ?? []).length} item(s)</span>
|
|
221
|
-
{:else if
|
|
225
|
+
{:else if inputCat == 'resource-object'}
|
|
222
226
|
<ObjectResourceInput {format} bind:value />
|
|
223
|
-
{:else if
|
|
227
|
+
{:else if inputCat == 'object'}
|
|
224
228
|
<textarea
|
|
225
229
|
{disabled}
|
|
226
230
|
style="min-height: {minHeight}; max-height: {maxHeight}"
|
|
227
231
|
class="col-span-10 {valid
|
|
228
232
|
? ''
|
|
229
233
|
: 'border border-red-700 border-opacity-30 focus:border-red-700 focus:border-opacity-30 bg-red-100'}"
|
|
230
|
-
placeholder={JSON.stringify(defaultValue, null, 4)}
|
|
234
|
+
placeholder={defaultValue ? JSON.stringify(defaultValue, null, 4) : ''}
|
|
231
235
|
bind:value={rawValue}
|
|
232
236
|
/>
|
|
233
|
-
{:else if
|
|
237
|
+
{:else if inputCat == 'enum'}
|
|
234
238
|
<select {disabled} class="px-6" bind:value>
|
|
235
|
-
{#each enum_ as e}
|
|
239
|
+
{#each enum_ ?? [] as e}
|
|
236
240
|
<option>{e}</option>
|
|
237
241
|
{/each}
|
|
238
242
|
</select>
|
|
239
|
-
{:else if
|
|
243
|
+
{:else if inputCat == 'date'}
|
|
240
244
|
<input class="inline-block" type="datetime-local" bind:value />
|
|
241
|
-
{:else if
|
|
245
|
+
{:else if inputCat == 'base64'}
|
|
242
246
|
<input
|
|
243
247
|
type="file"
|
|
244
248
|
class="my-6"
|
|
245
249
|
on:change={(x) => fileChanged(x, (val) => (value = val))}
|
|
246
250
|
multiple={false}
|
|
247
251
|
/>
|
|
248
|
-
{:else if
|
|
252
|
+
{:else if inputCat == 'resource-string'}
|
|
249
253
|
<ResourcePicker
|
|
250
254
|
bind:value
|
|
251
255
|
resourceType={format.split('-').length > 1
|
|
252
256
|
? format.substring('resource-'.length)
|
|
253
257
|
: undefined}
|
|
254
258
|
/>
|
|
255
|
-
{:else}
|
|
259
|
+
{:else if inputCat == 'string'}
|
|
256
260
|
<textarea
|
|
257
261
|
{disabled}
|
|
258
262
|
style="height: {minHeight}; max-height: {maxHeight}"
|
|
259
263
|
class="col-span-10 {valid
|
|
260
264
|
? ''
|
|
261
265
|
: 'border border-red-700 border-opacity-30 focus:border-red-700 focus:border-opacity-30 bg-red-100'}"
|
|
262
|
-
placeholder={defaultValue}
|
|
266
|
+
placeholder={defaultValue ?? ''}
|
|
263
267
|
bind:value
|
|
268
|
+
on:input={() => dispatch('input', { rawValue: value, isRaw: false })}
|
|
264
269
|
/>
|
|
265
270
|
{/if}
|
|
266
271
|
{#if !required}
|
|
@@ -269,9 +274,7 @@ $: {
|
|
|
269
274
|
{disabled}
|
|
270
275
|
class="default-button-secondary items-center leading-4 py-0 my-px px-1 float-right"
|
|
271
276
|
on:click={() => (value = undefined)}
|
|
272
|
-
>Reset<Tooltip
|
|
273
|
-
>Reset to default value
|
|
274
|
-
</Tooltip></button
|
|
277
|
+
>Reset<Tooltip>Reset to default value</Tooltip></button
|
|
275
278
|
>
|
|
276
279
|
</div>
|
|
277
280
|
{/if}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import { type InputCat } from '../utils';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
5
|
label?: string | undefined;
|
|
@@ -9,7 +10,7 @@ declare const __propDef: {
|
|
|
9
10
|
contentEncoding?: string | undefined;
|
|
10
11
|
type?: string | undefined;
|
|
11
12
|
required?: boolean | undefined;
|
|
12
|
-
pattern
|
|
13
|
+
pattern?: undefined | string;
|
|
13
14
|
valid?: boolean | undefined;
|
|
14
15
|
minRows?: number | undefined;
|
|
15
16
|
maxRows?: number | undefined;
|
|
@@ -21,9 +22,13 @@ declare const __propDef: {
|
|
|
21
22
|
contentEncoding?: "base64" | undefined;
|
|
22
23
|
} | undefined;
|
|
23
24
|
displayHeader?: boolean | undefined;
|
|
25
|
+
numberAsString?: boolean | undefined;
|
|
24
26
|
evalValueToRaw?: (() => void) | undefined;
|
|
27
|
+
inputCat?: InputCat | undefined;
|
|
25
28
|
};
|
|
26
29
|
events: {
|
|
30
|
+
input: CustomEvent<any>;
|
|
31
|
+
} & {
|
|
27
32
|
[evt: string]: CustomEvent<any>;
|
|
28
33
|
};
|
|
29
34
|
slots: {};
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
$: minHeight = `${1 + exports.minRows * 1.2}em`;
|
|
8
|
-
$: maxHeight = exports.maxRows ? `${1 + exports.maxRows * 1.2}em` : `auto`;
|
|
1
|
+
<script>export let value;
|
|
2
|
+
export let placeholder = '';
|
|
3
|
+
export let minRows = 1;
|
|
4
|
+
export let maxRows = 20;
|
|
5
|
+
$: minHeight = `${1 + minRows * 1.2}em`;
|
|
6
|
+
$: maxHeight = maxRows ? `${1 + maxRows * 1.2}em` : `auto`;
|
|
9
7
|
</script>
|
|
10
8
|
|
|
11
9
|
<div class="container">
|