@windmill-labs/shared-utils 1.0.1 → 1.0.3

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 (68) hide show
  1. package/assets/tokens/colorTokensConfig.d.ts +2 -0
  2. package/base.d.ts +1 -0
  3. package/cloud.d.ts +1 -0
  4. package/common.d.ts +108 -0
  5. package/components/apps/components/display/dbtable/queries/count.d.ts +5 -0
  6. package/components/apps/components/display/dbtable/queries/delete.d.ts +5 -0
  7. package/components/apps/components/display/dbtable/queries/insert.d.ts +5 -0
  8. package/components/apps/components/display/dbtable/queries/select.d.ts +11 -0
  9. package/components/apps/components/display/dbtable/queries/update.d.ts +11 -0
  10. package/components/apps/components/display/dbtable/utils.d.ts +84 -0
  11. package/components/apps/editor/appPolicy.d.ts +3 -0
  12. package/components/apps/editor/appUtilsCore.d.ts +7 -0
  13. package/components/apps/editor/appUtilsS3.d.ts +22 -0
  14. package/components/apps/editor/commonAppUtils.d.ts +10 -0
  15. package/components/apps/editor/component/components.d.ts +5045 -0
  16. package/components/apps/editor/component/default-codes.d.ts +3 -0
  17. package/components/apps/editor/component/index.d.ts +3 -0
  18. package/components/apps/editor/component/sets.d.ts +7 -0
  19. package/components/apps/editor/componentsPanel/componentDefaultProps.d.ts +3 -0
  20. package/components/apps/gridUtils.d.ts +14 -0
  21. package/components/apps/inputType.d.ts +176 -0
  22. package/components/apps/rx.d.ts +29 -0
  23. package/components/apps/sharedTypes.d.ts +19 -0
  24. package/components/apps/types.d.ts +273 -0
  25. package/components/common/alert/model.d.ts +2 -0
  26. package/components/common/badge/model.d.ts +8 -0
  27. package/components/common/button/model.d.ts +45 -0
  28. package/components/common/fileInput/model.d.ts +1 -0
  29. package/components/common/index.d.ts +24 -0
  30. package/components/common/skeleton/model.d.ts +21 -0
  31. package/components/dbTypes.d.ts +11 -0
  32. package/components/diff_drawer.d.ts +26 -0
  33. package/components/ducklake.d.ts +1 -0
  34. package/components/flows/scheduleUtils.d.ts +7 -0
  35. package/components/random_positive_adjetive.d.ts +1 -0
  36. package/components/raw_apps/utils.d.ts +15 -0
  37. package/components/triggers/email/utils.d.ts +4 -0
  38. package/components/triggers/gcp/utils.d.ts +2 -0
  39. package/components/triggers/http/utils.d.ts +11 -0
  40. package/components/triggers/kafka/utils.d.ts +2 -0
  41. package/components/triggers/mqtt/utils.d.ts +2 -0
  42. package/components/triggers/nats/utils.d.ts +2 -0
  43. package/components/triggers/postgres/utils.d.ts +8 -0
  44. package/components/triggers/sqs/utils.d.ts +2 -0
  45. package/components/triggers/triggers.svelte.d.ts +32 -0
  46. package/components/triggers/utils.d.ts +81 -0
  47. package/components/triggers/websocket/utils.d.ts +2 -0
  48. package/components/triggers.d.ts +20 -0
  49. package/gen/core/ApiError.d.ts +10 -0
  50. package/gen/core/ApiRequestOptions.d.ts +13 -0
  51. package/gen/core/ApiResult.d.ts +7 -0
  52. package/gen/core/CancelablePromise.d.ts +26 -0
  53. package/gen/core/OpenAPI.d.ts +27 -0
  54. package/gen/core/request.d.ts +29 -0
  55. package/gen/index.d.ts +6 -0
  56. package/gen/schemas.gen.d.ts +6192 -0
  57. package/gen/services.gen.d.ts +5735 -0
  58. package/gen/types.gen.d.ts +20116 -0
  59. package/history.svelte.d.ts +9 -0
  60. package/hub.d.ts +48 -0
  61. package/lib.d.ts +3 -0
  62. package/lib.es.js +70 -3
  63. package/package.json +1 -1
  64. package/schema.d.ts +3 -0
  65. package/stores.d.ts +96 -0
  66. package/svelte5Utils.svelte.d.ts +49 -0
  67. package/toast.d.ts +8 -0
  68. package/utils.d.ts +250 -0
@@ -0,0 +1,9 @@
1
+ import { type Writable } from 'svelte/store';
2
+ export type History<T> = Writable<{
3
+ history: T[];
4
+ index: number;
5
+ }>;
6
+ export declare function initHistory<T>(initial: T): History<T>;
7
+ export declare function undo<T>(history: History<T> | undefined, now: T): T;
8
+ export declare function redo<T>(history: History<T> | undefined): T;
9
+ export declare function push<T>(history: History<T> | undefined, value: T, noSetIndex?: boolean): void;
package/hub.d.ts ADDED
@@ -0,0 +1,48 @@
1
+ import type { Schema } from './common';
2
+ import { type Flow, type Script } from './gen';
3
+ export declare const DEFAULT_HUB_BASE_URL = "https://hub.windmill.dev";
4
+ export declare const PRIVATE_HUB_MIN_VERSION = 10000000;
5
+ export declare function scriptToHubUrl(content: string, summary: string, description: string, kind: Script['kind'], language: Script['language'], schema: Schema | any, lock: string | undefined, hubBaseUrl: string): URL;
6
+ export declare const HubScript: {
7
+ readonly SIGNATURE_TEMPLATE: string;
8
+ };
9
+ export declare const HubFlow: {
10
+ readonly SIGNATURE_TEMPLATE: "67";
11
+ };
12
+ export declare function replaceScriptPlaceholderWithItsValues(id: string, content: string): string;
13
+ export declare function loadHubFlows(): Promise<{
14
+ id: number;
15
+ flow_id: number;
16
+ summary: string;
17
+ apps: Array<(string)>;
18
+ approved: boolean;
19
+ votes: number;
20
+ }[] | undefined>;
21
+ export declare function loadHubApps(): Promise<{
22
+ id: number;
23
+ app_id: number;
24
+ summary: string;
25
+ apps: Array<(string)>;
26
+ approved: boolean;
27
+ votes: number;
28
+ }[] | undefined>;
29
+ export declare function flowToHubUrl(flow: Flow, hubBaseUrl: string): URL;
30
+ export declare function appToHubUrl(staticApp: any, hubBaseUrl: string): URL;
31
+ type HubPaths = {
32
+ gitSync: string;
33
+ gitSyncTest: string;
34
+ gitInitRepo: string;
35
+ slackErrorHandler: string;
36
+ slackRecoveryHandler: string;
37
+ slackSuccessHandler: string;
38
+ slackReport: string;
39
+ discordReport: string;
40
+ smtpReport: string;
41
+ teamsErrorHandler: string;
42
+ teamsRecoveryHandler: string;
43
+ teamsSuccessHandler: string;
44
+ emailErrorHandler: string;
45
+ cloneRepoToS3forGitRepoViewer: string;
46
+ };
47
+ export declare const hubPaths: HubPaths;
48
+ export {};
package/lib.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { updatePolicy } from './components/apps/editor/appPolicy';
2
+ export { genWmillTs } from './components/raw_apps/utils';
3
+ export declare function capitalize(word: string): string;
package/lib.es.js CHANGED
@@ -1232,7 +1232,7 @@ function computeS3ImageViewerPolicy(c) {
1232
1232
  function collectStaticFields(c) {
1233
1233
  return Object.fromEntries(Object.entries(c ?? {}).filter(([c, L]) => L.type == "static").map(([c, L]) => [c, L.value]));
1234
1234
  }
1235
- var import_build = /* @__PURE__ */ __toESM(require_build());
1235
+ var import_build = /* @__PURE__ */ __toESM(require_build(), 1);
1236
1236
  async function updatePolicy(c, L) {
1237
1237
  let R = allItems(c.grid, c.subgrids), z = await Promise.all(R.flatMap((L) => {
1238
1238
  let R = L.data, z = [{
@@ -1314,7 +1314,7 @@ async function processRunnable(c, L, R, z) {
1314
1314
  let B = collectStaticFields(R), V = collectOneOfFields(R, z), H = Object.entries(R).map(([c, L]) => L.allowUserResources ? c : void 0).filter(Boolean);
1315
1315
  if (L?.type == "runnableByName") {
1316
1316
  let R = await hash(L.inlineScript?.content);
1317
- return console.log("hex", R, c), [`${c}:rawscript/${R}`, {
1317
+ return console.debug("hex", R, c), [`${c}:rawscript/${R}`, {
1318
1318
  static_inputs: B,
1319
1319
  one_of_inputs: V,
1320
1320
  allow_user_resources: H
@@ -1334,4 +1334,71 @@ async function hash(c) {
1334
1334
  return L.update(c ?? ""), Array.from(await L.digest()).map((c) => c.toString(16).padStart(2, "0")).join("");
1335
1335
  }
1336
1336
  }
1337
- export { updatePolicy };
1337
+ function schemaToTsType(c) {
1338
+ let L = c.properties, R = c.required;
1339
+ return !c || !L ? "any" : `{ ${Object.keys(L).map((c) => {
1340
+ let z = L[c], B = `${c}${R?.includes(c) ? "" : "?"}`, V = "any";
1341
+ return z.type === "string" ? V = "string" : z.type === "number" || z.type === "integer" ? V = "number" : z.type === "boolean" ? V = "boolean" : z.type === "array" ? (V = z.items?.type ?? "any", V === "integer" && (V = "number"), V = `${V}[]`) : z.type === "object" && z.properties && (V = schemaToTsType(z)), `${B}: ${V}`;
1342
+ }).join("; ")} }`;
1343
+ }
1344
+ function removeStaticFields(c, L) {
1345
+ let R = Object.keys(L).filter((c) => L[c].type == "static");
1346
+ return {
1347
+ ...c,
1348
+ properties: { ...Object.fromEntries(Object.entries(c.properties ?? {}).filter(([c]) => !R.includes(c))) }
1349
+ };
1350
+ }
1351
+ function hiddenRunnableToTsType(c) {
1352
+ return c?.type == "runnableByName" ? c?.inlineScript?.schema ? schemaToTsType(removeStaticFields(c?.inlineScript?.schema, c?.fields ?? {})) : "{}" : c?.type == "runnableByPath" ? schemaToTsType(removeStaticFields(c?.schema, c?.fields ?? {})) : "{}";
1353
+ }
1354
+ function genWmillTs(c) {
1355
+ return `// THIS FILE IS READ-ONLY
1356
+ // AND GENERATED AUTOMATICALLY FROM YOUR RUNNABLES
1357
+
1358
+ ${Object.entries(c).map(([c, L]) => `export type RunBg${capitalize(c)} = ${hiddenRunnableToTsType(L)}\n`).join("\n")}
1359
+
1360
+ export const runBg = {
1361
+ ${Object.keys(c).map((c) => ` ${c}: null as unknown as (data: RunBg${capitalize(c)}) => Promise<any>`).join(",\n")}
1362
+ }
1363
+
1364
+ export const runBgAsync = {
1365
+ ${Object.keys(c).map((c) => ` ${c}: null as unknown as (data: RunBg${capitalize(c)}) => Promise<string>`).join(",\n")}
1366
+ }
1367
+
1368
+
1369
+ export type Job = {
1370
+ type: 'QueuedJob' | 'CompletedJob'
1371
+ id: string
1372
+ created_at: number
1373
+ started_at: number | undefined
1374
+ duration_ms: number
1375
+ success: boolean
1376
+ args: any
1377
+ result: any
1378
+ }
1379
+
1380
+ /**
1381
+ * Execute a job and wait for it to complete and return the completed job
1382
+ * @param id
1383
+ */
1384
+ // @ts-ignore
1385
+ export function waitJob(id: string): Promise<Job> {
1386
+ // implementation passed when bundling/deploying
1387
+ return null as unknown as Promise<Job>
1388
+ }
1389
+
1390
+ /**
1391
+ * Get a job by id and return immediately with the current state of the job
1392
+ * @param id
1393
+ */
1394
+ // @ts-ignore
1395
+ export function getJob(id: string): Promise<Job> {
1396
+ // implementation passed when bundling/deploying
1397
+ return null as unknown as Promise<Job>
1398
+ }
1399
+ `;
1400
+ }
1401
+ function capitalize(c) {
1402
+ return c ? c.charAt(0).toUpperCase() + c.slice(1) : "";
1403
+ }
1404
+ export { capitalize, genWmillTs, updatePolicy };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windmill-labs/shared-utils",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./lib.es.js",
package/schema.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import type { Schema, SchemaProperty } from './common';
2
+ export declare function schemaToTsType(schema: Schema | SchemaProperty): string;
3
+ export declare function schemaToObject(schema: Schema, args: Record<string, any>): Object;
package/stores.d.ts ADDED
@@ -0,0 +1,96 @@
1
+ import { type Readable } from 'svelte/store';
2
+ import type { IntrospectionQuery } from 'graphql';
3
+ import { type OperatorSettings, type TokenResponse, type UserWorkspaceList, type WorkspaceDefaultScripts } from './gen';
4
+ import { type StateStore } from './utils';
5
+ export interface UserExt {
6
+ email: string;
7
+ name?: string;
8
+ username: string;
9
+ is_admin: boolean;
10
+ is_super_admin: boolean;
11
+ operator: boolean;
12
+ created_at: string;
13
+ groups: string[];
14
+ pgroups: string[];
15
+ folders: string[];
16
+ folders_owners: string[];
17
+ }
18
+ export interface UserWorkspace {
19
+ id: string;
20
+ name: string;
21
+ username: string;
22
+ color?: string;
23
+ operator_settings?: OperatorSettings;
24
+ parent_workspace_id?: string | null;
25
+ disabled: boolean;
26
+ }
27
+ export declare function getWorkspaceFromStorage(): string | undefined;
28
+ export declare function clearWorkspaceFromStorage(): void;
29
+ export declare const tutorialsToDo: import("svelte/store").Writable<number[]>;
30
+ export declare const globalEmailInvite: import("svelte/store").Writable<string>;
31
+ export declare const awarenessStore: import("svelte/store").Writable<Record<string, string>>;
32
+ export declare const enterpriseLicense: import("svelte/store").Writable<string | undefined>;
33
+ export declare const whitelabelNameStore: Readable<string | undefined>;
34
+ export declare const workerTags: import("svelte/store").Writable<string[] | undefined>;
35
+ export declare const usageStore: import("svelte/store").Writable<number>;
36
+ export declare const workspaceUsageStore: import("svelte/store").Writable<number>;
37
+ export declare const initialArgsStore: import("svelte/store").Writable<any>;
38
+ export declare const oauthStore: import("svelte/store").Writable<TokenResponse | undefined>;
39
+ export declare const userStore: import("svelte/store").Writable<UserExt | undefined>;
40
+ export declare const workspaceStore: import("svelte/store").Writable<string | undefined>;
41
+ export declare const defaultScripts: import("svelte/store").Writable<WorkspaceDefaultScripts | undefined>;
42
+ export declare const dbClockDrift: import("svelte/store").Writable<number | undefined>;
43
+ export declare const isPremiumStore: import("svelte/store").Writable<boolean>;
44
+ export declare const starStore: import("svelte/store").Writable<number>;
45
+ export declare const usersWorkspaceStore: import("svelte/store").Writable<UserWorkspaceList | undefined>;
46
+ export declare const superadmin: import("svelte/store").Writable<string | false | undefined>;
47
+ export declare const devopsRole: import("svelte/store").Writable<string | false | undefined>;
48
+ export declare const lspTokenStore: import("svelte/store").Writable<string | undefined>;
49
+ export declare const hubBaseUrlStore: import("svelte/store").Writable<string>;
50
+ export declare const userWorkspaces: Readable<Array<UserWorkspace>>;
51
+ export declare const codeCompletionLoading: import("svelte/store").Writable<boolean>;
52
+ export declare const metadataCompletionEnabled: import("svelte/store").Writable<boolean>;
53
+ export declare const stepInputCompletionEnabled: import("svelte/store").Writable<boolean>;
54
+ export declare const FORMAT_ON_SAVE_SETTING_NAME = "formatOnSave";
55
+ export declare const VIM_MODE_SETTING_NAME = "vimMode";
56
+ export declare const RELATIVE_LINE_NUMBERS_SETTING_NAME = "relativeLineNumbers";
57
+ export declare const CODE_COMPLETION_SETTING_NAME = "codeCompletionSessionEnabled";
58
+ export declare const COPILOT_SESSION_MODEL_SETTING_NAME = "copilotSessionModel";
59
+ export declare const COPILOT_SESSION_PROVIDER_SETTING_NAME = "copilotSessionProvider";
60
+ export declare const formatOnSave: import("svelte/store").Writable<boolean>;
61
+ export declare const vimMode: import("svelte/store").Writable<boolean>;
62
+ export declare const relativeLineNumbers: import("svelte/store").Writable<boolean>;
63
+ export declare const codeCompletionSessionEnabled: import("svelte/store").Writable<boolean>;
64
+ export declare const usedTriggerKinds: import("svelte/store").Writable<string[]>;
65
+ type SQLBaseSchema = {
66
+ [schemaKey: string]: {
67
+ [tableKey: string]: {
68
+ [columnKey: string]: {
69
+ type: string;
70
+ default: string;
71
+ required: boolean;
72
+ };
73
+ };
74
+ };
75
+ };
76
+ export declare const SQLSchemaLanguages: readonly ["mysql", "bigquery", "postgresql", "snowflake", "mssql", "oracledb"];
77
+ export interface SQLSchema {
78
+ lang: (typeof SQLSchemaLanguages)[number] | 'ducklake';
79
+ schema: SQLBaseSchema;
80
+ publicOnly: boolean | undefined;
81
+ stringified: string;
82
+ }
83
+ export interface GraphqlSchema {
84
+ lang: 'graphql';
85
+ schema: IntrospectionQuery;
86
+ stringified: string;
87
+ }
88
+ export type DBSchema = SQLSchema | GraphqlSchema;
89
+ export type DBSchemas = Partial<Record<string, DBSchema>>;
90
+ export declare const dbSchemas: import("svelte/store").Writable<Partial<Record<string, DBSchema>>>;
91
+ export declare const instanceSettingsSelectedTab: import("svelte/store").Writable<string>;
92
+ export declare const isCriticalAlertsUIOpen: import("svelte/store").Writable<boolean>;
93
+ export declare const workspaceColor: Readable<string | null | undefined>;
94
+ export declare const isCurrentlyInTutorial: StateStore<boolean>;
95
+ export declare function getFlatTableNamesFromSchema(dbSchema: DBSchema | undefined): string[];
96
+ export {};
@@ -0,0 +1,49 @@
1
+ import type { StateStore } from './utils';
2
+ export declare function withProps<Component, Props>(component: Component, props: Props): {
3
+ component: Component;
4
+ props: Props;
5
+ };
6
+ export declare function createState<T>(initialValue: T): T;
7
+ export declare function stateSnapshot<T>(state: T): $state.Snapshot<T>;
8
+ export declare function refreshStateStore<T>(store: StateStore<T>): void;
9
+ export type UsePromiseResult<T> = ({
10
+ status: 'loading';
11
+ value?: undefined;
12
+ error?: undefined;
13
+ } | {
14
+ status: 'error';
15
+ error: any;
16
+ value?: undefined;
17
+ } | {
18
+ status: 'ok';
19
+ value: T;
20
+ error?: undefined;
21
+ } | {
22
+ status: 'idle';
23
+ value?: undefined;
24
+ error?: undefined;
25
+ }) & {
26
+ refresh: () => void;
27
+ clear: () => void;
28
+ };
29
+ export type UsePromiseOptions = {
30
+ loadInit?: boolean;
31
+ clearValueOnRefresh?: boolean;
32
+ };
33
+ export declare function usePromise<T>(createPromise: () => Promise<T>, { loadInit, clearValueOnRefresh }?: UsePromiseOptions): UsePromiseResult<T>;
34
+ /**
35
+ * Generic change tracker class that monitors changes in state using deep equality comparison
36
+ * and provides a counter to trigger Svelte 5 reactivity. Similar to the pattern used in
37
+ * FlowGraphV2.svelte's onModulesChange2 function.
38
+ */
39
+ export declare class ChangeTracker<T> {
40
+ #private;
41
+ counter: number;
42
+ constructor(initialValue?: T);
43
+ /**
44
+ * Check if the value has changed and update the counter to trigger reactivity
45
+ * @param value - The current value to check for changes
46
+ * @returns true if the value changed, false otherwise
47
+ */
48
+ track(value: T): boolean;
49
+ }
package/toast.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import type { ComponentProps } from 'svelte';
2
+ import type { Button } from './components/common';
3
+ export type ToastAction = {
4
+ label: string;
5
+ callback: () => void;
6
+ buttonType?: ComponentProps<typeof Button>['variant'];
7
+ };
8
+ export declare function sendUserToast(message: string, error?: boolean, actions?: ToastAction[], errorMessage?: string | undefined, duration?: number): void;
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;