@hubspot/local-dev-lib 0.0.5 → 0.0.6
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/customObjects.d.ts +7 -0
- package/api/customObjects.js +48 -0
- package/api/designManager.d.ts +13 -0
- package/api/designManager.js +21 -0
- package/api/fileManager.d.ts +5 -0
- package/api/fileManager.js +62 -0
- package/api/fileMapper.d.ts +10 -0
- package/api/fileMapper.js +104 -0
- package/api/functions.d.ts +4 -0
- package/api/functions.js +32 -0
- package/api/hubdb.d.ts +10 -0
- package/api/hubdb.js +61 -0
- package/api/lighthouseScore.d.ts +5 -0
- package/api/lighthouseScore.js +29 -0
- package/api/localDevAuth.d.ts +12 -0
- package/api/localDevAuth.js +38 -0
- package/api/marketplaceValidation.d.ts +5 -0
- package/api/marketplaceValidation.js +29 -0
- package/api/projects.d.ts +27 -0
- package/api/projects.js +126 -0
- package/api/sandboxHubs.d.ts +6 -0
- package/api/sandboxHubs.js +50 -0
- package/api/sandboxSync.d.ts +4 -0
- package/api/sandboxSync.js +35 -0
- package/api/secrets.d.ts +8 -0
- package/api/secrets.js +40 -0
- package/api/validateHubl.d.ts +2 -0
- package/api/validateHubl.js +18 -0
- package/config/CLIConfiguration.d.ts +22 -16
- package/config/CLIConfiguration.js +39 -9
- package/config/configFile.d.ts +4 -4
- package/config/configFile.js +2 -2
- package/config/configUtils.d.ts +8 -8
- package/config/config_DEPRECATED.d.ts +78 -0
- package/config/config_DEPRECATED.js +636 -0
- package/config/environment.d.ts +2 -3
- package/config/environment.js +11 -17
- package/config/index.d.ts +38 -0
- package/config/index.js +232 -0
- package/constants/api.d.ts +17 -0
- package/constants/api.js +20 -0
- package/constants/auth.d.ts +13 -0
- package/constants/auth.js +8 -1
- package/constants/config.d.ts +0 -4
- package/constants/config.js +1 -5
- package/constants/environments.d.ts +1 -0
- package/constants/environments.js +1 -0
- package/constants/extensions.d.ts +2 -0
- package/constants/extensions.js +4 -1
- package/constants/files.d.ts +16 -0
- package/constants/files.js +17 -1
- package/enums/build.d.ts +36 -0
- package/enums/build.js +39 -0
- package/enums/deploy.d.ts +11 -0
- package/enums/deploy.js +14 -0
- package/enums/project.d.ts +6 -0
- package/enums/project.js +9 -0
- package/errors/HubSpotAuthError.d.ts +8 -2
- package/errors/HubSpotAuthError.js +14 -0
- package/errors/apiErrors.d.ts +9 -0
- package/errors/apiErrors.js +182 -0
- package/errors/errors_DEPRECATED.d.ts +7 -0
- package/errors/errors_DEPRECATED.js +73 -0
- package/errors/fileSystemErrors.d.ts +1 -7
- package/errors/standardErrors.d.ts +7 -1
- package/errors/standardErrors.js +20 -23
- package/http/getAxiosConfig.d.ts +6 -0
- package/http/getAxiosConfig.js +22 -0
- package/http/index.d.ts +18 -0
- package/http/index.js +175 -0
- package/lang/en.lyaml +151 -13
- package/lib/cms/functions.d.ts +13 -0
- package/lib/cms/functions.js +181 -0
- package/lib/cms/handleFieldsJS.d.ts +2 -1
- package/lib/cms/handleFieldsJS.js +4 -3
- package/lib/cms/modules.js +3 -3
- package/lib/cms/processFieldsJs.d.ts +1 -0
- package/lib/cms/processFieldsJs.js +122 -0
- package/lib/cms/templates.d.ts +25 -0
- package/lib/cms/templates.js +62 -0
- package/lib/cms/themes.js +2 -2
- package/lib/cms/uploadFolder.d.ts +18 -0
- package/lib/cms/uploadFolder.js +182 -0
- package/lib/cms/watch.d.ts +20 -0
- package/lib/cms/watch.js +194 -0
- package/lib/customObjects.d.ts +5 -0
- package/lib/customObjects.js +36 -0
- package/lib/environment.d.ts +2 -1
- package/lib/fileMapper.d.ts +13 -0
- package/lib/fileMapper.js +322 -0
- package/lib/github.d.ts +6 -3
- package/lib/github.js +36 -27
- package/lib/gitignore.js +1 -46
- package/lib/hubdb.d.ts +16 -0
- package/lib/hubdb.js +130 -0
- package/lib/ignoreRules.d.ts +3 -0
- package/lib/ignoreRules.js +69 -0
- package/lib/logging/git.d.ts +2 -0
- package/lib/logging/git.js +54 -0
- package/lib/logging/logger.d.ts +44 -0
- package/lib/logging/logger.js +146 -0
- package/lib/logging/logs.d.ts +22 -0
- package/lib/logging/logs.js +82 -0
- package/lib/logging/table.d.ts +3 -0
- package/lib/logging/table.js +47 -0
- package/lib/oauth.d.ts +7 -0
- package/lib/oauth.js +44 -0
- package/lib/path.d.ts +2 -1
- package/lib/path.js +8 -3
- package/lib/personalAccessKey.d.ts +13 -0
- package/lib/personalAccessKey.js +135 -0
- package/lib/sandboxes.d.ts +14 -0
- package/lib/sandboxes.js +71 -0
- package/lib/trackUsage.d.ts +1 -0
- package/lib/trackUsage.js +53 -0
- package/lib/validate.d.ts +2 -0
- package/lib/validate.js +40 -0
- package/models/OAuth2Manager.d.ts +34 -0
- package/models/OAuth2Manager.js +126 -0
- package/package.json +24 -13
- package/types/Accounts.d.ts +66 -21
- package/types/Activity.d.ts +20 -0
- package/types/Activity.js +2 -0
- package/types/Api.d.ts +2 -0
- package/types/Api.js +2 -0
- package/types/Build.d.ts +41 -0
- package/types/Build.js +2 -0
- package/types/CLIOptions.d.ts +5 -0
- package/types/ComponentStructure.d.ts +20 -0
- package/types/ComponentStructure.js +2 -0
- package/types/Config.d.ts +17 -4
- package/types/Deploy.d.ts +42 -0
- package/types/Deploy.js +2 -0
- package/types/Error.d.ts +32 -7
- package/types/FileManager.d.ts +66 -0
- package/types/FileManager.js +2 -0
- package/types/Files.d.ts +33 -1
- package/types/Functions.d.ts +40 -0
- package/types/Functions.js +2 -0
- package/types/Github.d.ts +6 -0
- package/types/Http.d.ts +33 -0
- package/types/Http.js +2 -0
- package/types/Hubdb.d.ts +90 -0
- package/types/Hubdb.js +2 -0
- package/types/HublValidation.d.ts +59 -0
- package/types/HublValidation.js +2 -0
- package/types/Lighthouse.d.ts +25 -0
- package/types/Lighthouse.js +2 -0
- package/types/MarketplaceValidation.d.ts +28 -0
- package/types/MarketplaceValidation.js +2 -0
- package/types/Project.d.ts +38 -0
- package/types/Project.js +2 -0
- package/types/Sandbox.d.ts +165 -0
- package/types/Sandbox.js +2 -0
- package/types/Schemas.d.ts +42 -0
- package/types/Schemas.js +2 -0
- package/utils/{modules.d.ts → cms/modules.d.ts} +1 -1
- package/utils/{modules.js → cms/modules.js} +3 -3
- package/utils/getAccountIdentifier.d.ts +10 -0
- package/utils/getAccountIdentifier.js +40 -0
- package/utils/git.d.ts +7 -2
- package/utils/git.js +54 -7
- package/utils/lang.d.ts +4 -0
- package/utils/lang.js +9 -2
- package/utils/notify.d.ts +1 -0
- package/utils/notify.js +42 -0
- package/utils/objectUtils.d.ts +8 -0
- package/utils/objectUtils.js +33 -0
- package/constants/index.d.ts +0 -16
- package/constants/index.js +0 -12
- package/http/requestOptions.d.ts +0 -20
- package/http/requestOptions.js +0 -27
- package/lang/lang/en.lyaml +0 -109
- package/lib/cms/index.d.ts +0 -10
- package/lib/cms/index.js +0 -13
- package/lib/index.d.ts +0 -11
- package/lib/index.js +0 -14
- /package/utils/{fieldsJS.d.ts → cms/fieldsJS.d.ts} +0 -0
- /package/utils/{fieldsJS.js → cms/fieldsJS.js} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FetchSchemasResponse, Schema } from '../types/Schemas';
|
|
2
|
+
export declare function batchCreateObjects(accountId: number, objectTypeId: string, objects: JSON): Promise<void>;
|
|
3
|
+
export declare function createObjectSchema(accountId: number, schema: JSON): Promise<Schema>;
|
|
4
|
+
export declare function updateObjectSchema(accountId: number, schemaObjectType: string, schema: Schema): Promise<Schema>;
|
|
5
|
+
export declare function fetchObjectSchema(accountId: number, schemaObjectType: string): Promise<Schema>;
|
|
6
|
+
export declare function fetchObjectSchemas(accountId: number): Promise<FetchSchemasResponse>;
|
|
7
|
+
export declare function deleteObjectSchema(accountId: number, schemaObjectType: string): Promise<void>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.deleteObjectSchema = exports.fetchObjectSchemas = exports.fetchObjectSchema = exports.updateObjectSchema = exports.createObjectSchema = exports.batchCreateObjects = void 0;
|
|
7
|
+
const http_1 = __importDefault(require("../http"));
|
|
8
|
+
const CUSTOM_OBJECTS_API_PATH = 'crm/v3/objects';
|
|
9
|
+
const SCHEMA_API_PATH = 'crm-object-schemas/v3/schemas';
|
|
10
|
+
async function batchCreateObjects(accountId, objectTypeId, objects) {
|
|
11
|
+
http_1.default.post(accountId, {
|
|
12
|
+
url: `${CUSTOM_OBJECTS_API_PATH}/${objectTypeId}/batch/create`,
|
|
13
|
+
body: objects,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
exports.batchCreateObjects = batchCreateObjects;
|
|
17
|
+
async function createObjectSchema(accountId, schema) {
|
|
18
|
+
return http_1.default.post(accountId, {
|
|
19
|
+
url: SCHEMA_API_PATH,
|
|
20
|
+
body: schema,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
exports.createObjectSchema = createObjectSchema;
|
|
24
|
+
async function updateObjectSchema(accountId, schemaObjectType, schema) {
|
|
25
|
+
return http_1.default.patch(accountId, {
|
|
26
|
+
url: `${SCHEMA_API_PATH}/${schemaObjectType}`,
|
|
27
|
+
body: schema,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
exports.updateObjectSchema = updateObjectSchema;
|
|
31
|
+
async function fetchObjectSchema(accountId, schemaObjectType) {
|
|
32
|
+
return http_1.default.get(accountId, {
|
|
33
|
+
url: `${SCHEMA_API_PATH}/${schemaObjectType}`,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
exports.fetchObjectSchema = fetchObjectSchema;
|
|
37
|
+
async function fetchObjectSchemas(accountId) {
|
|
38
|
+
return http_1.default.get(accountId, {
|
|
39
|
+
url: SCHEMA_API_PATH,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
exports.fetchObjectSchemas = fetchObjectSchemas;
|
|
43
|
+
async function deleteObjectSchema(accountId, schemaObjectType) {
|
|
44
|
+
return http_1.default.delete(accountId, {
|
|
45
|
+
url: `${SCHEMA_API_PATH}/${schemaObjectType}`,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
exports.deleteObjectSchema = deleteObjectSchema;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type FetchThemesResponse = {
|
|
2
|
+
objects: Array<{
|
|
3
|
+
theme: {
|
|
4
|
+
path: string;
|
|
5
|
+
};
|
|
6
|
+
}>;
|
|
7
|
+
};
|
|
8
|
+
export declare function fetchThemes(accountId: number, query?: {}): Promise<FetchThemesResponse>;
|
|
9
|
+
type FetchBuiltinMappingResponse = {
|
|
10
|
+
[key: string]: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function fetchBuiltinMapping(accountId: number): Promise<FetchBuiltinMappingResponse>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.fetchBuiltinMapping = exports.fetchThemes = void 0;
|
|
7
|
+
const http_1 = __importDefault(require("../http"));
|
|
8
|
+
const DESIGN_MANAGER_API_PATH = 'designmanager/v1';
|
|
9
|
+
async function fetchThemes(accountId, query = {}) {
|
|
10
|
+
return http_1.default.get(accountId, {
|
|
11
|
+
url: `${DESIGN_MANAGER_API_PATH}/themes/combined`,
|
|
12
|
+
query,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.fetchThemes = fetchThemes;
|
|
16
|
+
async function fetchBuiltinMapping(accountId) {
|
|
17
|
+
return http_1.default.get(accountId, {
|
|
18
|
+
url: `${DESIGN_MANAGER_API_PATH}/widgets/builtin-mapping`,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
exports.fetchBuiltinMapping = fetchBuiltinMapping;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FetchStatResponse, FetchFilesOrFolderResponse, UploadResponse } from '../types/FileManager';
|
|
2
|
+
export declare function uploadFile(accountId: number, src: string, dest: string): Promise<UploadResponse>;
|
|
3
|
+
export declare function fetchStat(accountId: number, src: string): Promise<FetchStatResponse>;
|
|
4
|
+
export declare function fetchFiles(accountId: number, folderId: number, offset: number, archived?: boolean): Promise<FetchFilesOrFolderResponse>;
|
|
5
|
+
export declare function fetchFolders(accountId: number, folderId: number): Promise<FetchFilesOrFolderResponse>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.fetchFolders = exports.fetchFiles = exports.fetchStat = exports.uploadFile = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const http_1 = __importDefault(require("../http"));
|
|
10
|
+
const FILE_MANAGER_V2_API_PATH = 'filemanager/api/v2';
|
|
11
|
+
const FILE_MANAGER_V3_API_PATH = 'filemanager/api/v3';
|
|
12
|
+
async function uploadFile(accountId, src, dest) {
|
|
13
|
+
const directory = path_1.default.dirname(dest);
|
|
14
|
+
const filename = path_1.default.basename(dest);
|
|
15
|
+
const formData = {
|
|
16
|
+
file: fs_1.default.createReadStream(src),
|
|
17
|
+
fileName: filename,
|
|
18
|
+
options: JSON.stringify({
|
|
19
|
+
access: 'PUBLIC_INDEXABLE',
|
|
20
|
+
overwrite: true,
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
if (directory && directory !== '.') {
|
|
24
|
+
formData.folderPath = directory;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
formData.folderPath = '/';
|
|
28
|
+
}
|
|
29
|
+
return http_1.default.post(accountId, {
|
|
30
|
+
url: `${FILE_MANAGER_V3_API_PATH}/files/upload`,
|
|
31
|
+
formData,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
exports.uploadFile = uploadFile;
|
|
35
|
+
async function fetchStat(accountId, src) {
|
|
36
|
+
return http_1.default.get(accountId, {
|
|
37
|
+
url: `${FILE_MANAGER_V2_API_PATH}/files/stat/${src}`,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
exports.fetchStat = fetchStat;
|
|
41
|
+
async function fetchFiles(accountId, folderId, offset, archived) {
|
|
42
|
+
return http_1.default.get(accountId, {
|
|
43
|
+
url: `${FILE_MANAGER_V2_API_PATH}/files/`,
|
|
44
|
+
query: {
|
|
45
|
+
hidden: 0,
|
|
46
|
+
offset: offset,
|
|
47
|
+
folder_id: folderId,
|
|
48
|
+
...(!archived && { archived: 0 }),
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.fetchFiles = fetchFiles;
|
|
53
|
+
async function fetchFolders(accountId, folderId) {
|
|
54
|
+
return http_1.default.get(accountId, {
|
|
55
|
+
url: `${FILE_MANAGER_V2_API_PATH}/folders/`,
|
|
56
|
+
query: {
|
|
57
|
+
hidden: 0,
|
|
58
|
+
parent_folder_id: folderId,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
exports.fetchFolders = fetchFolders;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FileMapperNode, FileMapperOptions, FileTree } from '../types/Files';
|
|
2
|
+
export declare const FILE_MAPPER_API_PATH = "content/filemapper/v1";
|
|
3
|
+
export declare function upload(accountId: number, src: string, dest: string, options?: FileMapperOptions): Promise<void>;
|
|
4
|
+
export declare function fetchModule(accountId: number, moduleId: number, options?: FileMapperOptions): Promise<FileTree>;
|
|
5
|
+
export declare function fetchFileStream(accountId: number, filePath: string, destination: string, options?: FileMapperOptions): Promise<FileMapperNode>;
|
|
6
|
+
export declare function download(accountId: number, filepath: string, options?: FileMapperOptions): Promise<FileMapperNode>;
|
|
7
|
+
export declare function downloadDefault(accountId: number, filepath: string, options?: FileMapperOptions): Promise<FileMapperNode>;
|
|
8
|
+
export declare function deleteFile(accountId: number, filePath: string, options?: FileMapperOptions): Promise<void>;
|
|
9
|
+
export declare function moveFile(accountId: number, srcPath: string, destPath: string): Promise<void>;
|
|
10
|
+
export declare function getDirectoryContentsByPath(accountId: number, path: string): Promise<void>;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getDirectoryContentsByPath = exports.moveFile = exports.deleteFile = exports.downloadDefault = exports.download = exports.fetchFileStream = exports.fetchModule = exports.upload = exports.FILE_MAPPER_API_PATH = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const content_disposition_1 = __importDefault(require("content-disposition"));
|
|
10
|
+
const http_1 = __importDefault(require("../http"));
|
|
11
|
+
const path_2 = require("../lib/path");
|
|
12
|
+
exports.FILE_MAPPER_API_PATH = 'content/filemapper/v1';
|
|
13
|
+
function createFileMapperNodeFromStreamResponse(filePath, response) {
|
|
14
|
+
if (filePath[0] !== '/') {
|
|
15
|
+
filePath = `/${filePath}`;
|
|
16
|
+
}
|
|
17
|
+
if (filePath[filePath.length - 1] === '/') {
|
|
18
|
+
filePath = filePath.slice(0, filePath.length - 1);
|
|
19
|
+
}
|
|
20
|
+
const node = {
|
|
21
|
+
source: null,
|
|
22
|
+
path: filePath,
|
|
23
|
+
name: path_1.default.basename(filePath),
|
|
24
|
+
folder: false,
|
|
25
|
+
children: [],
|
|
26
|
+
createdAt: 0,
|
|
27
|
+
updatedAt: 0,
|
|
28
|
+
};
|
|
29
|
+
if (!(response.headers && response.headers['content-disposition'])) {
|
|
30
|
+
return node;
|
|
31
|
+
}
|
|
32
|
+
const { parameters } = content_disposition_1.default.parse(response.headers['content-disposition']);
|
|
33
|
+
return {
|
|
34
|
+
...node,
|
|
35
|
+
name: parameters.filename,
|
|
36
|
+
createdAt: parseInt(parameters['creation-date'], 10) || 0,
|
|
37
|
+
updatedAt: parseInt(parameters['modification-date'], 10) || 0,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
async function upload(accountId, src, dest, options = {}) {
|
|
41
|
+
return http_1.default.post(accountId, {
|
|
42
|
+
url: `${exports.FILE_MAPPER_API_PATH}/upload/${encodeURIComponent(dest)}`,
|
|
43
|
+
formData: {
|
|
44
|
+
file: fs_1.default.createReadStream(path_1.default.resolve((0, path_2.getCwd)(), src)),
|
|
45
|
+
},
|
|
46
|
+
...options,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
exports.upload = upload;
|
|
50
|
+
// Fetch a module by moduleId
|
|
51
|
+
async function fetchModule(accountId, moduleId, options = {}) {
|
|
52
|
+
return http_1.default.get(accountId, {
|
|
53
|
+
url: `${exports.FILE_MAPPER_API_PATH}/modules/${moduleId}`,
|
|
54
|
+
...options,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
exports.fetchModule = fetchModule;
|
|
58
|
+
//Fetch a file by file path.
|
|
59
|
+
async function fetchFileStream(accountId, filePath, destination, options = {}) {
|
|
60
|
+
const response = await http_1.default.getOctetStream(accountId, {
|
|
61
|
+
url: `${exports.FILE_MAPPER_API_PATH}/stream/${encodeURIComponent(filePath)}`,
|
|
62
|
+
...options,
|
|
63
|
+
}, destination);
|
|
64
|
+
return createFileMapperNodeFromStreamResponse(filePath, response);
|
|
65
|
+
}
|
|
66
|
+
exports.fetchFileStream = fetchFileStream;
|
|
67
|
+
// Fetch a folder or file node by path.
|
|
68
|
+
async function download(accountId, filepath, options = {}) {
|
|
69
|
+
return http_1.default.get(accountId, {
|
|
70
|
+
url: `${exports.FILE_MAPPER_API_PATH}/download/${encodeURIComponent(filepath)}`,
|
|
71
|
+
...options,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
exports.download = download;
|
|
75
|
+
// Fetch a folder or file node by path.
|
|
76
|
+
async function downloadDefault(accountId, filepath, options = {}) {
|
|
77
|
+
return http_1.default.get(accountId, {
|
|
78
|
+
url: `${exports.FILE_MAPPER_API_PATH}/download-default/${filepath}`,
|
|
79
|
+
...options,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
exports.downloadDefault = downloadDefault;
|
|
83
|
+
// Delete a file or folder by path
|
|
84
|
+
async function deleteFile(accountId, filePath, options = {}) {
|
|
85
|
+
return http_1.default.delete(accountId, {
|
|
86
|
+
url: `${exports.FILE_MAPPER_API_PATH}/delete/${encodeURIComponent(filePath)}`,
|
|
87
|
+
...options,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
exports.deleteFile = deleteFile;
|
|
91
|
+
// Moves file from srcPath to destPath
|
|
92
|
+
async function moveFile(accountId, srcPath, destPath) {
|
|
93
|
+
return http_1.default.put(accountId, {
|
|
94
|
+
url: `${exports.FILE_MAPPER_API_PATH}/rename/${srcPath}?path=${destPath}`,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
exports.moveFile = moveFile;
|
|
98
|
+
// Get directory contents
|
|
99
|
+
async function getDirectoryContentsByPath(accountId, path) {
|
|
100
|
+
return http_1.default.get(accountId, {
|
|
101
|
+
url: `${exports.FILE_MAPPER_API_PATH}/meta/${path}`,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
exports.getDirectoryContentsByPath = getDirectoryContentsByPath;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { GetBuildStatusResponse, GetRoutesResponse } from '../types/Functions';
|
|
2
|
+
export declare function getRoutes(accountId: number): Promise<GetRoutesResponse>;
|
|
3
|
+
export declare function buildPackage(accountId: number, folderPath: string): Promise<string>;
|
|
4
|
+
export declare function getBuildStatus(portalId: number, buildId: number): Promise<GetBuildStatusResponse>;
|
package/api/functions.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getBuildStatus = exports.buildPackage = exports.getRoutes = void 0;
|
|
7
|
+
const http_1 = __importDefault(require("../http"));
|
|
8
|
+
const FUNCTION_API_PATH = 'cms/v3/functions';
|
|
9
|
+
async function getRoutes(accountId) {
|
|
10
|
+
return http_1.default.get(accountId, {
|
|
11
|
+
url: `${FUNCTION_API_PATH}/routes`,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
exports.getRoutes = getRoutes;
|
|
15
|
+
async function buildPackage(accountId, folderPath) {
|
|
16
|
+
return http_1.default.post(accountId, {
|
|
17
|
+
url: `${FUNCTION_API_PATH}/build/async`,
|
|
18
|
+
headers: {
|
|
19
|
+
Accept: 'text/plain',
|
|
20
|
+
},
|
|
21
|
+
body: {
|
|
22
|
+
folderPath,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.buildPackage = buildPackage;
|
|
27
|
+
async function getBuildStatus(portalId, buildId) {
|
|
28
|
+
return http_1.default.get(portalId, {
|
|
29
|
+
url: `${FUNCTION_API_PATH}/build/${buildId}/poll`,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
exports.getBuildStatus = getBuildStatus;
|
package/api/hubdb.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { QueryParams } from '../types/Http';
|
|
2
|
+
import { CreateRowsResponse, FetchRowsResponse, Row, Schema, Table } from '../types/Hubdb';
|
|
3
|
+
export declare function fetchTable(accountId: number, tableId: string): Promise<Table>;
|
|
4
|
+
export declare function createTable(accountId: number, schema: Schema): Promise<Table>;
|
|
5
|
+
export declare function updateTable(accountId: number, tableId: string, schema: Schema): Promise<unknown>;
|
|
6
|
+
export declare function publishTable(accountId: number, tableId: string): Promise<Table>;
|
|
7
|
+
export declare function deleteTable(accountId: number, tableId: string): Promise<void>;
|
|
8
|
+
export declare function createRows(accountId: number, tableId: string, rows: Array<Row>): Promise<CreateRowsResponse>;
|
|
9
|
+
export declare function fetchRows(accountId: number, tableId: string, query?: QueryParams): Promise<FetchRowsResponse>;
|
|
10
|
+
export declare function deleteRows(accountId: number, tableId: string, rowIds: Array<string>): Promise<void>;
|
package/api/hubdb.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.deleteRows = exports.fetchRows = exports.createRows = exports.deleteTable = exports.publishTable = exports.updateTable = exports.createTable = exports.fetchTable = void 0;
|
|
7
|
+
const http_1 = __importDefault(require("../http"));
|
|
8
|
+
const HUBDB_API_PATH = 'cms/v3/hubdb';
|
|
9
|
+
async function fetchTable(accountId, tableId) {
|
|
10
|
+
return http_1.default.get(accountId, {
|
|
11
|
+
url: `${HUBDB_API_PATH}/tables/${tableId}`,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
exports.fetchTable = fetchTable;
|
|
15
|
+
async function createTable(accountId, schema) {
|
|
16
|
+
return http_1.default.post(accountId, {
|
|
17
|
+
url: `${HUBDB_API_PATH}/tables`,
|
|
18
|
+
body: schema,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
exports.createTable = createTable;
|
|
22
|
+
async function updateTable(accountId, tableId, schema) {
|
|
23
|
+
return http_1.default.patch(accountId, {
|
|
24
|
+
url: `${HUBDB_API_PATH}/tables/${tableId}/draft`,
|
|
25
|
+
body: schema,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
exports.updateTable = updateTable;
|
|
29
|
+
async function publishTable(accountId, tableId) {
|
|
30
|
+
return http_1.default.post(accountId, {
|
|
31
|
+
url: `${HUBDB_API_PATH}/tables/${tableId}/draft/publish`,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
exports.publishTable = publishTable;
|
|
35
|
+
async function deleteTable(accountId, tableId) {
|
|
36
|
+
return http_1.default.delete(accountId, {
|
|
37
|
+
url: `${HUBDB_API_PATH}/tables/${tableId}`,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
exports.deleteTable = deleteTable;
|
|
41
|
+
async function createRows(accountId, tableId, rows) {
|
|
42
|
+
return http_1.default.post(accountId, {
|
|
43
|
+
url: `${HUBDB_API_PATH}/tables/${tableId}/rows/draft/batch/create`,
|
|
44
|
+
body: { inputs: rows },
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
exports.createRows = createRows;
|
|
48
|
+
async function fetchRows(accountId, tableId, query = {}) {
|
|
49
|
+
return http_1.default.get(accountId, {
|
|
50
|
+
url: `${HUBDB_API_PATH}/tables/${tableId}/rows/draft`,
|
|
51
|
+
query,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
exports.fetchRows = fetchRows;
|
|
55
|
+
async function deleteRows(accountId, tableId, rowIds) {
|
|
56
|
+
return http_1.default.post(accountId, {
|
|
57
|
+
url: `${HUBDB_API_PATH}/tables/${tableId}/rows/draft/batch/purge`,
|
|
58
|
+
body: { inputs: rowIds },
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
exports.deleteRows = deleteRows;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Body, QueryParams } from '../types/Http';
|
|
2
|
+
import { GetLighthouseScoreResponse, RequestLighthouseScoreResponse } from '../types/Lighthouse';
|
|
3
|
+
export declare function requestLighthouseScore(accountId: number, body?: Body): Promise<RequestLighthouseScoreResponse>;
|
|
4
|
+
export declare function getLighthouseScoreStatus(accountId: number, query?: QueryParams): Promise<string>;
|
|
5
|
+
export declare function getLighthouseScore(accountId: number, query?: QueryParams): Promise<GetLighthouseScoreResponse>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getLighthouseScore = exports.getLighthouseScoreStatus = exports.requestLighthouseScore = void 0;
|
|
7
|
+
const http_1 = __importDefault(require("../http"));
|
|
8
|
+
const LIGHTHOUSE_SCORE_API_BASE = 'quality-engine/v1/lighthouse';
|
|
9
|
+
async function requestLighthouseScore(accountId, body = {}) {
|
|
10
|
+
return http_1.default.post(accountId, {
|
|
11
|
+
url: `${LIGHTHOUSE_SCORE_API_BASE}/request`,
|
|
12
|
+
body,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.requestLighthouseScore = requestLighthouseScore;
|
|
16
|
+
async function getLighthouseScoreStatus(accountId, query = {}) {
|
|
17
|
+
return http_1.default.get(accountId, {
|
|
18
|
+
url: `${LIGHTHOUSE_SCORE_API_BASE}/status`,
|
|
19
|
+
query,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
exports.getLighthouseScoreStatus = getLighthouseScoreStatus;
|
|
23
|
+
async function getLighthouseScore(accountId, query = {}) {
|
|
24
|
+
return http_1.default.get(accountId, {
|
|
25
|
+
url: `${LIGHTHOUSE_SCORE_API_BASE}/scores`,
|
|
26
|
+
query,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
exports.getLighthouseScore = getLighthouseScore;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Environment } from '../types/Config';
|
|
2
|
+
import { ScopeData } from '../types/Accounts';
|
|
3
|
+
type AccessTokenResponse = {
|
|
4
|
+
hubId: number;
|
|
5
|
+
oauthAccessToken: string;
|
|
6
|
+
expiresAtMillis: number;
|
|
7
|
+
scopeGroups: Array<string>;
|
|
8
|
+
encodedOauthRefreshToken: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function fetchAccessToken(personalAccessKey: string, env?: Environment, portalId?: number): Promise<AccessTokenResponse>;
|
|
11
|
+
export declare function fetchScopeData(accountId: number, scopeGroup: string): Promise<ScopeData>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.fetchScopeData = exports.fetchAccessToken = void 0;
|
|
7
|
+
const getAxiosConfig_1 = require("../http/getAxiosConfig");
|
|
8
|
+
const http_1 = __importDefault(require("../http"));
|
|
9
|
+
const environments_1 = require("../constants/environments");
|
|
10
|
+
const axios_1 = __importDefault(require("axios"));
|
|
11
|
+
const LOCALDEVAUTH_API_AUTH_PATH = 'localdevauth/v1/auth';
|
|
12
|
+
async function fetchAccessToken(personalAccessKey, env = environments_1.ENVIRONMENTS.PROD, portalId) {
|
|
13
|
+
const query = portalId ? { portalId } : {};
|
|
14
|
+
const axiosConfig = (0, getAxiosConfig_1.getAxiosConfig)({
|
|
15
|
+
env,
|
|
16
|
+
localHostOverride: true,
|
|
17
|
+
url: `${LOCALDEVAUTH_API_AUTH_PATH}/refresh`,
|
|
18
|
+
body: {
|
|
19
|
+
encodedOAuthRefreshToken: personalAccessKey,
|
|
20
|
+
},
|
|
21
|
+
params: query,
|
|
22
|
+
});
|
|
23
|
+
const { data } = await (0, axios_1.default)({
|
|
24
|
+
...axiosConfig,
|
|
25
|
+
method: 'post',
|
|
26
|
+
});
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
exports.fetchAccessToken = fetchAccessToken;
|
|
30
|
+
async function fetchScopeData(accountId, scopeGroup) {
|
|
31
|
+
return http_1.default.get(accountId, {
|
|
32
|
+
url: `localdevauth/v1/auth/check-scopes`,
|
|
33
|
+
query: {
|
|
34
|
+
scopeGroup,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
exports.fetchScopeData = fetchScopeData;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Body, QueryParams } from '../types/Http';
|
|
2
|
+
import { GetValidationResultsResponse } from '../types/MarketplaceValidation';
|
|
3
|
+
export declare function requestValidation(accountId: number, body?: Body): Promise<number>;
|
|
4
|
+
export declare function getValidationStatus(accountId: number, query?: QueryParams): Promise<string>;
|
|
5
|
+
export declare function getValidationResults(accountId: number, query?: QueryParams): Promise<GetValidationResultsResponse>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getValidationResults = exports.getValidationStatus = exports.requestValidation = void 0;
|
|
7
|
+
const http_1 = __importDefault(require("../http"));
|
|
8
|
+
const VALIDATION_API_BASE = 'quality-engine/v1/validation';
|
|
9
|
+
function requestValidation(accountId, body = {}) {
|
|
10
|
+
return http_1.default.post(accountId, {
|
|
11
|
+
url: `${VALIDATION_API_BASE}/request`,
|
|
12
|
+
body,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.requestValidation = requestValidation;
|
|
16
|
+
function getValidationStatus(accountId, query = {}) {
|
|
17
|
+
return http_1.default.get(accountId, {
|
|
18
|
+
url: `${VALIDATION_API_BASE}/status`,
|
|
19
|
+
query,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
exports.getValidationStatus = getValidationStatus;
|
|
23
|
+
function getValidationResults(accountId, query = {}) {
|
|
24
|
+
return http_1.default.get(accountId, {
|
|
25
|
+
url: `${VALIDATION_API_BASE}/results`,
|
|
26
|
+
query,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
exports.getValidationResults = getValidationResults;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { QueryParams } from '../types/Http';
|
|
3
|
+
import { Project, FetchProjectResponse, UploadProjectResponse, ProjectSettings } from '../types/Project';
|
|
4
|
+
import { Build, FetchProjectBuildsResponse } from '../types/Build';
|
|
5
|
+
import { ComponentMetadataResponse, ComponentStructureResponse } from '../types/ComponentStructure';
|
|
6
|
+
import { Deploy, ProjectDeployResponse } from '../types/Deploy';
|
|
7
|
+
export declare function fetchProjects(accountId: number): Promise<FetchProjectResponse>;
|
|
8
|
+
export declare function createProject(accountId: number, name: string): Promise<Project>;
|
|
9
|
+
export declare function uploadProject(accountId: number, projectName: string, projectFile: string, uploadMessage: string, platformVersion?: string): Promise<UploadProjectResponse>;
|
|
10
|
+
export declare function fetchProject(accountId: number, projectName: string): Promise<Project>;
|
|
11
|
+
export declare function downloadProject(accountId: number, projectName: string, buildId: number): Promise<Buffer>;
|
|
12
|
+
export declare function deleteProject(accountId: number, projectName: string): Promise<void>;
|
|
13
|
+
type FetchPlatformVersionResponse = {
|
|
14
|
+
defaultPlatformVersion: string;
|
|
15
|
+
activePlatformVersions: Array<string>;
|
|
16
|
+
};
|
|
17
|
+
export declare function fetchPlatformVersions(accountId: number): Promise<FetchPlatformVersionResponse>;
|
|
18
|
+
export declare function fetchProjectBuilds(accountId: number, projectName: string, query: QueryParams): Promise<FetchProjectBuildsResponse>;
|
|
19
|
+
export declare function getBuildStatus(accountId: number, projectName: string, buildId: number): Promise<Build>;
|
|
20
|
+
export declare function getBuildStructure(accountId: number, projectName: string, buildId: number): Promise<ComponentStructureResponse>;
|
|
21
|
+
export declare function deployProject(accountId: number, projectName: string, buildId: number): Promise<ProjectDeployResponse>;
|
|
22
|
+
export declare function getDeployStatus(accountId: number, projectName: string, deployId: number): Promise<Deploy>;
|
|
23
|
+
export declare function getDeployStructure(accountId: number, projectName: string, deployId: number): Promise<ComponentStructureResponse>;
|
|
24
|
+
export declare function fetchProjectSettings(accountId: number, projectName: string): Promise<ProjectSettings>;
|
|
25
|
+
export declare function fetchDeployComponentsMetadata(accountId: number, projectId: number): Promise<ComponentMetadataResponse>;
|
|
26
|
+
export declare function cancelStagedBuild(accountId: number, projectName: string): Promise<void>;
|
|
27
|
+
export {};
|