@embedreach/components 0.1.64 → 0.1.65
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/chunks/index.js +285 -284
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +8 -7
- package/dist/index.umd.js +26 -26
- package/package.json +1 -1
package/dist/chunks/index.js
CHANGED
|
@@ -3,6 +3,12 @@ import * as React from "react";
|
|
|
3
3
|
import React__default, { createContext as createContext$1, Component, forwardRef, createElement as createElement$1, useReducer, useMemo, useEffect, useRef, useState, useId as useId$2, useContext as useContext$1, useInsertionEffect, useCallback, Children, isValidElement, useLayoutEffect, Fragment as Fragment$1 } from "react";
|
|
4
4
|
import * as ReactDOM from "react-dom";
|
|
5
5
|
import ReactDOM__default from "react-dom";
|
|
6
|
+
const BUSINESS_SEGMENT_PATH = "/segments";
|
|
7
|
+
const BUSINESS_AUTOMATION_PATH = "/automations";
|
|
8
|
+
const CHANNEL_SENDER_PATH = "/channel/senders";
|
|
9
|
+
const CHANNEL_ACCOUNT_PATH = "/channel/accounts";
|
|
10
|
+
const COMMUNICATION_GROUP_PATH = "/communication-groups";
|
|
11
|
+
const STRIPO_PATH = "/stripo";
|
|
6
12
|
var Subscribable = class {
|
|
7
13
|
constructor() {
|
|
8
14
|
this.listeners = /* @__PURE__ */ new Set();
|
|
@@ -2495,6 +2501,278 @@ function useMutation(options, queryClient) {
|
|
|
2495
2501
|
}
|
|
2496
2502
|
return { ...result, mutate, mutateAsync: result.mutate };
|
|
2497
2503
|
}
|
|
2504
|
+
let EventEmitter$1 = class EventEmitter {
|
|
2505
|
+
handlers = /* @__PURE__ */ new Map();
|
|
2506
|
+
/**
|
|
2507
|
+
* Subscribes to an event
|
|
2508
|
+
* @template TEvent - Event name literal type
|
|
2509
|
+
* @param {TEvent} event - Event to subscribe to
|
|
2510
|
+
* @param {EventHandler<TEventMap[TEvent]>} handler - Event handler
|
|
2511
|
+
* @returns {Unsubscribe} Unsubscribe function
|
|
2512
|
+
*/
|
|
2513
|
+
subscribe(event, handler) {
|
|
2514
|
+
const handlers = this.handlers.get(event) || /* @__PURE__ */ new Set();
|
|
2515
|
+
handlers.add(handler);
|
|
2516
|
+
this.handlers.set(event, handlers);
|
|
2517
|
+
return () => {
|
|
2518
|
+
const handlersSet = this.handlers.get(event);
|
|
2519
|
+
if (handlersSet) {
|
|
2520
|
+
handlersSet.delete(handler);
|
|
2521
|
+
if (handlersSet.size === 0) {
|
|
2522
|
+
this.handlers.delete(event);
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
};
|
|
2526
|
+
}
|
|
2527
|
+
/**
|
|
2528
|
+
* Emits an event with payload
|
|
2529
|
+
* @template TEvent - Event name literal type
|
|
2530
|
+
* @param {TEvent} event - Event to emit
|
|
2531
|
+
* @param {TEventMap[TEvent]} payload - Event payload
|
|
2532
|
+
*/
|
|
2533
|
+
emit(event, payload) {
|
|
2534
|
+
const handlers = this.handlers.get(event);
|
|
2535
|
+
if (handlers) {
|
|
2536
|
+
handlers.forEach((handler) => handler(payload));
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
/**
|
|
2540
|
+
* Removes all event handlers
|
|
2541
|
+
*/
|
|
2542
|
+
clearAll() {
|
|
2543
|
+
this.handlers.clear();
|
|
2544
|
+
}
|
|
2545
|
+
};
|
|
2546
|
+
const eventEmitter = new EventEmitter$1();
|
|
2547
|
+
const EVENT_API_UNAUTHORIZED = "api:unauthorized";
|
|
2548
|
+
const EVENT_API_AUTHORIZED = "api:authorized";
|
|
2549
|
+
const CACHE_STANDARD = {
|
|
2550
|
+
// Consider data stale after 5 minutes
|
|
2551
|
+
staleTime: 5 * 60 * 1e3,
|
|
2552
|
+
// Keep inactive data in cache for 10 minutes
|
|
2553
|
+
gcTime: 10 * 60 * 1e3,
|
|
2554
|
+
// Revalidate when window regains focus
|
|
2555
|
+
refetchOnWindowFocus: true
|
|
2556
|
+
};
|
|
2557
|
+
const HOSTNAME = "https://api.embedreach.com";
|
|
2558
|
+
const BASE_URL = `${HOSTNAME}/api`;
|
|
2559
|
+
let authToken;
|
|
2560
|
+
let unauthorizedEventSent = false;
|
|
2561
|
+
let unauthorizedEventTimeout = null;
|
|
2562
|
+
let authorizedEventSent = false;
|
|
2563
|
+
const setAuthToken = (token) => {
|
|
2564
|
+
authToken = token;
|
|
2565
|
+
};
|
|
2566
|
+
const baseRequest = async (endpoint, config = {}) => {
|
|
2567
|
+
const response = await fetch(`${BASE_URL}${endpoint}`, {
|
|
2568
|
+
...config,
|
|
2569
|
+
credentials: "include",
|
|
2570
|
+
headers: {
|
|
2571
|
+
"Content-Type": "application/json",
|
|
2572
|
+
...authToken && { Authorization: `Bearer ${authToken}` },
|
|
2573
|
+
...config.headers
|
|
2574
|
+
}
|
|
2575
|
+
});
|
|
2576
|
+
if (response.status === 401) {
|
|
2577
|
+
if (!unauthorizedEventSent) {
|
|
2578
|
+
unauthorizedEventSent = true;
|
|
2579
|
+
eventEmitter.emit(EVENT_API_UNAUTHORIZED, void 0);
|
|
2580
|
+
if (unauthorizedEventTimeout) {
|
|
2581
|
+
window.clearTimeout(unauthorizedEventTimeout);
|
|
2582
|
+
}
|
|
2583
|
+
unauthorizedEventTimeout = window.setTimeout(() => {
|
|
2584
|
+
unauthorizedEventSent = false;
|
|
2585
|
+
authorizedEventSent = false;
|
|
2586
|
+
unauthorizedEventTimeout = null;
|
|
2587
|
+
}, 5e3);
|
|
2588
|
+
}
|
|
2589
|
+
throw new Error("Unauthorized");
|
|
2590
|
+
}
|
|
2591
|
+
if (!response.ok) {
|
|
2592
|
+
throw new Error(`API Error: ${response.statusText}`);
|
|
2593
|
+
}
|
|
2594
|
+
if (!authorizedEventSent) {
|
|
2595
|
+
eventEmitter.emit(EVENT_API_AUTHORIZED, void 0);
|
|
2596
|
+
authorizedEventSent = true;
|
|
2597
|
+
}
|
|
2598
|
+
return response.json();
|
|
2599
|
+
};
|
|
2600
|
+
const createQueryClient = () => new QueryClient({
|
|
2601
|
+
defaultOptions: {
|
|
2602
|
+
queries: {
|
|
2603
|
+
retry: (failureCount, error2) => {
|
|
2604
|
+
if (error2 instanceof Error && error2.message === "Unauthorized") {
|
|
2605
|
+
return false;
|
|
2606
|
+
}
|
|
2607
|
+
return failureCount < 3;
|
|
2608
|
+
},
|
|
2609
|
+
...CACHE_STANDARD
|
|
2610
|
+
}
|
|
2611
|
+
}
|
|
2612
|
+
});
|
|
2613
|
+
const createAutomation = async (params) => {
|
|
2614
|
+
const response = await baseRequest(
|
|
2615
|
+
BUSINESS_AUTOMATION_PATH,
|
|
2616
|
+
{
|
|
2617
|
+
method: "POST",
|
|
2618
|
+
body: JSON.stringify(params)
|
|
2619
|
+
}
|
|
2620
|
+
);
|
|
2621
|
+
return response.data;
|
|
2622
|
+
};
|
|
2623
|
+
const getAutomation = async (automationId) => {
|
|
2624
|
+
const response = await baseRequest(
|
|
2625
|
+
`${BUSINESS_AUTOMATION_PATH}/${automationId}`
|
|
2626
|
+
);
|
|
2627
|
+
return response.data;
|
|
2628
|
+
};
|
|
2629
|
+
const getAutomationRecipients = async (automationId) => {
|
|
2630
|
+
const response = await baseRequest(
|
|
2631
|
+
`${BUSINESS_AUTOMATION_PATH}/${automationId}/recipients`
|
|
2632
|
+
);
|
|
2633
|
+
return response.data;
|
|
2634
|
+
};
|
|
2635
|
+
const updateAutomation = async (id2, params) => {
|
|
2636
|
+
const response = await baseRequest(
|
|
2637
|
+
`${BUSINESS_AUTOMATION_PATH}/${id2}`,
|
|
2638
|
+
{
|
|
2639
|
+
method: "PATCH",
|
|
2640
|
+
body: JSON.stringify(params)
|
|
2641
|
+
}
|
|
2642
|
+
);
|
|
2643
|
+
return response.data;
|
|
2644
|
+
};
|
|
2645
|
+
const getBusinessAutomationStatistics = async (automationId) => {
|
|
2646
|
+
if (!automationId) {
|
|
2647
|
+
const response = await baseRequest(
|
|
2648
|
+
`${BUSINESS_AUTOMATION_PATH}/statistics`
|
|
2649
|
+
);
|
|
2650
|
+
return response.data;
|
|
2651
|
+
} else {
|
|
2652
|
+
const response = await baseRequest(
|
|
2653
|
+
`${BUSINESS_AUTOMATION_PATH}/${automationId}/statistics`
|
|
2654
|
+
);
|
|
2655
|
+
return response.data;
|
|
2656
|
+
}
|
|
2657
|
+
};
|
|
2658
|
+
const listBusinessAutomations = async (args) => {
|
|
2659
|
+
const params = new URLSearchParams();
|
|
2660
|
+
if (args.cursor) params.append("cursor", args.cursor);
|
|
2661
|
+
if (args.limit) params.append("limit", args.limit.toString());
|
|
2662
|
+
if (args.status) params.append("status", args.status);
|
|
2663
|
+
if (args.search) params.append("search", args.search);
|
|
2664
|
+
const response = await baseRequest(
|
|
2665
|
+
`${BUSINESS_AUTOMATION_PATH}?${params.toString()}`,
|
|
2666
|
+
{
|
|
2667
|
+
method: "GET"
|
|
2668
|
+
}
|
|
2669
|
+
);
|
|
2670
|
+
return response.data;
|
|
2671
|
+
};
|
|
2672
|
+
const duplicateBusinessAutomation = async (automationId) => {
|
|
2673
|
+
const response = await baseRequest(
|
|
2674
|
+
`${BUSINESS_AUTOMATION_PATH}`,
|
|
2675
|
+
{
|
|
2676
|
+
method: "POST",
|
|
2677
|
+
body: JSON.stringify({
|
|
2678
|
+
duplicate: true,
|
|
2679
|
+
source_id: automationId
|
|
2680
|
+
})
|
|
2681
|
+
}
|
|
2682
|
+
);
|
|
2683
|
+
return response.data;
|
|
2684
|
+
};
|
|
2685
|
+
const useGetBusinessAutomation = (automationId) => {
|
|
2686
|
+
const queryClient = useQueryClient();
|
|
2687
|
+
const getAutomationQuery = useQuery({
|
|
2688
|
+
queryKey: ["automations", automationId],
|
|
2689
|
+
queryFn: () => getAutomation(automationId)
|
|
2690
|
+
});
|
|
2691
|
+
return {
|
|
2692
|
+
// Get automation query
|
|
2693
|
+
automation: getAutomationQuery.data,
|
|
2694
|
+
isFetching: getAutomationQuery.isFetching,
|
|
2695
|
+
isLoading: getAutomationQuery.isLoading,
|
|
2696
|
+
fetchError: getAutomationQuery.error,
|
|
2697
|
+
refetchAutomation: getAutomationQuery.refetch,
|
|
2698
|
+
invalidateAutomation: () => queryClient.invalidateQueries({
|
|
2699
|
+
queryKey: ["automations", automationId]
|
|
2700
|
+
})
|
|
2701
|
+
};
|
|
2702
|
+
};
|
|
2703
|
+
const useGetBusinessAutomationRecipients = (automationId) => {
|
|
2704
|
+
const getAutomationRecipientsQuery = useQuery({
|
|
2705
|
+
queryKey: ["automations", automationId, "recipients"],
|
|
2706
|
+
queryFn: () => getAutomationRecipients(automationId)
|
|
2707
|
+
});
|
|
2708
|
+
return {
|
|
2709
|
+
// Get automation recipients query
|
|
2710
|
+
recipients: getAutomationRecipientsQuery.data,
|
|
2711
|
+
isFetching: getAutomationRecipientsQuery.isFetching,
|
|
2712
|
+
isLoading: getAutomationRecipientsQuery.isLoading,
|
|
2713
|
+
fetchError: getAutomationRecipientsQuery.error,
|
|
2714
|
+
refetchAutomationRecipients: getAutomationRecipientsQuery.refetch
|
|
2715
|
+
};
|
|
2716
|
+
};
|
|
2717
|
+
const useCreateBusinessAutomation = () => {
|
|
2718
|
+
const queryClient = useQueryClient();
|
|
2719
|
+
const createAutomationMutation = useMutation({
|
|
2720
|
+
mutationFn: (params) => createAutomation(params),
|
|
2721
|
+
onSuccess: () => {
|
|
2722
|
+
queryClient.invalidateQueries({ queryKey: ["automations"] });
|
|
2723
|
+
}
|
|
2724
|
+
});
|
|
2725
|
+
return {
|
|
2726
|
+
// Create automation mutation
|
|
2727
|
+
createAutomation: createAutomationMutation.mutate,
|
|
2728
|
+
isCreating: createAutomationMutation.isPending,
|
|
2729
|
+
createError: createAutomationMutation.error,
|
|
2730
|
+
isCreateSuccess: createAutomationMutation.isSuccess
|
|
2731
|
+
};
|
|
2732
|
+
};
|
|
2733
|
+
const useUpdateBusinessAutomation = (automationId) => {
|
|
2734
|
+
const queryClient = useQueryClient();
|
|
2735
|
+
const updateAutomationMutation = useMutation({
|
|
2736
|
+
mutationFn: (params) => updateAutomation(automationId, params),
|
|
2737
|
+
onSuccess: () => {
|
|
2738
|
+
queryClient.invalidateQueries({ queryKey: ["automations"] });
|
|
2739
|
+
queryClient.invalidateQueries({
|
|
2740
|
+
queryKey: ["automations", automationId]
|
|
2741
|
+
});
|
|
2742
|
+
}
|
|
2743
|
+
});
|
|
2744
|
+
return {
|
|
2745
|
+
updateAutomation: updateAutomationMutation.mutate,
|
|
2746
|
+
isUpdating: updateAutomationMutation.isPending,
|
|
2747
|
+
updateError: updateAutomationMutation.error,
|
|
2748
|
+
isUpdateSuccess: updateAutomationMutation.isSuccess
|
|
2749
|
+
};
|
|
2750
|
+
};
|
|
2751
|
+
const useGetBusinessAutomationStatistics = (automationId) => {
|
|
2752
|
+
const getStatisticsQuery = useQuery({
|
|
2753
|
+
queryKey: ["automations", automationId, "statistics"],
|
|
2754
|
+
queryFn: () => getBusinessAutomationStatistics(automationId)
|
|
2755
|
+
});
|
|
2756
|
+
return {
|
|
2757
|
+
statistics: getStatisticsQuery.data,
|
|
2758
|
+
isFetching: getStatisticsQuery.isFetching,
|
|
2759
|
+
isLoading: getStatisticsQuery.isLoading,
|
|
2760
|
+
fetchError: getStatisticsQuery.error
|
|
2761
|
+
};
|
|
2762
|
+
};
|
|
2763
|
+
var AutomationTriggerType = /* @__PURE__ */ ((AutomationTriggerType2) => {
|
|
2764
|
+
AutomationTriggerType2["ONE_TIME"] = "one_time";
|
|
2765
|
+
return AutomationTriggerType2;
|
|
2766
|
+
})(AutomationTriggerType || {});
|
|
2767
|
+
var AutomationStatus = /* @__PURE__ */ ((AutomationStatus2) => {
|
|
2768
|
+
AutomationStatus2["DRAFT"] = "draft";
|
|
2769
|
+
AutomationStatus2["ACTIVE"] = "active";
|
|
2770
|
+
AutomationStatus2["RUNNING"] = "running";
|
|
2771
|
+
AutomationStatus2["COMPLETED"] = "completed";
|
|
2772
|
+
AutomationStatus2["FAILED"] = "failed";
|
|
2773
|
+
AutomationStatus2["DEACTIVATED"] = "deactivated";
|
|
2774
|
+
return AutomationStatus2;
|
|
2775
|
+
})(AutomationStatus || {});
|
|
2498
2776
|
var sharedConfig = {
|
|
2499
2777
|
context: void 0,
|
|
2500
2778
|
registry: void 0,
|
|
@@ -7785,115 +8063,6 @@ let D$1 = class D extends Component {
|
|
|
7785
8063
|
return React__default.createElement(a4.Provider, { value: { flags: e4, flagKeyMap: r2, ldClient: n2, error: o2 } }, this.props.children);
|
|
7786
8064
|
}
|
|
7787
8065
|
};
|
|
7788
|
-
let EventEmitter$1 = class EventEmitter {
|
|
7789
|
-
handlers = /* @__PURE__ */ new Map();
|
|
7790
|
-
/**
|
|
7791
|
-
* Subscribes to an event
|
|
7792
|
-
* @template TEvent - Event name literal type
|
|
7793
|
-
* @param {TEvent} event - Event to subscribe to
|
|
7794
|
-
* @param {EventHandler<TEventMap[TEvent]>} handler - Event handler
|
|
7795
|
-
* @returns {Unsubscribe} Unsubscribe function
|
|
7796
|
-
*/
|
|
7797
|
-
subscribe(event, handler) {
|
|
7798
|
-
const handlers = this.handlers.get(event) || /* @__PURE__ */ new Set();
|
|
7799
|
-
handlers.add(handler);
|
|
7800
|
-
this.handlers.set(event, handlers);
|
|
7801
|
-
return () => {
|
|
7802
|
-
const handlersSet = this.handlers.get(event);
|
|
7803
|
-
if (handlersSet) {
|
|
7804
|
-
handlersSet.delete(handler);
|
|
7805
|
-
if (handlersSet.size === 0) {
|
|
7806
|
-
this.handlers.delete(event);
|
|
7807
|
-
}
|
|
7808
|
-
}
|
|
7809
|
-
};
|
|
7810
|
-
}
|
|
7811
|
-
/**
|
|
7812
|
-
* Emits an event with payload
|
|
7813
|
-
* @template TEvent - Event name literal type
|
|
7814
|
-
* @param {TEvent} event - Event to emit
|
|
7815
|
-
* @param {TEventMap[TEvent]} payload - Event payload
|
|
7816
|
-
*/
|
|
7817
|
-
emit(event, payload) {
|
|
7818
|
-
const handlers = this.handlers.get(event);
|
|
7819
|
-
if (handlers) {
|
|
7820
|
-
handlers.forEach((handler) => handler(payload));
|
|
7821
|
-
}
|
|
7822
|
-
}
|
|
7823
|
-
/**
|
|
7824
|
-
* Removes all event handlers
|
|
7825
|
-
*/
|
|
7826
|
-
clearAll() {
|
|
7827
|
-
this.handlers.clear();
|
|
7828
|
-
}
|
|
7829
|
-
};
|
|
7830
|
-
const eventEmitter = new EventEmitter$1();
|
|
7831
|
-
const EVENT_API_UNAUTHORIZED = "api:unauthorized";
|
|
7832
|
-
const EVENT_API_AUTHORIZED = "api:authorized";
|
|
7833
|
-
const CACHE_STANDARD = {
|
|
7834
|
-
// Consider data stale after 5 minutes
|
|
7835
|
-
staleTime: 5 * 60 * 1e3,
|
|
7836
|
-
// Keep inactive data in cache for 10 minutes
|
|
7837
|
-
gcTime: 10 * 60 * 1e3,
|
|
7838
|
-
// Revalidate when window regains focus
|
|
7839
|
-
refetchOnWindowFocus: true
|
|
7840
|
-
};
|
|
7841
|
-
const HOSTNAME = "https://api.embedreach.com";
|
|
7842
|
-
const BASE_URL = `${HOSTNAME}/api`;
|
|
7843
|
-
let authToken;
|
|
7844
|
-
let unauthorizedEventSent = false;
|
|
7845
|
-
let unauthorizedEventTimeout = null;
|
|
7846
|
-
let authorizedEventSent = false;
|
|
7847
|
-
const setAuthToken = (token) => {
|
|
7848
|
-
authToken = token;
|
|
7849
|
-
};
|
|
7850
|
-
const baseRequest = async (endpoint, config = {}) => {
|
|
7851
|
-
const response = await fetch(`${BASE_URL}${endpoint}`, {
|
|
7852
|
-
...config,
|
|
7853
|
-
credentials: "include",
|
|
7854
|
-
headers: {
|
|
7855
|
-
"Content-Type": "application/json",
|
|
7856
|
-
...authToken && { Authorization: `Bearer ${authToken}` },
|
|
7857
|
-
...config.headers
|
|
7858
|
-
}
|
|
7859
|
-
});
|
|
7860
|
-
if (response.status === 401) {
|
|
7861
|
-
if (!unauthorizedEventSent) {
|
|
7862
|
-
unauthorizedEventSent = true;
|
|
7863
|
-
eventEmitter.emit(EVENT_API_UNAUTHORIZED, void 0);
|
|
7864
|
-
if (unauthorizedEventTimeout) {
|
|
7865
|
-
window.clearTimeout(unauthorizedEventTimeout);
|
|
7866
|
-
}
|
|
7867
|
-
unauthorizedEventTimeout = window.setTimeout(() => {
|
|
7868
|
-
unauthorizedEventSent = false;
|
|
7869
|
-
authorizedEventSent = false;
|
|
7870
|
-
unauthorizedEventTimeout = null;
|
|
7871
|
-
}, 5e3);
|
|
7872
|
-
}
|
|
7873
|
-
throw new Error("Unauthorized");
|
|
7874
|
-
}
|
|
7875
|
-
if (!response.ok) {
|
|
7876
|
-
throw new Error(`API Error: ${response.statusText}`);
|
|
7877
|
-
}
|
|
7878
|
-
if (!authorizedEventSent) {
|
|
7879
|
-
eventEmitter.emit(EVENT_API_AUTHORIZED, void 0);
|
|
7880
|
-
authorizedEventSent = true;
|
|
7881
|
-
}
|
|
7882
|
-
return response.json();
|
|
7883
|
-
};
|
|
7884
|
-
const createQueryClient = () => new QueryClient({
|
|
7885
|
-
defaultOptions: {
|
|
7886
|
-
queries: {
|
|
7887
|
-
retry: (failureCount, error2) => {
|
|
7888
|
-
if (error2 instanceof Error && error2.message === "Unauthorized") {
|
|
7889
|
-
return false;
|
|
7890
|
-
}
|
|
7891
|
-
return failureCount < 3;
|
|
7892
|
-
},
|
|
7893
|
-
...CACHE_STANDARD
|
|
7894
|
-
}
|
|
7895
|
-
}
|
|
7896
|
-
});
|
|
7897
8066
|
const TOAST_LIMIT = 1;
|
|
7898
8067
|
const TOAST_REMOVE_DELAY = 1e6;
|
|
7899
8068
|
let count$2 = 0;
|
|
@@ -25352,175 +25521,6 @@ const createMotionComponent = /* @__PURE__ */ createMotionComponentFactory({
|
|
|
25352
25521
|
...layout
|
|
25353
25522
|
}, createDomVisualElement);
|
|
25354
25523
|
const motion = /* @__PURE__ */ createDOMMotionComponentProxy(createMotionComponent);
|
|
25355
|
-
const BUSINESS_SEGMENT_PATH = "/segments";
|
|
25356
|
-
const BUSINESS_AUTOMATION_PATH = "/automations";
|
|
25357
|
-
const CHANNEL_SENDER_PATH = "/channel/senders";
|
|
25358
|
-
const CHANNEL_ACCOUNT_PATH = "/channel/accounts";
|
|
25359
|
-
const COMMUNICATION_GROUP_PATH = "/communication-groups";
|
|
25360
|
-
const STRIPO_PATH = "/stripo";
|
|
25361
|
-
const createAutomation = async (params) => {
|
|
25362
|
-
const response = await baseRequest(
|
|
25363
|
-
BUSINESS_AUTOMATION_PATH,
|
|
25364
|
-
{
|
|
25365
|
-
method: "POST",
|
|
25366
|
-
body: JSON.stringify(params)
|
|
25367
|
-
}
|
|
25368
|
-
);
|
|
25369
|
-
return response.data;
|
|
25370
|
-
};
|
|
25371
|
-
const getAutomation = async (automationId) => {
|
|
25372
|
-
const response = await baseRequest(
|
|
25373
|
-
`${BUSINESS_AUTOMATION_PATH}/${automationId}`
|
|
25374
|
-
);
|
|
25375
|
-
return response.data;
|
|
25376
|
-
};
|
|
25377
|
-
const getAutomationRecipients = async (automationId) => {
|
|
25378
|
-
const response = await baseRequest(
|
|
25379
|
-
`${BUSINESS_AUTOMATION_PATH}/${automationId}/recipients`
|
|
25380
|
-
);
|
|
25381
|
-
return response.data;
|
|
25382
|
-
};
|
|
25383
|
-
const updateAutomation = async (id2, params) => {
|
|
25384
|
-
const response = await baseRequest(
|
|
25385
|
-
`${BUSINESS_AUTOMATION_PATH}/${id2}`,
|
|
25386
|
-
{
|
|
25387
|
-
method: "PATCH",
|
|
25388
|
-
body: JSON.stringify(params)
|
|
25389
|
-
}
|
|
25390
|
-
);
|
|
25391
|
-
return response.data;
|
|
25392
|
-
};
|
|
25393
|
-
const getBusinessAutomationStatistics = async (automationId) => {
|
|
25394
|
-
if (!automationId) {
|
|
25395
|
-
const response = await baseRequest(
|
|
25396
|
-
`${BUSINESS_AUTOMATION_PATH}/statistics`
|
|
25397
|
-
);
|
|
25398
|
-
return response.data;
|
|
25399
|
-
} else {
|
|
25400
|
-
const response = await baseRequest(
|
|
25401
|
-
`${BUSINESS_AUTOMATION_PATH}/${automationId}/statistics`
|
|
25402
|
-
);
|
|
25403
|
-
return response.data;
|
|
25404
|
-
}
|
|
25405
|
-
};
|
|
25406
|
-
const listBusinessAutomations = async (args) => {
|
|
25407
|
-
const params = new URLSearchParams();
|
|
25408
|
-
if (args.cursor) params.append("cursor", args.cursor);
|
|
25409
|
-
if (args.limit) params.append("limit", args.limit.toString());
|
|
25410
|
-
if (args.status) params.append("status", args.status);
|
|
25411
|
-
if (args.search) params.append("search", args.search);
|
|
25412
|
-
const response = await baseRequest(
|
|
25413
|
-
`${BUSINESS_AUTOMATION_PATH}?${params.toString()}`,
|
|
25414
|
-
{
|
|
25415
|
-
method: "GET"
|
|
25416
|
-
}
|
|
25417
|
-
);
|
|
25418
|
-
return response.data;
|
|
25419
|
-
};
|
|
25420
|
-
const duplicateBusinessAutomation = async (automationId) => {
|
|
25421
|
-
const response = await baseRequest(
|
|
25422
|
-
`${BUSINESS_AUTOMATION_PATH}`,
|
|
25423
|
-
{
|
|
25424
|
-
method: "POST",
|
|
25425
|
-
body: JSON.stringify({
|
|
25426
|
-
duplicate: true,
|
|
25427
|
-
source_id: automationId
|
|
25428
|
-
})
|
|
25429
|
-
}
|
|
25430
|
-
);
|
|
25431
|
-
return response.data;
|
|
25432
|
-
};
|
|
25433
|
-
const useGetBusinessAutomation = (automationId) => {
|
|
25434
|
-
const queryClient = useQueryClient();
|
|
25435
|
-
const getAutomationQuery = useQuery({
|
|
25436
|
-
queryKey: ["automations", automationId],
|
|
25437
|
-
queryFn: () => getAutomation(automationId)
|
|
25438
|
-
});
|
|
25439
|
-
return {
|
|
25440
|
-
// Get automation query
|
|
25441
|
-
automation: getAutomationQuery.data,
|
|
25442
|
-
isFetching: getAutomationQuery.isFetching,
|
|
25443
|
-
isLoading: getAutomationQuery.isLoading,
|
|
25444
|
-
fetchError: getAutomationQuery.error,
|
|
25445
|
-
refetchAutomation: getAutomationQuery.refetch,
|
|
25446
|
-
invalidateAutomation: () => queryClient.invalidateQueries({
|
|
25447
|
-
queryKey: ["automations", automationId]
|
|
25448
|
-
})
|
|
25449
|
-
};
|
|
25450
|
-
};
|
|
25451
|
-
const useGetBusinessAutomationRecipients = (automationId) => {
|
|
25452
|
-
const getAutomationRecipientsQuery = useQuery({
|
|
25453
|
-
queryKey: ["automations", automationId, "recipients"],
|
|
25454
|
-
queryFn: () => getAutomationRecipients(automationId)
|
|
25455
|
-
});
|
|
25456
|
-
return {
|
|
25457
|
-
// Get automation recipients query
|
|
25458
|
-
recipients: getAutomationRecipientsQuery.data,
|
|
25459
|
-
isFetching: getAutomationRecipientsQuery.isFetching,
|
|
25460
|
-
isLoading: getAutomationRecipientsQuery.isLoading,
|
|
25461
|
-
fetchError: getAutomationRecipientsQuery.error,
|
|
25462
|
-
refetchAutomationRecipients: getAutomationRecipientsQuery.refetch
|
|
25463
|
-
};
|
|
25464
|
-
};
|
|
25465
|
-
const useCreateBusinessAutomation = () => {
|
|
25466
|
-
const queryClient = useQueryClient();
|
|
25467
|
-
const createAutomationMutation = useMutation({
|
|
25468
|
-
mutationFn: (params) => createAutomation(params),
|
|
25469
|
-
onSuccess: () => {
|
|
25470
|
-
queryClient.invalidateQueries({ queryKey: ["automations"] });
|
|
25471
|
-
}
|
|
25472
|
-
});
|
|
25473
|
-
return {
|
|
25474
|
-
// Create automation mutation
|
|
25475
|
-
createAutomation: createAutomationMutation.mutate,
|
|
25476
|
-
isCreating: createAutomationMutation.isPending,
|
|
25477
|
-
createError: createAutomationMutation.error,
|
|
25478
|
-
isCreateSuccess: createAutomationMutation.isSuccess
|
|
25479
|
-
};
|
|
25480
|
-
};
|
|
25481
|
-
const useUpdateBusinessAutomation = (automationId) => {
|
|
25482
|
-
const queryClient = useQueryClient();
|
|
25483
|
-
const updateAutomationMutation = useMutation({
|
|
25484
|
-
mutationFn: (params) => updateAutomation(automationId, params),
|
|
25485
|
-
onSuccess: () => {
|
|
25486
|
-
queryClient.invalidateQueries({ queryKey: ["automations"] });
|
|
25487
|
-
queryClient.invalidateQueries({
|
|
25488
|
-
queryKey: ["automations", automationId]
|
|
25489
|
-
});
|
|
25490
|
-
}
|
|
25491
|
-
});
|
|
25492
|
-
return {
|
|
25493
|
-
updateAutomation: updateAutomationMutation.mutate,
|
|
25494
|
-
isUpdating: updateAutomationMutation.isPending,
|
|
25495
|
-
updateError: updateAutomationMutation.error,
|
|
25496
|
-
isUpdateSuccess: updateAutomationMutation.isSuccess
|
|
25497
|
-
};
|
|
25498
|
-
};
|
|
25499
|
-
const useGetBusinessAutomationStatistics = (automationId) => {
|
|
25500
|
-
const getStatisticsQuery = useQuery({
|
|
25501
|
-
queryKey: ["automations", automationId, "statistics"],
|
|
25502
|
-
queryFn: () => getBusinessAutomationStatistics(automationId)
|
|
25503
|
-
});
|
|
25504
|
-
return {
|
|
25505
|
-
statistics: getStatisticsQuery.data,
|
|
25506
|
-
isFetching: getStatisticsQuery.isFetching,
|
|
25507
|
-
isLoading: getStatisticsQuery.isLoading,
|
|
25508
|
-
fetchError: getStatisticsQuery.error
|
|
25509
|
-
};
|
|
25510
|
-
};
|
|
25511
|
-
var AutomationTriggerType = /* @__PURE__ */ ((AutomationTriggerType2) => {
|
|
25512
|
-
AutomationTriggerType2["ONE_TIME"] = "one_time";
|
|
25513
|
-
return AutomationTriggerType2;
|
|
25514
|
-
})(AutomationTriggerType || {});
|
|
25515
|
-
var AutomationStatus = /* @__PURE__ */ ((AutomationStatus2) => {
|
|
25516
|
-
AutomationStatus2["DRAFT"] = "draft";
|
|
25517
|
-
AutomationStatus2["ACTIVE"] = "active";
|
|
25518
|
-
AutomationStatus2["RUNNING"] = "running";
|
|
25519
|
-
AutomationStatus2["COMPLETED"] = "completed";
|
|
25520
|
-
AutomationStatus2["FAILED"] = "failed";
|
|
25521
|
-
AutomationStatus2["DEACTIVATED"] = "deactivated";
|
|
25522
|
-
return AutomationStatus2;
|
|
25523
|
-
})(AutomationStatus || {});
|
|
25524
25524
|
const createCommunicationGroup = async (params) => {
|
|
25525
25525
|
const response = await baseRequest(
|
|
25526
25526
|
`${COMMUNICATION_GROUP_PATH}`,
|
|
@@ -47131,13 +47131,14 @@ export {
|
|
|
47131
47131
|
Switch$2 as T,
|
|
47132
47132
|
deleteNestedDataByPath as U,
|
|
47133
47133
|
useTransition as V,
|
|
47134
|
-
|
|
47135
|
-
|
|
47136
|
-
|
|
47137
|
-
|
|
47138
|
-
|
|
47134
|
+
AutomationTriggerType as W,
|
|
47135
|
+
ReachProvider as X,
|
|
47136
|
+
CreateAutomationDialog as Y,
|
|
47137
|
+
CreateAutomationModal as Z,
|
|
47138
|
+
Engage as _,
|
|
47139
47139
|
createComponent as a,
|
|
47140
|
-
|
|
47140
|
+
SegmentBuilderDialog as a0,
|
|
47141
|
+
ViewAutomationModal as a1,
|
|
47141
47142
|
createSignal as b,
|
|
47142
47143
|
createMemo as c,
|
|
47143
47144
|
delegateEvents as d,
|
package/dist/index.d.ts
CHANGED
package/dist/index.es.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { W, Y, Z, _, X, a0, a1 } from "./chunks/index.js";
|
|
2
2
|
export {
|
|
3
|
-
|
|
4
|
-
Y as
|
|
5
|
-
Z as
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
a0 as
|
|
3
|
+
W as AutomationTriggerType,
|
|
4
|
+
Y as CreateAutomationDialog,
|
|
5
|
+
Z as CreateAutomationModal,
|
|
6
|
+
_ as Engage,
|
|
7
|
+
X as ReachProvider,
|
|
8
|
+
a0 as SegmentBuilderDialog,
|
|
9
|
+
a1 as ViewAutomationModal
|
|
9
10
|
};
|