@hubspot/local-dev-lib 1.13.1 → 2.0.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 +6 -5
- package/api/appsDev.js +6 -10
- package/api/customObjects.d.ts +7 -6
- package/api/customObjects.js +13 -16
- package/api/designManager.d.ts +3 -2
- package/api/designManager.js +5 -8
- package/api/developerTestAccounts.d.ts +5 -4
- package/api/developerTestAccounts.js +9 -10
- package/api/fileManager.d.ts +5 -4
- package/api/fileManager.js +9 -9
- package/api/fileMapper.d.ts +8 -8
- package/api/fileMapper.js +16 -16
- package/api/fileTransport.d.ts +4 -3
- package/api/fileTransport.js +5 -5
- package/api/functions.d.ts +6 -5
- package/api/functions.js +11 -14
- package/api/github.d.ts +6 -6
- package/api/github.js +29 -13
- package/api/hubdb.d.ts +9 -8
- package/api/hubdb.js +17 -20
- package/api/lighthouseScore.d.ts +4 -3
- package/api/lighthouseScore.js +7 -10
- package/api/localDevAuth.d.ts +5 -4
- package/api/localDevAuth.js +8 -9
- package/api/marketplaceValidation.d.ts +4 -3
- package/api/marketplaceValidation.js +4 -7
- package/api/projects.d.ts +31 -30
- package/api/projects.js +52 -52
- package/api/sandboxHubs.d.ts +5 -4
- package/api/sandboxHubs.js +9 -10
- package/api/sandboxSync.d.ts +4 -4
- package/api/sandboxSync.js +5 -14
- package/api/secrets.d.ts +5 -4
- package/api/secrets.js +9 -12
- package/api/validateHubl.d.ts +2 -1
- package/api/validateHubl.js +3 -6
- package/config/CLIConfiguration.d.ts +3 -3
- package/config/CLIConfiguration.js +22 -20
- package/config/configFile.js +7 -14
- package/config/config_DEPRECATED.js +5 -2
- package/config/index.js +45 -48
- package/errors/errors_DEPRECATED.js +2 -2
- package/errors/index.d.ts +18 -0
- package/errors/index.js +63 -0
- package/http/addQueryParams.d.ts +2 -0
- package/http/addQueryParams.js +14 -0
- package/http/getAxiosConfig.d.ts +2 -2
- package/http/getAxiosConfig.js +10 -2
- package/http/index.d.ts +9 -14
- package/http/index.js +28 -53
- package/http/unauthed.d.ts +15 -0
- package/http/unauthed.js +38 -0
- package/lang/en.json +1 -2
- package/lang/lang/en.json +1 -2
- package/lib/archive.js +11 -10
- package/lib/cms/functions.d.ts +7 -1
- package/lib/cms/functions.js +22 -18
- package/lib/cms/handleFieldsJS.js +8 -7
- package/lib/cms/modules.js +4 -5
- package/lib/cms/processFieldsJs.js +8 -7
- package/lib/cms/templates.js +2 -3
- package/lib/cms/uploadFolder.js +16 -14
- package/lib/cms/validate.js +1 -1
- package/lib/cms/watch.js +16 -9
- package/lib/customObjects.js +4 -15
- package/lib/fileManager.js +22 -21
- package/lib/fileMapper.js +24 -31
- package/lib/fs.js +2 -2
- package/lib/github.js +21 -21
- package/lib/gitignore.js +2 -2
- package/lib/hubdb.d.ts +3 -2
- package/lib/hubdb.js +11 -9
- package/lib/notify.js +2 -2
- package/lib/oauth.d.ts +1 -1
- package/lib/oauth.js +8 -17
- package/lib/personalAccessKey.js +16 -21
- package/lib/portManager.js +2 -2
- package/lib/trackUsage.js +3 -3
- package/models/FileSystemError.d.ts +6 -0
- package/models/FileSystemError.js +47 -0
- package/models/HubSpotHttpError.d.ts +24 -0
- package/models/HubSpotHttpError.js +197 -0
- package/models/OAuth2Manager.d.ts +1 -2
- package/models/OAuth2Manager.js +13 -28
- package/package.json +2 -1
- package/types/Error.d.ts +7 -5
- package/types/Files.d.ts +4 -4
- package/types/Http.d.ts +6 -10
- package/types/Sandbox.d.ts +0 -5
- package/utils/PortManagerServer.d.ts +3 -3
- package/utils/PortManagerServer.js +9 -9
- package/utils/cms/modules.js +2 -2
- package/utils/detectPort.js +3 -3
- package/errors/apiErrors.d.ts +0 -25
- package/errors/apiErrors.js +0 -176
- package/errors/fileSystemErrors.d.ts +0 -6
- package/errors/fileSystemErrors.js +0 -35
- package/errors/standardErrors.d.ts +0 -20
- package/errors/standardErrors.js +0 -62
- package/lib/developerTestAccounts.d.ts +0 -4
- package/lib/developerTestAccounts.js +0 -35
- package/lib/sandboxes.d.ts +0 -14
- package/lib/sandboxes.js +0 -70
- package/models/HubSpotAuthError.d.ts +0 -12
- package/models/HubSpotAuthError.js +0 -20
package/api/appsDev.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
1
|
+
import { AxiosPromise } from 'axios';
|
|
2
|
+
import { PublicApp, PublicAppInstallCounts, PublicAppDeveloperTestAccountInstallData, FetchPublicAppsForPortalResponse } from '../types/Apps';
|
|
3
|
+
export declare function fetchPublicAppsForPortal(accountId: number): AxiosPromise<FetchPublicAppsForPortalResponse>;
|
|
4
|
+
export declare function fetchPublicAppDeveloperTestAccountInstallData(appId: number, accountId: number): AxiosPromise<PublicAppDeveloperTestAccountInstallData>;
|
|
5
|
+
export declare function fetchPublicAppProductionInstallCounts(appId: number, accountId: number): AxiosPromise<PublicAppInstallCounts>;
|
|
6
|
+
export declare function fetchPublicAppMetadata(appId: number, accountId: number): AxiosPromise<PublicApp>;
|
package/api/appsDev.js
CHANGED
|
@@ -1,32 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.fetchPublicAppMetadata = exports.fetchPublicAppProductionInstallCounts = exports.fetchPublicAppDeveloperTestAccountInstallData = exports.fetchPublicAppsForPortal = void 0;
|
|
7
|
-
const http_1 =
|
|
4
|
+
const http_1 = require("../http");
|
|
8
5
|
const APPS_DEV_API_PATH = 'apps-dev/external/public/v3';
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
function fetchPublicAppsForPortal(accountId) {
|
|
7
|
+
return http_1.http.get(accountId, {
|
|
11
8
|
url: `${APPS_DEV_API_PATH}/full/portal`,
|
|
12
9
|
});
|
|
13
|
-
return resp ? resp.results : [];
|
|
14
10
|
}
|
|
15
11
|
exports.fetchPublicAppsForPortal = fetchPublicAppsForPortal;
|
|
16
12
|
function fetchPublicAppDeveloperTestAccountInstallData(appId, accountId) {
|
|
17
|
-
return http_1.
|
|
13
|
+
return http_1.http.get(accountId, {
|
|
18
14
|
url: `${APPS_DEV_API_PATH}/${appId}/test-portal-installs`,
|
|
19
15
|
});
|
|
20
16
|
}
|
|
21
17
|
exports.fetchPublicAppDeveloperTestAccountInstallData = fetchPublicAppDeveloperTestAccountInstallData;
|
|
22
18
|
function fetchPublicAppProductionInstallCounts(appId, accountId) {
|
|
23
|
-
return http_1.
|
|
19
|
+
return http_1.http.get(accountId, {
|
|
24
20
|
url: `${APPS_DEV_API_PATH}/${appId}/install-counts-without-test-portals`,
|
|
25
21
|
});
|
|
26
22
|
}
|
|
27
23
|
exports.fetchPublicAppProductionInstallCounts = fetchPublicAppProductionInstallCounts;
|
|
28
24
|
function fetchPublicAppMetadata(appId, accountId) {
|
|
29
|
-
return http_1.
|
|
25
|
+
return http_1.http.get(accountId, {
|
|
30
26
|
url: `${APPS_DEV_API_PATH}/${appId}/full`,
|
|
31
27
|
});
|
|
32
28
|
}
|
package/api/customObjects.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { AxiosPromise } from 'axios';
|
|
1
2
|
import { FetchSchemasResponse, Schema, CreateObjectsResponse } from '../types/Schemas';
|
|
2
|
-
export declare function batchCreateObjects(accountId: number, objectTypeId: string, objects: JSON):
|
|
3
|
-
export declare function createObjectSchema(accountId: number, schema: JSON):
|
|
4
|
-
export declare function updateObjectSchema(accountId: number, schemaObjectType: string, schema: Schema):
|
|
5
|
-
export declare function fetchObjectSchema(accountId: number, schemaObjectType: string):
|
|
6
|
-
export declare function fetchObjectSchemas(accountId: number):
|
|
7
|
-
export declare function deleteObjectSchema(accountId: number, schemaObjectType: string):
|
|
3
|
+
export declare function batchCreateObjects(accountId: number, objectTypeId: string, objects: JSON): AxiosPromise<CreateObjectsResponse>;
|
|
4
|
+
export declare function createObjectSchema(accountId: number, schema: JSON): AxiosPromise<Schema>;
|
|
5
|
+
export declare function updateObjectSchema(accountId: number, schemaObjectType: string, schema: Schema): AxiosPromise<Schema>;
|
|
6
|
+
export declare function fetchObjectSchema(accountId: number, schemaObjectType: string): AxiosPromise<Schema>;
|
|
7
|
+
export declare function fetchObjectSchemas(accountId: number): AxiosPromise<FetchSchemasResponse>;
|
|
8
|
+
export declare function deleteObjectSchema(accountId: number, schemaObjectType: string): AxiosPromise<void>;
|
package/api/customObjects.js
CHANGED
|
@@ -1,47 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.deleteObjectSchema = exports.fetchObjectSchemas = exports.fetchObjectSchema = exports.updateObjectSchema = exports.createObjectSchema = exports.batchCreateObjects = void 0;
|
|
7
|
-
const http_1 =
|
|
4
|
+
const http_1 = require("../http");
|
|
8
5
|
const CUSTOM_OBJECTS_API_PATH = 'crm/v3/objects';
|
|
9
6
|
const SCHEMA_API_PATH = 'crm-object-schemas/v3/schemas';
|
|
10
|
-
|
|
11
|
-
return http_1.
|
|
7
|
+
function batchCreateObjects(accountId, objectTypeId, objects) {
|
|
8
|
+
return http_1.http.post(accountId, {
|
|
12
9
|
url: `${CUSTOM_OBJECTS_API_PATH}/${objectTypeId}/batch/create`,
|
|
13
10
|
data: objects,
|
|
14
11
|
});
|
|
15
12
|
}
|
|
16
13
|
exports.batchCreateObjects = batchCreateObjects;
|
|
17
|
-
|
|
18
|
-
return http_1.
|
|
14
|
+
function createObjectSchema(accountId, schema) {
|
|
15
|
+
return http_1.http.post(accountId, {
|
|
19
16
|
url: SCHEMA_API_PATH,
|
|
20
17
|
data: schema,
|
|
21
18
|
});
|
|
22
19
|
}
|
|
23
20
|
exports.createObjectSchema = createObjectSchema;
|
|
24
|
-
|
|
25
|
-
return http_1.
|
|
21
|
+
function updateObjectSchema(accountId, schemaObjectType, schema) {
|
|
22
|
+
return http_1.http.patch(accountId, {
|
|
26
23
|
url: `${SCHEMA_API_PATH}/${schemaObjectType}`,
|
|
27
24
|
data: schema,
|
|
28
25
|
});
|
|
29
26
|
}
|
|
30
27
|
exports.updateObjectSchema = updateObjectSchema;
|
|
31
|
-
|
|
32
|
-
return http_1.
|
|
28
|
+
function fetchObjectSchema(accountId, schemaObjectType) {
|
|
29
|
+
return http_1.http.get(accountId, {
|
|
33
30
|
url: `${SCHEMA_API_PATH}/${schemaObjectType}`,
|
|
34
31
|
});
|
|
35
32
|
}
|
|
36
33
|
exports.fetchObjectSchema = fetchObjectSchema;
|
|
37
|
-
|
|
38
|
-
return http_1.
|
|
34
|
+
function fetchObjectSchemas(accountId) {
|
|
35
|
+
return http_1.http.get(accountId, {
|
|
39
36
|
url: SCHEMA_API_PATH,
|
|
40
37
|
});
|
|
41
38
|
}
|
|
42
39
|
exports.fetchObjectSchemas = fetchObjectSchemas;
|
|
43
|
-
|
|
44
|
-
return http_1.
|
|
40
|
+
function deleteObjectSchema(accountId, schemaObjectType) {
|
|
41
|
+
return http_1.http.delete(accountId, {
|
|
45
42
|
url: `${SCHEMA_API_PATH}/${schemaObjectType}`,
|
|
46
43
|
});
|
|
47
44
|
}
|
package/api/designManager.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { AxiosPromise } from 'axios';
|
|
1
2
|
import { QueryParams } from '../types/Http';
|
|
2
3
|
import { FetchThemesResponse, FetchBuiltinMappingResponse } from '../types/DesignManager';
|
|
3
|
-
export declare function fetchThemes(accountId: number, params?: QueryParams):
|
|
4
|
-
export declare function fetchBuiltinMapping(accountId: number):
|
|
4
|
+
export declare function fetchThemes(accountId: number, params?: QueryParams): AxiosPromise<FetchThemesResponse>;
|
|
5
|
+
export declare function fetchBuiltinMapping(accountId: number): AxiosPromise<FetchBuiltinMappingResponse>;
|
package/api/designManager.js
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.fetchBuiltinMapping = exports.fetchThemes = void 0;
|
|
7
|
-
const http_1 =
|
|
4
|
+
const http_1 = require("../http");
|
|
8
5
|
const DESIGN_MANAGER_API_PATH = 'designmanager/v1';
|
|
9
|
-
|
|
10
|
-
return http_1.
|
|
6
|
+
function fetchThemes(accountId, params = {}) {
|
|
7
|
+
return http_1.http.get(accountId, {
|
|
11
8
|
url: `${DESIGN_MANAGER_API_PATH}/themes/combined`,
|
|
12
9
|
params,
|
|
13
10
|
});
|
|
14
11
|
}
|
|
15
12
|
exports.fetchThemes = fetchThemes;
|
|
16
|
-
|
|
17
|
-
return http_1.
|
|
13
|
+
function fetchBuiltinMapping(accountId) {
|
|
14
|
+
return http_1.http.get(accountId, {
|
|
18
15
|
url: `${DESIGN_MANAGER_API_PATH}/widgets/builtin-mapping`,
|
|
19
16
|
});
|
|
20
17
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { AxiosPromise } from 'axios';
|
|
1
2
|
import { DeveloperTestAccount, FetchDeveloperTestAccountsResponse } from '../types/developerTestAccounts';
|
|
2
3
|
import { Environment } from '../types/Config';
|
|
3
|
-
export declare function fetchDeveloperTestAccounts(accountId: number):
|
|
4
|
-
export declare function createDeveloperTestAccount(accountId: number, accountName: string):
|
|
5
|
-
export declare function deleteDeveloperTestAccount(accountId: number, testAccountId: number):
|
|
6
|
-
export declare function fetchDeveloperTestAccountData(accessToken: string, accountId: number, env?: Environment):
|
|
4
|
+
export declare function fetchDeveloperTestAccounts(accountId: number): AxiosPromise<FetchDeveloperTestAccountsResponse>;
|
|
5
|
+
export declare function createDeveloperTestAccount(accountId: number, accountName: string): AxiosPromise<DeveloperTestAccount>;
|
|
6
|
+
export declare function deleteDeveloperTestAccount(accountId: number, testAccountId: number): AxiosPromise<void>;
|
|
7
|
+
export declare function fetchDeveloperTestAccountData(accessToken: string, accountId: number, env?: Environment): AxiosPromise<DeveloperTestAccount>;
|
|
@@ -5,32 +5,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.fetchDeveloperTestAccountData = exports.deleteDeveloperTestAccount = exports.createDeveloperTestAccount = exports.fetchDeveloperTestAccounts = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const http_1 =
|
|
8
|
+
const http_1 = require("../http");
|
|
9
9
|
const getAxiosConfig_1 = require("../http/getAxiosConfig");
|
|
10
10
|
const environments_1 = require("../constants/environments");
|
|
11
11
|
const api_1 = require("../constants/api");
|
|
12
12
|
const TEST_ACCOUNTS_API_PATH = 'integrators/test-portals/v2';
|
|
13
|
-
|
|
14
|
-
return http_1.
|
|
13
|
+
function fetchDeveloperTestAccounts(accountId) {
|
|
14
|
+
return http_1.http.get(accountId, {
|
|
15
15
|
url: TEST_ACCOUNTS_API_PATH,
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
exports.fetchDeveloperTestAccounts = fetchDeveloperTestAccounts;
|
|
19
|
-
|
|
20
|
-
return http_1.
|
|
19
|
+
function createDeveloperTestAccount(accountId, accountName) {
|
|
20
|
+
return http_1.http.post(accountId, {
|
|
21
21
|
url: TEST_ACCOUNTS_API_PATH,
|
|
22
22
|
data: { accountName, generatePersonalAccessKey: true },
|
|
23
23
|
timeout: api_1.SANDBOX_TIMEOUT,
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
exports.createDeveloperTestAccount = createDeveloperTestAccount;
|
|
27
|
-
|
|
28
|
-
return http_1.
|
|
27
|
+
function deleteDeveloperTestAccount(accountId, testAccountId) {
|
|
28
|
+
return http_1.http.delete(accountId, {
|
|
29
29
|
url: `${TEST_ACCOUNTS_API_PATH}/${testAccountId}`,
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
exports.deleteDeveloperTestAccount = deleteDeveloperTestAccount;
|
|
33
|
-
|
|
33
|
+
function fetchDeveloperTestAccountData(accessToken, accountId, env = environments_1.ENVIRONMENTS.PROD) {
|
|
34
34
|
const axiosConfig = (0, getAxiosConfig_1.getAxiosConfig)({
|
|
35
35
|
env,
|
|
36
36
|
url: `${TEST_ACCOUNTS_API_PATH}/self`,
|
|
@@ -43,7 +43,6 @@ async function fetchDeveloperTestAccountData(accessToken, accountId, env = envir
|
|
|
43
43
|
Authorization: `Bearer ${accessToken}`,
|
|
44
44
|
},
|
|
45
45
|
};
|
|
46
|
-
|
|
47
|
-
return data;
|
|
46
|
+
return (0, axios_1.default)(reqWithToken);
|
|
48
47
|
}
|
|
49
48
|
exports.fetchDeveloperTestAccountData = fetchDeveloperTestAccountData;
|
package/api/fileManager.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { AxiosPromise } from 'axios';
|
|
1
2
|
import { FetchStatResponse, FetchFilesResponse, FetchFolderResponse, UploadResponse } from '../types/FileManager';
|
|
2
|
-
export declare function uploadFile(accountId: number, src: string, dest: string):
|
|
3
|
-
export declare function fetchStat(accountId: number, src: string):
|
|
4
|
-
export declare function fetchFiles(accountId: number, folderId: number | 'None', offset: number, archived?: boolean):
|
|
5
|
-
export declare function fetchFolders(accountId: number, folderId: number | 'None'):
|
|
3
|
+
export declare function uploadFile(accountId: number, src: string, dest: string): AxiosPromise<UploadResponse>;
|
|
4
|
+
export declare function fetchStat(accountId: number, src: string): AxiosPromise<FetchStatResponse>;
|
|
5
|
+
export declare function fetchFiles(accountId: number, folderId: number | 'None', offset: number, archived?: boolean): AxiosPromise<FetchFilesResponse>;
|
|
6
|
+
export declare function fetchFolders(accountId: number, folderId: number | 'None'): AxiosPromise<FetchFolderResponse>;
|
package/api/fileManager.js
CHANGED
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.fetchFolders = exports.fetchFiles = exports.fetchStat = exports.uploadFile = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const http_1 =
|
|
9
|
+
const http_1 = require("../http");
|
|
10
10
|
const FILE_MANAGER_V2_API_PATH = 'filemanager/api/v2';
|
|
11
11
|
const FILE_MANAGER_V3_API_PATH = 'filemanager/api/v3';
|
|
12
|
-
|
|
12
|
+
function uploadFile(accountId, src, dest) {
|
|
13
13
|
const directory = path_1.default.dirname(dest);
|
|
14
14
|
const filename = path_1.default.basename(dest);
|
|
15
15
|
const formData = {
|
|
@@ -26,21 +26,21 @@ async function uploadFile(accountId, src, dest) {
|
|
|
26
26
|
else {
|
|
27
27
|
formData.folderPath = '/';
|
|
28
28
|
}
|
|
29
|
-
return http_1.
|
|
29
|
+
return http_1.http.post(accountId, {
|
|
30
30
|
url: `${FILE_MANAGER_V3_API_PATH}/files/upload`,
|
|
31
31
|
data: formData,
|
|
32
32
|
headers: { 'Content-Type': 'multipart/form-data' },
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
exports.uploadFile = uploadFile;
|
|
36
|
-
|
|
37
|
-
return http_1.
|
|
36
|
+
function fetchStat(accountId, src) {
|
|
37
|
+
return http_1.http.get(accountId, {
|
|
38
38
|
url: `${FILE_MANAGER_V2_API_PATH}/files/stat/${src}`,
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
exports.fetchStat = fetchStat;
|
|
42
|
-
|
|
43
|
-
return http_1.
|
|
42
|
+
function fetchFiles(accountId, folderId, offset, archived) {
|
|
43
|
+
return http_1.http.get(accountId, {
|
|
44
44
|
url: `${FILE_MANAGER_V2_API_PATH}/files/`,
|
|
45
45
|
params: {
|
|
46
46
|
hidden: 0,
|
|
@@ -51,8 +51,8 @@ async function fetchFiles(accountId, folderId, offset, archived) {
|
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
exports.fetchFiles = fetchFiles;
|
|
54
|
-
|
|
55
|
-
return http_1.
|
|
54
|
+
function fetchFolders(accountId, folderId) {
|
|
55
|
+
return http_1.http.get(accountId, {
|
|
56
56
|
url: `${FILE_MANAGER_V2_API_PATH}/folders/`,
|
|
57
57
|
params: {
|
|
58
58
|
hidden: 0,
|
package/api/fileMapper.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { AxiosResponse } from 'axios';
|
|
1
|
+
import { AxiosResponse, AxiosPromise } from 'axios';
|
|
2
2
|
import { FileMapperNode, FileMapperOptions, FileTree } from '../types/Files';
|
|
3
3
|
export declare const FILE_MAPPER_API_PATH = "content/filemapper/v1";
|
|
4
4
|
export declare function createFileMapperNodeFromStreamResponse(filePath: string, response: Partial<AxiosResponse>): FileMapperNode;
|
|
5
|
-
export declare function upload(accountId: number, src: string, dest: string, options?: FileMapperOptions):
|
|
6
|
-
export declare function fetchModule(accountId: number, moduleId: number, options?: FileMapperOptions):
|
|
5
|
+
export declare function upload(accountId: number, src: string, dest: string, options?: FileMapperOptions): AxiosPromise<void>;
|
|
6
|
+
export declare function fetchModule(accountId: number, moduleId: number, options?: FileMapperOptions): AxiosPromise<FileTree>;
|
|
7
7
|
export declare function fetchFileStream(accountId: number, filePath: string, destination: string, options?: FileMapperOptions): Promise<FileMapperNode>;
|
|
8
|
-
export declare function download(accountId: number, filepath: string, options?: FileMapperOptions):
|
|
9
|
-
export declare function downloadDefault(accountId: number, filepath: string, options?: FileMapperOptions):
|
|
10
|
-
export declare function deleteFile(accountId: number, filePath: string):
|
|
11
|
-
export declare function moveFile(accountId: number, srcPath: string, destPath: string):
|
|
12
|
-
export declare function getDirectoryContentsByPath(accountId: number, path: string):
|
|
8
|
+
export declare function download(accountId: number, filepath: string, options?: FileMapperOptions): AxiosPromise<FileMapperNode>;
|
|
9
|
+
export declare function downloadDefault(accountId: number, filepath: string, options?: FileMapperOptions): AxiosPromise<FileMapperNode>;
|
|
10
|
+
export declare function deleteFile(accountId: number, filePath: string): AxiosPromise<void>;
|
|
11
|
+
export declare function moveFile(accountId: number, srcPath: string, destPath: string): AxiosPromise<void>;
|
|
12
|
+
export declare function getDirectoryContentsByPath(accountId: number, path: string): AxiosPromise<FileMapperNode>;
|
package/api/fileMapper.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.getDirectoryContentsByPath = exports.moveFile = exports.deleteFile = exp
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const content_disposition_1 = __importDefault(require("content-disposition"));
|
|
10
|
-
const http_1 =
|
|
10
|
+
const http_1 = require("../http");
|
|
11
11
|
const path_2 = require("../lib/path");
|
|
12
12
|
exports.FILE_MAPPER_API_PATH = 'content/filemapper/v1';
|
|
13
13
|
function createFileMapperNodeFromStreamResponse(filePath, response) {
|
|
@@ -38,8 +38,8 @@ function createFileMapperNodeFromStreamResponse(filePath, response) {
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
exports.createFileMapperNodeFromStreamResponse = createFileMapperNodeFromStreamResponse;
|
|
41
|
-
|
|
42
|
-
return http_1.
|
|
41
|
+
function upload(accountId, src, dest, options = {}) {
|
|
42
|
+
return http_1.http.post(accountId, {
|
|
43
43
|
url: `${exports.FILE_MAPPER_API_PATH}/upload/${encodeURIComponent(dest)}`,
|
|
44
44
|
data: {
|
|
45
45
|
file: fs_1.default.createReadStream(path_1.default.resolve((0, path_2.getCwd)(), src)),
|
|
@@ -50,8 +50,8 @@ async function upload(accountId, src, dest, options = {}) {
|
|
|
50
50
|
}
|
|
51
51
|
exports.upload = upload;
|
|
52
52
|
// Fetch a module by moduleId
|
|
53
|
-
|
|
54
|
-
return http_1.
|
|
53
|
+
function fetchModule(accountId, moduleId, options = {}) {
|
|
54
|
+
return http_1.http.get(accountId, {
|
|
55
55
|
url: `${exports.FILE_MAPPER_API_PATH}/modules/${moduleId}`,
|
|
56
56
|
...options,
|
|
57
57
|
});
|
|
@@ -59,7 +59,7 @@ async function fetchModule(accountId, moduleId, options = {}) {
|
|
|
59
59
|
exports.fetchModule = fetchModule;
|
|
60
60
|
// Fetch a file by file path.
|
|
61
61
|
async function fetchFileStream(accountId, filePath, destination, options = {}) {
|
|
62
|
-
const response = await http_1.
|
|
62
|
+
const response = await http_1.http.getOctetStream(accountId, {
|
|
63
63
|
url: `${exports.FILE_MAPPER_API_PATH}/stream/${encodeURIComponent(filePath)}`,
|
|
64
64
|
...options,
|
|
65
65
|
}, destination);
|
|
@@ -67,39 +67,39 @@ async function fetchFileStream(accountId, filePath, destination, options = {}) {
|
|
|
67
67
|
}
|
|
68
68
|
exports.fetchFileStream = fetchFileStream;
|
|
69
69
|
// Fetch a folder or file node by path.
|
|
70
|
-
|
|
71
|
-
return http_1.
|
|
70
|
+
function download(accountId, filepath, options = {}) {
|
|
71
|
+
return http_1.http.get(accountId, {
|
|
72
72
|
url: `${exports.FILE_MAPPER_API_PATH}/download/${encodeURIComponent(filepath)}`,
|
|
73
73
|
...options,
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
exports.download = download;
|
|
77
77
|
// Fetch a folder or file node by path.
|
|
78
|
-
|
|
79
|
-
return http_1.
|
|
78
|
+
function downloadDefault(accountId, filepath, options = {}) {
|
|
79
|
+
return http_1.http.get(accountId, {
|
|
80
80
|
url: `${exports.FILE_MAPPER_API_PATH}/download-default/${filepath}`,
|
|
81
81
|
...options,
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
exports.downloadDefault = downloadDefault;
|
|
85
85
|
// Delete a file or folder by path
|
|
86
|
-
|
|
87
|
-
return http_1.
|
|
86
|
+
function deleteFile(accountId, filePath) {
|
|
87
|
+
return http_1.http.delete(accountId, {
|
|
88
88
|
url: `${exports.FILE_MAPPER_API_PATH}/delete/${encodeURIComponent(filePath)}`,
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
exports.deleteFile = deleteFile;
|
|
92
92
|
// Moves file from srcPath to destPath
|
|
93
|
-
|
|
94
|
-
return http_1.
|
|
93
|
+
function moveFile(accountId, srcPath, destPath) {
|
|
94
|
+
return http_1.http.put(accountId, {
|
|
95
95
|
url: `${exports.FILE_MAPPER_API_PATH}/rename/${srcPath}?path=${destPath}`,
|
|
96
96
|
headers: { 'Content-Type': 'application/json' },
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
exports.moveFile = moveFile;
|
|
100
100
|
// Get directory contents
|
|
101
|
-
|
|
102
|
-
return http_1.
|
|
101
|
+
function getDirectoryContentsByPath(accountId, path) {
|
|
102
|
+
return http_1.http.get(accountId, {
|
|
103
103
|
url: `${exports.FILE_MAPPER_API_PATH}/meta/${path}`,
|
|
104
104
|
});
|
|
105
105
|
}
|
package/api/fileTransport.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
1
|
+
import { AxiosPromise } from 'axios';
|
|
2
|
+
export declare function createSchemaFromHubFile(accountId: number, filepath: string): AxiosPromise;
|
|
3
|
+
export declare function updateSchemaFromHubFile(accountId: number, filepath: string): AxiosPromise;
|
|
4
|
+
export declare function fetchHubFileSchema(accountId: number, objectName: string, path: string): AxiosPromise;
|
package/api/fileTransport.js
CHANGED
|
@@ -7,11 +7,11 @@ exports.fetchHubFileSchema = exports.updateSchemaFromHubFile = exports.createSch
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const path_2 = require("../lib/path");
|
|
10
|
-
const http_1 =
|
|
10
|
+
const http_1 = require("../http");
|
|
11
11
|
const HUBFILES_API_PATH = '/file-transport/v1/hubfiles';
|
|
12
|
-
|
|
12
|
+
function createSchemaFromHubFile(accountId, filepath) {
|
|
13
13
|
const file = fs_1.default.createReadStream(path_1.default.resolve((0, path_2.getCwd)(), filepath));
|
|
14
|
-
return http_1.
|
|
14
|
+
return http_1.http.post(accountId, {
|
|
15
15
|
url: `${HUBFILES_API_PATH}/object-schemas`,
|
|
16
16
|
data: {
|
|
17
17
|
file,
|
|
@@ -22,7 +22,7 @@ async function createSchemaFromHubFile(accountId, filepath) {
|
|
|
22
22
|
exports.createSchemaFromHubFile = createSchemaFromHubFile;
|
|
23
23
|
async function updateSchemaFromHubFile(accountId, filepath) {
|
|
24
24
|
const file = fs_1.default.createReadStream(path_1.default.resolve((0, path_2.getCwd)(), filepath));
|
|
25
|
-
return http_1.
|
|
25
|
+
return http_1.http.put(accountId, {
|
|
26
26
|
url: `${HUBFILES_API_PATH}/object-schemas`,
|
|
27
27
|
data: {
|
|
28
28
|
file,
|
|
@@ -32,7 +32,7 @@ async function updateSchemaFromHubFile(accountId, filepath) {
|
|
|
32
32
|
}
|
|
33
33
|
exports.updateSchemaFromHubFile = updateSchemaFromHubFile;
|
|
34
34
|
async function fetchHubFileSchema(accountId, objectName, path) {
|
|
35
|
-
return http_1.
|
|
35
|
+
return http_1.http.getOctetStream(accountId, {
|
|
36
36
|
url: `${HUBFILES_API_PATH}/object-schemas/${objectName}`,
|
|
37
37
|
}, path);
|
|
38
38
|
}
|
package/api/functions.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { AxiosPromise } from 'axios';
|
|
1
2
|
import { QueryParams } from '../types/Http';
|
|
2
3
|
import { GetBuildStatusResponse, GetRoutesResponse } from '../types/Functions';
|
|
3
|
-
export declare function getRoutes(accountId: number):
|
|
4
|
-
export declare function getFunctionLogs(accountId: number, route: string, params?: QueryParams):
|
|
5
|
-
export declare function getLatestFunctionLog(accountId: number, route: string):
|
|
6
|
-
export declare function buildPackage(accountId: number, folderPath: string):
|
|
7
|
-
export declare function getBuildStatus(accountId: number, buildId: number):
|
|
4
|
+
export declare function getRoutes(accountId: number): AxiosPromise<GetRoutesResponse>;
|
|
5
|
+
export declare function getFunctionLogs(accountId: number, route: string, params?: QueryParams): AxiosPromise;
|
|
6
|
+
export declare function getLatestFunctionLog(accountId: number, route: string): AxiosPromise;
|
|
7
|
+
export declare function buildPackage(accountId: number, folderPath: string): AxiosPromise<string>;
|
|
8
|
+
export declare function getBuildStatus(accountId: number, buildId: number): AxiosPromise<GetBuildStatusResponse>;
|
package/api/functions.js
CHANGED
|
@@ -1,33 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getBuildStatus = exports.buildPackage = exports.getLatestFunctionLog = exports.getFunctionLogs = exports.getRoutes = void 0;
|
|
7
|
-
const http_1 =
|
|
4
|
+
const http_1 = require("../http");
|
|
8
5
|
const FUNCTION_API_PATH = 'cms/v3/functions';
|
|
9
|
-
|
|
10
|
-
return http_1.
|
|
6
|
+
function getRoutes(accountId) {
|
|
7
|
+
return http_1.http.get(accountId, {
|
|
11
8
|
url: `${FUNCTION_API_PATH}/routes`,
|
|
12
9
|
});
|
|
13
10
|
}
|
|
14
11
|
exports.getRoutes = getRoutes;
|
|
15
|
-
|
|
12
|
+
function getFunctionLogs(accountId, route, params = {}) {
|
|
16
13
|
const { limit = 5 } = params;
|
|
17
|
-
return http_1.
|
|
14
|
+
return http_1.http.get(accountId, {
|
|
18
15
|
url: `${FUNCTION_API_PATH}/results/by-route/${encodeURIComponent(route)}`,
|
|
19
16
|
params: { ...params, limit },
|
|
20
17
|
});
|
|
21
18
|
}
|
|
22
19
|
exports.getFunctionLogs = getFunctionLogs;
|
|
23
|
-
|
|
24
|
-
return http_1.
|
|
20
|
+
function getLatestFunctionLog(accountId, route) {
|
|
21
|
+
return http_1.http.get(accountId, {
|
|
25
22
|
url: `${FUNCTION_API_PATH}/results/by-route/${encodeURIComponent(route)}/latest`,
|
|
26
23
|
});
|
|
27
24
|
}
|
|
28
25
|
exports.getLatestFunctionLog = getLatestFunctionLog;
|
|
29
|
-
|
|
30
|
-
return http_1.
|
|
26
|
+
function buildPackage(accountId, folderPath) {
|
|
27
|
+
return http_1.http.post(accountId, {
|
|
31
28
|
url: `${FUNCTION_API_PATH}/build/async`,
|
|
32
29
|
headers: {
|
|
33
30
|
Accept: 'text/plain',
|
|
@@ -38,8 +35,8 @@ async function buildPackage(accountId, folderPath) {
|
|
|
38
35
|
});
|
|
39
36
|
}
|
|
40
37
|
exports.buildPackage = buildPackage;
|
|
41
|
-
|
|
42
|
-
return http_1.
|
|
38
|
+
function getBuildStatus(accountId, buildId) {
|
|
39
|
+
return http_1.http.get(accountId, {
|
|
43
40
|
url: `${FUNCTION_API_PATH}/build/${buildId}/poll`,
|
|
44
41
|
});
|
|
45
42
|
}
|
package/api/github.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
2
|
+
import { AxiosPromise } from 'axios';
|
|
3
3
|
import { GithubReleaseData, GithubRepoFile, RepoPath } from '../types/Github';
|
|
4
4
|
declare global {
|
|
5
5
|
var githubToken: string;
|
|
6
6
|
}
|
|
7
|
-
export declare function fetchRepoReleaseData(repoPath: RepoPath, tag?: string):
|
|
8
|
-
export declare function fetchRepoAsZip(zipUrl: string):
|
|
9
|
-
export declare function fetchRepoFile(repoPath: RepoPath, filePath: string, ref: string):
|
|
10
|
-
export declare function fetchRepoFileByDownloadUrl(downloadUrl: string):
|
|
11
|
-
export declare function fetchRepoContents(repoPath: RepoPath, path: string, ref?: string):
|
|
7
|
+
export declare function fetchRepoReleaseData(repoPath: RepoPath, tag?: string): AxiosPromise<GithubReleaseData>;
|
|
8
|
+
export declare function fetchRepoAsZip(zipUrl: string): AxiosPromise<Buffer>;
|
|
9
|
+
export declare function fetchRepoFile(repoPath: RepoPath, filePath: string, ref: string): AxiosPromise<Buffer>;
|
|
10
|
+
export declare function fetchRepoFileByDownloadUrl(downloadUrl: string): AxiosPromise<Buffer>;
|
|
11
|
+
export declare function fetchRepoContents(repoPath: RepoPath, path: string, ref?: string): AxiosPromise<Array<GithubRepoFile>>;
|
package/api/github.js
CHANGED
|
@@ -8,48 +8,64 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
8
8
|
const getAxiosConfig_1 = require("../http/getAxiosConfig");
|
|
9
9
|
const GITHUB_REPOS_API = 'https://api.github.com/repos';
|
|
10
10
|
const GITHUB_RAW_CONTENT_API_PATH = 'https://raw.githubusercontent.com';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
function getAdditionalHeaders() {
|
|
12
|
+
const headers = {};
|
|
13
|
+
if (global && global.githubToken) {
|
|
14
|
+
headers.authorization = `Bearer ${global.githubToken}`;
|
|
15
|
+
}
|
|
16
|
+
else if (process.env.GITHUB_TOKEN) {
|
|
17
|
+
headers.authorization = `Bearer ${process.env.GITHUB_TOKEN}`;
|
|
18
|
+
}
|
|
19
|
+
return headers;
|
|
20
|
+
}
|
|
14
21
|
// Returns information about the repo's releases. Defaults to "latest" if no tag is provided
|
|
15
22
|
// https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#get-a-release-by-tag-name
|
|
16
|
-
|
|
23
|
+
function fetchRepoReleaseData(repoPath, tag = '') {
|
|
17
24
|
const URL = `${GITHUB_REPOS_API}/${repoPath}/releases`;
|
|
18
25
|
return axios_1.default.get(`${URL}/${tag ? `tags/${tag}` : 'latest'}`, {
|
|
19
|
-
headers: {
|
|
26
|
+
headers: {
|
|
27
|
+
...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(),
|
|
28
|
+
...getAdditionalHeaders(),
|
|
29
|
+
},
|
|
20
30
|
});
|
|
21
31
|
}
|
|
22
32
|
exports.fetchRepoReleaseData = fetchRepoReleaseData;
|
|
23
33
|
// Returns the entire repo content as a zip, using the zipball_url from fetchRepoReleaseData()
|
|
24
34
|
// https://docs.github.com/en/rest/repos/contents?apiVersion=2022-11-28#download-a-repository-archive-zip
|
|
25
|
-
|
|
35
|
+
function fetchRepoAsZip(zipUrl) {
|
|
26
36
|
return axios_1.default.get(zipUrl, {
|
|
27
37
|
responseType: 'arraybuffer',
|
|
28
|
-
headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...
|
|
38
|
+
headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...getAdditionalHeaders() },
|
|
29
39
|
});
|
|
30
40
|
}
|
|
31
41
|
exports.fetchRepoAsZip = fetchRepoAsZip;
|
|
32
42
|
// Returns the raw file contents via the raw.githubusercontent endpoint
|
|
33
|
-
|
|
43
|
+
function fetchRepoFile(repoPath, filePath, ref) {
|
|
34
44
|
return axios_1.default.get(`${GITHUB_RAW_CONTENT_API_PATH}/${repoPath}/${ref}/${filePath}`, {
|
|
35
|
-
headers: {
|
|
45
|
+
headers: {
|
|
46
|
+
...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(),
|
|
47
|
+
...getAdditionalHeaders(),
|
|
48
|
+
},
|
|
36
49
|
});
|
|
37
50
|
}
|
|
38
51
|
exports.fetchRepoFile = fetchRepoFile;
|
|
39
52
|
// Returns the raw file contents via the raw.githubusercontent endpoint
|
|
40
|
-
|
|
53
|
+
function fetchRepoFileByDownloadUrl(downloadUrl) {
|
|
41
54
|
return axios_1.default.get(downloadUrl, {
|
|
42
|
-
headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...
|
|
55
|
+
headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...getAdditionalHeaders() },
|
|
43
56
|
responseType: 'arraybuffer',
|
|
44
57
|
});
|
|
45
58
|
}
|
|
46
59
|
exports.fetchRepoFileByDownloadUrl = fetchRepoFileByDownloadUrl;
|
|
47
60
|
// Returns the contents of a file or directory in a repository by path
|
|
48
61
|
// https://docs.github.com/en/rest/repos/contents?apiVersion=2022-11-28#get-repository-content
|
|
49
|
-
|
|
62
|
+
function fetchRepoContents(repoPath, path, ref) {
|
|
50
63
|
const refQuery = ref ? `?ref=${ref}` : '';
|
|
51
64
|
return axios_1.default.get(`${GITHUB_REPOS_API}/${repoPath}/contents/${path}${refQuery}`, {
|
|
52
|
-
headers: {
|
|
65
|
+
headers: {
|
|
66
|
+
...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(),
|
|
67
|
+
...getAdditionalHeaders(),
|
|
68
|
+
},
|
|
53
69
|
});
|
|
54
70
|
}
|
|
55
71
|
exports.fetchRepoContents = fetchRepoContents;
|