@windmill-labs/shared-utils 1.0.3 → 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.
@@ -1,3 +1,6 @@
1
+ import type { Runnable } from '../inputType';
1
2
  import type { App } from '../types';
3
+ import { type TriggerableV2 } from './commonAppUtils';
2
4
  import type { Policy } from '$lib/gen';
3
5
  export declare function updatePolicy(app: App, currentPolicy: Policy | undefined): Promise<Policy>;
6
+ export declare function processRunnable(id: string, runnable: Runnable, fields: Record<string, any>, app: App): Promise<[string, TriggerableV2] | undefined>;
@@ -1,7 +1,7 @@
1
1
  import type { IntRange } from '../../../../common';
2
2
  import type { NARROW_GRID_COLUMNS, WIDE_GRID_COLUMNS } from '../../gridUtils';
3
3
  import type { ChartType } from 'chart.js';
4
- import { BarChart4, Binary, FormInput, Inspect, List, Monitor, PieChart, Table2, TextCursorInput, Type, Lock, Calendar, ToggleLeft, GripHorizontal, Code2, SlidersHorizontal, PlusSquare, ListOrdered, BoxSelect, Smile, DollarSign, SeparatorHorizontal, SeparatorVertical, Paperclip, Image, SidebarClose, MapPin, FlipHorizontal, FlipVertical, FileText, AtSignIcon, Split, Download, PanelLeft, PanelTopInactive, Heading1, FileBarChart, Menu, Network, Database, UploadCloud, AlertTriangle, Clock, CalendarClock, AppWindow, PanelTop, RefreshCw, ListCollapse, GalleryThumbnails, Code } from 'lucide-svelte';
4
+ import { BarChart4, Binary, FormInput, Inspect, List, Monitor, PieChart, Table2, TextCursorInput, Type, Lock, Calendar, ToggleLeft, GripHorizontal, Code2, SlidersHorizontal, PlusSquare, ListOrdered, BoxSelect, Smile, DollarSign, SeparatorHorizontal, SeparatorVertical, Paperclip, Image, SidebarClose, MapPin, FlipHorizontal, FlipVertical, FileText, AtSignIcon, Split, Download, PanelLeft, PanelTopInactive, Heading1, FileBarChart, Menu, Network, Database, UploadCloud, AlertTriangle, Clock, CalendarClock, AppWindow, PanelTop, RefreshCw, ListCollapse, GalleryThumbnails, Code, MessageSquare } from 'lucide-svelte';
5
5
  import type { Aligned, BaseAppComponent, ComponentCustomCSS, GridItem, OneOfConfiguration, RichConfiguration, RichConfigurations, StaticRichConfigurations } from '../../types';
6
6
  import type { Size } from '../../svelte-grid/types';
7
7
  import type { AppInputSpec, EvalV2AppInput, InputConnectionEval, ResultAppInput, StaticAppInput, TemplateV2AppInput } from '../../inputType';
@@ -9,7 +9,7 @@ export type BaseComponent<T extends string> = {
9
9
  type: T;
10
10
  };
11
11
  export type RecomputeOthersSource = {
12
- recomputeIds: string[] | undefined;
12
+ recomputeIds?: string[] | undefined;
13
13
  };
14
14
  export type CustomComponentConfig = {
15
15
  name: string;
@@ -123,6 +123,7 @@ export type AggridInfiniteComponentEe = BaseComponent<'aggridinfinitecomponentee
123
123
  onChange?: string[] | undefined;
124
124
  };
125
125
  export type DisplayComponent = BaseComponent<'displaycomponent'>;
126
+ export type ChatComponent = BaseComponent<'chatcomponent'> & RecomputeOthersSource;
126
127
  export type JobIdDisplayComponent = BaseComponent<'jobiddisplaycomponent'>;
127
128
  export type LogComponent = BaseComponent<'logcomponent'>;
128
129
  export type JobIdLogComponent = BaseComponent<'jobidlogcomponent'>;
@@ -232,7 +233,7 @@ export type DateSelectComponent = BaseComponent<'dateselectcomponent'> & {
232
233
  onChange?: string[];
233
234
  };
234
235
  export type RecomputeAllComponent = BaseComponent<'recomputeallcomponent'>;
235
- export type TypedComponent = DBExplorerComponent | DisplayComponent | LogComponent | JobIdLogComponent | FlowStatusComponent | JobIdFlowStatusComponent | TextInputComponent | QuillComponent | CodeInputComponent | TextareaInputComponent | PasswordInputComponent | EmailInputComponent | DateInputComponent | NumberInputComponent | CurrencyComponent | SliderComponent | RangeComponent | BarChartComponent | TimeseriesComponent | HtmlComponent | CustomComponent | MarkdownComponent | TableComponent | TextComponent | ButtonComponent | PieChartComponent | ScatterChartComponent | SelectComponent | ResourceSelectComponent | MultiSelectComponent | CheckboxComponent | FormComponent | FormButtonComponent | VegaLiteComponent | PlotlyComponent | TabsComponent | ContainerComponent | ListComponent | IconComponent | HorizontalDividerComponent | VerticalDividerComponent | FileInputComponent | ImageComponent | AggridComponent | AggridComponentEe | DrawerComponent | MapComponent | VerticalSplitPanesComponent | HorizontalSplitPanesComponent | PdfComponent | ModalComponent | StepperComponent | Schemaformcomponent | SelectTabComponent | ConditionalWrapperComponent | SelectStepComponent | DownloadComponent | ChartJsComponent | CarouselListComponent | AccordionListComponent | PlotlyComponentV2 | ChartJsComponentV2 | StatisticCardComponent | MenuComponent | DecisionTreeComponent | S3FileInputComponent | AgChartsComponent | AgChartsComponentEe | AlertComponent | DateSliderComponent | TimeInputComponent | DateTimeInputComponent | AggridInfiniteComponent | AggridInfiniteComponentEe | MultiSelectComponentV2 | NavBarComponent | DateSelectComponent | JobIdDisplayComponent | RecomputeAllComponent | ResourceConnectComponent;
236
+ export type TypedComponent = DBExplorerComponent | DisplayComponent | ChatComponent | LogComponent | JobIdLogComponent | FlowStatusComponent | JobIdFlowStatusComponent | TextInputComponent | QuillComponent | CodeInputComponent | TextareaInputComponent | PasswordInputComponent | EmailInputComponent | DateInputComponent | NumberInputComponent | CurrencyComponent | SliderComponent | RangeComponent | BarChartComponent | TimeseriesComponent | HtmlComponent | CustomComponent | MarkdownComponent | TableComponent | TextComponent | ButtonComponent | PieChartComponent | ScatterChartComponent | SelectComponent | ResourceSelectComponent | MultiSelectComponent | CheckboxComponent | FormComponent | FormButtonComponent | VegaLiteComponent | PlotlyComponent | TabsComponent | ContainerComponent | ListComponent | IconComponent | HorizontalDividerComponent | VerticalDividerComponent | FileInputComponent | ImageComponent | AggridComponent | AggridComponentEe | DrawerComponent | MapComponent | VerticalSplitPanesComponent | HorizontalSplitPanesComponent | PdfComponent | ModalComponent | StepperComponent | Schemaformcomponent | SelectTabComponent | ConditionalWrapperComponent | SelectStepComponent | DownloadComponent | ChartJsComponent | CarouselListComponent | AccordionListComponent | PlotlyComponentV2 | ChartJsComponentV2 | StatisticCardComponent | MenuComponent | DecisionTreeComponent | S3FileInputComponent | AgChartsComponent | AgChartsComponentEe | AlertComponent | DateSliderComponent | TimeInputComponent | DateTimeInputComponent | AggridInfiniteComponent | AggridInfiniteComponentEe | MultiSelectComponentV2 | NavBarComponent | DateSelectComponent | JobIdDisplayComponent | RecomputeAllComponent | ResourceConnectComponent;
236
237
  export type AppComponent = BaseAppComponent & TypedComponent;
237
238
  export type AppComponentDimensions = `${IntRange<1, typeof NARROW_GRID_COLUMNS>}:${number}-${IntRange<1, typeof WIDE_GRID_COLUMNS>}:${number}`;
238
239
  export declare function getRecommendedDimensionsByComponent(componentType: AppComponent['type'], column: number): Size;
@@ -258,6 +259,21 @@ export type AppComponentConfig<T extends TypedComponent['type']> = {
258
259
  */
259
260
  initialData: InitialAppComponent;
260
261
  customCss: ComponentCustomCSS<T>;
262
+ /**
263
+ * Optional configuration for runnable inputs validation
264
+ */
265
+ runnableInputsInfo?: {
266
+ /**
267
+ * Function to validate runnable inputs and return a warning if needed
268
+ * @param fields - The fields object from componentInput.fields
269
+ * @returns Warning object with type, title, and message, or undefined if valid
270
+ */
271
+ validate?: (fields: Record<string, any>) => {
272
+ type: 'warning' | 'error' | 'info';
273
+ title: string;
274
+ message: string;
275
+ } | undefined;
276
+ };
261
277
  };
262
278
  export type PresetComponentConfig = {
263
279
  name: string;
@@ -343,6 +359,251 @@ export declare const components: {
343
359
  };
344
360
  };
345
361
  };
362
+ readonly chatcomponent: {
363
+ readonly name: "Chat";
364
+ readonly icon: typeof MessageSquare;
365
+ readonly documentationLink: "https://www.windmill.dev/docs/apps/app_configuration_settings/chat";
366
+ readonly dims: AppComponentDimensions;
367
+ readonly customCss: {
368
+ readonly container: {
369
+ readonly class: "";
370
+ readonly style: "";
371
+ };
372
+ readonly messagesContainer: {
373
+ readonly class: "";
374
+ readonly style: "";
375
+ };
376
+ readonly inputContainer: {
377
+ readonly class: "";
378
+ readonly style: "";
379
+ };
380
+ readonly userMessage: {
381
+ readonly class: "";
382
+ readonly style: "";
383
+ };
384
+ readonly assistantMessage: {
385
+ readonly class: "";
386
+ readonly style: "";
387
+ };
388
+ readonly input: {
389
+ readonly class: "";
390
+ readonly style: "";
391
+ };
392
+ readonly button: {
393
+ readonly class: "";
394
+ readonly style: "";
395
+ };
396
+ };
397
+ readonly runnableInputsInfo: {
398
+ readonly validate: (fields: any) => {
399
+ type: "warning";
400
+ title: string;
401
+ message: string;
402
+ } | undefined;
403
+ };
404
+ readonly initialData: {
405
+ readonly componentInput: {
406
+ readonly type: "runnable";
407
+ readonly fieldType: "any";
408
+ readonly fields: {};
409
+ readonly runnable: undefined;
410
+ };
411
+ readonly recomputeIds: true;
412
+ readonly configuration: {
413
+ readonly placeholder: {
414
+ readonly type: "static";
415
+ readonly fieldType: "text";
416
+ readonly value: "Type a message...";
417
+ };
418
+ readonly onSuccess: {
419
+ readonly type: "oneOf";
420
+ readonly tooltip: "Action to perform on success";
421
+ readonly selected: "none";
422
+ readonly labels: {
423
+ none: string;
424
+ errorOverlay: string;
425
+ gotoUrl: string;
426
+ setTab: string;
427
+ sendToast: string;
428
+ sendErrorToast: string;
429
+ open: string;
430
+ close: string;
431
+ openModal: string;
432
+ closeModal: string;
433
+ clearFiles: string;
434
+ };
435
+ readonly configuration: {
436
+ readonly none: {};
437
+ readonly gotoUrl: {
438
+ readonly url: {
439
+ readonly tooltip: "Go to the given url, absolute or relative";
440
+ readonly fieldType: "text";
441
+ readonly type: "static";
442
+ readonly value: "";
443
+ readonly placeholder: "/apps/get/foo";
444
+ readonly onDemandOnly: true;
445
+ };
446
+ readonly newTab: {
447
+ readonly tooltip: "Open the url in a new tab";
448
+ readonly fieldType: "boolean";
449
+ readonly type: "static";
450
+ readonly value: true;
451
+ };
452
+ };
453
+ readonly setTab: {
454
+ readonly setTab: {
455
+ readonly type: "static";
456
+ readonly value: Array<{
457
+ id: string;
458
+ index: number;
459
+ }>;
460
+ readonly fieldType: "array";
461
+ readonly subFieldType: "tab-select";
462
+ readonly tooltip: "Set the tabs id and index to go to on success";
463
+ readonly onDemandOnly: true;
464
+ };
465
+ };
466
+ readonly sendToast: {
467
+ readonly message: {
468
+ readonly tooltip: "The message of the toast to display";
469
+ readonly fieldType: "text";
470
+ readonly type: "static";
471
+ readonly value: "";
472
+ readonly placeholder: "Hello there";
473
+ readonly onDemandOnly: true;
474
+ };
475
+ };
476
+ readonly openModal: {
477
+ readonly modalId: {
478
+ readonly tooltip: "The id of the modal to open";
479
+ readonly fieldType: "text";
480
+ readonly type: "static";
481
+ readonly value: "";
482
+ readonly deprecated: true;
483
+ };
484
+ };
485
+ readonly closeModal: {
486
+ readonly modalId: {
487
+ readonly tooltip: "The id of the modal to close";
488
+ readonly fieldType: "text";
489
+ readonly type: "static";
490
+ readonly value: "";
491
+ readonly deprecated: true;
492
+ };
493
+ };
494
+ readonly open: {
495
+ readonly id: {
496
+ readonly tooltip: "The id of the modal or the drawer to open";
497
+ readonly fieldType: "text";
498
+ readonly type: "static";
499
+ readonly value: "";
500
+ };
501
+ };
502
+ readonly close: {
503
+ readonly id: {
504
+ readonly tooltip: "The id of the modal or the drawer to close";
505
+ readonly fieldType: "text";
506
+ readonly type: "static";
507
+ readonly value: "";
508
+ };
509
+ };
510
+ readonly clearFiles: {
511
+ readonly id: {
512
+ readonly tooltip: "The id of s3 file input to clear";
513
+ readonly fieldType: "text";
514
+ readonly type: "static";
515
+ readonly value: "";
516
+ };
517
+ };
518
+ };
519
+ };
520
+ readonly onError: {
521
+ readonly type: "oneOf";
522
+ readonly tooltip: "Action to perform on error";
523
+ readonly selected: "errorOverlay";
524
+ readonly labels: {
525
+ none: string;
526
+ errorOverlay: string;
527
+ gotoUrl: string;
528
+ setTab: string;
529
+ sendToast: string;
530
+ sendErrorToast: string;
531
+ open: string;
532
+ close: string;
533
+ openModal: string;
534
+ closeModal: string;
535
+ clearFiles: string;
536
+ };
537
+ readonly configuration: {
538
+ readonly errorOverlay: {};
539
+ readonly gotoUrl: {
540
+ readonly url: {
541
+ readonly tooltip: "Go to the given url, absolute or relative";
542
+ readonly fieldType: "text";
543
+ readonly type: "static";
544
+ readonly value: "";
545
+ readonly placeholder: "/apps/get/foo";
546
+ readonly onDemandOnly: true;
547
+ };
548
+ readonly newTab: {
549
+ readonly tooltip: "Open the url in a new tab";
550
+ readonly fieldType: "boolean";
551
+ readonly type: "static";
552
+ readonly value: true;
553
+ };
554
+ };
555
+ readonly setTab: {
556
+ readonly setTab: {
557
+ readonly type: "static";
558
+ readonly value: Array<{
559
+ id: string;
560
+ index: number;
561
+ }>;
562
+ readonly fieldType: "array";
563
+ readonly subFieldType: "tab-select";
564
+ readonly tooltip: "Set the tabs id and index to go to on error";
565
+ readonly onDemandOnly: true;
566
+ };
567
+ };
568
+ readonly sendErrorToast: {
569
+ readonly message: {
570
+ readonly tooltip: "The message of the toast to display";
571
+ readonly fieldType: "text";
572
+ readonly type: "static";
573
+ readonly value: "An error occurred";
574
+ readonly placeholder: "Hello there";
575
+ readonly onDemandOnly: true;
576
+ };
577
+ readonly appendError: {
578
+ readonly tooltip: "Append the error message to the toast";
579
+ readonly fieldType: "boolean";
580
+ readonly type: "static";
581
+ readonly value: true;
582
+ };
583
+ };
584
+ readonly open: {
585
+ readonly id: {
586
+ readonly tooltip: "The id of the modal or the drawer to open";
587
+ readonly fieldType: "text";
588
+ readonly type: "static";
589
+ readonly value: "";
590
+ readonly noVariablePicker: true;
591
+ };
592
+ };
593
+ readonly close: {
594
+ readonly id: {
595
+ readonly tooltip: "The id of the modal or the drawer to close";
596
+ readonly fieldType: "text";
597
+ readonly type: "static";
598
+ readonly value: "";
599
+ readonly noVariablePicker: true;
600
+ };
601
+ };
602
+ };
603
+ };
604
+ };
605
+ };
606
+ };
346
607
  readonly jobidlogcomponent: {
347
608
  readonly name: "Log by Job Id";
348
609
  readonly icon: typeof Monitor;
@@ -2840,7 +3101,6 @@ export declare const components: {
2840
3101
  readonly customCss: {
2841
3102
  readonly input: {
2842
3103
  readonly style: "";
2843
- readonly tooltip: "https://github.com/rob-balfre/svelte-select/blob/master/docs/theming_variables.md";
2844
3104
  readonly class: "";
2845
3105
  };
2846
3106
  };
@@ -212,6 +212,7 @@ export type AppViewerContext = {
212
212
  invalidate?: (key: string, error: string) => void;
213
213
  validateAll?: () => void;
214
214
  clearFiles?: () => void;
215
+ sendMessage?: (message: string) => void;
215
216
  showToast?: (message: string, error?: boolean) => void;
216
217
  recompute?: () => void;
217
218
  askNewResource?: () => void;
@@ -0,0 +1,10 @@
1
+ import type { Policy, ScriptLang } from '$lib/gen';
2
+ import type { InlineScript, RunnableWithFields } from '../apps/inputType';
3
+ export declare function updateRawAppPolicy(runnables: Record<string, Runnable>, currentPolicy: Policy | undefined): Promise<Policy>;
4
+ type RunnableWithInlineScript = RunnableWithFields & {
5
+ inlineScript?: InlineScript & {
6
+ language: ScriptLang;
7
+ };
8
+ };
9
+ export type Runnable = RunnableWithInlineScript | undefined;
10
+ export {};
@@ -1737,6 +1737,9 @@ export declare class FlowService {
1737
1737
  * @param data.withDeploymentMsg (default false)
1738
1738
  * include deployment message
1739
1739
  *
1740
+ * @param data.withoutDescription (default false)
1741
+ * If true, the description field will be omitted from the response.
1742
+ *
1740
1743
  * @returns unknown All flow
1741
1744
  * @throws ApiError
1742
1745
  */
@@ -2277,6 +2280,9 @@ export declare class ScriptService {
2277
2280
  * @param data.languages Filter to only include scripts written in the given languages.
2278
2281
  * Accepts multiple values as a comma-separated list.
2279
2282
  *
2283
+ * @param data.withoutDescription (default false)
2284
+ * If true, the description field will be omitted from the response.
2285
+ *
2280
2286
  * @returns Script All scripts
2281
2287
  * @throws ApiError
2282
2288
  */
@@ -4188,6 +4188,12 @@ export type ListFlowsData = {
4188
4188
  *
4189
4189
  */
4190
4190
  withDeploymentMsg?: boolean;
4191
+ /**
4192
+ * (default false)
4193
+ * If true, the description field will be omitted from the response.
4194
+ *
4195
+ */
4196
+ withoutDescription?: boolean;
4191
4197
  workspace: string;
4192
4198
  };
4193
4199
  export type ListFlowsResponse = Array<(Flow & {
@@ -4586,6 +4592,12 @@ export type ExecuteComponentData = {
4586
4592
  [key: string]: unknown;
4587
4593
  };
4588
4594
  force_viewer_allow_user_resources?: Array<(string)>;
4595
+ /**
4596
+ * Runnable query parameters
4597
+ */
4598
+ run_query_params?: {
4599
+ [key: string]: unknown;
4600
+ };
4589
4601
  };
4590
4602
  workspace: string;
4591
4603
  };
@@ -4792,6 +4804,12 @@ export type ListScriptsData = {
4792
4804
  *
4793
4805
  */
4794
4806
  withDeploymentMsg?: boolean;
4807
+ /**
4808
+ * (default false)
4809
+ * If true, the description field will be omitted from the response.
4810
+ *
4811
+ */
4812
+ withoutDescription?: boolean;
4795
4813
  workspace: string;
4796
4814
  };
4797
4815
  export type ListScriptsResponse = Array<Script>;
@@ -12233,6 +12251,12 @@ export type $OpenApiTs = {
12233
12251
  *
12234
12252
  */
12235
12253
  withDeploymentMsg?: boolean;
12254
+ /**
12255
+ * (default false)
12256
+ * If true, the description field will be omitted from the response.
12257
+ *
12258
+ */
12259
+ withoutDescription?: boolean;
12236
12260
  workspace: string;
12237
12261
  };
12238
12262
  res: {
@@ -13009,6 +13033,12 @@ export type $OpenApiTs = {
13009
13033
  [key: string]: unknown;
13010
13034
  };
13011
13035
  force_viewer_allow_user_resources?: Array<(string)>;
13036
+ /**
13037
+ * Runnable query parameters
13038
+ */
13039
+ run_query_params?: {
13040
+ [key: string]: unknown;
13041
+ };
13012
13042
  };
13013
13043
  workspace: string;
13014
13044
  };
@@ -13296,6 +13326,12 @@ export type $OpenApiTs = {
13296
13326
  *
13297
13327
  */
13298
13328
  withDeploymentMsg?: boolean;
13329
+ /**
13330
+ * (default false)
13331
+ * If true, the description field will be omitted from the response.
13332
+ *
13333
+ */
13334
+ withoutDescription?: boolean;
13299
13335
  workspace: string;
13300
13336
  };
13301
13337
  res: {
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
1
  export { updatePolicy } from './components/apps/editor/appPolicy';
2
2
  export { genWmillTs } from './components/raw_apps/utils';
3
+ export { updateRawAppPolicy } from './components/raw_apps/rawAppPolicy';
3
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,7 +1231,16 @@ 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
  }
1235
- var import_build = /* @__PURE__ */ __toESM(require_build(), 1);
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
+ }
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) => {
1238
1246
  let R = L.data, z = [{
@@ -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("");
@@ -1398,7 +1406,29 @@ export function getJob(id: string): Promise<Job> {
1398
1406
  }
1399
1407
  `;
1400
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
+ }
1401
1431
  function capitalize(c) {
1402
1432
  return c ? c.charAt(0).toUpperCase() + c.slice(1) : "";
1403
1433
  }
1404
- export { capitalize, genWmillTs, updatePolicy };
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.3",
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
+ }