@teleporthq/teleport-uidl-validator
Advanced tools
Comparing version 0.10.7 to 0.10.8
@@ -39,2 +39,3 @@ "use strict"; | ||
var parseComponentNode = function (node) { | ||
var _a, _b; | ||
switch (node.type) { | ||
@@ -49,2 +50,10 @@ case 'element': | ||
} | ||
// @ts-ignore | ||
if ((_a = elementContent.abilities) === null || _a === void 0 ? void 0 : _a.link) { | ||
// @ts-ignore | ||
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') { | ||
content.url = teleport_shared_1.UIDLUtils.transformStringAssignmentToJson(content.url); | ||
} | ||
} | ||
if (Array.isArray(elementContent.children)) { | ||
@@ -64,4 +73,3 @@ elementContent.children = elementContent.children.map(function (child) { | ||
var reference = conditionalNode.content.reference; | ||
conditionalNode.content.node = parseComponentNode(conditionalNode.content | ||
.node); | ||
conditionalNode.content.node = parseComponentNode(conditionalNode.content.node); | ||
if (typeof reference === 'string') { | ||
@@ -82,4 +90,3 @@ conditionalNode.content.reference = teleport_shared_1.UIDLUtils.transformStringAssignmentToJson(reference); | ||
if (slotNode.content.fallback) { | ||
slotNode.content.fallback = parseComponentNode(slotNode.content | ||
.fallback); | ||
slotNode.content.fallback = parseComponentNode(slotNode.content.fallback); | ||
} | ||
@@ -86,0 +93,0 @@ return slotNode; |
@@ -302,2 +302,8 @@ { | ||
"style": { "$ref": "#/definitions/styleDefinitions" }, | ||
"abilities": { | ||
"type": "object", | ||
"properties": { | ||
"link": { "$ref": "#/definitions/linkDefinition" } | ||
} | ||
}, | ||
"attrs": { | ||
@@ -369,2 +375,9 @@ "type": "object", | ||
}, | ||
"linkDefinition": { | ||
"type": "object", | ||
"properties": { | ||
"type": { "type": "string", "enum": ["url", "section", "navlink", "mail", "phone"] }, | ||
"content": { "type": "object" } | ||
} | ||
}, | ||
"eventDefinitions": { | ||
@@ -371,0 +384,0 @@ "type": "object", |
@@ -28,2 +28,3 @@ import { UIDLUtils } from '@teleporthq/teleport-shared'; | ||
const parseComponentNode = (node) => { | ||
var _a, _b; | ||
switch (node.type) { | ||
@@ -38,2 +39,10 @@ case 'element': | ||
} | ||
// @ts-ignore | ||
if ((_a = elementContent.abilities) === null || _a === void 0 ? void 0 : _a.link) { | ||
// @ts-ignore | ||
const { content, type } = (_b = elementContent.abilities) === null || _b === void 0 ? void 0 : _b.link; | ||
if (type === 'url' && typeof content.url === 'string') { | ||
content.url = UIDLUtils.transformStringAssignmentToJson(content.url); | ||
} | ||
} | ||
if (Array.isArray(elementContent.children)) { | ||
@@ -53,4 +62,3 @@ elementContent.children = elementContent.children.map((child) => { | ||
const { reference } = conditionalNode.content; | ||
conditionalNode.content.node = parseComponentNode(conditionalNode.content | ||
.node); | ||
conditionalNode.content.node = parseComponentNode(conditionalNode.content.node); | ||
if (typeof reference === 'string') { | ||
@@ -71,4 +79,3 @@ conditionalNode.content.reference = UIDLUtils.transformStringAssignmentToJson(reference); | ||
if (slotNode.content.fallback) { | ||
slotNode.content.fallback = parseComponentNode(slotNode.content | ||
.fallback); | ||
slotNode.content.fallback = parseComponentNode(slotNode.content.fallback); | ||
} | ||
@@ -75,0 +82,0 @@ return slotNode; |
@@ -302,2 +302,8 @@ { | ||
"style": { "$ref": "#/definitions/styleDefinitions" }, | ||
"abilities": { | ||
"type": "object", | ||
"properties": { | ||
"link": { "$ref": "#/definitions/linkDefinition" } | ||
} | ||
}, | ||
"attrs": { | ||
@@ -369,2 +375,9 @@ "type": "object", | ||
}, | ||
"linkDefinition": { | ||
"type": "object", | ||
"properties": { | ||
"type": { "type": "string", "enum": ["url", "section", "navlink", "mail", "phone"] }, | ||
"content": { "type": "object" } | ||
} | ||
}, | ||
"eventDefinitions": { | ||
@@ -371,0 +384,0 @@ "type": "object", |
{ | ||
"name": "@teleporthq/teleport-uidl-validator", | ||
"version": "0.10.7", | ||
"version": "0.10.8", | ||
"description": "A module that offers validation and parsing for non-standard UIDL structures", | ||
@@ -29,7 +29,7 @@ "author": "teleportHQ", | ||
"dependencies": { | ||
"@teleporthq/teleport-shared": "^0.10.7", | ||
"@teleporthq/teleport-types": "^0.10.7", | ||
"@teleporthq/teleport-shared": "^0.10.8", | ||
"@teleporthq/teleport-types": "^0.10.8", | ||
"ajv": "^6.10.2" | ||
}, | ||
"gitHead": "88c0dc0974fa1a2b3034b02fcbc49a95999553d1" | ||
"gitHead": "47623653d1c32928b855cdccc27796acc9fa8fe7" | ||
} |
@@ -55,6 +55,5 @@ import { UIDLUtils } from '@teleporthq/teleport-shared' | ||
(parsedComponnets: Record<string, ComponentUIDL>, key) => { | ||
parsedComponnets[key] = parseComponentJSON((result.components[key] as unknown) as Record< | ||
string, | ||
unknown | ||
>) | ||
parsedComponnets[key] = parseComponentJSON( | ||
(result.components[key] as unknown) as Record<string, unknown> | ||
) | ||
return parsedComponnets | ||
@@ -86,2 +85,11 @@ }, | ||
// @ts-ignore | ||
if (elementContent.abilities?.link) { | ||
// @ts-ignore | ||
const { content, type } = elementContent.abilities?.link | ||
if (type === 'url' && typeof content.url === 'string') { | ||
content.url = UIDLUtils.transformStringAssignmentToJson(content.url) | ||
} | ||
} | ||
if (Array.isArray(elementContent.children)) { | ||
@@ -103,4 +111,5 @@ elementContent.children = elementContent.children.map((child) => { | ||
conditionalNode.content.node = parseComponentNode((conditionalNode.content | ||
.node as unknown) as Record<string, unknown>) | ||
conditionalNode.content.node = parseComponentNode( | ||
(conditionalNode.content.node as unknown) as Record<string, unknown> | ||
) | ||
@@ -119,6 +128,5 @@ if (typeof reference === 'string') { | ||
repeatNode.content.node = parseComponentNode((repeatNode.content.node as unknown) as Record< | ||
string, | ||
unknown | ||
>) as UIDLElementNode | ||
repeatNode.content.node = parseComponentNode( | ||
(repeatNode.content.node as unknown) as Record<string, unknown> | ||
) as UIDLElementNode | ||
@@ -135,7 +143,5 @@ if (typeof dataSource === 'string') { | ||
if (slotNode.content.fallback) { | ||
slotNode.content.fallback = parseComponentNode((slotNode.content | ||
.fallback as unknown) as Record<string, unknown>) as | ||
| UIDLElementNode | ||
| UIDLStaticValue | ||
| UIDLDynamicReference | ||
slotNode.content.fallback = parseComponentNode( | ||
(slotNode.content.fallback as unknown) as Record<string, unknown> | ||
) as UIDLElementNode | UIDLStaticValue | UIDLDynamicReference | ||
} | ||
@@ -142,0 +148,0 @@ |
@@ -302,2 +302,8 @@ { | ||
"style": {"$ref": "#/definitions/styleDefinitions"}, | ||
"abilities": { | ||
"type": "object", | ||
"properties": { | ||
"link": {"$ref": "#/definitions/linkDefinition"} | ||
} | ||
}, | ||
"attrs": { | ||
@@ -369,2 +375,9 @@ "type": "object", | ||
}, | ||
"linkDefinition": { | ||
"type": "object", | ||
"properties": { | ||
"type": { "type": "string", "enum": ["url", "section", "navlink", "mail", "phone"] }, | ||
"content": { "type": "object" } | ||
} | ||
}, | ||
"eventDefinitions":{ | ||
@@ -371,0 +384,0 @@ "type": "object", |
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
428390
5567