@livechat/developer-studio-api 5.3.0-beta.v1 → 5.3.1-beta.generator

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.js CHANGED
@@ -152,6 +152,7 @@ __export(src_exports, {
152
152
  cdpCustomerEventMessageZod: () => cdpCustomerEventMessageZod,
153
153
  consoleClientInstance: () => consoleClientInstance,
154
154
  dpsClientInstance: () => dpsClientInstance,
155
+ enrichWorkflowTrigger: () => enrichWorkflowTrigger,
155
156
  extractTokenFromAuthorizationHeader: () => extractTokenFromAuthorizationHeader,
156
157
  getAdapterClientConfig: () => getAdapterClientConfig,
157
158
  getAdapterClientDefaultConfig: () => getAdapterClientDefaultConfig,
@@ -225,6 +226,7 @@ __export(src_exports, {
225
226
  integrationSubscriptionZods: () => integrationSubscriptionZods,
226
227
  isFilter: () => isFilter,
227
228
  isFilterGroup: () => isFilterGroup,
229
+ isWorkflowBaseHttpTaskCore: () => isWorkflowBaseHttpTaskCore,
228
230
  livechatClientInstance: () => livechatClientInstance,
229
231
  mailchimpClientInstance: () => mailchimpClientInstance,
230
232
  mailchimpEventsZods: () => mailchimpEventsZods,
@@ -2268,7 +2270,7 @@ var KLAVIYO_API_REVISION = "2025-07-15";
2268
2270
  var klaviyoApi = {
2269
2271
  getAccount(_0) {
2270
2272
  return __async(this, arguments, function* ({ token }) {
2271
- var _a, _b, _c, _d;
2273
+ var _a, _b, _c;
2272
2274
  const { data } = yield import_axios7.default.get(
2273
2275
  "https://a.klaviyo.com/api/accounts/",
2274
2276
  {
@@ -2278,9 +2280,10 @@ var klaviyoApi = {
2278
2280
  }
2279
2281
  }
2280
2282
  );
2281
- const contactInformationEmail = (_d = (_c = (_b = (_a = data.data) == null ? void 0 : _a[0]) == null ? void 0 : _b.attributes) == null ? void 0 : _c.contact_information) == null ? void 0 : _d.default_sender_email;
2283
+ const contactInformation = (_c = (_b = (_a = data.data) == null ? void 0 : _a[0]) == null ? void 0 : _b.attributes) == null ? void 0 : _c.contact_information;
2282
2284
  return {
2283
- email: contactInformationEmail
2285
+ email: contactInformation == null ? void 0 : contactInformation.default_sender_email,
2286
+ organizationName: contactInformation == null ? void 0 : contactInformation.organization_name
2284
2287
  };
2285
2288
  });
2286
2289
  }
@@ -4507,6 +4510,11 @@ var WorkflowExecutionTaskStatus = /* @__PURE__ */ ((WorkflowExecutionTaskStatus2
4507
4510
  return WorkflowExecutionTaskStatus2;
4508
4511
  })(WorkflowExecutionTaskStatus || {});
4509
4512
 
4513
+ // src/apis/integrations/text/platform/workflow/workflows/_contracts/dtos/tasks/http.ts
4514
+ function isWorkflowBaseHttpTaskCore(task) {
4515
+ return task.name === WorkflowTaskType.http;
4516
+ }
4517
+
4510
4518
  // src/apis/integrations/text/platform/workflow/workflows/_contracts/dtos/tasks/switch/variants/condition.ts
4511
4519
  var WorkflowConditionTaskLogic = /* @__PURE__ */ ((WorkflowConditionTaskLogic2) => {
4512
4520
  WorkflowConditionTaskLogic2["AND"] = "AND";
@@ -4818,177 +4826,490 @@ function getWorkflowApiCrmConfig(authorization) {
4818
4826
  });
4819
4827
  }
4820
4828
 
4821
- // src/apis/integrations/vercel/instance.ts
4822
- var import_axios23 = __toESM(require("axios"));
4823
- function getVercelClientAuthorization(req, headerPrefix = "x-adapter-vercel") {
4824
- if (req.headers instanceof Headers) {
4825
- return {
4826
- token: req.headers.get(`${headerPrefix}-token`)
4827
- };
4828
- }
4829
- return {
4830
- token: req.headers[`${headerPrefix}-token`]
4831
- };
4832
- }
4833
- var vercelClientInstance = import_axios23.default.create({
4834
- baseURL: "https://api.vercel.com"
4835
- });
4836
- vercelClientInstance.interceptors.response.use(
4837
- (r) => r,
4838
- (error) => {
4839
- var _a, _b;
4840
- if (import_axios23.default.isAxiosError(error)) {
4841
- if (((_a = error.response) == null ? void 0 : _a.status) === 401 || ((_b = error.response) == null ? void 0 : _b.status) === 403) {
4842
- throw new UnauthorizeApiError("vercel");
4829
+ // src/apis/integrations/text/platform/workflow/workflows/internal/crm/api.ts
4830
+ var getUrl3 = (segments = []) => buildUrlFromSegments(segments, "/internal/crm");
4831
+ var urls4 = {
4832
+ getOrganizations: (queryParams) => enrichUrlWithQueryParams(getUrl3(["stats"]), queryParams),
4833
+ getOrganization: (organizationId) => getUrl3(["stats", organizationId]),
4834
+ getWorkflows: (queryParams) => enrichUrlWithQueryParams(getUrl3(["workflows"]), queryParams),
4835
+ getWorkflow: (id) => getUrl3(["workflows", id]),
4836
+ getWorkflowExecutions: (id, queryParams) => enrichUrlWithQueryParams(
4837
+ getUrl3(["workflows", id, "executions"]),
4838
+ queryParams
4839
+ ),
4840
+ getWorkflowExecution: (id, executionId) => getUrl3(["workflows", id, "executions", executionId]),
4841
+ getWorkflowIntrospection: (id) => getUrl3(["workflows", id, "metadata"])
4842
+ };
4843
+ var textPlatformWorkflowsInternalCrmApi = {
4844
+ meta: {
4845
+ urls: urls4
4846
+ },
4847
+ getOrganizations(queryParams, authorization) {
4848
+ return __async(this, null, function* () {
4849
+ const { data: organizations } = yield textClientInstance.get(
4850
+ urls4.getOrganizations(queryParams),
4851
+ getWorkflowApiCrmConfig(authorization)
4852
+ );
4853
+ return organizations;
4854
+ });
4855
+ },
4856
+ getOrganization(organizationId, authorization) {
4857
+ return __async(this, null, function* () {
4858
+ const { data: organization } = yield textClientInstance.get(
4859
+ urls4.getOrganization(organizationId),
4860
+ getWorkflowApiCrmConfig(authorization)
4861
+ );
4862
+ return organization;
4863
+ });
4864
+ },
4865
+ getWorkflows(queryParams, authorization) {
4866
+ return __async(this, null, function* () {
4867
+ const { data: workflows } = yield textClientInstance.get(urls4.getWorkflows(queryParams), getWorkflowApiCrmConfig(authorization));
4868
+ workflows.data = workflows.data.map(enrichWorkflowTrigger);
4869
+ return workflows;
4870
+ });
4871
+ },
4872
+ getWorkflow(workflowId, authorization) {
4873
+ return __async(this, null, function* () {
4874
+ const searchParams = new URLSearchParams();
4875
+ const query = searchParams.toString();
4876
+ const { data: workflow } = yield textClientInstance.get(
4877
+ `${urls4.getWorkflow(workflowId)}${query ? `?${query}` : ""}`,
4878
+ getWorkflowApiCrmConfig(authorization)
4879
+ );
4880
+ return enrichWorkflowTrigger(workflow);
4881
+ });
4882
+ },
4883
+ getWorkflowExecutions(workflowId, queryParams, authorization) {
4884
+ return __async(this, null, function* () {
4885
+ const { data: executions } = yield textClientInstance.get(
4886
+ urls4.getWorkflowExecutions(workflowId, queryParams),
4887
+ getWorkflowApiCrmConfig(authorization)
4888
+ );
4889
+ return executions;
4890
+ });
4891
+ },
4892
+ getWorkflowExecution(workflowId, executionId, authorization) {
4893
+ return __async(this, null, function* () {
4894
+ const { data: execution } = yield textClientInstance.get(
4895
+ urls4.getWorkflowExecution(workflowId, executionId),
4896
+ getWorkflowApiCrmConfig(authorization)
4897
+ );
4898
+ return execution;
4899
+ });
4900
+ },
4901
+ getWorkflowIntrospection(workflowId, version, authorization) {
4902
+ return __async(this, null, function* () {
4903
+ const searchParams = new URLSearchParams();
4904
+ if (version) {
4905
+ searchParams.append("version", `${version}`);
4843
4906
  }
4844
- }
4845
- throw error;
4846
- }
4847
- );
4848
- function getVercelClientConfig(options = {}) {
4849
- var _a;
4850
- const currentHeaders = vercelClientInstance.defaults.headers;
4851
- const config = {
4852
- authorization: (_a = options.token ? `Bearer ${options.token}` : void 0) != null ? _a : currentHeaders.Authorization
4853
- };
4854
- if (options.ensureAuthorizationToken && !config.authorization) {
4855
- throw new UnauthorizeApiError("vercel");
4856
- }
4857
- return {
4858
- headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
4859
- };
4860
- }
4861
- function initVercelClient(token) {
4862
- if (token) {
4863
- updateVercelClient(token);
4864
- }
4865
- }
4866
- function updateVercelClient(token) {
4867
- const headers = vercelClientInstance.defaults.headers;
4868
- if (token) {
4869
- headers.Authorization = `Bearer ${token}`;
4870
- } else {
4871
- delete headers.Authorization;
4907
+ const query = searchParams.toString();
4908
+ const { data: introspection } = yield textClientInstance.get(
4909
+ `${urls4.getWorkflowIntrospection(workflowId)}${query ? `?${query}` : ""}`,
4910
+ getWorkflowApiCrmConfig(authorization)
4911
+ );
4912
+ return {
4913
+ tasks: introspection
4914
+ };
4915
+ });
4872
4916
  }
4873
- }
4917
+ };
4874
4918
 
4875
- // src/apis/platform/accounts/instance.ts
4876
- var AccountsApiError = class extends ApiErrorBase {
4877
- constructor() {
4878
- super(...arguments);
4879
- this.name = "accounts";
4880
- }
4919
+ // src/apis/integrations/text/platform/workflow/workflows/internal/api.ts
4920
+ var textPlatformWorkflowsInternalApi = {
4921
+ crm: textPlatformWorkflowsInternalCrmApi
4881
4922
  };
4882
- var UnauthorizeAccountsApiError = class extends UnauthorizeApiError {
4883
- constructor(message) {
4884
- super("accounts", message);
4923
+
4924
+ // src/apis/integrations/text/platform/workflow/workflows/api.ts
4925
+ var enrichWorkflowTrigger = (workflow) => {
4926
+ var _a, _b, _c, _d, _e, _f, _g, _h;
4927
+ if (((_a = workflow.trigger) == null ? void 0 : _a.type) === WorkflowTriggerType.webhook) {
4928
+ workflow.trigger.name = (_c = workflow.trigger.sub_type) != null ? _c : `${workflow.trigger.webhook.source}-${(_b = workflow.trigger.webhook.event) == null ? void 0 : _b.name}`;
4885
4929
  }
4886
- };
4887
- var AccountApiClient = class extends ApiClient {
4888
- constructor() {
4889
- super(...arguments);
4890
- this.UnauthorizedError = UnauthorizeAccountsApiError;
4891
- this.Error = AccountsApiError;
4892
- this.options = {
4893
- headers: {
4894
- "Content-Type": "application/json"
4895
- }
4896
- };
4930
+ if (((_d = workflow.trigger) == null ? void 0 : _d.type) === WorkflowTriggerType.webhookManual) {
4931
+ workflow.trigger.name = "webhook_manual";
4897
4932
  }
4898
- };
4899
- var platformAccountsClientInstance = new AccountApiClient({
4900
- baseURL: "https://accounts.labs.livechatinc.com"
4901
- });
4902
- function initPlatformAccountsClient(baseUrl, token) {
4903
- if (baseUrl) {
4904
- platformAccountsClientInstance.updateConfig({
4905
- baseURL: baseUrl
4906
- });
4933
+ if (((_e = workflow.trigger) == null ? void 0 : _e.type) === WorkflowTriggerType.manual) {
4934
+ workflow.trigger.name = "manual";
4907
4935
  }
4908
- platformAccountsClientInstance.updateAuthorization({
4909
- token
4910
- });
4911
- }
4912
-
4913
- // src/apis/platform/billing/instance.ts
4914
- var import_axios24 = __toESM(require("axios"));
4915
- var billingClientInstance = import_axios24.default.create({
4916
- baseURL: "https://billing.labs.livechatinc.com"
4917
- });
4918
- function getBillingClientConfig(options = {}) {
4919
- var _a;
4920
- const defaultAuthorization = billingClientInstance.defaults.headers.Authorization;
4921
- const headers = {
4922
- authorization: (_a = options.token ? `Bearer ${options.token}` : void 0) != null ? _a : defaultAuthorization
4923
- };
4924
- return {
4925
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
4926
- };
4927
- }
4928
- function initBillingClient(baseUrl, token) {
4929
- if (baseUrl) {
4930
- billingClientInstance.interceptors.request.use(
4931
- (config) => {
4932
- config.baseURL = baseUrl;
4933
- return config;
4934
- },
4935
- (error) => Promise.reject(error)
4936
- );
4936
+ if (((_f = workflow.trigger) == null ? void 0 : _f.type) === WorkflowTriggerType.agent) {
4937
+ workflow.trigger.name = "ai_agent";
4937
4938
  }
4938
- if (token) {
4939
- billingClientInstance.defaults.headers.Authorization = `Bearer ${token}`;
4940
- } else {
4941
- delete billingClientInstance.defaults.headers.Authorization;
4939
+ if (((_g = workflow.trigger) == null ? void 0 : _g.type) === WorkflowTriggerType.recurring) {
4940
+ workflow.trigger.name = "scheduled";
4942
4941
  }
4943
- }
4944
-
4945
- // src/apis/platform/cdp/events/_contracts/payloads/events.ts
4946
- var import_zod12 = require("zod");
4947
- var CdpCustomerEventType = /* @__PURE__ */ ((CdpCustomerEventType2) => {
4948
- CdpCustomerEventType2["EmailSet"] = "customer_email_set";
4949
- CdpCustomerEventType2["PropertiesValuesUpdated"] = "customer_properties_values_updated";
4950
- return CdpCustomerEventType2;
4951
- })(CdpCustomerEventType || {});
4952
- var customerMetadataZod = import_zod12.z.object({
4953
- organization_id: import_zod12.z.string(),
4954
- customer_id: import_zod12.z.string(),
4955
- master_id: import_zod12.z.string()
4956
- });
4957
- var cdpCustomerEventMessageZod = import_zod12.z.discriminatedUnion("type", [
4958
- import_zod12.z.object({
4959
- id: import_zod12.z.string(),
4960
- type: import_zod12.z.literal("customer_email_set" /* EmailSet */),
4961
- data: customerMetadataZod.extend({
4962
- email: import_zod12.z.string()
4963
- }).passthrough()
4964
- }),
4965
- import_zod12.z.object({
4966
- id: import_zod12.z.string(),
4967
- type: import_zod12.z.literal("customer_properties_values_updated" /* PropertiesValuesUpdated */),
4968
- data: customerMetadataZod.extend({
4969
- customer_properties: import_zod12.z.record(
4970
- import_zod12.z.object({
4971
- value: import_zod12.z.unknown(),
4972
- last_updated_at: import_zod12.z.string(),
4973
- last_updated_agent_account_id: import_zod12.z.string().optional(),
4974
- last_updated_agent_client_id: import_zod12.z.string().optional()
4975
- }).passthrough()
4976
- )
4977
- }).passthrough()
4978
- })
4979
- ]);
4980
-
4981
- // src/apis/platform/console/instance.ts
4982
- var import_axios25 = __toESM(require("axios"));
4983
- var REGION = {
4984
- FRA: "fra",
4985
- DAL: "dal",
4986
- FRA_A: "fra-a",
4987
- FRA_B: "fra-b"
4942
+ if (((_h = workflow.trigger) == null ? void 0 : _h.type) === WorkflowTriggerType.oneTime) {
4943
+ workflow.trigger.name = "one_time";
4944
+ }
4945
+ return workflow;
4988
4946
  };
4989
- var supportedRegions = Object.values(REGION);
4990
- var getRegion = (token) => {
4991
- const region = token.split(":")[0];
4947
+ var getUrl4 = (segments = [], version) => buildUrlFromSegments(
4948
+ segments,
4949
+ `/workflow_platform/${version ? `${version}/` : ""}workflows`
4950
+ );
4951
+ var urls5 = {
4952
+ getWorkflows: (queryParams) => enrichUrlWithQueryParams(getUrl4([], "v1.0" /* V1 */), queryParams),
4953
+ createWorkflow: () => getUrl4(),
4954
+ getWorkflow: (id) => getUrl4([id], "v1.0" /* V1 */),
4955
+ updateWorkflow: (id) => getUrl4([id]),
4956
+ deleteWorkflow: (id) => getUrl4([id]),
4957
+ createWorkflowDraft: (id) => getUrl4([id, "draft"]),
4958
+ publishWorkflowDraft: (id) => getUrl4([id, "publish"]),
4959
+ toggleWorkflowActivation: (id) => getUrl4([id, "activation"]),
4960
+ executeWorkflow: (id) => getUrl4([id, "executions"]),
4961
+ getWorkflowExecutions: (id, queryParams) => enrichUrlWithQueryParams(
4962
+ getUrl4([id, "executions"], "v1.0" /* V1 */),
4963
+ queryParams
4964
+ ),
4965
+ getWorkflowExecution: (id, executionId) => getUrl4([id, "executions", executionId], "v1.0" /* V1 */),
4966
+ getWorkflowIntrospection: (id) => getUrl4([id, "metadata"], "v1.0" /* V1 */),
4967
+ introspectWorkflowTask: (id) => getUrl4([id, "run_task"], "v1.0" /* V1 */)
4968
+ };
4969
+ var textPlatformWorkflowsApi = {
4970
+ internal: textPlatformWorkflowsInternalApi,
4971
+ meta: {
4972
+ urls: urls5
4973
+ },
4974
+ getWorkflows(queryParams, authorization) {
4975
+ return __async(this, null, function* () {
4976
+ const { data: workflows } = yield textClientInstance.get(
4977
+ urls5.getWorkflows(queryParams),
4978
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
4979
+ ensureAuthorizationToken: true
4980
+ }))
4981
+ );
4982
+ workflows.data = workflows.data.map(enrichWorkflowTrigger);
4983
+ return workflows;
4984
+ });
4985
+ },
4986
+ getWorkflow(workflowId, version, authorization) {
4987
+ return __async(this, null, function* () {
4988
+ const searchParams = new URLSearchParams();
4989
+ if (version) {
4990
+ searchParams.append("version", `${version}`);
4991
+ }
4992
+ const query = searchParams.toString();
4993
+ const { data: workflow } = yield textClientInstance.get(
4994
+ `${urls5.getWorkflow(workflowId)}${query ? `?${query}` : ""}`,
4995
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
4996
+ ensureAuthorizationToken: true
4997
+ }))
4998
+ );
4999
+ return enrichWorkflowTrigger(workflow);
5000
+ });
5001
+ },
5002
+ createWorkflow(payload, authorization) {
5003
+ return __async(this, null, function* () {
5004
+ return textClientInstance.post(
5005
+ urls5.createWorkflow(),
5006
+ __spreadProps(__spreadValues({}, payload), {
5007
+ trigger: payload.trigger || {}
5008
+ }),
5009
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
5010
+ ensureAuthorizationToken: true
5011
+ }))
5012
+ );
5013
+ });
5014
+ },
5015
+ updateWorkflow(workflowId, payload, authorization) {
5016
+ return __async(this, null, function* () {
5017
+ return textClientInstance.put(
5018
+ urls5.updateWorkflow(workflowId),
5019
+ __spreadProps(__spreadValues({}, payload), {
5020
+ trigger: payload.trigger || {}
5021
+ }),
5022
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
5023
+ ensureAuthorizationToken: true
5024
+ }))
5025
+ );
5026
+ });
5027
+ },
5028
+ deleteWorkflow(workflowId, authorization) {
5029
+ return __async(this, null, function* () {
5030
+ return textClientInstance.delete(urls5.deleteWorkflow(workflowId), __spreadValues({}, getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
5031
+ ensureAuthorizationToken: true
5032
+ }))));
5033
+ });
5034
+ },
5035
+ createWorkflowDraft(workflowId, payload, authorization) {
5036
+ return __async(this, null, function* () {
5037
+ return textClientInstance.post(
5038
+ urls5.createWorkflowDraft(workflowId),
5039
+ __spreadProps(__spreadValues({}, payload), {
5040
+ trigger: payload.trigger || {}
5041
+ }),
5042
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
5043
+ ensureAuthorizationToken: true
5044
+ }))
5045
+ );
5046
+ });
5047
+ },
5048
+ publishWorkflowDraft(workflowId, authorization) {
5049
+ return __async(this, null, function* () {
5050
+ return textClientInstance.post(
5051
+ urls5.publishWorkflowDraft(workflowId),
5052
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
5053
+ ensureAuthorizationToken: true
5054
+ }))
5055
+ );
5056
+ });
5057
+ },
5058
+ toggleWorkflowActivation(workflowId, isActive, authorization) {
5059
+ return __async(this, null, function* () {
5060
+ return textClientInstance.put(
5061
+ urls5.toggleWorkflowActivation(workflowId),
5062
+ {
5063
+ active: isActive
5064
+ },
5065
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
5066
+ ensureAuthorizationToken: true
5067
+ }))
5068
+ );
5069
+ });
5070
+ },
5071
+ executeWorkflow(workflowId, input, authorization) {
5072
+ return __async(this, null, function* () {
5073
+ const { data: execution } = yield textClientInstance.post(
5074
+ urls5.executeWorkflow(workflowId),
5075
+ {
5076
+ input
5077
+ },
5078
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
5079
+ ensureAuthorizationToken: true
5080
+ }))
5081
+ );
5082
+ return execution;
5083
+ });
5084
+ },
5085
+ getWorkflowExecutions(workflowId, queryParams, authorization) {
5086
+ return __async(this, null, function* () {
5087
+ const { data: executions } = yield textClientInstance.get(
5088
+ urls5.getWorkflowExecutions(workflowId, queryParams),
5089
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
5090
+ ensureAuthorizationToken: true
5091
+ }))
5092
+ );
5093
+ return executions;
5094
+ });
5095
+ },
5096
+ getWorkflowExecution(workflowId, executionId, authorization) {
5097
+ return __async(this, null, function* () {
5098
+ const { data: execution } = yield textClientInstance.get(
5099
+ urls5.getWorkflowExecution(workflowId, executionId),
5100
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
5101
+ ensureAuthorizationToken: true
5102
+ }))
5103
+ );
5104
+ return execution;
5105
+ });
5106
+ },
5107
+ getWorkflowIntrospection(workflowId, version, authorization) {
5108
+ return __async(this, null, function* () {
5109
+ const searchParams = new URLSearchParams();
5110
+ if (version) {
5111
+ searchParams.append("version", `${version}`);
5112
+ }
5113
+ const query = searchParams.toString();
5114
+ const { data: introspection } = yield textClientInstance.get(
5115
+ `${urls5.getWorkflowIntrospection(workflowId)}${query ? `?${query}` : ""}`,
5116
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
5117
+ ensureAuthorizationToken: true
5118
+ }))
5119
+ );
5120
+ return {
5121
+ tasks: introspection
5122
+ };
5123
+ });
5124
+ },
5125
+ introspectWorkflowTask(workflowId, payload, authorization) {
5126
+ return __async(this, null, function* () {
5127
+ const response = yield textClientInstance.post(
5128
+ urls5.introspectWorkflowTask(workflowId),
5129
+ {
5130
+ task_reference_name: payload.taskReferenceName,
5131
+ input_parameters: payload.inputParameters
5132
+ },
5133
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
5134
+ ensureAuthorizationToken: true
5135
+ }))
5136
+ );
5137
+ return response.data;
5138
+ });
5139
+ }
5140
+ };
5141
+
5142
+ // src/apis/integrations/vercel/instance.ts
5143
+ var import_axios23 = __toESM(require("axios"));
5144
+ function getVercelClientAuthorization(req, headerPrefix = "x-adapter-vercel") {
5145
+ if (req.headers instanceof Headers) {
5146
+ return {
5147
+ token: req.headers.get(`${headerPrefix}-token`)
5148
+ };
5149
+ }
5150
+ return {
5151
+ token: req.headers[`${headerPrefix}-token`]
5152
+ };
5153
+ }
5154
+ var vercelClientInstance = import_axios23.default.create({
5155
+ baseURL: "https://api.vercel.com"
5156
+ });
5157
+ vercelClientInstance.interceptors.response.use(
5158
+ (r) => r,
5159
+ (error) => {
5160
+ var _a, _b;
5161
+ if (import_axios23.default.isAxiosError(error)) {
5162
+ if (((_a = error.response) == null ? void 0 : _a.status) === 401 || ((_b = error.response) == null ? void 0 : _b.status) === 403) {
5163
+ throw new UnauthorizeApiError("vercel");
5164
+ }
5165
+ }
5166
+ throw error;
5167
+ }
5168
+ );
5169
+ function getVercelClientConfig(options = {}) {
5170
+ var _a;
5171
+ const currentHeaders = vercelClientInstance.defaults.headers;
5172
+ const config = {
5173
+ authorization: (_a = options.token ? `Bearer ${options.token}` : void 0) != null ? _a : currentHeaders.Authorization
5174
+ };
5175
+ if (options.ensureAuthorizationToken && !config.authorization) {
5176
+ throw new UnauthorizeApiError("vercel");
5177
+ }
5178
+ return {
5179
+ headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
5180
+ };
5181
+ }
5182
+ function initVercelClient(token) {
5183
+ if (token) {
5184
+ updateVercelClient(token);
5185
+ }
5186
+ }
5187
+ function updateVercelClient(token) {
5188
+ const headers = vercelClientInstance.defaults.headers;
5189
+ if (token) {
5190
+ headers.Authorization = `Bearer ${token}`;
5191
+ } else {
5192
+ delete headers.Authorization;
5193
+ }
5194
+ }
5195
+
5196
+ // src/apis/platform/accounts/instance.ts
5197
+ var AccountsApiError = class extends ApiErrorBase {
5198
+ constructor() {
5199
+ super(...arguments);
5200
+ this.name = "accounts";
5201
+ }
5202
+ };
5203
+ var UnauthorizeAccountsApiError = class extends UnauthorizeApiError {
5204
+ constructor(message) {
5205
+ super("accounts", message);
5206
+ }
5207
+ };
5208
+ var AccountApiClient = class extends ApiClient {
5209
+ constructor() {
5210
+ super(...arguments);
5211
+ this.UnauthorizedError = UnauthorizeAccountsApiError;
5212
+ this.Error = AccountsApiError;
5213
+ this.options = {
5214
+ headers: {
5215
+ "Content-Type": "application/json"
5216
+ }
5217
+ };
5218
+ }
5219
+ };
5220
+ var platformAccountsClientInstance = new AccountApiClient({
5221
+ baseURL: "https://accounts.labs.livechatinc.com"
5222
+ });
5223
+ function initPlatformAccountsClient(baseUrl, token) {
5224
+ if (baseUrl) {
5225
+ platformAccountsClientInstance.updateConfig({
5226
+ baseURL: baseUrl
5227
+ });
5228
+ }
5229
+ platformAccountsClientInstance.updateAuthorization({
5230
+ token
5231
+ });
5232
+ }
5233
+
5234
+ // src/apis/platform/billing/instance.ts
5235
+ var import_axios24 = __toESM(require("axios"));
5236
+ var billingClientInstance = import_axios24.default.create({
5237
+ baseURL: "https://billing.labs.livechatinc.com"
5238
+ });
5239
+ function getBillingClientConfig(options = {}) {
5240
+ var _a;
5241
+ const defaultAuthorization = billingClientInstance.defaults.headers.Authorization;
5242
+ const headers = {
5243
+ authorization: (_a = options.token ? `Bearer ${options.token}` : void 0) != null ? _a : defaultAuthorization
5244
+ };
5245
+ return {
5246
+ headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
5247
+ };
5248
+ }
5249
+ function initBillingClient(baseUrl, token) {
5250
+ if (baseUrl) {
5251
+ billingClientInstance.interceptors.request.use(
5252
+ (config) => {
5253
+ config.baseURL = baseUrl;
5254
+ return config;
5255
+ },
5256
+ (error) => Promise.reject(error)
5257
+ );
5258
+ }
5259
+ if (token) {
5260
+ billingClientInstance.defaults.headers.Authorization = `Bearer ${token}`;
5261
+ } else {
5262
+ delete billingClientInstance.defaults.headers.Authorization;
5263
+ }
5264
+ }
5265
+
5266
+ // src/apis/platform/cdp/events/_contracts/payloads/events.ts
5267
+ var import_zod12 = require("zod");
5268
+ var CdpCustomerEventType = /* @__PURE__ */ ((CdpCustomerEventType2) => {
5269
+ CdpCustomerEventType2["EmailSet"] = "customer_email_set";
5270
+ CdpCustomerEventType2["PropertiesValuesUpdated"] = "customer_properties_values_updated";
5271
+ return CdpCustomerEventType2;
5272
+ })(CdpCustomerEventType || {});
5273
+ var customerMetadataZod = import_zod12.z.object({
5274
+ organization_id: import_zod12.z.string(),
5275
+ customer_id: import_zod12.z.string(),
5276
+ master_id: import_zod12.z.string()
5277
+ });
5278
+ var cdpCustomerEventMessageZod = import_zod12.z.discriminatedUnion("type", [
5279
+ import_zod12.z.object({
5280
+ id: import_zod12.z.string(),
5281
+ type: import_zod12.z.literal("customer_email_set" /* EmailSet */),
5282
+ data: customerMetadataZod.extend({
5283
+ email: import_zod12.z.string()
5284
+ }).passthrough()
5285
+ }),
5286
+ import_zod12.z.object({
5287
+ id: import_zod12.z.string(),
5288
+ type: import_zod12.z.literal("customer_properties_values_updated" /* PropertiesValuesUpdated */),
5289
+ data: customerMetadataZod.extend({
5290
+ customer_properties: import_zod12.z.record(
5291
+ import_zod12.z.object({
5292
+ value: import_zod12.z.unknown(),
5293
+ last_updated_at: import_zod12.z.string(),
5294
+ last_updated_agent_account_id: import_zod12.z.string().optional(),
5295
+ last_updated_agent_client_id: import_zod12.z.string().optional()
5296
+ }).passthrough()
5297
+ )
5298
+ }).passthrough()
5299
+ })
5300
+ ]);
5301
+
5302
+ // src/apis/platform/console/instance.ts
5303
+ var import_axios25 = __toESM(require("axios"));
5304
+ var REGION = {
5305
+ FRA: "fra",
5306
+ DAL: "dal",
5307
+ FRA_A: "fra-a",
5308
+ FRA_B: "fra-b"
5309
+ };
5310
+ var supportedRegions = Object.values(REGION);
5311
+ var getRegion = (token) => {
5312
+ const region = token.split(":")[0];
4992
5313
  if (supportedRegions.includes(region)) {
4993
5314
  return region;
4994
5315
  }
@@ -5784,434 +6105,124 @@ function getWorkflowsClientConfig(options = {}) {
5784
6105
  const headers = {
5785
6106
  platform: {
5786
6107
  token: (_c = currentHeaders.Authorization) != null ? _c : ((_a = options.platform) == null ? void 0 : _a.token) ? `${(_b = options.platform.tokenType) != null ? _b : "Bearer"} ${options.platform.token}` : void 0
5787
- }
5788
- };
5789
- if (currentHeaders.Authorization) {
5790
- currentHeaders["X-Region"] = (_d = getRegion4(currentHeaders.Authorization)) != null ? _d : void 0;
5791
- }
5792
- if (((_e = options.ensureAuthorizationToken) == null ? void 0 : _e.platform) && !headers.platform.token) {
5793
- throw new UnauthorizeApiError("accounts");
5794
- }
5795
- return {
5796
- headers: __spreadValues({}, headers.platform.token ? { Authorization: headers.platform.token } : {})
5797
- };
5798
- }
5799
- var getWorkflowsClientDefaultConfig = (authorization) => getWorkflowsClientConfig(__spreadProps(__spreadValues({}, authorization), {
5800
- ensureAuthorizationToken: {
5801
- platform: true
5802
- }
5803
- }));
5804
- function initWorkflowsClient(baseUrl, tokens) {
5805
- if (baseUrl) {
5806
- workflowsClientInstance.interceptors.request.use(
5807
- (config) => {
5808
- config.baseURL = baseUrl;
5809
- return config;
5810
- },
5811
- (error) => Promise.reject(error)
5812
- );
5813
- }
5814
- if (tokens) {
5815
- updateWorkflowsClient(tokens);
5816
- }
5817
- }
5818
- function updateWorkflowsClient(tokens) {
5819
- var _a, _b;
5820
- const headers = workflowsClientInstance.defaults.headers;
5821
- if ((_a = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _a.token) {
5822
- headers.Authorization = `${(_b = tokens.platform.tokenType) != null ? _b : "Bearer"} ${tokens.platform.token}`;
5823
- }
5824
- }
5825
-
5826
- // src/apis/integrations/text/platform/workflow/resources/api.ts
5827
- var integrationNameToProduct = {
5828
- ["text-helpdesk" /* HelpDesk */]: "helpdesk",
5829
- ["text-livechat" /* LiveChat */]: "livechat"
5830
- };
5831
- var textPlatformWorkflowsResourcesApi = {
5832
- get(resource, params, authorization) {
5833
- return __async(this, null, function* () {
5834
- var _a;
5835
- const baseProvider = (_a = integrationNameToProduct[resource.provider]) != null ? _a : resource.provider;
5836
- const provider = resource.product ? `${baseProvider}-${resource.product}` : baseProvider;
5837
- const config = getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
5838
- ensureAuthorizationToken: true
5839
- }));
5840
- return textClientInstance.get(
5841
- `/workflow_platform/external_resources/${encodeURIComponent(provider)}/${encodeURIComponent(resource.name)}`,
5842
- __spreadProps(__spreadValues({}, config), {
5843
- params,
5844
- headers: __spreadProps(__spreadValues({}, config.headers), {
5845
- "X-Cred-ID": authorization == null ? void 0 : authorization.credentialId
5846
- })
5847
- })
5848
- ).catch((error) => {
5849
- if (error instanceof TextApiError) {
5850
- throw error.withCustomMessage(
5851
- `Couldn't get external resources. [${error.message}]`
5852
- );
5853
- }
5854
- throw error;
5855
- });
5856
- });
5857
- }
5858
- };
5859
-
5860
- // src/apis/integrations/text/platform/workflow/templates/api.ts
5861
- var getUrl3 = (segments = [], version) => buildUrlFromSegments(
5862
- segments,
5863
- `/workflow_platform/${version ? `${version}/` : ""}workflows/templates`
5864
- );
5865
- var urls4 = {
5866
- getList: (queryParams) => enrichUrlWithQueryParams(getUrl3([], "v1.0" /* V1 */), queryParams),
5867
- get: (templateId) => getUrl3([templateId], "v1.0" /* V1 */)
5868
- };
5869
- var textPlatformWorkflowsTemplatesApi = {
5870
- meta: {
5871
- urls: urls4
5872
- },
5873
- getList(queryParams, authorization) {
5874
- return __async(this, null, function* () {
5875
- return textClientInstance.get(
5876
- urls4.getList(queryParams),
5877
- getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
5878
- ensureAuthorizationToken: true
5879
- }))
5880
- ).catch((error) => {
5881
- if (error instanceof TextApiError) {
5882
- throw error.withCustomMessage(
5883
- `Couldn't get workflow templates. [${error.message}]`
5884
- );
5885
- }
5886
- throw error;
5887
- });
5888
- });
5889
- },
5890
- get(templateId, authorization) {
5891
- return __async(this, null, function* () {
5892
- return textClientInstance.get(
5893
- urls4.get(templateId),
5894
- getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
5895
- ensureAuthorizationToken: true
5896
- }))
5897
- ).catch((error) => {
5898
- if (error instanceof TextApiError) {
5899
- throw error.withCustomMessage(
5900
- `Couldn't get workflow template. [${error.message}]`
5901
- );
5902
- }
5903
- throw error;
5904
- });
5905
- });
5906
- }
5907
- };
5908
-
5909
- // src/apis/integrations/text/platform/workflow/workflows/internal/crm/api.ts
5910
- var getUrl4 = (segments = []) => buildUrlFromSegments(segments, "/internal/crm");
5911
- var urls5 = {
5912
- getOrganizations: (queryParams) => enrichUrlWithQueryParams(getUrl4(["stats"]), queryParams),
5913
- getOrganization: (organizationId) => getUrl4(["stats", organizationId]),
5914
- getWorkflows: (queryParams) => enrichUrlWithQueryParams(getUrl4(["workflows"]), queryParams),
5915
- getWorkflow: (id) => getUrl4(["workflows", id]),
5916
- getWorkflowExecutions: (id, queryParams) => enrichUrlWithQueryParams(
5917
- getUrl4(["workflows", id, "executions"]),
5918
- queryParams
5919
- ),
5920
- getWorkflowExecution: (id, executionId) => getUrl4(["workflows", id, "executions", executionId]),
5921
- getWorkflowIntrospection: (id) => getUrl4(["workflows", id, "metadata"])
5922
- };
5923
- var textPlatformWorkflowsInternalCrmApi = {
5924
- meta: {
5925
- urls: urls5
5926
- },
5927
- getOrganizations(queryParams, authorization) {
5928
- return __async(this, null, function* () {
5929
- const { data: organizations } = yield textClientInstance.get(
5930
- urls5.getOrganizations(queryParams),
5931
- getWorkflowApiCrmConfig(authorization)
5932
- );
5933
- return organizations;
5934
- });
5935
- },
5936
- getOrganization(organizationId, authorization) {
5937
- return __async(this, null, function* () {
5938
- const { data: organization } = yield textClientInstance.get(
5939
- urls5.getOrganization(organizationId),
5940
- getWorkflowApiCrmConfig(authorization)
5941
- );
5942
- return organization;
5943
- });
5944
- },
5945
- getWorkflows(queryParams, authorization) {
5946
- return __async(this, null, function* () {
5947
- const { data: workflows } = yield textClientInstance.get(urls5.getWorkflows(queryParams), getWorkflowApiCrmConfig(authorization));
5948
- workflows.data = workflows.data.map(enrichWorkflowTrigger);
5949
- return workflows;
5950
- });
5951
- },
5952
- getWorkflow(workflowId, authorization) {
5953
- return __async(this, null, function* () {
5954
- const searchParams = new URLSearchParams();
5955
- const query = searchParams.toString();
5956
- const { data: workflow } = yield textClientInstance.get(
5957
- `${urls5.getWorkflow(workflowId)}${query ? `?${query}` : ""}`,
5958
- getWorkflowApiCrmConfig(authorization)
5959
- );
5960
- return enrichWorkflowTrigger(workflow);
5961
- });
5962
- },
5963
- getWorkflowExecutions(workflowId, queryParams, authorization) {
5964
- return __async(this, null, function* () {
5965
- const { data: executions } = yield textClientInstance.get(
5966
- urls5.getWorkflowExecutions(workflowId, queryParams),
5967
- getWorkflowApiCrmConfig(authorization)
5968
- );
5969
- return executions;
5970
- });
5971
- },
5972
- getWorkflowExecution(workflowId, executionId, authorization) {
5973
- return __async(this, null, function* () {
5974
- const { data: execution } = yield textClientInstance.get(
5975
- urls5.getWorkflowExecution(workflowId, executionId),
5976
- getWorkflowApiCrmConfig(authorization)
5977
- );
5978
- return execution;
5979
- });
5980
- },
5981
- getWorkflowIntrospection(workflowId, version, authorization) {
5982
- return __async(this, null, function* () {
5983
- const searchParams = new URLSearchParams();
5984
- if (version) {
5985
- searchParams.append("version", `${version}`);
5986
- }
5987
- const query = searchParams.toString();
5988
- const { data: introspection } = yield textClientInstance.get(
5989
- `${urls5.getWorkflowIntrospection(workflowId)}${query ? `?${query}` : ""}`,
5990
- getWorkflowApiCrmConfig(authorization)
5991
- );
5992
- return {
5993
- tasks: introspection
5994
- };
5995
- });
6108
+ }
6109
+ };
6110
+ if (currentHeaders.Authorization) {
6111
+ currentHeaders["X-Region"] = (_d = getRegion4(currentHeaders.Authorization)) != null ? _d : void 0;
5996
6112
  }
5997
- };
5998
-
5999
- // src/apis/integrations/text/platform/workflow/workflows/internal/api.ts
6000
- var textPlatformWorkflowsInternalApi = {
6001
- crm: textPlatformWorkflowsInternalCrmApi
6002
- };
6003
-
6004
- // src/apis/integrations/text/platform/workflow/workflows/api.ts
6005
- var enrichWorkflowTrigger = (workflow) => {
6006
- var _a, _b, _c, _d, _e, _f, _g;
6007
- if (((_a = workflow.trigger) == null ? void 0 : _a.type) === WorkflowTriggerType.webhook) {
6008
- workflow.trigger.name = (_c = workflow.trigger.sub_type) != null ? _c : `${workflow.trigger.webhook.source}-${(_b = workflow.trigger.webhook.event) == null ? void 0 : _b.name}`;
6113
+ if (((_e = options.ensureAuthorizationToken) == null ? void 0 : _e.platform) && !headers.platform.token) {
6114
+ throw new UnauthorizeApiError("accounts");
6009
6115
  }
6010
- if (((_d = workflow.trigger) == null ? void 0 : _d.type) === WorkflowTriggerType.webhookManual) {
6011
- workflow.trigger.name = "webhook_manual";
6116
+ return {
6117
+ headers: __spreadValues({}, headers.platform.token ? { Authorization: headers.platform.token } : {})
6118
+ };
6119
+ }
6120
+ var getWorkflowsClientDefaultConfig = (authorization) => getWorkflowsClientConfig(__spreadProps(__spreadValues({}, authorization), {
6121
+ ensureAuthorizationToken: {
6122
+ platform: true
6012
6123
  }
6013
- if (((_e = workflow.trigger) == null ? void 0 : _e.type) === WorkflowTriggerType.manual) {
6014
- workflow.trigger.name = "manual";
6124
+ }));
6125
+ function initWorkflowsClient(baseUrl, tokens) {
6126
+ if (baseUrl) {
6127
+ workflowsClientInstance.interceptors.request.use(
6128
+ (config) => {
6129
+ config.baseURL = baseUrl;
6130
+ return config;
6131
+ },
6132
+ (error) => Promise.reject(error)
6133
+ );
6015
6134
  }
6016
- if (((_f = workflow.trigger) == null ? void 0 : _f.type) === WorkflowTriggerType.agent) {
6017
- workflow.trigger.name = "ai_agent";
6135
+ if (tokens) {
6136
+ updateWorkflowsClient(tokens);
6018
6137
  }
6019
- if (((_g = workflow.trigger) == null ? void 0 : _g.type) === WorkflowTriggerType.recurring) {
6020
- workflow.trigger.name = "scheduled";
6138
+ }
6139
+ function updateWorkflowsClient(tokens) {
6140
+ var _a, _b;
6141
+ const headers = workflowsClientInstance.defaults.headers;
6142
+ if ((_a = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _a.token) {
6143
+ headers.Authorization = `${(_b = tokens.platform.tokenType) != null ? _b : "Bearer"} ${tokens.platform.token}`;
6144
+ }
6145
+ }
6146
+
6147
+ // src/apis/integrations/text/platform/workflow/resources/api.ts
6148
+ var integrationNameToProduct = {
6149
+ ["text-helpdesk" /* HelpDesk */]: "helpdesk",
6150
+ ["text-livechat" /* LiveChat */]: "livechat"
6151
+ };
6152
+ var textPlatformWorkflowsResourcesApi = {
6153
+ get(resource, params, authorization) {
6154
+ return __async(this, null, function* () {
6155
+ var _a;
6156
+ const baseProvider = (_a = integrationNameToProduct[resource.provider]) != null ? _a : resource.provider;
6157
+ const provider = resource.product ? `${baseProvider}-${resource.product}` : baseProvider;
6158
+ const config = getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6159
+ ensureAuthorizationToken: true
6160
+ }));
6161
+ return textClientInstance.get(
6162
+ `/workflow_platform/external_resources/${encodeURIComponent(provider)}/${encodeURIComponent(resource.name)}`,
6163
+ __spreadProps(__spreadValues({}, config), {
6164
+ params,
6165
+ headers: __spreadProps(__spreadValues({}, config.headers), {
6166
+ "X-Cred-ID": authorization == null ? void 0 : authorization.credentialId
6167
+ })
6168
+ })
6169
+ ).catch((error) => {
6170
+ if (error instanceof TextApiError) {
6171
+ throw error.withCustomMessage(
6172
+ `Couldn't get external resources. [${error.message}]`
6173
+ );
6174
+ }
6175
+ throw error;
6176
+ });
6177
+ });
6021
6178
  }
6022
- return workflow;
6023
6179
  };
6180
+
6181
+ // src/apis/integrations/text/platform/workflow/templates/api.ts
6024
6182
  var getUrl5 = (segments = [], version) => buildUrlFromSegments(
6025
6183
  segments,
6026
- `/workflow_platform/${version ? `${version}/` : ""}workflows`
6184
+ `/workflow_platform/${version ? `${version}/` : ""}workflows/templates`
6027
6185
  );
6028
6186
  var urls6 = {
6029
- getWorkflows: (queryParams) => enrichUrlWithQueryParams(getUrl5([], "v1.0" /* V1 */), queryParams),
6030
- createWorkflow: () => getUrl5(),
6031
- getWorkflow: (id) => getUrl5([id], "v1.0" /* V1 */),
6032
- updateWorkflow: (id) => getUrl5([id]),
6033
- deleteWorkflow: (id) => getUrl5([id]),
6034
- createWorkflowDraft: (id) => getUrl5([id, "draft"]),
6035
- publishWorkflowDraft: (id) => getUrl5([id, "publish"]),
6036
- toggleWorkflowActivation: (id) => getUrl5([id, "activation"]),
6037
- executeWorkflow: (id) => getUrl5([id, "executions"]),
6038
- getWorkflowExecutions: (id, queryParams) => enrichUrlWithQueryParams(
6039
- getUrl5([id, "executions"], "v1.0" /* V1 */),
6040
- queryParams
6041
- ),
6042
- getWorkflowExecution: (id, executionId) => getUrl5([id, "executions", executionId], "v1.0" /* V1 */),
6043
- getWorkflowIntrospection: (id) => getUrl5([id, "metadata"], "v1.0" /* V1 */),
6044
- introspectWorkflowTask: (id) => getUrl5([id, "run_task"], "v1.0" /* V1 */)
6187
+ getList: (queryParams) => enrichUrlWithQueryParams(getUrl5([], "v1.0" /* V1 */), queryParams),
6188
+ get: (templateId) => getUrl5([templateId], "v1.0" /* V1 */)
6045
6189
  };
6046
- var textPlatformWorkflowsApi = {
6047
- internal: textPlatformWorkflowsInternalApi,
6190
+ var textPlatformWorkflowsTemplatesApi = {
6048
6191
  meta: {
6049
6192
  urls: urls6
6050
6193
  },
6051
- getWorkflows(queryParams, authorization) {
6052
- return __async(this, null, function* () {
6053
- const { data: workflows } = yield textClientInstance.get(
6054
- urls6.getWorkflows(queryParams),
6055
- getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6056
- ensureAuthorizationToken: true
6057
- }))
6058
- );
6059
- workflows.data = workflows.data.map(enrichWorkflowTrigger);
6060
- return workflows;
6061
- });
6062
- },
6063
- getWorkflow(workflowId, version, authorization) {
6064
- return __async(this, null, function* () {
6065
- const searchParams = new URLSearchParams();
6066
- if (version) {
6067
- searchParams.append("version", `${version}`);
6068
- }
6069
- const query = searchParams.toString();
6070
- const { data: workflow } = yield textClientInstance.get(
6071
- `${urls6.getWorkflow(workflowId)}${query ? `?${query}` : ""}`,
6072
- getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6073
- ensureAuthorizationToken: true
6074
- }))
6075
- );
6076
- return enrichWorkflowTrigger(workflow);
6077
- });
6078
- },
6079
- createWorkflow(payload, authorization) {
6080
- return __async(this, null, function* () {
6081
- return textClientInstance.post(
6082
- urls6.createWorkflow(),
6083
- __spreadProps(__spreadValues({}, payload), {
6084
- trigger: payload.trigger || {}
6085
- }),
6086
- getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6087
- ensureAuthorizationToken: true
6088
- }))
6089
- );
6090
- });
6091
- },
6092
- updateWorkflow(workflowId, payload, authorization) {
6093
- return __async(this, null, function* () {
6094
- return textClientInstance.put(
6095
- urls6.updateWorkflow(workflowId),
6096
- __spreadProps(__spreadValues({}, payload), {
6097
- trigger: payload.trigger || {}
6098
- }),
6099
- getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6100
- ensureAuthorizationToken: true
6101
- }))
6102
- );
6103
- });
6104
- },
6105
- deleteWorkflow(workflowId, authorization) {
6106
- return __async(this, null, function* () {
6107
- return textClientInstance.delete(urls6.deleteWorkflow(workflowId), __spreadValues({}, getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6108
- ensureAuthorizationToken: true
6109
- }))));
6110
- });
6111
- },
6112
- createWorkflowDraft(workflowId, payload, authorization) {
6113
- return __async(this, null, function* () {
6114
- return textClientInstance.post(
6115
- urls6.createWorkflowDraft(workflowId),
6116
- __spreadProps(__spreadValues({}, payload), {
6117
- trigger: payload.trigger || {}
6118
- }),
6119
- getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6120
- ensureAuthorizationToken: true
6121
- }))
6122
- );
6123
- });
6124
- },
6125
- publishWorkflowDraft(workflowId, authorization) {
6126
- return __async(this, null, function* () {
6127
- return textClientInstance.post(
6128
- urls6.publishWorkflowDraft(workflowId),
6129
- getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6130
- ensureAuthorizationToken: true
6131
- }))
6132
- );
6133
- });
6134
- },
6135
- toggleWorkflowActivation(workflowId, isActive, authorization) {
6136
- return __async(this, null, function* () {
6137
- return textClientInstance.put(
6138
- urls6.toggleWorkflowActivation(workflowId),
6139
- {
6140
- active: isActive
6141
- },
6142
- getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6143
- ensureAuthorizationToken: true
6144
- }))
6145
- );
6146
- });
6147
- },
6148
- executeWorkflow(workflowId, input, authorization) {
6149
- return __async(this, null, function* () {
6150
- const { data: execution } = yield textClientInstance.post(
6151
- urls6.executeWorkflow(workflowId),
6152
- {
6153
- input
6154
- },
6155
- getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6156
- ensureAuthorizationToken: true
6157
- }))
6158
- );
6159
- return execution;
6160
- });
6161
- },
6162
- getWorkflowExecutions(workflowId, queryParams, authorization) {
6163
- return __async(this, null, function* () {
6164
- const { data: executions } = yield textClientInstance.get(
6165
- urls6.getWorkflowExecutions(workflowId, queryParams),
6166
- getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6167
- ensureAuthorizationToken: true
6168
- }))
6169
- );
6170
- return executions;
6171
- });
6172
- },
6173
- getWorkflowExecution(workflowId, executionId, authorization) {
6174
- return __async(this, null, function* () {
6175
- const { data: execution } = yield textClientInstance.get(
6176
- urls6.getWorkflowExecution(workflowId, executionId),
6177
- getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6178
- ensureAuthorizationToken: true
6179
- }))
6180
- );
6181
- return execution;
6182
- });
6183
- },
6184
- getWorkflowIntrospection(workflowId, version, authorization) {
6194
+ getList(queryParams, authorization) {
6185
6195
  return __async(this, null, function* () {
6186
- const searchParams = new URLSearchParams();
6187
- if (version) {
6188
- searchParams.append("version", `${version}`);
6189
- }
6190
- const query = searchParams.toString();
6191
- const { data: introspection } = yield textClientInstance.get(
6192
- `${urls6.getWorkflowIntrospection(workflowId)}${query ? `?${query}` : ""}`,
6196
+ return textClientInstance.get(
6197
+ urls6.getList(queryParams),
6193
6198
  getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6194
6199
  ensureAuthorizationToken: true
6195
6200
  }))
6196
- );
6197
- return {
6198
- tasks: introspection
6199
- };
6201
+ ).catch((error) => {
6202
+ if (error instanceof TextApiError) {
6203
+ throw error.withCustomMessage(
6204
+ `Couldn't get workflow templates. [${error.message}]`
6205
+ );
6206
+ }
6207
+ throw error;
6208
+ });
6200
6209
  });
6201
6210
  },
6202
- introspectWorkflowTask(workflowId, payload, authorization) {
6211
+ get(templateId, authorization) {
6203
6212
  return __async(this, null, function* () {
6204
- const response = yield textClientInstance.post(
6205
- urls6.introspectWorkflowTask(workflowId),
6206
- {
6207
- task_reference_name: payload.taskReferenceName,
6208
- input_parameters: payload.inputParameters
6209
- },
6213
+ return textClientInstance.get(
6214
+ urls6.get(templateId),
6210
6215
  getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6211
6216
  ensureAuthorizationToken: true
6212
6217
  }))
6213
- );
6214
- return response.data;
6218
+ ).catch((error) => {
6219
+ if (error instanceof TextApiError) {
6220
+ throw error.withCustomMessage(
6221
+ `Couldn't get workflow template. [${error.message}]`
6222
+ );
6223
+ }
6224
+ throw error;
6225
+ });
6215
6226
  });
6216
6227
  }
6217
6228
  };
@@ -9949,6 +9960,7 @@ function initApi(config, tokens) {
9949
9960
  cdpCustomerEventMessageZod,
9950
9961
  consoleClientInstance,
9951
9962
  dpsClientInstance,
9963
+ enrichWorkflowTrigger,
9952
9964
  extractTokenFromAuthorizationHeader,
9953
9965
  getAdapterClientConfig,
9954
9966
  getAdapterClientDefaultConfig,
@@ -10022,6 +10034,7 @@ function initApi(config, tokens) {
10022
10034
  integrationSubscriptionZods,
10023
10035
  isFilter,
10024
10036
  isFilterGroup,
10037
+ isWorkflowBaseHttpTaskCore,
10025
10038
  livechatClientInstance,
10026
10039
  mailchimpClientInstance,
10027
10040
  mailchimpEventsZods,