windmill-components 1.13.8 → 1.13.11
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/components/FlowEditor.svelte +2 -1
- package/components/ModuleStep.svelte +2 -1
- package/infer.d.ts +1 -1
- package/infer.js +1 -1
- package/logout.js +3 -3
- package/package.json +3 -1
- package/scripts.d.ts +1 -0
- package/scripts.js +20 -0
- package/stores.d.ts +1 -1
- package/stores.js +1 -1
- package/user.d.ts +3 -0
- package/user.js +31 -0
- package/utils.d.ts +1 -6
- package/utils.js +2 -49
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
<script>import { faPlus } from '@fortawesome/free-solid-svg-icons';
|
|
2
|
-
import { emptySchema
|
|
2
|
+
import { emptySchema } from '../utils';
|
|
3
3
|
import Icon from 'svelte-awesome';
|
|
4
4
|
import { FlowModuleValue, ScriptService } from '../gen/index.js';
|
|
5
5
|
import SchemaEditor from './SchemaEditor.svelte';
|
|
6
6
|
import { workspaceStore } from '../stores';
|
|
7
7
|
import ModuleStep from './ModuleStep.svelte';
|
|
8
8
|
import FlowPreview from './FlowPreview.svelte';
|
|
9
|
+
import { loadSchema } from '../scripts';
|
|
9
10
|
export let flow;
|
|
10
11
|
let args = {};
|
|
11
12
|
let schemas = [];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script>import SchemaForm from './SchemaForm.svelte';
|
|
2
2
|
import ScriptPicker from './ScriptPicker.svelte';
|
|
3
|
-
import { emptySchema
|
|
3
|
+
import { emptySchema } from '../utils';
|
|
4
|
+
import { loadSchema as UloadSchema } from '../scripts';
|
|
4
5
|
import FlowPreview from './FlowPreview.svelte';
|
|
5
6
|
export let flow;
|
|
6
7
|
export let i;
|
package/infer.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Schema } from './common';
|
|
1
|
+
import type { Schema } from './common.js';
|
|
2
2
|
export declare function inferArgs(language: 'python3' | 'deno', code: string, schema: Schema): Promise<void>;
|
package/infer.js
CHANGED
package/logout.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { goto } from '$app/navigation';
|
|
2
|
-
import { UserService } from './gen';
|
|
3
|
-
import { clearStores } from './stores';
|
|
4
|
-
import { sendUserToast } from './utils';
|
|
2
|
+
import { UserService } from './gen/index.js';
|
|
3
|
+
import { clearStores } from './stores.js';
|
|
4
|
+
import { sendUserToast } from './utils.js';
|
|
5
5
|
export function logoutWithRedirect(rd) {
|
|
6
6
|
const error = encodeURIComponent('You have been logged out because your session has expired.');
|
|
7
7
|
goto(`/user/login?error=${error}${rd ? '&rd=' + encodeURIComponent(rd) : ''}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "windmill-components",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.11",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"@sveltejs/adapter-node": "^1.0.0-next.78",
|
|
6
6
|
"@sveltejs/adapter-static": "^1.0.0-next.34",
|
|
@@ -171,7 +171,9 @@
|
|
|
171
171
|
"./gen/services/WorkspaceService": "./gen/services/WorkspaceService.js",
|
|
172
172
|
"./infer": "./infer.js",
|
|
173
173
|
"./logout": "./logout.js",
|
|
174
|
+
"./scripts": "./scripts.js",
|
|
174
175
|
"./stores": "./stores.js",
|
|
176
|
+
"./user": "./user.js",
|
|
175
177
|
"./utils": "./utils.js"
|
|
176
178
|
}
|
|
177
179
|
}
|
package/scripts.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadSchema(path: string): Promise<any>;
|
package/scripts.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { get } from "svelte/store";
|
|
2
|
+
import { ScriptService } from "./gen";
|
|
3
|
+
import { inferArgs } from "./infer";
|
|
4
|
+
import { workspaceStore } from "./stores";
|
|
5
|
+
import { emptySchema } from "./utils";
|
|
6
|
+
export async function loadSchema(path) {
|
|
7
|
+
if (path.startsWith('hub/')) {
|
|
8
|
+
const code = await ScriptService.getHubScriptContentByPath({ path });
|
|
9
|
+
const schema = emptySchema();
|
|
10
|
+
await inferArgs('deno', code, schema);
|
|
11
|
+
return schema;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
const script = await ScriptService.getScriptByPath({
|
|
15
|
+
workspace: get(workspaceStore),
|
|
16
|
+
path: path ?? ''
|
|
17
|
+
});
|
|
18
|
+
return script.schema;
|
|
19
|
+
}
|
|
20
|
+
}
|
package/stores.d.ts
CHANGED
package/stores.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { browser } from '$app/env';
|
|
2
2
|
import { writable } from 'svelte/store';
|
|
3
|
-
import { getUserExt } from './
|
|
3
|
+
import { getUserExt } from './user';
|
|
4
4
|
let persistedWorkspace = browser && localStorage.getItem('workspace');
|
|
5
5
|
export const userStore = writable(undefined);
|
|
6
6
|
export const workspaceStore = writable(persistedWorkspace ? String(persistedWorkspace) : undefined);
|
package/user.d.ts
ADDED
package/user.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { get } from 'svelte/store';
|
|
2
|
+
import { UserService } from './gen/index.js';
|
|
3
|
+
import { superadmin } from './stores.js';
|
|
4
|
+
export async function refreshSuperadmin() {
|
|
5
|
+
if (get(superadmin) == undefined) {
|
|
6
|
+
UserService.globalWhoami().then((x) => {
|
|
7
|
+
if (x.super_admin) {
|
|
8
|
+
superadmin.set(x.email);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
superadmin.set(false);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export async function getUserExt(workspace) {
|
|
17
|
+
try {
|
|
18
|
+
const user = await UserService.whoami({ workspace });
|
|
19
|
+
return mapUserToUserExt(user);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function mapUserToUserExt(user) {
|
|
26
|
+
return {
|
|
27
|
+
...user,
|
|
28
|
+
groups: user.groups,
|
|
29
|
+
pgroups: user.groups.map((x) => `g/${x}`)
|
|
30
|
+
};
|
|
31
|
+
}
|
package/utils.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type UserExt } from './stores';
|
|
1
|
+
import type { UserExt } from './stores.js';
|
|
3
2
|
export declare function isToday(someDate: Date): boolean;
|
|
4
3
|
export declare function daysAgo(someDate: Date): number;
|
|
5
4
|
export declare function secondsAgo(date: Date): number;
|
|
@@ -8,12 +7,9 @@ export declare function displayDate(dateString: string | undefined): string;
|
|
|
8
7
|
export declare function getToday(): Date;
|
|
9
8
|
export declare function sendUserToast(message: string, error?: boolean): void;
|
|
10
9
|
export declare function truncateHash(hash: string): string;
|
|
11
|
-
export declare function getUserExt(workspace: string): Promise<UserExt | undefined>;
|
|
12
10
|
export declare function sleep(ms: number): Promise<void>;
|
|
13
11
|
export declare function validatePassword(password: string): boolean;
|
|
14
|
-
export declare function refreshSuperadmin(): Promise<void>;
|
|
15
12
|
export declare function clickOutside(node: any): any;
|
|
16
|
-
export declare function loadSchema(path: string): Promise<any>;
|
|
17
13
|
export declare type DropdownType = 'action' | 'delete';
|
|
18
14
|
export interface DropdownItem {
|
|
19
15
|
displayName: string;
|
|
@@ -55,4 +51,3 @@ export declare function groupBy<T>(scripts: T[], toGroup: (t: T) => string, dflt
|
|
|
55
51
|
export declare function truncate(s: string, n: number, suffix?: string): string;
|
|
56
52
|
export declare function truncateRev(s: string, n: number, prefix?: string): string;
|
|
57
53
|
export declare function isString(value: any): boolean;
|
|
58
|
-
export declare function mapUserToUserExt(user: User): UserExt;
|
package/utils.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { get } from 'svelte/store';
|
|
4
|
-
import { ScriptService, UserService } from './gen/index.js';
|
|
5
|
-
import { inferArgs } from './infer';
|
|
6
|
-
import { superadmin, workspaceStore } from './stores';
|
|
1
|
+
import pkg from '@zerodevx/svelte-toast';
|
|
2
|
+
const { toast } = pkg;
|
|
7
3
|
export function isToday(someDate) {
|
|
8
4
|
const today = new Date();
|
|
9
5
|
return (someDate.getDate() == today.getDate() &&
|
|
@@ -63,15 +59,6 @@ export function truncateHash(hash) {
|
|
|
63
59
|
return hash;
|
|
64
60
|
}
|
|
65
61
|
}
|
|
66
|
-
export async function getUserExt(workspace) {
|
|
67
|
-
try {
|
|
68
|
-
const user = await UserService.whoami({ workspace });
|
|
69
|
-
return mapUserToUserExt(user);
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
return undefined;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
62
|
export function sleep(ms) {
|
|
76
63
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
77
64
|
}
|
|
@@ -79,18 +66,6 @@ export function validatePassword(password) {
|
|
|
79
66
|
const re = /^(?=.*[\d])(?=.*[!@#$%^&*])[\w!@#$%^&*]{8,30}$/;
|
|
80
67
|
return re.test(password);
|
|
81
68
|
}
|
|
82
|
-
export async function refreshSuperadmin() {
|
|
83
|
-
if (get(superadmin) == undefined) {
|
|
84
|
-
UserService.globalWhoami().then((x) => {
|
|
85
|
-
if (x.super_admin) {
|
|
86
|
-
superadmin.set(x.email);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
superadmin.set(false);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
69
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
95
70
|
export function clickOutside(node) {
|
|
96
71
|
const handleClick = (event) => {
|
|
@@ -105,21 +80,6 @@ export function clickOutside(node) {
|
|
|
105
80
|
}
|
|
106
81
|
};
|
|
107
82
|
}
|
|
108
|
-
export async function loadSchema(path) {
|
|
109
|
-
if (path.startsWith('hub/')) {
|
|
110
|
-
const code = await ScriptService.getHubScriptContentByPath({ path });
|
|
111
|
-
const schema = emptySchema();
|
|
112
|
-
await inferArgs('deno', code, schema);
|
|
113
|
-
return schema;
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
const script = await ScriptService.getScriptByPath({
|
|
117
|
-
workspace: get(workspaceStore),
|
|
118
|
-
path: path ?? ''
|
|
119
|
-
});
|
|
120
|
-
return script.schema;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
83
|
export function emptySchema() {
|
|
124
84
|
return {
|
|
125
85
|
$schema: 'https://json-schema.org/draft/2020-12/schema',
|
|
@@ -232,10 +192,3 @@ export function truncateRev(s, n, prefix = '...') {
|
|
|
232
192
|
export function isString(value) {
|
|
233
193
|
return typeof value === 'string' || value instanceof String;
|
|
234
194
|
}
|
|
235
|
-
export function mapUserToUserExt(user) {
|
|
236
|
-
return {
|
|
237
|
-
...user,
|
|
238
|
-
groups: user.groups,
|
|
239
|
-
pgroups: user.groups.map((x) => `g/${x}`)
|
|
240
|
-
};
|
|
241
|
-
}
|