@wbsuite/react-hooks 1.0.214 → 1.0.216
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/hooks/useAgents/index.d.ts +2 -0
- package/cjs/hooks/useAgents/index.js +32 -0
- package/cjs/hooks/useApps/index.d.ts +2 -0
- package/cjs/hooks/useApps/index.js +32 -0
- package/cjs/hooks/useArticles/index.d.ts +5 -0
- package/cjs/hooks/useArticles/index.js +45 -0
- package/cjs/hooks/useAttributes/index.d.ts +2 -0
- package/cjs/hooks/useAttributes/index.js +52 -0
- package/cjs/hooks/useAttributesGroups/index.d.ts +3 -0
- package/cjs/hooks/useAttributesGroups/index.js +47 -0
- package/cjs/hooks/useAutomations/index.d.ts +2 -0
- package/cjs/hooks/useAutomations/index.js +32 -0
- package/cjs/hooks/useBackend/get.d.ts +2 -0
- package/cjs/hooks/useBackend/get.js +52 -0
- package/cjs/hooks/useBackend/index.d.ts +17 -0
- package/cjs/hooks/useBackend/index.js +22 -0
- package/cjs/hooks/useBackend/list.d.ts +2 -0
- package/cjs/hooks/useBackend/list.js +55 -0
- package/cjs/hooks/useBackend/post.d.ts +2 -0
- package/cjs/hooks/useBackend/post.js +52 -0
- package/cjs/hooks/useBackend/put.d.ts +2 -0
- package/cjs/hooks/useBackend/put.js +52 -0
- package/cjs/hooks/useCampaigns/index.d.ts +2 -0
- package/cjs/hooks/useCampaigns/index.js +35 -0
- package/cjs/hooks/useCategories/index.d.ts +3 -0
- package/cjs/hooks/useCategories/index.js +37 -0
- package/cjs/hooks/useChats/index.d.ts +3 -0
- package/cjs/hooks/useChats/index.js +37 -0
- package/cjs/hooks/useContactGroups/index.d.ts +3 -0
- package/cjs/hooks/useContactGroups/index.js +57 -0
- package/cjs/hooks/useContacts/index.d.ts +3 -0
- package/cjs/hooks/useContacts/index.js +52 -0
- package/cjs/hooks/useCurrencies/index.d.ts +3 -0
- package/cjs/hooks/useCurrencies/index.js +37 -0
- package/cjs/hooks/useCustomers/index.d.ts +3 -0
- package/cjs/hooks/useCustomers/index.js +52 -0
- package/cjs/hooks/useDocuments/index.d.ts +10 -0
- package/cjs/hooks/useDocuments/index.js +145 -0
- package/cjs/hooks/useDomains/index.d.ts +2 -0
- package/cjs/hooks/useDomains/index.js +32 -0
- package/cjs/hooks/useEmailTemplates/index.d.ts +2 -0
- package/cjs/hooks/useEmailTemplates/index.js +37 -0
- package/cjs/hooks/useEntityStatuses/index.d.ts +2 -0
- package/cjs/hooks/useEntityStatuses/index.js +34 -0
- package/cjs/hooks/useFormSubmissions/index.d.ts +2 -0
- package/cjs/hooks/useFormSubmissions/index.js +9 -0
- package/cjs/hooks/useForms/index.d.ts +2 -0
- package/cjs/hooks/useForms/index.js +37 -0
- package/cjs/hooks/useIntegrations/index.d.ts +2 -0
- package/cjs/hooks/useIntegrations/index.js +39 -0
- package/cjs/hooks/useInvites/index.d.ts +2 -0
- package/cjs/hooks/useInvites/index.js +47 -0
- package/cjs/hooks/useLabels/index.d.ts +3 -0
- package/cjs/hooks/useLabels/index.js +32 -0
- package/cjs/hooks/useLanguages/index.d.ts +5 -0
- package/cjs/hooks/useLanguages/index.js +39 -0
- package/cjs/hooks/useLeads/index.d.ts +30 -0
- package/cjs/hooks/useLeads/index.js +113 -0
- package/cjs/hooks/useMedia/index.d.ts +2 -0
- package/cjs/hooks/useMedia/index.js +34 -0
- package/cjs/hooks/useOrders/index.d.ts +2 -0
- package/cjs/hooks/useOrders/index.js +76 -0
- package/cjs/hooks/usePaths/index.d.ts +2 -0
- package/cjs/hooks/usePaths/index.js +37 -0
- package/cjs/hooks/usePermissions/index.d.ts +2 -0
- package/cjs/hooks/usePermissions/index.js +47 -0
- package/cjs/hooks/useProducts/index.d.ts +2 -0
- package/cjs/hooks/useProducts/index.js +52 -0
- package/cjs/hooks/useProfile/index.d.ts +3 -0
- package/cjs/hooks/useProfile/index.js +57 -0
- package/cjs/hooks/useRenting/index.d.ts +47 -0
- package/cjs/hooks/useRenting/index.js +52 -0
- package/cjs/hooks/useRoles/index.d.ts +2 -0
- package/cjs/hooks/useRoles/index.js +32 -0
- package/cjs/hooks/useRoom/index.d.ts +3 -0
- package/cjs/hooks/useRoom/index.js +55 -0
- package/cjs/hooks/useRotations/index.d.ts +2 -0
- package/cjs/hooks/useRotations/index.js +37 -0
- package/cjs/hooks/useSiteConfig/index.d.ts +5 -0
- package/cjs/hooks/useSiteConfig/index.js +33 -0
- package/cjs/hooks/useStatuses/index.d.ts +2 -0
- package/cjs/hooks/useStatuses/index.js +32 -0
- package/cjs/hooks/useStock/index.d.ts +20 -0
- package/cjs/hooks/useStock/index.js +51 -0
- package/cjs/hooks/useStores/index.d.ts +3 -0
- package/cjs/hooks/useStores/index.js +62 -0
- package/cjs/hooks/useSubscriptions/index.d.ts +2 -0
- package/cjs/hooks/useSubscriptions/index.js +37 -0
- package/cjs/hooks/useTable/index.d.ts +3 -0
- package/cjs/hooks/useTable/index.js +34 -0
- package/cjs/hooks/useTeams/index.d.ts +5 -0
- package/cjs/hooks/useTeams/index.js +52 -0
- package/cjs/hooks/useTickets/index.d.ts +3 -0
- package/cjs/hooks/useTickets/index.js +47 -0
- package/cjs/hooks/useTransactions/index.d.ts +8 -0
- package/cjs/hooks/useTransactions/index.js +61 -0
- package/cjs/hooks/useTranslations/index.d.ts +5 -0
- package/cjs/hooks/useTranslations/index.js +42 -0
- package/cjs/hooks/useUserConnections/index.d.ts +2 -0
- package/cjs/hooks/useUserConnections/index.js +53 -0
- package/cjs/hooks/useUserSubscriptions/index.d.ts +6 -0
- package/cjs/hooks/useUserSubscriptions/index.js +47 -0
- package/cjs/hooks/useUsers/index.d.ts +17 -0
- package/cjs/hooks/useUsers/index.js +141 -0
- package/cjs/hooks/useWBSuite/index.d.ts +2 -0
- package/cjs/hooks/useWBSuite/index.js +39 -0
- package/cjs/hooks/useWebsites/index.d.ts +2 -0
- package/cjs/hooks/useWebsites/index.js +77 -0
- package/{src/index.ts → cjs/index.d.ts} +1 -1
- package/cjs/index.js +119 -0
- package/cjs/models/Requestor.d.ts +24 -0
- package/cjs/models/Requestor.js +53 -0
- package/{src/next/utils/index.ts → cjs/next/utils/index.d.ts} +1 -1
- package/cjs/next/utils/index.js +6 -0
- package/cjs/next/utils/wrapAsync.d.ts +1 -0
- package/cjs/next/utils/wrapAsync.js +54 -0
- package/cjs/utils/authWithApiKey.d.ts +4 -0
- package/cjs/utils/authWithApiKey.js +8 -0
- package/cjs/utils/authWithToken.d.ts +4 -0
- package/cjs/utils/authWithToken.js +8 -0
- package/cjs/utils/index.d.ts +11 -0
- package/cjs/utils/index.js +19 -0
- package/esm/hooks/useAgents/index.d.ts +2 -0
- package/esm/hooks/useAgents/index.js +28 -0
- package/esm/hooks/useApps/index.d.ts +2 -0
- package/esm/hooks/useApps/index.js +28 -0
- package/esm/hooks/useArticles/index.d.ts +5 -0
- package/esm/hooks/useArticles/index.js +40 -0
- package/esm/hooks/useAttributes/index.d.ts +2 -0
- package/esm/hooks/useAttributes/index.js +48 -0
- package/esm/hooks/useAttributesGroups/index.d.ts +3 -0
- package/esm/hooks/useAttributesGroups/index.js +43 -0
- package/esm/hooks/useAutomations/index.d.ts +2 -0
- package/esm/hooks/useAutomations/index.js +28 -0
- package/esm/hooks/useBackend/get.d.ts +2 -0
- package/esm/hooks/useBackend/get.js +48 -0
- package/esm/hooks/useBackend/index.d.ts +17 -0
- package/esm/hooks/useBackend/index.js +18 -0
- package/esm/hooks/useBackend/list.d.ts +2 -0
- package/esm/hooks/useBackend/list.js +51 -0
- package/esm/hooks/useBackend/post.d.ts +2 -0
- package/esm/hooks/useBackend/post.js +48 -0
- package/esm/hooks/useBackend/put.d.ts +2 -0
- package/esm/hooks/useBackend/put.js +48 -0
- package/esm/hooks/useCampaigns/index.d.ts +2 -0
- package/esm/hooks/useCampaigns/index.js +31 -0
- package/esm/hooks/useCategories/index.d.ts +3 -0
- package/esm/hooks/useCategories/index.js +33 -0
- package/esm/hooks/useChats/index.d.ts +3 -0
- package/esm/hooks/useChats/index.js +33 -0
- package/esm/hooks/useContactGroups/index.d.ts +3 -0
- package/esm/hooks/useContactGroups/index.js +53 -0
- package/esm/hooks/useContacts/index.d.ts +3 -0
- package/esm/hooks/useContacts/index.js +48 -0
- package/esm/hooks/useCurrencies/index.d.ts +3 -0
- package/esm/hooks/useCurrencies/index.js +33 -0
- package/esm/hooks/useCustomers/index.d.ts +3 -0
- package/esm/hooks/useCustomers/index.js +48 -0
- package/esm/hooks/useDocuments/index.d.ts +10 -0
- package/esm/hooks/useDocuments/index.js +141 -0
- package/esm/hooks/useDomains/index.d.ts +2 -0
- package/esm/hooks/useDomains/index.js +28 -0
- package/esm/hooks/useEmailTemplates/index.d.ts +2 -0
- package/esm/hooks/useEmailTemplates/index.js +33 -0
- package/esm/hooks/useEntityStatuses/index.d.ts +2 -0
- package/esm/hooks/useEntityStatuses/index.js +30 -0
- package/esm/hooks/useFormSubmissions/index.d.ts +2 -0
- package/esm/hooks/useFormSubmissions/index.js +5 -0
- package/esm/hooks/useForms/index.d.ts +2 -0
- package/esm/hooks/useForms/index.js +33 -0
- package/esm/hooks/useIntegrations/index.d.ts +2 -0
- package/esm/hooks/useIntegrations/index.js +35 -0
- package/esm/hooks/useInvites/index.d.ts +2 -0
- package/esm/hooks/useInvites/index.js +43 -0
- package/esm/hooks/useLabels/index.d.ts +3 -0
- package/esm/hooks/useLabels/index.js +28 -0
- package/esm/hooks/useLanguages/index.d.ts +5 -0
- package/esm/hooks/useLanguages/index.js +35 -0
- package/esm/hooks/useLeads/index.d.ts +30 -0
- package/esm/hooks/useLeads/index.js +109 -0
- package/esm/hooks/useMedia/index.d.ts +2 -0
- package/esm/hooks/useMedia/index.js +30 -0
- package/esm/hooks/useOrders/index.d.ts +2 -0
- package/esm/hooks/useOrders/index.js +72 -0
- package/esm/hooks/usePaths/index.d.ts +2 -0
- package/esm/hooks/usePaths/index.js +33 -0
- package/esm/hooks/usePermissions/index.d.ts +2 -0
- package/esm/hooks/usePermissions/index.js +43 -0
- package/esm/hooks/useProducts/index.d.ts +2 -0
- package/esm/hooks/useProducts/index.js +48 -0
- package/esm/hooks/useProfile/index.d.ts +3 -0
- package/esm/hooks/useProfile/index.js +53 -0
- package/esm/hooks/useRenting/index.d.ts +47 -0
- package/esm/hooks/useRenting/index.js +48 -0
- package/esm/hooks/useRoles/index.d.ts +2 -0
- package/esm/hooks/useRoles/index.js +28 -0
- package/esm/hooks/useRoom/index.d.ts +3 -0
- package/esm/hooks/useRoom/index.js +51 -0
- package/esm/hooks/useRotations/index.d.ts +2 -0
- package/esm/hooks/useRotations/index.js +33 -0
- package/esm/hooks/useSiteConfig/index.d.ts +5 -0
- package/esm/hooks/useSiteConfig/index.js +29 -0
- package/esm/hooks/useStatuses/index.d.ts +2 -0
- package/esm/hooks/useStatuses/index.js +28 -0
- package/esm/hooks/useStock/index.d.ts +20 -0
- package/esm/hooks/useStock/index.js +47 -0
- package/esm/hooks/useStores/index.d.ts +3 -0
- package/esm/hooks/useStores/index.js +58 -0
- package/esm/hooks/useSubscriptions/index.d.ts +2 -0
- package/esm/hooks/useSubscriptions/index.js +33 -0
- package/esm/hooks/useTable/index.d.ts +3 -0
- package/esm/hooks/useTable/index.js +30 -0
- package/esm/hooks/useTeams/index.d.ts +5 -0
- package/esm/hooks/useTeams/index.js +48 -0
- package/esm/hooks/useTickets/index.d.ts +3 -0
- package/esm/hooks/useTickets/index.js +43 -0
- package/esm/hooks/useTransactions/index.d.ts +8 -0
- package/esm/hooks/useTransactions/index.js +57 -0
- package/esm/hooks/useTranslations/index.d.ts +5 -0
- package/esm/hooks/useTranslations/index.js +38 -0
- package/esm/hooks/useUserConnections/index.d.ts +2 -0
- package/esm/hooks/useUserConnections/index.js +49 -0
- package/esm/hooks/useUserSubscriptions/index.d.ts +6 -0
- package/esm/hooks/useUserSubscriptions/index.js +43 -0
- package/esm/hooks/useUsers/index.d.ts +17 -0
- package/esm/hooks/useUsers/index.js +137 -0
- package/esm/hooks/useWBSuite/index.d.ts +2 -0
- package/esm/hooks/useWBSuite/index.js +35 -0
- package/esm/hooks/useWebsites/index.d.ts +2 -0
- package/esm/hooks/useWebsites/index.js +73 -0
- package/esm/index.d.ts +51 -0
- package/esm/index.js +52 -0
- package/esm/models/Requestor.d.ts +24 -0
- package/esm/models/Requestor.js +47 -0
- package/esm/next/utils/index.d.ts +2 -0
- package/esm/next/utils/index.js +3 -0
- package/esm/next/utils/wrapAsync.d.ts +1 -0
- package/esm/next/utils/wrapAsync.js +50 -0
- package/esm/utils/authWithApiKey.d.ts +4 -0
- package/esm/utils/authWithApiKey.js +4 -0
- package/esm/utils/authWithToken.d.ts +4 -0
- package/esm/utils/authWithToken.js +4 -0
- package/esm/utils/index.d.ts +11 -0
- package/esm/utils/index.js +3 -0
- package/package.json +1 -1
- package/README.md +0 -66
- package/docs/USAGE.md +0 -107
- package/eslint.config.js +0 -12
- package/src/hooks/useAgents/index.ts +0 -10
- package/src/hooks/useApps/index.ts +0 -10
- package/src/hooks/useArticles/index.ts +0 -18
- package/src/hooks/useAttributes/index.ts +0 -18
- package/src/hooks/useAttributesGroups/index.ts +0 -17
- package/src/hooks/useAutomations/index.ts +0 -10
- package/src/hooks/useBackend/get.ts +0 -6
- package/src/hooks/useBackend/index.ts +0 -40
- package/src/hooks/useBackend/list.ts +0 -6
- package/src/hooks/useBackend/post.ts +0 -6
- package/src/hooks/useBackend/put.ts +0 -6
- package/src/hooks/useCampaigns/index.ts +0 -11
- package/src/hooks/useCategories/index.ts +0 -13
- package/src/hooks/useChats/index.ts +0 -13
- package/src/hooks/useContactGroups/index.ts +0 -28
- package/src/hooks/useContacts/index.ts +0 -21
- package/src/hooks/useCurrencies/index.ts +0 -14
- package/src/hooks/useCustomers/index.ts +0 -21
- package/src/hooks/useDocuments/index.ts +0 -86
- package/src/hooks/useDomains/index.ts +0 -10
- package/src/hooks/useEmailTemplates/index.ts +0 -13
- package/src/hooks/useEntityStatuses/index.ts +0 -13
- package/src/hooks/useFormSubmissions/index.ts +0 -6
- package/src/hooks/useForms/index.ts +0 -16
- package/src/hooks/useIntegrations/index.ts +0 -15
- package/src/hooks/useInvites/index.ts +0 -19
- package/src/hooks/useLabels/index.ts +0 -13
- package/src/hooks/useLanguages/index.ts +0 -16
- package/src/hooks/useLeads/index.ts +0 -149
- package/src/hooks/useMedia/index.ts +0 -13
- package/src/hooks/useOrders/index.ts +0 -74
- package/src/hooks/usePaths/index.ts +0 -16
- package/src/hooks/usePermissions/index.ts +0 -16
- package/src/hooks/useProducts/index.ts +0 -18
- package/src/hooks/useProfile/index.ts +0 -20
- package/src/hooks/useRenting/index.ts +0 -57
- package/src/hooks/useRoles/index.ts +0 -10
- package/src/hooks/useRoom/index.ts +0 -20
- package/src/hooks/useRotations/index.ts +0 -13
- package/src/hooks/useSiteConfig/index.ts +0 -13
- package/src/hooks/useStatuses/index.ts +0 -10
- package/src/hooks/useStock/index.ts +0 -48
- package/src/hooks/useStores/index.ts +0 -23
- package/src/hooks/useSubscriptions/index.ts +0 -17
- package/src/hooks/useTable/index.ts +0 -15
- package/src/hooks/useTeams/index.ts +0 -29
- package/src/hooks/useTickets/index.ts +0 -17
- package/src/hooks/useTransactions/index.ts +0 -43
- package/src/hooks/useTranslations/index.ts +0 -20
- package/src/hooks/useUserConnections/index.ts +0 -18
- package/src/hooks/useUserSubscriptions/index.ts +0 -28
- package/src/hooks/useUsers/index.ts +0 -57
- package/src/hooks/useWBSuite/index.ts +0 -29
- package/src/hooks/useWebsites/index.ts +0 -34
- package/src/models/Requestor.ts +0 -67
- package/src/next/utils/wrapAsync.ts +0 -2
- package/src/utils/authWithApiKey.ts +0 -3
- package/src/utils/authWithToken.ts +0 -3
- package/src/utils/index.ts +0 -7
- package/tsconfig.json +0 -20
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
2
|
-
import { Chat } from '@wb/types/chats/chats.model';
|
|
3
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
4
|
-
|
|
5
|
-
export const useTickets: BackendHook<Chat> = (auth?: RequestorOptions['auth']) => {
|
|
6
|
-
const { requestor, ...endpoints } = useBackend('tickets', { auth });
|
|
7
|
-
return {
|
|
8
|
-
requestor,
|
|
9
|
-
...endpoints,
|
|
10
|
-
resolve: (ticketId: string) =>
|
|
11
|
-
requestor.makeRequest.post(`tickets/${ticketId}/resolve`).then(({ data }) => data),
|
|
12
|
-
addComment: (ticketId: string, note: { text: string, extra: Record<string, unknown> }) =>
|
|
13
|
-
requestor.makeRequest.post(`tickets/${ticketId}/comment`, note).then(({ data }) => data),
|
|
14
|
-
commentHistory: (ticketId: string) =>
|
|
15
|
-
requestor.makeRequest.post(`tickets/${ticketId}/comment/history`).then(({ data }) => data),
|
|
16
|
-
};
|
|
17
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { WBBackendConfig } from '@wb/types/backendConfig/backendConfig';
|
|
2
|
-
|
|
3
|
-
const process = (globalThis as any).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
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
};
|
package/src/models/Requestor.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
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
|
-
}
|
package/src/utils/index.ts
DELETED
package/tsconfig.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
}
|