@hubspot/local-dev-lib 1.10.0 → 1.12.0
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/projects.d.ts +2 -2
- package/api/projects.js +10 -9
- package/lib/path.d.ts +1 -0
- package/lib/path.js +13 -1
- package/lib/personalAccessKey.d.ts +1 -1
- package/lib/personalAccessKey.js +2 -1
- package/package.json +1 -1
- package/types/ComponentStructure.d.ts +30 -10
package/api/projects.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { QueryParams } from '../types/Http';
|
|
3
3
|
import { Project, FetchProjectResponse, UploadProjectResponse, ProjectSettings, FetchPlatformVersionResponse } from '../types/Project';
|
|
4
4
|
import { Build, FetchProjectBuildsResponse } from '../types/Build';
|
|
5
|
-
import {
|
|
5
|
+
import { ComponentStructureResponse, ProjectComponentsMetadata } from '../types/ComponentStructure';
|
|
6
6
|
import { Deploy, ProjectDeployResponse } from '../types/Deploy';
|
|
7
7
|
import { ProjectLog } from '../types/ProjectLog';
|
|
8
8
|
import { MigrateAppResponse, CloneAppResponse, PollAppResponse } from '../types/Migration';
|
|
@@ -10,6 +10,7 @@ export declare function fetchProjects(accountId: number): Promise<FetchProjectRe
|
|
|
10
10
|
export declare function createProject(accountId: number, name: string): Promise<Project>;
|
|
11
11
|
export declare function uploadProject(accountId: number, projectName: string, projectFile: string, uploadMessage: string, platformVersion?: string): Promise<UploadProjectResponse>;
|
|
12
12
|
export declare function fetchProject(accountId: number, projectName: string): Promise<Project>;
|
|
13
|
+
export declare function fetchProjectComponentsMetadata(accountId: number, projectId: number): Promise<ProjectComponentsMetadata>;
|
|
13
14
|
export declare function downloadProject(accountId: number, projectName: string, buildId: number): Promise<Buffer>;
|
|
14
15
|
export declare function deleteProject(accountId: number, projectName: string): Promise<void>;
|
|
15
16
|
export declare function fetchPlatformVersions(accountId: number): Promise<FetchPlatformVersionResponse>;
|
|
@@ -20,7 +21,6 @@ export declare function deployProject(accountId: number, projectName: string, bu
|
|
|
20
21
|
export declare function getDeployStatus(accountId: number, projectName: string, deployId: number): Promise<Deploy>;
|
|
21
22
|
export declare function getDeployStructure(accountId: number, projectName: string, deployId: number): Promise<ComponentStructureResponse>;
|
|
22
23
|
export declare function fetchProjectSettings(accountId: number, projectName: string): Promise<ProjectSettings>;
|
|
23
|
-
export declare function fetchDeployComponentsMetadata(accountId: number, projectId: number): Promise<ComponentMetadataResponse>;
|
|
24
24
|
export declare function provisionBuild(accountId: number, projectName: string, platformVersion?: string): Promise<Build>;
|
|
25
25
|
export declare function queueBuild(accountId: number, projectName: string, platformVersion?: string): Promise<void>;
|
|
26
26
|
export declare function uploadFileToBuild(accountId: number, projectName: string, filePath: string, path: string): Promise<void>;
|
package/api/projects.js
CHANGED
|
@@ -3,10 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.downloadClonedProject = exports.checkCloneStatus = exports.cloneApp = exports.checkMigrationStatus = exports.migrateApp = exports.fetchDeployWarnLogs = exports.fetchBuildWarnLogs = exports.cancelStagedBuild = exports.deleteFileFromBuild = exports.uploadFileToBuild = exports.queueBuild = exports.provisionBuild = exports.
|
|
6
|
+
exports.downloadClonedProject = exports.checkCloneStatus = exports.cloneApp = exports.checkMigrationStatus = exports.migrateApp = exports.fetchDeployWarnLogs = exports.fetchBuildWarnLogs = exports.cancelStagedBuild = exports.deleteFileFromBuild = exports.uploadFileToBuild = exports.queueBuild = exports.provisionBuild = exports.fetchProjectSettings = exports.getDeployStructure = exports.getDeployStatus = exports.deployProject = exports.getBuildStructure = exports.getBuildStatus = exports.fetchProjectBuilds = exports.fetchPlatformVersions = exports.deleteProject = exports.downloadProject = exports.fetchProjectComponentsMetadata = exports.fetchProject = exports.uploadProject = exports.createProject = exports.fetchProjects = void 0;
|
|
7
7
|
const http_1 = __importDefault(require("../http"));
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const PROJECTS_API_PATH = 'dfs/v1/projects';
|
|
10
|
+
const DEVELOPER_FILE_SYSTEM_PATH = 'dfs/v1';
|
|
10
11
|
const PROJECTS_DEPLOY_API_PATH = 'dfs/deploy/v1';
|
|
11
12
|
const PROJECTS_LOGS_API_PATH = 'dfs/logging/v1';
|
|
12
13
|
const DEVELOPER_PROJECTS_API_PATH = 'developer/projects/v1';
|
|
@@ -36,7 +37,7 @@ async function uploadProject(accountId, projectName, projectFile, uploadMessage,
|
|
|
36
37
|
}
|
|
37
38
|
return http_1.default.post(accountId, {
|
|
38
39
|
url: `${PROJECTS_API_PATH}/upload/${encodeURIComponent(projectName)}`,
|
|
39
|
-
timeout:
|
|
40
|
+
timeout: 60_000,
|
|
40
41
|
data: formData,
|
|
41
42
|
headers: { 'Content-Type': 'multipart/form-data' },
|
|
42
43
|
});
|
|
@@ -48,6 +49,12 @@ async function fetchProject(accountId, projectName) {
|
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
51
|
exports.fetchProject = fetchProject;
|
|
52
|
+
async function fetchProjectComponentsMetadata(accountId, projectId) {
|
|
53
|
+
return http_1.default.get(accountId, {
|
|
54
|
+
url: `${DEVELOPER_FILE_SYSTEM_PATH}/projects-deployed-build/${projectId}`,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
exports.fetchProjectComponentsMetadata = fetchProjectComponentsMetadata;
|
|
51
58
|
async function downloadProject(accountId, projectName, buildId) {
|
|
52
59
|
return http_1.default.get(accountId, {
|
|
53
60
|
url: `${PROJECTS_API_PATH}/${encodeURIComponent(projectName)}/builds/${buildId}/archive-full`,
|
|
@@ -115,18 +122,12 @@ async function fetchProjectSettings(accountId, projectName) {
|
|
|
115
122
|
});
|
|
116
123
|
}
|
|
117
124
|
exports.fetchProjectSettings = fetchProjectSettings;
|
|
118
|
-
async function fetchDeployComponentsMetadata(accountId, projectId) {
|
|
119
|
-
return http_1.default.get(accountId, {
|
|
120
|
-
url: `${PROJECTS_API_PATH}/by-id/${projectId}/deploy-components-metadata`,
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
exports.fetchDeployComponentsMetadata = fetchDeployComponentsMetadata;
|
|
124
125
|
async function provisionBuild(accountId, projectName, platformVersion) {
|
|
125
126
|
return http_1.default.post(accountId, {
|
|
126
127
|
url: `${PROJECTS_API_PATH}/${encodeURIComponent(projectName)}/builds/staged/provision`,
|
|
127
128
|
params: { platformVersion },
|
|
128
129
|
headers: { 'Content-Type': 'application/json' },
|
|
129
|
-
timeout:
|
|
130
|
+
timeout: 50_000,
|
|
130
131
|
});
|
|
131
132
|
}
|
|
132
133
|
exports.provisionBuild = provisionBuild;
|
package/lib/path.d.ts
CHANGED
|
@@ -11,3 +11,4 @@ export declare function isAllowedExtension(filepath: string, allowList?: Array<s
|
|
|
11
11
|
export declare function getAbsoluteFilePath(_path: string): string;
|
|
12
12
|
export declare function sanitizeFileName(fileName: string): string;
|
|
13
13
|
export declare function isValidPath(_path: string): boolean;
|
|
14
|
+
export declare function untildify(pathWithTilde: string): string;
|
package/lib/path.js
CHANGED
|
@@ -3,10 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isValidPath = exports.sanitizeFileName = exports.getAbsoluteFilePath = exports.isAllowedExtension = exports.getAllowedExtensions = exports.getExt = exports.getCwd = exports.splitHubSpotPath = exports.splitLocalPath = exports.convertToLocalFileSystemPath = exports.convertToUnixPath = void 0;
|
|
6
|
+
exports.untildify = exports.isValidPath = exports.sanitizeFileName = exports.getAbsoluteFilePath = exports.isAllowedExtension = exports.getAllowedExtensions = exports.getExt = exports.getCwd = exports.splitHubSpotPath = exports.splitLocalPath = exports.convertToLocalFileSystemPath = exports.convertToUnixPath = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const unixify_1 = __importDefault(require("unixify"));
|
|
9
9
|
const extensions_1 = require("../constants/extensions");
|
|
10
|
+
const os_1 = __importDefault(require("os"));
|
|
10
11
|
function convertToUnixPath(_path) {
|
|
11
12
|
return (0, unixify_1.default)(path_1.default.normalize(_path));
|
|
12
13
|
}
|
|
@@ -120,3 +121,14 @@ function isValidPath(_path) {
|
|
|
120
121
|
return true;
|
|
121
122
|
}
|
|
122
123
|
exports.isValidPath = isValidPath;
|
|
124
|
+
// Based on the untildify package: https://github.com/sindresorhus/untildify/blob/main/index.js
|
|
125
|
+
function untildify(pathWithTilde) {
|
|
126
|
+
const homeDirectory = os_1.default.homedir();
|
|
127
|
+
if (typeof pathWithTilde !== 'string') {
|
|
128
|
+
throw new TypeError(`Expected a string, got ${typeof pathWithTilde}`);
|
|
129
|
+
}
|
|
130
|
+
return homeDirectory
|
|
131
|
+
? pathWithTilde.replace(/^~(?=$|\/|\\)/, homeDirectory)
|
|
132
|
+
: pathWithTilde;
|
|
133
|
+
}
|
|
134
|
+
exports.untildify = untildify;
|
|
@@ -2,7 +2,7 @@ import { CLIAccount } from '../types/Accounts';
|
|
|
2
2
|
import { Environment } from '../types/Config';
|
|
3
3
|
import { AccessToken } from '../types/Accounts';
|
|
4
4
|
export declare function getAccessToken(personalAccessKey: string, env?: Environment, accountId?: number): Promise<AccessToken>;
|
|
5
|
-
export declare function accessTokenForPersonalAccessKey(accountId: number): Promise<string | undefined>;
|
|
5
|
+
export declare function accessTokenForPersonalAccessKey(accountId: number, forceRefresh?: boolean): Promise<string | undefined>;
|
|
6
6
|
export declare function enabledFeaturesForPersonalAccessKey(accountId: number): Promise<{
|
|
7
7
|
[key: string]: number;
|
|
8
8
|
} | undefined>;
|
package/lib/personalAccessKey.js
CHANGED
|
@@ -92,7 +92,7 @@ async function getNewAccessTokenByAccountId(accountId) {
|
|
|
92
92
|
const accessTokenResponse = await getNewAccessToken(accountId, personalAccessKey, auth?.tokenInfo?.expiresAt, env);
|
|
93
93
|
return accessTokenResponse;
|
|
94
94
|
}
|
|
95
|
-
async function accessTokenForPersonalAccessKey(accountId) {
|
|
95
|
+
async function accessTokenForPersonalAccessKey(accountId, forceRefresh = false) {
|
|
96
96
|
const account = (0, config_1.getAccountConfig)(accountId);
|
|
97
97
|
if (!account) {
|
|
98
98
|
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.accountNotFound`, { accountId });
|
|
@@ -101,6 +101,7 @@ async function accessTokenForPersonalAccessKey(accountId) {
|
|
|
101
101
|
const authTokenInfo = auth && auth.tokenInfo;
|
|
102
102
|
const authDataExists = authTokenInfo && auth?.tokenInfo?.accessToken;
|
|
103
103
|
if (!authDataExists ||
|
|
104
|
+
forceRefresh ||
|
|
104
105
|
(0, moment_1.default)().add(5, 'minutes').isAfter((0, moment_1.default)(authTokenInfo.expiresAt))) {
|
|
105
106
|
return getNewAccessToken(accountId, personalAccessKey, authTokenInfo && authTokenInfo.expiresAt, env).then(tokenInfo => tokenInfo.accessToken);
|
|
106
107
|
}
|
package/package.json
CHANGED
|
@@ -6,15 +6,35 @@ export type ComponentStructure = {
|
|
|
6
6
|
export type ComponentStructureResponse = {
|
|
7
7
|
topLevelComponentsWithChildren: ComponentStructure;
|
|
8
8
|
};
|
|
9
|
-
export type
|
|
10
|
-
|
|
9
|
+
export type ProjectComponentsMetadata = {
|
|
10
|
+
topLevelComponentMetadata: TopLevelComponents[];
|
|
11
|
+
};
|
|
12
|
+
export interface ComponentMetadata<T> {
|
|
11
13
|
componentName: string;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
appId: string;
|
|
14
|
+
type: {
|
|
15
|
+
name: T;
|
|
15
16
|
};
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
}
|
|
17
|
+
deployOutput: unknown;
|
|
18
|
+
}
|
|
19
|
+
export interface TopLevelComponent extends ComponentMetadata<ValueOf<typeof COMPONENT_TYPES>> {
|
|
20
|
+
featureComponents: FeatureComponents[];
|
|
21
|
+
}
|
|
22
|
+
export interface PrivateAppComponentMetadata extends TopLevelComponent {
|
|
23
|
+
deployOutput: {
|
|
24
|
+
cardId: number;
|
|
25
|
+
appId: number;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export type TopLevelComponents = PrivateAppComponentMetadata | TopLevelComponent;
|
|
29
|
+
export interface FeatureComponent<T = unknown> extends ComponentMetadata<ValueOf<typeof SUBCOMPONENT_TYPES>> {
|
|
30
|
+
deployOutput: T;
|
|
31
|
+
}
|
|
32
|
+
export type AppFunctionComponentMetadata = FeatureComponent<{
|
|
33
|
+
appId: number;
|
|
34
|
+
appFunctionName: string;
|
|
35
|
+
endpoint?: {
|
|
36
|
+
path: string;
|
|
37
|
+
methods: string[];
|
|
38
|
+
};
|
|
39
|
+
}>;
|
|
40
|
+
export type FeatureComponents = FeatureComponent | AppFunctionComponentMetadata;
|