@forge/manifest
13.8.1-next.0-experimental-1e9569613.9.0-next.3
out/validators/storage-validator.js~
out/validators/storage-validator.jsModified+22−9
Index: package/out/validators/storage-validator.js
===================================================================
--- package/out/validators/storage-validator.js
+++ package/out/validators/storage-validator.js
@@ -50,12 +50,21 @@
return validationErrors;
}
validateCustomEntities(manifest) {
const validationErrors = [];
- const entities = manifest?.typedContent?.app?.storage?.entities;
- if (entities) {
+ if (!manifest) {
+ return validationErrors;
+ }
+ const entities = manifest.typedContent?.app?.storage?.entities;
+ if (Array.isArray(entities)) {
entities.forEach((entity) => {
+ if (entity === null || typeof entity !== 'object' || Array.isArray(entity)) {
+ return;
+ }
const { name, attributes } = entity;
+ if (attributes === null || typeof attributes !== 'object' || Array.isArray(attributes)) {
+ return;
+ }
if (Object.keys(attributes).length > this.entityAttributesMaxCount) {
validationErrors.push({
message: text_1.errors.app.storage.entities.tooManyAttributes(name, this.entityAttributesMaxCount),
reference: text_1.References.App,
@@ -72,10 +81,10 @@
...(0, utils_1.findPosition)('entities', manifest.yamlContentByLine)
});
}
});
- if (entity.indexes) {
- const { indexes } = entity;
+ const indexes = Array.isArray(entity.indexes) ? entity.indexes : [];
+ if (indexes.length > 0) {
if (indexes.length > this.entityIndexesMaxCount) {
validationErrors.push({
message: text_1.errors.app.storage.entities.tooManyIndexes(name, this.entityIndexesMaxCount),
reference: text_1.References.App,
@@ -89,14 +98,18 @@
indexes.forEach((index) => {
if (typeof index === 'string') {
indexRange.push(index);
}
- else if (typeof index === 'object') {
- indexName.push(index.name);
- indexRange.push(...index.range);
- if (index.partition) {
- indexPartition.push(...index.partition);
+ else if (index !== null && typeof index === 'object' && !Array.isArray(index)) {
+ if (typeof index.name === 'string') {
+ indexName.push(index.name);
}
+ if (Array.isArray(index.range)) {
+ indexRange.push(...index.range.filter((range) => typeof range === 'string'));
+ }
+ if (Array.isArray(index.partition)) {
+ indexPartition.push(...index.partition.filter((partition) => typeof partition === 'string'));
+ }
}
});
if (indexName.find((name) => name === this.reservedIndexName)) {
validationErrors.push({