@hubspot/cms-dev-server 0.16.13 → 0.16.14
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/run.js +69 -23
- package/package.json +3 -3
package/dist/run.js
CHANGED
|
@@ -1239,7 +1239,7 @@ function trackUsage(action) {
|
|
|
1239
1239
|
eventName: EVENT_NAME,
|
|
1240
1240
|
action,
|
|
1241
1241
|
nodeVersion: getNodeVersionData(),
|
|
1242
|
-
version: "0.16.
|
|
1242
|
+
version: "0.16.14",
|
|
1243
1243
|
os: getPlatform()
|
|
1244
1244
|
};
|
|
1245
1245
|
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -1419,34 +1419,79 @@ async function fetchModuleGraphQLData(accountId, query, requestedModulePath, pag
|
|
|
1419
1419
|
}
|
|
1420
1420
|
|
|
1421
1421
|
// src/lib/renderModule.ts
|
|
1422
|
+
var VALIDATE_FIELDS_ENDPOINT = "/designmanager/v1/modules/validate-fields";
|
|
1423
|
+
var VALIDATE_META_ENDPOINT = "/designmanager/v1/modules/validate-meta";
|
|
1422
1424
|
var { default: hsCliHttp3 } = localDevHttpImport3;
|
|
1423
1425
|
var { filterToModuleDataDepsIncludedIn, getModuleDataDependecyTypeFrom } = cmsComponents2;
|
|
1424
|
-
var
|
|
1426
|
+
var handleValidationApiError = (result, type, renderContext, requestedModulePath) => {
|
|
1427
|
+
if (result.status === "rejected") {
|
|
1428
|
+
const errorMessage = result.reason ? `${result.reason.name}: ${result.reason.message}` : "";
|
|
1429
|
+
if (errorMessage) {
|
|
1430
|
+
renderContext.criticalDevErrors.push({
|
|
1431
|
+
message: `Failed request to validate module for ${requestedModulePath} - ${type} Validation Error`,
|
|
1432
|
+
error: new Error(errorMessage),
|
|
1433
|
+
level: "error"
|
|
1434
|
+
});
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
};
|
|
1438
|
+
var handleModuleValidationErrors = (validationErrors = [], type, renderContext, requestedModulePath) => {
|
|
1439
|
+
const validationSeverityToLogLevel = {
|
|
1440
|
+
FATAL: "error",
|
|
1441
|
+
WARNING: "warn"
|
|
1442
|
+
};
|
|
1443
|
+
if (!Array.isArray(validationErrors)) {
|
|
1444
|
+
return;
|
|
1445
|
+
}
|
|
1446
|
+
validationErrors.forEach((validationError) => {
|
|
1447
|
+
renderContext.criticalDevErrors.push({
|
|
1448
|
+
message: `${type} Validation Error in ${requestedModulePath}: ${validationError.message}`,
|
|
1449
|
+
error: new Error(validationError.message),
|
|
1450
|
+
level: validationSeverityToLogLevel[validationError.severity] || "info"
|
|
1451
|
+
});
|
|
1452
|
+
});
|
|
1453
|
+
};
|
|
1454
|
+
var getApplyValidationToRenderContext = (portalId, fieldsJSON, metaJSON, requestedModulePath) => {
|
|
1425
1455
|
return async (renderResult) => {
|
|
1426
1456
|
const { renderContext } = renderResult;
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
WARNING: "warn"
|
|
1430
|
-
};
|
|
1431
|
-
let validationRequest;
|
|
1457
|
+
let fieldsValidationResponse;
|
|
1458
|
+
let metaValidationResponse;
|
|
1432
1459
|
try {
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1460
|
+
const [fieldsResult, metaResult] = await Promise.allSettled([
|
|
1461
|
+
hsCliHttp3.post(portalId, {
|
|
1462
|
+
url: VALIDATE_FIELDS_ENDPOINT,
|
|
1463
|
+
data: fieldsJSON,
|
|
1464
|
+
resolveWithFullResponse: true
|
|
1465
|
+
}),
|
|
1466
|
+
hsCliHttp3.post(portalId, {
|
|
1467
|
+
url: VALIDATE_META_ENDPOINT,
|
|
1468
|
+
data: metaJSON,
|
|
1469
|
+
resolveWithFullResponse: true
|
|
1470
|
+
})
|
|
1471
|
+
]);
|
|
1472
|
+
[fieldsResult, metaResult].forEach(
|
|
1473
|
+
(result, index) => handleValidationApiError(
|
|
1474
|
+
result,
|
|
1475
|
+
index === 0 ? "Field" : "Meta",
|
|
1476
|
+
renderContext,
|
|
1477
|
+
requestedModulePath
|
|
1478
|
+
)
|
|
1479
|
+
);
|
|
1480
|
+
fieldsValidationResponse = fieldsResult.status === "fulfilled" ? fieldsResult.value : null;
|
|
1481
|
+
metaValidationResponse = metaResult.status === "fulfilled" ? metaResult.value : null;
|
|
1438
1482
|
} catch {
|
|
1439
|
-
console.log("Failed to validate module
|
|
1440
|
-
}
|
|
1441
|
-
if (validationRequest.length) {
|
|
1442
|
-
validationRequest.forEach((fieldValidationError) => {
|
|
1443
|
-
renderContext.criticalDevErrors.push({
|
|
1444
|
-
message: `Field Validation Error in ${requestedModulePath}: ${fieldValidationError.message}`,
|
|
1445
|
-
error: new Error(fieldValidationError.message),
|
|
1446
|
-
level: validationSeverityToLogLevel[fieldValidationError.severity] || "info"
|
|
1447
|
-
});
|
|
1448
|
-
});
|
|
1483
|
+
console.log("Failed to validate module for", requestedModulePath);
|
|
1449
1484
|
}
|
|
1485
|
+
[fieldsValidationResponse, metaValidationResponse].forEach(
|
|
1486
|
+
(response, index) => {
|
|
1487
|
+
handleModuleValidationErrors(
|
|
1488
|
+
response,
|
|
1489
|
+
index === 0 ? "Field" : "Meta",
|
|
1490
|
+
renderContext,
|
|
1491
|
+
requestedModulePath
|
|
1492
|
+
);
|
|
1493
|
+
}
|
|
1494
|
+
);
|
|
1450
1495
|
return renderResult;
|
|
1451
1496
|
};
|
|
1452
1497
|
};
|
|
@@ -1511,9 +1556,10 @@ async function renderModule(viteServer, requestedModulePath, moduleProps, pageUr
|
|
|
1511
1556
|
const { renderFieldsToJson } = await viteServer.ssrLoadModule(internalSsrPath);
|
|
1512
1557
|
const fieldsJSON = renderFieldsToJson(fields, requestedModulePath);
|
|
1513
1558
|
const fieldValues = getFieldValuesForModule(fieldsJSON, fieldOverrides);
|
|
1514
|
-
const applyFieldsValidationToRenderContext =
|
|
1559
|
+
const applyFieldsValidationToRenderContext = getApplyValidationToRenderContext(
|
|
1515
1560
|
environmentConfig.getPortalID(),
|
|
1516
1561
|
fieldsJSON,
|
|
1562
|
+
meta,
|
|
1517
1563
|
requestedModulePath
|
|
1518
1564
|
);
|
|
1519
1565
|
if (componentModule.query && typeof componentModule.query === "string") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.14",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@babel/parser": "^7.25.3",
|
|
30
30
|
"@babel/traverse": "^7.25.3",
|
|
31
31
|
"@babel/types": "^7.25.2",
|
|
32
|
-
"@hubspot/cms-components": "^0.16.
|
|
32
|
+
"@hubspot/cms-components": "^0.16.14",
|
|
33
33
|
"@hubspot/local-dev-lib": "^1.9.0",
|
|
34
34
|
"@inquirer/select": "^2.0.0",
|
|
35
35
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
@@ -114,5 +114,5 @@
|
|
|
114
114
|
"publishConfig": {
|
|
115
115
|
"access": "public"
|
|
116
116
|
},
|
|
117
|
-
"gitHead": "
|
|
117
|
+
"gitHead": "118cfe71322d72863fa87a8838f26c9e4799b1f0"
|
|
118
118
|
}
|