@hubspot/cms-dev-server 0.16.13 → 0.16.15
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/generateJsonFromJsx.js +9 -1
- package/dist/generateJsonFromJsx.js.map +7 -0
- package/dist/index.js +9 -1
- package/dist/index.js.map +7 -0
- package/dist/internalSsr.js +9 -1
- package/dist/internalSsr.js.map +7 -0
- package/dist/island-runtime.js.map +7 -0
- package/dist/run.js +79 -25
- package/dist/run.js.map +7 -0
- package/dist/storybook/index.js.map +7 -0
- package/dist/storybook-main/main.js +9 -1
- package/dist/storybook-main/main.js.map +7 -0
- package/dist/storybook-main/preview.js.map +7 -0
- package/package.json +3 -3
- package/types/island-runtime.d.ts +2 -0
package/dist/run.js
CHANGED
|
@@ -643,12 +643,13 @@ function findCmsModules(cmsModules = {}) {
|
|
|
643
643
|
JSXOpeningElement(path11) {
|
|
644
644
|
if (!t.isJSXIdentifier(path11.node.name, {
|
|
645
645
|
name: moduleLocalImportName
|
|
646
|
-
})
|
|
646
|
+
})) {
|
|
647
647
|
return null;
|
|
648
648
|
}
|
|
649
649
|
moduleUsed = true;
|
|
650
650
|
let cmsModuleName;
|
|
651
651
|
let cmsModulePath;
|
|
652
|
+
let cmsModuleLabel;
|
|
652
653
|
for (const prop of path11.node.attributes) {
|
|
653
654
|
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
|
|
654
655
|
cmsModuleName = prop.value.value;
|
|
@@ -658,6 +659,10 @@ function findCmsModules(cmsModules = {}) {
|
|
|
658
659
|
cmsModulePath = prop.value.value;
|
|
659
660
|
continue;
|
|
660
661
|
}
|
|
662
|
+
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "label" }) && t.isStringLiteral(prop.value)) {
|
|
663
|
+
cmsModuleLabel = prop.value.value;
|
|
664
|
+
continue;
|
|
665
|
+
}
|
|
661
666
|
pluginError(
|
|
662
667
|
new Error(
|
|
663
668
|
`Error: ${id.replace(config.root, "")}:${prop.loc.start.line} "name" and "path" must be primitive strings`
|
|
@@ -669,6 +674,9 @@ function findCmsModules(cmsModules = {}) {
|
|
|
669
674
|
name: cmsModuleName,
|
|
670
675
|
path: cmsModulePath
|
|
671
676
|
};
|
|
677
|
+
if (cmsModuleLabel) {
|
|
678
|
+
cmsModuleProps.label = cmsModuleLabel;
|
|
679
|
+
}
|
|
672
680
|
if (Object.hasOwn(localCmsModules, cmsModuleProps.name)) {
|
|
673
681
|
pluginError(
|
|
674
682
|
new Error(
|
|
@@ -955,7 +963,7 @@ async function renderComponentWithCSS(viteServer, componentPath, Component, prop
|
|
|
955
963
|
html,
|
|
956
964
|
renderContext,
|
|
957
965
|
[]
|
|
958
|
-
// Build-time generated static asset
|
|
966
|
+
// Build-time generated static asset array is only available when deployed
|
|
959
967
|
);
|
|
960
968
|
}
|
|
961
969
|
const cssNeeded = collectCssInDev2(componentPathWithExtension, viteServer);
|
|
@@ -1239,7 +1247,7 @@ function trackUsage(action) {
|
|
|
1239
1247
|
eventName: EVENT_NAME,
|
|
1240
1248
|
action,
|
|
1241
1249
|
nodeVersion: getNodeVersionData(),
|
|
1242
|
-
version: "0.16.
|
|
1250
|
+
version: "0.16.15",
|
|
1243
1251
|
os: getPlatform()
|
|
1244
1252
|
};
|
|
1245
1253
|
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -1419,34 +1427,79 @@ async function fetchModuleGraphQLData(accountId, query, requestedModulePath, pag
|
|
|
1419
1427
|
}
|
|
1420
1428
|
|
|
1421
1429
|
// src/lib/renderModule.ts
|
|
1430
|
+
var VALIDATE_FIELDS_ENDPOINT = "/designmanager/v1/modules/validate-fields";
|
|
1431
|
+
var VALIDATE_META_ENDPOINT = "/designmanager/v1/modules/validate-meta";
|
|
1422
1432
|
var { default: hsCliHttp3 } = localDevHttpImport3;
|
|
1423
1433
|
var { filterToModuleDataDepsIncludedIn, getModuleDataDependecyTypeFrom } = cmsComponents2;
|
|
1424
|
-
var
|
|
1434
|
+
var handleValidationApiError = (result, type, renderContext, requestedModulePath) => {
|
|
1435
|
+
if (result.status === "rejected") {
|
|
1436
|
+
const errorMessage = result.reason ? `${result.reason.name}: ${result.reason.message}` : "";
|
|
1437
|
+
if (errorMessage) {
|
|
1438
|
+
renderContext.criticalDevErrors.push({
|
|
1439
|
+
message: `Failed request to validate module for ${requestedModulePath} - ${type} Validation Error`,
|
|
1440
|
+
error: new Error(errorMessage),
|
|
1441
|
+
level: "error"
|
|
1442
|
+
});
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
};
|
|
1446
|
+
var handleModuleValidationErrors = (validationErrors = [], type, renderContext, requestedModulePath) => {
|
|
1447
|
+
const validationSeverityToLogLevel = {
|
|
1448
|
+
FATAL: "error",
|
|
1449
|
+
WARNING: "warn"
|
|
1450
|
+
};
|
|
1451
|
+
if (!Array.isArray(validationErrors)) {
|
|
1452
|
+
return;
|
|
1453
|
+
}
|
|
1454
|
+
validationErrors.forEach((validationError) => {
|
|
1455
|
+
renderContext.criticalDevErrors.push({
|
|
1456
|
+
message: `${type} Validation Error in ${requestedModulePath}: ${validationError.message}`,
|
|
1457
|
+
error: new Error(validationError.message),
|
|
1458
|
+
level: validationSeverityToLogLevel[validationError.severity] || "info"
|
|
1459
|
+
});
|
|
1460
|
+
});
|
|
1461
|
+
};
|
|
1462
|
+
var getApplyValidationToRenderContext = (portalId, fieldsJSON, metaJSON, requestedModulePath) => {
|
|
1425
1463
|
return async (renderResult) => {
|
|
1426
1464
|
const { renderContext } = renderResult;
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
WARNING: "warn"
|
|
1430
|
-
};
|
|
1431
|
-
let validationRequest;
|
|
1465
|
+
let fieldsValidationResponse;
|
|
1466
|
+
let metaValidationResponse;
|
|
1432
1467
|
try {
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1468
|
+
const [fieldsResult, metaResult] = await Promise.allSettled([
|
|
1469
|
+
hsCliHttp3.post(portalId, {
|
|
1470
|
+
url: VALIDATE_FIELDS_ENDPOINT,
|
|
1471
|
+
data: fieldsJSON,
|
|
1472
|
+
resolveWithFullResponse: true
|
|
1473
|
+
}),
|
|
1474
|
+
hsCliHttp3.post(portalId, {
|
|
1475
|
+
url: VALIDATE_META_ENDPOINT,
|
|
1476
|
+
data: metaJSON,
|
|
1477
|
+
resolveWithFullResponse: true
|
|
1478
|
+
})
|
|
1479
|
+
]);
|
|
1480
|
+
[fieldsResult, metaResult].forEach(
|
|
1481
|
+
(result, index) => handleValidationApiError(
|
|
1482
|
+
result,
|
|
1483
|
+
index === 0 ? "Field" : "Meta",
|
|
1484
|
+
renderContext,
|
|
1485
|
+
requestedModulePath
|
|
1486
|
+
)
|
|
1487
|
+
);
|
|
1488
|
+
fieldsValidationResponse = fieldsResult.status === "fulfilled" ? fieldsResult.value : null;
|
|
1489
|
+
metaValidationResponse = metaResult.status === "fulfilled" ? metaResult.value : null;
|
|
1438
1490
|
} 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
|
-
});
|
|
1491
|
+
console.log("Failed to validate module for", requestedModulePath);
|
|
1449
1492
|
}
|
|
1493
|
+
[fieldsValidationResponse, metaValidationResponse].forEach(
|
|
1494
|
+
(response, index) => {
|
|
1495
|
+
handleModuleValidationErrors(
|
|
1496
|
+
response,
|
|
1497
|
+
index === 0 ? "Field" : "Meta",
|
|
1498
|
+
renderContext,
|
|
1499
|
+
requestedModulePath
|
|
1500
|
+
);
|
|
1501
|
+
}
|
|
1502
|
+
);
|
|
1450
1503
|
return renderResult;
|
|
1451
1504
|
};
|
|
1452
1505
|
};
|
|
@@ -1511,9 +1564,10 @@ async function renderModule(viteServer, requestedModulePath, moduleProps, pageUr
|
|
|
1511
1564
|
const { renderFieldsToJson } = await viteServer.ssrLoadModule(internalSsrPath);
|
|
1512
1565
|
const fieldsJSON = renderFieldsToJson(fields, requestedModulePath);
|
|
1513
1566
|
const fieldValues = getFieldValuesForModule(fieldsJSON, fieldOverrides);
|
|
1514
|
-
const applyFieldsValidationToRenderContext =
|
|
1567
|
+
const applyFieldsValidationToRenderContext = getApplyValidationToRenderContext(
|
|
1515
1568
|
environmentConfig.getPortalID(),
|
|
1516
1569
|
fieldsJSON,
|
|
1570
|
+
meta,
|
|
1517
1571
|
requestedModulePath
|
|
1518
1572
|
);
|
|
1519
1573
|
if (componentModule.query && typeof componentModule.query === "string") {
|