@windmill-labs/shared-utils 1.0.2 → 1.0.5
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/assets/tokens/colorTokensConfig.d.ts +2 -0
- package/base.d.ts +1 -0
- package/cloud.d.ts +1 -0
- package/common.d.ts +108 -0
- package/components/apps/components/display/dbtable/queries/count.d.ts +5 -0
- package/components/apps/components/display/dbtable/queries/delete.d.ts +5 -0
- package/components/apps/components/display/dbtable/queries/insert.d.ts +5 -0
- package/components/apps/components/display/dbtable/queries/select.d.ts +11 -0
- package/components/apps/components/display/dbtable/queries/update.d.ts +11 -0
- package/components/apps/components/display/dbtable/utils.d.ts +84 -0
- package/components/apps/editor/appPolicy.d.ts +6 -0
- package/components/apps/editor/appUtilsCore.d.ts +7 -0
- package/components/apps/editor/appUtilsS3.d.ts +22 -0
- package/components/apps/editor/commonAppUtils.d.ts +10 -0
- package/components/apps/editor/component/components.d.ts +5305 -0
- package/components/apps/editor/component/default-codes.d.ts +3 -0
- package/components/apps/editor/component/index.d.ts +3 -0
- package/components/apps/editor/component/sets.d.ts +7 -0
- package/components/apps/editor/componentsPanel/componentDefaultProps.d.ts +3 -0
- package/components/apps/gridUtils.d.ts +14 -0
- package/components/apps/inputType.d.ts +176 -0
- package/components/apps/rx.d.ts +29 -0
- package/components/apps/sharedTypes.d.ts +19 -0
- package/components/apps/types.d.ts +274 -0
- package/components/common/alert/model.d.ts +2 -0
- package/components/common/badge/model.d.ts +8 -0
- package/components/common/button/model.d.ts +45 -0
- package/components/common/fileInput/model.d.ts +1 -0
- package/components/common/index.d.ts +24 -0
- package/components/common/skeleton/model.d.ts +21 -0
- package/components/dbTypes.d.ts +11 -0
- package/components/diff_drawer.d.ts +26 -0
- package/components/ducklake.d.ts +1 -0
- package/components/flows/scheduleUtils.d.ts +7 -0
- package/components/random_positive_adjetive.d.ts +1 -0
- package/components/raw_apps/rawAppPolicy.d.ts +10 -0
- package/components/raw_apps/utils.d.ts +15 -0
- package/components/triggers/email/utils.d.ts +4 -0
- package/components/triggers/gcp/utils.d.ts +2 -0
- package/components/triggers/http/utils.d.ts +11 -0
- package/components/triggers/kafka/utils.d.ts +2 -0
- package/components/triggers/mqtt/utils.d.ts +2 -0
- package/components/triggers/nats/utils.d.ts +2 -0
- package/components/triggers/postgres/utils.d.ts +8 -0
- package/components/triggers/sqs/utils.d.ts +2 -0
- package/components/triggers/triggers.svelte.d.ts +32 -0
- package/components/triggers/utils.d.ts +81 -0
- package/components/triggers/websocket/utils.d.ts +2 -0
- package/components/triggers.d.ts +20 -0
- package/gen/core/ApiError.d.ts +10 -0
- package/gen/core/ApiRequestOptions.d.ts +13 -0
- package/gen/core/ApiResult.d.ts +7 -0
- package/gen/core/CancelablePromise.d.ts +26 -0
- package/gen/core/OpenAPI.d.ts +27 -0
- package/gen/core/request.d.ts +29 -0
- package/gen/index.d.ts +6 -0
- package/gen/schemas.gen.d.ts +6192 -0
- package/gen/services.gen.d.ts +5741 -0
- package/gen/types.gen.d.ts +20152 -0
- package/history.svelte.d.ts +9 -0
- package/hub.d.ts +48 -0
- package/jsr.json +6 -0
- package/lib.d.ts +4 -3
- package/lib.es.js +105 -8
- package/package.json +11 -11
- package/schema.d.ts +3 -0
- package/stores.d.ts +96 -0
- package/svelte5Utils.svelte.d.ts +49 -0
- package/toast.d.ts +8 -0
- package/utils.d.ts +250 -0
- package/appPolicy.d.ts +0 -3
package/utils.d.ts
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { type UserExt } from './stores';
|
|
2
|
+
import { sendUserToast } from './toast';
|
|
3
|
+
import type { Job, RunnableKind, Script, ScriptLang, Retry } from './gen';
|
|
4
|
+
import type { EnumType, SchemaProperty } from './common';
|
|
5
|
+
import type { Schema } from './common';
|
|
6
|
+
export { sendUserToast };
|
|
7
|
+
import type { AnyMeltElement } from '@melt-ui/svelte';
|
|
8
|
+
import type { TriggerKind } from './components/triggers';
|
|
9
|
+
export type RunsSelectionMode = 'cancel' | 're-run';
|
|
10
|
+
export declare namespace OpenApi {
|
|
11
|
+
enum OpenApiVersion {
|
|
12
|
+
V2 = 0,
|
|
13
|
+
V3 = 1,
|
|
14
|
+
V3_1 = 2
|
|
15
|
+
}
|
|
16
|
+
function isV2(doc: OpenAPI.Document): doc is OpenAPIV2.Document;
|
|
17
|
+
function isV3(doc: OpenAPI.Document): doc is OpenAPIV3.Document;
|
|
18
|
+
function isV3_1(doc: OpenAPI.Document): doc is OpenAPIV3_1.Document;
|
|
19
|
+
function getOpenApiVersion(version: string): OpenApiVersion;
|
|
20
|
+
/**
|
|
21
|
+
* Parses and validates an OpenAPI specification provided as a string in either JSON or YAML format.
|
|
22
|
+
*
|
|
23
|
+
* @param api - A string containing a valid OpenAPI specification in JSON or YAML format.
|
|
24
|
+
* @returns A promise that resolves to a tuple:
|
|
25
|
+
* - The first element is the validated OpenAPI document.
|
|
26
|
+
* - The second element is the detected OpenAPI version (2, 3.0, or 3.1).
|
|
27
|
+
*
|
|
28
|
+
* @throws Will throw an error if the specification is invalid or cannot be parsed.
|
|
29
|
+
*/
|
|
30
|
+
function parse(api: string): Promise<[OpenAPI.Document, OpenApiVersion]>;
|
|
31
|
+
}
|
|
32
|
+
export declare function isJobCancelable(j: Job): boolean;
|
|
33
|
+
export declare function isJobReRunnable(j: Job): boolean;
|
|
34
|
+
export declare const WORKER_NAME_PREFIX = "wk";
|
|
35
|
+
export declare function isJobSelectable(selectionType: RunsSelectionMode): (j: Job) => boolean;
|
|
36
|
+
export declare function escapeHtml(unsafe: string): string;
|
|
37
|
+
export declare function validateUsername(username: string): string;
|
|
38
|
+
export declare function parseQueryParams(url: string | undefined): Record<string, string>;
|
|
39
|
+
export declare function displayDateOnly(dateString: string | Date | undefined): string;
|
|
40
|
+
export declare function retrieveCommonWorkerPrefix(workerName: string): string;
|
|
41
|
+
export declare function subtractDaysFromDateString(dateString: string | undefined, days: number): string | undefined;
|
|
42
|
+
export declare function displayDate(dateString: string | Date | undefined, displaySecond?: boolean, displayDate?: boolean): string;
|
|
43
|
+
export declare function displayTime(dateString: string | Date | undefined): string;
|
|
44
|
+
export declare function displaySize(sizeInBytes: number | undefined): string | undefined;
|
|
45
|
+
export declare function msToSec(ms: number | undefined, maximumFractionDigits?: number): string;
|
|
46
|
+
export declare function removeTriggerKindIfUnused(length: number, triggerKind: TriggerKind, usedTriggerKinds: string[]): string[];
|
|
47
|
+
export declare function msToReadableTime(ms: number | undefined, maximumFractionDigits?: number): string;
|
|
48
|
+
export declare function msToReadableTimeShort(ms: number | undefined, maximumFractionDigits?: number): string;
|
|
49
|
+
export declare function getToday(): Date;
|
|
50
|
+
export declare function truncateHash(hash: string): string;
|
|
51
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
52
|
+
export declare function addIfNotExists<T>(e: T, arr: Array<T> | undefined): Array<T>;
|
|
53
|
+
export declare function validatePassword(password: string): boolean;
|
|
54
|
+
interface ClickOutsideOptions {
|
|
55
|
+
capture?: boolean;
|
|
56
|
+
exclude?: (() => Promise<HTMLElement[]>) | HTMLElement[] | undefined;
|
|
57
|
+
stopPropagation?: boolean;
|
|
58
|
+
customEventName?: string;
|
|
59
|
+
eventToListenName?: 'click' | 'pointerdown';
|
|
60
|
+
onClickOutside?: (event: MouseEvent) => void;
|
|
61
|
+
}
|
|
62
|
+
export declare function clickOutside(node: Node, options?: ClickOutsideOptions | boolean): {
|
|
63
|
+
destroy(): void;
|
|
64
|
+
update(newOptions: ClickOutsideOptions | boolean): void;
|
|
65
|
+
};
|
|
66
|
+
export declare function pointerDownOutside(node: Node, options?: ClickOutsideOptions): {
|
|
67
|
+
destroy(): void;
|
|
68
|
+
update(newOptions: ClickOutsideOptions): void;
|
|
69
|
+
};
|
|
70
|
+
export interface DropdownItem {
|
|
71
|
+
displayName: string;
|
|
72
|
+
eventName?: string;
|
|
73
|
+
action?: ((event?: MouseEvent) => Promise<void>) | ((event?: MouseEvent) => void);
|
|
74
|
+
href?: string;
|
|
75
|
+
separatorTop?: boolean;
|
|
76
|
+
separatorBottom?: boolean;
|
|
77
|
+
type?: 'action' | 'delete';
|
|
78
|
+
disabled?: boolean;
|
|
79
|
+
icon?: any | undefined;
|
|
80
|
+
}
|
|
81
|
+
export declare const DELETE: "delete";
|
|
82
|
+
export declare function emptySchema(): Schema;
|
|
83
|
+
export declare function simpleSchema(): Schema;
|
|
84
|
+
export declare function removeItemAll<T>(arr: T[], value: T): T[];
|
|
85
|
+
export declare function emptyString(str: string | undefined | null): boolean;
|
|
86
|
+
export declare function emptyStringTrimmed(str: string | undefined | null): boolean;
|
|
87
|
+
export declare function defaultIfEmptyString(str: string | undefined, dflt: string): string;
|
|
88
|
+
export declare function removeKeysWithEmptyValues(obj: any): any;
|
|
89
|
+
export declare function allTrue(dict: {
|
|
90
|
+
[id: string]: boolean;
|
|
91
|
+
}): boolean;
|
|
92
|
+
export declare function elapsedSinceSecs(date: string): number;
|
|
93
|
+
export declare function pathIsEmpty(path: string): boolean;
|
|
94
|
+
export declare function encodeState(state: any): string;
|
|
95
|
+
export declare function decodeState(query: string): any;
|
|
96
|
+
export declare function itemsExists<T>(arr: T[] | undefined, item: T): boolean;
|
|
97
|
+
export declare function groupBy<K, V>(items: V[], toGroup: (t: V) => K, toSort: (t: V) => string, dflts?: K[]): [K, V[]][];
|
|
98
|
+
export declare function removeMarkdown(text: string): string;
|
|
99
|
+
export declare function truncate(s: string, n: number, suffix?: string): string;
|
|
100
|
+
export declare function truncateRev(s: string, n: number, prefix?: string): string;
|
|
101
|
+
export declare function isString(value: any): value is string | String;
|
|
102
|
+
export type InputCat = 'string' | 'email' | 'number' | 'boolean' | 'list' | 'resource-object' | 'enum' | 'date' | 'base64' | 'resource-string' | 'object' | 'sql' | 'yaml' | 'currency' | 'oneOf' | 'dynamic' | 'json-schema' | 'ai-provider';
|
|
103
|
+
export declare namespace DynamicInput {
|
|
104
|
+
type HelperScript = {
|
|
105
|
+
source: 'deployed';
|
|
106
|
+
path: string;
|
|
107
|
+
runnable_kind: RunnableKind;
|
|
108
|
+
} | {
|
|
109
|
+
source: 'inline';
|
|
110
|
+
code: string;
|
|
111
|
+
lang: ScriptLang;
|
|
112
|
+
};
|
|
113
|
+
const generatePythonFnTemplate: (functionName: string) => string;
|
|
114
|
+
const generateJsFnTemplate: (functionName: string) => string;
|
|
115
|
+
const generateDefaultTemplateFn: (functionName: string, lang: ScriptLang) => string;
|
|
116
|
+
const getGenerateTemplateFn: (lang: ScriptLang) => (functionName: string) => string;
|
|
117
|
+
const isDynInputFormat: (format?: string) => boolean;
|
|
118
|
+
}
|
|
119
|
+
export declare function setInputCat(type: string | undefined, format: string | undefined, itemsType: string | undefined, enum_: any, contentEncoding: string | undefined): InputCat;
|
|
120
|
+
export declare function formatCron(inp: string): string;
|
|
121
|
+
export declare function scriptLangArrayToCommaList(languages: ScriptLang[]): string;
|
|
122
|
+
export declare function cronV1toV2(inp: string): string;
|
|
123
|
+
export declare function classNames(...classes: Array<string | undefined>): string;
|
|
124
|
+
export declare function download(filename: string, fileContent: string, mimeType?: string): void;
|
|
125
|
+
export declare function copyToClipboard(value?: string, sendToast?: boolean): Promise<boolean>;
|
|
126
|
+
export declare function pluralize(quantity: number, word: string, customPlural?: string): string;
|
|
127
|
+
export declare function addDeterminant(word: string): string;
|
|
128
|
+
export { capitalize } from './sharedUtils';
|
|
129
|
+
export declare function addWhitespaceBeforeCapitals(word?: string): string;
|
|
130
|
+
export declare function isObject(obj: any): obj is Record<string, any>;
|
|
131
|
+
export declare function debounce(func: (...args: any[]) => any, wait: number): {
|
|
132
|
+
debounced: (...args: any[]) => void;
|
|
133
|
+
clearDebounce: () => void;
|
|
134
|
+
};
|
|
135
|
+
export declare function throttle<T>(func: (...args: any[]) => T, wait: number): (...args: any[]) => void;
|
|
136
|
+
export declare function isMac(): boolean;
|
|
137
|
+
export declare function getModifierKey(): string;
|
|
138
|
+
export declare function isValidHexColor(color: string): boolean;
|
|
139
|
+
export declare function sortObject<T>(o: T & object): T;
|
|
140
|
+
export declare function sortArray<T>(array: T[], compareFn?: (a: T, b: T) => number): T[];
|
|
141
|
+
export declare function generateRandomString(len?: number): string;
|
|
142
|
+
export declare function deepMergeWithPriority<T>(target: T, source: T): T;
|
|
143
|
+
export declare function canWrite(path: string, extra_perms: Record<string, boolean>, user?: UserExt): boolean;
|
|
144
|
+
export declare function isOwner(path: string, user: UserExt | undefined, workspace: string | undefined): boolean;
|
|
145
|
+
export declare function isObviousOwner(path: string, user?: UserExt): boolean;
|
|
146
|
+
export declare function extractCustomProperties(styleStr: string): string;
|
|
147
|
+
export declare function computeSharableHash(args: any): string;
|
|
148
|
+
export declare function toCamel(s: string): string;
|
|
149
|
+
export declare function cleanExpr(expr: string | undefined): string;
|
|
150
|
+
export declare function isCodeInjection(expr: string | undefined): boolean;
|
|
151
|
+
export declare function urlParamsToObject(params: URLSearchParams): Record<string, string>;
|
|
152
|
+
export declare function tryEvery({ tryCode, timeoutCode, interval, timeout }: {
|
|
153
|
+
tryCode: () => Promise<any>;
|
|
154
|
+
timeoutCode: () => void;
|
|
155
|
+
interval: number;
|
|
156
|
+
timeout: number;
|
|
157
|
+
}): Promise<void>;
|
|
158
|
+
export declare function roughSizeOfObject(object: object | string | any): number;
|
|
159
|
+
export type Value = {
|
|
160
|
+
language?: Script['language'];
|
|
161
|
+
content?: string;
|
|
162
|
+
path?: string;
|
|
163
|
+
draft_only?: boolean;
|
|
164
|
+
value?: any;
|
|
165
|
+
draft?: Value;
|
|
166
|
+
[key: string]: any;
|
|
167
|
+
};
|
|
168
|
+
export declare function replaceFalseWithUndefined(obj: any): any;
|
|
169
|
+
export declare function cleanValueProperties(obj: Value): any;
|
|
170
|
+
export declare function orderedJsonStringify(obj: any, space?: string | number): string;
|
|
171
|
+
export declare function orderedYamlStringify(obj: any): string;
|
|
172
|
+
export declare function computeShow(argName: string, expr: string | undefined, args: any): any;
|
|
173
|
+
export declare function urlize(input: string, formatter: 'html' | 'md'): string;
|
|
174
|
+
export declare function storeLocalSetting(name: string, value: string | undefined): void;
|
|
175
|
+
export declare function getLocalSetting(name: string): string | null | undefined;
|
|
176
|
+
export declare function computeKind(enum_: EnumType, contentEncoding: 'base64' | 'binary' | undefined, pattern: string | undefined, format: string | undefined): 'base64' | 'none' | 'pattern' | 'enum' | 'resource' | 'format' | 'date-time';
|
|
177
|
+
export declare function shouldDisplayPlaceholder(type: string | undefined, format: string | undefined, enum_: EnumType, contentEncoding: 'base64' | 'binary' | undefined, pattern: string | undefined, extra: Record<string, any> | undefined): boolean;
|
|
178
|
+
export declare function getSchemaFromProperties(properties: {
|
|
179
|
+
[name: string]: SchemaProperty;
|
|
180
|
+
}): Schema;
|
|
181
|
+
export declare function validateFileExtension(ext: string): boolean;
|
|
182
|
+
export declare function isFlowPreview(job_kind: Job['job_kind'] | undefined): job_kind is "flowpreview" | "flownode";
|
|
183
|
+
export declare function isNotFlow(job_kind: Job['job_kind'] | undefined): job_kind is "script" | "aiagent" | "identity" | "preview" | "dependencies" | "flowdependencies" | "appdependencies" | "script_hub" | "deploymentcallback" | "flowscript" | "appscript" | undefined;
|
|
184
|
+
export declare function isScriptPreview(job_kind: Job['job_kind'] | undefined): job_kind is "preview" | "flowscript" | "appscript";
|
|
185
|
+
export declare function conditionalMelt(node: HTMLElement, meltItem: AnyMeltElement | undefined): void | import("svelte/action").ActionReturn<undefined, Record<never, any>>;
|
|
186
|
+
export type Item = {
|
|
187
|
+
displayName: string;
|
|
188
|
+
action?: (e: MouseEvent) => void;
|
|
189
|
+
icon?: any;
|
|
190
|
+
iconColor?: string;
|
|
191
|
+
href?: string;
|
|
192
|
+
hrefTarget?: '_blank' | '_self' | '_parent' | '_top';
|
|
193
|
+
disabled?: boolean;
|
|
194
|
+
type?: 'action' | 'delete';
|
|
195
|
+
hide?: boolean | undefined;
|
|
196
|
+
extra?: Snippet;
|
|
197
|
+
id?: string;
|
|
198
|
+
};
|
|
199
|
+
export declare function isObjectTooBig(obj: any): boolean;
|
|
200
|
+
export declare function localeConcatAnd(items: string[]): string;
|
|
201
|
+
export declare function formatDate(dateString: string | undefined): string;
|
|
202
|
+
export declare function formatDateShort(dateString: string | undefined): string;
|
|
203
|
+
export declare function toJsonStr(result: any): string;
|
|
204
|
+
export declare function getOS(): "Windows" | "macOS" | "iOS" | "Android" | "Linux" | "Unknown OS";
|
|
205
|
+
import { type ClassValue } from 'clsx';
|
|
206
|
+
import type { Component, Snippet } from 'svelte';
|
|
207
|
+
import { OpenAPIV2, type OpenAPI, type OpenAPIV3, type OpenAPIV3_1 } from 'openapi-types';
|
|
208
|
+
import type { IPosition } from 'monaco-editor';
|
|
209
|
+
export declare function cn(...inputs: ClassValue[]): string;
|
|
210
|
+
export type StateStore<T> = {
|
|
211
|
+
val: T;
|
|
212
|
+
};
|
|
213
|
+
export type ReadFieldsRecursivelyOptions = {
|
|
214
|
+
excludeField?: string[];
|
|
215
|
+
};
|
|
216
|
+
export declare function readFieldsRecursively(obj: any, options?: ReadFieldsRecursivelyOptions): void;
|
|
217
|
+
export declare function reorder<T>(items: T[], oldIndex: number, newIndex: number): T[];
|
|
218
|
+
export declare function scroll_into_view_if_needed_polyfill(elem: Element, centerIfNeeded?: boolean): IntersectionObserver;
|
|
219
|
+
export declare function clone<T>(t: T): T;
|
|
220
|
+
export declare const editorPositionMap: Record<string, IPosition>;
|
|
221
|
+
export type S3Uri = `s3://${string}/${string}`;
|
|
222
|
+
export type S3Object = S3Uri | {
|
|
223
|
+
s3: string;
|
|
224
|
+
storage?: string;
|
|
225
|
+
};
|
|
226
|
+
export declare function parseS3Object(s3Object: S3Object): {
|
|
227
|
+
s3: string;
|
|
228
|
+
storage?: string;
|
|
229
|
+
};
|
|
230
|
+
export declare function formatS3Object(s3Object: S3Object): S3Uri;
|
|
231
|
+
export declare function isS3Uri(uri: string): uri is S3Uri;
|
|
232
|
+
export declare function uniqueBy<T>(array: T[], key: (t: T) => any): T[];
|
|
233
|
+
export declare function pruneNullishArray<T>(array: (T | null | undefined)[]): T[];
|
|
234
|
+
export declare function assert(msg: string, condition: boolean, value?: any): void;
|
|
235
|
+
export declare function createCache<Keys extends Record<string, any>, T, InitialKeys extends Keys = Keys>(compute: (keys: Keys) => T, params?: {
|
|
236
|
+
maxSize?: number;
|
|
237
|
+
initial?: InitialKeys;
|
|
238
|
+
invalidateMs?: number;
|
|
239
|
+
}): (keys: Keys) => T;
|
|
240
|
+
export declare function wait(ms: number): Promise<unknown>;
|
|
241
|
+
export declare function validateRetryConfig(retry: Retry | undefined): string | null;
|
|
242
|
+
export type CssColor = keyof (typeof tokensFile)['tokens']['light'];
|
|
243
|
+
import tokensFile from './assets/tokens/tokens.json';
|
|
244
|
+
export declare function getCssColor(color: CssColor, { alpha, format }: {
|
|
245
|
+
alpha?: number;
|
|
246
|
+
format?: 'css-var' | 'hex-dark' | 'hex-light';
|
|
247
|
+
}): string;
|
|
248
|
+
export type IconType = Component<{
|
|
249
|
+
size?: number;
|
|
250
|
+
}> | typeof import('lucide-svelte').Dot;
|
package/appPolicy.d.ts
DELETED