@hubspot/local-dev-lib 4.0.4 → 5.0.0-beta.1
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/api/appsDev.d.ts +2 -2
- package/api/appsDev.js +13 -22
- package/api/crm.d.ts +2 -2
- package/api/crm.js +9 -16
- package/api/customObjects.d.ts +2 -2
- package/api/customObjects.js +13 -22
- package/api/designManager.d.ts +2 -2
- package/api/designManager.js +5 -10
- package/api/devSecrets.d.ts +2 -2
- package/api/devSecrets.js +9 -16
- package/api/developerTestAccounts.d.ts +2 -4
- package/api/developerTestAccounts.js +23 -52
- package/api/fileManager.d.ts +2 -2
- package/api/fileManager.js +14 -24
- package/api/fileMapper.d.ts +2 -3
- package/api/fileMapper.js +34 -49
- package/api/fileTransport.d.ts +1 -1
- package/api/fileTransport.js +12 -21
- package/api/fireAlarm.d.ts +2 -3
- package/api/fireAlarm.js +5 -9
- package/api/functions.d.ts +2 -2
- package/api/functions.js +11 -19
- package/api/github.d.ts +2 -4
- package/api/github.js +16 -27
- package/api/hubdb.d.ts +2 -2
- package/api/hubdb.js +19 -31
- package/api/lighthouseScore.d.ts +2 -2
- package/api/lighthouseScore.js +7 -13
- package/api/localDevAuth.d.ts +3 -6
- package/api/localDevAuth.js +10 -37
- package/api/marketplaceValidation.d.ts +2 -2
- package/api/marketplaceValidation.js +7 -13
- package/api/projects.d.ts +6 -8
- package/api/projects.js +65 -100
- package/api/sandboxHubs.d.ts +2 -5
- package/api/sandboxHubs.js +15 -42
- package/api/sandboxSync.d.ts +2 -2
- package/api/sandboxSync.js +7 -12
- package/api/secrets.d.ts +2 -2
- package/api/secrets.js +9 -16
- package/api/validateHubl.d.ts +2 -2
- package/api/validateHubl.js +3 -7
- package/config/defaultAccountOverride.d.ts +2 -1
- package/config/defaultAccountOverride.js +16 -26
- package/config/index.d.ts +4 -4
- package/config/index.js +141 -177
- package/config/migrate.d.ts +2 -2
- package/config/migrate.js +26 -37
- package/config/state.d.ts +1 -1
- package/config/state.js +17 -45
- package/config/utils.d.ts +4 -4
- package/config/utils.js +85 -108
- package/constants/api.js +3 -6
- package/constants/auth.js +9 -12
- package/constants/config.js +37 -43
- package/constants/endpoints.d.ts +6 -0
- package/constants/endpoints.js +6 -0
- package/constants/environments.js +1 -4
- package/constants/extensions.js +6 -9
- package/constants/files.js +5 -8
- package/constants/ports.js +3 -6
- package/constants/projects.js +2 -5
- package/enums/build.d.ts +1 -0
- package/enums/build.js +6 -8
- package/enums/deploy.js +2 -5
- package/enums/project.js +1 -4
- package/errors/index.d.ts +4 -5
- package/errors/index.js +17 -39
- package/errors/isSystemError.d.ts +2 -0
- package/errors/isSystemError.js +9 -0
- package/http/addQueryParams.d.ts +1 -1
- package/http/addQueryParams.js +1 -5
- package/http/client.js +14 -42
- package/http/getAxiosConfig.d.ts +1 -1
- package/http/getAxiosConfig.js +21 -31
- package/http/index.d.ts +2 -2
- package/http/index.js +39 -46
- package/http/unauthed.d.ts +1 -1
- package/http/unauthed.js +15 -18
- package/lang/en.json +1 -1
- package/lib/archive.d.ts +1 -3
- package/lib/archive.js +37 -67
- package/lib/cms/functions.d.ts +1 -1
- package/lib/cms/functions.js +45 -55
- package/lib/cms/handleFieldsJS.js +36 -44
- package/lib/cms/modules.d.ts +2 -2
- package/lib/cms/modules.js +49 -59
- package/lib/cms/processFieldsJs.js +17 -32
- package/lib/cms/templates.js +17 -26
- package/lib/cms/themes.js +10 -18
- package/lib/cms/uploadFolder.d.ts +4 -4
- package/lib/cms/uploadFolder.js +55 -64
- package/lib/cms/validate.d.ts +1 -1
- package/lib/cms/validate.js +11 -18
- package/lib/cms/watch.d.ts +2 -2
- package/lib/cms/watch.js +66 -73
- package/lib/crm.d.ts +1 -1
- package/lib/crm.js +15 -23
- package/lib/customObjects.d.ts +1 -1
- package/lib/customObjects.js +15 -25
- package/lib/environment.d.ts +1 -1
- package/lib/environment.js +5 -11
- package/lib/escapeRegExp.js +1 -5
- package/lib/fileManager.js +43 -51
- package/lib/fileMapper.d.ts +1 -1
- package/lib/fileMapper.js +68 -84
- package/lib/fs.d.ts +1 -1
- package/lib/fs.js +18 -27
- package/lib/github.d.ts +1 -3
- package/lib/github.js +39 -51
- package/lib/gitignore.d.ts +1 -1
- package/lib/gitignore.js +16 -24
- package/lib/hubdb.d.ts +1 -1
- package/lib/hubdb.js +29 -40
- package/lib/ignoreRules.js +25 -34
- package/lib/isDeepEqual.js +1 -5
- package/lib/logger.d.ts +8 -20
- package/lib/logger.js +47 -59
- package/lib/notify.js +9 -16
- package/lib/oauth.d.ts +2 -2
- package/lib/oauth.js +12 -17
- package/lib/path.d.ts +0 -1
- package/lib/path.js +30 -48
- package/lib/personalAccessKey.d.ts +2 -4
- package/lib/personalAccessKey.js +43 -60
- package/lib/portManager.d.ts +2 -2
- package/lib/portManager.js +26 -41
- package/lib/text.js +2 -7
- package/lib/trackUsage.d.ts +0 -2
- package/lib/trackUsage.js +23 -29
- package/lib/urls.js +4 -9
- package/models/FileSystemError.d.ts +1 -1
- package/models/FileSystemError.js +12 -16
- package/models/HubSpotConfigError.d.ts +1 -1
- package/models/HubSpotConfigError.js +8 -12
- package/models/HubSpotHttpError.d.ts +1 -1
- package/models/HubSpotHttpError.js +22 -26
- package/models/OAuth2Manager.d.ts +1 -1
- package/models/OAuth2Manager.js +17 -24
- package/package.json +20 -16
- package/types/Accounts.d.ts +6 -5
- package/types/Accounts.js +1 -2
- package/types/Activity.d.ts +3 -3
- package/types/Activity.js +1 -2
- package/types/Api.d.ts +1 -1
- package/types/Api.js +1 -2
- package/types/Apps.js +1 -2
- package/types/Archive.js +1 -2
- package/types/Build.d.ts +4 -5
- package/types/Build.js +1 -2
- package/types/CLIOptions.js +1 -2
- package/types/ComponentStructure.d.ts +2 -2
- package/types/ComponentStructure.js +1 -2
- package/types/Config.d.ts +4 -6
- package/types/Config.js +1 -2
- package/types/Crm.js +1 -2
- package/types/Deploy.d.ts +5 -11
- package/types/Deploy.js +1 -2
- package/types/DesignManager.js +1 -2
- package/types/DevSecrets.js +1 -2
- package/types/Error.js +1 -2
- package/types/FieldsJS.js +1 -2
- package/types/FileManager.js +1 -2
- package/types/Files.d.ts +4 -4
- package/types/Files.js +1 -2
- package/types/FireAlarm.js +1 -2
- package/types/Functions.js +1 -2
- package/types/Github.d.ts +1 -1
- package/types/Github.js +1 -2
- package/types/Http.d.ts +0 -4
- package/types/Http.js +1 -2
- package/types/Hubdb.js +1 -2
- package/types/HublValidation.js +1 -2
- package/types/Lang.d.ts +1 -1
- package/types/Lang.js +1 -2
- package/types/Lighthouse.js +1 -2
- package/types/MarketplaceValidation.js +1 -2
- package/types/Migration.d.ts +2 -2
- package/types/Migration.js +1 -4
- package/types/Modules.js +1 -2
- package/types/PortManager.js +1 -2
- package/types/Project.d.ts +3 -21
- package/types/Project.js +1 -2
- package/types/ProjectComponents.d.ts +24 -0
- package/types/ProjectComponents.js +1 -0
- package/types/ProjectLog.js +1 -2
- package/types/Sandbox.js +2 -5
- package/types/Schemas.js +1 -2
- package/types/Secrets.js +1 -2
- package/types/Utils.js +1 -2
- package/types/developerTestAccounts.js +1 -2
- package/utils/PortManagerServer.d.ts +1 -2
- package/utils/PortManagerServer.js +32 -38
- package/utils/cms/fieldsJS.d.ts +1 -1
- package/utils/cms/fieldsJS.js +1 -5
- package/utils/cms/modules.d.ts +1 -1
- package/utils/cms/modules.js +13 -22
- package/utils/detectPort.js +12 -19
- package/utils/git.js +17 -26
- package/utils/lang.d.ts +1 -1
- package/utils/lang.js +5 -14
- package/utils/personalAccessKey.d.ts +8 -0
- package/utils/personalAccessKey.js +51 -0
- package/errors/errors_DEPRECATED.d.ts +0 -3
- package/errors/errors_DEPRECATED.js +0 -60
package/api/fileMapper.js
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const content_disposition_1 = __importDefault(require("content-disposition"));
|
|
10
|
-
const http_1 = require("../http");
|
|
11
|
-
const path_2 = require("../lib/path");
|
|
12
|
-
exports.FILE_MAPPER_API_PATH = 'content/filemapper/v1';
|
|
13
|
-
function createFileMapperNodeFromStreamResponse(filePath, response) {
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import contentDisposition from 'content-disposition';
|
|
4
|
+
import { http } from '../http/index.js';
|
|
5
|
+
import { getCwd } from '../lib/path.js';
|
|
6
|
+
import { FILE_MAPPER_API_PATH } from '../constants/endpoints.js';
|
|
7
|
+
export function createFileMapperNodeFromStreamResponse(filePath, response) {
|
|
14
8
|
if (filePath[0] !== '/') {
|
|
15
9
|
filePath = `/${filePath}`;
|
|
16
10
|
}
|
|
@@ -20,7 +14,7 @@ function createFileMapperNodeFromStreamResponse(filePath, response) {
|
|
|
20
14
|
const node = {
|
|
21
15
|
source: null,
|
|
22
16
|
path: filePath,
|
|
23
|
-
name:
|
|
17
|
+
name: path.basename(filePath),
|
|
24
18
|
folder: false,
|
|
25
19
|
children: [],
|
|
26
20
|
createdAt: 0,
|
|
@@ -29,7 +23,7 @@ function createFileMapperNodeFromStreamResponse(filePath, response) {
|
|
|
29
23
|
if (!(response.headers && response.headers['content-disposition'])) {
|
|
30
24
|
return node;
|
|
31
25
|
}
|
|
32
|
-
const { parameters } =
|
|
26
|
+
const { parameters } = contentDisposition.parse(response.headers['content-disposition']);
|
|
33
27
|
return {
|
|
34
28
|
...node,
|
|
35
29
|
name: parameters.filename,
|
|
@@ -37,70 +31,61 @@ function createFileMapperNodeFromStreamResponse(filePath, response) {
|
|
|
37
31
|
updatedAt: parseInt(parameters['modification-date'], 10) || 0,
|
|
38
32
|
};
|
|
39
33
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
url: `${exports.FILE_MAPPER_API_PATH}/upload/${encodeURIComponent(dest)}`,
|
|
34
|
+
export function upload(accountId, src, dest, options = {}) {
|
|
35
|
+
return http.post(accountId, {
|
|
36
|
+
url: `${FILE_MAPPER_API_PATH}/upload/${encodeURIComponent(dest)}`,
|
|
44
37
|
data: {
|
|
45
|
-
file:
|
|
38
|
+
file: fs.createReadStream(path.resolve(getCwd(), src)),
|
|
46
39
|
},
|
|
47
40
|
headers: { 'Content-Type': 'multipart/form-data' },
|
|
48
41
|
...options,
|
|
49
42
|
});
|
|
50
43
|
}
|
|
51
|
-
exports.upload = upload;
|
|
52
44
|
// Fetch a module by moduleId
|
|
53
|
-
function fetchModule(accountId, moduleId, options = {}) {
|
|
54
|
-
return
|
|
55
|
-
url: `${
|
|
45
|
+
export function fetchModule(accountId, moduleId, options = {}) {
|
|
46
|
+
return http.get(accountId, {
|
|
47
|
+
url: `${FILE_MAPPER_API_PATH}/modules/${moduleId}`,
|
|
56
48
|
...options,
|
|
57
49
|
});
|
|
58
50
|
}
|
|
59
|
-
exports.fetchModule = fetchModule;
|
|
60
51
|
// Fetch a file by file path.
|
|
61
|
-
async function fetchFileStream(accountId, filePath, destination, options = {}) {
|
|
62
|
-
const response = await
|
|
63
|
-
url: `${
|
|
52
|
+
export async function fetchFileStream(accountId, filePath, destination, options = {}) {
|
|
53
|
+
const response = await http.getOctetStream(accountId, {
|
|
54
|
+
url: `${FILE_MAPPER_API_PATH}/stream/${encodeURIComponent(filePath)}`,
|
|
64
55
|
...options,
|
|
65
56
|
}, destination);
|
|
66
57
|
return createFileMapperNodeFromStreamResponse(filePath, response);
|
|
67
58
|
}
|
|
68
|
-
exports.fetchFileStream = fetchFileStream;
|
|
69
59
|
// Fetch a folder or file node by path.
|
|
70
|
-
function download(accountId, filepath, options = {}) {
|
|
71
|
-
return
|
|
72
|
-
url: `${
|
|
60
|
+
export function download(accountId, filepath, options = {}) {
|
|
61
|
+
return http.get(accountId, {
|
|
62
|
+
url: `${FILE_MAPPER_API_PATH}/download/${encodeURIComponent(filepath)}`,
|
|
73
63
|
...options,
|
|
74
64
|
});
|
|
75
65
|
}
|
|
76
|
-
exports.download = download;
|
|
77
66
|
// Fetch a folder or file node by path.
|
|
78
|
-
function downloadDefault(accountId, filepath, options = {}) {
|
|
79
|
-
return
|
|
80
|
-
url: `${
|
|
67
|
+
export function downloadDefault(accountId, filepath, options = {}) {
|
|
68
|
+
return http.get(accountId, {
|
|
69
|
+
url: `${FILE_MAPPER_API_PATH}/download-default/${filepath}`,
|
|
81
70
|
...options,
|
|
82
71
|
});
|
|
83
72
|
}
|
|
84
|
-
exports.downloadDefault = downloadDefault;
|
|
85
73
|
// Delete a file or folder by path
|
|
86
|
-
function deleteFile(accountId, filePath) {
|
|
87
|
-
return
|
|
88
|
-
url: `${
|
|
74
|
+
export function deleteFile(accountId, filePath) {
|
|
75
|
+
return http.delete(accountId, {
|
|
76
|
+
url: `${FILE_MAPPER_API_PATH}/delete/${encodeURIComponent(filePath)}`,
|
|
89
77
|
});
|
|
90
78
|
}
|
|
91
|
-
exports.deleteFile = deleteFile;
|
|
92
79
|
// Moves file from srcPath to destPath
|
|
93
|
-
function moveFile(accountId, srcPath, destPath) {
|
|
94
|
-
return
|
|
95
|
-
url: `${
|
|
80
|
+
export function moveFile(accountId, srcPath, destPath) {
|
|
81
|
+
return http.put(accountId, {
|
|
82
|
+
url: `${FILE_MAPPER_API_PATH}/rename/${srcPath}?path=${destPath}`,
|
|
96
83
|
headers: { 'Content-Type': 'application/json' },
|
|
97
84
|
});
|
|
98
85
|
}
|
|
99
|
-
exports.moveFile = moveFile;
|
|
100
86
|
// Get directory contents
|
|
101
|
-
function getDirectoryContentsByPath(accountId, path) {
|
|
102
|
-
return
|
|
103
|
-
url: `${
|
|
87
|
+
export function getDirectoryContentsByPath(accountId, path) {
|
|
88
|
+
return http.get(accountId, {
|
|
89
|
+
url: `${FILE_MAPPER_API_PATH}/meta/${path}`,
|
|
104
90
|
});
|
|
105
91
|
}
|
|
106
|
-
exports.getDirectoryContentsByPath = getDirectoryContentsByPath;
|
package/api/fileTransport.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HubSpotPromise } from '../types/Http';
|
|
1
|
+
import { HubSpotPromise } from '../types/Http.js';
|
|
2
2
|
export declare function createSchemaFromHubFile(accountId: number, filepath: string): HubSpotPromise;
|
|
3
3
|
export declare function updateSchemaFromHubFile(accountId: number, filepath: string): HubSpotPromise;
|
|
4
4
|
export declare function fetchHubFileSchema(accountId: number, objectName: string, path: string): HubSpotPromise;
|
package/api/fileTransport.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.fetchHubFileSchema = exports.updateSchemaFromHubFile = exports.createSchemaFromHubFile = void 0;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const path_2 = require("../lib/path");
|
|
10
|
-
const http_1 = require("../http");
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { getCwd } from '../lib/path.js';
|
|
4
|
+
import { http } from '../http/index.js';
|
|
11
5
|
const HUBFILES_API_PATH = '/file-transport/v1/hubfiles';
|
|
12
|
-
function createSchemaFromHubFile(accountId, filepath) {
|
|
13
|
-
const file =
|
|
14
|
-
return
|
|
6
|
+
export function createSchemaFromHubFile(accountId, filepath) {
|
|
7
|
+
const file = fs.createReadStream(path.resolve(getCwd(), filepath));
|
|
8
|
+
return http.post(accountId, {
|
|
15
9
|
url: `${HUBFILES_API_PATH}/object-schemas`,
|
|
16
10
|
data: {
|
|
17
11
|
file,
|
|
@@ -19,10 +13,9 @@ function createSchemaFromHubFile(accountId, filepath) {
|
|
|
19
13
|
headers: { 'Content-Type': 'multipart/form-data' },
|
|
20
14
|
});
|
|
21
15
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return http_1.http.put(accountId, {
|
|
16
|
+
export async function updateSchemaFromHubFile(accountId, filepath) {
|
|
17
|
+
const file = fs.createReadStream(path.resolve(getCwd(), filepath));
|
|
18
|
+
return http.put(accountId, {
|
|
26
19
|
url: `${HUBFILES_API_PATH}/object-schemas`,
|
|
27
20
|
data: {
|
|
28
21
|
file,
|
|
@@ -30,10 +23,8 @@ async function updateSchemaFromHubFile(accountId, filepath) {
|
|
|
30
23
|
headers: { 'Content-Type': 'multipart/form-data' },
|
|
31
24
|
});
|
|
32
25
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return http_1.http.getOctetStream(accountId, {
|
|
26
|
+
export async function fetchHubFileSchema(accountId, objectName, path) {
|
|
27
|
+
return http.getOctetStream(accountId, {
|
|
36
28
|
url: `${HUBFILES_API_PATH}/object-schemas/${objectName}`,
|
|
37
29
|
}, path);
|
|
38
30
|
}
|
|
39
|
-
exports.fetchHubFileSchema = fetchHubFileSchema;
|
package/api/fireAlarm.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { FireAlarm } from '../types/FireAlarm';
|
|
2
|
-
import { HubSpotPromise } from '../types/Http';
|
|
3
|
-
export declare const FIREALARM_API_AUTH_PATH = "firealarm/v4/alarm";
|
|
1
|
+
import { FireAlarm } from '../types/FireAlarm.js';
|
|
2
|
+
import { HubSpotPromise } from '../types/Http.js';
|
|
4
3
|
export declare function fetchFireAlarms(accountId: number): HubSpotPromise<Array<FireAlarm>>;
|
package/api/fireAlarm.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function fetchFireAlarms(accountId) {
|
|
7
|
-
return http_1.http.get(accountId, {
|
|
8
|
-
url: `${exports.FIREALARM_API_AUTH_PATH}/hubspot-cli/${accountId}`,
|
|
1
|
+
import { http } from '../http/index.js';
|
|
2
|
+
import { FIREALARM_API_AUTH_PATH } from '../constants/endpoints.js';
|
|
3
|
+
export function fetchFireAlarms(accountId) {
|
|
4
|
+
return http.get(accountId, {
|
|
5
|
+
url: `${FIREALARM_API_AUTH_PATH}/hubspot-cli/${accountId}`,
|
|
9
6
|
});
|
|
10
7
|
}
|
|
11
|
-
exports.fetchFireAlarms = fetchFireAlarms;
|
package/api/functions.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HubSpotPromise, QueryParams } from '../types/Http';
|
|
2
|
-
import { GetBuildStatusResponse, FunctionLog, GetRoutesResponse, GetFunctionLogsResponse } from '../types/Functions';
|
|
1
|
+
import { HubSpotPromise, QueryParams } from '../types/Http.js';
|
|
2
|
+
import { GetBuildStatusResponse, FunctionLog, GetRoutesResponse, GetFunctionLogsResponse } from '../types/Functions.js';
|
|
3
3
|
export declare function getRoutes(accountId: number): HubSpotPromise<GetRoutesResponse>;
|
|
4
4
|
export declare function getFunctionLogs(accountId: number, route: string, params?: QueryParams): HubSpotPromise<GetFunctionLogsResponse>;
|
|
5
5
|
export declare function getLatestFunctionLog(accountId: number, route: string): HubSpotPromise<FunctionLog>;
|
package/api/functions.js
CHANGED
|
@@ -1,30 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getBuildStatus = exports.buildPackage = exports.getLatestFunctionLog = exports.getFunctionLogs = exports.getRoutes = void 0;
|
|
4
|
-
const http_1 = require("../http");
|
|
1
|
+
import { http } from '../http/index.js';
|
|
5
2
|
const FUNCTION_API_PATH = 'cms/v3/functions';
|
|
6
|
-
function getRoutes(accountId) {
|
|
7
|
-
return
|
|
3
|
+
export function getRoutes(accountId) {
|
|
4
|
+
return http.get(accountId, {
|
|
8
5
|
url: `${FUNCTION_API_PATH}/routes`,
|
|
9
6
|
});
|
|
10
7
|
}
|
|
11
|
-
|
|
12
|
-
function getFunctionLogs(accountId, route, params = {}) {
|
|
8
|
+
export function getFunctionLogs(accountId, route, params = {}) {
|
|
13
9
|
const { limit = 5 } = params;
|
|
14
|
-
return
|
|
10
|
+
return http.get(accountId, {
|
|
15
11
|
url: `${FUNCTION_API_PATH}/results/by-route/${encodeURIComponent(route)}`,
|
|
16
12
|
params: { ...params, limit },
|
|
17
13
|
});
|
|
18
14
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return http_1.http.get(accountId, {
|
|
15
|
+
export function getLatestFunctionLog(accountId, route) {
|
|
16
|
+
return http.get(accountId, {
|
|
22
17
|
url: `${FUNCTION_API_PATH}/results/by-route/${encodeURIComponent(route)}/latest`,
|
|
23
18
|
});
|
|
24
19
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return http_1.http.post(accountId, {
|
|
20
|
+
export function buildPackage(accountId, folderPath) {
|
|
21
|
+
return http.post(accountId, {
|
|
28
22
|
url: `${FUNCTION_API_PATH}/build/async`,
|
|
29
23
|
headers: {
|
|
30
24
|
Accept: 'text/plain',
|
|
@@ -34,10 +28,8 @@ function buildPackage(accountId, folderPath) {
|
|
|
34
28
|
},
|
|
35
29
|
});
|
|
36
30
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return http_1.http.get(accountId, {
|
|
31
|
+
export function getBuildStatus(accountId, buildId) {
|
|
32
|
+
return http.get(accountId, {
|
|
40
33
|
url: `${FUNCTION_API_PATH}/build/${buildId}/poll`,
|
|
41
34
|
});
|
|
42
35
|
}
|
|
43
|
-
exports.getBuildStatus = getBuildStatus;
|
package/api/github.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { GithubReleaseData, GithubRepoFile, RepoPath } from '../types/Github';
|
|
4
|
-
import { HubSpotPromise } from '../types/Http';
|
|
1
|
+
import { GithubReleaseData, GithubRepoFile, RepoPath } from '../types/Github.js';
|
|
2
|
+
import { HubSpotPromise } from '../types/Http.js';
|
|
5
3
|
declare global {
|
|
6
4
|
var githubToken: string;
|
|
7
5
|
}
|
package/api/github.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.fetchRepoContents = exports.fetchRepoFileByDownloadUrl = exports.fetchRepoFile = exports.fetchRepoAsZip = exports.fetchRepoReleaseData = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const getAxiosConfig_1 = require("../http/getAxiosConfig");
|
|
9
|
-
const errors_1 = require("../errors");
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { getDefaultUserAgentHeader } from '../http/getAxiosConfig.js';
|
|
3
|
+
import { isSpecifiedError } from '../errors/index.js';
|
|
10
4
|
const GITHUB_REPOS_API = 'https://api.github.com/repos';
|
|
11
5
|
const GITHUB_RAW_CONTENT_API_PATH = 'https://raw.githubusercontent.com';
|
|
12
6
|
function getAdditionalHeaders() {
|
|
@@ -21,17 +15,17 @@ function getAdditionalHeaders() {
|
|
|
21
15
|
}
|
|
22
16
|
function githubRequestWithFallback(url, responseType) {
|
|
23
17
|
const headersWithAuth = {
|
|
24
|
-
...
|
|
18
|
+
...getDefaultUserAgentHeader(),
|
|
25
19
|
...getAdditionalHeaders(),
|
|
26
20
|
};
|
|
27
21
|
if (headersWithAuth.authorization) {
|
|
28
|
-
return
|
|
22
|
+
return axios
|
|
29
23
|
.get(url, { headers: headersWithAuth, responseType })
|
|
30
24
|
.catch(error => {
|
|
31
25
|
// 404 with an auth token might mean an SSO issue so retry without the authorization header
|
|
32
|
-
if (
|
|
33
|
-
return
|
|
34
|
-
headers: { ...
|
|
26
|
+
if (isSpecifiedError(error, { statusCode: 404 })) {
|
|
27
|
+
return axios.get(url, {
|
|
28
|
+
headers: { ...getDefaultUserAgentHeader() },
|
|
35
29
|
responseType,
|
|
36
30
|
});
|
|
37
31
|
}
|
|
@@ -39,39 +33,34 @@ function githubRequestWithFallback(url, responseType) {
|
|
|
39
33
|
});
|
|
40
34
|
}
|
|
41
35
|
// No auth token, proceed normally
|
|
42
|
-
return
|
|
36
|
+
return axios.get(url, { headers: headersWithAuth, responseType });
|
|
43
37
|
}
|
|
44
38
|
// Returns information about the repo's releases. Defaults to "latest" if no tag is provided
|
|
45
39
|
// https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#get-a-release-by-tag-name
|
|
46
|
-
function fetchRepoReleaseData(repoPath, tag = '') {
|
|
40
|
+
export function fetchRepoReleaseData(repoPath, tag = '') {
|
|
47
41
|
const URL = `${GITHUB_REPOS_API}/${repoPath}/releases`;
|
|
48
42
|
return githubRequestWithFallback(`${URL}/${tag ? `tags/${tag}` : 'latest'}`);
|
|
49
43
|
}
|
|
50
|
-
exports.fetchRepoReleaseData = fetchRepoReleaseData;
|
|
51
44
|
// Returns the entire repo content as a zip, using the zipball_url from fetchRepoReleaseData()
|
|
52
45
|
// https://docs.github.com/en/rest/repos/contents?apiVersion=2022-11-28#download-a-repository-archive-zip
|
|
53
|
-
function fetchRepoAsZip(zipUrl) {
|
|
54
|
-
return
|
|
46
|
+
export function fetchRepoAsZip(zipUrl) {
|
|
47
|
+
return axios.get(zipUrl, {
|
|
55
48
|
responseType: 'arraybuffer',
|
|
56
|
-
headers: { ...
|
|
49
|
+
headers: { ...getDefaultUserAgentHeader(), ...getAdditionalHeaders() },
|
|
57
50
|
});
|
|
58
51
|
}
|
|
59
|
-
exports.fetchRepoAsZip = fetchRepoAsZip;
|
|
60
52
|
// Returns the raw file contents via the raw.githubusercontent endpoint
|
|
61
|
-
function fetchRepoFile(repoPath, filePath, ref) {
|
|
53
|
+
export function fetchRepoFile(repoPath, filePath, ref) {
|
|
62
54
|
const url = `${GITHUB_RAW_CONTENT_API_PATH}/${repoPath}/${ref}/${filePath}`;
|
|
63
55
|
return githubRequestWithFallback(url);
|
|
64
56
|
}
|
|
65
|
-
exports.fetchRepoFile = fetchRepoFile;
|
|
66
57
|
// Returns the raw file contents via the raw.githubusercontent endpoint
|
|
67
|
-
function fetchRepoFileByDownloadUrl(downloadUrl) {
|
|
58
|
+
export function fetchRepoFileByDownloadUrl(downloadUrl) {
|
|
68
59
|
return githubRequestWithFallback(downloadUrl, 'arraybuffer');
|
|
69
60
|
}
|
|
70
|
-
exports.fetchRepoFileByDownloadUrl = fetchRepoFileByDownloadUrl;
|
|
71
61
|
// Returns the contents of a file or directory in a repository by path
|
|
72
62
|
// https://docs.github.com/en/rest/repos/contents?apiVersion=2022-11-28#get-repository-content
|
|
73
|
-
function fetchRepoContents(repoPath, path, ref) {
|
|
63
|
+
export function fetchRepoContents(repoPath, path, ref) {
|
|
74
64
|
const refQuery = ref ? `?ref=${ref}` : '';
|
|
75
65
|
return githubRequestWithFallback(`${GITHUB_REPOS_API}/${repoPath}/contents/${path}${refQuery}`);
|
|
76
66
|
}
|
|
77
|
-
exports.fetchRepoContents = fetchRepoContents;
|
package/api/hubdb.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HubSpotPromise, QueryParams } from '../types/Http';
|
|
2
|
-
import { CreateRowsResponse, FetchRowsResponse, Row, Schema, Table, FetchTablesResponse } from '../types/Hubdb';
|
|
1
|
+
import { HubSpotPromise, QueryParams } from '../types/Http.js';
|
|
2
|
+
import { CreateRowsResponse, FetchRowsResponse, Row, Schema, Table, FetchTablesResponse } from '../types/Hubdb.js';
|
|
3
3
|
export declare function fetchTables(accountId: number): HubSpotPromise<FetchTablesResponse>;
|
|
4
4
|
export declare function fetchTable(accountId: number, tableId: string): HubSpotPromise<Table>;
|
|
5
5
|
export declare function createTable(accountId: number, schema: Schema): HubSpotPromise<Table>;
|
package/api/hubdb.js
CHANGED
|
@@ -1,67 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deleteRows = exports.fetchRows = exports.createRows = exports.deleteTable = exports.publishTable = exports.updateTable = exports.createTable = exports.fetchTable = exports.fetchTables = void 0;
|
|
4
|
-
const http_1 = require("../http");
|
|
1
|
+
import { http } from '../http/index.js';
|
|
5
2
|
const HUBDB_API_PATH = 'cms/v3/hubdb';
|
|
6
|
-
function fetchTables(accountId) {
|
|
7
|
-
return
|
|
3
|
+
export function fetchTables(accountId) {
|
|
4
|
+
return http.get(accountId, {
|
|
8
5
|
url: `${HUBDB_API_PATH}/tables`,
|
|
9
6
|
});
|
|
10
7
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return http_1.http.get(accountId, {
|
|
8
|
+
export function fetchTable(accountId, tableId) {
|
|
9
|
+
return http.get(accountId, {
|
|
14
10
|
url: `${HUBDB_API_PATH}/tables/${tableId}`,
|
|
15
11
|
});
|
|
16
12
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return http_1.http.post(accountId, {
|
|
13
|
+
export function createTable(accountId, schema) {
|
|
14
|
+
return http.post(accountId, {
|
|
20
15
|
url: `${HUBDB_API_PATH}/tables`,
|
|
21
16
|
data: schema,
|
|
22
17
|
});
|
|
23
18
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return http_1.http.patch(accountId, {
|
|
19
|
+
export function updateTable(accountId, tableId, schema) {
|
|
20
|
+
return http.patch(accountId, {
|
|
27
21
|
url: `${HUBDB_API_PATH}/tables/${tableId}/draft`,
|
|
28
22
|
data: schema,
|
|
29
23
|
});
|
|
30
24
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return http_1.http.post(accountId, {
|
|
25
|
+
export function publishTable(accountId, tableId) {
|
|
26
|
+
return http.post(accountId, {
|
|
34
27
|
url: `${HUBDB_API_PATH}/tables/${tableId}/draft/publish`,
|
|
35
28
|
headers: {
|
|
36
29
|
'Content-Type': 'application/json',
|
|
37
30
|
},
|
|
38
31
|
});
|
|
39
32
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return http_1.http.delete(accountId, {
|
|
33
|
+
export function deleteTable(accountId, tableId) {
|
|
34
|
+
return http.delete(accountId, {
|
|
43
35
|
url: `${HUBDB_API_PATH}/tables/${tableId}`,
|
|
44
36
|
});
|
|
45
37
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return http_1.http.post(accountId, {
|
|
38
|
+
export function createRows(accountId, tableId, rows) {
|
|
39
|
+
return http.post(accountId, {
|
|
49
40
|
url: `${HUBDB_API_PATH}/tables/${tableId}/rows/draft/batch/create`,
|
|
50
41
|
data: { inputs: rows },
|
|
51
42
|
});
|
|
52
43
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return http_1.http.get(accountId, {
|
|
44
|
+
export function fetchRows(accountId, tableId, params = {}) {
|
|
45
|
+
return http.get(accountId, {
|
|
56
46
|
url: `${HUBDB_API_PATH}/tables/${tableId}/rows/draft`,
|
|
57
47
|
params,
|
|
58
48
|
});
|
|
59
49
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return http_1.http.post(accountId, {
|
|
50
|
+
export function deleteRows(accountId, tableId, rowIds) {
|
|
51
|
+
return http.post(accountId, {
|
|
63
52
|
url: `${HUBDB_API_PATH}/tables/${tableId}/rows/draft/batch/purge`,
|
|
64
53
|
data: { inputs: rowIds },
|
|
65
54
|
});
|
|
66
55
|
}
|
|
67
|
-
exports.deleteRows = deleteRows;
|
package/api/lighthouseScore.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Data, HubSpotPromise, QueryParams } from '../types/Http';
|
|
2
|
-
import { GetLighthouseScoreResponse, RequestLighthouseScoreResponse } from '../types/Lighthouse';
|
|
1
|
+
import { Data, HubSpotPromise, QueryParams } from '../types/Http.js';
|
|
2
|
+
import { GetLighthouseScoreResponse, RequestLighthouseScoreResponse } from '../types/Lighthouse.js';
|
|
3
3
|
export declare function requestLighthouseScore(accountId: number, data?: Data): HubSpotPromise<RequestLighthouseScoreResponse>;
|
|
4
4
|
export declare function getLighthouseScoreStatus(accountId: number, params?: QueryParams): HubSpotPromise<string>;
|
|
5
5
|
export declare function getLighthouseScore(accountId: number, params?: QueryParams): HubSpotPromise<GetLighthouseScoreResponse>;
|
package/api/lighthouseScore.js
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getLighthouseScore = exports.getLighthouseScoreStatus = exports.requestLighthouseScore = void 0;
|
|
4
|
-
const http_1 = require("../http");
|
|
1
|
+
import { http } from '../http/index.js';
|
|
5
2
|
const LIGHTHOUSE_SCORE_API_BASE = 'quality-engine/v1/lighthouse';
|
|
6
|
-
function requestLighthouseScore(accountId, data = {}) {
|
|
7
|
-
return
|
|
3
|
+
export function requestLighthouseScore(accountId, data = {}) {
|
|
4
|
+
return http.post(accountId, {
|
|
8
5
|
url: `${LIGHTHOUSE_SCORE_API_BASE}/request`,
|
|
9
6
|
data,
|
|
10
7
|
});
|
|
11
8
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return http_1.http.get(accountId, {
|
|
9
|
+
export function getLighthouseScoreStatus(accountId, params = {}) {
|
|
10
|
+
return http.get(accountId, {
|
|
15
11
|
url: `${LIGHTHOUSE_SCORE_API_BASE}/status`,
|
|
16
12
|
params,
|
|
17
13
|
});
|
|
18
14
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return http_1.http.get(accountId, {
|
|
15
|
+
export function getLighthouseScore(accountId, params = {}) {
|
|
16
|
+
return http.get(accountId, {
|
|
22
17
|
url: `${LIGHTHOUSE_SCORE_API_BASE}/scores`,
|
|
23
18
|
params,
|
|
24
19
|
});
|
|
25
20
|
}
|
|
26
|
-
exports.getLighthouseScore = getLighthouseScore;
|
package/api/localDevAuth.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { HubSpotPromise } from '../types/Http';
|
|
5
|
-
export declare const LOCALDEVAUTH_ACCESS_TOKEN_PATH: string;
|
|
6
|
-
export declare function fetchAccessToken(personalAccessKey: string, env?: Environment, portalId?: number): HubSpotPromise<AccessTokenResponse>;
|
|
1
|
+
import { ScopeData, EnabledFeaturesResponse, ScopeAuthorizationResponse } from '../types/Accounts.js';
|
|
2
|
+
import { PublicAppInstallationData } from '../types/Apps.js';
|
|
3
|
+
import { HubSpotPromise } from '../types/Http.js';
|
|
7
4
|
export declare function fetchScopeData(accountId: number, scopeGroup: string): HubSpotPromise<ScopeData>;
|
|
8
5
|
export declare function fetchScopeAuthorizationData(accountId: number): HubSpotPromise<ScopeAuthorizationResponse>;
|
|
9
6
|
export declare function fetchAppInstallationData(portalId: number, projectId: number, appUid: string, requiredScopeGroups: Array<string>, optionalScopeGroups?: Array<string>): HubSpotPromise<PublicAppInstallationData>;
|
package/api/localDevAuth.js
CHANGED
|
@@ -1,43 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const http_1 = require("../http");
|
|
6
|
-
const environments_1 = require("../constants/environments");
|
|
7
|
-
const client_1 = require("../http/client");
|
|
8
|
-
const LOCALDEVAUTH_API_AUTH_PATH = 'localdevauth/v1/auth';
|
|
9
|
-
exports.LOCALDEVAUTH_ACCESS_TOKEN_PATH = `${LOCALDEVAUTH_API_AUTH_PATH}/refresh`;
|
|
10
|
-
function fetchAccessToken(personalAccessKey, env = environments_1.ENVIRONMENTS.PROD, portalId) {
|
|
11
|
-
const axiosConfig = (0, getAxiosConfig_1.getAxiosConfig)({
|
|
12
|
-
env,
|
|
13
|
-
localHostOverride: true,
|
|
14
|
-
url: exports.LOCALDEVAUTH_ACCESS_TOKEN_PATH,
|
|
15
|
-
data: {
|
|
16
|
-
encodedOAuthRefreshToken: personalAccessKey,
|
|
17
|
-
},
|
|
18
|
-
params: portalId ? { portalId } : {},
|
|
19
|
-
});
|
|
20
|
-
return (0, client_1.httpClient)({
|
|
21
|
-
...axiosConfig,
|
|
22
|
-
method: 'post',
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
exports.fetchAccessToken = fetchAccessToken;
|
|
26
|
-
function fetchScopeData(accountId, scopeGroup) {
|
|
27
|
-
return http_1.http.get(accountId, {
|
|
1
|
+
import { http } from '../http/index.js';
|
|
2
|
+
import { LOCALDEVAUTH_API_AUTH_PATH } from '../constants/endpoints.js';
|
|
3
|
+
export function fetchScopeData(accountId, scopeGroup) {
|
|
4
|
+
return http.get(accountId, {
|
|
28
5
|
url: `${LOCALDEVAUTH_API_AUTH_PATH}/check-scopes`,
|
|
29
6
|
params: { scopeGroup },
|
|
30
7
|
});
|
|
31
8
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return http_1.http.get(accountId, {
|
|
9
|
+
export async function fetchScopeAuthorizationData(accountId) {
|
|
10
|
+
return http.get(accountId, {
|
|
35
11
|
url: `${LOCALDEVAUTH_API_AUTH_PATH}/scope-groups/authorized`,
|
|
36
12
|
});
|
|
37
13
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return http_1.http.post(portalId, {
|
|
14
|
+
export function fetchAppInstallationData(portalId, projectId, appUid, requiredScopeGroups, optionalScopeGroups = []) {
|
|
15
|
+
return http.post(portalId, {
|
|
41
16
|
url: `${LOCALDEVAUTH_API_AUTH_PATH}/install-info`,
|
|
42
17
|
data: {
|
|
43
18
|
portalId,
|
|
@@ -48,10 +23,8 @@ function fetchAppInstallationData(portalId, projectId, appUid, requiredScopeGrou
|
|
|
48
23
|
},
|
|
49
24
|
});
|
|
50
25
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return http_1.http.get(accountId, {
|
|
26
|
+
export async function fetchEnabledFeatures(accountId) {
|
|
27
|
+
return http.get(accountId, {
|
|
54
28
|
url: `${LOCALDEVAUTH_API_AUTH_PATH}/enabled-features`,
|
|
55
29
|
});
|
|
56
30
|
}
|
|
57
|
-
exports.fetchEnabledFeatures = fetchEnabledFeatures;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Data, HubSpotPromise, QueryParams } from '../types/Http';
|
|
2
|
-
import { GetValidationResultsResponse } from '../types/MarketplaceValidation';
|
|
1
|
+
import { Data, HubSpotPromise, QueryParams } from '../types/Http.js';
|
|
2
|
+
import { GetValidationResultsResponse } from '../types/MarketplaceValidation.js';
|
|
3
3
|
export declare function requestValidation(accountId: number, data?: Data): HubSpotPromise<number>;
|
|
4
4
|
export declare function getValidationStatus(accountId: number, params?: QueryParams): HubSpotPromise<string>;
|
|
5
5
|
export declare function getValidationResults(accountId: number, params?: QueryParams): HubSpotPromise<GetValidationResultsResponse>;
|