@integry/sdk 4.7.39 → 4.7.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. package/dist/esm/index.csm.js +1 -1
  2. package/dist/umd/index.umd.js +1 -1
  3. package/package.json +6 -1
  4. package/.eslintignore +0 -1
  5. package/.vscode/launch.json +0 -17
  6. package/CHANGELOG_INTERNAL.md +0 -134
  7. package/README_INTERNAL.md +0 -176
  8. package/THIRD_PARTY_LICENSES +0 -525
  9. package/generateTests.js +0 -80
  10. package/jest.config.cjs +0 -10
  11. package/src/components/AddTagButton/index.ts +0 -23
  12. package/src/components/BasicSelect/index.ts +0 -123
  13. package/src/components/BasicSelect/styles.module.scss +0 -44
  14. package/src/components/Button/index.ts +0 -97
  15. package/src/components/Button/styles.module.scss +0 -152
  16. package/src/components/CheckboxGroup/Checkbox.ts +0 -104
  17. package/src/components/CheckboxGroup/index.ts +0 -190
  18. package/src/components/CheckboxGroup/styles.module.scss +0 -63
  19. package/src/components/CollapsedMenu/index.ts +0 -104
  20. package/src/components/CollapsedMenu/styles.module.scss +0 -46
  21. package/src/components/ConfigureFieldWrapper/index.ts +0 -85
  22. package/src/components/ConfigureFieldWrapper/styles.module.scss +0 -57
  23. package/src/components/EditableText/index.ts +0 -121
  24. package/src/components/EditableText/styles.module.scss +0 -38
  25. package/src/components/EditableTextArea/index.ts +0 -143
  26. package/src/components/EditableTextArea/styles.module.scss +0 -91
  27. package/src/components/ErrorMessage/index.ts +0 -16
  28. package/src/components/ErrorMessage/styles.module.scss +0 -19
  29. package/src/components/ErrorPage/index.ts +0 -42
  30. package/src/components/ErrorPage/styles.module.scss +0 -26
  31. package/src/components/Footer/index.ts +0 -41
  32. package/src/components/Footer/styles.module.scss +0 -40
  33. package/src/components/HTMLContent/index.tsx +0 -205
  34. package/src/components/HTMLContent/styles.module.scss +0 -3
  35. package/src/components/InfoBox/index.ts +0 -48
  36. package/src/components/InfoBox/styles.module.scss +0 -21
  37. package/src/components/Input/BaseInput/index.ts +0 -170
  38. package/src/components/Input/BaseInput/styles.module.scss +0 -95
  39. package/src/components/Input/DateInput/index.ts +0 -103
  40. package/src/components/Input/DateInput/styles.module.scss +0 -50
  41. package/src/components/Input/Input/index.ts +0 -225
  42. package/src/components/Input/Input/styles.module.scss +0 -16
  43. package/src/components/Input/PasswordInput/index.ts +0 -164
  44. package/src/components/Input/PasswordInput/styles.module.scss +0 -37
  45. package/src/components/Input/index.ts +0 -7
  46. package/src/components/Label/index.ts +0 -61
  47. package/src/components/Label/styles.module.scss +0 -41
  48. package/src/components/LargeLoader/index.ts +0 -25
  49. package/src/components/LargeLoader/styles.module.scss +0 -16
  50. package/src/components/Listbox/ListBoxItem.ts +0 -57
  51. package/src/components/Listbox/index.ts +0 -488
  52. package/src/components/Listbox/styles.module.scss +0 -197
  53. package/src/components/Loader/index.ts +0 -25
  54. package/src/components/Loader/styles.module.scss +0 -16
  55. package/src/components/MediaGallery/MediaGalleryModal.ts +0 -82
  56. package/src/components/MediaGallery/MediaSlider.ts +0 -76
  57. package/src/components/MediaGallery/index.ts +0 -92
  58. package/src/components/MediaGallery/styles.module.scss +0 -156
  59. package/src/components/MediaUpload/index.ts +0 -233
  60. package/src/components/MediaUpload/styles.module.scss +0 -118
  61. package/src/components/Modal/index.ts +0 -87
  62. package/src/components/Modal/styles.module.scss +0 -441
  63. package/src/components/MultipurposeField/Dropdown/ListBoxItem.tsx +0 -59
  64. package/src/components/MultipurposeField/Dropdown/index.tsx +0 -1202
  65. package/src/components/MultipurposeField/Dropdown/styles.module.scss +0 -215
  66. package/src/components/MultipurposeField/TagMenu/index.ts +0 -536
  67. package/src/components/MultipurposeField/TagMenu/styles.module.scss +0 -175
  68. package/src/components/MultipurposeField/TagOptions/index.tsx +0 -83
  69. package/src/components/MultipurposeField/TagOptions/styles.module.scss +0 -95
  70. package/src/components/MultipurposeField/index.tsx +0 -944
  71. package/src/components/MultipurposeField/styles.module.scss +0 -77
  72. package/src/components/NewModal/index.ts +0 -69
  73. package/src/components/NewModal/styles.module.scss +0 -70
  74. package/src/components/OverflowTooltip/index.tsx +0 -59
  75. package/src/components/PopUp/ConfirmationPopUp/index.ts +0 -58
  76. package/src/components/PopUp/ConfirmationPopUp/styles.module.scss +0 -49
  77. package/src/components/PopUp/SuccessPopUp/index.ts +0 -62
  78. package/src/components/PopUp/SuccessPopUp/styles.module.scss +0 -38
  79. package/src/components/RadioGroup/Radio.ts +0 -128
  80. package/src/components/RadioGroup/index.ts +0 -169
  81. package/src/components/RadioGroup/styles.module.scss +0 -81
  82. package/src/components/Search/index.ts +0 -69
  83. package/src/components/Search/styles.module.scss +0 -149
  84. package/src/components/TabBar/Tab.ts +0 -33
  85. package/src/components/TabBar/index.ts +0 -64
  86. package/src/components/TabBar/styles.module.scss +0 -43
  87. package/src/components/Tag/index.ts +0 -29
  88. package/src/components/Tag/styles.module.scss +0 -57
  89. package/src/components/TagsMenu/index.ts +0 -1697
  90. package/src/components/TagsMenu/styles.module.scss +0 -350
  91. package/src/components/TestComponent/index.ts +0 -71
  92. package/src/components/TestComponent/styles.module.scss +0 -152
  93. package/src/components/TextArea/index.ts +0 -172
  94. package/src/components/TextArea/styles.module.scss +0 -72
  95. package/src/components/TextContent/index.tsx +0 -128
  96. package/src/components/TextContent/styles.module.scss +0 -6
  97. package/src/components/ThreeDotLoader/index.ts +0 -39
  98. package/src/components/ThreeDotLoader/styles.module.scss +0 -41
  99. package/src/components/TimeInput/index.ts +0 -129
  100. package/src/components/TimeInput/styles.module.scss +0 -16
  101. package/src/components/Toggle/index.ts +0 -34
  102. package/src/components/Toggle/styles.module.scss +0 -56
  103. package/src/components/Toggle-v2/index.ts +0 -40
  104. package/src/components/Toggle-v2/styles.module.scss +0 -86
  105. package/src/components/Tooltip/index.ts +0 -271
  106. package/src/components/Tooltip/styles.module.scss +0 -105
  107. package/src/components/form/FunctionField/index.ts +0 -816
  108. package/src/components/form/FunctionField/styles.module.scss +0 -478
  109. package/src/components/form/ObjectField/__snapshots__/index.ts.test.tsx.snap +0 -3
  110. package/src/components/form/ObjectField/index.ts +0 -593
  111. package/src/components/form/ObjectField/index.ts.test.tsx +0 -213
  112. package/src/components/form/ObjectField/styles.module.scss +0 -103
  113. package/src/components/form/index.ts +0 -4
  114. package/src/contexts/AppContext.ts +0 -12
  115. package/src/declaration.d.ts +0 -7
  116. package/src/extensions/HMAC.ts +0 -25
  117. package/src/extensions/IntegryAPIError.ts +0 -19
  118. package/src/features/common/AccountDropdown/index.ts +0 -291
  119. package/src/features/common/AccountDropdown/styles.module.scss +0 -19
  120. package/src/features/common/ActionForm/index.ts +0 -2602
  121. package/src/features/common/ActionForm/styles.module.scss +0 -35
  122. package/src/features/common/AppCard/index.ts +0 -207
  123. package/src/features/common/AppCard/styles.module.scss +0 -117
  124. package/src/features/common/AppCardCompact/index.ts +0 -189
  125. package/src/features/common/AppCardCompact/styles.module.scss +0 -141
  126. package/src/features/common/AuthSelector/index.ts +0 -537
  127. package/src/features/common/AuthSelector/styles.module.scss +0 -161
  128. package/src/features/common/AuthSelectorCompact/index.ts +0 -706
  129. package/src/features/common/AuthSelectorCompact/styles.module.scss +0 -219
  130. package/src/features/common/AuthSelectorDropdown/index.ts +0 -704
  131. package/src/features/common/AuthSelectorDropdown/styles.module.scss +0 -361
  132. package/src/features/common/AuthSelectorV2/index.ts +0 -336
  133. package/src/features/common/AuthSelectorV2/styles.module.scss +0 -235
  134. package/src/features/common/DynamicField/index.ts +0 -402
  135. package/src/features/common/DynamicField/styles.module.scss +0 -266
  136. package/src/features/common/DynamicTypedField/index.ts +0 -504
  137. package/src/features/common/DynamicTypedField/styles.module.scss +0 -135
  138. package/src/features/common/FunctionForm/index.ts +0 -1095
  139. package/src/features/common/FunctionForm/styles.module.scss +0 -225
  140. package/src/features/common/MappingUI/index.ts +0 -649
  141. package/src/features/common/MappingUI/styles.module.scss +0 -121
  142. package/src/features/common/MarketplaceAppCard/index.ts +0 -279
  143. package/src/features/common/MarketplaceAppCard/styles.module.scss +0 -231
  144. package/src/features/common/MarketplaceAppCardCompact/index.ts +0 -283
  145. package/src/features/common/MarketplaceAppCardCompact/styles.module.scss +0 -255
  146. package/src/features/common/NewMappingUI/index.ts +0 -515
  147. package/src/features/common/NewMappingUI/styles.module.scss +0 -113
  148. package/src/features/common/RequestAppWidget/RequestAppModal/index.ts +0 -67
  149. package/src/features/common/RequestAppWidget/RequestAppModal/styles.module.scss +0 -23
  150. package/src/features/common/RequestAppWidget/index.ts +0 -48
  151. package/src/features/common/RequestAppWidget/request-app-form.ts +0 -89
  152. package/src/features/common/RequestAppWidget/styles.module.scss +0 -43
  153. package/src/features/common/SectionField/index.ts +0 -272
  154. package/src/features/common/SectionField/styles.module.scss +0 -67
  155. package/src/features/common/Step/index.ts +0 -827
  156. package/src/features/common/Step/styles.module.scss +0 -12
  157. package/src/features/common/StepNavigation/CollapsedSteps.ts +0 -131
  158. package/src/features/common/StepNavigation/NavItem.ts +0 -111
  159. package/src/features/common/StepNavigation/index.ts +0 -261
  160. package/src/features/common/StepNavigation/styles.module.scss +0 -117
  161. package/src/features/common/Steps/index.ts +0 -1140
  162. package/src/features/common/Steps/styles.module.scss +0 -314
  163. package/src/features/containers/AppFlowContainer/AppFlowListing/compactStyles.module.scss +0 -404
  164. package/src/features/containers/AppFlowContainer/AppFlowListing/flow-instance.tsx +0 -367
  165. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCard.test.tsx +0 -58
  166. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCard.tsx +0 -208
  167. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCardCompact.test.tsx +0 -49
  168. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCardCompact.tsx +0 -421
  169. package/src/features/containers/AppFlowContainer/AppFlowListing/flowInstanceCompact.tsx +0 -577
  170. package/src/features/containers/AppFlowContainer/AppFlowListing/index.tsx +0 -83
  171. package/src/features/containers/AppFlowContainer/AppFlowListing/styles.module.scss +0 -233
  172. package/src/features/containers/AppFlowContainer/AppFlowWrap/app-page-loader.tsx +0 -45
  173. package/src/features/containers/AppFlowContainer/AppFlowWrap/index.tsx +0 -1085
  174. package/src/features/containers/AppFlowContainer/AppFlowWrap/styles.module.scss +0 -465
  175. package/src/features/containers/AppFlowContainer/Authentication/index.ts +0 -610
  176. package/src/features/containers/AppFlowContainer/Authentication/styles.module.scss +0 -468
  177. package/src/features/containers/AppFlowContainer/index.ts +0 -114
  178. package/src/features/containers/AppPageContainer/AppPage/index.tsx +0 -262
  179. package/src/features/containers/AppPageContainer/AppPage/styles.module.scss +0 -120
  180. package/src/features/containers/AppPageContainer/IntegrationCard/index.ts +0 -165
  181. package/src/features/containers/AppPageContainer/IntegrationCard/styles.module.scss +0 -81
  182. package/src/features/containers/AppPageContainer/index.tsx +0 -93
  183. package/src/features/containers/AppPageContainer/styles.module.scss +0 -0
  184. package/src/features/containers/AppsForFlows/index.ts +0 -161
  185. package/src/features/containers/AppsForFlows/styles.module.scss +0 -280
  186. package/src/features/containers/AppsForFlowsCompact/index.ts +0 -161
  187. package/src/features/containers/AppsForFlowsCompact/styles.module.scss +0 -279
  188. package/src/features/containers/AuthSetupContainer/AppSelection.ts +0 -73
  189. package/src/features/containers/AuthSetupContainer/AuthTypeSelection.ts +0 -67
  190. package/src/features/containers/AuthSetupContainer/Footer.ts +0 -32
  191. package/src/features/containers/AuthSetupContainer/Header.ts +0 -39
  192. package/src/features/containers/AuthSetupContainer/PostAdditionPopup.ts +0 -27
  193. package/src/features/containers/AuthSetupContainer/index.ts +0 -349
  194. package/src/features/containers/AuthSetupContainer/styles.module.scss +0 -229
  195. package/src/features/containers/FlowSetupContainer/index.ts +0 -391
  196. package/src/features/containers/FlowSetupContainer/styles.module.scss +0 -18
  197. package/src/features/containers/MarkeplaceApps/index.ts +0 -583
  198. package/src/features/containers/MarkeplaceApps/styles.module.scss +0 -558
  199. package/src/features/containers/MarketplaceAppsCompact/index.ts +0 -585
  200. package/src/features/containers/MarketplaceAppsCompact/styles.module.scss +0 -563
  201. package/src/features/containers/MarketplaceAppsContainer/index.ts +0 -91
  202. package/src/features/containers/MarketplaceContainer/AppCard/index.ts +0 -91
  203. package/src/features/containers/MarketplaceContainer/AppCard/styles.module.scss +0 -66
  204. package/src/features/containers/MarketplaceContainer/AppListing/index.ts +0 -34
  205. package/src/features/containers/MarketplaceContainer/AppListing/styles.module.scss +0 -10
  206. package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/index.ts +0 -132
  207. package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/styles.module.scss +0 -117
  208. package/src/features/containers/MarketplaceContainer/index.ts +0 -242
  209. package/src/features/containers/MarketplaceContainer/styles.module.scss +0 -84
  210. package/src/features/containers/SDKContainer/index.ts +0 -817
  211. package/src/features/containers/SDKContainer/styles.module.scss +0 -266
  212. package/src/features/containers/SDKDebugContainer/index.ts +0 -137
  213. package/src/features/containers/SDKDebugContainer/styles.module.scss +0 -37
  214. package/src/features/containers/SDKFailedContainer/index.ts +0 -117
  215. package/src/features/containers/SDKFailedContainer/styles.module.scss +0 -57
  216. package/src/features/integrations/IntegrationRow/Icons.ts +0 -77
  217. package/src/features/integrations/IntegrationRow/index.ts +0 -129
  218. package/src/features/integrations/IntegrationRow/styles.module.scss +0 -62
  219. package/src/features/integrations/IntegrationsHeader/index.ts +0 -34
  220. package/src/features/integrations/IntegrationsHeader/styles.module.scss +0 -47
  221. package/src/features/integrations/IntegrationsList/index.ts +0 -252
  222. package/src/features/integrations/IntegrationsList/styles.module.scss +0 -67
  223. package/src/features/templates/Template/index.ts +0 -295
  224. package/src/features/templates/Template/styles.module.scss +0 -226
  225. package/src/features/templates/TemplatesView/index.ts +0 -368
  226. package/src/features/templates/TemplatesView/styles.module.scss +0 -71
  227. package/src/features/templates/TemplatesViewCompact/index.ts +0 -364
  228. package/src/features/templates/TemplatesViewCompact/styles.module.scss +0 -141
  229. package/src/hooks/useAutosizeTextArea.ts +0 -22
  230. package/src/hooks/useCustomRef.ts +0 -13
  231. package/src/hooks/useDebounce.ts +0 -17
  232. package/src/hooks/useElementResize.ts +0 -40
  233. package/src/hooks/useEventListener.ts +0 -42
  234. package/src/hooks/useHover.ts +0 -40
  235. package/src/hooks/useOnClickOutside.ts +0 -32
  236. package/src/index.ts +0 -2244
  237. package/src/index.umd.ts +0 -13
  238. package/src/interfaces/index.ts +0 -938
  239. package/src/modules/api/index.ts +0 -1325
  240. package/src/modules/api/responseHandler.ts +0 -38
  241. package/src/modules/event-emitter/index.ts +0 -72
  242. package/src/modules/event-emitter/runners/abstract.ts +0 -21
  243. package/src/modules/event-emitter/runners/default.ts +0 -11
  244. package/src/modules/event-emitter/runners/ntimes.ts +0 -28
  245. package/src/modules/event-emitter/types.ts +0 -34
  246. package/src/store/actionFunctions.ts +0 -1578
  247. package/src/store/index.ts +0 -17
  248. package/src/store/initialState.ts +0 -58
  249. package/src/types/index.ts +0 -320
  250. package/src/types/preact-compat.d.ts +0 -4
  251. package/src/types/store.ts +0 -366
  252. package/src/types/utils.ts +0 -19
  253. package/src/utils/ActivityOutputUtils.ts +0 -176
  254. package/src/utils/common.ts +0 -20
  255. package/src/utils/copyToClipboard.ts +0 -24
  256. package/src/utils/datetime.ts +0 -101
  257. package/src/utils/getUrlParam.ts +0 -11
  258. package/src/utils/isAuthMessage.ts +0 -16
  259. package/src/utils/isBrowser.ts +0 -1
  260. package/src/utils/jsonEncodeDecode.ts +0 -15
  261. package/src/utils/objectUtils.ts +0 -117
  262. package/src/utils/popup.ts +0 -30
  263. package/src/utils/searchJson.ts +0 -51
  264. package/src/utils/stepUtils.ts +0 -45
  265. package/src/utils/truncate.ts +0 -6
  266. package/test/setup.ts +0 -1
  267. package/vitest.config.ts +0 -16
@@ -1,1325 +0,0 @@
1
- /**
2
- * Simple API module
3
- */
4
-
5
- import fetch from 'unfetch';
6
-
7
- // eslint-disable-next-line import/no-cycle
8
- import {
9
- APIConfig,
10
- BundleResponse,
11
- IntegrationSaveResponse,
12
- SaveOrUpdateIntegrationBody,
13
- TemplateResponse,
14
- IntegrationResponse,
15
- TemplateStep,
16
- ActivityCustomField,
17
- AppsForAuthConnectionResponse,
18
- AppsForAuthConnection,
19
- Integration,
20
- MarketplaceAppBundle,
21
- AppRequestFormData,
22
- MarketplaceAppAuthorizationType,
23
- UploadFileObj,
24
- AppFlowsResponse,
25
- BrandingApp,
26
- ExecuteFlowResponse,
27
- IncomingWebhookPayload,
28
- NestedObject,
29
- MarketplaceApp,
30
- } from '@/interfaces';
31
-
32
- import { ResponseHandler } from './responseHandler';
33
-
34
- class IntegryAPI {
35
- private config: APIConfig;
36
-
37
- constructor(config: APIConfig) {
38
- this.config = config;
39
- }
40
-
41
- static addUrlSearchParams = (
42
- url: URL,
43
- paramList: Record<string, string | number | boolean | null>,
44
- ) =>
45
- Object.keys(paramList).map(
46
- (objKey) =>
47
- paramList[objKey] !== undefined &&
48
- paramList[objKey] !== null &&
49
- url.searchParams.append(objKey, `${paramList[objKey]}`),
50
- );
51
-
52
- public getTemplate = async (
53
- templateId: number,
54
- self_auth_id?: number,
55
- app_auth_id?: number,
56
- ): Promise<TemplateResponse | null> => {
57
- const url = new URL(`${this.config.baseUrlv2}/template/${templateId}/`);
58
-
59
- IntegryAPI.addUrlSearchParams(url, {
60
- app_key: this.config.appKey,
61
- hash: this.config.hash,
62
- user_id: this.config.userId,
63
- self_api_key: this.config.apiKey || null,
64
- self_auth_id: this.config.authId || self_auth_id || null,
65
- self_auth_extras: this.config.extras
66
- ? JSON.stringify(this.config.extras)
67
- : null,
68
- app_auth_id: app_auth_id || null,
69
- });
70
-
71
- try {
72
- const response = await fetch(url.toString()).then((data) =>
73
- ResponseHandler<TemplateResponse>(data),
74
- );
75
- return response.data;
76
- } catch (error) {
77
- console.error(error);
78
- return null;
79
- }
80
- };
81
-
82
- public getAuthUrl = (authorizationTypeId: number): string => {
83
- const url = new URL(
84
- `${this.config.baseUrl}/auth/login/${authorizationTypeId}/`,
85
- );
86
-
87
- IntegryAPI.addUrlSearchParams(url, {
88
- app_key: this.config.appKey,
89
- hash: this.config.hash,
90
- user_id: this.config.userId,
91
- });
92
-
93
- return url.toString();
94
- };
95
-
96
- public getAuthUrlByApp = (appName: string): string => {
97
- const url = new URL(`${this.config.baseUrl}/auth/app/login/${appName}/`);
98
-
99
- IntegryAPI.addUrlSearchParams(url, {
100
- app_key: this.config.appKey,
101
- hash: this.config.hash,
102
- user_id: this.config.userId,
103
- });
104
-
105
- return url.toString();
106
- };
107
-
108
- public getAppById = async (appId: string): Promise<BrandingApp | null> => {
109
- const url = new URL(`${this.config.baseUrl}/api/apps/${appId}/`);
110
-
111
- IntegryAPI.addUrlSearchParams(url, {
112
- app_key: this.config.appKey,
113
- hash: this.config.hash,
114
- user_id: this.config.userId,
115
- sdk_request: true,
116
- });
117
-
118
- try {
119
- const response = await fetch(url.toString()).then((data) =>
120
- ResponseHandler<BrandingApp>(data),
121
- );
122
-
123
- return response.data;
124
- } catch (error) {
125
- console.error(error);
126
- return null;
127
- }
128
- };
129
-
130
- public getTemplateStep = async (
131
- stepId: number,
132
- integrationId?: number,
133
- versionId?: number,
134
- self_auth_id?: number,
135
- app_auth_id?: number,
136
- ): Promise<TemplateStep | null> => {
137
- const url = new URL(`${this.config.baseUrl}/template_step/${stepId}/`);
138
-
139
- IntegryAPI.addUrlSearchParams(url, {
140
- app_key: this.config.appKey,
141
- hash: this.config.hash,
142
- user_id: this.config.userId,
143
- self_api_key: this.config.apiKey || null,
144
- self_auth_id: this.config.authId || self_auth_id || null,
145
- integration_id: integrationId ? `${integrationId}` : null,
146
- version_id: versionId ? `${versionId}` : null,
147
- self_auth_extras: this.config.extras
148
- ? JSON.stringify(this.config.extras)
149
- : null,
150
- app_auth_id: app_auth_id || null,
151
- v: '4.0',
152
- });
153
-
154
- try {
155
- const response = await fetch(url.toString()).then((data) =>
156
- ResponseHandler<TemplateStep>(data),
157
- );
158
-
159
- return response.data;
160
- } catch (error) {
161
- console.error(error);
162
- return null;
163
- }
164
- };
165
-
166
- public verifyOAuth = async (authId: number): Promise<boolean | null> => {
167
- const url = new URL(
168
- `${this.config.baseUrl}/${this.config.oauthVerifyPath}`,
169
- );
170
-
171
- IntegryAPI.addUrlSearchParams(url, {
172
- authorization_id: `${authId}`,
173
- app_key: this.config.appKey,
174
- hash: this.config.hash,
175
- user_id: this.config.userId,
176
- });
177
-
178
- try {
179
- const response = await fetch(url.toString(), { method: 'POST' }).then(
180
- ResponseHandler,
181
- );
182
- return !!response.data;
183
- } catch (error) {
184
- console.error(error);
185
- return null;
186
- }
187
- };
188
-
189
- public verifyOAuthWithError = async (
190
- authId: number,
191
- ): Promise<{
192
- error_message: string;
193
- status: number;
194
- is_valid: boolean;
195
- } | null> => {
196
- const url = new URL(
197
- `${this.config.baseUrl}/${this.config.oauthVerifyPath}?return_error=true`,
198
- );
199
-
200
- IntegryAPI.addUrlSearchParams(url, {
201
- authorization_id: `${authId}`,
202
- app_key: this.config.appKey,
203
- hash: this.config.hash,
204
- user_id: this.config.userId,
205
- });
206
-
207
- try {
208
- const response = await fetch(url.toString(), {
209
- method: 'POST',
210
- }).then((data) =>
211
- ResponseHandler<{
212
- error_message: string;
213
- status: number;
214
- is_valid: boolean;
215
- }>(data),
216
- );
217
- return response.data;
218
- } catch (error) {
219
- console.error(error);
220
- return null;
221
- }
222
- };
223
-
224
- public deleteAuth = async (
225
- authId: number,
226
- force?: boolean,
227
- ): Promise<{
228
- data: string | null;
229
- status: number;
230
- } | null> => {
231
- const url = new URL(
232
- `${this.config.baseUrl}/connected-accounts/${authId}?force=${
233
- force ?? false
234
- }`,
235
- );
236
-
237
- IntegryAPI.addUrlSearchParams(url, {
238
- app_key: this.config.appKey,
239
- hash: this.config.hash,
240
- user_id: this.config.userId,
241
- });
242
-
243
- try {
244
- const response = await fetch(url.toString(), {
245
- method: 'DELETE',
246
- }).then((data) => ResponseHandler<string>(data));
247
-
248
- return {
249
- status: response.status,
250
- data: response.data,
251
- };
252
- } catch (error) {
253
- console.error(error);
254
- return null;
255
- }
256
- };
257
-
258
- public callDynamicDataEndpoint = async <T>(
259
- url: URL,
260
- endpointData: Record<string, string> = {},
261
- method = 'GET',
262
- body?: Record<string, string>,
263
- ): Promise<T | null> => {
264
- IntegryAPI.addUrlSearchParams(url, {
265
- app_key: this.config.appKey,
266
- hash: this.config.hash,
267
- user_id: this.config.userId,
268
- ...endpointData,
269
- });
270
-
271
- try {
272
- const response = await fetch(url.toString(), {
273
- method,
274
- headers: {
275
- 'Content-Type': 'application/json',
276
- },
277
- body: JSON.stringify(body),
278
- }).then((data) => ResponseHandler<T>(data));
279
- return response.data;
280
- } catch (error) {
281
- console.error(error);
282
- return null;
283
- }
284
- };
285
-
286
- public getTemplateListing = async (
287
- deploymentId: number,
288
- tags?: string[],
289
- ): Promise<BundleResponse | null> => {
290
- const url = new URL(`${this.config.baseUrl}/bundle/${deploymentId}/`);
291
-
292
- if ((tags || []).length > 0) {
293
- IntegryAPI.addUrlSearchParams(url, {
294
- app_key: this.config.appKey,
295
- hash: this.config.hash,
296
- user_id: this.config.userId,
297
- tags: (tags || []).join(','),
298
- });
299
- } else {
300
- IntegryAPI.addUrlSearchParams(url, {
301
- app_key: this.config.appKey,
302
- hash: this.config.hash,
303
- user_id: this.config.userId,
304
- });
305
- }
306
-
307
- try {
308
- const response = await fetch(url.toString()).then((data) =>
309
- ResponseHandler<BundleResponse>(data),
310
- );
311
- return response.data;
312
- } catch (error) {
313
- console.error(error);
314
- return null;
315
- }
316
- };
317
-
318
- public getTemplateListingV2 = async (
319
- tags?: string[],
320
- deploymentId?: number | null,
321
- ): Promise<BundleResponse | null> => {
322
- const url = new URL(
323
- `${this.config.baseUrl}/api/v1/sdk/flows/?page_size=9999&show_draft=true${
324
- deploymentId ? `&deployment_id=${deploymentId}` : ''
325
- }`,
326
- );
327
-
328
- if ((tags || []).length > 0) {
329
- IntegryAPI.addUrlSearchParams(url, {
330
- app_key: this.config.appKey,
331
- hash: this.config.hash,
332
- user_id: this.config.userId,
333
- tags: (tags || []).join(','),
334
- });
335
- } else {
336
- IntegryAPI.addUrlSearchParams(url, {
337
- app_key: this.config.appKey,
338
- hash: this.config.hash,
339
- user_id: this.config.userId,
340
- });
341
- }
342
-
343
- try {
344
- const response = await fetch(url.toString()).then((data) =>
345
- ResponseHandler<BundleResponse>(data),
346
- );
347
- return response.data;
348
- } catch (error) {
349
- console.error(error);
350
- return null;
351
- }
352
- };
353
-
354
- public saveIntegration = async (
355
- body: SaveOrUpdateIntegrationBody,
356
- ): Promise<IntegrationSaveResponse | null> => {
357
- const url = new URL(`${this.config.baseUrlv2}/integration/`);
358
-
359
- IntegryAPI.addUrlSearchParams(url, {
360
- async: false,
361
- app_key: this.config.appKey,
362
- hash: this.config.hash,
363
- user_id: this.config.userId,
364
- activate: this.config?.defaultIntegrationStatus ?? true,
365
- });
366
-
367
- try {
368
- const response = await fetch(url.toString(), {
369
- method: 'POST',
370
- body: JSON.stringify(body),
371
- headers: {
372
- 'Content-Type': 'application/json',
373
- },
374
- }).then((data) => ResponseHandler<IntegrationSaveResponse>(data));
375
- return response.data;
376
- } catch (error) {
377
- console.error(error);
378
- return null;
379
- }
380
- };
381
-
382
- public getAppsForAuthConnection = async (payload?: {
383
- deploymentId?: string;
384
- page?: number;
385
- tags?: string;
386
- }): Promise<any | null> => {
387
- const url = new URL(`${this.config.baseUrl}/api/v1/sdk/flow-apps/`);
388
-
389
- IntegryAPI.addUrlSearchParams(url, {
390
- app_key: this.config.appKey,
391
- hash: this.config.hash,
392
- user_id: this.config.userId,
393
- page: `${payload?.page ?? ''}`,
394
- tags: payload?.tags ?? '',
395
- page_size: 9999,
396
- });
397
-
398
- try {
399
- const response = await fetch(url.toString(), {
400
- method: 'GET',
401
- }).then((data) => ResponseHandler<BrandingApp>(data));
402
- return response.data;
403
- } catch (error) {
404
- console.error(error);
405
- return null;
406
- }
407
- };
408
-
409
- public updateIntegration = async (
410
- integrationId: string,
411
- shouldActivate: boolean,
412
- body: SaveOrUpdateIntegrationBody,
413
- ): Promise<boolean | null> => {
414
- const url = new URL(
415
- `${this.config.baseUrlv2}/integration/${integrationId}/`,
416
- );
417
-
418
- IntegryAPI.addUrlSearchParams(url, {
419
- async: false,
420
- app_key: this.config.appKey,
421
- hash: this.config.hash,
422
- user_id: this.config.userId,
423
- activate: shouldActivate,
424
- });
425
-
426
- try {
427
- const response = await fetch(url.toString(), {
428
- method: 'PUT',
429
- body: JSON.stringify(body),
430
- headers: {
431
- 'Content-Type': 'application/json',
432
- },
433
- }).then((data) => ResponseHandler<boolean>(data));
434
- return response.data;
435
- } catch (error) {
436
- console.error(error);
437
- return null;
438
- }
439
- };
440
-
441
- public renameIntegration = async (
442
- integrationId: string,
443
- name: string,
444
- ): Promise<Integration | null> => {
445
- const url = new URL(
446
- `${this.config.baseUrlv2}/integration/${integrationId}/rename/`,
447
- );
448
-
449
- IntegryAPI.addUrlSearchParams(url, {
450
- app_key: this.config.appKey,
451
- hash: this.config.hash,
452
- user_id: this.config.userId,
453
- });
454
-
455
- try {
456
- const response = await fetch(url.toString(), {
457
- method: 'PUT',
458
- body: JSON.stringify({ name }),
459
- headers: {
460
- 'Content-Type': 'application/json',
461
- },
462
- }).then((data) => ResponseHandler<Integration>(data));
463
- return response.data;
464
- } catch (error) {
465
- console.error(error);
466
- return null;
467
- }
468
- };
469
-
470
- public deleteIntegration = async (
471
- integrationId: number,
472
- ): Promise<boolean | null> => {
473
- const url = new URL(
474
- `${this.config.baseUrl}/setup/template/${integrationId}/`,
475
- );
476
-
477
- IntegryAPI.addUrlSearchParams(url, {
478
- app_key: this.config.appKey,
479
- hash: this.config.hash,
480
- user_id: this.config.userId,
481
- });
482
-
483
- try {
484
- const response = await fetch(url.toString(), {
485
- method: 'DELETE',
486
- }).then((data) => ResponseHandler<boolean>(data));
487
- return response.data;
488
- } catch (error) {
489
- console.error(error);
490
- return null;
491
- }
492
- };
493
-
494
- public toggleIntegration = async (
495
- integrationId: number,
496
- activate: boolean,
497
- ): Promise<string | null> => {
498
- const url = new URL(
499
- `${this.config.baseUrlv2}/integration/${integrationId}/${
500
- activate ? 'enable' : 'disable'
501
- }/`,
502
- );
503
-
504
- IntegryAPI.addUrlSearchParams(url, {
505
- app_key: this.config.appKey,
506
- hash: this.config.hash,
507
- user_id: this.config.userId,
508
- });
509
-
510
- try {
511
- const response = await fetch(url.toString(), {
512
- method: 'PUT',
513
- }).then((data) => ResponseHandler<string>(data));
514
- return response.data;
515
- } catch (error) {
516
- console.error(error);
517
- return null;
518
- }
519
- };
520
-
521
- public getIntegrationById = async (
522
- integrationId: number,
523
- isReadOnly?: boolean,
524
- ): Promise<IntegrationResponse | null> => {
525
- const url = new URL(
526
- `${this.config.baseUrlv2}/integration/${integrationId}`,
527
- );
528
-
529
- IntegryAPI.addUrlSearchParams(url, {
530
- app_key: this.config.appKey,
531
- hash: this.config.hash,
532
- user_id: this.config.userId,
533
- is_read_only: !!isReadOnly,
534
- });
535
-
536
- try {
537
- const response = await fetch(url.toString(), {
538
- method: 'GET',
539
- }).then((data) => ResponseHandler<IntegrationResponse>(data));
540
- return response.data;
541
- } catch (error) {
542
- console.error(error);
543
- return null;
544
- }
545
- };
546
-
547
- public getCustomFields = async (params: {
548
- activityFieldId: number;
549
- stepName?: string;
550
- authorizationId: number;
551
- endpointData?: Record<string, string | number>;
552
- }): Promise<ActivityCustomField[] | null> => {
553
- const url = new URL(
554
- `${this.config.baseUrl}/endpoints/get_custom_fields/${params.activityFieldId}/`,
555
- );
556
-
557
- IntegryAPI.addUrlSearchParams(url, {
558
- app_key: this.config.appKey,
559
- hash: this.config.hash,
560
- user_id: this.config.userId,
561
- step_name: params.stepName || '',
562
- authorization_id: `${params.authorizationId}`,
563
- ...(params.endpointData || {}),
564
- });
565
-
566
- try {
567
- const response = await fetch(url.toString(), {
568
- method: 'GET',
569
- }).then((data) => ResponseHandler<ActivityCustomField[]>(data));
570
- return response.data;
571
- } catch (error) {
572
- console.error(error);
573
- return null;
574
- }
575
- };
576
-
577
- public verifyAuthConfig = async (params: {
578
- deploymentId?: string;
579
- }): Promise<{ config_verified: boolean; meta: any } | null> => {
580
- const url = new URL(`${this.config.baseUrl}/verify-sdk-config/`);
581
-
582
- if (params.deploymentId) {
583
- IntegryAPI.addUrlSearchParams(url, {
584
- app_key: this.config.appKey,
585
- hash: this.config.hash,
586
- user_id: this.config.userId,
587
- bundle_id: params.deploymentId || '',
588
- });
589
- } else {
590
- IntegryAPI.addUrlSearchParams(url, {
591
- app_key: this.config.appKey,
592
- hash: this.config.hash,
593
- user_id: this.config.userId,
594
- });
595
- }
596
-
597
- try {
598
- const response = await fetch(url.toString(), {
599
- method: 'GET',
600
- }).then((data) =>
601
- ResponseHandler<{ config_verified: boolean; meta: any }>(data),
602
- );
603
- return response.data;
604
- } catch (error) {
605
- console.error(error);
606
- return null;
607
- }
608
- };
609
-
610
- public getMarketplaceApps = async (payload: {
611
- marketplaceId: string;
612
- }): Promise<MarketplaceAppBundle[] | null> => {
613
- const url = new URL(`${this.config.baseUrl}/sdk/bundle_apps/`);
614
-
615
- IntegryAPI.addUrlSearchParams(url, {
616
- app_key: this.config.appKey,
617
- hash: this.config.hash,
618
- user_id: this.config.userId,
619
- bundle: payload.marketplaceId,
620
- });
621
-
622
- try {
623
- const response = await fetch(url.toString(), {
624
- method: 'GET',
625
- }).then((data) => ResponseHandler<MarketplaceAppBundle[]>(data));
626
- return response.data;
627
- } catch (error) {
628
- console.error(error);
629
- return null;
630
- }
631
- };
632
-
633
- public getMarketplaceAppDetail = async (payload: {
634
- marketplaceId: string;
635
- marketplaceAppId: string;
636
- app_auth_id?: number | undefined | null;
637
- }): Promise<MarketplaceAppBundle | null> => {
638
- const url = new URL(
639
- `${this.config.baseUrl}/sdk/bundle_apps/${payload.marketplaceAppId}/`,
640
- );
641
-
642
- IntegryAPI.addUrlSearchParams(url, {
643
- app_key: this.config.appKey,
644
- hash: this.config.hash,
645
- user_id: this.config.userId,
646
- bundle: payload.marketplaceId,
647
- app_auth_id: payload.app_auth_id || null,
648
- });
649
-
650
- try {
651
- const response = await fetch(url.toString(), {
652
- method: 'GET',
653
- }).then((data) => ResponseHandler<MarketplaceAppBundle>(data));
654
- return response.data;
655
- } catch (error) {
656
- console.error(error);
657
- return null;
658
- }
659
- };
660
-
661
- public sendRequestForNewApp = async (
662
- marketplaceId: number,
663
- formData: AppRequestFormData,
664
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
665
- ): Promise<any | null> => {
666
- const url = new URL(
667
- `${this.config.baseUrl}/bundle/${marketplaceId}/app_requests/`,
668
- );
669
-
670
- IntegryAPI.addUrlSearchParams(url, {
671
- app_key: this.config.appKey,
672
- hash: this.config.hash,
673
- user_id: this.config.userId,
674
- });
675
-
676
- try {
677
- const response = await fetch(url.toString(), {
678
- method: 'POST',
679
- body: JSON.stringify(formData),
680
- headers: {
681
- 'Content-Type': 'application/json',
682
- },
683
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
684
- }).then((data) => ResponseHandler<any>(data));
685
- return response.data;
686
- } catch (error) {
687
- console.error(error);
688
- return null;
689
- }
690
- };
691
-
692
- public getMarketplaceDetails = async (payload: {
693
- marketplaceId: string;
694
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
695
- }): Promise<any | null> => {
696
- const url = new URL(
697
- `${this.config.baseUrl}/bundle/${payload.marketplaceId}`,
698
- );
699
-
700
- IntegryAPI.addUrlSearchParams(url, {
701
- app_key: this.config.appKey,
702
- hash: this.config.hash,
703
- user_id: this.config.userId,
704
- });
705
-
706
- try {
707
- const response = await fetch(url.toString(), {
708
- method: 'GET',
709
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
710
- }).then((data) => ResponseHandler<any>(data));
711
- return response.data;
712
- } catch (error) {
713
- console.error(error);
714
- return null;
715
- }
716
- };
717
-
718
- public setDefaultAuthorization = async (payload: {
719
- authorizationId: number;
720
- authorizationTypeId: number;
721
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
722
- }): Promise<{ id: number; user_identity: string } | null> => {
723
- const url = new URL(
724
- `${this.config.baseUrl}/connected-accounts/${payload.authorizationId}/set_as_default/`,
725
- );
726
-
727
- IntegryAPI.addUrlSearchParams(url, {
728
- app_key: this.config.appKey,
729
- hash: this.config.hash,
730
- user_id: this.config.userId,
731
- authorization_type: `${payload.authorizationTypeId}`,
732
- });
733
-
734
- try {
735
- const response = await fetch(url.toString(), {
736
- method: 'POST',
737
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
738
- }).then((data) =>
739
- ResponseHandler<{ id: number; user_identity: string }>(data),
740
- );
741
- return response.data;
742
- } catch (error) {
743
- console.error(error);
744
- return null;
745
- }
746
- };
747
-
748
- public saveAppDescription = async (
749
- bundleAppId: number,
750
- payload: {
751
- long_description: string;
752
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
753
- },
754
- ): Promise<any | null> => {
755
- const url = new URL(`${this.config.baseUrl}/bundle_apps/${bundleAppId}/`);
756
-
757
- IntegryAPI.addUrlSearchParams(url, {
758
- app_key: this.config.appKey,
759
- hash: this.config.hash,
760
- user_id: this.config.userId,
761
- });
762
-
763
- try {
764
- const response = await fetch(url.toString(), {
765
- method: 'PATCH',
766
- body: JSON.stringify(payload),
767
- headers: {
768
- 'Content-Type': 'application/json',
769
- },
770
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
771
- }).then((data) => ResponseHandler<any>(data));
772
- return response.data;
773
- } catch (error) {
774
- console.error(error);
775
- return null;
776
- }
777
- };
778
-
779
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
780
- public getIUTestingAccounts = async (): Promise<MarketplaceAppAuthorizationType | null> => {
781
- const url = new URL(
782
- `${this.config.baseUrl}/connected-accounts/list_workspace_connected_accounts/`,
783
- );
784
-
785
- IntegryAPI.addUrlSearchParams(url, {
786
- app_key: this.config.appKey,
787
- hash: this.config.hash,
788
- user_id: this.config.userId,
789
- });
790
-
791
- try {
792
- const response = await fetch(url.toString(), {
793
- method: 'GET',
794
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
795
- }).then((data) => ResponseHandler<MarketplaceAppAuthorizationType>(data));
796
- return response.data;
797
- } catch (error) {
798
- console.error(error);
799
- return null;
800
- }
801
- };
802
-
803
- public uploadFile = async (
804
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
805
- formData: any,
806
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
807
- ): Promise<any | null> => {
808
- const url = new URL(`${this.config.baseUrl}/api/files/`);
809
-
810
- IntegryAPI.addUrlSearchParams(url, {
811
- app_key: this.config.appKey,
812
- hash: this.config.hash,
813
- user_id: this.config.userId,
814
- });
815
-
816
- try {
817
- const response = await fetch(url.toString(), {
818
- method: 'POST',
819
- body: formData,
820
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
821
- }).then((data) => ResponseHandler<any>(data));
822
- return response.data;
823
- } catch (error) {
824
- console.error(error);
825
- return null;
826
- }
827
- };
828
-
829
- public saveAppMedia = async (
830
- bundleAppId: number,
831
- payload: {
832
- media: UploadFileObj[];
833
- },
834
- ): Promise<MarketplaceAppBundle | null> => {
835
- const url = new URL(
836
- `${this.config.baseUrl}/bundle_apps/${bundleAppId}/save_media/`,
837
- );
838
-
839
- IntegryAPI.addUrlSearchParams(url, {
840
- app_key: this.config.appKey,
841
- hash: this.config.hash,
842
- user_id: this.config.userId,
843
- });
844
-
845
- try {
846
- const response = await fetch(url.toString(), {
847
- method: 'POST',
848
- body: JSON.stringify(payload.media),
849
- headers: {
850
- 'Content-Type': 'application/json',
851
- },
852
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
853
- }).then((data) => ResponseHandler<MarketplaceAppBundle>(data));
854
- return response.data;
855
- } catch (error) {
856
- console.error(error);
857
- return null;
858
- }
859
- };
860
-
861
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
862
- public getAppInfo = async (
863
- appId: number | string,
864
- ): Promise<BrandingApp | null> => {
865
- const url = new URL(`${this.config.baseUrl}/api/v1/sdk/apps/${appId}/`);
866
-
867
- IntegryAPI.addUrlSearchParams(url, {
868
- app_key: this.config.appKey,
869
- hash: this.config.hash,
870
- user_id: this.config.userId,
871
- });
872
-
873
- try {
874
- const response = await fetch(url.toString(), {
875
- method: 'GET',
876
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
877
- }).then((data) => ResponseHandler<BrandingApp>(data));
878
- return response.data;
879
- } catch (error) {
880
- console.error(error);
881
- return null;
882
- }
883
- };
884
-
885
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
886
- public getAppFlows = async (
887
- appId: number | string,
888
- tags?: string[],
889
- authId?: any,
890
- ): Promise<AppFlowsResponse | null> => {
891
- const url = new URL(
892
- `${this.config.baseUrl}/api/v1/sdk/apps/${appId}/flows/`,
893
- );
894
- if (authId) {
895
- IntegryAPI.addUrlSearchParams(url, {
896
- app_key: this.config.appKey,
897
- hash: this.config.hash,
898
- user_id: this.config.userId,
899
- tags: (tags || []).join(','),
900
- show_draft: true,
901
- authorization_id: authId,
902
- page_size: 9999,
903
- });
904
- } else {
905
- IntegryAPI.addUrlSearchParams(url, {
906
- app_key: this.config.appKey,
907
- hash: this.config.hash,
908
- user_id: this.config.userId,
909
- tags: (tags || []).join(','),
910
- show_draft: true,
911
- page_size: 9999,
912
- });
913
- }
914
-
915
- try {
916
- const response = await fetch(url.toString(), {
917
- method: 'GET',
918
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
919
- }).then((data) => ResponseHandler<AppFlowsResponse>(data));
920
- return response.data;
921
- } catch (error) {
922
- console.error(error);
923
- return null;
924
- }
925
- };
926
-
927
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
928
- public getAdminAppFlows = async ({
929
- appId,
930
- bundleId,
931
- }: {
932
- appId: number | string;
933
- bundleId: number;
934
- }): Promise<AppFlowsResponse | null> => {
935
- const url = new URL(
936
- `${this.config.baseUrl}/api/v1/sdk/bundle/${bundleId}/apps/${appId}/templates/`,
937
- );
938
-
939
- IntegryAPI.addUrlSearchParams(url, {
940
- app_key: this.config.appKey,
941
- hash: this.config.hash,
942
- user_id: this.config.userId,
943
- });
944
-
945
- try {
946
- const response = await fetch(url.toString(), {
947
- method: 'GET',
948
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
949
- }).then((data) => ResponseHandler<AppFlowsResponse>(data));
950
- return response.data;
951
- } catch (error) {
952
- console.error(error);
953
- return null;
954
- }
955
- };
956
-
957
- public executeFlow = async (
958
- triggerPath: string,
959
- body: IncomingWebhookPayload,
960
- ): Promise<ExecuteFlowResponse | null> => {
961
- const url = new URL(triggerPath);
962
- IntegryAPI.addUrlSearchParams(url, {
963
- app_key: this.config.appKey,
964
- hash: this.config.hash,
965
- user_id: this.config.userId,
966
- });
967
- try {
968
- const response = await fetch(url.toString(), {
969
- method: 'POST',
970
- body: JSON.stringify(body),
971
- headers: {
972
- 'Content-Type': 'application/json',
973
- },
974
- }).then((data) => ResponseHandler<ExecuteFlowResponse>(data));
975
- return response.data;
976
- } catch (error) {
977
- console.error(error);
978
- return null;
979
- }
980
- };
981
-
982
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
983
- public getApps = async ({
984
- tags = <string[] | []>[],
985
- nextURL = <string | null>null,
986
- }): Promise<any | null> => {
987
- // const url = (tags || []).length > 0 ? new URL(`${this.config.baseUrl}/api/v1/sdk/flow-apps/?tags=${tags.join(',')}`) : new URL(`${this.config.baseUrl}/api/v1/sdk/flow-apps/`);
988
- const url = new URL(`${this.config.baseUrl}/api/v1/sdk/flow-apps/`);
989
-
990
- if ((tags || []).length > 0) {
991
- IntegryAPI.addUrlSearchParams(url, {
992
- app_key: this.config.appKey,
993
- hash: this.config.hash,
994
- user_id: this.config.userId,
995
- tags: tags.join(','),
996
- show_draft: true,
997
- });
998
- } else {
999
- IntegryAPI.addUrlSearchParams(url, {
1000
- app_key: this.config.appKey,
1001
- hash: this.config.hash,
1002
- user_id: this.config.userId,
1003
- tags: tags.join(','),
1004
- show_draft: true,
1005
- });
1006
- }
1007
-
1008
- if (nextURL === null) {
1009
- IntegryAPI.addUrlSearchParams(url, {
1010
- page_size: 100,
1011
- });
1012
- }
1013
-
1014
- try {
1015
- const response = await fetch(nextURL || url.toString(), {
1016
- method: 'GET',
1017
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1018
- }).then((data) => ResponseHandler<BrandingApp>(data));
1019
- return response.data;
1020
- } catch (error) {
1021
- console.error(error);
1022
- return null;
1023
- }
1024
- };
1025
-
1026
- public getMarketplaceAppsV2 = async ({
1027
- cursor = <string | null>null,
1028
- search = '',
1029
- fetchAll = false,
1030
- }): Promise<any | null> => {
1031
- const url = new URL(`${this.config.baseAPIUrl}/apps/list/`);
1032
-
1033
- IntegryAPI.addUrlSearchParams(url, {
1034
- app_key: this.config.appKey,
1035
- hash: this.config.hash,
1036
- user_id: this.config.userId,
1037
- page_size: fetchAll ? 9999 : 30,
1038
- });
1039
-
1040
- if (search !== '' && search !== null) {
1041
- IntegryAPI.addUrlSearchParams(url, {
1042
- search,
1043
- });
1044
- }
1045
-
1046
- const body: Record<string, string> = {};
1047
- if (cursor !== null) {
1048
- body._cursor = cursor;
1049
- }
1050
-
1051
- try {
1052
- const response = await fetch(url.toString(), {
1053
- method: 'POST',
1054
- body: JSON.stringify(body),
1055
- headers: {
1056
- 'Content-Type': 'application/json',
1057
- },
1058
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1059
- }).then((data) => ResponseHandler<MarketplaceApp>(data));
1060
- return response.data;
1061
- } catch (error) {
1062
- console.error(error);
1063
- return null;
1064
- }
1065
- };
1066
-
1067
- public getAdminApps = async ({
1068
- nextURL = <string | null>null,
1069
- bundleId = <string | number | null>0,
1070
- }): Promise<any | null> => {
1071
- const url = new URL(
1072
- `${this.config.baseUrl}/api/v1/sdk/bundle/${bundleId}/apps/`,
1073
- );
1074
-
1075
- IntegryAPI.addUrlSearchParams(url, {
1076
- app_key: this.config.appKey,
1077
- hash: this.config.hash,
1078
- user_id: this.config.userId,
1079
- });
1080
-
1081
- try {
1082
- const response = await fetch(nextURL || url.toString(), {
1083
- method: 'GET',
1084
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1085
- }).then((data) => ResponseHandler<BrandingApp>(data));
1086
- return response.data;
1087
- } catch (error) {
1088
- console.error(error);
1089
- return null;
1090
- }
1091
- };
1092
-
1093
- public callDynamicDataEndpointWithTags = async <T>(
1094
- url: URL,
1095
- endpointData: Record<string, string> = {},
1096
- body: string | number | NestedObject,
1097
- ): Promise<T | null> => {
1098
- IntegryAPI.addUrlSearchParams(url, {
1099
- app_key: this.config.appKey,
1100
- hash: this.config.hash,
1101
- user_id: this.config.userId,
1102
- ...endpointData,
1103
- });
1104
-
1105
- let mergedBody = { query_string_data: body };
1106
- if (typeof body === 'object') {
1107
- mergedBody = { ...body, query_string_data: body };
1108
- }
1109
-
1110
- try {
1111
- const response = await fetch(url.toString(), {
1112
- method: 'POST',
1113
- body: JSON.stringify(mergedBody),
1114
- headers: {
1115
- 'Content-Type': 'application/json',
1116
- },
1117
- }).then((data) => ResponseHandler<T>(data));
1118
- return response.data;
1119
- } catch (error) {
1120
- console.error(error);
1121
- return null;
1122
- }
1123
- };
1124
-
1125
- public callSourceFlowIntegrationInvocationUrl = async <T>(
1126
- url: URL,
1127
- endpointData: Record<string, string> = {},
1128
- body: string | number | NestedObject = {},
1129
- ): Promise<T | null> => {
1130
- IntegryAPI.addUrlSearchParams(url, {
1131
- app_key: this.config.appKey,
1132
- hash: this.config.hash,
1133
- user_id: this.config.userId,
1134
- ...endpointData,
1135
- });
1136
-
1137
- try {
1138
- const response = await fetch(url.toString(), {
1139
- method: 'POST',
1140
- body: JSON.stringify(body),
1141
- headers: {
1142
- 'Content-Type': 'application/json',
1143
- },
1144
- }).then((data) => ResponseHandler<T>(data));
1145
- return response.data;
1146
- } catch (error) {
1147
- console.error(error);
1148
- return null;
1149
- }
1150
- };
1151
-
1152
- public getUserVariables = async (): Promise<any | null> => {
1153
- const url = new URL(`${this.config.baseUrl}/api/v1/app-user-variables/`);
1154
-
1155
- IntegryAPI.addUrlSearchParams(url, {
1156
- app_key: this.config.appKey,
1157
- hash: this.config.hash,
1158
- user_id: this.config.userId,
1159
- });
1160
-
1161
- try {
1162
- const response = await fetch(url.toString(), { method: 'GET' }).then(
1163
- ResponseHandler,
1164
- );
1165
- return response.data;
1166
- } catch (error) {
1167
- console.error(error);
1168
- return null;
1169
- }
1170
- };
1171
-
1172
- public getFunctionDetails = async (
1173
- functionName: string,
1174
- variables: Record<string, unknown> = {},
1175
- version: string | null = null,
1176
- allowWorkspaceConnectedAccounts = false,
1177
- ): Promise<any | null> => {
1178
- const url = new URL(
1179
- `${this.config.baseAPIUrl}/functions/${functionName}/get/`,
1180
- );
1181
-
1182
- IntegryAPI.addUrlSearchParams(url, {
1183
- app_key: this.config.appKey,
1184
- hash: this.config.hash,
1185
- user_id: this.config.userId,
1186
- include: 'meta',
1187
- ...(allowWorkspaceConnectedAccounts && {
1188
- allow_workspace_connected_accounts: true,
1189
- }),
1190
- });
1191
-
1192
- try {
1193
- const headers: Record<string, string> = {
1194
- 'Content-Type': 'application/json',
1195
- };
1196
- if (version) {
1197
- headers.Version = version;
1198
- }
1199
- const response = await fetch(url.toString(), {
1200
- method: 'POST',
1201
- body: JSON.stringify({
1202
- _variables: variables,
1203
- }),
1204
- headers,
1205
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1206
- }).then((data) => ResponseHandler<BrandingApp>(data));
1207
- return response.data;
1208
- } catch (error) {
1209
- console.error(error);
1210
- return null;
1211
- }
1212
- };
1213
-
1214
- public getFunctionSignature = async (
1215
- functionName: string,
1216
- ): Promise<any | null> => {
1217
- const url = new URL(
1218
- `${this.config.baseAPIUrl}/functions/${functionName}/get/`,
1219
- );
1220
-
1221
- IntegryAPI.addUrlSearchParams(url, {
1222
- app_key: this.config.appKey,
1223
- hash: this.config.hash,
1224
- user_id: this.config.userId,
1225
- });
1226
-
1227
- try {
1228
- const response = await fetch(url.toString(), {
1229
- method: 'GET',
1230
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1231
- }).then((data) => ResponseHandler<BrandingApp>(data));
1232
- return response.data;
1233
- } catch (error) {
1234
- console.error(error);
1235
- return null;
1236
- }
1237
- };
1238
-
1239
- public getConnectedAccounts = async (appName: string): Promise<any> => {
1240
- const url = new URL(`${this.config.baseUrl}/apps/${appName}/get/`);
1241
-
1242
- IntegryAPI.addUrlSearchParams(url, {
1243
- app_key: this.config.appKey,
1244
- hash: this.config.hash,
1245
- user_id: this.config.userId,
1246
- });
1247
-
1248
- try {
1249
- const response = await fetch(url.toString(), {
1250
- method: 'POST',
1251
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1252
- }).then((data) => ResponseHandler<string[]>(data));
1253
- return response.data;
1254
- } catch (error) {
1255
- console.error(error);
1256
- return null;
1257
- }
1258
- };
1259
-
1260
- public getApp = async (appName: string): Promise<any> => {
1261
- const url = new URL(`${this.config.baseUrl}/apps/${appName}/get/`);
1262
-
1263
- IntegryAPI.addUrlSearchParams(url, {
1264
- app_key: this.config.appKey,
1265
- hash: this.config.hash,
1266
- user_id: this.config.userId,
1267
- });
1268
-
1269
- try {
1270
- const response = await fetch(url.toString(), {
1271
- method: 'POST',
1272
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1273
- }).then((data) => ResponseHandler<string[]>(data));
1274
- return response.data;
1275
- } catch (error) {
1276
- console.error(error);
1277
- return null;
1278
- }
1279
- };
1280
-
1281
- public invokeFunction = async (
1282
- functionDetails: any,
1283
- connectedAccountId: string,
1284
- ): Promise<any | null> => {
1285
- const url = new URL(functionDetails.url);
1286
- IntegryAPI.addUrlSearchParams(url, {
1287
- app_key: this.config.appKey,
1288
- hash: this.config.hash,
1289
- user_id: this.config.userId,
1290
- });
1291
-
1292
- if (connectedAccountId) {
1293
- IntegryAPI.addUrlSearchParams(url, {
1294
- connected_account_id: connectedAccountId,
1295
- });
1296
- }
1297
-
1298
- try {
1299
- const response = await fetch(url.toString(), {
1300
- method: functionDetails.method,
1301
- headers: functionDetails.headers,
1302
- body: JSON.stringify({
1303
- ...functionDetails.args,
1304
- ...(functionDetails.vars && { _variables: functionDetails.vars }),
1305
- }),
1306
- });
1307
-
1308
- // Now directly await the response.json() to parse the JSON
1309
- const results = await response.json(); // This will return the parsed JSON
1310
- return results; // Return the results to the caller
1311
- } catch (error) {
1312
- return new Error('Error while invoking function');
1313
- }
1314
- };
1315
-
1316
- public getAuthConfig = (): string | null => {
1317
- let authConfig = '';
1318
- authConfig = `app_key=${this.config.appKey}&hash=${
1319
- this.config.hash
1320
- }&user_id=${encodeURIComponent(this.config.userId)}`;
1321
- return authConfig;
1322
- };
1323
- }
1324
-
1325
- export { IntegryAPI };