@hubspot/local-dev-lib 0.2.2 → 0.2.3-experimental.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/LICENSE +12 -0
- package/README.md +17 -0
- package/api/appsDev.d.ts +6 -0
- package/api/appsDev.js +29 -0
- package/api/customObjects.d.ts +8 -7
- package/api/customObjects.js +13 -16
- package/api/designManager.d.ts +4 -13
- package/api/designManager.js +6 -9
- package/api/developerTestAccounts.d.ts +7 -0
- package/api/developerTestAccounts.js +48 -0
- package/api/fileManager.d.ts +5 -4
- package/api/fileManager.js +11 -11
- package/api/fileMapper.d.ts +8 -7
- package/api/fileMapper.js +17 -17
- package/api/fileTransport.d.ts +4 -0
- package/api/fileTransport.js +39 -0
- package/api/functions.d.ts +7 -4
- package/api/functions.js +22 -11
- package/api/github.d.ts +7 -9
- package/api/github.js +31 -13
- package/api/hubdb.d.ts +11 -10
- package/api/hubdb.js +28 -22
- package/api/lighthouseScore.d.ts +4 -4
- package/api/lighthouseScore.js +9 -12
- package/api/localDevAuth.d.ts +8 -16
- package/api/localDevAuth.js +34 -13
- package/api/marketplaceValidation.d.ts +4 -4
- package/api/marketplaceValidation.js +8 -11
- package/api/projects.d.ts +31 -24
- package/api/projects.js +164 -44
- package/api/sandboxHubs.d.ts +6 -4
- package/api/sandboxHubs.js +10 -11
- package/api/sandboxSync.d.ts +4 -4
- package/api/sandboxSync.js +4 -13
- package/api/secrets.d.ts +6 -8
- package/api/secrets.js +9 -12
- package/api/validateHubl.d.ts +2 -1
- package/api/validateHubl.js +3 -6
- package/config/CLIConfiguration.d.ts +15 -11
- package/config/CLIConfiguration.js +175 -90
- package/config/configFile.js +12 -18
- package/config/configUtils.d.ts +2 -21
- package/config/configUtils.js +5 -4
- package/config/config_DEPRECATED.d.ts +6 -8
- package/config/config_DEPRECATED.js +79 -25
- package/config/environment.js +5 -4
- package/config/getAccountIdentifier.d.ts +2 -0
- package/config/getAccountIdentifier.js +15 -0
- package/config/index.d.ts +14 -8
- package/config/index.js +108 -57
- package/constants/config.d.ts +18 -1
- package/constants/config.js +20 -3
- package/constants/environments.d.ts +1 -0
- package/constants/environments.js +1 -0
- package/constants/extensions.d.ts +2 -0
- package/constants/extensions.js +3 -1
- package/constants/files.d.ts +2 -2
- package/constants/files.js +3 -3
- package/errors/errors_DEPRECATED.d.ts +1 -5
- 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 +6 -3
- package/http/getAxiosConfig.js +51 -7
- package/http/index.d.ts +11 -12
- package/http/index.js +35 -41
- package/http/unauthed.d.ts +14 -0
- package/http/unauthed.js +38 -0
- package/lang/en.json +378 -386
- package/lib/archive.d.ts +2 -8
- package/lib/archive.js +34 -30
- package/lib/cms/functions.d.ts +7 -12
- package/lib/cms/functions.js +49 -51
- package/lib/cms/handleFieldsJS.js +16 -14
- package/lib/cms/modules.d.ts +4 -15
- package/lib/cms/modules.js +81 -78
- package/lib/cms/processFieldsJs.js +10 -33
- package/lib/cms/templates.d.ts +43 -3
- package/lib/cms/templates.js +53 -11
- package/lib/cms/uploadFolder.d.ts +3 -14
- package/lib/cms/uploadFolder.js +58 -42
- package/lib/cms/validate.js +1 -1
- package/lib/cms/watch.d.ts +2 -18
- package/lib/cms/watch.js +63 -68
- package/lib/customObjects.js +4 -15
- package/lib/fileManager.d.ts +2 -6
- package/lib/fileManager.js +54 -65
- package/lib/fileMapper.d.ts +4 -15
- package/lib/fileMapper.js +67 -88
- package/lib/fs.d.ts +1 -1
- package/lib/fs.js +10 -6
- package/lib/github.d.ts +12 -14
- package/lib/github.js +70 -35
- package/lib/gitignore.d.ts +2 -0
- package/lib/gitignore.js +21 -4
- package/lib/hubdb.d.ts +3 -2
- package/lib/hubdb.js +11 -9
- package/{utils → lib}/notify.js +2 -2
- package/lib/oauth.d.ts +2 -5
- package/lib/oauth.js +14 -25
- package/lib/path.d.ts +3 -0
- package/lib/path.js +46 -1
- package/lib/personalAccessKey.d.ts +8 -11
- package/lib/personalAccessKey.js +75 -38
- package/lib/portManager.d.ts +3 -5
- package/lib/portManager.js +18 -6
- package/lib/trackUsage.js +18 -11
- package/lib/urls.js +5 -1
- 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 +5 -27
- package/models/OAuth2Manager.js +41 -64
- package/package.json +34 -35
- package/types/Accounts.d.ts +103 -3
- package/types/Apps.d.ts +77 -0
- package/types/Archive.d.ts +9 -0
- package/types/Archive.js +2 -0
- package/types/Build.d.ts +4 -2
- package/types/ComponentStructure.d.ts +30 -10
- package/types/Config.d.ts +19 -2
- package/types/Deploy.d.ts +3 -2
- package/types/DesignManager.d.ts +10 -0
- package/types/DesignManager.js +2 -0
- package/types/Error.d.ts +9 -5
- package/types/FieldsJS.d.ts +1 -0
- package/types/FieldsJS.js +2 -0
- package/types/FileManager.d.ts +1 -1
- package/types/Files.d.ts +43 -4
- package/types/Functions.d.ts +52 -0
- package/types/Github.d.ts +13 -0
- package/types/Http.d.ts +12 -11
- package/types/Hubdb.d.ts +9 -0
- package/types/MarketplaceValidation.d.ts +7 -3
- package/types/Migration.d.ts +28 -0
- package/types/Migration.js +10 -0
- package/types/Modules.d.ts +11 -0
- package/types/PortManager.d.ts +7 -0
- package/types/Project.d.ts +30 -0
- package/types/ProjectLog.d.ts +9 -0
- package/types/ProjectLog.js +2 -0
- package/types/Sandbox.d.ts +37 -47
- package/types/Schemas.d.ts +56 -0
- package/types/Secrets.d.ts +3 -0
- package/types/Secrets.js +2 -0
- package/types/developerTestAccounts.d.ts +13 -0
- package/types/developerTestAccounts.js +2 -0
- package/utils/PortManagerServer.d.ts +6 -7
- package/utils/PortManagerServer.js +22 -16
- package/utils/{getAccountIdentifier.d.ts → accounts.d.ts} +0 -6
- package/utils/{getAccountIdentifier.js → accounts.js} +1 -13
- package/utils/cms/fieldsJS.d.ts +1 -2
- package/utils/cms/modules.js +2 -2
- package/utils/detectPort.js +3 -3
- package/utils/git.d.ts +1 -7
- package/utils/git.js +2 -18
- package/errors/apiErrors.d.ts +0 -19
- package/errors/apiErrors.js +0 -179
- package/errors/fileSystemErrors.d.ts +0 -5
- package/errors/fileSystemErrors.js +0 -31
- package/errors/standardErrors.d.ts +0 -27
- package/errors/standardErrors.js +0 -59
- package/lang/lang/en.json +0 -401
- package/lib/logging/git.d.ts +0 -2
- package/lib/logging/git.js +0 -54
- package/lib/logging/logs.d.ts +0 -22
- package/lib/logging/logs.js +0 -86
- package/lib/logging/table.d.ts +0 -3
- package/lib/logging/table.js +0 -47
- package/lib/sandboxes.d.ts +0 -14
- package/lib/sandboxes.js +0 -71
- package/models/HubSpotAuthError.d.ts +0 -12
- package/models/HubSpotAuthError.js +0 -20
- package/types/LogCallbacks.d.ts +0 -7
- package/utils/logger.d.ts +0 -5
- package/utils/logger.js +0 -23
- package/utils/objectUtils.d.ts +0 -8
- package/utils/objectUtils.js +0 -33
- /package/{utils → lib}/escapeRegExp.d.ts +0 -0
- /package/{utils → lib}/escapeRegExp.js +0 -0
- /package/lib/{logging/logger.d.ts → logger.d.ts} +0 -0
- /package/lib/{logging/logger.js → logger.js} +0 -0
- /package/{utils → lib}/notify.d.ts +0 -0
- /package/types/{LogCallbacks.js → Apps.js} +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Copyright 2019 HubSpot, Inc.
|
|
2
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
you may not use this file except in compliance with the License.
|
|
4
|
+
You may obtain a copy of the License at
|
|
5
|
+
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
|
|
8
|
+
Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
See the License for the specific language governing permissions and
|
|
12
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# hubspot/local-dev-lib
|
|
2
|
+
|
|
3
|
+
Provides library functionality for HubSpot local development tooling, including the [HubSpot CLI](https://github.com/HubSpot/hubspot-cli).
|
|
4
|
+
|
|
5
|
+
**NOTE:** This library is intended to replace the deprecated [@hubspot/cli-lib](https://github.com/HubSpot/cli-lib) library.
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
This library contains utils that facilitate interactions with HubSpot. It is consumed by the [HubSpot CLI](https://github.com/HubSpot/hubspot-cli) as well as other HubSpot development tooling. Major exports include:
|
|
10
|
+
|
|
11
|
+
- Config utils for managing HubSpot account configuration and access keys ([docs](./config/README.md))
|
|
12
|
+
- API utils to interact with HubSpot assets such as Design Manager and Developer Projects ([docs](./api/README.md))
|
|
13
|
+
- Utils to navigate the local filesystem, parse common HubSpot files, interact with common HubSpot objects, and connect with GitHub ([docs](./lib/README.md))
|
|
14
|
+
|
|
15
|
+
## Contributing
|
|
16
|
+
|
|
17
|
+
For more information on developing, see the [Contributing Guide](CONTRIBUTING.md).
|
package/api/appsDev.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PublicApp, PublicAppInstallCounts, PublicAppDeveloperTestAccountInstallData, FetchPublicAppsForPortalResponse } from '../types/Apps';
|
|
2
|
+
import { HubSpotPromise } from '../types/Http';
|
|
3
|
+
export declare function fetchPublicAppsForPortal(accountId: number): HubSpotPromise<FetchPublicAppsForPortalResponse>;
|
|
4
|
+
export declare function fetchPublicAppDeveloperTestAccountInstallData(appId: number, accountId: number): HubSpotPromise<PublicAppDeveloperTestAccountInstallData>;
|
|
5
|
+
export declare function fetchPublicAppProductionInstallCounts(appId: number, accountId: number): HubSpotPromise<PublicAppInstallCounts>;
|
|
6
|
+
export declare function fetchPublicAppMetadata(appId: number, accountId: number): HubSpotPromise<PublicApp>;
|
package/api/appsDev.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchPublicAppMetadata = exports.fetchPublicAppProductionInstallCounts = exports.fetchPublicAppDeveloperTestAccountInstallData = exports.fetchPublicAppsForPortal = void 0;
|
|
4
|
+
const http_1 = require("../http");
|
|
5
|
+
const APPS_DEV_API_PATH = 'apps-dev/external/public/v3';
|
|
6
|
+
function fetchPublicAppsForPortal(accountId) {
|
|
7
|
+
return http_1.http.get(accountId, {
|
|
8
|
+
url: `${APPS_DEV_API_PATH}/full/portal`,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
exports.fetchPublicAppsForPortal = fetchPublicAppsForPortal;
|
|
12
|
+
function fetchPublicAppDeveloperTestAccountInstallData(appId, accountId) {
|
|
13
|
+
return http_1.http.get(accountId, {
|
|
14
|
+
url: `${APPS_DEV_API_PATH}/${appId}/test-portal-installs`,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
exports.fetchPublicAppDeveloperTestAccountInstallData = fetchPublicAppDeveloperTestAccountInstallData;
|
|
18
|
+
function fetchPublicAppProductionInstallCounts(appId, accountId) {
|
|
19
|
+
return http_1.http.get(accountId, {
|
|
20
|
+
url: `${APPS_DEV_API_PATH}/${appId}/install-counts-without-test-portals`,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
exports.fetchPublicAppProductionInstallCounts = fetchPublicAppProductionInstallCounts;
|
|
24
|
+
function fetchPublicAppMetadata(appId, accountId) {
|
|
25
|
+
return http_1.http.get(accountId, {
|
|
26
|
+
url: `${APPS_DEV_API_PATH}/${appId}/full`,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
exports.fetchPublicAppMetadata = fetchPublicAppMetadata;
|
package/api/customObjects.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { FetchSchemasResponse, Schema } from '../types/Schemas';
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
1
|
+
import { FetchSchemasResponse, Schema, SchemaDefinition, ObjectDefinition, CreateObjectsResponse } from '../types/Schemas';
|
|
2
|
+
import { HubSpotPromise } from '../types/Http';
|
|
3
|
+
export declare function batchCreateObjects(accountId: number, objectTypeId: string, objects: ObjectDefinition): HubSpotPromise<CreateObjectsResponse>;
|
|
4
|
+
export declare function createObjectSchema(accountId: number, schema: SchemaDefinition): HubSpotPromise<Schema>;
|
|
5
|
+
export declare function updateObjectSchema(accountId: number, schemaObjectType: string, schema: SchemaDefinition): HubSpotPromise<Schema>;
|
|
6
|
+
export declare function fetchObjectSchema(accountId: number, schemaObjectType: string): HubSpotPromise<Schema>;
|
|
7
|
+
export declare function fetchObjectSchemas(accountId: number): HubSpotPromise<FetchSchemasResponse>;
|
|
8
|
+
export declare function deleteObjectSchema(accountId: number, schemaObjectType: string): HubSpotPromise<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
|
-
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,13 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 {};
|
|
1
|
+
import { HubSpotPromise, QueryParams } from '../types/Http';
|
|
2
|
+
import { FetchThemesResponse, FetchBuiltinMappingResponse } from '../types/DesignManager';
|
|
3
|
+
export declare function fetchThemes(accountId: number, params?: QueryParams): HubSpotPromise<FetchThemesResponse>;
|
|
4
|
+
export declare function fetchBuiltinMapping(accountId: number): HubSpotPromise<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
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DeveloperTestAccount, FetchDeveloperTestAccountsResponse } from '../types/developerTestAccounts';
|
|
2
|
+
import { Environment } from '../types/Config';
|
|
3
|
+
import { HubSpotPromise } from '../types/Http';
|
|
4
|
+
export declare function fetchDeveloperTestAccounts(accountId: number): HubSpotPromise<FetchDeveloperTestAccountsResponse>;
|
|
5
|
+
export declare function createDeveloperTestAccount(accountId: number, accountName: string): HubSpotPromise<DeveloperTestAccount>;
|
|
6
|
+
export declare function deleteDeveloperTestAccount(accountId: number, testAccountId: number): HubSpotPromise<void>;
|
|
7
|
+
export declare function fetchDeveloperTestAccountData(accessToken: string, accountId: number, env?: Environment): HubSpotPromise<DeveloperTestAccount>;
|
|
@@ -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.fetchDeveloperTestAccountData = exports.deleteDeveloperTestAccount = exports.createDeveloperTestAccount = exports.fetchDeveloperTestAccounts = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const http_1 = require("../http");
|
|
9
|
+
const getAxiosConfig_1 = require("../http/getAxiosConfig");
|
|
10
|
+
const environments_1 = require("../constants/environments");
|
|
11
|
+
const api_1 = require("../constants/api");
|
|
12
|
+
const TEST_ACCOUNTS_API_PATH = 'integrators/test-portals/v2';
|
|
13
|
+
function fetchDeveloperTestAccounts(accountId) {
|
|
14
|
+
return http_1.http.get(accountId, {
|
|
15
|
+
url: TEST_ACCOUNTS_API_PATH,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
exports.fetchDeveloperTestAccounts = fetchDeveloperTestAccounts;
|
|
19
|
+
function createDeveloperTestAccount(accountId, accountName) {
|
|
20
|
+
return http_1.http.post(accountId, {
|
|
21
|
+
url: TEST_ACCOUNTS_API_PATH,
|
|
22
|
+
data: { accountName, generatePersonalAccessKey: true },
|
|
23
|
+
timeout: api_1.SANDBOX_TIMEOUT,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.createDeveloperTestAccount = createDeveloperTestAccount;
|
|
27
|
+
function deleteDeveloperTestAccount(accountId, testAccountId) {
|
|
28
|
+
return http_1.http.delete(accountId, {
|
|
29
|
+
url: `${TEST_ACCOUNTS_API_PATH}/${testAccountId}`,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
exports.deleteDeveloperTestAccount = deleteDeveloperTestAccount;
|
|
33
|
+
function fetchDeveloperTestAccountData(accessToken, accountId, env = environments_1.ENVIRONMENTS.PROD) {
|
|
34
|
+
const axiosConfig = (0, getAxiosConfig_1.getAxiosConfig)({
|
|
35
|
+
env,
|
|
36
|
+
url: `${TEST_ACCOUNTS_API_PATH}/self`,
|
|
37
|
+
params: { portalId: accountId },
|
|
38
|
+
});
|
|
39
|
+
const reqWithToken = {
|
|
40
|
+
...axiosConfig,
|
|
41
|
+
headers: {
|
|
42
|
+
...axiosConfig.headers,
|
|
43
|
+
Authorization: `Bearer ${accessToken}`,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
return (0, axios_1.default)(reqWithToken);
|
|
47
|
+
}
|
|
48
|
+
exports.fetchDeveloperTestAccountData = fetchDeveloperTestAccountData;
|
package/api/fileManager.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { HubSpotPromise } from '../types/Http';
|
|
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): HubSpotPromise<UploadResponse>;
|
|
4
|
+
export declare function fetchStat(accountId: number, src: string): HubSpotPromise<FetchStatResponse>;
|
|
5
|
+
export declare function fetchFiles(accountId: number, folderId: number | 'None', offset: number, archived?: boolean): HubSpotPromise<FetchFilesResponse>;
|
|
6
|
+
export declare function fetchFolders(accountId: number, folderId: number | 'None'): HubSpotPromise<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,23 +26,23 @@ 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,
|
|
47
47
|
offset: offset,
|
|
48
48
|
folder_id: folderId,
|
|
@@ -51,10 +51,10 @@ 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,
|
|
59
59
|
parent_folder_id: folderId,
|
|
60
60
|
},
|
package/api/fileMapper.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { FileMapperNode, FileMapperOptions, FileTree } from '../types/Files';
|
|
3
|
+
import { HubSpotPromise } from '../types/Http';
|
|
3
4
|
export declare const FILE_MAPPER_API_PATH = "content/filemapper/v1";
|
|
4
5
|
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):
|
|
6
|
+
export declare function upload(accountId: number, src: string, dest: string, options?: FileMapperOptions): HubSpotPromise<void>;
|
|
7
|
+
export declare function fetchModule(accountId: number, moduleId: number, options?: FileMapperOptions): HubSpotPromise<FileTree>;
|
|
7
8
|
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):
|
|
9
|
+
export declare function download(accountId: number, filepath: string, options?: FileMapperOptions): HubSpotPromise<FileMapperNode>;
|
|
10
|
+
export declare function downloadDefault(accountId: number, filepath: string, options?: FileMapperOptions): HubSpotPromise<FileMapperNode>;
|
|
11
|
+
export declare function deleteFile(accountId: number, filePath: string): HubSpotPromise<void>;
|
|
12
|
+
export declare function moveFile(accountId: number, srcPath: string, destPath: string): HubSpotPromise<void>;
|
|
13
|
+
export declare function getDirectoryContentsByPath(accountId: number, path: string): HubSpotPromise<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
|
-
...options,
|
|
90
89
|
});
|
|
91
90
|
}
|
|
92
91
|
exports.deleteFile = deleteFile;
|
|
93
92
|
// Moves file from srcPath to destPath
|
|
94
|
-
|
|
95
|
-
return http_1.
|
|
93
|
+
function moveFile(accountId, srcPath, destPath) {
|
|
94
|
+
return http_1.http.put(accountId, {
|
|
96
95
|
url: `${exports.FILE_MAPPER_API_PATH}/rename/${srcPath}?path=${destPath}`,
|
|
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
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { HubSpotPromise } from '../types/Http';
|
|
2
|
+
export declare function createSchemaFromHubFile(accountId: number, filepath: string): HubSpotPromise;
|
|
3
|
+
export declare function updateSchemaFromHubFile(accountId: number, filepath: string): HubSpotPromise;
|
|
4
|
+
export declare function fetchHubFileSchema(accountId: number, objectName: string, path: string): HubSpotPromise;
|
|
@@ -0,0 +1,39 @@
|
|
|
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.fetchHubFileSchema = exports.updateSchemaFromHubFile = exports.createSchemaFromHubFile = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const path_2 = require("../lib/path");
|
|
10
|
+
const http_1 = require("../http");
|
|
11
|
+
const HUBFILES_API_PATH = '/file-transport/v1/hubfiles';
|
|
12
|
+
function createSchemaFromHubFile(accountId, filepath) {
|
|
13
|
+
const file = fs_1.default.createReadStream(path_1.default.resolve((0, path_2.getCwd)(), filepath));
|
|
14
|
+
return http_1.http.post(accountId, {
|
|
15
|
+
url: `${HUBFILES_API_PATH}/object-schemas`,
|
|
16
|
+
data: {
|
|
17
|
+
file,
|
|
18
|
+
},
|
|
19
|
+
headers: { 'Content-Type': 'multipart/form-data' },
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
exports.createSchemaFromHubFile = createSchemaFromHubFile;
|
|
23
|
+
async function updateSchemaFromHubFile(accountId, filepath) {
|
|
24
|
+
const file = fs_1.default.createReadStream(path_1.default.resolve((0, path_2.getCwd)(), filepath));
|
|
25
|
+
return http_1.http.put(accountId, {
|
|
26
|
+
url: `${HUBFILES_API_PATH}/object-schemas`,
|
|
27
|
+
data: {
|
|
28
|
+
file,
|
|
29
|
+
},
|
|
30
|
+
headers: { 'Content-Type': 'multipart/form-data' },
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
exports.updateSchemaFromHubFile = updateSchemaFromHubFile;
|
|
34
|
+
async function fetchHubFileSchema(accountId, objectName, path) {
|
|
35
|
+
return http_1.http.getOctetStream(accountId, {
|
|
36
|
+
url: `${HUBFILES_API_PATH}/object-schemas/${objectName}`,
|
|
37
|
+
}, path);
|
|
38
|
+
}
|
|
39
|
+
exports.fetchHubFileSchema = fetchHubFileSchema;
|
package/api/functions.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
1
|
+
import { HubSpotPromise, QueryParams } from '../types/Http';
|
|
2
|
+
import { GetBuildStatusResponse, FunctionLog, GetRoutesResponse, GetFunctionLogsResponse } from '../types/Functions';
|
|
3
|
+
export declare function getRoutes(accountId: number): HubSpotPromise<GetRoutesResponse>;
|
|
4
|
+
export declare function getFunctionLogs(accountId: number, route: string, params?: QueryParams): HubSpotPromise<GetFunctionLogsResponse>;
|
|
5
|
+
export declare function getLatestFunctionLog(accountId: number, route: string): HubSpotPromise<FunctionLog>;
|
|
6
|
+
export declare function buildPackage(accountId: number, folderPath: string): HubSpotPromise<string>;
|
|
7
|
+
export declare function getBuildStatus(accountId: number, buildId: number): HubSpotPromise<GetBuildStatusResponse>;
|
package/api/functions.js
CHANGED
|
@@ -1,19 +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
|
-
exports.getBuildStatus = exports.buildPackage = exports.getRoutes = void 0;
|
|
7
|
-
const http_1 =
|
|
3
|
+
exports.getBuildStatus = exports.buildPackage = exports.getLatestFunctionLog = exports.getFunctionLogs = exports.getRoutes = void 0;
|
|
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
|
-
|
|
16
|
-
|
|
12
|
+
function getFunctionLogs(accountId, route, params = {}) {
|
|
13
|
+
const { limit = 5 } = params;
|
|
14
|
+
return http_1.http.get(accountId, {
|
|
15
|
+
url: `${FUNCTION_API_PATH}/results/by-route/${encodeURIComponent(route)}`,
|
|
16
|
+
params: { ...params, limit },
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
exports.getFunctionLogs = getFunctionLogs;
|
|
20
|
+
function getLatestFunctionLog(accountId, route) {
|
|
21
|
+
return http_1.http.get(accountId, {
|
|
22
|
+
url: `${FUNCTION_API_PATH}/results/by-route/${encodeURIComponent(route)}/latest`,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
exports.getLatestFunctionLog = getLatestFunctionLog;
|
|
26
|
+
function buildPackage(accountId, folderPath) {
|
|
27
|
+
return http_1.http.post(accountId, {
|
|
17
28
|
url: `${FUNCTION_API_PATH}/build/async`,
|
|
18
29
|
headers: {
|
|
19
30
|
Accept: 'text/plain',
|
|
@@ -24,8 +35,8 @@ async function buildPackage(accountId, folderPath) {
|
|
|
24
35
|
});
|
|
25
36
|
}
|
|
26
37
|
exports.buildPackage = buildPackage;
|
|
27
|
-
|
|
28
|
-
return http_1.
|
|
38
|
+
function getBuildStatus(accountId, buildId) {
|
|
39
|
+
return http_1.http.get(accountId, {
|
|
29
40
|
url: `${FUNCTION_API_PATH}/build/${buildId}/poll`,
|
|
30
41
|
});
|
|
31
42
|
}
|
package/api/github.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { GithubReleaseData, GithubRepoFile, RepoPath } from '../types/Github';
|
|
3
|
+
import { HubSpotPromise } from '../types/Http';
|
|
4
4
|
declare global {
|
|
5
5
|
var githubToken: string;
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function fetchRepoContents(repoPath: RepoPath, path: string, ref?: string): Promise<AxiosResponse<Array<GithubRepoFile>>>;
|
|
13
|
-
export {};
|
|
7
|
+
export declare function fetchRepoReleaseData(repoPath: RepoPath, tag?: string): HubSpotPromise<GithubReleaseData>;
|
|
8
|
+
export declare function fetchRepoAsZip(zipUrl: string): HubSpotPromise<Buffer>;
|
|
9
|
+
export declare function fetchRepoFile<T = Buffer>(repoPath: RepoPath, filePath: string, ref: string): HubSpotPromise<T>;
|
|
10
|
+
export declare function fetchRepoFileByDownloadUrl(downloadUrl: string): HubSpotPromise<Buffer>;
|
|
11
|
+
export declare function fetchRepoContents(repoPath: RepoPath, path: string, ref?: string): HubSpotPromise<Array<GithubRepoFile>>;
|