@livechat/platform-workflows 0.0.82 → 0.0.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -22,7 +22,7 @@ interface LoginErrorPageProps {
22
22
  welcomeImage: React.ReactNode;
23
23
  onAuthorize: () => void;
24
24
  }
25
- declare function LoginErrorPage({ errorImage, welcomeImage, onAuthorize, }: LoginErrorPageProps): JSX.Element;
25
+ declare function LoginErrorPage({ errorImage, welcomeImage, onAuthorize }: LoginErrorPageProps): JSX.Element;
26
26
 
27
27
  interface WorkflowsModuleProps {
28
28
  waitlistImage: React$1.ReactNode;
package/dist/index.d.ts CHANGED
@@ -22,7 +22,7 @@ interface LoginErrorPageProps {
22
22
  welcomeImage: React.ReactNode;
23
23
  onAuthorize: () => void;
24
24
  }
25
- declare function LoginErrorPage({ errorImage, welcomeImage, onAuthorize, }: LoginErrorPageProps): JSX.Element;
25
+ declare function LoginErrorPage({ errorImage, welcomeImage, onAuthorize }: LoginErrorPageProps): JSX.Element;
26
26
 
27
27
  interface WorkflowsModuleProps {
28
28
  waitlistImage: React$1.ReactNode;
package/dist/index.js CHANGED
@@ -2309,6 +2309,7 @@ var import_developer_studio_ui_react46 = require("@livechat/developer-studio-ui-
2309
2309
  // src/views/Workflows/Creator/index.tsx
2310
2310
  var import_react_router_dom17 = require("react-router-dom");
2311
2311
  var import_developer_studio_ui_react34 = require("@livechat/developer-studio-ui-react");
2312
+ var import_platform_integrations5 = require("@livechat/platform-integrations");
2312
2313
 
2313
2314
  // src/constants/products.ts
2314
2315
  var OTHER_TYPES = {
@@ -12463,7 +12464,7 @@ var validateTasks = (workflow, frames, products) => {
12463
12464
  const resolvingErrors = jsonUtils.getMatchesInObject(task2).map((match2) => {
12464
12465
  const segments = match2.rawValue.split(".");
12465
12466
  const resolved = jsonUtils.resolveTextByContext(match2.value, frame);
12466
- let message = `Invalid field value`;
12467
+ let message = "Invalid field value";
12467
12468
  const params = {};
12468
12469
  if (!(frame == null ? void 0 : frame[segments[0]])) {
12469
12470
  if (segments[0]) {
@@ -12483,7 +12484,7 @@ var validateTasks = (workflow, frames, products) => {
12483
12484
  message += " - trigger not found";
12484
12485
  }
12485
12486
  } else if (!workflow.trigger.type || workflow.trigger.type === "recurring" || workflow.trigger.type === "webhook") {
12486
- message = `Couldn't use manual parameters when trigger is not manual`;
12487
+ message = "Couldn't use manual parameters when trigger is not manual";
12487
12488
  } else {
12488
12489
  message += " - invalid input property";
12489
12490
  }
@@ -12568,7 +12569,7 @@ var validateTasks = (workflow, frames, products) => {
12568
12569
  initial
12569
12570
  );
12570
12571
  }
12571
- return taskReducer(workflow.definition.tasks, [], `/definition/tasks`);
12572
+ return taskReducer(workflow.definition.tasks, [], "/definition/tasks");
12572
12573
  };
12573
12574
  var validateTrigger = (workflow, frames, products) => {
12574
12575
  var _a;
@@ -12581,7 +12582,7 @@ var validateTrigger = (workflow, frames, products) => {
12581
12582
  frames.trigger
12582
12583
  );
12583
12584
  if (!resolved) {
12584
- let message = `Invalid field value`;
12585
+ let message = "Invalid field value";
12585
12586
  const params = {};
12586
12587
  if (segments[0] === "workflow") {
12587
12588
  if (segments[1] === "credentials") {
@@ -12615,14 +12616,14 @@ var validateTrigger = (workflow, frames, products) => {
12615
12616
  }).filter(Boolean);
12616
12617
  const connectionErrors = resolvingErrors.filter((error) => error.params.subType === "credentials").map((error) => {
12617
12618
  return {
12618
- instancePath: `/trigger`,
12619
+ instancePath: "/trigger",
12619
12620
  keyword: "connection",
12620
12621
  message: `Not connected to ${error.params.provider}`,
12621
12622
  params: {}
12622
12623
  };
12623
12624
  });
12624
12625
  const activationError = config2 && config2.customization.provider.startsWith(import_developer_studio_api18.IntegrationNames.Text) && !products.find(({ product }) => product === config2.customization.product) ? {
12625
- instancePath: `/trigger`,
12626
+ instancePath: "/trigger",
12626
12627
  keyword: "activation",
12627
12628
  message: `${config2.customization.product} not activated`,
12628
12629
  params: {}
@@ -12776,8 +12777,8 @@ var getWorkflowValidation = (workflow, internal, external) => {
12776
12777
  if ("missingProperty" in rawError.params) {
12777
12778
  if (rawError.params.missingProperty) {
12778
12779
  rawError.instancePath = `${rawError.instancePath}/${rawError.params.missingProperty}`;
12779
- rawError.message = `property is required`;
12780
- rawError.keyword = `requiredProperty`;
12780
+ rawError.message = "property is required";
12781
+ rawError.keyword = "requiredProperty";
12781
12782
  }
12782
12783
  }
12783
12784
  switch (rawError.keyword) {
@@ -12788,7 +12789,7 @@ var getWorkflowValidation = (workflow, internal, external) => {
12788
12789
  workflow
12789
12790
  )) == null ? void 0 : _a[0] : void 0;
12790
12791
  if (value === null) {
12791
- message = `This field cannot be empty`;
12792
+ message = "This field cannot be empty";
12792
12793
  } else {
12793
12794
  message = "Invalid value type";
12794
12795
  }
@@ -12797,7 +12798,7 @@ var getWorkflowValidation = (workflow, internal, external) => {
12797
12798
  message = `Field '${rawError.params.missingProperty}' is required`;
12798
12799
  break;
12799
12800
  case "requiredProperty":
12800
- message = `This field cannot be empty`;
12801
+ message = "This field cannot be empty";
12801
12802
  break;
12802
12803
  case "minLength":
12803
12804
  message = `Must have more than ${rawError.params.limit} characters`;
@@ -13273,30 +13274,33 @@ function WorkflowCreatorProviderBase({
13273
13274
  return;
13274
13275
  }
13275
13276
  setAction("isSaving", true);
13276
- if (state2.workflow.id) {
13277
- const updateMutationResult = yield updateWorkflowAction.mutateAsync(
13278
- state2.workflow
13279
- );
13280
- if (!silent) {
13281
- notifications.addSuccessToast(
13282
- "Workflow has been updated successfully"
13277
+ try {
13278
+ if (state2.workflow.id) {
13279
+ const updateMutationResult = yield updateWorkflowAction.mutateAsync(
13280
+ state2.workflow
13283
13281
  );
13284
- }
13285
- setWorkflow((prevState) => __spreadProps(__spreadValues({}, prevState), {
13286
- version: updateMutationResult.version
13287
- }));
13288
- } else {
13289
- const workflowId = yield createWorkflowAction.mutateAsync(
13290
- state2.workflow
13291
- );
13292
- if (!silent) {
13293
- notifications.addSuccessToast(
13294
- "Workflow has been created successfully"
13282
+ if (!silent) {
13283
+ notifications.addSuccessToast(
13284
+ "Workflow has been updated successfully"
13285
+ );
13286
+ }
13287
+ setWorkflow((prevState) => __spreadProps(__spreadValues({}, prevState), {
13288
+ version: updateMutationResult.version
13289
+ }));
13290
+ } else {
13291
+ const workflowId = yield createWorkflowAction.mutateAsync(
13292
+ state2.workflow
13295
13293
  );
13294
+ if (!silent) {
13295
+ notifications.addSuccessToast(
13296
+ "Workflow has been created successfully"
13297
+ );
13298
+ }
13299
+ navigate(`/workflow/${workflowId}`);
13296
13300
  }
13297
- navigate(`/workflow/${workflowId}`);
13301
+ } finally {
13302
+ setAction("isSaving", false);
13298
13303
  }
13299
- setAction("isSaving", false);
13300
13304
  }),
13301
13305
  [
13302
13306
  createWorkflowAction,
@@ -13317,33 +13321,39 @@ function WorkflowCreatorProviderBase({
13317
13321
  return;
13318
13322
  }
13319
13323
  setAction("isActivating", true);
13320
- yield activateWorkflowAction.mutateAsync({
13321
- id: state2.workflow.id,
13322
- active: !state2.workflow.active
13323
- });
13324
- setWorkflow((prevState) => __spreadProps(__spreadValues({}, prevState), {
13325
- active: !prevState.active
13326
- }));
13327
- notifications.addSuccessToast(
13328
- `Workflow has been ${state2.workflow.active ? "deactivated" : "activated"}`
13329
- );
13330
- setAction("isActivating", false);
13324
+ try {
13325
+ yield activateWorkflowAction.mutateAsync({
13326
+ id: state2.workflow.id,
13327
+ active: !state2.workflow.active
13328
+ });
13329
+ setWorkflow((prevState) => __spreadProps(__spreadValues({}, prevState), {
13330
+ active: !prevState.active
13331
+ }));
13332
+ notifications.addSuccessToast(
13333
+ `Workflow has been ${state2.workflow.active ? "deactivated" : "activated"}`
13334
+ );
13335
+ } finally {
13336
+ setAction("isActivating", false);
13337
+ }
13331
13338
  }), [activateWorkflowAction, notifications, validate, setWorkflow, setAction]);
13332
13339
  const remove = (0, import_react10.useCallback)(() => __async(this, null, function* () {
13333
13340
  const state2 = autosaveStateRef.current;
13334
13341
  setAction("isRemoving", true);
13335
- if (state2.workflow.draft) {
13336
- if (state2.workflow.related_workflow_id) {
13337
- yield deleteWorkflowAction.mutateAsync({
13338
- id: state2.workflow.related_workflow_id
13339
- });
13342
+ try {
13343
+ if (state2.workflow.draft) {
13344
+ if (state2.workflow.related_workflow_id) {
13345
+ yield deleteWorkflowAction.mutateAsync({
13346
+ id: state2.workflow.related_workflow_id
13347
+ });
13348
+ }
13349
+ } else {
13350
+ yield deleteWorkflowAction.mutateAsync(state2.workflow);
13340
13351
  }
13341
- } else {
13342
- yield deleteWorkflowAction.mutateAsync(state2.workflow);
13352
+ navigate("/workflow/list");
13353
+ notifications.addSuccessToast("Workflow has been removed successfully");
13354
+ } finally {
13355
+ setAction("isRemoving", false);
13343
13356
  }
13344
- navigate("/workflow/list");
13345
- notifications.addSuccessToast("Workflow has been removed successfully");
13346
- setAction("isRemoving", false);
13347
13357
  }), [setAction, navigate, notifications, deleteWorkflowAction]);
13348
13358
  const createDraft = (0, import_react10.useCallback)(
13349
13359
  (options2) => __async(this, null, function* () {
@@ -13358,19 +13368,22 @@ function WorkflowCreatorProviderBase({
13358
13368
  }
13359
13369
  }
13360
13370
  setAction("isCreating", true);
13361
- if (state2.workflow.related_workflow_id) {
13362
- yield deleteWorkflowAction.mutateAsync({
13363
- id: state2.workflow.related_workflow_id
13364
- });
13371
+ try {
13372
+ if (state2.workflow.related_workflow_id) {
13373
+ yield deleteWorkflowAction.mutateAsync({
13374
+ id: state2.workflow.related_workflow_id
13375
+ });
13376
+ }
13377
+ const draftId = yield createWorkflowDraftAction.mutateAsync(
13378
+ state2.workflow
13379
+ );
13380
+ navigate(`/workflow/${draftId}`);
13381
+ notifications.addSuccessToast(
13382
+ "Workflow draft has been created successfully"
13383
+ );
13384
+ } finally {
13385
+ setAction("isCreating", false);
13365
13386
  }
13366
- const draftId = yield createWorkflowDraftAction.mutateAsync(
13367
- state2.workflow
13368
- );
13369
- navigate(`/workflow/${draftId}`);
13370
- notifications.addSuccessToast(
13371
- "Workflow draft has been created successfully"
13372
- );
13373
- setAction("isCreating", false);
13374
13387
  }),
13375
13388
  [
13376
13389
  createWorkflowDraftAction,
@@ -13397,19 +13410,24 @@ function WorkflowCreatorProviderBase({
13397
13410
  return;
13398
13411
  }
13399
13412
  setAction("isPublishing", true);
13400
- if (state2.workflow.id) {
13401
- const { id } = yield publishWorkflowAction.mutateAsync(state2.workflow);
13402
- navigate(`/workflow/${id}`);
13403
- } else {
13404
- const id = yield createWorkflowAction.mutateAsync(__spreadProps(__spreadValues({}, state2.workflow), {
13405
- draft: false
13406
- }));
13407
- navigate(`/workflow/${id}`);
13413
+ try {
13414
+ if (state2.workflow.id) {
13415
+ const { id } = yield publishWorkflowAction.mutateAsync(
13416
+ state2.workflow
13417
+ );
13418
+ navigate(`/workflow/${id}`);
13419
+ } else {
13420
+ const id = yield createWorkflowAction.mutateAsync(__spreadProps(__spreadValues({}, state2.workflow), {
13421
+ draft: false
13422
+ }));
13423
+ navigate(`/workflow/${id}`);
13424
+ }
13425
+ notifications.addSuccessToast(
13426
+ "Workflow draft has been published successfully"
13427
+ );
13428
+ } finally {
13429
+ setAction("isPublishing", false);
13408
13430
  }
13409
- notifications.addSuccessToast(
13410
- "Workflow draft has been published successfully"
13411
- );
13412
- setAction("isPublishing", false);
13413
13431
  }),
13414
13432
  [
13415
13433
  validate,
@@ -13423,26 +13441,29 @@ function WorkflowCreatorProviderBase({
13423
13441
  const discardDraft = (0, import_react10.useCallback)(() => __async(this, null, function* () {
13424
13442
  const state2 = autosaveStateRef.current;
13425
13443
  setAction("isDiscarding", true);
13426
- if (state2.workflow.draft) {
13427
- if (state2.workflow.id) {
13428
- yield deleteWorkflowAction.mutateAsync(state2.workflow);
13429
- }
13430
- if (state2.workflow.related_workflow_id) {
13431
- navigate(`/workflow/${state2.workflow.related_workflow_id}`);
13432
- } else {
13433
- navigate(`/workflow/list`);
13444
+ try {
13445
+ if (state2.workflow.draft) {
13446
+ if (state2.workflow.id) {
13447
+ yield deleteWorkflowAction.mutateAsync(state2.workflow);
13448
+ }
13449
+ if (state2.workflow.related_workflow_id) {
13450
+ navigate(`/workflow/${state2.workflow.related_workflow_id}`);
13451
+ } else {
13452
+ navigate("/workflow/list");
13453
+ }
13454
+ } else if (state2.workflow.related_workflow_id) {
13455
+ yield deleteWorkflowAction.mutateAsync({
13456
+ id: state2.workflow.related_workflow_id,
13457
+ related_workflow_id: state2.workflow.id
13458
+ });
13459
+ navigate(`/workflow/${state2.workflow.id}`);
13434
13460
  }
13435
- } else if (state2.workflow.related_workflow_id) {
13436
- yield deleteWorkflowAction.mutateAsync({
13437
- id: state2.workflow.related_workflow_id,
13438
- related_workflow_id: state2.workflow.id
13439
- });
13440
- navigate(`/workflow/${state2.workflow.id}`);
13461
+ notifications.addSuccessToast(
13462
+ "Workflow draft has been discarded successfully"
13463
+ );
13464
+ } finally {
13465
+ setAction("isDiscarding", false);
13441
13466
  }
13442
- notifications.addSuccessToast(
13443
- "Workflow draft has been discarded successfully"
13444
- );
13445
- setAction("isDiscarding", false);
13446
13467
  }), [deleteWorkflowAction, notifications, navigate, setAction]);
13447
13468
  const [previewModalVisible, setPreviewModalVisible] = (0, import_react10.useState)({ isVisible: false });
13448
13469
  return /* @__PURE__ */ jsx4(
@@ -21320,7 +21341,7 @@ function WorkflowDetailsPanel({
21320
21341
  {
21321
21342
  isSelected: tab === "info",
21322
21343
  onClick: () => {
21323
- navigate(`../info`, { replace: true, relative: "route" });
21344
+ navigate("../info", { replace: true, relative: "route" });
21324
21345
  },
21325
21346
  children: "Info"
21326
21347
  }
@@ -21330,7 +21351,7 @@ function WorkflowDetailsPanel({
21330
21351
  {
21331
21352
  isSelected: tab === "executions",
21332
21353
  onClick: () => {
21333
- navigate(`../executions`, { replace: true, relative: "route" });
21354
+ navigate("../executions", { replace: true, relative: "route" });
21334
21355
  },
21335
21356
  children: "History"
21336
21357
  }
@@ -22034,11 +22055,14 @@ function WorkflowCreator() {
22034
22055
  const { id } = (0, import_react_router_dom17.useParams)();
22035
22056
  const navigate = (0, import_react_router_dom17.useNavigate)();
22036
22057
  const workflowQuery = useFetchWorkflow(id === "new" ? void 0 : id);
22058
+ const credentialsQuery = (0, import_platform_integrations5.useFetchIntegrationCredentialsQuery)();
22059
+ const organizationProducts = (0, import_developer_studio_ui_react34.useFetchOrganizationProducts)();
22037
22060
  useFetchWorkflow((_a = workflowQuery.data) == null ? void 0 : _a.related_workflow_id);
22038
22061
  if (!id) {
22039
22062
  return;
22040
22063
  }
22041
- if (id !== "new" && workflowQuery.isLoading) {
22064
+ const isLoading = workflowQuery.isLoading || credentialsQuery.isInitialLoading || organizationProducts.isInitialLoading;
22065
+ if (id !== "new" && isLoading) {
22042
22066
  return /* @__PURE__ */ jsx4(import_developer_studio_ui_react34.Loader, { stretch: true });
22043
22067
  }
22044
22068
  if (id !== "new" && !workflowQuery.isSuccess) {
package/dist/index.mjs CHANGED
@@ -2312,7 +2312,11 @@ import {
2312
2312
  useNavigate as useNavigate13,
2313
2313
  useParams as useParams4
2314
2314
  } from "react-router-dom";
2315
- import { Loader as Loader3 } from "@livechat/developer-studio-ui-react";
2315
+ import {
2316
+ Loader as Loader3,
2317
+ useFetchOrganizationProducts as useFetchOrganizationProducts2
2318
+ } from "@livechat/developer-studio-ui-react";
2319
+ import { useFetchIntegrationCredentialsQuery as useFetchIntegrationCredentialsQuery2 } from "@livechat/platform-integrations";
2316
2320
 
2317
2321
  // src/constants/products.ts
2318
2322
  var OTHER_TYPES = {
@@ -12540,7 +12544,7 @@ var validateTasks = (workflow, frames, products) => {
12540
12544
  const resolvingErrors = jsonUtils.getMatchesInObject(task2).map((match2) => {
12541
12545
  const segments = match2.rawValue.split(".");
12542
12546
  const resolved = jsonUtils.resolveTextByContext(match2.value, frame);
12543
- let message = `Invalid field value`;
12547
+ let message = "Invalid field value";
12544
12548
  const params = {};
12545
12549
  if (!(frame == null ? void 0 : frame[segments[0]])) {
12546
12550
  if (segments[0]) {
@@ -12560,7 +12564,7 @@ var validateTasks = (workflow, frames, products) => {
12560
12564
  message += " - trigger not found";
12561
12565
  }
12562
12566
  } else if (!workflow.trigger.type || workflow.trigger.type === "recurring" || workflow.trigger.type === "webhook") {
12563
- message = `Couldn't use manual parameters when trigger is not manual`;
12567
+ message = "Couldn't use manual parameters when trigger is not manual";
12564
12568
  } else {
12565
12569
  message += " - invalid input property";
12566
12570
  }
@@ -12645,7 +12649,7 @@ var validateTasks = (workflow, frames, products) => {
12645
12649
  initial
12646
12650
  );
12647
12651
  }
12648
- return taskReducer(workflow.definition.tasks, [], `/definition/tasks`);
12652
+ return taskReducer(workflow.definition.tasks, [], "/definition/tasks");
12649
12653
  };
12650
12654
  var validateTrigger = (workflow, frames, products) => {
12651
12655
  var _a;
@@ -12658,7 +12662,7 @@ var validateTrigger = (workflow, frames, products) => {
12658
12662
  frames.trigger
12659
12663
  );
12660
12664
  if (!resolved) {
12661
- let message = `Invalid field value`;
12665
+ let message = "Invalid field value";
12662
12666
  const params = {};
12663
12667
  if (segments[0] === "workflow") {
12664
12668
  if (segments[1] === "credentials") {
@@ -12692,14 +12696,14 @@ var validateTrigger = (workflow, frames, products) => {
12692
12696
  }).filter(Boolean);
12693
12697
  const connectionErrors = resolvingErrors.filter((error) => error.params.subType === "credentials").map((error) => {
12694
12698
  return {
12695
- instancePath: `/trigger`,
12699
+ instancePath: "/trigger",
12696
12700
  keyword: "connection",
12697
12701
  message: `Not connected to ${error.params.provider}`,
12698
12702
  params: {}
12699
12703
  };
12700
12704
  });
12701
12705
  const activationError = config2 && config2.customization.provider.startsWith(IntegrationNames12.Text) && !products.find(({ product }) => product === config2.customization.product) ? {
12702
- instancePath: `/trigger`,
12706
+ instancePath: "/trigger",
12703
12707
  keyword: "activation",
12704
12708
  message: `${config2.customization.product} not activated`,
12705
12709
  params: {}
@@ -12853,8 +12857,8 @@ var getWorkflowValidation = (workflow, internal, external) => {
12853
12857
  if ("missingProperty" in rawError.params) {
12854
12858
  if (rawError.params.missingProperty) {
12855
12859
  rawError.instancePath = `${rawError.instancePath}/${rawError.params.missingProperty}`;
12856
- rawError.message = `property is required`;
12857
- rawError.keyword = `requiredProperty`;
12860
+ rawError.message = "property is required";
12861
+ rawError.keyword = "requiredProperty";
12858
12862
  }
12859
12863
  }
12860
12864
  switch (rawError.keyword) {
@@ -12865,7 +12869,7 @@ var getWorkflowValidation = (workflow, internal, external) => {
12865
12869
  workflow
12866
12870
  )) == null ? void 0 : _a[0] : void 0;
12867
12871
  if (value === null) {
12868
- message = `This field cannot be empty`;
12872
+ message = "This field cannot be empty";
12869
12873
  } else {
12870
12874
  message = "Invalid value type";
12871
12875
  }
@@ -12874,7 +12878,7 @@ var getWorkflowValidation = (workflow, internal, external) => {
12874
12878
  message = `Field '${rawError.params.missingProperty}' is required`;
12875
12879
  break;
12876
12880
  case "requiredProperty":
12877
- message = `This field cannot be empty`;
12881
+ message = "This field cannot be empty";
12878
12882
  break;
12879
12883
  case "minLength":
12880
12884
  message = `Must have more than ${rawError.params.limit} characters`;
@@ -13350,30 +13354,33 @@ function WorkflowCreatorProviderBase({
13350
13354
  return;
13351
13355
  }
13352
13356
  setAction("isSaving", true);
13353
- if (state2.workflow.id) {
13354
- const updateMutationResult = yield updateWorkflowAction.mutateAsync(
13355
- state2.workflow
13356
- );
13357
- if (!silent) {
13358
- notifications.addSuccessToast(
13359
- "Workflow has been updated successfully"
13357
+ try {
13358
+ if (state2.workflow.id) {
13359
+ const updateMutationResult = yield updateWorkflowAction.mutateAsync(
13360
+ state2.workflow
13360
13361
  );
13361
- }
13362
- setWorkflow((prevState) => __spreadProps(__spreadValues({}, prevState), {
13363
- version: updateMutationResult.version
13364
- }));
13365
- } else {
13366
- const workflowId = yield createWorkflowAction.mutateAsync(
13367
- state2.workflow
13368
- );
13369
- if (!silent) {
13370
- notifications.addSuccessToast(
13371
- "Workflow has been created successfully"
13362
+ if (!silent) {
13363
+ notifications.addSuccessToast(
13364
+ "Workflow has been updated successfully"
13365
+ );
13366
+ }
13367
+ setWorkflow((prevState) => __spreadProps(__spreadValues({}, prevState), {
13368
+ version: updateMutationResult.version
13369
+ }));
13370
+ } else {
13371
+ const workflowId = yield createWorkflowAction.mutateAsync(
13372
+ state2.workflow
13372
13373
  );
13374
+ if (!silent) {
13375
+ notifications.addSuccessToast(
13376
+ "Workflow has been created successfully"
13377
+ );
13378
+ }
13379
+ navigate(`/workflow/${workflowId}`);
13373
13380
  }
13374
- navigate(`/workflow/${workflowId}`);
13381
+ } finally {
13382
+ setAction("isSaving", false);
13375
13383
  }
13376
- setAction("isSaving", false);
13377
13384
  }),
13378
13385
  [
13379
13386
  createWorkflowAction,
@@ -13394,33 +13401,39 @@ function WorkflowCreatorProviderBase({
13394
13401
  return;
13395
13402
  }
13396
13403
  setAction("isActivating", true);
13397
- yield activateWorkflowAction.mutateAsync({
13398
- id: state2.workflow.id,
13399
- active: !state2.workflow.active
13400
- });
13401
- setWorkflow((prevState) => __spreadProps(__spreadValues({}, prevState), {
13402
- active: !prevState.active
13403
- }));
13404
- notifications.addSuccessToast(
13405
- `Workflow has been ${state2.workflow.active ? "deactivated" : "activated"}`
13406
- );
13407
- setAction("isActivating", false);
13404
+ try {
13405
+ yield activateWorkflowAction.mutateAsync({
13406
+ id: state2.workflow.id,
13407
+ active: !state2.workflow.active
13408
+ });
13409
+ setWorkflow((prevState) => __spreadProps(__spreadValues({}, prevState), {
13410
+ active: !prevState.active
13411
+ }));
13412
+ notifications.addSuccessToast(
13413
+ `Workflow has been ${state2.workflow.active ? "deactivated" : "activated"}`
13414
+ );
13415
+ } finally {
13416
+ setAction("isActivating", false);
13417
+ }
13408
13418
  }), [activateWorkflowAction, notifications, validate, setWorkflow, setAction]);
13409
13419
  const remove = useCallback2(() => __async(this, null, function* () {
13410
13420
  const state2 = autosaveStateRef.current;
13411
13421
  setAction("isRemoving", true);
13412
- if (state2.workflow.draft) {
13413
- if (state2.workflow.related_workflow_id) {
13414
- yield deleteWorkflowAction.mutateAsync({
13415
- id: state2.workflow.related_workflow_id
13416
- });
13422
+ try {
13423
+ if (state2.workflow.draft) {
13424
+ if (state2.workflow.related_workflow_id) {
13425
+ yield deleteWorkflowAction.mutateAsync({
13426
+ id: state2.workflow.related_workflow_id
13427
+ });
13428
+ }
13429
+ } else {
13430
+ yield deleteWorkflowAction.mutateAsync(state2.workflow);
13417
13431
  }
13418
- } else {
13419
- yield deleteWorkflowAction.mutateAsync(state2.workflow);
13432
+ navigate("/workflow/list");
13433
+ notifications.addSuccessToast("Workflow has been removed successfully");
13434
+ } finally {
13435
+ setAction("isRemoving", false);
13420
13436
  }
13421
- navigate("/workflow/list");
13422
- notifications.addSuccessToast("Workflow has been removed successfully");
13423
- setAction("isRemoving", false);
13424
13437
  }), [setAction, navigate, notifications, deleteWorkflowAction]);
13425
13438
  const createDraft = useCallback2(
13426
13439
  (options2) => __async(this, null, function* () {
@@ -13435,19 +13448,22 @@ function WorkflowCreatorProviderBase({
13435
13448
  }
13436
13449
  }
13437
13450
  setAction("isCreating", true);
13438
- if (state2.workflow.related_workflow_id) {
13439
- yield deleteWorkflowAction.mutateAsync({
13440
- id: state2.workflow.related_workflow_id
13441
- });
13451
+ try {
13452
+ if (state2.workflow.related_workflow_id) {
13453
+ yield deleteWorkflowAction.mutateAsync({
13454
+ id: state2.workflow.related_workflow_id
13455
+ });
13456
+ }
13457
+ const draftId = yield createWorkflowDraftAction.mutateAsync(
13458
+ state2.workflow
13459
+ );
13460
+ navigate(`/workflow/${draftId}`);
13461
+ notifications.addSuccessToast(
13462
+ "Workflow draft has been created successfully"
13463
+ );
13464
+ } finally {
13465
+ setAction("isCreating", false);
13442
13466
  }
13443
- const draftId = yield createWorkflowDraftAction.mutateAsync(
13444
- state2.workflow
13445
- );
13446
- navigate(`/workflow/${draftId}`);
13447
- notifications.addSuccessToast(
13448
- "Workflow draft has been created successfully"
13449
- );
13450
- setAction("isCreating", false);
13451
13467
  }),
13452
13468
  [
13453
13469
  createWorkflowDraftAction,
@@ -13474,19 +13490,24 @@ function WorkflowCreatorProviderBase({
13474
13490
  return;
13475
13491
  }
13476
13492
  setAction("isPublishing", true);
13477
- if (state2.workflow.id) {
13478
- const { id } = yield publishWorkflowAction.mutateAsync(state2.workflow);
13479
- navigate(`/workflow/${id}`);
13480
- } else {
13481
- const id = yield createWorkflowAction.mutateAsync(__spreadProps(__spreadValues({}, state2.workflow), {
13482
- draft: false
13483
- }));
13484
- navigate(`/workflow/${id}`);
13493
+ try {
13494
+ if (state2.workflow.id) {
13495
+ const { id } = yield publishWorkflowAction.mutateAsync(
13496
+ state2.workflow
13497
+ );
13498
+ navigate(`/workflow/${id}`);
13499
+ } else {
13500
+ const id = yield createWorkflowAction.mutateAsync(__spreadProps(__spreadValues({}, state2.workflow), {
13501
+ draft: false
13502
+ }));
13503
+ navigate(`/workflow/${id}`);
13504
+ }
13505
+ notifications.addSuccessToast(
13506
+ "Workflow draft has been published successfully"
13507
+ );
13508
+ } finally {
13509
+ setAction("isPublishing", false);
13485
13510
  }
13486
- notifications.addSuccessToast(
13487
- "Workflow draft has been published successfully"
13488
- );
13489
- setAction("isPublishing", false);
13490
13511
  }),
13491
13512
  [
13492
13513
  validate,
@@ -13500,26 +13521,29 @@ function WorkflowCreatorProviderBase({
13500
13521
  const discardDraft = useCallback2(() => __async(this, null, function* () {
13501
13522
  const state2 = autosaveStateRef.current;
13502
13523
  setAction("isDiscarding", true);
13503
- if (state2.workflow.draft) {
13504
- if (state2.workflow.id) {
13505
- yield deleteWorkflowAction.mutateAsync(state2.workflow);
13506
- }
13507
- if (state2.workflow.related_workflow_id) {
13508
- navigate(`/workflow/${state2.workflow.related_workflow_id}`);
13509
- } else {
13510
- navigate(`/workflow/list`);
13524
+ try {
13525
+ if (state2.workflow.draft) {
13526
+ if (state2.workflow.id) {
13527
+ yield deleteWorkflowAction.mutateAsync(state2.workflow);
13528
+ }
13529
+ if (state2.workflow.related_workflow_id) {
13530
+ navigate(`/workflow/${state2.workflow.related_workflow_id}`);
13531
+ } else {
13532
+ navigate("/workflow/list");
13533
+ }
13534
+ } else if (state2.workflow.related_workflow_id) {
13535
+ yield deleteWorkflowAction.mutateAsync({
13536
+ id: state2.workflow.related_workflow_id,
13537
+ related_workflow_id: state2.workflow.id
13538
+ });
13539
+ navigate(`/workflow/${state2.workflow.id}`);
13511
13540
  }
13512
- } else if (state2.workflow.related_workflow_id) {
13513
- yield deleteWorkflowAction.mutateAsync({
13514
- id: state2.workflow.related_workflow_id,
13515
- related_workflow_id: state2.workflow.id
13516
- });
13517
- navigate(`/workflow/${state2.workflow.id}`);
13541
+ notifications.addSuccessToast(
13542
+ "Workflow draft has been discarded successfully"
13543
+ );
13544
+ } finally {
13545
+ setAction("isDiscarding", false);
13518
13546
  }
13519
- notifications.addSuccessToast(
13520
- "Workflow draft has been discarded successfully"
13521
- );
13522
- setAction("isDiscarding", false);
13523
13547
  }), [deleteWorkflowAction, notifications, navigate, setAction]);
13524
13548
  const [previewModalVisible, setPreviewModalVisible] = useState4({ isVisible: false });
13525
13549
  return /* @__PURE__ */ jsx4(
@@ -21664,7 +21688,7 @@ function WorkflowDetailsPanel({
21664
21688
  {
21665
21689
  isSelected: tab === "info",
21666
21690
  onClick: () => {
21667
- navigate(`../info`, { replace: true, relative: "route" });
21691
+ navigate("../info", { replace: true, relative: "route" });
21668
21692
  },
21669
21693
  children: "Info"
21670
21694
  }
@@ -21674,7 +21698,7 @@ function WorkflowDetailsPanel({
21674
21698
  {
21675
21699
  isSelected: tab === "executions",
21676
21700
  onClick: () => {
21677
- navigate(`../executions`, { replace: true, relative: "route" });
21701
+ navigate("../executions", { replace: true, relative: "route" });
21678
21702
  },
21679
21703
  children: "History"
21680
21704
  }
@@ -22404,11 +22428,14 @@ function WorkflowCreator() {
22404
22428
  const { id } = useParams4();
22405
22429
  const navigate = useNavigate13();
22406
22430
  const workflowQuery = useFetchWorkflow(id === "new" ? void 0 : id);
22431
+ const credentialsQuery = useFetchIntegrationCredentialsQuery2();
22432
+ const organizationProducts = useFetchOrganizationProducts2();
22407
22433
  useFetchWorkflow((_a = workflowQuery.data) == null ? void 0 : _a.related_workflow_id);
22408
22434
  if (!id) {
22409
22435
  return;
22410
22436
  }
22411
- if (id !== "new" && workflowQuery.isLoading) {
22437
+ const isLoading = workflowQuery.isLoading || credentialsQuery.isInitialLoading || organizationProducts.isInitialLoading;
22438
+ if (id !== "new" && isLoading) {
22412
22439
  return /* @__PURE__ */ jsx4(Loader3, { stretch: true });
22413
22440
  }
22414
22441
  if (id !== "new" && !workflowQuery.isSuccess) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livechat/platform-workflows",
3
- "version": "0.0.82",
3
+ "version": "0.0.83",
4
4
  "description": "Text Platform | Workflows",
5
5
  "author": "Wojciech Dudek",
6
6
  "license": "MIT",
@@ -81,9 +81,9 @@
81
81
  "uuid": "^9.0.1",
82
82
  "validator": "^13.12.0",
83
83
  "web-worker": "^1.3.0",
84
- "@livechat/developer-studio-api": "3.4.10",
85
- "@livechat/developer-studio-ui-react": "1.1.1",
86
- "@livechat/platform-integrations": "0.0.47"
84
+ "@livechat/developer-studio-api": "3.4.11",
85
+ "@livechat/platform-integrations": "0.0.48",
86
+ "@livechat/developer-studio-ui-react": "1.1.2"
87
87
  },
88
88
  "peerDependencies": {
89
89
  "@tanstack/react-query": "4.36.1",