@wbsuite/react-hooks 1.0.208 → 1.0.209

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 (298) hide show
  1. package/README.md +66 -0
  2. package/docs/USAGE.md +107 -0
  3. package/eslint.config.js +12 -0
  4. package/package.json +1 -1
  5. package/src/hooks/useAgents/index.ts +10 -0
  6. package/src/hooks/useArticles/index.ts +18 -0
  7. package/src/hooks/useAttributes/index.ts +18 -0
  8. package/src/hooks/useAttributesGroups/index.ts +17 -0
  9. package/src/hooks/useAutomations/index.ts +10 -0
  10. package/src/hooks/useBackend/get.ts +6 -0
  11. package/src/hooks/useBackend/index.ts +40 -0
  12. package/src/hooks/useBackend/list.ts +6 -0
  13. package/src/hooks/useBackend/post.ts +6 -0
  14. package/src/hooks/useBackend/put.ts +6 -0
  15. package/src/hooks/useCampaigns/index.ts +11 -0
  16. package/src/hooks/useCategories/index.ts +7 -0
  17. package/src/hooks/useChats/index.ts +13 -0
  18. package/src/hooks/useContactGroups/index.ts +28 -0
  19. package/src/hooks/useContacts/index.ts +21 -0
  20. package/src/hooks/useCurrencies/index.ts +14 -0
  21. package/src/hooks/useCustomers/index.ts +21 -0
  22. package/src/hooks/useDocuments/index.ts +86 -0
  23. package/src/hooks/useDomains/index.ts +10 -0
  24. package/src/hooks/useEmailTemplates/index.ts +13 -0
  25. package/src/hooks/useEntityStatuses/index.ts +13 -0
  26. package/src/hooks/useForms/index.ts +16 -0
  27. package/src/hooks/useIntegrations/index.ts +15 -0
  28. package/src/hooks/useInvites/index.ts +19 -0
  29. package/src/hooks/useLabels/index.ts +13 -0
  30. package/src/hooks/useLanguages/index.ts +16 -0
  31. package/src/hooks/useLeads/index.ts +149 -0
  32. package/src/hooks/useMedia/index.ts +13 -0
  33. package/src/hooks/useOrders/index.ts +74 -0
  34. package/src/hooks/usePaths/index.ts +16 -0
  35. package/src/hooks/usePermissions/index.ts +16 -0
  36. package/src/hooks/useProducts/index.ts +18 -0
  37. package/src/hooks/useProfile/index.ts +20 -0
  38. package/src/hooks/useRenting/index.ts +57 -0
  39. package/src/hooks/useRoles/index.ts +10 -0
  40. package/src/hooks/useRoom/index.ts +20 -0
  41. package/src/hooks/useRotations/index.ts +13 -0
  42. package/src/hooks/useSiteConfig/index.ts +13 -0
  43. package/src/hooks/useStatuses/index.ts +10 -0
  44. package/src/hooks/useStock/index.ts +48 -0
  45. package/src/hooks/useStores/index.ts +23 -0
  46. package/src/hooks/useSubscriptions/index.ts +17 -0
  47. package/src/hooks/useTable/index.ts +15 -0
  48. package/src/hooks/useTeams/index.ts +29 -0
  49. package/src/hooks/useTickets/index.ts +17 -0
  50. package/src/hooks/useTransactions/index.ts +43 -0
  51. package/src/hooks/useTranslations/index.ts +20 -0
  52. package/src/hooks/useUserConnections/index.ts +18 -0
  53. package/src/hooks/useUserSubscriptions/index.ts +28 -0
  54. package/src/hooks/useUsers/index.ts +57 -0
  55. package/src/hooks/useWBSuite/index.ts +29 -0
  56. package/src/hooks/useWebsites/index.ts +34 -0
  57. package/{cjs/index.d.ts → src/index.ts} +1 -1
  58. package/src/models/Requestor.ts +67 -0
  59. package/{cjs/next/utils/index.d.ts → src/next/utils/index.ts} +1 -1
  60. package/src/next/utils/wrapAsync.ts +2 -0
  61. package/src/utils/authWithApiKey.ts +3 -0
  62. package/src/utils/authWithToken.ts +3 -0
  63. package/src/utils/index.ts +7 -0
  64. package/tsconfig.json +20 -0
  65. package/cjs/hooks/useAgents/index.d.ts +0 -2
  66. package/cjs/hooks/useAgents/index.js +0 -32
  67. package/cjs/hooks/useArticles/index.d.ts +0 -5
  68. package/cjs/hooks/useArticles/index.js +0 -45
  69. package/cjs/hooks/useAttributes/index.d.ts +0 -2
  70. package/cjs/hooks/useAttributes/index.js +0 -52
  71. package/cjs/hooks/useAttributesGroups/index.d.ts +0 -3
  72. package/cjs/hooks/useAttributesGroups/index.js +0 -47
  73. package/cjs/hooks/useAutomations/index.d.ts +0 -2
  74. package/cjs/hooks/useAutomations/index.js +0 -32
  75. package/cjs/hooks/useBackend/get.d.ts +0 -2
  76. package/cjs/hooks/useBackend/get.js +0 -52
  77. package/cjs/hooks/useBackend/index.d.ts +0 -17
  78. package/cjs/hooks/useBackend/index.js +0 -22
  79. package/cjs/hooks/useBackend/list.d.ts +0 -2
  80. package/cjs/hooks/useBackend/list.js +0 -55
  81. package/cjs/hooks/useBackend/post.d.ts +0 -2
  82. package/cjs/hooks/useBackend/post.js +0 -52
  83. package/cjs/hooks/useBackend/put.d.ts +0 -2
  84. package/cjs/hooks/useBackend/put.js +0 -52
  85. package/cjs/hooks/useCampaigns/index.d.ts +0 -2
  86. package/cjs/hooks/useCampaigns/index.js +0 -35
  87. package/cjs/hooks/useCategories/index.d.ts +0 -3
  88. package/cjs/hooks/useCategories/index.js +0 -9
  89. package/cjs/hooks/useChats/index.d.ts +0 -3
  90. package/cjs/hooks/useChats/index.js +0 -37
  91. package/cjs/hooks/useContactGroups/index.d.ts +0 -3
  92. package/cjs/hooks/useContactGroups/index.js +0 -57
  93. package/cjs/hooks/useContacts/index.d.ts +0 -3
  94. package/cjs/hooks/useContacts/index.js +0 -52
  95. package/cjs/hooks/useCurrencies/index.d.ts +0 -3
  96. package/cjs/hooks/useCurrencies/index.js +0 -37
  97. package/cjs/hooks/useCustomers/index.d.ts +0 -3
  98. package/cjs/hooks/useCustomers/index.js +0 -52
  99. package/cjs/hooks/useDocuments/index.d.ts +0 -10
  100. package/cjs/hooks/useDocuments/index.js +0 -145
  101. package/cjs/hooks/useDomains/index.d.ts +0 -2
  102. package/cjs/hooks/useDomains/index.js +0 -32
  103. package/cjs/hooks/useEmailTemplates/index.d.ts +0 -2
  104. package/cjs/hooks/useEmailTemplates/index.js +0 -37
  105. package/cjs/hooks/useEntityStatuses/index.d.ts +0 -2
  106. package/cjs/hooks/useEntityStatuses/index.js +0 -34
  107. package/cjs/hooks/useForms/index.d.ts +0 -2
  108. package/cjs/hooks/useForms/index.js +0 -37
  109. package/cjs/hooks/useIntegrations/index.d.ts +0 -2
  110. package/cjs/hooks/useIntegrations/index.js +0 -39
  111. package/cjs/hooks/useInvites/index.d.ts +0 -2
  112. package/cjs/hooks/useInvites/index.js +0 -47
  113. package/cjs/hooks/useLabels/index.d.ts +0 -3
  114. package/cjs/hooks/useLabels/index.js +0 -32
  115. package/cjs/hooks/useLanguages/index.d.ts +0 -5
  116. package/cjs/hooks/useLanguages/index.js +0 -39
  117. package/cjs/hooks/useLeads/index.d.ts +0 -30
  118. package/cjs/hooks/useLeads/index.js +0 -113
  119. package/cjs/hooks/useMedia/index.d.ts +0 -2
  120. package/cjs/hooks/useMedia/index.js +0 -34
  121. package/cjs/hooks/useOrders/index.d.ts +0 -2
  122. package/cjs/hooks/useOrders/index.js +0 -76
  123. package/cjs/hooks/usePaths/index.d.ts +0 -2
  124. package/cjs/hooks/usePaths/index.js +0 -37
  125. package/cjs/hooks/usePermissions/index.d.ts +0 -2
  126. package/cjs/hooks/usePermissions/index.js +0 -47
  127. package/cjs/hooks/useProducts/index.d.ts +0 -2
  128. package/cjs/hooks/useProducts/index.js +0 -47
  129. package/cjs/hooks/useProfile/index.d.ts +0 -3
  130. package/cjs/hooks/useProfile/index.js +0 -57
  131. package/cjs/hooks/useRenting/index.d.ts +0 -47
  132. package/cjs/hooks/useRenting/index.js +0 -52
  133. package/cjs/hooks/useRoles/index.d.ts +0 -2
  134. package/cjs/hooks/useRoles/index.js +0 -32
  135. package/cjs/hooks/useRoom/index.d.ts +0 -3
  136. package/cjs/hooks/useRoom/index.js +0 -55
  137. package/cjs/hooks/useRotations/index.d.ts +0 -2
  138. package/cjs/hooks/useRotations/index.js +0 -37
  139. package/cjs/hooks/useSiteConfig/index.d.ts +0 -5
  140. package/cjs/hooks/useSiteConfig/index.js +0 -33
  141. package/cjs/hooks/useStatuses/index.d.ts +0 -2
  142. package/cjs/hooks/useStatuses/index.js +0 -32
  143. package/cjs/hooks/useStock/index.d.ts +0 -20
  144. package/cjs/hooks/useStock/index.js +0 -51
  145. package/cjs/hooks/useStores/index.d.ts +0 -3
  146. package/cjs/hooks/useStores/index.js +0 -62
  147. package/cjs/hooks/useSubscriptions/index.d.ts +0 -2
  148. package/cjs/hooks/useSubscriptions/index.js +0 -37
  149. package/cjs/hooks/useTable/index.d.ts +0 -3
  150. package/cjs/hooks/useTable/index.js +0 -34
  151. package/cjs/hooks/useTeams/index.d.ts +0 -5
  152. package/cjs/hooks/useTeams/index.js +0 -52
  153. package/cjs/hooks/useTickets/index.d.ts +0 -3
  154. package/cjs/hooks/useTickets/index.js +0 -47
  155. package/cjs/hooks/useTransactions/index.d.ts +0 -8
  156. package/cjs/hooks/useTransactions/index.js +0 -61
  157. package/cjs/hooks/useTranslations/index.d.ts +0 -5
  158. package/cjs/hooks/useTranslations/index.js +0 -42
  159. package/cjs/hooks/useUserConnections/index.d.ts +0 -2
  160. package/cjs/hooks/useUserConnections/index.js +0 -53
  161. package/cjs/hooks/useUserSubscriptions/index.d.ts +0 -6
  162. package/cjs/hooks/useUserSubscriptions/index.js +0 -47
  163. package/cjs/hooks/useUsers/index.d.ts +0 -17
  164. package/cjs/hooks/useUsers/index.js +0 -141
  165. package/cjs/hooks/useWBSuite/index.d.ts +0 -2
  166. package/cjs/hooks/useWBSuite/index.js +0 -39
  167. package/cjs/hooks/useWebsites/index.d.ts +0 -2
  168. package/cjs/hooks/useWebsites/index.js +0 -72
  169. package/cjs/index.js +0 -115
  170. package/cjs/models/Requestor.d.ts +0 -24
  171. package/cjs/models/Requestor.js +0 -53
  172. package/cjs/next/utils/index.js +0 -6
  173. package/cjs/next/utils/wrapAsync.d.ts +0 -1
  174. package/cjs/next/utils/wrapAsync.js +0 -54
  175. package/cjs/utils/authWithApiKey.d.ts +0 -4
  176. package/cjs/utils/authWithApiKey.js +0 -8
  177. package/cjs/utils/authWithToken.d.ts +0 -4
  178. package/cjs/utils/authWithToken.js +0 -8
  179. package/cjs/utils/index.d.ts +0 -11
  180. package/cjs/utils/index.js +0 -19
  181. package/esm/hooks/useAgents/index.d.ts +0 -2
  182. package/esm/hooks/useAgents/index.js +0 -28
  183. package/esm/hooks/useArticles/index.d.ts +0 -5
  184. package/esm/hooks/useArticles/index.js +0 -40
  185. package/esm/hooks/useAttributes/index.d.ts +0 -2
  186. package/esm/hooks/useAttributes/index.js +0 -48
  187. package/esm/hooks/useAttributesGroups/index.d.ts +0 -3
  188. package/esm/hooks/useAttributesGroups/index.js +0 -43
  189. package/esm/hooks/useAutomations/index.d.ts +0 -2
  190. package/esm/hooks/useAutomations/index.js +0 -28
  191. package/esm/hooks/useBackend/get.d.ts +0 -2
  192. package/esm/hooks/useBackend/get.js +0 -48
  193. package/esm/hooks/useBackend/index.d.ts +0 -17
  194. package/esm/hooks/useBackend/index.js +0 -18
  195. package/esm/hooks/useBackend/list.d.ts +0 -2
  196. package/esm/hooks/useBackend/list.js +0 -51
  197. package/esm/hooks/useBackend/post.d.ts +0 -2
  198. package/esm/hooks/useBackend/post.js +0 -48
  199. package/esm/hooks/useBackend/put.d.ts +0 -2
  200. package/esm/hooks/useBackend/put.js +0 -48
  201. package/esm/hooks/useCampaigns/index.d.ts +0 -2
  202. package/esm/hooks/useCampaigns/index.js +0 -31
  203. package/esm/hooks/useCategories/index.d.ts +0 -3
  204. package/esm/hooks/useCategories/index.js +0 -5
  205. package/esm/hooks/useChats/index.d.ts +0 -3
  206. package/esm/hooks/useChats/index.js +0 -33
  207. package/esm/hooks/useContactGroups/index.d.ts +0 -3
  208. package/esm/hooks/useContactGroups/index.js +0 -53
  209. package/esm/hooks/useContacts/index.d.ts +0 -3
  210. package/esm/hooks/useContacts/index.js +0 -48
  211. package/esm/hooks/useCurrencies/index.d.ts +0 -3
  212. package/esm/hooks/useCurrencies/index.js +0 -33
  213. package/esm/hooks/useCustomers/index.d.ts +0 -3
  214. package/esm/hooks/useCustomers/index.js +0 -48
  215. package/esm/hooks/useDocuments/index.d.ts +0 -10
  216. package/esm/hooks/useDocuments/index.js +0 -141
  217. package/esm/hooks/useDomains/index.d.ts +0 -2
  218. package/esm/hooks/useDomains/index.js +0 -28
  219. package/esm/hooks/useEmailTemplates/index.d.ts +0 -2
  220. package/esm/hooks/useEmailTemplates/index.js +0 -33
  221. package/esm/hooks/useEntityStatuses/index.d.ts +0 -2
  222. package/esm/hooks/useEntityStatuses/index.js +0 -30
  223. package/esm/hooks/useForms/index.d.ts +0 -2
  224. package/esm/hooks/useForms/index.js +0 -33
  225. package/esm/hooks/useIntegrations/index.d.ts +0 -2
  226. package/esm/hooks/useIntegrations/index.js +0 -35
  227. package/esm/hooks/useInvites/index.d.ts +0 -2
  228. package/esm/hooks/useInvites/index.js +0 -43
  229. package/esm/hooks/useLabels/index.d.ts +0 -3
  230. package/esm/hooks/useLabels/index.js +0 -28
  231. package/esm/hooks/useLanguages/index.d.ts +0 -5
  232. package/esm/hooks/useLanguages/index.js +0 -35
  233. package/esm/hooks/useLeads/index.d.ts +0 -30
  234. package/esm/hooks/useLeads/index.js +0 -109
  235. package/esm/hooks/useMedia/index.d.ts +0 -2
  236. package/esm/hooks/useMedia/index.js +0 -30
  237. package/esm/hooks/useOrders/index.d.ts +0 -2
  238. package/esm/hooks/useOrders/index.js +0 -72
  239. package/esm/hooks/usePaths/index.d.ts +0 -2
  240. package/esm/hooks/usePaths/index.js +0 -33
  241. package/esm/hooks/usePermissions/index.d.ts +0 -2
  242. package/esm/hooks/usePermissions/index.js +0 -43
  243. package/esm/hooks/useProducts/index.d.ts +0 -2
  244. package/esm/hooks/useProducts/index.js +0 -43
  245. package/esm/hooks/useProfile/index.d.ts +0 -3
  246. package/esm/hooks/useProfile/index.js +0 -53
  247. package/esm/hooks/useRenting/index.d.ts +0 -47
  248. package/esm/hooks/useRenting/index.js +0 -48
  249. package/esm/hooks/useRoles/index.d.ts +0 -2
  250. package/esm/hooks/useRoles/index.js +0 -28
  251. package/esm/hooks/useRoom/index.d.ts +0 -3
  252. package/esm/hooks/useRoom/index.js +0 -51
  253. package/esm/hooks/useRotations/index.d.ts +0 -2
  254. package/esm/hooks/useRotations/index.js +0 -33
  255. package/esm/hooks/useSiteConfig/index.d.ts +0 -5
  256. package/esm/hooks/useSiteConfig/index.js +0 -29
  257. package/esm/hooks/useStatuses/index.d.ts +0 -2
  258. package/esm/hooks/useStatuses/index.js +0 -28
  259. package/esm/hooks/useStock/index.d.ts +0 -20
  260. package/esm/hooks/useStock/index.js +0 -47
  261. package/esm/hooks/useStores/index.d.ts +0 -3
  262. package/esm/hooks/useStores/index.js +0 -58
  263. package/esm/hooks/useSubscriptions/index.d.ts +0 -2
  264. package/esm/hooks/useSubscriptions/index.js +0 -33
  265. package/esm/hooks/useTable/index.d.ts +0 -3
  266. package/esm/hooks/useTable/index.js +0 -30
  267. package/esm/hooks/useTeams/index.d.ts +0 -5
  268. package/esm/hooks/useTeams/index.js +0 -48
  269. package/esm/hooks/useTickets/index.d.ts +0 -3
  270. package/esm/hooks/useTickets/index.js +0 -43
  271. package/esm/hooks/useTransactions/index.d.ts +0 -8
  272. package/esm/hooks/useTransactions/index.js +0 -57
  273. package/esm/hooks/useTranslations/index.d.ts +0 -5
  274. package/esm/hooks/useTranslations/index.js +0 -38
  275. package/esm/hooks/useUserConnections/index.d.ts +0 -2
  276. package/esm/hooks/useUserConnections/index.js +0 -49
  277. package/esm/hooks/useUserSubscriptions/index.d.ts +0 -6
  278. package/esm/hooks/useUserSubscriptions/index.js +0 -43
  279. package/esm/hooks/useUsers/index.d.ts +0 -17
  280. package/esm/hooks/useUsers/index.js +0 -137
  281. package/esm/hooks/useWBSuite/index.d.ts +0 -2
  282. package/esm/hooks/useWBSuite/index.js +0 -35
  283. package/esm/hooks/useWebsites/index.d.ts +0 -2
  284. package/esm/hooks/useWebsites/index.js +0 -68
  285. package/esm/index.d.ts +0 -49
  286. package/esm/index.js +0 -50
  287. package/esm/models/Requestor.d.ts +0 -24
  288. package/esm/models/Requestor.js +0 -47
  289. package/esm/next/utils/index.d.ts +0 -2
  290. package/esm/next/utils/index.js +0 -3
  291. package/esm/next/utils/wrapAsync.d.ts +0 -1
  292. package/esm/next/utils/wrapAsync.js +0 -50
  293. package/esm/utils/authWithApiKey.d.ts +0 -4
  294. package/esm/utils/authWithApiKey.js +0 -4
  295. package/esm/utils/authWithToken.d.ts +0 -4
  296. package/esm/utils/authWithToken.js +0 -4
  297. package/esm/utils/index.d.ts +0 -11
  298. package/esm/utils/index.js +0 -3
@@ -0,0 +1,43 @@
1
+ import { CustomResponse } from '@wb/types/custom-response/custom-response.model';
2
+ import { BackendHook, useBackend } from '../useBackend';
3
+ import { RequestorOptions } from 'models/Requestor';
4
+
5
+ type EntityTypes = 'renting' | 'order';
6
+
7
+ export const useTransactions: BackendHook<
8
+ Record<string, string>,
9
+ any,
10
+ {
11
+ listPaymentMethods: () => Promise<CustomResponse<Record<string, unknown>[]>>;
12
+ getPublicPayment: (
13
+ entity: EntityTypes,
14
+ entityId: string,
15
+ method: string
16
+ ) => Promise<CustomResponse<Record<string, unknown>[]>>;
17
+ }
18
+ > = (auth?: RequestorOptions['auth']) => {
19
+ const { requestor, ...rest } = useBackend('transactions', { auth });
20
+ return {
21
+ ...rest,
22
+ requestor,
23
+ listPaymentMethods: () => {
24
+ return requestor.makeRequest.get(`transactions/methods`).then(({ data }) => data);
25
+ },
26
+ getPayment: (entity: EntityTypes, entityId: string, method: string, amount?: number) => {
27
+ return requestor.makeRequest
28
+ .post(`transactions/${method}/${entity}/${entityId}`, { amount })
29
+ .then(({ data }) => data);
30
+ },
31
+ getPublicPayment: (entity: EntityTypes, entityId: string, method: string, amount?: number) => {
32
+ return requestor.makeRequest
33
+ .post(`transactions/public/${method}/${entity}/${entityId}`, { amount })
34
+ .then(({ data }) => data);
35
+ },
36
+ cancelPayment: (transactionId: string) => {
37
+ return requestor.makeRequest.post(`transactions/cancel/${transactionId}`).then(({ data }) => data);
38
+ },
39
+ completePayment: (transactionId: string) => {
40
+ return requestor.makeRequest.post(`transactions/complete/${transactionId}`).then(({ data }) => data);
41
+ },
42
+ };
43
+ };
@@ -0,0 +1,20 @@
1
+ import { RequestorOptions } from 'models/Requestor';
2
+ import { BackendHook, useBackend } from '../useBackend';
3
+
4
+ export const useTranslations: BackendHook<
5
+ Record<string, string>,
6
+ any,
7
+ { getJson: () => Promise<Record<string, unknown>>; getProductJson: () => Promise<Record<string, unknown>> }
8
+ > = (auth?: RequestorOptions['auth']) => {
9
+ const { requestor, ...rest } = useBackend('translations', { auth });
10
+ return {
11
+ ...rest,
12
+ requestor,
13
+ getJson: () => {
14
+ return requestor.makeRequest.get(`translations/getAll`).then(({ data }) => data);
15
+ },
16
+ getProductJson: () => {
17
+ return requestor.makeRequest.get(`translations/product/getAll`).then(({ data }) => data);
18
+ },
19
+ };
20
+ };
@@ -0,0 +1,18 @@
1
+ import { BackendHook, useBackend } from '../useBackend';
2
+ import { RequestorOptions } from 'models/Requestor';
3
+
4
+ export const useUserConnection: BackendHook = (auth?: RequestorOptions['auth']) => {
5
+ const { requestor, ...endpoints } = useBackend('user-connections', { auth });
6
+ return {
7
+ requestor,
8
+ ...endpoints,
9
+ create: (data) =>
10
+ requestor.makeRequest.post(`user-connections`, data).then(({ data }) => data),
11
+ update: (id: any, data: any) =>
12
+ requestor.makeRequest.put(`user-connections/${id}`, data).then(({ data }) => data),
13
+ delete: (id: string) =>
14
+ requestor.makeRequest.delete(`user-connections/${id}`).then(({ data }) => data),
15
+ searchContactExternalId: (searchValue: string, { userConnectionIds }: { userConnectionIds?: string[] }) =>
16
+ requestor.makeRequest.get(`user-connections/search/contact/${searchValue}`, { params: { userConnectionIds } }).then(({ data }) => data),
17
+ };
18
+ };
@@ -0,0 +1,28 @@
1
+
2
+ import { BackendHook, useBackend } from '../useBackend';
3
+ import { RequestorOptions } from 'models/Requestor';
4
+
5
+ export const useUserSubscriptions: BackendHook<
6
+ Record<string, string>,
7
+ any,
8
+ {
9
+ subscribe: (subscriptionId: string, subscriptionDetails: Record<string, unknown>) => Promise<void>;
10
+ requestPayment: (userSubscriptionId: string, data: Record<string, unknown>) => Promise<void>;
11
+ cancel: (userSubscriptionId: string) => Promise<void>;
12
+ }
13
+ > = (auth?: RequestorOptions['auth']) => {
14
+ const { requestor, ...rest } = useBackend('user-subscriptions', { auth });
15
+ return {
16
+ ...rest,
17
+ requestor,
18
+ subscribe: (subscriptionId: string, subscriptionDetails: Record<string, unknown>) => {
19
+ return requestor.makeRequest.post(`user-subscriptions/${subscriptionId}`, subscriptionDetails).then(({ data }) => data);
20
+ },
21
+ requestPayment: (userSubscriptionId: string, data: Record<string, unknown>) => {
22
+ return requestor.makeRequest.post(`user-subscriptions/payment/request/${userSubscriptionId}`, data).then(({ data }) => data);
23
+ },
24
+ cancel: (userSubscriptionId: string) => {
25
+ return requestor.makeRequest.post(`user-subscriptions/${userSubscriptionId}/cancel`).then(({ data }) => data);
26
+ }
27
+ };
28
+ };
@@ -0,0 +1,57 @@
1
+ import { BackendHook, useBackend } from '../useBackend';
2
+ import { CustomResponse } from '@wb/types/custom-response/custom-response.model';
3
+ import { RequestorOptions } from 'models/Requestor';
4
+
5
+ type LoginResponse = CustomResponse<{ user: unknown; token: { access_token: string; expires_in: number; token_type: string } }>;
6
+ type LoginFunction = (
7
+ username: string,
8
+ password: string
9
+ ) => Promise<LoginResponse>;
10
+
11
+ export const useUsers: BackendHook<
12
+ any,
13
+ any,
14
+ {
15
+ login: LoginFunction;
16
+ getSession: () => Promise<LoginResponse>
17
+ restartSession: (token: string) => Promise<LoginResponse> | Promise<CustomResponse>
18
+ }
19
+ > = (auth?: RequestorOptions['auth']) => {
20
+ const { requestor, ...endpoints } = useBackend('users', { auth });
21
+ return {
22
+ ...endpoints,
23
+ requestor,
24
+ login: async (username: string, password: string) => {
25
+ const { data: response } = await requestor.makeRequest.post<LoginResponse>('users/login', { username, password });
26
+ return response;
27
+ },
28
+ getSession: async () => {
29
+ const { data: response } = await requestor.makeRequest.get<LoginResponse>('users/login');
30
+ return response;
31
+ },
32
+ restartSession: async () => {
33
+ try {
34
+ const { data: response } = await requestor.makeRequest.get<LoginResponse>('users/login')
35
+ return response;
36
+ } catch(err) {
37
+ return { success: false, data: null };
38
+ }
39
+ },
40
+ getPermissions: async () => {
41
+ return requestor.makeRequest.get<LoginResponse>('users/permissions').then(({ data }) => data);
42
+ },
43
+ getUserSummary: async (userId: string) => {
44
+ const { data: response } = await requestor.makeRequest.get<LoginResponse>(`users/${userId}/profile`).then(({ data }) => data);
45
+ return response;
46
+ },
47
+ logout: async () => {
48
+ return requestor.makeRequest.post<LoginResponse>('users/logout').then(({ data }) => data);
49
+ },
50
+ updateStore: (userId: string, stores: string[]) => {
51
+ return requestor.makeRequest.put(`users/${userId}/stores`, { stores }).then(({ data }) => data);
52
+ },
53
+ updateRoles: (userId: string, roles: string[]) => {
54
+ return requestor.makeRequest.put(`users/${userId}/roles`, { roles }).then(({ data }) => data);
55
+ }
56
+ };
57
+ };
@@ -0,0 +1,29 @@
1
+ import { WBBackendConfig } from '@wb/types/backendConfig/backendConfig';
2
+
3
+ const process = globalThis.process || {};
4
+
5
+ const DEFAULTS = {
6
+ apiURL: process?.env?.WB_API_URL || 'https://api.wbsuite.app/api/v2',
7
+ publicURL: process?.env?.WB_PUBLIC_URL || 'https://api.wbsuite.app/public',
8
+ };
9
+
10
+ (globalThis as any).WBSUITE_CONFIG;
11
+ (globalThis as any).initialized = false;
12
+
13
+ export const useWBSuite = (wbsuiteConfiguration: Partial<WBBackendConfig> = {}) => {
14
+ if (!(globalThis as any).initialized) {
15
+ (globalThis as any).initialized = true;
16
+ (globalThis as any).WBSUITE_CONFIG = {
17
+ ...DEFAULTS,
18
+ ...Object.fromEntries(
19
+ Object.entries({
20
+ ...wbsuiteConfiguration,
21
+ }).filter(([, value]) => value !== undefined && value !== null)
22
+ ),
23
+ };
24
+ return true;
25
+ } else {
26
+ console.warn('Configuration skipped since it was already configured');
27
+ return false;
28
+ }
29
+ };
@@ -0,0 +1,34 @@
1
+ import { RequestorOptions } from 'models/Requestor';
2
+ import { BackendHook, useBackend } from '../useBackend';
3
+
4
+ export const useWebsites: BackendHook<Record<string, string>, any> = (auth?: RequestorOptions['auth']) => {
5
+ const { requestor, ...rest } = useBackend('websites', { auth });
6
+ return {
7
+ ...rest,
8
+ requestor,
9
+ getProductSiteById: (siteId: string) => {
10
+ return requestor.makeRequest.get(`websites/product/${siteId}`).then(({ data }) => data);
11
+ },
12
+ getPublicById: (siteId: string) => {
13
+ return requestor.makeRequest.get(`websites/${siteId}/public`).then(({ data }) => data);
14
+ },
15
+ resetApiKey: (siteId: string) => {
16
+ return requestor.makeRequest.put(`websites/${siteId}/apiKey`).then(({ data }) => data);
17
+ },
18
+ expireApiKey: (siteId: string) => {
19
+ return requestor.makeRequest.delete(`websites/${siteId}/apiKey`).then(({ data }) => data);
20
+ },
21
+ getIntegrationDetails: (siteId: string) => {
22
+ return requestor.makeRequest.get(`websites/${siteId}/integrate`).then(({ data }) => data);
23
+ },
24
+ addDomain: (siteId: string, origin: string) => {
25
+ return requestor.makeRequest.post(`websites/${siteId}/domain`, { origin }).then(({ data }) => data);
26
+ },
27
+ removeDomain: (siteId: string) => {
28
+ return requestor.makeRequest.delete(`websites/${siteId}/domain`).then(({ data }) => data);
29
+ },
30
+ duplicateSite: (siteId: string, overrides: { name?: string; description?: string }) => {
31
+ return requestor.makeRequest.post(`websites/${siteId}/duplicate`, overrides).then(({ data }) => data);
32
+ },
33
+ };
34
+ };
@@ -46,4 +46,4 @@ export { useContactGroups } from './hooks/useContactGroups';
46
46
  export { useLabels } from './hooks/useLabels';
47
47
  export { useAgents } from './hooks/useAgents';
48
48
  export { useAutomations } from './hooks/useAutomations';
49
- export { useTickets } from './hooks/useTickets';
49
+ export { useTickets } from './hooks/useTickets';
@@ -0,0 +1,67 @@
1
+ import { WBBackendConfig } from '@wb/types/backendConfig/backendConfig';
2
+ import axios, { AxiosInstance, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
3
+ import { useWBSuite } from '../hooks/useWBSuite';
4
+
5
+ type Validator = (isCreate: boolean, body: any) => boolean;
6
+
7
+ export type RequestorOptions = {
8
+ auth:
9
+ | { type: 'token' | 'apiKey' } & (
10
+ | { type: 'token'; token: string }
11
+ | { type: 'apiKey'; apiKey: string }
12
+ );
13
+ };
14
+
15
+ export class Requestor {
16
+ makeRequest: AxiosInstance;
17
+ validateWith?: Validator;
18
+
19
+ constructor(
20
+ config: Partial<WBBackendConfig>,
21
+ validator?: Validator,
22
+ opts: Partial<RequestorOptions> = {}
23
+ ) {
24
+ if (!config) {
25
+ useWBSuite();
26
+ }
27
+ this.makeRequest = axios.create({ baseURL: config?.apiURL ?? (globalThis as any).WBSUITE_CONFIG?.apiURL });
28
+ this.validateWith = validator;
29
+ this.makeRequest.interceptors.request.use((requestConfig: InternalAxiosRequestConfig) => {
30
+ if ((opts.auth?.type === 'apiKey' && opts.auth.apiKey) || config?.apiKey) {
31
+ requestConfig.headers['x-api-key'] = (opts.auth?.type === 'apiKey' && opts.auth.apiKey) || config?.apiKey;
32
+ }
33
+ if (opts.auth?.type === 'token' && opts.auth.token) {
34
+ delete requestConfig.headers['x-api-key'];
35
+ requestConfig.headers.Authorization = `Bearer ${opts.auth?.type === 'token' && opts.auth.token}`;
36
+ }
37
+ return requestConfig;
38
+ });
39
+ if (config?.environment === 'development') {
40
+ this.makeRequest.interceptors.response.use(
41
+ (response: AxiosResponse) => {
42
+ console.log(
43
+ `${new Date().toISOString()} [INFO] --- ${response.request.host} ${response.status} ${JSON.stringify(
44
+ response.data
45
+ )}`
46
+ );
47
+ return response;
48
+ },
49
+ (response: AxiosResponse) => {
50
+ console.error(
51
+ `${new Date().toISOString()} [ERROR] --- ${response.request.host} ${response.status} ${JSON.stringify(
52
+ response.data
53
+ )}`
54
+ );
55
+ return Promise.reject(response);
56
+ }
57
+ );
58
+ }
59
+ }
60
+
61
+ public get validate() {
62
+ return {
63
+ create: (body: any) => this.validateWith?.(true, body) ?? true,
64
+ edit: (body: any) => this.validateWith?.(false, body) ?? true,
65
+ };
66
+ }
67
+ }
@@ -1,2 +1,2 @@
1
1
  import { wrapAsync } from "./wrapAsync";
2
- export { wrapAsync };
2
+ export { wrapAsync };
@@ -0,0 +1,2 @@
1
+ // eslint-disable-next-line
2
+ export const wrapAsync = async (fn: Function, ...args: any[]) => { return await fn(...args) };
@@ -0,0 +1,3 @@
1
+ export const authWithApiKey = (apiKey: string) => {
2
+ return { type: 'apiKey', apiKey };
3
+ };
@@ -0,0 +1,3 @@
1
+ export const authWithToken = (token: string) => {
2
+ return { type: 'token', token };
3
+ };
@@ -0,0 +1,7 @@
1
+ export * from './authWithApiKey';
2
+ export * from './authWithToken';
3
+
4
+ export type WebSuiteAuth = | { type: 'token' | 'apiKey' | 'siteApiKey' } & (
5
+ | { type: 'token'; token: string }
6
+ | { type: 'apiKey'; apiKey: string }
7
+ )
package/tsconfig.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "esnext",
4
+ "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
5
+ "lib": ["es6", "dom", "es2016", "es2017", "es2020"],
6
+ "target": "es5",
7
+ "outDir": "./dist/react-hooks/esm" /* Redirect output structure to the directory. */,
8
+ "baseUrl": "./src" /* Base directory to resolve non-absolute module names. */,
9
+ "declaration": true /* Concatenate and emit output to single file. */,
10
+ "strict": true /* Enable all strict type-checking options. */,
11
+ "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
12
+ "inlineSourceMap": true /* Emit a single file with source maps instead of having a separate file. */,
13
+ "inlineSources": true /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */,
14
+ "skipLibCheck": true /* Skip type checking of declaration files. */,
15
+ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
16
+ "allowSyntheticDefaultImports": true
17
+ },
18
+ "include": ["src/**/*.ts", "eslint.config.js"],
19
+ "exclude": ["node_modules", "dist"]
20
+ }
@@ -1,2 +0,0 @@
1
- import { BackendHook } from '../useBackend';
2
- export declare const useAgents: BackendHook<any, undefined>;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __rest = (this && this.__rest) || function (s, e) {
14
- var t = {};
15
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
- t[p] = s[p];
17
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
- t[p[i]] = s[p[i]];
21
- }
22
- return t;
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.useAgents = void 0;
26
- var useBackend_1 = require("../useBackend");
27
- var useAgents = function (auth) {
28
- var _a = (0, useBackend_1.useBackend)('agents', { auth: auth }), requestor = _a.requestor, rest = __rest(_a, ["requestor"]);
29
- return __assign(__assign({}, rest), { requestor: requestor });
30
- };
31
- exports.useAgents = useAgents;
32
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvaG9va3MvdXNlQWdlbnRzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFDQSw0Q0FBd0Q7QUFFakQsSUFBTSxTQUFTLEdBQWdDLFVBQUMsSUFBK0I7SUFDcEYsSUFBTSxLQUF5QixJQUFBLHVCQUFVLEVBQUMsUUFBUSxFQUFFLEVBQUUsSUFBSSxNQUFBLEVBQUUsQ0FBQyxFQUFyRCxTQUFTLGVBQUEsRUFBSyxJQUFJLGNBQXBCLGFBQXNCLENBQWlDLENBQUM7SUFDOUQsNkJBQ0ssSUFBSSxLQUNQLFNBQVMsV0FBQSxJQUNUO0FBQ0osQ0FBQyxDQUFDO0FBTlcsUUFBQSxTQUFTLGFBTXBCIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgUmVxdWVzdG9yT3B0aW9ucyB9IGZyb20gJ21vZGVscy9SZXF1ZXN0b3InO1xuaW1wb3J0IHsgQmFja2VuZEhvb2ssIHVzZUJhY2tlbmQgfSBmcm9tICcuLi91c2VCYWNrZW5kJztcblxuZXhwb3J0IGNvbnN0IHVzZUFnZW50czogQmFja2VuZEhvb2s8YW55LCB1bmRlZmluZWQ+ID0gKGF1dGg/OiBSZXF1ZXN0b3JPcHRpb25zWydhdXRoJ10pID0+IHtcbiAgY29uc3QgeyByZXF1ZXN0b3IsIC4uLnJlc3QgfSA9IHVzZUJhY2tlbmQoJ2FnZW50cycsIHsgYXV0aCB9KTtcbiAgcmV0dXJuIHtcbiAgICAuLi5yZXN0LFxuICAgIHJlcXVlc3RvcixcbiAgfTtcbn07XG4iXX0=
@@ -1,5 +0,0 @@
1
- import { BackendHook } from '../useBackend';
2
- export declare const deserialize: (content: string) => any;
3
- export declare const useArticles: BackendHook<any, any, {
4
- deserialize: (content: string) => string;
5
- }>;
@@ -1,45 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __rest = (this && this.__rest) || function (s, e) {
14
- var t = {};
15
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
- t[p] = s[p];
17
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
- t[p[i]] = s[p[i]];
21
- }
22
- return t;
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.useArticles = exports.deserialize = void 0;
26
- var html_1 = require("@slate-serializers/html");
27
- var useBackend_1 = require("../useBackend");
28
- var deserialize = function (content) {
29
- try {
30
- var deserializedContent = JSON.parse(content);
31
- if (Array.isArray(deserializedContent))
32
- return (0, html_1.slateToHtml)(deserializedContent);
33
- return deserializedContent;
34
- }
35
- catch (e) {
36
- return content;
37
- }
38
- };
39
- exports.deserialize = deserialize;
40
- var useArticles = function (auth) {
41
- var endpoints = __rest((0, useBackend_1.useBackend)('articles', { auth: auth }), []);
42
- return __assign(__assign({}, endpoints), { deserialize: exports.deserialize });
43
- };
44
- exports.useArticles = useArticles;
45
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvaG9va3MvdXNlQXJ0aWNsZXMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLGdEQUFzRDtBQUN0RCw0Q0FBd0Q7QUFHakQsSUFBTSxXQUFXLEdBQUcsVUFBQyxPQUFlO0lBQ3pDLElBQUksQ0FBQztRQUNILElBQU0sbUJBQW1CLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FBQyxPQUFPLENBQUMsQ0FBQztRQUNoRCxJQUFHLEtBQUssQ0FBQyxPQUFPLENBQUMsbUJBQW1CLENBQUM7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fSBjYXRjaCAoZSkge1xuICAgIHJldHVybiBjb250ZW50O1xuICB9XG59XG5cbmV4cG9ydCBjb25zdCB1c2VBcnRpY2xlczogQmFja2VuZEhvb2s8YW55LCBhbnksIHsgZGVzZXJpYWxpemU6IChjb250ZW50OiBzdHJpbmcpID0+IHN0cmluZyB9PiAgPSAoYXV0aD86IFJlcXVlc3Rvck9wdGlvbnNbJ2F1dGgnXSkgPT4ge1xuICBjb25zdCB7IC4uLmVuZHBvaW50cyB9ID0gdXNlQmFja2VuZCgnYXJ0aWNsZXMnLCB7IGF1dGggfSk7XG4gIHJldHVybiB7IC4uLmVuZHBvaW50cywgZGVzZXJpYWxpemUgfTtcbn07XG4iXX0=
@@ -1,2 +0,0 @@
1
- import { BackendHook } from '../useBackend';
2
- export declare const useAttributes: BackendHook;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __rest = (this && this.__rest) || function (s, e) {
14
- var t = {};
15
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
- t[p] = s[p];
17
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
- t[p[i]] = s[p[i]];
21
- }
22
- return t;
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.useAttributes = void 0;
26
- var useBackend_1 = require("../useBackend");
27
- var useAttributes = function (auth) {
28
- var _a = (0, useBackend_1.useBackend)('attributes', { auth: auth }), requestor = _a.requestor, endpoints = __rest(_a, ["requestor"]);
29
- return __assign(__assign({ requestor: requestor }, endpoints), { create: function (data) {
30
- return requestor.makeRequest.post("attributes", data).then(function (_a) {
31
- var data = _a.data;
32
- return data;
33
- });
34
- }, update: function (id, data) {
35
- return requestor.makeRequest.put("attributes/".concat(id), data).then(function (_a) {
36
- var data = _a.data;
37
- return data;
38
- });
39
- }, delete: function (id) {
40
- return requestor.makeRequest.delete("attributes/".concat(id)).then(function (_a) {
41
- var data = _a.data;
42
- return data;
43
- });
44
- }, getGrouped: function () {
45
- return requestor.makeRequest.get("attributes/grouped").then(function (_a) {
46
- var data = _a.data;
47
- return data;
48
- });
49
- } });
50
- };
51
- exports.useAttributes = useAttributes;
52
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvaG9va3MvdXNlQXR0cmlidXRlcy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsNENBQXdEO0FBR2pELElBQU0sYUFBYSxHQUFnQixVQUFDLElBQStCO0lBQ3hFLElBQU0sS0FBOEIsSUFBQSx1QkFBVSxFQUFDLFlBQVksRUFBRSxFQUFFLElBQUksTUFBQSxFQUFFLENBQUMsRUFBOUQsU0FBUyxlQUFBLEVBQUssU0FBUyxjQUF6QixhQUEyQixDQUFxQyxDQUFDO0lBQ3ZFLDJCQUNFLFNBQVMsV0FBQSxJQUNOLFNBQVMsS0FDWixNQUFNLEVBQUUsVUFBQyxJQUFJO1lBQ1gsT0FBQSxTQUFTLENBQUMsV0FBVyxDQUFDLElBQUksQ0FBQyxZQUFZLEVBQUUsSUFBSSxDQUFDLENBQUMsSUFBSSxDQUFDLFVBQUMsRUFBUTtvQkFBTixJQUFJLFVBQUE7Z0JBQU8sT0FBQSxJQUFJO1lBQUosQ0FBSSxDQUFDO1FB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4gIGNvbnN0IHsgcmVxdWVzdG9yLCAuLi5lbmRwb2ludHMgfSA9IHVzZUJhY2tlbmQoJ2F0dHJpYnV0ZXMnLCB7IGF1dGggfSk7XG4gIHJldHVybiB7XG4gICAgcmVxdWVzdG9yLFxuICAgIC4uLmVuZHBvaW50cyxcbiAgICBjcmVhdGU6IChkYXRhKSA9PlxuICAgICAgcmVxdWVzdG9yLm1ha2VSZXF1ZXN0LnBvc3QoYGF0dHJpYnV0ZXNgLCBkYXRhKS50aGVuKCh7IGRhdGEgfSkgPT4gZGF0YSksXG4gICAgdXBkYXRlOiAoaWQ6IGFueSwgZGF0YTogYW55KSA9PlxuICAgICAgcmVxdWVzdG9yLm1ha2VSZXF1ZXN0LnB1dChgYXR0cmlidXRlcy8ke2lkfWAsIGRhdGEpLnRoZW4oKHsgZGF0YSB9KSA9PiBkYXRhKSxcbiAgICBkZWxldGU6IChpZDogc3RyaW5nKSA9PlxuICAgICAgcmVxdWVzdG9yLm1ha2VSZXF1ZXN0LmRlbGV0ZShgYXR0cmlidXRlcy8ke2lkfWApLnRoZW4oKHsgZGF0YSB9KSA9PiBkYXRhKSxcbiAgICBnZXRHcm91cGVkOiAoKSA9PlxuICAgICAgcmVxdWVzdG9yLm1ha2VSZXF1ZXN0LmdldChgYXR0cmlidXRlcy9ncm91cGVkYCkudGhlbigoeyBkYXRhIH0pID0+IGRhdGEpLFxuICB9O1xufTtcbiJdfQ==
@@ -1,3 +0,0 @@
1
- import { BackendHook } from '../useBackend';
2
- import { IAttributeGroup } from '@wb/types/products/attributeGroup.model';
3
- export declare const useAttributesGroups: BackendHook<IAttributeGroup>;
@@ -1,47 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __rest = (this && this.__rest) || function (s, e) {
14
- var t = {};
15
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
- t[p] = s[p];
17
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
- t[p[i]] = s[p[i]];
21
- }
22
- return t;
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.useAttributesGroups = void 0;
26
- var useBackend_1 = require("../useBackend");
27
- var useAttributesGroups = function (auth) {
28
- var _a = (0, useBackend_1.useBackend)('attribute/groups', { auth: auth }), requestor = _a.requestor, endpoints = __rest(_a, ["requestor"]);
29
- return __assign(__assign({ requestor: requestor }, endpoints), { create: function (data) {
30
- return requestor.makeRequest.post("attribute/groups", data).then(function (_a) {
31
- var data = _a.data;
32
- return data;
33
- });
34
- }, update: function (id, data) {
35
- return requestor.makeRequest.put("attribute/groups/".concat(id), data).then(function (_a) {
36
- var data = _a.data;
37
- return data;
38
- });
39
- }, delete: function (id) {
40
- return requestor.makeRequest.delete("attribute/groups/".concat(id)).then(function (_a) {
41
- var data = _a.data;
42
- return data;
43
- });
44
- } });
45
- };
46
- exports.useAttributesGroups = useAttributesGroups;
47
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvaG9va3MvdXNlQXR0cmlidXRlc0dyb3Vwcy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsNENBQXdEO0FBSWpELElBQU0sbUJBQW1CLEdBQWlDLFVBQUMsSUFBK0I7SUFDL0YsSUFBTSx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@ -1,32 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __rest = (this && this.__rest) || function (s, e) {
14
- var t = {};
15
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
- t[p] = s[p];
17
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
- t[p[i]] = s[p[i]];
21
- }
22
- return t;
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.useAutomations = void 0;
26
- var useBackend_1 = require("../useBackend");
27
- var useAutomations = function (auth) {
28
- var _a = (0, useBackend_1.useBackend)('automations', { auth: auth }), requestor = _a.requestor, rest = __rest(_a, ["requestor"]);
29
- return __assign(__assign({}, rest), { requestor: requestor });
30
- };
31
- exports.useAutomations = useAutomations;
32
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvaG9va3MvdXNlQXV0b21hdGlvbnMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUNBLDRDQUF3RDtBQUVqRCxJQUFNLGNBQWMsR0FBZ0MsVUFBQyxJQUErQjtJQUN6RixJQUFNLEtBQXlCLElBQUEsdUJBQVUsRUFBQyxhQUFhLEVBQUUsRUFBRSxJQUFJLE1BQUEsRUFBRSxDQUFDLEVBQTFELFNBQVMsZUFBQSxFQUFLLElBQUksY0FBcEIsYUFBc0IsQ0FBc0MsQ0FBQztJQUNuRSw2QkFDSyxJQUFJLEtBQ1AsU0FBUyxXQUFBLElBQ1Q7QUFDSixDQUFDLENBQUM7QUFOVyxRQUFBLGNBQWMsa0JBTXpCIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgUmVxdWVzdG9yT3B0aW9ucyB9IGZyb20gJ21vZGVscy9SZXF1ZXN0b3InO1xuaW1wb3J0IHsgQmFja2VuZEhvb2ssIHVzZUJhY2tlbmQgfSBmcm9tICcuLi91c2VCYWNrZW5kJztcblxuZXhwb3J0IGNvbnN0IHVzZUF1dG9tYXRpb25zOiBCYWNrZW5kSG9vazxhbnksIHVuZGVmaW5lZD4gPSAoYXV0aD86IFJlcXVlc3Rvck9wdGlvbnNbJ2F1dGgnXSkgPT4ge1xuICBjb25zdCB7IHJlcXVlc3RvciwgLi4ucmVzdCB9ID0gdXNlQmFja2VuZCgnYXV0b21hdGlvbnMnLCB7IGF1dGggfSk7XG4gIHJldHVybiB7XG4gICAgLi4ucmVzdCxcbiAgICByZXF1ZXN0b3IsXG4gIH07XG59O1xuIl19
@@ -1,2 +0,0 @@
1
- import { Requestor } from '../../models/Requestor';
2
- export declare const get: (requestor: Requestor, path: string, id: string) => Promise<any>;