raml-typesystem
Advanced tools
Comparing version 0.0.29-rc2 to 0.0.30
@@ -8,2 +8,3 @@ import tsInterfaces = require("./typesystem-interfaces"); | ||
export declare var USER_DEFINED_EXTRA: string; | ||
export declare var SOURCE_EXTRA: string; | ||
export declare function getSchemaUtils(): any; | ||
@@ -10,0 +11,0 @@ export interface IStatus { |
@@ -16,2 +16,3 @@ "use strict"; | ||
exports.USER_DEFINED_EXTRA = tsInterfaces.USER_DEFINED_EXTRA; | ||
exports.SOURCE_EXTRA = tsInterfaces.SOURCE_EXTRA; | ||
// export function instanceOfHasExtra(instance : nominalTypes.ITypeDefinition) : instance is IHasExtra { | ||
@@ -18,0 +19,0 @@ // returninstance instanceof ts.AbstractType || instance instanceof nominalTypes.AbstractType; |
@@ -138,2 +138,5 @@ "use strict"; | ||
} | ||
t.subTypes().forEach(function (x) { | ||
var ns = toNominal(x, callback, customizer); | ||
}); | ||
return vs; | ||
@@ -140,0 +143,0 @@ } |
@@ -648,2 +648,3 @@ "use strict"; | ||
} | ||
var hasfacetsOrOtherStuffDoesNotAllowedInExternals = null; | ||
n.children().forEach(function (x) { | ||
@@ -658,2 +659,3 @@ var key = x.key(); | ||
if (key === "repeat") { | ||
hasfacetsOrOtherStuffDoesNotAllowedInExternals = "repeat"; | ||
return; | ||
@@ -681,4 +683,8 @@ } | ||
if (key === "facets") { | ||
hasfacetsOrOtherStuffDoesNotAllowedInExternals = key; | ||
return; | ||
} | ||
if (key == "default" || key == "xml" || key == "required") { | ||
hasfacetsOrOtherStuffDoesNotAllowedInExternals = key; | ||
} | ||
if (key.charAt(0) == '(' && key.charAt(key.length - 1) == ')') { | ||
@@ -747,2 +753,4 @@ result.addMeta(new meta.Annotation(key.substr(1, key.length - 2), x.value())); | ||
actualResult.putExtra(ts.GLOBAL, global); | ||
actualResult.putExtra(ts.SOURCE_EXTRA, n); | ||
actualResult.putExtra(tsInterfaces.HAS_FACETS, hasfacetsOrOtherStuffDoesNotAllowedInExternals); | ||
return actualResult; | ||
@@ -749,0 +757,0 @@ } |
@@ -9,4 +9,8 @@ export interface IValidationPath { | ||
} | ||
export declare var TOP_LEVEL_EXTRA: string; | ||
export declare var DEFINED_IN_TYPES_EXTRA: string; | ||
export declare var USER_DEFINED_EXTRA: string; | ||
export declare const TOP_LEVEL_EXTRA: string; | ||
export declare const DEFINED_IN_TYPES_EXTRA: string; | ||
export declare const USER_DEFINED_EXTRA: string; | ||
export declare const SOURCE_EXTRA: string; | ||
export declare const SCHEMA_AND_TYPE_EXTRA: string; | ||
export declare const GLOBAL_EXTRA: string; | ||
export declare const HAS_FACETS: string; |
@@ -5,2 +5,6 @@ "use strict"; | ||
exports.USER_DEFINED_EXTRA = "USER_DEFINED"; | ||
exports.SOURCE_EXTRA = "SOURCE"; | ||
exports.SCHEMA_AND_TYPE_EXTRA = "SCHEMA"; | ||
exports.GLOBAL_EXTRA = "GLOBAL"; | ||
exports.HAS_FACETS = "HAS_FACETS"; | ||
//# sourceMappingURL=typesystem-interfaces.js.map |
@@ -38,2 +38,3 @@ /// <reference path="../../typings/main.d.ts" /> | ||
export declare const TOPLEVEL: string; | ||
export declare const SOURCE_EXTRA: string; | ||
export declare function error(message: string, source: any): Status; | ||
@@ -40,0 +41,0 @@ export declare abstract class TypeInformation { |
@@ -211,3 +211,15 @@ "use strict"; | ||
}); | ||
it("sub types information exists", function () { | ||
var tps = ps.parseJSONTypeCollection({ | ||
types: { | ||
A: { type: "object", properties: { "x": "string" } }, | ||
B: { type: "A" } | ||
} | ||
}, ts.builtInRegistry()); | ||
var tp = tps.getType("A"); | ||
var nt = nm.toNominal(tp, function (x) { return null; }); | ||
assert.isTrue(nt.subTypes().length == 1); | ||
assert.isTrue(nt.subTypes()[0].nameId() == "B"); | ||
}); | ||
}); | ||
//# sourceMappingURL=toNominalTests.js.map |
@@ -1705,3 +1705,33 @@ "use strict"; | ||
}); | ||
it("External with facets", function () { | ||
var tp = ps.parseJSONTypeCollection({ | ||
schemas: { | ||
T: '{ "type": "object"}', | ||
Hello: { | ||
type: "T", | ||
facets: { | ||
"zz": "number" | ||
} | ||
}, | ||
} | ||
}); | ||
var st = tp.getType("Hello").validateType(); | ||
assert.isTrue(!st.isOk()); | ||
assert.isTrue(st.getErrors().length == 1); | ||
}); | ||
it("External with facets", function () { | ||
var tp = ps.parseJSONTypeCollection({ | ||
schemas: { | ||
T: '{ "type": "object"}', | ||
Hello: { | ||
type: "T", | ||
xml: {} | ||
}, | ||
} | ||
}); | ||
var st = tp.getType("Hello").validateType(); | ||
assert.isTrue(!st.isOk()); | ||
assert.isTrue(st.getErrors().length == 1); | ||
}); | ||
}); | ||
//# sourceMappingURL=typeValidationTests.js.map |
{ | ||
"name": "raml-typesystem", | ||
"version": "0.0.29-rc2", | ||
"version": "0.0.30", | ||
"main": "dist/src/index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -20,2 +20,3 @@ import ts=require("./typesystem") | ||
export var USER_DEFINED_EXTRA = tsInterfaces.USER_DEFINED_EXTRA; | ||
export var SOURCE_EXTRA = tsInterfaces.SOURCE_EXTRA; | ||
@@ -22,0 +23,0 @@ // export function instanceOfHasExtra(instance : nominalTypes.ITypeDefinition) : instance is IHasExtra { |
@@ -161,4 +161,8 @@ import ts=require("./typesystem") | ||
} | ||
t.subTypes().forEach(x=>{ | ||
var ns=toNominal(x,callback,customizer); | ||
}) | ||
return vs; | ||
} | ||
@@ -701,2 +701,4 @@ import ts=require("./typesystem") | ||
} | ||
var hasfacetsOrOtherStuffDoesNotAllowedInExternals:string=null; | ||
n.children().forEach(x=>{ | ||
@@ -711,5 +713,7 @@ var key = x.key(); | ||
if (key==="repeat"){ | ||
hasfacetsOrOtherStuffDoesNotAllowedInExternals="repeat"; | ||
return; | ||
} | ||
if (key==="uses"){ | ||
//FIXME this should be handled depending from parse level | ||
@@ -735,4 +739,8 @@ return; | ||
if (key==="facets"){ | ||
hasfacetsOrOtherStuffDoesNotAllowedInExternals=key; | ||
return; | ||
} | ||
if (key=="default"||key=="xml"||key=="required"){ | ||
hasfacetsOrOtherStuffDoesNotAllowedInExternals=key; | ||
} | ||
if (key.charAt(0)=='('&& key.charAt(key.length-1)==')'){ | ||
@@ -802,3 +810,5 @@ result.addMeta(new meta.Annotation(key.substr(1, key.length-2), x.value())); | ||
actualResult.putExtra(ts.GLOBAL,global); | ||
actualResult.putExtra(ts.SOURCE_EXTRA, n); | ||
actualResult.putExtra(tsInterfaces.HAS_FACETS, hasfacetsOrOtherStuffDoesNotAllowedInExternals); | ||
return actualResult; | ||
} |
@@ -11,4 +11,8 @@ export interface IValidationPath{ | ||
export var TOP_LEVEL_EXTRA = "topLevel"; | ||
export var DEFINED_IN_TYPES_EXTRA = "definedInTypes"; | ||
export var USER_DEFINED_EXTRA = "USER_DEFINED"; | ||
export const TOP_LEVEL_EXTRA = "topLevel"; | ||
export const DEFINED_IN_TYPES_EXTRA = "definedInTypes"; | ||
export const USER_DEFINED_EXTRA = "USER_DEFINED"; | ||
export const SOURCE_EXTRA = "SOURCE"; | ||
export const SCHEMA_AND_TYPE_EXTRA="SCHEMA"; | ||
export const GLOBAL_EXTRA="GLOBAL"; | ||
export const HAS_FACETS="HAS_FACETS"; |
@@ -153,7 +153,7 @@ /// <reference path="../typings/main.d.ts" /> | ||
export const OK_STATUS=new Status(Status.OK,Status.OK,"",null); | ||
export const SCHEMA_AND_TYPE="SCHEMA" | ||
export const GLOBAL="GLOBAL" | ||
export const SCHEMA_AND_TYPE=tsInterfaces.SCHEMA_AND_TYPE_EXTRA; | ||
export const GLOBAL=tsInterfaces.GLOBAL_EXTRA; | ||
export const TOPLEVEL=tsInterfaces.TOP_LEVEL_EXTRA; | ||
export const SOURCE_EXTRA = tsInterfaces.SOURCE_EXTRA; | ||
export const TOPLEVEL="TOPLEVEL" | ||
export function error(message:string,source:any){ | ||
@@ -645,2 +645,10 @@ return new Status(Status.ERROR,0,message,source); | ||
} | ||
if (this.isExternal()){ | ||
if (this.getExtra(tsInterfaces.HAS_FACETS)){ | ||
var fs=new Status(Status.ERROR, 0, "External types can not declare facet '"+this.getExtra(tsInterfaces.HAS_FACETS)+"'",this); | ||
fs.setValidationPath({ name:this.getExtra(tsInterfaces.HAS_FACETS)}); | ||
rs.addSubStatus(fs); | ||
} | ||
} | ||
}; | ||
@@ -647,0 +655,0 @@ |
@@ -224,2 +224,16 @@ import ps= require("./actualParse") | ||
}); | ||
it("sub types information exists", function () { | ||
var tps = ps.parseJSONTypeCollection({ | ||
types:{ | ||
A: { type: "object",properties:{ "x":"string"}}, | ||
B: { type: "A"} | ||
} | ||
},ts.builtInRegistry()) | ||
var tp=tps.getType("A") | ||
var nt=nm.toNominal(tp,x=>null); | ||
assert.isTrue(nt.subTypes().length==1); | ||
assert.isTrue(nt.subTypes()[0].nameId()=="B"); | ||
}); | ||
}); |
@@ -1895,2 +1895,41 @@ import ps= require("./actualParse") | ||
}) | ||
it("External with facets", function () { | ||
var tp = ps.parseJSONTypeCollection({ | ||
schemas:{ | ||
T: '{ "type": "object"}', | ||
Hello:{ | ||
type: "T", | ||
facets:{ | ||
"zz" : "number" | ||
} | ||
}, | ||
} | ||
}) | ||
var st= tp.getType("Hello").validateType(); | ||
assert.isTrue(!st.isOk()); | ||
assert.isTrue(st.getErrors().length==1); | ||
}) | ||
it("External with facets", function () { | ||
var tp = ps.parseJSONTypeCollection({ | ||
schemas:{ | ||
T: '{ "type": "object"}', | ||
Hello:{ | ||
type: "T", | ||
xml:{ | ||
} | ||
}, | ||
} | ||
}) | ||
var st= tp.getType("Hello").validateType(); | ||
assert.isTrue(!st.isOk()); | ||
assert.isTrue(st.getErrors().length==1); | ||
}) | ||
}) |
@@ -6,3 +6,2 @@ { | ||
"gitUrl" : "https://github.com/raml-org/raml-js-parser-2.git", | ||
"gitBranch" : "rc2", | ||
"installTypings" : true | ||
@@ -13,3 +12,2 @@ }, | ||
"gitUrl" : "https://github.com/raml-org/raml-definition-system.git", | ||
"gitBranch" : "develop", | ||
"installTypings" : true | ||
@@ -21,3 +19,2 @@ }, | ||
"gitUrl" : "https://github.com/raml-org/typesystem-ts.git", | ||
"gitBranch" : "rc2", | ||
"installTypings" : true | ||
@@ -24,0 +21,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 too big to display
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1749457
39504
1