@hubspot/ui-extensions-dev-server 0.8.30 → 0.8.33
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/dist/lib/DevModeInterface.d.ts +3 -3
- package/dist/lib/DevServerState.d.ts +2 -2
- package/dist/lib/config.d.ts +1 -0
- package/dist/lib/config.js +42 -1
- package/dist/lib/types.d.ts +15 -3
- package/dist/lib/utils.js +2 -2
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExtensionOutputConfig, Logger, PlatformVersion, ProjectComponentMap, ProjectConfig } from './types';
|
|
2
2
|
import { PromptModule } from 'inquirer';
|
|
3
3
|
import { DevServerState } from './DevServerState';
|
|
4
4
|
interface SetupArguments {
|
|
@@ -24,10 +24,10 @@ interface StartArguments {
|
|
|
24
24
|
}
|
|
25
25
|
interface AppExtensionMapping {
|
|
26
26
|
name: string;
|
|
27
|
-
value:
|
|
27
|
+
value: ExtensionOutputConfig;
|
|
28
28
|
}
|
|
29
29
|
declare class DevModeInterface {
|
|
30
|
-
configs?:
|
|
30
|
+
configs?: ExtensionOutputConfig[];
|
|
31
31
|
devServerState?: DevServerState;
|
|
32
32
|
onUploadRequired?: VoidFunction;
|
|
33
33
|
shutdown?: () => Promise<void>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { AppConfig,
|
|
1
|
+
import { AppConfig, ExtensionOutputConfig, ExtensionMetadata, Logger, PlatformVersion } from './types';
|
|
2
2
|
import { ServiceConfiguration, ProxyServiceConfig } from '@hubspot/app-functions-dev-server';
|
|
3
3
|
type DevServerStateLocalDevUrlMapping = ProxyServiceConfig['localDevUrlMapping'] | undefined;
|
|
4
4
|
interface DevServerStateArgs {
|
|
5
5
|
localDevUrlMapping?: DevServerStateLocalDevUrlMapping;
|
|
6
|
-
extensionConfigs?:
|
|
6
|
+
extensionConfigs?: ExtensionOutputConfig[];
|
|
7
7
|
accountId: number | undefined;
|
|
8
8
|
expressPort: number;
|
|
9
9
|
webSocketPort: number;
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AppConfig, ExtensionConfigMap, LocalAppConfig, Logger } from './types';
|
|
2
2
|
export declare function loadConfigByPath<T = unknown>(configPath: string): T;
|
|
3
|
+
export declare function validateCardConfig(config?: unknown): Error | true;
|
|
3
4
|
export declare function loadExtensionConfig(appConfig: AppConfig, appPath: string): ExtensionConfigMap;
|
|
4
5
|
export declare function validateProxyConfigKey(urlKey: string, logger: Logger, localConfigPath: string): void;
|
|
5
6
|
export declare function validateProxyConfigValue(value: string, key: string, logger: Logger, localConfigPath: string): void;
|
package/dist/lib/config.js
CHANGED
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
6
|
};
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.loadLocalConfig = exports.validateProxyConfigValue = exports.validateProxyConfigKey = exports.loadExtensionConfig = exports.loadConfigByPath = void 0;
|
|
8
|
+
exports.loadLocalConfig = exports.validateProxyConfigValue = exports.validateProxyConfigKey = exports.loadExtensionConfig = exports.validateCardConfig = exports.loadConfigByPath = void 0;
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
11
|
const utils_1 = require("./utils");
|
|
@@ -14,6 +14,43 @@ function loadConfigByPath(configPath) {
|
|
|
14
14
|
return JSON.parse(source);
|
|
15
15
|
}
|
|
16
16
|
exports.loadConfigByPath = loadConfigByPath;
|
|
17
|
+
function validateCardConfig(config) {
|
|
18
|
+
if (!config || typeof config !== 'object') {
|
|
19
|
+
return new Error('Card config must be an object');
|
|
20
|
+
}
|
|
21
|
+
if (!('type' in config) || config.type !== 'crm-card') {
|
|
22
|
+
return new Error('`type` must be "crm-card"');
|
|
23
|
+
}
|
|
24
|
+
if (!('data' in config) ||
|
|
25
|
+
typeof config.data !== 'object' ||
|
|
26
|
+
config.data === null) {
|
|
27
|
+
return new Error('`data` must be an object');
|
|
28
|
+
}
|
|
29
|
+
const { data } = config;
|
|
30
|
+
if (!('title' in data) || typeof data.title !== 'string') {
|
|
31
|
+
return new Error('`data` must have a `title` string');
|
|
32
|
+
}
|
|
33
|
+
if (!('location' in data) || typeof data.location !== 'string') {
|
|
34
|
+
return new Error('`data` must have a `location` string');
|
|
35
|
+
}
|
|
36
|
+
if (!('module' in data) ||
|
|
37
|
+
typeof data.module !== 'object' ||
|
|
38
|
+
data.module === null) {
|
|
39
|
+
return new Error('`data` must have a `module` object');
|
|
40
|
+
}
|
|
41
|
+
if (!('file' in data.module) || typeof data.module.file !== 'string') {
|
|
42
|
+
return new Error('`data.module` must have a `file` string');
|
|
43
|
+
}
|
|
44
|
+
if (!('objectTypes' in data) || !Array.isArray(data.objectTypes)) {
|
|
45
|
+
return new Error('`data.module` must have an `objectTypes` array');
|
|
46
|
+
}
|
|
47
|
+
if (data.objectTypes.length === 0 ||
|
|
48
|
+
data.objectTypes.some(({ name }) => typeof name !== 'string')) {
|
|
49
|
+
return new Error('all `data.module.objectTypes` objects must have `name` strings');
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
exports.validateCardConfig = validateCardConfig;
|
|
17
54
|
function loadExtensionConfig(appConfig, appPath) {
|
|
18
55
|
var _a, _b;
|
|
19
56
|
const crmCardsSubConfigFiles = (_b = (_a = appConfig === null || appConfig === void 0 ? void 0 : appConfig.extensions) === null || _a === void 0 ? void 0 : _a.crm) === null || _b === void 0 ? void 0 : _b.cards;
|
|
@@ -26,6 +63,10 @@ function loadExtensionConfig(appConfig, appPath) {
|
|
|
26
63
|
const cardConfigPath = path_1.default.join(appPath, card.file);
|
|
27
64
|
try {
|
|
28
65
|
const cardConfig = loadConfigByPath(cardConfigPath);
|
|
66
|
+
const validation = validateCardConfig(cardConfig);
|
|
67
|
+
if (validation !== true) {
|
|
68
|
+
console.error(`[DevServer] Extension config ${cardConfigPath} is invalid: ${validation.message}`);
|
|
69
|
+
}
|
|
29
70
|
if (cardConfig && cardConfig.data) {
|
|
30
71
|
const cardConfigDir = path_1.default.parse(cardConfigPath).dir;
|
|
31
72
|
const entryPointPath = path_1.default.join(cardConfigDir, (_b = (_a = cardConfig.data) === null || _a === void 0 ? void 0 : _a.module) === null || _b === void 0 ? void 0 : _b.file);
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -4,6 +4,18 @@ export interface ObjectTypes {
|
|
|
4
4
|
name: string;
|
|
5
5
|
}
|
|
6
6
|
export interface ExtensionConfig {
|
|
7
|
+
type: string;
|
|
8
|
+
data: {
|
|
9
|
+
title: string;
|
|
10
|
+
location: string;
|
|
11
|
+
module: {
|
|
12
|
+
file: string;
|
|
13
|
+
};
|
|
14
|
+
objectTypes: ObjectTypes[];
|
|
15
|
+
uid?: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface ExtensionOutputConfig extends ExtensionConfig {
|
|
7
19
|
type: string;
|
|
8
20
|
output: string;
|
|
9
21
|
path: string;
|
|
@@ -17,13 +29,13 @@ export interface ExtensionConfig {
|
|
|
17
29
|
file: string;
|
|
18
30
|
};
|
|
19
31
|
objectTypes: ObjectTypes[];
|
|
32
|
+
uid?: string;
|
|
20
33
|
sourceId?: string | null;
|
|
21
34
|
};
|
|
22
|
-
uid?: string;
|
|
23
35
|
appConfig?: AppConfig;
|
|
24
36
|
}
|
|
25
37
|
export interface ExtensionConfigMap {
|
|
26
|
-
[key: string]:
|
|
38
|
+
[key: string]: ExtensionOutputConfig;
|
|
27
39
|
}
|
|
28
40
|
interface CardConfig {
|
|
29
41
|
file: string;
|
|
@@ -95,7 +107,7 @@ export interface BaseMessage {
|
|
|
95
107
|
}
|
|
96
108
|
export interface ExtensionMetadata {
|
|
97
109
|
baseMessage: BaseMessage;
|
|
98
|
-
config:
|
|
110
|
+
config: ExtensionOutputConfig;
|
|
99
111
|
}
|
|
100
112
|
export type PlatformVersion = (typeof PLATFORM_VERSION)[keyof typeof PLATFORM_VERSION];
|
|
101
113
|
export interface FunctionMetadata {
|
package/dist/lib/utils.js
CHANGED
|
@@ -34,8 +34,8 @@ function loadManifest(outputDir, output) {
|
|
|
34
34
|
}
|
|
35
35
|
exports.loadManifest = loadManifest;
|
|
36
36
|
function buildSourceId(appConfig, extensionConfig) {
|
|
37
|
-
if (appConfig.uid && extensionConfig.uid) {
|
|
38
|
-
return `${appConfig.uid}::${extensionConfig.uid}`;
|
|
37
|
+
if (appConfig.uid && extensionConfig.data.uid) {
|
|
38
|
+
return `${appConfig.uid}::${extensionConfig.data.uid}`;
|
|
39
39
|
}
|
|
40
40
|
return null;
|
|
41
41
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/ui-extensions-dev-server",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.33",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jest",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
],
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@hubspot/app-functions-dev-server": "0.8.
|
|
27
|
+
"@hubspot/app-functions-dev-server": "0.8.31",
|
|
28
28
|
"cors": "^2.8.5",
|
|
29
29
|
"detect-port": "1.5.1",
|
|
30
30
|
"estraverse": "^5.3.0",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"optional": true
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "43946879c6cc1dbd76102fe92f6c1838ea34db6b"
|
|
67
67
|
}
|