flatspecSpec.js 2.62 KB
// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See https://js.arcgis.com/4.6/esri/copyright.txt for details.
//>>built
define(["require","exports","./schema","../core/promiseUtils"],function(v,n,f,t){function r(a,b,c,d){var l=[],e;a:{if(b.properties){if("layerType"in b.properties){e=b.properties.layerType.enum[0];break a}if("type"in b.properties){e=b.properties.type.enum[0];break a}}e=void 0}e&&/<\?TYPE\?>/.test(c)?c=c.replace("?TYPE?",e):c.indexOf("\x3c?TYPE?\x3e")&&(c=c.replace("\x3c?TYPE?\x3e",""));d.classPaths&&(d.classPaths[c]=a);0<d.schemaPath.indexOf(a)?l.push({path:c,type:"LOOP0!"}):(d.schemaPath.push(a),
l=p(b,c,d),d.schemaPath.pop());return l}function u(a,b,c){a=a.$ref.replace("#/definitions/","");return r(a,c.definitions[a],b,c)}function p(a,b,c){var d=[],l=c.filteredProperties;c.filteredProperties=null;if("array"===a.type)d=d.concat(p(a.items,b+"[]",c));else if("properties"in a)for(var e in a.properties){if(!l||l.has(e))d=d.concat(p(a.properties[e],b?b+"."+e:e,c))}else if("allOf"in a){var g=null,h=new Set;e=0;for(a=a.allOf;e<a.length;e++){var k=a[e];if("$ref"in k){if(g)throw Error("Cannot process more than 1 ref in an allOf construct");
g=k}else if("properties"in k)for(var f in k.properties)h.add(f);else throw Error("allOf construct only allows simple top-level property filters");}a=c.filteredProperties;c.filteredProperties=h;d=d.concat(u(g,b,c));c.filteredProperties=a}else if("oneOf"in a){f=a.oneOf;e=f.length;var n=k=0,q=[],m="";for(h in f)m=f[h],m.$ref?k++:m.type&&n++;q=Object.keys(q);m=k===e?"refs":2===e&&0<k&&1===q.length&&"null"===q[0]?"refsAndNull":n===e?"types":"mix";if("refs"===m||"refsAndNull"===m)for(g in a.oneOf)"null"!==
a.oneOf[g].type&&(h="\x3c?TYPE?\x3e",d=d.concat(p(a.oneOf[g],""+b+h,c)));else if("types"===m)d.push({path:b,type:q.join("|")});else for(g in a.oneOf)h=".oneOf["+g+"]",d=d.concat(p(a.oneOf[g],""+b+h,c))}else"$ref"in a?d=d.concat(u(a,b,c)):(g="unknown",a.type&&(g=Array.isArray(a.type)?a.type.join("|"):a.type.replace(/ /g,"").split(",").join("|")),b={path:b,type:g},a.enum&&(b.enum=a.enum.join("|")),d.push(b));c.filteredProperties=l;return d}Object.defineProperty(n,"__esModule",{value:!0});n.scan=function(a){var b=
r(a||"webScene",a?f.json.definitions[a+"_schema.json"]:f.json,"",{definitions:f.json.definitions,schemaPath:[]});b.sort(function(a,b){return a.path.localeCompare(b.path)});return t.resolve(b.filter(function(a,d){return 0===d||b[d-1].path!==a.path}))};n.collectClassPaths=function(a){var b={definitions:f.json.definitions,schemaPath:[],classPaths:{}};r(a||"webScene",a?f.json.definitions[a+"_schema.json"]:f.json,"",b);return t.resolve(b.classPaths)}});