@livechat/developer-studio-api 5.3.1-beta.generator.v5 → 5.3.5-beta.generator.11

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
@@ -123,6 +123,7 @@ __export(src_exports, {
123
123
  TicketStatus: () => TicketStatus,
124
124
  UnauthorizeAccountsApiError: () => UnauthorizeAccountsApiError,
125
125
  UnauthorizeApiError: () => UnauthorizeApiError,
126
+ WorkflowAgentTriggerSubType: () => WorkflowAgentTriggerSubType,
126
127
  WorkflowConditionTaskFieldType: () => WorkflowConditionTaskFieldType,
127
128
  WorkflowConditionTaskLogic: () => WorkflowConditionTaskLogic,
128
129
  WorkflowConditionTaskOperator: () => WorkflowConditionTaskOperator,
@@ -132,7 +133,10 @@ __export(src_exports, {
132
133
  WorkflowExecutionDefinitionStatus: () => WorkflowExecutionDefinitionStatus,
133
134
  WorkflowExecutionStatus: () => WorkflowExecutionStatus,
134
135
  WorkflowExecutionTaskStatus: () => WorkflowExecutionTaskStatus,
136
+ WorkflowExecutionType: () => WorkflowExecutionType,
135
137
  WorkflowItemKind: () => WorkflowItemKind,
138
+ WorkflowManualTriggerSubType: () => WorkflowManualTriggerSubType,
139
+ WorkflowManualTriggerSubTypeName: () => WorkflowManualTriggerSubTypeName,
136
140
  WorkflowTaskType: () => WorkflowTaskType,
137
141
  WorkflowTemplateCategory: () => WorkflowTemplateCategory,
138
142
  WorkflowTriggerType: () => WorkflowTriggerType,
@@ -152,7 +156,6 @@ __export(src_exports, {
152
156
  cdpCustomerEventMessageZod: () => cdpCustomerEventMessageZod,
153
157
  consoleClientInstance: () => consoleClientInstance,
154
158
  dpsClientInstance: () => dpsClientInstance,
155
- enrichWorkflowTrigger: () => enrichWorkflowTrigger,
156
159
  extractTokenFromAuthorizationHeader: () => extractTokenFromAuthorizationHeader,
157
160
  getAdapterClientConfig: () => getAdapterClientConfig,
158
161
  getAdapterClientDefaultConfig: () => getAdapterClientDefaultConfig,
@@ -4396,7 +4399,7 @@ var isFilter = (filter) => {
4396
4399
  // src/apis/integrations/text/platform/workflow/_contracts/filters/serialize.ts
4397
4400
  var convertValueToString = (value) => {
4398
4401
  if (typeof value === "string") {
4399
- return `"${value}"`;
4402
+ return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
4400
4403
  }
4401
4404
  if (value === null) {
4402
4405
  return "null";
@@ -4588,6 +4591,16 @@ var WorkflowConditionTaskFieldType = /* @__PURE__ */ ((WorkflowConditionTaskFiel
4588
4591
  return WorkflowConditionTaskFieldType2;
4589
4592
  })(WorkflowConditionTaskFieldType || {});
4590
4593
 
4594
+ // src/apis/integrations/text/platform/workflow/workflows/_contracts/dtos/triggers/agent.ts
4595
+ var WorkflowAgentTriggerSubType = {
4596
+ chat: "chat"
4597
+ };
4598
+ var WorkflowExecutionType = {
4599
+ conversational: "conversational",
4600
+ background: "background",
4601
+ hybrid: "hybrid"
4602
+ };
4603
+
4591
4604
  // src/apis/integrations/text/platform/workflow/workflows/_contracts/dtos/triggers/base.ts
4592
4605
  var WorkflowTriggerType = {
4593
4606
  manual: "manual_only",
@@ -4598,6 +4611,16 @@ var WorkflowTriggerType = {
4598
4611
  webhookManual: "webhook_manual"
4599
4612
  };
4600
4613
 
4614
+ // src/apis/integrations/text/platform/workflow/workflows/_contracts/dtos/triggers/manual.ts
4615
+ var WorkflowManualTriggerSubType = {
4616
+ forSelectedChat: "for_selected_chat",
4617
+ forSelectedTicket: "for_selected_ticket"
4618
+ };
4619
+ var WorkflowManualTriggerSubTypeName = {
4620
+ [WorkflowManualTriggerSubType.forSelectedChat]: "text-livechat-manual",
4621
+ [WorkflowManualTriggerSubType.forSelectedTicket]: "text-helpdesk-manual"
4622
+ };
4623
+
4601
4624
  // src/apis/integrations/text/platform/workflow/workflows/_contracts/dtos/workflowElement.ts
4602
4625
  var TRIGGER_REFERENCE_NAME = "trigger";
4603
4626
 
@@ -4826,492 +4849,179 @@ function getWorkflowApiCrmConfig(authorization) {
4826
4849
  });
4827
4850
  }
4828
4851
 
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}`);
4852
+ // src/apis/integrations/vercel/instance.ts
4853
+ var import_axios23 = __toESM(require("axios"));
4854
+ function getVercelClientAuthorization(req, headerPrefix = "x-adapter-vercel") {
4855
+ if (req.headers instanceof Headers) {
4856
+ return {
4857
+ token: req.headers.get(`${headerPrefix}-token`)
4858
+ };
4859
+ }
4860
+ return {
4861
+ token: req.headers[`${headerPrefix}-token`]
4862
+ };
4863
+ }
4864
+ var vercelClientInstance = import_axios23.default.create({
4865
+ baseURL: "https://api.vercel.com"
4866
+ });
4867
+ vercelClientInstance.interceptors.response.use(
4868
+ (r) => r,
4869
+ (error) => {
4870
+ var _a, _b;
4871
+ if (import_axios23.default.isAxiosError(error)) {
4872
+ if (((_a = error.response) == null ? void 0 : _a.status) === 401 || ((_b = error.response) == null ? void 0 : _b.status) === 403) {
4873
+ throw new UnauthorizeApiError("vercel");
4906
4874
  }
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
- });
4875
+ }
4876
+ throw error;
4916
4877
  }
4917
- };
4878
+ );
4879
+ function getVercelClientConfig(options = {}) {
4880
+ var _a;
4881
+ const currentHeaders = vercelClientInstance.defaults.headers;
4882
+ const config = {
4883
+ authorization: (_a = options.token ? `Bearer ${options.token}` : void 0) != null ? _a : currentHeaders.Authorization
4884
+ };
4885
+ if (options.ensureAuthorizationToken && !config.authorization) {
4886
+ throw new UnauthorizeApiError("vercel");
4887
+ }
4888
+ return {
4889
+ headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
4890
+ };
4891
+ }
4892
+ function initVercelClient(token) {
4893
+ if (token) {
4894
+ updateVercelClient(token);
4895
+ }
4896
+ }
4897
+ function updateVercelClient(token) {
4898
+ const headers = vercelClientInstance.defaults.headers;
4899
+ if (token) {
4900
+ headers.Authorization = `Bearer ${token}`;
4901
+ } else {
4902
+ delete headers.Authorization;
4903
+ }
4904
+ }
4918
4905
 
4919
- // src/apis/integrations/text/platform/workflow/workflows/internal/api.ts
4920
- var textPlatformWorkflowsInternalApi = {
4921
- crm: textPlatformWorkflowsInternalCrmApi
4906
+ // src/apis/platform/accounts/instance.ts
4907
+ var AccountsApiError = class extends ApiErrorBase {
4908
+ constructor() {
4909
+ super(...arguments);
4910
+ this.name = "accounts";
4911
+ }
4922
4912
  };
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}`;
4913
+ var UnauthorizeAccountsApiError = class extends UnauthorizeApiError {
4914
+ constructor(message) {
4915
+ super("accounts", message);
4929
4916
  }
4930
- if (((_d = workflow.trigger) == null ? void 0 : _d.type) === WorkflowTriggerType.webhookManual) {
4931
- workflow.trigger.name = "webhook_manual";
4917
+ };
4918
+ var AccountApiClient = class extends ApiClient {
4919
+ constructor() {
4920
+ super(...arguments);
4921
+ this.UnauthorizedError = UnauthorizeAccountsApiError;
4922
+ this.Error = AccountsApiError;
4923
+ this.options = {
4924
+ headers: {
4925
+ "Content-Type": "application/json"
4926
+ }
4927
+ };
4932
4928
  }
4933
- if (((_e = workflow.trigger) == null ? void 0 : _e.type) === WorkflowTriggerType.manual) {
4934
- workflow.trigger.name = "manual";
4929
+ };
4930
+ var platformAccountsClientInstance = new AccountApiClient({
4931
+ baseURL: "https://accounts.labs.livechatinc.com"
4932
+ });
4933
+ function initPlatformAccountsClient(baseUrl, token) {
4934
+ if (baseUrl) {
4935
+ platformAccountsClientInstance.updateConfig({
4936
+ baseURL: baseUrl
4937
+ });
4935
4938
  }
4936
- if (((_f = workflow.trigger) == null ? void 0 : _f.type) === WorkflowTriggerType.agent) {
4937
- workflow.trigger.name = "ai_agent";
4939
+ platformAccountsClientInstance.updateAuthorization({
4940
+ token
4941
+ });
4942
+ }
4943
+
4944
+ // src/apis/platform/billing/instance.ts
4945
+ var import_axios24 = __toESM(require("axios"));
4946
+ var billingClientInstance = import_axios24.default.create({
4947
+ baseURL: "https://billing.labs.livechatinc.com"
4948
+ });
4949
+ function getBillingClientConfig(options = {}) {
4950
+ var _a;
4951
+ const defaultAuthorization = billingClientInstance.defaults.headers.Authorization;
4952
+ const headers = {
4953
+ authorization: (_a = options.token ? `Bearer ${options.token}` : void 0) != null ? _a : defaultAuthorization
4954
+ };
4955
+ return {
4956
+ headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
4957
+ };
4958
+ }
4959
+ function initBillingClient(baseUrl, token) {
4960
+ if (baseUrl) {
4961
+ billingClientInstance.interceptors.request.use(
4962
+ (config) => {
4963
+ config.baseURL = baseUrl;
4964
+ return config;
4965
+ },
4966
+ (error) => Promise.reject(error)
4967
+ );
4938
4968
  }
4939
- if (((_g = workflow.trigger) == null ? void 0 : _g.type) === WorkflowTriggerType.recurring) {
4940
- workflow.trigger.name = "scheduled";
4969
+ if (token) {
4970
+ billingClientInstance.defaults.headers.Authorization = `Bearer ${token}`;
4971
+ } else {
4972
+ delete billingClientInstance.defaults.headers.Authorization;
4941
4973
  }
4942
- if (((_h = workflow.trigger) == null ? void 0 : _h.type) === WorkflowTriggerType.oneTime) {
4943
- workflow.trigger.name = "one_time";
4944
- }
4945
- return workflow;
4946
- };
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];
5313
- if (supportedRegions.includes(region)) {
5314
- return region;
4974
+ }
4975
+
4976
+ // src/apis/platform/cdp/events/_contracts/payloads/events.ts
4977
+ var import_zod12 = require("zod");
4978
+ var CdpCustomerEventType = /* @__PURE__ */ ((CdpCustomerEventType2) => {
4979
+ CdpCustomerEventType2["EmailSet"] = "customer_email_set";
4980
+ CdpCustomerEventType2["PropertiesValuesUpdated"] = "customer_properties_values_updated";
4981
+ return CdpCustomerEventType2;
4982
+ })(CdpCustomerEventType || {});
4983
+ var customerMetadataZod = import_zod12.z.object({
4984
+ organization_id: import_zod12.z.string(),
4985
+ customer_id: import_zod12.z.string(),
4986
+ master_id: import_zod12.z.string()
4987
+ });
4988
+ var cdpCustomerEventMessageZod = import_zod12.z.discriminatedUnion("type", [
4989
+ import_zod12.z.object({
4990
+ id: import_zod12.z.string(),
4991
+ type: import_zod12.z.literal("customer_email_set" /* EmailSet */),
4992
+ data: customerMetadataZod.extend({
4993
+ email: import_zod12.z.string()
4994
+ }).passthrough()
4995
+ }),
4996
+ import_zod12.z.object({
4997
+ id: import_zod12.z.string(),
4998
+ type: import_zod12.z.literal("customer_properties_values_updated" /* PropertiesValuesUpdated */),
4999
+ data: customerMetadataZod.extend({
5000
+ customer_properties: import_zod12.z.record(
5001
+ import_zod12.z.object({
5002
+ value: import_zod12.z.unknown(),
5003
+ last_updated_at: import_zod12.z.string(),
5004
+ last_updated_agent_account_id: import_zod12.z.string().optional(),
5005
+ last_updated_agent_client_id: import_zod12.z.string().optional()
5006
+ }).passthrough()
5007
+ )
5008
+ }).passthrough()
5009
+ })
5010
+ ]);
5011
+
5012
+ // src/apis/platform/console/instance.ts
5013
+ var import_axios25 = __toESM(require("axios"));
5014
+ var REGION = {
5015
+ FRA: "fra",
5016
+ DAL: "dal",
5017
+ FRA_A: "fra-a",
5018
+ FRA_B: "fra-b"
5019
+ };
5020
+ var supportedRegions = Object.values(REGION);
5021
+ var getRegion = (token) => {
5022
+ const region = token.split(":")[0];
5023
+ if (supportedRegions.includes(region)) {
5024
+ return region;
5315
5025
  }
5316
5026
  };
5317
5027
  var ConsoleApiError = class _ConsoleApiError extends ApiErrorBase {
@@ -6110,119 +5820,434 @@ function getWorkflowsClientConfig(options = {}) {
6110
5820
  if (currentHeaders.Authorization) {
6111
5821
  currentHeaders["X-Region"] = (_d = getRegion4(currentHeaders.Authorization)) != null ? _d : void 0;
6112
5822
  }
6113
- if (((_e = options.ensureAuthorizationToken) == null ? void 0 : _e.platform) && !headers.platform.token) {
6114
- throw new UnauthorizeApiError("accounts");
5823
+ if (((_e = options.ensureAuthorizationToken) == null ? void 0 : _e.platform) && !headers.platform.token) {
5824
+ throw new UnauthorizeApiError("accounts");
5825
+ }
5826
+ return {
5827
+ headers: __spreadValues({}, headers.platform.token ? { Authorization: headers.platform.token } : {})
5828
+ };
5829
+ }
5830
+ var getWorkflowsClientDefaultConfig = (authorization) => getWorkflowsClientConfig(__spreadProps(__spreadValues({}, authorization), {
5831
+ ensureAuthorizationToken: {
5832
+ platform: true
5833
+ }
5834
+ }));
5835
+ function initWorkflowsClient(baseUrl, tokens) {
5836
+ if (baseUrl) {
5837
+ workflowsClientInstance.interceptors.request.use(
5838
+ (config) => {
5839
+ config.baseURL = baseUrl;
5840
+ return config;
5841
+ },
5842
+ (error) => Promise.reject(error)
5843
+ );
5844
+ }
5845
+ if (tokens) {
5846
+ updateWorkflowsClient(tokens);
5847
+ }
5848
+ }
5849
+ function updateWorkflowsClient(tokens) {
5850
+ var _a, _b;
5851
+ const headers = workflowsClientInstance.defaults.headers;
5852
+ if ((_a = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _a.token) {
5853
+ headers.Authorization = `${(_b = tokens.platform.tokenType) != null ? _b : "Bearer"} ${tokens.platform.token}`;
5854
+ }
5855
+ }
5856
+
5857
+ // src/apis/integrations/text/platform/workflow/resources/api.ts
5858
+ var integrationNameToProduct = {
5859
+ ["text-helpdesk" /* HelpDesk */]: "helpdesk",
5860
+ ["text-livechat" /* LiveChat */]: "livechat"
5861
+ };
5862
+ var textPlatformWorkflowsResourcesApi = {
5863
+ get(resource, params, authorization) {
5864
+ return __async(this, null, function* () {
5865
+ var _a;
5866
+ const baseProvider = (_a = integrationNameToProduct[resource.provider]) != null ? _a : resource.provider;
5867
+ const provider = resource.product ? `${baseProvider}-${resource.product}` : baseProvider;
5868
+ const config = getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
5869
+ ensureAuthorizationToken: true
5870
+ }));
5871
+ return textClientInstance.get(
5872
+ `/workflow_platform/external_resources/${encodeURIComponent(provider)}/${encodeURIComponent(resource.name)}`,
5873
+ __spreadProps(__spreadValues({}, config), {
5874
+ params,
5875
+ headers: __spreadProps(__spreadValues({}, config.headers), {
5876
+ "X-Cred-ID": authorization == null ? void 0 : authorization.credentialId
5877
+ })
5878
+ })
5879
+ ).catch((error) => {
5880
+ if (error instanceof TextApiError) {
5881
+ throw error.withCustomMessage(
5882
+ `Couldn't get external resources. [${error.message}]`
5883
+ );
5884
+ }
5885
+ throw error;
5886
+ });
5887
+ });
5888
+ }
5889
+ };
5890
+
5891
+ // src/apis/integrations/text/platform/workflow/templates/api.ts
5892
+ var getUrl3 = (segments = [], version) => buildUrlFromSegments(
5893
+ segments,
5894
+ `/workflow_platform/${version ? `${version}/` : ""}workflows/templates`
5895
+ );
5896
+ var urls4 = {
5897
+ getList: (queryParams) => enrichUrlWithQueryParams(getUrl3([], "v1.0" /* V1 */), queryParams),
5898
+ get: (templateId) => getUrl3([templateId], "v1.0" /* V1 */)
5899
+ };
5900
+ var textPlatformWorkflowsTemplatesApi = {
5901
+ meta: {
5902
+ urls: urls4
5903
+ },
5904
+ getList(queryParams, authorization) {
5905
+ return __async(this, null, function* () {
5906
+ return textClientInstance.get(
5907
+ urls4.getList(queryParams),
5908
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
5909
+ ensureAuthorizationToken: true
5910
+ }))
5911
+ ).catch((error) => {
5912
+ if (error instanceof TextApiError) {
5913
+ throw error.withCustomMessage(
5914
+ `Couldn't get workflow templates. [${error.message}]`
5915
+ );
5916
+ }
5917
+ throw error;
5918
+ });
5919
+ });
5920
+ },
5921
+ get(templateId, authorization) {
5922
+ return __async(this, null, function* () {
5923
+ return textClientInstance.get(
5924
+ urls4.get(templateId),
5925
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
5926
+ ensureAuthorizationToken: true
5927
+ }))
5928
+ ).catch((error) => {
5929
+ if (error instanceof TextApiError) {
5930
+ throw error.withCustomMessage(
5931
+ `Couldn't get workflow template. [${error.message}]`
5932
+ );
5933
+ }
5934
+ throw error;
5935
+ });
5936
+ });
5937
+ }
5938
+ };
5939
+
5940
+ // src/apis/integrations/text/platform/workflow/workflows/internal/crm/api.ts
5941
+ var getUrl4 = (segments = []) => buildUrlFromSegments(segments, "/internal/crm");
5942
+ var urls5 = {
5943
+ getOrganizations: (queryParams) => enrichUrlWithQueryParams(getUrl4(["stats"]), queryParams),
5944
+ getOrganization: (organizationId) => getUrl4(["stats", organizationId]),
5945
+ getWorkflows: (queryParams) => enrichUrlWithQueryParams(getUrl4(["workflows"]), queryParams),
5946
+ getWorkflow: (id) => getUrl4(["workflows", id]),
5947
+ getWorkflowExecutions: (id, queryParams) => enrichUrlWithQueryParams(
5948
+ getUrl4(["workflows", id, "executions"]),
5949
+ queryParams
5950
+ ),
5951
+ getWorkflowExecution: (id, executionId) => getUrl4(["workflows", id, "executions", executionId]),
5952
+ getWorkflowIntrospection: (id) => getUrl4(["workflows", id, "metadata"])
5953
+ };
5954
+ var textPlatformWorkflowsInternalCrmApi = {
5955
+ meta: {
5956
+ urls: urls5
5957
+ },
5958
+ getOrganizations(queryParams, authorization) {
5959
+ return __async(this, null, function* () {
5960
+ const { data: organizations } = yield textClientInstance.get(
5961
+ urls5.getOrganizations(queryParams),
5962
+ getWorkflowApiCrmConfig(authorization)
5963
+ );
5964
+ return organizations;
5965
+ });
5966
+ },
5967
+ getOrganization(organizationId, authorization) {
5968
+ return __async(this, null, function* () {
5969
+ const { data: organization } = yield textClientInstance.get(
5970
+ urls5.getOrganization(organizationId),
5971
+ getWorkflowApiCrmConfig(authorization)
5972
+ );
5973
+ return organization;
5974
+ });
5975
+ },
5976
+ getWorkflows(queryParams, authorization) {
5977
+ return __async(this, null, function* () {
5978
+ const { data: workflows } = yield textClientInstance.get(urls5.getWorkflows(queryParams), getWorkflowApiCrmConfig(authorization));
5979
+ workflows.data = workflows.data.map(enrichWorkflowTrigger);
5980
+ return workflows;
5981
+ });
5982
+ },
5983
+ getWorkflow(workflowId, authorization) {
5984
+ return __async(this, null, function* () {
5985
+ const searchParams = new URLSearchParams();
5986
+ const query = searchParams.toString();
5987
+ const { data: workflow } = yield textClientInstance.get(
5988
+ `${urls5.getWorkflow(workflowId)}${query ? `?${query}` : ""}`,
5989
+ getWorkflowApiCrmConfig(authorization)
5990
+ );
5991
+ return enrichWorkflowTrigger(workflow);
5992
+ });
5993
+ },
5994
+ getWorkflowExecutions(workflowId, queryParams, authorization) {
5995
+ return __async(this, null, function* () {
5996
+ const { data: executions } = yield textClientInstance.get(
5997
+ urls5.getWorkflowExecutions(workflowId, queryParams),
5998
+ getWorkflowApiCrmConfig(authorization)
5999
+ );
6000
+ return executions;
6001
+ });
6002
+ },
6003
+ getWorkflowExecution(workflowId, executionId, authorization) {
6004
+ return __async(this, null, function* () {
6005
+ const { data: execution } = yield textClientInstance.get(
6006
+ urls5.getWorkflowExecution(workflowId, executionId),
6007
+ getWorkflowApiCrmConfig(authorization)
6008
+ );
6009
+ return execution;
6010
+ });
6011
+ },
6012
+ getWorkflowIntrospection(workflowId, version, authorization) {
6013
+ return __async(this, null, function* () {
6014
+ const searchParams = new URLSearchParams();
6015
+ if (version) {
6016
+ searchParams.append("version", `${version}`);
6017
+ }
6018
+ const query = searchParams.toString();
6019
+ const { data: introspection } = yield textClientInstance.get(
6020
+ `${urls5.getWorkflowIntrospection(workflowId)}${query ? `?${query}` : ""}`,
6021
+ getWorkflowApiCrmConfig(authorization)
6022
+ );
6023
+ return {
6024
+ tasks: introspection
6025
+ };
6026
+ });
6027
+ }
6028
+ };
6029
+
6030
+ // src/apis/integrations/text/platform/workflow/workflows/internal/api.ts
6031
+ var textPlatformWorkflowsInternalApi = {
6032
+ crm: textPlatformWorkflowsInternalCrmApi
6033
+ };
6034
+
6035
+ // src/apis/integrations/text/platform/workflow/workflows/api.ts
6036
+ var enrichWorkflowTrigger = (workflow) => {
6037
+ var _a, _b, _c;
6038
+ const trigger = workflow.trigger;
6039
+ if ((trigger == null ? void 0 : trigger.type) === WorkflowTriggerType.webhook && "webhook" in trigger) {
6040
+ const webhookTrigger = trigger;
6041
+ webhookTrigger.name = (_b = webhookTrigger.sub_type) != null ? _b : `${webhookTrigger.webhook.source}-${(_a = webhookTrigger.webhook.event) == null ? void 0 : _a.name}`;
6115
6042
  }
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
6043
+ if ((trigger == null ? void 0 : trigger.type) === WorkflowTriggerType.webhookManual) {
6044
+ trigger.name = "webhook_manual";
6123
6045
  }
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
- );
6046
+ if ((trigger == null ? void 0 : trigger.type) === WorkflowTriggerType.manual) {
6047
+ trigger.name = trigger.sub_type ? WorkflowManualTriggerSubTypeName[trigger.sub_type] : "manual";
6134
6048
  }
6135
- if (tokens) {
6136
- updateWorkflowsClient(tokens);
6049
+ if ((trigger == null ? void 0 : trigger.type) === WorkflowTriggerType.agent) {
6050
+ trigger.name = "ai_agent";
6137
6051
  }
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}`;
6052
+ if ((trigger == null ? void 0 : trigger.type) === WorkflowTriggerType.recurring) {
6053
+ trigger.name = "scheduled";
6144
6054
  }
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
- });
6055
+ if (((_c = workflow.trigger) == null ? void 0 : _c.type) === WorkflowTriggerType.oneTime) {
6056
+ workflow.trigger.name = "one_time";
6178
6057
  }
6058
+ return workflow;
6179
6059
  };
6180
-
6181
- // src/apis/integrations/text/platform/workflow/templates/api.ts
6182
6060
  var getUrl5 = (segments = [], version) => buildUrlFromSegments(
6183
6061
  segments,
6184
- `/workflow_platform/${version ? `${version}/` : ""}workflows/templates`
6062
+ `/workflow_platform/${version ? `${version}/` : ""}workflows`
6185
6063
  );
6186
6064
  var urls6 = {
6187
- getList: (queryParams) => enrichUrlWithQueryParams(getUrl5([], "v1.0" /* V1 */), queryParams),
6188
- get: (templateId) => getUrl5([templateId], "v1.0" /* V1 */)
6065
+ getWorkflows: (queryParams) => enrichUrlWithQueryParams(getUrl5([], "v1.0" /* V1 */), queryParams),
6066
+ createWorkflow: () => getUrl5(),
6067
+ getWorkflow: (id) => getUrl5([id], "v1.0" /* V1 */),
6068
+ updateWorkflow: (id) => getUrl5([id]),
6069
+ deleteWorkflow: (id) => getUrl5([id]),
6070
+ createWorkflowDraft: (id) => getUrl5([id, "draft"]),
6071
+ publishWorkflowDraft: (id) => getUrl5([id, "publish"]),
6072
+ toggleWorkflowActivation: (id) => getUrl5([id, "activation"]),
6073
+ executeWorkflow: (id) => getUrl5([id, "executions"]),
6074
+ getWorkflowExecutions: (id, queryParams) => enrichUrlWithQueryParams(
6075
+ getUrl5([id, "executions"], "v1.0" /* V1 */),
6076
+ queryParams
6077
+ ),
6078
+ getWorkflowExecution: (id, executionId) => getUrl5([id, "executions", executionId], "v1.0" /* V1 */),
6079
+ getWorkflowIntrospection: (id) => getUrl5([id, "metadata"], "v1.0" /* V1 */),
6080
+ introspectWorkflowTask: (id) => getUrl5([id, "run_task"], "v1.0" /* V1 */)
6189
6081
  };
6190
- var textPlatformWorkflowsTemplatesApi = {
6082
+ var textPlatformWorkflowsApi = {
6083
+ internal: textPlatformWorkflowsInternalApi,
6191
6084
  meta: {
6192
6085
  urls: urls6
6193
6086
  },
6194
- getList(queryParams, authorization) {
6087
+ getWorkflows(queryParams, authorization) {
6195
6088
  return __async(this, null, function* () {
6196
- return textClientInstance.get(
6197
- urls6.getList(queryParams),
6089
+ const { data: workflows } = yield textClientInstance.get(
6090
+ urls6.getWorkflows(queryParams),
6198
6091
  getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6199
6092
  ensureAuthorizationToken: true
6200
6093
  }))
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
- });
6094
+ );
6095
+ workflows.data = workflows.data.map(enrichWorkflowTrigger);
6096
+ return workflows;
6209
6097
  });
6210
6098
  },
6211
- get(templateId, authorization) {
6099
+ getWorkflow(workflowId, version, authorization) {
6212
6100
  return __async(this, null, function* () {
6213
- return textClientInstance.get(
6214
- urls6.get(templateId),
6101
+ const searchParams = new URLSearchParams();
6102
+ if (version) {
6103
+ searchParams.append("version", `${version}`);
6104
+ }
6105
+ const query = searchParams.toString();
6106
+ const { data: workflow } = yield textClientInstance.get(
6107
+ `${urls6.getWorkflow(workflowId)}${query ? `?${query}` : ""}`,
6215
6108
  getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6216
6109
  ensureAuthorizationToken: true
6217
6110
  }))
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
- });
6111
+ );
6112
+ return enrichWorkflowTrigger(workflow);
6113
+ });
6114
+ },
6115
+ createWorkflow(payload, authorization) {
6116
+ return __async(this, null, function* () {
6117
+ return textClientInstance.post(
6118
+ urls6.createWorkflow(),
6119
+ __spreadProps(__spreadValues({}, payload), {
6120
+ trigger: payload.trigger || {}
6121
+ }),
6122
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6123
+ ensureAuthorizationToken: true
6124
+ }))
6125
+ );
6126
+ });
6127
+ },
6128
+ updateWorkflow(workflowId, payload, authorization) {
6129
+ return __async(this, null, function* () {
6130
+ return textClientInstance.put(
6131
+ urls6.updateWorkflow(workflowId),
6132
+ __spreadProps(__spreadValues({}, payload), {
6133
+ trigger: payload.trigger || {}
6134
+ }),
6135
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6136
+ ensureAuthorizationToken: true
6137
+ }))
6138
+ );
6139
+ });
6140
+ },
6141
+ deleteWorkflow(workflowId, authorization) {
6142
+ return __async(this, null, function* () {
6143
+ return textClientInstance.delete(urls6.deleteWorkflow(workflowId), __spreadValues({}, getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6144
+ ensureAuthorizationToken: true
6145
+ }))));
6146
+ });
6147
+ },
6148
+ createWorkflowDraft(workflowId, payload, authorization) {
6149
+ return __async(this, null, function* () {
6150
+ return textClientInstance.post(
6151
+ urls6.createWorkflowDraft(workflowId),
6152
+ __spreadProps(__spreadValues({}, payload), {
6153
+ trigger: payload.trigger || {}
6154
+ }),
6155
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6156
+ ensureAuthorizationToken: true
6157
+ }))
6158
+ );
6159
+ });
6160
+ },
6161
+ publishWorkflowDraft(workflowId, authorization) {
6162
+ return __async(this, null, function* () {
6163
+ return textClientInstance.post(
6164
+ urls6.publishWorkflowDraft(workflowId),
6165
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6166
+ ensureAuthorizationToken: true
6167
+ }))
6168
+ );
6169
+ });
6170
+ },
6171
+ toggleWorkflowActivation(workflowId, isActive, authorization) {
6172
+ return __async(this, null, function* () {
6173
+ return textClientInstance.put(
6174
+ urls6.toggleWorkflowActivation(workflowId),
6175
+ {
6176
+ active: isActive
6177
+ },
6178
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6179
+ ensureAuthorizationToken: true
6180
+ }))
6181
+ );
6182
+ });
6183
+ },
6184
+ executeWorkflow(workflowId, input, authorization) {
6185
+ return __async(this, null, function* () {
6186
+ const { data: execution } = yield textClientInstance.post(
6187
+ urls6.executeWorkflow(workflowId),
6188
+ {
6189
+ input
6190
+ },
6191
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6192
+ ensureAuthorizationToken: true
6193
+ }))
6194
+ );
6195
+ return execution;
6196
+ });
6197
+ },
6198
+ getWorkflowExecutions(workflowId, queryParams, authorization) {
6199
+ return __async(this, null, function* () {
6200
+ const { data: executions } = yield textClientInstance.get(
6201
+ urls6.getWorkflowExecutions(workflowId, queryParams),
6202
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6203
+ ensureAuthorizationToken: true
6204
+ }))
6205
+ );
6206
+ return executions;
6207
+ });
6208
+ },
6209
+ getWorkflowExecution(workflowId, executionId, authorization) {
6210
+ return __async(this, null, function* () {
6211
+ const { data: execution } = yield textClientInstance.get(
6212
+ urls6.getWorkflowExecution(workflowId, executionId),
6213
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6214
+ ensureAuthorizationToken: true
6215
+ }))
6216
+ );
6217
+ return execution;
6218
+ });
6219
+ },
6220
+ getWorkflowIntrospection(workflowId, version, authorization) {
6221
+ return __async(this, null, function* () {
6222
+ const searchParams = new URLSearchParams();
6223
+ if (version) {
6224
+ searchParams.append("version", `${version}`);
6225
+ }
6226
+ const query = searchParams.toString();
6227
+ const { data: introspection } = yield textClientInstance.get(
6228
+ `${urls6.getWorkflowIntrospection(workflowId)}${query ? `?${query}` : ""}`,
6229
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6230
+ ensureAuthorizationToken: true
6231
+ }))
6232
+ );
6233
+ return {
6234
+ tasks: introspection
6235
+ };
6236
+ });
6237
+ },
6238
+ introspectWorkflowTask(workflowId, payload, authorization) {
6239
+ return __async(this, null, function* () {
6240
+ const response = yield textClientInstance.post(
6241
+ urls6.introspectWorkflowTask(workflowId),
6242
+ {
6243
+ task_reference_name: payload.taskReferenceName,
6244
+ input_parameters: payload.inputParameters
6245
+ },
6246
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
6247
+ ensureAuthorizationToken: true
6248
+ }))
6249
+ );
6250
+ return response.data;
6226
6251
  });
6227
6252
  }
6228
6253
  };
@@ -9931,6 +9956,7 @@ function initApi(config, tokens) {
9931
9956
  TicketStatus,
9932
9957
  UnauthorizeAccountsApiError,
9933
9958
  UnauthorizeApiError,
9959
+ WorkflowAgentTriggerSubType,
9934
9960
  WorkflowConditionTaskFieldType,
9935
9961
  WorkflowConditionTaskLogic,
9936
9962
  WorkflowConditionTaskOperator,
@@ -9940,7 +9966,10 @@ function initApi(config, tokens) {
9940
9966
  WorkflowExecutionDefinitionStatus,
9941
9967
  WorkflowExecutionStatus,
9942
9968
  WorkflowExecutionTaskStatus,
9969
+ WorkflowExecutionType,
9943
9970
  WorkflowItemKind,
9971
+ WorkflowManualTriggerSubType,
9972
+ WorkflowManualTriggerSubTypeName,
9944
9973
  WorkflowTaskType,
9945
9974
  WorkflowTemplateCategory,
9946
9975
  WorkflowTriggerType,
@@ -9960,7 +9989,6 @@ function initApi(config, tokens) {
9960
9989
  cdpCustomerEventMessageZod,
9961
9990
  consoleClientInstance,
9962
9991
  dpsClientInstance,
9963
- enrichWorkflowTrigger,
9964
9992
  extractTokenFromAuthorizationHeader,
9965
9993
  getAdapterClientConfig,
9966
9994
  getAdapterClientDefaultConfig,