@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.
Files changed (71) 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 +6 -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 +5305 -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 +274 -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/rawAppPolicy.d.ts +10 -0
  37. package/components/raw_apps/utils.d.ts +15 -0
  38. package/components/triggers/email/utils.d.ts +4 -0
  39. package/components/triggers/gcp/utils.d.ts +2 -0
  40. package/components/triggers/http/utils.d.ts +11 -0
  41. package/components/triggers/kafka/utils.d.ts +2 -0
  42. package/components/triggers/mqtt/utils.d.ts +2 -0
  43. package/components/triggers/nats/utils.d.ts +2 -0
  44. package/components/triggers/postgres/utils.d.ts +8 -0
  45. package/components/triggers/sqs/utils.d.ts +2 -0
  46. package/components/triggers/triggers.svelte.d.ts +32 -0
  47. package/components/triggers/utils.d.ts +81 -0
  48. package/components/triggers/websocket/utils.d.ts +2 -0
  49. package/components/triggers.d.ts +20 -0
  50. package/gen/core/ApiError.d.ts +10 -0
  51. package/gen/core/ApiRequestOptions.d.ts +13 -0
  52. package/gen/core/ApiResult.d.ts +7 -0
  53. package/gen/core/CancelablePromise.d.ts +26 -0
  54. package/gen/core/OpenAPI.d.ts +27 -0
  55. package/gen/core/request.d.ts +29 -0
  56. package/gen/index.d.ts +6 -0
  57. package/gen/schemas.gen.d.ts +6192 -0
  58. package/gen/services.gen.d.ts +5741 -0
  59. package/gen/types.gen.d.ts +20152 -0
  60. package/history.svelte.d.ts +9 -0
  61. package/hub.d.ts +48 -0
  62. package/jsr.json +6 -0
  63. package/lib.d.ts +4 -3
  64. package/lib.es.js +105 -8
  65. package/package.json +11 -11
  66. package/schema.d.ts +3 -0
  67. package/stores.d.ts +96 -0
  68. package/svelte5Utils.svelte.d.ts +49 -0
  69. package/toast.d.ts +8 -0
  70. package/utils.d.ts +250 -0
  71. package/appPolicy.d.ts +0 -3
@@ -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/jsr.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "@windmill-labs/shared-utils",
3
+ "version": "1.0.5",
4
+ "license": "MIT",
5
+ "exports": "./mod.ts"
6
+ }
package/lib.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- import { App } from '../types';
2
- import { Policy } from '../../../../../../src/lib/gen';
3
- export declare function updatePolicy(app: App, currentPolicy: Policy | undefined): Promise<Policy>;
1
+ export { updatePolicy } from './components/apps/editor/appPolicy';
2
+ export { genWmillTs } from './components/raw_apps/utils';
3
+ export { updateRawAppPolicy } from './components/raw_apps/rawAppPolicy';
4
+ export declare function capitalize(word: string): string;
package/lib.es.js CHANGED
@@ -592,8 +592,7 @@ var init_whatwgEncodingApi = __esmMin((() => {})), dist_es_exports = /* @__PURE_
592
592
  }
593
593
  })), require_build = /* @__PURE__ */ __commonJSMin(((c) => {
594
594
  Object.defineProperty(c, "__esModule", { value: !0 }), (init_tslib_es6(), __toCommonJS(tslib_es6_exports)).__exportStar(require_jsSha256(), c);
595
- }));
596
- require_build();
595
+ })), import_build$1 = /* @__PURE__ */ __toESM(require_build());
597
596
  function wrapDucklakeQuery(c, L) {
598
597
  let R = `ATTACH 'ducklake://${L}' AS dl;USE dl;\n`;
599
598
  return c.replace(/^(--.*\n)*/, (c) => c + R);
@@ -1232,6 +1231,15 @@ function computeS3ImageViewerPolicy(c) {
1232
1231
  function collectStaticFields(c) {
1233
1232
  return Object.fromEntries(Object.entries(c ?? {}).filter(([c, L]) => L.type == "static").map(([c, L]) => [c, L.value]));
1234
1233
  }
1234
+ async function hash(c) {
1235
+ try {
1236
+ let L = new TextEncoder().encode(c), R = await crypto.subtle.digest("SHA-256", L);
1237
+ return Array.from(new Uint8Array(R)).map((c) => c.toString(16).padStart(2, "0")).join("");
1238
+ } catch {
1239
+ let L = new import_build$1.Sha256();
1240
+ return L.update(c ?? ""), Array.from(await L.digest()).map((c) => c.toString(16).padStart(2, "0")).join("");
1241
+ }
1242
+ }
1235
1243
  var import_build = /* @__PURE__ */ __toESM(require_build());
1236
1244
  async function updatePolicy(c, L) {
1237
1245
  let R = allItems(c.grid, c.subgrids), z = await Promise.all(R.flatMap((L) => {
@@ -1286,9 +1294,9 @@ async function updatePolicy(c, L) {
1286
1294
  z.push(...c);
1287
1295
  }
1288
1296
  return z.filter((c) => c.input).map(async (L) => {
1289
- if (L.input?.type == "runnable") return await processRunnable(L.id, L.input.runnable, L.input.fields, c);
1297
+ if (L.input?.type == "runnable") return await processRunnable$1(L.id, L.input.runnable, L.input.fields, c);
1290
1298
  });
1291
- }).concat(Object.values(c.hiddenInlineScripts ?? {}).map(async (L, R) => await processRunnable("bg_" + R, L, L.fields, c)))), B = Object.fromEntries(z.filter(Boolean)), V = R.filter((c) => c.data.type === "s3fileinputcomponent").map((L) => {
1299
+ }).concat(Object.values(c.hiddenInlineScripts ?? {}).map(async (L, R) => await processRunnable$1("bg_" + R, L, L.fields, c)))), B = Object.fromEntries(z.filter(Boolean)), V = R.filter((c) => c.data.type === "s3fileinputcomponent").map((L) => {
1292
1300
  let R = L.data.configuration;
1293
1301
  return computeS3FileInputPolicy(R?.type?.configuration?.s3, c);
1294
1302
  }).filter(Boolean);
@@ -1310,10 +1318,10 @@ async function updatePolicy(c, L) {
1310
1318
  triggerables_v2: B
1311
1319
  };
1312
1320
  }
1313
- async function processRunnable(c, L, R, z) {
1321
+ async function processRunnable$1(c, L, R, z) {
1314
1322
  let B = collectStaticFields(R), V = collectOneOfFields(R, z), H = Object.entries(R).map(([c, L]) => L.allowUserResources ? c : void 0).filter(Boolean);
1315
1323
  if (L?.type == "runnableByName") {
1316
- let R = await hash(L.inlineScript?.content);
1324
+ let R = await hash$1(L.inlineScript?.content);
1317
1325
  return console.debug("hex", R, c), [`${c}:rawscript/${R}`, {
1318
1326
  static_inputs: B,
1319
1327
  one_of_inputs: V,
@@ -1325,7 +1333,7 @@ async function processRunnable(c, L, R, z) {
1325
1333
  allow_user_resources: H
1326
1334
  }];
1327
1335
  }
1328
- async function hash(c) {
1336
+ async function hash$1(c) {
1329
1337
  try {
1330
1338
  let L = new TextEncoder().encode(c), R = await crypto.subtle.digest("SHA-256", L);
1331
1339
  return Array.from(new Uint8Array(R)).map((c) => c.toString(16).padStart(2, "0")).join("");
@@ -1334,4 +1342,93 @@ async function hash(c) {
1334
1342
  return L.update(c ?? ""), Array.from(await L.digest()).map((c) => c.toString(16).padStart(2, "0")).join("");
1335
1343
  }
1336
1344
  }
1337
- export { updatePolicy };
1345
+ function schemaToTsType(c) {
1346
+ let L = c.properties, R = c.required;
1347
+ return !c || !L ? "any" : `{ ${Object.keys(L).map((c) => {
1348
+ let z = L[c], B = `${c}${R?.includes(c) ? "" : "?"}`, V = "any";
1349
+ 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}`;
1350
+ }).join("; ")} }`;
1351
+ }
1352
+ function removeStaticFields(c, L) {
1353
+ let R = Object.keys(L).filter((c) => L[c].type == "static");
1354
+ return {
1355
+ ...c,
1356
+ properties: { ...Object.fromEntries(Object.entries(c.properties ?? {}).filter(([c]) => !R.includes(c))) }
1357
+ };
1358
+ }
1359
+ function hiddenRunnableToTsType(c) {
1360
+ return c?.type == "runnableByName" ? c?.inlineScript?.schema ? schemaToTsType(removeStaticFields(c?.inlineScript?.schema, c?.fields ?? {})) : "{}" : c?.type == "runnableByPath" ? schemaToTsType(removeStaticFields(c?.schema, c?.fields ?? {})) : "{}";
1361
+ }
1362
+ function genWmillTs(c) {
1363
+ return `// THIS FILE IS READ-ONLY
1364
+ // AND GENERATED AUTOMATICALLY FROM YOUR RUNNABLES
1365
+
1366
+ ${Object.entries(c).map(([c, L]) => `export type RunBg${capitalize(c)} = ${hiddenRunnableToTsType(L)}\n`).join("\n")}
1367
+
1368
+ export const runBg = {
1369
+ ${Object.keys(c).map((c) => ` ${c}: null as unknown as (data: RunBg${capitalize(c)}) => Promise<any>`).join(",\n")}
1370
+ }
1371
+
1372
+ export const runBgAsync = {
1373
+ ${Object.keys(c).map((c) => ` ${c}: null as unknown as (data: RunBg${capitalize(c)}) => Promise<string>`).join(",\n")}
1374
+ }
1375
+
1376
+
1377
+ export type Job = {
1378
+ type: 'QueuedJob' | 'CompletedJob'
1379
+ id: string
1380
+ created_at: number
1381
+ started_at: number | undefined
1382
+ duration_ms: number
1383
+ success: boolean
1384
+ args: any
1385
+ result: any
1386
+ }
1387
+
1388
+ /**
1389
+ * Execute a job and wait for it to complete and return the completed job
1390
+ * @param id
1391
+ */
1392
+ // @ts-ignore
1393
+ export function waitJob(id: string): Promise<Job> {
1394
+ // implementation passed when bundling/deploying
1395
+ return null as unknown as Promise<Job>
1396
+ }
1397
+
1398
+ /**
1399
+ * Get a job by id and return immediately with the current state of the job
1400
+ * @param id
1401
+ */
1402
+ // @ts-ignore
1403
+ export function getJob(id: string): Promise<Job> {
1404
+ // implementation passed when bundling/deploying
1405
+ return null as unknown as Promise<Job>
1406
+ }
1407
+ `;
1408
+ }
1409
+ async function updateRawAppPolicy(c, L) {
1410
+ let R = Object.fromEntries(await Promise.all(Object.values(c).map(async (c) => await processRunnable(c?.name ?? "", c, c?.fields ?? {}))));
1411
+ return {
1412
+ ...L,
1413
+ triggerables_v2: R
1414
+ };
1415
+ }
1416
+ async function processRunnable(c, L, R) {
1417
+ let z = collectStaticFields(R), B = Object.entries(R).map(([c, L]) => L.allowUserResources ? c : void 0).filter(Boolean);
1418
+ if (L?.type == "runnableByName") {
1419
+ let R = await hash(L.inlineScript?.content);
1420
+ return console.log("hex", R, c), [`${c}:rawscript/${R}`, {
1421
+ static_inputs: z,
1422
+ one_of_inputs: {},
1423
+ allow_user_resources: B
1424
+ }];
1425
+ } else if (L?.type == "runnableByPath") return [`${c}:${L.runType === "hubscript" ? "script" : L.runType}/${L.path}`, {
1426
+ static_inputs: z,
1427
+ one_of_inputs: {},
1428
+ allow_user_resources: B
1429
+ }];
1430
+ }
1431
+ function capitalize(c) {
1432
+ return c ? c.charAt(0).toUpperCase() + c.slice(1) : "";
1433
+ }
1434
+ export { capitalize, genWmillTs, updatePolicy, updateRawAppPolicy };
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
- "name": "@windmill-labs/shared-utils",
3
- "version": "1.0.2",
4
- "type": "module",
5
- "private": false,
6
- "main": "./lib.es.js",
7
- "module": "./lib.es.js",
8
- "exports": {
9
- ".": "./lib.es.js"
10
- },
11
- "types": "./lib.d.ts"
12
- }
2
+ "name": "@windmill-labs/shared-utils",
3
+ "version": "1.0.5",
4
+ "type": "module",
5
+ "private": false,
6
+ "main": "./lib.es.js",
7
+ "module": "./lib.es.js",
8
+ "exports": {
9
+ ".": "./lib.es.js"
10
+ },
11
+ "types": "./lib.d.ts"
12
+ }
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;