@hubspot/local-dev-lib 0.0.6 → 0.0.8
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.js +3 -3
- package/api/functions.js +1 -1
- package/api/hubdb.js +4 -4
- package/api/lighthouseScore.d.ts +2 -2
- package/api/lighthouseScore.js +2 -2
- package/api/localDevAuth.d.ts +5 -1
- package/api/localDevAuth.js +1 -1
- package/api/marketplaceValidation.d.ts +2 -2
- package/api/marketplaceValidation.js +2 -2
- package/api/projects.js +2 -2
- package/api/sandboxHubs.js +1 -1
- package/api/sandboxSync.js +1 -1
- package/api/secrets.js +2 -2
- package/api/validateHubl.js +1 -1
- package/config/config_DEPRECATED.js +3 -1
- package/errors/apiErrors.d.ts +22 -8
- package/errors/apiErrors.js +44 -29
- package/errors/errors_DEPRECATED.js +2 -2
- package/errors/standardErrors.js +1 -1
- package/http/index.js +1 -0
- package/lang/en.lyaml +4 -4
- package/lib/fileMapper.d.ts +19 -3
- package/lib/fileMapper.js +14 -5
- package/lib/hubdb.d.ts +1 -1
- package/lib/hubdb.js +1 -1
- package/lib/personalAccessKey.d.ts +1 -1
- package/lib/personalAccessKey.js +3 -3
- package/lib/trackUsage.js +2 -2
- package/{errors → models}/HubSpotAuthError.d.ts +1 -1
- package/{errors → models}/HubSpotAuthError.js +2 -2
- package/models/OAuth2Manager.d.ts +1 -1
- package/models/OAuth2Manager.js +3 -3
- package/package.json +4 -7
- package/types/Error.d.ts +6 -3
- package/types/Http.d.ts +8 -11
- package/types/Hubdb.d.ts +27 -17
package/api/customObjects.js
CHANGED
|
@@ -10,21 +10,21 @@ const SCHEMA_API_PATH = 'crm-object-schemas/v3/schemas';
|
|
|
10
10
|
async function batchCreateObjects(accountId, objectTypeId, objects) {
|
|
11
11
|
http_1.default.post(accountId, {
|
|
12
12
|
url: `${CUSTOM_OBJECTS_API_PATH}/${objectTypeId}/batch/create`,
|
|
13
|
-
|
|
13
|
+
data: objects,
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
exports.batchCreateObjects = batchCreateObjects;
|
|
17
17
|
async function createObjectSchema(accountId, schema) {
|
|
18
18
|
return http_1.default.post(accountId, {
|
|
19
19
|
url: SCHEMA_API_PATH,
|
|
20
|
-
|
|
20
|
+
data: schema,
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
exports.createObjectSchema = createObjectSchema;
|
|
24
24
|
async function updateObjectSchema(accountId, schemaObjectType, schema) {
|
|
25
25
|
return http_1.default.patch(accountId, {
|
|
26
26
|
url: `${SCHEMA_API_PATH}/${schemaObjectType}`,
|
|
27
|
-
|
|
27
|
+
data: schema,
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
exports.updateObjectSchema = updateObjectSchema;
|
package/api/functions.js
CHANGED
package/api/hubdb.js
CHANGED
|
@@ -15,14 +15,14 @@ exports.fetchTable = fetchTable;
|
|
|
15
15
|
async function createTable(accountId, schema) {
|
|
16
16
|
return http_1.default.post(accountId, {
|
|
17
17
|
url: `${HUBDB_API_PATH}/tables`,
|
|
18
|
-
|
|
18
|
+
data: schema,
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
exports.createTable = createTable;
|
|
22
22
|
async function updateTable(accountId, tableId, schema) {
|
|
23
23
|
return http_1.default.patch(accountId, {
|
|
24
24
|
url: `${HUBDB_API_PATH}/tables/${tableId}/draft`,
|
|
25
|
-
|
|
25
|
+
data: schema,
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
exports.updateTable = updateTable;
|
|
@@ -41,7 +41,7 @@ exports.deleteTable = deleteTable;
|
|
|
41
41
|
async function createRows(accountId, tableId, rows) {
|
|
42
42
|
return http_1.default.post(accountId, {
|
|
43
43
|
url: `${HUBDB_API_PATH}/tables/${tableId}/rows/draft/batch/create`,
|
|
44
|
-
|
|
44
|
+
data: { inputs: rows },
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
exports.createRows = createRows;
|
|
@@ -55,7 +55,7 @@ exports.fetchRows = fetchRows;
|
|
|
55
55
|
async function deleteRows(accountId, tableId, rowIds) {
|
|
56
56
|
return http_1.default.post(accountId, {
|
|
57
57
|
url: `${HUBDB_API_PATH}/tables/${tableId}/rows/draft/batch/purge`,
|
|
58
|
-
|
|
58
|
+
data: { inputs: rowIds },
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
exports.deleteRows = deleteRows;
|
package/api/lighthouseScore.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Data, QueryParams } from '../types/Http';
|
|
2
2
|
import { GetLighthouseScoreResponse, RequestLighthouseScoreResponse } from '../types/Lighthouse';
|
|
3
|
-
export declare function requestLighthouseScore(accountId: number,
|
|
3
|
+
export declare function requestLighthouseScore(accountId: number, data?: Data): Promise<RequestLighthouseScoreResponse>;
|
|
4
4
|
export declare function getLighthouseScoreStatus(accountId: number, query?: QueryParams): Promise<string>;
|
|
5
5
|
export declare function getLighthouseScore(accountId: number, query?: QueryParams): Promise<GetLighthouseScoreResponse>;
|
package/api/lighthouseScore.js
CHANGED
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getLighthouseScore = exports.getLighthouseScoreStatus = exports.requestLighthouseScore = void 0;
|
|
7
7
|
const http_1 = __importDefault(require("../http"));
|
|
8
8
|
const LIGHTHOUSE_SCORE_API_BASE = 'quality-engine/v1/lighthouse';
|
|
9
|
-
async function requestLighthouseScore(accountId,
|
|
9
|
+
async function requestLighthouseScore(accountId, data = {}) {
|
|
10
10
|
return http_1.default.post(accountId, {
|
|
11
11
|
url: `${LIGHTHOUSE_SCORE_API_BASE}/request`,
|
|
12
|
-
|
|
12
|
+
data,
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
exports.requestLighthouseScore = requestLighthouseScore;
|
package/api/localDevAuth.d.ts
CHANGED
|
@@ -2,10 +2,14 @@ import { Environment } from '../types/Config';
|
|
|
2
2
|
import { ScopeData } from '../types/Accounts';
|
|
3
3
|
type AccessTokenResponse = {
|
|
4
4
|
hubId: number;
|
|
5
|
+
userId: number;
|
|
5
6
|
oauthAccessToken: string;
|
|
6
7
|
expiresAtMillis: number;
|
|
8
|
+
enabledFeatures?: {
|
|
9
|
+
[key: string]: number;
|
|
10
|
+
};
|
|
7
11
|
scopeGroups: Array<string>;
|
|
8
|
-
|
|
12
|
+
encodedOAuthRefreshToken: string;
|
|
9
13
|
};
|
|
10
14
|
export declare function fetchAccessToken(personalAccessKey: string, env?: Environment, portalId?: number): Promise<AccessTokenResponse>;
|
|
11
15
|
export declare function fetchScopeData(accountId: number, scopeGroup: string): Promise<ScopeData>;
|
package/api/localDevAuth.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Data, QueryParams } from '../types/Http';
|
|
2
2
|
import { GetValidationResultsResponse } from '../types/MarketplaceValidation';
|
|
3
|
-
export declare function requestValidation(accountId: number,
|
|
3
|
+
export declare function requestValidation(accountId: number, data?: Data): Promise<number>;
|
|
4
4
|
export declare function getValidationStatus(accountId: number, query?: QueryParams): Promise<string>;
|
|
5
5
|
export declare function getValidationResults(accountId: number, query?: QueryParams): Promise<GetValidationResultsResponse>;
|
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getValidationResults = exports.getValidationStatus = exports.requestValidation = void 0;
|
|
7
7
|
const http_1 = __importDefault(require("../http"));
|
|
8
8
|
const VALIDATION_API_BASE = 'quality-engine/v1/validation';
|
|
9
|
-
function requestValidation(accountId,
|
|
9
|
+
function requestValidation(accountId, data = {}) {
|
|
10
10
|
return http_1.default.post(accountId, {
|
|
11
11
|
url: `${VALIDATION_API_BASE}/request`,
|
|
12
|
-
|
|
12
|
+
data,
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
exports.requestValidation = requestValidation;
|
package/api/projects.js
CHANGED
|
@@ -18,7 +18,7 @@ exports.fetchProjects = fetchProjects;
|
|
|
18
18
|
async function createProject(accountId, name) {
|
|
19
19
|
return http_1.default.post(accountId, {
|
|
20
20
|
url: PROJECTS_API_PATH,
|
|
21
|
-
|
|
21
|
+
data: {
|
|
22
22
|
name,
|
|
23
23
|
},
|
|
24
24
|
});
|
|
@@ -87,7 +87,7 @@ exports.getBuildStructure = getBuildStructure;
|
|
|
87
87
|
async function deployProject(accountId, projectName, buildId) {
|
|
88
88
|
return http_1.default.post(accountId, {
|
|
89
89
|
url: `${PROJECTS_DEPLOY_API_PATH}/deploys/queue/async`,
|
|
90
|
-
|
|
90
|
+
data: {
|
|
91
91
|
projectName,
|
|
92
92
|
buildId,
|
|
93
93
|
},
|
package/api/sandboxHubs.js
CHANGED
|
@@ -13,7 +13,7 @@ const SANDBOX_API_PATH = 'sandbox-hubs/v1';
|
|
|
13
13
|
const SANDBOX_API_PATH_V2 = 'sandbox-hubs/v2';
|
|
14
14
|
async function createSandbox(accountId, name, type) {
|
|
15
15
|
return http_1.default.post(accountId, {
|
|
16
|
-
|
|
16
|
+
data: { name, type, generatePersonalAccessKey: true },
|
|
17
17
|
timeout: api_1.SANDBOX_TIMEOUT,
|
|
18
18
|
url: SANDBOX_API_PATH_V2, // Create uses v2 for sandbox type and PAK generation support
|
|
19
19
|
});
|
package/api/sandboxSync.js
CHANGED
|
@@ -9,7 +9,7 @@ const api_1 = require("../constants/api");
|
|
|
9
9
|
const SANDBOXES_SYNC_API_PATH = 'sandboxes-sync/v1';
|
|
10
10
|
async function initiateSync(fromHubId, toHubId, tasks, sandboxHubId) {
|
|
11
11
|
return http_1.default.post(fromHubId, {
|
|
12
|
-
|
|
12
|
+
data: {
|
|
13
13
|
command: 'SYNC',
|
|
14
14
|
fromHubId,
|
|
15
15
|
toHubId,
|
package/api/secrets.js
CHANGED
|
@@ -9,7 +9,7 @@ const SECRETS_API_PATH = 'cms/v3/functions/secrets';
|
|
|
9
9
|
async function addSecret(accountId, key, value) {
|
|
10
10
|
return http_1.default.post(accountId, {
|
|
11
11
|
url: SECRETS_API_PATH,
|
|
12
|
-
|
|
12
|
+
data: {
|
|
13
13
|
key,
|
|
14
14
|
secret: value,
|
|
15
15
|
},
|
|
@@ -19,7 +19,7 @@ exports.addSecret = addSecret;
|
|
|
19
19
|
async function updateSecret(accountId, key, value) {
|
|
20
20
|
return http_1.default.put(accountId, {
|
|
21
21
|
url: SECRETS_API_PATH,
|
|
22
|
-
|
|
22
|
+
data: {
|
|
23
23
|
key,
|
|
24
24
|
secret: value,
|
|
25
25
|
},
|
package/api/validateHubl.js
CHANGED
|
@@ -9,7 +9,7 @@ const HUBL_VALIDATE_API_PATH = 'cos-rendering/v1/internal/validate';
|
|
|
9
9
|
async function validateHubl(accountId, sourceCode, hublValidationOptions) {
|
|
10
10
|
return http_1.default.post(accountId, {
|
|
11
11
|
url: HUBL_VALIDATE_API_PATH,
|
|
12
|
-
|
|
12
|
+
data: {
|
|
13
13
|
template_source: sourceCode,
|
|
14
14
|
...hublValidationOptions,
|
|
15
15
|
},
|
|
@@ -377,7 +377,9 @@ function updateAccountConfig(configOptions) {
|
|
|
377
377
|
tokenInfo,
|
|
378
378
|
};
|
|
379
379
|
}
|
|
380
|
-
const env = (0, environment_1.getValidEnv)(environment ||
|
|
380
|
+
const env = (0, environment_1.getValidEnv)(environment ||
|
|
381
|
+
(configOptions && configOptions.env) ||
|
|
382
|
+
(accountConfig && accountConfig.env));
|
|
381
383
|
const mode = defaultMode && defaultMode.toLowerCase();
|
|
382
384
|
const nextAccountConfig = {
|
|
383
385
|
...accountConfig,
|
package/errors/apiErrors.d.ts
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
import { StatusCodeError, StatusCodeErrorContext } from '../types/Error';
|
|
2
|
-
import { HubSpotAuthError } from '
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
1
|
+
import { GenericError, StatusCodeError, StatusCodeErrorContext } from '../types/Error';
|
|
2
|
+
import { HubSpotAuthError } from '../models/HubSpotAuthError';
|
|
3
|
+
export declare function isApiStatusCodeError(err: GenericError): boolean;
|
|
4
|
+
export declare function isMissingScopeError(err: GenericError): boolean;
|
|
5
|
+
export declare function isGatingError(err: GenericError): boolean;
|
|
6
|
+
export declare function isApiUploadValidationError(err: GenericError): boolean;
|
|
7
|
+
export declare function isSpecifiedHubSpotAuthError(err: GenericError, { status, category, subCategory }: Partial<HubSpotAuthError>): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* @throws
|
|
10
|
+
*/
|
|
6
11
|
export declare function throwStatusCodeError(error: StatusCodeError, context?: StatusCodeErrorContext): never;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
/**
|
|
13
|
+
* @throws
|
|
14
|
+
*/
|
|
15
|
+
export declare function throwApiStatusCodeError(error: StatusCodeError, context?: StatusCodeErrorContext): never;
|
|
16
|
+
/**
|
|
17
|
+
* @throws
|
|
18
|
+
*/
|
|
19
|
+
export declare function throwApiError(error: StatusCodeError, context?: StatusCodeErrorContext): never;
|
|
20
|
+
/**
|
|
21
|
+
* @throws
|
|
22
|
+
*/
|
|
23
|
+
export declare function throwApiUploadError(error: StatusCodeError, context?: StatusCodeErrorContext): never;
|
package/errors/apiErrors.js
CHANGED
|
@@ -1,38 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.throwApiUploadError = exports.throwApiError = exports.throwApiStatusCodeError = exports.throwStatusCodeError = exports.isSpecifiedHubSpotAuthError = exports.isGatingError = exports.isMissingScopeError = void 0;
|
|
3
|
+
exports.throwApiUploadError = exports.throwApiError = exports.throwApiStatusCodeError = exports.throwStatusCodeError = exports.isSpecifiedHubSpotAuthError = exports.isApiUploadValidationError = exports.isGatingError = exports.isMissingScopeError = exports.isApiStatusCodeError = 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
|
function isApiStatusCodeError(err) {
|
|
8
8
|
return (err.name === 'StatusCodeError' ||
|
|
9
|
-
(err.
|
|
9
|
+
(!!err.status && err.status >= 100 && err.status < 600));
|
|
10
10
|
}
|
|
11
|
+
exports.isApiStatusCodeError = isApiStatusCodeError;
|
|
11
12
|
function isMissingScopeError(err) {
|
|
12
|
-
return
|
|
13
|
-
err.
|
|
14
|
-
err.error &&
|
|
13
|
+
return (isApiStatusCodeError(err) &&
|
|
14
|
+
err.status === 403 &&
|
|
15
|
+
!!err.error &&
|
|
15
16
|
err.error.category === 'MISSING_SCOPES');
|
|
16
17
|
}
|
|
17
18
|
exports.isMissingScopeError = isMissingScopeError;
|
|
18
19
|
function isGatingError(err) {
|
|
19
|
-
return
|
|
20
|
-
err.
|
|
21
|
-
err.error &&
|
|
20
|
+
return (isApiStatusCodeError(err) &&
|
|
21
|
+
err.status === 403 &&
|
|
22
|
+
!!err.error &&
|
|
22
23
|
err.error.category === 'GATED');
|
|
23
24
|
}
|
|
24
25
|
exports.isGatingError = isGatingError;
|
|
25
26
|
function isApiUploadValidationError(err) {
|
|
26
|
-
return
|
|
27
|
-
err.
|
|
28
|
-
err.response
|
|
29
|
-
|
|
27
|
+
return (isApiStatusCodeError(err) &&
|
|
28
|
+
err.status === 400 &&
|
|
29
|
+
!!err.response &&
|
|
30
|
+
!!err.response.body &&
|
|
31
|
+
!!(err.response.body.message || !!err.response.body.errors));
|
|
30
32
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
exports.isApiUploadValidationError = isApiUploadValidationError;
|
|
34
|
+
function isSpecifiedHubSpotAuthError(err, { status, category, subCategory }) {
|
|
35
|
+
const statusCodeErr = !status || err.status === status;
|
|
33
36
|
const categoryErr = !category || err.category === category;
|
|
34
37
|
const subCategoryErr = !subCategory || err.subCategory === subCategory;
|
|
35
|
-
return (err.name === 'HubSpotAuthError' &&
|
|
38
|
+
return Boolean(err.name === 'HubSpotAuthError' &&
|
|
36
39
|
statusCodeErr &&
|
|
37
40
|
categoryErr &&
|
|
38
41
|
subCategoryErr);
|
|
@@ -63,23 +66,29 @@ function logValidationErrors(error) {
|
|
|
63
66
|
(0, standardErrors_1.throwError)(new Error(validationErrorMessages.join(' '), { cause: error }));
|
|
64
67
|
}
|
|
65
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* @throws
|
|
71
|
+
*/
|
|
66
72
|
function throwStatusCodeError(error, context = {}) {
|
|
67
|
-
const {
|
|
73
|
+
const { status, message, response } = error;
|
|
68
74
|
const errorData = JSON.stringify({
|
|
69
|
-
|
|
75
|
+
status,
|
|
70
76
|
message,
|
|
71
|
-
url: response.request.href,
|
|
72
|
-
method: response.request.method,
|
|
73
|
-
response: response.body,
|
|
74
|
-
headers: response.headers,
|
|
77
|
+
url: response ? response.request.href : null,
|
|
78
|
+
method: response ? response.request.method : null,
|
|
79
|
+
response: response ? response.body : null,
|
|
80
|
+
headers: response ? response.headers : null,
|
|
75
81
|
context,
|
|
76
82
|
});
|
|
77
83
|
throw new Error(errorData, { cause: error });
|
|
78
84
|
}
|
|
79
85
|
exports.throwStatusCodeError = throwStatusCodeError;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
86
|
+
/**
|
|
87
|
+
* @throws
|
|
88
|
+
*/
|
|
89
|
+
function throwApiStatusCodeError(error, context = {}) {
|
|
90
|
+
const i18nKey = 'errors.errorTypes.api';
|
|
91
|
+
const { status } = error;
|
|
83
92
|
const { method } = error.options || {};
|
|
84
93
|
const { projectName } = context;
|
|
85
94
|
const isPutOrPost = method === 'PUT' || method === 'POST';
|
|
@@ -101,7 +110,7 @@ function throwApiStatusCodeError(error, context) {
|
|
|
101
110
|
}
|
|
102
111
|
const isProjectMissingScopeError = isMissingScopeError(error) && projectName;
|
|
103
112
|
const isProjectGatingError = isGatingError(error) && projectName;
|
|
104
|
-
switch (
|
|
113
|
+
switch (status) {
|
|
105
114
|
case 400:
|
|
106
115
|
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.400`, { messageDetail }));
|
|
107
116
|
break;
|
|
@@ -142,10 +151,10 @@ function throwApiStatusCodeError(error, context) {
|
|
|
142
151
|
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.503`, { messageDetail }));
|
|
143
152
|
break;
|
|
144
153
|
default:
|
|
145
|
-
if (
|
|
154
|
+
if (status && status >= 500 && status < 600) {
|
|
146
155
|
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.500Generic`, { messageDetail }));
|
|
147
156
|
}
|
|
148
|
-
else if (
|
|
157
|
+
else if (status && status >= 400 && status < 500) {
|
|
149
158
|
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.400Generic`, { messageDetail }));
|
|
150
159
|
}
|
|
151
160
|
else {
|
|
@@ -166,14 +175,20 @@ function throwApiStatusCodeError(error, context) {
|
|
|
166
175
|
(0, standardErrors_1.throwError)(new Error(errorMessage.join(' '), { cause: error }));
|
|
167
176
|
}
|
|
168
177
|
exports.throwApiStatusCodeError = throwApiStatusCodeError;
|
|
169
|
-
|
|
178
|
+
/**
|
|
179
|
+
* @throws
|
|
180
|
+
*/
|
|
181
|
+
function throwApiError(error, context = {}) {
|
|
170
182
|
if (isApiStatusCodeError(error)) {
|
|
171
183
|
throwApiStatusCodeError(error, context);
|
|
172
184
|
}
|
|
173
185
|
(0, standardErrors_1.throwError)(error);
|
|
174
186
|
}
|
|
175
187
|
exports.throwApiError = throwApiError;
|
|
176
|
-
|
|
188
|
+
/**
|
|
189
|
+
* @throws
|
|
190
|
+
*/
|
|
191
|
+
function throwApiUploadError(error, context = {}) {
|
|
177
192
|
if (isApiUploadValidationError(error)) {
|
|
178
193
|
logValidationErrors(error);
|
|
179
194
|
}
|
|
@@ -6,9 +6,9 @@ function isSystemError(err) {
|
|
|
6
6
|
}
|
|
7
7
|
function debugErrorAndContext(error, context) {
|
|
8
8
|
if (error.name === 'StatusCodeError') {
|
|
9
|
-
const {
|
|
9
|
+
const { status, message, response } = error;
|
|
10
10
|
console.debug('Error: %o', {
|
|
11
|
-
|
|
11
|
+
status,
|
|
12
12
|
message,
|
|
13
13
|
url: response.request.href,
|
|
14
14
|
method: response.request.method,
|
package/errors/standardErrors.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.throwError = exports.throwAuthErrorWithMessage = exports.throwTypeErrorWithMessage = exports.throwErrorWithMessage = exports.isFatalError = exports.isSystemError = void 0;
|
|
4
|
-
const HubSpotAuthError_1 = require("
|
|
4
|
+
const HubSpotAuthError_1 = require("../models/HubSpotAuthError");
|
|
5
5
|
const lang_1 = require("../utils/lang");
|
|
6
6
|
const apiErrors_1 = require("./apiErrors");
|
|
7
7
|
function isSystemError(err) {
|
package/http/index.js
CHANGED
package/lang/en.lyaml
CHANGED
|
@@ -134,8 +134,8 @@ en:
|
|
|
134
134
|
logging:
|
|
135
135
|
creatingFile: "Creating file at {{ path }}"
|
|
136
136
|
processFieldsJs:
|
|
137
|
-
converting:
|
|
138
|
-
converted:
|
|
137
|
+
converting: 'Converting "{{ src }}" to "{{ dest }}".'
|
|
138
|
+
converted: 'Finished converting "{{ src }}" to "{{ dest }}".'
|
|
139
139
|
errors:
|
|
140
140
|
hubdb:
|
|
141
141
|
invalidJsonPath: "The HubDB table file must be a '.json' file"
|
|
@@ -242,6 +242,6 @@ en:
|
|
|
242
242
|
fetchTaskStatus: "There was an error fetching the task status while syncing sandboxes."
|
|
243
243
|
fetchTypes: "There was an error fetching sandbox types."
|
|
244
244
|
processFieldsJs:
|
|
245
|
-
fieldsJsNotReturnArray:
|
|
246
|
-
fieldsJsNotFunction:
|
|
245
|
+
fieldsJsNotReturnArray: 'There was an error loading JS file "{{ path }}". Expected type "Array". Make sure that your function returns an array'
|
|
246
|
+
fieldsJsNotFunction: 'There was an error loading JS file "{{ path }}". Expected type "Function". Make sure that your default export is a function.'
|
|
247
247
|
invalidMjsFile: ".mjs files are only supported when using Node 13.2.0+"
|
package/lib/fileMapper.d.ts
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
|
-
import { Mode, FileMapperOptions, FileMapperInputOptions } from '../types/Files';
|
|
1
|
+
import { FileMapperNode, Mode, FileMapperOptions, FileMapperInputOptions } from '../types/Files';
|
|
2
2
|
import { LogCallbacksArg } from '../types/LogCallbacks';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function isPathToFile(filepath: string): boolean;
|
|
4
|
+
export declare function isPathToModule(filepath: string): boolean;
|
|
5
|
+
export declare function isPathToRoot(filepath: string): boolean;
|
|
6
|
+
export declare function isPathToHubspot(filepath: string): boolean;
|
|
7
|
+
export declare function getFileMapperQueryValues(mode?: Mode | null, { staging, assetVersion }?: FileMapperInputOptions): FileMapperOptions;
|
|
8
|
+
type PathTypeData = {
|
|
9
|
+
isModule: boolean;
|
|
10
|
+
isHubspot: boolean;
|
|
11
|
+
isFile: boolean;
|
|
12
|
+
isRoot: boolean;
|
|
13
|
+
isFolder: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare function getTypeDataFromPath(src: string): PathTypeData;
|
|
16
|
+
type RecursiveFileMapperCallback = (node: FileMapperNode, filepath?: string, depth?: number) => boolean;
|
|
17
|
+
export declare function recurseFolder(node: FileMapperNode, callback: RecursiveFileMapperCallback, filepath?: string, depth?: number): boolean;
|
|
18
|
+
export declare function writeUtimes(accountId: number, filepath: string, node: FileMapperNode): Promise<void>;
|
|
4
19
|
declare const filemapperCallbackKeys: string[];
|
|
20
|
+
export declare function fetchFolderFromApi(accountId: number, src: string, mode?: Mode, options?: FileMapperInputOptions, logCallbacks?: LogCallbacksArg<typeof filemapperCallbackKeys>): Promise<FileMapperNode>;
|
|
5
21
|
/**
|
|
6
22
|
* Fetch a file/folder and write to local file system.
|
|
7
23
|
*
|
|
@@ -9,5 +25,5 @@ declare const filemapperCallbackKeys: string[];
|
|
|
9
25
|
* @param {FileMapperInputArguments} input
|
|
10
26
|
* @returns {Promise}
|
|
11
27
|
*/
|
|
12
|
-
export declare function downloadFileOrFolder(accountId: number, src: string, dest: string, mode
|
|
28
|
+
export declare function downloadFileOrFolder(accountId: number, src: string, dest: string, mode?: Mode, options?: FileMapperInputOptions, logCallbacks?: LogCallbacksArg<typeof filemapperCallbackKeys>): Promise<void>;
|
|
13
29
|
export {};
|
package/lib/fileMapper.js
CHANGED
|
@@ -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.downloadFileOrFolder = exports.getFileMapperQueryValues = void 0;
|
|
6
|
+
exports.downloadFileOrFolder = exports.fetchFolderFromApi = exports.writeUtimes = exports.recurseFolder = exports.getTypeDataFromPath = exports.getFileMapperQueryValues = exports.isPathToHubspot = exports.isPathToRoot = exports.isPathToModule = exports.isPathToFile = void 0;
|
|
7
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const p_queue_1 = __importDefault(require("p-queue"));
|
|
@@ -22,26 +22,30 @@ function isPathToFile(filepath) {
|
|
|
22
22
|
const ext = (0, path_2.getExt)(filepath);
|
|
23
23
|
return !!ext && ext !== extensions_1.MODULE_EXTENSION && ext !== extensions_1.FUNCTIONS_EXTENSION;
|
|
24
24
|
}
|
|
25
|
+
exports.isPathToFile = isPathToFile;
|
|
25
26
|
function isPathToModule(filepath) {
|
|
26
27
|
const ext = (0, path_2.getExt)(filepath);
|
|
27
28
|
return ext === extensions_1.MODULE_EXTENSION;
|
|
28
29
|
}
|
|
30
|
+
exports.isPathToModule = isPathToModule;
|
|
29
31
|
function isPathToRoot(filepath) {
|
|
30
32
|
if (typeof filepath !== 'string')
|
|
31
33
|
return false;
|
|
32
34
|
// Root pattern matches empty strings and: / \
|
|
33
35
|
return /^(\/|\\)?$/.test(filepath.trim());
|
|
34
36
|
}
|
|
37
|
+
exports.isPathToRoot = isPathToRoot;
|
|
35
38
|
function isPathToHubspot(filepath) {
|
|
36
39
|
if (typeof filepath !== 'string')
|
|
37
40
|
return false;
|
|
38
41
|
return /^(\/|\\)?@hubspot/i.test(filepath.trim());
|
|
39
42
|
}
|
|
43
|
+
exports.isPathToHubspot = isPathToHubspot;
|
|
40
44
|
function useApiBuffer(mode) {
|
|
41
45
|
return mode === files_1.MODE.draft;
|
|
42
46
|
}
|
|
43
47
|
// Determines API param based on mode an options
|
|
44
|
-
function getFileMapperQueryValues(mode, { staging, assetVersion }) {
|
|
48
|
+
function getFileMapperQueryValues(mode, { staging, assetVersion } = {}) {
|
|
45
49
|
return {
|
|
46
50
|
params: {
|
|
47
51
|
buffer: useApiBuffer(mode),
|
|
@@ -88,6 +92,7 @@ function getTypeDataFromPath(src) {
|
|
|
88
92
|
isFolder,
|
|
89
93
|
};
|
|
90
94
|
}
|
|
95
|
+
exports.getTypeDataFromPath = getTypeDataFromPath;
|
|
91
96
|
function recurseFolder(node, callback, filepath = '', depth = 0) {
|
|
92
97
|
validateFileMapperNode(node);
|
|
93
98
|
const isRootFolder = node.folder && depth === 0;
|
|
@@ -108,6 +113,7 @@ function recurseFolder(node, callback, filepath = '', depth = 0) {
|
|
|
108
113
|
});
|
|
109
114
|
return depth === 0 ? false : __break;
|
|
110
115
|
}
|
|
116
|
+
exports.recurseFolder = recurseFolder;
|
|
111
117
|
async function writeUtimes(accountId, filepath, node) {
|
|
112
118
|
try {
|
|
113
119
|
const now = new Date();
|
|
@@ -123,6 +129,7 @@ async function writeUtimes(accountId, filepath, node) {
|
|
|
123
129
|
});
|
|
124
130
|
}
|
|
125
131
|
}
|
|
132
|
+
exports.writeUtimes = writeUtimes;
|
|
126
133
|
async function skipExisting(filepath, overwrite = false) {
|
|
127
134
|
if (overwrite) {
|
|
128
135
|
return false;
|
|
@@ -145,9 +152,9 @@ async function fetchAndWriteFileStream(accountId, srcPath, filepath, mode, optio
|
|
|
145
152
|
if (!(0, path_2.isAllowedExtension)(srcPath)) {
|
|
146
153
|
(0, standardErrors_1.throwErrorWithMessage)('filemapper.invalidFileType', { srcPath });
|
|
147
154
|
}
|
|
155
|
+
let node;
|
|
148
156
|
try {
|
|
149
|
-
|
|
150
|
-
await writeUtimes(accountId, filepath, node);
|
|
157
|
+
node = await (0, fileMapper_1.fetchFileStream)(accountId, srcPath, filepath, getFileMapperQueryValues(mode, options));
|
|
151
158
|
}
|
|
152
159
|
catch (err) {
|
|
153
160
|
(0, apiErrors_1.throwStatusCodeError)(err, {
|
|
@@ -155,6 +162,7 @@ async function fetchAndWriteFileStream(accountId, srcPath, filepath, mode, optio
|
|
|
155
162
|
request: srcPath,
|
|
156
163
|
});
|
|
157
164
|
}
|
|
165
|
+
await writeUtimes(accountId, filepath, node);
|
|
158
166
|
}
|
|
159
167
|
// Writes an individual file or folder (not recursive). If file source is missing, the
|
|
160
168
|
//file is fetched.
|
|
@@ -189,7 +197,7 @@ async function writeFileMapperNode(accountId, filepath, node, mode, options = {}
|
|
|
189
197
|
return true;
|
|
190
198
|
}
|
|
191
199
|
function isTimeout(err) {
|
|
192
|
-
return !!err && (err.
|
|
200
|
+
return !!err && (err.status === 408 || err.code === 'ESOCKETTIMEDOUT');
|
|
193
201
|
}
|
|
194
202
|
async function downloadFile(accountId, src, destPath, mode, options = {}, logCallbacks) {
|
|
195
203
|
const logger = (0, logger_1.makeTypedLogger)(logCallbacks, 'filemapper');
|
|
@@ -263,6 +271,7 @@ async function fetchFolderFromApi(accountId, src, mode, options = {}, logCallbac
|
|
|
263
271
|
}
|
|
264
272
|
}
|
|
265
273
|
}
|
|
274
|
+
exports.fetchFolderFromApi = fetchFolderFromApi;
|
|
266
275
|
async function downloadFolder(accountId, src, destPath, mode, options = {}, logCallbacks) {
|
|
267
276
|
const logger = (0, logger_1.makeTypedLogger)(logCallbacks, 'filemapper');
|
|
268
277
|
try {
|
package/lib/hubdb.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Row } from '../types/Hubdb';
|
|
2
|
-
export declare function addRowsToHubDbTable(accountId: number, tableId: string, rows
|
|
2
|
+
export declare function addRowsToHubDbTable(accountId: number, tableId: string, rows?: Array<Row>): Promise<{
|
|
3
3
|
tableId: string;
|
|
4
4
|
rowCount: number;
|
|
5
5
|
}>;
|
package/lib/hubdb.js
CHANGED
|
@@ -28,7 +28,7 @@ function validateJsonFile(src) {
|
|
|
28
28
|
}
|
|
29
29
|
validateJsonPath(src);
|
|
30
30
|
}
|
|
31
|
-
async function addRowsToHubDbTable(accountId, tableId, rows) {
|
|
31
|
+
async function addRowsToHubDbTable(accountId, tableId, rows = []) {
|
|
32
32
|
const rowsToUpdate = rows.map(row => {
|
|
33
33
|
const values = row.values;
|
|
34
34
|
return {
|
|
@@ -5,7 +5,7 @@ type AccessToken = {
|
|
|
5
5
|
accessToken: string;
|
|
6
6
|
expiresAt: string;
|
|
7
7
|
scopeGroups: Array<string>;
|
|
8
|
-
|
|
8
|
+
encodedOAuthRefreshToken: string;
|
|
9
9
|
};
|
|
10
10
|
export declare function getAccessToken(personalAccessKey: string, env?: Environment, accountId?: number): Promise<AccessToken>;
|
|
11
11
|
export declare function accessTokenForPersonalAccessKey(accountId: number): Promise<string | undefined>;
|
package/lib/personalAccessKey.js
CHANGED
|
@@ -22,7 +22,7 @@ async function getAccessToken(personalAccessKey, env = environments_1.ENVIRONMEN
|
|
|
22
22
|
}
|
|
23
23
|
catch (e) {
|
|
24
24
|
const error = e;
|
|
25
|
-
if (error.response) {
|
|
25
|
+
if (error.response && error.response.body) {
|
|
26
26
|
(0, standardErrors_1.throwAuthErrorWithMessage)('personalAccessKey.invalidPersonalAccessKey', { errorMessage: error.response.body.message || '' }, error);
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
@@ -34,7 +34,7 @@ async function getAccessToken(personalAccessKey, env = environments_1.ENVIRONMEN
|
|
|
34
34
|
accessToken: response.oauthAccessToken,
|
|
35
35
|
expiresAt: (0, moment_1.default)(response.expiresAtMillis).toISOString(),
|
|
36
36
|
scopeGroups: response.scopeGroups,
|
|
37
|
-
|
|
37
|
+
encodedOAuthRefreshToken: response.encodedOAuthRefreshToken,
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
exports.getAccessToken = getAccessToken;
|
|
@@ -89,7 +89,7 @@ async function accessTokenForPersonalAccessKey(accountId) {
|
|
|
89
89
|
return auth?.tokenInfo?.accessToken;
|
|
90
90
|
}
|
|
91
91
|
exports.accessTokenForPersonalAccessKey = accessTokenForPersonalAccessKey;
|
|
92
|
-
// Adds
|
|
92
|
+
// Adds an account to the config using authType: personalAccessKey
|
|
93
93
|
const updateConfigWithPersonalAccessKey = async (personalAccessKey, name, env, makeDefault = false) => {
|
|
94
94
|
const accountEnv = env || (0, config_1.getEnv)(name);
|
|
95
95
|
let token;
|
package/lib/trackUsage.js
CHANGED
|
@@ -37,7 +37,7 @@ async function trackUsage(eventName, eventClass, meta = {}, accountId) {
|
|
|
37
37
|
(0, logger_1.debug)(`${i18nKey}.sendingEventAuthenticated`);
|
|
38
38
|
return http_1.default.post(accountId, {
|
|
39
39
|
url: `${path}/authenticated`,
|
|
40
|
-
|
|
40
|
+
data: usageEvent,
|
|
41
41
|
resolveWithFullResponse: true,
|
|
42
42
|
});
|
|
43
43
|
}
|
|
@@ -46,7 +46,7 @@ async function trackUsage(eventName, eventClass, meta = {}, accountId) {
|
|
|
46
46
|
http_1.default.post(accountId, {
|
|
47
47
|
env,
|
|
48
48
|
url: path,
|
|
49
|
-
|
|
49
|
+
data: usageEvent,
|
|
50
50
|
resolveWithFullResponse: true,
|
|
51
51
|
});
|
|
52
52
|
}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HubSpotAuthError = void 0;
|
|
4
4
|
class HubSpotAuthError extends Error {
|
|
5
|
-
|
|
5
|
+
status;
|
|
6
6
|
category;
|
|
7
7
|
subCategory;
|
|
8
8
|
constructor(message, { cause = {} }) {
|
|
9
9
|
super(message);
|
|
10
10
|
this.name = 'HubSpotAuthError';
|
|
11
|
-
this.
|
|
11
|
+
this.status = cause.status;
|
|
12
12
|
this.category = cause?.response?.body?.category || undefined;
|
|
13
13
|
this.subCategory =
|
|
14
14
|
(cause.response &&
|
|
@@ -21,7 +21,7 @@ declare class OAuth2Manager {
|
|
|
21
21
|
exchangeForTokens(exchangeProof: ExchangeProof): Promise<void>;
|
|
22
22
|
refreshAccessToken(): Promise<void>;
|
|
23
23
|
toObj(): {
|
|
24
|
-
|
|
24
|
+
env: import("../types/Config").Environment;
|
|
25
25
|
clientSecret: string | undefined;
|
|
26
26
|
clientId: string | undefined;
|
|
27
27
|
scopes: string[] | undefined;
|
package/models/OAuth2Manager.js
CHANGED
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const axios_1 = __importDefault(require("axios"));
|
|
7
7
|
const moment_1 = __importDefault(require("moment"));
|
|
8
|
-
const environments_1 = require("../constants/environments");
|
|
9
8
|
const urls_1 = require("../lib/urls");
|
|
10
9
|
const environment_1 = require("../lib/environment");
|
|
11
10
|
const logger_1 = require("../utils/logger");
|
|
@@ -18,9 +17,10 @@ class OAuth2Manager {
|
|
|
18
17
|
writeTokenInfo;
|
|
19
18
|
refreshTokenRequest;
|
|
20
19
|
constructor(account, writeTokenInfo) {
|
|
21
|
-
this.account = account;
|
|
22
20
|
this.writeTokenInfo = writeTokenInfo;
|
|
23
21
|
this.refreshTokenRequest = null;
|
|
22
|
+
this.account = account;
|
|
23
|
+
// NOTE: Potential issues by not using maskProductionValue = '' for env like in cli-lib
|
|
24
24
|
}
|
|
25
25
|
async accessToken() {
|
|
26
26
|
if (!this.account.auth.tokenInfo?.refreshToken) {
|
|
@@ -106,7 +106,7 @@ class OAuth2Manager {
|
|
|
106
106
|
}
|
|
107
107
|
toObj() {
|
|
108
108
|
return {
|
|
109
|
-
|
|
109
|
+
env: this.account.env,
|
|
110
110
|
clientSecret: this.account.auth.clientSecret,
|
|
111
111
|
clientId: this.account.auth.clientId,
|
|
112
112
|
scopes: this.account.auth.scopes,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/local-dev-lib",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -12,21 +12,19 @@
|
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
|
-
"build": "rm -rf ./dist/ && tsc --rootDir . --outdir dist && yarn copy-files",
|
|
15
|
+
"build": "rm -rf ./dist/ && tsc --rootDir . --outdir dist && yarn copy-files && yarn clear-postinstall",
|
|
16
16
|
"check-main": "branch=$(git rev-parse --abbrev-ref HEAD) && [ $branch = main ] || (echo 'Error: New release can only be published on main branch' && exit 1)",
|
|
17
|
+
"clear-postinstall": "cd dist && npm pkg delete scripts.postinstall",
|
|
17
18
|
"copy-files": "cp -r lang dist/lang",
|
|
18
19
|
"lint": "eslint --max-warnings=0 . && prettier --check ./**/*.ts",
|
|
19
20
|
"local-dev": "yarn build && cd dist && yarn link && cd .. && tsc --watch --rootDir . --outdir dist",
|
|
20
|
-
"postinstall": "husky install",
|
|
21
|
-
"prepack": "pinst --disable",
|
|
22
|
-
"postpack": "pinst --enable",
|
|
23
21
|
"prettier:write": "prettier --write ./**/*.{ts,js,json}",
|
|
24
22
|
"pub": "cd dist && npm publish --tag latest && cd ..",
|
|
25
23
|
"push": "git push --atomic origin main v$npm_package_version",
|
|
26
24
|
"release:major": "yarn check-main && yarn version --major && yarn build && yarn pub && yarn push",
|
|
27
25
|
"release:minor": "yarn check-main && yarn version --minor && yarn build && yarn pub && yarn push",
|
|
28
26
|
"release:patch": "yarn check-main && yarn version --patch && yarn build && yarn pub && yarn push",
|
|
29
|
-
"test": "
|
|
27
|
+
"test": "node --experimental-vm-modules ./node_modules/.bin/jest"
|
|
30
28
|
},
|
|
31
29
|
"license": "Apache-2.0",
|
|
32
30
|
"devDependencies": {
|
|
@@ -44,7 +42,6 @@
|
|
|
44
42
|
"eslint": "^8.35.0",
|
|
45
43
|
"husky": "^8.0.0",
|
|
46
44
|
"jest": "^29.5.0",
|
|
47
|
-
"pinst": "^3.0.0",
|
|
48
45
|
"ts-jest": "^29.0.5",
|
|
49
46
|
"typescript": "^4.9.5"
|
|
50
47
|
},
|
package/types/Error.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { HttpMethod } from './Api';
|
|
2
|
+
export interface GenericError extends Error {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
}
|
|
2
5
|
export interface BaseError extends Error {
|
|
3
6
|
name: string;
|
|
4
7
|
message: string;
|
|
@@ -6,13 +9,13 @@ export interface BaseError extends Error {
|
|
|
6
9
|
code?: string | null;
|
|
7
10
|
syscall?: string | null;
|
|
8
11
|
reason?: string;
|
|
9
|
-
|
|
12
|
+
status?: number;
|
|
10
13
|
error?: BaseError;
|
|
11
14
|
errors?: Array<BaseError>;
|
|
12
15
|
}
|
|
13
16
|
export interface StatusCodeError extends BaseError {
|
|
14
17
|
name: string;
|
|
15
|
-
|
|
18
|
+
status?: number;
|
|
16
19
|
message: string;
|
|
17
20
|
category?: string;
|
|
18
21
|
subCategory?: string;
|
|
@@ -30,7 +33,7 @@ export interface StatusCodeError extends BaseError {
|
|
|
30
33
|
headers: {
|
|
31
34
|
[key: string]: string;
|
|
32
35
|
};
|
|
33
|
-
|
|
36
|
+
status: number;
|
|
34
37
|
};
|
|
35
38
|
options?: {
|
|
36
39
|
method: HttpMethod;
|
package/types/Http.d.ts
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ReadStream } from 'fs';
|
|
3
|
-
export type
|
|
3
|
+
export type Data = {
|
|
4
4
|
[key: string]: any;
|
|
5
5
|
};
|
|
6
|
+
export type QueryParams = {
|
|
7
|
+
[key: string]: string | number | boolean | undefined;
|
|
8
|
+
};
|
|
6
9
|
export type AxiosConfigOptions = {
|
|
10
|
+
baseURL?: string;
|
|
7
11
|
url: string;
|
|
8
12
|
env?: string;
|
|
9
13
|
localHostOverride?: boolean;
|
|
10
|
-
params?:
|
|
11
|
-
|
|
12
|
-
buffer?: boolean;
|
|
13
|
-
environmentId?: number;
|
|
14
|
-
version?: string;
|
|
15
|
-
};
|
|
16
|
-
body?: Body | JSON;
|
|
14
|
+
params?: QueryParams;
|
|
15
|
+
data?: Data;
|
|
17
16
|
resolveWithFullResponse?: boolean;
|
|
18
|
-
|
|
19
|
-
export type QueryParams = {
|
|
20
|
-
[key: string]: string | number | boolean;
|
|
17
|
+
timeout?: number;
|
|
21
18
|
};
|
|
22
19
|
export type FormData = {
|
|
23
20
|
[key: string]: string | ReadStream;
|
package/types/Hubdb.d.ts
CHANGED
|
@@ -10,22 +10,25 @@ export type Schema = {
|
|
|
10
10
|
export type Table = {
|
|
11
11
|
id: string;
|
|
12
12
|
name: string;
|
|
13
|
-
portalId
|
|
13
|
+
portalId?: number;
|
|
14
14
|
createdAt: string;
|
|
15
15
|
publishedAt: string;
|
|
16
16
|
updatedAt: string;
|
|
17
17
|
label: string;
|
|
18
18
|
columns: Array<Column>;
|
|
19
|
-
rows
|
|
20
|
-
partitioningSettings?:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
rows?: Array<Row>;
|
|
20
|
+
partitioningSettings?: {
|
|
21
|
+
teamIds: Array<any>;
|
|
22
|
+
userIds: Array<any>;
|
|
23
|
+
};
|
|
24
|
+
published?: boolean;
|
|
25
|
+
cosObjectType?: string;
|
|
26
|
+
updated?: number;
|
|
24
27
|
archived: boolean;
|
|
25
|
-
columnCount
|
|
26
|
-
cdnPurgeEmbargoTime
|
|
28
|
+
columnCount?: number;
|
|
29
|
+
cdnPurgeEmbargoTime?: number | null;
|
|
27
30
|
rowCount: number;
|
|
28
|
-
createdBy
|
|
31
|
+
createdBy?: {
|
|
29
32
|
id: string;
|
|
30
33
|
email: string;
|
|
31
34
|
firstName: string;
|
|
@@ -34,15 +37,17 @@ export type Table = {
|
|
|
34
37
|
useForPages: boolean;
|
|
35
38
|
allowChildTables: boolean;
|
|
36
39
|
enableChildTablePages: boolean;
|
|
37
|
-
crmObjectTypeId
|
|
38
|
-
dynamicMetaTags?:
|
|
40
|
+
crmObjectTypeId?: number;
|
|
41
|
+
dynamicMetaTags?: {
|
|
42
|
+
[key: string]: number;
|
|
43
|
+
};
|
|
39
44
|
allowPublicApiAccess: boolean;
|
|
40
45
|
};
|
|
41
46
|
export type Column = {
|
|
42
47
|
name: string;
|
|
43
48
|
label: string;
|
|
44
|
-
id
|
|
45
|
-
archived
|
|
49
|
+
id?: string;
|
|
50
|
+
archived?: boolean;
|
|
46
51
|
type: string;
|
|
47
52
|
deleted?: boolean;
|
|
48
53
|
foreignIdsByName?: {
|
|
@@ -66,7 +71,9 @@ export type Row = {
|
|
|
66
71
|
updatedAt: string;
|
|
67
72
|
publishedAt: string | null;
|
|
68
73
|
values: {
|
|
69
|
-
text_column
|
|
74
|
+
text_column?: string;
|
|
75
|
+
number_column?: number;
|
|
76
|
+
multiselect?: Array<any>;
|
|
70
77
|
};
|
|
71
78
|
path: string | null;
|
|
72
79
|
name: string | null;
|
|
@@ -76,8 +83,11 @@ export type Row = {
|
|
|
76
83
|
export type CreateRowsResponse = {
|
|
77
84
|
status: string;
|
|
78
85
|
results: Array<Row>;
|
|
79
|
-
startedAt
|
|
80
|
-
completedAt
|
|
86
|
+
startedAt?: string;
|
|
87
|
+
completedAt?: string;
|
|
88
|
+
links?: {
|
|
89
|
+
[key: string]: any;
|
|
90
|
+
};
|
|
81
91
|
};
|
|
82
92
|
export type FetchRowsResponse = {
|
|
83
93
|
total: number;
|
|
@@ -86,5 +96,5 @@ export type FetchRowsResponse = {
|
|
|
86
96
|
next: {
|
|
87
97
|
after: string | null;
|
|
88
98
|
};
|
|
89
|
-
};
|
|
99
|
+
} | null;
|
|
90
100
|
};
|