@loopback/repository-json-schema 4.0.0-alpha.7 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +15 -10
- package/dist/build-schema.d.ts +137 -0
- package/dist/build-schema.js +445 -0
- package/dist/build-schema.js.map +1 -0
- package/dist/filter-json-schema.d.ts +54 -0
- package/dist/filter-json-schema.js +198 -0
- package/dist/filter-json-schema.js.map +1 -0
- package/dist/index.d.ts +36 -1
- package/dist/index.js +18 -7
- package/dist/index.js.map +1 -0
- package/dist/keys.d.ts +8 -0
- package/dist/keys.js +13 -0
- package/dist/keys.js.map +1 -0
- package/package.json +42 -33
- package/src/build-schema.ts +491 -79
- package/src/filter-json-schema.ts +237 -0
- package/src/index.ts +42 -1
- package/src/keys.ts +15 -0
- package/CHANGELOG.md +0 -75
- package/api-docs/apple-touch-icon-114x114-precomposed.png +0 -0
- package/api-docs/apple-touch-icon-144x144-precomposed.png +0 -0
- package/api-docs/apple-touch-icon-57x57-precomposed.png +0 -0
- package/api-docs/apple-touch-icon-72x72-precomposed.png +0 -0
- package/api-docs/apple-touch-icon-precomposed.png +0 -0
- package/api-docs/apple-touch-icon.png +0 -0
- package/api-docs/css/bootstrap.min.css +0 -9
- package/api-docs/css/code-themes/arta.css +0 -158
- package/api-docs/css/code-themes/ascetic.css +0 -50
- package/api-docs/css/code-themes/brown_paper.css +0 -104
- package/api-docs/css/code-themes/brown_papersq.png +0 -0
- package/api-docs/css/code-themes/dark.css +0 -103
- package/api-docs/css/code-themes/default.css +0 -135
- package/api-docs/css/code-themes/far.css +0 -111
- package/api-docs/css/code-themes/github.css +0 -127
- package/api-docs/css/code-themes/googlecode.css +0 -144
- package/api-docs/css/code-themes/idea.css +0 -121
- package/api-docs/css/code-themes/ir_black.css +0 -104
- package/api-docs/css/code-themes/magula.css +0 -121
- package/api-docs/css/code-themes/monokai.css +0 -114
- package/api-docs/css/code-themes/pojoaque.css +0 -104
- package/api-docs/css/code-themes/pojoaque.jpg +0 -0
- package/api-docs/css/code-themes/rainbow.css +0 -114
- package/api-docs/css/code-themes/school_book.css +0 -111
- package/api-docs/css/code-themes/school_book.png +0 -0
- package/api-docs/css/code-themes/sl-theme.css +0 -45
- package/api-docs/css/code-themes/solarized_dark.css +0 -88
- package/api-docs/css/code-themes/solarized_light.css +0 -88
- package/api-docs/css/code-themes/sunburst.css +0 -158
- package/api-docs/css/code-themes/tomorrow-night-blue.css +0 -52
- package/api-docs/css/code-themes/tomorrow-night-bright.css +0 -51
- package/api-docs/css/code-themes/tomorrow-night-eighties.css +0 -51
- package/api-docs/css/code-themes/tomorrow-night.css +0 -52
- package/api-docs/css/code-themes/tomorrow.css +0 -49
- package/api-docs/css/code-themes/vs.css +0 -86
- package/api-docs/css/code-themes/xcode.css +0 -154
- package/api-docs/css/code-themes/zenburn.css +0 -115
- package/api-docs/css/main.css +0 -139
- package/api-docs/favicon.ico +0 -0
- package/api-docs/fonts/0ihfXUL2emPh0ROJezvraLO3LdcAZYWl9Si6vvxL-qU.woff +0 -0
- package/api-docs/fonts/OsJ2DjdpjqFRVUSto6IffLO3LdcAZYWl9Si6vvxL-qU.woff +0 -0
- package/api-docs/fonts/_aijTyevf54tkVDLy-dlnLO3LdcAZYWl9Si6vvxL-qU.woff +0 -0
- package/api-docs/index.html +0 -53
- package/api-docs/js/main.js +0 -19
- package/api-docs/js/vendor/bootstrap.min.js +0 -6
- package/api-docs/js/vendor/jquery-1.10.1.min.js +0 -6
- package/api-docs/js/vendor/jquery.scrollTo-1.4.3.1.js +0 -218
- package/api-docs/js/vendor/modernizr-2.6.2-respond-1.1.0.min.js +0 -11
- package/dist/src/build-schema.d.ts +0 -50
- package/dist/src/build-schema.js +0 -143
- package/dist/src/build-schema.js.map +0 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +0 -11
- package/dist/src/index.js.map +0 -1
- package/index.d.ts +0 -6
- package/index.js +0 -6
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* jQuery.ScrollTo
|
|
3
|
-
* Copyright (c) 2007-2012 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
|
|
4
|
-
* Dual licensed under MIT and GPL.
|
|
5
|
-
* Date: 4/09/2012
|
|
6
|
-
*
|
|
7
|
-
* @projectDescription Easy element scrolling using jQuery.
|
|
8
|
-
* http://flesler.blogspot.com/2007/10/jqueryscrollto.html
|
|
9
|
-
* @author Ariel Flesler
|
|
10
|
-
* @version 1.4.3.1
|
|
11
|
-
*
|
|
12
|
-
* @id jQuery.scrollTo
|
|
13
|
-
* @id jQuery.fn.scrollTo
|
|
14
|
-
* @param {String, Number, DOMElement, jQuery, Object} target Where to scroll the matched elements.
|
|
15
|
-
* The different options for target are:
|
|
16
|
-
* - A number position (will be applied to all axes).
|
|
17
|
-
* - A string position ('44', '100px', '+=90', etc ) will be applied to all axes
|
|
18
|
-
* - A jQuery/DOM element ( logically, child of the element to scroll )
|
|
19
|
-
* - A string selector, that will be relative to the element to scroll ( 'li:eq(2)', etc )
|
|
20
|
-
* - A hash { top:x, left:y }, x and y can be any kind of number/string like above.
|
|
21
|
-
* - A percentage of the container's dimension/s, for example: 50% to go to the middle.
|
|
22
|
-
* - The string 'max' for go-to-end.
|
|
23
|
-
* @param {Number, Function} duration The OVERALL length of the animation, this argument can be the settings object instead.
|
|
24
|
-
* @param {Object,Function} settings Optional set of settings or the onAfter callback.
|
|
25
|
-
* @option {String} axis Which axis must be scrolled, use 'x', 'y', 'xy' or 'yx'.
|
|
26
|
-
* @option {Number, Function} duration The OVERALL length of the animation.
|
|
27
|
-
* @option {String} easing The easing method for the animation.
|
|
28
|
-
* @option {Boolean} margin If true, the margin of the target element will be deducted from the final position.
|
|
29
|
-
* @option {Object, Number} offset Add/deduct from the end position. One number for both axes or { top:x, left:y }.
|
|
30
|
-
* @option {Object, Number} over Add/deduct the height/width multiplied by 'over', can be { top:x, left:y } when using both axes.
|
|
31
|
-
* @option {Boolean} queue If true, and both axis are given, the 2nd axis will only be animated after the first one ends.
|
|
32
|
-
* @option {Function} onAfter Function to be called after the scrolling ends.
|
|
33
|
-
* @option {Function} onAfterFirst If queuing is activated, this function will be called after the first scrolling ends.
|
|
34
|
-
* @return {jQuery} Returns the same jQuery object, for chaining.
|
|
35
|
-
*
|
|
36
|
-
* @desc Scroll to a fixed position
|
|
37
|
-
* @example $('div').scrollTo( 340 );
|
|
38
|
-
*
|
|
39
|
-
* @desc Scroll relatively to the actual position
|
|
40
|
-
* @example $('div').scrollTo( '+=340px', { axis:'y' } );
|
|
41
|
-
*
|
|
42
|
-
* @desc Scroll using a selector (relative to the scrolled element)
|
|
43
|
-
* @example $('div').scrollTo( 'p.paragraph:eq(2)', 500, { easing:'swing', queue:true, axis:'xy' } );
|
|
44
|
-
*
|
|
45
|
-
* @desc Scroll to a DOM element (same for jQuery object)
|
|
46
|
-
* @example var second_child = document.getElementById('container').firstChild.nextSibling;
|
|
47
|
-
* $('#container').scrollTo( second_child, { duration:500, axis:'x', onAfter:function(){
|
|
48
|
-
* alert('scrolled!!');
|
|
49
|
-
* }});
|
|
50
|
-
*
|
|
51
|
-
* @desc Scroll on both axes, to different values
|
|
52
|
-
* @example $('div').scrollTo( { top: 300, left:'+=200' }, { axis:'xy', offset:-20 } );
|
|
53
|
-
*/
|
|
54
|
-
|
|
55
|
-
;(function( $ ){
|
|
56
|
-
|
|
57
|
-
var $scrollTo = $.scrollTo = function( target, duration, settings ){
|
|
58
|
-
$(window).scrollTo( target, duration, settings );
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
$scrollTo.defaults = {
|
|
62
|
-
axis:'xy',
|
|
63
|
-
duration: parseFloat($.fn.jquery) >= 1.3 ? 0 : 1,
|
|
64
|
-
limit:true
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// Returns the element that needs to be animated to scroll the window.
|
|
68
|
-
// Kept for backwards compatibility (specially for localScroll & serialScroll)
|
|
69
|
-
$scrollTo.window = function( scope ){
|
|
70
|
-
return $(window)._scrollable();
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
// Hack, hack, hack :)
|
|
74
|
-
// Returns the real elements to scroll (supports window/iframes, documents and regular nodes)
|
|
75
|
-
$.fn._scrollable = function(){
|
|
76
|
-
return this.map(function(){
|
|
77
|
-
var elem = this,
|
|
78
|
-
isWin = !elem.nodeName || $.inArray( elem.nodeName.toLowerCase(), ['iframe','#document','html','body'] ) != -1;
|
|
79
|
-
|
|
80
|
-
if( !isWin )
|
|
81
|
-
return elem;
|
|
82
|
-
|
|
83
|
-
var doc = (elem.contentWindow || elem).document || elem.ownerDocument || elem;
|
|
84
|
-
|
|
85
|
-
return /webkit/i.test(navigator.userAgent) || doc.compatMode == 'BackCompat' ?
|
|
86
|
-
doc.body :
|
|
87
|
-
doc.documentElement;
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
$.fn.scrollTo = function( target, duration, settings ){
|
|
92
|
-
if( typeof duration == 'object' ){
|
|
93
|
-
settings = duration;
|
|
94
|
-
duration = 0;
|
|
95
|
-
}
|
|
96
|
-
if( typeof settings == 'function' )
|
|
97
|
-
settings = { onAfter:settings };
|
|
98
|
-
|
|
99
|
-
if( target == 'max' )
|
|
100
|
-
target = 9e9;
|
|
101
|
-
|
|
102
|
-
settings = $.extend( {}, $scrollTo.defaults, settings );
|
|
103
|
-
// Speed is still recognized for backwards compatibility
|
|
104
|
-
duration = duration || settings.duration;
|
|
105
|
-
// Make sure the settings are given right
|
|
106
|
-
settings.queue = settings.queue && settings.axis.length > 1;
|
|
107
|
-
|
|
108
|
-
if( settings.queue )
|
|
109
|
-
// Let's keep the overall duration
|
|
110
|
-
duration /= 2;
|
|
111
|
-
settings.offset = both( settings.offset );
|
|
112
|
-
settings.over = both( settings.over );
|
|
113
|
-
|
|
114
|
-
return this._scrollable().each(function(){
|
|
115
|
-
// Null target yields nothing, just like jQuery does
|
|
116
|
-
if (target == null) return;
|
|
117
|
-
|
|
118
|
-
var elem = this,
|
|
119
|
-
$elem = $(elem),
|
|
120
|
-
targ = target, toff, attr = {},
|
|
121
|
-
win = $elem.is('html,body');
|
|
122
|
-
|
|
123
|
-
switch( typeof targ ){
|
|
124
|
-
// A number will pass the regex
|
|
125
|
-
case 'number':
|
|
126
|
-
case 'string':
|
|
127
|
-
if( /^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(targ) ){
|
|
128
|
-
targ = both( targ );
|
|
129
|
-
// We are done
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
// Relative selector, no break!
|
|
133
|
-
targ = $(targ,this);
|
|
134
|
-
if (!targ.length) return;
|
|
135
|
-
case 'object':
|
|
136
|
-
// DOMElement / jQuery
|
|
137
|
-
if( targ.is || targ.style )
|
|
138
|
-
// Get the real position of the target
|
|
139
|
-
toff = (targ = $(targ)).offset();
|
|
140
|
-
}
|
|
141
|
-
$.each( settings.axis.split(''), function( i, axis ){
|
|
142
|
-
var Pos = axis == 'x' ? 'Left' : 'Top',
|
|
143
|
-
pos = Pos.toLowerCase(),
|
|
144
|
-
key = 'scroll' + Pos,
|
|
145
|
-
old = elem[key],
|
|
146
|
-
max = $scrollTo.max(elem, axis);
|
|
147
|
-
|
|
148
|
-
if( toff ){// jQuery / DOMElement
|
|
149
|
-
attr[key] = toff[pos] + ( win ? 0 : old - $elem.offset()[pos] );
|
|
150
|
-
|
|
151
|
-
// If it's a dom element, reduce the margin
|
|
152
|
-
if( settings.margin ){
|
|
153
|
-
attr[key] -= parseInt(targ.css('margin'+Pos)) || 0;
|
|
154
|
-
attr[key] -= parseInt(targ.css('border'+Pos+'Width')) || 0;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
attr[key] += settings.offset[pos] || 0;
|
|
158
|
-
|
|
159
|
-
if( settings.over[pos] )
|
|
160
|
-
// Scroll to a fraction of its width/height
|
|
161
|
-
attr[key] += targ[axis=='x'?'width':'height']() * settings.over[pos];
|
|
162
|
-
}else{
|
|
163
|
-
var val = targ[pos];
|
|
164
|
-
// Handle percentage values
|
|
165
|
-
attr[key] = val.slice && val.slice(-1) == '%' ?
|
|
166
|
-
parseFloat(val) / 100 * max
|
|
167
|
-
: val;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Number or 'number'
|
|
171
|
-
if( settings.limit && /^\d+$/.test(attr[key]) )
|
|
172
|
-
// Check the limits
|
|
173
|
-
attr[key] = attr[key] <= 0 ? 0 : Math.min( attr[key], max );
|
|
174
|
-
|
|
175
|
-
// Queueing axes
|
|
176
|
-
if( !i && settings.queue ){
|
|
177
|
-
// Don't waste time animating, if there's no need.
|
|
178
|
-
if( old != attr[key] )
|
|
179
|
-
// Intermediate animation
|
|
180
|
-
animate( settings.onAfterFirst );
|
|
181
|
-
// Don't animate this axis again in the next iteration.
|
|
182
|
-
delete attr[key];
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
animate( settings.onAfter );
|
|
187
|
-
|
|
188
|
-
function animate( callback ){
|
|
189
|
-
$elem.animate( attr, duration, settings.easing, callback && function(){
|
|
190
|
-
callback.call(this, target, settings);
|
|
191
|
-
});
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
}).end();
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
// Max scrolling position, works on quirks mode
|
|
198
|
-
// It only fails (not too badly) on IE, quirks mode.
|
|
199
|
-
$scrollTo.max = function( elem, axis ){
|
|
200
|
-
var Dim = axis == 'x' ? 'Width' : 'Height',
|
|
201
|
-
scroll = 'scroll'+Dim;
|
|
202
|
-
|
|
203
|
-
if( !$(elem).is('html,body') )
|
|
204
|
-
return elem[scroll] - $(elem)[Dim.toLowerCase()]();
|
|
205
|
-
|
|
206
|
-
var size = 'client' + Dim,
|
|
207
|
-
html = elem.ownerDocument.documentElement,
|
|
208
|
-
body = elem.ownerDocument.body;
|
|
209
|
-
|
|
210
|
-
return Math.max( html[scroll], body[scroll] )
|
|
211
|
-
- Math.min( html[size] , body[size] );
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
function both( val ){
|
|
215
|
-
return typeof val == 'object' ? val : { top:val, left:val };
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
})( jQuery );
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/* Modernizr 2.6.2 (Custom Build) | MIT & BSD
|
|
2
|
-
* Build: http://modernizr.com/download/#-fontface-backgroundsize-borderimage-borderradius-boxshadow-flexbox-hsla-multiplebgs-opacity-rgba-textshadow-cssanimations-csscolumns-generatedcontent-cssgradients-cssreflections-csstransforms-csstransforms3d-csstransitions-applicationcache-canvas-canvastext-draganddrop-hashchange-history-audio-video-indexeddb-input-inputtypes-localstorage-postmessage-sessionstorage-websockets-websqldatabase-webworkers-geolocation-inlinesvg-smil-svg-svgclippaths-touch-webgl-shiv-mq-cssclasses-addtest-prefixed-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-load
|
|
3
|
-
*/
|
|
4
|
-
;window.Modernizr=function(a,b,c){function D(a){j.cssText=a}function E(a,b){return D(n.join(a+";")+(b||""))}function F(a,b){return typeof a===b}function G(a,b){return!!~(""+a).indexOf(b)}function H(a,b){for(var d in a){var e=a[d];if(!G(e,"-")&&j[e]!==c)return b=="pfx"?e:!0}return!1}function I(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:F(f,"function")?f.bind(d||b):f}return!1}function J(a,b,c){var d=a.charAt(0).toUpperCase()+a.slice(1),e=(a+" "+p.join(d+" ")+d).split(" ");return F(b,"string")||F(b,"undefined")?H(e,b):(e=(a+" "+q.join(d+" ")+d).split(" "),I(e,b,c))}function K(){e.input=function(c){for(var d=0,e=c.length;d<e;d++)u[c[d]]=c[d]in k;return u.list&&(u.list=!!b.createElement("datalist")&&!!a.HTMLDataListElement),u}("autocomplete autofocus list placeholder max min multiple pattern required step".split(" ")),e.inputtypes=function(a){for(var d=0,e,f,h,i=a.length;d<i;d++)k.setAttribute("type",f=a[d]),e=k.type!=="text",e&&(k.value=l,k.style.cssText="position:absolute;visibility:hidden;",/^range$/.test(f)&&k.style.WebkitAppearance!==c?(g.appendChild(k),h=b.defaultView,e=h.getComputedStyle&&h.getComputedStyle(k,null).WebkitAppearance!=="textfield"&&k.offsetHeight!==0,g.removeChild(k)):/^(search|tel)$/.test(f)||(/^(url|email)$/.test(f)?e=k.checkValidity&&k.checkValidity()===!1:e=k.value!=l)),t[a[d]]=!!e;return t}("search tel url email datetime date month week time datetime-local number range color".split(" "))}var d="2.6.2",e={},f=!0,g=b.documentElement,h="modernizr",i=b.createElement(h),j=i.style,k=b.createElement("input"),l=":)",m={}.toString,n=" -webkit- -moz- -o- -ms- ".split(" "),o="Webkit Moz O ms",p=o.split(" "),q=o.toLowerCase().split(" "),r={svg:"http://www.w3.org/2000/svg"},s={},t={},u={},v=[],w=v.slice,x,y=function(a,c,d,e){var f,i,j,k,l=b.createElement("div"),m=b.body,n=m||b.createElement("body");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:h+(d+1),l.appendChild(j);return f=["­",'<style id="s',h,'">',a,"</style>"].join(""),l.id=h,(m?l:n).innerHTML+=f,n.appendChild(l),m||(n.style.background="",n.style.overflow="hidden",k=g.style.overflow,g.style.overflow="hidden",g.appendChild(n)),i=c(l,a),m?l.parentNode.removeChild(l):(n.parentNode.removeChild(n),g.style.overflow=k),!!i},z=function(b){var c=a.matchMedia||a.msMatchMedia;if(c)return c(b).matches;var d;return y("@media "+b+" { #"+h+" { position: absolute; } }",function(b){d=(a.getComputedStyle?getComputedStyle(b,null):b.currentStyle)["position"]=="absolute"}),d},A=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;return f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=F(e[d],"function"),F(e[d],"undefined")||(e[d]=c),e.removeAttribute(d))),e=null,f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),B={}.hasOwnProperty,C;!F(B,"undefined")&&!F(B.call,"undefined")?C=function(a,b){return B.call(a,b)}:C=function(a,b){return b in a&&F(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=w.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(w.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(w.call(arguments)))};return e}),s.flexbox=function(){return J("flexWrap")},s.canvas=function(){var a=b.createElement("canvas");return!!a.getContext&&!!a.getContext("2d")},s.canvastext=function(){return!!e.canvas&&!!F(b.createElement("canvas").getContext("2d").fillText,"function")},s.webgl=function(){return!!a.WebGLRenderingContext},s.touch=function(){var c;return"ontouchstart"in a||a.DocumentTouch&&b instanceof DocumentTouch?c=!0:y(["@media (",n.join("touch-enabled),("),h,")","{#modernizr{top:9px;position:absolute}}"].join(""),function(a){c=a.offsetTop===9}),c},s.geolocation=function(){return"geolocation"in navigator},s.postmessage=function(){return!!a.postMessage},s.websqldatabase=function(){return!!a.openDatabase},s.indexedDB=function(){return!!J("indexedDB",a)},s.hashchange=function(){return A("hashchange",a)&&(b.documentMode===c||b.documentMode>7)},s.history=function(){return!!a.history&&!!history.pushState},s.draganddrop=function(){var a=b.createElement("div");return"draggable"in a||"ondragstart"in a&&"ondrop"in a},s.websockets=function(){return"WebSocket"in a||"MozWebSocket"in a},s.rgba=function(){return D("background-color:rgba(150,255,150,.5)"),G(j.backgroundColor,"rgba")},s.hsla=function(){return D("background-color:hsla(120,40%,100%,.5)"),G(j.backgroundColor,"rgba")||G(j.backgroundColor,"hsla")},s.multiplebgs=function(){return D("background:url(https://),url(https://),red url(https://)"),/(url\s*\(.*?){3}/.test(j.background)},s.backgroundsize=function(){return J("backgroundSize")},s.borderimage=function(){return J("borderImage")},s.borderradius=function(){return J("borderRadius")},s.boxshadow=function(){return J("boxShadow")},s.textshadow=function(){return b.createElement("div").style.textShadow===""},s.opacity=function(){return E("opacity:.55"),/^0.55$/.test(j.opacity)},s.cssanimations=function(){return J("animationName")},s.csscolumns=function(){return J("columnCount")},s.cssgradients=function(){var a="background-image:",b="gradient(linear,left top,right bottom,from(#9f9),to(white));",c="linear-gradient(left top,#9f9, white);";return D((a+"-webkit- ".split(" ").join(b+a)+n.join(c+a)).slice(0,-a.length)),G(j.backgroundImage,"gradient")},s.cssreflections=function(){return J("boxReflect")},s.csstransforms=function(){return!!J("transform")},s.csstransforms3d=function(){var a=!!J("perspective");return a&&"webkitPerspective"in g.style&&y("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}",function(b,c){a=b.offsetLeft===9&&b.offsetHeight===3}),a},s.csstransitions=function(){return J("transition")},s.fontface=function(){var a;return y('@font-face {font-family:"font";src:url("https://")}',function(c,d){var e=b.getElementById("smodernizr"),f=e.sheet||e.styleSheet,g=f?f.cssRules&&f.cssRules[0]?f.cssRules[0].cssText:f.cssText||"":"";a=/src/i.test(g)&&g.indexOf(d.split(" ")[0])===0}),a},s.generatedcontent=function(){var a;return y(["#",h,"{font:0/0 a}#",h,':after{content:"',l,'";visibility:hidden;font:3px/1 a}'].join(""),function(b){a=b.offsetHeight>=3}),a},s.video=function(){var a=b.createElement("video"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,""),c.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,""),c.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")}catch(d){}return c},s.audio=function(){var a=b.createElement("audio"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),c.mp3=a.canPlayType("audio/mpeg;").replace(/^no$/,""),c.wav=a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),c.m4a=(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")).replace(/^no$/,"")}catch(d){}return c},s.localstorage=function(){try{return localStorage.setItem(h,h),localStorage.removeItem(h),!0}catch(a){return!1}},s.sessionstorage=function(){try{return sessionStorage.setItem(h,h),sessionStorage.removeItem(h),!0}catch(a){return!1}},s.webworkers=function(){return!!a.Worker},s.applicationcache=function(){return!!a.applicationCache},s.svg=function(){return!!b.createElementNS&&!!b.createElementNS(r.svg,"svg").createSVGRect},s.inlinesvg=function(){var a=b.createElement("div");return a.innerHTML="<svg/>",(a.firstChild&&a.firstChild.namespaceURI)==r.svg},s.smil=function(){return!!b.createElementNS&&/SVGAnimate/.test(m.call(b.createElementNS(r.svg,"animate")))},s.svgclippaths=function(){return!!b.createElementNS&&/SVGClipPath/.test(m.call(b.createElementNS(r.svg,"clipPath")))};for(var L in s)C(s,L)&&(x=L.toLowerCase(),e[x]=s[L](),v.push((e[x]?"":"no-")+x));return e.input||K(),e.addTest=function(a,b){if(typeof a=="object")for(var d in a)C(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,typeof f!="undefined"&&f&&(g.className+=" "+(b?"":"no-")+a),e[a]=b}return e},D(""),i=k=null,function(a,b){function k(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function l(){var a=r.elements;return typeof a=="string"?a.split(" "):a}function m(a){var b=i[a[g]];return b||(b={},h++,a[g]=h,i[h]=b),b}function n(a,c,f){c||(c=b);if(j)return c.createElement(a);f||(f=m(c));var g;return f.cache[a]?g=f.cache[a].cloneNode():e.test(a)?g=(f.cache[a]=f.createElem(a)).cloneNode():g=f.createElem(a),g.canHaveChildren&&!d.test(a)?f.frag.appendChild(g):g}function o(a,c){a||(a=b);if(j)return a.createDocumentFragment();c=c||m(a);var d=c.frag.cloneNode(),e=0,f=l(),g=f.length;for(;e<g;e++)d.createElement(f[e]);return d}function p(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return r.shivMethods?n(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+l().join().replace(/\w+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(r,b.frag)}function q(a){a||(a=b);var c=m(a);return r.shivCSS&&!f&&!c.hasCSS&&(c.hasCSS=!!k(a,"article,aside,figcaption,figure,footer,header,hgroup,nav,section{display:block}mark{background:#FF0;color:#000}")),j||p(a,c),a}var c=a.html5||{},d=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,e=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,f,g="_html5shiv",h=0,i={},j;(function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",f="hidden"in a,j=a.childNodes.length==1||function(){b.createElement("a");var a=b.createDocumentFragment();return typeof a.cloneNode=="undefined"||typeof a.createDocumentFragment=="undefined"||typeof a.createElement=="undefined"}()}catch(c){f=!0,j=!0}})();var r={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,supportsUnknownElements:j,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:q,createElement:n,createDocumentFragment:o};a.html5=r,q(b)}(this,b),e._version=d,e._prefixes=n,e._domPrefixes=q,e._cssomPrefixes=p,e.mq=z,e.hasEvent=A,e.testProp=function(a){return H([a])},e.testAllProps=J,e.testStyles=y,e.prefixed=function(a,b,c){return b?J(a,b,c):J(a,"pfx")},g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+v.join(" "):""),e}(this,this.document),function(a,b,c){function d(a){return"[object Function]"==o.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=p.shift();q=1,a?a.t?m(function(){("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};1===y[c]&&(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),"img"!=a&&(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&"[object Opera]"==o.call(a.opera),l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return"[object Array]"==o.call(a)},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f<d;f++)g=a[f].split("="),(e=z[g.shift()])&&(c=e(c,g));for(f=0;f<b;f++)c=x[f](c);return c}function g(a,e,f,g,h){var i=b(a),j=i.autoCallback;i.url.split(".").pop().split("?").shift(),i.bypass||(e&&(e=d(e)?e:e[a]||e[g]||e[a.split("/").pop().split("?")[0]]),i.instead?i.instead(a,e,f,g,h):(y[i.url]?i.noexec=!0:y[i.url]=1,f.load(i.url,i.forceCSS||!i.forceJS&&"css"==i.url.split(".").pop().split("?").shift()?"c":c,i.noexec,i.attrs,i.timeout),(d(e)||d(j))&&f.load(function(){k(),e&&e(i.origUrl,h,g),j&&j(i.origUrl,h,g),y[i.url]=2})))}function h(a,b){function c(a,c){if(a){if(e(a))c||(j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}),g(a,j,b,0,h);else if(Object(a)===a)for(n in m=function(){var b=0,c;for(c in a)a.hasOwnProperty(c)&&b++;return b}(),a)a.hasOwnProperty(n)&&(!c&&!--m&&(d(j)?j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}:j[n]=function(a){return function(){var b=[].slice.call(arguments);a&&a.apply(this,b),l()}}(k[n])),g(a[n],j,b,n,h))}else!c&&l()}var h=!!a.test,i=a.load||a.both,j=a.callback||f,k=j,l=a.complete||f,m,n;c(h?a.yep:a.nope,!!i),i&&c(i)}var i,j,l=this.yepnope.loader;if(e(a))g(a,0,l,0);else if(w(a))for(i=0;i<a.length;i++)j=a[i],e(j)?g(j,0,l,0):w(j)?B(j):Object(j)===j&&h(j,l);else Object(a)===a&&h(a,l)},B.addPrefix=function(a,b){z[a]=b},B.addFilter=function(a){x.push(a)},B.errorTimeout=1e4,null==b.readyState&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",A=function(){b.removeEventListener("DOMContentLoaded",A,0),b.readyState="complete"},0)),a.yepnope=k(),a.yepnope.executeStack=h,a.yepnope.injectJs=function(a,c,d,e,i,j){var k=b.createElement("script"),l,o,e=e||B.errorTimeout;k.src=a;for(o in d)k.setAttribute(o,d[o]);c=j?h:c||f,k.onreadystatechange=k.onload=function(){!l&&g(k.readyState)&&(l=1,c(),k.onload=k.onreadystatechange=null)},m(function(){l||(l=1,c(1))},e),i?k.onload():n.parentNode.insertBefore(k,n)},a.yepnope.injectCss=function(a,c,d,e,g,i){var e=b.createElement("link"),j,c=i?h:c||f;e.href=a,e.rel="stylesheet",e.type="text/css";for(j in d)e.setAttribute(j,d[j]);g||(n.parentNode.insertBefore(e,n),m(c,0))}}(this,document),Modernizr.load=function(){yepnope.apply(window,[].slice.call(arguments,0))};
|
|
5
|
-
|
|
6
|
-
/*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */
|
|
7
|
-
/*! NOTE: If you're already including a window.matchMedia polyfill via Modernizr or otherwise, you don't need this part */
|
|
8
|
-
window.matchMedia=window.matchMedia||(function(e,f){var c,a=e.documentElement,b=a.firstElementChild||a.firstChild,d=e.createElement("body"),g=e.createElement("div");g.id="mq-test-1";g.style.cssText="position:absolute;top:-100em";d.style.background="none";d.appendChild(g);return function(h){g.innerHTML='­<style media="'+h+'"> #mq-test-1 { width: 42px; }</style>';a.insertBefore(d,b);c=g.offsetWidth==42;a.removeChild(d);return{matches:c,media:h}}})(document);
|
|
9
|
-
|
|
10
|
-
/*! Respond.js v1.1.0: min/max-width media query polyfill. (c) Scott Jehl. MIT/GPLv2 Lic. j.mp/respondjs */
|
|
11
|
-
(function(e){e.respond={};respond.update=function(){};respond.mediaQueriesSupported=e.matchMedia&&e.matchMedia("only all").matches;if(respond.mediaQueriesSupported){return}var w=e.document,s=w.documentElement,i=[],k=[],q=[],o={},h=30,f=w.getElementsByTagName("head")[0]||s,g=w.getElementsByTagName("base")[0],b=f.getElementsByTagName("link"),d=[],a=function(){var D=b,y=D.length,B=0,A,z,C,x;for(;B<y;B++){A=D[B],z=A.href,C=A.media,x=A.rel&&A.rel.toLowerCase()==="stylesheet";if(!!z&&x&&!o[z]){if(A.styleSheet&&A.styleSheet.rawCssText){m(A.styleSheet.rawCssText,z,C);o[z]=true}else{if((!/^([a-zA-Z:]*\/\/)/.test(z)&&!g)||z.replace(RegExp.$1,"").split("/")[0]===e.location.host){d.push({href:z,media:C})}}}}u()},u=function(){if(d.length){var x=d.shift();n(x.href,function(y){m(y,x.href,x.media);o[x.href]=true;u()})}},m=function(I,x,z){var G=I.match(/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi),J=G&&G.length||0,x=x.substring(0,x.lastIndexOf("/")),y=function(K){return K.replace(/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,"$1"+x+"$2$3")},A=!J&&z,D=0,C,E,F,B,H;if(x.length){x+="/"}if(A){J=1}for(;D<J;D++){C=0;if(A){E=z;k.push(y(I))}else{E=G[D].match(/@media *([^\{]+)\{([\S\s]+?)$/)&&RegExp.$1;k.push(RegExp.$2&&y(RegExp.$2))}B=E.split(",");H=B.length;for(;C<H;C++){F=B[C];i.push({media:F.split("(")[0].match(/(only\s+)?([a-zA-Z]+)\s?/)&&RegExp.$2||"all",rules:k.length-1,hasquery:F.indexOf("(")>-1,minw:F.match(/\(min\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:F.match(/\(max\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}}j()},l,r,v=function(){var z,A=w.createElement("div"),x=w.body,y=false;A.style.cssText="position:absolute;font-size:1em;width:1em";if(!x){x=y=w.createElement("body");x.style.background="none"}x.appendChild(A);s.insertBefore(x,s.firstChild);z=A.offsetWidth;if(y){s.removeChild(x)}else{x.removeChild(A)}z=p=parseFloat(z);return z},p,j=function(I){var x="clientWidth",B=s[x],H=w.compatMode==="CSS1Compat"&&B||w.body[x]||B,D={},G=b[b.length-1],z=(new Date()).getTime();if(I&&l&&z-l<h){clearTimeout(r);r=setTimeout(j,h);return}else{l=z}for(var E in i){var K=i[E],C=K.minw,J=K.maxw,A=C===null,L=J===null,y="em";if(!!C){C=parseFloat(C)*(C.indexOf(y)>-1?(p||v()):1)}if(!!J){J=parseFloat(J)*(J.indexOf(y)>-1?(p||v()):1)}if(!K.hasquery||(!A||!L)&&(A||H>=C)&&(L||H<=J)){if(!D[K.media]){D[K.media]=[]}D[K.media].push(k[K.rules])}}for(var E in q){if(q[E]&&q[E].parentNode===f){f.removeChild(q[E])}}for(var E in D){var M=w.createElement("style"),F=D[E].join("\n");M.type="text/css";M.media=E;f.insertBefore(M,G.nextSibling);if(M.styleSheet){M.styleSheet.cssText=F}else{M.appendChild(w.createTextNode(F))}q.push(M)}},n=function(x,z){var y=c();if(!y){return}y.open("GET",x,true);y.onreadystatechange=function(){if(y.readyState!=4||y.status!=200&&y.status!=304){return}z(y.responseText)};if(y.readyState==4){return}y.send(null)},c=(function(){var x=false;try{x=new XMLHttpRequest()}catch(y){x=new ActiveXObject("Microsoft.XMLHTTP")}return function(){return x}})();a();respond.update=a;function t(){j(true)}if(e.addEventListener){e.addEventListener("resize",t,false)}else{if(e.attachEvent){e.attachEvent("onresize",t)}}})(this);
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { PropertyDefinition } from '@loopback/repository';
|
|
2
|
-
import { Definition, PrimitiveType } from 'typescript-json-schema';
|
|
3
|
-
export declare const JSON_SCHEMA_KEY = "loopback:json-schema";
|
|
4
|
-
/**
|
|
5
|
-
* Type definition for JSON Schema
|
|
6
|
-
*/
|
|
7
|
-
export interface JsonDefinition extends Definition {
|
|
8
|
-
allOf?: JsonDefinition[];
|
|
9
|
-
oneOf?: JsonDefinition[];
|
|
10
|
-
anyOf?: JsonDefinition[];
|
|
11
|
-
items?: JsonDefinition | JsonDefinition[];
|
|
12
|
-
additionalItems?: {
|
|
13
|
-
anyOf: JsonDefinition[];
|
|
14
|
-
};
|
|
15
|
-
enum?: PrimitiveType[] | JsonDefinition[];
|
|
16
|
-
additionalProperties?: JsonDefinition | boolean;
|
|
17
|
-
definitions?: {
|
|
18
|
-
[definition: string]: JsonDefinition;
|
|
19
|
-
};
|
|
20
|
-
properties?: {
|
|
21
|
-
[property: string]: JsonDefinition;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Gets the JSON Schema of a TypeScript model/class by seeing if one exists
|
|
26
|
-
* in a cache. If not, one is generated and then cached.
|
|
27
|
-
* @param ctor Contructor of class to get JSON Schema from
|
|
28
|
-
*/
|
|
29
|
-
export declare function getJsonSchema(ctor: Function): JsonDefinition;
|
|
30
|
-
/**
|
|
31
|
-
* Gets the wrapper function of primitives string, number, and boolean
|
|
32
|
-
* @param type Name of type
|
|
33
|
-
*/
|
|
34
|
-
export declare function stringTypeToWrapper(type: string): Function;
|
|
35
|
-
/**
|
|
36
|
-
* Determines whether the given constructor is a custom type or not
|
|
37
|
-
* @param ctor Constructor
|
|
38
|
-
*/
|
|
39
|
-
export declare function isComplexType(ctor: Function): boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Converts property metadata into a JSON property definition
|
|
42
|
-
* @param meta
|
|
43
|
-
*/
|
|
44
|
-
export declare function metaToJsonProperty(meta: PropertyDefinition): JsonDefinition;
|
|
45
|
-
/**
|
|
46
|
-
* Converts a TypeScript class into a JSON Schema using TypeScript's
|
|
47
|
-
* reflection API
|
|
48
|
-
* @param ctor Constructor of class to convert from
|
|
49
|
-
*/
|
|
50
|
-
export declare function modelToJsonSchema(ctor: Function): JsonDefinition;
|
package/dist/src/build-schema.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright IBM Corp. 2018. All Rights Reserved.
|
|
3
|
-
// Node module: @loopback/repository-json-schema
|
|
4
|
-
// This file is licensed under the MIT License.
|
|
5
|
-
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const repository_1 = require("@loopback/repository");
|
|
8
|
-
const lodash_1 = require("lodash");
|
|
9
|
-
const context_1 = require("@loopback/context");
|
|
10
|
-
exports.JSON_SCHEMA_KEY = 'loopback:json-schema';
|
|
11
|
-
/**
|
|
12
|
-
* Gets the JSON Schema of a TypeScript model/class by seeing if one exists
|
|
13
|
-
* in a cache. If not, one is generated and then cached.
|
|
14
|
-
* @param ctor Contructor of class to get JSON Schema from
|
|
15
|
-
*/
|
|
16
|
-
function getJsonSchema(ctor) {
|
|
17
|
-
// NOTE(shimks) currently impossible to dynamically update
|
|
18
|
-
const jsonSchema = context_1.MetadataInspector.getClassMetadata(exports.JSON_SCHEMA_KEY, ctor);
|
|
19
|
-
if (jsonSchema) {
|
|
20
|
-
return jsonSchema;
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
const newSchema = modelToJsonSchema(ctor);
|
|
24
|
-
context_1.MetadataInspector.defineMetadata(exports.JSON_SCHEMA_KEY, newSchema, ctor);
|
|
25
|
-
return newSchema;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.getJsonSchema = getJsonSchema;
|
|
29
|
-
/**
|
|
30
|
-
* Gets the wrapper function of primitives string, number, and boolean
|
|
31
|
-
* @param type Name of type
|
|
32
|
-
*/
|
|
33
|
-
function stringTypeToWrapper(type) {
|
|
34
|
-
type = type.toLowerCase();
|
|
35
|
-
let wrapper;
|
|
36
|
-
switch (type) {
|
|
37
|
-
case 'number': {
|
|
38
|
-
wrapper = Number;
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
case 'string': {
|
|
42
|
-
wrapper = String;
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
case 'boolean': {
|
|
46
|
-
wrapper = Boolean;
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
default: {
|
|
50
|
-
throw new Error('Unsupported type');
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return wrapper;
|
|
54
|
-
}
|
|
55
|
-
exports.stringTypeToWrapper = stringTypeToWrapper;
|
|
56
|
-
/**
|
|
57
|
-
* Determines whether the given constructor is a custom type or not
|
|
58
|
-
* @param ctor Constructor
|
|
59
|
-
*/
|
|
60
|
-
function isComplexType(ctor) {
|
|
61
|
-
return !lodash_1.includes([String, Number, Boolean, Object, Function], ctor);
|
|
62
|
-
}
|
|
63
|
-
exports.isComplexType = isComplexType;
|
|
64
|
-
/**
|
|
65
|
-
* Converts property metadata into a JSON property definition
|
|
66
|
-
* @param meta
|
|
67
|
-
*/
|
|
68
|
-
function metaToJsonProperty(meta) {
|
|
69
|
-
let ctor = meta.type;
|
|
70
|
-
let def = {};
|
|
71
|
-
// errors out if @property.array() is not used on a property of array
|
|
72
|
-
if (ctor === Array) {
|
|
73
|
-
throw new Error('type is defined as an array');
|
|
74
|
-
}
|
|
75
|
-
if (typeof ctor === 'string') {
|
|
76
|
-
ctor = stringTypeToWrapper(ctor);
|
|
77
|
-
}
|
|
78
|
-
const propDef = isComplexType(ctor)
|
|
79
|
-
? { $ref: `#/definitions/${ctor.name}` }
|
|
80
|
-
: { type: ctor.name.toLowerCase() };
|
|
81
|
-
if (meta.array) {
|
|
82
|
-
def.type = 'array';
|
|
83
|
-
def.items = propDef;
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
Object.assign(def, propDef);
|
|
87
|
-
}
|
|
88
|
-
return def;
|
|
89
|
-
}
|
|
90
|
-
exports.metaToJsonProperty = metaToJsonProperty;
|
|
91
|
-
// NOTE(shimks) no metadata for: union, optional, nested array, any, enum,
|
|
92
|
-
// string literal, anonymous types, and inherited properties
|
|
93
|
-
/**
|
|
94
|
-
* Converts a TypeScript class into a JSON Schema using TypeScript's
|
|
95
|
-
* reflection API
|
|
96
|
-
* @param ctor Constructor of class to convert from
|
|
97
|
-
*/
|
|
98
|
-
function modelToJsonSchema(ctor) {
|
|
99
|
-
const meta = repository_1.ModelMetadataHelper.getModelMetadata(ctor);
|
|
100
|
-
const result = {};
|
|
101
|
-
// returns an empty object if metadata is an empty object
|
|
102
|
-
if (!(meta instanceof repository_1.ModelDefinition)) {
|
|
103
|
-
return {};
|
|
104
|
-
}
|
|
105
|
-
result.title = meta.title || ctor.name;
|
|
106
|
-
if (meta.description) {
|
|
107
|
-
result.description = meta.description;
|
|
108
|
-
}
|
|
109
|
-
for (const p in meta.properties) {
|
|
110
|
-
if (!meta.properties[p].type) {
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
result.properties = result.properties || {};
|
|
114
|
-
result.properties[p] = result.properties[p] || {};
|
|
115
|
-
const metaProperty = meta.properties[p];
|
|
116
|
-
const metaType = metaProperty.type;
|
|
117
|
-
// populating "properties" key
|
|
118
|
-
result.properties[p] = metaToJsonProperty(metaProperty);
|
|
119
|
-
// populating JSON Schema 'definitions'
|
|
120
|
-
if (typeof metaType === 'function' && isComplexType(metaType)) {
|
|
121
|
-
const propSchema = getJsonSchema(metaType);
|
|
122
|
-
if (propSchema && Object.keys(propSchema).length > 0) {
|
|
123
|
-
result.definitions = result.definitions || {};
|
|
124
|
-
// delete nested definition
|
|
125
|
-
if (propSchema.definitions) {
|
|
126
|
-
for (const key in propSchema.definitions) {
|
|
127
|
-
result.definitions[key] = propSchema.definitions[key];
|
|
128
|
-
}
|
|
129
|
-
delete propSchema.definitions;
|
|
130
|
-
}
|
|
131
|
-
result.definitions[metaType.name] = propSchema;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
// handling 'required' metadata
|
|
135
|
-
if (metaProperty.required) {
|
|
136
|
-
result.required = result.required || [];
|
|
137
|
-
result.required.push(p);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return result;
|
|
141
|
-
}
|
|
142
|
-
exports.modelToJsonSchema = modelToJsonSchema;
|
|
143
|
-
//# sourceMappingURL=build-schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-schema.js","sourceRoot":"","sources":["../../src/build-schema.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,gDAAgD;AAChD,+CAA+C;AAC/C,gEAAgE;;AAEhE,qDAI8B;AAC9B,mCAAgC;AAEhC,+CAAoD;AAEvC,QAAA,eAAe,GAAG,sBAAsB,CAAC;AAmBtD;;;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C,CAAC,CAAC;wBACzC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;oBACxD,CAAC;oBACD,OAAO,UAAU,CAAC,WAAW,CAAC;gBAChC,CAAC;gBAED,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC;YACjD,CAAC;QACH,CAAC;QAED,+BAA+B;QAC/B,EAAE,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC1B,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;YACxC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IACD,MAAM,CAAC,MAAM,CAAC;AAChB,CAAC;AAvDD,8CAuDC"}
|
package/dist/src/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './build-schema';
|
package/dist/src/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright IBM Corp. 2018. All Rights Reserved.
|
|
3
|
-
// Node module: @loopback/repository-json-schema
|
|
4
|
-
// This file is licensed under the MIT License.
|
|
5
|
-
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
-
function __export(m) {
|
|
7
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
__export(require("./build-schema"));
|
|
11
|
-
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,gDAAgD;AAChD,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,oCAA+B"}
|
package/index.d.ts
DELETED
package/index.js
DELETED