Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

raml-typesystem

Package Overview
Dependencies
Maintainers
2
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

raml-typesystem - npm Package Compare versions

Comparing version 0.0.86 to 0.0.87

16

dist/src/datetime.d.ts
import ts = require("./typesystem");
export declare class DateOnlyR extends ts.GenericTypeOf {
export declare class DateOnlyR extends ts.TypeOfRestriction {
constructor();
check(value: any): ts.Status;
requiredType(): ts.InheritedType;
value(): boolean;
facetName(): string;
}
export declare class TimeOnlyR extends ts.GenericTypeOf {
export declare class TimeOnlyR extends ts.TypeOfRestriction {
constructor();
check(value: any): ts.Status;
requiredType(): ts.InheritedType;
value(): boolean;
facetName(): string;
}
export declare class DateTimeOnlyR extends ts.GenericTypeOf {
export declare class DateTimeOnlyR extends ts.TypeOfRestriction {
constructor();
check(value: any): ts.Status;
requiredType(): ts.InheritedType;
value(): boolean;
facetName(): string;
}
export declare class DateTimeR extends ts.GenericTypeOf {
export declare class DateTimeR extends ts.TypeOfRestriction {
constructor();
check(value: any): ts.Status;
requiredType(): ts.InheritedType;
value(): boolean;
facetName(): string;
}

@@ -22,3 +22,3 @@ "use strict";

function DateOnlyR() {
return _super !== null && _super.apply(this, arguments) || this;
return _super.call(this, "date-only") || this;
}

@@ -37,5 +37,2 @@ DateOnlyR.prototype.check = function (value) {

};
DateOnlyR.prototype.value = function () {
return true;
};
DateOnlyR.prototype.facetName = function () {

@@ -45,3 +42,3 @@ return "should be date-only";

return DateOnlyR;
}(ts.GenericTypeOf));
}(ts.TypeOfRestriction));
exports.DateOnlyR = DateOnlyR;

@@ -61,3 +58,3 @@ function checkTime(time) {

function TimeOnlyR() {
return _super !== null && _super.apply(this, arguments) || this;
return _super.call(this, "time-only") || this;
}

@@ -82,5 +79,2 @@ TimeOnlyR.prototype.check = function (value) {

};
TimeOnlyR.prototype.value = function () {
return true;
};
TimeOnlyR.prototype.facetName = function () {

@@ -90,3 +84,3 @@ return "should be time-only";

return TimeOnlyR;
}(ts.GenericTypeOf));
}(ts.TypeOfRestriction));
exports.TimeOnlyR = TimeOnlyR;

@@ -96,3 +90,3 @@ var DateTimeOnlyR = /** @class */ (function (_super) {

function DateTimeOnlyR() {
return _super !== null && _super.apply(this, arguments) || this;
return _super.call(this, "datetime-only") || this;
}

@@ -118,5 +112,2 @@ DateTimeOnlyR.prototype.check = function (value) {

};
DateTimeOnlyR.prototype.value = function () {
return true;
};
DateTimeOnlyR.prototype.facetName = function () {

@@ -126,3 +117,3 @@ return "should be datetime-only";

return DateTimeOnlyR;
}(ts.GenericTypeOf));
}(ts.TypeOfRestriction));
exports.DateTimeOnlyR = DateTimeOnlyR;

@@ -136,3 +127,3 @@ var r1 = /(Mon|Tue|Wed|Thu|Fri|Sat|Sun)\,[ ]+\d{2}[ ]+(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[ ]+\d{4}[ ]+\d{2}:\d{2}:\d{2}[ ]+GMT/;

function DateTimeR() {
return _super !== null && _super.apply(this, arguments) || this;
return _super.call(this, "datetime") || this;
}

@@ -176,10 +167,7 @@ DateTimeR.prototype.check = function (value) {

};
DateTimeR.prototype.value = function () {
return true;
};
DateTimeR.prototype.facetName = function () {
return "should be datetime-only";
return "should be datetime";
};
return DateTimeR;
}(ts.GenericTypeOf));
}(ts.TypeOfRestriction));
exports.DateTimeR = DateTimeR;

@@ -186,0 +174,0 @@ function checkDateOnlyString(dateStr, dateFormat) {

@@ -14,2 +14,3 @@ export import tsInterfaces = require("./typesystem-interfaces");

export declare var SOURCE_EXTRA: string;
export declare let messageRegistry: any;
export declare function getSchemaUtils(): any;

@@ -225,3 +226,3 @@ export declare type IStatus = tsInterfaces.IStatus;

*/
export declare function parseFromAST(data: IParseNode): IParsedTypeCollection;
export declare function parseFromAST(data: IParseNode, ignoreUses?: boolean): IParsedTypeCollection;
/**

@@ -228,0 +229,0 @@ * parses type collection definition from a JSON structure

@@ -20,2 +20,3 @@ "use strict";

exports.SOURCE_EXTRA = exports.tsInterfaces.SOURCE_EXTRA;
exports.messageRegistry = require("../../resources/errorMessages");
// export function instanceOfHasExtra(instance : nominalTypes.ITypeDefinition) : instance is IHasExtra {

@@ -89,4 +90,5 @@ // returninstance instanceof ts.AbstractType || instance instanceof nominalTypes.AbstractType;

*/
function parseFromAST(data) {
return tc.parseTypeCollection(data, ts.builtInRegistry());
function parseFromAST(data, ignoreUses) {
if (ignoreUses === void 0) { ignoreUses = false; }
return tc.parseTypeCollection(data, ts.builtInRegistry(), ignoreUses);
}

@@ -116,3 +118,3 @@ exports.parseFromAST = parseFromAST;

}
return tc.parse(name, data, collection ? collection.getTypeRegistry() : ts.builtInRegistry(), defaultsToAny, annotation, global, ignoreTypeAttr);
return tc.parse(name, data, collection ? collection.getTypeRegistry() : ts.builtInRegistry(), defaultsToAny, annotation, global, ignoreTypeAttr, false, []);
}

@@ -119,0 +121,0 @@ exports.parseTypeFromAST = parseTypeFromAST;

@@ -587,5 +587,5 @@ "use strict";

var _this = this;
if (typeof this.value() === 'object') {
var v = this.value();
if (typeof v === 'object' && (v == null || !Array.isArray(v))) {
var rs = new typesystem_1.Status(typesystem_1.Status.OK, "", "", this);
var v = this.value();
if (v) {

@@ -636,3 +636,3 @@ Object.keys(v).forEach(function (x) {

else {
return ts.error(messageRegistry.EXMAPLES_MAP, this);
return ts.error(messageRegistry.EXMAPLES_MAP, this, {}, typesystem_1.Status.ERROR, true);
}

@@ -639,0 +639,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ts = require("./typesystem");
var tsInterfaces = require("./typesystem-interfaces");
var nt = require("./nominal-types");

@@ -181,2 +182,5 @@ var parse = require("./parse");

vs.addAdapter(t);
if (!t.isBuiltin()) {
vs.putExtra(tsInterfaces.USER_DEFINED_EXTRA, true);
}
if (t.isEmpty()) {

@@ -183,0 +187,0 @@ vs.addAdapter(new nt.Empty());

@@ -35,3 +35,3 @@ import ts = require("./typesystem");

}[];
add(t: ts.AbstractType): void;
add(t: ts.AbstractType, typePath: string[]): void;
}

@@ -74,4 +74,4 @@ export declare class TypeCollection {

export declare function parseTypes(n: any, tr?: ts.TypeRegistry): TypeCollection;
export declare function parseTypeCollection(n: ParseNode, tr: ts.TypeRegistry): TypeCollection;
export declare function parsePropertyBean(n: ParseNode, tr: ts.TypeRegistry): PropertyBean;
export declare function parseTypeCollection(n: ParseNode, tr: ts.TypeRegistry, ignoreUses?: boolean): TypeCollection;
export declare function parsePropertyBean(n: ParseNode, tr: ts.TypeRegistry, typePath: string[]): PropertyBean;
export declare class TypeProto {

@@ -102,2 +102,2 @@ name: string;

*/
export declare function parse(name: string, n: ParseNode, r?: ts.TypeRegistry, defaultsToAny?: boolean, annotation?: boolean, global?: boolean, ignoreTypeAttr?: boolean, isPropertyType?: boolean): ts.AbstractType;
export declare function parse(name: string, n: ParseNode, r: ts.TypeRegistry, defaultsToAny: boolean, annotation: boolean, global: boolean, ignoreTypeAttr: boolean, isPropertyType: boolean, typePath: string[]): ts.AbstractType;

@@ -99,3 +99,3 @@ "use strict";

if (r === void 0) { r = ts.builtInRegistry(); }
return parse(name, new JSObjectNode(null, n, false, provider), r);
return parse(name, new JSObjectNode(null, n, false, provider), r, false, false, true, false, false, []);
}

@@ -114,3 +114,5 @@ exports.parseJSON = parseJSON;

}
PropertyBean.prototype.add = function (t) {
PropertyBean.prototype.add = function (t, typePath) {
// const p = typePath.concat(this.id).join(", ");
// console.log(p);
if (!this.optional && !this.additonal && !this.regExp && !this.type.isSubTypeOf(ts.NIL)) {

@@ -259,3 +261,3 @@ t.addMeta(new rs.HasProperty(this.id));

try {
var tp = parse(name, chld, this);
var tp = parse(name, chld, this, false, false, true, false, false, []);
}

@@ -336,3 +338,4 @@ finally {

}
function parseTypeCollection(n, tr) {
function parseTypeCollection(n, tr, ignoreUses) {
if (ignoreUses === void 0) { ignoreUses = false; }
var result = new TypeCollection(n.path());

@@ -368,11 +371,13 @@ if (n.anchor) {

}
var uses = n.childWithKey("uses");
if (uses && uses.kind() === NodeKind.ARRAY) {
uses = transformToArray(uses);
if (!ignoreUses) {
var uses = n.childWithKey("uses");
if (uses && uses.kind() === NodeKind.ARRAY) {
uses = transformToArray(uses);
}
if (uses && uses.kind() === NodeKind.MAP) {
uses.children().forEach(function (c) {
result.addLibrary(c.key(), parseTypeCollection(c, tr));
});
}
}
if (uses && uses.kind() === NodeKind.MAP) {
uses.children().forEach(function (c) {
result.addLibrary(c.key(), parseTypeCollection(c, tr));
});
}
if (tpes && tpes.kind() !== NodeKind.SCALAR) {

@@ -395,3 +400,3 @@ tpes.children().filter(function (x) { return x.key() && true; }).forEach(function (x) {

tpes.children().forEach(function (x) {
result.addAnnotationType(parse(x.key(), x, reg, false, true, false));
result.addAnnotationType(parse(x.key(), x, reg, false, true, false, false, false, []));
});

@@ -402,3 +407,3 @@ }

exports.parseTypeCollection = parseTypeCollection;
function parsePropertyBean(n, tr) {
function parsePropertyBean(n, tr, typePath) {
var result = new PropertyBean();

@@ -446,3 +451,5 @@ var hasRequiredFacet = false;

}
result.type = parse(null, n, tr, false, false, false, false, true);
var tp1 = [].concat(typePath);
tp1.push(name);
result.type = parse(null, n, tr, false, false, false, false, true, tp1);
var chainingData = n.getMeta("chaining");

@@ -777,9 +784,7 @@ if (chainingData && chainingData.length > 0) {

*/
function parse(name, n, r, defaultsToAny, annotation, global, ignoreTypeAttr, isPropertyType) {
function parse(name, n, r, defaultsToAny, annotation, global, ignoreTypeAttr, isPropertyType, typePath) {
if (r === void 0) { r = ts.builtInRegistry(); }
if (defaultsToAny === void 0) { defaultsToAny = false; }
if (annotation === void 0) { annotation = false; }
if (global === void 0) { global = true; }
if (ignoreTypeAttr === void 0) { ignoreTypeAttr = false; }
if (isPropertyType === void 0) { isPropertyType = false; }
if (typePath.length == 0) {
typePath = [name];
}
//mentioning fragment' uses

@@ -933,3 +938,5 @@ var uses = n.childWithKey("uses");

else if (tp.kind() == NodeKind.MAP) {
superTypes = [parse("", tp, r, false, false, false)];
var tp1 = [].concat(typePath);
tp1.push("#super");
superTypes = [parse("", tp, r, false, false, false, false, false, tp1)];
}

@@ -966,3 +973,3 @@ if (sAnnotations.length > 0 && sAnnotations.filter(function (x) { return x.length > 0; }).length > 0) {

}
if (AccumulatingRegistry.isInstance(r)) {
if (name != null && name.length > 0 && AccumulatingRegistry.isInstance(r)) {
result = contributeToAccumulatingRegistry(result, r);

@@ -1025,3 +1032,5 @@ }

else if (y.kind() == NodeKind.MAP) {
return parse("", y, r, false, false, false);
var tp1 = [].concat(typePath);
tp1.push("#super");
return parse("", y, r, false, false, false, false, false, tp1);
}

@@ -1094,3 +1103,5 @@ });

hasProps = true;
parsePropertyBean(x, r).add(result);
var tp1 = [].concat(typePath);
tp1.push("#props");
parsePropertyBean(x, r, tp1).add(result, tp1);
});

@@ -1124,3 +1135,5 @@ }

props.children().forEach(function (x) {
var bean = parsePropertyBean(x, r);
var tp1 = [].concat(typePath);
tp1.push("#facets");
var bean = parsePropertyBean(x, r, tp1);
result.addMeta(new meta.FacetDeclaration(bean.id, bean.type, bean.optional));

@@ -1127,0 +1140,0 @@ });

@@ -578,7 +578,6 @@ import su = require("./schemaUtil");

}
export declare class NullRestriction extends GenericTypeOf {
export declare class NullRestriction extends TypeOfRestriction {
constructor();
check(i: any): Status;
requiredType(): RootType;
value(): boolean;
facetName(): string;

@@ -585,0 +584,0 @@ }

{
"name": "raml-typesystem",
"version": "0.0.86",
"version": "0.0.87",
"main": "dist/src/index.js",

@@ -5,0 +5,0 @@ "scripts": {

@@ -15,3 +15,6 @@ declare function require(path:string):any

export class DateOnlyR extends ts.GenericTypeOf{
export class DateOnlyR extends ts.TypeOfRestriction{
constructor(){
super("date-only")
}
check(value:any):ts.Status {

@@ -29,5 +32,2 @@ if (typeof value=="string"){

}
value(){
return true;
}
facetName(){

@@ -52,3 +52,6 @@ return "should be date-only"

export class TimeOnlyR extends ts.GenericTypeOf{
export class TimeOnlyR extends ts.TypeOfRestriction{
constructor(){
super("time-only")
}
check(value:any):ts.Status {

@@ -74,5 +77,2 @@ if (typeof value=="string"){

}
value(){
return true;
}
facetName(){

@@ -82,3 +82,8 @@ return "should be time-only"

}
export class DateTimeOnlyR extends ts.GenericTypeOf{
export class DateTimeOnlyR extends ts.TypeOfRestriction{
constructor(){
super("datetime-only")
}
check(value:any):ts.Status {

@@ -105,5 +110,2 @@ if (typeof value=="string"){

}
value(){
return true;
}
facetName(){

@@ -120,3 +122,6 @@ return "should be datetime-only"

var r0=/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})(?:\.\d+)?((?:[\+\-]\d{2}:\d{2})|Z)$/;
export class DateTimeR extends ts.GenericTypeOf{
export class DateTimeR extends ts.TypeOfRestriction{
constructor(){
super("datetime")
}
check(value:any):ts.Status {

@@ -160,7 +165,4 @@ var c=ts.VALIDATED_TYPE;

}
value(){
return true;
}
facetName(){
return "should be datetime-only"
return "should be datetime"
}

@@ -167,0 +169,0 @@ }

@@ -25,2 +25,3 @@ import ts=require("./typesystem")

export var SOURCE_EXTRA = tsInterfaces.SOURCE_EXTRA;
export let messageRegistry = require("../../resources/errorMessages");

@@ -297,4 +298,4 @@ // export function instanceOfHasExtra(instance : nominalTypes.ITypeDefinition) : instance is IHasExtra {

*/
export function parseFromAST(data:IParseNode):IParsedTypeCollection {
return tc.parseTypeCollection(<any>data, ts.builtInRegistry());
export function parseFromAST(data:IParseNode,ignoreUses=false):IParsedTypeCollection {
return tc.parseTypeCollection(<any>data, ts.builtInRegistry(),ignoreUses);
}

@@ -326,3 +327,3 @@ /**

}
return tc.parse(name,<any>data,collection? <ts.TypeRegistry>collection.getTypeRegistry():ts.builtInRegistry(),defaultsToAny,annotation,global,ignoreTypeAttr);
return tc.parse(name,<any>data,collection? <ts.TypeRegistry>collection.getTypeRegistry():ts.builtInRegistry(),defaultsToAny,annotation,global,ignoreTypeAttr, false, []);
}

@@ -329,0 +330,0 @@ /**

@@ -614,5 +614,5 @@ import ts=require("./typesystem");

validateSelfIndividual(parentStatus:ts.Status,registry:ts.TypeRegistry):ts.Status {
if (typeof this.value()==='object'){
var v=this.value();
if (typeof v==='object' && (v==null||!Array.isArray(v))){
var rs=new Status(Status.OK,"","",this);
var v=this.value();
if (v) {

@@ -665,3 +665,3 @@ Object.keys(v).forEach(x=> {

else{
return ts.error(messageRegistry.EXMAPLES_MAP,this);
return ts.error(messageRegistry.EXMAPLES_MAP,this,{},Status.ERROR,true);
}

@@ -668,0 +668,0 @@ }

import ts=require("./typesystem")
import tsInterfaces=require("./typesystem-interfaces")
import nt=require("./nominal-types")

@@ -201,2 +202,5 @@ import parse=require("./parse")

vs.addAdapter(t);
if(!t.isBuiltin()) {
vs.putExtra(tsInterfaces.USER_DEFINED_EXTRA, true)
}
if (t.isEmpty()){

@@ -203,0 +207,0 @@ vs.addAdapter(new nt.Empty());

@@ -111,3 +111,3 @@ import ts=require("./typesystem");

export function parseJSON(name: string,n:any,r:ts.TypeRegistry=ts.builtInRegistry(), provider?: su.IContentProvider):ts.AbstractType {
return parse(name,new JSObjectNode(null,n, false, provider),r);
return parse(name,new JSObjectNode(null,n, false, provider),r,false,false,true,false,false,[]);
}

@@ -133,3 +133,5 @@ export function parseJSONTypeCollection(n:any,r:ts.TypeRegistry=ts.builtInRegistry(), provider?: su.IContentProvider):TypeCollection {

add(t:ts.AbstractType){
add(t:ts.AbstractType,typePath:string[]){
// const p = typePath.concat(this.id).join(", ");
// console.log(p);
if (!this.optional&&!this.additonal&&!this.regExp&&!this.type.isSubTypeOf(ts.NIL)){

@@ -290,3 +292,3 @@ t.addMeta(new rs.HasProperty(this.id));

try {
var tp = parse(name, chld, this);
var tp = parse(name, chld, this,false,false,true,false,false,[]);
}

@@ -373,3 +375,3 @@ finally {

export function parseTypeCollection(n:ParseNode,tr:ts.TypeRegistry):TypeCollection{
export function parseTypeCollection(n:ParseNode,tr:ts.TypeRegistry,ignoreUses=false):TypeCollection{
var result=new TypeCollection(n.path());

@@ -408,12 +410,13 @@ if (n.anchor){

}
var uses=n.childWithKey("uses");
if (uses&&uses.kind()===NodeKind.ARRAY){
uses=transformToArray(uses);
if(!ignoreUses) {
var uses=n.childWithKey("uses");
if (uses&&uses.kind()===NodeKind.ARRAY){
uses=transformToArray(uses);
}
if (uses&&uses.kind()===NodeKind.MAP){
uses.children().forEach(c=>{
result.addLibrary(c.key(),parseTypeCollection(c,tr));
})
}
}
if (uses&&uses.kind()===NodeKind.MAP){
uses.children().forEach(c=>{
result.addLibrary(c.key(),parseTypeCollection(c,tr));
})
}

@@ -437,3 +440,3 @@ if (tpes&&tpes.kind()!==NodeKind.SCALAR){

tpes.children().forEach(x=>{
result.addAnnotationType(parse(x.key(),x,reg,false,true,false))
result.addAnnotationType(parse(x.key(),x,reg,false,true,false, false,false,[]))
});

@@ -445,3 +448,3 @@ }

export function parsePropertyBean(n:ParseNode,tr:ts.TypeRegistry):PropertyBean{
export function parsePropertyBean(n:ParseNode,tr:ts.TypeRegistry,typePath:string[]):PropertyBean{
var result=new PropertyBean();

@@ -490,3 +493,5 @@ var hasRequiredFacet = false;

}
result.type=parse(null, n,tr,false,false,false, false, true);
let tp1 = [].concat(typePath)
tp1.push(name)
result.type=parse(null, n,tr,false,false,false, false, true, tp1);
let chainingData = <meta.ChainingData[]>n.getMeta("chaining");

@@ -849,8 +854,12 @@ if(chainingData && chainingData.length>0){

r:ts.TypeRegistry=ts.builtInRegistry(),
defaultsToAny:boolean=false,
annotation:boolean=false,
global:boolean=true,
ignoreTypeAttr:boolean=false,
isPropertyType=false):ts.AbstractType{
defaultsToAny:boolean,
annotation:boolean,
global:boolean,
ignoreTypeAttr:boolean,
isPropertyType:boolean,
typePath:string[]):ts.AbstractType{
if(typePath.length==0){
typePath = [ name ]
}
//mentioning fragment' uses

@@ -1006,3 +1015,5 @@ var uses=n.childWithKey("uses");

else if (tp.kind()==NodeKind.MAP){
superTypes=[parse("",tp,r,false,false,false)];
let tp1 = [].concat(typePath)
tp1.push("#super")
superTypes=[parse("",tp,r,false,false,false, false, false, tp1)];
}

@@ -1036,3 +1047,3 @@ if(sAnnotations.length>0 && sAnnotations.filter(x=>x.length>0).length>0) {

}
if (AccumulatingRegistry.isInstance(r)){
if (name != null && name.length > 0 && AccumulatingRegistry.isInstance(r)){
result = contributeToAccumulatingRegistry(result, r);

@@ -1099,3 +1110,5 @@ }

else if (y.kind()==NodeKind.MAP){
return parse("",y,r,false,false,false);
let tp1 = [].concat(typePath)
tp1.push("#super")
return parse("",y,r,false,false,false, false, false,tp1);
}

@@ -1169,3 +1182,5 @@ });

hasProps = true;
parsePropertyBean(x, r).add(result);
let tp1 = [].concat(typePath)
tp1.push("#props")
parsePropertyBean(x, r,tp1).add(result,tp1);
});

@@ -1201,3 +1216,5 @@ }

props.children().forEach(x=>{
var bean=parsePropertyBean(x,r);
let tp1 = [].concat(typePath)
tp1.push("#facets")
var bean=parsePropertyBean(x,r,tp1);
result.addMeta(new meta.FacetDeclaration(bean.id,bean.type,bean.optional));

@@ -1204,0 +1221,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 too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc