@hubspot/local-dev-lib 0.2.4 → 0.3.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/customObjects.d.ts +14 -1
- package/api/customObjects.js +1 -1
- package/api/fileTransport.d.ts +3 -0
- package/api/fileTransport.js +39 -0
- package/api/sandboxHubs.d.ts +1 -1
- package/config/CLIConfiguration.d.ts +4 -4
- package/config/CLIConfiguration.js +42 -33
- package/config/configFile.js +5 -4
- package/config/configUtils.js +3 -2
- package/config/config_DEPRECATED.d.ts +2 -1
- package/config/config_DEPRECATED.js +23 -3
- package/config/environment.js +5 -4
- package/config/index.d.ts +2 -1
- package/config/index.js +8 -1
- package/constants/config.d.ts +7 -0
- package/constants/config.js +8 -2
- package/errors/apiErrors.d.ts +7 -2
- package/errors/apiErrors.js +12 -11
- package/errors/standardErrors.d.ts +1 -1
- package/http/index.d.ts +2 -4
- package/http/index.js +7 -8
- package/lang/en.json +10 -10
- package/lang/lang/en.json +10 -10
- package/lib/archive.d.ts +1 -3
- package/lib/archive.js +14 -16
- package/lib/cms/functions.d.ts +1 -3
- package/lib/cms/functions.js +25 -32
- package/lib/cms/handleFieldsJS.js +6 -5
- package/lib/cms/modules.d.ts +2 -3
- package/lib/cms/modules.js +16 -9
- package/lib/cms/templates.d.ts +1 -3
- package/lib/cms/templates.js +6 -7
- package/lib/cms/uploadFolder.d.ts +1 -3
- package/lib/cms/uploadFolder.js +14 -16
- package/lib/cms/watch.d.ts +1 -4
- package/lib/cms/watch.js +34 -47
- package/lib/fileManager.d.ts +2 -6
- package/lib/fileManager.js +31 -42
- package/lib/fileMapper.d.ts +2 -4
- package/lib/fileMapper.js +24 -35
- package/lib/github.d.ts +3 -4
- package/lib/github.js +35 -14
- package/lib/oauth.d.ts +1 -4
- package/lib/oauth.js +6 -8
- package/lib/personalAccessKey.js +19 -2
- package/lib/sandboxes.d.ts +1 -1
- package/lib/sandboxes.js +7 -8
- package/lib/trackUsage.js +5 -4
- package/models/OAuth2Manager.js +8 -7
- package/package.json +1 -1
- package/types/Accounts.d.ts +5 -0
- package/types/Sandbox.d.ts +13 -12
- package/utils/PortManagerServer.js +7 -7
- package/types/LogCallbacks.d.ts +0 -7
- package/types/LogCallbacks.js +0 -2
- package/utils/logger.d.ts +0 -5
- package/utils/logger.js +0 -23
package/api/customObjects.d.ts
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import { FetchSchemasResponse, Schema } from '../types/Schemas';
|
|
2
|
-
|
|
2
|
+
type CreateObjectsResponse = {
|
|
3
|
+
status: string;
|
|
4
|
+
startedAt: string;
|
|
5
|
+
completedAt: string;
|
|
6
|
+
results: Array<{
|
|
7
|
+
id: string;
|
|
8
|
+
properties: Array<any>;
|
|
9
|
+
createdAt: string;
|
|
10
|
+
updatedAt: string;
|
|
11
|
+
archived: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
};
|
|
14
|
+
export declare function batchCreateObjects(accountId: number, objectTypeId: string, objects: JSON): Promise<CreateObjectsResponse>;
|
|
3
15
|
export declare function createObjectSchema(accountId: number, schema: JSON): Promise<Schema>;
|
|
4
16
|
export declare function updateObjectSchema(accountId: number, schemaObjectType: string, schema: Schema): Promise<Schema>;
|
|
5
17
|
export declare function fetchObjectSchema(accountId: number, schemaObjectType: string): Promise<Schema>;
|
|
6
18
|
export declare function fetchObjectSchemas(accountId: number): Promise<FetchSchemasResponse>;
|
|
7
19
|
export declare function deleteObjectSchema(accountId: number, schemaObjectType: string): Promise<void>;
|
|
20
|
+
export {};
|
package/api/customObjects.js
CHANGED
|
@@ -8,7 +8,7 @@ const http_1 = __importDefault(require("../http"));
|
|
|
8
8
|
const CUSTOM_OBJECTS_API_PATH = 'crm/v3/objects';
|
|
9
9
|
const SCHEMA_API_PATH = 'crm-object-schemas/v3/schemas';
|
|
10
10
|
async function batchCreateObjects(accountId, objectTypeId, objects) {
|
|
11
|
-
http_1.default.post(accountId, {
|
|
11
|
+
return http_1.default.post(accountId, {
|
|
12
12
|
url: `${CUSTOM_OBJECTS_API_PATH}/${objectTypeId}/batch/create`,
|
|
13
13
|
data: objects,
|
|
14
14
|
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function createSchemaFromHubFile(accountId: number, filepath: string): Promise<unknown>;
|
|
2
|
+
export declare function updateSchemaFromHubFile(accountId: number, filepath: string): Promise<unknown>;
|
|
3
|
+
export declare function fetchHubFileSchema(accountId: number, objectName: string, path: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
@@ -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 = __importDefault(require("../http"));
|
|
11
|
+
const HUBFILES_API_PATH = '/file-transport/v1/hubfiles';
|
|
12
|
+
async function createSchemaFromHubFile(accountId, filepath) {
|
|
13
|
+
const file = fs_1.default.createReadStream(path_1.default.resolve((0, path_2.getCwd)(), filepath));
|
|
14
|
+
return http_1.default.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.default.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.default.getOctetStream(accountId, {
|
|
36
|
+
url: `${HUBFILES_API_PATH}/object-schemas/${objectName}`,
|
|
37
|
+
}, path);
|
|
38
|
+
}
|
|
39
|
+
exports.fetchHubFileSchema = fetchHubFileSchema;
|
package/api/sandboxHubs.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Environment } from '../types/Config';
|
|
2
2
|
import { SandboxHubData, SandboxResponse, SandboxUsageLimitsResponse } from '../types/Sandbox';
|
|
3
|
-
export declare function createSandbox(accountId: number, name: string, type:
|
|
3
|
+
export declare function createSandbox(accountId: number, name: string, type: 1 | 2): Promise<SandboxResponse>;
|
|
4
4
|
export declare function deleteSandbox(parentAccountId: number, sandboxAccountId: number): Promise<void>;
|
|
5
5
|
export declare function getSandboxUsageLimits(parentAccountId: number): Promise<SandboxUsageLimitsResponse>;
|
|
6
6
|
export declare function fetchSandboxHubData(accessToken: string, portalId: number, env?: Environment): Promise<SandboxHubData>;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { CLIConfig_NEW, Environment } from '../types/Config';
|
|
2
|
-
import { CLIAccount_NEW, FlatAccountFields_NEW } from '../types/Accounts';
|
|
2
|
+
import { CLIAccount_NEW, FlatAccountFields_NEW, AccountType } from '../types/Accounts';
|
|
3
3
|
import { CLIOptions } from '../types/CLIOptions';
|
|
4
|
-
import { LogCallbacksArg } from '../types/LogCallbacks';
|
|
5
|
-
declare const validateLogCallbackKeys: readonly ["noConfig", "noConfigAccounts", "emptyAccountConfig", "noAccountId", "duplicateAccountIds", "duplicateAccountNames", "nameContainsSpaces"];
|
|
6
4
|
declare class CLIConfiguration {
|
|
7
5
|
options: CLIOptions;
|
|
8
6
|
useEnvConfig: boolean;
|
|
@@ -16,7 +14,7 @@ declare class CLIConfiguration {
|
|
|
16
14
|
configIsEmpty(): boolean;
|
|
17
15
|
delete(): void;
|
|
18
16
|
write(updatedConfig?: CLIConfig_NEW): CLIConfig_NEW | null;
|
|
19
|
-
validate(
|
|
17
|
+
validate(): boolean;
|
|
20
18
|
getAccount(nameOrId: string | number | undefined): CLIAccount_NEW | null;
|
|
21
19
|
isConfigFlagEnabled(flag: keyof CLIConfig_NEW, defaultValue?: boolean): boolean;
|
|
22
20
|
getAccountId(nameOrId?: string | number): number | null;
|
|
@@ -27,6 +25,7 @@ declare class CLIConfiguration {
|
|
|
27
25
|
isAccountInConfig(nameOrId: string | number): boolean;
|
|
28
26
|
getAndLoadConfigIfNeeded(options?: CLIOptions): CLIConfig_NEW;
|
|
29
27
|
getEnv(nameOrId?: string | number): Environment;
|
|
28
|
+
getAccountType(accountType?: AccountType, sandboxAccountType?: string | null): AccountType;
|
|
30
29
|
/**
|
|
31
30
|
* @throws {Error}
|
|
32
31
|
*/
|
|
@@ -41,6 +40,7 @@ declare class CLIConfiguration {
|
|
|
41
40
|
renameAccount(currentName: string, newName: string): void;
|
|
42
41
|
/**
|
|
43
42
|
* @throws {Error}
|
|
43
|
+
* TODO: this does not account for the special handling of sandbox account deletes
|
|
44
44
|
*/
|
|
45
45
|
removeAccountFromConfig(nameOrId: string | number): boolean;
|
|
46
46
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const logger_1 = require("../
|
|
3
|
+
const logger_1 = require("../lib/logging/logger");
|
|
4
4
|
const standardErrors_1 = require("../errors/standardErrors");
|
|
5
5
|
const environment_1 = require("./environment");
|
|
6
6
|
const environment_2 = require("../lib/environment");
|
|
@@ -10,16 +10,8 @@ const environments_1 = require("../constants/environments");
|
|
|
10
10
|
const auth_1 = require("../constants/auth");
|
|
11
11
|
const config_1 = require("../constants/config");
|
|
12
12
|
const files_1 = require("../constants/files");
|
|
13
|
+
const lang_1 = require("../utils/lang");
|
|
13
14
|
const i18nKey = 'config.cliConfiguration';
|
|
14
|
-
const validateLogCallbackKeys = [
|
|
15
|
-
'noConfig',
|
|
16
|
-
'noConfigAccounts',
|
|
17
|
-
'emptyAccountConfig',
|
|
18
|
-
'noAccountId',
|
|
19
|
-
'duplicateAccountIds',
|
|
20
|
-
'duplicateAccountNames',
|
|
21
|
-
'nameContainsSpaces',
|
|
22
|
-
];
|
|
23
15
|
class CLIConfiguration {
|
|
24
16
|
options;
|
|
25
17
|
useEnvConfig;
|
|
@@ -47,18 +39,18 @@ class CLIConfiguration {
|
|
|
47
39
|
if (this.options.useEnv) {
|
|
48
40
|
const configFromEnv = (0, environment_1.loadConfigFromEnvironment)();
|
|
49
41
|
if (configFromEnv) {
|
|
50
|
-
(0,
|
|
42
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.load.configFromEnv`, {
|
|
51
43
|
accountId: configFromEnv.accounts[0].accountId,
|
|
52
|
-
});
|
|
44
|
+
}));
|
|
53
45
|
this.useEnvConfig = true;
|
|
54
46
|
this.config = configFromEnv;
|
|
55
47
|
}
|
|
56
48
|
}
|
|
57
49
|
else {
|
|
58
50
|
const configFromFile = (0, configFile_1.loadConfigFromFile)();
|
|
59
|
-
(0,
|
|
51
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.load.configFromFile`));
|
|
60
52
|
if (!configFromFile) {
|
|
61
|
-
(0,
|
|
53
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.load.empty`));
|
|
62
54
|
this.config = { accounts: [] };
|
|
63
55
|
}
|
|
64
56
|
this.useEnvConfig = false;
|
|
@@ -97,44 +89,43 @@ class CLIConfiguration {
|
|
|
97
89
|
}
|
|
98
90
|
return this.config;
|
|
99
91
|
}
|
|
100
|
-
validate(
|
|
101
|
-
const validateLogger = (0, logger_1.makeTypedLogger)(logCallbacks);
|
|
92
|
+
validate() {
|
|
102
93
|
if (!this.config) {
|
|
103
|
-
|
|
94
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.validate.noConfig`));
|
|
104
95
|
return false;
|
|
105
96
|
}
|
|
106
97
|
if (!Array.isArray(this.config.accounts)) {
|
|
107
|
-
|
|
98
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.validate.noConfigAccounts`));
|
|
108
99
|
return false;
|
|
109
100
|
}
|
|
110
101
|
const accountIdsMap = {};
|
|
111
102
|
const accountNamesMap = {};
|
|
112
103
|
return this.config.accounts.every(accountConfig => {
|
|
113
104
|
if (!accountConfig) {
|
|
114
|
-
|
|
105
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.validate.emptyAccountConfig`));
|
|
115
106
|
return false;
|
|
116
107
|
}
|
|
117
108
|
if (!accountConfig.accountId) {
|
|
118
|
-
|
|
109
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.validate.noAccountId`));
|
|
119
110
|
return false;
|
|
120
111
|
}
|
|
121
112
|
if (accountIdsMap[accountConfig.accountId]) {
|
|
122
|
-
|
|
113
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.validate.duplicateAccountIds`, {
|
|
123
114
|
accountId: accountConfig.accountId,
|
|
124
|
-
});
|
|
115
|
+
}));
|
|
125
116
|
return false;
|
|
126
117
|
}
|
|
127
118
|
if (accountConfig.name) {
|
|
128
119
|
if (accountNamesMap[accountConfig.name]) {
|
|
129
|
-
|
|
120
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.validate.duplicateAccountNames`, {
|
|
130
121
|
accountName: accountConfig.name,
|
|
131
|
-
});
|
|
122
|
+
}));
|
|
132
123
|
return false;
|
|
133
124
|
}
|
|
134
125
|
if (/\s+/.test(accountConfig.name)) {
|
|
135
|
-
|
|
126
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.validate.nameContainsSpaces`, {
|
|
136
127
|
accountName: accountConfig.name,
|
|
137
|
-
});
|
|
128
|
+
}));
|
|
138
129
|
return false;
|
|
139
130
|
}
|
|
140
131
|
accountNamesMap[accountConfig.name] = true;
|
|
@@ -227,6 +218,21 @@ class CLIConfiguration {
|
|
|
227
218
|
}
|
|
228
219
|
return environments_1.ENVIRONMENTS.PROD;
|
|
229
220
|
}
|
|
221
|
+
// Deprecating sandboxAccountType in favor of accountType
|
|
222
|
+
getAccountType(accountType, sandboxAccountType) {
|
|
223
|
+
if (accountType) {
|
|
224
|
+
return accountType;
|
|
225
|
+
}
|
|
226
|
+
if (typeof sandboxAccountType === 'string') {
|
|
227
|
+
if (sandboxAccountType.toUpperCase() === 'DEVELOPER') {
|
|
228
|
+
return config_1.HUBSPOT_ACCOUNT_TYPES.DEVELOPER_SANDBOX;
|
|
229
|
+
}
|
|
230
|
+
if (sandboxAccountType.toUpperCase() === 'STANDARD') {
|
|
231
|
+
return config_1.HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return config_1.HUBSPOT_ACCOUNT_TYPES.STANDARD;
|
|
235
|
+
}
|
|
230
236
|
/*
|
|
231
237
|
* Config Update Utils
|
|
232
238
|
*/
|
|
@@ -234,12 +240,12 @@ class CLIConfiguration {
|
|
|
234
240
|
* @throws {Error}
|
|
235
241
|
*/
|
|
236
242
|
updateAccount(updatedAccountFields, writeUpdate = true) {
|
|
237
|
-
const { accountId, apiKey, authType, clientId, clientSecret, defaultMode, env, name, parentAccountId, personalAccessKey, sandboxAccountType, scopes, tokenInfo, } = updatedAccountFields;
|
|
243
|
+
const { accountId, accountType, apiKey, authType, clientId, clientSecret, defaultMode, env, name, parentAccountId, personalAccessKey, sandboxAccountType, scopes, tokenInfo, } = updatedAccountFields;
|
|
238
244
|
if (!accountId) {
|
|
239
245
|
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.updateAccount.errors.accountIdRequired`);
|
|
240
246
|
}
|
|
241
247
|
if (!this.config) {
|
|
242
|
-
(0,
|
|
248
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.updateAccount.noConfigToUpdate`));
|
|
243
249
|
return null;
|
|
244
250
|
}
|
|
245
251
|
const currentAccountConfig = this.getAccount(accountId);
|
|
@@ -279,18 +285,20 @@ class CLIConfiguration {
|
|
|
279
285
|
safelyApplyUpdates('defaultMode', files_1.MODE[updatedDefaultMode]);
|
|
280
286
|
}
|
|
281
287
|
safelyApplyUpdates('personalAccessKey', personalAccessKey);
|
|
288
|
+
// Deprecating sandboxAccountType in favor of the more generic accountType
|
|
282
289
|
safelyApplyUpdates('sandboxAccountType', sandboxAccountType);
|
|
290
|
+
safelyApplyUpdates('accountType', this.getAccountType(accountType, sandboxAccountType));
|
|
283
291
|
safelyApplyUpdates('parentAccountId', parentAccountId);
|
|
284
292
|
const completedAccountConfig = nextAccountConfig;
|
|
285
293
|
if (currentAccountConfig) {
|
|
286
|
-
(0,
|
|
294
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.updateAccount.updating`, {
|
|
287
295
|
accountId,
|
|
288
|
-
});
|
|
296
|
+
}));
|
|
289
297
|
const index = this.getConfigAccountIndex(accountId);
|
|
290
298
|
this.config.accounts[index] = completedAccountConfig;
|
|
291
|
-
(0,
|
|
299
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.updateAccount.addingConfigEntry`, {
|
|
292
300
|
accountId,
|
|
293
|
-
});
|
|
301
|
+
}));
|
|
294
302
|
if (this.config.accounts) {
|
|
295
303
|
this.config.accounts.push(completedAccountConfig);
|
|
296
304
|
}
|
|
@@ -343,6 +351,7 @@ class CLIConfiguration {
|
|
|
343
351
|
}
|
|
344
352
|
/**
|
|
345
353
|
* @throws {Error}
|
|
354
|
+
* TODO: this does not account for the special handling of sandbox account deletes
|
|
346
355
|
*/
|
|
347
356
|
removeAccountFromConfig(nameOrId) {
|
|
348
357
|
if (!this.config) {
|
|
@@ -355,7 +364,7 @@ class CLIConfiguration {
|
|
|
355
364
|
let removedAccountIsDefault = false;
|
|
356
365
|
const accountConfig = this.getAccount(accountId);
|
|
357
366
|
if (accountConfig) {
|
|
358
|
-
(0,
|
|
367
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.removeAccountFromConfig.deleting`, { accountId }));
|
|
359
368
|
const index = this.getConfigAccountIndex(accountId);
|
|
360
369
|
this.config.accounts.splice(index, 1);
|
|
361
370
|
if (this.getDefaultAccount() === accountConfig.name) {
|
package/config/configFile.js
CHANGED
|
@@ -8,11 +8,12 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const os_1 = __importDefault(require("os"));
|
|
10
10
|
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
11
|
-
const logger_1 = require("../
|
|
11
|
+
const logger_1 = require("../lib/logging/logger");
|
|
12
12
|
const fileSystemErrors_1 = require("../errors/fileSystemErrors");
|
|
13
13
|
const standardErrors_1 = require("../errors/standardErrors");
|
|
14
14
|
const config_1 = require("../constants/config");
|
|
15
15
|
const configUtils_1 = require("./configUtils");
|
|
16
|
+
const lang_1 = require("../utils/lang");
|
|
16
17
|
const i18nKey = 'config.configFile';
|
|
17
18
|
function getConfigFilePath() {
|
|
18
19
|
return path_1.default.join(os_1.default.homedir(), config_1.HUBSPOT_CONFIGURATION_FOLDER, config_1.HUBSPOT_CONFIGURATION_FILE);
|
|
@@ -42,7 +43,7 @@ function readConfigFile(configPath) {
|
|
|
42
43
|
source = fs_extra_1.default.readFileSync(configPath).toString();
|
|
43
44
|
}
|
|
44
45
|
catch (err) {
|
|
45
|
-
(0,
|
|
46
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.errorReading`, { configPath }));
|
|
46
47
|
(0, fileSystemErrors_1.throwFileSystemError)(err, {
|
|
47
48
|
filepath: configPath,
|
|
48
49
|
read: true,
|
|
@@ -77,7 +78,7 @@ function loadConfigFromFile() {
|
|
|
77
78
|
}
|
|
78
79
|
return parseConfig(source);
|
|
79
80
|
}
|
|
80
|
-
(0,
|
|
81
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.errorLoading`, { configPath }));
|
|
81
82
|
return null;
|
|
82
83
|
}
|
|
83
84
|
exports.loadConfigFromFile = loadConfigFromFile;
|
|
@@ -96,7 +97,7 @@ function writeConfigToFile(config) {
|
|
|
96
97
|
try {
|
|
97
98
|
fs_extra_1.default.ensureFileSync(configPath);
|
|
98
99
|
fs_extra_1.default.writeFileSync(configPath, source);
|
|
99
|
-
(0,
|
|
100
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.writeSuccess`, { configPath }));
|
|
100
101
|
}
|
|
101
102
|
catch (err) {
|
|
102
103
|
(0, fileSystemErrors_1.throwFileSystemError)(err, {
|
package/config/configUtils.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateConfig = exports.getOrderedConfig = exports.getOrderedAccount = void 0;
|
|
4
|
-
const logger_1 = require("../
|
|
4
|
+
const logger_1 = require("../lib/logging/logger");
|
|
5
5
|
const auth_1 = require("../constants/auth");
|
|
6
|
+
const lang_1 = require("../utils/lang");
|
|
6
7
|
const i18nKey = 'config.configUtils';
|
|
7
8
|
function getOrderedAccount(unorderedAccount) {
|
|
8
9
|
const { name, accountId, env, authType, ...rest } = unorderedAccount;
|
|
@@ -75,7 +76,7 @@ function generateConfig(type, options) {
|
|
|
75
76
|
configAccount = generateOauthAccountConfig(options);
|
|
76
77
|
break;
|
|
77
78
|
default:
|
|
78
|
-
(0,
|
|
79
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.unknownType`, { type }));
|
|
79
80
|
return null;
|
|
80
81
|
}
|
|
81
82
|
if (configAccount) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CLIConfig_DEPRECATED, Environment } from '../types/Config';
|
|
2
|
-
import { CLIAccount_DEPRECATED, FlatAccountFields_DEPRECATED } from '../types/Accounts';
|
|
2
|
+
import { AccountType, CLIAccount_DEPRECATED, FlatAccountFields_DEPRECATED } from '../types/Accounts';
|
|
3
3
|
import { Mode } from '../types/Files';
|
|
4
4
|
import { CLIOptions, WriteConfigOptions } from '../types/CLIOptions';
|
|
5
5
|
export declare const getConfig: () => CLIConfig_DEPRECATED | null;
|
|
@@ -27,6 +27,7 @@ export declare function isTrackingAllowed(): boolean;
|
|
|
27
27
|
export declare function getAndLoadConfigIfNeeded(options?: {}): Partial<CLIConfig_DEPRECATED>;
|
|
28
28
|
export declare function findConfig(directory: string): string | null;
|
|
29
29
|
export declare function getEnv(nameOrId?: string | number): Environment;
|
|
30
|
+
export declare function getAccountType(accountType?: AccountType, sandboxAccountType?: string | null): AccountType;
|
|
30
31
|
export declare function getAccountConfig(accountId: number | undefined): CLIAccount_DEPRECATED | undefined;
|
|
31
32
|
export declare function getAccountId(nameOrId?: string | number): number | undefined;
|
|
32
33
|
/**
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isConfigFlagEnabled = exports.loadConfigFromEnvironment = exports.deleteConfigFile = exports.deleteEmptyConfigFile = exports.createEmptyConfigFile = exports.deleteAccount = exports.renameAccount = exports.updateAllowUsageTracking = exports.updateHttpTimeout = exports.updateDefaultMode = exports.updateDefaultAccount = exports.updateAccountConfig = exports.removeSandboxAccountFromConfig = exports.getAccountId = exports.getAccountConfig = exports.getEnv = exports.findConfig = exports.getAndLoadConfigIfNeeded = exports.isTrackingAllowed = exports.loadConfig = exports.writeConfig = exports.getOrderedConfig = exports.getOrderedAccount = exports.accountNameExistsInConfig = exports.validateConfig = exports.getConfigPath = exports.setConfigPath = exports.getConfigAccountId = exports.getConfigDefaultAccount = exports.getConfigAccounts = exports.setConfig = exports.getConfig = void 0;
|
|
6
|
+
exports.isConfigFlagEnabled = exports.loadConfigFromEnvironment = exports.deleteConfigFile = exports.deleteEmptyConfigFile = exports.createEmptyConfigFile = exports.deleteAccount = exports.renameAccount = exports.updateAllowUsageTracking = exports.updateHttpTimeout = exports.updateDefaultMode = exports.updateDefaultAccount = exports.updateAccountConfig = exports.removeSandboxAccountFromConfig = exports.getAccountId = exports.getAccountConfig = exports.getAccountType = exports.getEnv = exports.findConfig = exports.getAndLoadConfigIfNeeded = exports.isTrackingAllowed = exports.loadConfig = exports.writeConfig = exports.getOrderedConfig = exports.getOrderedAccount = exports.accountNameExistsInConfig = exports.validateConfig = exports.getConfigPath = exports.setConfigPath = exports.getConfigAccountId = exports.getConfigDefaultAccount = exports.getConfigAccounts = exports.setConfig = exports.getConfig = void 0;
|
|
7
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
8
|
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
9
9
|
const findup_sync_1 = __importDefault(require("findup-sync"));
|
|
@@ -287,6 +287,22 @@ function getEnv(nameOrId) {
|
|
|
287
287
|
return env;
|
|
288
288
|
}
|
|
289
289
|
exports.getEnv = getEnv;
|
|
290
|
+
// Deprecating sandboxAccountType in favor of accountType
|
|
291
|
+
function getAccountType(accountType, sandboxAccountType) {
|
|
292
|
+
if (accountType) {
|
|
293
|
+
return accountType;
|
|
294
|
+
}
|
|
295
|
+
if (typeof sandboxAccountType === 'string') {
|
|
296
|
+
if (sandboxAccountType.toUpperCase() === 'DEVELOPER') {
|
|
297
|
+
return config_1.HUBSPOT_ACCOUNT_TYPES.DEVELOPER_SANDBOX;
|
|
298
|
+
}
|
|
299
|
+
if (sandboxAccountType.toUpperCase() === 'STANDARD') {
|
|
300
|
+
return config_1.HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return config_1.HUBSPOT_ACCOUNT_TYPES.STANDARD;
|
|
304
|
+
}
|
|
305
|
+
exports.getAccountType = getAccountType;
|
|
290
306
|
function getAccountConfig(accountId) {
|
|
291
307
|
return getConfigAccounts(getAndLoadConfigIfNeeded())?.find(account => account.portalId === accountId);
|
|
292
308
|
}
|
|
@@ -343,7 +359,10 @@ function removeSandboxAccountFromConfig(nameOrId) {
|
|
|
343
359
|
throw new Error(`Unable to find account for ${nameOrId}.`);
|
|
344
360
|
}
|
|
345
361
|
const accountConfig = getAccountConfig(accountId);
|
|
346
|
-
|
|
362
|
+
const accountType = getAccountType(accountConfig?.accountType, accountConfig?.sandboxAccountType);
|
|
363
|
+
const isSandboxAccount = accountType === config_1.HUBSPOT_ACCOUNT_TYPES.DEVELOPER_SANDBOX ||
|
|
364
|
+
accountType === config_1.HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX;
|
|
365
|
+
if (!isSandboxAccount)
|
|
347
366
|
return promptDefaultAccount;
|
|
348
367
|
if (config.defaultPortal === accountConfig?.name) {
|
|
349
368
|
promptDefaultAccount = true;
|
|
@@ -362,7 +381,7 @@ exports.removeSandboxAccountFromConfig = removeSandboxAccountFromConfig;
|
|
|
362
381
|
* @throws {Error}
|
|
363
382
|
*/
|
|
364
383
|
function updateAccountConfig(configOptions) {
|
|
365
|
-
const {
|
|
384
|
+
const { accountType, apiKey, authType, clientId, clientSecret, defaultMode, environment, name, parentAccountId, personalAccessKey, portalId, sandboxAccountType, scopes, tokenInfo, } = configOptions;
|
|
366
385
|
if (!portalId) {
|
|
367
386
|
throw new Error('A portalId is required to update the config');
|
|
368
387
|
}
|
|
@@ -389,6 +408,7 @@ function updateAccountConfig(configOptions) {
|
|
|
389
408
|
...(portalId && { portalId }),
|
|
390
409
|
authType,
|
|
391
410
|
auth,
|
|
411
|
+
accountType: getAccountType(accountType, sandboxAccountType),
|
|
392
412
|
apiKey,
|
|
393
413
|
defaultMode: mode && Object.hasOwn(files_1.MODE, mode) ? mode : undefined,
|
|
394
414
|
personalAccessKey,
|
package/config/environment.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadConfigFromEnvironment = void 0;
|
|
4
|
-
const logger_1 = require("../
|
|
4
|
+
const logger_1 = require("../lib/logging/logger");
|
|
5
5
|
const environments_1 = require("../constants/environments");
|
|
6
6
|
const auth_1 = require("../constants/auth");
|
|
7
7
|
const configUtils_1 = require("./configUtils");
|
|
8
8
|
const environment_1 = require("../lib/environment");
|
|
9
|
+
const lang_1 = require("../utils/lang");
|
|
9
10
|
const i18nKey = 'config.environment';
|
|
10
11
|
function getConfigVariablesFromEnv() {
|
|
11
12
|
const env = process.env;
|
|
@@ -22,11 +23,11 @@ function getConfigVariablesFromEnv() {
|
|
|
22
23
|
function loadConfigFromEnvironment() {
|
|
23
24
|
const { apiKey, clientId, clientSecret, personalAccessKey, accountId, refreshToken, env, } = getConfigVariablesFromEnv();
|
|
24
25
|
if (!accountId) {
|
|
25
|
-
(0,
|
|
26
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.loadConfig.missingAccountId`));
|
|
26
27
|
return null;
|
|
27
28
|
}
|
|
28
29
|
if (!env) {
|
|
29
|
-
(0,
|
|
30
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.loadConfig.missingEnv`));
|
|
30
31
|
return null;
|
|
31
32
|
}
|
|
32
33
|
if (personalAccessKey) {
|
|
@@ -53,7 +54,7 @@ function loadConfigFromEnvironment() {
|
|
|
53
54
|
env,
|
|
54
55
|
});
|
|
55
56
|
}
|
|
56
|
-
(0,
|
|
57
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.loadConfig.unknownAuthType`));
|
|
57
58
|
return null;
|
|
58
59
|
}
|
|
59
60
|
exports.loadConfigFromEnvironment = loadConfigFromEnvironment;
|
package/config/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as config_DEPRECATED from './config_DEPRECATED';
|
|
2
2
|
import { CLIConfig } from '../types/Config';
|
|
3
3
|
import { CLIOptions, WriteConfigOptions } from '../types/CLIOptions';
|
|
4
|
-
import { CLIAccount, FlatAccountFields } from '../types/Accounts';
|
|
4
|
+
import { AccountType, CLIAccount, FlatAccountFields } from '../types/Accounts';
|
|
5
5
|
export declare function loadConfig(path: string, options?: CLIOptions): CLIConfig | null;
|
|
6
6
|
export declare function getAndLoadConfigIfNeeded(options?: CLIOptions): Partial<CLIConfig> | null;
|
|
7
7
|
export declare function validateConfig(): boolean;
|
|
@@ -27,6 +27,7 @@ export declare function deleteConfigFile(): void;
|
|
|
27
27
|
export declare function isConfigFlagEnabled(flag: keyof CLIConfig): boolean;
|
|
28
28
|
export declare function isTrackingAllowed(): boolean;
|
|
29
29
|
export declare function getEnv(nameOrId?: string | number): import("../types/Config").Environment;
|
|
30
|
+
export declare function getAccountType(accountType?: AccountType, sandboxAccountType?: string | null): AccountType;
|
|
30
31
|
export declare const getConfigAccounts: typeof config_DEPRECATED.getConfigAccounts;
|
|
31
32
|
export declare const getConfigDefaultAccount: typeof config_DEPRECATED.getConfigDefaultAccount;
|
|
32
33
|
export declare const getConfigAccountId: typeof config_DEPRECATED.getConfigAccountId;
|
package/config/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.updateDefaultMode = exports.findConfig = exports.setConfigPath = exports.setConfig = exports.getOrderedConfig = exports.getOrderedAccount = exports.getConfigAccountId = exports.getConfigDefaultAccount = exports.getConfigAccounts = exports.getEnv = exports.isTrackingAllowed = exports.isConfigFlagEnabled = exports.deleteConfigFile = exports.updateAllowUsageTracking = exports.updateHttpTimeout = exports.deleteAccount = exports.removeSandboxAccountFromConfig = exports.getAccountId = exports.renameAccount = exports.updateDefaultAccount = exports.updateAccountConfig = exports.accountNameExistsInConfig = exports.getAccountConfig = exports.getConfigPath = exports.writeConfig = exports.getConfig = exports.deleteEmptyConfigFile = exports.createEmptyConfigFile = exports.loadConfigFromEnvironment = exports.validateConfig = exports.getAndLoadConfigIfNeeded = exports.loadConfig = void 0;
|
|
29
|
+
exports.updateDefaultMode = exports.findConfig = exports.setConfigPath = exports.setConfig = exports.getOrderedConfig = exports.getOrderedAccount = exports.getConfigAccountId = exports.getConfigDefaultAccount = exports.getConfigAccounts = exports.getAccountType = exports.getEnv = exports.isTrackingAllowed = exports.isConfigFlagEnabled = exports.deleteConfigFile = exports.updateAllowUsageTracking = exports.updateHttpTimeout = exports.deleteAccount = exports.removeSandboxAccountFromConfig = exports.getAccountId = exports.renameAccount = exports.updateDefaultAccount = exports.updateAccountConfig = exports.accountNameExistsInConfig = exports.getAccountConfig = exports.getConfigPath = exports.writeConfig = exports.getConfig = exports.deleteEmptyConfigFile = exports.createEmptyConfigFile = exports.loadConfigFromEnvironment = exports.validateConfig = exports.getAndLoadConfigIfNeeded = exports.loadConfig = void 0;
|
|
30
30
|
const config_DEPRECATED = __importStar(require("./config_DEPRECATED"));
|
|
31
31
|
const CLIConfiguration_1 = __importDefault(require("./CLIConfiguration"));
|
|
32
32
|
const configFile_1 = require("./configFile");
|
|
@@ -220,6 +220,13 @@ function getEnv(nameOrId) {
|
|
|
220
220
|
return config_DEPRECATED.getEnv(nameOrId);
|
|
221
221
|
}
|
|
222
222
|
exports.getEnv = getEnv;
|
|
223
|
+
function getAccountType(accountType, sandboxAccountType) {
|
|
224
|
+
if (CLIConfiguration_1.default.isActive()) {
|
|
225
|
+
return CLIConfiguration_1.default.getAccountType(accountType, sandboxAccountType);
|
|
226
|
+
}
|
|
227
|
+
return config_DEPRECATED.getAccountType(accountType, sandboxAccountType);
|
|
228
|
+
}
|
|
229
|
+
exports.getAccountType = getAccountType;
|
|
223
230
|
// These functions are either not supported or have breaking changes with the new config setup
|
|
224
231
|
exports.getConfigAccounts = config_DEPRECATED.getConfigAccounts;
|
|
225
232
|
exports.getConfigDefaultAccount = config_DEPRECATED.getConfigDefaultAccount;
|
package/constants/config.d.ts
CHANGED
|
@@ -2,3 +2,10 @@ export declare const DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = "hubspot.config.yml
|
|
|
2
2
|
export declare const HUBSPOT_CONFIGURATION_FOLDER = ".hubspot";
|
|
3
3
|
export declare const HUBSPOT_CONFIGURATION_FILE = "config.yml";
|
|
4
4
|
export declare const MIN_HTTP_TIMEOUT = 3000;
|
|
5
|
+
export declare const HUBSPOT_ACCOUNT_TYPES: {
|
|
6
|
+
readonly DEVELOPER_SANDBOX: "DEVELOPER_SANDBOX";
|
|
7
|
+
readonly DEVELOPER_TEST: "DEVELOPER_TEST";
|
|
8
|
+
readonly DEVELOPER: "DEVELOPER";
|
|
9
|
+
readonly STANDARD_SANDBOX: "STANDARD_SANDBOX";
|
|
10
|
+
readonly STANDARD: "STANDARD";
|
|
11
|
+
};
|
package/constants/config.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MIN_HTTP_TIMEOUT = exports.HUBSPOT_CONFIGURATION_FILE = exports.HUBSPOT_CONFIGURATION_FOLDER = exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = void 0;
|
|
4
|
-
// NOTE this is the legacy config file name (We still need to keep it around though)
|
|
3
|
+
exports.HUBSPOT_ACCOUNT_TYPES = exports.MIN_HTTP_TIMEOUT = exports.HUBSPOT_CONFIGURATION_FILE = exports.HUBSPOT_CONFIGURATION_FOLDER = exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = void 0;
|
|
5
4
|
exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = 'hubspot.config.yml';
|
|
6
5
|
exports.HUBSPOT_CONFIGURATION_FOLDER = '.hubspot';
|
|
7
6
|
exports.HUBSPOT_CONFIGURATION_FILE = 'config.yml';
|
|
8
7
|
exports.MIN_HTTP_TIMEOUT = 3000;
|
|
8
|
+
exports.HUBSPOT_ACCOUNT_TYPES = {
|
|
9
|
+
DEVELOPER_SANDBOX: 'DEVELOPER_SANDBOX',
|
|
10
|
+
DEVELOPER_TEST: 'DEVELOPER_TEST',
|
|
11
|
+
DEVELOPER: 'DEVELOPER',
|
|
12
|
+
STANDARD_SANDBOX: 'STANDARD_SANDBOX',
|
|
13
|
+
STANDARD: 'STANDARD',
|
|
14
|
+
};
|
package/errors/apiErrors.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { AxiosError } from 'axios';
|
|
2
2
|
import { GenericError, AxiosErrorContext } from '../types/Error';
|
|
3
3
|
import { HubSpotAuthError } from '../models/HubSpotAuthError';
|
|
4
|
-
export declare function
|
|
5
|
-
|
|
4
|
+
export declare function isSpecifiedError(err: Error | AxiosError, { statusCode, category, subCategory, }: {
|
|
5
|
+
statusCode?: number;
|
|
6
|
+
category?: string;
|
|
7
|
+
subCategory?: string;
|
|
8
|
+
}): boolean;
|
|
9
|
+
export declare function isMissingScopeError(err: Error | AxiosError): boolean;
|
|
10
|
+
export declare function isGatingError(err: Error | AxiosError): boolean;
|
|
6
11
|
export declare function isApiUploadValidationError(err: AxiosError<any>): boolean;
|
|
7
12
|
export declare function isSpecifiedHubSpotAuthError(err: GenericError, { status, category, subCategory }: Partial<HubSpotAuthError>): boolean;
|
|
8
13
|
export declare function getAxiosErrorWithContext(error: AxiosError<any>, context?: AxiosErrorContext): Error;
|
package/errors/apiErrors.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.throwApiUploadError = exports.throwApiError = exports.getAxiosErrorWithContext = exports.isSpecifiedHubSpotAuthError = exports.isApiUploadValidationError = exports.isGatingError = exports.isMissingScopeError = void 0;
|
|
3
|
+
exports.throwApiUploadError = exports.throwApiError = exports.getAxiosErrorWithContext = exports.isSpecifiedHubSpotAuthError = exports.isApiUploadValidationError = exports.isGatingError = exports.isMissingScopeError = exports.isSpecifiedError = void 0;
|
|
4
4
|
const api_1 = require("../constants/api");
|
|
5
5
|
const lang_1 = require("../utils/lang");
|
|
6
6
|
const standardErrors_1 = require("./standardErrors");
|
|
7
7
|
const i18nKey = 'errors.apiErrors';
|
|
8
|
-
|
|
8
|
+
function isSpecifiedError(err, { statusCode, category, subCategory, }) {
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
const error = (err && err.cause) || err;
|
|
11
|
+
const statusCodeErr = !statusCode || error.response?.status === statusCode;
|
|
12
|
+
const categoryErr = !category || error.response?.data?.category === category;
|
|
13
|
+
const subCategoryErr = !subCategory || error.response?.data?.subCategory === subCategory;
|
|
14
|
+
return error.isAxiosError && statusCodeErr && categoryErr && subCategoryErr;
|
|
15
|
+
}
|
|
16
|
+
exports.isSpecifiedError = isSpecifiedError;
|
|
9
17
|
function isMissingScopeError(err) {
|
|
10
|
-
return (err
|
|
11
|
-
err.status === 403 &&
|
|
12
|
-
!!err.response &&
|
|
13
|
-
err.response.data.category === 'MISSING_SCOPES');
|
|
18
|
+
return isSpecifiedError(err, { statusCode: 403, category: 'MISSING_SCOPES' });
|
|
14
19
|
}
|
|
15
20
|
exports.isMissingScopeError = isMissingScopeError;
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
21
|
function isGatingError(err) {
|
|
18
|
-
return (err
|
|
19
|
-
err.status === 403 &&
|
|
20
|
-
!!err.response &&
|
|
21
|
-
err.response.data.category === 'GATED');
|
|
22
|
+
return isSpecifiedError(err, { statusCode: 403, category: 'GATED' });
|
|
22
23
|
}
|
|
23
24
|
exports.isGatingError = isGatingError;
|
|
24
25
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -8,7 +8,7 @@ export declare function isFatalError(err: BaseError): boolean;
|
|
|
8
8
|
*/
|
|
9
9
|
export declare function throwErrorWithMessage(identifier: LangKey, interpolation?: {
|
|
10
10
|
[key: string]: string | number;
|
|
11
|
-
}, cause?: BaseError): never;
|
|
11
|
+
}, cause?: BaseError | AxiosError): never;
|
|
12
12
|
/**
|
|
13
13
|
* @throws
|
|
14
14
|
*/
|
package/http/index.d.ts
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import { LogCallbacksArg } from '../types/LogCallbacks';
|
|
2
|
-
import { HttpOptions } from '../types/Http';
|
|
3
1
|
import { AxiosResponse } from 'axios';
|
|
2
|
+
import { HttpOptions } from '../types/Http';
|
|
4
3
|
declare function getRequest<T>(accountId: number, options: HttpOptions): Promise<T>;
|
|
5
4
|
declare function postRequest<T>(accountId: number, options: HttpOptions): Promise<T>;
|
|
6
5
|
declare function putRequest<T>(accountId: number, options: HttpOptions): Promise<T>;
|
|
7
6
|
declare function patchRequest<T>(accountId: number, options: HttpOptions): Promise<T>;
|
|
8
7
|
declare function deleteRequest<T>(accountId: number, options: HttpOptions): Promise<T>;
|
|
9
|
-
declare const getRequestStreamCallbackKeys: readonly ["onWrite"];
|
|
10
8
|
declare const http: {
|
|
11
9
|
get: typeof getRequest;
|
|
12
10
|
post: typeof postRequest;
|
|
13
11
|
put: typeof putRequest;
|
|
14
12
|
patch: typeof patchRequest;
|
|
15
13
|
delete: typeof deleteRequest;
|
|
16
|
-
getOctetStream: (accountId: number, options: HttpOptions, destPath: string
|
|
14
|
+
getOctetStream: (accountId: number, options: HttpOptions, destPath: string) => Promise<AxiosResponse>;
|
|
17
15
|
};
|
|
18
16
|
export default http;
|