Skip to content

Commit 5805c64

Browse files
authored
Merge pull request #166 from HubSpot/next
2 parents ec80022 + aac79f0 commit 5805c64

File tree

92 files changed

+2035
-2337
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+2035
-2337
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ module.exports = {
1212
parserOptions: {
1313
ecmaVersion: 2022,
1414
},
15-
plugins: ['@typescript-eslint'],
15+
plugins: ['@typescript-eslint', 'import'],
1616
rules: {
1717
'no-console': 'off',
1818
'no-return-await': 'error',
1919
'@typescript-eslint/no-non-null-assertion': 'off',
20+
'import/no-default-export': 'error',
2021
},
2122
overrides: [
2223
{

api/README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,9 @@ Here's how to use the `addSecret` API util:
2222
```js
2323
const { loadConfig } = require('@hubspot/local-dev-lib/config');
2424
const { addSecret } = require('@hubspot/local-dev-lib/api/secrets');
25-
const { throwApiError } = require('@hubspot/local-dev-lib/errors/apiErrors');
2625

2726
// Parse and store the config file information
2827
loadConfig();
2928
const accountId = 12345;
30-
31-
try {
32-
await addSecret(accountId, 'my-secret-name', 'my-secret-value');
33-
} catch (e) {
34-
throwApiError(e);
35-
}
29+
await addSecret(accountId, 'my-secret-name', 'my-secret-value');
3630
```

api/__tests__/projects.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
jest.mock('../../http');
22
jest.mock('fs');
33
import { createReadStream } from 'fs';
4-
import http from '../../http';
4+
import { http } from '../../http';
55
import {
66
cancelStagedBuild,
77
checkCloneStatus,

api/appsDev.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import http from '../http';
1+
import { AxiosPromise } from 'axios';
2+
import { http } from '../http';
23
import {
34
PublicApp,
45
PublicAppInstallCounts,
@@ -8,20 +9,18 @@ import {
89

910
const APPS_DEV_API_PATH = 'apps-dev/external/public/v3';
1011

11-
export async function fetchPublicAppsForPortal(
12+
export function fetchPublicAppsForPortal(
1213
accountId: number
13-
): Promise<Array<PublicApp>> {
14-
const resp = await http.get<FetchPublicAppsForPortalResponse>(accountId, {
14+
): AxiosPromise<FetchPublicAppsForPortalResponse> {
15+
return http.get<FetchPublicAppsForPortalResponse>(accountId, {
1516
url: `${APPS_DEV_API_PATH}/full/portal`,
1617
});
17-
18-
return resp ? resp.results : [];
1918
}
2019

2120
export function fetchPublicAppDeveloperTestAccountInstallData(
2221
appId: number,
2322
accountId: number
24-
): Promise<PublicAppDeveloperTestAccountInstallData> {
23+
): AxiosPromise<PublicAppDeveloperTestAccountInstallData> {
2524
return http.get<PublicAppDeveloperTestAccountInstallData>(accountId, {
2625
url: `${APPS_DEV_API_PATH}/${appId}/test-portal-installs`,
2726
});
@@ -30,7 +29,7 @@ export function fetchPublicAppDeveloperTestAccountInstallData(
3029
export function fetchPublicAppProductionInstallCounts(
3130
appId: number,
3231
accountId: number
33-
): Promise<PublicAppInstallCounts> {
32+
): AxiosPromise<PublicAppInstallCounts> {
3433
return http.get<PublicAppInstallCounts>(accountId, {
3534
url: `${APPS_DEV_API_PATH}/${appId}/install-counts-without-test-portals`,
3635
});
@@ -39,7 +38,7 @@ export function fetchPublicAppProductionInstallCounts(
3938
export function fetchPublicAppMetadata(
4039
appId: number,
4140
accountId: number
42-
): Promise<PublicApp> {
41+
): AxiosPromise<PublicApp> {
4342
return http.get<PublicApp>(accountId, {
4443
url: `${APPS_DEV_API_PATH}/${appId}/full`,
4544
});

api/customObjects.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import http from '../http';
1+
import { AxiosPromise } from 'axios';
2+
import { http } from '../http';
23
import {
34
FetchSchemasResponse,
45
Schema,
@@ -8,59 +9,59 @@ import {
89
const CUSTOM_OBJECTS_API_PATH = 'crm/v3/objects';
910
const SCHEMA_API_PATH = 'crm-object-schemas/v3/schemas';
1011

11-
export async function batchCreateObjects(
12+
export function batchCreateObjects(
1213
accountId: number,
1314
objectTypeId: string,
1415
objects: JSON
15-
): Promise<CreateObjectsResponse> {
16+
): AxiosPromise<CreateObjectsResponse> {
1617
return http.post<CreateObjectsResponse>(accountId, {
1718
url: `${CUSTOM_OBJECTS_API_PATH}/${objectTypeId}/batch/create`,
1819
data: objects,
1920
});
2021
}
2122

22-
export async function createObjectSchema(
23+
export function createObjectSchema(
2324
accountId: number,
2425
schema: JSON
25-
): Promise<Schema> {
26-
return http.post(accountId, {
26+
): AxiosPromise<Schema> {
27+
return http.post<Schema>(accountId, {
2728
url: SCHEMA_API_PATH,
2829
data: schema,
2930
});
3031
}
3132

32-
export async function updateObjectSchema(
33+
export function updateObjectSchema(
3334
accountId: number,
3435
schemaObjectType: string,
3536
schema: Schema
36-
): Promise<Schema> {
37-
return http.patch(accountId, {
37+
): AxiosPromise<Schema> {
38+
return http.patch<Schema>(accountId, {
3839
url: `${SCHEMA_API_PATH}/${schemaObjectType}`,
3940
data: schema,
4041
});
4142
}
4243

43-
export async function fetchObjectSchema(
44+
export function fetchObjectSchema(
4445
accountId: number,
4546
schemaObjectType: string
46-
): Promise<Schema> {
47-
return http.get(accountId, {
47+
): AxiosPromise<Schema> {
48+
return http.get<Schema>(accountId, {
4849
url: `${SCHEMA_API_PATH}/${schemaObjectType}`,
4950
});
5051
}
5152

52-
export async function fetchObjectSchemas(
53+
export function fetchObjectSchemas(
5354
accountId: number
54-
): Promise<FetchSchemasResponse> {
55-
return http.get(accountId, {
55+
): AxiosPromise<FetchSchemasResponse> {
56+
return http.get<FetchSchemasResponse>(accountId, {
5657
url: SCHEMA_API_PATH,
5758
});
5859
}
5960

60-
export async function deleteObjectSchema(
61+
export function deleteObjectSchema(
6162
accountId: number,
6263
schemaObjectType: string
63-
): Promise<void> {
64+
): AxiosPromise<void> {
6465
return http.delete(accountId, {
6566
url: `${SCHEMA_API_PATH}/${schemaObjectType}`,
6667
});

api/designManager.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import http from '../http';
1+
import { AxiosPromise } from 'axios';
2+
import { http } from '../http';
23
import { QueryParams } from '../types/Http';
34
import {
45
FetchThemesResponse,
@@ -7,19 +8,19 @@ import {
78

89
const DESIGN_MANAGER_API_PATH = 'designmanager/v1';
910

10-
export async function fetchThemes(
11+
export function fetchThemes(
1112
accountId: number,
1213
params: QueryParams = {}
13-
): Promise<FetchThemesResponse> {
14+
): AxiosPromise<FetchThemesResponse> {
1415
return http.get<FetchThemesResponse>(accountId, {
1516
url: `${DESIGN_MANAGER_API_PATH}/themes/combined`,
1617
params,
1718
});
1819
}
1920

20-
export async function fetchBuiltinMapping(
21+
export function fetchBuiltinMapping(
2122
accountId: number
22-
): Promise<FetchBuiltinMappingResponse> {
23+
): AxiosPromise<FetchBuiltinMappingResponse> {
2324
return http.get<FetchBuiltinMappingResponse>(accountId, {
2425
url: `${DESIGN_MANAGER_API_PATH}/widgets/builtin-mapping`,
2526
});

api/developerTestAccounts.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import axios from 'axios';
2-
import http from '../http';
1+
import axios, { AxiosPromise } from 'axios';
2+
import { http } from '../http';
33
import { getAxiosConfig } from '../http/getAxiosConfig';
44
import { ENVIRONMENTS } from '../constants/environments';
55
import {
@@ -11,39 +11,39 @@ import { Environment } from '../types/Config';
1111

1212
const TEST_ACCOUNTS_API_PATH = 'integrators/test-portals/v2';
1313

14-
export async function fetchDeveloperTestAccounts(
14+
export function fetchDeveloperTestAccounts(
1515
accountId: number
16-
): Promise<FetchDeveloperTestAccountsResponse> {
17-
return http.get(accountId, {
16+
): AxiosPromise<FetchDeveloperTestAccountsResponse> {
17+
return http.get<FetchDeveloperTestAccountsResponse>(accountId, {
1818
url: TEST_ACCOUNTS_API_PATH,
1919
});
2020
}
2121

22-
export async function createDeveloperTestAccount(
22+
export function createDeveloperTestAccount(
2323
accountId: number,
2424
accountName: string
25-
): Promise<DeveloperTestAccount> {
26-
return http.post(accountId, {
25+
): AxiosPromise<DeveloperTestAccount> {
26+
return http.post<DeveloperTestAccount>(accountId, {
2727
url: TEST_ACCOUNTS_API_PATH,
2828
data: { accountName, generatePersonalAccessKey: true }, // For CLI, generatePersonalAccessKey will always be true since we'll be saving the entry to the config
2929
timeout: SANDBOX_TIMEOUT,
3030
});
3131
}
3232

33-
export async function deleteDeveloperTestAccount(
33+
export function deleteDeveloperTestAccount(
3434
accountId: number,
3535
testAccountId: number
36-
): Promise<void> {
36+
): AxiosPromise<void> {
3737
return http.delete(accountId, {
3838
url: `${TEST_ACCOUNTS_API_PATH}/${testAccountId}`,
3939
});
4040
}
4141

42-
export async function fetchDeveloperTestAccountData(
42+
export function fetchDeveloperTestAccountData(
4343
accessToken: string,
4444
accountId: number,
4545
env: Environment = ENVIRONMENTS.PROD
46-
): Promise<DeveloperTestAccount> {
46+
): AxiosPromise<DeveloperTestAccount> {
4747
const axiosConfig = getAxiosConfig({
4848
env,
4949
url: `${TEST_ACCOUNTS_API_PATH}/self`,
@@ -57,7 +57,5 @@ export async function fetchDeveloperTestAccountData(
5757
},
5858
};
5959

60-
const { data } = await axios<DeveloperTestAccount>(reqWithToken);
61-
62-
return data;
60+
return axios<DeveloperTestAccount>(reqWithToken);
6361
}

api/fileManager.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import { AxiosPromise } from 'axios';
12
import fs from 'fs';
23
import path from 'path';
3-
import http from '../http';
4+
import { http } from '../http';
45
import { FormData } from '../types/Http';
56
import {
67
FetchStatResponse,
@@ -12,11 +13,11 @@ import {
1213
const FILE_MANAGER_V2_API_PATH = 'filemanager/api/v2';
1314
const FILE_MANAGER_V3_API_PATH = 'filemanager/api/v3';
1415

15-
export async function uploadFile(
16+
export function uploadFile(
1617
accountId: number,
1718
src: string,
1819
dest: string
19-
): Promise<UploadResponse> {
20+
): AxiosPromise<UploadResponse> {
2021
const directory = path.dirname(dest);
2122
const filename = path.basename(dest);
2223
const formData: FormData = {
@@ -34,29 +35,29 @@ export async function uploadFile(
3435
formData.folderPath = '/';
3536
}
3637

37-
return http.post(accountId, {
38+
return http.post<UploadResponse>(accountId, {
3839
url: `${FILE_MANAGER_V3_API_PATH}/files/upload`,
3940
data: formData,
4041
headers: { 'Content-Type': 'multipart/form-data' },
4142
});
4243
}
4344

44-
export async function fetchStat(
45+
export function fetchStat(
4546
accountId: number,
4647
src: string
47-
): Promise<FetchStatResponse> {
48-
return http.get(accountId, {
48+
): AxiosPromise<FetchStatResponse> {
49+
return http.get<FetchStatResponse>(accountId, {
4950
url: `${FILE_MANAGER_V2_API_PATH}/files/stat/${src}`,
5051
});
5152
}
5253

53-
export async function fetchFiles(
54+
export function fetchFiles(
5455
accountId: number,
5556
folderId: number | 'None',
5657
offset: number,
5758
archived?: boolean
58-
): Promise<FetchFilesResponse> {
59-
return http.get(accountId, {
59+
): AxiosPromise<FetchFilesResponse> {
60+
return http.get<FetchFilesResponse>(accountId, {
6061
url: `${FILE_MANAGER_V2_API_PATH}/files/`,
6162
params: {
6263
hidden: 0,
@@ -67,11 +68,11 @@ export async function fetchFiles(
6768
});
6869
}
6970

70-
export async function fetchFolders(
71+
export function fetchFolders(
7172
accountId: number,
7273
folderId: number | 'None'
73-
): Promise<FetchFolderResponse> {
74-
return http.get(accountId, {
74+
): AxiosPromise<FetchFolderResponse> {
75+
return http.get<FetchFolderResponse>(accountId, {
7576
url: `${FILE_MANAGER_V2_API_PATH}/folders/`,
7677
params: {
7778
hidden: 0,

0 commit comments

Comments
 (0)