@hubspot/local-dev-lib 0.2.4 → 0.2.5-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 +16 -16
- package/api/fileTransport.d.ts +4 -0
- package/api/fileTransport.js +39 -0
- package/api/functions.d.ts +7 -7
- package/api/functions.js +13 -16
- 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 +163 -43
- 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 +106 -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 +49 -6
- 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 +2 -27
- package/models/OAuth2Manager.js +20 -34
- package/package.json +34 -36
- 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 -12
- 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 -16
- package/errors/apiErrors.js +0 -176
- package/errors/fileSystemErrors.d.ts +0 -6
- package/errors/fileSystemErrors.js +0 -35
- package/errors/standardErrors.d.ts +0 -21
- package/errors/standardErrors.js +0 -52
- 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/types/Sandbox.d.ts
CHANGED
|
@@ -6,9 +6,9 @@ type User = {
|
|
|
6
6
|
userId: number;
|
|
7
7
|
firstName: string;
|
|
8
8
|
lastName: string;
|
|
9
|
-
gdprDeleted
|
|
10
|
-
removed
|
|
11
|
-
deactivated
|
|
9
|
+
gdprDeleted?: boolean;
|
|
10
|
+
removed?: boolean;
|
|
11
|
+
deactivated?: boolean;
|
|
12
12
|
};
|
|
13
13
|
type TaskError = {
|
|
14
14
|
message: string;
|
|
@@ -47,13 +47,13 @@ type MutationError = {
|
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
|
-
type
|
|
50
|
+
type SyncMutationData = {
|
|
51
51
|
numRequests: number;
|
|
52
52
|
numSuccesses: number;
|
|
53
53
|
errors: Array<TaskError>;
|
|
54
54
|
mutationErrors: Array<MutationError>;
|
|
55
55
|
};
|
|
56
|
-
export type
|
|
56
|
+
export type CompositeSyncTask = {
|
|
57
57
|
id: string;
|
|
58
58
|
parentHubId: number;
|
|
59
59
|
sandboxHubId: number;
|
|
@@ -70,45 +70,46 @@ export type Task = {
|
|
|
70
70
|
startedAt: string;
|
|
71
71
|
completedAt: string;
|
|
72
72
|
error: MutationError;
|
|
73
|
-
creates:
|
|
74
|
-
updates:
|
|
75
|
-
deletes:
|
|
73
|
+
creates: SyncMutationData;
|
|
74
|
+
updates: SyncMutationData;
|
|
75
|
+
deletes: SyncMutationData;
|
|
76
76
|
diffSummary: string;
|
|
77
77
|
portableKeys: Array<string>;
|
|
78
78
|
};
|
|
79
|
+
export type SyncTask = {
|
|
80
|
+
id: string;
|
|
81
|
+
parentHubId: number;
|
|
82
|
+
sandboxHubId: number;
|
|
83
|
+
fromHubId: number;
|
|
84
|
+
toHubId: number;
|
|
85
|
+
command: string;
|
|
86
|
+
status: string;
|
|
87
|
+
result: string;
|
|
88
|
+
sandboxType: string;
|
|
89
|
+
requestedAt: string;
|
|
90
|
+
requestedByUserId: number;
|
|
91
|
+
requestedByUser: User;
|
|
92
|
+
startedAt: string;
|
|
93
|
+
completedAt: string;
|
|
94
|
+
tasks: Array<CompositeSyncTask>;
|
|
95
|
+
};
|
|
79
96
|
export type Sandbox = {
|
|
80
97
|
sandboxHubId: number;
|
|
81
98
|
parentHubId: number;
|
|
82
99
|
createdAt: string;
|
|
83
|
-
updatedAt
|
|
84
|
-
archivedAt
|
|
100
|
+
updatedAt?: string | null;
|
|
101
|
+
archivedAt?: string | null;
|
|
85
102
|
type: string;
|
|
86
103
|
archived: boolean;
|
|
87
104
|
name: string;
|
|
88
105
|
domain: string;
|
|
89
106
|
createdByUser: User;
|
|
90
|
-
updatedByUser
|
|
91
|
-
lastSync
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
toHubId: number;
|
|
97
|
-
command: string;
|
|
98
|
-
status: string;
|
|
99
|
-
result: string;
|
|
100
|
-
sandboxType: string;
|
|
101
|
-
requestedAt: string;
|
|
102
|
-
requestedByUserId: number;
|
|
103
|
-
requestedByUser: User;
|
|
104
|
-
startedAt: string;
|
|
105
|
-
completedAt: string;
|
|
106
|
-
tasks: Array<Task>;
|
|
107
|
-
};
|
|
108
|
-
currentUserHasAccess: boolean | null;
|
|
109
|
-
currentUserHasSuperAdminAccess: boolean | null;
|
|
110
|
-
requestAccessFrom: User | null;
|
|
111
|
-
superAdminsInSandbox: number | null;
|
|
107
|
+
updatedByUser?: User | null;
|
|
108
|
+
lastSync?: SyncTask;
|
|
109
|
+
currentUserHasAccess?: boolean;
|
|
110
|
+
currentUserHasSuperAdminAccess?: boolean;
|
|
111
|
+
requestAccessFrom?: User | null;
|
|
112
|
+
superAdminsInSandbox?: number;
|
|
112
113
|
};
|
|
113
114
|
export type SandboxResponse = {
|
|
114
115
|
sandbox: Sandbox;
|
|
@@ -129,35 +130,24 @@ export type Usage = {
|
|
|
129
130
|
export type SandboxUsageLimitsResponse = {
|
|
130
131
|
usage: Usage;
|
|
131
132
|
};
|
|
132
|
-
export type
|
|
133
|
+
export type TaskRequestData = {
|
|
133
134
|
type: string;
|
|
134
135
|
};
|
|
135
136
|
export type InitiateSyncResponse = {
|
|
136
137
|
links: {
|
|
137
138
|
status: string;
|
|
138
139
|
};
|
|
139
|
-
sync:
|
|
140
|
-
id: string;
|
|
141
|
-
parentHubId: number;
|
|
142
|
-
sandboxHubId: number;
|
|
143
|
-
fromHubId: number;
|
|
144
|
-
toHubId: number;
|
|
145
|
-
command: string;
|
|
146
|
-
status: string;
|
|
147
|
-
sandboxType: string;
|
|
148
|
-
requestedAt: string;
|
|
149
|
-
requestedByUserId: number;
|
|
150
|
-
tasks: Array<Task>;
|
|
151
|
-
};
|
|
140
|
+
sync: SyncTask;
|
|
152
141
|
id: string;
|
|
153
142
|
};
|
|
154
143
|
export type SandboxType = {
|
|
155
144
|
name: string;
|
|
156
145
|
dependsOn: Array<string>;
|
|
157
|
-
|
|
146
|
+
pushToProductionEnabled: boolean;
|
|
158
147
|
isBeta: boolean;
|
|
159
148
|
diffEnabled: boolean;
|
|
160
149
|
groupType: string;
|
|
150
|
+
syncMandatory: boolean;
|
|
161
151
|
};
|
|
162
152
|
export type FetchTypesResponse = {
|
|
163
153
|
results: Array<SandboxType>;
|
package/types/Schemas.d.ts
CHANGED
|
@@ -25,3 +25,59 @@ export type Schema = {
|
|
|
25
25
|
export type FetchSchemasResponse = {
|
|
26
26
|
results: Array<Schema>;
|
|
27
27
|
};
|
|
28
|
+
export type CreateObjectsResponse = {
|
|
29
|
+
status: string;
|
|
30
|
+
startedAt: string;
|
|
31
|
+
completedAt: string;
|
|
32
|
+
results: Array<{
|
|
33
|
+
id: string;
|
|
34
|
+
properties: Array<any>;
|
|
35
|
+
createdAt: string;
|
|
36
|
+
updatedAt: string;
|
|
37
|
+
archived: boolean;
|
|
38
|
+
}>;
|
|
39
|
+
};
|
|
40
|
+
export type SchemaDefinition = {
|
|
41
|
+
allowsSensitiveProperties?: boolean;
|
|
42
|
+
associatedObjects?: Array<string>;
|
|
43
|
+
description?: string;
|
|
44
|
+
labels: {
|
|
45
|
+
plural: string;
|
|
46
|
+
singular: string;
|
|
47
|
+
};
|
|
48
|
+
searchableProperties?: Array<string>;
|
|
49
|
+
secondaryDisplayProperties?: Array<string>;
|
|
50
|
+
name: string;
|
|
51
|
+
primaryDisplayProperty?: string;
|
|
52
|
+
properties: [
|
|
53
|
+
{
|
|
54
|
+
isPrimaryDisplayLabel: true;
|
|
55
|
+
label: string;
|
|
56
|
+
name: string;
|
|
57
|
+
}
|
|
58
|
+
];
|
|
59
|
+
requiredProperties: Array<string>;
|
|
60
|
+
};
|
|
61
|
+
export type ObjectDefinition = {
|
|
62
|
+
inputs: [
|
|
63
|
+
{
|
|
64
|
+
associations?: [
|
|
65
|
+
{
|
|
66
|
+
types: [
|
|
67
|
+
{
|
|
68
|
+
associationCategory: string;
|
|
69
|
+
associationTypeId: number;
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
to: {
|
|
73
|
+
id: string;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
];
|
|
77
|
+
objectWriteTraceId?: number;
|
|
78
|
+
properties: {
|
|
79
|
+
[key: string]: string;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
];
|
|
83
|
+
};
|
package/types/Secrets.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type DeveloperTestAccount = {
|
|
2
|
+
testPortalId: number;
|
|
3
|
+
parentPortalId: number;
|
|
4
|
+
accountName: string;
|
|
5
|
+
createdAt: string;
|
|
6
|
+
updatedAt: string;
|
|
7
|
+
status: string;
|
|
8
|
+
id: number;
|
|
9
|
+
};
|
|
10
|
+
export type FetchDeveloperTestAccountsResponse = {
|
|
11
|
+
results: DeveloperTestAccount[];
|
|
12
|
+
maxTestPortals: number;
|
|
13
|
+
};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Express, Request, Response } from 'express';
|
|
3
3
|
import { Server } from 'http';
|
|
4
|
-
import { RequestPortsData } from '../types/PortManager';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
declare class PortManagerServer {
|
|
4
|
+
import { RequestPortsData, ServerPortMap } from '../types/PortManager';
|
|
5
|
+
export declare const HEALTH_CHECK_PATH = "/port-manager-health-check";
|
|
6
|
+
export declare const SERVICE_HEALTHY = "OK";
|
|
7
|
+
declare class _PortManagerServer {
|
|
9
8
|
app?: Express;
|
|
10
9
|
server?: Server;
|
|
11
10
|
serverPortMap: ServerPortMap;
|
|
@@ -25,5 +24,5 @@ declare class PortManagerServer {
|
|
|
25
24
|
deleteServerInstance: (req: Request, res: Response) => void;
|
|
26
25
|
closeServer: (req: Request, res: Response) => void;
|
|
27
26
|
}
|
|
28
|
-
declare const
|
|
29
|
-
export
|
|
27
|
+
export declare const PortManagerServer: _PortManagerServer;
|
|
28
|
+
export {};
|
|
@@ -3,15 +3,18 @@ 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.PortManagerServer = exports.SERVICE_HEALTHY = exports.HEALTH_CHECK_PATH = void 0;
|
|
6
7
|
const express_1 = __importDefault(require("express"));
|
|
7
8
|
const cors_1 = __importDefault(require("cors"));
|
|
8
9
|
const detectPort_1 = require("./detectPort");
|
|
9
10
|
const ports_1 = require("../constants/ports");
|
|
10
|
-
const
|
|
11
|
-
const logger_1 = require("
|
|
11
|
+
const errors_1 = require("../errors");
|
|
12
|
+
const logger_1 = require("../lib/logger");
|
|
12
13
|
const lang_1 = require("./lang");
|
|
13
14
|
const i18nKey = 'utils.PortManagerServer';
|
|
14
|
-
|
|
15
|
+
exports.HEALTH_CHECK_PATH = '/port-manager-health-check';
|
|
16
|
+
exports.SERVICE_HEALTHY = 'OK';
|
|
17
|
+
class _PortManagerServer {
|
|
15
18
|
app;
|
|
16
19
|
server;
|
|
17
20
|
serverPortMap;
|
|
@@ -20,7 +23,7 @@ class PortManagerServer {
|
|
|
20
23
|
}
|
|
21
24
|
async init() {
|
|
22
25
|
if (this.app) {
|
|
23
|
-
(0,
|
|
26
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.duplicateInstance`));
|
|
24
27
|
}
|
|
25
28
|
this.app = (0, express_1.default)();
|
|
26
29
|
this.app.use(express_1.default.json());
|
|
@@ -28,15 +31,15 @@ class PortManagerServer {
|
|
|
28
31
|
this.setupRoutes();
|
|
29
32
|
try {
|
|
30
33
|
this.server = await this.listen();
|
|
34
|
+
logger_1.logger.debug(this.server);
|
|
31
35
|
}
|
|
32
36
|
catch (e) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.portInUse`, {
|
|
37
|
+
if ((0, errors_1.isSystemError)(e) && e.code === 'EADDRINUSE') {
|
|
38
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.portInUse`, {
|
|
36
39
|
port: ports_1.PORT_MANAGER_SERVER_PORT,
|
|
37
|
-
},
|
|
40
|
+
}), { cause: e });
|
|
38
41
|
}
|
|
39
|
-
throw
|
|
42
|
+
throw e;
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
45
|
reset() {
|
|
@@ -47,9 +50,9 @@ class PortManagerServer {
|
|
|
47
50
|
listen() {
|
|
48
51
|
return new Promise((resolve, reject) => {
|
|
49
52
|
const server = this.app.listen(ports_1.PORT_MANAGER_SERVER_PORT, () => {
|
|
50
|
-
(0,
|
|
53
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.started`, {
|
|
51
54
|
port: ports_1.PORT_MANAGER_SERVER_PORT,
|
|
52
|
-
});
|
|
55
|
+
}));
|
|
53
56
|
resolve(server);
|
|
54
57
|
}).on('error', (err) => {
|
|
55
58
|
reject(err);
|
|
@@ -65,16 +68,19 @@ class PortManagerServer {
|
|
|
65
68
|
this.app.post('/servers', this.assignPortsToServers);
|
|
66
69
|
this.app.delete('/servers/:instanceId', this.deleteServerInstance);
|
|
67
70
|
this.app.post('/close', this.closeServer);
|
|
71
|
+
this.app.use(exports.HEALTH_CHECK_PATH, (req, res) => {
|
|
72
|
+
res.status(200).send({ status: exports.SERVICE_HEALTHY });
|
|
73
|
+
});
|
|
68
74
|
}
|
|
69
75
|
setPort(instanceId, port) {
|
|
70
|
-
(0,
|
|
76
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.setPort`, { instanceId, port }));
|
|
71
77
|
this.serverPortMap[instanceId] = port;
|
|
72
78
|
}
|
|
73
79
|
deletePort(instanceId) {
|
|
74
|
-
(0,
|
|
80
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.deletedPort`, {
|
|
75
81
|
instanceId,
|
|
76
82
|
port: this.serverPortMap[instanceId],
|
|
77
|
-
});
|
|
83
|
+
}));
|
|
78
84
|
delete this.serverPortMap[instanceId];
|
|
79
85
|
}
|
|
80
86
|
send404(res, instanceId) {
|
|
@@ -148,11 +154,11 @@ class PortManagerServer {
|
|
|
148
154
|
};
|
|
149
155
|
closeServer = (req, res) => {
|
|
150
156
|
if (this.server) {
|
|
151
|
-
(0,
|
|
157
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.close`));
|
|
152
158
|
res.sendStatus(200);
|
|
153
159
|
this.server.close();
|
|
154
160
|
this.reset();
|
|
155
161
|
}
|
|
156
162
|
};
|
|
157
163
|
}
|
|
158
|
-
exports.
|
|
164
|
+
exports.PortManagerServer = new _PortManagerServer();
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { CLIAccount } from '../types/Accounts';
|
|
2
2
|
import { CLIConfig } from '../types/Config';
|
|
3
|
-
type Account = {
|
|
4
|
-
portalId?: number;
|
|
5
|
-
accountId?: number;
|
|
6
|
-
};
|
|
7
|
-
export declare function getAccountIdentifier(account?: Account | null): number | undefined;
|
|
8
3
|
export declare function getAccounts(config?: CLIConfig | null): Array<CLIAccount>;
|
|
9
4
|
export declare function getDefaultAccount(config?: CLIConfig | null): string | number | undefined;
|
|
10
|
-
export {};
|
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDefaultAccount = exports.getAccounts =
|
|
4
|
-
function getAccountIdentifier(account) {
|
|
5
|
-
if (!account) {
|
|
6
|
-
return undefined;
|
|
7
|
-
}
|
|
8
|
-
else if (Object.hasOwn(account, 'portalId')) {
|
|
9
|
-
return account.portalId;
|
|
10
|
-
}
|
|
11
|
-
else if (Object.hasOwn(account, 'accountId')) {
|
|
12
|
-
return account.accountId;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.getAccountIdentifier = getAccountIdentifier;
|
|
3
|
+
exports.getDefaultAccount = exports.getAccounts = void 0;
|
|
16
4
|
function getAccounts(config) {
|
|
17
5
|
if (!config) {
|
|
18
6
|
return [];
|
package/utils/cms/fieldsJS.d.ts
CHANGED
package/utils/cms/modules.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.isModuleFolderChild = exports.isModuleFolder = exports.isPathInput = voi
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const path_2 = require("../../lib/path");
|
|
9
9
|
const extensions_1 = require("../../constants/extensions");
|
|
10
|
-
const
|
|
10
|
+
const lang_1 = require("../lang");
|
|
11
11
|
const i18nKey = 'utils.cms.modules';
|
|
12
12
|
const isBool = (x) => !!x === x;
|
|
13
13
|
function isPathInput(pathInput) {
|
|
@@ -19,7 +19,7 @@ exports.isPathInput = isPathInput;
|
|
|
19
19
|
function throwInvalidPathInput(pathInput) {
|
|
20
20
|
if (isPathInput(pathInput))
|
|
21
21
|
return;
|
|
22
|
-
(0,
|
|
22
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.throwInvalidPathInput`));
|
|
23
23
|
}
|
|
24
24
|
function isModuleFolder(pathInput) {
|
|
25
25
|
throwInvalidPathInput(pathInput);
|
package/utils/detectPort.js
CHANGED
|
@@ -30,15 +30,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
30
30
|
exports.detectPort = void 0;
|
|
31
31
|
const net_1 = __importDefault(require("net"));
|
|
32
32
|
const address_1 = require("address");
|
|
33
|
-
const standardErrors_1 = require("../errors/standardErrors");
|
|
34
33
|
const ports_1 = require("../constants/ports");
|
|
34
|
+
const lang_1 = require("./lang");
|
|
35
35
|
const i18nKey = 'utils.detectPort';
|
|
36
36
|
function detectPort(port, exclude = []) {
|
|
37
37
|
if (port && (port < ports_1.MIN_PORT_NUMBER || port > ports_1.MAX_PORT_NUMBER)) {
|
|
38
|
-
(0,
|
|
38
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.invalidPort`, {
|
|
39
39
|
minPort: ports_1.MIN_PORT_NUMBER,
|
|
40
40
|
maxPort: ports_1.MAX_PORT_NUMBER,
|
|
41
|
-
});
|
|
41
|
+
}));
|
|
42
42
|
}
|
|
43
43
|
const portToUse = port || 0;
|
|
44
44
|
const maxPort = Math.min(portToUse + 10, ports_1.MAX_PORT_NUMBER);
|
package/utils/git.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
+
export declare function getGitignoreFiles(configPath: string): Array<string>;
|
|
1
2
|
export declare function isConfigPathInGitRepo(configPath: string): boolean;
|
|
2
3
|
export declare function configFilenameIsIgnoredByGitignore(ignoreFiles: Array<string>, configPath: string): boolean;
|
|
3
|
-
type GitInclusionResult = {
|
|
4
|
-
inGit: boolean;
|
|
5
|
-
configIgnored: boolean;
|
|
6
|
-
gitignoreFiles: Array<string>;
|
|
7
|
-
};
|
|
8
|
-
export declare function checkGitInclusion(configPath: string): GitInclusionResult;
|
|
9
|
-
export {};
|
package/utils/git.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.
|
|
6
|
+
exports.configFilenameIsIgnoredByGitignore = exports.isConfigPathInGitRepo = exports.getGitignoreFiles = void 0;
|
|
7
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const ignore_1 = __importDefault(require("ignore"));
|
|
@@ -47,6 +47,7 @@ function getGitignoreFiles(configPath) {
|
|
|
47
47
|
}
|
|
48
48
|
return files;
|
|
49
49
|
}
|
|
50
|
+
exports.getGitignoreFiles = getGitignoreFiles;
|
|
50
51
|
function isConfigPathInGitRepo(configPath) {
|
|
51
52
|
const gitDir = getGitComparisonDir();
|
|
52
53
|
if (!gitDir)
|
|
@@ -68,20 +69,3 @@ function configFilenameIsIgnoredByGitignore(ignoreFiles, configPath) {
|
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
71
|
exports.configFilenameIsIgnoredByGitignore = configFilenameIsIgnoredByGitignore;
|
|
71
|
-
function checkGitInclusion(configPath) {
|
|
72
|
-
const result = {
|
|
73
|
-
inGit: false,
|
|
74
|
-
configIgnored: false,
|
|
75
|
-
gitignoreFiles: [],
|
|
76
|
-
};
|
|
77
|
-
if (isConfigPathInGitRepo(configPath)) {
|
|
78
|
-
result.inGit = true;
|
|
79
|
-
result.gitignoreFiles = getGitignoreFiles(configPath);
|
|
80
|
-
if (configFilenameIsIgnoredByGitignore(result.gitignoreFiles, configPath)) {
|
|
81
|
-
// Found ignore statement in .gitignore that matches config filename
|
|
82
|
-
result.configIgnored = true;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return result;
|
|
86
|
-
}
|
|
87
|
-
exports.checkGitInclusion = checkGitInclusion;
|
package/errors/apiErrors.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { AxiosError } from 'axios';
|
|
2
|
-
import { GenericError, AxiosErrorContext } from '../types/Error';
|
|
3
|
-
import { HubSpotAuthError } from '../models/HubSpotAuthError';
|
|
4
|
-
export declare function isMissingScopeError(err: AxiosError<any>): boolean;
|
|
5
|
-
export declare function isGatingError(err: AxiosError<any>): boolean;
|
|
6
|
-
export declare function isApiUploadValidationError(err: AxiosError<any>): boolean;
|
|
7
|
-
export declare function isSpecifiedHubSpotAuthError(err: GenericError, { status, category, subCategory }: Partial<HubSpotAuthError>): boolean;
|
|
8
|
-
export declare function getAxiosErrorWithContext(error: AxiosError<any>, context?: AxiosErrorContext): Error;
|
|
9
|
-
/**
|
|
10
|
-
* @throws
|
|
11
|
-
*/
|
|
12
|
-
export declare function throwApiError(error: AxiosError, context?: AxiosErrorContext): never;
|
|
13
|
-
/**
|
|
14
|
-
* @throws
|
|
15
|
-
*/
|
|
16
|
-
export declare function throwApiUploadError(error: AxiosError, context?: AxiosErrorContext): never;
|
package/errors/apiErrors.js
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.throwApiUploadError = exports.throwApiError = exports.getAxiosErrorWithContext = exports.isSpecifiedHubSpotAuthError = exports.isApiUploadValidationError = exports.isGatingError = exports.isMissingScopeError = void 0;
|
|
4
|
-
const api_1 = require("../constants/api");
|
|
5
|
-
const lang_1 = require("../utils/lang");
|
|
6
|
-
const standardErrors_1 = require("./standardErrors");
|
|
7
|
-
const i18nKey = 'errors.apiErrors';
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
-
function isMissingScopeError(err) {
|
|
10
|
-
return (err.isAxiosError &&
|
|
11
|
-
err.status === 403 &&
|
|
12
|
-
!!err.response &&
|
|
13
|
-
err.response.data.category === 'MISSING_SCOPES');
|
|
14
|
-
}
|
|
15
|
-
exports.isMissingScopeError = isMissingScopeError;
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
-
function isGatingError(err) {
|
|
18
|
-
return (err.isAxiosError &&
|
|
19
|
-
err.status === 403 &&
|
|
20
|
-
!!err.response &&
|
|
21
|
-
err.response.data.category === 'GATED');
|
|
22
|
-
}
|
|
23
|
-
exports.isGatingError = isGatingError;
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
-
function isApiUploadValidationError(err) {
|
|
26
|
-
return (err.isAxiosError &&
|
|
27
|
-
err.status === 400 &&
|
|
28
|
-
!!err.response &&
|
|
29
|
-
!!(err.response?.data?.message || !!err.response?.data?.errors));
|
|
30
|
-
}
|
|
31
|
-
exports.isApiUploadValidationError = isApiUploadValidationError;
|
|
32
|
-
function isSpecifiedHubSpotAuthError(err, { status, category, subCategory }) {
|
|
33
|
-
const statusCodeErr = !status || err.status === status;
|
|
34
|
-
const categoryErr = !category || err.category === category;
|
|
35
|
-
const subCategoryErr = !subCategory || err.subCategory === subCategory;
|
|
36
|
-
return Boolean(err.name === 'HubSpotAuthError' &&
|
|
37
|
-
statusCodeErr &&
|
|
38
|
-
categoryErr &&
|
|
39
|
-
subCategoryErr);
|
|
40
|
-
}
|
|
41
|
-
exports.isSpecifiedHubSpotAuthError = isSpecifiedHubSpotAuthError;
|
|
42
|
-
function parseValidationErrors(responseData = { errors: [], message: '' }) {
|
|
43
|
-
const errorMessages = [];
|
|
44
|
-
const { errors, message } = responseData;
|
|
45
|
-
if (message) {
|
|
46
|
-
errorMessages.push(message);
|
|
47
|
-
}
|
|
48
|
-
if (errors) {
|
|
49
|
-
const specificErrors = errors.map(error => {
|
|
50
|
-
let errorMessage = error.message;
|
|
51
|
-
if (error.errorTokens && error.errorTokens.line) {
|
|
52
|
-
errorMessage = `line ${error.errorTokens.line}: ${errorMessage}`;
|
|
53
|
-
}
|
|
54
|
-
return errorMessage;
|
|
55
|
-
});
|
|
56
|
-
errorMessages.push(...specificErrors);
|
|
57
|
-
}
|
|
58
|
-
return errorMessages;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* @throws
|
|
62
|
-
*/
|
|
63
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
64
|
-
function throwValidationErrors(error) {
|
|
65
|
-
const validationErrorMessages = parseValidationErrors(error?.response?.data);
|
|
66
|
-
if (validationErrorMessages.length) {
|
|
67
|
-
(0, standardErrors_1.throwError)(new Error(validationErrorMessages.join(' '), { cause: error }));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function getAxiosErrorWithContext(
|
|
71
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
72
|
-
error, context = {}) {
|
|
73
|
-
const { status } = error;
|
|
74
|
-
const method = error.config?.method;
|
|
75
|
-
const { projectName } = context;
|
|
76
|
-
let messageDetail;
|
|
77
|
-
if (context.accountId) {
|
|
78
|
-
const action = (method && api_1.HTTP_METHOD_VERBS[method]) || api_1.HTTP_METHOD_VERBS.get;
|
|
79
|
-
const preposition = (method && api_1.HTTP_METHOD_PREPOSITIONS[method]) ||
|
|
80
|
-
api_1.HTTP_METHOD_PREPOSITIONS.get;
|
|
81
|
-
const requestName = context.request
|
|
82
|
-
? `${action} ${preposition} '${context.request}'`
|
|
83
|
-
: action;
|
|
84
|
-
messageDetail = (0, lang_1.i18n)(`${i18nKey}.messageDetail`, {
|
|
85
|
-
accountId: context.accountId,
|
|
86
|
-
requestName,
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
messageDetail = (0, lang_1.i18n)(`${i18nKey}.genericMessageDetail`);
|
|
91
|
-
}
|
|
92
|
-
const errorMessage = [];
|
|
93
|
-
if ((method === 'put' || method === 'post') && context.payload) {
|
|
94
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.unableToUpload`, { payload: context.payload }));
|
|
95
|
-
}
|
|
96
|
-
const isProjectMissingScopeError = isMissingScopeError(error) && projectName;
|
|
97
|
-
const isProjectGatingError = isGatingError(error) && projectName;
|
|
98
|
-
switch (status) {
|
|
99
|
-
case 400:
|
|
100
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.400`, { messageDetail }));
|
|
101
|
-
break;
|
|
102
|
-
case 401:
|
|
103
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.401`, { messageDetail }));
|
|
104
|
-
break;
|
|
105
|
-
case 403:
|
|
106
|
-
if (isProjectMissingScopeError) {
|
|
107
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.403ProjectMissingScope`, {
|
|
108
|
-
accountId: context.accountId || '',
|
|
109
|
-
}));
|
|
110
|
-
}
|
|
111
|
-
else if (isProjectGatingError) {
|
|
112
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.403ProjectGating`, {
|
|
113
|
-
accountId: context.accountId || '',
|
|
114
|
-
}));
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.403`, { messageDetail }));
|
|
118
|
-
}
|
|
119
|
-
break;
|
|
120
|
-
case 404:
|
|
121
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.404`, { messageDetail }));
|
|
122
|
-
break;
|
|
123
|
-
case 429:
|
|
124
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.429`, { messageDetail }));
|
|
125
|
-
break;
|
|
126
|
-
case 503:
|
|
127
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.503`, { messageDetail }));
|
|
128
|
-
break;
|
|
129
|
-
default:
|
|
130
|
-
if (status && status >= 500 && status < 600) {
|
|
131
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.500Generic`, { messageDetail }));
|
|
132
|
-
}
|
|
133
|
-
else if (status && status >= 400 && status < 500) {
|
|
134
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.400Generic`, { messageDetail }));
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.generic`, { messageDetail }));
|
|
138
|
-
}
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
if (error?.response?.data) {
|
|
142
|
-
const { message, errors } = error.response.data;
|
|
143
|
-
if (message && !isProjectMissingScopeError && !isProjectGatingError) {
|
|
144
|
-
errorMessage.push(message);
|
|
145
|
-
}
|
|
146
|
-
if (errors) {
|
|
147
|
-
errors.forEach((err) => {
|
|
148
|
-
if (err.message) {
|
|
149
|
-
errorMessage.push('\n- ' + err.message);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return new Error(errorMessage.join(' '), { cause: error });
|
|
155
|
-
}
|
|
156
|
-
exports.getAxiosErrorWithContext = getAxiosErrorWithContext;
|
|
157
|
-
/**
|
|
158
|
-
* @throws
|
|
159
|
-
*/
|
|
160
|
-
function throwApiError(error, context = {}) {
|
|
161
|
-
if (error.isAxiosError) {
|
|
162
|
-
throw getAxiosErrorWithContext(error, context);
|
|
163
|
-
}
|
|
164
|
-
(0, standardErrors_1.throwError)(error);
|
|
165
|
-
}
|
|
166
|
-
exports.throwApiError = throwApiError;
|
|
167
|
-
/**
|
|
168
|
-
* @throws
|
|
169
|
-
*/
|
|
170
|
-
function throwApiUploadError(error, context = {}) {
|
|
171
|
-
if (isApiUploadValidationError(error)) {
|
|
172
|
-
throwValidationErrors(error);
|
|
173
|
-
}
|
|
174
|
-
throwApiError(error, context);
|
|
175
|
-
}
|
|
176
|
-
exports.throwApiUploadError = throwApiUploadError;
|