New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@teleporthq/teleport-uidl-validator

Package Overview
Dependencies
Maintainers
4
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@teleporthq/teleport-uidl-validator - npm Package Compare versions

Comparing version

to
0.17.7

1

dist/cjs/decoders/component-decoder.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.rootComponentUIDLDecoder = exports.componentUIDLDecoder = void 0;
var json_type_validation_1 = require("@mojotech/json-type-validation");

@@ -4,0 +5,0 @@ var utils_1 = require("./utils");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CustomCombinators = void 0;
/* tslint:disable member-ordering */

@@ -4,0 +5,0 @@ var json_type_validation_1 = require("@mojotech/json-type-validation");

7

dist/cjs/decoders/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.projectUIDLDecoder = exports.rootComponentUIDLDecoder = exports.componentUIDLDecoder = void 0;
var component_decoder_1 = require("./component-decoder");
exports.componentUIDLDecoder = component_decoder_1.componentUIDLDecoder;
exports.rootComponentUIDLDecoder = component_decoder_1.rootComponentUIDLDecoder;
Object.defineProperty(exports, "componentUIDLDecoder", { enumerable: true, get: function () { return component_decoder_1.componentUIDLDecoder; } });
Object.defineProperty(exports, "rootComponentUIDLDecoder", { enumerable: true, get: function () { return component_decoder_1.rootComponentUIDLDecoder; } });
var project_decoder_1 = require("./project-decoder");
exports.projectUIDLDecoder = project_decoder_1.projectUIDLDecoder;
Object.defineProperty(exports, "projectUIDLDecoder", { enumerable: true, get: function () { return project_decoder_1.projectUIDLDecoder; } });
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.projectUIDLDecoder = exports.globalProjectValuesDecoder = exports.webManifestDecoder = void 0;
var json_type_validation_1 = require("@mojotech/json-type-validation");

@@ -4,0 +5,0 @@ var utils_1 = require("./utils");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.elementComponentReferencedStyle = exports.classDynamicReferenceDecoder = exports.elementInlineReferencedStyle = exports.elementProjectReferencedStyle = exports.styleConditionsDecoder = exports.elementStyleWithMediaConditionDecoder = exports.elementStyleWithStateConditionDecoder = exports.elementStateDecoder = exports.rawValueDecoder = exports.uidlLinkNodeDecoder = exports.phoneLinkNodeDecoder = exports.uidlMailLinkNodeDecoder = exports.navLinkNodeDecoder = exports.sectionLinkNodeDecoder = exports.urlLinkNodeDecoder = exports.stateChangeEventDecoder = exports.propCallEventDecoder = exports.eventHandlerStatementDecoder = exports.styleDefinitionsDecoder = exports.styleValueDecoder = exports.attributeValueDecoder = exports.importReferenceDecoder = exports.dependencyDecoder = exports.localDependencyDecoder = exports.externaldependencyDecoder = exports.peerDependencyDecoder = exports.outputOptionsDecoder = exports.stateDefinitionsDecoder = exports.propDefinitionsDecoder = exports.stateValueDetailsDecoder = exports.componentSeoDecoder = exports.iconAssetDecoder = exports.canonicalAssetDecoder = exports.fontAssetDecoder = exports.externalStyleAssetDecoder = exports.inlineStyletAssetDecoder = exports.externalScriptAssetDecoder = exports.inlineScriptAssetDecoder = exports.baseAssetDecoder = exports.globalAssetsDecoder = exports.pageOptionsDecoder = exports.stateOrPropDefinitionDecoder = exports.styleSetDefinitionDecoder = exports.tokenReferenceDecoder = exports.projectStyleConditionsDecoder = exports.styleSetStateConditionDecoder = exports.styleSetMediaConditionDecoder = exports.staticValueDecoder = exports.dynamicValueDecoder = exports.referenceTypeDecoder = void 0;
exports.uidlNodeDecoder = exports.elementNodeDecoder = exports.conditionalNodeDecoder = exports.repeatNodeDecoder = exports.slotNodeDecoder = exports.elementDecoder = exports.designTokensDecoder = void 0;
var json_type_validation_1 = require("@mojotech/json-type-validation");

@@ -4,0 +6,0 @@ var custom_combinators_1 = require("./custom-combinators");

"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Decoders = exports.Parser = exports.Validator = void 0;
var Parser = __importStar(require("./parser"));

@@ -18,6 +34,6 @@ exports.Parser = Parser;

var validator_1 = require("./validator");
exports.Validator = validator_1.default;
__export(require("./decoders/component-decoder"));
__export(require("./decoders/project-decoder"));
__export(require("./decoders/utils"));
Object.defineProperty(exports, "Validator", { enumerable: true, get: function () { return __importDefault(validator_1).default; } });
__exportStar(require("./decoders/component-decoder"), exports);
__exportStar(require("./decoders/project-decoder"), exports);
__exportStar(require("./decoders/utils"), exports);
//# sourceMappingURL=index.js.map

@@ -14,9 +14,9 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.parseProjectJSON = exports.parseComponentJSON = void 0;
var teleport_shared_1 = require("@teleporthq/teleport-shared");
var teleport_types_1 = require("@teleporthq/teleport-types");
exports.parseComponentJSON = function (input, params) {
var parseComponentJSON = function (input, params) {
if (params === void 0) { params = {}; }
var _a;
var safeInput = params.noClone ? input : teleport_shared_1.UIDLUtils.cloneObject(input);
if ((_a = input) === null || _a === void 0 ? void 0 : _a.styleSetDefinitions) {
if (input === null || input === void 0 ? void 0 : input.styleSetDefinitions) {
var styleSetDefinitions = safeInput.styleSetDefinitions;

@@ -39,5 +39,6 @@ Object.values(styleSetDefinitions).forEach(function (styleRef) {

};
exports.parseProjectJSON = function (input, params) {
exports.parseComponentJSON = parseComponentJSON;
var parseProjectJSON = function (input, params) {
var _a;
if (params === void 0) { params = {}; }
var _a;
var safeInput = params.noClone ? input : teleport_shared_1.UIDLUtils.cloneObject(input);

@@ -71,8 +72,9 @@ var root = safeInput.root;

};
exports.parseProjectJSON = parseProjectJSON;
var parseComponentNode = function (node) {
var _a, _b, _c;
var _a, _b;
switch (node.type) {
case 'element':
var elementContent = node.content;
if ((_a = elementContent) === null || _a === void 0 ? void 0 : _a.referencedStyles) {
if (elementContent === null || elementContent === void 0 ? void 0 : elementContent.referencedStyles) {
Object.values(elementContent.referencedStyles).forEach(function (styleRef) {

@@ -109,5 +111,5 @@ var content = styleRef.content;

// @ts-ignore
if ((_b = elementContent.abilities) === null || _b === void 0 ? void 0 : _b.link) {
if ((_a = elementContent.abilities) === null || _a === void 0 ? void 0 : _a.link) {
// @ts-ignore
var _d = (_c = elementContent.abilities) === null || _c === void 0 ? void 0 : _c.link, content = _d.content, type = _d.type;
var _c = (_b = elementContent.abilities) === null || _b === void 0 ? void 0 : _b.link, content = _c.content, type = _c.type;
if (type === 'url' && typeof content.url === 'string') {

@@ -114,0 +116,0 @@ content.url = teleport_shared_1.UIDLUtils.transformStringAssignmentToJson(content.url);

"use strict";
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -24,3 +34,2 @@ var teleport_types_1 = require("@teleporthq/teleport-types");

Validator.prototype.validateComponentSchema = function (input) {
var _a;
try {

@@ -33,7 +42,6 @@ var cleanedUIDL = utils.validateNulls(input);

var errorMsg = utils.formatErrors([{ kind: e.kind, message: e.message, at: e.at }]);
throw new teleport_types_1.ComponentValidationError("Component - " + ((_a = input) === null || _a === void 0 ? void 0 : _a.name) + " \n\n " + errorMsg);
throw new teleport_types_1.ComponentValidationError("Component - " + (input === null || input === void 0 ? void 0 : input.name) + " \n\n " + errorMsg);
}
};
Validator.prototype.validateRootComponentSchema = function (input) {
var _a;
try {

@@ -46,3 +54,3 @@ var cleanedUIDL = utils.validateNulls(input);

var errorMsg = utils.formatErrors([{ kind: e.kind, message: e.message, at: e.at }]);
throw new teleport_types_1.ComponentValidationError("Component - " + ((_a = input) === null || _a === void 0 ? void 0 : _a.name) + "\n\n " + errorMsg);
throw new teleport_types_1.ComponentValidationError("Component - " + (input === null || input === void 0 ? void 0 : input.name) + "\n\n " + errorMsg);
}

@@ -65,3 +73,3 @@ };

utils.checkForDuplicateDefinitions(input);
var errors = __spreadArrays(errorsInDefinitions, errorsWithLocalVariables);
var errors = __spreadArray(__spreadArray([], errorsInDefinitions), errorsWithLocalVariables);
if (errors.length > 0) {

@@ -80,3 +88,3 @@ throw new teleport_types_1.ComponentValidationError("UIDL Component Content Validation Error. Please check the following: \n" + errors);

var errorsWtihComponentExistence = utils.checkComponentExistenceAndReferences(input);
allErrors = __spreadArrays(errorsOnRouteNode, errorsWtihComponentExistence, errorsWithComponentNaming, errorsInRootComponent, errorsInStyleSet);
allErrors = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], errorsOnRouteNode), errorsWtihComponentExistence), errorsWithComponentNaming), errorsInRootComponent), errorsInStyleSet);
}

@@ -83,0 +91,0 @@ if (allErrors.length > 0) {

@@ -1,2 +0,2 @@

import { ProjectUIDL, ComponentUIDL } from '@teleporthq/teleport-types';
import { ProjectUIDL, ComponentUIDL, UIDLStaticValue, UIDLStyleSetTokenReference } from '@teleporthq/teleport-types';
export declare const checkForDuplicateDefinitions: (input: ComponentUIDL) => void;

@@ -9,9 +9,9 @@ export declare const checkForLocalVariables: (input: ComponentUIDL) => string[];

export declare const checkProjectStyleSet: (input: ProjectUIDL) => string[];
export declare const checStylekContentForErrors: (content: Record<string, import("@teleporthq/teleport-types").UIDLStyleSheetContent>) => string[];
export declare const checStylekContentForErrors: (content: Record<string, UIDLStaticValue | UIDLStyleSetTokenReference>) => string[];
export declare const checkRootComponent: (input: ProjectUIDL) => string[];
export declare const formatErrors: (errors: {
export declare const formatErrors: (errors: Array<{
kind: string;
at: string;
message: string;
}[]) => string;
}>) => string;
export declare const validateNulls: (uidl: Record<string, unknown>) => any;
"use strict";
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateNulls = exports.formatErrors = exports.checkRootComponent = exports.checStylekContentForErrors = exports.checkProjectStyleSet = exports.checkComponentNaming = exports.checkComponentExistenceAndReferences = exports.checkRouteDefinition = exports.checkDynamicDefinitions = exports.checkForLocalVariables = exports.checkForDuplicateDefinitions = void 0;
var teleport_shared_1 = require("@teleporthq/teleport-shared");
var teleport_types_1 = require("@teleporthq/teleport-types");
// Prop definitions and state definitions should have different keys
exports.checkForDuplicateDefinitions = function (input) {
var checkForDuplicateDefinitions = function (input) {
var props = Object.keys(input.propDefinitions || {});

@@ -23,6 +22,7 @@ var states = Object.keys(input.stateDefinitions || {});

};
exports.checkForDuplicateDefinitions = checkForDuplicateDefinitions;
// In "repeat" node:
// If index is used, "useIndex" must be declared in "meta"
// If custom local variable is used, it's name must be specified inside "meta" as "iteratorName"
exports.checkForLocalVariables = function (input) {
var checkForLocalVariables = function (input) {
var errors = [];

@@ -49,2 +49,3 @@ teleport_shared_1.UIDLUtils.traverseRepeats(input.node, function (repeatContent) {

};
exports.checkForLocalVariables = checkForLocalVariables;
var validLocalVariableUsage = function (dynamicId, repeatIteratorName) {

@@ -61,4 +62,4 @@ var iteratorName = repeatIteratorName || 'item';

If props or states are defined and not used, a warning witll be displayed */
exports.checkDynamicDefinitions = function (input) {
var _a, _b;
var checkDynamicDefinitions = function (input) {
var _a;
var propKeys = Object.keys(input.propDefinitions || {});

@@ -68,3 +69,3 @@ var stateKeys = Object.keys(input.stateDefinitions || {});

var componentStyleSetKyes = Object.keys(input.styleSetDefinitions || {});
var importDefinitions = (_b = (_a = input) === null || _a === void 0 ? void 0 : _a.importDefinitions, (_b !== null && _b !== void 0 ? _b : {}));
var importDefinitions = ((_a = input === null || input === void 0 ? void 0 : input.importDefinitions) !== null && _a !== void 0 ? _a : {});
if (Object.keys(importKeys).length > 0) {

@@ -174,2 +175,3 @@ importKeys = importKeys.reduce(function (acc, importRef) {

};
exports.checkDynamicDefinitions = checkDynamicDefinitions;
var dynamicPathExistsInDefinitions = function (path, defKeys) {

@@ -186,3 +188,3 @@ if (!path.includes('.')) {

// A projectUIDL must contain "route" key
exports.checkRouteDefinition = function (input) {
var checkRouteDefinition = function (input) {
var errors = [];

@@ -196,5 +198,6 @@ var keys = Object.keys(input.root.stateDefinitions || {});

};
exports.checkRouteDefinition = checkRouteDefinition;
// All referenced components inside of the projectUIDL should be defined
// in the components section and all the project-referenced styles and tokens
exports.checkComponentExistenceAndReferences = function (input) {
var checkComponentExistenceAndReferences = function (input) {
var _a, _b, _c, _d;

@@ -205,3 +208,3 @@ var errors = [];

var tokens = Object.keys(((_c = (_b = input.root) === null || _b === void 0 ? void 0 : _b.designLanguage) === null || _c === void 0 ? void 0 : _c.tokens) || {});
var nodesToParse = __spreadArrays([
var nodesToParse = __spreadArray([
input.root.node

@@ -215,4 +218,3 @@ ], Object.values(input.components || {}).map(function (component) { return component.node; }));

conditions.forEach(function (condition) {
var _a;
if ((_a = condition) === null || _a === void 0 ? void 0 : _a.content) {
if (condition === null || condition === void 0 ? void 0 : condition.content) {
errors.push.apply(errors, checkForTokensInstyles(condition.content, tokens));

@@ -225,11 +227,10 @@ }

teleport_shared_1.UIDLUtils.traverseElements(node, function (element) {
var _a, _b;
/* Checking for project-referenced styles */
if ((_a = element) === null || _a === void 0 ? void 0 : _a.referencedStyles) {
var _c = checkForReferencedStylesUsed(element.referencedStyles, styleSetDefinitions, tokens), errorsInRferences = _c.errorsInRferences, usedStyleRefrences = _c.usedStyleRefrences;
if (element === null || element === void 0 ? void 0 : element.referencedStyles) {
var _a = checkForReferencedStylesUsed(element.referencedStyles, styleSetDefinitions, tokens), errorsInRferences = _a.errorsInRferences, usedStyleRefrences = _a.usedStyleRefrences;
errors.push.apply(errors, errorsInRferences);
usedReferencedStyles = __spreadArrays(usedReferencedStyles, usedStyleRefrences);
usedReferencedStyles = __spreadArray(__spreadArray([], usedReferencedStyles), usedStyleRefrences);
}
/* Checking for token references used in styles */
if ((_b = element) === null || _b === void 0 ? void 0 : _b.style) {
if (element === null || element === void 0 ? void 0 : element.style) {
errors.push.apply(errors, checkForTokensInstyles(element.style, tokens));

@@ -252,2 +253,3 @@ }

};
exports.checkComponentExistenceAndReferences = checkComponentExistenceAndReferences;
var checkForReferencedStylesUsed = function (referencedStyles, styleSetDefinitions, tokens) {

@@ -293,3 +295,3 @@ var errorsInRferences = [];

// }
exports.checkComponentNaming = function (input) {
var checkComponentNaming = function (input) {
var errors = [];

@@ -304,3 +306,4 @@ var namesUsed = Object.keys(input.components || {});

};
exports.checkProjectStyleSet = function (input) {
exports.checkComponentNaming = checkComponentNaming;
var checkProjectStyleSet = function (input) {
var errors = [];

@@ -319,3 +322,4 @@ var styleSet = input.root.styleSetDefinitions;

};
exports.checStylekContentForErrors = function (content) {
exports.checkProjectStyleSet = checkProjectStyleSet;
var checStylekContentForErrors = function (content) {
var errors = [];

@@ -334,4 +338,5 @@ Object.values(content).forEach(function (styleContent) {

};
exports.checStylekContentForErrors = checStylekContentForErrors;
// The "root" node should contain only elements of type "conditional"
exports.checkRootComponent = function (input) {
var checkRootComponent = function (input) {
var errors = [];

@@ -363,4 +368,5 @@ var routeNaming = [];

};
exports.checkRootComponent = checkRootComponent;
// The errors should be displayed in a human-readeable way
exports.formatErrors = function (errors) {
var formatErrors = function (errors) {
var listOfErrors = [];

@@ -373,3 +379,4 @@ errors.forEach(function (error) {

};
exports.validateNulls = function (uidl) {
exports.formatErrors = formatErrors;
var validateNulls = function (uidl) {
return JSON.parse(JSON.stringify(uidl), function (key, value) {

@@ -382,2 +389,3 @@ if (value === undefined || value == null) {

};
exports.validateNulls = validateNulls;
//# sourceMappingURL=utils.js.map

@@ -16,5 +16,4 @@ var __assign = (this && this.__assign) || function () {

if (params === void 0) { params = {}; }
var _a;
var safeInput = params.noClone ? input : UIDLUtils.cloneObject(input);
if ((_a = input) === null || _a === void 0 ? void 0 : _a.styleSetDefinitions) {
if (input === null || input === void 0 ? void 0 : input.styleSetDefinitions) {
var styleSetDefinitions = safeInput.styleSetDefinitions;

@@ -38,4 +37,4 @@ Object.values(styleSetDefinitions).forEach(function (styleRef) {

export var parseProjectJSON = function (input, params) {
var _a;
if (params === void 0) { params = {}; }
var _a;
var safeInput = params.noClone ? input : UIDLUtils.cloneObject(input);

@@ -70,7 +69,7 @@ var root = safeInput.root;

var parseComponentNode = function (node) {
var _a, _b, _c;
var _a, _b;
switch (node.type) {
case 'element':
var elementContent = node.content;
if ((_a = elementContent) === null || _a === void 0 ? void 0 : _a.referencedStyles) {
if (elementContent === null || elementContent === void 0 ? void 0 : elementContent.referencedStyles) {
Object.values(elementContent.referencedStyles).forEach(function (styleRef) {

@@ -107,5 +106,5 @@ var content = styleRef.content;

// @ts-ignore
if ((_b = elementContent.abilities) === null || _b === void 0 ? void 0 : _b.link) {
if ((_a = elementContent.abilities) === null || _a === void 0 ? void 0 : _a.link) {
// @ts-ignore
var _d = (_c = elementContent.abilities) === null || _c === void 0 ? void 0 : _c.link, content = _d.content, type = _d.type;
var _c = (_b = elementContent.abilities) === null || _b === void 0 ? void 0 : _b.link, content = _c.content, type = _c.type;
if (type === 'url' && typeof content.url === 'string') {

@@ -112,0 +111,0 @@ content.url = UIDLUtils.transformStringAssignmentToJson(content.url);

@@ -1,7 +0,5 @@

var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};

@@ -15,3 +13,2 @@ import { ProjectValidationError, ComponentValidationError, } from '@teleporthq/teleport-types';

Validator.prototype.validateComponentSchema = function (input) {
var _a;
try {

@@ -24,7 +21,6 @@ var cleanedUIDL = utils.validateNulls(input);

var errorMsg = utils.formatErrors([{ kind: e.kind, message: e.message, at: e.at }]);
throw new ComponentValidationError("Component - " + ((_a = input) === null || _a === void 0 ? void 0 : _a.name) + " \n\n " + errorMsg);
throw new ComponentValidationError("Component - " + (input === null || input === void 0 ? void 0 : input.name) + " \n\n " + errorMsg);
}
};
Validator.prototype.validateRootComponentSchema = function (input) {
var _a;
try {

@@ -37,3 +33,3 @@ var cleanedUIDL = utils.validateNulls(input);

var errorMsg = utils.formatErrors([{ kind: e.kind, message: e.message, at: e.at }]);
throw new ComponentValidationError("Component - " + ((_a = input) === null || _a === void 0 ? void 0 : _a.name) + "\n\n " + errorMsg);
throw new ComponentValidationError("Component - " + (input === null || input === void 0 ? void 0 : input.name) + "\n\n " + errorMsg);
}

@@ -56,3 +52,3 @@ };

utils.checkForDuplicateDefinitions(input);
var errors = __spreadArrays(errorsInDefinitions, errorsWithLocalVariables);
var errors = __spreadArray(__spreadArray([], errorsInDefinitions), errorsWithLocalVariables);
if (errors.length > 0) {

@@ -71,3 +67,3 @@ throw new ComponentValidationError("UIDL Component Content Validation Error. Please check the following: \n" + errors);

var errorsWtihComponentExistence = utils.checkComponentExistenceAndReferences(input);
allErrors = __spreadArrays(errorsOnRouteNode, errorsWtihComponentExistence, errorsWithComponentNaming, errorsInRootComponent, errorsInStyleSet);
allErrors = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], errorsOnRouteNode), errorsWtihComponentExistence), errorsWithComponentNaming), errorsInRootComponent), errorsInStyleSet);
}

@@ -74,0 +70,0 @@ if (allErrors.length > 0) {

@@ -1,2 +0,2 @@

import { ProjectUIDL, ComponentUIDL } from '@teleporthq/teleport-types';
import { ProjectUIDL, ComponentUIDL, UIDLStaticValue, UIDLStyleSetTokenReference } from '@teleporthq/teleport-types';
export declare const checkForDuplicateDefinitions: (input: ComponentUIDL) => void;

@@ -9,9 +9,9 @@ export declare const checkForLocalVariables: (input: ComponentUIDL) => string[];

export declare const checkProjectStyleSet: (input: ProjectUIDL) => string[];
export declare const checStylekContentForErrors: (content: Record<string, import("@teleporthq/teleport-types").UIDLStyleSheetContent>) => string[];
export declare const checStylekContentForErrors: (content: Record<string, UIDLStaticValue | UIDLStyleSetTokenReference>) => string[];
export declare const checkRootComponent: (input: ProjectUIDL) => string[];
export declare const formatErrors: (errors: {
export declare const formatErrors: (errors: Array<{
kind: string;
at: string;
message: string;
}[]) => string;
}>) => string;
export declare const validateNulls: (uidl: Record<string, unknown>) => any;

@@ -1,7 +0,5 @@

var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};

@@ -58,3 +56,3 @@ import { UIDLUtils } from '@teleporthq/teleport-shared';

export var checkDynamicDefinitions = function (input) {
var _a, _b;
var _a;
var propKeys = Object.keys(input.propDefinitions || {});

@@ -64,3 +62,3 @@ var stateKeys = Object.keys(input.stateDefinitions || {});

var componentStyleSetKyes = Object.keys(input.styleSetDefinitions || {});
var importDefinitions = (_b = (_a = input) === null || _a === void 0 ? void 0 : _a.importDefinitions, (_b !== null && _b !== void 0 ? _b : {}));
var importDefinitions = ((_a = input === null || input === void 0 ? void 0 : input.importDefinitions) !== null && _a !== void 0 ? _a : {});
if (Object.keys(importKeys).length > 0) {

@@ -198,3 +196,3 @@ importKeys = importKeys.reduce(function (acc, importRef) {

var tokens = Object.keys(((_c = (_b = input.root) === null || _b === void 0 ? void 0 : _b.designLanguage) === null || _c === void 0 ? void 0 : _c.tokens) || {});
var nodesToParse = __spreadArrays([
var nodesToParse = __spreadArray([
input.root.node

@@ -208,4 +206,3 @@ ], Object.values(input.components || {}).map(function (component) { return component.node; }));

conditions.forEach(function (condition) {
var _a;
if ((_a = condition) === null || _a === void 0 ? void 0 : _a.content) {
if (condition === null || condition === void 0 ? void 0 : condition.content) {
errors.push.apply(errors, checkForTokensInstyles(condition.content, tokens));

@@ -218,11 +215,10 @@ }

UIDLUtils.traverseElements(node, function (element) {
var _a, _b;
/* Checking for project-referenced styles */
if ((_a = element) === null || _a === void 0 ? void 0 : _a.referencedStyles) {
var _c = checkForReferencedStylesUsed(element.referencedStyles, styleSetDefinitions, tokens), errorsInRferences = _c.errorsInRferences, usedStyleRefrences = _c.usedStyleRefrences;
if (element === null || element === void 0 ? void 0 : element.referencedStyles) {
var _a = checkForReferencedStylesUsed(element.referencedStyles, styleSetDefinitions, tokens), errorsInRferences = _a.errorsInRferences, usedStyleRefrences = _a.usedStyleRefrences;
errors.push.apply(errors, errorsInRferences);
usedReferencedStyles = __spreadArrays(usedReferencedStyles, usedStyleRefrences);
usedReferencedStyles = __spreadArray(__spreadArray([], usedReferencedStyles), usedStyleRefrences);
}
/* Checking for token references used in styles */
if ((_b = element) === null || _b === void 0 ? void 0 : _b.style) {
if (element === null || element === void 0 ? void 0 : element.style) {
errors.push.apply(errors, checkForTokensInstyles(element.style, tokens));

@@ -229,0 +225,0 @@ }

{
"name": "@teleporthq/teleport-uidl-validator",
"version": "0.17.3",
"version": "0.17.7",
"description": "A module that offers validation and parsing for non-standard UIDL structures",

@@ -28,6 +28,6 @@ "author": "teleportHQ",

"@mojotech/json-type-validation": "^3.1.0",
"@teleporthq/teleport-shared": "^0.17.3",
"@teleporthq/teleport-types": "^0.17.3"
"@teleporthq/teleport-shared": "^0.17.7",
"@teleporthq/teleport-types": "^0.17.7"
},
"gitHead": "1a673d148f2626c5488092f3e88b3a9d7c9725b4"
"gitHead": "5547aade455379febefd8b84efa856f6346a8404"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet