20211231 commit
This commit is contained in:
parent
c6f5a5c49f
commit
7fd21e0187
60
CMA 3.0 Documentation
Normal file
60
CMA 3.0 Documentation
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
Documentation of cma
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
1. GetOTP
|
||||||
|
===========
|
||||||
|
-->Send mobilenumber and countrycode in POST method using getOtp link
|
||||||
|
-->get mobilenumber and countrycode from application
|
||||||
|
-->check mobilenumber exist or not
|
||||||
|
-->if exist means
|
||||||
|
-->send to msg91 with mobilenumber and otp, get response from msg91
|
||||||
|
-->final result sent as response
|
||||||
|
-->not exist means insert mobilenumber and countrycode in register table
|
||||||
|
-->final result sent as response
|
||||||
|
|
||||||
|
2. VerifyOTP
|
||||||
|
============
|
||||||
|
-->send mobilenumber and otp as base64encode and devicetype,devicetoken,deviceid as normal value in POST method using verifyOtp link
|
||||||
|
-->get mobilenumber and otp as base64 decodemethod and also get devicetype,devicetoken,deviceidfrom application
|
||||||
|
-->send to msg91 with mobilenumber and otp, get response from msg91
|
||||||
|
-->final result sent as response
|
||||||
|
-->check that response is seccess or error
|
||||||
|
-->Get userid from select query by using mobile number
|
||||||
|
-->if success means update those values into register table by using userId
|
||||||
|
-->not success means show error
|
||||||
|
|
||||||
|
3.ResendOTP
|
||||||
|
===========
|
||||||
|
-->Send mobilenumber in POST method using resendOtp link
|
||||||
|
-->get mobilenumber and countrycode from application
|
||||||
|
-->Get counrtycode from select query by using mobile number
|
||||||
|
-->send to msg91 with mobilenumber and get response from msg91
|
||||||
|
-->final result sent as response
|
||||||
|
|
||||||
|
4.Listplans
|
||||||
|
==========
|
||||||
|
-->using userid and deviceid we have to check there is any data in register table(this is for check which device is having this app with this mobile number)
|
||||||
|
-->if yes
|
||||||
|
-->check trial_status is 0 or 1 in register table (trial_status from select query of userid & deviceid)
|
||||||
|
-->if 0 means show all palns in plan table
|
||||||
|
-->sent code is 1 for success & message & result
|
||||||
|
-->if 1 means show plans without trial plan
|
||||||
|
-->sent code is 1 for success & message & result
|
||||||
|
-->if no
|
||||||
|
-->show code is 2 for error & message is "this mobile number is register with another device please check"
|
||||||
|
|
||||||
|
5.SubscribePlan
|
||||||
|
==============
|
||||||
|
-->using userid and deviceid ,we have to check there is any data in register table with deviceid and userid(this is for check which device is having this app with this mobile number)
|
||||||
|
-->if yes
|
||||||
|
-->get mobile and plan from application also get plan table all details using select query
|
||||||
|
-->check there is any match from select query of planid and given request plan id
|
||||||
|
-->if match
|
||||||
|
-->get usertype(1-free,0-payment) is 1 or 0
|
||||||
|
-->if 1 this is free plan
|
||||||
|
-->update details trial-status=1,status=2(activeplan),plan_type=1,startdate,enddate with 7days(dynamically get days from above select query) perid in register table by using mobilenumber
|
||||||
|
-->if 0 means this is paid plan
|
||||||
|
-->update details status=2(activeplan),plan_type=2(dynamic),startdate,enddate with 365days(dynamically get days from above select query) perid in register table by using mobilenumber
|
||||||
|
-->sent code is 1 for success & message & planid
|
||||||
|
-->if no
|
||||||
|
-->show code is 2 for error & message is "this mobile number is register with another device please check"
|
15
client.js
Normal file
15
client.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
const WebSocket = require('ws')
|
||||||
|
const url = 'ws://localhost:9000'
|
||||||
|
const connection = new WebSocket(url)
|
||||||
|
|
||||||
|
connection.onopen = () => {
|
||||||
|
connection.send("Message From Client")
|
||||||
|
}
|
||||||
|
|
||||||
|
connection.onerror = (error) => {
|
||||||
|
console.log("WebSocket error:", error)
|
||||||
|
}
|
||||||
|
|
||||||
|
connection.onmessage = (e) => {
|
||||||
|
console.log(e.data)
|
||||||
|
}
|
24
index.js
Normal file
24
index.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
var express = require('express');
|
||||||
|
var bodyparser = require('body-parser');
|
||||||
|
var mysql = require('mysql');
|
||||||
|
var cookieParser = require('cookie-parser');
|
||||||
|
var expsession = require('express-session');
|
||||||
|
|
||||||
|
var app = express();
|
||||||
|
|
||||||
|
//included files
|
||||||
|
var connect= require('./lib/db');
|
||||||
|
var indexRouter= require('./routes/api');
|
||||||
|
|
||||||
|
//use method
|
||||||
|
app.use(bodyparser.json());
|
||||||
|
app.use('/',indexRouter);
|
||||||
|
app.use(cookieParser());
|
||||||
|
app.use(expsession({
|
||||||
|
secret: '34SDgsdgspxxxxxxxdfsG', // just a long random string
|
||||||
|
resave: false,
|
||||||
|
saveUninitialized: true
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
|
18
lib/db.js
Normal file
18
lib/db.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
var mysql = require('mysql');
|
||||||
|
var connection=mysql.createConnection({
|
||||||
|
host :'localhost',
|
||||||
|
user :'root',
|
||||||
|
password :'',
|
||||||
|
database :'cma_api'
|
||||||
|
});
|
||||||
|
connection.connect(function(error){
|
||||||
|
if(error)
|
||||||
|
{
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
console.log("Database Connected...");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
module.exports = connection;
|
12
node_modules/.bin/is-ci
generated
vendored
Normal file
12
node_modules/.bin/is-ci
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../is-ci/bin.js" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../is-ci/bin.js" "$@"
|
||||||
|
fi
|
17
node_modules/.bin/is-ci.cmd
generated
vendored
Normal file
17
node_modules/.bin/is-ci.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\is-ci\bin.js" %*
|
28
node_modules/.bin/is-ci.ps1
generated
vendored
Normal file
28
node_modules/.bin/is-ci.ps1
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../is-ci/bin.js" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../is-ci/bin.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../is-ci/bin.js" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../is-ci/bin.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
12
node_modules/.bin/mime
generated
vendored
Normal file
12
node_modules/.bin/mime
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../mime/cli.js" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../mime/cli.js" "$@"
|
||||||
|
fi
|
17
node_modules/.bin/mime.cmd
generated
vendored
Normal file
17
node_modules/.bin/mime.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\mime\cli.js" %*
|
28
node_modules/.bin/mime.ps1
generated
vendored
Normal file
28
node_modules/.bin/mime.ps1
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../mime/cli.js" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../mime/cli.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../mime/cli.js" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../mime/cli.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
12
node_modules/.bin/mkdirp
generated
vendored
Normal file
12
node_modules/.bin/mkdirp
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../mkdirp/bin/cmd.js" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../mkdirp/bin/cmd.js" "$@"
|
||||||
|
fi
|
17
node_modules/.bin/mkdirp.cmd
generated
vendored
Normal file
17
node_modules/.bin/mkdirp.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\mkdirp\bin\cmd.js" %*
|
28
node_modules/.bin/mkdirp.ps1
generated
vendored
Normal file
28
node_modules/.bin/mkdirp.ps1
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../mkdirp/bin/cmd.js" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../mkdirp/bin/cmd.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../mkdirp/bin/cmd.js" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../mkdirp/bin/cmd.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
12
node_modules/.bin/nodemon
generated
vendored
Normal file
12
node_modules/.bin/nodemon
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../nodemon/bin/nodemon.js" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../nodemon/bin/nodemon.js" "$@"
|
||||||
|
fi
|
17
node_modules/.bin/nodemon.cmd
generated
vendored
Normal file
17
node_modules/.bin/nodemon.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\nodemon\bin\nodemon.js" %*
|
28
node_modules/.bin/nodemon.ps1
generated
vendored
Normal file
28
node_modules/.bin/nodemon.ps1
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../nodemon/bin/nodemon.js" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../nodemon/bin/nodemon.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../nodemon/bin/nodemon.js" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../nodemon/bin/nodemon.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
12
node_modules/.bin/nodetouch
generated
vendored
Normal file
12
node_modules/.bin/nodetouch
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../touch/bin/nodetouch.js" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../touch/bin/nodetouch.js" "$@"
|
||||||
|
fi
|
17
node_modules/.bin/nodetouch.cmd
generated
vendored
Normal file
17
node_modules/.bin/nodetouch.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\touch\bin\nodetouch.js" %*
|
28
node_modules/.bin/nodetouch.ps1
generated
vendored
Normal file
28
node_modules/.bin/nodetouch.ps1
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../touch/bin/nodetouch.js" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../touch/bin/nodetouch.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../touch/bin/nodetouch.js" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../touch/bin/nodetouch.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
12
node_modules/.bin/nopt
generated
vendored
Normal file
12
node_modules/.bin/nopt
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../nopt/bin/nopt.js" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../nopt/bin/nopt.js" "$@"
|
||||||
|
fi
|
17
node_modules/.bin/nopt.cmd
generated
vendored
Normal file
17
node_modules/.bin/nopt.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\nopt\bin\nopt.js" %*
|
28
node_modules/.bin/nopt.ps1
generated
vendored
Normal file
28
node_modules/.bin/nopt.ps1
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../nopt/bin/nopt.js" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../nopt/bin/nopt.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../nopt/bin/nopt.js" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../nopt/bin/nopt.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
12
node_modules/.bin/rc
generated
vendored
Normal file
12
node_modules/.bin/rc
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../rc/cli.js" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../rc/cli.js" "$@"
|
||||||
|
fi
|
17
node_modules/.bin/rc.cmd
generated
vendored
Normal file
17
node_modules/.bin/rc.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\rc\cli.js" %*
|
28
node_modules/.bin/rc.ps1
generated
vendored
Normal file
28
node_modules/.bin/rc.ps1
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../rc/cli.js" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../rc/cli.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../rc/cli.js" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../rc/cli.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
12
node_modules/.bin/semver
generated
vendored
Normal file
12
node_modules/.bin/semver
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../semver/bin/semver" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../semver/bin/semver" "$@"
|
||||||
|
fi
|
17
node_modules/.bin/semver.cmd
generated
vendored
Normal file
17
node_modules/.bin/semver.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\semver\bin\semver" %*
|
28
node_modules/.bin/semver.ps1
generated
vendored
Normal file
28
node_modules/.bin/semver.ps1
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../semver/bin/semver" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../semver/bin/semver" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../semver/bin/semver" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../semver/bin/semver" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
12
node_modules/.bin/sshpk-conv
generated
vendored
Normal file
12
node_modules/.bin/sshpk-conv
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../sshpk/bin/sshpk-conv" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../sshpk/bin/sshpk-conv" "$@"
|
||||||
|
fi
|
17
node_modules/.bin/sshpk-conv.cmd
generated
vendored
Normal file
17
node_modules/.bin/sshpk-conv.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\sshpk\bin\sshpk-conv" %*
|
28
node_modules/.bin/sshpk-conv.ps1
generated
vendored
Normal file
28
node_modules/.bin/sshpk-conv.ps1
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../sshpk/bin/sshpk-conv" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../sshpk/bin/sshpk-conv" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../sshpk/bin/sshpk-conv" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../sshpk/bin/sshpk-conv" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
12
node_modules/.bin/sshpk-sign
generated
vendored
Normal file
12
node_modules/.bin/sshpk-sign
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../sshpk/bin/sshpk-sign" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../sshpk/bin/sshpk-sign" "$@"
|
||||||
|
fi
|
17
node_modules/.bin/sshpk-sign.cmd
generated
vendored
Normal file
17
node_modules/.bin/sshpk-sign.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\sshpk\bin\sshpk-sign" %*
|
28
node_modules/.bin/sshpk-sign.ps1
generated
vendored
Normal file
28
node_modules/.bin/sshpk-sign.ps1
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../sshpk/bin/sshpk-sign" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../sshpk/bin/sshpk-sign" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../sshpk/bin/sshpk-sign" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../sshpk/bin/sshpk-sign" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
12
node_modules/.bin/sshpk-verify
generated
vendored
Normal file
12
node_modules/.bin/sshpk-verify
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../sshpk/bin/sshpk-verify" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../sshpk/bin/sshpk-verify" "$@"
|
||||||
|
fi
|
17
node_modules/.bin/sshpk-verify.cmd
generated
vendored
Normal file
17
node_modules/.bin/sshpk-verify.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\sshpk\bin\sshpk-verify" %*
|
28
node_modules/.bin/sshpk-verify.ps1
generated
vendored
Normal file
28
node_modules/.bin/sshpk-verify.ps1
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../sshpk/bin/sshpk-verify" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../sshpk/bin/sshpk-verify" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../sshpk/bin/sshpk-verify" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../sshpk/bin/sshpk-verify" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
12
node_modules/.bin/uuid
generated
vendored
Normal file
12
node_modules/.bin/uuid
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../uuid/bin/uuid" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../uuid/bin/uuid" "$@"
|
||||||
|
fi
|
17
node_modules/.bin/uuid.cmd
generated
vendored
Normal file
17
node_modules/.bin/uuid.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\uuid\bin\uuid" %*
|
28
node_modules/.bin/uuid.ps1
generated
vendored
Normal file
28
node_modules/.bin/uuid.ps1
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../uuid/bin/uuid" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../uuid/bin/uuid" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../uuid/bin/uuid" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../uuid/bin/uuid" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
2182
node_modules/.package-lock.json
generated
vendored
Normal file
2182
node_modules/.package-lock.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
132
node_modules/@sindresorhus/is/dist/index.d.ts
generated
vendored
Normal file
132
node_modules/@sindresorhus/is/dist/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
/// <reference types="node" />
|
||||||
|
/// <reference lib="es2016" />
|
||||||
|
/// <reference lib="es2017.sharedmemory" />
|
||||||
|
/// <reference lib="esnext.asynciterable" />
|
||||||
|
/// <reference lib="dom" />
|
||||||
|
declare type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
|
||||||
|
declare type Primitive = null | undefined | string | number | boolean | Symbol;
|
||||||
|
export interface ArrayLike {
|
||||||
|
length: number;
|
||||||
|
}
|
||||||
|
export interface Class<T = unknown> {
|
||||||
|
new (...args: any[]): T;
|
||||||
|
}
|
||||||
|
declare type DomElement = object & {
|
||||||
|
nodeType: 1;
|
||||||
|
nodeName: string;
|
||||||
|
};
|
||||||
|
declare type NodeStream = object & {
|
||||||
|
pipe: Function;
|
||||||
|
};
|
||||||
|
export declare const enum TypeName {
|
||||||
|
null = "null",
|
||||||
|
boolean = "boolean",
|
||||||
|
undefined = "undefined",
|
||||||
|
string = "string",
|
||||||
|
number = "number",
|
||||||
|
symbol = "symbol",
|
||||||
|
Function = "Function",
|
||||||
|
GeneratorFunction = "GeneratorFunction",
|
||||||
|
AsyncFunction = "AsyncFunction",
|
||||||
|
Observable = "Observable",
|
||||||
|
Array = "Array",
|
||||||
|
Buffer = "Buffer",
|
||||||
|
Object = "Object",
|
||||||
|
RegExp = "RegExp",
|
||||||
|
Date = "Date",
|
||||||
|
Error = "Error",
|
||||||
|
Map = "Map",
|
||||||
|
Set = "Set",
|
||||||
|
WeakMap = "WeakMap",
|
||||||
|
WeakSet = "WeakSet",
|
||||||
|
Int8Array = "Int8Array",
|
||||||
|
Uint8Array = "Uint8Array",
|
||||||
|
Uint8ClampedArray = "Uint8ClampedArray",
|
||||||
|
Int16Array = "Int16Array",
|
||||||
|
Uint16Array = "Uint16Array",
|
||||||
|
Int32Array = "Int32Array",
|
||||||
|
Uint32Array = "Uint32Array",
|
||||||
|
Float32Array = "Float32Array",
|
||||||
|
Float64Array = "Float64Array",
|
||||||
|
ArrayBuffer = "ArrayBuffer",
|
||||||
|
SharedArrayBuffer = "SharedArrayBuffer",
|
||||||
|
DataView = "DataView",
|
||||||
|
Promise = "Promise",
|
||||||
|
URL = "URL"
|
||||||
|
}
|
||||||
|
declare function is(value: unknown): TypeName;
|
||||||
|
declare namespace is {
|
||||||
|
const undefined: (value: unknown) => value is undefined;
|
||||||
|
const string: (value: unknown) => value is string;
|
||||||
|
const number: (value: unknown) => value is number;
|
||||||
|
const function_: (value: unknown) => value is Function;
|
||||||
|
const null_: (value: unknown) => value is null;
|
||||||
|
const class_: (value: unknown) => value is Class<unknown>;
|
||||||
|
const boolean: (value: unknown) => value is boolean;
|
||||||
|
const symbol: (value: unknown) => value is Symbol;
|
||||||
|
const numericString: (value: unknown) => boolean;
|
||||||
|
const array: (arg: any) => arg is any[];
|
||||||
|
const buffer: (input: unknown) => input is Buffer;
|
||||||
|
const nullOrUndefined: (value: unknown) => value is null | undefined;
|
||||||
|
const object: (value: unknown) => value is object;
|
||||||
|
const iterable: (value: unknown) => value is IterableIterator<unknown>;
|
||||||
|
const asyncIterable: (value: unknown) => value is AsyncIterableIterator<unknown>;
|
||||||
|
const generator: (value: unknown) => value is Generator;
|
||||||
|
const nativePromise: (value: unknown) => value is Promise<unknown>;
|
||||||
|
const promise: (value: unknown) => value is Promise<unknown>;
|
||||||
|
const generatorFunction: (value: unknown) => value is GeneratorFunction;
|
||||||
|
const asyncFunction: (value: unknown) => value is Function;
|
||||||
|
const boundFunction: (value: unknown) => value is Function;
|
||||||
|
const regExp: (value: unknown) => value is RegExp;
|
||||||
|
const date: (value: unknown) => value is Date;
|
||||||
|
const error: (value: unknown) => value is Error;
|
||||||
|
const map: (value: unknown) => value is Map<unknown, unknown>;
|
||||||
|
const set: (value: unknown) => value is Set<unknown>;
|
||||||
|
const weakMap: (value: unknown) => value is WeakMap<object, unknown>;
|
||||||
|
const weakSet: (value: unknown) => value is WeakSet<object>;
|
||||||
|
const int8Array: (value: unknown) => value is Int8Array;
|
||||||
|
const uint8Array: (value: unknown) => value is Uint8Array;
|
||||||
|
const uint8ClampedArray: (value: unknown) => value is Uint8ClampedArray;
|
||||||
|
const int16Array: (value: unknown) => value is Int16Array;
|
||||||
|
const uint16Array: (value: unknown) => value is Uint16Array;
|
||||||
|
const int32Array: (value: unknown) => value is Int32Array;
|
||||||
|
const uint32Array: (value: unknown) => value is Uint32Array;
|
||||||
|
const float32Array: (value: unknown) => value is Float32Array;
|
||||||
|
const float64Array: (value: unknown) => value is Float64Array;
|
||||||
|
const arrayBuffer: (value: unknown) => value is ArrayBuffer;
|
||||||
|
const sharedArrayBuffer: (value: unknown) => value is SharedArrayBuffer;
|
||||||
|
const dataView: (value: unknown) => value is DataView;
|
||||||
|
const directInstanceOf: <T>(instance: unknown, klass: Class<T>) => instance is T;
|
||||||
|
const urlInstance: (value: unknown) => value is URL;
|
||||||
|
const urlString: (value: unknown) => boolean;
|
||||||
|
const truthy: (value: unknown) => boolean;
|
||||||
|
const falsy: (value: unknown) => boolean;
|
||||||
|
const nan: (value: unknown) => boolean;
|
||||||
|
const primitive: (value: unknown) => value is Primitive;
|
||||||
|
const integer: (value: unknown) => value is number;
|
||||||
|
const safeInteger: (value: unknown) => value is number;
|
||||||
|
const plainObject: (value: unknown) => boolean;
|
||||||
|
const typedArray: (value: unknown) => value is TypedArray;
|
||||||
|
const arrayLike: (value: unknown) => value is ArrayLike;
|
||||||
|
const inRange: (value: number, range: number | number[]) => boolean;
|
||||||
|
const domElement: (value: unknown) => value is DomElement;
|
||||||
|
const observable: (value: unknown) => boolean;
|
||||||
|
const nodeStream: (value: unknown) => value is NodeStream;
|
||||||
|
const infinite: (value: unknown) => boolean;
|
||||||
|
const even: (value: number) => boolean;
|
||||||
|
const odd: (value: number) => boolean;
|
||||||
|
const emptyArray: (value: unknown) => boolean;
|
||||||
|
const nonEmptyArray: (value: unknown) => boolean;
|
||||||
|
const emptyString: (value: unknown) => boolean;
|
||||||
|
const nonEmptyString: (value: unknown) => boolean;
|
||||||
|
const emptyStringOrWhitespace: (value: unknown) => boolean;
|
||||||
|
const emptyObject: (value: unknown) => boolean;
|
||||||
|
const nonEmptyObject: (value: unknown) => boolean;
|
||||||
|
const emptySet: (value: unknown) => boolean;
|
||||||
|
const nonEmptySet: (value: unknown) => boolean;
|
||||||
|
const emptyMap: (value: unknown) => boolean;
|
||||||
|
const nonEmptyMap: (value: unknown) => boolean;
|
||||||
|
const any: (predicate: unknown, ...values: unknown[]) => boolean;
|
||||||
|
const all: (predicate: unknown, ...values: unknown[]) => boolean;
|
||||||
|
}
|
||||||
|
export default is;
|
245
node_modules/@sindresorhus/is/dist/index.js
generated
vendored
Normal file
245
node_modules/@sindresorhus/is/dist/index.js
generated
vendored
Normal file
@ -0,0 +1,245 @@
|
|||||||
|
"use strict";
|
||||||
|
/// <reference lib="es2016"/>
|
||||||
|
/// <reference lib="es2017.sharedmemory"/>
|
||||||
|
/// <reference lib="esnext.asynciterable"/>
|
||||||
|
/// <reference lib="dom"/>
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
// TODO: Use the `URL` global when targeting Node.js 10
|
||||||
|
// tslint:disable-next-line
|
||||||
|
const URLGlobal = typeof URL === 'undefined' ? require('url').URL : URL;
|
||||||
|
const toString = Object.prototype.toString;
|
||||||
|
const isOfType = (type) => (value) => typeof value === type;
|
||||||
|
const isBuffer = (input) => !is.nullOrUndefined(input) && !is.nullOrUndefined(input.constructor) && is.function_(input.constructor.isBuffer) && input.constructor.isBuffer(input);
|
||||||
|
const getObjectType = (value) => {
|
||||||
|
const objectName = toString.call(value).slice(8, -1);
|
||||||
|
if (objectName) {
|
||||||
|
return objectName;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
const isObjectOfType = (type) => (value) => getObjectType(value) === type;
|
||||||
|
function is(value) {
|
||||||
|
switch (value) {
|
||||||
|
case null:
|
||||||
|
return "null" /* null */;
|
||||||
|
case true:
|
||||||
|
case false:
|
||||||
|
return "boolean" /* boolean */;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
switch (typeof value) {
|
||||||
|
case 'undefined':
|
||||||
|
return "undefined" /* undefined */;
|
||||||
|
case 'string':
|
||||||
|
return "string" /* string */;
|
||||||
|
case 'number':
|
||||||
|
return "number" /* number */;
|
||||||
|
case 'symbol':
|
||||||
|
return "symbol" /* symbol */;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
if (is.function_(value)) {
|
||||||
|
return "Function" /* Function */;
|
||||||
|
}
|
||||||
|
if (is.observable(value)) {
|
||||||
|
return "Observable" /* Observable */;
|
||||||
|
}
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
return "Array" /* Array */;
|
||||||
|
}
|
||||||
|
if (isBuffer(value)) {
|
||||||
|
return "Buffer" /* Buffer */;
|
||||||
|
}
|
||||||
|
const tagType = getObjectType(value);
|
||||||
|
if (tagType) {
|
||||||
|
return tagType;
|
||||||
|
}
|
||||||
|
if (value instanceof String || value instanceof Boolean || value instanceof Number) {
|
||||||
|
throw new TypeError('Please don\'t use object wrappers for primitive types');
|
||||||
|
}
|
||||||
|
return "Object" /* Object */;
|
||||||
|
}
|
||||||
|
(function (is) {
|
||||||
|
// tslint:disable-next-line:strict-type-predicates
|
||||||
|
const isObject = (value) => typeof value === 'object';
|
||||||
|
// tslint:disable:variable-name
|
||||||
|
is.undefined = isOfType('undefined');
|
||||||
|
is.string = isOfType('string');
|
||||||
|
is.number = isOfType('number');
|
||||||
|
is.function_ = isOfType('function');
|
||||||
|
// tslint:disable-next-line:strict-type-predicates
|
||||||
|
is.null_ = (value) => value === null;
|
||||||
|
is.class_ = (value) => is.function_(value) && value.toString().startsWith('class ');
|
||||||
|
is.boolean = (value) => value === true || value === false;
|
||||||
|
is.symbol = isOfType('symbol');
|
||||||
|
// tslint:enable:variable-name
|
||||||
|
is.numericString = (value) => is.string(value) && value.length > 0 && !Number.isNaN(Number(value));
|
||||||
|
is.array = Array.isArray;
|
||||||
|
is.buffer = isBuffer;
|
||||||
|
is.nullOrUndefined = (value) => is.null_(value) || is.undefined(value);
|
||||||
|
is.object = (value) => !is.nullOrUndefined(value) && (is.function_(value) || isObject(value));
|
||||||
|
is.iterable = (value) => !is.nullOrUndefined(value) && is.function_(value[Symbol.iterator]);
|
||||||
|
is.asyncIterable = (value) => !is.nullOrUndefined(value) && is.function_(value[Symbol.asyncIterator]);
|
||||||
|
is.generator = (value) => is.iterable(value) && is.function_(value.next) && is.function_(value.throw);
|
||||||
|
is.nativePromise = (value) => isObjectOfType("Promise" /* Promise */)(value);
|
||||||
|
const hasPromiseAPI = (value) => !is.null_(value) &&
|
||||||
|
isObject(value) &&
|
||||||
|
is.function_(value.then) &&
|
||||||
|
is.function_(value.catch);
|
||||||
|
is.promise = (value) => is.nativePromise(value) || hasPromiseAPI(value);
|
||||||
|
is.generatorFunction = isObjectOfType("GeneratorFunction" /* GeneratorFunction */);
|
||||||
|
is.asyncFunction = isObjectOfType("AsyncFunction" /* AsyncFunction */);
|
||||||
|
is.boundFunction = (value) => is.function_(value) && !value.hasOwnProperty('prototype');
|
||||||
|
is.regExp = isObjectOfType("RegExp" /* RegExp */);
|
||||||
|
is.date = isObjectOfType("Date" /* Date */);
|
||||||
|
is.error = isObjectOfType("Error" /* Error */);
|
||||||
|
is.map = (value) => isObjectOfType("Map" /* Map */)(value);
|
||||||
|
is.set = (value) => isObjectOfType("Set" /* Set */)(value);
|
||||||
|
is.weakMap = (value) => isObjectOfType("WeakMap" /* WeakMap */)(value);
|
||||||
|
is.weakSet = (value) => isObjectOfType("WeakSet" /* WeakSet */)(value);
|
||||||
|
is.int8Array = isObjectOfType("Int8Array" /* Int8Array */);
|
||||||
|
is.uint8Array = isObjectOfType("Uint8Array" /* Uint8Array */);
|
||||||
|
is.uint8ClampedArray = isObjectOfType("Uint8ClampedArray" /* Uint8ClampedArray */);
|
||||||
|
is.int16Array = isObjectOfType("Int16Array" /* Int16Array */);
|
||||||
|
is.uint16Array = isObjectOfType("Uint16Array" /* Uint16Array */);
|
||||||
|
is.int32Array = isObjectOfType("Int32Array" /* Int32Array */);
|
||||||
|
is.uint32Array = isObjectOfType("Uint32Array" /* Uint32Array */);
|
||||||
|
is.float32Array = isObjectOfType("Float32Array" /* Float32Array */);
|
||||||
|
is.float64Array = isObjectOfType("Float64Array" /* Float64Array */);
|
||||||
|
is.arrayBuffer = isObjectOfType("ArrayBuffer" /* ArrayBuffer */);
|
||||||
|
is.sharedArrayBuffer = isObjectOfType("SharedArrayBuffer" /* SharedArrayBuffer */);
|
||||||
|
is.dataView = isObjectOfType("DataView" /* DataView */);
|
||||||
|
is.directInstanceOf = (instance, klass) => Object.getPrototypeOf(instance) === klass.prototype;
|
||||||
|
is.urlInstance = (value) => isObjectOfType("URL" /* URL */)(value);
|
||||||
|
is.urlString = (value) => {
|
||||||
|
if (!is.string(value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
new URLGlobal(value); // tslint:disable-line no-unused-expression
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (_a) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
is.truthy = (value) => Boolean(value);
|
||||||
|
is.falsy = (value) => !value;
|
||||||
|
is.nan = (value) => Number.isNaN(value);
|
||||||
|
const primitiveTypes = new Set([
|
||||||
|
'undefined',
|
||||||
|
'string',
|
||||||
|
'number',
|
||||||
|
'boolean',
|
||||||
|
'symbol'
|
||||||
|
]);
|
||||||
|
is.primitive = (value) => is.null_(value) || primitiveTypes.has(typeof value);
|
||||||
|
is.integer = (value) => Number.isInteger(value);
|
||||||
|
is.safeInteger = (value) => Number.isSafeInteger(value);
|
||||||
|
is.plainObject = (value) => {
|
||||||
|
// From: https://github.com/sindresorhus/is-plain-obj/blob/master/index.js
|
||||||
|
let prototype;
|
||||||
|
return getObjectType(value) === "Object" /* Object */ &&
|
||||||
|
(prototype = Object.getPrototypeOf(value), prototype === null || // tslint:disable-line:ban-comma-operator
|
||||||
|
prototype === Object.getPrototypeOf({}));
|
||||||
|
};
|
||||||
|
const typedArrayTypes = new Set([
|
||||||
|
"Int8Array" /* Int8Array */,
|
||||||
|
"Uint8Array" /* Uint8Array */,
|
||||||
|
"Uint8ClampedArray" /* Uint8ClampedArray */,
|
||||||
|
"Int16Array" /* Int16Array */,
|
||||||
|
"Uint16Array" /* Uint16Array */,
|
||||||
|
"Int32Array" /* Int32Array */,
|
||||||
|
"Uint32Array" /* Uint32Array */,
|
||||||
|
"Float32Array" /* Float32Array */,
|
||||||
|
"Float64Array" /* Float64Array */
|
||||||
|
]);
|
||||||
|
is.typedArray = (value) => {
|
||||||
|
const objectType = getObjectType(value);
|
||||||
|
if (objectType === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return typedArrayTypes.has(objectType);
|
||||||
|
};
|
||||||
|
const isValidLength = (value) => is.safeInteger(value) && value > -1;
|
||||||
|
is.arrayLike = (value) => !is.nullOrUndefined(value) && !is.function_(value) && isValidLength(value.length);
|
||||||
|
is.inRange = (value, range) => {
|
||||||
|
if (is.number(range)) {
|
||||||
|
return value >= Math.min(0, range) && value <= Math.max(range, 0);
|
||||||
|
}
|
||||||
|
if (is.array(range) && range.length === 2) {
|
||||||
|
return value >= Math.min(...range) && value <= Math.max(...range);
|
||||||
|
}
|
||||||
|
throw new TypeError(`Invalid range: ${JSON.stringify(range)}`);
|
||||||
|
};
|
||||||
|
const NODE_TYPE_ELEMENT = 1;
|
||||||
|
const DOM_PROPERTIES_TO_CHECK = [
|
||||||
|
'innerHTML',
|
||||||
|
'ownerDocument',
|
||||||
|
'style',
|
||||||
|
'attributes',
|
||||||
|
'nodeValue'
|
||||||
|
];
|
||||||
|
is.domElement = (value) => is.object(value) && value.nodeType === NODE_TYPE_ELEMENT && is.string(value.nodeName) &&
|
||||||
|
!is.plainObject(value) && DOM_PROPERTIES_TO_CHECK.every(property => property in value);
|
||||||
|
is.observable = (value) => {
|
||||||
|
if (!value) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (value[Symbol.observable] && value === value[Symbol.observable]()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (value['@@observable'] && value === value['@@observable']()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
is.nodeStream = (value) => !is.nullOrUndefined(value) && isObject(value) && is.function_(value.pipe) && !is.observable(value);
|
||||||
|
is.infinite = (value) => value === Infinity || value === -Infinity;
|
||||||
|
const isAbsoluteMod2 = (rem) => (value) => is.integer(value) && Math.abs(value % 2) === rem;
|
||||||
|
is.even = isAbsoluteMod2(0);
|
||||||
|
is.odd = isAbsoluteMod2(1);
|
||||||
|
const isWhiteSpaceString = (value) => is.string(value) && /\S/.test(value) === false;
|
||||||
|
is.emptyArray = (value) => is.array(value) && value.length === 0;
|
||||||
|
is.nonEmptyArray = (value) => is.array(value) && value.length > 0;
|
||||||
|
is.emptyString = (value) => is.string(value) && value.length === 0;
|
||||||
|
is.nonEmptyString = (value) => is.string(value) && value.length > 0;
|
||||||
|
is.emptyStringOrWhitespace = (value) => is.emptyString(value) || isWhiteSpaceString(value);
|
||||||
|
is.emptyObject = (value) => is.object(value) && !is.map(value) && !is.set(value) && Object.keys(value).length === 0;
|
||||||
|
is.nonEmptyObject = (value) => is.object(value) && !is.map(value) && !is.set(value) && Object.keys(value).length > 0;
|
||||||
|
is.emptySet = (value) => is.set(value) && value.size === 0;
|
||||||
|
is.nonEmptySet = (value) => is.set(value) && value.size > 0;
|
||||||
|
is.emptyMap = (value) => is.map(value) && value.size === 0;
|
||||||
|
is.nonEmptyMap = (value) => is.map(value) && value.size > 0;
|
||||||
|
const predicateOnArray = (method, predicate, values) => {
|
||||||
|
if (is.function_(predicate) === false) {
|
||||||
|
throw new TypeError(`Invalid predicate: ${JSON.stringify(predicate)}`);
|
||||||
|
}
|
||||||
|
if (values.length === 0) {
|
||||||
|
throw new TypeError('Invalid number of values');
|
||||||
|
}
|
||||||
|
return method.call(values, predicate);
|
||||||
|
};
|
||||||
|
// tslint:disable variable-name
|
||||||
|
is.any = (predicate, ...values) => predicateOnArray(Array.prototype.some, predicate, values);
|
||||||
|
is.all = (predicate, ...values) => predicateOnArray(Array.prototype.every, predicate, values);
|
||||||
|
// tslint:enable variable-name
|
||||||
|
})(is || (is = {}));
|
||||||
|
// Some few keywords are reserved, but we'll populate them for Node.js users
|
||||||
|
// See https://github.com/Microsoft/TypeScript/issues/2536
|
||||||
|
Object.defineProperties(is, {
|
||||||
|
class: {
|
||||||
|
value: is.class_
|
||||||
|
},
|
||||||
|
function: {
|
||||||
|
value: is.function_
|
||||||
|
},
|
||||||
|
null: {
|
||||||
|
value: is.null_
|
||||||
|
}
|
||||||
|
});
|
||||||
|
exports.default = is;
|
||||||
|
// For CommonJS default export support
|
||||||
|
module.exports = is;
|
||||||
|
module.exports.default = is;
|
||||||
|
//# sourceMappingURL=index.js.map
|
1
node_modules/@sindresorhus/is/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@sindresorhus/is/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
9
node_modules/@sindresorhus/is/license
generated
vendored
Normal file
9
node_modules/@sindresorhus/is/license
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
63
node_modules/@sindresorhus/is/package.json
generated
vendored
Normal file
63
node_modules/@sindresorhus/is/package.json
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
{
|
||||||
|
"name": "@sindresorhus/is",
|
||||||
|
"version": "0.14.0",
|
||||||
|
"description": "Type check values: `is.string('🦄') //=> true`",
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "sindresorhus/is",
|
||||||
|
"author": {
|
||||||
|
"name": "Sindre Sorhus",
|
||||||
|
"email": "sindresorhus@gmail.com",
|
||||||
|
"url": "sindresorhus.com"
|
||||||
|
},
|
||||||
|
"main": "dist/index.js",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"lint": "tslint --format stylish --project .",
|
||||||
|
"build": "del dist && tsc",
|
||||||
|
"test": "npm run lint && npm run build && ava dist/tests",
|
||||||
|
"prepublish": "npm run build && del dist/tests"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"type",
|
||||||
|
"types",
|
||||||
|
"is",
|
||||||
|
"check",
|
||||||
|
"checking",
|
||||||
|
"validate",
|
||||||
|
"validation",
|
||||||
|
"utility",
|
||||||
|
"util",
|
||||||
|
"typeof",
|
||||||
|
"instanceof",
|
||||||
|
"object",
|
||||||
|
"assert",
|
||||||
|
"assertion",
|
||||||
|
"test",
|
||||||
|
"kind",
|
||||||
|
"primitive",
|
||||||
|
"verify",
|
||||||
|
"compare"
|
||||||
|
],
|
||||||
|
"devDependencies": {
|
||||||
|
"@sindresorhus/tsconfig": "^0.1.0",
|
||||||
|
"@types/jsdom": "^11.12.0",
|
||||||
|
"@types/node": "^10.12.10",
|
||||||
|
"@types/tempy": "^0.2.0",
|
||||||
|
"@types/zen-observable": "^0.8.0",
|
||||||
|
"ava": "^0.25.0",
|
||||||
|
"del-cli": "^1.1.0",
|
||||||
|
"jsdom": "^11.6.2",
|
||||||
|
"rxjs": "^6.3.3",
|
||||||
|
"tempy": "^0.2.1",
|
||||||
|
"tslint": "^5.9.1",
|
||||||
|
"tslint-xo": "^0.10.0",
|
||||||
|
"typescript": "^3.2.1",
|
||||||
|
"zen-observable": "^0.8.8"
|
||||||
|
},
|
||||||
|
"types": "dist/index.d.ts"
|
||||||
|
}
|
451
node_modules/@sindresorhus/is/readme.md
generated
vendored
Normal file
451
node_modules/@sindresorhus/is/readme.md
generated
vendored
Normal file
@ -0,0 +1,451 @@
|
|||||||
|
# is [![Build Status](https://travis-ci.org/sindresorhus/is.svg?branch=master)](https://travis-ci.org/sindresorhus/is)
|
||||||
|
|
||||||
|
> Type check values: `is.string('🦄') //=> true`
|
||||||
|
|
||||||
|
<img src="header.gif" width="182" align="right">
|
||||||
|
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```
|
||||||
|
$ npm install @sindresorhus/is
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
const is = require('@sindresorhus/is');
|
||||||
|
|
||||||
|
is('🦄');
|
||||||
|
//=> 'string'
|
||||||
|
|
||||||
|
is(new Map());
|
||||||
|
//=> 'Map'
|
||||||
|
|
||||||
|
is.number(6);
|
||||||
|
//=> true
|
||||||
|
```
|
||||||
|
|
||||||
|
When using `is` together with TypeScript, [type guards](http://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types) are being used to infer the correct type inside if-else statements.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import is from '@sindresorhus/is';
|
||||||
|
|
||||||
|
const padLeft = (value: string, padding: string | number) => {
|
||||||
|
if (is.number(padding)) {
|
||||||
|
// `padding` is typed as `number`
|
||||||
|
return Array(padding + 1).join(' ') + value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is.string(padding)) {
|
||||||
|
// `padding` is typed as `string`
|
||||||
|
return padding + value;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new TypeError(`Expected 'padding' to be of type 'string' or 'number', got '${is(padding)}'.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
padLeft('🦄', 3);
|
||||||
|
//=> ' 🦄'
|
||||||
|
|
||||||
|
padLeft('🦄', '🌈');
|
||||||
|
//=> '🌈🦄'
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
### is(value)
|
||||||
|
|
||||||
|
Returns the type of `value`.
|
||||||
|
|
||||||
|
Primitives are lowercase and object types are camelcase.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
- `'undefined'`
|
||||||
|
- `'null'`
|
||||||
|
- `'string'`
|
||||||
|
- `'symbol'`
|
||||||
|
- `'Array'`
|
||||||
|
- `'Function'`
|
||||||
|
- `'Object'`
|
||||||
|
|
||||||
|
Note: It will throw an error if you try to feed it object-wrapped primitives, as that's a bad practice. For example `new String('foo')`.
|
||||||
|
|
||||||
|
### is.{method}
|
||||||
|
|
||||||
|
All the below methods accept a value and returns a boolean for whether the value is of the desired type.
|
||||||
|
|
||||||
|
#### Primitives
|
||||||
|
|
||||||
|
##### .undefined(value)
|
||||||
|
##### .null(value)
|
||||||
|
##### .string(value)
|
||||||
|
##### .number(value)
|
||||||
|
##### .boolean(value)
|
||||||
|
##### .symbol(value)
|
||||||
|
|
||||||
|
#### Built-in types
|
||||||
|
|
||||||
|
##### .array(value)
|
||||||
|
##### .function(value)
|
||||||
|
##### .buffer(value)
|
||||||
|
##### .object(value)
|
||||||
|
|
||||||
|
Keep in mind that [functions are objects too](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions).
|
||||||
|
|
||||||
|
##### .numericString(value)
|
||||||
|
|
||||||
|
Returns `true` for a string that represents a number. For example, `'42'` and `'-8'`.
|
||||||
|
|
||||||
|
Note: `'NaN'` returns `false`, but `'Infinity'` and `'-Infinity'` return `true`.
|
||||||
|
|
||||||
|
##### .regExp(value)
|
||||||
|
##### .date(value)
|
||||||
|
##### .error(value)
|
||||||
|
##### .nativePromise(value)
|
||||||
|
##### .promise(value)
|
||||||
|
|
||||||
|
Returns `true` for any object with a `.then()` and `.catch()` method. Prefer this one over `.nativePromise()` as you usually want to allow userland promise implementations too.
|
||||||
|
|
||||||
|
##### .generator(value)
|
||||||
|
|
||||||
|
Returns `true` for any object that implements its own `.next()` and `.throw()` methods and has a function definition for `Symbol.iterator`.
|
||||||
|
|
||||||
|
##### .generatorFunction(value)
|
||||||
|
|
||||||
|
##### .asyncFunction(value)
|
||||||
|
|
||||||
|
Returns `true` for any `async` function that can be called with the `await` operator.
|
||||||
|
|
||||||
|
```js
|
||||||
|
is.asyncFunction(async () => {});
|
||||||
|
// => true
|
||||||
|
|
||||||
|
is.asyncFunction(() => {});
|
||||||
|
// => false
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .boundFunction(value)
|
||||||
|
|
||||||
|
Returns `true` for any `bound` function.
|
||||||
|
|
||||||
|
```js
|
||||||
|
is.boundFunction(() => {});
|
||||||
|
// => true
|
||||||
|
|
||||||
|
is.boundFunction(function () {}.bind(null));
|
||||||
|
// => true
|
||||||
|
|
||||||
|
is.boundFunction(function () {});
|
||||||
|
// => false
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .map(value)
|
||||||
|
##### .set(value)
|
||||||
|
##### .weakMap(value)
|
||||||
|
##### .weakSet(value)
|
||||||
|
|
||||||
|
#### Typed arrays
|
||||||
|
|
||||||
|
##### .int8Array(value)
|
||||||
|
##### .uint8Array(value)
|
||||||
|
##### .uint8ClampedArray(value)
|
||||||
|
##### .int16Array(value)
|
||||||
|
##### .uint16Array(value)
|
||||||
|
##### .int32Array(value)
|
||||||
|
##### .uint32Array(value)
|
||||||
|
##### .float32Array(value)
|
||||||
|
##### .float64Array(value)
|
||||||
|
|
||||||
|
#### Structured data
|
||||||
|
|
||||||
|
##### .arrayBuffer(value)
|
||||||
|
##### .sharedArrayBuffer(value)
|
||||||
|
##### .dataView(value)
|
||||||
|
|
||||||
|
#### Emptiness
|
||||||
|
|
||||||
|
##### .emptyString(value)
|
||||||
|
|
||||||
|
Returns `true` if the value is a `string` and the `.length` is 0.
|
||||||
|
|
||||||
|
##### .nonEmptyString(value)
|
||||||
|
|
||||||
|
Returns `true` if the value is a `string` and the `.length` is more than 0.
|
||||||
|
|
||||||
|
##### .emptyStringOrWhitespace(value)
|
||||||
|
|
||||||
|
Returns `true` if `is.emptyString(value)` or if it's a `string` that is all whitespace.
|
||||||
|
|
||||||
|
##### .emptyArray(value)
|
||||||
|
|
||||||
|
Returns `true` if the value is an `Array` and the `.length` is 0.
|
||||||
|
|
||||||
|
##### .nonEmptyArray(value)
|
||||||
|
|
||||||
|
Returns `true` if the value is an `Array` and the `.length` is more than 0.
|
||||||
|
|
||||||
|
##### .emptyObject(value)
|
||||||
|
|
||||||
|
Returns `true` if the value is an `Object` and `Object.keys(value).length` is 0.
|
||||||
|
|
||||||
|
Please note that `Object.keys` returns only own enumerable properties. Hence something like this can happen:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const object1 = {};
|
||||||
|
|
||||||
|
Object.defineProperty(object1, 'property1', {
|
||||||
|
value: 42,
|
||||||
|
writable: true,
|
||||||
|
enumerable: false,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
|
||||||
|
is.emptyObject(object1);
|
||||||
|
// => true
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .nonEmptyObject(value)
|
||||||
|
|
||||||
|
Returns `true` if the value is an `Object` and `Object.keys(value).length` is more than 0.
|
||||||
|
|
||||||
|
##### .emptySet(value)
|
||||||
|
|
||||||
|
Returns `true` if the value is a `Set` and the `.size` is 0.
|
||||||
|
|
||||||
|
##### .nonEmptySet(Value)
|
||||||
|
|
||||||
|
Returns `true` if the value is a `Set` and the `.size` is more than 0.
|
||||||
|
|
||||||
|
##### .emptyMap(value)
|
||||||
|
|
||||||
|
Returns `true` if the value is a `Map` and the `.size` is 0.
|
||||||
|
|
||||||
|
##### .nonEmptyMap(value)
|
||||||
|
|
||||||
|
Returns `true` if the value is a `Map` and the `.size` is more than 0.
|
||||||
|
|
||||||
|
#### Miscellaneous
|
||||||
|
|
||||||
|
##### .directInstanceOf(value, class)
|
||||||
|
|
||||||
|
Returns `true` if `value` is a direct instance of `class`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
is.directInstanceOf(new Error(), Error);
|
||||||
|
//=> true
|
||||||
|
|
||||||
|
class UnicornError extends Error {}
|
||||||
|
|
||||||
|
is.directInstanceOf(new UnicornError(), Error);
|
||||||
|
//=> false
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .urlInstance(value)
|
||||||
|
|
||||||
|
Returns `true` if `value` is an instance of the [`URL` class](https://developer.mozilla.org/en-US/docs/Web/API/URL).
|
||||||
|
|
||||||
|
```js
|
||||||
|
const url = new URL('https://example.com');
|
||||||
|
|
||||||
|
is.urlInstance(url);
|
||||||
|
//=> true
|
||||||
|
```
|
||||||
|
|
||||||
|
### .url(value)
|
||||||
|
|
||||||
|
Returns `true` if `value` is a URL string.
|
||||||
|
|
||||||
|
Note: this only does basic checking using the [`URL` class](https://developer.mozilla.org/en-US/docs/Web/API/URL) constructor.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const url = 'https://example.com';
|
||||||
|
|
||||||
|
is.url(url);
|
||||||
|
//=> true
|
||||||
|
|
||||||
|
is.url(new URL(url));
|
||||||
|
//=> false
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .truthy(value)
|
||||||
|
|
||||||
|
Returns `true` for all values that evaluate to true in a boolean context:
|
||||||
|
|
||||||
|
```js
|
||||||
|
is.truthy('🦄');
|
||||||
|
//=> true
|
||||||
|
|
||||||
|
is.truthy(undefined);
|
||||||
|
//=> false
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .falsy(value)
|
||||||
|
|
||||||
|
Returns `true` if `value` is one of: `false`, `0`, `''`, `null`, `undefined`, `NaN`.
|
||||||
|
|
||||||
|
##### .nan(value)
|
||||||
|
##### .nullOrUndefined(value)
|
||||||
|
##### .primitive(value)
|
||||||
|
|
||||||
|
JavaScript primitives are as follows: `null`, `undefined`, `string`, `number`, `boolean`, `symbol`.
|
||||||
|
|
||||||
|
##### .integer(value)
|
||||||
|
|
||||||
|
##### .safeInteger(value)
|
||||||
|
|
||||||
|
Returns `true` if `value` is a [safe integer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger).
|
||||||
|
|
||||||
|
##### .plainObject(value)
|
||||||
|
|
||||||
|
An object is plain if it's created by either `{}`, `new Object()`, or `Object.create(null)`.
|
||||||
|
|
||||||
|
##### .iterable(value)
|
||||||
|
##### .asyncIterable(value)
|
||||||
|
##### .class(value)
|
||||||
|
|
||||||
|
Returns `true` for instances created by a class.
|
||||||
|
|
||||||
|
##### .typedArray(value)
|
||||||
|
|
||||||
|
##### .arrayLike(value)
|
||||||
|
|
||||||
|
A `value` is array-like if it is not a function and has a `value.length` that is a safe integer greater than or equal to 0.
|
||||||
|
|
||||||
|
```js
|
||||||
|
is.arrayLike(document.forms);
|
||||||
|
//=> true
|
||||||
|
|
||||||
|
function foo() {
|
||||||
|
is.arrayLike(arguments);
|
||||||
|
//=> true
|
||||||
|
}
|
||||||
|
foo();
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .inRange(value, range)
|
||||||
|
|
||||||
|
Check if `value` (number) is in the given `range`. The range is an array of two values, lower bound and upper bound, in no specific order.
|
||||||
|
|
||||||
|
```js
|
||||||
|
is.inRange(3, [0, 5]);
|
||||||
|
is.inRange(3, [5, 0]);
|
||||||
|
is.inRange(0, [-2, 2]);
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .inRange(value, upperBound)
|
||||||
|
|
||||||
|
Check if `value` (number) is in the range of `0` to `upperBound`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
is.inRange(3, 10);
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .domElement(value)
|
||||||
|
|
||||||
|
Returns `true` if `value` is a DOM Element.
|
||||||
|
|
||||||
|
##### .nodeStream(value)
|
||||||
|
|
||||||
|
Returns `true` if `value` is a Node.js [stream](https://nodejs.org/api/stream.html).
|
||||||
|
|
||||||
|
```js
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
is.nodeStream(fs.createReadStream('unicorn.png'));
|
||||||
|
//=> true
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .observable(value)
|
||||||
|
|
||||||
|
Returns `true` if `value` is an `Observable`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const {Observable} = require('rxjs');
|
||||||
|
|
||||||
|
is.observable(new Observable());
|
||||||
|
//=> true
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .infinite(value)
|
||||||
|
|
||||||
|
Check if `value` is `Infinity` or `-Infinity`.
|
||||||
|
|
||||||
|
##### .even(value)
|
||||||
|
|
||||||
|
Returns `true` if `value` is an even integer.
|
||||||
|
|
||||||
|
##### .odd(value)
|
||||||
|
|
||||||
|
Returns `true` if `value` is an odd integer.
|
||||||
|
|
||||||
|
##### .any(predicate, ...values)
|
||||||
|
|
||||||
|
Returns `true` if **any** of the input `values` returns true in the `predicate`:
|
||||||
|
|
||||||
|
```js
|
||||||
|
is.any(is.string, {}, true, '🦄');
|
||||||
|
//=> true
|
||||||
|
|
||||||
|
is.any(is.boolean, 'unicorns', [], new Map());
|
||||||
|
//=> false
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .all(predicate, ...values)
|
||||||
|
|
||||||
|
Returns `true` if **all** of the input `values` returns true in the `predicate`:
|
||||||
|
|
||||||
|
```js
|
||||||
|
is.all(is.object, {}, new Map(), new Set());
|
||||||
|
//=> true
|
||||||
|
|
||||||
|
is.all(is.string, '🦄', [], 'unicorns');
|
||||||
|
//=> false
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## FAQ
|
||||||
|
|
||||||
|
### Why yet another type checking module?
|
||||||
|
|
||||||
|
There are hundreds of type checking modules on npm, unfortunately, I couldn't find any that fit my needs:
|
||||||
|
|
||||||
|
- Includes both type methods and ability to get the type
|
||||||
|
- Types of primitives returned as lowercase and object types as camelcase
|
||||||
|
- Covers all built-ins
|
||||||
|
- Unsurprising behavior
|
||||||
|
- Well-maintained
|
||||||
|
- Comprehensive test suite
|
||||||
|
|
||||||
|
For the ones I found, pick 3 of these.
|
||||||
|
|
||||||
|
The most common mistakes I noticed in these modules was using `instanceof` for type checking, forgetting that functions are objects, and omitting `symbol` as a primitive.
|
||||||
|
|
||||||
|
|
||||||
|
## Related
|
||||||
|
|
||||||
|
- [ow](https://github.com/sindresorhus/ow) - Function argument validation for humans
|
||||||
|
- [is-stream](https://github.com/sindresorhus/is-stream) - Check if something is a Node.js stream
|
||||||
|
- [is-observable](https://github.com/sindresorhus/is-observable) - Check if a value is an Observable
|
||||||
|
- [file-type](https://github.com/sindresorhus/file-type) - Detect the file type of a Buffer/Uint8Array
|
||||||
|
- [is-ip](https://github.com/sindresorhus/is-ip) - Check if a string is an IP address
|
||||||
|
- [is-array-sorted](https://github.com/sindresorhus/is-array-sorted) - Check if an Array is sorted
|
||||||
|
- [is-error-constructor](https://github.com/sindresorhus/is-error-constructor) - Check if a value is an error constructor
|
||||||
|
- [is-empty-iterable](https://github.com/sindresorhus/is-empty-iterable) - Check if an Iterable is empty
|
||||||
|
- [is-blob](https://github.com/sindresorhus/is-blob) - Check if a value is a Blob - File-like object of immutable, raw data
|
||||||
|
- [has-emoji](https://github.com/sindresorhus/has-emoji) - Check whether a string has any emoji
|
||||||
|
|
||||||
|
|
||||||
|
## Created by
|
||||||
|
|
||||||
|
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||||
|
- [Giora Guttsait](https://github.com/gioragutt)
|
||||||
|
- [Brandon Smith](https://github.com/brandon93s)
|
||||||
|
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT
|
21
node_modules/@szmarczak/http-timer/LICENSE
generated
vendored
Normal file
21
node_modules/@szmarczak/http-timer/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2018 Szymon Marczak
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
70
node_modules/@szmarczak/http-timer/README.md
generated
vendored
Normal file
70
node_modules/@szmarczak/http-timer/README.md
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
# http-timer
|
||||||
|
> Timings for HTTP requests
|
||||||
|
|
||||||
|
[![Build Status](https://travis-ci.org/szmarczak/http-timer.svg?branch=master)](https://travis-ci.org/szmarczak/http-timer)
|
||||||
|
[![Coverage Status](https://coveralls.io/repos/github/szmarczak/http-timer/badge.svg?branch=master)](https://coveralls.io/github/szmarczak/http-timer?branch=master)
|
||||||
|
[![install size](https://packagephobia.now.sh/badge?p=@szmarczak/http-timer)](https://packagephobia.now.sh/result?p=@szmarczak/http-timer)
|
||||||
|
|
||||||
|
Inspired by the [`request` package](https://github.com/request/request).
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
```js
|
||||||
|
'use strict';
|
||||||
|
const https = require('https');
|
||||||
|
const timer = require('@szmarczak/http-timer');
|
||||||
|
|
||||||
|
const request = https.get('https://httpbin.org/anything');
|
||||||
|
const timings = timer(request);
|
||||||
|
|
||||||
|
request.on('response', response => {
|
||||||
|
response.on('data', () => {}); // Consume the data somehow
|
||||||
|
response.on('end', () => {
|
||||||
|
console.log(timings);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// { start: 1535708511443,
|
||||||
|
// socket: 1535708511444,
|
||||||
|
// lookup: 1535708511444,
|
||||||
|
// connect: 1535708511582,
|
||||||
|
// upload: 1535708511887,
|
||||||
|
// response: 1535708512037,
|
||||||
|
// end: 1535708512040,
|
||||||
|
// phases:
|
||||||
|
// { wait: 1,
|
||||||
|
// dns: 0,
|
||||||
|
// tcp: 138,
|
||||||
|
// request: 305,
|
||||||
|
// firstByte: 150,
|
||||||
|
// download: 3,
|
||||||
|
// total: 597 } }
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
### timer(request)
|
||||||
|
|
||||||
|
Returns: `Object`
|
||||||
|
|
||||||
|
- `start` - Time when the request started.
|
||||||
|
- `socket` - Time when a socket was assigned to the request.
|
||||||
|
- `lookup` - Time when the DNS lookup finished.
|
||||||
|
- `connect` - Time when the socket successfully connected.
|
||||||
|
- `upload` - Time when the request finished uploading.
|
||||||
|
- `response` - Time when the request fired the `response` event.
|
||||||
|
- `end` - Time when the response fired the `end` event.
|
||||||
|
- `error` - Time when the request fired the `error` event.
|
||||||
|
- `phases`
|
||||||
|
- `wait` - `timings.socket - timings.start`
|
||||||
|
- `dns` - `timings.lookup - timings.socket`
|
||||||
|
- `tcp` - `timings.connect - timings.lookup`
|
||||||
|
- `request` - `timings.upload - timings.connect`
|
||||||
|
- `firstByte` - `timings.response - timings.upload`
|
||||||
|
- `download` - `timings.end - timings.response`
|
||||||
|
- `total` - `timings.end - timings.start` or `timings.error - timings.start`
|
||||||
|
|
||||||
|
**Note**: The time is a `number` representing the milliseconds elapsed since the UNIX epoch.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT
|
47
node_modules/@szmarczak/http-timer/package.json
generated
vendored
Normal file
47
node_modules/@szmarczak/http-timer/package.json
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"name": "@szmarczak/http-timer",
|
||||||
|
"version": "1.1.2",
|
||||||
|
"description": "Timings for HTTP requests",
|
||||||
|
"main": "source",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "xo && nyc ava",
|
||||||
|
"coveralls": "nyc report --reporter=text-lcov | coveralls"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"source"
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"http",
|
||||||
|
"https",
|
||||||
|
"timer",
|
||||||
|
"timings"
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/szmarczak/http-timer.git"
|
||||||
|
},
|
||||||
|
"author": "Szymon Marczak",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/szmarczak/http-timer/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/szmarczak/http-timer#readme",
|
||||||
|
"xo": {
|
||||||
|
"rules": {
|
||||||
|
"unicorn/filename-case": "camelCase"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"ava": "^0.25.0",
|
||||||
|
"coveralls": "^3.0.2",
|
||||||
|
"p-event": "^2.1.0",
|
||||||
|
"nyc": "^12.0.2",
|
||||||
|
"xo": "^0.22.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"defer-to-connect": "^1.0.1"
|
||||||
|
}
|
||||||
|
}
|
99
node_modules/@szmarczak/http-timer/source/index.js
generated
vendored
Normal file
99
node_modules/@szmarczak/http-timer/source/index.js
generated
vendored
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
'use strict';
|
||||||
|
const deferToConnect = require('defer-to-connect');
|
||||||
|
|
||||||
|
module.exports = request => {
|
||||||
|
const timings = {
|
||||||
|
start: Date.now(),
|
||||||
|
socket: null,
|
||||||
|
lookup: null,
|
||||||
|
connect: null,
|
||||||
|
upload: null,
|
||||||
|
response: null,
|
||||||
|
end: null,
|
||||||
|
error: null,
|
||||||
|
phases: {
|
||||||
|
wait: null,
|
||||||
|
dns: null,
|
||||||
|
tcp: null,
|
||||||
|
request: null,
|
||||||
|
firstByte: null,
|
||||||
|
download: null,
|
||||||
|
total: null
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleError = origin => {
|
||||||
|
const emit = origin.emit.bind(origin);
|
||||||
|
origin.emit = (event, ...args) => {
|
||||||
|
// Catches the `error` event
|
||||||
|
if (event === 'error') {
|
||||||
|
timings.error = Date.now();
|
||||||
|
timings.phases.total = timings.error - timings.start;
|
||||||
|
|
||||||
|
origin.emit = emit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Saves the original behavior
|
||||||
|
return emit(event, ...args);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
let uploadFinished = false;
|
||||||
|
const onUpload = () => {
|
||||||
|
timings.upload = Date.now();
|
||||||
|
timings.phases.request = timings.upload - timings.connect;
|
||||||
|
};
|
||||||
|
|
||||||
|
handleError(request);
|
||||||
|
|
||||||
|
request.once('socket', socket => {
|
||||||
|
timings.socket = Date.now();
|
||||||
|
timings.phases.wait = timings.socket - timings.start;
|
||||||
|
|
||||||
|
const lookupListener = () => {
|
||||||
|
timings.lookup = Date.now();
|
||||||
|
timings.phases.dns = timings.lookup - timings.socket;
|
||||||
|
};
|
||||||
|
|
||||||
|
socket.once('lookup', lookupListener);
|
||||||
|
|
||||||
|
deferToConnect(socket, () => {
|
||||||
|
timings.connect = Date.now();
|
||||||
|
|
||||||
|
if (timings.lookup === null) {
|
||||||
|
socket.removeListener('lookup', lookupListener);
|
||||||
|
timings.lookup = timings.connect;
|
||||||
|
timings.phases.dns = timings.lookup - timings.socket;
|
||||||
|
}
|
||||||
|
|
||||||
|
timings.phases.tcp = timings.connect - timings.lookup;
|
||||||
|
|
||||||
|
if (uploadFinished && !timings.upload) {
|
||||||
|
onUpload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
request.once('finish', () => {
|
||||||
|
uploadFinished = true;
|
||||||
|
|
||||||
|
if (timings.connect) {
|
||||||
|
onUpload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
request.once('response', response => {
|
||||||
|
timings.response = Date.now();
|
||||||
|
timings.phases.firstByte = timings.response - timings.upload;
|
||||||
|
|
||||||
|
handleError(response);
|
||||||
|
|
||||||
|
response.once('end', () => {
|
||||||
|
timings.end = Date.now();
|
||||||
|
timings.phases.download = timings.end - timings.response;
|
||||||
|
timings.phases.total = timings.end - timings.start;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return timings;
|
||||||
|
};
|
46
node_modules/abbrev/LICENSE
generated
vendored
Normal file
46
node_modules/abbrev/LICENSE
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
This software is dual-licensed under the ISC and MIT licenses.
|
||||||
|
You may use this software under EITHER of the following licenses.
|
||||||
|
|
||||||
|
----------
|
||||||
|
|
||||||
|
The ISC License
|
||||||
|
|
||||||
|
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||||
|
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
----------
|
||||||
|
|
||||||
|
Copyright Isaac Z. Schlueter and Contributors
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person
|
||||||
|
obtaining a copy of this software and associated documentation
|
||||||
|
files (the "Software"), to deal in the Software without
|
||||||
|
restriction, including without limitation the rights to use,
|
||||||
|
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the
|
||||||
|
Software is furnished to do so, subject to the following
|
||||||
|
conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
OTHER DEALINGS IN THE SOFTWARE.
|
23
node_modules/abbrev/README.md
generated
vendored
Normal file
23
node_modules/abbrev/README.md
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# abbrev-js
|
||||||
|
|
||||||
|
Just like [ruby's Abbrev](http://apidock.com/ruby/Abbrev).
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
var abbrev = require("abbrev");
|
||||||
|
abbrev("foo", "fool", "folding", "flop");
|
||||||
|
|
||||||
|
// returns:
|
||||||
|
{ fl: 'flop'
|
||||||
|
, flo: 'flop'
|
||||||
|
, flop: 'flop'
|
||||||
|
, fol: 'folding'
|
||||||
|
, fold: 'folding'
|
||||||
|
, foldi: 'folding'
|
||||||
|
, foldin: 'folding'
|
||||||
|
, folding: 'folding'
|
||||||
|
, foo: 'foo'
|
||||||
|
, fool: 'fool'
|
||||||
|
}
|
||||||
|
|
||||||
|
This is handy for command-line scripts, or other cases where you want to be able to accept shorthands.
|
61
node_modules/abbrev/abbrev.js
generated
vendored
Normal file
61
node_modules/abbrev/abbrev.js
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
module.exports = exports = abbrev.abbrev = abbrev
|
||||||
|
|
||||||
|
abbrev.monkeyPatch = monkeyPatch
|
||||||
|
|
||||||
|
function monkeyPatch () {
|
||||||
|
Object.defineProperty(Array.prototype, 'abbrev', {
|
||||||
|
value: function () { return abbrev(this) },
|
||||||
|
enumerable: false, configurable: true, writable: true
|
||||||
|
})
|
||||||
|
|
||||||
|
Object.defineProperty(Object.prototype, 'abbrev', {
|
||||||
|
value: function () { return abbrev(Object.keys(this)) },
|
||||||
|
enumerable: false, configurable: true, writable: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function abbrev (list) {
|
||||||
|
if (arguments.length !== 1 || !Array.isArray(list)) {
|
||||||
|
list = Array.prototype.slice.call(arguments, 0)
|
||||||
|
}
|
||||||
|
for (var i = 0, l = list.length, args = [] ; i < l ; i ++) {
|
||||||
|
args[i] = typeof list[i] === "string" ? list[i] : String(list[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
// sort them lexicographically, so that they're next to their nearest kin
|
||||||
|
args = args.sort(lexSort)
|
||||||
|
|
||||||
|
// walk through each, seeing how much it has in common with the next and previous
|
||||||
|
var abbrevs = {}
|
||||||
|
, prev = ""
|
||||||
|
for (var i = 0, l = args.length ; i < l ; i ++) {
|
||||||
|
var current = args[i]
|
||||||
|
, next = args[i + 1] || ""
|
||||||
|
, nextMatches = true
|
||||||
|
, prevMatches = true
|
||||||
|
if (current === next) continue
|
||||||
|
for (var j = 0, cl = current.length ; j < cl ; j ++) {
|
||||||
|
var curChar = current.charAt(j)
|
||||||
|
nextMatches = nextMatches && curChar === next.charAt(j)
|
||||||
|
prevMatches = prevMatches && curChar === prev.charAt(j)
|
||||||
|
if (!nextMatches && !prevMatches) {
|
||||||
|
j ++
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
prev = current
|
||||||
|
if (j === cl) {
|
||||||
|
abbrevs[current] = current
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for (var a = current.substr(0, j) ; j <= cl ; j ++) {
|
||||||
|
abbrevs[a] = current
|
||||||
|
a += current.charAt(j)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return abbrevs
|
||||||
|
}
|
||||||
|
|
||||||
|
function lexSort (a, b) {
|
||||||
|
return a === b ? 0 : a > b ? 1 : -1
|
||||||
|
}
|
21
node_modules/abbrev/package.json
generated
vendored
Normal file
21
node_modules/abbrev/package.json
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"name": "abbrev",
|
||||||
|
"version": "1.1.1",
|
||||||
|
"description": "Like ruby's abbrev module, but in js",
|
||||||
|
"author": "Isaac Z. Schlueter <i@izs.me>",
|
||||||
|
"main": "abbrev.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "tap test.js --100",
|
||||||
|
"preversion": "npm test",
|
||||||
|
"postversion": "npm publish",
|
||||||
|
"postpublish": "git push origin --all; git push origin --tags"
|
||||||
|
},
|
||||||
|
"repository": "http://github.com/isaacs/abbrev-js",
|
||||||
|
"license": "ISC",
|
||||||
|
"devDependencies": {
|
||||||
|
"tap": "^10.1"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"abbrev.js"
|
||||||
|
]
|
||||||
|
}
|
236
node_modules/accepts/HISTORY.md
generated
vendored
Normal file
236
node_modules/accepts/HISTORY.md
generated
vendored
Normal file
@ -0,0 +1,236 @@
|
|||||||
|
1.3.7 / 2019-04-29
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.6.2
|
||||||
|
- Fix sorting charset, encoding, and language with extra parameters
|
||||||
|
|
||||||
|
1.3.6 / 2019-04-28
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.24
|
||||||
|
- deps: mime-db@~1.40.0
|
||||||
|
|
||||||
|
1.3.5 / 2018-02-28
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.18
|
||||||
|
- deps: mime-db@~1.33.0
|
||||||
|
|
||||||
|
1.3.4 / 2017-08-22
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.16
|
||||||
|
- deps: mime-db@~1.29.0
|
||||||
|
|
||||||
|
1.3.3 / 2016-05-02
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.11
|
||||||
|
- deps: mime-db@~1.23.0
|
||||||
|
* deps: negotiator@0.6.1
|
||||||
|
- perf: improve `Accept` parsing speed
|
||||||
|
- perf: improve `Accept-Charset` parsing speed
|
||||||
|
- perf: improve `Accept-Encoding` parsing speed
|
||||||
|
- perf: improve `Accept-Language` parsing speed
|
||||||
|
|
||||||
|
1.3.2 / 2016-03-08
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.10
|
||||||
|
- Fix extension of `application/dash+xml`
|
||||||
|
- Update primary extension for `audio/mp4`
|
||||||
|
- deps: mime-db@~1.22.0
|
||||||
|
|
||||||
|
1.3.1 / 2016-01-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.9
|
||||||
|
- deps: mime-db@~1.21.0
|
||||||
|
|
||||||
|
1.3.0 / 2015-09-29
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.7
|
||||||
|
- deps: mime-db@~1.19.0
|
||||||
|
* deps: negotiator@0.6.0
|
||||||
|
- Fix including type extensions in parameters in `Accept` parsing
|
||||||
|
- Fix parsing `Accept` parameters with quoted equals
|
||||||
|
- Fix parsing `Accept` parameters with quoted semicolons
|
||||||
|
- Lazy-load modules from main entry point
|
||||||
|
- perf: delay type concatenation until needed
|
||||||
|
- perf: enable strict mode
|
||||||
|
- perf: hoist regular expressions
|
||||||
|
- perf: remove closures getting spec properties
|
||||||
|
- perf: remove a closure from media type parsing
|
||||||
|
- perf: remove property delete from media type parsing
|
||||||
|
|
||||||
|
1.2.13 / 2015-09-06
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.6
|
||||||
|
- deps: mime-db@~1.18.0
|
||||||
|
|
||||||
|
1.2.12 / 2015-07-30
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.4
|
||||||
|
- deps: mime-db@~1.16.0
|
||||||
|
|
||||||
|
1.2.11 / 2015-07-16
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.3
|
||||||
|
- deps: mime-db@~1.15.0
|
||||||
|
|
||||||
|
1.2.10 / 2015-07-01
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.2
|
||||||
|
- deps: mime-db@~1.14.0
|
||||||
|
|
||||||
|
1.2.9 / 2015-06-08
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.1
|
||||||
|
- perf: fix deopt during mapping
|
||||||
|
|
||||||
|
1.2.8 / 2015-06-07
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.0
|
||||||
|
- deps: mime-db@~1.13.0
|
||||||
|
* perf: avoid argument reassignment & argument slice
|
||||||
|
* perf: avoid negotiator recursive construction
|
||||||
|
* perf: enable strict mode
|
||||||
|
* perf: remove unnecessary bitwise operator
|
||||||
|
|
||||||
|
1.2.7 / 2015-05-10
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.5.3
|
||||||
|
- Fix media type parameter matching to be case-insensitive
|
||||||
|
|
||||||
|
1.2.6 / 2015-05-07
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.11
|
||||||
|
- deps: mime-db@~1.9.1
|
||||||
|
* deps: negotiator@0.5.2
|
||||||
|
- Fix comparing media types with quoted values
|
||||||
|
- Fix splitting media types with quoted commas
|
||||||
|
|
||||||
|
1.2.5 / 2015-03-13
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.10
|
||||||
|
- deps: mime-db@~1.8.0
|
||||||
|
|
||||||
|
1.2.4 / 2015-02-14
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Support Node.js 0.6
|
||||||
|
* deps: mime-types@~2.0.9
|
||||||
|
- deps: mime-db@~1.7.0
|
||||||
|
* deps: negotiator@0.5.1
|
||||||
|
- Fix preference sorting to be stable for long acceptable lists
|
||||||
|
|
||||||
|
1.2.3 / 2015-01-31
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.8
|
||||||
|
- deps: mime-db@~1.6.0
|
||||||
|
|
||||||
|
1.2.2 / 2014-12-30
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.7
|
||||||
|
- deps: mime-db@~1.5.0
|
||||||
|
|
||||||
|
1.2.1 / 2014-12-30
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.5
|
||||||
|
- deps: mime-db@~1.3.1
|
||||||
|
|
||||||
|
1.2.0 / 2014-12-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.5.0
|
||||||
|
- Fix list return order when large accepted list
|
||||||
|
- Fix missing identity encoding when q=0 exists
|
||||||
|
- Remove dynamic building of Negotiator class
|
||||||
|
|
||||||
|
1.1.4 / 2014-12-10
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.4
|
||||||
|
- deps: mime-db@~1.3.0
|
||||||
|
|
||||||
|
1.1.3 / 2014-11-09
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.3
|
||||||
|
- deps: mime-db@~1.2.0
|
||||||
|
|
||||||
|
1.1.2 / 2014-10-14
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.4.9
|
||||||
|
- Fix error when media type has invalid parameter
|
||||||
|
|
||||||
|
1.1.1 / 2014-09-28
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.2
|
||||||
|
- deps: mime-db@~1.1.0
|
||||||
|
* deps: negotiator@0.4.8
|
||||||
|
- Fix all negotiations to be case-insensitive
|
||||||
|
- Stable sort preferences of same quality according to client order
|
||||||
|
|
||||||
|
1.1.0 / 2014-09-02
|
||||||
|
==================
|
||||||
|
|
||||||
|
* update `mime-types`
|
||||||
|
|
||||||
|
1.0.7 / 2014-07-04
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix wrong type returned from `type` when match after unknown extension
|
||||||
|
|
||||||
|
1.0.6 / 2014-06-24
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.4.7
|
||||||
|
|
||||||
|
1.0.5 / 2014-06-20
|
||||||
|
==================
|
||||||
|
|
||||||
|
* fix crash when unknown extension given
|
||||||
|
|
||||||
|
1.0.4 / 2014-06-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* use `mime-types`
|
||||||
|
|
||||||
|
1.0.3 / 2014-06-11
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.4.6
|
||||||
|
- Order by specificity when quality is the same
|
||||||
|
|
||||||
|
1.0.2 / 2014-05-29
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix interpretation when header not in request
|
||||||
|
* deps: pin negotiator@0.4.5
|
||||||
|
|
||||||
|
1.0.1 / 2014-01-18
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Identity encoding isn't always acceptable
|
||||||
|
* deps: negotiator@~0.4.0
|
||||||
|
|
||||||
|
1.0.0 / 2013-12-27
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Genesis
|
23
node_modules/accepts/LICENSE
generated
vendored
Normal file
23
node_modules/accepts/LICENSE
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
|
||||||
|
Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
'Software'), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
142
node_modules/accepts/README.md
generated
vendored
Normal file
142
node_modules/accepts/README.md
generated
vendored
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
# accepts
|
||||||
|
|
||||||
|
[![NPM Version][npm-version-image]][npm-url]
|
||||||
|
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||||
|
[![Node.js Version][node-version-image]][node-version-url]
|
||||||
|
[![Build Status][travis-image]][travis-url]
|
||||||
|
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||||
|
|
||||||
|
Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator).
|
||||||
|
Extracted from [koa](https://www.npmjs.com/package/koa) for general use.
|
||||||
|
|
||||||
|
In addition to negotiator, it allows:
|
||||||
|
|
||||||
|
- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])`
|
||||||
|
as well as `('text/html', 'application/json')`.
|
||||||
|
- Allows type shorthands such as `json`.
|
||||||
|
- Returns `false` when no types match
|
||||||
|
- Treats non-existent headers as `*`
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
This is a [Node.js](https://nodejs.org/en/) module available through the
|
||||||
|
[npm registry](https://www.npmjs.com/). Installation is done using the
|
||||||
|
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install accepts
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
<!-- eslint-disable no-unused-vars -->
|
||||||
|
|
||||||
|
```js
|
||||||
|
var accepts = require('accepts')
|
||||||
|
```
|
||||||
|
|
||||||
|
### accepts(req)
|
||||||
|
|
||||||
|
Create a new `Accepts` object for the given `req`.
|
||||||
|
|
||||||
|
#### .charset(charsets)
|
||||||
|
|
||||||
|
Return the first accepted charset. If nothing in `charsets` is accepted,
|
||||||
|
then `false` is returned.
|
||||||
|
|
||||||
|
#### .charsets()
|
||||||
|
|
||||||
|
Return the charsets that the request accepts, in the order of the client's
|
||||||
|
preference (most preferred first).
|
||||||
|
|
||||||
|
#### .encoding(encodings)
|
||||||
|
|
||||||
|
Return the first accepted encoding. If nothing in `encodings` is accepted,
|
||||||
|
then `false` is returned.
|
||||||
|
|
||||||
|
#### .encodings()
|
||||||
|
|
||||||
|
Return the encodings that the request accepts, in the order of the client's
|
||||||
|
preference (most preferred first).
|
||||||
|
|
||||||
|
#### .language(languages)
|
||||||
|
|
||||||
|
Return the first accepted language. If nothing in `languages` is accepted,
|
||||||
|
then `false` is returned.
|
||||||
|
|
||||||
|
#### .languages()
|
||||||
|
|
||||||
|
Return the languages that the request accepts, in the order of the client's
|
||||||
|
preference (most preferred first).
|
||||||
|
|
||||||
|
#### .type(types)
|
||||||
|
|
||||||
|
Return the first accepted type (and it is returned as the same text as what
|
||||||
|
appears in the `types` array). If nothing in `types` is accepted, then `false`
|
||||||
|
is returned.
|
||||||
|
|
||||||
|
The `types` array can contain full MIME types or file extensions. Any value
|
||||||
|
that is not a full MIME types is passed to `require('mime-types').lookup`.
|
||||||
|
|
||||||
|
#### .types()
|
||||||
|
|
||||||
|
Return the types that the request accepts, in the order of the client's
|
||||||
|
preference (most preferred first).
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Simple type negotiation
|
||||||
|
|
||||||
|
This simple example shows how to use `accepts` to return a different typed
|
||||||
|
respond body based on what the client wants to accept. The server lists it's
|
||||||
|
preferences in order and will get back the best match between the client and
|
||||||
|
server.
|
||||||
|
|
||||||
|
```js
|
||||||
|
var accepts = require('accepts')
|
||||||
|
var http = require('http')
|
||||||
|
|
||||||
|
function app (req, res) {
|
||||||
|
var accept = accepts(req)
|
||||||
|
|
||||||
|
// the order of this list is significant; should be server preferred order
|
||||||
|
switch (accept.type(['json', 'html'])) {
|
||||||
|
case 'json':
|
||||||
|
res.setHeader('Content-Type', 'application/json')
|
||||||
|
res.write('{"hello":"world!"}')
|
||||||
|
break
|
||||||
|
case 'html':
|
||||||
|
res.setHeader('Content-Type', 'text/html')
|
||||||
|
res.write('<b>hello, world!</b>')
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
// the fallback is text/plain, so no need to specify it above
|
||||||
|
res.setHeader('Content-Type', 'text/plain')
|
||||||
|
res.write('hello, world!')
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
res.end()
|
||||||
|
}
|
||||||
|
|
||||||
|
http.createServer(app).listen(3000)
|
||||||
|
```
|
||||||
|
|
||||||
|
You can test this out with the cURL program:
|
||||||
|
```sh
|
||||||
|
curl -I -H'Accept: text/html' http://localhost:3000/
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[MIT](LICENSE)
|
||||||
|
|
||||||
|
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/accepts/master
|
||||||
|
[coveralls-url]: https://coveralls.io/r/jshttp/accepts?branch=master
|
||||||
|
[node-version-image]: https://badgen.net/npm/node/accepts
|
||||||
|
[node-version-url]: https://nodejs.org/en/download
|
||||||
|
[npm-downloads-image]: https://badgen.net/npm/dm/accepts
|
||||||
|
[npm-url]: https://npmjs.org/package/accepts
|
||||||
|
[npm-version-image]: https://badgen.net/npm/v/accepts
|
||||||
|
[travis-image]: https://badgen.net/travis/jshttp/accepts/master
|
||||||
|
[travis-url]: https://travis-ci.org/jshttp/accepts
|
238
node_modules/accepts/index.js
generated
vendored
Normal file
238
node_modules/accepts/index.js
generated
vendored
Normal file
@ -0,0 +1,238 @@
|
|||||||
|
/*!
|
||||||
|
* accepts
|
||||||
|
* Copyright(c) 2014 Jonathan Ong
|
||||||
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
var Negotiator = require('negotiator')
|
||||||
|
var mime = require('mime-types')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module exports.
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = Accepts
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Accepts object for the given req.
|
||||||
|
*
|
||||||
|
* @param {object} req
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
function Accepts (req) {
|
||||||
|
if (!(this instanceof Accepts)) {
|
||||||
|
return new Accepts(req)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.headers = req.headers
|
||||||
|
this.negotiator = new Negotiator(req)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the given `type(s)` is acceptable, returning
|
||||||
|
* the best match when true, otherwise `undefined`, in which
|
||||||
|
* case you should respond with 406 "Not Acceptable".
|
||||||
|
*
|
||||||
|
* The `type` value may be a single mime type string
|
||||||
|
* such as "application/json", the extension name
|
||||||
|
* such as "json" or an array `["json", "html", "text/plain"]`. When a list
|
||||||
|
* or array is given the _best_ match, if any is returned.
|
||||||
|
*
|
||||||
|
* Examples:
|
||||||
|
*
|
||||||
|
* // Accept: text/html
|
||||||
|
* this.types('html');
|
||||||
|
* // => "html"
|
||||||
|
*
|
||||||
|
* // Accept: text/*, application/json
|
||||||
|
* this.types('html');
|
||||||
|
* // => "html"
|
||||||
|
* this.types('text/html');
|
||||||
|
* // => "text/html"
|
||||||
|
* this.types('json', 'text');
|
||||||
|
* // => "json"
|
||||||
|
* this.types('application/json');
|
||||||
|
* // => "application/json"
|
||||||
|
*
|
||||||
|
* // Accept: text/*, application/json
|
||||||
|
* this.types('image/png');
|
||||||
|
* this.types('png');
|
||||||
|
* // => undefined
|
||||||
|
*
|
||||||
|
* // Accept: text/*;q=.5, application/json
|
||||||
|
* this.types(['html', 'json']);
|
||||||
|
* this.types('html', 'json');
|
||||||
|
* // => "json"
|
||||||
|
*
|
||||||
|
* @param {String|Array} types...
|
||||||
|
* @return {String|Array|Boolean}
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Accepts.prototype.type =
|
||||||
|
Accepts.prototype.types = function (types_) {
|
||||||
|
var types = types_
|
||||||
|
|
||||||
|
// support flattened arguments
|
||||||
|
if (types && !Array.isArray(types)) {
|
||||||
|
types = new Array(arguments.length)
|
||||||
|
for (var i = 0; i < types.length; i++) {
|
||||||
|
types[i] = arguments[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no types, return all requested types
|
||||||
|
if (!types || types.length === 0) {
|
||||||
|
return this.negotiator.mediaTypes()
|
||||||
|
}
|
||||||
|
|
||||||
|
// no accept header, return first given type
|
||||||
|
if (!this.headers.accept) {
|
||||||
|
return types[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
var mimes = types.map(extToMime)
|
||||||
|
var accepts = this.negotiator.mediaTypes(mimes.filter(validMime))
|
||||||
|
var first = accepts[0]
|
||||||
|
|
||||||
|
return first
|
||||||
|
? types[mimes.indexOf(first)]
|
||||||
|
: false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return accepted encodings or best fit based on `encodings`.
|
||||||
|
*
|
||||||
|
* Given `Accept-Encoding: gzip, deflate`
|
||||||
|
* an array sorted by quality is returned:
|
||||||
|
*
|
||||||
|
* ['gzip', 'deflate']
|
||||||
|
*
|
||||||
|
* @param {String|Array} encodings...
|
||||||
|
* @return {String|Array}
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Accepts.prototype.encoding =
|
||||||
|
Accepts.prototype.encodings = function (encodings_) {
|
||||||
|
var encodings = encodings_
|
||||||
|
|
||||||
|
// support flattened arguments
|
||||||
|
if (encodings && !Array.isArray(encodings)) {
|
||||||
|
encodings = new Array(arguments.length)
|
||||||
|
for (var i = 0; i < encodings.length; i++) {
|
||||||
|
encodings[i] = arguments[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no encodings, return all requested encodings
|
||||||
|
if (!encodings || encodings.length === 0) {
|
||||||
|
return this.negotiator.encodings()
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.negotiator.encodings(encodings)[0] || false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return accepted charsets or best fit based on `charsets`.
|
||||||
|
*
|
||||||
|
* Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5`
|
||||||
|
* an array sorted by quality is returned:
|
||||||
|
*
|
||||||
|
* ['utf-8', 'utf-7', 'iso-8859-1']
|
||||||
|
*
|
||||||
|
* @param {String|Array} charsets...
|
||||||
|
* @return {String|Array}
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Accepts.prototype.charset =
|
||||||
|
Accepts.prototype.charsets = function (charsets_) {
|
||||||
|
var charsets = charsets_
|
||||||
|
|
||||||
|
// support flattened arguments
|
||||||
|
if (charsets && !Array.isArray(charsets)) {
|
||||||
|
charsets = new Array(arguments.length)
|
||||||
|
for (var i = 0; i < charsets.length; i++) {
|
||||||
|
charsets[i] = arguments[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no charsets, return all requested charsets
|
||||||
|
if (!charsets || charsets.length === 0) {
|
||||||
|
return this.negotiator.charsets()
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.negotiator.charsets(charsets)[0] || false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return accepted languages or best fit based on `langs`.
|
||||||
|
*
|
||||||
|
* Given `Accept-Language: en;q=0.8, es, pt`
|
||||||
|
* an array sorted by quality is returned:
|
||||||
|
*
|
||||||
|
* ['es', 'pt', 'en']
|
||||||
|
*
|
||||||
|
* @param {String|Array} langs...
|
||||||
|
* @return {Array|String}
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Accepts.prototype.lang =
|
||||||
|
Accepts.prototype.langs =
|
||||||
|
Accepts.prototype.language =
|
||||||
|
Accepts.prototype.languages = function (languages_) {
|
||||||
|
var languages = languages_
|
||||||
|
|
||||||
|
// support flattened arguments
|
||||||
|
if (languages && !Array.isArray(languages)) {
|
||||||
|
languages = new Array(arguments.length)
|
||||||
|
for (var i = 0; i < languages.length; i++) {
|
||||||
|
languages[i] = arguments[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no languages, return all requested languages
|
||||||
|
if (!languages || languages.length === 0) {
|
||||||
|
return this.negotiator.languages()
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.negotiator.languages(languages)[0] || false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert extnames to mime.
|
||||||
|
*
|
||||||
|
* @param {String} type
|
||||||
|
* @return {String}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function extToMime (type) {
|
||||||
|
return type.indexOf('/') === -1
|
||||||
|
? mime.lookup(type)
|
||||||
|
: type
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if mime is valid.
|
||||||
|
*
|
||||||
|
* @param {String} type
|
||||||
|
* @return {String}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function validMime (type) {
|
||||||
|
return typeof type === 'string'
|
||||||
|
}
|
47
node_modules/accepts/package.json
generated
vendored
Normal file
47
node_modules/accepts/package.json
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"name": "accepts",
|
||||||
|
"description": "Higher-level content negotiation",
|
||||||
|
"version": "1.3.7",
|
||||||
|
"contributors": [
|
||||||
|
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||||
|
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "jshttp/accepts",
|
||||||
|
"dependencies": {
|
||||||
|
"mime-types": "~2.1.24",
|
||||||
|
"negotiator": "0.6.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"deep-equal": "1.0.1",
|
||||||
|
"eslint": "5.16.0",
|
||||||
|
"eslint-config-standard": "12.0.0",
|
||||||
|
"eslint-plugin-import": "2.17.2",
|
||||||
|
"eslint-plugin-markdown": "1.0.0",
|
||||||
|
"eslint-plugin-node": "8.0.1",
|
||||||
|
"eslint-plugin-promise": "4.1.1",
|
||||||
|
"eslint-plugin-standard": "4.0.0",
|
||||||
|
"mocha": "6.1.4",
|
||||||
|
"nyc": "14.0.0"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"LICENSE",
|
||||||
|
"HISTORY.md",
|
||||||
|
"index.js"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.6"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"lint": "eslint --plugin markdown --ext js,md .",
|
||||||
|
"test": "mocha --reporter spec --check-leaks --bail test/",
|
||||||
|
"test-cov": "nyc --reporter=html --reporter=text npm test",
|
||||||
|
"test-travis": "nyc --reporter=text npm test"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"content",
|
||||||
|
"negotiation",
|
||||||
|
"accept",
|
||||||
|
"accepts"
|
||||||
|
]
|
||||||
|
}
|
20
node_modules/ajv/.tonic_example.js
generated
vendored
Normal file
20
node_modules/ajv/.tonic_example.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
var Ajv = require('ajv');
|
||||||
|
var ajv = new Ajv({allErrors: true});
|
||||||
|
|
||||||
|
var schema = {
|
||||||
|
"properties": {
|
||||||
|
"foo": { "type": "string" },
|
||||||
|
"bar": { "type": "number", "maximum": 3 }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var validate = ajv.compile(schema);
|
||||||
|
|
||||||
|
test({"foo": "abc", "bar": 2});
|
||||||
|
test({"foo": 2, "bar": 4});
|
||||||
|
|
||||||
|
function test(data) {
|
||||||
|
var valid = validate(data);
|
||||||
|
if (valid) console.log('Valid!');
|
||||||
|
else console.log('Invalid: ' + ajv.errorsText(validate.errors));
|
||||||
|
}
|
22
node_modules/ajv/LICENSE
generated
vendored
Normal file
22
node_modules/ajv/LICENSE
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2015-2017 Evgeny Poberezkin
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
1497
node_modules/ajv/README.md
generated
vendored
Normal file
1497
node_modules/ajv/README.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
7189
node_modules/ajv/dist/ajv.bundle.js
generated
vendored
Normal file
7189
node_modules/ajv/dist/ajv.bundle.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
3
node_modules/ajv/dist/ajv.min.js
generated
vendored
Normal file
3
node_modules/ajv/dist/ajv.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/ajv/dist/ajv.min.js.map
generated
vendored
Normal file
1
node_modules/ajv/dist/ajv.min.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
397
node_modules/ajv/lib/ajv.d.ts
generated
vendored
Normal file
397
node_modules/ajv/lib/ajv.d.ts
generated
vendored
Normal file
@ -0,0 +1,397 @@
|
|||||||
|
declare var ajv: {
|
||||||
|
(options?: ajv.Options): ajv.Ajv;
|
||||||
|
new(options?: ajv.Options): ajv.Ajv;
|
||||||
|
ValidationError: typeof AjvErrors.ValidationError;
|
||||||
|
MissingRefError: typeof AjvErrors.MissingRefError;
|
||||||
|
$dataMetaSchema: object;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare namespace AjvErrors {
|
||||||
|
class ValidationError extends Error {
|
||||||
|
constructor(errors: Array<ajv.ErrorObject>);
|
||||||
|
|
||||||
|
message: string;
|
||||||
|
errors: Array<ajv.ErrorObject>;
|
||||||
|
ajv: true;
|
||||||
|
validation: true;
|
||||||
|
}
|
||||||
|
|
||||||
|
class MissingRefError extends Error {
|
||||||
|
constructor(baseId: string, ref: string, message?: string);
|
||||||
|
static message: (baseId: string, ref: string) => string;
|
||||||
|
|
||||||
|
message: string;
|
||||||
|
missingRef: string;
|
||||||
|
missingSchema: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare namespace ajv {
|
||||||
|
type ValidationError = AjvErrors.ValidationError;
|
||||||
|
|
||||||
|
type MissingRefError = AjvErrors.MissingRefError;
|
||||||
|
|
||||||
|
interface Ajv {
|
||||||
|
/**
|
||||||
|
* Validate data using schema
|
||||||
|
* Schema will be compiled and cached (using serialized JSON as key, [fast-json-stable-stringify](https://github.com/epoberezkin/fast-json-stable-stringify) is used to serialize by default).
|
||||||
|
* @param {string|object|Boolean} schemaKeyRef key, ref or schema object
|
||||||
|
* @param {Any} data to be validated
|
||||||
|
* @return {Boolean} validation result. Errors from the last validation will be available in `ajv.errors` (and also in compiled schema: `schema.errors`).
|
||||||
|
*/
|
||||||
|
validate(schemaKeyRef: object | string | boolean, data: any): boolean | PromiseLike<any>;
|
||||||
|
/**
|
||||||
|
* Create validating function for passed schema.
|
||||||
|
* @param {object|Boolean} schema schema object
|
||||||
|
* @return {Function} validating function
|
||||||
|
*/
|
||||||
|
compile(schema: object | boolean): ValidateFunction;
|
||||||
|
/**
|
||||||
|
* Creates validating function for passed schema with asynchronous loading of missing schemas.
|
||||||
|
* `loadSchema` option should be a function that accepts schema uri and node-style callback.
|
||||||
|
* @this Ajv
|
||||||
|
* @param {object|Boolean} schema schema object
|
||||||
|
* @param {Boolean} meta optional true to compile meta-schema; this parameter can be skipped
|
||||||
|
* @param {Function} callback optional node-style callback, it is always called with 2 parameters: error (or null) and validating function.
|
||||||
|
* @return {PromiseLike<ValidateFunction>} validating function
|
||||||
|
*/
|
||||||
|
compileAsync(schema: object | boolean, meta?: Boolean, callback?: (err: Error, validate: ValidateFunction) => any): PromiseLike<ValidateFunction>;
|
||||||
|
/**
|
||||||
|
* Adds schema to the instance.
|
||||||
|
* @param {object|Array} schema schema or array of schemas. If array is passed, `key` and other parameters will be ignored.
|
||||||
|
* @param {string} key Optional schema key. Can be passed to `validate` method instead of schema object or id/ref. One schema per instance can have empty `id` and `key`.
|
||||||
|
* @return {Ajv} this for method chaining
|
||||||
|
*/
|
||||||
|
addSchema(schema: Array<object> | object, key?: string): Ajv;
|
||||||
|
/**
|
||||||
|
* Add schema that will be used to validate other schemas
|
||||||
|
* options in META_IGNORE_OPTIONS are alway set to false
|
||||||
|
* @param {object} schema schema object
|
||||||
|
* @param {string} key optional schema key
|
||||||
|
* @return {Ajv} this for method chaining
|
||||||
|
*/
|
||||||
|
addMetaSchema(schema: object, key?: string): Ajv;
|
||||||
|
/**
|
||||||
|
* Validate schema
|
||||||
|
* @param {object|Boolean} schema schema to validate
|
||||||
|
* @return {Boolean} true if schema is valid
|
||||||
|
*/
|
||||||
|
validateSchema(schema: object | boolean): boolean;
|
||||||
|
/**
|
||||||
|
* Get compiled schema from the instance by `key` or `ref`.
|
||||||
|
* @param {string} keyRef `key` that was passed to `addSchema` or full schema reference (`schema.id` or resolved id).
|
||||||
|
* @return {Function} schema validating function (with property `schema`). Returns undefined if keyRef can't be resolved to an existing schema.
|
||||||
|
*/
|
||||||
|
getSchema(keyRef: string): ValidateFunction | undefined;
|
||||||
|
/**
|
||||||
|
* Remove cached schema(s).
|
||||||
|
* If no parameter is passed all schemas but meta-schemas are removed.
|
||||||
|
* If RegExp is passed all schemas with key/id matching pattern but meta-schemas are removed.
|
||||||
|
* Even if schema is referenced by other schemas it still can be removed as other schemas have local references.
|
||||||
|
* @param {string|object|RegExp|Boolean} schemaKeyRef key, ref, pattern to match key/ref or schema object
|
||||||
|
* @return {Ajv} this for method chaining
|
||||||
|
*/
|
||||||
|
removeSchema(schemaKeyRef?: object | string | RegExp | boolean): Ajv;
|
||||||
|
/**
|
||||||
|
* Add custom format
|
||||||
|
* @param {string} name format name
|
||||||
|
* @param {string|RegExp|Function} format string is converted to RegExp; function should return boolean (true when valid)
|
||||||
|
* @return {Ajv} this for method chaining
|
||||||
|
*/
|
||||||
|
addFormat(name: string, format: FormatValidator | FormatDefinition): Ajv;
|
||||||
|
/**
|
||||||
|
* Define custom keyword
|
||||||
|
* @this Ajv
|
||||||
|
* @param {string} keyword custom keyword, should be a valid identifier, should be different from all standard, custom and macro keywords.
|
||||||
|
* @param {object} definition keyword definition object with properties `type` (type(s) which the keyword applies to), `validate` or `compile`.
|
||||||
|
* @return {Ajv} this for method chaining
|
||||||
|
*/
|
||||||
|
addKeyword(keyword: string, definition: KeywordDefinition): Ajv;
|
||||||
|
/**
|
||||||
|
* Get keyword definition
|
||||||
|
* @this Ajv
|
||||||
|
* @param {string} keyword pre-defined or custom keyword.
|
||||||
|
* @return {object|Boolean} custom keyword definition, `true` if it is a predefined keyword, `false` otherwise.
|
||||||
|
*/
|
||||||
|
getKeyword(keyword: string): object | boolean;
|
||||||
|
/**
|
||||||
|
* Remove keyword
|
||||||
|
* @this Ajv
|
||||||
|
* @param {string} keyword pre-defined or custom keyword.
|
||||||
|
* @return {Ajv} this for method chaining
|
||||||
|
*/
|
||||||
|
removeKeyword(keyword: string): Ajv;
|
||||||
|
/**
|
||||||
|
* Validate keyword
|
||||||
|
* @this Ajv
|
||||||
|
* @param {object} definition keyword definition object
|
||||||
|
* @param {boolean} throwError true to throw exception if definition is invalid
|
||||||
|
* @return {boolean} validation result
|
||||||
|
*/
|
||||||
|
validateKeyword(definition: KeywordDefinition, throwError: boolean): boolean;
|
||||||
|
/**
|
||||||
|
* Convert array of error message objects to string
|
||||||
|
* @param {Array<object>} errors optional array of validation errors, if not passed errors from the instance are used.
|
||||||
|
* @param {object} options optional options with properties `separator` and `dataVar`.
|
||||||
|
* @return {string} human readable string with all errors descriptions
|
||||||
|
*/
|
||||||
|
errorsText(errors?: Array<ErrorObject> | null, options?: ErrorsTextOptions): string;
|
||||||
|
errors?: Array<ErrorObject> | null;
|
||||||
|
_opts: Options;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CustomLogger {
|
||||||
|
log(...args: any[]): any;
|
||||||
|
warn(...args: any[]): any;
|
||||||
|
error(...args: any[]): any;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ValidateFunction {
|
||||||
|
(
|
||||||
|
data: any,
|
||||||
|
dataPath?: string,
|
||||||
|
parentData?: object | Array<any>,
|
||||||
|
parentDataProperty?: string | number,
|
||||||
|
rootData?: object | Array<any>
|
||||||
|
): boolean | PromiseLike<any>;
|
||||||
|
schema?: object | boolean;
|
||||||
|
errors?: null | Array<ErrorObject>;
|
||||||
|
refs?: object;
|
||||||
|
refVal?: Array<any>;
|
||||||
|
root?: ValidateFunction | object;
|
||||||
|
$async?: true;
|
||||||
|
source?: object;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Options {
|
||||||
|
$data?: boolean;
|
||||||
|
allErrors?: boolean;
|
||||||
|
verbose?: boolean;
|
||||||
|
jsonPointers?: boolean;
|
||||||
|
uniqueItems?: boolean;
|
||||||
|
unicode?: boolean;
|
||||||
|
format?: false | string;
|
||||||
|
formats?: object;
|
||||||
|
keywords?: object;
|
||||||
|
unknownFormats?: true | string[] | 'ignore';
|
||||||
|
schemas?: Array<object> | object;
|
||||||
|
schemaId?: '$id' | 'id' | 'auto';
|
||||||
|
missingRefs?: true | 'ignore' | 'fail';
|
||||||
|
extendRefs?: true | 'ignore' | 'fail';
|
||||||
|
loadSchema?: (uri: string, cb?: (err: Error, schema: object) => void) => PromiseLike<object | boolean>;
|
||||||
|
removeAdditional?: boolean | 'all' | 'failing';
|
||||||
|
useDefaults?: boolean | 'empty' | 'shared';
|
||||||
|
coerceTypes?: boolean | 'array';
|
||||||
|
strictDefaults?: boolean | 'log';
|
||||||
|
strictKeywords?: boolean | 'log';
|
||||||
|
strictNumbers?: boolean;
|
||||||
|
async?: boolean | string;
|
||||||
|
transpile?: string | ((code: string) => string);
|
||||||
|
meta?: boolean | object;
|
||||||
|
validateSchema?: boolean | 'log';
|
||||||
|
addUsedSchema?: boolean;
|
||||||
|
inlineRefs?: boolean | number;
|
||||||
|
passContext?: boolean;
|
||||||
|
loopRequired?: number;
|
||||||
|
ownProperties?: boolean;
|
||||||
|
multipleOfPrecision?: boolean | number;
|
||||||
|
errorDataPath?: string,
|
||||||
|
messages?: boolean;
|
||||||
|
sourceCode?: boolean;
|
||||||
|
processCode?: (code: string, schema: object) => string;
|
||||||
|
cache?: object;
|
||||||
|
logger?: CustomLogger | false;
|
||||||
|
nullable?: boolean;
|
||||||
|
serialize?: ((schema: object | boolean) => any) | false;
|
||||||
|
}
|
||||||
|
|
||||||
|
type FormatValidator = string | RegExp | ((data: string) => boolean | PromiseLike<any>);
|
||||||
|
type NumberFormatValidator = ((data: number) => boolean | PromiseLike<any>);
|
||||||
|
|
||||||
|
interface NumberFormatDefinition {
|
||||||
|
type: "number",
|
||||||
|
validate: NumberFormatValidator;
|
||||||
|
compare?: (data1: number, data2: number) => number;
|
||||||
|
async?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface StringFormatDefinition {
|
||||||
|
type?: "string",
|
||||||
|
validate: FormatValidator;
|
||||||
|
compare?: (data1: string, data2: string) => number;
|
||||||
|
async?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
type FormatDefinition = NumberFormatDefinition | StringFormatDefinition;
|
||||||
|
|
||||||
|
interface KeywordDefinition {
|
||||||
|
type?: string | Array<string>;
|
||||||
|
async?: boolean;
|
||||||
|
$data?: boolean;
|
||||||
|
errors?: boolean | string;
|
||||||
|
metaSchema?: object;
|
||||||
|
// schema: false makes validate not to expect schema (ValidateFunction)
|
||||||
|
schema?: boolean;
|
||||||
|
statements?: boolean;
|
||||||
|
dependencies?: Array<string>;
|
||||||
|
modifying?: boolean;
|
||||||
|
valid?: boolean;
|
||||||
|
// one and only one of the following properties should be present
|
||||||
|
validate?: SchemaValidateFunction | ValidateFunction;
|
||||||
|
compile?: (schema: any, parentSchema: object, it: CompilationContext) => ValidateFunction;
|
||||||
|
macro?: (schema: any, parentSchema: object, it: CompilationContext) => object | boolean;
|
||||||
|
inline?: (it: CompilationContext, keyword: string, schema: any, parentSchema: object) => string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CompilationContext {
|
||||||
|
level: number;
|
||||||
|
dataLevel: number;
|
||||||
|
dataPathArr: string[];
|
||||||
|
schema: any;
|
||||||
|
schemaPath: string;
|
||||||
|
baseId: string;
|
||||||
|
async: boolean;
|
||||||
|
opts: Options;
|
||||||
|
formats: {
|
||||||
|
[index: string]: FormatDefinition | undefined;
|
||||||
|
};
|
||||||
|
keywords: {
|
||||||
|
[index: string]: KeywordDefinition | undefined;
|
||||||
|
};
|
||||||
|
compositeRule: boolean;
|
||||||
|
validate: (schema: object) => boolean;
|
||||||
|
util: {
|
||||||
|
copy(obj: any, target?: any): any;
|
||||||
|
toHash(source: string[]): { [index: string]: true | undefined };
|
||||||
|
equal(obj: any, target: any): boolean;
|
||||||
|
getProperty(str: string): string;
|
||||||
|
schemaHasRules(schema: object, rules: any): string;
|
||||||
|
escapeQuotes(str: string): string;
|
||||||
|
toQuotedString(str: string): string;
|
||||||
|
getData(jsonPointer: string, dataLevel: number, paths: string[]): string;
|
||||||
|
escapeJsonPointer(str: string): string;
|
||||||
|
unescapeJsonPointer(str: string): string;
|
||||||
|
escapeFragment(str: string): string;
|
||||||
|
unescapeFragment(str: string): string;
|
||||||
|
};
|
||||||
|
self: Ajv;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SchemaValidateFunction {
|
||||||
|
(
|
||||||
|
schema: any,
|
||||||
|
data: any,
|
||||||
|
parentSchema?: object,
|
||||||
|
dataPath?: string,
|
||||||
|
parentData?: object | Array<any>,
|
||||||
|
parentDataProperty?: string | number,
|
||||||
|
rootData?: object | Array<any>
|
||||||
|
): boolean | PromiseLike<any>;
|
||||||
|
errors?: Array<ErrorObject>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ErrorsTextOptions {
|
||||||
|
separator?: string;
|
||||||
|
dataVar?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ErrorObject {
|
||||||
|
keyword: string;
|
||||||
|
dataPath: string;
|
||||||
|
schemaPath: string;
|
||||||
|
params: ErrorParameters;
|
||||||
|
// Added to validation errors of propertyNames keyword schema
|
||||||
|
propertyName?: string;
|
||||||
|
// Excluded if messages set to false.
|
||||||
|
message?: string;
|
||||||
|
// These are added with the `verbose` option.
|
||||||
|
schema?: any;
|
||||||
|
parentSchema?: object;
|
||||||
|
data?: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
type ErrorParameters = RefParams | LimitParams | AdditionalPropertiesParams |
|
||||||
|
DependenciesParams | FormatParams | ComparisonParams |
|
||||||
|
MultipleOfParams | PatternParams | RequiredParams |
|
||||||
|
TypeParams | UniqueItemsParams | CustomParams |
|
||||||
|
PatternRequiredParams | PropertyNamesParams |
|
||||||
|
IfParams | SwitchParams | NoParams | EnumParams;
|
||||||
|
|
||||||
|
interface RefParams {
|
||||||
|
ref: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface LimitParams {
|
||||||
|
limit: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AdditionalPropertiesParams {
|
||||||
|
additionalProperty: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DependenciesParams {
|
||||||
|
property: string;
|
||||||
|
missingProperty: string;
|
||||||
|
depsCount: number;
|
||||||
|
deps: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface FormatParams {
|
||||||
|
format: string
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ComparisonParams {
|
||||||
|
comparison: string;
|
||||||
|
limit: number | string;
|
||||||
|
exclusive: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MultipleOfParams {
|
||||||
|
multipleOf: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PatternParams {
|
||||||
|
pattern: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RequiredParams {
|
||||||
|
missingProperty: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TypeParams {
|
||||||
|
type: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface UniqueItemsParams {
|
||||||
|
i: number;
|
||||||
|
j: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CustomParams {
|
||||||
|
keyword: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PatternRequiredParams {
|
||||||
|
missingPattern: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PropertyNamesParams {
|
||||||
|
propertyName: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IfParams {
|
||||||
|
failingKeyword: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SwitchParams {
|
||||||
|
caseIndex: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface NoParams { }
|
||||||
|
|
||||||
|
interface EnumParams {
|
||||||
|
allowedValues: Array<any>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export = ajv;
|
506
node_modules/ajv/lib/ajv.js
generated
vendored
Normal file
506
node_modules/ajv/lib/ajv.js
generated
vendored
Normal file
@ -0,0 +1,506 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var compileSchema = require('./compile')
|
||||||
|
, resolve = require('./compile/resolve')
|
||||||
|
, Cache = require('./cache')
|
||||||
|
, SchemaObject = require('./compile/schema_obj')
|
||||||
|
, stableStringify = require('fast-json-stable-stringify')
|
||||||
|
, formats = require('./compile/formats')
|
||||||
|
, rules = require('./compile/rules')
|
||||||
|
, $dataMetaSchema = require('./data')
|
||||||
|
, util = require('./compile/util');
|
||||||
|
|
||||||
|
module.exports = Ajv;
|
||||||
|
|
||||||
|
Ajv.prototype.validate = validate;
|
||||||
|
Ajv.prototype.compile = compile;
|
||||||
|
Ajv.prototype.addSchema = addSchema;
|
||||||
|
Ajv.prototype.addMetaSchema = addMetaSchema;
|
||||||
|
Ajv.prototype.validateSchema = validateSchema;
|
||||||
|
Ajv.prototype.getSchema = getSchema;
|
||||||
|
Ajv.prototype.removeSchema = removeSchema;
|
||||||
|
Ajv.prototype.addFormat = addFormat;
|
||||||
|
Ajv.prototype.errorsText = errorsText;
|
||||||
|
|
||||||
|
Ajv.prototype._addSchema = _addSchema;
|
||||||
|
Ajv.prototype._compile = _compile;
|
||||||
|
|
||||||
|
Ajv.prototype.compileAsync = require('./compile/async');
|
||||||
|
var customKeyword = require('./keyword');
|
||||||
|
Ajv.prototype.addKeyword = customKeyword.add;
|
||||||
|
Ajv.prototype.getKeyword = customKeyword.get;
|
||||||
|
Ajv.prototype.removeKeyword = customKeyword.remove;
|
||||||
|
Ajv.prototype.validateKeyword = customKeyword.validate;
|
||||||
|
|
||||||
|
var errorClasses = require('./compile/error_classes');
|
||||||
|
Ajv.ValidationError = errorClasses.Validation;
|
||||||
|
Ajv.MissingRefError = errorClasses.MissingRef;
|
||||||
|
Ajv.$dataMetaSchema = $dataMetaSchema;
|
||||||
|
|
||||||
|
var META_SCHEMA_ID = 'http://json-schema.org/draft-07/schema';
|
||||||
|
|
||||||
|
var META_IGNORE_OPTIONS = [ 'removeAdditional', 'useDefaults', 'coerceTypes', 'strictDefaults' ];
|
||||||
|
var META_SUPPORT_DATA = ['/properties'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates validator instance.
|
||||||
|
* Usage: `Ajv(opts)`
|
||||||
|
* @param {Object} opts optional options
|
||||||
|
* @return {Object} ajv instance
|
||||||
|
*/
|
||||||
|
function Ajv(opts) {
|
||||||
|
if (!(this instanceof Ajv)) return new Ajv(opts);
|
||||||
|
opts = this._opts = util.copy(opts) || {};
|
||||||
|
setLogger(this);
|
||||||
|
this._schemas = {};
|
||||||
|
this._refs = {};
|
||||||
|
this._fragments = {};
|
||||||
|
this._formats = formats(opts.format);
|
||||||
|
|
||||||
|
this._cache = opts.cache || new Cache;
|
||||||
|
this._loadingSchemas = {};
|
||||||
|
this._compilations = [];
|
||||||
|
this.RULES = rules();
|
||||||
|
this._getId = chooseGetId(opts);
|
||||||
|
|
||||||
|
opts.loopRequired = opts.loopRequired || Infinity;
|
||||||
|
if (opts.errorDataPath == 'property') opts._errorDataPathProperty = true;
|
||||||
|
if (opts.serialize === undefined) opts.serialize = stableStringify;
|
||||||
|
this._metaOpts = getMetaSchemaOptions(this);
|
||||||
|
|
||||||
|
if (opts.formats) addInitialFormats(this);
|
||||||
|
if (opts.keywords) addInitialKeywords(this);
|
||||||
|
addDefaultMetaSchema(this);
|
||||||
|
if (typeof opts.meta == 'object') this.addMetaSchema(opts.meta);
|
||||||
|
if (opts.nullable) this.addKeyword('nullable', {metaSchema: {type: 'boolean'}});
|
||||||
|
addInitialSchemas(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate data using schema
|
||||||
|
* Schema will be compiled and cached (using serialized JSON as key. [fast-json-stable-stringify](https://github.com/epoberezkin/fast-json-stable-stringify) is used to serialize.
|
||||||
|
* @this Ajv
|
||||||
|
* @param {String|Object} schemaKeyRef key, ref or schema object
|
||||||
|
* @param {Any} data to be validated
|
||||||
|
* @return {Boolean} validation result. Errors from the last validation will be available in `ajv.errors` (and also in compiled schema: `schema.errors`).
|
||||||
|
*/
|
||||||
|
function validate(schemaKeyRef, data) {
|
||||||
|
var v;
|
||||||
|
if (typeof schemaKeyRef == 'string') {
|
||||||
|
v = this.getSchema(schemaKeyRef);
|
||||||
|
if (!v) throw new Error('no schema with key or ref "' + schemaKeyRef + '"');
|
||||||
|
} else {
|
||||||
|
var schemaObj = this._addSchema(schemaKeyRef);
|
||||||
|
v = schemaObj.validate || this._compile(schemaObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
var valid = v(data);
|
||||||
|
if (v.$async !== true) this.errors = v.errors;
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create validating function for passed schema.
|
||||||
|
* @this Ajv
|
||||||
|
* @param {Object} schema schema object
|
||||||
|
* @param {Boolean} _meta true if schema is a meta-schema. Used internally to compile meta schemas of custom keywords.
|
||||||
|
* @return {Function} validating function
|
||||||
|
*/
|
||||||
|
function compile(schema, _meta) {
|
||||||
|
var schemaObj = this._addSchema(schema, undefined, _meta);
|
||||||
|
return schemaObj.validate || this._compile(schemaObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds schema to the instance.
|
||||||
|
* @this Ajv
|
||||||
|
* @param {Object|Array} schema schema or array of schemas. If array is passed, `key` and other parameters will be ignored.
|
||||||
|
* @param {String} key Optional schema key. Can be passed to `validate` method instead of schema object or id/ref. One schema per instance can have empty `id` and `key`.
|
||||||
|
* @param {Boolean} _skipValidation true to skip schema validation. Used internally, option validateSchema should be used instead.
|
||||||
|
* @param {Boolean} _meta true if schema is a meta-schema. Used internally, addMetaSchema should be used instead.
|
||||||
|
* @return {Ajv} this for method chaining
|
||||||
|
*/
|
||||||
|
function addSchema(schema, key, _skipValidation, _meta) {
|
||||||
|
if (Array.isArray(schema)){
|
||||||
|
for (var i=0; i<schema.length; i++) this.addSchema(schema[i], undefined, _skipValidation, _meta);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
var id = this._getId(schema);
|
||||||
|
if (id !== undefined && typeof id != 'string')
|
||||||
|
throw new Error('schema id must be string');
|
||||||
|
key = resolve.normalizeId(key || id);
|
||||||
|
checkUnique(this, key);
|
||||||
|
this._schemas[key] = this._addSchema(schema, _skipValidation, _meta, true);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add schema that will be used to validate other schemas
|
||||||
|
* options in META_IGNORE_OPTIONS are alway set to false
|
||||||
|
* @this Ajv
|
||||||
|
* @param {Object} schema schema object
|
||||||
|
* @param {String} key optional schema key
|
||||||
|
* @param {Boolean} skipValidation true to skip schema validation, can be used to override validateSchema option for meta-schema
|
||||||
|
* @return {Ajv} this for method chaining
|
||||||
|
*/
|
||||||
|
function addMetaSchema(schema, key, skipValidation) {
|
||||||
|
this.addSchema(schema, key, skipValidation, true);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate schema
|
||||||
|
* @this Ajv
|
||||||
|
* @param {Object} schema schema to validate
|
||||||
|
* @param {Boolean} throwOrLogError pass true to throw (or log) an error if invalid
|
||||||
|
* @return {Boolean} true if schema is valid
|
||||||
|
*/
|
||||||
|
function validateSchema(schema, throwOrLogError) {
|
||||||
|
var $schema = schema.$schema;
|
||||||
|
if ($schema !== undefined && typeof $schema != 'string')
|
||||||
|
throw new Error('$schema must be a string');
|
||||||
|
$schema = $schema || this._opts.defaultMeta || defaultMeta(this);
|
||||||
|
if (!$schema) {
|
||||||
|
this.logger.warn('meta-schema not available');
|
||||||
|
this.errors = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
var valid = this.validate($schema, schema);
|
||||||
|
if (!valid && throwOrLogError) {
|
||||||
|
var message = 'schema is invalid: ' + this.errorsText();
|
||||||
|
if (this._opts.validateSchema == 'log') this.logger.error(message);
|
||||||
|
else throw new Error(message);
|
||||||
|
}
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function defaultMeta(self) {
|
||||||
|
var meta = self._opts.meta;
|
||||||
|
self._opts.defaultMeta = typeof meta == 'object'
|
||||||
|
? self._getId(meta) || meta
|
||||||
|
: self.getSchema(META_SCHEMA_ID)
|
||||||
|
? META_SCHEMA_ID
|
||||||
|
: undefined;
|
||||||
|
return self._opts.defaultMeta;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get compiled schema from the instance by `key` or `ref`.
|
||||||
|
* @this Ajv
|
||||||
|
* @param {String} keyRef `key` that was passed to `addSchema` or full schema reference (`schema.id` or resolved id).
|
||||||
|
* @return {Function} schema validating function (with property `schema`).
|
||||||
|
*/
|
||||||
|
function getSchema(keyRef) {
|
||||||
|
var schemaObj = _getSchemaObj(this, keyRef);
|
||||||
|
switch (typeof schemaObj) {
|
||||||
|
case 'object': return schemaObj.validate || this._compile(schemaObj);
|
||||||
|
case 'string': return this.getSchema(schemaObj);
|
||||||
|
case 'undefined': return _getSchemaFragment(this, keyRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _getSchemaFragment(self, ref) {
|
||||||
|
var res = resolve.schema.call(self, { schema: {} }, ref);
|
||||||
|
if (res) {
|
||||||
|
var schema = res.schema
|
||||||
|
, root = res.root
|
||||||
|
, baseId = res.baseId;
|
||||||
|
var v = compileSchema.call(self, schema, root, undefined, baseId);
|
||||||
|
self._fragments[ref] = new SchemaObject({
|
||||||
|
ref: ref,
|
||||||
|
fragment: true,
|
||||||
|
schema: schema,
|
||||||
|
root: root,
|
||||||
|
baseId: baseId,
|
||||||
|
validate: v
|
||||||
|
});
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _getSchemaObj(self, keyRef) {
|
||||||
|
keyRef = resolve.normalizeId(keyRef);
|
||||||
|
return self._schemas[keyRef] || self._refs[keyRef] || self._fragments[keyRef];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove cached schema(s).
|
||||||
|
* If no parameter is passed all schemas but meta-schemas are removed.
|
||||||
|
* If RegExp is passed all schemas with key/id matching pattern but meta-schemas are removed.
|
||||||
|
* Even if schema is referenced by other schemas it still can be removed as other schemas have local references.
|
||||||
|
* @this Ajv
|
||||||
|
* @param {String|Object|RegExp} schemaKeyRef key, ref, pattern to match key/ref or schema object
|
||||||
|
* @return {Ajv} this for method chaining
|
||||||
|
*/
|
||||||
|
function removeSchema(schemaKeyRef) {
|
||||||
|
if (schemaKeyRef instanceof RegExp) {
|
||||||
|
_removeAllSchemas(this, this._schemas, schemaKeyRef);
|
||||||
|
_removeAllSchemas(this, this._refs, schemaKeyRef);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
switch (typeof schemaKeyRef) {
|
||||||
|
case 'undefined':
|
||||||
|
_removeAllSchemas(this, this._schemas);
|
||||||
|
_removeAllSchemas(this, this._refs);
|
||||||
|
this._cache.clear();
|
||||||
|
return this;
|
||||||
|
case 'string':
|
||||||
|
var schemaObj = _getSchemaObj(this, schemaKeyRef);
|
||||||
|
if (schemaObj) this._cache.del(schemaObj.cacheKey);
|
||||||
|
delete this._schemas[schemaKeyRef];
|
||||||
|
delete this._refs[schemaKeyRef];
|
||||||
|
return this;
|
||||||
|
case 'object':
|
||||||
|
var serialize = this._opts.serialize;
|
||||||
|
var cacheKey = serialize ? serialize(schemaKeyRef) : schemaKeyRef;
|
||||||
|
this._cache.del(cacheKey);
|
||||||
|
var id = this._getId(schemaKeyRef);
|
||||||
|
if (id) {
|
||||||
|
id = resolve.normalizeId(id);
|
||||||
|
delete this._schemas[id];
|
||||||
|
delete this._refs[id];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _removeAllSchemas(self, schemas, regex) {
|
||||||
|
for (var keyRef in schemas) {
|
||||||
|
var schemaObj = schemas[keyRef];
|
||||||
|
if (!schemaObj.meta && (!regex || regex.test(keyRef))) {
|
||||||
|
self._cache.del(schemaObj.cacheKey);
|
||||||
|
delete schemas[keyRef];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* @this Ajv */
|
||||||
|
function _addSchema(schema, skipValidation, meta, shouldAddSchema) {
|
||||||
|
if (typeof schema != 'object' && typeof schema != 'boolean')
|
||||||
|
throw new Error('schema should be object or boolean');
|
||||||
|
var serialize = this._opts.serialize;
|
||||||
|
var cacheKey = serialize ? serialize(schema) : schema;
|
||||||
|
var cached = this._cache.get(cacheKey);
|
||||||
|
if (cached) return cached;
|
||||||
|
|
||||||
|
shouldAddSchema = shouldAddSchema || this._opts.addUsedSchema !== false;
|
||||||
|
|
||||||
|
var id = resolve.normalizeId(this._getId(schema));
|
||||||
|
if (id && shouldAddSchema) checkUnique(this, id);
|
||||||
|
|
||||||
|
var willValidate = this._opts.validateSchema !== false && !skipValidation;
|
||||||
|
var recursiveMeta;
|
||||||
|
if (willValidate && !(recursiveMeta = id && id == resolve.normalizeId(schema.$schema)))
|
||||||
|
this.validateSchema(schema, true);
|
||||||
|
|
||||||
|
var localRefs = resolve.ids.call(this, schema);
|
||||||
|
|
||||||
|
var schemaObj = new SchemaObject({
|
||||||
|
id: id,
|
||||||
|
schema: schema,
|
||||||
|
localRefs: localRefs,
|
||||||
|
cacheKey: cacheKey,
|
||||||
|
meta: meta
|
||||||
|
});
|
||||||
|
|
||||||
|
if (id[0] != '#' && shouldAddSchema) this._refs[id] = schemaObj;
|
||||||
|
this._cache.put(cacheKey, schemaObj);
|
||||||
|
|
||||||
|
if (willValidate && recursiveMeta) this.validateSchema(schema, true);
|
||||||
|
|
||||||
|
return schemaObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* @this Ajv */
|
||||||
|
function _compile(schemaObj, root) {
|
||||||
|
if (schemaObj.compiling) {
|
||||||
|
schemaObj.validate = callValidate;
|
||||||
|
callValidate.schema = schemaObj.schema;
|
||||||
|
callValidate.errors = null;
|
||||||
|
callValidate.root = root ? root : callValidate;
|
||||||
|
if (schemaObj.schema.$async === true)
|
||||||
|
callValidate.$async = true;
|
||||||
|
return callValidate;
|
||||||
|
}
|
||||||
|
schemaObj.compiling = true;
|
||||||
|
|
||||||
|
var currentOpts;
|
||||||
|
if (schemaObj.meta) {
|
||||||
|
currentOpts = this._opts;
|
||||||
|
this._opts = this._metaOpts;
|
||||||
|
}
|
||||||
|
|
||||||
|
var v;
|
||||||
|
try { v = compileSchema.call(this, schemaObj.schema, root, schemaObj.localRefs); }
|
||||||
|
catch(e) {
|
||||||
|
delete schemaObj.validate;
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
schemaObj.compiling = false;
|
||||||
|
if (schemaObj.meta) this._opts = currentOpts;
|
||||||
|
}
|
||||||
|
|
||||||
|
schemaObj.validate = v;
|
||||||
|
schemaObj.refs = v.refs;
|
||||||
|
schemaObj.refVal = v.refVal;
|
||||||
|
schemaObj.root = v.root;
|
||||||
|
return v;
|
||||||
|
|
||||||
|
|
||||||
|
/* @this {*} - custom context, see passContext option */
|
||||||
|
function callValidate() {
|
||||||
|
/* jshint validthis: true */
|
||||||
|
var _validate = schemaObj.validate;
|
||||||
|
var result = _validate.apply(this, arguments);
|
||||||
|
callValidate.errors = _validate.errors;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function chooseGetId(opts) {
|
||||||
|
switch (opts.schemaId) {
|
||||||
|
case 'auto': return _get$IdOrId;
|
||||||
|
case 'id': return _getId;
|
||||||
|
default: return _get$Id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* @this Ajv */
|
||||||
|
function _getId(schema) {
|
||||||
|
if (schema.$id) this.logger.warn('schema $id ignored', schema.$id);
|
||||||
|
return schema.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* @this Ajv */
|
||||||
|
function _get$Id(schema) {
|
||||||
|
if (schema.id) this.logger.warn('schema id ignored', schema.id);
|
||||||
|
return schema.$id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _get$IdOrId(schema) {
|
||||||
|
if (schema.$id && schema.id && schema.$id != schema.id)
|
||||||
|
throw new Error('schema $id is different from id');
|
||||||
|
return schema.$id || schema.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert array of error message objects to string
|
||||||
|
* @this Ajv
|
||||||
|
* @param {Array<Object>} errors optional array of validation errors, if not passed errors from the instance are used.
|
||||||
|
* @param {Object} options optional options with properties `separator` and `dataVar`.
|
||||||
|
* @return {String} human readable string with all errors descriptions
|
||||||
|
*/
|
||||||
|
function errorsText(errors, options) {
|
||||||
|
errors = errors || this.errors;
|
||||||
|
if (!errors) return 'No errors';
|
||||||
|
options = options || {};
|
||||||
|
var separator = options.separator === undefined ? ', ' : options.separator;
|
||||||
|
var dataVar = options.dataVar === undefined ? 'data' : options.dataVar;
|
||||||
|
|
||||||
|
var text = '';
|
||||||
|
for (var i=0; i<errors.length; i++) {
|
||||||
|
var e = errors[i];
|
||||||
|
if (e) text += dataVar + e.dataPath + ' ' + e.message + separator;
|
||||||
|
}
|
||||||
|
return text.slice(0, -separator.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add custom format
|
||||||
|
* @this Ajv
|
||||||
|
* @param {String} name format name
|
||||||
|
* @param {String|RegExp|Function} format string is converted to RegExp; function should return boolean (true when valid)
|
||||||
|
* @return {Ajv} this for method chaining
|
||||||
|
*/
|
||||||
|
function addFormat(name, format) {
|
||||||
|
if (typeof format == 'string') format = new RegExp(format);
|
||||||
|
this._formats[name] = format;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function addDefaultMetaSchema(self) {
|
||||||
|
var $dataSchema;
|
||||||
|
if (self._opts.$data) {
|
||||||
|
$dataSchema = require('./refs/data.json');
|
||||||
|
self.addMetaSchema($dataSchema, $dataSchema.$id, true);
|
||||||
|
}
|
||||||
|
if (self._opts.meta === false) return;
|
||||||
|
var metaSchema = require('./refs/json-schema-draft-07.json');
|
||||||
|
if (self._opts.$data) metaSchema = $dataMetaSchema(metaSchema, META_SUPPORT_DATA);
|
||||||
|
self.addMetaSchema(metaSchema, META_SCHEMA_ID, true);
|
||||||
|
self._refs['http://json-schema.org/schema'] = META_SCHEMA_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function addInitialSchemas(self) {
|
||||||
|
var optsSchemas = self._opts.schemas;
|
||||||
|
if (!optsSchemas) return;
|
||||||
|
if (Array.isArray(optsSchemas)) self.addSchema(optsSchemas);
|
||||||
|
else for (var key in optsSchemas) self.addSchema(optsSchemas[key], key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function addInitialFormats(self) {
|
||||||
|
for (var name in self._opts.formats) {
|
||||||
|
var format = self._opts.formats[name];
|
||||||
|
self.addFormat(name, format);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function addInitialKeywords(self) {
|
||||||
|
for (var name in self._opts.keywords) {
|
||||||
|
var keyword = self._opts.keywords[name];
|
||||||
|
self.addKeyword(name, keyword);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function checkUnique(self, id) {
|
||||||
|
if (self._schemas[id] || self._refs[id])
|
||||||
|
throw new Error('schema with key or id "' + id + '" already exists');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getMetaSchemaOptions(self) {
|
||||||
|
var metaOpts = util.copy(self._opts);
|
||||||
|
for (var i=0; i<META_IGNORE_OPTIONS.length; i++)
|
||||||
|
delete metaOpts[META_IGNORE_OPTIONS[i]];
|
||||||
|
return metaOpts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function setLogger(self) {
|
||||||
|
var logger = self._opts.logger;
|
||||||
|
if (logger === false) {
|
||||||
|
self.logger = {log: noop, warn: noop, error: noop};
|
||||||
|
} else {
|
||||||
|
if (logger === undefined) logger = console;
|
||||||
|
if (!(typeof logger == 'object' && logger.log && logger.warn && logger.error))
|
||||||
|
throw new Error('logger must implement log, warn and error methods');
|
||||||
|
self.logger = logger;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function noop() {}
|
26
node_modules/ajv/lib/cache.js
generated
vendored
Normal file
26
node_modules/ajv/lib/cache.js
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
var Cache = module.exports = function Cache() {
|
||||||
|
this._cache = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Cache.prototype.put = function Cache_put(key, value) {
|
||||||
|
this._cache[key] = value;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Cache.prototype.get = function Cache_get(key) {
|
||||||
|
return this._cache[key];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Cache.prototype.del = function Cache_del(key) {
|
||||||
|
delete this._cache[key];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Cache.prototype.clear = function Cache_clear() {
|
||||||
|
this._cache = {};
|
||||||
|
};
|
90
node_modules/ajv/lib/compile/async.js
generated
vendored
Normal file
90
node_modules/ajv/lib/compile/async.js
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var MissingRefError = require('./error_classes').MissingRef;
|
||||||
|
|
||||||
|
module.exports = compileAsync;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates validating function for passed schema with asynchronous loading of missing schemas.
|
||||||
|
* `loadSchema` option should be a function that accepts schema uri and returns promise that resolves with the schema.
|
||||||
|
* @this Ajv
|
||||||
|
* @param {Object} schema schema object
|
||||||
|
* @param {Boolean} meta optional true to compile meta-schema; this parameter can be skipped
|
||||||
|
* @param {Function} callback an optional node-style callback, it is called with 2 parameters: error (or null) and validating function.
|
||||||
|
* @return {Promise} promise that resolves with a validating function.
|
||||||
|
*/
|
||||||
|
function compileAsync(schema, meta, callback) {
|
||||||
|
/* eslint no-shadow: 0 */
|
||||||
|
/* global Promise */
|
||||||
|
/* jshint validthis: true */
|
||||||
|
var self = this;
|
||||||
|
if (typeof this._opts.loadSchema != 'function')
|
||||||
|
throw new Error('options.loadSchema should be a function');
|
||||||
|
|
||||||
|
if (typeof meta == 'function') {
|
||||||
|
callback = meta;
|
||||||
|
meta = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
var p = loadMetaSchemaOf(schema).then(function () {
|
||||||
|
var schemaObj = self._addSchema(schema, undefined, meta);
|
||||||
|
return schemaObj.validate || _compileAsync(schemaObj);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (callback) {
|
||||||
|
p.then(
|
||||||
|
function(v) { callback(null, v); },
|
||||||
|
callback
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return p;
|
||||||
|
|
||||||
|
|
||||||
|
function loadMetaSchemaOf(sch) {
|
||||||
|
var $schema = sch.$schema;
|
||||||
|
return $schema && !self.getSchema($schema)
|
||||||
|
? compileAsync.call(self, { $ref: $schema }, true)
|
||||||
|
: Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _compileAsync(schemaObj) {
|
||||||
|
try { return self._compile(schemaObj); }
|
||||||
|
catch(e) {
|
||||||
|
if (e instanceof MissingRefError) return loadMissingSchema(e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function loadMissingSchema(e) {
|
||||||
|
var ref = e.missingSchema;
|
||||||
|
if (added(ref)) throw new Error('Schema ' + ref + ' is loaded but ' + e.missingRef + ' cannot be resolved');
|
||||||
|
|
||||||
|
var schemaPromise = self._loadingSchemas[ref];
|
||||||
|
if (!schemaPromise) {
|
||||||
|
schemaPromise = self._loadingSchemas[ref] = self._opts.loadSchema(ref);
|
||||||
|
schemaPromise.then(removePromise, removePromise);
|
||||||
|
}
|
||||||
|
|
||||||
|
return schemaPromise.then(function (sch) {
|
||||||
|
if (!added(ref)) {
|
||||||
|
return loadMetaSchemaOf(sch).then(function () {
|
||||||
|
if (!added(ref)) self.addSchema(sch, ref, undefined, meta);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}).then(function() {
|
||||||
|
return _compileAsync(schemaObj);
|
||||||
|
});
|
||||||
|
|
||||||
|
function removePromise() {
|
||||||
|
delete self._loadingSchemas[ref];
|
||||||
|
}
|
||||||
|
|
||||||
|
function added(ref) {
|
||||||
|
return self._refs[ref] || self._schemas[ref];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
node_modules/ajv/lib/compile/equal.js
generated
vendored
Normal file
5
node_modules/ajv/lib/compile/equal.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
// do NOT remove this file - it would break pre-compiled schemas
|
||||||
|
// https://github.com/ajv-validator/ajv/issues/889
|
||||||
|
module.exports = require('fast-deep-equal');
|
34
node_modules/ajv/lib/compile/error_classes.js
generated
vendored
Normal file
34
node_modules/ajv/lib/compile/error_classes.js
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var resolve = require('./resolve');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
Validation: errorSubclass(ValidationError),
|
||||||
|
MissingRef: errorSubclass(MissingRefError)
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function ValidationError(errors) {
|
||||||
|
this.message = 'validation failed';
|
||||||
|
this.errors = errors;
|
||||||
|
this.ajv = this.validation = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MissingRefError.message = function (baseId, ref) {
|
||||||
|
return 'can\'t resolve reference ' + ref + ' from id ' + baseId;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function MissingRefError(baseId, ref, message) {
|
||||||
|
this.message = message || MissingRefError.message(baseId, ref);
|
||||||
|
this.missingRef = resolve.url(baseId, ref);
|
||||||
|
this.missingSchema = resolve.normalizeId(resolve.fullPath(this.missingRef));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function errorSubclass(Subclass) {
|
||||||
|
Subclass.prototype = Object.create(Error.prototype);
|
||||||
|
Subclass.prototype.constructor = Subclass;
|
||||||
|
return Subclass;
|
||||||
|
}
|
142
node_modules/ajv/lib/compile/formats.js
generated
vendored
Normal file
142
node_modules/ajv/lib/compile/formats.js
generated
vendored
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var util = require('./util');
|
||||||
|
|
||||||
|
var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
|
||||||
|
var DAYS = [0,31,28,31,30,31,30,31,31,30,31,30,31];
|
||||||
|
var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
|
||||||
|
var HOSTNAME = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i;
|
||||||
|
var URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
|
||||||
|
var URIREF = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
|
||||||
|
// uri-template: https://tools.ietf.org/html/rfc6570
|
||||||
|
var URITEMPLATE = /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i;
|
||||||
|
// For the source: https://gist.github.com/dperini/729294
|
||||||
|
// For test cases: https://mathiasbynens.be/demo/url-regex
|
||||||
|
// @todo Delete current URL in favour of the commented out URL rule when this issue is fixed https://github.com/eslint/eslint/issues/7983.
|
||||||
|
// var URL = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu;
|
||||||
|
var URL = /^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i;
|
||||||
|
var UUID = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
|
||||||
|
var JSON_POINTER = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
|
||||||
|
var JSON_POINTER_URI_FRAGMENT = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
|
||||||
|
var RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = formats;
|
||||||
|
|
||||||
|
function formats(mode) {
|
||||||
|
mode = mode == 'full' ? 'full' : 'fast';
|
||||||
|
return util.copy(formats[mode]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
formats.fast = {
|
||||||
|
// date: http://tools.ietf.org/html/rfc3339#section-5.6
|
||||||
|
date: /^\d\d\d\d-[0-1]\d-[0-3]\d$/,
|
||||||
|
// date-time: http://tools.ietf.org/html/rfc3339#section-5.6
|
||||||
|
time: /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,
|
||||||
|
'date-time': /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,
|
||||||
|
// uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js
|
||||||
|
uri: /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,
|
||||||
|
'uri-reference': /^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,
|
||||||
|
'uri-template': URITEMPLATE,
|
||||||
|
url: URL,
|
||||||
|
// email (sources from jsen validator):
|
||||||
|
// http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address#answer-8829363
|
||||||
|
// http://www.w3.org/TR/html5/forms.html#valid-e-mail-address (search for 'willful violation')
|
||||||
|
email: /^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,
|
||||||
|
hostname: HOSTNAME,
|
||||||
|
// optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html
|
||||||
|
ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
|
||||||
|
// optimized http://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses
|
||||||
|
ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
|
||||||
|
regex: regex,
|
||||||
|
// uuid: http://tools.ietf.org/html/rfc4122
|
||||||
|
uuid: UUID,
|
||||||
|
// JSON-pointer: https://tools.ietf.org/html/rfc6901
|
||||||
|
// uri fragment: https://tools.ietf.org/html/rfc3986#appendix-A
|
||||||
|
'json-pointer': JSON_POINTER,
|
||||||
|
'json-pointer-uri-fragment': JSON_POINTER_URI_FRAGMENT,
|
||||||
|
// relative JSON-pointer: http://tools.ietf.org/html/draft-luff-relative-json-pointer-00
|
||||||
|
'relative-json-pointer': RELATIVE_JSON_POINTER
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
formats.full = {
|
||||||
|
date: date,
|
||||||
|
time: time,
|
||||||
|
'date-time': date_time,
|
||||||
|
uri: uri,
|
||||||
|
'uri-reference': URIREF,
|
||||||
|
'uri-template': URITEMPLATE,
|
||||||
|
url: URL,
|
||||||
|
email: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,
|
||||||
|
hostname: HOSTNAME,
|
||||||
|
ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
|
||||||
|
ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
|
||||||
|
regex: regex,
|
||||||
|
uuid: UUID,
|
||||||
|
'json-pointer': JSON_POINTER,
|
||||||
|
'json-pointer-uri-fragment': JSON_POINTER_URI_FRAGMENT,
|
||||||
|
'relative-json-pointer': RELATIVE_JSON_POINTER
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function isLeapYear(year) {
|
||||||
|
// https://tools.ietf.org/html/rfc3339#appendix-C
|
||||||
|
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function date(str) {
|
||||||
|
// full-date from http://tools.ietf.org/html/rfc3339#section-5.6
|
||||||
|
var matches = str.match(DATE);
|
||||||
|
if (!matches) return false;
|
||||||
|
|
||||||
|
var year = +matches[1];
|
||||||
|
var month = +matches[2];
|
||||||
|
var day = +matches[3];
|
||||||
|
|
||||||
|
return month >= 1 && month <= 12 && day >= 1 &&
|
||||||
|
day <= (month == 2 && isLeapYear(year) ? 29 : DAYS[month]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function time(str, full) {
|
||||||
|
var matches = str.match(TIME);
|
||||||
|
if (!matches) return false;
|
||||||
|
|
||||||
|
var hour = matches[1];
|
||||||
|
var minute = matches[2];
|
||||||
|
var second = matches[3];
|
||||||
|
var timeZone = matches[5];
|
||||||
|
return ((hour <= 23 && minute <= 59 && second <= 59) ||
|
||||||
|
(hour == 23 && minute == 59 && second == 60)) &&
|
||||||
|
(!full || timeZone);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var DATE_TIME_SEPARATOR = /t|\s/i;
|
||||||
|
function date_time(str) {
|
||||||
|
// http://tools.ietf.org/html/rfc3339#section-5.6
|
||||||
|
var dateTime = str.split(DATE_TIME_SEPARATOR);
|
||||||
|
return dateTime.length == 2 && date(dateTime[0]) && time(dateTime[1], true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var NOT_URI_FRAGMENT = /\/|:/;
|
||||||
|
function uri(str) {
|
||||||
|
// http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "."
|
||||||
|
return NOT_URI_FRAGMENT.test(str) && URI.test(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var Z_ANCHOR = /[^\\]\\Z/;
|
||||||
|
function regex(str) {
|
||||||
|
if (Z_ANCHOR.test(str)) return false;
|
||||||
|
try {
|
||||||
|
new RegExp(str);
|
||||||
|
return true;
|
||||||
|
} catch(e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
387
node_modules/ajv/lib/compile/index.js
generated
vendored
Normal file
387
node_modules/ajv/lib/compile/index.js
generated
vendored
Normal file
@ -0,0 +1,387 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var resolve = require('./resolve')
|
||||||
|
, util = require('./util')
|
||||||
|
, errorClasses = require('./error_classes')
|
||||||
|
, stableStringify = require('fast-json-stable-stringify');
|
||||||
|
|
||||||
|
var validateGenerator = require('../dotjs/validate');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Functions below are used inside compiled validations function
|
||||||
|
*/
|
||||||
|
|
||||||
|
var ucs2length = util.ucs2length;
|
||||||
|
var equal = require('fast-deep-equal');
|
||||||
|
|
||||||
|
// this error is thrown by async schemas to return validation errors via exception
|
||||||
|
var ValidationError = errorClasses.Validation;
|
||||||
|
|
||||||
|
module.exports = compile;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compiles schema to validation function
|
||||||
|
* @this Ajv
|
||||||
|
* @param {Object} schema schema object
|
||||||
|
* @param {Object} root object with information about the root schema for this schema
|
||||||
|
* @param {Object} localRefs the hash of local references inside the schema (created by resolve.id), used for inline resolution
|
||||||
|
* @param {String} baseId base ID for IDs in the schema
|
||||||
|
* @return {Function} validation function
|
||||||
|
*/
|
||||||
|
function compile(schema, root, localRefs, baseId) {
|
||||||
|
/* jshint validthis: true, evil: true */
|
||||||
|
/* eslint no-shadow: 0 */
|
||||||
|
var self = this
|
||||||
|
, opts = this._opts
|
||||||
|
, refVal = [ undefined ]
|
||||||
|
, refs = {}
|
||||||
|
, patterns = []
|
||||||
|
, patternsHash = {}
|
||||||
|
, defaults = []
|
||||||
|
, defaultsHash = {}
|
||||||
|
, customRules = [];
|
||||||
|
|
||||||
|
root = root || { schema: schema, refVal: refVal, refs: refs };
|
||||||
|
|
||||||
|
var c = checkCompiling.call(this, schema, root, baseId);
|
||||||
|
var compilation = this._compilations[c.index];
|
||||||
|
if (c.compiling) return (compilation.callValidate = callValidate);
|
||||||
|
|
||||||
|
var formats = this._formats;
|
||||||
|
var RULES = this.RULES;
|
||||||
|
|
||||||
|
try {
|
||||||
|
var v = localCompile(schema, root, localRefs, baseId);
|
||||||
|
compilation.validate = v;
|
||||||
|
var cv = compilation.callValidate;
|
||||||
|
if (cv) {
|
||||||
|
cv.schema = v.schema;
|
||||||
|
cv.errors = null;
|
||||||
|
cv.refs = v.refs;
|
||||||
|
cv.refVal = v.refVal;
|
||||||
|
cv.root = v.root;
|
||||||
|
cv.$async = v.$async;
|
||||||
|
if (opts.sourceCode) cv.source = v.source;
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
} finally {
|
||||||
|
endCompiling.call(this, schema, root, baseId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* @this {*} - custom context, see passContext option */
|
||||||
|
function callValidate() {
|
||||||
|
/* jshint validthis: true */
|
||||||
|
var validate = compilation.validate;
|
||||||
|
var result = validate.apply(this, arguments);
|
||||||
|
callValidate.errors = validate.errors;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function localCompile(_schema, _root, localRefs, baseId) {
|
||||||
|
var isRoot = !_root || (_root && _root.schema == _schema);
|
||||||
|
if (_root.schema != root.schema)
|
||||||
|
return compile.call(self, _schema, _root, localRefs, baseId);
|
||||||
|
|
||||||
|
var $async = _schema.$async === true;
|
||||||
|
|
||||||
|
var sourceCode = validateGenerator({
|
||||||
|
isTop: true,
|
||||||
|
schema: _schema,
|
||||||
|
isRoot: isRoot,
|
||||||
|
baseId: baseId,
|
||||||
|
root: _root,
|
||||||
|
schemaPath: '',
|
||||||
|
errSchemaPath: '#',
|
||||||
|
errorPath: '""',
|
||||||
|
MissingRefError: errorClasses.MissingRef,
|
||||||
|
RULES: RULES,
|
||||||
|
validate: validateGenerator,
|
||||||
|
util: util,
|
||||||
|
resolve: resolve,
|
||||||
|
resolveRef: resolveRef,
|
||||||
|
usePattern: usePattern,
|
||||||
|
useDefault: useDefault,
|
||||||
|
useCustomRule: useCustomRule,
|
||||||
|
opts: opts,
|
||||||
|
formats: formats,
|
||||||
|
logger: self.logger,
|
||||||
|
self: self
|
||||||
|
});
|
||||||
|
|
||||||
|
sourceCode = vars(refVal, refValCode) + vars(patterns, patternCode)
|
||||||
|
+ vars(defaults, defaultCode) + vars(customRules, customRuleCode)
|
||||||
|
+ sourceCode;
|
||||||
|
|
||||||
|
if (opts.processCode) sourceCode = opts.processCode(sourceCode, _schema);
|
||||||
|
// console.log('\n\n\n *** \n', JSON.stringify(sourceCode));
|
||||||
|
var validate;
|
||||||
|
try {
|
||||||
|
var makeValidate = new Function(
|
||||||
|
'self',
|
||||||
|
'RULES',
|
||||||
|
'formats',
|
||||||
|
'root',
|
||||||
|
'refVal',
|
||||||
|
'defaults',
|
||||||
|
'customRules',
|
||||||
|
'equal',
|
||||||
|
'ucs2length',
|
||||||
|
'ValidationError',
|
||||||
|
sourceCode
|
||||||
|
);
|
||||||
|
|
||||||
|
validate = makeValidate(
|
||||||
|
self,
|
||||||
|
RULES,
|
||||||
|
formats,
|
||||||
|
root,
|
||||||
|
refVal,
|
||||||
|
defaults,
|
||||||
|
customRules,
|
||||||
|
equal,
|
||||||
|
ucs2length,
|
||||||
|
ValidationError
|
||||||
|
);
|
||||||
|
|
||||||
|
refVal[0] = validate;
|
||||||
|
} catch(e) {
|
||||||
|
self.logger.error('Error compiling schema, function code:', sourceCode);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
validate.schema = _schema;
|
||||||
|
validate.errors = null;
|
||||||
|
validate.refs = refs;
|
||||||
|
validate.refVal = refVal;
|
||||||
|
validate.root = isRoot ? validate : _root;
|
||||||
|
if ($async) validate.$async = true;
|
||||||
|
if (opts.sourceCode === true) {
|
||||||
|
validate.source = {
|
||||||
|
code: sourceCode,
|
||||||
|
patterns: patterns,
|
||||||
|
defaults: defaults
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return validate;
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveRef(baseId, ref, isRoot) {
|
||||||
|
ref = resolve.url(baseId, ref);
|
||||||
|
var refIndex = refs[ref];
|
||||||
|
var _refVal, refCode;
|
||||||
|
if (refIndex !== undefined) {
|
||||||
|
_refVal = refVal[refIndex];
|
||||||
|
refCode = 'refVal[' + refIndex + ']';
|
||||||
|
return resolvedRef(_refVal, refCode);
|
||||||
|
}
|
||||||
|
if (!isRoot && root.refs) {
|
||||||
|
var rootRefId = root.refs[ref];
|
||||||
|
if (rootRefId !== undefined) {
|
||||||
|
_refVal = root.refVal[rootRefId];
|
||||||
|
refCode = addLocalRef(ref, _refVal);
|
||||||
|
return resolvedRef(_refVal, refCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
refCode = addLocalRef(ref);
|
||||||
|
var v = resolve.call(self, localCompile, root, ref);
|
||||||
|
if (v === undefined) {
|
||||||
|
var localSchema = localRefs && localRefs[ref];
|
||||||
|
if (localSchema) {
|
||||||
|
v = resolve.inlineRef(localSchema, opts.inlineRefs)
|
||||||
|
? localSchema
|
||||||
|
: compile.call(self, localSchema, root, localRefs, baseId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v === undefined) {
|
||||||
|
removeLocalRef(ref);
|
||||||
|
} else {
|
||||||
|
replaceLocalRef(ref, v);
|
||||||
|
return resolvedRef(v, refCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addLocalRef(ref, v) {
|
||||||
|
var refId = refVal.length;
|
||||||
|
refVal[refId] = v;
|
||||||
|
refs[ref] = refId;
|
||||||
|
return 'refVal' + refId;
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeLocalRef(ref) {
|
||||||
|
delete refs[ref];
|
||||||
|
}
|
||||||
|
|
||||||
|
function replaceLocalRef(ref, v) {
|
||||||
|
var refId = refs[ref];
|
||||||
|
refVal[refId] = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolvedRef(refVal, code) {
|
||||||
|
return typeof refVal == 'object' || typeof refVal == 'boolean'
|
||||||
|
? { code: code, schema: refVal, inline: true }
|
||||||
|
: { code: code, $async: refVal && !!refVal.$async };
|
||||||
|
}
|
||||||
|
|
||||||
|
function usePattern(regexStr) {
|
||||||
|
var index = patternsHash[regexStr];
|
||||||
|
if (index === undefined) {
|
||||||
|
index = patternsHash[regexStr] = patterns.length;
|
||||||
|
patterns[index] = regexStr;
|
||||||
|
}
|
||||||
|
return 'pattern' + index;
|
||||||
|
}
|
||||||
|
|
||||||
|
function useDefault(value) {
|
||||||
|
switch (typeof value) {
|
||||||
|
case 'boolean':
|
||||||
|
case 'number':
|
||||||
|
return '' + value;
|
||||||
|
case 'string':
|
||||||
|
return util.toQuotedString(value);
|
||||||
|
case 'object':
|
||||||
|
if (value === null) return 'null';
|
||||||
|
var valueStr = stableStringify(value);
|
||||||
|
var index = defaultsHash[valueStr];
|
||||||
|
if (index === undefined) {
|
||||||
|
index = defaultsHash[valueStr] = defaults.length;
|
||||||
|
defaults[index] = value;
|
||||||
|
}
|
||||||
|
return 'default' + index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function useCustomRule(rule, schema, parentSchema, it) {
|
||||||
|
if (self._opts.validateSchema !== false) {
|
||||||
|
var deps = rule.definition.dependencies;
|
||||||
|
if (deps && !deps.every(function(keyword) {
|
||||||
|
return Object.prototype.hasOwnProperty.call(parentSchema, keyword);
|
||||||
|
}))
|
||||||
|
throw new Error('parent schema must have all required keywords: ' + deps.join(','));
|
||||||
|
|
||||||
|
var validateSchema = rule.definition.validateSchema;
|
||||||
|
if (validateSchema) {
|
||||||
|
var valid = validateSchema(schema);
|
||||||
|
if (!valid) {
|
||||||
|
var message = 'keyword schema is invalid: ' + self.errorsText(validateSchema.errors);
|
||||||
|
if (self._opts.validateSchema == 'log') self.logger.error(message);
|
||||||
|
else throw new Error(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var compile = rule.definition.compile
|
||||||
|
, inline = rule.definition.inline
|
||||||
|
, macro = rule.definition.macro;
|
||||||
|
|
||||||
|
var validate;
|
||||||
|
if (compile) {
|
||||||
|
validate = compile.call(self, schema, parentSchema, it);
|
||||||
|
} else if (macro) {
|
||||||
|
validate = macro.call(self, schema, parentSchema, it);
|
||||||
|
if (opts.validateSchema !== false) self.validateSchema(validate, true);
|
||||||
|
} else if (inline) {
|
||||||
|
validate = inline.call(self, it, rule.keyword, schema, parentSchema);
|
||||||
|
} else {
|
||||||
|
validate = rule.definition.validate;
|
||||||
|
if (!validate) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (validate === undefined)
|
||||||
|
throw new Error('custom keyword "' + rule.keyword + '"failed to compile');
|
||||||
|
|
||||||
|
var index = customRules.length;
|
||||||
|
customRules[index] = validate;
|
||||||
|
|
||||||
|
return {
|
||||||
|
code: 'customRule' + index,
|
||||||
|
validate: validate
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the schema is currently compiled
|
||||||
|
* @this Ajv
|
||||||
|
* @param {Object} schema schema to compile
|
||||||
|
* @param {Object} root root object
|
||||||
|
* @param {String} baseId base schema ID
|
||||||
|
* @return {Object} object with properties "index" (compilation index) and "compiling" (boolean)
|
||||||
|
*/
|
||||||
|
function checkCompiling(schema, root, baseId) {
|
||||||
|
/* jshint validthis: true */
|
||||||
|
var index = compIndex.call(this, schema, root, baseId);
|
||||||
|
if (index >= 0) return { index: index, compiling: true };
|
||||||
|
index = this._compilations.length;
|
||||||
|
this._compilations[index] = {
|
||||||
|
schema: schema,
|
||||||
|
root: root,
|
||||||
|
baseId: baseId
|
||||||
|
};
|
||||||
|
return { index: index, compiling: false };
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the schema from the currently compiled list
|
||||||
|
* @this Ajv
|
||||||
|
* @param {Object} schema schema to compile
|
||||||
|
* @param {Object} root root object
|
||||||
|
* @param {String} baseId base schema ID
|
||||||
|
*/
|
||||||
|
function endCompiling(schema, root, baseId) {
|
||||||
|
/* jshint validthis: true */
|
||||||
|
var i = compIndex.call(this, schema, root, baseId);
|
||||||
|
if (i >= 0) this._compilations.splice(i, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Index of schema compilation in the currently compiled list
|
||||||
|
* @this Ajv
|
||||||
|
* @param {Object} schema schema to compile
|
||||||
|
* @param {Object} root root object
|
||||||
|
* @param {String} baseId base schema ID
|
||||||
|
* @return {Integer} compilation index
|
||||||
|
*/
|
||||||
|
function compIndex(schema, root, baseId) {
|
||||||
|
/* jshint validthis: true */
|
||||||
|
for (var i=0; i<this._compilations.length; i++) {
|
||||||
|
var c = this._compilations[i];
|
||||||
|
if (c.schema == schema && c.root == root && c.baseId == baseId) return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function patternCode(i, patterns) {
|
||||||
|
return 'var pattern' + i + ' = new RegExp(' + util.toQuotedString(patterns[i]) + ');';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function defaultCode(i) {
|
||||||
|
return 'var default' + i + ' = defaults[' + i + '];';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function refValCode(i, refVal) {
|
||||||
|
return refVal[i] === undefined ? '' : 'var refVal' + i + ' = refVal[' + i + '];';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function customRuleCode(i) {
|
||||||
|
return 'var customRule' + i + ' = customRules[' + i + '];';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function vars(arr, statement) {
|
||||||
|
if (!arr.length) return '';
|
||||||
|
var code = '';
|
||||||
|
for (var i=0; i<arr.length; i++)
|
||||||
|
code += statement(i, arr);
|
||||||
|
return code;
|
||||||
|
}
|
270
node_modules/ajv/lib/compile/resolve.js
generated
vendored
Normal file
270
node_modules/ajv/lib/compile/resolve.js
generated
vendored
Normal file
@ -0,0 +1,270 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var URI = require('uri-js')
|
||||||
|
, equal = require('fast-deep-equal')
|
||||||
|
, util = require('./util')
|
||||||
|
, SchemaObject = require('./schema_obj')
|
||||||
|
, traverse = require('json-schema-traverse');
|
||||||
|
|
||||||
|
module.exports = resolve;
|
||||||
|
|
||||||
|
resolve.normalizeId = normalizeId;
|
||||||
|
resolve.fullPath = getFullPath;
|
||||||
|
resolve.url = resolveUrl;
|
||||||
|
resolve.ids = resolveIds;
|
||||||
|
resolve.inlineRef = inlineRef;
|
||||||
|
resolve.schema = resolveSchema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [resolve and compile the references ($ref)]
|
||||||
|
* @this Ajv
|
||||||
|
* @param {Function} compile reference to schema compilation funciton (localCompile)
|
||||||
|
* @param {Object} root object with information about the root schema for the current schema
|
||||||
|
* @param {String} ref reference to resolve
|
||||||
|
* @return {Object|Function} schema object (if the schema can be inlined) or validation function
|
||||||
|
*/
|
||||||
|
function resolve(compile, root, ref) {
|
||||||
|
/* jshint validthis: true */
|
||||||
|
var refVal = this._refs[ref];
|
||||||
|
if (typeof refVal == 'string') {
|
||||||
|
if (this._refs[refVal]) refVal = this._refs[refVal];
|
||||||
|
else return resolve.call(this, compile, root, refVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
refVal = refVal || this._schemas[ref];
|
||||||
|
if (refVal instanceof SchemaObject) {
|
||||||
|
return inlineRef(refVal.schema, this._opts.inlineRefs)
|
||||||
|
? refVal.schema
|
||||||
|
: refVal.validate || this._compile(refVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
var res = resolveSchema.call(this, root, ref);
|
||||||
|
var schema, v, baseId;
|
||||||
|
if (res) {
|
||||||
|
schema = res.schema;
|
||||||
|
root = res.root;
|
||||||
|
baseId = res.baseId;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (schema instanceof SchemaObject) {
|
||||||
|
v = schema.validate || compile.call(this, schema.schema, root, undefined, baseId);
|
||||||
|
} else if (schema !== undefined) {
|
||||||
|
v = inlineRef(schema, this._opts.inlineRefs)
|
||||||
|
? schema
|
||||||
|
: compile.call(this, schema, root, undefined, baseId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve schema, its root and baseId
|
||||||
|
* @this Ajv
|
||||||
|
* @param {Object} root root object with properties schema, refVal, refs
|
||||||
|
* @param {String} ref reference to resolve
|
||||||
|
* @return {Object} object with properties schema, root, baseId
|
||||||
|
*/
|
||||||
|
function resolveSchema(root, ref) {
|
||||||
|
/* jshint validthis: true */
|
||||||
|
var p = URI.parse(ref)
|
||||||
|
, refPath = _getFullPath(p)
|
||||||
|
, baseId = getFullPath(this._getId(root.schema));
|
||||||
|
if (Object.keys(root.schema).length === 0 || refPath !== baseId) {
|
||||||
|
var id = normalizeId(refPath);
|
||||||
|
var refVal = this._refs[id];
|
||||||
|
if (typeof refVal == 'string') {
|
||||||
|
return resolveRecursive.call(this, root, refVal, p);
|
||||||
|
} else if (refVal instanceof SchemaObject) {
|
||||||
|
if (!refVal.validate) this._compile(refVal);
|
||||||
|
root = refVal;
|
||||||
|
} else {
|
||||||
|
refVal = this._schemas[id];
|
||||||
|
if (refVal instanceof SchemaObject) {
|
||||||
|
if (!refVal.validate) this._compile(refVal);
|
||||||
|
if (id == normalizeId(ref))
|
||||||
|
return { schema: refVal, root: root, baseId: baseId };
|
||||||
|
root = refVal;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!root.schema) return;
|
||||||
|
baseId = getFullPath(this._getId(root.schema));
|
||||||
|
}
|
||||||
|
return getJsonPointer.call(this, p, baseId, root.schema, root);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* @this Ajv */
|
||||||
|
function resolveRecursive(root, ref, parsedRef) {
|
||||||
|
/* jshint validthis: true */
|
||||||
|
var res = resolveSchema.call(this, root, ref);
|
||||||
|
if (res) {
|
||||||
|
var schema = res.schema;
|
||||||
|
var baseId = res.baseId;
|
||||||
|
root = res.root;
|
||||||
|
var id = this._getId(schema);
|
||||||
|
if (id) baseId = resolveUrl(baseId, id);
|
||||||
|
return getJsonPointer.call(this, parsedRef, baseId, schema, root);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var PREVENT_SCOPE_CHANGE = util.toHash(['properties', 'patternProperties', 'enum', 'dependencies', 'definitions']);
|
||||||
|
/* @this Ajv */
|
||||||
|
function getJsonPointer(parsedRef, baseId, schema, root) {
|
||||||
|
/* jshint validthis: true */
|
||||||
|
parsedRef.fragment = parsedRef.fragment || '';
|
||||||
|
if (parsedRef.fragment.slice(0,1) != '/') return;
|
||||||
|
var parts = parsedRef.fragment.split('/');
|
||||||
|
|
||||||
|
for (var i = 1; i < parts.length; i++) {
|
||||||
|
var part = parts[i];
|
||||||
|
if (part) {
|
||||||
|
part = util.unescapeFragment(part);
|
||||||
|
schema = schema[part];
|
||||||
|
if (schema === undefined) break;
|
||||||
|
var id;
|
||||||
|
if (!PREVENT_SCOPE_CHANGE[part]) {
|
||||||
|
id = this._getId(schema);
|
||||||
|
if (id) baseId = resolveUrl(baseId, id);
|
||||||
|
if (schema.$ref) {
|
||||||
|
var $ref = resolveUrl(baseId, schema.$ref);
|
||||||
|
var res = resolveSchema.call(this, root, $ref);
|
||||||
|
if (res) {
|
||||||
|
schema = res.schema;
|
||||||
|
root = res.root;
|
||||||
|
baseId = res.baseId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (schema !== undefined && schema !== root.schema)
|
||||||
|
return { schema: schema, root: root, baseId: baseId };
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var SIMPLE_INLINED = util.toHash([
|
||||||
|
'type', 'format', 'pattern',
|
||||||
|
'maxLength', 'minLength',
|
||||||
|
'maxProperties', 'minProperties',
|
||||||
|
'maxItems', 'minItems',
|
||||||
|
'maximum', 'minimum',
|
||||||
|
'uniqueItems', 'multipleOf',
|
||||||
|
'required', 'enum'
|
||||||
|
]);
|
||||||
|
function inlineRef(schema, limit) {
|
||||||
|
if (limit === false) return false;
|
||||||
|
if (limit === undefined || limit === true) return checkNoRef(schema);
|
||||||
|
else if (limit) return countKeys(schema) <= limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function checkNoRef(schema) {
|
||||||
|
var item;
|
||||||
|
if (Array.isArray(schema)) {
|
||||||
|
for (var i=0; i<schema.length; i++) {
|
||||||
|
item = schema[i];
|
||||||
|
if (typeof item == 'object' && !checkNoRef(item)) return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (var key in schema) {
|
||||||
|
if (key == '$ref') return false;
|
||||||
|
item = schema[key];
|
||||||
|
if (typeof item == 'object' && !checkNoRef(item)) return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function countKeys(schema) {
|
||||||
|
var count = 0, item;
|
||||||
|
if (Array.isArray(schema)) {
|
||||||
|
for (var i=0; i<schema.length; i++) {
|
||||||
|
item = schema[i];
|
||||||
|
if (typeof item == 'object') count += countKeys(item);
|
||||||
|
if (count == Infinity) return Infinity;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (var key in schema) {
|
||||||
|
if (key == '$ref') return Infinity;
|
||||||
|
if (SIMPLE_INLINED[key]) {
|
||||||
|
count++;
|
||||||
|
} else {
|
||||||
|
item = schema[key];
|
||||||
|
if (typeof item == 'object') count += countKeys(item) + 1;
|
||||||
|
if (count == Infinity) return Infinity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getFullPath(id, normalize) {
|
||||||
|
if (normalize !== false) id = normalizeId(id);
|
||||||
|
var p = URI.parse(id);
|
||||||
|
return _getFullPath(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _getFullPath(p) {
|
||||||
|
return URI.serialize(p).split('#')[0] + '#';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var TRAILING_SLASH_HASH = /#\/?$/;
|
||||||
|
function normalizeId(id) {
|
||||||
|
return id ? id.replace(TRAILING_SLASH_HASH, '') : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function resolveUrl(baseId, id) {
|
||||||
|
id = normalizeId(id);
|
||||||
|
return URI.resolve(baseId, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* @this Ajv */
|
||||||
|
function resolveIds(schema) {
|
||||||
|
var schemaId = normalizeId(this._getId(schema));
|
||||||
|
var baseIds = {'': schemaId};
|
||||||
|
var fullPaths = {'': getFullPath(schemaId, false)};
|
||||||
|
var localRefs = {};
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
traverse(schema, {allKeys: true}, function(sch, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
|
||||||
|
if (jsonPtr === '') return;
|
||||||
|
var id = self._getId(sch);
|
||||||
|
var baseId = baseIds[parentJsonPtr];
|
||||||
|
var fullPath = fullPaths[parentJsonPtr] + '/' + parentKeyword;
|
||||||
|
if (keyIndex !== undefined)
|
||||||
|
fullPath += '/' + (typeof keyIndex == 'number' ? keyIndex : util.escapeFragment(keyIndex));
|
||||||
|
|
||||||
|
if (typeof id == 'string') {
|
||||||
|
id = baseId = normalizeId(baseId ? URI.resolve(baseId, id) : id);
|
||||||
|
|
||||||
|
var refVal = self._refs[id];
|
||||||
|
if (typeof refVal == 'string') refVal = self._refs[refVal];
|
||||||
|
if (refVal && refVal.schema) {
|
||||||
|
if (!equal(sch, refVal.schema))
|
||||||
|
throw new Error('id "' + id + '" resolves to more than one schema');
|
||||||
|
} else if (id != normalizeId(fullPath)) {
|
||||||
|
if (id[0] == '#') {
|
||||||
|
if (localRefs[id] && !equal(sch, localRefs[id]))
|
||||||
|
throw new Error('id "' + id + '" resolves to more than one schema');
|
||||||
|
localRefs[id] = sch;
|
||||||
|
} else {
|
||||||
|
self._refs[id] = fullPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
baseIds[jsonPtr] = baseId;
|
||||||
|
fullPaths[jsonPtr] = fullPath;
|
||||||
|
});
|
||||||
|
|
||||||
|
return localRefs;
|
||||||
|
}
|
66
node_modules/ajv/lib/compile/rules.js
generated
vendored
Normal file
66
node_modules/ajv/lib/compile/rules.js
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var ruleModules = require('../dotjs')
|
||||||
|
, toHash = require('./util').toHash;
|
||||||
|
|
||||||
|
module.exports = function rules() {
|
||||||
|
var RULES = [
|
||||||
|
{ type: 'number',
|
||||||
|
rules: [ { 'maximum': ['exclusiveMaximum'] },
|
||||||
|
{ 'minimum': ['exclusiveMinimum'] }, 'multipleOf', 'format'] },
|
||||||
|
{ type: 'string',
|
||||||
|
rules: [ 'maxLength', 'minLength', 'pattern', 'format' ] },
|
||||||
|
{ type: 'array',
|
||||||
|
rules: [ 'maxItems', 'minItems', 'items', 'contains', 'uniqueItems' ] },
|
||||||
|
{ type: 'object',
|
||||||
|
rules: [ 'maxProperties', 'minProperties', 'required', 'dependencies', 'propertyNames',
|
||||||
|
{ 'properties': ['additionalProperties', 'patternProperties'] } ] },
|
||||||
|
{ rules: [ '$ref', 'const', 'enum', 'not', 'anyOf', 'oneOf', 'allOf', 'if' ] }
|
||||||
|
];
|
||||||
|
|
||||||
|
var ALL = [ 'type', '$comment' ];
|
||||||
|
var KEYWORDS = [
|
||||||
|
'$schema', '$id', 'id', '$data', '$async', 'title',
|
||||||
|
'description', 'default', 'definitions',
|
||||||
|
'examples', 'readOnly', 'writeOnly',
|
||||||
|
'contentMediaType', 'contentEncoding',
|
||||||
|
'additionalItems', 'then', 'else'
|
||||||
|
];
|
||||||
|
var TYPES = [ 'number', 'integer', 'string', 'array', 'object', 'boolean', 'null' ];
|
||||||
|
RULES.all = toHash(ALL);
|
||||||
|
RULES.types = toHash(TYPES);
|
||||||
|
|
||||||
|
RULES.forEach(function (group) {
|
||||||
|
group.rules = group.rules.map(function (keyword) {
|
||||||
|
var implKeywords;
|
||||||
|
if (typeof keyword == 'object') {
|
||||||
|
var key = Object.keys(keyword)[0];
|
||||||
|
implKeywords = keyword[key];
|
||||||
|
keyword = key;
|
||||||
|
implKeywords.forEach(function (k) {
|
||||||
|
ALL.push(k);
|
||||||
|
RULES.all[k] = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
ALL.push(keyword);
|
||||||
|
var rule = RULES.all[keyword] = {
|
||||||
|
keyword: keyword,
|
||||||
|
code: ruleModules[keyword],
|
||||||
|
implements: implKeywords
|
||||||
|
};
|
||||||
|
return rule;
|
||||||
|
});
|
||||||
|
|
||||||
|
RULES.all.$comment = {
|
||||||
|
keyword: '$comment',
|
||||||
|
code: ruleModules.$comment
|
||||||
|
};
|
||||||
|
|
||||||
|
if (group.type) RULES.types[group.type] = group;
|
||||||
|
});
|
||||||
|
|
||||||
|
RULES.keywords = toHash(ALL.concat(KEYWORDS));
|
||||||
|
RULES.custom = {};
|
||||||
|
|
||||||
|
return RULES;
|
||||||
|
};
|
9
node_modules/ajv/lib/compile/schema_obj.js
generated
vendored
Normal file
9
node_modules/ajv/lib/compile/schema_obj.js
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var util = require('./util');
|
||||||
|
|
||||||
|
module.exports = SchemaObject;
|
||||||
|
|
||||||
|
function SchemaObject(obj) {
|
||||||
|
util.copy(obj, this);
|
||||||
|
}
|
20
node_modules/ajv/lib/compile/ucs2length.js
generated
vendored
Normal file
20
node_modules/ajv/lib/compile/ucs2length.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
// https://mathiasbynens.be/notes/javascript-encoding
|
||||||
|
// https://github.com/bestiejs/punycode.js - punycode.ucs2.decode
|
||||||
|
module.exports = function ucs2length(str) {
|
||||||
|
var length = 0
|
||||||
|
, len = str.length
|
||||||
|
, pos = 0
|
||||||
|
, value;
|
||||||
|
while (pos < len) {
|
||||||
|
length++;
|
||||||
|
value = str.charCodeAt(pos++);
|
||||||
|
if (value >= 0xD800 && value <= 0xDBFF && pos < len) {
|
||||||
|
// high surrogate, and there is a next character
|
||||||
|
value = str.charCodeAt(pos);
|
||||||
|
if ((value & 0xFC00) == 0xDC00) pos++; // low surrogate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return length;
|
||||||
|
};
|
239
node_modules/ajv/lib/compile/util.js
generated
vendored
Normal file
239
node_modules/ajv/lib/compile/util.js
generated
vendored
Normal file
@ -0,0 +1,239 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
copy: copy,
|
||||||
|
checkDataType: checkDataType,
|
||||||
|
checkDataTypes: checkDataTypes,
|
||||||
|
coerceToTypes: coerceToTypes,
|
||||||
|
toHash: toHash,
|
||||||
|
getProperty: getProperty,
|
||||||
|
escapeQuotes: escapeQuotes,
|
||||||
|
equal: require('fast-deep-equal'),
|
||||||
|
ucs2length: require('./ucs2length'),
|
||||||
|
varOccurences: varOccurences,
|
||||||
|
varReplace: varReplace,
|
||||||
|
schemaHasRules: schemaHasRules,
|
||||||
|
schemaHasRulesExcept: schemaHasRulesExcept,
|
||||||
|
schemaUnknownRules: schemaUnknownRules,
|
||||||
|
toQuotedString: toQuotedString,
|
||||||
|
getPathExpr: getPathExpr,
|
||||||
|
getPath: getPath,
|
||||||
|
getData: getData,
|
||||||
|
unescapeFragment: unescapeFragment,
|
||||||
|
unescapeJsonPointer: unescapeJsonPointer,
|
||||||
|
escapeFragment: escapeFragment,
|
||||||
|
escapeJsonPointer: escapeJsonPointer
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function copy(o, to) {
|
||||||
|
to = to || {};
|
||||||
|
for (var key in o) to[key] = o[key];
|
||||||
|
return to;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function checkDataType(dataType, data, strictNumbers, negate) {
|
||||||
|
var EQUAL = negate ? ' !== ' : ' === '
|
||||||
|
, AND = negate ? ' || ' : ' && '
|
||||||
|
, OK = negate ? '!' : ''
|
||||||
|
, NOT = negate ? '' : '!';
|
||||||
|
switch (dataType) {
|
||||||
|
case 'null': return data + EQUAL + 'null';
|
||||||
|
case 'array': return OK + 'Array.isArray(' + data + ')';
|
||||||
|
case 'object': return '(' + OK + data + AND +
|
||||||
|
'typeof ' + data + EQUAL + '"object"' + AND +
|
||||||
|
NOT + 'Array.isArray(' + data + '))';
|
||||||
|
case 'integer': return '(typeof ' + data + EQUAL + '"number"' + AND +
|
||||||
|
NOT + '(' + data + ' % 1)' +
|
||||||
|
AND + data + EQUAL + data +
|
||||||
|
(strictNumbers ? (AND + OK + 'isFinite(' + data + ')') : '') + ')';
|
||||||
|
case 'number': return '(typeof ' + data + EQUAL + '"' + dataType + '"' +
|
||||||
|
(strictNumbers ? (AND + OK + 'isFinite(' + data + ')') : '') + ')';
|
||||||
|
default: return 'typeof ' + data + EQUAL + '"' + dataType + '"';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function checkDataTypes(dataTypes, data, strictNumbers) {
|
||||||
|
switch (dataTypes.length) {
|
||||||
|
case 1: return checkDataType(dataTypes[0], data, strictNumbers, true);
|
||||||
|
default:
|
||||||
|
var code = '';
|
||||||
|
var types = toHash(dataTypes);
|
||||||
|
if (types.array && types.object) {
|
||||||
|
code = types.null ? '(': '(!' + data + ' || ';
|
||||||
|
code += 'typeof ' + data + ' !== "object")';
|
||||||
|
delete types.null;
|
||||||
|
delete types.array;
|
||||||
|
delete types.object;
|
||||||
|
}
|
||||||
|
if (types.number) delete types.integer;
|
||||||
|
for (var t in types)
|
||||||
|
code += (code ? ' && ' : '' ) + checkDataType(t, data, strictNumbers, true);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var COERCE_TO_TYPES = toHash([ 'string', 'number', 'integer', 'boolean', 'null' ]);
|
||||||
|
function coerceToTypes(optionCoerceTypes, dataTypes) {
|
||||||
|
if (Array.isArray(dataTypes)) {
|
||||||
|
var types = [];
|
||||||
|
for (var i=0; i<dataTypes.length; i++) {
|
||||||
|
var t = dataTypes[i];
|
||||||
|
if (COERCE_TO_TYPES[t]) types[types.length] = t;
|
||||||
|
else if (optionCoerceTypes === 'array' && t === 'array') types[types.length] = t;
|
||||||
|
}
|
||||||
|
if (types.length) return types;
|
||||||
|
} else if (COERCE_TO_TYPES[dataTypes]) {
|
||||||
|
return [dataTypes];
|
||||||
|
} else if (optionCoerceTypes === 'array' && dataTypes === 'array') {
|
||||||
|
return ['array'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function toHash(arr) {
|
||||||
|
var hash = {};
|
||||||
|
for (var i=0; i<arr.length; i++) hash[arr[i]] = true;
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
|
||||||
|
var SINGLE_QUOTE = /'|\\/g;
|
||||||
|
function getProperty(key) {
|
||||||
|
return typeof key == 'number'
|
||||||
|
? '[' + key + ']'
|
||||||
|
: IDENTIFIER.test(key)
|
||||||
|
? '.' + key
|
||||||
|
: "['" + escapeQuotes(key) + "']";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function escapeQuotes(str) {
|
||||||
|
return str.replace(SINGLE_QUOTE, '\\$&')
|
||||||
|
.replace(/\n/g, '\\n')
|
||||||
|
.replace(/\r/g, '\\r')
|
||||||
|
.replace(/\f/g, '\\f')
|
||||||
|
.replace(/\t/g, '\\t');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function varOccurences(str, dataVar) {
|
||||||
|
dataVar += '[^0-9]';
|
||||||
|
var matches = str.match(new RegExp(dataVar, 'g'));
|
||||||
|
return matches ? matches.length : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function varReplace(str, dataVar, expr) {
|
||||||
|
dataVar += '([^0-9])';
|
||||||
|
expr = expr.replace(/\$/g, '$$$$');
|
||||||
|
return str.replace(new RegExp(dataVar, 'g'), expr + '$1');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function schemaHasRules(schema, rules) {
|
||||||
|
if (typeof schema == 'boolean') return !schema;
|
||||||
|
for (var key in schema) if (rules[key]) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function schemaHasRulesExcept(schema, rules, exceptKeyword) {
|
||||||
|
if (typeof schema == 'boolean') return !schema && exceptKeyword != 'not';
|
||||||
|
for (var key in schema) if (key != exceptKeyword && rules[key]) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function schemaUnknownRules(schema, rules) {
|
||||||
|
if (typeof schema == 'boolean') return;
|
||||||
|
for (var key in schema) if (!rules[key]) return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function toQuotedString(str) {
|
||||||
|
return '\'' + escapeQuotes(str) + '\'';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getPathExpr(currentPath, expr, jsonPointers, isNumber) {
|
||||||
|
var path = jsonPointers // false by default
|
||||||
|
? '\'/\' + ' + expr + (isNumber ? '' : '.replace(/~/g, \'~0\').replace(/\\//g, \'~1\')')
|
||||||
|
: (isNumber ? '\'[\' + ' + expr + ' + \']\'' : '\'[\\\'\' + ' + expr + ' + \'\\\']\'');
|
||||||
|
return joinPaths(currentPath, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getPath(currentPath, prop, jsonPointers) {
|
||||||
|
var path = jsonPointers // false by default
|
||||||
|
? toQuotedString('/' + escapeJsonPointer(prop))
|
||||||
|
: toQuotedString(getProperty(prop));
|
||||||
|
return joinPaths(currentPath, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
|
||||||
|
var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
|
||||||
|
function getData($data, lvl, paths) {
|
||||||
|
var up, jsonPointer, data, matches;
|
||||||
|
if ($data === '') return 'rootData';
|
||||||
|
if ($data[0] == '/') {
|
||||||
|
if (!JSON_POINTER.test($data)) throw new Error('Invalid JSON-pointer: ' + $data);
|
||||||
|
jsonPointer = $data;
|
||||||
|
data = 'rootData';
|
||||||
|
} else {
|
||||||
|
matches = $data.match(RELATIVE_JSON_POINTER);
|
||||||
|
if (!matches) throw new Error('Invalid JSON-pointer: ' + $data);
|
||||||
|
up = +matches[1];
|
||||||
|
jsonPointer = matches[2];
|
||||||
|
if (jsonPointer == '#') {
|
||||||
|
if (up >= lvl) throw new Error('Cannot access property/index ' + up + ' levels up, current level is ' + lvl);
|
||||||
|
return paths[lvl - up];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (up > lvl) throw new Error('Cannot access data ' + up + ' levels up, current level is ' + lvl);
|
||||||
|
data = 'data' + ((lvl - up) || '');
|
||||||
|
if (!jsonPointer) return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
var expr = data;
|
||||||
|
var segments = jsonPointer.split('/');
|
||||||
|
for (var i=0; i<segments.length; i++) {
|
||||||
|
var segment = segments[i];
|
||||||
|
if (segment) {
|
||||||
|
data += getProperty(unescapeJsonPointer(segment));
|
||||||
|
expr += ' && ' + data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return expr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function joinPaths (a, b) {
|
||||||
|
if (a == '""') return b;
|
||||||
|
return (a + ' + ' + b).replace(/([^\\])' \+ '/g, '$1');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function unescapeFragment(str) {
|
||||||
|
return unescapeJsonPointer(decodeURIComponent(str));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function escapeFragment(str) {
|
||||||
|
return encodeURIComponent(escapeJsonPointer(str));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function escapeJsonPointer(str) {
|
||||||
|
return str.replace(/~/g, '~0').replace(/\//g, '~1');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function unescapeJsonPointer(str) {
|
||||||
|
return str.replace(/~1/g, '/').replace(/~0/g, '~');
|
||||||
|
}
|
49
node_modules/ajv/lib/data.js
generated
vendored
Normal file
49
node_modules/ajv/lib/data.js
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var KEYWORDS = [
|
||||||
|
'multipleOf',
|
||||||
|
'maximum',
|
||||||
|
'exclusiveMaximum',
|
||||||
|
'minimum',
|
||||||
|
'exclusiveMinimum',
|
||||||
|
'maxLength',
|
||||||
|
'minLength',
|
||||||
|
'pattern',
|
||||||
|
'additionalItems',
|
||||||
|
'maxItems',
|
||||||
|
'minItems',
|
||||||
|
'uniqueItems',
|
||||||
|
'maxProperties',
|
||||||
|
'minProperties',
|
||||||
|
'required',
|
||||||
|
'additionalProperties',
|
||||||
|
'enum',
|
||||||
|
'format',
|
||||||
|
'const'
|
||||||
|
];
|
||||||
|
|
||||||
|
module.exports = function (metaSchema, keywordsJsonPointers) {
|
||||||
|
for (var i=0; i<keywordsJsonPointers.length; i++) {
|
||||||
|
metaSchema = JSON.parse(JSON.stringify(metaSchema));
|
||||||
|
var segments = keywordsJsonPointers[i].split('/');
|
||||||
|
var keywords = metaSchema;
|
||||||
|
var j;
|
||||||
|
for (j=1; j<segments.length; j++)
|
||||||
|
keywords = keywords[segments[j]];
|
||||||
|
|
||||||
|
for (j=0; j<KEYWORDS.length; j++) {
|
||||||
|
var key = KEYWORDS[j];
|
||||||
|
var schema = keywords[key];
|
||||||
|
if (schema) {
|
||||||
|
keywords[key] = {
|
||||||
|
anyOf: [
|
||||||
|
schema,
|
||||||
|
{ $ref: 'https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#' }
|
||||||
|
]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return metaSchema;
|
||||||
|
};
|
37
node_modules/ajv/lib/definition_schema.js
generated
vendored
Normal file
37
node_modules/ajv/lib/definition_schema.js
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var metaSchema = require('./refs/json-schema-draft-07.json');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
$id: 'https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js',
|
||||||
|
definitions: {
|
||||||
|
simpleTypes: metaSchema.definitions.simpleTypes
|
||||||
|
},
|
||||||
|
type: 'object',
|
||||||
|
dependencies: {
|
||||||
|
schema: ['validate'],
|
||||||
|
$data: ['validate'],
|
||||||
|
statements: ['inline'],
|
||||||
|
valid: {not: {required: ['macro']}}
|
||||||
|
},
|
||||||
|
properties: {
|
||||||
|
type: metaSchema.properties.type,
|
||||||
|
schema: {type: 'boolean'},
|
||||||
|
statements: {type: 'boolean'},
|
||||||
|
dependencies: {
|
||||||
|
type: 'array',
|
||||||
|
items: {type: 'string'}
|
||||||
|
},
|
||||||
|
metaSchema: {type: 'object'},
|
||||||
|
modifying: {type: 'boolean'},
|
||||||
|
valid: {type: 'boolean'},
|
||||||
|
$data: {type: 'boolean'},
|
||||||
|
async: {type: 'boolean'},
|
||||||
|
errors: {
|
||||||
|
anyOf: [
|
||||||
|
{type: 'boolean'},
|
||||||
|
{const: 'full'}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
113
node_modules/ajv/lib/dot/_limit.jst
generated
vendored
Normal file
113
node_modules/ajv/lib/dot/_limit.jst
generated
vendored
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
{{# def.definitions }}
|
||||||
|
{{# def.errors }}
|
||||||
|
{{# def.setupKeyword }}
|
||||||
|
{{# def.$data }}
|
||||||
|
|
||||||
|
{{## def.setExclusiveLimit:
|
||||||
|
$exclusive = true;
|
||||||
|
$errorKeyword = $exclusiveKeyword;
|
||||||
|
$errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
|
||||||
|
#}}
|
||||||
|
|
||||||
|
{{
|
||||||
|
var $isMax = $keyword == 'maximum'
|
||||||
|
, $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum'
|
||||||
|
, $schemaExcl = it.schema[$exclusiveKeyword]
|
||||||
|
, $isDataExcl = it.opts.$data && $schemaExcl && $schemaExcl.$data
|
||||||
|
, $op = $isMax ? '<' : '>'
|
||||||
|
, $notOp = $isMax ? '>' : '<'
|
||||||
|
, $errorKeyword = undefined;
|
||||||
|
|
||||||
|
if (!($isData || typeof $schema == 'number' || $schema === undefined)) {
|
||||||
|
throw new Error($keyword + ' must be number');
|
||||||
|
}
|
||||||
|
if (!($isDataExcl || $schemaExcl === undefined
|
||||||
|
|| typeof $schemaExcl == 'number'
|
||||||
|
|| typeof $schemaExcl == 'boolean')) {
|
||||||
|
throw new Error($exclusiveKeyword + ' must be number or boolean');
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{? $isDataExcl }}
|
||||||
|
{{
|
||||||
|
var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr)
|
||||||
|
, $exclusive = 'exclusive' + $lvl
|
||||||
|
, $exclType = 'exclType' + $lvl
|
||||||
|
, $exclIsNumber = 'exclIsNumber' + $lvl
|
||||||
|
, $opExpr = 'op' + $lvl
|
||||||
|
, $opStr = '\' + ' + $opExpr + ' + \'';
|
||||||
|
}}
|
||||||
|
var schemaExcl{{=$lvl}} = {{=$schemaValueExcl}};
|
||||||
|
{{ $schemaValueExcl = 'schemaExcl' + $lvl; }}
|
||||||
|
|
||||||
|
var {{=$exclusive}};
|
||||||
|
var {{=$exclType}} = typeof {{=$schemaValueExcl}};
|
||||||
|
if ({{=$exclType}} != 'boolean' && {{=$exclType}} != 'undefined' && {{=$exclType}} != 'number') {
|
||||||
|
{{ var $errorKeyword = $exclusiveKeyword; }}
|
||||||
|
{{# def.error:'_exclusiveLimit' }}
|
||||||
|
} else if ({{# def.$dataNotType:'number' }}
|
||||||
|
{{=$exclType}} == 'number'
|
||||||
|
? (
|
||||||
|
({{=$exclusive}} = {{=$schemaValue}} === undefined || {{=$schemaValueExcl}} {{=$op}}= {{=$schemaValue}})
|
||||||
|
? {{=$data}} {{=$notOp}}= {{=$schemaValueExcl}}
|
||||||
|
: {{=$data}} {{=$notOp}} {{=$schemaValue}}
|
||||||
|
)
|
||||||
|
: (
|
||||||
|
({{=$exclusive}} = {{=$schemaValueExcl}} === true)
|
||||||
|
? {{=$data}} {{=$notOp}}= {{=$schemaValue}}
|
||||||
|
: {{=$data}} {{=$notOp}} {{=$schemaValue}}
|
||||||
|
)
|
||||||
|
|| {{=$data}} !== {{=$data}}) {
|
||||||
|
var op{{=$lvl}} = {{=$exclusive}} ? '{{=$op}}' : '{{=$op}}=';
|
||||||
|
{{
|
||||||
|
if ($schema === undefined) {
|
||||||
|
$errorKeyword = $exclusiveKeyword;
|
||||||
|
$errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
|
||||||
|
$schemaValue = $schemaValueExcl;
|
||||||
|
$isData = $isDataExcl;
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
{{??}}
|
||||||
|
{{
|
||||||
|
var $exclIsNumber = typeof $schemaExcl == 'number'
|
||||||
|
, $opStr = $op; /*used in error*/
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{? $exclIsNumber && $isData }}
|
||||||
|
{{ var $opExpr = '\'' + $opStr + '\''; /*used in error*/ }}
|
||||||
|
if ({{# def.$dataNotType:'number' }}
|
||||||
|
( {{=$schemaValue}} === undefined
|
||||||
|
|| {{=$schemaExcl}} {{=$op}}= {{=$schemaValue}}
|
||||||
|
? {{=$data}} {{=$notOp}}= {{=$schemaExcl}}
|
||||||
|
: {{=$data}} {{=$notOp}} {{=$schemaValue}} )
|
||||||
|
|| {{=$data}} !== {{=$data}}) {
|
||||||
|
{{??}}
|
||||||
|
{{
|
||||||
|
if ($exclIsNumber && $schema === undefined) {
|
||||||
|
{{# def.setExclusiveLimit }}
|
||||||
|
$schemaValue = $schemaExcl;
|
||||||
|
$notOp += '=';
|
||||||
|
} else {
|
||||||
|
if ($exclIsNumber)
|
||||||
|
$schemaValue = Math[$isMax ? 'min' : 'max']($schemaExcl, $schema);
|
||||||
|
|
||||||
|
if ($schemaExcl === ($exclIsNumber ? $schemaValue : true)) {
|
||||||
|
{{# def.setExclusiveLimit }}
|
||||||
|
$notOp += '=';
|
||||||
|
} else {
|
||||||
|
$exclusive = false;
|
||||||
|
$opStr += '=';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var $opExpr = '\'' + $opStr + '\''; /*used in error*/
|
||||||
|
}}
|
||||||
|
|
||||||
|
if ({{# def.$dataNotType:'number' }}
|
||||||
|
{{=$data}} {{=$notOp}} {{=$schemaValue}}
|
||||||
|
|| {{=$data}} !== {{=$data}}) {
|
||||||
|
{{?}}
|
||||||
|
{{?}}
|
||||||
|
{{ $errorKeyword = $errorKeyword || $keyword; }}
|
||||||
|
{{# def.error:'_limit' }}
|
||||||
|
} {{? $breakOnError }} else { {{?}}
|
12
node_modules/ajv/lib/dot/_limitItems.jst
generated
vendored
Normal file
12
node_modules/ajv/lib/dot/_limitItems.jst
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{{# def.definitions }}
|
||||||
|
{{# def.errors }}
|
||||||
|
{{# def.setupKeyword }}
|
||||||
|
{{# def.$data }}
|
||||||
|
|
||||||
|
{{# def.numberKeyword }}
|
||||||
|
|
||||||
|
{{ var $op = $keyword == 'maxItems' ? '>' : '<'; }}
|
||||||
|
if ({{# def.$dataNotType:'number' }} {{=$data}}.length {{=$op}} {{=$schemaValue}}) {
|
||||||
|
{{ var $errorKeyword = $keyword; }}
|
||||||
|
{{# def.error:'_limitItems' }}
|
||||||
|
} {{? $breakOnError }} else { {{?}}
|
12
node_modules/ajv/lib/dot/_limitLength.jst
generated
vendored
Normal file
12
node_modules/ajv/lib/dot/_limitLength.jst
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{{# def.definitions }}
|
||||||
|
{{# def.errors }}
|
||||||
|
{{# def.setupKeyword }}
|
||||||
|
{{# def.$data }}
|
||||||
|
|
||||||
|
{{# def.numberKeyword }}
|
||||||
|
|
||||||
|
{{ var $op = $keyword == 'maxLength' ? '>' : '<'; }}
|
||||||
|
if ({{# def.$dataNotType:'number' }} {{# def.strLength }} {{=$op}} {{=$schemaValue}}) {
|
||||||
|
{{ var $errorKeyword = $keyword; }}
|
||||||
|
{{# def.error:'_limitLength' }}
|
||||||
|
} {{? $breakOnError }} else { {{?}}
|
12
node_modules/ajv/lib/dot/_limitProperties.jst
generated
vendored
Normal file
12
node_modules/ajv/lib/dot/_limitProperties.jst
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{{# def.definitions }}
|
||||||
|
{{# def.errors }}
|
||||||
|
{{# def.setupKeyword }}
|
||||||
|
{{# def.$data }}
|
||||||
|
|
||||||
|
{{# def.numberKeyword }}
|
||||||
|
|
||||||
|
{{ var $op = $keyword == 'maxProperties' ? '>' : '<'; }}
|
||||||
|
if ({{# def.$dataNotType:'number' }} Object.keys({{=$data}}).length {{=$op}} {{=$schemaValue}}) {
|
||||||
|
{{ var $errorKeyword = $keyword; }}
|
||||||
|
{{# def.error:'_limitProperties' }}
|
||||||
|
} {{? $breakOnError }} else { {{?}}
|
32
node_modules/ajv/lib/dot/allOf.jst
generated
vendored
Normal file
32
node_modules/ajv/lib/dot/allOf.jst
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
{{# def.definitions }}
|
||||||
|
{{# def.errors }}
|
||||||
|
{{# def.setupKeyword }}
|
||||||
|
{{# def.setupNextLevel }}
|
||||||
|
|
||||||
|
{{
|
||||||
|
var $currentBaseId = $it.baseId
|
||||||
|
, $allSchemasEmpty = true;
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{~ $schema:$sch:$i }}
|
||||||
|
{{? {{# def.nonEmptySchema:$sch }} }}
|
||||||
|
{{
|
||||||
|
$allSchemasEmpty = false;
|
||||||
|
$it.schema = $sch;
|
||||||
|
$it.schemaPath = $schemaPath + '[' + $i + ']';
|
||||||
|
$it.errSchemaPath = $errSchemaPath + '/' + $i;
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{# def.insertSubschemaCode }}
|
||||||
|
|
||||||
|
{{# def.ifResultValid }}
|
||||||
|
{{?}}
|
||||||
|
{{~}}
|
||||||
|
|
||||||
|
{{? $breakOnError }}
|
||||||
|
{{? $allSchemasEmpty }}
|
||||||
|
if (true) {
|
||||||
|
{{??}}
|
||||||
|
{{= $closingBraces.slice(0,-1) }}
|
||||||
|
{{?}}
|
||||||
|
{{?}}
|
46
node_modules/ajv/lib/dot/anyOf.jst
generated
vendored
Normal file
46
node_modules/ajv/lib/dot/anyOf.jst
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
{{# def.definitions }}
|
||||||
|
{{# def.errors }}
|
||||||
|
{{# def.setupKeyword }}
|
||||||
|
{{# def.setupNextLevel }}
|
||||||
|
|
||||||
|
{{
|
||||||
|
var $noEmptySchema = $schema.every(function($sch) {
|
||||||
|
return {{# def.nonEmptySchema:$sch }};
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
{{? $noEmptySchema }}
|
||||||
|
{{ var $currentBaseId = $it.baseId; }}
|
||||||
|
var {{=$errs}} = errors;
|
||||||
|
var {{=$valid}} = false;
|
||||||
|
|
||||||
|
{{# def.setCompositeRule }}
|
||||||
|
|
||||||
|
{{~ $schema:$sch:$i }}
|
||||||
|
{{
|
||||||
|
$it.schema = $sch;
|
||||||
|
$it.schemaPath = $schemaPath + '[' + $i + ']';
|
||||||
|
$it.errSchemaPath = $errSchemaPath + '/' + $i;
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{# def.insertSubschemaCode }}
|
||||||
|
|
||||||
|
{{=$valid}} = {{=$valid}} || {{=$nextValid}};
|
||||||
|
|
||||||
|
if (!{{=$valid}}) {
|
||||||
|
{{ $closingBraces += '}'; }}
|
||||||
|
{{~}}
|
||||||
|
|
||||||
|
{{# def.resetCompositeRule }}
|
||||||
|
|
||||||
|
{{= $closingBraces }}
|
||||||
|
|
||||||
|
if (!{{=$valid}}) {
|
||||||
|
{{# def.extraError:'anyOf' }}
|
||||||
|
} else {
|
||||||
|
{{# def.resetErrors }}
|
||||||
|
{{? it.opts.allErrors }} } {{?}}
|
||||||
|
{{??}}
|
||||||
|
{{? $breakOnError }}
|
||||||
|
if (true) {
|
||||||
|
{{?}}
|
||||||
|
{{?}}
|
51
node_modules/ajv/lib/dot/coerce.def
generated
vendored
Normal file
51
node_modules/ajv/lib/dot/coerce.def
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
{{## def.coerceType:
|
||||||
|
{{
|
||||||
|
var $dataType = 'dataType' + $lvl
|
||||||
|
, $coerced = 'coerced' + $lvl;
|
||||||
|
}}
|
||||||
|
var {{=$dataType}} = typeof {{=$data}};
|
||||||
|
var {{=$coerced}} = undefined;
|
||||||
|
|
||||||
|
{{? it.opts.coerceTypes == 'array' }}
|
||||||
|
if ({{=$dataType}} == 'object' && Array.isArray({{=$data}}) && {{=$data}}.length == 1) {
|
||||||
|
{{=$data}} = {{=$data}}[0];
|
||||||
|
{{=$dataType}} = typeof {{=$data}};
|
||||||
|
if ({{=it.util.checkDataType(it.schema.type, $data, it.opts.strictNumbers)}}) {{=$coerced}} = {{=$data}};
|
||||||
|
}
|
||||||
|
{{?}}
|
||||||
|
|
||||||
|
if ({{=$coerced}} !== undefined) ;
|
||||||
|
{{~ $coerceToTypes:$type:$i }}
|
||||||
|
{{? $type == 'string' }}
|
||||||
|
else if ({{=$dataType}} == 'number' || {{=$dataType}} == 'boolean')
|
||||||
|
{{=$coerced}} = '' + {{=$data}};
|
||||||
|
else if ({{=$data}} === null) {{=$coerced}} = '';
|
||||||
|
{{?? $type == 'number' || $type == 'integer' }}
|
||||||
|
else if ({{=$dataType}} == 'boolean' || {{=$data}} === null
|
||||||
|
|| ({{=$dataType}} == 'string' && {{=$data}} && {{=$data}} == +{{=$data}}
|
||||||
|
{{? $type == 'integer' }} && !({{=$data}} % 1){{?}}))
|
||||||
|
{{=$coerced}} = +{{=$data}};
|
||||||
|
{{?? $type == 'boolean' }}
|
||||||
|
else if ({{=$data}} === 'false' || {{=$data}} === 0 || {{=$data}} === null)
|
||||||
|
{{=$coerced}} = false;
|
||||||
|
else if ({{=$data}} === 'true' || {{=$data}} === 1)
|
||||||
|
{{=$coerced}} = true;
|
||||||
|
{{?? $type == 'null' }}
|
||||||
|
else if ({{=$data}} === '' || {{=$data}} === 0 || {{=$data}} === false)
|
||||||
|
{{=$coerced}} = null;
|
||||||
|
{{?? it.opts.coerceTypes == 'array' && $type == 'array' }}
|
||||||
|
else if ({{=$dataType}} == 'string' || {{=$dataType}} == 'number' || {{=$dataType}} == 'boolean' || {{=$data}} == null)
|
||||||
|
{{=$coerced}} = [{{=$data}}];
|
||||||
|
{{?}}
|
||||||
|
{{~}}
|
||||||
|
else {
|
||||||
|
{{# def.error:'type' }}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ({{=$coerced}} !== undefined) {
|
||||||
|
{{# def.setParentData }}
|
||||||
|
{{=$data}} = {{=$coerced}};
|
||||||
|
{{? !$dataLvl }}if ({{=$parentData}} !== undefined){{?}}
|
||||||
|
{{=$parentData}}[{{=$parentDataProperty}}] = {{=$coerced}};
|
||||||
|
}
|
||||||
|
#}}
|
9
node_modules/ajv/lib/dot/comment.jst
generated
vendored
Normal file
9
node_modules/ajv/lib/dot/comment.jst
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{{# def.definitions }}
|
||||||
|
{{# def.setupKeyword }}
|
||||||
|
|
||||||
|
{{ var $comment = it.util.toQuotedString($schema); }}
|
||||||
|
{{? it.opts.$comment === true }}
|
||||||
|
console.log({{=$comment}});
|
||||||
|
{{?? typeof it.opts.$comment == 'function' }}
|
||||||
|
self._opts.$comment({{=$comment}}, {{=it.util.toQuotedString($errSchemaPath)}}, validate.root.schema);
|
||||||
|
{{?}}
|
11
node_modules/ajv/lib/dot/const.jst
generated
vendored
Normal file
11
node_modules/ajv/lib/dot/const.jst
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{{# def.definitions }}
|
||||||
|
{{# def.errors }}
|
||||||
|
{{# def.setupKeyword }}
|
||||||
|
{{# def.$data }}
|
||||||
|
|
||||||
|
{{? !$isData }}
|
||||||
|
var schema{{=$lvl}} = validate.schema{{=$schemaPath}};
|
||||||
|
{{?}}
|
||||||
|
var {{=$valid}} = equal({{=$data}}, schema{{=$lvl}});
|
||||||
|
{{# def.checkError:'const' }}
|
||||||
|
{{? $breakOnError }} else { {{?}}
|
55
node_modules/ajv/lib/dot/contains.jst
generated
vendored
Normal file
55
node_modules/ajv/lib/dot/contains.jst
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
{{# def.definitions }}
|
||||||
|
{{# def.errors }}
|
||||||
|
{{# def.setupKeyword }}
|
||||||
|
{{# def.setupNextLevel }}
|
||||||
|
|
||||||
|
|
||||||
|
{{
|
||||||
|
var $idx = 'i' + $lvl
|
||||||
|
, $dataNxt = $it.dataLevel = it.dataLevel + 1
|
||||||
|
, $nextData = 'data' + $dataNxt
|
||||||
|
, $currentBaseId = it.baseId
|
||||||
|
, $nonEmptySchema = {{# def.nonEmptySchema:$schema }};
|
||||||
|
}}
|
||||||
|
|
||||||
|
var {{=$errs}} = errors;
|
||||||
|
var {{=$valid}};
|
||||||
|
|
||||||
|
{{? $nonEmptySchema }}
|
||||||
|
{{# def.setCompositeRule }}
|
||||||
|
|
||||||
|
{{
|
||||||
|
$it.schema = $schema;
|
||||||
|
$it.schemaPath = $schemaPath;
|
||||||
|
$it.errSchemaPath = $errSchemaPath;
|
||||||
|
}}
|
||||||
|
|
||||||
|
var {{=$nextValid}} = false;
|
||||||
|
|
||||||
|
for (var {{=$idx}} = 0; {{=$idx}} < {{=$data}}.length; {{=$idx}}++) {
|
||||||
|
{{
|
||||||
|
$it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
|
||||||
|
var $passData = $data + '[' + $idx + ']';
|
||||||
|
$it.dataPathArr[$dataNxt] = $idx;
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{# def.generateSubschemaCode }}
|
||||||
|
{{# def.optimizeValidate }}
|
||||||
|
|
||||||
|
if ({{=$nextValid}}) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
{{# def.resetCompositeRule }}
|
||||||
|
{{= $closingBraces }}
|
||||||
|
|
||||||
|
if (!{{=$nextValid}}) {
|
||||||
|
{{??}}
|
||||||
|
if ({{=$data}}.length == 0) {
|
||||||
|
{{?}}
|
||||||
|
|
||||||
|
{{# def.error:'contains' }}
|
||||||
|
} else {
|
||||||
|
{{? $nonEmptySchema }}
|
||||||
|
{{# def.resetErrors }}
|
||||||
|
{{?}}
|
||||||
|
{{? it.opts.allErrors }} } {{?}}
|
191
node_modules/ajv/lib/dot/custom.jst
generated
vendored
Normal file
191
node_modules/ajv/lib/dot/custom.jst
generated
vendored
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
{{# def.definitions }}
|
||||||
|
{{# def.errors }}
|
||||||
|
{{# def.setupKeyword }}
|
||||||
|
{{# def.$data }}
|
||||||
|
|
||||||
|
{{
|
||||||
|
var $rule = this
|
||||||
|
, $definition = 'definition' + $lvl
|
||||||
|
, $rDef = $rule.definition
|
||||||
|
, $closingBraces = '';
|
||||||
|
var $validate = $rDef.validate;
|
||||||
|
var $compile, $inline, $macro, $ruleValidate, $validateCode;
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{? $isData && $rDef.$data }}
|
||||||
|
{{
|
||||||
|
$validateCode = 'keywordValidate' + $lvl;
|
||||||
|
var $validateSchema = $rDef.validateSchema;
|
||||||
|
}}
|
||||||
|
var {{=$definition}} = RULES.custom['{{=$keyword}}'].definition;
|
||||||
|
var {{=$validateCode}} = {{=$definition}}.validate;
|
||||||
|
{{??}}
|
||||||
|
{{
|
||||||
|
$ruleValidate = it.useCustomRule($rule, $schema, it.schema, it);
|
||||||
|
if (!$ruleValidate) return;
|
||||||
|
$schemaValue = 'validate.schema' + $schemaPath;
|
||||||
|
$validateCode = $ruleValidate.code;
|
||||||
|
$compile = $rDef.compile;
|
||||||
|
$inline = $rDef.inline;
|
||||||
|
$macro = $rDef.macro;
|
||||||
|
}}
|
||||||
|
{{?}}
|
||||||
|
|
||||||
|
{{
|
||||||
|
var $ruleErrs = $validateCode + '.errors'
|
||||||
|
, $i = 'i' + $lvl
|
||||||
|
, $ruleErr = 'ruleErr' + $lvl
|
||||||
|
, $asyncKeyword = $rDef.async;
|
||||||
|
|
||||||
|
if ($asyncKeyword && !it.async)
|
||||||
|
throw new Error('async keyword in sync schema');
|
||||||
|
}}
|
||||||
|
|
||||||
|
|
||||||
|
{{? !($inline || $macro) }}{{=$ruleErrs}} = null;{{?}}
|
||||||
|
var {{=$errs}} = errors;
|
||||||
|
var {{=$valid}};
|
||||||
|
|
||||||
|
{{## def.callRuleValidate:
|
||||||
|
{{=$validateCode}}.call(
|
||||||
|
{{? it.opts.passContext }}this{{??}}self{{?}}
|
||||||
|
{{? $compile || $rDef.schema === false }}
|
||||||
|
, {{=$data}}
|
||||||
|
{{??}}
|
||||||
|
, {{=$schemaValue}}
|
||||||
|
, {{=$data}}
|
||||||
|
, validate.schema{{=it.schemaPath}}
|
||||||
|
{{?}}
|
||||||
|
, {{# def.dataPath }}
|
||||||
|
{{# def.passParentData }}
|
||||||
|
, rootData
|
||||||
|
)
|
||||||
|
#}}
|
||||||
|
|
||||||
|
{{## def.extendErrors:_inline:
|
||||||
|
for (var {{=$i}}={{=$errs}}; {{=$i}}<errors; {{=$i}}++) {
|
||||||
|
var {{=$ruleErr}} = vErrors[{{=$i}}];
|
||||||
|
if ({{=$ruleErr}}.dataPath === undefined)
|
||||||
|
{{=$ruleErr}}.dataPath = (dataPath || '') + {{= it.errorPath }};
|
||||||
|
{{# _inline ? 'if (\{\{=$ruleErr\}\}.schemaPath === undefined) {' : '' }}
|
||||||
|
{{=$ruleErr}}.schemaPath = "{{=$errSchemaPath}}";
|
||||||
|
{{# _inline ? '}' : '' }}
|
||||||
|
{{? it.opts.verbose }}
|
||||||
|
{{=$ruleErr}}.schema = {{=$schemaValue}};
|
||||||
|
{{=$ruleErr}}.data = {{=$data}};
|
||||||
|
{{?}}
|
||||||
|
}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{? $isData && $rDef.$data }}
|
||||||
|
{{ $closingBraces += '}'; }}
|
||||||
|
if ({{=$schemaValue}} === undefined) {
|
||||||
|
{{=$valid}} = true;
|
||||||
|
} else {
|
||||||
|
{{? $validateSchema }}
|
||||||
|
{{ $closingBraces += '}'; }}
|
||||||
|
{{=$valid}} = {{=$definition}}.validateSchema({{=$schemaValue}});
|
||||||
|
if ({{=$valid}}) {
|
||||||
|
{{?}}
|
||||||
|
{{?}}
|
||||||
|
|
||||||
|
{{? $inline }}
|
||||||
|
{{? $rDef.statements }}
|
||||||
|
{{= $ruleValidate.validate }}
|
||||||
|
{{??}}
|
||||||
|
{{=$valid}} = {{= $ruleValidate.validate }};
|
||||||
|
{{?}}
|
||||||
|
{{?? $macro }}
|
||||||
|
{{# def.setupNextLevel }}
|
||||||
|
{{
|
||||||
|
$it.schema = $ruleValidate.validate;
|
||||||
|
$it.schemaPath = '';
|
||||||
|
}}
|
||||||
|
{{# def.setCompositeRule }}
|
||||||
|
{{ var $code = it.validate($it).replace(/validate\.schema/g, $validateCode); }}
|
||||||
|
{{# def.resetCompositeRule }}
|
||||||
|
{{= $code }}
|
||||||
|
{{??}}
|
||||||
|
{{# def.beginDefOut}}
|
||||||
|
{{# def.callRuleValidate }}
|
||||||
|
{{# def.storeDefOut:def_callRuleValidate }}
|
||||||
|
|
||||||
|
{{? $rDef.errors === false }}
|
||||||
|
{{=$valid}} = {{? $asyncKeyword }}await {{?}}{{= def_callRuleValidate }};
|
||||||
|
{{??}}
|
||||||
|
{{? $asyncKeyword }}
|
||||||
|
{{ $ruleErrs = 'customErrors' + $lvl; }}
|
||||||
|
var {{=$ruleErrs}} = null;
|
||||||
|
try {
|
||||||
|
{{=$valid}} = await {{= def_callRuleValidate }};
|
||||||
|
} catch (e) {
|
||||||
|
{{=$valid}} = false;
|
||||||
|
if (e instanceof ValidationError) {{=$ruleErrs}} = e.errors;
|
||||||
|
else throw e;
|
||||||
|
}
|
||||||
|
{{??}}
|
||||||
|
{{=$ruleErrs}} = null;
|
||||||
|
{{=$valid}} = {{= def_callRuleValidate }};
|
||||||
|
{{?}}
|
||||||
|
{{?}}
|
||||||
|
{{?}}
|
||||||
|
|
||||||
|
{{? $rDef.modifying }}
|
||||||
|
if ({{=$parentData}}) {{=$data}} = {{=$parentData}}[{{=$parentDataProperty}}];
|
||||||
|
{{?}}
|
||||||
|
|
||||||
|
{{= $closingBraces }}
|
||||||
|
|
||||||
|
{{## def.notValidationResult:
|
||||||
|
{{? $rDef.valid === undefined }}
|
||||||
|
!{{? $macro }}{{=$nextValid}}{{??}}{{=$valid}}{{?}}
|
||||||
|
{{??}}
|
||||||
|
{{= !$rDef.valid }}
|
||||||
|
{{?}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
{{? $rDef.valid }}
|
||||||
|
{{? $breakOnError }} if (true) { {{?}}
|
||||||
|
{{??}}
|
||||||
|
if ({{# def.notValidationResult }}) {
|
||||||
|
{{ $errorKeyword = $rule.keyword; }}
|
||||||
|
{{# def.beginDefOut}}
|
||||||
|
{{# def.error:'custom' }}
|
||||||
|
{{# def.storeDefOut:def_customError }}
|
||||||
|
|
||||||
|
{{? $inline }}
|
||||||
|
{{? $rDef.errors }}
|
||||||
|
{{? $rDef.errors != 'full' }}
|
||||||
|
{{# def.extendErrors:true }}
|
||||||
|
{{?}}
|
||||||
|
{{??}}
|
||||||
|
{{? $rDef.errors === false}}
|
||||||
|
{{= def_customError }}
|
||||||
|
{{??}}
|
||||||
|
if ({{=$errs}} == errors) {
|
||||||
|
{{= def_customError }}
|
||||||
|
} else {
|
||||||
|
{{# def.extendErrors:true }}
|
||||||
|
}
|
||||||
|
{{?}}
|
||||||
|
{{?}}
|
||||||
|
{{?? $macro }}
|
||||||
|
{{# def.extraError:'custom' }}
|
||||||
|
{{??}}
|
||||||
|
{{? $rDef.errors === false}}
|
||||||
|
{{= def_customError }}
|
||||||
|
{{??}}
|
||||||
|
if (Array.isArray({{=$ruleErrs}})) {
|
||||||
|
if (vErrors === null) vErrors = {{=$ruleErrs}};
|
||||||
|
else vErrors = vErrors.concat({{=$ruleErrs}});
|
||||||
|
errors = vErrors.length;
|
||||||
|
{{# def.extendErrors:false }}
|
||||||
|
} else {
|
||||||
|
{{= def_customError }}
|
||||||
|
}
|
||||||
|
{{?}}
|
||||||
|
{{?}}
|
||||||
|
|
||||||
|
} {{? $breakOnError }} else { {{?}}
|
||||||
|
{{?}}
|
47
node_modules/ajv/lib/dot/defaults.def
generated
vendored
Normal file
47
node_modules/ajv/lib/dot/defaults.def
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
{{## def.assignDefault:
|
||||||
|
{{? it.compositeRule }}
|
||||||
|
{{
|
||||||
|
if (it.opts.strictDefaults) {
|
||||||
|
var $defaultMsg = 'default is ignored for: ' + $passData;
|
||||||
|
if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);
|
||||||
|
else throw new Error($defaultMsg);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
{{??}}
|
||||||
|
if ({{=$passData}} === undefined
|
||||||
|
{{? it.opts.useDefaults == 'empty' }}
|
||||||
|
|| {{=$passData}} === null
|
||||||
|
|| {{=$passData}} === ''
|
||||||
|
{{?}}
|
||||||
|
)
|
||||||
|
{{=$passData}} = {{? it.opts.useDefaults == 'shared' }}
|
||||||
|
{{= it.useDefault($sch.default) }}
|
||||||
|
{{??}}
|
||||||
|
{{= JSON.stringify($sch.default) }}
|
||||||
|
{{?}};
|
||||||
|
{{?}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.defaultProperties:
|
||||||
|
{{
|
||||||
|
var $schema = it.schema.properties
|
||||||
|
, $schemaKeys = Object.keys($schema); }}
|
||||||
|
{{~ $schemaKeys:$propertyKey }}
|
||||||
|
{{ var $sch = $schema[$propertyKey]; }}
|
||||||
|
{{? $sch.default !== undefined }}
|
||||||
|
{{ var $passData = $data + it.util.getProperty($propertyKey); }}
|
||||||
|
{{# def.assignDefault }}
|
||||||
|
{{?}}
|
||||||
|
{{~}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.defaultItems:
|
||||||
|
{{~ it.schema.items:$sch:$i }}
|
||||||
|
{{? $sch.default !== undefined }}
|
||||||
|
{{ var $passData = $data + '[' + $i + ']'; }}
|
||||||
|
{{# def.assignDefault }}
|
||||||
|
{{?}}
|
||||||
|
{{~}}
|
||||||
|
#}}
|
203
node_modules/ajv/lib/dot/definitions.def
generated
vendored
Normal file
203
node_modules/ajv/lib/dot/definitions.def
generated
vendored
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
{{## def.setupKeyword:
|
||||||
|
{{
|
||||||
|
var $lvl = it.level;
|
||||||
|
var $dataLvl = it.dataLevel;
|
||||||
|
var $schema = it.schema[$keyword];
|
||||||
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
||||||
|
var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
|
||||||
|
var $breakOnError = !it.opts.allErrors;
|
||||||
|
var $errorKeyword;
|
||||||
|
|
||||||
|
var $data = 'data' + ($dataLvl || '');
|
||||||
|
var $valid = 'valid' + $lvl;
|
||||||
|
var $errs = 'errs__' + $lvl;
|
||||||
|
}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.setCompositeRule:
|
||||||
|
{{
|
||||||
|
var $wasComposite = it.compositeRule;
|
||||||
|
it.compositeRule = $it.compositeRule = true;
|
||||||
|
}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.resetCompositeRule:
|
||||||
|
{{ it.compositeRule = $it.compositeRule = $wasComposite; }}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.setupNextLevel:
|
||||||
|
{{
|
||||||
|
var $it = it.util.copy(it);
|
||||||
|
var $closingBraces = '';
|
||||||
|
$it.level++;
|
||||||
|
var $nextValid = 'valid' + $it.level;
|
||||||
|
}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.ifValid:
|
||||||
|
{{? $breakOnError }}
|
||||||
|
if ({{=$valid}}) {
|
||||||
|
{{ $closingBraces += '}'; }}
|
||||||
|
{{?}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.ifResultValid:
|
||||||
|
{{? $breakOnError }}
|
||||||
|
if ({{=$nextValid}}) {
|
||||||
|
{{ $closingBraces += '}'; }}
|
||||||
|
{{?}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.elseIfValid:
|
||||||
|
{{? $breakOnError }}
|
||||||
|
{{ $closingBraces += '}'; }}
|
||||||
|
else {
|
||||||
|
{{?}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.nonEmptySchema:_schema:
|
||||||
|
(it.opts.strictKeywords
|
||||||
|
? (typeof _schema == 'object' && Object.keys(_schema).length > 0)
|
||||||
|
|| _schema === false
|
||||||
|
: it.util.schemaHasRules(_schema, it.RULES.all))
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.strLength:
|
||||||
|
{{? it.opts.unicode === false }}
|
||||||
|
{{=$data}}.length
|
||||||
|
{{??}}
|
||||||
|
ucs2length({{=$data}})
|
||||||
|
{{?}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.willOptimize:
|
||||||
|
it.util.varOccurences($code, $nextData) < 2
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.generateSubschemaCode:
|
||||||
|
{{
|
||||||
|
var $code = it.validate($it);
|
||||||
|
$it.baseId = $currentBaseId;
|
||||||
|
}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.insertSubschemaCode:
|
||||||
|
{{= it.validate($it) }}
|
||||||
|
{{ $it.baseId = $currentBaseId; }}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def._optimizeValidate:
|
||||||
|
it.util.varReplace($code, $nextData, $passData)
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.optimizeValidate:
|
||||||
|
{{? {{# def.willOptimize}} }}
|
||||||
|
{{= {{# def._optimizeValidate }} }}
|
||||||
|
{{??}}
|
||||||
|
var {{=$nextData}} = {{=$passData}};
|
||||||
|
{{= $code }}
|
||||||
|
{{?}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.$data:
|
||||||
|
{{
|
||||||
|
var $isData = it.opts.$data && $schema && $schema.$data
|
||||||
|
, $schemaValue;
|
||||||
|
}}
|
||||||
|
{{? $isData }}
|
||||||
|
var schema{{=$lvl}} = {{= it.util.getData($schema.$data, $dataLvl, it.dataPathArr) }};
|
||||||
|
{{ $schemaValue = 'schema' + $lvl; }}
|
||||||
|
{{??}}
|
||||||
|
{{ $schemaValue = $schema; }}
|
||||||
|
{{?}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.$dataNotType:_type:
|
||||||
|
{{?$isData}} ({{=$schemaValue}} !== undefined && typeof {{=$schemaValue}} != _type) || {{?}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.check$dataIsArray:
|
||||||
|
if (schema{{=$lvl}} === undefined) {{=$valid}} = true;
|
||||||
|
else if (!Array.isArray(schema{{=$lvl}})) {{=$valid}} = false;
|
||||||
|
else {
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.numberKeyword:
|
||||||
|
{{? !($isData || typeof $schema == 'number') }}
|
||||||
|
{{ throw new Error($keyword + ' must be number'); }}
|
||||||
|
{{?}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.beginDefOut:
|
||||||
|
{{
|
||||||
|
var $$outStack = $$outStack || [];
|
||||||
|
$$outStack.push(out);
|
||||||
|
out = '';
|
||||||
|
}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.storeDefOut:_variable:
|
||||||
|
{{
|
||||||
|
var _variable = out;
|
||||||
|
out = $$outStack.pop();
|
||||||
|
}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.dataPath:(dataPath || ''){{? it.errorPath != '""'}} + {{= it.errorPath }}{{?}}#}}
|
||||||
|
|
||||||
|
{{## def.setParentData:
|
||||||
|
{{
|
||||||
|
var $parentData = $dataLvl ? 'data' + (($dataLvl-1)||'') : 'parentData'
|
||||||
|
, $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
|
||||||
|
}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
{{## def.passParentData:
|
||||||
|
{{# def.setParentData }}
|
||||||
|
, {{= $parentData }}
|
||||||
|
, {{= $parentDataProperty }}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.iterateProperties:
|
||||||
|
{{? $ownProperties }}
|
||||||
|
{{=$dataProperties}} = {{=$dataProperties}} || Object.keys({{=$data}});
|
||||||
|
for (var {{=$idx}}=0; {{=$idx}}<{{=$dataProperties}}.length; {{=$idx}}++) {
|
||||||
|
var {{=$key}} = {{=$dataProperties}}[{{=$idx}}];
|
||||||
|
{{??}}
|
||||||
|
for (var {{=$key}} in {{=$data}}) {
|
||||||
|
{{?}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.noPropertyInData:
|
||||||
|
{{=$useData}} === undefined
|
||||||
|
{{? $ownProperties }}
|
||||||
|
|| !{{# def.isOwnProperty }}
|
||||||
|
{{?}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.isOwnProperty:
|
||||||
|
Object.prototype.hasOwnProperty.call({{=$data}}, '{{=it.util.escapeQuotes($propertyKey)}}')
|
||||||
|
#}}
|
79
node_modules/ajv/lib/dot/dependencies.jst
generated
vendored
Normal file
79
node_modules/ajv/lib/dot/dependencies.jst
generated
vendored
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
{{# def.definitions }}
|
||||||
|
{{# def.errors }}
|
||||||
|
{{# def.missing }}
|
||||||
|
{{# def.setupKeyword }}
|
||||||
|
{{# def.setupNextLevel }}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.propertyInData:
|
||||||
|
{{=$data}}{{= it.util.getProperty($property) }} !== undefined
|
||||||
|
{{? $ownProperties }}
|
||||||
|
&& Object.prototype.hasOwnProperty.call({{=$data}}, '{{=it.util.escapeQuotes($property)}}')
|
||||||
|
{{?}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{
|
||||||
|
var $schemaDeps = {}
|
||||||
|
, $propertyDeps = {}
|
||||||
|
, $ownProperties = it.opts.ownProperties;
|
||||||
|
|
||||||
|
for ($property in $schema) {
|
||||||
|
if ($property == '__proto__') continue;
|
||||||
|
var $sch = $schema[$property];
|
||||||
|
var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps;
|
||||||
|
$deps[$property] = $sch;
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
|
||||||
|
var {{=$errs}} = errors;
|
||||||
|
|
||||||
|
{{ var $currentErrorPath = it.errorPath; }}
|
||||||
|
|
||||||
|
var missing{{=$lvl}};
|
||||||
|
{{ for (var $property in $propertyDeps) { }}
|
||||||
|
{{ $deps = $propertyDeps[$property]; }}
|
||||||
|
{{? $deps.length }}
|
||||||
|
if ({{# def.propertyInData }}
|
||||||
|
{{? $breakOnError }}
|
||||||
|
&& ({{# def.checkMissingProperty:$deps }})) {
|
||||||
|
{{# def.errorMissingProperty:'dependencies' }}
|
||||||
|
{{??}}
|
||||||
|
) {
|
||||||
|
{{~ $deps:$propertyKey }}
|
||||||
|
{{# def.allErrorsMissingProperty:'dependencies' }}
|
||||||
|
{{~}}
|
||||||
|
{{?}}
|
||||||
|
} {{# def.elseIfValid }}
|
||||||
|
{{?}}
|
||||||
|
{{ } }}
|
||||||
|
|
||||||
|
{{
|
||||||
|
it.errorPath = $currentErrorPath;
|
||||||
|
var $currentBaseId = $it.baseId;
|
||||||
|
}}
|
||||||
|
|
||||||
|
|
||||||
|
{{ for (var $property in $schemaDeps) { }}
|
||||||
|
{{ var $sch = $schemaDeps[$property]; }}
|
||||||
|
{{? {{# def.nonEmptySchema:$sch }} }}
|
||||||
|
{{=$nextValid}} = true;
|
||||||
|
|
||||||
|
if ({{# def.propertyInData }}) {
|
||||||
|
{{
|
||||||
|
$it.schema = $sch;
|
||||||
|
$it.schemaPath = $schemaPath + it.util.getProperty($property);
|
||||||
|
$it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($property);
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{# def.insertSubschemaCode }}
|
||||||
|
}
|
||||||
|
|
||||||
|
{{# def.ifResultValid }}
|
||||||
|
{{?}}
|
||||||
|
{{ } }}
|
||||||
|
|
||||||
|
{{? $breakOnError }}
|
||||||
|
{{= $closingBraces }}
|
||||||
|
if ({{=$errs}} == errors) {
|
||||||
|
{{?}}
|
30
node_modules/ajv/lib/dot/enum.jst
generated
vendored
Normal file
30
node_modules/ajv/lib/dot/enum.jst
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{{# def.definitions }}
|
||||||
|
{{# def.errors }}
|
||||||
|
{{# def.setupKeyword }}
|
||||||
|
{{# def.$data }}
|
||||||
|
|
||||||
|
{{
|
||||||
|
var $i = 'i' + $lvl
|
||||||
|
, $vSchema = 'schema' + $lvl;
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{? !$isData }}
|
||||||
|
var {{=$vSchema}} = validate.schema{{=$schemaPath}};
|
||||||
|
{{?}}
|
||||||
|
var {{=$valid}};
|
||||||
|
|
||||||
|
{{?$isData}}{{# def.check$dataIsArray }}{{?}}
|
||||||
|
|
||||||
|
{{=$valid}} = false;
|
||||||
|
|
||||||
|
for (var {{=$i}}=0; {{=$i}}<{{=$vSchema}}.length; {{=$i}}++)
|
||||||
|
if (equal({{=$data}}, {{=$vSchema}}[{{=$i}}])) {
|
||||||
|
{{=$valid}} = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
{{? $isData }} } {{?}}
|
||||||
|
|
||||||
|
{{# def.checkError:'enum' }}
|
||||||
|
|
||||||
|
{{? $breakOnError }} else { {{?}}
|
194
node_modules/ajv/lib/dot/errors.def
generated
vendored
Normal file
194
node_modules/ajv/lib/dot/errors.def
generated
vendored
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
{{# def.definitions }}
|
||||||
|
|
||||||
|
{{## def._error:_rule:
|
||||||
|
{{ 'istanbul ignore else'; }}
|
||||||
|
{{? it.createErrors !== false }}
|
||||||
|
{
|
||||||
|
keyword: '{{= $errorKeyword || _rule }}'
|
||||||
|
, dataPath: (dataPath || '') + {{= it.errorPath }}
|
||||||
|
, schemaPath: {{=it.util.toQuotedString($errSchemaPath)}}
|
||||||
|
, params: {{# def._errorParams[_rule] }}
|
||||||
|
{{? it.opts.messages !== false }}
|
||||||
|
, message: {{# def._errorMessages[_rule] }}
|
||||||
|
{{?}}
|
||||||
|
{{? it.opts.verbose }}
|
||||||
|
, schema: {{# def._errorSchemas[_rule] }}
|
||||||
|
, parentSchema: validate.schema{{=it.schemaPath}}
|
||||||
|
, data: {{=$data}}
|
||||||
|
{{?}}
|
||||||
|
}
|
||||||
|
{{??}}
|
||||||
|
{}
|
||||||
|
{{?}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def._addError:_rule:
|
||||||
|
if (vErrors === null) vErrors = [err];
|
||||||
|
else vErrors.push(err);
|
||||||
|
errors++;
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.addError:_rule:
|
||||||
|
var err = {{# def._error:_rule }};
|
||||||
|
{{# def._addError:_rule }}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.error:_rule:
|
||||||
|
{{# def.beginDefOut}}
|
||||||
|
{{# def._error:_rule }}
|
||||||
|
{{# def.storeDefOut:__err }}
|
||||||
|
|
||||||
|
{{? !it.compositeRule && $breakOnError }}
|
||||||
|
{{ 'istanbul ignore if'; }}
|
||||||
|
{{? it.async }}
|
||||||
|
throw new ValidationError([{{=__err}}]);
|
||||||
|
{{??}}
|
||||||
|
validate.errors = [{{=__err}}];
|
||||||
|
return false;
|
||||||
|
{{?}}
|
||||||
|
{{??}}
|
||||||
|
var err = {{=__err}};
|
||||||
|
{{# def._addError:_rule }}
|
||||||
|
{{?}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.extraError:_rule:
|
||||||
|
{{# def.addError:_rule}}
|
||||||
|
{{? !it.compositeRule && $breakOnError }}
|
||||||
|
{{ 'istanbul ignore if'; }}
|
||||||
|
{{? it.async }}
|
||||||
|
throw new ValidationError(vErrors);
|
||||||
|
{{??}}
|
||||||
|
validate.errors = vErrors;
|
||||||
|
return false;
|
||||||
|
{{?}}
|
||||||
|
{{?}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.checkError:_rule:
|
||||||
|
if (!{{=$valid}}) {
|
||||||
|
{{# def.error:_rule }}
|
||||||
|
}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.resetErrors:
|
||||||
|
errors = {{=$errs}};
|
||||||
|
if (vErrors !== null) {
|
||||||
|
if ({{=$errs}}) vErrors.length = {{=$errs}};
|
||||||
|
else vErrors = null;
|
||||||
|
}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.concatSchema:{{?$isData}}' + {{=$schemaValue}} + '{{??}}{{=$schema}}{{?}}#}}
|
||||||
|
{{## def.appendSchema:{{?$isData}}' + {{=$schemaValue}}{{??}}{{=$schemaValue}}'{{?}}#}}
|
||||||
|
{{## def.concatSchemaEQ:{{?$isData}}' + {{=$schemaValue}} + '{{??}}{{=it.util.escapeQuotes($schema)}}{{?}}#}}
|
||||||
|
|
||||||
|
{{## def._errorMessages = {
|
||||||
|
'false schema': "'boolean schema is false'",
|
||||||
|
$ref: "'can\\\'t resolve reference {{=it.util.escapeQuotes($schema)}}'",
|
||||||
|
additionalItems: "'should NOT have more than {{=$schema.length}} items'",
|
||||||
|
additionalProperties: "'{{? it.opts._errorDataPathProperty }}is an invalid additional property{{??}}should NOT have additional properties{{?}}'",
|
||||||
|
anyOf: "'should match some schema in anyOf'",
|
||||||
|
const: "'should be equal to constant'",
|
||||||
|
contains: "'should contain a valid item'",
|
||||||
|
dependencies: "'should have {{? $deps.length == 1 }}property {{= it.util.escapeQuotes($deps[0]) }}{{??}}properties {{= it.util.escapeQuotes($deps.join(\", \")) }}{{?}} when property {{= it.util.escapeQuotes($property) }} is present'",
|
||||||
|
'enum': "'should be equal to one of the allowed values'",
|
||||||
|
format: "'should match format \"{{#def.concatSchemaEQ}}\"'",
|
||||||
|
'if': "'should match \"' + {{=$ifClause}} + '\" schema'",
|
||||||
|
_limit: "'should be {{=$opStr}} {{#def.appendSchema}}",
|
||||||
|
_exclusiveLimit: "'{{=$exclusiveKeyword}} should be boolean'",
|
||||||
|
_limitItems: "'should NOT have {{?$keyword=='maxItems'}}more{{??}}fewer{{?}} than {{#def.concatSchema}} items'",
|
||||||
|
_limitLength: "'should NOT be {{?$keyword=='maxLength'}}longer{{??}}shorter{{?}} than {{#def.concatSchema}} characters'",
|
||||||
|
_limitProperties:"'should NOT have {{?$keyword=='maxProperties'}}more{{??}}fewer{{?}} than {{#def.concatSchema}} properties'",
|
||||||
|
multipleOf: "'should be multiple of {{#def.appendSchema}}",
|
||||||
|
not: "'should NOT be valid'",
|
||||||
|
oneOf: "'should match exactly one schema in oneOf'",
|
||||||
|
pattern: "'should match pattern \"{{#def.concatSchemaEQ}}\"'",
|
||||||
|
propertyNames: "'property name \\'{{=$invalidName}}\\' is invalid'",
|
||||||
|
required: "'{{? it.opts._errorDataPathProperty }}is a required property{{??}}should have required property \\'{{=$missingProperty}}\\'{{?}}'",
|
||||||
|
type: "'should be {{? $typeIsArray }}{{= $typeSchema.join(\",\") }}{{??}}{{=$typeSchema}}{{?}}'",
|
||||||
|
uniqueItems: "'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)'",
|
||||||
|
custom: "'should pass \"{{=$rule.keyword}}\" keyword validation'",
|
||||||
|
patternRequired: "'should have property matching pattern \\'{{=$missingPattern}}\\''",
|
||||||
|
switch: "'should pass \"switch\" keyword validation'",
|
||||||
|
_formatLimit: "'should be {{=$opStr}} \"{{#def.concatSchemaEQ}}\"'",
|
||||||
|
_formatExclusiveLimit: "'{{=$exclusiveKeyword}} should be boolean'"
|
||||||
|
} #}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.schemaRefOrVal: {{?$isData}}validate.schema{{=$schemaPath}}{{??}}{{=$schema}}{{?}} #}}
|
||||||
|
{{## def.schemaRefOrQS: {{?$isData}}validate.schema{{=$schemaPath}}{{??}}{{=it.util.toQuotedString($schema)}}{{?}} #}}
|
||||||
|
|
||||||
|
{{## def._errorSchemas = {
|
||||||
|
'false schema': "false",
|
||||||
|
$ref: "{{=it.util.toQuotedString($schema)}}",
|
||||||
|
additionalItems: "false",
|
||||||
|
additionalProperties: "false",
|
||||||
|
anyOf: "validate.schema{{=$schemaPath}}",
|
||||||
|
const: "validate.schema{{=$schemaPath}}",
|
||||||
|
contains: "validate.schema{{=$schemaPath}}",
|
||||||
|
dependencies: "validate.schema{{=$schemaPath}}",
|
||||||
|
'enum': "validate.schema{{=$schemaPath}}",
|
||||||
|
format: "{{#def.schemaRefOrQS}}",
|
||||||
|
'if': "validate.schema{{=$schemaPath}}",
|
||||||
|
_limit: "{{#def.schemaRefOrVal}}",
|
||||||
|
_exclusiveLimit: "validate.schema{{=$schemaPath}}",
|
||||||
|
_limitItems: "{{#def.schemaRefOrVal}}",
|
||||||
|
_limitLength: "{{#def.schemaRefOrVal}}",
|
||||||
|
_limitProperties:"{{#def.schemaRefOrVal}}",
|
||||||
|
multipleOf: "{{#def.schemaRefOrVal}}",
|
||||||
|
not: "validate.schema{{=$schemaPath}}",
|
||||||
|
oneOf: "validate.schema{{=$schemaPath}}",
|
||||||
|
pattern: "{{#def.schemaRefOrQS}}",
|
||||||
|
propertyNames: "validate.schema{{=$schemaPath}}",
|
||||||
|
required: "validate.schema{{=$schemaPath}}",
|
||||||
|
type: "validate.schema{{=$schemaPath}}",
|
||||||
|
uniqueItems: "{{#def.schemaRefOrVal}}",
|
||||||
|
custom: "validate.schema{{=$schemaPath}}",
|
||||||
|
patternRequired: "validate.schema{{=$schemaPath}}",
|
||||||
|
switch: "validate.schema{{=$schemaPath}}",
|
||||||
|
_formatLimit: "{{#def.schemaRefOrQS}}",
|
||||||
|
_formatExclusiveLimit: "validate.schema{{=$schemaPath}}"
|
||||||
|
} #}}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.schemaValueQS: {{?$isData}}{{=$schemaValue}}{{??}}{{=it.util.toQuotedString($schema)}}{{?}} #}}
|
||||||
|
|
||||||
|
{{## def._errorParams = {
|
||||||
|
'false schema': "{}",
|
||||||
|
$ref: "{ ref: '{{=it.util.escapeQuotes($schema)}}' }",
|
||||||
|
additionalItems: "{ limit: {{=$schema.length}} }",
|
||||||
|
additionalProperties: "{ additionalProperty: '{{=$additionalProperty}}' }",
|
||||||
|
anyOf: "{}",
|
||||||
|
const: "{ allowedValue: schema{{=$lvl}} }",
|
||||||
|
contains: "{}",
|
||||||
|
dependencies: "{ property: '{{= it.util.escapeQuotes($property) }}', missingProperty: '{{=$missingProperty}}', depsCount: {{=$deps.length}}, deps: '{{= it.util.escapeQuotes($deps.length==1 ? $deps[0] : $deps.join(\", \")) }}' }",
|
||||||
|
'enum': "{ allowedValues: schema{{=$lvl}} }",
|
||||||
|
format: "{ format: {{#def.schemaValueQS}} }",
|
||||||
|
'if': "{ failingKeyword: {{=$ifClause}} }",
|
||||||
|
_limit: "{ comparison: {{=$opExpr}}, limit: {{=$schemaValue}}, exclusive: {{=$exclusive}} }",
|
||||||
|
_exclusiveLimit: "{}",
|
||||||
|
_limitItems: "{ limit: {{=$schemaValue}} }",
|
||||||
|
_limitLength: "{ limit: {{=$schemaValue}} }",
|
||||||
|
_limitProperties:"{ limit: {{=$schemaValue}} }",
|
||||||
|
multipleOf: "{ multipleOf: {{=$schemaValue}} }",
|
||||||
|
not: "{}",
|
||||||
|
oneOf: "{ passingSchemas: {{=$passingSchemas}} }",
|
||||||
|
pattern: "{ pattern: {{#def.schemaValueQS}} }",
|
||||||
|
propertyNames: "{ propertyName: '{{=$invalidName}}' }",
|
||||||
|
required: "{ missingProperty: '{{=$missingProperty}}' }",
|
||||||
|
type: "{ type: '{{? $typeIsArray }}{{= $typeSchema.join(\",\") }}{{??}}{{=$typeSchema}}{{?}}' }",
|
||||||
|
uniqueItems: "{ i: i, j: j }",
|
||||||
|
custom: "{ keyword: '{{=$rule.keyword}}' }",
|
||||||
|
patternRequired: "{ missingPattern: '{{=$missingPattern}}' }",
|
||||||
|
switch: "{ caseIndex: {{=$caseIndex}} }",
|
||||||
|
_formatLimit: "{ comparison: {{=$opExpr}}, limit: {{#def.schemaValueQS}}, exclusive: {{=$exclusive}} }",
|
||||||
|
_formatExclusiveLimit: "{}"
|
||||||
|
} #}}
|
106
node_modules/ajv/lib/dot/format.jst
generated
vendored
Normal file
106
node_modules/ajv/lib/dot/format.jst
generated
vendored
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
{{# def.definitions }}
|
||||||
|
{{# def.errors }}
|
||||||
|
{{# def.setupKeyword }}
|
||||||
|
|
||||||
|
{{## def.skipFormat:
|
||||||
|
{{? $breakOnError }} if (true) { {{?}}
|
||||||
|
{{ return out; }}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
{{? it.opts.format === false }}{{# def.skipFormat }}{{?}}
|
||||||
|
|
||||||
|
|
||||||
|
{{# def.$data }}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.$dataCheckFormat:
|
||||||
|
{{# def.$dataNotType:'string' }}
|
||||||
|
({{? $unknownFormats != 'ignore' }}
|
||||||
|
({{=$schemaValue}} && !{{=$format}}
|
||||||
|
{{? $allowUnknown }}
|
||||||
|
&& self._opts.unknownFormats.indexOf({{=$schemaValue}}) == -1
|
||||||
|
{{?}}) ||
|
||||||
|
{{?}}
|
||||||
|
({{=$format}} && {{=$formatType}} == '{{=$ruleType}}'
|
||||||
|
&& !(typeof {{=$format}} == 'function'
|
||||||
|
? {{? it.async}}
|
||||||
|
(async{{=$lvl}} ? await {{=$format}}({{=$data}}) : {{=$format}}({{=$data}}))
|
||||||
|
{{??}}
|
||||||
|
{{=$format}}({{=$data}})
|
||||||
|
{{?}}
|
||||||
|
: {{=$format}}.test({{=$data}}))))
|
||||||
|
#}}
|
||||||
|
|
||||||
|
{{## def.checkFormat:
|
||||||
|
{{
|
||||||
|
var $formatRef = 'formats' + it.util.getProperty($schema);
|
||||||
|
if ($isObject) $formatRef += '.validate';
|
||||||
|
}}
|
||||||
|
{{? typeof $format == 'function' }}
|
||||||
|
{{=$formatRef}}({{=$data}})
|
||||||
|
{{??}}
|
||||||
|
{{=$formatRef}}.test({{=$data}})
|
||||||
|
{{?}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
|
||||||
|
{{
|
||||||
|
var $unknownFormats = it.opts.unknownFormats
|
||||||
|
, $allowUnknown = Array.isArray($unknownFormats);
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{? $isData }}
|
||||||
|
{{
|
||||||
|
var $format = 'format' + $lvl
|
||||||
|
, $isObject = 'isObject' + $lvl
|
||||||
|
, $formatType = 'formatType' + $lvl;
|
||||||
|
}}
|
||||||
|
var {{=$format}} = formats[{{=$schemaValue}}];
|
||||||
|
var {{=$isObject}} = typeof {{=$format}} == 'object'
|
||||||
|
&& !({{=$format}} instanceof RegExp)
|
||||||
|
&& {{=$format}}.validate;
|
||||||
|
var {{=$formatType}} = {{=$isObject}} && {{=$format}}.type || 'string';
|
||||||
|
if ({{=$isObject}}) {
|
||||||
|
{{? it.async}}
|
||||||
|
var async{{=$lvl}} = {{=$format}}.async;
|
||||||
|
{{?}}
|
||||||
|
{{=$format}} = {{=$format}}.validate;
|
||||||
|
}
|
||||||
|
if ({{# def.$dataCheckFormat }}) {
|
||||||
|
{{??}}
|
||||||
|
{{ var $format = it.formats[$schema]; }}
|
||||||
|
{{? !$format }}
|
||||||
|
{{? $unknownFormats == 'ignore' }}
|
||||||
|
{{ it.logger.warn('unknown format "' + $schema + '" ignored in schema at path "' + it.errSchemaPath + '"'); }}
|
||||||
|
{{# def.skipFormat }}
|
||||||
|
{{?? $allowUnknown && $unknownFormats.indexOf($schema) >= 0 }}
|
||||||
|
{{# def.skipFormat }}
|
||||||
|
{{??}}
|
||||||
|
{{ throw new Error('unknown format "' + $schema + '" is used in schema at path "' + it.errSchemaPath + '"'); }}
|
||||||
|
{{?}}
|
||||||
|
{{?}}
|
||||||
|
{{
|
||||||
|
var $isObject = typeof $format == 'object'
|
||||||
|
&& !($format instanceof RegExp)
|
||||||
|
&& $format.validate;
|
||||||
|
var $formatType = $isObject && $format.type || 'string';
|
||||||
|
if ($isObject) {
|
||||||
|
var $async = $format.async === true;
|
||||||
|
$format = $format.validate;
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
{{? $formatType != $ruleType }}
|
||||||
|
{{# def.skipFormat }}
|
||||||
|
{{?}}
|
||||||
|
{{? $async }}
|
||||||
|
{{
|
||||||
|
if (!it.async) throw new Error('async format in sync schema');
|
||||||
|
var $formatRef = 'formats' + it.util.getProperty($schema) + '.validate';
|
||||||
|
}}
|
||||||
|
if (!(await {{=$formatRef}}({{=$data}}))) {
|
||||||
|
{{??}}
|
||||||
|
if (!{{# def.checkFormat }}) {
|
||||||
|
{{?}}
|
||||||
|
{{?}}
|
||||||
|
{{# def.error:'format' }}
|
||||||
|
} {{? $breakOnError }} else { {{?}}
|
73
node_modules/ajv/lib/dot/if.jst
generated
vendored
Normal file
73
node_modules/ajv/lib/dot/if.jst
generated
vendored
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
{{# def.definitions }}
|
||||||
|
{{# def.errors }}
|
||||||
|
{{# def.setupKeyword }}
|
||||||
|
{{# def.setupNextLevel }}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.validateIfClause:_clause:
|
||||||
|
{{
|
||||||
|
$it.schema = it.schema['_clause'];
|
||||||
|
$it.schemaPath = it.schemaPath + '._clause';
|
||||||
|
$it.errSchemaPath = it.errSchemaPath + '/_clause';
|
||||||
|
}}
|
||||||
|
{{# def.insertSubschemaCode }}
|
||||||
|
{{=$valid}} = {{=$nextValid}};
|
||||||
|
{{? $thenPresent && $elsePresent }}
|
||||||
|
{{ $ifClause = 'ifClause' + $lvl; }}
|
||||||
|
var {{=$ifClause}} = '_clause';
|
||||||
|
{{??}}
|
||||||
|
{{ $ifClause = '\'_clause\''; }}
|
||||||
|
{{?}}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
{{
|
||||||
|
var $thenSch = it.schema['then']
|
||||||
|
, $elseSch = it.schema['else']
|
||||||
|
, $thenPresent = $thenSch !== undefined && {{# def.nonEmptySchema:$thenSch }}
|
||||||
|
, $elsePresent = $elseSch !== undefined && {{# def.nonEmptySchema:$elseSch }}
|
||||||
|
, $currentBaseId = $it.baseId;
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{? $thenPresent || $elsePresent }}
|
||||||
|
{{
|
||||||
|
var $ifClause;
|
||||||
|
$it.createErrors = false;
|
||||||
|
$it.schema = $schema;
|
||||||
|
$it.schemaPath = $schemaPath;
|
||||||
|
$it.errSchemaPath = $errSchemaPath;
|
||||||
|
}}
|
||||||
|
var {{=$errs}} = errors;
|
||||||
|
var {{=$valid}} = true;
|
||||||
|
|
||||||
|
{{# def.setCompositeRule }}
|
||||||
|
{{# def.insertSubschemaCode }}
|
||||||
|
{{ $it.createErrors = true; }}
|
||||||
|
{{# def.resetErrors }}
|
||||||
|
{{# def.resetCompositeRule }}
|
||||||
|
|
||||||
|
{{? $thenPresent }}
|
||||||
|
if ({{=$nextValid}}) {
|
||||||
|
{{# def.validateIfClause:then }}
|
||||||
|
}
|
||||||
|
{{? $elsePresent }}
|
||||||
|
else {
|
||||||
|
{{?}}
|
||||||
|
{{??}}
|
||||||
|
if (!{{=$nextValid}}) {
|
||||||
|
{{?}}
|
||||||
|
|
||||||
|
{{? $elsePresent }}
|
||||||
|
{{# def.validateIfClause:else }}
|
||||||
|
}
|
||||||
|
{{?}}
|
||||||
|
|
||||||
|
if (!{{=$valid}}) {
|
||||||
|
{{# def.extraError:'if' }}
|
||||||
|
}
|
||||||
|
{{? $breakOnError }} else { {{?}}
|
||||||
|
{{??}}
|
||||||
|
{{? $breakOnError }}
|
||||||
|
if (true) {
|
||||||
|
{{?}}
|
||||||
|
{{?}}
|
||||||
|
|
98
node_modules/ajv/lib/dot/items.jst
generated
vendored
Normal file
98
node_modules/ajv/lib/dot/items.jst
generated
vendored
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
{{# def.definitions }}
|
||||||
|
{{# def.errors }}
|
||||||
|
{{# def.setupKeyword }}
|
||||||
|
{{# def.setupNextLevel }}
|
||||||
|
|
||||||
|
|
||||||
|
{{## def.validateItems:startFrom:
|
||||||
|
for (var {{=$idx}} = {{=startFrom}}; {{=$idx}} < {{=$data}}.length; {{=$idx}}++) {
|
||||||
|
{{
|
||||||
|
$it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
|
||||||
|
var $passData = $data + '[' + $idx + ']';
|
||||||
|
$it.dataPathArr[$dataNxt] = $idx;
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{# def.generateSubschemaCode }}
|
||||||
|
{{# def.optimizeValidate }}
|
||||||
|
|
||||||
|
{{? $breakOnError }}
|
||||||
|
if (!{{=$nextValid}}) break;
|
||||||
|
{{?}}
|
||||||
|
}
|
||||||
|
#}}
|
||||||
|
|
||||||
|
{{
|
||||||
|
var $idx = 'i' + $lvl
|
||||||
|
, $dataNxt = $it.dataLevel = it.dataLevel + 1
|
||||||
|
, $nextData = 'data' + $dataNxt
|
||||||
|
, $currentBaseId = it.baseId;
|
||||||
|
}}
|
||||||
|
|
||||||
|
var {{=$errs}} = errors;
|
||||||
|
var {{=$valid}};
|
||||||
|
|
||||||
|
{{? Array.isArray($schema) }}
|
||||||
|
{{ /* 'items' is an array of schemas */}}
|
||||||
|
{{ var $additionalItems = it.schema.additionalItems; }}
|
||||||
|
{{? $additionalItems === false }}
|
||||||
|
{{=$valid}} = {{=$data}}.length <= {{= $schema.length }};
|
||||||
|
{{
|
||||||
|
var $currErrSchemaPath = $errSchemaPath;
|
||||||
|
$errSchemaPath = it.errSchemaPath + '/additionalItems';
|
||||||
|
}}
|
||||||
|
{{# def.checkError:'additionalItems' }}
|
||||||
|
{{ $errSchemaPath = $currErrSchemaPath; }}
|
||||||
|
{{# def.elseIfValid}}
|
||||||
|
{{?}}
|
||||||
|
|
||||||
|
{{~ $schema:$sch:$i }}
|
||||||
|
{{? {{# def.nonEmptySchema:$sch }} }}
|
||||||
|
{{=$nextValid}} = true;
|
||||||
|
|
||||||
|
if ({{=$data}}.length > {{=$i}}) {
|
||||||
|
{{
|
||||||
|
var $passData = $data + '[' + $i + ']';
|
||||||
|
$it.schema = $sch;
|
||||||
|
$it.schemaPath = $schemaPath + '[' + $i + ']';
|
||||||
|
$it.errSchemaPath = $errSchemaPath + '/' + $i;
|
||||||
|
$it.errorPath = it.util.getPathExpr(it.errorPath, $i, it.opts.jsonPointers, true);
|
||||||
|
$it.dataPathArr[$dataNxt] = $i;
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{# def.generateSubschemaCode }}
|
||||||
|
{{# def.optimizeValidate }}
|
||||||
|
}
|
||||||
|
|
||||||
|
{{# def.ifResultValid }}
|
||||||
|
{{?}}
|
||||||
|
{{~}}
|
||||||
|
|
||||||
|
{{? typeof $additionalItems == 'object' && {{# def.nonEmptySchema:$additionalItems }} }}
|
||||||
|
{{
|
||||||
|
$it.schema = $additionalItems;
|
||||||
|
$it.schemaPath = it.schemaPath + '.additionalItems';
|
||||||
|
$it.errSchemaPath = it.errSchemaPath + '/additionalItems';
|
||||||
|
}}
|
||||||
|
{{=$nextValid}} = true;
|
||||||
|
|
||||||
|
if ({{=$data}}.length > {{= $schema.length }}) {
|
||||||
|
{{# def.validateItems: $schema.length }}
|
||||||
|
}
|
||||||
|
|
||||||
|
{{# def.ifResultValid }}
|
||||||
|
{{?}}
|
||||||
|
|
||||||
|
{{?? {{# def.nonEmptySchema:$schema }} }}
|
||||||
|
{{ /* 'items' is a single schema */}}
|
||||||
|
{{
|
||||||
|
$it.schema = $schema;
|
||||||
|
$it.schemaPath = $schemaPath;
|
||||||
|
$it.errSchemaPath = $errSchemaPath;
|
||||||
|
}}
|
||||||
|
{{# def.validateItems: 0 }}
|
||||||
|
{{?}}
|
||||||
|
|
||||||
|
{{? $breakOnError }}
|
||||||
|
{{= $closingBraces }}
|
||||||
|
if ({{=$errs}} == errors) {
|
||||||
|
{{?}}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user