@kizenapps/engine 1.5.2-065350b → 1.6.0

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 (53) hide show
  1. package/README.md +4 -0
  2. package/dist/{ThirdPartyScript-DVgjFFyS.d.ts → ThirdPartyScript-CvOXQBiO.d.ts} +1 -0
  3. package/dist/{automation-CRWtgS0X.d.ts → automation-ez9zQ2sv.d.ts} +10 -4
  4. package/dist/{chunk-N2EE7JZP.js → chunk-3GJVC5NN.js} +23 -8
  5. package/dist/chunk-3GJVC5NN.js.map +1 -0
  6. package/dist/{chunk-MLEJMH2T.js → chunk-3RZHGFVE.js} +11 -34
  7. package/dist/chunk-3RZHGFVE.js.map +1 -0
  8. package/dist/{chunk-QNBRMIZJ.js → chunk-4GEJIHMC.js} +4 -4
  9. package/dist/{chunk-QNBRMIZJ.js.map → chunk-4GEJIHMC.js.map} +1 -1
  10. package/dist/{chunk-UCQWTSOW.js → chunk-5FZ4UC6V.js} +17 -5
  11. package/dist/chunk-5FZ4UC6V.js.map +1 -0
  12. package/dist/{chunk-Q227EJ6P.js → chunk-7TTCHSPL.js} +3 -3
  13. package/dist/{chunk-Q227EJ6P.js.map → chunk-7TTCHSPL.js.map} +1 -1
  14. package/dist/{chunk-KWHKLJVW.js → chunk-BJBB73QA.js} +5 -4
  15. package/dist/chunk-BJBB73QA.js.map +1 -0
  16. package/dist/{chunk-N6FXIBTB.js → chunk-CNSOU3UB.js} +3 -3
  17. package/dist/{chunk-N6FXIBTB.js.map → chunk-CNSOU3UB.js.map} +1 -1
  18. package/dist/{chunk-SBGLMAOP.js → chunk-OMIBO27E.js} +3 -3
  19. package/dist/{chunk-SBGLMAOP.js.map → chunk-OMIBO27E.js.map} +1 -1
  20. package/dist/{chunk-S66EWYBT.js → chunk-UXYECVO2.js} +3 -3
  21. package/dist/{chunk-S66EWYBT.js.map → chunk-UXYECVO2.js.map} +1 -1
  22. package/dist/communication.d.ts +2 -2
  23. package/dist/communication.js +2 -2
  24. package/dist/contexts/base.d.ts +2 -1
  25. package/dist/contexts/base.js +4 -4
  26. package/dist/contexts/floatingFrame.d.ts +1 -1
  27. package/dist/contexts/floatingFrame.js +5 -5
  28. package/dist/contexts/recordDetail.d.ts +1 -1
  29. package/dist/contexts/recordDetail.js +5 -5
  30. package/dist/{generic-FaDES8rA.d.ts → generic-CyEFBI-k.d.ts} +1 -1
  31. package/dist/index.d.ts +6 -6
  32. package/dist/index.js +4 -4
  33. package/dist/react.d.ts +4 -4
  34. package/dist/react.js +26 -10
  35. package/dist/react.js.map +1 -1
  36. package/dist/translation.json +1 -0
  37. package/dist/types.d.ts +5 -5
  38. package/dist/util.d.ts +3 -3
  39. package/dist/util.js +6 -6
  40. package/dist/{values-Ds-qJB6k.d.ts → values-BbMHmBFn.d.ts} +2 -2
  41. package/dist/workers/calendarSource.worker.js +7 -7
  42. package/dist/workers/calendarSource.worker.js.map +1 -1
  43. package/dist/workers/floatingFrame.worker.js +8 -8
  44. package/dist/workers/floatingFrame.worker.js.map +1 -1
  45. package/dist/workers/generic.worker.js +7 -7
  46. package/dist/workers/generic.worker.js.map +1 -1
  47. package/dist/workers/recordDetail.worker.js +8 -8
  48. package/dist/workers/recordDetail.worker.js.map +1 -1
  49. package/package.json +1 -1
  50. package/dist/chunk-KWHKLJVW.js.map +0 -1
  51. package/dist/chunk-MLEJMH2T.js.map +0 -1
  52. package/dist/chunk-N2EE7JZP.js.map +0 -1
  53. package/dist/chunk-UCQWTSOW.js.map +0 -1
package/README.md CHANGED
@@ -197,3 +197,7 @@ const ScriptButton = ({ pluginScript }: { pluginScript: string }) => {
197
197
  #### Worker Runner
198
198
 
199
199
  Some worker calls are coordinated using `@tanstack/react-query`. If your consumer app also uses react-query, the app engine will use your existing query provider. If you aren't already using react-query, the engine provider will be wrapped in its own query context and no additional action is needed.
200
+
201
+ ### Script Return Values
202
+
203
+ Scripts can return values from the worker thread. Awaiting the execute function returned from a plugin runner script will yield the value that the worker thread returned.
@@ -403,6 +403,7 @@ declare const ACTIONS: {
403
403
  SHOW_VIEW_IN_MODAL_REQUEST: string;
404
404
  CLOSE_MODAL_REQUEST: string;
405
405
  CONSOLE_LOG: string;
406
+ RUN_EVENT_SCRIPT: string;
406
407
  };
407
408
  declare enum INDICATOR_TYPE {
408
409
  NONE = "none",
@@ -1,4 +1,4 @@
1
- import { b2 as ACTIONS, U as UnknownJSON, b3 as ALLOWED_INTEGRATIONS, J as ConsoleLogLevel, M as ModalConfig, S as StateChangePayload, k as ShowToastOptions, h as InternalSessionData, l as ShowViewInModalOptions, aT as SetInternalSessionDataFn, aB as OnShowModalFn, az as OnShowCreateRecordModalFn, aA as OnShowCreateRelatedRecordModalFn, ax as OnCloseModalFn, ay as OnNetworkErrorFn, W as WorkerContextArgs, a7 as EmployeeConfig } from './ThirdPartyScript-DVgjFFyS.js';
1
+ import { b2 as ACTIONS, U as UnknownJSON, b3 as ALLOWED_INTEGRATIONS, J as ConsoleLogLevel, M as ModalConfig, S as StateChangePayload, k as ShowToastOptions, h as InternalSessionData, l as ShowViewInModalOptions, aT as SetInternalSessionDataFn, aB as OnShowModalFn, az as OnShowCreateRecordModalFn, aA as OnShowCreateRelatedRecordModalFn, ax as OnCloseModalFn, ay as OnNetworkErrorFn, W as WorkerContextArgs, a7 as EmployeeConfig } from './ThirdPartyScript-CvOXQBiO.js';
2
2
  import { H as HideConfig, S as ShowConfig } from './floatingFrames-BzaoL7cq.js';
3
3
 
4
4
  interface CommonPluginDefinition {
@@ -57,6 +57,7 @@ interface RunScriptOptions {
57
57
  getPendingCacheCount?: GetPendingCacheCountFn | undefined;
58
58
  invalidateCache?: InvalidateCacheFn | undefined;
59
59
  onConsoleLog?: OnConsoleLogFn;
60
+ onRunEventScript?: OnRunEventScriptFn;
60
61
  }
61
62
  type RequestableQueryMethods = 'get' | 'post' | 'patch' | 'delete';
62
63
  type OnNetworkRequestFn = (method: RequestableQueryMethods, url: string, payload?: UnknownJSON, options?: UnknownJSON) => Promise<{
@@ -188,8 +189,13 @@ interface ConsoleLogEvent extends BaseEvent {
188
189
  level: ConsoleLogLevel;
189
190
  args: unknown[];
190
191
  }
192
+ interface RunEventScriptEvent extends BaseEvent {
193
+ scriptName: string;
194
+ args?: UnknownJSON;
195
+ }
191
196
  type OnConsoleLogFn = (level: ConsoleLogLevel, args: unknown[]) => void;
192
- type MessageEventData = QueryRequestEvent | UIOutputEvent | IframeOutputEvent | PostFormDataRequestEvent | UploadFileRequestEvent | SetStateEvent | DoneEvent | ErrorEvent | OpenWindowEvent | CommunicateEvent | HideEvent | ShowEvent | CopyToClipboardEvent | OpenCreateRecordModalRequestEvent | OpenCreateRelatedRecordModalRequestEvent | ShowToastEvent | RefreshTimelineEvent | RefreshEntityEvent | UpdateSessionDataEvent | InstallThirdPartyScriptRequestEvent | PromptRequestEvent | DynamicPromptRequestEvent | ShowViewInModalRequestEvent | CloseModalRequestEvent | AuthorizeEvent | ConsoleLogEvent;
197
+ type OnRunEventScriptFn = (scriptName: string, args?: UnknownJSON) => void;
198
+ type MessageEventData = QueryRequestEvent | UIOutputEvent | IframeOutputEvent | PostFormDataRequestEvent | UploadFileRequestEvent | SetStateEvent | DoneEvent | ErrorEvent | OpenWindowEvent | CommunicateEvent | HideEvent | ShowEvent | CopyToClipboardEvent | OpenCreateRecordModalRequestEvent | OpenCreateRelatedRecordModalRequestEvent | ShowToastEvent | RefreshTimelineEvent | RefreshEntityEvent | UpdateSessionDataEvent | InstallThirdPartyScriptRequestEvent | PromptRequestEvent | DynamicPromptRequestEvent | ShowViewInModalRequestEvent | CloseModalRequestEvent | AuthorizeEvent | ConsoleLogEvent | RunEventScriptEvent;
193
199
  type InvalidateCacheFn = (category: 'timeline' | 'entity', entityId: string) => void;
194
200
  type GetPendingCacheCountFn = (search: string) => number;
195
201
  interface KizenFile extends File {
@@ -285,7 +291,7 @@ interface FloatingFrameConfig extends CommonPluginDefinition {
285
291
  employee_config?: EmployeeConfig<FloatingFrameEmployeeConfig>;
286
292
  args?: Record<string, UnknownJSON>;
287
293
  }
288
- type ExecuteFloatingFrameScript = (script: string, args?: Record<string, unknown>) => void;
294
+ type ExecuteFloatingFrameScript = (script: string, args?: Record<string, unknown>) => Promise<unknown>;
289
295
 
290
296
  interface RoutablePageConfig extends CommonPluginDefinition {
291
297
  api_name: string;
@@ -350,4 +356,4 @@ interface AutomationStepConfig<T = unknown> {
350
356
  plugin_api_name?: string;
351
357
  }
352
358
 
353
- export type { ShowEvent as $, AutomationStepConfig as A, BaseEvent as B, CommonExecutionPlugin as C, DataAdornmentConfig as D, ErrorEvent as E, FloatingFrameConfig as F, GetPendingCacheCountFn as G, HideEvent as H, IframeOutputEvent as I, OpenCreateRecordModalRequestEvent as J, KizenFile as K, OpenCreateRelatedRecordModalRequestEvent as L, MessageEventData as M, OpenWindowEvent as N, OnClearToastsFn as O, PerformKizenFileUploadFn as P, PostFormDataRequestEvent as Q, RoutablePageConfig as R, PromptRequestEvent as S, ToolbarItemConfig as T, QueryRequestEvent as U, RecipientConfig as V, RefreshEntityEvent as W, RefreshTimelineEvent as X, RequestableQueryMethods as Y, SchemaValidation as Z, SetStateEvent as _, CommonPluginDefinition as a, ShowToastEvent as a0, ShowViewInModalRequestEvent as a1, TerminatorContent as a2, Terminators as a3, UIOutputEvent as a4, UpdateSessionDataEvent as a5, UploadFilePayload as a6, UploadFileRequestEvent as a7, WindowPosition as a8, RouteScriptConfig as b, CalendarSourceConfig as c, RunScriptOptions as d, AuthorizeEvent as e, CalendarDefinition as f, CalendarScriptReturnData as g, CalendarSourceMap as h, CalendarSources as i, CloseModalRequestEvent as j, CommunicateEvent as k, ConsoleLogEvent as l, CopyToClipboardEvent as m, CreateFileIdFn as n, DoneEvent as o, DynamicPromptRequestEvent as p, ExecuteCalendarSourceScript as q, ExecuteFloatingFrameScript as r, FloatingFrameEmployeeConfig as s, FrameQuadrant as t, InstallThirdPartyScriptRequestEvent as u, InvalidateCacheFn as v, MinimizedConfig as w, OnConsoleLogFn as x, OnNetworkRequestFn as y, OnShowToastFn as z };
359
+ export type { SchemaValidation as $, AutomationStepConfig as A, BaseEvent as B, CommonExecutionPlugin as C, DataAdornmentConfig as D, ErrorEvent as E, FloatingFrameConfig as F, GetPendingCacheCountFn as G, HideEvent as H, IframeOutputEvent as I, OnShowToastFn as J, KizenFile as K, OpenCreateRecordModalRequestEvent as L, MessageEventData as M, OpenCreateRelatedRecordModalRequestEvent as N, OnClearToastsFn as O, OpenWindowEvent as P, PerformKizenFileUploadFn as Q, RoutablePageConfig as R, PostFormDataRequestEvent as S, ToolbarItemConfig as T, PromptRequestEvent as U, QueryRequestEvent as V, RecipientConfig as W, RefreshEntityEvent as X, RefreshTimelineEvent as Y, RequestableQueryMethods as Z, RunEventScriptEvent as _, CommonPluginDefinition as a, SetStateEvent as a0, ShowEvent as a1, ShowToastEvent as a2, ShowViewInModalRequestEvent as a3, TerminatorContent as a4, Terminators as a5, UIOutputEvent as a6, UpdateSessionDataEvent as a7, UploadFilePayload as a8, UploadFileRequestEvent as a9, WindowPosition as aa, RouteScriptConfig as b, CalendarSourceConfig as c, RunScriptOptions as d, AuthorizeEvent as e, CalendarDefinition as f, CalendarScriptReturnData as g, CalendarSourceMap as h, CalendarSources as i, CloseModalRequestEvent as j, CommunicateEvent as k, ConsoleLogEvent as l, CopyToClipboardEvent as m, CreateFileIdFn as n, DoneEvent as o, DynamicPromptRequestEvent as p, ExecuteCalendarSourceScript as q, ExecuteFloatingFrameScript as r, FloatingFrameEmployeeConfig as s, FrameQuadrant as t, InstallThirdPartyScriptRequestEvent as u, InvalidateCacheFn as v, MinimizedConfig as w, OnConsoleLogFn as x, OnNetworkRequestFn as y, OnRunEventScriptFn as z };
@@ -1,6 +1,6 @@
1
- import { getPartialLocation, generateUUIDV4 } from './chunk-MLEJMH2T.js';
2
- import { getAllNestedInputsFromConfig, deserializeConsoleArg, KizenRequestError } from './chunk-SBGLMAOP.js';
3
- import { IFRAME_PREFIX, ACTIONS, RESPONSES, COMMUNICATIONS, thirdPartyGlobalNames, getScriptIntegrationType, thirdPartySetupScripts, thirdPartyReadyPredicates } from './chunk-KWHKLJVW.js';
1
+ import { getPartialLocation, generateUUIDV4 } from './chunk-3RZHGFVE.js';
2
+ import { getAllNestedInputsFromConfig, deserializeConsoleArg, KizenRequestError } from './chunk-OMIBO27E.js';
3
+ import { IFRAME_PREFIX, ACTIONS, RESPONSES, COMMUNICATIONS, thirdPartyGlobalNames, getScriptIntegrationType, thirdPartySetupScripts, thirdPartyReadyPredicates } from './chunk-BJBB73QA.js';
4
4
  import { __commonJS, __toESM } from './chunk-5WRI5ZAA.js';
5
5
  import DOMPurify from 'dompurify';
6
6
 
@@ -1829,6 +1829,8 @@ var WorkerManager = class {
1829
1829
  pushHistory;
1830
1830
  appPath;
1831
1831
  onConsoleLog;
1832
+ onRunEventScript;
1833
+ isDebug;
1832
1834
  constructor(args) {
1833
1835
  this.scriptUIRef = args.scriptUIRef;
1834
1836
  this.onStateChange = args.onStateChange;
@@ -1855,6 +1857,8 @@ var WorkerManager = class {
1855
1857
  this.pushHistory = args.pushHistory;
1856
1858
  this.appPath = args.appPath;
1857
1859
  this.onConsoleLog = args.onConsoleLog;
1860
+ this.onRunEventScript = args.onRunEventScript;
1861
+ this.isDebug = args.isDebug ?? false;
1858
1862
  if (this.plugin) {
1859
1863
  this.frameId = `${IFRAME_PREFIX}-${this.plugin.plugin_api_name}-${this.plugin.api_name}`;
1860
1864
  }
@@ -2091,6 +2095,14 @@ var WorkerManager = class {
2091
2095
  }
2092
2096
  return;
2093
2097
  }
2098
+ case ACTIONS.RUN_EVENT_SCRIPT: {
2099
+ const consideredEvent = event;
2100
+ this.onRunEventScript?.(consideredEvent.scriptName, consideredEvent.args);
2101
+ if (!this.onRunEventScript && this.isDebug) {
2102
+ console.warn(`No handler for RUN_EVENT_SCRIPT: ${consideredEvent.scriptName}`);
2103
+ }
2104
+ return;
2105
+ }
2094
2106
  default:
2095
2107
  return;
2096
2108
  }
@@ -2520,7 +2532,8 @@ var runScript = async ({
2520
2532
  performFileUpload,
2521
2533
  getPendingCacheCount,
2522
2534
  invalidateCache,
2523
- onConsoleLog
2535
+ onConsoleLog,
2536
+ onRunEventScript
2524
2537
  }) => {
2525
2538
  const isDebug = isFlagEnabled("script-runner-logging");
2526
2539
  let worker;
@@ -2598,7 +2611,9 @@ var runScript = async ({
2598
2611
  performFileUpload,
2599
2612
  getPendingCacheCount,
2600
2613
  invalidateCache,
2601
- onConsoleLog
2614
+ onConsoleLog,
2615
+ onRunEventScript,
2616
+ isDebug
2602
2617
  });
2603
2618
  setLoadingState(true);
2604
2619
  instance.run(
@@ -2655,8 +2670,8 @@ var modalSize = {
2655
2670
  };
2656
2671
 
2657
2672
  // src/index.ts
2658
- var version = "1.5.2-065350b";
2673
+ var version = "1.6.0";
2659
2674
 
2660
2675
  export { forceQualifiedUrl, getDisabledValue, getEnabledState, getHash, getLinkValue, getPluginSafeHTML, getQrCodeValue, getStableHash, isFlagEnabled, mergeConfig, modalSize, pluginMapper, reduceEnabledResults, replaceConfigValues, runExpression, runObjectExpression, runOptionExpression, runScript, runStringExpression, version };
2661
- //# sourceMappingURL=chunk-N2EE7JZP.js.map
2662
- //# sourceMappingURL=chunk-N2EE7JZP.js.map
2676
+ //# sourceMappingURL=chunk-3GJVC5NN.js.map
2677
+ //# sourceMappingURL=chunk-3GJVC5NN.js.map