@teleporthq/teleport-uidl-validator
Advanced tools
Comparing version 0.27.4-alpha.0 to 0.27.5-alpha.0
import { Decoder } from '@mojotech/json-type-validation'; | ||
import { VUIDLGlobalProjectValues, WebManifest, VProjectUIDL, ContextsUIDL, ContextUIDLItem, ResourcesUIDL, ResourceItemUIDL } from '@teleporthq/teleport-types'; | ||
import { VUIDLGlobalProjectValues, WebManifest, VProjectUIDL, UIDLResources } from '@teleporthq/teleport-types'; | ||
export declare const webManifestDecoder: Decoder<WebManifest>; | ||
export declare const globalProjectValuesDecoder: Decoder<VUIDLGlobalProjectValues>; | ||
export declare const contextItemDecoder: Decoder<ContextUIDLItem>; | ||
export declare const contextsDecoder: Decoder<ContextsUIDL>; | ||
export declare const projectResourceItemDecoder: Decoder<ResourceItemUIDL>; | ||
export declare const resourcesDecoder: Decoder<ResourcesUIDL>; | ||
export declare const resourcesDecoder: Decoder<UIDLResources>; | ||
export declare const projectUIDLDecoder: Decoder<VProjectUIDL>; | ||
//# sourceMappingURL=project-decoder.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.projectUIDLDecoder = exports.resourcesDecoder = exports.projectResourceItemDecoder = exports.contextsDecoder = exports.contextItemDecoder = exports.globalProjectValuesDecoder = exports.webManifestDecoder = void 0; | ||
exports.projectUIDLDecoder = exports.resourcesDecoder = exports.globalProjectValuesDecoder = exports.webManifestDecoder = void 0; | ||
var json_type_validation_1 = require("@mojotech/json-type-validation"); | ||
@@ -33,17 +33,5 @@ var utils_1 = require("./utils"); | ||
}); | ||
exports.contextItemDecoder = (0, json_type_validation_1.object)({ | ||
name: (0, json_type_validation_1.string)(), | ||
fileName: (0, json_type_validation_1.optional)((0, json_type_validation_1.string)()), | ||
}); | ||
exports.contextsDecoder = (0, json_type_validation_1.object)({ | ||
rootFolder: (0, json_type_validation_1.optional)((0, json_type_validation_1.string)()), | ||
items: (0, json_type_validation_1.dict)((0, json_type_validation_1.optional)(exports.contextItemDecoder)), | ||
}); | ||
exports.projectResourceItemDecoder = (0, json_type_validation_1.intersection)(utils_1.resourceDecoder, (0, json_type_validation_1.object)({ | ||
id: (0, json_type_validation_1.string)(), | ||
name: (0, json_type_validation_1.string)(), | ||
})); | ||
exports.resourcesDecoder = (0, json_type_validation_1.object)({ | ||
rootFolder: (0, json_type_validation_1.optional)((0, json_type_validation_1.string)()), | ||
items: (0, json_type_validation_1.dict)((0, json_type_validation_1.optional)(exports.projectResourceItemDecoder)), | ||
resourceMappers: (0, json_type_validation_1.optional)((0, json_type_validation_1.dict)((0, json_type_validation_1.lazy)(function () { return utils_1.dependencyDecoder; }))), | ||
items: (0, json_type_validation_1.optional)((0, json_type_validation_1.dict)((0, json_type_validation_1.lazy)(function () { return utils_1.resourceItemDecoder; }))), | ||
}); | ||
@@ -55,5 +43,11 @@ exports.projectUIDLDecoder = (0, json_type_validation_1.object)({ | ||
components: (0, json_type_validation_1.optional)((0, json_type_validation_1.dict)(component_decoder_1.componentUIDLDecoder)), | ||
contexts: (0, json_type_validation_1.optional)(exports.contextsDecoder), | ||
resources: (0, json_type_validation_1.optional)(exports.resourcesDecoder), | ||
contexts: (0, json_type_validation_1.optional)((0, json_type_validation_1.object)({ | ||
rootFolder: (0, json_type_validation_1.string)(), | ||
items: (0, json_type_validation_1.dict)((0, json_type_validation_1.object)({ | ||
name: (0, json_type_validation_1.string)(), | ||
fileName: (0, json_type_validation_1.optional)((0, json_type_validation_1.string)()), | ||
})), | ||
})), | ||
}); | ||
//# sourceMappingURL=project-decoder.js.map |
import { Decoder } from '@mojotech/json-type-validation'; | ||
import { UIDLStaticValue, ReferenceType, UIDLDynamicReference, UIDLPropDefinition, UIDLStateDefinition, UIDLStateValueDetails, UIDLPageOptions, UIDLComponentOutputOptions, UIDLDependency, UIDLStyleDefinitions, UIDLStyleValue, UIDLAttributeValue, UIDLEventHandlerStatement, UIDLNavLinkNode, UIDLMailLinkNode, UIDLPhoneLinkNode, UIDLRawValue, UIDLElementStyleStates, UIDLStyleStateCondition, UIDLStyleMediaQueryScreenSizeCondition, UIDLStyleConditions, UIDLElementNodeProjectReferencedStyle, VUIDLComponentSEO, VUIDLGlobalAsset, UIDLExternalDependency, UIDLLocalDependency, UIDLPeerDependency, UIDLImportReference, UIDLStyleSetTokenReference, VUIDLStyleSetDefnition, VUIDLElement, VUIDLSlotNode, VUIDLConditionalNode, VUIDLRepeatNode, VUIDLElementNode, VUIDLNode, VUIDLElementNodeInlineReferencedStyle, VUIDLSectionLinkNode, VUIDLLinkNode, VUIDLURLLinkNode, VUIDLStyleSetConditions, VUIDLStyleSetMediaCondition, VUIDLStyleSetStateCondition, VUIDLDesignTokens, UIDLPropCallEvent, UIDLStateModifierEvent, UIDLScriptExternalAsset, UIDLScriptInlineAsset, VUIDLStyleInlineAsset, UIDLStyleExternalAsset, VUIDLFontAsset, UIDLCanonicalAsset, UIDLIconAsset, UIDLAssetBase, VUIDLElementNodeClassReferencedStyle, UIDLCompDynamicReference, UIDLComponentStyleReference, PagePaginationOptions, VCMSItemUIDLElementNode, VCMSListUIDLElementNode, Resource, InitialPropsData, InitialPathsData, UIDLExpressionValue, UIDLDynamicLinkNode } from '@teleporthq/teleport-types'; | ||
import { UIDLStaticValue, ReferenceType, UIDLDynamicReference, UIDLPropDefinition, UIDLStateDefinition, UIDLStateValueDetails, UIDLPageOptions, UIDLComponentOutputOptions, UIDLDependency, UIDLStyleDefinitions, UIDLStyleValue, UIDLAttributeValue, UIDLEventHandlerStatement, UIDLNavLinkNode, UIDLMailLinkNode, UIDLPhoneLinkNode, UIDLRawValue, UIDLElementStyleStates, UIDLStyleStateCondition, UIDLStyleMediaQueryScreenSizeCondition, UIDLStyleConditions, UIDLElementNodeProjectReferencedStyle, VUIDLComponentSEO, VUIDLGlobalAsset, UIDLExternalDependency, UIDLLocalDependency, UIDLPeerDependency, UIDLImportReference, UIDLStyleSetTokenReference, VUIDLStyleSetDefnition, VUIDLElement, VUIDLSlotNode, VUIDLConditionalNode, VUIDLRepeatNode, VUIDLElementNode, VUIDLNode, VUIDLElementNodeInlineReferencedStyle, VUIDLSectionLinkNode, VUIDLLinkNode, VUIDLURLLinkNode, VUIDLStyleSetConditions, VUIDLStyleSetMediaCondition, VUIDLStyleSetStateCondition, VUIDLDesignTokens, UIDLPropCallEvent, UIDLStateModifierEvent, UIDLScriptExternalAsset, UIDLScriptInlineAsset, VUIDLStyleInlineAsset, UIDLStyleExternalAsset, VUIDLFontAsset, UIDLCanonicalAsset, UIDLIconAsset, UIDLAssetBase, VUIDLElementNodeClassReferencedStyle, UIDLCompDynamicReference, UIDLComponentStyleReference, PagePaginationOptions, VCMSItemUIDLElementNode, VCMSListUIDLElementNode, UIDLInitialPathsData, UIDLInitialPropsData, UIDLExpressionValue, UIDLDynamicLinkNode, UIDLENVValue, UIDLPropValue, UIDLResourceItem } from '@teleporthq/teleport-types'; | ||
export declare const referenceTypeDecoder: Decoder<ReferenceType>; | ||
@@ -8,5 +8,7 @@ export declare const dynamicValueDecoder: Decoder<UIDLDynamicReference>; | ||
export declare const rawValueDecoder: Decoder<UIDLRawValue>; | ||
export declare const resourceDecoder: Decoder<Resource>; | ||
export declare const initialPropsDecoder: Decoder<InitialPropsData>; | ||
export declare const initialPathsDecoder: Decoder<InitialPathsData>; | ||
export declare const envValueDecoder: Decoder<UIDLENVValue>; | ||
export declare const dyamicFunctionParam: Decoder<UIDLPropValue>; | ||
export declare const resourceItemDecoder: Decoder<UIDLResourceItem>; | ||
export declare const initialPropsDecoder: Decoder<UIDLInitialPropsData>; | ||
export declare const initialPathsDecoder: Decoder<UIDLInitialPathsData>; | ||
export declare const styleSetMediaConditionDecoder: Decoder<VUIDLStyleSetMediaCondition>; | ||
@@ -13,0 +15,0 @@ export declare const styleSetStateConditionDecoder: Decoder<VUIDLStyleSetStateCondition>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.elementStateDecoder = exports.uidlLinkNodeDecoder = exports.phoneLinkNodeDecoder = exports.uidlMailLinkNodeDecoder = exports.navLinkNodeDecoder = exports.sectionLinkNodeDecoder = exports.dynamicLinkDecoder = exports.urlLinkNodeDecoder = exports.stateChangeEventDecoder = exports.propCallEventDecoder = exports.eventHandlerStatementDecoder = exports.styleDefinitionsDecoder = exports.styleValueDecoder = exports.uidlComponentStyleReference = exports.attributeValueDecoder = exports.importReferenceDecoder = exports.dependencyDecoder = exports.localDependencyDecoder = exports.externaldependencyDecoder = exports.peerDependencyDecoder = exports.outputOptionsDecoder = exports.stateValueDetailsDecoder = exports.pageOptionsDecoder = exports.stateDefinitionsDecoder = exports.pageOptionsPaginationDecoder = exports.propDefinitionsDecoder = exports.componentSeoDecoder = exports.iconAssetDecoder = exports.canonicalAssetDecoder = exports.fontAssetDecoder = exports.externalStyleAssetDecoder = exports.inlineStyletAssetDecoder = exports.externalScriptAssetDecoder = exports.inlineScriptAssetDecoder = exports.baseAssetDecoder = exports.globalAssetsDecoder = exports.stateOrPropDefinitionDecoder = exports.styleSetDefinitionDecoder = exports.tokenReferenceDecoder = exports.projectStyleConditionsDecoder = exports.styleSetStateConditionDecoder = exports.styleSetMediaConditionDecoder = exports.initialPathsDecoder = exports.initialPropsDecoder = exports.resourceDecoder = exports.rawValueDecoder = exports.staticValueDecoder = exports.expressionValueDecoder = exports.dynamicValueDecoder = exports.referenceTypeDecoder = void 0; | ||
exports.uidlNodeDecoder = exports.cmsListNodeDecoder = exports.cmsItemNodeDecoder = exports.elementNodeDecoder = exports.conditionalNodeDecoder = exports.repeatNodeDecoder = exports.slotNodeDecoder = exports.elementDecoder = exports.designTokensDecoder = exports.elementComponentReferencedStyle = exports.classDynamicReferenceDecoder = exports.elementInlineReferencedStyle = exports.elementProjectReferencedStyle = exports.styleConditionsDecoder = exports.elementStyleWithMediaConditionDecoder = exports.elementStyleWithStateConditionDecoder = void 0; | ||
exports.phoneLinkNodeDecoder = exports.uidlMailLinkNodeDecoder = exports.navLinkNodeDecoder = exports.sectionLinkNodeDecoder = exports.dynamicLinkDecoder = exports.urlLinkNodeDecoder = exports.stateChangeEventDecoder = exports.propCallEventDecoder = exports.eventHandlerStatementDecoder = exports.styleDefinitionsDecoder = exports.styleValueDecoder = exports.uidlComponentStyleReference = exports.attributeValueDecoder = exports.importReferenceDecoder = exports.dependencyDecoder = exports.localDependencyDecoder = exports.externaldependencyDecoder = exports.peerDependencyDecoder = exports.outputOptionsDecoder = exports.stateValueDetailsDecoder = exports.pageOptionsDecoder = exports.stateDefinitionsDecoder = exports.pageOptionsPaginationDecoder = exports.propDefinitionsDecoder = exports.componentSeoDecoder = exports.iconAssetDecoder = exports.canonicalAssetDecoder = exports.fontAssetDecoder = exports.externalStyleAssetDecoder = exports.inlineStyletAssetDecoder = exports.externalScriptAssetDecoder = exports.inlineScriptAssetDecoder = exports.baseAssetDecoder = exports.globalAssetsDecoder = exports.stateOrPropDefinitionDecoder = exports.styleSetDefinitionDecoder = exports.tokenReferenceDecoder = exports.projectStyleConditionsDecoder = exports.styleSetStateConditionDecoder = exports.styleSetMediaConditionDecoder = exports.initialPathsDecoder = exports.initialPropsDecoder = exports.resourceItemDecoder = exports.dyamicFunctionParam = exports.envValueDecoder = exports.rawValueDecoder = exports.staticValueDecoder = exports.expressionValueDecoder = exports.dynamicValueDecoder = exports.referenceTypeDecoder = void 0; | ||
exports.uidlNodeDecoder = exports.cmsListNodeDecoder = exports.cmsItemNodeDecoder = exports.elementNodeDecoder = exports.conditionalNodeDecoder = exports.repeatNodeDecoder = exports.slotNodeDecoder = exports.elementDecoder = exports.designTokensDecoder = exports.elementComponentReferencedStyle = exports.classDynamicReferenceDecoder = exports.elementInlineReferencedStyle = exports.elementProjectReferencedStyle = exports.styleConditionsDecoder = exports.elementStyleWithMediaConditionDecoder = exports.elementStyleWithStateConditionDecoder = exports.elementStateDecoder = exports.uidlLinkNodeDecoder = void 0; | ||
var json_type_validation_1 = require("@mojotech/json-type-validation"); | ||
var custom_combinators_1 = require("./custom-combinators"); | ||
var isValidComponentName = custom_combinators_1.CustomCombinators.isValidComponentName, isValidFileName = custom_combinators_1.CustomCombinators.isValidFileName, isValidElementName = custom_combinators_1.CustomCombinators.isValidElementName, isValidNavLink = custom_combinators_1.CustomCombinators.isValidNavLink; | ||
var resourceValueDecoder = (0, json_type_validation_1.union)((0, json_type_validation_1.object)({ type: (0, json_type_validation_1.constant)('static'), value: (0, json_type_validation_1.string)() }), (0, json_type_validation_1.object)({ type: (0, json_type_validation_1.constant)('env'), value: (0, json_type_validation_1.string)(), fallback: (0, json_type_validation_1.optional)((0, json_type_validation_1.string)()) })); | ||
exports.referenceTypeDecoder = (0, json_type_validation_1.union)((0, json_type_validation_1.constant)('prop'), (0, json_type_validation_1.constant)('state'), (0, json_type_validation_1.constant)('local'), (0, json_type_validation_1.constant)('attr'), (0, json_type_validation_1.constant)('children'), (0, json_type_validation_1.constant)('token'), (0, json_type_validation_1.constant)('ctx')); | ||
@@ -31,9 +30,25 @@ exports.dynamicValueDecoder = (0, json_type_validation_1.object)({ | ||
}); | ||
var resourceUrlParamsDecoder = (0, json_type_validation_1.dict)((0, json_type_validation_1.union)(exports.staticValueDecoder, exports.dynamicValueDecoder, exports.expressionValueDecoder, (0, json_type_validation_1.array)((0, json_type_validation_1.union)(exports.staticValueDecoder, exports.dynamicValueDecoder)))); | ||
exports.resourceDecoder = (0, json_type_validation_1.object)({ | ||
baseUrl: resourceValueDecoder, | ||
urlParams: (0, json_type_validation_1.optional)((0, json_type_validation_1.union)(resourceUrlParamsDecoder, (0, json_type_validation_1.dict)(resourceUrlParamsDecoder), (0, json_type_validation_1.unknownJson)())), | ||
authToken: (0, json_type_validation_1.optional)(resourceValueDecoder), | ||
route: (0, json_type_validation_1.optional)(resourceValueDecoder), | ||
exports.envValueDecoder = (0, json_type_validation_1.object)({ | ||
type: (0, json_type_validation_1.constant)('env'), | ||
content: (0, json_type_validation_1.string)(), | ||
}); | ||
exports.dyamicFunctionParam = (0, json_type_validation_1.object)({ | ||
type: (0, json_type_validation_1.constant)('dynamic'), | ||
content: (0, json_type_validation_1.object)({ | ||
referenceType: (0, json_type_validation_1.constant)('prop'), | ||
id: (0, json_type_validation_1.string)(), | ||
}), | ||
}); | ||
exports.resourceItemDecoder = (0, json_type_validation_1.object)({ | ||
name: (0, json_type_validation_1.string)(), | ||
headers: (0, json_type_validation_1.optional)((0, json_type_validation_1.dict)((0, json_type_validation_1.union)(exports.staticValueDecoder, exports.envValueDecoder))), | ||
path: (0, json_type_validation_1.object)({ | ||
baseUrl: (0, json_type_validation_1.union)(exports.staticValueDecoder, exports.envValueDecoder), | ||
route: exports.staticValueDecoder, | ||
}), | ||
method: (0, json_type_validation_1.withDefault)('GET', (0, json_type_validation_1.union)((0, json_type_validation_1.constant)('GET'), (0, json_type_validation_1.constant)('POST'))), | ||
body: (0, json_type_validation_1.optional)((0, json_type_validation_1.dict)(exports.staticValueDecoder)), | ||
mappers: (0, json_type_validation_1.withDefault)([], (0, json_type_validation_1.array)((0, json_type_validation_1.string)())), | ||
params: (0, json_type_validation_1.optional)((0, json_type_validation_1.dict)((0, json_type_validation_1.union)(exports.staticValueDecoder, exports.dyamicFunctionParam))), | ||
}); | ||
exports.initialPropsDecoder = (0, json_type_validation_1.object)({ | ||
@@ -45,7 +60,6 @@ exposeAs: (0, json_type_validation_1.object)({ | ||
}), | ||
resourceMappers: (0, json_type_validation_1.optional)((0, json_type_validation_1.array)((0, json_type_validation_1.object)({ | ||
name: (0, json_type_validation_1.string)(), | ||
resource: (0, json_type_validation_1.lazy)(function () { return exports.externaldependencyDecoder; }), | ||
}))), | ||
resource: exports.resourceDecoder, | ||
resource: (0, json_type_validation_1.object)({ | ||
id: (0, json_type_validation_1.string)(), | ||
params: (0, json_type_validation_1.optional)((0, json_type_validation_1.dict)((0, json_type_validation_1.union)(exports.staticValueDecoder, exports.dyamicFunctionParam, exports.expressionValueDecoder))), | ||
}), | ||
}); | ||
@@ -58,3 +72,6 @@ exports.initialPathsDecoder = (0, json_type_validation_1.object)({ | ||
}), | ||
resource: exports.resourceDecoder, | ||
resource: (0, json_type_validation_1.object)({ | ||
id: (0, json_type_validation_1.string)(), | ||
params: (0, json_type_validation_1.optional)((0, json_type_validation_1.dict)((0, json_type_validation_1.union)(exports.staticValueDecoder, exports.dyamicFunctionParam, exports.expressionValueDecoder))), | ||
}), | ||
}); | ||
@@ -150,3 +167,6 @@ exports.styleSetMediaConditionDecoder = (0, json_type_validation_1.object)({ | ||
pageSize: (0, json_type_validation_1.number)(), | ||
totalCountPath: (0, json_type_validation_1.optional)((0, json_type_validation_1.array)((0, json_type_validation_1.string)())), | ||
totalCountPath: (0, json_type_validation_1.object)({ | ||
type: (0, json_type_validation_1.union)((0, json_type_validation_1.constant)('headers'), (0, json_type_validation_1.constant)('body')), | ||
path: (0, json_type_validation_1.array)((0, json_type_validation_1.union)((0, json_type_validation_1.string)(), (0, json_type_validation_1.number)())), | ||
}), | ||
}); | ||
@@ -387,6 +407,6 @@ exports.stateDefinitionsDecoder = (0, json_type_validation_1.object)({ | ||
itemValuePath: (0, json_type_validation_1.optional)((0, json_type_validation_1.array)((0, json_type_validation_1.string)())), | ||
resourceMappers: (0, json_type_validation_1.optional)((0, json_type_validation_1.array)((0, json_type_validation_1.object)({ | ||
name: (0, json_type_validation_1.string)(), | ||
resource: exports.externaldependencyDecoder, | ||
}))), | ||
resource: (0, json_type_validation_1.optional)((0, json_type_validation_1.object)({ | ||
id: (0, json_type_validation_1.string)(), | ||
params: (0, json_type_validation_1.optional)((0, json_type_validation_1.dict)((0, json_type_validation_1.union)(exports.staticValueDecoder, exports.dyamicFunctionParam, exports.expressionValueDecoder))), | ||
})), | ||
}), | ||
@@ -403,11 +423,10 @@ }); | ||
}), | ||
resourceId: (0, json_type_validation_1.optional)((0, json_type_validation_1.string)()), | ||
statePersistanceName: (0, json_type_validation_1.optional)((0, json_type_validation_1.string)()), | ||
itemValuePath: (0, json_type_validation_1.optional)((0, json_type_validation_1.array)((0, json_type_validation_1.string)())), | ||
valuePath: (0, json_type_validation_1.optional)((0, json_type_validation_1.array)((0, json_type_validation_1.string)())), | ||
loopItemsReference: (0, json_type_validation_1.optional)(exports.attributeValueDecoder), | ||
resourceMappers: (0, json_type_validation_1.optional)((0, json_type_validation_1.array)((0, json_type_validation_1.object)({ | ||
name: (0, json_type_validation_1.string)(), | ||
resource: exports.externaldependencyDecoder, | ||
}))), | ||
loopItemsReference: (0, json_type_validation_1.optional)(exports.dynamicValueDecoder), | ||
resource: (0, json_type_validation_1.optional)((0, json_type_validation_1.object)({ | ||
id: (0, json_type_validation_1.string)(), | ||
params: (0, json_type_validation_1.optional)((0, json_type_validation_1.dict)((0, json_type_validation_1.union)(exports.staticValueDecoder, exports.dyamicFunctionParam, exports.expressionValueDecoder))), | ||
})), | ||
}), | ||
@@ -414,0 +433,0 @@ }); |
import { Decoder } from '@mojotech/json-type-validation'; | ||
import { VUIDLGlobalProjectValues, WebManifest, VProjectUIDL, ContextsUIDL, ContextUIDLItem, ResourcesUIDL, ResourceItemUIDL } from '@teleporthq/teleport-types'; | ||
import { VUIDLGlobalProjectValues, WebManifest, VProjectUIDL, UIDLResources } from '@teleporthq/teleport-types'; | ||
export declare const webManifestDecoder: Decoder<WebManifest>; | ||
export declare const globalProjectValuesDecoder: Decoder<VUIDLGlobalProjectValues>; | ||
export declare const contextItemDecoder: Decoder<ContextUIDLItem>; | ||
export declare const contextsDecoder: Decoder<ContextsUIDL>; | ||
export declare const projectResourceItemDecoder: Decoder<ResourceItemUIDL>; | ||
export declare const resourcesDecoder: Decoder<ResourcesUIDL>; | ||
export declare const resourcesDecoder: Decoder<UIDLResources>; | ||
export declare const projectUIDLDecoder: Decoder<VProjectUIDL>; | ||
//# sourceMappingURL=project-decoder.d.ts.map |
@@ -1,3 +0,3 @@ | ||
import { object, optional, string, dict, array, intersection, } from '@mojotech/json-type-validation'; | ||
import { globalAssetsDecoder, resourceDecoder } from './utils'; | ||
import { object, optional, string, dict, array, lazy, } from '@mojotech/json-type-validation'; | ||
import { dependencyDecoder, globalAssetsDecoder, resourceItemDecoder } from './utils'; | ||
import { componentUIDLDecoder, rootComponentUIDLDecoder } from './component-decoder'; | ||
@@ -30,17 +30,5 @@ export var webManifestDecoder = object({ | ||
}); | ||
export var contextItemDecoder = object({ | ||
name: string(), | ||
fileName: optional(string()), | ||
}); | ||
export var contextsDecoder = object({ | ||
rootFolder: optional(string()), | ||
items: dict(optional(contextItemDecoder)), | ||
}); | ||
export var projectResourceItemDecoder = intersection(resourceDecoder, object({ | ||
id: string(), | ||
name: string(), | ||
})); | ||
export var resourcesDecoder = object({ | ||
rootFolder: optional(string()), | ||
items: dict(optional(projectResourceItemDecoder)), | ||
resourceMappers: optional(dict(lazy(function () { return dependencyDecoder; }))), | ||
items: optional(dict(lazy(function () { return resourceItemDecoder; }))), | ||
}); | ||
@@ -52,5 +40,11 @@ export var projectUIDLDecoder = object({ | ||
components: optional(dict(componentUIDLDecoder)), | ||
contexts: optional(contextsDecoder), | ||
resources: optional(resourcesDecoder), | ||
contexts: optional(object({ | ||
rootFolder: string(), | ||
items: dict(object({ | ||
name: string(), | ||
fileName: optional(string()), | ||
})), | ||
})), | ||
}); | ||
//# sourceMappingURL=project-decoder.js.map |
import { Decoder } from '@mojotech/json-type-validation'; | ||
import { UIDLStaticValue, ReferenceType, UIDLDynamicReference, UIDLPropDefinition, UIDLStateDefinition, UIDLStateValueDetails, UIDLPageOptions, UIDLComponentOutputOptions, UIDLDependency, UIDLStyleDefinitions, UIDLStyleValue, UIDLAttributeValue, UIDLEventHandlerStatement, UIDLNavLinkNode, UIDLMailLinkNode, UIDLPhoneLinkNode, UIDLRawValue, UIDLElementStyleStates, UIDLStyleStateCondition, UIDLStyleMediaQueryScreenSizeCondition, UIDLStyleConditions, UIDLElementNodeProjectReferencedStyle, VUIDLComponentSEO, VUIDLGlobalAsset, UIDLExternalDependency, UIDLLocalDependency, UIDLPeerDependency, UIDLImportReference, UIDLStyleSetTokenReference, VUIDLStyleSetDefnition, VUIDLElement, VUIDLSlotNode, VUIDLConditionalNode, VUIDLRepeatNode, VUIDLElementNode, VUIDLNode, VUIDLElementNodeInlineReferencedStyle, VUIDLSectionLinkNode, VUIDLLinkNode, VUIDLURLLinkNode, VUIDLStyleSetConditions, VUIDLStyleSetMediaCondition, VUIDLStyleSetStateCondition, VUIDLDesignTokens, UIDLPropCallEvent, UIDLStateModifierEvent, UIDLScriptExternalAsset, UIDLScriptInlineAsset, VUIDLStyleInlineAsset, UIDLStyleExternalAsset, VUIDLFontAsset, UIDLCanonicalAsset, UIDLIconAsset, UIDLAssetBase, VUIDLElementNodeClassReferencedStyle, UIDLCompDynamicReference, UIDLComponentStyleReference, PagePaginationOptions, VCMSItemUIDLElementNode, VCMSListUIDLElementNode, Resource, InitialPropsData, InitialPathsData, UIDLExpressionValue, UIDLDynamicLinkNode } from '@teleporthq/teleport-types'; | ||
import { UIDLStaticValue, ReferenceType, UIDLDynamicReference, UIDLPropDefinition, UIDLStateDefinition, UIDLStateValueDetails, UIDLPageOptions, UIDLComponentOutputOptions, UIDLDependency, UIDLStyleDefinitions, UIDLStyleValue, UIDLAttributeValue, UIDLEventHandlerStatement, UIDLNavLinkNode, UIDLMailLinkNode, UIDLPhoneLinkNode, UIDLRawValue, UIDLElementStyleStates, UIDLStyleStateCondition, UIDLStyleMediaQueryScreenSizeCondition, UIDLStyleConditions, UIDLElementNodeProjectReferencedStyle, VUIDLComponentSEO, VUIDLGlobalAsset, UIDLExternalDependency, UIDLLocalDependency, UIDLPeerDependency, UIDLImportReference, UIDLStyleSetTokenReference, VUIDLStyleSetDefnition, VUIDLElement, VUIDLSlotNode, VUIDLConditionalNode, VUIDLRepeatNode, VUIDLElementNode, VUIDLNode, VUIDLElementNodeInlineReferencedStyle, VUIDLSectionLinkNode, VUIDLLinkNode, VUIDLURLLinkNode, VUIDLStyleSetConditions, VUIDLStyleSetMediaCondition, VUIDLStyleSetStateCondition, VUIDLDesignTokens, UIDLPropCallEvent, UIDLStateModifierEvent, UIDLScriptExternalAsset, UIDLScriptInlineAsset, VUIDLStyleInlineAsset, UIDLStyleExternalAsset, VUIDLFontAsset, UIDLCanonicalAsset, UIDLIconAsset, UIDLAssetBase, VUIDLElementNodeClassReferencedStyle, UIDLCompDynamicReference, UIDLComponentStyleReference, PagePaginationOptions, VCMSItemUIDLElementNode, VCMSListUIDLElementNode, UIDLInitialPathsData, UIDLInitialPropsData, UIDLExpressionValue, UIDLDynamicLinkNode, UIDLENVValue, UIDLPropValue, UIDLResourceItem } from '@teleporthq/teleport-types'; | ||
export declare const referenceTypeDecoder: Decoder<ReferenceType>; | ||
@@ -8,5 +8,7 @@ export declare const dynamicValueDecoder: Decoder<UIDLDynamicReference>; | ||
export declare const rawValueDecoder: Decoder<UIDLRawValue>; | ||
export declare const resourceDecoder: Decoder<Resource>; | ||
export declare const initialPropsDecoder: Decoder<InitialPropsData>; | ||
export declare const initialPathsDecoder: Decoder<InitialPathsData>; | ||
export declare const envValueDecoder: Decoder<UIDLENVValue>; | ||
export declare const dyamicFunctionParam: Decoder<UIDLPropValue>; | ||
export declare const resourceItemDecoder: Decoder<UIDLResourceItem>; | ||
export declare const initialPropsDecoder: Decoder<UIDLInitialPropsData>; | ||
export declare const initialPathsDecoder: Decoder<UIDLInitialPathsData>; | ||
export declare const styleSetMediaConditionDecoder: Decoder<VUIDLStyleSetMediaCondition>; | ||
@@ -13,0 +15,0 @@ export declare const styleSetStateConditionDecoder: Decoder<VUIDLStyleSetStateCondition>; |
@@ -1,5 +0,4 @@ | ||
import { object, string, dict, constant, number, optional, union, boolean, array, lazy, oneOf, intersection, unknownJson, withDefault, anyJson, } from '@mojotech/json-type-validation'; | ||
import { object, string, dict, constant, number, optional, union, boolean, array, lazy, oneOf, intersection, withDefault, anyJson, } from '@mojotech/json-type-validation'; | ||
import { CustomCombinators } from './custom-combinators'; | ||
var isValidComponentName = CustomCombinators.isValidComponentName, isValidFileName = CustomCombinators.isValidFileName, isValidElementName = CustomCombinators.isValidElementName, isValidNavLink = CustomCombinators.isValidNavLink; | ||
var resourceValueDecoder = union(object({ type: constant('static'), value: string() }), object({ type: constant('env'), value: string(), fallback: optional(string()) })); | ||
export var referenceTypeDecoder = union(constant('prop'), constant('state'), constant('local'), constant('attr'), constant('children'), constant('token'), constant('ctx')); | ||
@@ -27,9 +26,25 @@ export var dynamicValueDecoder = object({ | ||
}); | ||
var resourceUrlParamsDecoder = dict(union(staticValueDecoder, dynamicValueDecoder, expressionValueDecoder, array(union(staticValueDecoder, dynamicValueDecoder)))); | ||
export var resourceDecoder = object({ | ||
baseUrl: resourceValueDecoder, | ||
urlParams: optional(union(resourceUrlParamsDecoder, dict(resourceUrlParamsDecoder), unknownJson())), | ||
authToken: optional(resourceValueDecoder), | ||
route: optional(resourceValueDecoder), | ||
export var envValueDecoder = object({ | ||
type: constant('env'), | ||
content: string(), | ||
}); | ||
export var dyamicFunctionParam = object({ | ||
type: constant('dynamic'), | ||
content: object({ | ||
referenceType: constant('prop'), | ||
id: string(), | ||
}), | ||
}); | ||
export var resourceItemDecoder = object({ | ||
name: string(), | ||
headers: optional(dict(union(staticValueDecoder, envValueDecoder))), | ||
path: object({ | ||
baseUrl: union(staticValueDecoder, envValueDecoder), | ||
route: staticValueDecoder, | ||
}), | ||
method: withDefault('GET', union(constant('GET'), constant('POST'))), | ||
body: optional(dict(staticValueDecoder)), | ||
mappers: withDefault([], array(string())), | ||
params: optional(dict(union(staticValueDecoder, dyamicFunctionParam))), | ||
}); | ||
export var initialPropsDecoder = object({ | ||
@@ -41,7 +56,6 @@ exposeAs: object({ | ||
}), | ||
resourceMappers: optional(array(object({ | ||
name: string(), | ||
resource: lazy(function () { return externaldependencyDecoder; }), | ||
}))), | ||
resource: resourceDecoder, | ||
resource: object({ | ||
id: string(), | ||
params: optional(dict(union(staticValueDecoder, dyamicFunctionParam, expressionValueDecoder))), | ||
}), | ||
}); | ||
@@ -54,3 +68,6 @@ export var initialPathsDecoder = object({ | ||
}), | ||
resource: resourceDecoder, | ||
resource: object({ | ||
id: string(), | ||
params: optional(dict(union(staticValueDecoder, dyamicFunctionParam, expressionValueDecoder))), | ||
}), | ||
}); | ||
@@ -146,3 +163,6 @@ export var styleSetMediaConditionDecoder = object({ | ||
pageSize: number(), | ||
totalCountPath: optional(array(string())), | ||
totalCountPath: object({ | ||
type: union(constant('headers'), constant('body')), | ||
path: array(union(string(), number())), | ||
}), | ||
}); | ||
@@ -383,6 +403,6 @@ export var stateDefinitionsDecoder = object({ | ||
itemValuePath: optional(array(string())), | ||
resourceMappers: optional(array(object({ | ||
name: string(), | ||
resource: externaldependencyDecoder, | ||
}))), | ||
resource: optional(object({ | ||
id: string(), | ||
params: optional(dict(union(staticValueDecoder, dyamicFunctionParam, expressionValueDecoder))), | ||
})), | ||
}), | ||
@@ -399,11 +419,10 @@ }); | ||
}), | ||
resourceId: optional(string()), | ||
statePersistanceName: optional(string()), | ||
itemValuePath: optional(array(string())), | ||
valuePath: optional(array(string())), | ||
loopItemsReference: optional(attributeValueDecoder), | ||
resourceMappers: optional(array(object({ | ||
name: string(), | ||
resource: externaldependencyDecoder, | ||
}))), | ||
loopItemsReference: optional(dynamicValueDecoder), | ||
resource: optional(object({ | ||
id: string(), | ||
params: optional(dict(union(staticValueDecoder, dyamicFunctionParam, expressionValueDecoder))), | ||
})), | ||
}), | ||
@@ -410,0 +429,0 @@ }); |
{ | ||
"name": "@teleporthq/teleport-uidl-validator", | ||
"version": "0.27.4-alpha.0", | ||
"version": "0.27.5-alpha.0", | ||
"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.27.4-alpha.0", | ||
"@teleporthq/teleport-types": "^0.27.4-alpha.0" | ||
"@teleporthq/teleport-shared": "^0.27.5-alpha.0", | ||
"@teleporthq/teleport-types": "^0.27.5-alpha.0" | ||
}, | ||
"gitHead": "182513645c9074b0739b30e28a0a45d04805e72d" | ||
"gitHead": "46bbbd44f6b43dfdf9cfaf1c3428e9ee106eeecd" | ||
} |
@@ -8,3 +8,3 @@ import { | ||
array, | ||
intersection, | ||
lazy, | ||
} from '@mojotech/json-type-validation' | ||
@@ -15,8 +15,5 @@ import { | ||
VProjectUIDL, | ||
ContextsUIDL, | ||
ContextUIDLItem, | ||
ResourcesUIDL, | ||
ResourceItemUIDL, | ||
UIDLResources, | ||
} from '@teleporthq/teleport-types' | ||
import { globalAssetsDecoder, resourceDecoder } from './utils' | ||
import { dependencyDecoder, globalAssetsDecoder, resourceItemDecoder } from './utils' | ||
import { componentUIDLDecoder, rootComponentUIDLDecoder } from './component-decoder' | ||
@@ -54,25 +51,7 @@ | ||
export const contextItemDecoder: Decoder<ContextUIDLItem> = object({ | ||
name: string(), | ||
fileName: optional(string()), | ||
export const resourcesDecoder: Decoder<UIDLResources> = object({ | ||
resourceMappers: optional(dict(lazy(() => dependencyDecoder))), | ||
items: optional(dict(lazy(() => resourceItemDecoder))), | ||
}) | ||
export const contextsDecoder: Decoder<ContextsUIDL> = object({ | ||
rootFolder: optional(string()), | ||
items: dict(optional(contextItemDecoder)), | ||
}) | ||
export const projectResourceItemDecoder: Decoder<ResourceItemUIDL> = intersection( | ||
resourceDecoder, | ||
object({ | ||
id: string(), | ||
name: string(), | ||
}) | ||
) | ||
export const resourcesDecoder: Decoder<ResourcesUIDL> = object({ | ||
rootFolder: optional(string()), | ||
items: dict(optional(projectResourceItemDecoder)), | ||
}) | ||
export const projectUIDLDecoder: Decoder<VProjectUIDL> = object({ | ||
@@ -83,4 +62,14 @@ name: string(), | ||
components: optional(dict(componentUIDLDecoder)), | ||
contexts: optional(contextsDecoder), | ||
resources: optional(resourcesDecoder), | ||
contexts: optional( | ||
object({ | ||
rootFolder: string(), | ||
items: dict( | ||
object({ | ||
name: string(), | ||
fileName: optional(string()), | ||
}) | ||
), | ||
}) | ||
), | ||
}) |
@@ -15,3 +15,2 @@ import { | ||
intersection, | ||
unknownJson, | ||
withDefault, | ||
@@ -78,12 +77,12 @@ anyJson, | ||
UIDLComponentStyleReference, | ||
ResourceValue, | ||
ResourceUrlParams, | ||
PagePaginationOptions, | ||
VCMSItemUIDLElementNode, | ||
VCMSListUIDLElementNode, | ||
Resource, | ||
InitialPropsData, | ||
InitialPathsData, | ||
UIDLInitialPathsData, | ||
UIDLInitialPropsData, | ||
UIDLExpressionValue, | ||
UIDLDynamicLinkNode, | ||
UIDLENVValue, | ||
UIDLPropValue, | ||
UIDLResourceItem, | ||
} from '@teleporthq/teleport-types' | ||
@@ -95,7 +94,2 @@ import { CustomCombinators } from './custom-combinators' | ||
const resourceValueDecoder: Decoder<ResourceValue> = union( | ||
object({ type: constant('static'), value: string() }), | ||
object({ type: constant('env'), value: string(), fallback: optional(string()) }) | ||
) | ||
export const referenceTypeDecoder: Decoder<ReferenceType> = union( | ||
@@ -136,21 +130,29 @@ constant('prop'), | ||
const resourceUrlParamsDecoder: Decoder<ResourceUrlParams> = dict( | ||
union( | ||
staticValueDecoder, | ||
dynamicValueDecoder, | ||
expressionValueDecoder, | ||
array(union(staticValueDecoder, dynamicValueDecoder)) | ||
) | ||
) | ||
export const envValueDecoder: Decoder<UIDLENVValue> = object({ | ||
type: constant('env'), | ||
content: string(), | ||
}) | ||
export const resourceDecoder: Decoder<Resource> = object({ | ||
baseUrl: resourceValueDecoder, | ||
urlParams: optional( | ||
union(resourceUrlParamsDecoder, dict(resourceUrlParamsDecoder), unknownJson()) | ||
), | ||
authToken: optional(resourceValueDecoder), | ||
route: optional(resourceValueDecoder), | ||
export const dyamicFunctionParam: Decoder<UIDLPropValue> = object({ | ||
type: constant('dynamic'), | ||
content: object({ | ||
referenceType: constant('prop'), | ||
id: string(), | ||
}), | ||
}) | ||
export const initialPropsDecoder: Decoder<InitialPropsData> = object({ | ||
export const resourceItemDecoder: Decoder<UIDLResourceItem> = object({ | ||
name: string(), | ||
headers: optional(dict(union(staticValueDecoder, envValueDecoder))), | ||
path: object({ | ||
baseUrl: union(staticValueDecoder, envValueDecoder), | ||
route: staticValueDecoder, | ||
}), | ||
method: withDefault('GET', union(constant('GET'), constant('POST'))), | ||
body: optional(dict(staticValueDecoder)), | ||
mappers: withDefault([], array(string())), | ||
params: optional(dict(union(staticValueDecoder, dyamicFunctionParam))), | ||
}) | ||
export const initialPropsDecoder: Decoder<UIDLInitialPropsData> = object({ | ||
exposeAs: object({ | ||
@@ -161,14 +163,9 @@ name: string(), | ||
}), | ||
resourceMappers: optional( | ||
array( | ||
object({ | ||
name: string(), | ||
resource: lazy(() => externaldependencyDecoder), | ||
}) | ||
) | ||
), | ||
resource: resourceDecoder, | ||
resource: object({ | ||
id: string(), | ||
params: optional(dict(union(staticValueDecoder, dyamicFunctionParam, expressionValueDecoder))), | ||
}), | ||
}) | ||
export const initialPathsDecoder: Decoder<InitialPathsData> = object({ | ||
export const initialPathsDecoder: Decoder<UIDLInitialPathsData> = object({ | ||
exposeAs: object({ | ||
@@ -179,3 +176,6 @@ name: string(), | ||
}), | ||
resource: resourceDecoder, | ||
resource: object({ | ||
id: string(), | ||
params: optional(dict(union(staticValueDecoder, dyamicFunctionParam, expressionValueDecoder))), | ||
}), | ||
}) | ||
@@ -342,3 +342,6 @@ | ||
pageSize: number(), | ||
totalCountPath: optional(array(string())), | ||
totalCountPath: object({ | ||
type: union(constant('headers'), constant('body')), | ||
path: array(union(string(), number())), | ||
}), | ||
}) | ||
@@ -695,9 +698,9 @@ | ||
itemValuePath: optional(array(string())), | ||
resourceMappers: optional( | ||
array( | ||
object({ | ||
name: string(), | ||
resource: externaldependencyDecoder, | ||
}) | ||
) | ||
resource: optional( | ||
object({ | ||
id: string(), | ||
params: optional( | ||
dict(union(staticValueDecoder, dyamicFunctionParam, expressionValueDecoder)) | ||
), | ||
}) | ||
), | ||
@@ -716,14 +719,13 @@ }), | ||
}), | ||
resourceId: optional(string()), | ||
statePersistanceName: optional(string()), | ||
itemValuePath: optional(array(string())), | ||
valuePath: optional(array(string())), | ||
loopItemsReference: optional(attributeValueDecoder), | ||
resourceMappers: optional( | ||
array( | ||
object({ | ||
name: string(), | ||
resource: externaldependencyDecoder, | ||
}) | ||
) | ||
loopItemsReference: optional(dynamicValueDecoder), | ||
resource: optional( | ||
object({ | ||
id: string(), | ||
params: optional( | ||
dict(union(staticValueDecoder, dyamicFunctionParam, expressionValueDecoder)) | ||
), | ||
}) | ||
), | ||
@@ -730,0 +732,0 @@ }), |
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
489132
7964