@hubspot/local-dev-lib 3.19.2 → 3.19.3-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 +1 -0
- package/api/appsDev.js +10 -1
- package/api/github.js +28 -22
- package/api/localDevAuth.d.ts +1 -1
- package/config/config_DEPRECATED.js +2 -4
- package/lib/hubdb.d.ts +1 -1
- package/package.json +1 -1
package/api/appsDev.d.ts
CHANGED
|
@@ -5,3 +5,4 @@ export declare function fetchPublicAppDeveloperTestAccountInstallData(appId: num
|
|
|
5
5
|
export declare function fetchPublicAppProductionInstallCounts(appId: number, accountId: number): HubSpotPromise<PublicAppInstallCounts>;
|
|
6
6
|
export declare function fetchPublicAppMetadata(appId: number, accountId: number): HubSpotPromise<PublicApp>;
|
|
7
7
|
export declare function installStaticAuthAppOnTestAccount(appId: number, accountId: number, scopeGroupIds: number[]): HubSpotPromise<void>;
|
|
8
|
+
export declare function fetchAppMetadataByUid(appUid: string, accountId: number): HubSpotPromise<PublicApp>;
|
package/api/appsDev.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.installStaticAuthAppOnTestAccount = exports.fetchPublicAppMetadata = exports.fetchPublicAppProductionInstallCounts = exports.fetchPublicAppDeveloperTestAccountInstallData = exports.fetchPublicAppsForPortal = void 0;
|
|
3
|
+
exports.fetchAppMetadataByUid = exports.installStaticAuthAppOnTestAccount = exports.fetchPublicAppMetadata = exports.fetchPublicAppProductionInstallCounts = exports.fetchPublicAppDeveloperTestAccountInstallData = exports.fetchPublicAppsForPortal = void 0;
|
|
4
4
|
const http_1 = require("../http");
|
|
5
5
|
const APPS_DEV_API_PATH = 'apps-dev/external/public/v3';
|
|
6
6
|
const APPS_HUBLETS_API_PATH = 'apps-hublets/external/static-token/v3';
|
|
@@ -39,3 +39,12 @@ function installStaticAuthAppOnTestAccount(appId, accountId, scopeGroupIds) {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
exports.installStaticAuthAppOnTestAccount = installStaticAuthAppOnTestAccount;
|
|
42
|
+
function fetchAppMetadataByUid(appUid, accountId) {
|
|
43
|
+
return http_1.http.get(accountId, {
|
|
44
|
+
url: `${APPS_DEV_API_PATH}/full/portal/sourceId`,
|
|
45
|
+
params: {
|
|
46
|
+
sourceId: appUid,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
exports.fetchAppMetadataByUid = fetchAppMetadataByUid;
|
package/api/github.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.fetchRepoContents = exports.fetchRepoFileByDownloadUrl = exports.fetchRepoFile = exports.fetchRepoAsZip = exports.fetchRepoReleaseData = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const getAxiosConfig_1 = require("../http/getAxiosConfig");
|
|
9
|
+
const errors_1 = require("../errors");
|
|
9
10
|
const GITHUB_REPOS_API = 'https://api.github.com/repos';
|
|
10
11
|
const GITHUB_RAW_CONTENT_API_PATH = 'https://raw.githubusercontent.com';
|
|
11
12
|
function getAdditionalHeaders() {
|
|
@@ -18,16 +19,33 @@ function getAdditionalHeaders() {
|
|
|
18
19
|
}
|
|
19
20
|
return headers;
|
|
20
21
|
}
|
|
22
|
+
function githubRequestWithFallback(url, responseType) {
|
|
23
|
+
const headersWithAuth = {
|
|
24
|
+
...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(),
|
|
25
|
+
...getAdditionalHeaders(),
|
|
26
|
+
};
|
|
27
|
+
if (headersWithAuth.authorization) {
|
|
28
|
+
return axios_1.default
|
|
29
|
+
.get(url, { headers: headersWithAuth, responseType })
|
|
30
|
+
.catch(error => {
|
|
31
|
+
// 404 with an auth token might mean an SSO issue so retry without the authorization header
|
|
32
|
+
if ((0, errors_1.isSpecifiedError)(error, { statusCode: 404 })) {
|
|
33
|
+
return axios_1.default.get(url, {
|
|
34
|
+
headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)() },
|
|
35
|
+
responseType,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
throw error;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
// No auth token, proceed normally
|
|
42
|
+
return axios_1.default.get(url, { headers: headersWithAuth, responseType });
|
|
43
|
+
}
|
|
21
44
|
// Returns information about the repo's releases. Defaults to "latest" if no tag is provided
|
|
22
45
|
// https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#get-a-release-by-tag-name
|
|
23
46
|
function fetchRepoReleaseData(repoPath, tag = '') {
|
|
24
47
|
const URL = `${GITHUB_REPOS_API}/${repoPath}/releases`;
|
|
25
|
-
return
|
|
26
|
-
headers: {
|
|
27
|
-
...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(),
|
|
28
|
-
...getAdditionalHeaders(),
|
|
29
|
-
},
|
|
30
|
-
});
|
|
48
|
+
return githubRequestWithFallback(`${URL}/${tag ? `tags/${tag}` : 'latest'}`);
|
|
31
49
|
}
|
|
32
50
|
exports.fetchRepoReleaseData = fetchRepoReleaseData;
|
|
33
51
|
// Returns the entire repo content as a zip, using the zipball_url from fetchRepoReleaseData()
|
|
@@ -41,31 +59,19 @@ function fetchRepoAsZip(zipUrl) {
|
|
|
41
59
|
exports.fetchRepoAsZip = fetchRepoAsZip;
|
|
42
60
|
// Returns the raw file contents via the raw.githubusercontent endpoint
|
|
43
61
|
function fetchRepoFile(repoPath, filePath, ref) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(),
|
|
47
|
-
...getAdditionalHeaders(),
|
|
48
|
-
},
|
|
49
|
-
});
|
|
62
|
+
const url = `${GITHUB_RAW_CONTENT_API_PATH}/${repoPath}/${ref}/${filePath}`;
|
|
63
|
+
return githubRequestWithFallback(url);
|
|
50
64
|
}
|
|
51
65
|
exports.fetchRepoFile = fetchRepoFile;
|
|
52
66
|
// Returns the raw file contents via the raw.githubusercontent endpoint
|
|
53
67
|
function fetchRepoFileByDownloadUrl(downloadUrl) {
|
|
54
|
-
return
|
|
55
|
-
headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...getAdditionalHeaders() },
|
|
56
|
-
responseType: 'arraybuffer',
|
|
57
|
-
});
|
|
68
|
+
return githubRequestWithFallback(downloadUrl, 'arraybuffer');
|
|
58
69
|
}
|
|
59
70
|
exports.fetchRepoFileByDownloadUrl = fetchRepoFileByDownloadUrl;
|
|
60
71
|
// Returns the contents of a file or directory in a repository by path
|
|
61
72
|
// https://docs.github.com/en/rest/repos/contents?apiVersion=2022-11-28#get-repository-content
|
|
62
73
|
function fetchRepoContents(repoPath, path, ref) {
|
|
63
74
|
const refQuery = ref ? `?ref=${ref}` : '';
|
|
64
|
-
return
|
|
65
|
-
headers: {
|
|
66
|
-
...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(),
|
|
67
|
-
...getAdditionalHeaders(),
|
|
68
|
-
},
|
|
69
|
-
});
|
|
75
|
+
return githubRequestWithFallback(`${GITHUB_REPOS_API}/${repoPath}/contents/${path}${refQuery}`);
|
|
70
76
|
}
|
|
71
77
|
exports.fetchRepoContents = fetchRepoContents;
|
package/api/localDevAuth.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ export declare function fetchAccessToken(personalAccessKey: string, env?: Enviro
|
|
|
7
7
|
export declare function fetchScopeData(accountId: number, scopeGroup: string): HubSpotPromise<ScopeData>;
|
|
8
8
|
export declare function fetchScopeAuthorizationData(accountId: number): HubSpotPromise<ScopeAuthorizationResponse>;
|
|
9
9
|
export declare function fetchAppInstallationData(portalId: number, projectId: number, appUid: string, requiredScopeGroups: Array<string>, optionalScopeGroups?: Array<string>): HubSpotPromise<PublicAppInstallationData>;
|
|
10
|
-
export declare function fetchEnabledFeatures(accountId: number): Promise<import("axios").AxiosResponse<EnabledFeaturesResponse, any
|
|
10
|
+
export declare function fetchEnabledFeatures(accountId: number): Promise<import("axios").AxiosResponse<EnabledFeaturesResponse, any>>;
|
|
@@ -14,7 +14,6 @@ const auth_1 = require("../constants/auth");
|
|
|
14
14
|
const files_1 = require("../constants/files");
|
|
15
15
|
const environment_1 = require("../lib/environment");
|
|
16
16
|
const logger_1 = require("../lib/logger");
|
|
17
|
-
const git_1 = require("../utils/git");
|
|
18
17
|
const errors_DEPRECATED_1 = require("../errors/errors_DEPRECATED");
|
|
19
18
|
const ALL_CMS_PUBLISH_MODES = Object.values(files_1.CMS_PUBLISH_MODE);
|
|
20
19
|
let _config;
|
|
@@ -191,12 +190,11 @@ function readConfigFile() {
|
|
|
191
190
|
return { source, error };
|
|
192
191
|
}
|
|
193
192
|
try {
|
|
194
|
-
(0, git_1.isConfigPathInGitRepo)(_configPath);
|
|
195
193
|
source = fs_extra_1.default.readFileSync(_configPath);
|
|
196
194
|
}
|
|
197
195
|
catch (err) {
|
|
198
196
|
error = err;
|
|
199
|
-
logger_1.logger.error(
|
|
197
|
+
logger_1.logger.error(`Config file could not be read: ${_configPath}`);
|
|
200
198
|
(0, errors_DEPRECATED_1.logFileSystemErrorInstance)(error, {
|
|
201
199
|
filepath: _configPath,
|
|
202
200
|
operation: 'read',
|
|
@@ -215,7 +213,7 @@ function parseConfig(configSource) {
|
|
|
215
213
|
}
|
|
216
214
|
catch (err) {
|
|
217
215
|
error = err;
|
|
218
|
-
logger_1.logger.error(
|
|
216
|
+
logger_1.logger.error(`Config file could not be parsed: ${_configPath}`);
|
|
219
217
|
(0, errors_DEPRECATED_1.logErrorInstance)(err);
|
|
220
218
|
}
|
|
221
219
|
return { parsed, error };
|
package/lib/hubdb.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare function createHubDbTable(accountId: number, src: string): Promis
|
|
|
8
8
|
tableId: string;
|
|
9
9
|
rowCount: number;
|
|
10
10
|
}>;
|
|
11
|
-
export declare function updateHubDbTable(accountId: number, tableId: string, src: string): Promise<AxiosResponse<Table, any
|
|
11
|
+
export declare function updateHubDbTable(accountId: number, tableId: string, src: string): Promise<AxiosResponse<Table, any>>;
|
|
12
12
|
export declare function downloadHubDbTable(accountId: number, tableId: string, dest: string): Promise<{
|
|
13
13
|
filePath: string;
|
|
14
14
|
}>;
|
package/package.json
CHANGED