@hubspot/ui-extensions-dev-server 0.8.47 → 0.8.50
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/DevModeParentInterface.js +3 -0
- package/dist/lib/ast.d.ts +4 -1
- package/dist/lib/ast.js +91 -34
- package/dist/lib/constants.d.ts +2 -0
- package/dist/lib/constants.js +2 -0
- package/dist/lib/plugins/codeBlockingPlugin.js +4 -1
- package/dist/lib/plugins/manifestPlugin.js +1 -1
- package/dist/lib/types.d.ts +6 -1
- package/package.json +3 -3
|
@@ -44,7 +44,10 @@ class DevModeParentInterface {
|
|
|
44
44
|
return constants_1.PLATFORM_VERSION.V20231;
|
|
45
45
|
case constants_1.PLATFORM_VERSION.V20232:
|
|
46
46
|
return constants_1.PLATFORM_VERSION.V20232;
|
|
47
|
+
case constants_1.PLATFORM_VERSION.V20251:
|
|
48
|
+
return constants_1.PLATFORM_VERSION.V20251;
|
|
47
49
|
case constants_1.PLATFORM_VERSION.V20252:
|
|
50
|
+
case constants_1.PLATFORM_VERSION.UNSTABLE:
|
|
48
51
|
return constants_1.PLATFORM_VERSION.V20252;
|
|
49
52
|
default:
|
|
50
53
|
return (0, utils_1.throwUnhandledPlatformVersionError)(platformVersion);
|
package/dist/lib/ast.d.ts
CHANGED
|
@@ -8,5 +8,8 @@ export declare function checkForOutOfBoundsImageImports(node: Node, output: Sour
|
|
|
8
8
|
export declare function traverseAbstractSyntaxTree(ast: Program, checks: SourceCodeChecks, extensionPath: string, logger: Logger): {
|
|
9
9
|
functions: {};
|
|
10
10
|
badImports: never[];
|
|
11
|
-
dataDependencies:
|
|
11
|
+
dataDependencies: {
|
|
12
|
+
importedHooks: {};
|
|
13
|
+
dependencies: never[];
|
|
14
|
+
};
|
|
12
15
|
};
|
package/dist/lib/ast.js
CHANGED
|
@@ -9,6 +9,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
9
9
|
// @ts-expect-error no type defs
|
|
10
10
|
const estraverse_1 = require("estraverse");
|
|
11
11
|
const utils_1 = require("./utils");
|
|
12
|
+
const EXPERIMENTAL_HOOKS = ['useCrmProperties'];
|
|
12
13
|
function _isVariableImported(node, variableName) {
|
|
13
14
|
if (!node) {
|
|
14
15
|
return false;
|
|
@@ -84,40 +85,93 @@ function _collectDataDependencies(node, output, logger) {
|
|
|
84
85
|
return;
|
|
85
86
|
}
|
|
86
87
|
try {
|
|
87
|
-
//
|
|
88
|
-
if (node.type === '
|
|
89
|
-
node.
|
|
90
|
-
node.
|
|
91
|
-
const
|
|
92
|
-
//
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
88
|
+
// Check for imports of our hooks.
|
|
89
|
+
if (node.type === 'ImportDeclaration' &&
|
|
90
|
+
typeof node.source.value === 'string' &&
|
|
91
|
+
node.source.value.startsWith('@hubspot/ui-extensions')) {
|
|
92
|
+
const isExperimental = node.source.value === '@hubspot/ui-extensions/experimental';
|
|
93
|
+
// If the imports are coming from our own package, loop over them to check for hooks
|
|
94
|
+
node.specifiers.forEach((specifier) => {
|
|
95
|
+
// If the specifier is an ImportSpecifier and the imported name is one of our tracked hooks, we will track it.
|
|
96
|
+
if (specifier.type === 'ImportSpecifier' &&
|
|
97
|
+
isExperimental &&
|
|
98
|
+
EXPERIMENTAL_HOOKS.includes(specifier.imported.name)) {
|
|
99
|
+
// The local name is the name the hook is imported as in the file, and the imported name is the original name of the hook.
|
|
100
|
+
output.dataDependencies.importedHooks[`${specifier.local.name}`] =
|
|
101
|
+
specifier.imported.name;
|
|
102
|
+
}
|
|
103
|
+
else if (
|
|
104
|
+
// We also have to track namespace level imports
|
|
105
|
+
specifier.type === 'ImportNamespaceSpecifier') {
|
|
106
|
+
// If the specifier is a namespace import, we will track all hooks that are imported from that namespace. Experimental and stable hooks are handled separately.
|
|
107
|
+
if (isExperimental) {
|
|
108
|
+
EXPERIMENTAL_HOOKS.forEach((hook) => {
|
|
109
|
+
output.dataDependencies.importedHooks[`${specifier.local.name}.${hook}`] = hook;
|
|
110
|
+
});
|
|
108
111
|
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
// Check for calls to our hooks.
|
|
115
|
+
}
|
|
116
|
+
else if (node.type === 'CallExpression') {
|
|
117
|
+
let hookName = '';
|
|
118
|
+
// This handles the case where the hook is called directly, eg `useCrmProperties()` (also supports aliased hooks)
|
|
119
|
+
if (node.callee.type === 'Identifier' &&
|
|
120
|
+
output.dataDependencies.importedHooks[node.callee.name]) {
|
|
121
|
+
hookName = output.dataDependencies.importedHooks[node.callee.name];
|
|
122
|
+
}
|
|
123
|
+
else if (
|
|
124
|
+
// This handles namespace import usage, eg `uiExtensions.useCrmProperties()`
|
|
125
|
+
node.callee.type === 'MemberExpression' &&
|
|
126
|
+
node.callee.object.type === 'Identifier' &&
|
|
127
|
+
node.callee.property.type === 'Identifier' &&
|
|
128
|
+
output.dataDependencies.importedHooks[`${node.callee.object.name}.${node.callee.property.name}`]) {
|
|
129
|
+
hookName =
|
|
130
|
+
output.dataDependencies.importedHooks[`${node.callee.object.name}.${node.callee.property.name}`];
|
|
131
|
+
}
|
|
132
|
+
// Then we handle each hook individually, as the usages and tracking format are different.
|
|
133
|
+
if (hookName === 'useCrmProperties') {
|
|
134
|
+
const propertyType = 'CrmRecordProperties';
|
|
135
|
+
// Validate actions parameter
|
|
136
|
+
if (!node.arguments[0]) {
|
|
137
|
+
logger.warn('useCrmProperties called without actions parameter');
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
// Get the second argument, the properties array
|
|
141
|
+
const propertiesNode = node.arguments[1];
|
|
142
|
+
const requestedProperties = [];
|
|
143
|
+
// If the second argument is an array with at least one element, collect the properties.
|
|
144
|
+
if (propertiesNode &&
|
|
145
|
+
propertiesNode.type === 'ArrayExpression' &&
|
|
146
|
+
propertiesNode.elements.length > 0) {
|
|
147
|
+
propertiesNode.elements.forEach((element) => {
|
|
148
|
+
/**
|
|
149
|
+
* We only support strings for now, and ignore the rest.
|
|
150
|
+
* This might be more generalized in the future as we support more hooks.
|
|
151
|
+
*/
|
|
152
|
+
if (element &&
|
|
153
|
+
element.type === 'Literal' &&
|
|
154
|
+
typeof element.value === 'string') {
|
|
155
|
+
requestedProperties.push(element.value);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
logger.warn(`Invalid property type in useCrmProperties: ${element ? element.type : 'undefined'}`);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
if (requestedProperties.length > 0) {
|
|
162
|
+
output.dataDependencies.dependencies.push({
|
|
163
|
+
/**
|
|
164
|
+
* This refID is a hash of the property type and the requested properties.
|
|
165
|
+
* This should allow us to create the same hash at execution time, to find the correct data from BE.
|
|
166
|
+
*/
|
|
167
|
+
referenceId: (0, utils_1.generateHash)(propertyType, requestedProperties),
|
|
168
|
+
properties: {
|
|
169
|
+
type: propertyType,
|
|
170
|
+
recordProperties: requestedProperties,
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
121
175
|
}
|
|
122
176
|
}
|
|
123
177
|
}
|
|
@@ -131,7 +185,10 @@ function traverseAbstractSyntaxTree(ast, checks, extensionPath, logger) {
|
|
|
131
185
|
const state = {
|
|
132
186
|
functions: {},
|
|
133
187
|
badImports: [],
|
|
134
|
-
dataDependencies:
|
|
188
|
+
dataDependencies: {
|
|
189
|
+
importedHooks: {},
|
|
190
|
+
dependencies: [],
|
|
191
|
+
},
|
|
135
192
|
};
|
|
136
193
|
try {
|
|
137
194
|
(0, estraverse_1.traverse)(ast, {
|
package/dist/lib/constants.d.ts
CHANGED
|
@@ -21,7 +21,9 @@ export declare const SERVER_CAPABILITIES: string[];
|
|
|
21
21
|
export declare const PLATFORM_VERSION: {
|
|
22
22
|
readonly V20231: "2023.1";
|
|
23
23
|
readonly V20232: "2023.2";
|
|
24
|
+
readonly V20251: "2025.1";
|
|
24
25
|
readonly V20252: "2025.2";
|
|
26
|
+
readonly UNSTABLE: "unstable";
|
|
25
27
|
};
|
|
26
28
|
export declare const PUBLIC_APP = "public-app";
|
|
27
29
|
export declare const PRIVATE_APP = "private-app";
|
package/dist/lib/constants.js
CHANGED
|
@@ -14,7 +14,10 @@ const codeBlockingPlugin = ({ logger, extensionPath }) => {
|
|
|
14
14
|
let sourceCodeMetadata = {
|
|
15
15
|
functions: {},
|
|
16
16
|
badImports: [],
|
|
17
|
-
dataDependencies:
|
|
17
|
+
dataDependencies: {
|
|
18
|
+
importedHooks: {},
|
|
19
|
+
dependencies: [],
|
|
20
|
+
},
|
|
18
21
|
};
|
|
19
22
|
const requireFunctionName = 'require';
|
|
20
23
|
try {
|
|
@@ -34,7 +34,7 @@ const manifestPlugin = (options) => {
|
|
|
34
34
|
const sourceCodeMetadata = (0, ast_1.traverseAbstractSyntaxTree)(ast, [], options.extensionPath || process.cwd(), logger);
|
|
35
35
|
allDataDependencies = [
|
|
36
36
|
...allDataDependencies,
|
|
37
|
-
...sourceCodeMetadata.dataDependencies,
|
|
37
|
+
...sourceCodeMetadata.dataDependencies.dependencies,
|
|
38
38
|
];
|
|
39
39
|
}
|
|
40
40
|
catch (e) {
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -209,7 +209,12 @@ export interface SourceCodeMetadata {
|
|
|
209
209
|
[functionName: string]: FunctionMetadata;
|
|
210
210
|
};
|
|
211
211
|
badImports: string[];
|
|
212
|
-
dataDependencies:
|
|
212
|
+
dataDependencies: {
|
|
213
|
+
importedHooks: {
|
|
214
|
+
[hookName: string]: string;
|
|
215
|
+
};
|
|
216
|
+
dependencies: DataDependency[];
|
|
217
|
+
};
|
|
213
218
|
}
|
|
214
219
|
export interface FunctionInvocationCheck {
|
|
215
220
|
functionName: string;
|
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.50",
|
|
4
4
|
"description": "",
|
|
5
5
|
"bin": {
|
|
6
6
|
"uie": "./dist/lib/bin/cli.js"
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
],
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@hubspot/app-functions-dev-server": "0.8.
|
|
30
|
+
"@hubspot/app-functions-dev-server": "0.8.50",
|
|
31
31
|
"chalk": "5.4.1",
|
|
32
32
|
"commander": "13.0.0",
|
|
33
33
|
"cors": "2.8.5",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"optional": true
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "0274315aed3fa8709f2ba403335e98316ceb7d2a"
|
|
73
73
|
}
|