Initial commit
This commit is contained in:
0
.gitignore
vendored
Normal file
0
.gitignore
vendored
Normal file
17
.vscode/launch.json
vendored
Normal file
17
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Launch Program",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"program": "${workspaceFolder}\\app.js",
|
||||
}
|
||||
]
|
||||
}
|
||||
165
app.js
Normal file
165
app.js
Normal file
@@ -0,0 +1,165 @@
|
||||
|
||||
const assert = require('assert');
|
||||
const moment = require('moment');
|
||||
const cbor = require('cbor');
|
||||
const express = require('express');
|
||||
const fs = require('fs');
|
||||
const http = require('http');
|
||||
const https = require('https');
|
||||
|
||||
const certificate = fs.readFileSync(process.env.CLIENT_CRT || 'cert/client.crt', 'utf8');
|
||||
const privateKey = fs.readFileSync(process.env.CLIENT_KEY || 'cert/client.key', 'utf8');
|
||||
|
||||
const credentials = {
|
||||
key: privateKey,
|
||||
cert: certificate,
|
||||
minVersion: process.env.MIN_TLS_VERSION || "TLSv1.1"
|
||||
};
|
||||
|
||||
const dbcontroller = require('./db');
|
||||
const routes = require('./routes')
|
||||
|
||||
const app = express();
|
||||
const http_port = parseInt(process.env.HTTP_PORT, 10) || 80;
|
||||
const https_port = parseInt(process.env.HTTPS_PORT, 10) || 443;
|
||||
const environment = process.env.CONFIGURATION || 'develop';
|
||||
|
||||
const httpServer = http.createServer(app);
|
||||
const httpsServer = https.createServer(credentials, app);
|
||||
|
||||
///// Splashscreen
|
||||
console.log(' _ __ __ _ ');
|
||||
console.log(' / | / /___ / /(_)_____ _____ ___ ____ ');
|
||||
console.log(' / |/ // _ \\ / // // ___// ___// _ \\ / __ \\');
|
||||
console.log(' / /| // __// // /(__ )(__ )/ __// / / /');
|
||||
console.log('/_/ |_/ \\___//_//_//____//____/ \\___//_/ /_/ ');
|
||||
console.log(' ');
|
||||
console.log(' T E C H N O L O G I E S');
|
||||
console.log('');
|
||||
console.log('');
|
||||
|
||||
///// Startup MongoDB Client
|
||||
dbcontroller.init()
|
||||
.then((err) => {
|
||||
if (err) { console.log('Unable to connect to database'); }
|
||||
else {
|
||||
console.log('-------------------------------------------------------');
|
||||
console.log(Date().toString());
|
||||
console.log('MongoDB Client initialized');
|
||||
console.log('-------------------------------------------------------');
|
||||
|
||||
///// Startup HTTP Server
|
||||
httpServer.listen(http_port, () => {
|
||||
console.log('-------------------------------------------------------');
|
||||
console.log(`Server listening at http://localhost:${http_port}`);
|
||||
console.log('Environment: ' + environment);
|
||||
console.log('HTTP Port: ' + http_port);
|
||||
console.log('-------------------------------------------------------');
|
||||
});
|
||||
|
||||
///// Startup HTTPS Server
|
||||
httpsServer.listen(https_port, () => {
|
||||
console.log('-------------------------------------------------------');
|
||||
console.log(`Server listening at https://localhost:${https_port}`);
|
||||
console.log('Environment: ' + environment);
|
||||
console.log('HTTPS Port: ' + https_port);
|
||||
console.log('-------------------------------------------------------');
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
app.use(express.json());
|
||||
app.use(express.raw({ type: 'application/cbor' }));
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
// Log request
|
||||
console.log('-------------------------------------------------------');
|
||||
console.log(req.method + ' ' + req.url + ' from ' + req.ip);
|
||||
next();
|
||||
});
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
if (!req.body.length) {
|
||||
// No body
|
||||
//////////
|
||||
console.log('Got empty frame');
|
||||
|
||||
///// Next handler
|
||||
next();
|
||||
|
||||
} else if (req.is('application/cbor')) {
|
||||
// CBOR frame
|
||||
/////////////
|
||||
console.log('Got CBOR frame');
|
||||
console.log('Encoded:');
|
||||
console.log(req.body.toString('hex'))
|
||||
///// Decode CBOR body
|
||||
cbor.decodeFirst(req.body, (err, decoded) => {
|
||||
///// Assign decoded data
|
||||
req.body = decoded;
|
||||
|
||||
///// Next handler
|
||||
console.log('Decoded:');
|
||||
console.log(req.body)
|
||||
next();
|
||||
});
|
||||
|
||||
} else {
|
||||
// JSON frame
|
||||
/////////////
|
||||
console.log('Got JSON frame');
|
||||
console.log(req.body)
|
||||
|
||||
///// Next handler
|
||||
next();
|
||||
}
|
||||
});
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
var length = 0;
|
||||
var send = res.send;
|
||||
|
||||
/////////////////////////
|
||||
// Redefine send function
|
||||
res.send = function (body) {
|
||||
if (req.is('application/cbor') || req.acceptsEncodings("application/cbor") || req.acceptsEncodings("cbor")) {
|
||||
// CBOR Frame
|
||||
/////////////
|
||||
console.log('Send CBOR frame');
|
||||
console.log('Decoded:');
|
||||
console.log(body)
|
||||
|
||||
///// Set header
|
||||
res.set('Content-Type', 'application/cbor');
|
||||
length = JSON.stringify(body).length;
|
||||
|
||||
///// Convert ' to "
|
||||
if (body.data) { body.data = cbor.encode(JSON.parse(body.data.replace(/'/g, '"'))); }
|
||||
|
||||
///// Encode JSON to CBOR
|
||||
body = cbor.encode(body);
|
||||
|
||||
// Log statistics
|
||||
console.log('Encoded:');
|
||||
console.log(body.toString('hex'))
|
||||
console.log(length + ' Bytes (JSON) -> ' + body.length + ' Bytes (CBOR) -> ' + Math.round((1 - length / body.length) * 100) + '% reduction');
|
||||
}
|
||||
|
||||
///// Send frame
|
||||
send.call(this, body);
|
||||
};
|
||||
|
||||
///// Next handler
|
||||
next();
|
||||
});
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
// Add formatted-date header
|
||||
res.setHeader("Formatted-Date", moment().format());
|
||||
next();
|
||||
});
|
||||
|
||||
app.use(routes)
|
||||
|
||||
|
||||
22
cert/client.config
Normal file
22
cert/client.config
Normal file
@@ -0,0 +1,22 @@
|
||||
[ req ]
|
||||
distinguished_name = dn
|
||||
req_extensions = v3_req
|
||||
prompt = no
|
||||
|
||||
[ dn ]
|
||||
CN = arnaudne.synology.me
|
||||
emailAddress = email@me.com
|
||||
O = ANELISSEN
|
||||
OU = Herault
|
||||
L = Montpellier
|
||||
ST = Occitanie
|
||||
C = FR
|
||||
|
||||
[v3_req]
|
||||
extendedKeyUsage = serverAuth
|
||||
subjectAltName = @alt_names
|
||||
|
||||
[alt_names]
|
||||
DNS.1 = arnaudne.synology.me
|
||||
DNS.2 = anelissen.ddns.net
|
||||
DNS.3 = localhost
|
||||
24
cert/client.crt
Normal file
24
cert/client.crt
Normal file
@@ -0,0 +1,24 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEGTCCAwGgAwIBAgIUHE0L4CSPMl27voe/B5pDqk6tf2gwDQYJKoZIhvcNAQEL
|
||||
BQAwgZkxHTAbBgNVBAMMFGFybmF1ZG5lLnN5bm9sb2d5Lm1lMRswGQYJKoZIhvcN
|
||||
AQkBFgxlbWFpbEBtZS5jb20xEjAQBgNVBAoMCUFORUxJU1NFTjEQMA4GA1UECwwH
|
||||
SGVyYXVsdDEUMBIGA1UEBwwLTW9udHBlbGxpZXIxEjAQBgNVBAgMCU9jY2l0YW5p
|
||||
ZTELMAkGA1UEBhMCRlIwHhcNMjEwNzIxMTcxOTA4WhcNNDgxMjA1MTcxOTA4WjCB
|
||||
mTEdMBsGA1UEAwwUYXJuYXVkbmUuc3lub2xvZ3kubWUxGzAZBgkqhkiG9w0BCQEW
|
||||
DGVtYWlsQG1lLmNvbTESMBAGA1UECgwJQU5FTElTU0VOMRAwDgYDVQQLDAdIZXJh
|
||||
dWx0MRQwEgYDVQQHDAtNb250cGVsbGllcjESMBAGA1UECAwJT2NjaXRhbmllMQsw
|
||||
CQYDVQQGEwJGUjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALkhOtny
|
||||
2ck90kJ4+zqJJNoPIHUlI3pSWyoo6aFd3HP9EF7d65HZ8+QEKnuqllfunYP4/uED
|
||||
j8ivlOUrrZzXinJaYuBKkf3ljjBacdTTRhVpeyat3lRGd/citiYSsR8r0ky6uje3
|
||||
1kEZy9lbAsv4Pw+337Q3lB3mm6d0HzZRt6jDRFKgdksKU+oVUXlI4t6+fmTWHQEE
|
||||
fzCWghjEEHZRIpeiYMkPzK58iiltM5fL887KnalI/LKttqnlC3mGUiOGbhJnxr3t
|
||||
HGeAVoXGTa8+TPo0DSpXCaqClElY/eMYYh8Y5ZsmhjzwtpoCLmVd6uoiasGm9ZUS
|
||||
o4bLEJTa+zkmVlMCAwEAAaNXMFUwEwYDVR0lBAwwCgYIKwYBBQUHAwEwPgYDVR0R
|
||||
BDcwNYIUYXJuYXVkbmUuc3lub2xvZ3kubWWCEmFuZWxpc3Nlbi5kZG5zLm5ldIIJ
|
||||
bG9jYWxob3N0MA0GCSqGSIb3DQEBCwUAA4IBAQBG5G6KQIf8TnCGUjToKlnXrjdb
|
||||
tKZD6+xZEBsxCaiLQQMqghmi7D/mjEICUPBW2dBIhJUitsJo9xAi7fT0T3T0NyVK
|
||||
hghowgNpMAHIwKSdPg2Hhwhx23nmVyqiOfg6LBo8y0MEPW/4lU6wx2W+ErrVW6/D
|
||||
6NBWb+NPn8hJ2o+wcL9ZWskwJigschzTbyMYtzafGHsvAGByMzgfIlTsbXsmUL3d
|
||||
RAb1UOEP7fwGgUEgoxoMWSP0D6qzX/UjPRJXGVOg3x/RoCXb9pbrrnRzj7INOrzE
|
||||
yDWMnTYubu9jSMdx8nPnMNY3MPRQtofs0PiIp/OJMKQPORPXs0UTv6mceGwI
|
||||
-----END CERTIFICATE-----
|
||||
27
cert/client.key
Normal file
27
cert/client.key
Normal file
@@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEowIBAAKCAQEAuSE62fLZyT3SQnj7Ookk2g8gdSUjelJbKijpoV3cc/0QXt3r
|
||||
kdnz5AQqe6qWV+6dg/j+4QOPyK+U5SutnNeKclpi4EqR/eWOMFpx1NNGFWl7Jq3e
|
||||
VEZ39yK2JhKxHyvSTLq6N7fWQRnL2VsCy/g/D7fftDeUHeabp3QfNlG3qMNEUqB2
|
||||
SwpT6hVReUji3r5+ZNYdAQR/MJaCGMQQdlEil6JgyQ/MrnyKKW0zl8vzzsqdqUj8
|
||||
sq22qeULeYZSI4ZuEmfGve0cZ4BWhcZNrz5M+jQNKlcJqoKUSVj94xhiHxjlmyaG
|
||||
PPC2mgIuZV3q6iJqwab1lRKjhssQlNr7OSZWUwIDAQABAoIBAEJYrV20keZ0OGlI
|
||||
MEkPI1zetPQmpitNXoyicvA40ivjUr2c7LKtmKFr+MmvHghPZLYKQ1Xiz+HNQyBK
|
||||
YgLmoCBRUkQtlVqXrTiZAViTivdbgR4gi6BKTO4Ny5ejdUTFkK2c8eXMBYX5N7wi
|
||||
yMLOqdL5Q7uze2qn3brKe/EcoiRhkaqjaPBBDCLIp9HHhVeC2PA7iurqnkFT7bBv
|
||||
z7bIh2M8dOJ2M9fFJZKuz2Q9Awh1NEcSYsm4wbVPPodBBZeyznEZ1cx4I5oxu4hE
|
||||
Of1UW+QdcpeMyxa2hl/VwtzKX9S3tk6+nlQLNlkZ/TYD+NyzVlQ/YRumUAqpfl45
|
||||
u1vjxekCgYEA8ix1Xf07LDUw4b7muaLK0KMRogk5Rw+0VOru/QGkKtrJBRuZKmvm
|
||||
3X/COo7oGSbLcJpUkVUYXhYK2TR3RYZiICUnsJ6zz5sl+8qQSULoGJioiwzt74aD
|
||||
dJ9ZBqDy5+ckvxJ1Xdx2ByN4EtKFtIn+owJFWGW902XawuaZbtb5KKUCgYEAw7MI
|
||||
14q6PAO1vyYnysnUnB7SzQP2f/f2147ui/0MpJkGC5wT2NW9rCQ1WpjQxBEqNfBJ
|
||||
bWF9jCHU5qG173iiccmglQMobTMDWHQJ+BFdTwwcHfgNot8EVTA0qz/HUcpwZTOy
|
||||
h8ChSaVh6tSRRJed5kr8tkwfoxHemiJFUv12WZcCgYBjvcvZGiL04jNvxqBgdJvz
|
||||
sjXg9suQaPdswhYMPlDPFa0VXXiH8Ej1kVj9pT4SndfMWMPb16Bhn9J4AxPcnqxr
|
||||
cOIX7EVCjDPosFUc12GgP7+rBXg53rzlm3ufL0rcGGcaCxAryFEUP5eEqRBIe01U
|
||||
9ep5re2w05J2E2O+MuwLwQKBgHrWuXkaQjYDmiSG3bljoQnyKx23HBZNXmsF8+R5
|
||||
DWOQDgRhju+vkqQoAjmA7KH1qEo9LsnyxOyeG9Y8sUfEsCq+hgai+dA5kiMGi29j
|
||||
7u78SfXhyyVt2XljjdvkZ8eGS7Cql6iwmEzy+5h8n0av6NQyQ5hmBgHE6LZVRrCG
|
||||
GrC3AoGBAMfdhTSKrt5T0IRKJr3xRqZxgVwtT2u1OAHtMSTBjqjPgi0w3S0EgVzU
|
||||
QrzasZt0grhB53MybpCN1OC2lqoNCaTU89ORYZ4D9Pwkf+i2e7doTDaDktBWULEz
|
||||
ssTZCb+DEVTBaAKuQ5zrUgmBYNM5xiaZyss21TWBgVc3rZaSB4V3
|
||||
-----END RSA PRIVATE KEY-----
|
||||
8
cert/generate_cert.sh
Normal file
8
cert/generate_cert.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
openssl genrsa -out client.key
|
||||
openssl req -new -config client.config -key client.key -out client.csr
|
||||
openssl x509 -req -days 9999 -extfile client.config -extensions v3_req -in client.csr -signkey client.key -out client.crt
|
||||
rm client.csr
|
||||
|
||||
openssl x509 -in client.crt -text -noout
|
||||
cat client.crt
|
||||
27
cert/key.pem
Normal file
27
cert/key.pem
Normal file
@@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEogIBAAKCAQEAtcC8h66MMOc0oJERcfYQFJ3yXtMULCDxv7t1UqhvBDdAoGCX
|
||||
UCxmiDYjvvkh2Lrowb1qirxJJrkpZj/UjqtQWzA0f0zFV3svvvTE2Hrmu1UwTamn
|
||||
k51Dl0D7ypPX6Wms2qb227KrRMWSwxp996EfKK4TgAvxlpzsr7xwMYH3hH63B586
|
||||
ALA04wMaSjpf/64EDYnJIo8YDb0K/x6iNVUO62tlERNZB3YtWyJBC/0mIsJyaxCF
|
||||
vyK85D106phhKezNCftn8uZ4sdys3xKCpLtxcvPQTPaKKPRAHB6FgA01bjtQKqiW
|
||||
p45Zo0YdCFXq0cjZe9wW46LCvLkzMXka+S0mcQIDAQABAoIBABhYwCiAxkDKx+72
|
||||
X9rfNlo8qjnvlpUuuJORfe7bpztuV1bkeYCA4h8++VzcrJ8GsqU5RWteO4JXbWdI
|
||||
B6Yw5qvAclfXJdxJISU4TqIdHIldqQHORydr+qDpUJFbaqHWyRPlJ85YSb8FpFpE
|
||||
Uzl3uN/PKceOUgd17/K+kFzhZxG1We5iNdJ5l7QLzUg4mn0Snu7xIkcXv74Gr3kx
|
||||
mOZPgP1+DZX87vSvEF2+84Id6EwJB4o4fi4QtAMmg66GyDkQrTJq/FJD8sAyfVIX
|
||||
YQs1KVaD/H6vMtRcFp2wB//bIhIiaBqeud0KTYNjVGccNx9cHTIwZIw8GltMfUJe
|
||||
E7Xf8v0CgYEA2ZUk7Hez2xwSc5y8JoMkOtwx4w4Ei++urdmxCs585r2dnZ3py1UA
|
||||
iQpdS/9oM5uMqf64mxvySHiBvyG0lraakLfKvQ0/gW/OOLXwXjoW0+1gQhY9qErT
|
||||
VaecwUnlpFTsiBQISFH1bINkmRKHTT+ca2uaFhvwY7OMIB8oligROssCgYEA1dgR
|
||||
nFYASDunn6Y8RaBufdNba7dX7fUaMD4YhwueWiGGp4SVzIUdSLpZqxic7N9pPAIU
|
||||
5OBmi5Qa7IwEsPCCmvGxVM7XQVJKtqEyJb2oL6eJ9h9JPa2FOolPAdS5uKlvJI43
|
||||
5bacB8HQUR7gTyRCwCuuQSXsrMuQftpYgas9UDMCgYAi06aXWwmk1rd1Xe8X0wHn
|
||||
kftCNqovo+u31BJsgmSnok4qPm5/p1lwlgIc+gK5z/oR872kxjJfuzo5V7HKNexD
|
||||
oceHvykdFMJTfXu9+VpSDbrMmTbBS0jMewmyPpvNU/KQTXSN7uBzwAxIHBkgGkB1
|
||||
SUHerBYsPz78nUAn2L35RQKBgBAKaSfE+7hvYR+EpLjEVAV0OUNXOW1MGW7M+aIH
|
||||
qRUxtpwSQfpZcdzmvZsr+Xl7OLWbol2Yx5hov6xGxINRRzrALoEiEtt/hMM2TECw
|
||||
fVE1zA9+QUwzG+9MJXUJs/S6IPApCuBcVk/upeWv3zuQiMFJhYS1h49epbQeRM1V
|
||||
PwApAoGAZ651jEj/Yyg+9FNthQbdxZ+PIgjz0HoggNzQoCR+AgLQ4UFYvxec97la
|
||||
ta7c7EWYdPHvrlNaD9+RF6NucNMncNmEEQtEFbQRQRsc5bu3nf4pE5vtLinP9KFb
|
||||
N1j5mZju/KZRt8Z21YN6cUxiH+lYquqgTKGAU2b4AOdTqs9Ke1M=
|
||||
-----END RSA PRIVATE KEY-----
|
||||
0
config/index.js
Normal file
0
config/index.js
Normal file
18
controllers/data.controller.js
Normal file
18
controllers/data.controller.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const services = require('../services')
|
||||
|
||||
const { data } = services
|
||||
|
||||
const postSetData = async (req, res, next) => {
|
||||
try {
|
||||
var values = { data: req.body.data, msn: req.body.msn, id: req.params.id }
|
||||
const code = await data.createData(values)
|
||||
res.send(code)
|
||||
} catch (e) {
|
||||
console.log(e.message)
|
||||
res.sendStatus(500)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
postSetData,
|
||||
}
|
||||
30
controllers/firmware.controller.js
Normal file
30
controllers/firmware.controller.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const services = require('../services')
|
||||
|
||||
const { firmware } = services
|
||||
|
||||
const postLookFirmware = async (req, res, next) => {
|
||||
const { serialNumber, hash, version, type, hardwareIndex, hardwareVersion } = req.body
|
||||
try {
|
||||
const obj = await firmware.lookFirmware(serialNumber, hash, version, type, hardwareIndex, hardwareVersion)
|
||||
res.send(obj)
|
||||
} catch (e) {
|
||||
console.log(e.message)
|
||||
res.sendStatus(500)
|
||||
}
|
||||
}
|
||||
|
||||
const postSyncFirmware = async (req, res, next) => {
|
||||
const { serialNumber, hash, version, type, hardwareIndex, hardwareVersion } = req.body
|
||||
try {
|
||||
const obj = await firmware.syncFirmware(serialNumber, hash, version, type, hardwareIndex, hardwareVersion)
|
||||
res.send(obj)
|
||||
} catch (e) {
|
||||
console.log(e.message)
|
||||
res.sendStatus(500)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
postLookFirmware,
|
||||
postSyncFirmware
|
||||
}
|
||||
67
controllers/grtd.controller.js
Normal file
67
controllers/grtd.controller.js
Normal file
@@ -0,0 +1,67 @@
|
||||
const services = require('../services')
|
||||
|
||||
const { device } = services
|
||||
|
||||
const postGetRequestToDo = async (req, res, next) => {
|
||||
///// Emit event to server
|
||||
try {
|
||||
await device.postRequestToDo(req.body.relayMsn, req.body);
|
||||
await device.getRequestToDo(req.body.relayMsn);
|
||||
var response = { todo: [{ serialNumber: req.body.relayMsn, configuration: 1 }] };
|
||||
console.log(req.body);
|
||||
res.send(response);
|
||||
} catch (error) {
|
||||
res.send(500);
|
||||
}
|
||||
}
|
||||
|
||||
const getModuleConfiguration = async (req, res, next) => {
|
||||
///// Emit event to server
|
||||
var response = {
|
||||
"name": "LRBST-R-TARACE",
|
||||
"inventory": [
|
||||
"7400040670330001"
|
||||
],
|
||||
"wakeUpTimes": [
|
||||
60,
|
||||
480,
|
||||
540,
|
||||
600,
|
||||
660,
|
||||
720,
|
||||
780,
|
||||
840,
|
||||
900,
|
||||
960,
|
||||
1020,
|
||||
1080
|
||||
]
|
||||
};
|
||||
|
||||
res.send(response);
|
||||
}
|
||||
|
||||
const setModuleConfiguration = async (req, res, next) => {
|
||||
|
||||
}
|
||||
|
||||
const getModulePrograms = async (req, res, next) => {
|
||||
|
||||
}
|
||||
|
||||
const setModulePrograms = async (req, res, next) => {
|
||||
|
||||
}
|
||||
|
||||
const reportModuleDataSent = async (req, res, next) => {
|
||||
res.send(200);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
postGetRequestToDo,
|
||||
getModuleConfiguration,
|
||||
setModuleConfiguration,
|
||||
getModulePrograms,
|
||||
setModulePrograms,
|
||||
reportModuleDataSent,
|
||||
}
|
||||
17
controllers/index.js
Normal file
17
controllers/index.js
Normal file
@@ -0,0 +1,17 @@
|
||||
const status = require('./status.controller')
|
||||
const data = require('./data.controller')
|
||||
const firmware = require('./firmware.controller')
|
||||
const ipx = require('./ipx.controller')
|
||||
const journal = require('./journal.controller')
|
||||
const longpolling = require('./longpolling.controller')
|
||||
const grtd = require('./grtd.controller')
|
||||
|
||||
module.exports = {
|
||||
status,
|
||||
data,
|
||||
firmware,
|
||||
ipx,
|
||||
journal,
|
||||
longpolling,
|
||||
grtd,
|
||||
}
|
||||
18
controllers/ipx.controller.js
Normal file
18
controllers/ipx.controller.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const services = require('../services')
|
||||
|
||||
const { ipx } = services
|
||||
|
||||
const postIpxData = async (req, res, next) => {
|
||||
try {
|
||||
var values = { ipxModules: req.body.ipxModules, id: req.params.id }
|
||||
const code = await ipx.createIpxData(values)
|
||||
res.send(code)
|
||||
} catch (e) {
|
||||
console.log(e.message)
|
||||
res.sendStatus(500)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
postIpxData,
|
||||
}
|
||||
18
controllers/journal.controller.js
Normal file
18
controllers/journal.controller.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const services = require('../services')
|
||||
|
||||
const { journal } = services
|
||||
|
||||
const postSetJournal = async (req, res, next) => {
|
||||
try {
|
||||
var values = { events: req.body.events, msn: req.body.msn, id: req.params.id }
|
||||
const code = await journal.createEvents(values)
|
||||
res.send(code)
|
||||
} catch (e) {
|
||||
console.log(e.message)
|
||||
res.sendStatus(500)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
postSetJournal,
|
||||
}
|
||||
109
controllers/longpolling.controller.js
Normal file
109
controllers/longpolling.controller.js
Normal file
@@ -0,0 +1,109 @@
|
||||
const services = require('../services')
|
||||
const events = require('events');
|
||||
const random_bytes = require('random-bytes');
|
||||
|
||||
const emitter = new events.EventEmitter();
|
||||
|
||||
const { longpolling } = services
|
||||
|
||||
const poll_server_timeout = 20000;
|
||||
const poll_client_timeout = 60000;
|
||||
|
||||
poll_request_event_identifier = function (id) { return ('poll-request-' + id).toLowerCase(); }
|
||||
poll_response_event_identifier = function (qid) { return ('poll-response-' + qid).toLowerCase(); }
|
||||
|
||||
poll_request = function (method, action, id, device, data, callback) {
|
||||
function request_listener(message) {
|
||||
///// Stop timeout
|
||||
clearTimeout(timeout);
|
||||
callback(null, message);
|
||||
};
|
||||
|
||||
///// Create object
|
||||
object = {
|
||||
method: method,
|
||||
nsip: device || '',
|
||||
action: action || '/',
|
||||
data: JSON.stringify(data).replace(/"/g, "'") || '{}',
|
||||
qid: random_bytes.sync(16).toString('hex')
|
||||
};
|
||||
|
||||
///// Wait long polling to open
|
||||
emitter.emit(poll_request_event_identifier(id), object);
|
||||
|
||||
///// Start timeout
|
||||
var timeout = setTimeout(() => {
|
||||
///// Remove listener
|
||||
emitter.removeListener(poll_response_event_identifier(object.qid), request_listener);
|
||||
|
||||
///// Send timeout
|
||||
console.log(id + ' did not long poll (' + object.qid + ')');
|
||||
callback('timeout', null);
|
||||
}, poll_client_timeout);
|
||||
|
||||
///// Listen for event
|
||||
emitter.once(poll_response_event_identifier(object.qid), request_listener);
|
||||
}
|
||||
|
||||
const postPeriodic = async (req, res, next) => {
|
||||
function listener(message) {
|
||||
///// Stop timeout
|
||||
clearTimeout(timeout);
|
||||
|
||||
///// Send response
|
||||
res.send(message);
|
||||
};
|
||||
|
||||
///// Start timeout
|
||||
var timeout = setTimeout(() => {
|
||||
///// Remove listener
|
||||
emitter.removeListener(poll_request_event_identifier(req.params.id), listener);
|
||||
|
||||
///// Send timeout
|
||||
res.sendStatus(408);
|
||||
console.log('Sending timeout to client ' + req.ip + ' (' + req.params.id + ')');
|
||||
}, poll_server_timeout);
|
||||
|
||||
///// Listen for event
|
||||
emitter.once(poll_request_event_identifier(req.params.id), listener);
|
||||
}
|
||||
|
||||
const postResponse = async (req, res, next) => {
|
||||
///// Emit event to client
|
||||
emitter.emit(poll_response_event_identifier(req.params.qid), req.body);
|
||||
|
||||
///// Response OK
|
||||
res.sendStatus(200);
|
||||
}
|
||||
|
||||
const getModuleRequest = async (req, res, next) => {
|
||||
///// Emit event to server
|
||||
url_encoded = req.query;
|
||||
poll_request(req.method, req.params.route, req.params.id, req.params.module, url_encoded, (error, body) => {
|
||||
if (error) { res.send(error); }
|
||||
else { res.send(body); }
|
||||
});
|
||||
|
||||
req.on("close", function () {
|
||||
console.log("Request cancelled by client");
|
||||
});
|
||||
}
|
||||
|
||||
const postModuleRequest = async (req, res, next) => {
|
||||
///// Emit event to server
|
||||
poll_request(req.method, req.params.route, req.params.id, req.params.module, req.body, (error, body) => {
|
||||
if (error) { res.send(error); }
|
||||
else { res.send(body); }
|
||||
});
|
||||
|
||||
req.on("close", function () {
|
||||
console.log("Request cancelled by client");
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
postPeriodic,
|
||||
postResponse,
|
||||
getModuleRequest,
|
||||
postModuleRequest
|
||||
}
|
||||
27
controllers/status.controller.js
Normal file
27
controllers/status.controller.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const services = require('../services')
|
||||
|
||||
const { status } = services
|
||||
|
||||
const postSetStatus = async (req, res, next) => {
|
||||
try {
|
||||
var code = 500;
|
||||
|
||||
if (req.body.status) {
|
||||
const values = { inputsAlerts: req.body.status.inputsAlerts || [], msn: req.body.msn, id: req.params.id }
|
||||
code = await status.createAlerts(values)
|
||||
|
||||
} else if (req.body.radioProducts) {
|
||||
for (const product of req.body.radioProducts) {
|
||||
const values = { inputsAlerts: product.inputsAlerts || [], msn: product.msn, id: req.params.id }
|
||||
code = await status.createAlerts(values)
|
||||
}
|
||||
}
|
||||
res.send(code)
|
||||
} catch (e) {
|
||||
res.sendStatus(500)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
postSetStatus,
|
||||
}
|
||||
173
db/dbcontroller.js
Normal file
173
db/dbcontroller.js
Normal file
@@ -0,0 +1,173 @@
|
||||
const MongoClient = require('mongodb').MongoClient;
|
||||
const models = require('../models')
|
||||
|
||||
const mongodb_hostname = process.env.MONGODB_HOST || 'localhost';
|
||||
const mongodb_port = process.env.MONGODB_PORT || 27017;
|
||||
const mongodb_database = process.env.MONGODB_DATABASE || 'lsp';
|
||||
const mongodb_url = 'mongodb://' + mongodb_hostname + ':' + mongodb_port;
|
||||
|
||||
const client = new MongoClient(mongodb_url, { useNewUrlParser: true, useUnifiedTopology: true });
|
||||
|
||||
const bucketMaxSize = 4096;
|
||||
|
||||
var _db;
|
||||
var _devices = MongoClient();
|
||||
var _data;
|
||||
var _ipx_data;
|
||||
var _events;
|
||||
var _alerts;
|
||||
|
||||
var days = function(date) {
|
||||
return new Date((date - date%86400) * 1000);
|
||||
}
|
||||
|
||||
var init = async function () {
|
||||
client.connect(function (err) {
|
||||
if (err) {
|
||||
return { error: "Error connecting to DB: " + err }
|
||||
|
||||
} else {
|
||||
_db = client.db(mongodb_database);
|
||||
_devices = _db.collection('devices');
|
||||
_data = _db.collection('data');
|
||||
_ipx_data = _db.collection('ipx-data');
|
||||
_events = _db.collection('events');
|
||||
_alerts = _db.collection('alerts');
|
||||
|
||||
////////////////////////////
|
||||
// FLUSH DB BY UNCOMMENTING
|
||||
// _devices.remove(function(err, objects){});
|
||||
// _data.remove(function(err, objects){});
|
||||
// _ipx_data.remove(function(err, objects){});
|
||||
// _events.remove(function(err, objects){});
|
||||
// _alerts.remove(function(err, objects){});
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var addData = async function (relay, device, element) {
|
||||
try {
|
||||
const model = await models.data.validateAsync(element);
|
||||
|
||||
await _data.updateOne(
|
||||
{
|
||||
device: device,
|
||||
date: days(element.date),
|
||||
bucketSize: { $lt: bucketMaxSize },
|
||||
},
|
||||
{
|
||||
$addToSet: {
|
||||
data: model
|
||||
},
|
||||
$min: { min: model.value },
|
||||
$max: { max: model.value },
|
||||
$inc: { bucketSize: 1 },
|
||||
},
|
||||
{
|
||||
upsert: true
|
||||
})
|
||||
.then(err => {
|
||||
return err;
|
||||
})
|
||||
} catch (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
var addEvent = async function (relay, device, element) {
|
||||
try {
|
||||
const model = await models.event.validateAsync(element);
|
||||
|
||||
await _events.updateOne(
|
||||
{
|
||||
device: device,
|
||||
date: days(element.date),
|
||||
bucketSize: { $lt: bucketMaxSize },
|
||||
},
|
||||
{
|
||||
$addToSet: {
|
||||
events: model
|
||||
},
|
||||
$min: { first: model.date },
|
||||
$max: { last: model.date },
|
||||
$inc: { bucketSize: 1 },
|
||||
},
|
||||
{
|
||||
upsert: true
|
||||
})
|
||||
.then(err => {
|
||||
return err;
|
||||
})
|
||||
} catch (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
var addAlert = async function (relay, device, element) {
|
||||
try {
|
||||
const model = await models.alert.validateAsync(element);
|
||||
|
||||
await _alerts.updateOne(
|
||||
{
|
||||
device: device,
|
||||
relay: relay,
|
||||
bucketSize: { $lt: bucketMaxSize },
|
||||
},
|
||||
{
|
||||
$addToSet: {
|
||||
alerts: model
|
||||
},
|
||||
$min: { first: model.date },
|
||||
$max: { last: model.date },
|
||||
$inc: { bucketSize: 1 },
|
||||
},
|
||||
{
|
||||
upsert: true
|
||||
})
|
||||
.then(err => {
|
||||
return err;
|
||||
})
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
var addIPXData = async function (relay, device, child, element) {
|
||||
try {
|
||||
const model = await models.ipxdata.validateAsync(element);
|
||||
|
||||
await _ipx_data.updateOne(
|
||||
{
|
||||
device: device,
|
||||
child: child,
|
||||
date: days(element.date),
|
||||
bucketSize: { $lt: bucketMaxSize },
|
||||
},
|
||||
{
|
||||
$addToSet: {
|
||||
data: model
|
||||
},
|
||||
$min: { first: model.date },
|
||||
$max: { last: model.date },
|
||||
$inc: { bucketSize: 1 },
|
||||
},
|
||||
{
|
||||
upsert: true
|
||||
})
|
||||
.then(err => {
|
||||
return err;
|
||||
})
|
||||
} catch (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
exports.init = init
|
||||
|
||||
exports.addData = addData
|
||||
exports.addEvent = addEvent
|
||||
exports.addAlert = addAlert
|
||||
exports.addIPXData = addIPXData
|
||||
3
db/index.js
Normal file
3
db/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
const db = require('./dbcontroller.js');
|
||||
|
||||
module.exports = db;
|
||||
167
db/mongoose_dbcontroller.js
Normal file
167
db/mongoose_dbcontroller.js
Normal file
@@ -0,0 +1,167 @@
|
||||
const Collection = require('mongodb').MongoClient;
|
||||
const mongoose = require('mongoose');
|
||||
|
||||
const mongodb_hostname = process.env.MONGODB_HOST || 'localhost';
|
||||
const mongodb_port = process.env.MONGODB_PORT || 27017;
|
||||
const mongodb_database = process.env.MONGODB_DATABASE || 'lsp';
|
||||
const mongodb_url = 'mongodb://' + mongodb_hostname + ':' + mongodb_port;
|
||||
|
||||
const db = mongoose.connection;
|
||||
|
||||
|
||||
const bucketMaxSize = 1000;
|
||||
|
||||
var _db;
|
||||
var _data = Collection();
|
||||
var _ipx_data;
|
||||
var _events;
|
||||
var _alerts;
|
||||
|
||||
var days = function(date) {
|
||||
const complete = new Date(1000 * date);
|
||||
const days = new Date(complete.toDateString())
|
||||
return days;
|
||||
}
|
||||
|
||||
var init = function (callback) {
|
||||
mongoose.connect(mongodb_url, { useNewUrlParser: true, useUnifiedTopology: true });
|
||||
db.on('error', console.error.bind(console, 'connection error:'));
|
||||
db.once('open', function () {
|
||||
// we're connected!
|
||||
if (callback) callback(null);
|
||||
});
|
||||
// client.connect(function (err) {
|
||||
// if (err) {
|
||||
// if (callback) callback({ error: "Error connecting to DB: " + err })
|
||||
// }
|
||||
// else {
|
||||
// _db = client.db(mongodb_database);
|
||||
// _data = _db.collection('data');
|
||||
// _ipx_data = _db.collection('ipx-data');
|
||||
// _events = _db.collection('events');
|
||||
// _alerts = _db.collection('alerts');
|
||||
|
||||
// ////////////////////////////
|
||||
// // FLUSH DB BY UNCOMMENTING
|
||||
// // _data.remove(function(err, objects){});
|
||||
// // _ipx_data.remove(function(err, objects){});
|
||||
// // _events.remove(function(err, objects){});
|
||||
// // _alerts.remove(function(err, objects){});
|
||||
|
||||
// if (callback) callback(null);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
var addData = function (relay, device, element, callback) {
|
||||
// const query = {
|
||||
// device: device,
|
||||
// date: days(element.date),
|
||||
// bucketSize: { $lt: bucketMaxSize },
|
||||
// };
|
||||
|
||||
// const data = {
|
||||
// index: element.index,
|
||||
// value: element.value,
|
||||
// date: new Date(1000 * element.date)
|
||||
// };
|
||||
|
||||
// const update = {
|
||||
// $push: {
|
||||
// data: data
|
||||
// },
|
||||
// $min: { min: data.value },
|
||||
// $max: { max: data.value },
|
||||
// $inc: { bucketSize: 1 },
|
||||
// };
|
||||
|
||||
// const options = {
|
||||
// upsert: true
|
||||
// };
|
||||
|
||||
// _data.updateOne(query, update, options, function (err, result) {
|
||||
// if (callback) { callback(err, result); }
|
||||
// });
|
||||
}
|
||||
|
||||
var addEvent = function (relay, device, element, callback) {
|
||||
// const query = {
|
||||
// device: device,
|
||||
// day: days(element.date),
|
||||
// bucketSize: { $lt: bucketMaxSize },
|
||||
// };
|
||||
|
||||
// const event = {
|
||||
// index: element.index,
|
||||
// value: element.value,
|
||||
// type: element.type,
|
||||
// date: new Date(1000 * element.date)
|
||||
// };
|
||||
|
||||
// const update = {
|
||||
// $push: {
|
||||
// events: event
|
||||
// },
|
||||
// $min: { first: event.date },
|
||||
// $max: { last: event.date },
|
||||
// $inc: { bucketSize: 1 },
|
||||
// };
|
||||
|
||||
// const options = {
|
||||
// upsert: true
|
||||
// };
|
||||
|
||||
// _events.updateOne(query, update, options, function (err, result) {
|
||||
// if (callback) { callback(err, result); }
|
||||
// });
|
||||
}
|
||||
|
||||
var addAlert = function (relay, device, element, callback) {
|
||||
// const object = {
|
||||
// relay: relay,
|
||||
// device: device,
|
||||
// date: new Date(1000 * element.date),
|
||||
// alert: element.alerts
|
||||
// };
|
||||
|
||||
// _alerts.insertOne(object, function (err, result) {
|
||||
// if (callback) { callback(err, result); }
|
||||
// });
|
||||
}
|
||||
|
||||
var addIPXData = function (relay, device, child, element, callback) {
|
||||
// const query = {
|
||||
// child: child,
|
||||
// date: days(element.timestamp),
|
||||
// bucketSize: { $lt: bucketMaxSize },
|
||||
// };
|
||||
|
||||
// const data = {
|
||||
// date: new Date(1000 * element.timestamp),
|
||||
// tags: element.tags
|
||||
// };
|
||||
|
||||
// const update = {
|
||||
// $push: {
|
||||
// data: data
|
||||
// },
|
||||
// $min: { first: data.date },
|
||||
// $max: { last: data.date },
|
||||
// $inc: { bucketSize: 1 },
|
||||
// };
|
||||
|
||||
// const options = {
|
||||
// upsert: true
|
||||
// };
|
||||
|
||||
// _ipx_data.updateOne(query, update, options, function (err, result) {
|
||||
// if (callback) { callback(err, result); }
|
||||
// });
|
||||
}
|
||||
|
||||
exports.init = init
|
||||
|
||||
exports.addData = addData
|
||||
exports.addEvent = addEvent
|
||||
exports.addAlert = addAlert
|
||||
exports.addIPXData = addIPXData
|
||||
9
models/alert.model.js
Normal file
9
models/alert.model.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const joi = require("joi")
|
||||
|
||||
const AlertSchema = joi.object({
|
||||
type: joi.number().required(),
|
||||
inputs: joi.object().keys().pattern(/^[0-9]?/, joi.array().items(joi.number().optional())).optional(),
|
||||
date: joi.date().timestamp("unix").optional().default(new Date())
|
||||
})
|
||||
|
||||
module.exports = AlertSchema
|
||||
10
models/data.model.js
Normal file
10
models/data.model.js
Normal file
@@ -0,0 +1,10 @@
|
||||
const joi = require("joi")
|
||||
|
||||
const DataSchema = joi.object({
|
||||
input: joi.number().required(),
|
||||
index: joi.number().required(),
|
||||
value: joi.number().required(),
|
||||
date: joi.date().timestamp("unix").required()
|
||||
})
|
||||
|
||||
module.exports = DataSchema
|
||||
10
models/event.model.js
Normal file
10
models/event.model.js
Normal file
@@ -0,0 +1,10 @@
|
||||
const joi = require("joi")
|
||||
|
||||
const EventSchema = joi.object({
|
||||
index: joi.number().required(),
|
||||
type: joi.number().required(),
|
||||
value: joi.string().required(),
|
||||
date: joi.date().timestamp("unix").required()
|
||||
});
|
||||
|
||||
module.exports = EventSchema
|
||||
11
models/index.js
Normal file
11
models/index.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const data = require('./data.model.js');
|
||||
const event = require('./event.model.js');
|
||||
const alert = require('./alert.model.js');
|
||||
const ipxdata = require('./ipxdata.model.js');
|
||||
|
||||
module.exports = {
|
||||
data,
|
||||
event,
|
||||
alert,
|
||||
ipxdata
|
||||
}
|
||||
13
models/ipxdata.model.js
Normal file
13
models/ipxdata.model.js
Normal file
@@ -0,0 +1,13 @@
|
||||
const joi = require("joi")
|
||||
|
||||
const IPXDataSchema = joi.object({
|
||||
date: joi.date().timestamp("unix").required(),
|
||||
tags: joi.array().items( joi.object({
|
||||
tag: joi.number().required(),
|
||||
type: joi.number().required(),
|
||||
data: joi.alternatives().try(joi.string(), joi.number())
|
||||
}).optional()
|
||||
).required()
|
||||
})
|
||||
|
||||
module.exports = IPXDataSchema
|
||||
15
node_modules/.bin/mime
generated
vendored
Normal file
15
node_modules/.bin/mime
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
"$basedir/node" "$basedir/../mime/cli.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../mime/cli.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
7
node_modules/.bin/mime.cmd
generated
vendored
Normal file
7
node_modules/.bin/mime.cmd
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
@IF EXIST "%~dp0\node.exe" (
|
||||
"%~dp0\node.exe" "%~dp0\..\mime\cli.js" %*
|
||||
) ELSE (
|
||||
@SETLOCAL
|
||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
node "%~dp0\..\mime\cli.js" %*
|
||||
)
|
||||
15
node_modules/.bin/semver
generated
vendored
Normal file
15
node_modules/.bin/semver
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/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
|
||||
"$basedir/node" "$basedir/../semver/bin/semver" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../semver/bin/semver" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
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
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\semver\bin\semver" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
18
node_modules/.bin/semver.ps1
generated
vendored
Normal file
18
node_modules/.bin/semver.ps1
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/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") {
|
||||
& "$basedir/node$exe" "$basedir/../semver/bin/semver" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../semver/bin/semver" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
12
node_modules/@hapi/hoek/LICENSE.md
generated
vendored
Normal file
12
node_modules/@hapi/hoek/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
Copyright (c) 2011-2020, Sideway Inc, and project contributors
|
||||
Copyright (c) 2011-2014, Walmart
|
||||
Copyright (c) 2011, Yahoo Inc.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* The names of any contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS OFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
19
node_modules/@hapi/hoek/README.md
generated
vendored
Normal file
19
node_modules/@hapi/hoek/README.md
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<a href="https://hapi.dev"><img src="https://raw.githubusercontent.com/hapijs/assets/master/images/family.png" width="180px" align="right" /></a>
|
||||
|
||||
# @hapi/hoek
|
||||
|
||||
#### Utility methods for the hapi ecosystem.
|
||||
|
||||
**hoek** is part of the **hapi** ecosystem and was designed to work seamlessly with the [hapi web framework](https://hapi.dev) and its other components (but works great on its own or with other frameworks). If you are using a different web framework and find this module useful, check out [hapi](https://hapi.dev) – they work even better together.
|
||||
|
||||
This module is not intended to solve every problem for everyone, but rather as a central place to store hapi-specific methods. If you're looking for a general purpose utility module, check out [lodash](https://github.com/lodash/lodash).
|
||||
|
||||
### Visit the [hapi.dev](https://hapi.dev) Developer Portal for tutorials, documentation, and support
|
||||
|
||||
## Useful resources
|
||||
|
||||
- [Documentation and API](https://hapi.dev/family/hoek/)
|
||||
- [Version status](https://hapi.dev/resources/status/#hoek) (builds, dependencies, node versions, licenses, eol)
|
||||
- [Changelog](https://hapi.dev/family/hoek/changelog/)
|
||||
- [Project policies](https://hapi.dev/policies/)
|
||||
- [Free and commercial support options](https://hapi.dev/support/)
|
||||
102
node_modules/@hapi/hoek/lib/applyToDefaults.js
generated
vendored
Normal file
102
node_modules/@hapi/hoek/lib/applyToDefaults.js
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
'use strict';
|
||||
|
||||
const Assert = require('./assert');
|
||||
const Clone = require('./clone');
|
||||
const Merge = require('./merge');
|
||||
const Reach = require('./reach');
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (defaults, source, options = {}) {
|
||||
|
||||
Assert(defaults && typeof defaults === 'object', 'Invalid defaults value: must be an object');
|
||||
Assert(!source || source === true || typeof source === 'object', 'Invalid source value: must be true, falsy or an object');
|
||||
Assert(typeof options === 'object', 'Invalid options: must be an object');
|
||||
|
||||
if (!source) { // If no source, return null
|
||||
return null;
|
||||
}
|
||||
|
||||
if (options.shallow) {
|
||||
return internals.applyToDefaultsWithShallow(defaults, source, options);
|
||||
}
|
||||
|
||||
const copy = Clone(defaults);
|
||||
|
||||
if (source === true) { // If source is set to true, use defaults
|
||||
return copy;
|
||||
}
|
||||
|
||||
const nullOverride = options.nullOverride !== undefined ? options.nullOverride : false;
|
||||
return Merge(copy, source, { nullOverride, mergeArrays: false });
|
||||
};
|
||||
|
||||
|
||||
internals.applyToDefaultsWithShallow = function (defaults, source, options) {
|
||||
|
||||
const keys = options.shallow;
|
||||
Assert(Array.isArray(keys), 'Invalid keys');
|
||||
|
||||
const seen = new Map();
|
||||
const merge = source === true ? null : new Set();
|
||||
|
||||
for (let key of keys) {
|
||||
key = Array.isArray(key) ? key : key.split('.'); // Pre-split optimization
|
||||
|
||||
const ref = Reach(defaults, key);
|
||||
if (ref &&
|
||||
typeof ref === 'object') {
|
||||
|
||||
seen.set(ref, merge && Reach(source, key) || ref);
|
||||
}
|
||||
else if (merge) {
|
||||
merge.add(key);
|
||||
}
|
||||
}
|
||||
|
||||
const copy = Clone(defaults, {}, seen);
|
||||
|
||||
if (!merge) {
|
||||
return copy;
|
||||
}
|
||||
|
||||
for (const key of merge) {
|
||||
internals.reachCopy(copy, source, key);
|
||||
}
|
||||
|
||||
const nullOverride = options.nullOverride !== undefined ? options.nullOverride : false;
|
||||
return Merge(copy, source, { nullOverride, mergeArrays: false });
|
||||
};
|
||||
|
||||
|
||||
internals.reachCopy = function (dst, src, path) {
|
||||
|
||||
for (const segment of path) {
|
||||
if (!(segment in src)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const val = src[segment];
|
||||
|
||||
if (typeof val !== 'object' || val === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
src = val;
|
||||
}
|
||||
|
||||
const value = src;
|
||||
let ref = dst;
|
||||
for (let i = 0; i < path.length - 1; ++i) {
|
||||
const segment = path[i];
|
||||
if (typeof ref[segment] !== 'object') {
|
||||
ref[segment] = {};
|
||||
}
|
||||
|
||||
ref = ref[segment];
|
||||
}
|
||||
|
||||
ref[path[path.length - 1]] = value;
|
||||
};
|
||||
21
node_modules/@hapi/hoek/lib/assert.js
generated
vendored
Normal file
21
node_modules/@hapi/hoek/lib/assert.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
const AssertError = require('./error');
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (condition, ...args) {
|
||||
|
||||
if (condition) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length === 1 &&
|
||||
args[0] instanceof Error) {
|
||||
|
||||
throw args[0];
|
||||
}
|
||||
|
||||
throw new AssertError(args);
|
||||
};
|
||||
29
node_modules/@hapi/hoek/lib/bench.js
generated
vendored
Normal file
29
node_modules/@hapi/hoek/lib/bench.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = internals.Bench = class {
|
||||
|
||||
constructor() {
|
||||
|
||||
this.ts = 0;
|
||||
this.reset();
|
||||
}
|
||||
|
||||
reset() {
|
||||
|
||||
this.ts = internals.Bench.now();
|
||||
}
|
||||
|
||||
elapsed() {
|
||||
|
||||
return internals.Bench.now() - this.ts;
|
||||
}
|
||||
|
||||
static now() {
|
||||
|
||||
const ts = process.hrtime();
|
||||
return (ts[0] * 1e3) + (ts[1] / 1e6);
|
||||
}
|
||||
};
|
||||
12
node_modules/@hapi/hoek/lib/block.js
generated
vendored
Normal file
12
node_modules/@hapi/hoek/lib/block.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
const Ignore = require('./ignore');
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function () {
|
||||
|
||||
return new Promise(Ignore);
|
||||
};
|
||||
176
node_modules/@hapi/hoek/lib/clone.js
generated
vendored
Normal file
176
node_modules/@hapi/hoek/lib/clone.js
generated
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
'use strict';
|
||||
|
||||
const Reach = require('./reach');
|
||||
const Types = require('./types');
|
||||
const Utils = require('./utils');
|
||||
|
||||
|
||||
const internals = {
|
||||
needsProtoHack: new Set([Types.set, Types.map, Types.weakSet, Types.weakMap])
|
||||
};
|
||||
|
||||
|
||||
module.exports = internals.clone = function (obj, options = {}, _seen = null) {
|
||||
|
||||
if (typeof obj !== 'object' ||
|
||||
obj === null) {
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
let clone = internals.clone;
|
||||
let seen = _seen;
|
||||
|
||||
if (options.shallow) {
|
||||
if (options.shallow !== true) {
|
||||
return internals.cloneWithShallow(obj, options);
|
||||
}
|
||||
|
||||
clone = (value) => value;
|
||||
}
|
||||
else if (seen) {
|
||||
const lookup = seen.get(obj);
|
||||
if (lookup) {
|
||||
return lookup;
|
||||
}
|
||||
}
|
||||
else {
|
||||
seen = new Map();
|
||||
}
|
||||
|
||||
// Built-in object types
|
||||
|
||||
const baseProto = Types.getInternalProto(obj);
|
||||
if (baseProto === Types.buffer) {
|
||||
return Buffer && Buffer.from(obj); // $lab:coverage:ignore$
|
||||
}
|
||||
|
||||
if (baseProto === Types.date) {
|
||||
return new Date(obj.getTime());
|
||||
}
|
||||
|
||||
if (baseProto === Types.regex) {
|
||||
return new RegExp(obj);
|
||||
}
|
||||
|
||||
// Generic objects
|
||||
|
||||
const newObj = internals.base(obj, baseProto, options);
|
||||
if (newObj === obj) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
if (seen) {
|
||||
seen.set(obj, newObj); // Set seen, since obj could recurse
|
||||
}
|
||||
|
||||
if (baseProto === Types.set) {
|
||||
for (const value of obj) {
|
||||
newObj.add(clone(value, options, seen));
|
||||
}
|
||||
}
|
||||
else if (baseProto === Types.map) {
|
||||
for (const [key, value] of obj) {
|
||||
newObj.set(key, clone(value, options, seen));
|
||||
}
|
||||
}
|
||||
|
||||
const keys = Utils.keys(obj, options);
|
||||
for (const key of keys) {
|
||||
if (key === '__proto__') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (baseProto === Types.array &&
|
||||
key === 'length') {
|
||||
|
||||
newObj.length = obj.length;
|
||||
continue;
|
||||
}
|
||||
|
||||
const descriptor = Object.getOwnPropertyDescriptor(obj, key);
|
||||
if (descriptor) {
|
||||
if (descriptor.get ||
|
||||
descriptor.set) {
|
||||
|
||||
Object.defineProperty(newObj, key, descriptor);
|
||||
}
|
||||
else if (descriptor.enumerable) {
|
||||
newObj[key] = clone(obj[key], options, seen);
|
||||
}
|
||||
else {
|
||||
Object.defineProperty(newObj, key, { enumerable: false, writable: true, configurable: true, value: clone(obj[key], options, seen) });
|
||||
}
|
||||
}
|
||||
else {
|
||||
Object.defineProperty(newObj, key, {
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
value: clone(obj[key], options, seen)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return newObj;
|
||||
};
|
||||
|
||||
|
||||
internals.cloneWithShallow = function (source, options) {
|
||||
|
||||
const keys = options.shallow;
|
||||
options = Object.assign({}, options);
|
||||
options.shallow = false;
|
||||
|
||||
const seen = new Map();
|
||||
|
||||
for (const key of keys) {
|
||||
const ref = Reach(source, key);
|
||||
if (typeof ref === 'object' ||
|
||||
typeof ref === 'function') {
|
||||
|
||||
seen.set(ref, ref);
|
||||
}
|
||||
}
|
||||
|
||||
return internals.clone(source, options, seen);
|
||||
};
|
||||
|
||||
|
||||
internals.base = function (obj, baseProto, options) {
|
||||
|
||||
if (options.prototype === false) { // Defaults to true
|
||||
if (internals.needsProtoHack.has(baseProto)) {
|
||||
return new baseProto.constructor();
|
||||
}
|
||||
|
||||
return baseProto === Types.array ? [] : {};
|
||||
}
|
||||
|
||||
const proto = Object.getPrototypeOf(obj);
|
||||
if (proto &&
|
||||
proto.isImmutable) {
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
if (baseProto === Types.array) {
|
||||
const newObj = [];
|
||||
if (proto !== baseProto) {
|
||||
Object.setPrototypeOf(newObj, proto);
|
||||
}
|
||||
|
||||
return newObj;
|
||||
}
|
||||
|
||||
if (internals.needsProtoHack.has(baseProto)) {
|
||||
const newObj = new proto.constructor();
|
||||
if (proto !== baseProto) {
|
||||
Object.setPrototypeOf(newObj, proto);
|
||||
}
|
||||
|
||||
return newObj;
|
||||
}
|
||||
|
||||
return Object.create(proto);
|
||||
};
|
||||
307
node_modules/@hapi/hoek/lib/contain.js
generated
vendored
Normal file
307
node_modules/@hapi/hoek/lib/contain.js
generated
vendored
Normal file
@@ -0,0 +1,307 @@
|
||||
'use strict';
|
||||
|
||||
const Assert = require('./assert');
|
||||
const DeepEqual = require('./deepEqual');
|
||||
const EscapeRegex = require('./escapeRegex');
|
||||
const Utils = require('./utils');
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (ref, values, options = {}) { // options: { deep, once, only, part, symbols }
|
||||
|
||||
/*
|
||||
string -> string(s)
|
||||
array -> item(s)
|
||||
object -> key(s)
|
||||
object -> object (key:value)
|
||||
*/
|
||||
|
||||
if (typeof values !== 'object') {
|
||||
values = [values];
|
||||
}
|
||||
|
||||
Assert(!Array.isArray(values) || values.length, 'Values array cannot be empty');
|
||||
|
||||
// String
|
||||
|
||||
if (typeof ref === 'string') {
|
||||
return internals.string(ref, values, options);
|
||||
}
|
||||
|
||||
// Array
|
||||
|
||||
if (Array.isArray(ref)) {
|
||||
return internals.array(ref, values, options);
|
||||
}
|
||||
|
||||
// Object
|
||||
|
||||
Assert(typeof ref === 'object', 'Reference must be string or an object');
|
||||
return internals.object(ref, values, options);
|
||||
};
|
||||
|
||||
|
||||
internals.array = function (ref, values, options) {
|
||||
|
||||
if (!Array.isArray(values)) {
|
||||
values = [values];
|
||||
}
|
||||
|
||||
if (!ref.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (options.only &&
|
||||
options.once &&
|
||||
ref.length !== values.length) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
let compare;
|
||||
|
||||
// Map values
|
||||
|
||||
const map = new Map();
|
||||
for (const value of values) {
|
||||
if (!options.deep ||
|
||||
!value ||
|
||||
typeof value !== 'object') {
|
||||
|
||||
const existing = map.get(value);
|
||||
if (existing) {
|
||||
++existing.allowed;
|
||||
}
|
||||
else {
|
||||
map.set(value, { allowed: 1, hits: 0 });
|
||||
}
|
||||
}
|
||||
else {
|
||||
compare = compare || internals.compare(options);
|
||||
|
||||
let found = false;
|
||||
for (const [key, existing] of map.entries()) {
|
||||
if (compare(key, value)) {
|
||||
++existing.allowed;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
map.set(value, { allowed: 1, hits: 0 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Lookup values
|
||||
|
||||
let hits = 0;
|
||||
for (const item of ref) {
|
||||
let match;
|
||||
if (!options.deep ||
|
||||
!item ||
|
||||
typeof item !== 'object') {
|
||||
|
||||
match = map.get(item);
|
||||
}
|
||||
else {
|
||||
compare = compare || internals.compare(options);
|
||||
|
||||
for (const [key, existing] of map.entries()) {
|
||||
if (compare(key, item)) {
|
||||
match = existing;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (match) {
|
||||
++match.hits;
|
||||
++hits;
|
||||
|
||||
if (options.once &&
|
||||
match.hits > match.allowed) {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Validate results
|
||||
|
||||
if (options.only &&
|
||||
hits !== ref.length) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const match of map.values()) {
|
||||
if (match.hits === match.allowed) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (match.hits < match.allowed &&
|
||||
!options.part) {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return !!hits;
|
||||
};
|
||||
|
||||
|
||||
internals.object = function (ref, values, options) {
|
||||
|
||||
Assert(options.once === undefined, 'Cannot use option once with object');
|
||||
|
||||
const keys = Utils.keys(ref, options);
|
||||
if (!keys.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Keys list
|
||||
|
||||
if (Array.isArray(values)) {
|
||||
return internals.array(keys, values, options);
|
||||
}
|
||||
|
||||
// Key value pairs
|
||||
|
||||
const symbols = Object.getOwnPropertySymbols(values).filter((sym) => values.propertyIsEnumerable(sym));
|
||||
const targets = [...Object.keys(values), ...symbols];
|
||||
|
||||
const compare = internals.compare(options);
|
||||
const set = new Set(targets);
|
||||
|
||||
for (const key of keys) {
|
||||
if (!set.has(key)) {
|
||||
if (options.only) {
|
||||
return false;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!compare(values[key], ref[key])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
set.delete(key);
|
||||
}
|
||||
|
||||
if (set.size) {
|
||||
return options.part ? set.size < targets.length : false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
internals.string = function (ref, values, options) {
|
||||
|
||||
// Empty string
|
||||
|
||||
if (ref === '') {
|
||||
return values.length === 1 && values[0] === '' || // '' contains ''
|
||||
!options.once && !values.some((v) => v !== ''); // '' contains multiple '' if !once
|
||||
}
|
||||
|
||||
// Map values
|
||||
|
||||
const map = new Map();
|
||||
const patterns = [];
|
||||
|
||||
for (const value of values) {
|
||||
Assert(typeof value === 'string', 'Cannot compare string reference to non-string value');
|
||||
|
||||
if (value) {
|
||||
const existing = map.get(value);
|
||||
if (existing) {
|
||||
++existing.allowed;
|
||||
}
|
||||
else {
|
||||
map.set(value, { allowed: 1, hits: 0 });
|
||||
patterns.push(EscapeRegex(value));
|
||||
}
|
||||
}
|
||||
else if (options.once ||
|
||||
options.only) {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!patterns.length) { // Non-empty string contains unlimited empty string
|
||||
return true;
|
||||
}
|
||||
|
||||
// Match patterns
|
||||
|
||||
const regex = new RegExp(`(${patterns.join('|')})`, 'g');
|
||||
const leftovers = ref.replace(regex, ($0, $1) => {
|
||||
|
||||
++map.get($1).hits;
|
||||
return ''; // Remove from string
|
||||
});
|
||||
|
||||
// Validate results
|
||||
|
||||
if (options.only &&
|
||||
leftovers) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
let any = false;
|
||||
for (const match of map.values()) {
|
||||
if (match.hits) {
|
||||
any = true;
|
||||
}
|
||||
|
||||
if (match.hits === match.allowed) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (match.hits < match.allowed &&
|
||||
!options.part) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// match.hits > match.allowed
|
||||
|
||||
if (options.once) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return !!any;
|
||||
};
|
||||
|
||||
|
||||
internals.compare = function (options) {
|
||||
|
||||
if (!options.deep) {
|
||||
return internals.shallow;
|
||||
}
|
||||
|
||||
const hasOnly = options.only !== undefined;
|
||||
const hasPart = options.part !== undefined;
|
||||
|
||||
const flags = {
|
||||
prototype: hasOnly ? options.only : hasPart ? !options.part : false,
|
||||
part: hasOnly ? !options.only : hasPart ? options.part : false
|
||||
};
|
||||
|
||||
return (a, b) => DeepEqual(a, b, flags);
|
||||
};
|
||||
|
||||
|
||||
internals.shallow = function (a, b) {
|
||||
|
||||
return a === b;
|
||||
};
|
||||
317
node_modules/@hapi/hoek/lib/deepEqual.js
generated
vendored
Normal file
317
node_modules/@hapi/hoek/lib/deepEqual.js
generated
vendored
Normal file
@@ -0,0 +1,317 @@
|
||||
'use strict';
|
||||
|
||||
const Types = require('./types');
|
||||
|
||||
|
||||
const internals = {
|
||||
mismatched: null
|
||||
};
|
||||
|
||||
|
||||
module.exports = function (obj, ref, options) {
|
||||
|
||||
options = Object.assign({ prototype: true }, options);
|
||||
|
||||
return !!internals.isDeepEqual(obj, ref, options, []);
|
||||
};
|
||||
|
||||
|
||||
internals.isDeepEqual = function (obj, ref, options, seen) {
|
||||
|
||||
if (obj === ref) { // Copied from Deep-eql, copyright(c) 2013 Jake Luer, jake@alogicalparadox.com, MIT Licensed, https://github.com/chaijs/deep-eql
|
||||
return obj !== 0 || 1 / obj === 1 / ref;
|
||||
}
|
||||
|
||||
const type = typeof obj;
|
||||
|
||||
if (type !== typeof ref) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (obj === null ||
|
||||
ref === null) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (type === 'function') {
|
||||
if (!options.deepFunction ||
|
||||
obj.toString() !== ref.toString()) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Continue as object
|
||||
}
|
||||
else if (type !== 'object') {
|
||||
return obj !== obj && ref !== ref; // NaN
|
||||
}
|
||||
|
||||
const instanceType = internals.getSharedType(obj, ref, !!options.prototype);
|
||||
switch (instanceType) {
|
||||
case Types.buffer:
|
||||
return Buffer && Buffer.prototype.equals.call(obj, ref); // $lab:coverage:ignore$
|
||||
case Types.promise:
|
||||
return obj === ref;
|
||||
case Types.regex:
|
||||
return obj.toString() === ref.toString();
|
||||
case internals.mismatched:
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = seen.length - 1; i >= 0; --i) {
|
||||
if (seen[i].isSame(obj, ref)) {
|
||||
return true; // If previous comparison failed, it would have stopped execution
|
||||
}
|
||||
}
|
||||
|
||||
seen.push(new internals.SeenEntry(obj, ref));
|
||||
|
||||
try {
|
||||
return !!internals.isDeepEqualObj(instanceType, obj, ref, options, seen);
|
||||
}
|
||||
finally {
|
||||
seen.pop();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
internals.getSharedType = function (obj, ref, checkPrototype) {
|
||||
|
||||
if (checkPrototype) {
|
||||
if (Object.getPrototypeOf(obj) !== Object.getPrototypeOf(ref)) {
|
||||
return internals.mismatched;
|
||||
}
|
||||
|
||||
return Types.getInternalProto(obj);
|
||||
}
|
||||
|
||||
const type = Types.getInternalProto(obj);
|
||||
if (type !== Types.getInternalProto(ref)) {
|
||||
return internals.mismatched;
|
||||
}
|
||||
|
||||
return type;
|
||||
};
|
||||
|
||||
|
||||
internals.valueOf = function (obj) {
|
||||
|
||||
const objValueOf = obj.valueOf;
|
||||
if (objValueOf === undefined) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
try {
|
||||
return objValueOf.call(obj);
|
||||
}
|
||||
catch (err) {
|
||||
return err;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
internals.hasOwnEnumerableProperty = function (obj, key) {
|
||||
|
||||
return Object.prototype.propertyIsEnumerable.call(obj, key);
|
||||
};
|
||||
|
||||
|
||||
internals.isSetSimpleEqual = function (obj, ref) {
|
||||
|
||||
for (const entry of Set.prototype.values.call(obj)) {
|
||||
if (!Set.prototype.has.call(ref, entry)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
internals.isDeepEqualObj = function (instanceType, obj, ref, options, seen) {
|
||||
|
||||
const { isDeepEqual, valueOf, hasOwnEnumerableProperty } = internals;
|
||||
const { keys, getOwnPropertySymbols } = Object;
|
||||
|
||||
if (instanceType === Types.array) {
|
||||
if (options.part) {
|
||||
|
||||
// Check if any index match any other index
|
||||
|
||||
for (const objValue of obj) {
|
||||
for (const refValue of ref) {
|
||||
if (isDeepEqual(objValue, refValue, options, seen)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (obj.length !== ref.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < obj.length; ++i) {
|
||||
if (!isDeepEqual(obj[i], ref[i], options, seen)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (instanceType === Types.set) {
|
||||
if (obj.size !== ref.size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!internals.isSetSimpleEqual(obj, ref)) {
|
||||
|
||||
// Check for deep equality
|
||||
|
||||
const ref2 = new Set(Set.prototype.values.call(ref));
|
||||
for (const objEntry of Set.prototype.values.call(obj)) {
|
||||
if (ref2.delete(objEntry)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let found = false;
|
||||
for (const refEntry of ref2) {
|
||||
if (isDeepEqual(objEntry, refEntry, options, seen)) {
|
||||
ref2.delete(refEntry);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (instanceType === Types.map) {
|
||||
if (obj.size !== ref.size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const [key, value] of Map.prototype.entries.call(obj)) {
|
||||
if (value === undefined && !Map.prototype.has.call(ref, key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isDeepEqual(value, Map.prototype.get.call(ref, key), options, seen)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (instanceType === Types.error) {
|
||||
|
||||
// Always check name and message
|
||||
|
||||
if (obj.name !== ref.name ||
|
||||
obj.message !== ref.message) {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Check .valueOf()
|
||||
|
||||
const valueOfObj = valueOf(obj);
|
||||
const valueOfRef = valueOf(ref);
|
||||
if ((obj !== valueOfObj || ref !== valueOfRef) &&
|
||||
!isDeepEqual(valueOfObj, valueOfRef, options, seen)) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check properties
|
||||
|
||||
const objKeys = keys(obj);
|
||||
if (!options.part &&
|
||||
objKeys.length !== keys(ref).length &&
|
||||
!options.skip) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
let skipped = 0;
|
||||
for (const key of objKeys) {
|
||||
if (options.skip &&
|
||||
options.skip.includes(key)) {
|
||||
|
||||
if (ref[key] === undefined) {
|
||||
++skipped;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!hasOwnEnumerableProperty(ref, key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isDeepEqual(obj[key], ref[key], options, seen)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!options.part &&
|
||||
objKeys.length - skipped !== keys(ref).length) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check symbols
|
||||
|
||||
if (options.symbols !== false) { // Defaults to true
|
||||
const objSymbols = getOwnPropertySymbols(obj);
|
||||
const refSymbols = new Set(getOwnPropertySymbols(ref));
|
||||
|
||||
for (const key of objSymbols) {
|
||||
if (!options.skip ||
|
||||
!options.skip.includes(key)) {
|
||||
|
||||
if (hasOwnEnumerableProperty(obj, key)) {
|
||||
if (!hasOwnEnumerableProperty(ref, key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isDeepEqual(obj[key], ref[key], options, seen)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (hasOwnEnumerableProperty(ref, key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
refSymbols.delete(key);
|
||||
}
|
||||
|
||||
for (const key of refSymbols) {
|
||||
if (hasOwnEnumerableProperty(ref, key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
internals.SeenEntry = class {
|
||||
|
||||
constructor(obj, ref) {
|
||||
|
||||
this.obj = obj;
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
isSame(obj, ref) {
|
||||
|
||||
return this.obj === obj && this.ref === ref;
|
||||
}
|
||||
};
|
||||
26
node_modules/@hapi/hoek/lib/error.js
generated
vendored
Normal file
26
node_modules/@hapi/hoek/lib/error.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
const Stringify = require('./stringify');
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = class extends Error {
|
||||
|
||||
constructor(args) {
|
||||
|
||||
const msgs = args
|
||||
.filter((arg) => arg !== '')
|
||||
.map((arg) => {
|
||||
|
||||
return typeof arg === 'string' ? arg : arg instanceof Error ? arg.message : Stringify(arg);
|
||||
});
|
||||
|
||||
super(msgs.join(' ') || 'Unknown error');
|
||||
|
||||
if (typeof Error.captureStackTrace === 'function') { // $lab:coverage:ignore$
|
||||
Error.captureStackTrace(this, exports.assert);
|
||||
}
|
||||
}
|
||||
};
|
||||
16
node_modules/@hapi/hoek/lib/escapeHeaderAttribute.js
generated
vendored
Normal file
16
node_modules/@hapi/hoek/lib/escapeHeaderAttribute.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
const Assert = require('./assert');
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (attribute) {
|
||||
|
||||
// Allowed value characters: !#$%&'()*+,-./:;<=>?@[]^_`{|}~ and space, a-z, A-Z, 0-9, \, "
|
||||
|
||||
Assert(/^[ \w\!#\$%&'\(\)\*\+,\-\.\/\:;<\=>\?@\[\]\^`\{\|\}~\"\\]*$/.test(attribute), 'Bad attribute value (' + attribute + ')');
|
||||
|
||||
return attribute.replace(/\\/g, '\\\\').replace(/\"/g, '\\"'); // Escape quotes and slash
|
||||
};
|
||||
87
node_modules/@hapi/hoek/lib/escapeHtml.js
generated
vendored
Normal file
87
node_modules/@hapi/hoek/lib/escapeHtml.js
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (input) {
|
||||
|
||||
if (!input) {
|
||||
return '';
|
||||
}
|
||||
|
||||
let escaped = '';
|
||||
|
||||
for (let i = 0; i < input.length; ++i) {
|
||||
|
||||
const charCode = input.charCodeAt(i);
|
||||
|
||||
if (internals.isSafe(charCode)) {
|
||||
escaped += input[i];
|
||||
}
|
||||
else {
|
||||
escaped += internals.escapeHtmlChar(charCode);
|
||||
}
|
||||
}
|
||||
|
||||
return escaped;
|
||||
};
|
||||
|
||||
|
||||
internals.escapeHtmlChar = function (charCode) {
|
||||
|
||||
const namedEscape = internals.namedHtml[charCode];
|
||||
if (typeof namedEscape !== 'undefined') {
|
||||
return namedEscape;
|
||||
}
|
||||
|
||||
if (charCode >= 256) {
|
||||
return '&#' + charCode + ';';
|
||||
}
|
||||
|
||||
const hexValue = charCode.toString(16).padStart(2, '0');
|
||||
return `&#x${hexValue};`;
|
||||
};
|
||||
|
||||
|
||||
internals.isSafe = function (charCode) {
|
||||
|
||||
return (typeof internals.safeCharCodes[charCode] !== 'undefined');
|
||||
};
|
||||
|
||||
|
||||
internals.namedHtml = {
|
||||
'38': '&',
|
||||
'60': '<',
|
||||
'62': '>',
|
||||
'34': '"',
|
||||
'160': ' ',
|
||||
'162': '¢',
|
||||
'163': '£',
|
||||
'164': '¤',
|
||||
'169': '©',
|
||||
'174': '®'
|
||||
};
|
||||
|
||||
|
||||
internals.safeCharCodes = (function () {
|
||||
|
||||
const safe = {};
|
||||
|
||||
for (let i = 32; i < 123; ++i) {
|
||||
|
||||
if ((i >= 97) || // a-z
|
||||
(i >= 65 && i <= 90) || // A-Z
|
||||
(i >= 48 && i <= 57) || // 0-9
|
||||
i === 32 || // space
|
||||
i === 46 || // .
|
||||
i === 44 || // ,
|
||||
i === 45 || // -
|
||||
i === 58 || // :
|
||||
i === 95) { // _
|
||||
|
||||
safe[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
return safe;
|
||||
}());
|
||||
41
node_modules/@hapi/hoek/lib/escapeJson.js
generated
vendored
Normal file
41
node_modules/@hapi/hoek/lib/escapeJson.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (input) {
|
||||
|
||||
if (!input) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const lessThan = 0x3C;
|
||||
const greaterThan = 0x3E;
|
||||
const andSymbol = 0x26;
|
||||
const lineSeperator = 0x2028;
|
||||
|
||||
// replace method
|
||||
let charCode;
|
||||
return input.replace(/[<>&\u2028\u2029]/g, (match) => {
|
||||
|
||||
charCode = match.charCodeAt(0);
|
||||
|
||||
if (charCode === lessThan) {
|
||||
return '\\u003c';
|
||||
}
|
||||
|
||||
if (charCode === greaterThan) {
|
||||
return '\\u003e';
|
||||
}
|
||||
|
||||
if (charCode === andSymbol) {
|
||||
return '\\u0026';
|
||||
}
|
||||
|
||||
if (charCode === lineSeperator) {
|
||||
return '\\u2028';
|
||||
}
|
||||
|
||||
return '\\u2029';
|
||||
});
|
||||
};
|
||||
11
node_modules/@hapi/hoek/lib/escapeRegex.js
generated
vendored
Normal file
11
node_modules/@hapi/hoek/lib/escapeRegex.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (string) {
|
||||
|
||||
// Escape ^$.*+-?=!:|\/()[]{},
|
||||
|
||||
return string.replace(/[\^\$\.\*\+\-\?\=\!\:\|\\\/\(\)\[\]\{\}\,]/g, '\\$&');
|
||||
};
|
||||
20
node_modules/@hapi/hoek/lib/flatten.js
generated
vendored
Normal file
20
node_modules/@hapi/hoek/lib/flatten.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = internals.flatten = function (array, target) {
|
||||
|
||||
const result = target || [];
|
||||
|
||||
for (let i = 0; i < array.length; ++i) {
|
||||
if (Array.isArray(array[i])) {
|
||||
internals.flatten(array[i], result);
|
||||
}
|
||||
else {
|
||||
result.push(array[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
6
node_modules/@hapi/hoek/lib/ignore.js
generated
vendored
Normal file
6
node_modules/@hapi/hoek/lib/ignore.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function () { };
|
||||
471
node_modules/@hapi/hoek/lib/index.d.ts
generated
vendored
Normal file
471
node_modules/@hapi/hoek/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,471 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
|
||||
/**
|
||||
* Performs a deep comparison of the two values including support for circular dependencies, prototype, and enumerable properties.
|
||||
*
|
||||
* @param obj - The value being compared.
|
||||
* @param ref - The reference value used for comparison.
|
||||
*
|
||||
* @return true when the two values are equal, otherwise false.
|
||||
*/
|
||||
export function deepEqual(obj: any, ref: any, options?: deepEqual.Options): boolean;
|
||||
|
||||
export namespace deepEqual {
|
||||
|
||||
interface Options {
|
||||
|
||||
/**
|
||||
* Compare functions with difference references by comparing their internal code and properties.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly deepFunction?: boolean;
|
||||
|
||||
/**
|
||||
* Allow partial match.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly part?: boolean;
|
||||
|
||||
/**
|
||||
* Compare the objects' prototypes.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly prototype?: boolean;
|
||||
|
||||
/**
|
||||
* List of object keys to ignore different values of.
|
||||
*
|
||||
* @default null
|
||||
*/
|
||||
readonly skip?: (string | symbol)[];
|
||||
|
||||
/**
|
||||
* Compare symbol properties.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly symbols?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clone any value, object, or array.
|
||||
*
|
||||
* @param obj - The value being cloned.
|
||||
* @param options - Optional settings.
|
||||
*
|
||||
* @returns A deep clone of `obj`.
|
||||
*/
|
||||
export function clone<T>(obj: T, options?: clone.Options): T;
|
||||
|
||||
export namespace clone {
|
||||
|
||||
interface Options {
|
||||
|
||||
/**
|
||||
* Clone the object's prototype.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly prototype?: boolean;
|
||||
|
||||
/**
|
||||
* Include symbol properties.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly symbols?: boolean;
|
||||
|
||||
/**
|
||||
* Shallow clone the specified keys.
|
||||
*
|
||||
* @default undefined
|
||||
*/
|
||||
readonly shallow?: string[] | string[][] | boolean;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Merge all the properties of source into target.
|
||||
*
|
||||
* @param target - The object being modified.
|
||||
* @param source - The object used to copy properties from.
|
||||
* @param options - Optional settings.
|
||||
*
|
||||
* @returns The `target` object.
|
||||
*/
|
||||
export function merge<T1 extends object, T2 extends object>(target: T1, source: T2, options?: merge.Options): T1 & T2;
|
||||
|
||||
export namespace merge {
|
||||
|
||||
interface Options {
|
||||
|
||||
/**
|
||||
* When true, null value from `source` overrides existing value in `target`.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly nullOverride?: boolean;
|
||||
|
||||
/**
|
||||
* When true, array value from `source` is merged with the existing value in `target`.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly mergeArrays?: boolean;
|
||||
|
||||
/**
|
||||
* Compare symbol properties.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly symbols?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Apply source to a copy of the defaults.
|
||||
*
|
||||
* @param defaults - An object with the default values to use of `options` does not contain the same keys.
|
||||
* @param source - The source used to override the `defaults`.
|
||||
* @param options - Optional settings.
|
||||
*
|
||||
* @returns A copy of `defaults` with `source` keys overriding any conflicts.
|
||||
*/
|
||||
export function applyToDefaults<T extends object>(defaults: Partial<T>, source: Partial<T> | boolean | null, options?: applyToDefaults.Options): Partial<T>;
|
||||
|
||||
export namespace applyToDefaults {
|
||||
|
||||
interface Options {
|
||||
|
||||
/**
|
||||
* When true, null value from `source` overrides existing value in `target`.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly nullOverride?: boolean;
|
||||
|
||||
/**
|
||||
* Shallow clone the specified keys.
|
||||
*
|
||||
* @default undefined
|
||||
*/
|
||||
readonly shallow?: string[] | string[][];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find the common unique items in two arrays.
|
||||
*
|
||||
* @param array1 - The first array to compare.
|
||||
* @param array2 - The second array to compare.
|
||||
* @param options - Optional settings.
|
||||
*
|
||||
* @return - An array of the common items. If `justFirst` is true, returns the first common item.
|
||||
*/
|
||||
export function intersect<T1, T2>(array1: intersect.Array<T1>, array2: intersect.Array<T2>, options?: intersect.Options): Array<T1 | T2>;
|
||||
export function intersect<T1, T2>(array1: intersect.Array<T1>, array2: intersect.Array<T2>, options?: intersect.Options): T1 | T2;
|
||||
|
||||
export namespace intersect {
|
||||
|
||||
type Array<T> = ArrayLike<T> | Set<T> | null;
|
||||
|
||||
interface Options {
|
||||
|
||||
/**
|
||||
* When true, return the first overlapping value.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly first?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the reference value contains the provided values.
|
||||
*
|
||||
* @param ref - The reference string, array, or object.
|
||||
* @param values - A single or array of values to find within `ref`. If `ref` is an object, `values` can be a key name, an array of key names, or an object with key-value pairs to compare.
|
||||
*
|
||||
* @return true if the value contains the provided values, otherwise false.
|
||||
*/
|
||||
export function contain(ref: string, values: string | string[], options?: contain.Options): boolean;
|
||||
export function contain(ref: any[], values: any, options?: contain.Options): boolean;
|
||||
export function contain(ref: object, values: string | string[] | object, options?: Omit<contain.Options, 'once'>): boolean;
|
||||
|
||||
export namespace contain {
|
||||
|
||||
interface Options {
|
||||
|
||||
/**
|
||||
* Perform a deep comparison.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly deep?: boolean;
|
||||
|
||||
/**
|
||||
* Allow only one occurrence of each value.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly once?: boolean;
|
||||
|
||||
/**
|
||||
* Allow only values explicitly listed.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly only?: boolean;
|
||||
|
||||
/**
|
||||
* Allow partial match.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly part?: boolean;
|
||||
|
||||
/**
|
||||
* Include symbol properties.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly symbols?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Flatten an array with sub arrays
|
||||
*
|
||||
* @param array - an array of items or other arrays to flatten.
|
||||
* @param target - if provided, an array to shallow copy the flattened `array` items to
|
||||
*
|
||||
* @return a flat array of the provided values (appended to `target` is provided).
|
||||
*/
|
||||
export function flatten<T>(array: ArrayLike<T | ReadonlyArray<T>>, target?: ArrayLike<T | ReadonlyArray<T>>): T[];
|
||||
|
||||
|
||||
/**
|
||||
* Convert an object key chain string to reference.
|
||||
*
|
||||
* @param obj - the object from which to look up the value.
|
||||
* @param chain - the string path of the requested value. The chain string is split into key names using `options.separator`, or an array containing each individual key name. A chain including negative numbers will work like a negative index on an array.
|
||||
*
|
||||
* @return The value referenced by the chain if found, otherwise undefined. If chain is null, undefined, or false, the object itself will be returned.
|
||||
*/
|
||||
export function reach(obj: object | null, chain: string | (string | number)[] | false | null | undefined, options?: reach.Options): any;
|
||||
|
||||
export namespace reach {
|
||||
|
||||
interface Options {
|
||||
|
||||
/**
|
||||
* String to split chain path on. Defaults to '.'.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly separator?: string;
|
||||
|
||||
/**
|
||||
* Value to return if the path or value is not present. No default value.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly default?: any;
|
||||
|
||||
/**
|
||||
* If true, will throw an error on missing member in the chain. Default to false.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly strict?: boolean;
|
||||
|
||||
/**
|
||||
* If true, allows traversing functions for properties. false will throw an error if a function is part of the chain.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly functions?: boolean;
|
||||
|
||||
/**
|
||||
* If true, allows traversing Set and Map objects for properties. false will return undefined regardless of the Set or Map passed.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly iterables?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replace string parameters (using format "{path.to.key}") with their corresponding object key values using `Hoek.reach()`.
|
||||
*
|
||||
* @param obj - the object from which to look up the value.
|
||||
* @param template - the string containing {} enclosed key paths to be replaced.
|
||||
*
|
||||
* @return The template string with the {} enclosed keys replaced with looked-up values.
|
||||
*/
|
||||
export function reachTemplate(obj: object | null, template: string, options?: reach.Options): string;
|
||||
|
||||
|
||||
/**
|
||||
* Throw an error if condition is falsy.
|
||||
*
|
||||
* @param condition - If `condition` is not truthy, an exception is thrown.
|
||||
* @param error - The error thrown if the condition fails.
|
||||
*
|
||||
* @return Does not return a value but throws if the `condition` is falsy.
|
||||
*/
|
||||
export function assert(condition: any, error: Error): void;
|
||||
|
||||
|
||||
/**
|
||||
* Throw an error if condition is falsy.
|
||||
*
|
||||
* @param condition - If `condition` is not truthy, an exception is thrown.
|
||||
* @param args - Any number of values, concatenated together (space separated) to create the error message.
|
||||
*
|
||||
* @return Does not return a value but throws if the `condition` is falsy.
|
||||
*/
|
||||
export function assert(condition: any, ...args: any): void;
|
||||
|
||||
|
||||
/**
|
||||
* A benchmarking timer, using the internal node clock for maximum accuracy.
|
||||
*/
|
||||
export class Bench {
|
||||
|
||||
constructor();
|
||||
|
||||
/** The starting timestamp expressed in the number of milliseconds since the epoch. */
|
||||
ts: number;
|
||||
|
||||
/** The time in milliseconds since the object was created. */
|
||||
elapsed(): number;
|
||||
|
||||
/** Reset the `ts` value to now. */
|
||||
reset(): void;
|
||||
|
||||
/** The current time in milliseconds since the epoch. */
|
||||
static now(): number;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Escape string for Regex construction by prefixing all reserved characters with a backslash.
|
||||
*
|
||||
* @param string - The string to be escaped.
|
||||
*
|
||||
* @return The escaped string.
|
||||
*/
|
||||
export function escapeRegex(string: string): string;
|
||||
|
||||
|
||||
/**
|
||||
* Escape string for usage as an attribute value in HTTP headers.
|
||||
*
|
||||
* @param attribute - The string to be escaped.
|
||||
*
|
||||
* @return The escaped string. Will throw on invalid characters that are not supported to be escaped.
|
||||
*/
|
||||
export function escapeHeaderAttribute(attribute: string): string;
|
||||
|
||||
|
||||
/**
|
||||
* Escape string for usage in HTML.
|
||||
*
|
||||
* @param string - The string to be escaped.
|
||||
*
|
||||
* @return The escaped string.
|
||||
*/
|
||||
export function escapeHtml(string: string): string;
|
||||
|
||||
|
||||
/**
|
||||
* Escape string for usage in JSON.
|
||||
*
|
||||
* @param string - The string to be escaped.
|
||||
*
|
||||
* @return The escaped string.
|
||||
*/
|
||||
export function escapeJson(string: string): string;
|
||||
|
||||
|
||||
/**
|
||||
* Wraps a function to ensure it can only execute once.
|
||||
*
|
||||
* @param method - The function to be wrapped.
|
||||
*
|
||||
* @return The wrapped function.
|
||||
*/
|
||||
export function once<T extends Function>(method: T): T;
|
||||
|
||||
|
||||
/**
|
||||
* A reusable no-op function.
|
||||
*/
|
||||
export function ignore(...ignore: any): void;
|
||||
|
||||
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string with protection against thrown errors.
|
||||
*
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer The JSON.stringify() `replacer` argument.
|
||||
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
||||
*
|
||||
* @return The JSON string. If the operation fails, an error string value is returned (no exception thrown).
|
||||
*/
|
||||
export function stringify(value: any, replacer?: any, space?: string | number): string;
|
||||
|
||||
|
||||
/**
|
||||
* Returns a Promise that resolves after the requested timeout.
|
||||
*
|
||||
* @param timeout - The number of milliseconds to wait before resolving the Promise.
|
||||
* @param returnValue - The value that the Promise will resolve to.
|
||||
*
|
||||
* @return A Promise that resolves with `returnValue`.
|
||||
*/
|
||||
export function wait<T>(timeout?: number, returnValue?: T): Promise<T>;
|
||||
|
||||
|
||||
/**
|
||||
* Returns a Promise that never resolves.
|
||||
*/
|
||||
export function block(): Promise<void>;
|
||||
|
||||
|
||||
/**
|
||||
* Determines if an object is a promise.
|
||||
*
|
||||
* @param promise - the object tested.
|
||||
*
|
||||
* @returns true if the object is a promise, otherwise false.
|
||||
*/
|
||||
export function isPromise(promise: any): boolean;
|
||||
|
||||
|
||||
export namespace ts {
|
||||
|
||||
/**
|
||||
* Defines a type that can must be one of T or U but not both.
|
||||
*/
|
||||
type XOR<T, U> = (T | U) extends object ? (internals.Without<T, U> & U) | (internals.Without<U, T> & T) : T | U;
|
||||
}
|
||||
|
||||
|
||||
declare namespace internals {
|
||||
|
||||
type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
|
||||
}
|
||||
45
node_modules/@hapi/hoek/lib/index.js
generated
vendored
Normal file
45
node_modules/@hapi/hoek/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
'use strict';
|
||||
|
||||
exports.applyToDefaults = require('./applyToDefaults');
|
||||
|
||||
exports.assert = require('./assert');
|
||||
|
||||
exports.Bench = require('./bench');
|
||||
|
||||
exports.block = require('./block');
|
||||
|
||||
exports.clone = require('./clone');
|
||||
|
||||
exports.contain = require('./contain');
|
||||
|
||||
exports.deepEqual = require('./deepEqual');
|
||||
|
||||
exports.Error = require('./error');
|
||||
|
||||
exports.escapeHeaderAttribute = require('./escapeHeaderAttribute');
|
||||
|
||||
exports.escapeHtml = require('./escapeHtml');
|
||||
|
||||
exports.escapeJson = require('./escapeJson');
|
||||
|
||||
exports.escapeRegex = require('./escapeRegex');
|
||||
|
||||
exports.flatten = require('./flatten');
|
||||
|
||||
exports.ignore = require('./ignore');
|
||||
|
||||
exports.intersect = require('./intersect');
|
||||
|
||||
exports.isPromise = require('./isPromise');
|
||||
|
||||
exports.merge = require('./merge');
|
||||
|
||||
exports.once = require('./once');
|
||||
|
||||
exports.reach = require('./reach');
|
||||
|
||||
exports.reachTemplate = require('./reachTemplate');
|
||||
|
||||
exports.stringify = require('./stringify');
|
||||
|
||||
exports.wait = require('./wait');
|
||||
41
node_modules/@hapi/hoek/lib/intersect.js
generated
vendored
Normal file
41
node_modules/@hapi/hoek/lib/intersect.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (array1, array2, options = {}) {
|
||||
|
||||
if (!array1 ||
|
||||
!array2) {
|
||||
|
||||
return (options.first ? null : []);
|
||||
}
|
||||
|
||||
const common = [];
|
||||
const hash = (Array.isArray(array1) ? new Set(array1) : array1);
|
||||
const found = new Set();
|
||||
for (const value of array2) {
|
||||
if (internals.has(hash, value) &&
|
||||
!found.has(value)) {
|
||||
|
||||
if (options.first) {
|
||||
return value;
|
||||
}
|
||||
|
||||
common.push(value);
|
||||
found.add(value);
|
||||
}
|
||||
}
|
||||
|
||||
return (options.first ? null : common);
|
||||
};
|
||||
|
||||
|
||||
internals.has = function (ref, key) {
|
||||
|
||||
if (typeof ref.has === 'function') {
|
||||
return ref.has(key);
|
||||
}
|
||||
|
||||
return ref[key] !== undefined;
|
||||
};
|
||||
9
node_modules/@hapi/hoek/lib/isPromise.js
generated
vendored
Normal file
9
node_modules/@hapi/hoek/lib/isPromise.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (promise) {
|
||||
|
||||
return !!promise && typeof promise.then === 'function';
|
||||
};
|
||||
78
node_modules/@hapi/hoek/lib/merge.js
generated
vendored
Normal file
78
node_modules/@hapi/hoek/lib/merge.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
'use strict';
|
||||
|
||||
const Assert = require('./assert');
|
||||
const Clone = require('./clone');
|
||||
const Utils = require('./utils');
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = internals.merge = function (target, source, options) {
|
||||
|
||||
Assert(target && typeof target === 'object', 'Invalid target value: must be an object');
|
||||
Assert(source === null || source === undefined || typeof source === 'object', 'Invalid source value: must be null, undefined, or an object');
|
||||
|
||||
if (!source) {
|
||||
return target;
|
||||
}
|
||||
|
||||
options = Object.assign({ nullOverride: true, mergeArrays: true }, options);
|
||||
|
||||
if (Array.isArray(source)) {
|
||||
Assert(Array.isArray(target), 'Cannot merge array onto an object');
|
||||
if (!options.mergeArrays) {
|
||||
target.length = 0; // Must not change target assignment
|
||||
}
|
||||
|
||||
for (let i = 0; i < source.length; ++i) {
|
||||
target.push(Clone(source[i], { symbols: options.symbols }));
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
const keys = Utils.keys(source, options);
|
||||
for (let i = 0; i < keys.length; ++i) {
|
||||
const key = keys[i];
|
||||
if (key === '__proto__' ||
|
||||
!Object.prototype.propertyIsEnumerable.call(source, key)) {
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
const value = source[key];
|
||||
if (value &&
|
||||
typeof value === 'object') {
|
||||
|
||||
if (target[key] === value) {
|
||||
continue; // Can occur for shallow merges
|
||||
}
|
||||
|
||||
if (!target[key] ||
|
||||
typeof target[key] !== 'object' ||
|
||||
(Array.isArray(target[key]) !== Array.isArray(value)) ||
|
||||
value instanceof Date ||
|
||||
(Buffer && Buffer.isBuffer(value)) || // $lab:coverage:ignore$
|
||||
value instanceof RegExp) {
|
||||
|
||||
target[key] = Clone(value, { symbols: options.symbols });
|
||||
}
|
||||
else {
|
||||
internals.merge(target[key], value, options);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (value !== null &&
|
||||
value !== undefined) { // Explicit to preserve empty strings
|
||||
|
||||
target[key] = value;
|
||||
}
|
||||
else if (options.nullOverride) {
|
||||
target[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
23
node_modules/@hapi/hoek/lib/once.js
generated
vendored
Normal file
23
node_modules/@hapi/hoek/lib/once.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (method) {
|
||||
|
||||
if (method._hoekOnce) {
|
||||
return method;
|
||||
}
|
||||
|
||||
let once = false;
|
||||
const wrapped = function (...args) {
|
||||
|
||||
if (!once) {
|
||||
once = true;
|
||||
method(...args);
|
||||
}
|
||||
};
|
||||
|
||||
wrapped._hoekOnce = true;
|
||||
return wrapped;
|
||||
};
|
||||
76
node_modules/@hapi/hoek/lib/reach.js
generated
vendored
Normal file
76
node_modules/@hapi/hoek/lib/reach.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
'use strict';
|
||||
|
||||
const Assert = require('./assert');
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (obj, chain, options) {
|
||||
|
||||
if (chain === false ||
|
||||
chain === null ||
|
||||
chain === undefined) {
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
if (typeof options === 'string') {
|
||||
options = { separator: options };
|
||||
}
|
||||
|
||||
const isChainArray = Array.isArray(chain);
|
||||
|
||||
Assert(!isChainArray || !options.separator, 'Separator option no valid for array-based chain');
|
||||
|
||||
const path = isChainArray ? chain : chain.split(options.separator || '.');
|
||||
let ref = obj;
|
||||
for (let i = 0; i < path.length; ++i) {
|
||||
let key = path[i];
|
||||
const type = options.iterables && internals.iterables(ref);
|
||||
|
||||
if (Array.isArray(ref) ||
|
||||
type === 'set') {
|
||||
|
||||
const number = Number(key);
|
||||
if (Number.isInteger(number)) {
|
||||
key = number < 0 ? ref.length + number : number;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ref ||
|
||||
typeof ref === 'function' && options.functions === false || // Defaults to true
|
||||
!type && ref[key] === undefined) {
|
||||
|
||||
Assert(!options.strict || i + 1 === path.length, 'Missing segment', key, 'in reach path ', chain);
|
||||
Assert(typeof ref === 'object' || options.functions === true || typeof ref !== 'function', 'Invalid segment', key, 'in reach path ', chain);
|
||||
ref = options.default;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!type) {
|
||||
ref = ref[key];
|
||||
}
|
||||
else if (type === 'set') {
|
||||
ref = [...ref][key];
|
||||
}
|
||||
else { // type === 'map'
|
||||
ref = ref.get(key);
|
||||
}
|
||||
}
|
||||
|
||||
return ref;
|
||||
};
|
||||
|
||||
|
||||
internals.iterables = function (ref) {
|
||||
|
||||
if (ref instanceof Set) {
|
||||
return 'set';
|
||||
}
|
||||
|
||||
if (ref instanceof Map) {
|
||||
return 'map';
|
||||
}
|
||||
};
|
||||
16
node_modules/@hapi/hoek/lib/reachTemplate.js
generated
vendored
Normal file
16
node_modules/@hapi/hoek/lib/reachTemplate.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
const Reach = require('./reach');
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (obj, template, options) {
|
||||
|
||||
return template.replace(/{([^}]+)}/g, ($0, chain) => {
|
||||
|
||||
const value = Reach(obj, chain, options);
|
||||
return (value === undefined || value === null ? '' : value);
|
||||
});
|
||||
};
|
||||
14
node_modules/@hapi/hoek/lib/stringify.js
generated
vendored
Normal file
14
node_modules/@hapi/hoek/lib/stringify.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (...args) {
|
||||
|
||||
try {
|
||||
return JSON.stringify.apply(null, args);
|
||||
}
|
||||
catch (err) {
|
||||
return '[Cannot display object: ' + err.message + ']';
|
||||
}
|
||||
};
|
||||
55
node_modules/@hapi/hoek/lib/types.js
generated
vendored
Normal file
55
node_modules/@hapi/hoek/lib/types.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
exports = module.exports = {
|
||||
array: Array.prototype,
|
||||
buffer: Buffer && Buffer.prototype, // $lab:coverage:ignore$
|
||||
date: Date.prototype,
|
||||
error: Error.prototype,
|
||||
generic: Object.prototype,
|
||||
map: Map.prototype,
|
||||
promise: Promise.prototype,
|
||||
regex: RegExp.prototype,
|
||||
set: Set.prototype,
|
||||
weakMap: WeakMap.prototype,
|
||||
weakSet: WeakSet.prototype
|
||||
};
|
||||
|
||||
|
||||
internals.typeMap = new Map([
|
||||
['[object Error]', exports.error],
|
||||
['[object Map]', exports.map],
|
||||
['[object Promise]', exports.promise],
|
||||
['[object Set]', exports.set],
|
||||
['[object WeakMap]', exports.weakMap],
|
||||
['[object WeakSet]', exports.weakSet]
|
||||
]);
|
||||
|
||||
|
||||
exports.getInternalProto = function (obj) {
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
return exports.array;
|
||||
}
|
||||
|
||||
if (Buffer && obj instanceof Buffer) { // $lab:coverage:ignore$
|
||||
return exports.buffer;
|
||||
}
|
||||
|
||||
if (obj instanceof Date) {
|
||||
return exports.date;
|
||||
}
|
||||
|
||||
if (obj instanceof RegExp) {
|
||||
return exports.regex;
|
||||
}
|
||||
|
||||
if (obj instanceof Error) {
|
||||
return exports.error;
|
||||
}
|
||||
|
||||
const objName = Object.prototype.toString.call(obj);
|
||||
return internals.typeMap.get(objName) || exports.generic;
|
||||
};
|
||||
9
node_modules/@hapi/hoek/lib/utils.js
generated
vendored
Normal file
9
node_modules/@hapi/hoek/lib/utils.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
exports.keys = function (obj, options = {}) {
|
||||
|
||||
return options.symbols !== false ? Reflect.ownKeys(obj) : Object.getOwnPropertyNames(obj); // Defaults to true
|
||||
};
|
||||
13
node_modules/@hapi/hoek/lib/wait.js
generated
vendored
Normal file
13
node_modules/@hapi/hoek/lib/wait.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
module.exports = function (timeout, returnValue) {
|
||||
|
||||
if (typeof timeout !== 'number' && timeout !== undefined) {
|
||||
throw new TypeError('Timeout must be a number');
|
||||
}
|
||||
|
||||
return new Promise((resolve) => setTimeout(resolve, timeout, returnValue));
|
||||
};
|
||||
60
node_modules/@hapi/hoek/package.json
generated
vendored
Normal file
60
node_modules/@hapi/hoek/package.json
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"_from": "@hapi/hoek@^9.0.0",
|
||||
"_id": "@hapi/hoek@9.2.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-sqKVVVOe5ivCaXDWivIJYVSaEgdQK9ul7a4Kity5Iw7u9+wBAPbX1RMSnLLmp7O4Vzj0WOWwMAJsTL00xwaNug==",
|
||||
"_location": "/@hapi/hoek",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@hapi/hoek@^9.0.0",
|
||||
"name": "@hapi/hoek",
|
||||
"escapedName": "@hapi%2fhoek",
|
||||
"scope": "@hapi",
|
||||
"rawSpec": "^9.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^9.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@hapi/topo",
|
||||
"/@sideway/address",
|
||||
"/joi"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.2.0.tgz",
|
||||
"_shasum": "f3933a44e365864f4dad5db94158106d511e8131",
|
||||
"_spec": "@hapi/hoek@^9.0.0",
|
||||
"_where": "C:\\Users\\anelissen\\Development\\tools\\node\\cbor\\node_modules\\joi",
|
||||
"bugs": {
|
||||
"url": "https://github.com/hapijs/hoek/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "General purpose node utilities",
|
||||
"devDependencies": {
|
||||
"@hapi/code": "8.x.x",
|
||||
"@hapi/lab": "^24.0.0",
|
||||
"typescript": "~4.0.2"
|
||||
},
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"homepage": "https://github.com/hapijs/hoek#readme",
|
||||
"keywords": [
|
||||
"utilities"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"main": "lib/index.js",
|
||||
"name": "@hapi/hoek",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/hapijs/hoek.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "lab -a @hapi/code -t 100 -L -Y",
|
||||
"test-cov-html": "lab -a @hapi/code -t 100 -L -r html -o coverage.html"
|
||||
},
|
||||
"types": "lib/index.d.ts",
|
||||
"version": "9.2.0"
|
||||
}
|
||||
10
node_modules/@hapi/topo/LICENSE.md
generated
vendored
Normal file
10
node_modules/@hapi/topo/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
Copyright (c) 2012-2020, Sideway Inc, and project contributors
|
||||
Copyright (c) 2012-2014, Walmart.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* The names of any contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS OFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
17
node_modules/@hapi/topo/README.md
generated
vendored
Normal file
17
node_modules/@hapi/topo/README.md
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
<a href="https://hapi.dev"><img src="https://raw.githubusercontent.com/hapijs/assets/master/images/family.png" width="180px" align="right" /></a>
|
||||
|
||||
# @hapi/topo
|
||||
|
||||
#### Topological sorting with grouping support.
|
||||
|
||||
**topo** is part of the **hapi** ecosystem and was designed to work seamlessly with the [hapi web framework](https://hapi.dev) and its other components (but works great on its own or with other frameworks). If you are using a different web framework and find this module useful, check out [hapi](https://hapi.dev) – they work even better together.
|
||||
|
||||
### Visit the [hapi.dev](https://hapi.dev) Developer Portal for tutorials, documentation, and support
|
||||
|
||||
## Useful resources
|
||||
|
||||
- [Documentation and API](https://hapi.dev/family/topo/)
|
||||
- [Version status](https://hapi.dev/resources/status/#topo) (builds, dependencies, node versions, licenses, eol)
|
||||
- [Changelog](https://hapi.dev/family/topo/changelog/)
|
||||
- [Project policies](https://hapi.dev/policies/)
|
||||
- [Free and commercial support options](https://hapi.dev/support/)
|
||||
60
node_modules/@hapi/topo/lib/index.d.ts
generated
vendored
Normal file
60
node_modules/@hapi/topo/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
export class Sorter<T> {
|
||||
|
||||
/**
|
||||
* An array of the topologically sorted nodes. This list is renewed upon each call to topo.add().
|
||||
*/
|
||||
nodes: T[];
|
||||
|
||||
/**
|
||||
* Adds a node or list of nodes to be added and topologically sorted
|
||||
*
|
||||
* @param nodes - A mixed value or array of mixed values to be added as nodes to the topologically sorted list.
|
||||
* @param options - Optional sorting information about the nodes.
|
||||
*
|
||||
* @returns Returns an array of the topologically sorted nodes.
|
||||
*/
|
||||
add(nodes: T | T[], options?: Options): T[];
|
||||
|
||||
/**
|
||||
* Merges another Sorter object into the current object.
|
||||
*
|
||||
* @param others - The other object or array of objects to be merged into the current one.
|
||||
*
|
||||
* @returns Returns an array of the topologically sorted nodes.
|
||||
*/
|
||||
merge(others: Sorter<T> | Sorter<T>[]): T[];
|
||||
|
||||
/**
|
||||
* Sorts the nodes array (only required if the manual option is used when adding items)
|
||||
*/
|
||||
sort(): T[];
|
||||
}
|
||||
|
||||
|
||||
export interface Options {
|
||||
|
||||
/**
|
||||
* The sorting group the added items belong to
|
||||
*/
|
||||
readonly group?: string;
|
||||
|
||||
/**
|
||||
* The group or groups the added items must come before
|
||||
*/
|
||||
readonly before?: string | string[];
|
||||
|
||||
/**
|
||||
* The group or groups the added items must come after
|
||||
*/
|
||||
readonly after?: string | string[];
|
||||
|
||||
/**
|
||||
* A number used to sort items with equal before/after requirements
|
||||
*/
|
||||
readonly sort?: number;
|
||||
|
||||
/**
|
||||
* If true, the array is not sorted automatically until sort() is called
|
||||
*/
|
||||
readonly manual?: boolean;
|
||||
}
|
||||
225
node_modules/@hapi/topo/lib/index.js
generated
vendored
Normal file
225
node_modules/@hapi/topo/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,225 @@
|
||||
'use strict';
|
||||
|
||||
const Assert = require('@hapi/hoek/lib/assert');
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
exports.Sorter = class {
|
||||
|
||||
constructor() {
|
||||
|
||||
this._items = [];
|
||||
this.nodes = [];
|
||||
}
|
||||
|
||||
add(nodes, options) {
|
||||
|
||||
options = options || {};
|
||||
|
||||
// Validate rules
|
||||
|
||||
const before = [].concat(options.before || []);
|
||||
const after = [].concat(options.after || []);
|
||||
const group = options.group || '?';
|
||||
const sort = options.sort || 0; // Used for merging only
|
||||
|
||||
Assert(!before.includes(group), `Item cannot come before itself: ${group}`);
|
||||
Assert(!before.includes('?'), 'Item cannot come before unassociated items');
|
||||
Assert(!after.includes(group), `Item cannot come after itself: ${group}`);
|
||||
Assert(!after.includes('?'), 'Item cannot come after unassociated items');
|
||||
|
||||
if (!Array.isArray(nodes)) {
|
||||
nodes = [nodes];
|
||||
}
|
||||
|
||||
for (const node of nodes) {
|
||||
const item = {
|
||||
seq: this._items.length,
|
||||
sort,
|
||||
before,
|
||||
after,
|
||||
group,
|
||||
node
|
||||
};
|
||||
|
||||
this._items.push(item);
|
||||
}
|
||||
|
||||
// Insert event
|
||||
|
||||
if (!options.manual) {
|
||||
const valid = this._sort();
|
||||
Assert(valid, 'item', group !== '?' ? `added into group ${group}` : '', 'created a dependencies error');
|
||||
}
|
||||
|
||||
return this.nodes;
|
||||
}
|
||||
|
||||
merge(others) {
|
||||
|
||||
if (!Array.isArray(others)) {
|
||||
others = [others];
|
||||
}
|
||||
|
||||
for (const other of others) {
|
||||
if (other) {
|
||||
for (const item of other._items) {
|
||||
this._items.push(Object.assign({}, item)); // Shallow cloned
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort items
|
||||
|
||||
this._items.sort(internals.mergeSort);
|
||||
for (let i = 0; i < this._items.length; ++i) {
|
||||
this._items[i].seq = i;
|
||||
}
|
||||
|
||||
const valid = this._sort();
|
||||
Assert(valid, 'merge created a dependencies error');
|
||||
|
||||
return this.nodes;
|
||||
}
|
||||
|
||||
sort() {
|
||||
|
||||
const valid = this._sort();
|
||||
Assert(valid, 'sort created a dependencies error');
|
||||
|
||||
return this.nodes;
|
||||
}
|
||||
|
||||
_sort() {
|
||||
|
||||
// Construct graph
|
||||
|
||||
const graph = {};
|
||||
const graphAfters = Object.create(null); // A prototype can bungle lookups w/ false positives
|
||||
const groups = Object.create(null);
|
||||
|
||||
for (const item of this._items) {
|
||||
const seq = item.seq; // Unique across all items
|
||||
const group = item.group;
|
||||
|
||||
// Determine Groups
|
||||
|
||||
groups[group] = groups[group] || [];
|
||||
groups[group].push(seq);
|
||||
|
||||
// Build intermediary graph using 'before'
|
||||
|
||||
graph[seq] = item.before;
|
||||
|
||||
// Build second intermediary graph with 'after'
|
||||
|
||||
for (const after of item.after) {
|
||||
graphAfters[after] = graphAfters[after] || [];
|
||||
graphAfters[after].push(seq);
|
||||
}
|
||||
}
|
||||
|
||||
// Expand intermediary graph
|
||||
|
||||
for (const node in graph) {
|
||||
const expandedGroups = [];
|
||||
|
||||
for (const graphNodeItem in graph[node]) {
|
||||
const group = graph[node][graphNodeItem];
|
||||
groups[group] = groups[group] || [];
|
||||
expandedGroups.push(...groups[group]);
|
||||
}
|
||||
|
||||
graph[node] = expandedGroups;
|
||||
}
|
||||
|
||||
// Merge intermediary graph using graphAfters into final graph
|
||||
|
||||
for (const group in graphAfters) {
|
||||
if (groups[group]) {
|
||||
for (const node of groups[group]) {
|
||||
graph[node].push(...graphAfters[group]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Compile ancestors
|
||||
|
||||
const ancestors = {};
|
||||
for (const node in graph) {
|
||||
const children = graph[node];
|
||||
for (const child of children) {
|
||||
ancestors[child] = ancestors[child] || [];
|
||||
ancestors[child].push(node);
|
||||
}
|
||||
}
|
||||
|
||||
// Topo sort
|
||||
|
||||
const visited = {};
|
||||
const sorted = [];
|
||||
|
||||
for (let i = 0; i < this._items.length; ++i) { // Looping through item.seq values out of order
|
||||
let next = i;
|
||||
|
||||
if (ancestors[i]) {
|
||||
next = null;
|
||||
for (let j = 0; j < this._items.length; ++j) { // As above, these are item.seq values
|
||||
if (visited[j] === true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!ancestors[j]) {
|
||||
ancestors[j] = [];
|
||||
}
|
||||
|
||||
const shouldSeeCount = ancestors[j].length;
|
||||
let seenCount = 0;
|
||||
for (let k = 0; k < shouldSeeCount; ++k) {
|
||||
if (visited[ancestors[j][k]]) {
|
||||
++seenCount;
|
||||
}
|
||||
}
|
||||
|
||||
if (seenCount === shouldSeeCount) {
|
||||
next = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (next !== null) {
|
||||
visited[next] = true;
|
||||
sorted.push(next);
|
||||
}
|
||||
}
|
||||
|
||||
if (sorted.length !== this._items.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const seqIndex = {};
|
||||
for (const item of this._items) {
|
||||
seqIndex[item.seq] = item;
|
||||
}
|
||||
|
||||
this._items = [];
|
||||
this.nodes = [];
|
||||
|
||||
for (const value of sorted) {
|
||||
const sortedItem = seqIndex[value];
|
||||
this.nodes.push(sortedItem.node);
|
||||
this._items.push(sortedItem);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
internals.mergeSort = (a, b) => {
|
||||
|
||||
return a.sort === b.sort ? 0 : (a.sort < b.sort ? -1 : 1);
|
||||
};
|
||||
63
node_modules/@hapi/topo/package.json
generated
vendored
Normal file
63
node_modules/@hapi/topo/package.json
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"_from": "@hapi/topo@^5.0.0",
|
||||
"_id": "@hapi/topo@5.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-foQZKJig7Ob0BMAYBfcJk8d77QtOe7Wo4ox7ff1lQYoNNAb6jwcY1ncdoy2e9wQZzvNy7ODZCYJkK8kzmcAnAg==",
|
||||
"_location": "/@hapi/topo",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@hapi/topo@^5.0.0",
|
||||
"name": "@hapi/topo",
|
||||
"escapedName": "@hapi%2ftopo",
|
||||
"scope": "@hapi",
|
||||
"rawSpec": "^5.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^5.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/joi"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-5.1.0.tgz",
|
||||
"_shasum": "dc448e332c6c6e37a4dc02fd84ba8d44b9afb012",
|
||||
"_spec": "@hapi/topo@^5.0.0",
|
||||
"_where": "C:\\Users\\anelissen\\Development\\tools\\node\\cbor\\node_modules\\joi",
|
||||
"bugs": {
|
||||
"url": "https://github.com/hapijs/topo/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"@hapi/hoek": "^9.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Topological sorting with grouping support",
|
||||
"devDependencies": {
|
||||
"@hapi/code": "8.x.x",
|
||||
"@hapi/lab": "24.x.x",
|
||||
"typescript": "~4.0.2"
|
||||
},
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"homepage": "https://github.com/hapijs/topo#readme",
|
||||
"keywords": [
|
||||
"topological",
|
||||
"sort",
|
||||
"toposort",
|
||||
"topsort"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"main": "lib/index.js",
|
||||
"name": "@hapi/topo",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/hapijs/topo.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "lab -a @hapi/code -t 100 -L -Y",
|
||||
"test-cov-html": "lab -a @hapi/code -t 100 -L -r html -o coverage.html"
|
||||
},
|
||||
"types": "lib/index.d.ts",
|
||||
"version": "5.1.0"
|
||||
}
|
||||
9
node_modules/@sideway/address/LICENSE.md
generated
vendored
Normal file
9
node_modules/@sideway/address/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
Copyright (c) 2019-2020, Sideway, Inc. and Project contributors
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* The names of any contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
14
node_modules/@sideway/address/README.md
generated
vendored
Normal file
14
node_modules/@sideway/address/README.md
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
# @sideway/address
|
||||
|
||||
#### Validate email address and domain.
|
||||
|
||||
**address** is part of the **joi** ecosystem.
|
||||
|
||||
### Visit the [joi.dev](https://joi.dev) Developer Portal for tutorials, documentation, and support
|
||||
|
||||
## Useful resources
|
||||
|
||||
- [Documentation and API](https://joi.dev/module/address/)
|
||||
- [Versions status](https://joi.dev/resources/status/#address)
|
||||
- [Changelog](https://joi.dev/module/address/changelog/)
|
||||
- [Project policies](https://joi.dev/policies/)
|
||||
120
node_modules/@sideway/address/lib/decode.js
generated
vendored
Normal file
120
node_modules/@sideway/address/lib/decode.js
generated
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
'use strict';
|
||||
|
||||
// Adapted from:
|
||||
// Copyright (c) 2017-2019 Justin Ridgewell, MIT Licensed, https://github.com/jridgewell/safe-decode-string-component
|
||||
// Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>, MIT Licensed, http://bjoern.hoehrmann.de/utf-8/decoder/dfa/
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
exports.decode = function (string) {
|
||||
|
||||
let percentPos = string.indexOf('%');
|
||||
if (percentPos === -1) {
|
||||
return string;
|
||||
}
|
||||
|
||||
let decoded = '';
|
||||
let last = 0;
|
||||
let codepoint = 0;
|
||||
let startOfOctets = percentPos;
|
||||
let state = internals.utf8.accept;
|
||||
|
||||
while (percentPos > -1 &&
|
||||
percentPos < string.length) {
|
||||
|
||||
const high = internals.resolveHex(string[percentPos + 1], 4);
|
||||
const low = internals.resolveHex(string[percentPos + 2], 0);
|
||||
const byte = high | low;
|
||||
const type = internals.utf8.data[byte];
|
||||
state = internals.utf8.data[256 + state + type];
|
||||
codepoint = (codepoint << 6) | (byte & internals.utf8.data[364 + type]);
|
||||
|
||||
if (state === internals.utf8.accept) {
|
||||
decoded += string.slice(last, startOfOctets);
|
||||
decoded += codepoint <= 0xFFFF
|
||||
? String.fromCharCode(codepoint)
|
||||
: String.fromCharCode(0xD7C0 + (codepoint >> 10), 0xDC00 + (codepoint & 0x3FF));
|
||||
|
||||
codepoint = 0;
|
||||
last = percentPos + 3;
|
||||
percentPos = string.indexOf('%', last);
|
||||
startOfOctets = percentPos;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (state === internals.utf8.reject) {
|
||||
return null;
|
||||
}
|
||||
|
||||
percentPos += 3;
|
||||
|
||||
if (percentPos >= string.length ||
|
||||
string[percentPos] !== '%') {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return decoded + string.slice(last);
|
||||
};
|
||||
|
||||
|
||||
internals.resolveHex = function (char, shift) {
|
||||
|
||||
const i = internals.hex[char];
|
||||
return i === undefined ? 255 : i << shift;
|
||||
};
|
||||
|
||||
|
||||
internals.hex = {
|
||||
'0': 0, '1': 1, '2': 2, '3': 3, '4': 4,
|
||||
'5': 5, '6': 6, '7': 7, '8': 8, '9': 9,
|
||||
'a': 10, 'A': 10, 'b': 11, 'B': 11, 'c': 12,
|
||||
'C': 12, 'd': 13, 'D': 13, 'e': 14, 'E': 14,
|
||||
'f': 15, 'F': 15
|
||||
};
|
||||
|
||||
|
||||
internals.utf8 = {
|
||||
accept: 12,
|
||||
reject: 0,
|
||||
data: [
|
||||
|
||||
// Maps bytes to character to a transition
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 7, 7,
|
||||
10, 9, 9, 9, 11, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
|
||||
// Maps a state to a new state when adding a transition
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
12, 0, 0, 0, 0, 24, 36, 48, 60, 72, 84, 96,
|
||||
0, 12, 12, 12, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 24, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 48, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
// Maps the current transition to a mask that needs to apply to the byte
|
||||
|
||||
0x7F, 0x3F, 0x3F, 0x3F, 0x00, 0x1F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07
|
||||
]
|
||||
};
|
||||
113
node_modules/@sideway/address/lib/domain.js
generated
vendored
Normal file
113
node_modules/@sideway/address/lib/domain.js
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
'use strict';
|
||||
|
||||
const Url = require('url');
|
||||
|
||||
const Errors = require('./errors');
|
||||
|
||||
|
||||
const internals = {
|
||||
minDomainSegments: 2,
|
||||
nonAsciiRx: /[^\x00-\x7f]/,
|
||||
domainControlRx: /[\x00-\x20@\:\/\\#!\$&\'\(\)\*\+,;=\?]/, // Control + space + separators
|
||||
tldSegmentRx: /^[a-zA-Z](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?$/,
|
||||
domainSegmentRx: /^[a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?$/,
|
||||
URL: Url.URL || URL // $lab:coverage:ignore$
|
||||
};
|
||||
|
||||
|
||||
exports.analyze = function (domain, options = {}) {
|
||||
|
||||
if (typeof domain !== 'string') {
|
||||
throw new Error('Invalid input: domain must be a string');
|
||||
}
|
||||
|
||||
if (!domain) {
|
||||
return Errors.code('DOMAIN_NON_EMPTY_STRING');
|
||||
}
|
||||
|
||||
if (domain.length > 256) {
|
||||
return Errors.code('DOMAIN_TOO_LONG');
|
||||
}
|
||||
|
||||
const ascii = !internals.nonAsciiRx.test(domain);
|
||||
if (!ascii) {
|
||||
if (options.allowUnicode === false) { // Defaults to true
|
||||
return Errors.code('DOMAIN_INVALID_UNICODE_CHARS');
|
||||
}
|
||||
|
||||
domain = domain.normalize('NFC');
|
||||
}
|
||||
|
||||
if (internals.domainControlRx.test(domain)) {
|
||||
return Errors.code('DOMAIN_INVALID_CHARS');
|
||||
}
|
||||
|
||||
domain = internals.punycode(domain);
|
||||
|
||||
// https://tools.ietf.org/html/rfc1035 section 2.3.1
|
||||
|
||||
const minDomainSegments = options.minDomainSegments || internals.minDomainSegments;
|
||||
|
||||
const segments = domain.split('.');
|
||||
if (segments.length < minDomainSegments) {
|
||||
return Errors.code('DOMAIN_SEGMENTS_COUNT');
|
||||
}
|
||||
|
||||
if (options.maxDomainSegments) {
|
||||
if (segments.length > options.maxDomainSegments) {
|
||||
return Errors.code('DOMAIN_SEGMENTS_COUNT_MAX');
|
||||
}
|
||||
}
|
||||
|
||||
const tlds = options.tlds;
|
||||
if (tlds) {
|
||||
const tld = segments[segments.length - 1].toLowerCase();
|
||||
if (tlds.deny && tlds.deny.has(tld) ||
|
||||
tlds.allow && !tlds.allow.has(tld)) {
|
||||
|
||||
return Errors.code('DOMAIN_FORBIDDEN_TLDS');
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < segments.length; ++i) {
|
||||
const segment = segments[i];
|
||||
|
||||
if (!segment.length) {
|
||||
return Errors.code('DOMAIN_EMPTY_SEGMENT');
|
||||
}
|
||||
|
||||
if (segment.length > 63) {
|
||||
return Errors.code('DOMAIN_LONG_SEGMENT');
|
||||
}
|
||||
|
||||
if (i < segments.length - 1) {
|
||||
if (!internals.domainSegmentRx.test(segment)) {
|
||||
return Errors.code('DOMAIN_INVALID_CHARS');
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!internals.tldSegmentRx.test(segment)) {
|
||||
return Errors.code('DOMAIN_INVALID_TLDS_CHARS');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
|
||||
exports.isValid = function (domain, options) {
|
||||
|
||||
return !exports.analyze(domain, options);
|
||||
};
|
||||
|
||||
|
||||
internals.punycode = function (domain) {
|
||||
|
||||
try {
|
||||
return new internals.URL(`http://${domain}`).host;
|
||||
}
|
||||
catch (err) {
|
||||
return domain;
|
||||
}
|
||||
};
|
||||
170
node_modules/@sideway/address/lib/email.js
generated
vendored
Normal file
170
node_modules/@sideway/address/lib/email.js
generated
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
'use strict';
|
||||
|
||||
const Util = require('util');
|
||||
|
||||
const Domain = require('./domain');
|
||||
const Errors = require('./errors');
|
||||
|
||||
|
||||
const internals = {
|
||||
nonAsciiRx: /[^\x00-\x7f]/,
|
||||
encoder: new (Util.TextEncoder || TextEncoder)() // $lab:coverage:ignore$
|
||||
};
|
||||
|
||||
|
||||
exports.analyze = function (email, options) {
|
||||
|
||||
return internals.email(email, options);
|
||||
};
|
||||
|
||||
|
||||
exports.isValid = function (email, options) {
|
||||
|
||||
return !internals.email(email, options);
|
||||
};
|
||||
|
||||
|
||||
internals.email = function (email, options = {}) {
|
||||
|
||||
if (typeof email !== 'string') {
|
||||
throw new Error('Invalid input: email must be a string');
|
||||
}
|
||||
|
||||
if (!email) {
|
||||
return Errors.code('EMPTY_STRING');
|
||||
}
|
||||
|
||||
// Unicode
|
||||
|
||||
const ascii = !internals.nonAsciiRx.test(email);
|
||||
if (!ascii) {
|
||||
if (options.allowUnicode === false) { // Defaults to true
|
||||
return Errors.code('FORBIDDEN_UNICODE');
|
||||
}
|
||||
|
||||
email = email.normalize('NFC');
|
||||
}
|
||||
|
||||
// Basic structure
|
||||
|
||||
const parts = email.split('@');
|
||||
if (parts.length !== 2) {
|
||||
return parts.length > 2 ? Errors.code('MULTIPLE_AT_CHAR') : Errors.code('MISSING_AT_CHAR');
|
||||
}
|
||||
|
||||
const [local, domain] = parts;
|
||||
|
||||
if (!local) {
|
||||
return Errors.code('EMPTY_LOCAL');
|
||||
}
|
||||
|
||||
if (!options.ignoreLength) {
|
||||
if (email.length > 254) { // http://tools.ietf.org/html/rfc5321#section-4.5.3.1.3
|
||||
return Errors.code('ADDRESS_TOO_LONG');
|
||||
}
|
||||
|
||||
if (internals.encoder.encode(local).length > 64) { // http://tools.ietf.org/html/rfc5321#section-4.5.3.1.1
|
||||
return Errors.code('LOCAL_TOO_LONG');
|
||||
}
|
||||
}
|
||||
|
||||
// Validate parts
|
||||
|
||||
return internals.local(local, ascii) || Domain.analyze(domain, options);
|
||||
};
|
||||
|
||||
|
||||
internals.local = function (local, ascii) {
|
||||
|
||||
const segments = local.split('.');
|
||||
for (const segment of segments) {
|
||||
if (!segment.length) {
|
||||
return Errors.code('EMPTY_LOCAL_SEGMENT');
|
||||
}
|
||||
|
||||
if (ascii) {
|
||||
if (!internals.atextRx.test(segment)) {
|
||||
return Errors.code('INVALID_LOCAL_CHARS');
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const char of segment) {
|
||||
if (internals.atextRx.test(char)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const binary = internals.binary(char);
|
||||
if (!internals.atomRx.test(binary)) {
|
||||
return Errors.code('INVALID_LOCAL_CHARS');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
internals.binary = function (char) {
|
||||
|
||||
return Array.from(internals.encoder.encode(char)).map((v) => String.fromCharCode(v)).join('');
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
From RFC 5321:
|
||||
|
||||
Mailbox = Local-part "@" ( Domain / address-literal )
|
||||
|
||||
Local-part = Dot-string / Quoted-string
|
||||
Dot-string = Atom *("." Atom)
|
||||
Atom = 1*atext
|
||||
atext = ALPHA / DIGIT / "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "/" / "=" / "?" / "^" / "_" / "`" / "{" / "|" / "}" / "~"
|
||||
|
||||
Domain = sub-domain *("." sub-domain)
|
||||
sub-domain = Let-dig [Ldh-str]
|
||||
Let-dig = ALPHA / DIGIT
|
||||
Ldh-str = *( ALPHA / DIGIT / "-" ) Let-dig
|
||||
|
||||
ALPHA = %x41-5A / %x61-7A ; a-z, A-Z
|
||||
DIGIT = %x30-39 ; 0-9
|
||||
|
||||
From RFC 6531:
|
||||
|
||||
sub-domain =/ U-label
|
||||
atext =/ UTF8-non-ascii
|
||||
|
||||
UTF8-non-ascii = UTF8-2 / UTF8-3 / UTF8-4
|
||||
|
||||
UTF8-2 = %xC2-DF UTF8-tail
|
||||
UTF8-3 = %xE0 %xA0-BF UTF8-tail /
|
||||
%xE1-EC 2( UTF8-tail ) /
|
||||
%xED %x80-9F UTF8-tail /
|
||||
%xEE-EF 2( UTF8-tail )
|
||||
UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ) /
|
||||
%xF1-F3 3( UTF8-tail ) /
|
||||
%xF4 %x80-8F 2( UTF8-tail )
|
||||
|
||||
UTF8-tail = %x80-BF
|
||||
|
||||
Note: The following are not supported:
|
||||
|
||||
RFC 5321: address-literal, Quoted-string
|
||||
RFC 5322: obs-*, CFWS
|
||||
*/
|
||||
|
||||
|
||||
internals.atextRx = /^[\w!#\$%&'\*\+\-/=\?\^`\{\|\}~]+$/; // _ included in \w
|
||||
|
||||
|
||||
internals.atomRx = new RegExp([
|
||||
|
||||
// %xC2-DF UTF8-tail
|
||||
'(?:[\\xc2-\\xdf][\\x80-\\xbf])',
|
||||
|
||||
// %xE0 %xA0-BF UTF8-tail %xE1-EC 2( UTF8-tail ) %xED %x80-9F UTF8-tail %xEE-EF 2( UTF8-tail )
|
||||
'(?:\\xe0[\\xa0-\\xbf][\\x80-\\xbf])|(?:[\\xe1-\\xec][\\x80-\\xbf]{2})|(?:\\xed[\\x80-\\x9f][\\x80-\\xbf])|(?:[\\xee-\\xef][\\x80-\\xbf]{2})',
|
||||
|
||||
// %xF0 %x90-BF 2( UTF8-tail ) %xF1-F3 3( UTF8-tail ) %xF4 %x80-8F 2( UTF8-tail )
|
||||
'(?:\\xf0[\\x90-\\xbf][\\x80-\\xbf]{2})|(?:[\\xf1-\\xf3][\\x80-\\xbf]{3})|(?:\\xf4[\\x80-\\x8f][\\x80-\\xbf]{2})'
|
||||
|
||||
].join('|'));
|
||||
29
node_modules/@sideway/address/lib/errors.js
generated
vendored
Normal file
29
node_modules/@sideway/address/lib/errors.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
exports.codes = {
|
||||
EMPTY_STRING: 'Address must be a non-empty string',
|
||||
FORBIDDEN_UNICODE: 'Address contains forbidden Unicode characters',
|
||||
MULTIPLE_AT_CHAR: 'Address cannot contain more than one @ character',
|
||||
MISSING_AT_CHAR: 'Address must contain one @ character',
|
||||
EMPTY_LOCAL: 'Address local part cannot be empty',
|
||||
ADDRESS_TOO_LONG: 'Address too long',
|
||||
LOCAL_TOO_LONG: 'Address local part too long',
|
||||
EMPTY_LOCAL_SEGMENT: 'Address local part contains empty dot-separated segment',
|
||||
INVALID_LOCAL_CHARS: 'Address local part contains invalid character',
|
||||
DOMAIN_NON_EMPTY_STRING: 'Domain must be a non-empty string',
|
||||
DOMAIN_TOO_LONG: 'Domain too long',
|
||||
DOMAIN_INVALID_UNICODE_CHARS: 'Domain contains forbidden Unicode characters',
|
||||
DOMAIN_INVALID_CHARS: 'Domain contains invalid character',
|
||||
DOMAIN_INVALID_TLDS_CHARS: 'Domain contains invalid tld character',
|
||||
DOMAIN_SEGMENTS_COUNT: 'Domain lacks the minimum required number of segments',
|
||||
DOMAIN_SEGMENTS_COUNT_MAX: 'Domain contains too many segments',
|
||||
DOMAIN_FORBIDDEN_TLDS: 'Domain uses forbidden TLD',
|
||||
DOMAIN_EMPTY_SEGMENT: 'Domain contains empty dot-separated segment',
|
||||
DOMAIN_LONG_SEGMENT: 'Domain contains dot-separated segment that is too long'
|
||||
};
|
||||
|
||||
|
||||
exports.code = function (code) {
|
||||
|
||||
return { code, error: exports.codes[code] };
|
||||
};
|
||||
255
node_modules/@sideway/address/lib/index.d.ts
generated
vendored
Normal file
255
node_modules/@sideway/address/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,255 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import * as Hoek from '@hapi/hoek';
|
||||
|
||||
|
||||
export namespace domain {
|
||||
|
||||
/**
|
||||
* Analyzes a string to verify it is a valid domain name.
|
||||
*
|
||||
* @param domain - the domain name to validate.
|
||||
* @param options - optional settings.
|
||||
*
|
||||
* @return - undefined when valid, otherwise an object with single error key with a string message value.
|
||||
*/
|
||||
function analyze(domain: string, options?: Options): Analysis | null;
|
||||
|
||||
/**
|
||||
* Analyzes a string to verify it is a valid domain name.
|
||||
*
|
||||
* @param domain - the domain name to validate.
|
||||
* @param options - optional settings.
|
||||
*
|
||||
* @return - true when valid, otherwise false.
|
||||
*/
|
||||
function isValid(domain: string, options?: Options): boolean;
|
||||
|
||||
interface Options {
|
||||
|
||||
/**
|
||||
* Determines whether Unicode characters are allowed.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly allowUnicode?: boolean;
|
||||
|
||||
/**
|
||||
* The minimum number of domain segments (e.g. `x.y.z` has 3 segments) required.
|
||||
*
|
||||
* @default 2
|
||||
*/
|
||||
readonly minDomainSegments?: number;
|
||||
|
||||
/**
|
||||
* Top-level-domain options
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly tlds?: Tlds.Allow | Tlds.Deny | boolean;
|
||||
}
|
||||
|
||||
namespace Tlds {
|
||||
|
||||
interface Allow {
|
||||
|
||||
readonly allow: Set<string> | true;
|
||||
}
|
||||
|
||||
interface Deny {
|
||||
|
||||
readonly deny: Set<string>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export namespace email {
|
||||
|
||||
/**
|
||||
* Analyzes a string to verify it is a valid email address.
|
||||
*
|
||||
* @param email - the email address to validate.
|
||||
* @param options - optional settings.
|
||||
*
|
||||
* @return - undefined when valid, otherwise an object with single error key with a string message value.
|
||||
*/
|
||||
function analyze(email: string, options?: Options): Analysis | null;
|
||||
|
||||
/**
|
||||
* Analyzes a string to verify it is a valid email address.
|
||||
*
|
||||
* @param email - the email address to validate.
|
||||
* @param options - optional settings.
|
||||
*
|
||||
* @return - true when valid, otherwise false.
|
||||
*/
|
||||
function isValid(email: string, options?: Options): boolean;
|
||||
|
||||
interface Options extends domain.Options {
|
||||
|
||||
/**
|
||||
* Determines whether to ignore the standards maximum email length limit.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly ignoreLength?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export interface Analysis {
|
||||
|
||||
/**
|
||||
* The reason validation failed.
|
||||
*/
|
||||
error: string;
|
||||
|
||||
/**
|
||||
* The error code.
|
||||
*/
|
||||
code: string;
|
||||
}
|
||||
|
||||
|
||||
export const errors: Record<string, string>;
|
||||
|
||||
|
||||
export namespace ip {
|
||||
|
||||
/**
|
||||
* Generates a regular expression used to validate IP addresses.
|
||||
*
|
||||
* @param options - optional settings.
|
||||
*
|
||||
* @returns an object with the regular expression and meta data.
|
||||
*/
|
||||
function regex(options?: Options): Expression;
|
||||
|
||||
interface Options {
|
||||
|
||||
/**
|
||||
* The required CIDR mode.
|
||||
*
|
||||
* @default 'optional'
|
||||
*/
|
||||
readonly cidr?: Cidr;
|
||||
|
||||
/**
|
||||
* The allowed versions.
|
||||
*
|
||||
* @default ['ipv4', 'ipv6', 'ipvfuture']
|
||||
*/
|
||||
readonly version?: Version | Version[];
|
||||
}
|
||||
|
||||
type Cidr = 'optional' | 'required' | 'forbidden';
|
||||
type Version = 'ipv4' | 'ipv6' | 'ipvfuture';
|
||||
|
||||
interface Expression {
|
||||
|
||||
/**
|
||||
* The CIDR mode.
|
||||
*/
|
||||
cidr: Cidr;
|
||||
|
||||
/**
|
||||
* The raw regular expression string.
|
||||
*/
|
||||
raw: string;
|
||||
|
||||
/**
|
||||
* The regular expression.
|
||||
*/
|
||||
regex: RegExp;
|
||||
|
||||
/**
|
||||
* The array of versions allowed.
|
||||
*/
|
||||
versions: Version[];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export namespace uri {
|
||||
|
||||
/**
|
||||
* Faster version of decodeURIComponent() that does not throw.
|
||||
*
|
||||
* @param string - the URL string to decode.
|
||||
*
|
||||
* @returns the decoded string or null if invalid.
|
||||
*/
|
||||
function decode(string: string): string | null;
|
||||
|
||||
/**
|
||||
* Generates a regular expression used to validate URI addresses.
|
||||
*
|
||||
* @param options - optional settings.
|
||||
*
|
||||
* @returns an object with the regular expression and meta data.
|
||||
*/
|
||||
function regex(options?: Options): Expression;
|
||||
|
||||
type Options = Hoek.ts.XOR<Options.Options, Options.Relative>;
|
||||
|
||||
namespace Options {
|
||||
|
||||
interface Query {
|
||||
|
||||
/**
|
||||
* Allow the use of [] in query parameters.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly allowQuerySquareBrackets?: boolean;
|
||||
}
|
||||
|
||||
interface Relative extends Query {
|
||||
|
||||
/**
|
||||
* Requires the URI to be relative.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly relativeOnly?: boolean;
|
||||
}
|
||||
|
||||
interface Options extends Query {
|
||||
|
||||
/**
|
||||
* Allow relative URIs.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly allowRelative?: boolean;
|
||||
|
||||
/**
|
||||
* Capture domain segment ($1).
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly domain?: boolean;
|
||||
|
||||
/**
|
||||
* The allowed URI schemes.
|
||||
*/
|
||||
readonly scheme?: Scheme | Scheme[];
|
||||
}
|
||||
|
||||
type Scheme = string | RegExp;
|
||||
}
|
||||
|
||||
interface Expression {
|
||||
|
||||
/**
|
||||
* The raw regular expression string.
|
||||
*/
|
||||
raw: string;
|
||||
|
||||
/**
|
||||
* The regular expression.
|
||||
*/
|
||||
regex: RegExp;
|
||||
}
|
||||
}
|
||||
97
node_modules/@sideway/address/lib/index.js
generated
vendored
Normal file
97
node_modules/@sideway/address/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
'use strict';
|
||||
|
||||
const Decode = require('./decode');
|
||||
const Domain = require('./domain');
|
||||
const Email = require('./email');
|
||||
const Errors = require('./errors');
|
||||
const Ip = require('./ip');
|
||||
const Tlds = require('./tlds');
|
||||
const Uri = require('./uri');
|
||||
|
||||
|
||||
const internals = {
|
||||
defaultTlds: { allow: Tlds, deny: null }
|
||||
};
|
||||
|
||||
|
||||
module.exports = {
|
||||
errors: Errors.codes,
|
||||
|
||||
domain: {
|
||||
analyze(domain, options) {
|
||||
|
||||
options = internals.options(options);
|
||||
return Domain.analyze(domain, options);
|
||||
},
|
||||
|
||||
isValid(domain, options) {
|
||||
|
||||
options = internals.options(options);
|
||||
return Domain.isValid(domain, options);
|
||||
}
|
||||
},
|
||||
email: {
|
||||
analyze(email, options) {
|
||||
|
||||
options = internals.options(options);
|
||||
return Email.analyze(email, options);
|
||||
},
|
||||
|
||||
isValid(email, options) {
|
||||
|
||||
options = internals.options(options);
|
||||
return Email.isValid(email, options);
|
||||
}
|
||||
},
|
||||
ip: {
|
||||
regex: Ip.regex
|
||||
},
|
||||
uri: {
|
||||
decode: Decode.decode,
|
||||
regex: Uri.regex
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
internals.options = function (options) {
|
||||
|
||||
if (!options) {
|
||||
return { tlds: internals.defaultTlds };
|
||||
}
|
||||
|
||||
if (options.tlds === false) { // Defaults to true
|
||||
return options;
|
||||
}
|
||||
|
||||
if (!options.tlds ||
|
||||
options.tlds === true) {
|
||||
|
||||
return Object.assign({}, options, { tlds: internals.defaultTlds });
|
||||
}
|
||||
|
||||
if (typeof options.tlds !== 'object') {
|
||||
throw new Error('Invalid options: tlds must be a boolean or an object');
|
||||
}
|
||||
|
||||
if (options.tlds.deny) {
|
||||
if (options.tlds.deny instanceof Set === false) {
|
||||
throw new Error('Invalid options: tlds.deny must be a Set object');
|
||||
}
|
||||
|
||||
if (options.tlds.allow) {
|
||||
throw new Error('Invalid options: cannot specify both tlds.allow and tlds.deny lists');
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
if (options.tlds.allow === true) {
|
||||
return Object.assign({}, options, { tlds: internals.defaultTlds });
|
||||
}
|
||||
|
||||
if (options.tlds.allow instanceof Set === false) {
|
||||
throw new Error('Invalid options: tlds.allow must be a Set object or true');
|
||||
}
|
||||
|
||||
return options;
|
||||
};
|
||||
63
node_modules/@sideway/address/lib/ip.js
generated
vendored
Normal file
63
node_modules/@sideway/address/lib/ip.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
'use strict';
|
||||
|
||||
const Assert = require('@hapi/hoek/lib/assert');
|
||||
|
||||
const Uri = require('./uri');
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
exports.regex = function (options = {}) {
|
||||
|
||||
// CIDR
|
||||
|
||||
Assert(options.cidr === undefined || typeof options.cidr === 'string', 'options.cidr must be a string');
|
||||
const cidr = options.cidr ? options.cidr.toLowerCase() : 'optional';
|
||||
Assert(['required', 'optional', 'forbidden'].includes(cidr), 'options.cidr must be one of required, optional, forbidden');
|
||||
|
||||
// Versions
|
||||
|
||||
Assert(options.version === undefined || typeof options.version === 'string' || Array.isArray(options.version), 'options.version must be a string or an array of string');
|
||||
let versions = options.version || ['ipv4', 'ipv6', 'ipvfuture'];
|
||||
if (!Array.isArray(versions)) {
|
||||
versions = [versions];
|
||||
}
|
||||
|
||||
Assert(versions.length >= 1, 'options.version must have at least 1 version specified');
|
||||
|
||||
for (let i = 0; i < versions.length; ++i) {
|
||||
Assert(typeof versions[i] === 'string', 'options.version must only contain strings');
|
||||
versions[i] = versions[i].toLowerCase();
|
||||
Assert(['ipv4', 'ipv6', 'ipvfuture'].includes(versions[i]), 'options.version contains unknown version ' + versions[i] + ' - must be one of ipv4, ipv6, ipvfuture');
|
||||
}
|
||||
|
||||
versions = Array.from(new Set(versions));
|
||||
|
||||
// Regex
|
||||
|
||||
const parts = versions.map((version) => {
|
||||
|
||||
// Forbidden
|
||||
|
||||
if (cidr === 'forbidden') {
|
||||
return Uri.ip[version];
|
||||
}
|
||||
|
||||
// Required
|
||||
|
||||
const cidrpart = `\\/${version === 'ipv4' ? Uri.ip.v4Cidr : Uri.ip.v6Cidr}`;
|
||||
|
||||
if (cidr === 'required') {
|
||||
return `${Uri.ip[version]}${cidrpart}`;
|
||||
}
|
||||
|
||||
// Optional
|
||||
|
||||
return `${Uri.ip[version]}(?:${cidrpart})?`;
|
||||
});
|
||||
|
||||
const raw = `(?:${parts.join('|')})`;
|
||||
const regex = new RegExp(`^${raw}$`);
|
||||
return { cidr, versions, regex, raw };
|
||||
};
|
||||
1520
node_modules/@sideway/address/lib/tlds.js
generated
vendored
Normal file
1520
node_modules/@sideway/address/lib/tlds.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
207
node_modules/@sideway/address/lib/uri.js
generated
vendored
Normal file
207
node_modules/@sideway/address/lib/uri.js
generated
vendored
Normal file
@@ -0,0 +1,207 @@
|
||||
'use strict';
|
||||
|
||||
const Assert = require('@hapi/hoek/lib/assert');
|
||||
const EscapeRegex = require('@hapi/hoek/lib/escapeRegex');
|
||||
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
internals.generate = function () {
|
||||
|
||||
const rfc3986 = {};
|
||||
|
||||
const hexDigit = '\\dA-Fa-f'; // HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
|
||||
const hexDigitOnly = '[' + hexDigit + ']';
|
||||
|
||||
const unreserved = '\\w-\\.~'; // unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
|
||||
const subDelims = '!\\$&\'\\(\\)\\*\\+,;='; // sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
|
||||
const pctEncoded = '%' + hexDigit; // pct-encoded = "%" HEXDIG HEXDIG
|
||||
const pchar = unreserved + pctEncoded + subDelims + ':@'; // pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
|
||||
const pcharOnly = '[' + pchar + ']';
|
||||
const decOctect = '(?:0{0,2}\\d|0?[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])'; // dec-octet = DIGIT / %x31-39 DIGIT / "1" 2DIGIT / "2" %x30-34 DIGIT / "25" %x30-35 ; 0-9 / 10-99 / 100-199 / 200-249 / 250-255
|
||||
|
||||
rfc3986.ipv4address = '(?:' + decOctect + '\\.){3}' + decOctect; // IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet
|
||||
|
||||
/*
|
||||
h16 = 1*4HEXDIG ; 16 bits of address represented in hexadecimal
|
||||
ls32 = ( h16 ":" h16 ) / IPv4address ; least-significant 32 bits of address
|
||||
IPv6address = 6( h16 ":" ) ls32
|
||||
/ "::" 5( h16 ":" ) ls32
|
||||
/ [ h16 ] "::" 4( h16 ":" ) ls32
|
||||
/ [ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32
|
||||
/ [ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32
|
||||
/ [ *3( h16 ":" ) h16 ] "::" h16 ":" ls32
|
||||
/ [ *4( h16 ":" ) h16 ] "::" ls32
|
||||
/ [ *5( h16 ":" ) h16 ] "::" h16
|
||||
/ [ *6( h16 ":" ) h16 ] "::"
|
||||
*/
|
||||
|
||||
const h16 = hexDigitOnly + '{1,4}';
|
||||
const ls32 = '(?:' + h16 + ':' + h16 + '|' + rfc3986.ipv4address + ')';
|
||||
const IPv6SixHex = '(?:' + h16 + ':){6}' + ls32;
|
||||
const IPv6FiveHex = '::(?:' + h16 + ':){5}' + ls32;
|
||||
const IPv6FourHex = '(?:' + h16 + ')?::(?:' + h16 + ':){4}' + ls32;
|
||||
const IPv6ThreeHex = '(?:(?:' + h16 + ':){0,1}' + h16 + ')?::(?:' + h16 + ':){3}' + ls32;
|
||||
const IPv6TwoHex = '(?:(?:' + h16 + ':){0,2}' + h16 + ')?::(?:' + h16 + ':){2}' + ls32;
|
||||
const IPv6OneHex = '(?:(?:' + h16 + ':){0,3}' + h16 + ')?::' + h16 + ':' + ls32;
|
||||
const IPv6NoneHex = '(?:(?:' + h16 + ':){0,4}' + h16 + ')?::' + ls32;
|
||||
const IPv6NoneHex2 = '(?:(?:' + h16 + ':){0,5}' + h16 + ')?::' + h16;
|
||||
const IPv6NoneHex3 = '(?:(?:' + h16 + ':){0,6}' + h16 + ')?::';
|
||||
|
||||
rfc3986.ipv4Cidr = '(?:\\d|[1-2]\\d|3[0-2])'; // IPv4 cidr = DIGIT / %x31-32 DIGIT / "3" %x30-32 ; 0-9 / 10-29 / 30-32
|
||||
rfc3986.ipv6Cidr = '(?:0{0,2}\\d|0?[1-9]\\d|1[01]\\d|12[0-8])'; // IPv6 cidr = DIGIT / %x31-39 DIGIT / "1" %x0-1 DIGIT / "12" %x0-8; 0-9 / 10-99 / 100-119 / 120-128
|
||||
rfc3986.ipv6address = '(?:' + IPv6SixHex + '|' + IPv6FiveHex + '|' + IPv6FourHex + '|' + IPv6ThreeHex + '|' + IPv6TwoHex + '|' + IPv6OneHex + '|' + IPv6NoneHex + '|' + IPv6NoneHex2 + '|' + IPv6NoneHex3 + ')';
|
||||
rfc3986.ipvFuture = 'v' + hexDigitOnly + '+\\.[' + unreserved + subDelims + ':]+'; // IPvFuture = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" )
|
||||
|
||||
rfc3986.scheme = '[a-zA-Z][a-zA-Z\\d+-\\.]*'; // scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
|
||||
rfc3986.schemeRegex = new RegExp(rfc3986.scheme);
|
||||
|
||||
const userinfo = '[' + unreserved + pctEncoded + subDelims + ':]*'; // userinfo = *( unreserved / pct-encoded / sub-delims / ":" )
|
||||
const IPLiteral = '\\[(?:' + rfc3986.ipv6address + '|' + rfc3986.ipvFuture + ')\\]'; // IP-literal = "[" ( IPv6address / IPvFuture ) "]"
|
||||
const regName = '[' + unreserved + pctEncoded + subDelims + ']{1,255}'; // reg-name = *( unreserved / pct-encoded / sub-delims )
|
||||
const host = '(?:' + IPLiteral + '|' + rfc3986.ipv4address + '|' + regName + ')'; // host = IP-literal / IPv4address / reg-name
|
||||
const port = '\\d*'; // port = *DIGIT
|
||||
const authority = '(?:' + userinfo + '@)?' + host + '(?::' + port + ')?'; // authority = [ userinfo "@" ] host [ ":" port ]
|
||||
const authorityCapture = '(?:' + userinfo + '@)?(' + host + ')(?::' + port + ')?';
|
||||
|
||||
/*
|
||||
segment = *pchar
|
||||
segment-nz = 1*pchar
|
||||
path = path-abempty ; begins with "/" '|' is empty
|
||||
/ path-absolute ; begins with "/" but not "//"
|
||||
/ path-noscheme ; begins with a non-colon segment
|
||||
/ path-rootless ; begins with a segment
|
||||
/ path-empty ; zero characters
|
||||
path-abempty = *( "/" segment )
|
||||
path-absolute = "/" [ segment-nz *( "/" segment ) ]
|
||||
path-rootless = segment-nz *( "/" segment )
|
||||
*/
|
||||
|
||||
const segment = pcharOnly + '*';
|
||||
const segmentNz = pcharOnly + '+';
|
||||
const segmentNzNc = '[' + unreserved + pctEncoded + subDelims + '@' + ']+';
|
||||
const pathEmpty = '';
|
||||
const pathAbEmpty = '(?:\\/' + segment + ')*';
|
||||
const pathAbsolute = '\\/(?:' + segmentNz + pathAbEmpty + ')?';
|
||||
const pathRootless = segmentNz + pathAbEmpty;
|
||||
const pathNoScheme = segmentNzNc + pathAbEmpty;
|
||||
const pathAbNoAuthority = '(?:\\/\\/\\/' + segment + pathAbEmpty + ')'; // Used by file:///
|
||||
|
||||
// hier-part = "//" authority path
|
||||
|
||||
rfc3986.hierPart = '(?:' + '(?:\\/\\/' + authority + pathAbEmpty + ')' + '|' + pathAbsolute + '|' + pathRootless + '|' + pathAbNoAuthority + ')';
|
||||
rfc3986.hierPartCapture = '(?:' + '(?:\\/\\/' + authorityCapture + pathAbEmpty + ')' + '|' + pathAbsolute + '|' + pathRootless + ')';
|
||||
|
||||
// relative-part = "//" authority path-abempty / path-absolute / path-noscheme / path-empty
|
||||
|
||||
rfc3986.relativeRef = '(?:' + '(?:\\/\\/' + authority + pathAbEmpty + ')' + '|' + pathAbsolute + '|' + pathNoScheme + '|' + pathEmpty + ')';
|
||||
rfc3986.relativeRefCapture = '(?:' + '(?:\\/\\/' + authorityCapture + pathAbEmpty + ')' + '|' + pathAbsolute + '|' + pathNoScheme + '|' + pathEmpty + ')';
|
||||
|
||||
// query = *( pchar / "/" / "?" )
|
||||
// query = *( pchar / "[" / "]" / "/" / "?" )
|
||||
|
||||
rfc3986.query = '[' + pchar + '\\/\\?]*(?=#|$)'; //Finish matching either at the fragment part '|' end of the line.
|
||||
rfc3986.queryWithSquareBrackets = '[' + pchar + '\\[\\]\\/\\?]*(?=#|$)';
|
||||
|
||||
// fragment = *( pchar / "/" / "?" )
|
||||
|
||||
rfc3986.fragment = '[' + pchar + '\\/\\?]*';
|
||||
|
||||
return rfc3986;
|
||||
};
|
||||
|
||||
internals.rfc3986 = internals.generate();
|
||||
|
||||
|
||||
exports.ip = {
|
||||
v4Cidr: internals.rfc3986.ipv4Cidr,
|
||||
v6Cidr: internals.rfc3986.ipv6Cidr,
|
||||
ipv4: internals.rfc3986.ipv4address,
|
||||
ipv6: internals.rfc3986.ipv6address,
|
||||
ipvfuture: internals.rfc3986.ipvFuture
|
||||
};
|
||||
|
||||
|
||||
internals.createRegex = function (options) {
|
||||
|
||||
const rfc = internals.rfc3986;
|
||||
|
||||
// Construct expression
|
||||
|
||||
const query = options.allowQuerySquareBrackets ? rfc.queryWithSquareBrackets : rfc.query;
|
||||
const suffix = '(?:\\?' + query + ')?' + '(?:#' + rfc.fragment + ')?';
|
||||
|
||||
// relative-ref = relative-part [ "?" query ] [ "#" fragment ]
|
||||
|
||||
const relative = options.domain ? rfc.relativeRefCapture : rfc.relativeRef;
|
||||
|
||||
if (options.relativeOnly) {
|
||||
return internals.wrap(relative + suffix);
|
||||
}
|
||||
|
||||
// Custom schemes
|
||||
|
||||
let customScheme = '';
|
||||
if (options.scheme) {
|
||||
Assert(options.scheme instanceof RegExp || typeof options.scheme === 'string' || Array.isArray(options.scheme), 'scheme must be a RegExp, String, or Array');
|
||||
|
||||
const schemes = [].concat(options.scheme);
|
||||
Assert(schemes.length >= 1, 'scheme must have at least 1 scheme specified');
|
||||
|
||||
// Flatten the array into a string to be used to match the schemes
|
||||
|
||||
const selections = [];
|
||||
for (let i = 0; i < schemes.length; ++i) {
|
||||
const scheme = schemes[i];
|
||||
Assert(scheme instanceof RegExp || typeof scheme === 'string', 'scheme at position ' + i + ' must be a RegExp or String');
|
||||
|
||||
if (scheme instanceof RegExp) {
|
||||
selections.push(scheme.source.toString());
|
||||
}
|
||||
else {
|
||||
Assert(rfc.schemeRegex.test(scheme), 'scheme at position ' + i + ' must be a valid scheme');
|
||||
selections.push(EscapeRegex(scheme));
|
||||
}
|
||||
}
|
||||
|
||||
customScheme = selections.join('|');
|
||||
}
|
||||
|
||||
// URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
|
||||
|
||||
const scheme = customScheme ? '(?:' + customScheme + ')' : rfc.scheme;
|
||||
const absolute = '(?:' + scheme + ':' + (options.domain ? rfc.hierPartCapture : rfc.hierPart) + ')';
|
||||
const prefix = options.allowRelative ? '(?:' + absolute + '|' + relative + ')' : absolute;
|
||||
return internals.wrap(prefix + suffix, customScheme);
|
||||
};
|
||||
|
||||
|
||||
internals.wrap = function (raw, scheme) {
|
||||
|
||||
raw = `(?=.)(?!https?\:/$)${raw}`; // Require at least one character and explicitly forbid 'http:/'
|
||||
|
||||
return {
|
||||
raw,
|
||||
regex: new RegExp(`^${raw}$`),
|
||||
scheme
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
internals.uriRegex = internals.createRegex({});
|
||||
|
||||
|
||||
exports.regex = function (options = {}) {
|
||||
|
||||
if (options.scheme ||
|
||||
options.allowRelative ||
|
||||
options.relativeOnly ||
|
||||
options.allowQuerySquareBrackets ||
|
||||
options.domain) {
|
||||
|
||||
return internals.createRegex(options);
|
||||
}
|
||||
|
||||
return internals.uriRegex;
|
||||
};
|
||||
63
node_modules/@sideway/address/package.json
generated
vendored
Normal file
63
node_modules/@sideway/address/package.json
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"_from": "@sideway/address@^4.1.0",
|
||||
"_id": "@sideway/address@4.1.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-idTz8ibqWFrPU8kMirL0CoPH/A29XOzzAzpyN3zQ4kAWnzmNfFmRaoMNN6VI8ske5M73HZyhIaW4OuSFIdM4oA==",
|
||||
"_location": "/@sideway/address",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@sideway/address@^4.1.0",
|
||||
"name": "@sideway/address",
|
||||
"escapedName": "@sideway%2faddress",
|
||||
"scope": "@sideway",
|
||||
"rawSpec": "^4.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^4.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/joi"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@sideway/address/-/address-4.1.2.tgz",
|
||||
"_shasum": "811b84333a335739d3969cfc434736268170cad1",
|
||||
"_spec": "@sideway/address@^4.1.0",
|
||||
"_where": "C:\\Users\\anelissen\\Development\\tools\\node\\cbor\\node_modules\\joi",
|
||||
"bugs": {
|
||||
"url": "https://github.com/sideway/address/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"@hapi/hoek": "^9.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Email address and domain validation",
|
||||
"devDependencies": {
|
||||
"@hapi/code": "8.x.x",
|
||||
"@hapi/lab": "24.x.x",
|
||||
"typescript": "4.0.x"
|
||||
},
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"homepage": "https://github.com/sideway/address#readme",
|
||||
"keywords": [
|
||||
"email",
|
||||
"domain",
|
||||
"address",
|
||||
"validation"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"main": "lib/index.js",
|
||||
"name": "@sideway/address",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/sideway/address.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "lab -a @hapi/code -t 100 -L -Y",
|
||||
"test-cov-html": "lab -a @hapi/code -t 100 -L -r html -o coverage.html"
|
||||
},
|
||||
"types": "lib/index.d.ts",
|
||||
"version": "4.1.2"
|
||||
}
|
||||
9
node_modules/@sideway/formula/LICENSE.md
generated
vendored
Normal file
9
node_modules/@sideway/formula/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
Copyright (c) 2019-2020, Sideway. Inc, and project contributors
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* The names of any contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
18
node_modules/@sideway/formula/README.md
generated
vendored
Normal file
18
node_modules/@sideway/formula/README.md
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
# @sideway/formula
|
||||
|
||||
#### Math and string formula parser.
|
||||
|
||||
**formula** is part of the **joi** ecosystem.
|
||||
|
||||
### Visit the [joi.dev](https://joi.dev) Developer Portal for tutorials, documentation, and support
|
||||
|
||||
## Useful resources
|
||||
|
||||
- [Documentation and API](https://joi.dev/module/formula/)
|
||||
- [Version status](https://joi.dev/resources/status/#formula) (builds, dependencies, node versions, licenses, eol)
|
||||
- [Changelog](https://joi.dev/module/formula/changelog/)
|
||||
- [Project policies](https://joi.dev/policies/)
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
Inspired by [**fparse**](https://github.com/bylexus/fparse), copyright 2012-2018 Alexander Schenkel <alex@alexi.ch>
|
||||
52
node_modules/@sideway/formula/lib/index.d.ts
generated
vendored
Normal file
52
node_modules/@sideway/formula/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Formula parser
|
||||
*/
|
||||
export class Parser<T extends (string | number)> {
|
||||
|
||||
/**
|
||||
* Create a new formula parser.
|
||||
*
|
||||
* @param formula - the formula string to parse.
|
||||
* @param options - optional settings.
|
||||
*/
|
||||
constructor(formula: string, options?: Options);
|
||||
|
||||
/**
|
||||
* Evaluate the formula.
|
||||
*
|
||||
* @param context - optional object with runtime formula context used to resolve variables.
|
||||
*
|
||||
* @returns the string or number outcome of the resolved formula.
|
||||
*/
|
||||
evaluate(context?: any): T;
|
||||
}
|
||||
|
||||
|
||||
export interface Options {
|
||||
|
||||
/**
|
||||
* A hash of key - value pairs used to convert constants to values.
|
||||
*/
|
||||
readonly constants?: Record<string, any>;
|
||||
|
||||
/**
|
||||
* A regular expression used to validate token variables.
|
||||
*/
|
||||
readonly tokenRx?: RegExp;
|
||||
|
||||
/**
|
||||
* A variable resolver factory function.
|
||||
*/
|
||||
readonly reference?: Options.Reference;
|
||||
|
||||
/**
|
||||
* A hash of key-value pairs used to resolve formula functions.
|
||||
*/
|
||||
readonly functions?: Record<string, Function>;
|
||||
}
|
||||
|
||||
|
||||
export namespace Options {
|
||||
|
||||
type Reference = (name: string) => (context: any) => any;
|
||||
}
|
||||
456
node_modules/@sideway/formula/lib/index.js
generated
vendored
Normal file
456
node_modules/@sideway/formula/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,456 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {
|
||||
operators: ['!', '^', '*', '/', '%', '+', '-', '<', '<=', '>', '>=', '==', '!=', '&&', '||', '??'],
|
||||
operatorCharacters: ['!', '^', '*', '/', '%', '+', '-', '<', '=', '>', '&', '|', '?'],
|
||||
operatorsOrder: [['^'], ['*', '/', '%'], ['+', '-'], ['<', '<=', '>', '>='], ['==', '!='], ['&&'], ['||', '??']],
|
||||
operatorsPrefix: ['!', 'n'],
|
||||
|
||||
literals: {
|
||||
'"': '"',
|
||||
'`': '`',
|
||||
'\'': '\'',
|
||||
'[': ']'
|
||||
},
|
||||
|
||||
numberRx: /^(?:[0-9]*\.?[0-9]*){1}$/,
|
||||
tokenRx: /^[\w\$\#\.\@\:\{\}]+$/,
|
||||
|
||||
symbol: Symbol('formula'),
|
||||
settings: Symbol('settings')
|
||||
};
|
||||
|
||||
|
||||
exports.Parser = class {
|
||||
|
||||
constructor(string, options = {}) {
|
||||
|
||||
if (!options[internals.settings] &&
|
||||
options.constants) {
|
||||
|
||||
for (const constant in options.constants) {
|
||||
const value = options.constants[constant];
|
||||
if (value !== null &&
|
||||
!['boolean', 'number', 'string'].includes(typeof value)) {
|
||||
|
||||
throw new Error(`Formula constant ${constant} contains invalid ${typeof value} value type`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.settings = options[internals.settings] ? options : Object.assign({ [internals.settings]: true, constants: {}, functions: {} }, options);
|
||||
this.single = null;
|
||||
|
||||
this._parts = null;
|
||||
this._parse(string);
|
||||
}
|
||||
|
||||
_parse(string) {
|
||||
|
||||
let parts = [];
|
||||
let current = '';
|
||||
let parenthesis = 0;
|
||||
let literal = false;
|
||||
|
||||
const flush = (inner) => {
|
||||
|
||||
if (parenthesis) {
|
||||
throw new Error('Formula missing closing parenthesis');
|
||||
}
|
||||
|
||||
const last = parts.length ? parts[parts.length - 1] : null;
|
||||
|
||||
if (!literal &&
|
||||
!current &&
|
||||
!inner) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (last &&
|
||||
last.type === 'reference' &&
|
||||
inner === ')') { // Function
|
||||
|
||||
last.type = 'function';
|
||||
last.value = this._subFormula(current, last.value);
|
||||
current = '';
|
||||
return;
|
||||
}
|
||||
|
||||
if (inner === ')') { // Segment
|
||||
const sub = new exports.Parser(current, this.settings);
|
||||
parts.push({ type: 'segment', value: sub });
|
||||
}
|
||||
else if (literal) {
|
||||
if (literal === ']') { // Reference
|
||||
parts.push({ type: 'reference', value: current });
|
||||
current = '';
|
||||
return;
|
||||
}
|
||||
|
||||
parts.push({ type: 'literal', value: current }); // Literal
|
||||
}
|
||||
else if (internals.operatorCharacters.includes(current)) { // Operator
|
||||
if (last &&
|
||||
last.type === 'operator' &&
|
||||
internals.operators.includes(last.value + current)) { // 2 characters operator
|
||||
|
||||
last.value += current;
|
||||
}
|
||||
else {
|
||||
parts.push({ type: 'operator', value: current });
|
||||
}
|
||||
}
|
||||
else if (current.match(internals.numberRx)) { // Number
|
||||
parts.push({ type: 'constant', value: parseFloat(current) });
|
||||
}
|
||||
else if (this.settings.constants[current] !== undefined) { // Constant
|
||||
parts.push({ type: 'constant', value: this.settings.constants[current] });
|
||||
}
|
||||
else { // Reference
|
||||
if (!current.match(internals.tokenRx)) {
|
||||
throw new Error(`Formula contains invalid token: ${current}`);
|
||||
}
|
||||
|
||||
parts.push({ type: 'reference', value: current });
|
||||
}
|
||||
|
||||
current = '';
|
||||
};
|
||||
|
||||
for (const c of string) {
|
||||
if (literal) {
|
||||
if (c === literal) {
|
||||
flush();
|
||||
literal = false;
|
||||
}
|
||||
else {
|
||||
current += c;
|
||||
}
|
||||
}
|
||||
else if (parenthesis) {
|
||||
if (c === '(') {
|
||||
current += c;
|
||||
++parenthesis;
|
||||
}
|
||||
else if (c === ')') {
|
||||
--parenthesis;
|
||||
if (!parenthesis) {
|
||||
flush(c);
|
||||
}
|
||||
else {
|
||||
current += c;
|
||||
}
|
||||
}
|
||||
else {
|
||||
current += c;
|
||||
}
|
||||
}
|
||||
else if (c in internals.literals) {
|
||||
literal = internals.literals[c];
|
||||
}
|
||||
else if (c === '(') {
|
||||
flush();
|
||||
++parenthesis;
|
||||
}
|
||||
else if (internals.operatorCharacters.includes(c)) {
|
||||
flush();
|
||||
current = c;
|
||||
flush();
|
||||
}
|
||||
else if (c !== ' ') {
|
||||
current += c;
|
||||
}
|
||||
else {
|
||||
flush();
|
||||
}
|
||||
}
|
||||
|
||||
flush();
|
||||
|
||||
// Replace prefix - to internal negative operator
|
||||
|
||||
parts = parts.map((part, i) => {
|
||||
|
||||
if (part.type !== 'operator' ||
|
||||
part.value !== '-' ||
|
||||
i && parts[i - 1].type !== 'operator') {
|
||||
|
||||
return part;
|
||||
}
|
||||
|
||||
return { type: 'operator', value: 'n' };
|
||||
});
|
||||
|
||||
// Validate tokens order
|
||||
|
||||
let operator = false;
|
||||
for (const part of parts) {
|
||||
if (part.type === 'operator') {
|
||||
if (internals.operatorsPrefix.includes(part.value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!operator) {
|
||||
throw new Error('Formula contains an operator in invalid position');
|
||||
}
|
||||
|
||||
if (!internals.operators.includes(part.value)) {
|
||||
throw new Error(`Formula contains an unknown operator ${part.value}`);
|
||||
}
|
||||
}
|
||||
else if (operator) {
|
||||
throw new Error('Formula missing expected operator');
|
||||
}
|
||||
|
||||
operator = !operator;
|
||||
}
|
||||
|
||||
if (!operator) {
|
||||
throw new Error('Formula contains invalid trailing operator');
|
||||
}
|
||||
|
||||
// Identify single part
|
||||
|
||||
if (parts.length === 1 &&
|
||||
['reference', 'literal', 'constant'].includes(parts[0].type)) {
|
||||
|
||||
this.single = { type: parts[0].type === 'reference' ? 'reference' : 'value', value: parts[0].value };
|
||||
}
|
||||
|
||||
// Process parts
|
||||
|
||||
this._parts = parts.map((part) => {
|
||||
|
||||
// Operators
|
||||
|
||||
if (part.type === 'operator') {
|
||||
return internals.operatorsPrefix.includes(part.value) ? part : part.value;
|
||||
}
|
||||
|
||||
// Literals, constants, segments
|
||||
|
||||
if (part.type !== 'reference') {
|
||||
return part.value;
|
||||
}
|
||||
|
||||
// References
|
||||
|
||||
if (this.settings.tokenRx &&
|
||||
!this.settings.tokenRx.test(part.value)) {
|
||||
|
||||
throw new Error(`Formula contains invalid reference ${part.value}`);
|
||||
}
|
||||
|
||||
if (this.settings.reference) {
|
||||
return this.settings.reference(part.value);
|
||||
}
|
||||
|
||||
return internals.reference(part.value);
|
||||
});
|
||||
}
|
||||
|
||||
_subFormula(string, name) {
|
||||
|
||||
const method = this.settings.functions[name];
|
||||
if (typeof method !== 'function') {
|
||||
throw new Error(`Formula contains unknown function ${name}`);
|
||||
}
|
||||
|
||||
let args = [];
|
||||
if (string) {
|
||||
let current = '';
|
||||
let parenthesis = 0;
|
||||
let literal = false;
|
||||
|
||||
const flush = () => {
|
||||
|
||||
if (!current) {
|
||||
throw new Error(`Formula contains function ${name} with invalid arguments ${string}`);
|
||||
}
|
||||
|
||||
args.push(current);
|
||||
current = '';
|
||||
};
|
||||
|
||||
for (let i = 0; i < string.length; ++i) {
|
||||
const c = string[i];
|
||||
if (literal) {
|
||||
current += c;
|
||||
if (c === literal) {
|
||||
literal = false;
|
||||
}
|
||||
}
|
||||
else if (c in internals.literals &&
|
||||
!parenthesis) {
|
||||
|
||||
current += c;
|
||||
literal = internals.literals[c];
|
||||
}
|
||||
else if (c === ',' &&
|
||||
!parenthesis) {
|
||||
|
||||
flush();
|
||||
}
|
||||
else {
|
||||
current += c;
|
||||
if (c === '(') {
|
||||
++parenthesis;
|
||||
}
|
||||
else if (c === ')') {
|
||||
--parenthesis;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flush();
|
||||
}
|
||||
|
||||
args = args.map((arg) => new exports.Parser(arg, this.settings));
|
||||
|
||||
return function (context) {
|
||||
|
||||
const innerValues = [];
|
||||
for (const arg of args) {
|
||||
innerValues.push(arg.evaluate(context));
|
||||
}
|
||||
|
||||
return method.call(context, ...innerValues);
|
||||
};
|
||||
}
|
||||
|
||||
evaluate(context) {
|
||||
|
||||
const parts = this._parts.slice();
|
||||
|
||||
// Prefix operators
|
||||
|
||||
for (let i = parts.length - 2; i >= 0; --i) {
|
||||
const part = parts[i];
|
||||
if (part &&
|
||||
part.type === 'operator') {
|
||||
|
||||
const current = parts[i + 1];
|
||||
parts.splice(i + 1, 1);
|
||||
const value = internals.evaluate(current, context);
|
||||
parts[i] = internals.single(part.value, value);
|
||||
}
|
||||
}
|
||||
|
||||
// Left-right operators
|
||||
|
||||
internals.operatorsOrder.forEach((set) => {
|
||||
|
||||
for (let i = 1; i < parts.length - 1;) {
|
||||
if (set.includes(parts[i])) {
|
||||
const operator = parts[i];
|
||||
const left = internals.evaluate(parts[i - 1], context);
|
||||
const right = internals.evaluate(parts[i + 1], context);
|
||||
|
||||
parts.splice(i, 2);
|
||||
const result = internals.calculate(operator, left, right);
|
||||
parts[i - 1] = result === 0 ? 0 : result; // Convert -0
|
||||
}
|
||||
else {
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return internals.evaluate(parts[0], context);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
exports.Parser.prototype[internals.symbol] = true;
|
||||
|
||||
|
||||
internals.reference = function (name) {
|
||||
|
||||
return function (context) {
|
||||
|
||||
return context && context[name] !== undefined ? context[name] : null;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
internals.evaluate = function (part, context) {
|
||||
|
||||
if (part === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (typeof part === 'function') {
|
||||
return part(context);
|
||||
}
|
||||
|
||||
if (part[internals.symbol]) {
|
||||
return part.evaluate(context);
|
||||
}
|
||||
|
||||
return part;
|
||||
};
|
||||
|
||||
|
||||
internals.single = function (operator, value) {
|
||||
|
||||
if (operator === '!') {
|
||||
return value ? false : true;
|
||||
}
|
||||
|
||||
// operator === 'n'
|
||||
|
||||
const negative = -value;
|
||||
if (negative === 0) { // Override -0
|
||||
return 0;
|
||||
}
|
||||
|
||||
return negative;
|
||||
};
|
||||
|
||||
|
||||
internals.calculate = function (operator, left, right) {
|
||||
|
||||
if (operator === '??') {
|
||||
return internals.exists(left) ? left : right;
|
||||
}
|
||||
|
||||
if (typeof left === 'string' ||
|
||||
typeof right === 'string') {
|
||||
|
||||
if (operator === '+') {
|
||||
left = internals.exists(left) ? left : '';
|
||||
right = internals.exists(right) ? right : '';
|
||||
return left + right;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (operator) {
|
||||
case '^': return Math.pow(left, right);
|
||||
case '*': return left * right;
|
||||
case '/': return left / right;
|
||||
case '%': return left % right;
|
||||
case '+': return left + right;
|
||||
case '-': return left - right;
|
||||
}
|
||||
}
|
||||
|
||||
switch (operator) {
|
||||
case '<': return left < right;
|
||||
case '<=': return left <= right;
|
||||
case '>': return left > right;
|
||||
case '>=': return left >= right;
|
||||
case '==': return left === right;
|
||||
case '!=': return left !== right;
|
||||
case '&&': return left && right;
|
||||
case '||': return left || right;
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
|
||||
internals.exists = function (value) {
|
||||
|
||||
return value !== null && value !== undefined;
|
||||
};
|
||||
61
node_modules/@sideway/formula/package.json
generated
vendored
Normal file
61
node_modules/@sideway/formula/package.json
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"_from": "@sideway/formula@^3.0.0",
|
||||
"_id": "@sideway/formula@3.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-vHe7wZ4NOXVfkoRb8T5otiENVlT7a3IAiw7H5M2+GO+9CDgcVUUsX1zalAztCmwyOr2RUTGJdgB+ZvSVqmdHmg==",
|
||||
"_location": "/@sideway/formula",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@sideway/formula@^3.0.0",
|
||||
"name": "@sideway/formula",
|
||||
"escapedName": "@sideway%2fformula",
|
||||
"scope": "@sideway",
|
||||
"rawSpec": "^3.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^3.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/joi"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@sideway/formula/-/formula-3.0.0.tgz",
|
||||
"_shasum": "fe158aee32e6bd5de85044be615bc08478a0a13c",
|
||||
"_spec": "@sideway/formula@^3.0.0",
|
||||
"_where": "C:\\Users\\anelissen\\Development\\tools\\node\\cbor\\node_modules\\joi",
|
||||
"bugs": {
|
||||
"url": "https://github.com/sideway/formula/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "Math and string formula parser.",
|
||||
"devDependencies": {
|
||||
"@hapi/code": "8.x.x",
|
||||
"@hapi/lab": "24.x.x",
|
||||
"typescript": "4.0.x"
|
||||
},
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"homepage": "https://github.com/sideway/formula#readme",
|
||||
"keywords": [
|
||||
"formula",
|
||||
"parser",
|
||||
"math",
|
||||
"string"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"main": "lib/index.js",
|
||||
"name": "@sideway/formula",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/sideway/formula.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "lab -a @hapi/code -t 100 -L -Y",
|
||||
"test-cov-html": "lab -a @hapi/code -t 100 -L -r html -o coverage.html"
|
||||
},
|
||||
"types": "lib/index.d.ts",
|
||||
"version": "3.0.0"
|
||||
}
|
||||
10
node_modules/@sideway/pinpoint/LICENSE.md
generated
vendored
Normal file
10
node_modules/@sideway/pinpoint/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
Copyright (c) 2019-2020, Sideway. Inc, and project contributors
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* The names of any contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS OFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
14
node_modules/@sideway/pinpoint/README.md
generated
vendored
Normal file
14
node_modules/@sideway/pinpoint/README.md
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
# @sideway/pinpoint
|
||||
|
||||
#### Return the filename and line number of the calling function.
|
||||
|
||||
**pinpoint** is part of the **joi** ecosystem.
|
||||
|
||||
### Visit the [joi.dev](https://joi.dev) Developer Portal for tutorials, documentation, and support
|
||||
|
||||
## Useful resources
|
||||
|
||||
- [Documentation and API](https://joi.dev/module/pinpoint/)
|
||||
- [Version status](https://joi.dev/resources/status/#pinpoint) (builds, dependencies, node versions, licenses, eol)
|
||||
- [Changelog](https://joi.dev/module/pinpoint/changelog/)
|
||||
- [Project policies](https://joi.dev/policies/)
|
||||
24
node_modules/@sideway/pinpoint/lib/index.d.ts
generated
vendored
Normal file
24
node_modules/@sideway/pinpoint/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
Returns the filename and line number of the caller in the call stack
|
||||
|
||||
@param depth - The distance from the location function in the call stack. Defaults to 1 (caller).
|
||||
|
||||
@return an object with the filename and line number.
|
||||
*/
|
||||
export function location(depth?: number): location.Location;
|
||||
|
||||
declare namespace location {
|
||||
|
||||
interface Location {
|
||||
|
||||
/**
|
||||
The fully qualified filename.
|
||||
*/
|
||||
readonly filename: string;
|
||||
|
||||
/**
|
||||
The file line number.
|
||||
*/
|
||||
readonly line: number;
|
||||
}
|
||||
}
|
||||
21
node_modules/@sideway/pinpoint/lib/index.js
generated
vendored
Normal file
21
node_modules/@sideway/pinpoint/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
const internals = {};
|
||||
|
||||
|
||||
exports.location = function (depth = 0) {
|
||||
|
||||
const orig = Error.prepareStackTrace;
|
||||
Error.prepareStackTrace = (ignore, stack) => stack;
|
||||
|
||||
const capture = {};
|
||||
Error.captureStackTrace(capture, this);
|
||||
const line = capture.stack[depth + 1];
|
||||
|
||||
Error.prepareStackTrace = orig;
|
||||
|
||||
return {
|
||||
filename: line.getFileName(),
|
||||
line: line.getLineNumber()
|
||||
};
|
||||
};
|
||||
58
node_modules/@sideway/pinpoint/package.json
generated
vendored
Normal file
58
node_modules/@sideway/pinpoint/package.json
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"_from": "@sideway/pinpoint@^2.0.0",
|
||||
"_id": "@sideway/pinpoint@2.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==",
|
||||
"_location": "/@sideway/pinpoint",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@sideway/pinpoint@^2.0.0",
|
||||
"name": "@sideway/pinpoint",
|
||||
"escapedName": "@sideway%2fpinpoint",
|
||||
"scope": "@sideway",
|
||||
"rawSpec": "^2.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/joi"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@sideway/pinpoint/-/pinpoint-2.0.0.tgz",
|
||||
"_shasum": "cff8ffadc372ad29fd3f78277aeb29e632cc70df",
|
||||
"_spec": "@sideway/pinpoint@^2.0.0",
|
||||
"_where": "C:\\Users\\anelissen\\Development\\tools\\node\\cbor\\node_modules\\joi",
|
||||
"bugs": {
|
||||
"url": "https://github.com/sideway/pinpoint/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "Return the filename and line number of the calling function",
|
||||
"devDependencies": {
|
||||
"@hapi/code": "8.x.x",
|
||||
"@hapi/lab": "24.x.x",
|
||||
"typescript": "4.0.x"
|
||||
},
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"homepage": "https://github.com/sideway/pinpoint#readme",
|
||||
"keywords": [
|
||||
"utilities"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"main": "lib/index.js",
|
||||
"name": "@sideway/pinpoint",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/sideway/pinpoint.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "lab -a @hapi/code -t 100 -L -Y",
|
||||
"test-cov-html": "lab -a @hapi/code -t 100 -L -r html -o coverage.html"
|
||||
},
|
||||
"types": "lib/index.d.ts",
|
||||
"version": "2.0.0"
|
||||
}
|
||||
21
node_modules/@types/bson/LICENSE
generated
vendored
Normal file
21
node_modules/@types/bson/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
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
|
||||
16
node_modules/@types/bson/README.md
generated
vendored
Normal file
16
node_modules/@types/bson/README.md
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
# Installation
|
||||
> `npm install --save @types/bson`
|
||||
|
||||
# Summary
|
||||
This package contains type definitions for bson (https://github.com/mongodb/js-bson).
|
||||
|
||||
# Details
|
||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/bson.
|
||||
|
||||
### Additional Details
|
||||
* Last updated: Tue, 06 Jul 2021 18:05:46 GMT
|
||||
* Dependencies: [@types/node](https://npmjs.com/package/@types/node)
|
||||
* Global values: none
|
||||
|
||||
# Credits
|
||||
These definitions were written by [Hiroki Horiuchi](https://github.com/horiuchi), [Federico Caselli](https://github.com/CaselIT), [Justin Grant](https://github.com/justingrant), and [Mikael Lirbank](https://github.com/lirbank).
|
||||
600
node_modules/@types/bson/index.d.ts
generated
vendored
Normal file
600
node_modules/@types/bson/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,600 @@
|
||||
// Type definitions for bson 4.0
|
||||
// Project: https://github.com/mongodb/js-bson
|
||||
// Definitions by: Hiroki Horiuchi <https://github.com/horiuchi>
|
||||
// Federico Caselli <https://github.com/CaselIT>
|
||||
// Justin Grant <https://github.com/justingrant>
|
||||
// Mikael Lirbank <https://github.com/lirbank>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node"/>
|
||||
|
||||
interface CommonSerializeOptions {
|
||||
/** {default:false}, the serializer will check if keys are valid. */
|
||||
checkKeys?: boolean | undefined;
|
||||
/** {default:false}, serialize the javascript functions. */
|
||||
serializeFunctions?: boolean | undefined;
|
||||
/** {default:true}, ignore undefined fields. */
|
||||
ignoreUndefined?: boolean | undefined;
|
||||
}
|
||||
|
||||
export interface SerializeOptions extends CommonSerializeOptions {
|
||||
/** {default:1024*1024*17}, minimum size of the internal temporary serialization buffer. */
|
||||
minInternalBufferSize?: number | undefined;
|
||||
}
|
||||
|
||||
export interface SerializeWithBufferAndIndexOptions extends CommonSerializeOptions {
|
||||
/** {default:0}, the index in the buffer where we wish to start serializing into. */
|
||||
index?: number | undefined;
|
||||
}
|
||||
|
||||
export interface DeserializeOptions {
|
||||
/** {default:false}, evaluate functions in the BSON document scoped to the object deserialized. */
|
||||
evalFunctions?: boolean | undefined;
|
||||
/** {default:false}, cache evaluated functions for reuse. */
|
||||
cacheFunctions?: boolean | undefined;
|
||||
/** {default:false}, use a crc32 code for caching, otherwise use the string of the function. */
|
||||
cacheFunctionsCrc32?: boolean | undefined;
|
||||
/** {default:true}, when deserializing a Long will fit it into a Number if it's smaller than 53 bits. */
|
||||
promoteLongs?: boolean | undefined;
|
||||
/** {default:false}, deserialize Binary data directly into node.js Buffer object. */
|
||||
promoteBuffers?: boolean | undefined;
|
||||
/** {default:false}, when deserializing will promote BSON values to their Node.js closest equivalent types. */
|
||||
promoteValues?: boolean | undefined;
|
||||
/** {default:null}, allow to specify if there what fields we wish to return as unserialized raw buffer. */
|
||||
fieldsAsRaw?: { readonly [fieldName: string]: boolean } | undefined;
|
||||
/** {default:false}, return BSON regular expressions as BSONRegExp instances. */
|
||||
bsonRegExp?: boolean | undefined;
|
||||
/** {default:false}, allows the buffer to be larger than the parsed BSON object. */
|
||||
allowObjectSmallerThanBufferSize?: boolean | undefined;
|
||||
}
|
||||
|
||||
export interface CalculateObjectSizeOptions {
|
||||
/** {default:false}, serialize the javascript functions */
|
||||
serializeFunctions?: boolean | undefined;
|
||||
/** {default:true}, ignore undefined fields. */
|
||||
ignoreUndefined?: boolean | undefined;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Serialize a Javascript object.
|
||||
*
|
||||
* @param object The Javascript object to serialize.
|
||||
* @param options Serialize options.
|
||||
* @return The Buffer object containing the serialized object.
|
||||
*/
|
||||
export function serialize(object: any, options?: SerializeOptions): Buffer;
|
||||
|
||||
/**
|
||||
* Serialize a Javascript object using a predefined Buffer and index into the buffer, useful when pre-allocating the space for serialization.
|
||||
*
|
||||
* @param object The Javascript object to serialize.
|
||||
* @param buffer The Buffer you pre-allocated to store the serialized BSON object.
|
||||
* @param options Serialize options.
|
||||
* @returns The index pointing to the last written byte in the buffer
|
||||
*/
|
||||
export function serializeWithBufferAndIndex(object: any, buffer: Buffer, options?: SerializeWithBufferAndIndexOptions): number;
|
||||
|
||||
/**
|
||||
* Deserialize data as BSON.
|
||||
*
|
||||
* @param buffer The buffer containing the serialized set of BSON documents.
|
||||
* @param options Deserialize options.
|
||||
* @returns The deserialized Javascript Object.
|
||||
*/
|
||||
export function deserialize(buffer: Buffer, options?: DeserializeOptions): any;
|
||||
|
||||
/**
|
||||
* Calculate the bson size for a passed in Javascript object.
|
||||
*
|
||||
* @param {Object} object the Javascript object to calculate the BSON byte size for.
|
||||
* @param {CalculateObjectSizeOptions} Options
|
||||
* @return {Number} returns the number of bytes the BSON object will take up.
|
||||
*/
|
||||
export function calculateObjectSize(object: any, options?: CalculateObjectSizeOptions): number;
|
||||
|
||||
/**
|
||||
* Deserialize stream data as BSON documents.
|
||||
*
|
||||
* @param data The buffer containing the serialized set of BSON documents.
|
||||
* @param startIndex The start index in the data Buffer where the deserialization is to start.
|
||||
* @param numberOfDocuments Number of documents to deserialize
|
||||
* @param documents An array where to store the deserialized documents
|
||||
* @param docStartIndex The index in the documents array from where to start inserting documents
|
||||
* @param options Additional options used for the deserialization
|
||||
* @returns The next index in the buffer after deserialization of the `numberOfDocuments`
|
||||
*/
|
||||
export function deserializeStream(
|
||||
data: Buffer,
|
||||
startIndex: number,
|
||||
numberOfDocuments: number,
|
||||
documents: Array<any>,
|
||||
docStartIndex: number,
|
||||
options?: DeserializeOptions
|
||||
): number;
|
||||
|
||||
/** A class representation of the BSON Binary type. */
|
||||
export class Binary {
|
||||
|
||||
static readonly SUBTYPE_DEFAULT: number;
|
||||
static readonly SUBTYPE_FUNCTION: number;
|
||||
static readonly SUBTYPE_BYTE_ARRAY: number;
|
||||
static readonly SUBTYPE_UUID_OLD: number;
|
||||
static readonly SUBTYPE_UUID: number;
|
||||
static readonly SUBTYPE_MD5: number;
|
||||
static readonly SUBTYPE_USER_DEFINED: number;
|
||||
|
||||
/**
|
||||
* @param buffer A buffer object containing the binary data
|
||||
* @param subType Binary data subtype
|
||||
*/
|
||||
constructor(buffer: Buffer, subType?: number);
|
||||
|
||||
/** The underlying Buffer which stores the binary data. */
|
||||
readonly buffer: Buffer;
|
||||
/** Binary data subtype */
|
||||
readonly sub_type?: number | undefined;
|
||||
|
||||
/** The length of the binary. */
|
||||
length(): number;
|
||||
/** Updates this binary with byte_value */
|
||||
put(byte_value: number | string): void;
|
||||
/** Reads length bytes starting at position. */
|
||||
read(position: number, length: number): Buffer;
|
||||
/** Returns the value of this binary as a string. */
|
||||
value(): string;
|
||||
/** Writes a buffer or string to the binary */
|
||||
write(buffer: Buffer | string, offset: number): void;
|
||||
}
|
||||
|
||||
/** A class representation of the BSON Code type. */
|
||||
export class Code {
|
||||
|
||||
/**
|
||||
* @param code A string or function.
|
||||
* @param scope An optional scope for the function.
|
||||
*/
|
||||
constructor(code: string | Function, scope?: any);
|
||||
|
||||
readonly code: string | Function;
|
||||
readonly scope?: any;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A class representation of the BSON DBRef type.
|
||||
*/
|
||||
export class DBRef {
|
||||
/**
|
||||
* @param namespace The collection name.
|
||||
* @param oid The reference ObjectId.
|
||||
* @param db Optional db name, if omitted the reference is local to the current db
|
||||
*/
|
||||
constructor(namespace: string, oid: ObjectId, db?: string);
|
||||
namespace: string;
|
||||
oid: ObjectId;
|
||||
db?: string | undefined;
|
||||
}
|
||||
|
||||
/** A class representation of the BSON Double type. */
|
||||
export class Double {
|
||||
/**
|
||||
* @param value The number we want to represent as a double.
|
||||
*/
|
||||
constructor(value: number);
|
||||
|
||||
/**
|
||||
* https://github.com/mongodb/js-bson/blob/master/lib/double.js#L17
|
||||
*/
|
||||
value: number;
|
||||
|
||||
|
||||
valueOf(): number;
|
||||
}
|
||||
|
||||
/** A class representation of the BSON Int32 type. */
|
||||
export class Int32 {
|
||||
/**
|
||||
* @param value The number we want to represent as an int32.
|
||||
*/
|
||||
constructor(value: number);
|
||||
|
||||
valueOf(): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class for Long and Timestamp.
|
||||
* In original js-node@1.0.x code 'Timestamp' is a 100% copy-paste of 'Long'
|
||||
* with 'Long' replaced by 'Timestamp' (changed to inheritance in js-node@2.0.0)
|
||||
*/
|
||||
declare class LongLike<T> {
|
||||
|
||||
/**
|
||||
* @param low The low (signed) 32 bits.
|
||||
* @param high The high (signed) 32 bits.
|
||||
*/
|
||||
constructor(low: number, high: number);
|
||||
|
||||
/** Returns the sum of `this` and the `other`. */
|
||||
add(other: T): T;
|
||||
/** Returns the bitwise-AND of `this` and the `other`. */
|
||||
and(other: T): T;
|
||||
/**
|
||||
* Compares `this` with the given `other`.
|
||||
* @returns 0 if they are the same, 1 if the this is greater, and -1 if the given one is greater.
|
||||
*/
|
||||
compare(other: T): number;
|
||||
/** Returns `this` divided by the given `other`. */
|
||||
div(other: T): T;
|
||||
/** Return whether `this` equals the `other` */
|
||||
equals(other: T): boolean;
|
||||
/** Return the high 32-bits value. */
|
||||
getHighBits(): number;
|
||||
/** Return the low 32-bits value. */
|
||||
getLowBits(): number;
|
||||
/** Return the low unsigned 32-bits value. */
|
||||
getLowBitsUnsigned(): number;
|
||||
/** Returns the number of bits needed to represent the absolute value of `this`. */
|
||||
getNumBitsAbs(): number;
|
||||
/** Return whether `this` is greater than the `other`. */
|
||||
greaterThan(other: T): boolean;
|
||||
/** Return whether `this` is greater than or equal to the `other`. */
|
||||
greaterThanOrEqual(other: T): boolean;
|
||||
/** Return whether `this` value is negative. */
|
||||
isNegative(): boolean;
|
||||
/** Return whether `this` value is odd. */
|
||||
isOdd(): boolean;
|
||||
/** Return whether `this` value is zero. */
|
||||
isZero(): boolean;
|
||||
/** Return whether `this` is less than the `other`. */
|
||||
lessThan(other: T): boolean;
|
||||
/** Return whether `this` is less than or equal to the `other`. */
|
||||
lessThanOrEqual(other: T): boolean;
|
||||
/** Returns `this` modulo the given `other`. */
|
||||
modulo(other: T): T;
|
||||
/** Returns the product of `this` and the given `other`. */
|
||||
multiply(other: T): T;
|
||||
/** The negation of this value. */
|
||||
negate(): T;
|
||||
/** The bitwise-NOT of this value. */
|
||||
not(): T;
|
||||
/** Return whether `this` does not equal to the `other`. */
|
||||
notEquals(other: T): boolean;
|
||||
/** Returns the bitwise-OR of `this` and the given `other`. */
|
||||
or(other: T): T;
|
||||
/**
|
||||
* Returns `this` with bits shifted to the left by the given amount.
|
||||
* @param numBits The number of bits by which to shift.
|
||||
*/
|
||||
shiftLeft(numBits: number): T;
|
||||
/**
|
||||
* Returns `this` with bits shifted to the right by the given amount.
|
||||
* @param numBits The number of bits by which to shift.
|
||||
*/
|
||||
shiftRight(numBits: number): T;
|
||||
/**
|
||||
* Returns `this` with bits shifted to the right by the given amount, with the new top bits matching the current sign bit.
|
||||
* @param numBits The number of bits by which to shift.
|
||||
*/
|
||||
shiftRightUnsigned(numBits: number): T;
|
||||
/** Returns the difference of `this` and the given `other`. */
|
||||
subtract(other: T): T;
|
||||
/** Return the int value (low 32 bits). */
|
||||
toInt(): number;
|
||||
/** Return the JSON value. */
|
||||
toJSON(): string;
|
||||
/** Returns closest floating-point representation to `this` value */
|
||||
toNumber(): number;
|
||||
/**
|
||||
* Return as a string
|
||||
* @param radix the radix in which the text should be written. {default:10}
|
||||
*/
|
||||
toString(radix?: number): string;
|
||||
/** Returns the bitwise-XOR of `this` and the given `other`. */
|
||||
xor(other: T): T;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A class representation of the BSON Long type, a 64-bit two's-complement
|
||||
* integer value, which faithfully simulates the behavior of a Java "Long". This
|
||||
* implementation is derived from LongLib in GWT.
|
||||
*/
|
||||
export class Long extends LongLike<Long> {
|
||||
|
||||
static readonly MAX_VALUE: Long;
|
||||
static readonly MIN_VALUE: Long;
|
||||
static readonly NEG_ONE: Long;
|
||||
static readonly ONE: Long;
|
||||
static readonly ZERO: Long;
|
||||
|
||||
/** Returns a Long representing the given (32-bit) integer value. */
|
||||
static fromInt(i: number): Long;
|
||||
/** Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned. */
|
||||
static fromNumber(n: number): Long;
|
||||
/**
|
||||
* Returns a Long representing the 64-bit integer that comes by concatenating the given high and low bits. Each is assumed to use 32 bits.
|
||||
* @param lowBits The low 32-bits.
|
||||
* @param highBits The high 32-bits.
|
||||
*/
|
||||
static fromBits(lowBits: number, highBits: number): Long;
|
||||
/**
|
||||
* Returns a Long representation of the given string
|
||||
* @param opt_radix The radix in which the text is written. {default:10}
|
||||
*/
|
||||
static fromString(s: string, opt_radix?: number): Long;
|
||||
|
||||
}
|
||||
|
||||
/** A class representation of the BSON Decimal128 type. */
|
||||
export class Decimal128 {
|
||||
|
||||
/** Create a Decimal128 instance from a string representation. */
|
||||
static fromString(s: string): Decimal128;
|
||||
|
||||
/**
|
||||
* @param bytes A buffer containing the raw Decimal128 bytes.
|
||||
*/
|
||||
constructor(bytes: Buffer);
|
||||
|
||||
/** A buffer containing the raw Decimal128 bytes. */
|
||||
readonly bytes: Buffer;
|
||||
|
||||
toJSON(): string;
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
/** A class representation of the BSON MaxKey type. */
|
||||
export class MaxKey {
|
||||
constructor();
|
||||
}
|
||||
|
||||
/** A class representation of the BSON MinKey type. */
|
||||
export class MinKey {
|
||||
constructor();
|
||||
}
|
||||
|
||||
/** A class representation of the BSON ObjectId type. */
|
||||
export class ObjectId {
|
||||
/**
|
||||
* Create a new ObjectId instance
|
||||
* @param {(string|number|ObjectId)} id Can be a 24 byte hex string, 12 byte binary string or a Number.
|
||||
*/
|
||||
constructor(id?: string | number | ObjectId);
|
||||
/** The generation time of this ObjectId instance */
|
||||
generationTime: number;
|
||||
/** If true cache the hex string representation of ObjectId */
|
||||
static cacheHexString?: boolean | undefined;
|
||||
/**
|
||||
* Creates an ObjectId from a hex string representation of an ObjectId.
|
||||
* @param {string} hexString create a ObjectId from a passed in 24 byte hexstring.
|
||||
* @return {ObjectId} return the created ObjectId
|
||||
*/
|
||||
static createFromHexString(hexString: string): ObjectId;
|
||||
/**
|
||||
* Creates an ObjectId from a second based number, with the rest of the ObjectId zeroed out. Used for comparisons or sorting the ObjectId.
|
||||
* @param {number} time an integer number representing a number of seconds.
|
||||
* @return {ObjectId} return the created ObjectId
|
||||
*/
|
||||
static createFromTime(time: number): ObjectId;
|
||||
/**
|
||||
* Checks if a value is a valid bson ObjectId
|
||||
*
|
||||
* @return {boolean} return true if the value is a valid bson ObjectId, return false otherwise.
|
||||
*/
|
||||
static isValid(id: string | number | ObjectId): boolean;
|
||||
/**
|
||||
* Compares the equality of this ObjectId with `otherID`.
|
||||
* @param {ObjectId|string} otherID ObjectId instance to compare against.
|
||||
* @return {boolean} the result of comparing two ObjectId's
|
||||
*/
|
||||
equals(otherID: ObjectId | string): boolean;
|
||||
/**
|
||||
* Generate a 12 byte id string used in ObjectId's
|
||||
* @param {number} time optional parameter allowing to pass in a second based timestamp.
|
||||
* @return {string} return the 12 byte id binary string.
|
||||
*/
|
||||
static generate(time?: number): Buffer;
|
||||
/**
|
||||
* Returns the generation date (accurate up to the second) that this ID was generated.
|
||||
* @return {Date} the generation date
|
||||
*/
|
||||
getTimestamp(): Date;
|
||||
/**
|
||||
* Return the ObjectId id as a 24 byte hex string representation
|
||||
* @return {string} return the 24 byte hex string representation.
|
||||
*/
|
||||
toHexString(): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* ObjectID (with capital "D") is deprecated. Use ObjectId (lowercase "d") instead.
|
||||
* @deprecated
|
||||
*/
|
||||
export { ObjectId as ObjectID };
|
||||
|
||||
/** A class representation of the BSON RegExp type. */
|
||||
export class BSONRegExp {
|
||||
|
||||
constructor(pattern: string, options: string);
|
||||
|
||||
readonly pattern: string;
|
||||
readonly options: string;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A class representation of the BSON Symbol type.
|
||||
* @deprecated
|
||||
*/
|
||||
export class Symbol {
|
||||
|
||||
constructor(value: string);
|
||||
|
||||
/** Access the wrapped string value. */
|
||||
valueOf(): string;
|
||||
|
||||
}
|
||||
|
||||
/** A class representation of the BSON Timestamp type. */
|
||||
export class Timestamp extends LongLike<Timestamp> {
|
||||
|
||||
static readonly MAX_VALUE: Timestamp;
|
||||
static readonly MIN_VALUE: Timestamp;
|
||||
static readonly NEG_ONE: Timestamp;
|
||||
static readonly ONE: Timestamp;
|
||||
static readonly ZERO: Timestamp;
|
||||
|
||||
/** Returns a Timestamp represented by the given (32-bit) integer value */
|
||||
static fromInt(value: number): Timestamp;
|
||||
/** Returns a Timestamp representing the given number value, provided that it is a finite number. */
|
||||
static fromNumber(value: number): Timestamp;
|
||||
/**
|
||||
* Returns a Timestamp for the given high and low bits. Each is assumed to use 32 bits.
|
||||
* @param lowBits The low 32-bits.
|
||||
* @param highBits The high 32-bits.
|
||||
*/
|
||||
static fromBits(lowBits: number, highBits: number): Timestamp;
|
||||
/**
|
||||
* Returns a Timestamp from the given string.
|
||||
* @param opt_radix The radix in which the text is written. {default:10}
|
||||
*/
|
||||
static fromString(str: string, opt_radix?: number): Timestamp;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Functions for serializing JavaScript objects into Mongodb Extended JSON (EJSON).
|
||||
* @namespace EJSON
|
||||
*/
|
||||
export namespace EJSON {
|
||||
|
||||
/**
|
||||
* Parse an Extended JSON string, constructing the JavaScript value or object described by that
|
||||
* string.
|
||||
*
|
||||
* @memberof EJSON
|
||||
* @param {string} text
|
||||
* @param {object} [options] Optional settings
|
||||
* @param {boolean} [options.relaxed=true] Attempt to return native JS types where possible, rather than BSON types (if true)
|
||||
* @return {object}
|
||||
*
|
||||
* @example
|
||||
* const { EJSON } = require('bson');
|
||||
* const text = '{ "int32": { "$numberInt": "10" } }';
|
||||
*
|
||||
* // prints { int32: { [String: '10'] _bsontype: 'Int32', value: '10' } }
|
||||
* console.log(EJSON.parse(text, { relaxed: false }));
|
||||
*
|
||||
* // prints { int32: 10 }
|
||||
* console.log(EJSON.parse(text));
|
||||
*/
|
||||
export function parse(text: string, options?: {relaxed?: boolean | undefined;}): {};
|
||||
|
||||
/**
|
||||
* Deserializes an Extended JSON object into a plain JavaScript object with native/BSON types
|
||||
*
|
||||
* @memberof EJSON
|
||||
* @param {object} ejson The Extended JSON object to deserialize
|
||||
* @param {object} [options] Optional settings passed to the parse method
|
||||
* @return {object}
|
||||
*/
|
||||
export function deserialize(ejson: {}, options?: {relaxed?: boolean | undefined;}): {};
|
||||
|
||||
/**
|
||||
* Serializes an object to an Extended JSON string, and reparse it as a JavaScript object.
|
||||
*
|
||||
* @memberof EJSON
|
||||
* @param {object} bson The object to serialize
|
||||
* @param {object} [options] Optional settings passed to the `stringify` function
|
||||
* @return {object}
|
||||
*/
|
||||
export function serialize(bson: {}, options?: {relaxed?: boolean | undefined;}): {};
|
||||
|
||||
/**
|
||||
* Converts a BSON document to an Extended JSON string, optionally replacing values if a replacer
|
||||
* function is specified or optionally including only the specified properties if a replacer array
|
||||
* is specified.
|
||||
*
|
||||
* @memberof EJSON
|
||||
* @param {object} value The value to convert to extended JSON
|
||||
* @param {function|array} [replacer] A function that alters the behavior of the stringification process, or an array of String and Number objects that serve as a whitelist for selecting/filtering the properties of the value object to be included in the JSON string. If this value is null or not provided, all properties of the object are included in the resulting JSON string
|
||||
* @param {string|number} [space] A String or Number object that's used to insert white space into the output JSON string for readability purposes.
|
||||
* @param {object} [options] Optional settings.
|
||||
* @param {boolean} [options.relaxed=true] Enabled Extended JSON's `relaxed` mode
|
||||
* @returns {string}
|
||||
*
|
||||
* @example
|
||||
* const { EJSON, Int32 } = require('bson');
|
||||
* const doc = { int32: new Int32(10) };
|
||||
*
|
||||
* // prints '{"int32":{"$numberInt":"10"}}'
|
||||
* console.log(EJSON.stringify(doc, { relaxed: false }));
|
||||
*
|
||||
* // prints '{"int32":10}'
|
||||
* console.log(EJSON.stringify(doc));
|
||||
*/
|
||||
export function stringify(
|
||||
value: {},
|
||||
options?: {relaxed?: boolean | undefined;}
|
||||
): string;
|
||||
|
||||
/**
|
||||
* Converts a BSON document to an Extended JSON string, optionally replacing values if a replacer
|
||||
* function is specified or optionally including only the specified properties if a replacer array
|
||||
* is specified.
|
||||
*
|
||||
* @memberof EJSON
|
||||
* @param {object} value The value to convert to extended JSON
|
||||
* @param {function|array} [replacer] A function that alters the behavior of the stringification process, or an array of String and Number objects that serve as a whitelist for selecting/filtering the properties of the value object to be included in the JSON string. If this value is null or not provided, all properties of the object are included in the resulting JSON string
|
||||
* @param {string|number} [space] A String or Number object that's used to insert white space into the output JSON string for readability purposes.
|
||||
* @param {object} [options] Optional settings.
|
||||
* @param {boolean} [options.relaxed=true] Enabled Extended JSON's `relaxed` mode
|
||||
* @returns {string}
|
||||
*
|
||||
* @example
|
||||
* const { EJSON, Int32 } = require('bson');
|
||||
* const doc = { int32: new Int32(10) };
|
||||
*
|
||||
* // prints '{"int32":{"$numberInt":"10"}}'
|
||||
* console.log(EJSON.stringify(doc, { relaxed: false }));
|
||||
*
|
||||
* // prints '{"int32":10}'
|
||||
* console.log(EJSON.stringify(doc));
|
||||
*/
|
||||
|
||||
export function stringify(
|
||||
value: {},
|
||||
replacer: ((key: string, value: any) => any) | Array<string|number> | null | undefined,
|
||||
options?: {relaxed?: boolean | undefined;}
|
||||
): string;
|
||||
/**
|
||||
* Converts a BSON document to an Extended JSON string, optionally replacing values if a replacer
|
||||
* function is specified or optionally including only the specified properties if a replacer array
|
||||
* is specified.
|
||||
*
|
||||
* @memberof EJSON
|
||||
* @param {object} value The value to convert to extended JSON
|
||||
* @param {function|array} [replacer] A function that alters the behavior of the stringification process, or an array of String and Number objects that serve as a whitelist for selecting/filtering the properties of the value object to be included in the JSON string. If this value is null or not provided, all properties of the object are included in the resulting JSON string
|
||||
* @param {string|number} [space] A String or Number object that's used to insert white space into the output JSON string for readability purposes.
|
||||
* @param {object} [options] Optional settings.
|
||||
* @param {boolean} [options.relaxed=true] Enabled Extended JSON's `relaxed` mode
|
||||
* @returns {string}
|
||||
*
|
||||
* @example
|
||||
* const { EJSON, Int32 } = require('bson');
|
||||
* const doc = { int32: new Int32(10) };
|
||||
*
|
||||
* // prints '{"int32":{"$numberInt":"10"}}'
|
||||
* console.log(EJSON.stringify(doc, { relaxed: false }));
|
||||
*
|
||||
* // prints '{"int32":10}'
|
||||
* console.log(EJSON.stringify(doc));
|
||||
*/
|
||||
export function stringify(
|
||||
value: {},
|
||||
replacer: ((key: string, value: any) => any) | Array<string | number> | null | undefined,
|
||||
indents?: string | number,
|
||||
options?: {relaxed?: boolean | undefined;}
|
||||
): string;
|
||||
}
|
||||
67
node_modules/@types/bson/package.json
generated
vendored
Normal file
67
node_modules/@types/bson/package.json
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
{
|
||||
"_from": "@types/bson@*",
|
||||
"_id": "@types/bson@4.0.4",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-awqorHvQS0DqxkHQ/FxcPX9E+H7Du51Qw/2F+5TBMSaE3G0hm+8D3eXJ6MAzFw75nE8V7xF0QvzUSdxIjJb/GA==",
|
||||
"_location": "/@types/bson",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@types/bson@*",
|
||||
"name": "@types/bson",
|
||||
"escapedName": "@types%2fbson",
|
||||
"scope": "@types",
|
||||
"rawSpec": "*",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "*"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@types/mongodb"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@types/bson/-/bson-4.0.4.tgz",
|
||||
"_shasum": "79d2d26e81070044db2a1a8b2cc2f673c840e1e5",
|
||||
"_spec": "@types/bson@*",
|
||||
"_where": "C:\\Users\\anelissen\\Development\\tools\\node\\cbor\\node_modules\\@types\\mongodb",
|
||||
"bugs": {
|
||||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Hiroki Horiuchi",
|
||||
"url": "https://github.com/horiuchi"
|
||||
},
|
||||
{
|
||||
"name": "Federico Caselli",
|
||||
"url": "https://github.com/CaselIT"
|
||||
},
|
||||
{
|
||||
"name": "Justin Grant",
|
||||
"url": "https://github.com/justingrant"
|
||||
},
|
||||
{
|
||||
"name": "Mikael Lirbank",
|
||||
"url": "https://github.com/lirbank"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "TypeScript definitions for bson",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/bson",
|
||||
"license": "MIT",
|
||||
"main": "",
|
||||
"name": "@types/bson",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||
"directory": "types/bson"
|
||||
},
|
||||
"scripts": {},
|
||||
"typeScriptVersion": "3.6",
|
||||
"types": "index.d.ts",
|
||||
"typesPublisherContentHash": "7828d55bc8d6ef153b4825e28fe498539c3482d3053144974fd0e343540e4331",
|
||||
"version": "4.0.4"
|
||||
}
|
||||
21
node_modules/@types/mongodb/LICENSE
generated
vendored
Normal file
21
node_modules/@types/mongodb/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
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
|
||||
16
node_modules/@types/mongodb/README.md
generated
vendored
Normal file
16
node_modules/@types/mongodb/README.md
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
# Installation
|
||||
> `npm install --save @types/mongodb`
|
||||
|
||||
# Summary
|
||||
This package contains type definitions for MongoDB (https://github.com/mongodb/node-mongodb-native).
|
||||
|
||||
# Details
|
||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mongodb.
|
||||
|
||||
### Additional Details
|
||||
* Last updated: Wed, 07 Jul 2021 00:01:43 GMT
|
||||
* Dependencies: [@types/bson](https://npmjs.com/package/@types/bson), [@types/node](https://npmjs.com/package/@types/node)
|
||||
* Global values: none
|
||||
|
||||
# Credits
|
||||
These definitions were written by [Federico Caselli](https://github.com/CaselIT), [Alan Marcell](https://github.com/alanmarcell), [Gaurav Lahoti](https://github.com/dante-101), [Mariano Cortesi](https://github.com/mcortesi), [Enrico Picci](https://github.com/EnricoPicci), [Alexander Christie](https://github.com/AJCStriker), [Julien Chaumond](https://github.com/julien-c), [Dan Aprahamian](https://github.com/daprahamian), [Denys Bushulyak](https://github.com/denys-bushulyak), [Bastien Arata](https://github.com/b4nst), [Wan Bachtiar](https://github.com/sindbach), [Geraldine Lemeur](https://github.com/geraldinelemeur), [Dominik Heigl](https://github.com/various89), [Angela-1](https://github.com/angela-1), [Hector Ribes](https://github.com/hector7), [Florian Richter](https://github.com/floric), [Erik Christensen](https://github.com/erikc5000), [Nick Zahn](https://github.com/Manc), [Jarom Loveridge](https://github.com/jloveridge), [Luis Pais](https://github.com/ranguna), [Hossein Saniei](https://github.com/HosseinAgha), [Alberto Silva](https://github.com/albertossilva), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Linus Unnebäck](https://github.com/LinusU), [Richard Bateman](https://github.com/taxilian), [Igor Strebezhev](https://github.com/xamgore), [Valentin Agachi](https://github.com/avaly), [HitkoDev](https://github.com/HitkoDev), [TJT](https://github.com/Celend), [Julien TASSIN](https://github.com/jtassin), [Anna Henningsen](https://github.com/addaleax), [Emmanuel Gautier](https://github.com/emmanuelgautier), [Wyatt Johnson](https://github.com/wyattjoh), and [Boris Figovsky](https://github.com/borfig).
|
||||
5230
node_modules/@types/mongodb/index.d.ts
generated
vendored
Normal file
5230
node_modules/@types/mongodb/index.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
188
node_modules/@types/mongodb/package.json
generated
vendored
Normal file
188
node_modules/@types/mongodb/package.json
generated
vendored
Normal file
@@ -0,0 +1,188 @@
|
||||
{
|
||||
"_from": "@types/mongodb@^3.5.27",
|
||||
"_id": "@types/mongodb@3.6.20",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-WcdpPJCakFzcWWD9juKoZbRtQxKIMYF/JIAM4JrNHrMcnJL6/a2NWjXxW7fo9hxboxxkg+icff8d7+WIEvKgYQ==",
|
||||
"_location": "/@types/mongodb",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@types/mongodb@^3.5.27",
|
||||
"name": "@types/mongodb",
|
||||
"escapedName": "@types%2fmongodb",
|
||||
"scope": "@types",
|
||||
"rawSpec": "^3.5.27",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^3.5.27"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/mongoose"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@types/mongodb/-/mongodb-3.6.20.tgz",
|
||||
"_shasum": "b7c5c580644f6364002b649af1c06c3c0454e1d2",
|
||||
"_spec": "@types/mongodb@^3.5.27",
|
||||
"_where": "C:\\Users\\anelissen\\Development\\tools\\node\\cbor\\node_modules\\mongoose",
|
||||
"bugs": {
|
||||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Federico Caselli",
|
||||
"url": "https://github.com/CaselIT"
|
||||
},
|
||||
{
|
||||
"name": "Alan Marcell",
|
||||
"url": "https://github.com/alanmarcell"
|
||||
},
|
||||
{
|
||||
"name": "Gaurav Lahoti",
|
||||
"url": "https://github.com/dante-101"
|
||||
},
|
||||
{
|
||||
"name": "Mariano Cortesi",
|
||||
"url": "https://github.com/mcortesi"
|
||||
},
|
||||
{
|
||||
"name": "Enrico Picci",
|
||||
"url": "https://github.com/EnricoPicci"
|
||||
},
|
||||
{
|
||||
"name": "Alexander Christie",
|
||||
"url": "https://github.com/AJCStriker"
|
||||
},
|
||||
{
|
||||
"name": "Julien Chaumond",
|
||||
"url": "https://github.com/julien-c"
|
||||
},
|
||||
{
|
||||
"name": "Dan Aprahamian",
|
||||
"url": "https://github.com/daprahamian"
|
||||
},
|
||||
{
|
||||
"name": "Denys Bushulyak",
|
||||
"url": "https://github.com/denys-bushulyak"
|
||||
},
|
||||
{
|
||||
"name": "Bastien Arata",
|
||||
"url": "https://github.com/b4nst"
|
||||
},
|
||||
{
|
||||
"name": "Wan Bachtiar",
|
||||
"url": "https://github.com/sindbach"
|
||||
},
|
||||
{
|
||||
"name": "Geraldine Lemeur",
|
||||
"url": "https://github.com/geraldinelemeur"
|
||||
},
|
||||
{
|
||||
"name": "Dominik Heigl",
|
||||
"url": "https://github.com/various89"
|
||||
},
|
||||
{
|
||||
"name": "Angela-1",
|
||||
"url": "https://github.com/angela-1"
|
||||
},
|
||||
{
|
||||
"name": "Hector Ribes",
|
||||
"url": "https://github.com/hector7"
|
||||
},
|
||||
{
|
||||
"name": "Florian Richter",
|
||||
"url": "https://github.com/floric"
|
||||
},
|
||||
{
|
||||
"name": "Erik Christensen",
|
||||
"url": "https://github.com/erikc5000"
|
||||
},
|
||||
{
|
||||
"name": "Nick Zahn",
|
||||
"url": "https://github.com/Manc"
|
||||
},
|
||||
{
|
||||
"name": "Jarom Loveridge",
|
||||
"url": "https://github.com/jloveridge"
|
||||
},
|
||||
{
|
||||
"name": "Luis Pais",
|
||||
"url": "https://github.com/ranguna"
|
||||
},
|
||||
{
|
||||
"name": "Hossein Saniei",
|
||||
"url": "https://github.com/HosseinAgha"
|
||||
},
|
||||
{
|
||||
"name": "Alberto Silva",
|
||||
"url": "https://github.com/albertossilva"
|
||||
},
|
||||
{
|
||||
"name": "Piotr Błażejewicz",
|
||||
"url": "https://github.com/peterblazejewicz"
|
||||
},
|
||||
{
|
||||
"name": "Linus Unnebäck",
|
||||
"url": "https://github.com/LinusU"
|
||||
},
|
||||
{
|
||||
"name": "Richard Bateman",
|
||||
"url": "https://github.com/taxilian"
|
||||
},
|
||||
{
|
||||
"name": "Igor Strebezhev",
|
||||
"url": "https://github.com/xamgore"
|
||||
},
|
||||
{
|
||||
"name": "Valentin Agachi",
|
||||
"url": "https://github.com/avaly"
|
||||
},
|
||||
{
|
||||
"name": "HitkoDev",
|
||||
"url": "https://github.com/HitkoDev"
|
||||
},
|
||||
{
|
||||
"name": "TJT",
|
||||
"url": "https://github.com/Celend"
|
||||
},
|
||||
{
|
||||
"name": "Julien TASSIN",
|
||||
"url": "https://github.com/jtassin"
|
||||
},
|
||||
{
|
||||
"name": "Anna Henningsen",
|
||||
"url": "https://github.com/addaleax"
|
||||
},
|
||||
{
|
||||
"name": "Emmanuel Gautier",
|
||||
"url": "https://github.com/emmanuelgautier"
|
||||
},
|
||||
{
|
||||
"name": "Wyatt Johnson",
|
||||
"url": "https://github.com/wyattjoh"
|
||||
},
|
||||
{
|
||||
"name": "Boris Figovsky",
|
||||
"url": "https://github.com/borfig"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"@types/bson": "*",
|
||||
"@types/node": "*"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "TypeScript definitions for MongoDB",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mongodb",
|
||||
"license": "MIT",
|
||||
"main": "",
|
||||
"name": "@types/mongodb",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||
"directory": "types/mongodb"
|
||||
},
|
||||
"scripts": {},
|
||||
"typeScriptVersion": "3.6",
|
||||
"types": "index.d.ts",
|
||||
"typesPublisherContentHash": "4424cca7a452613f996286310bde1bc954ab161915fd1ab3c77f71592d73bb34",
|
||||
"version": "3.6.20"
|
||||
}
|
||||
21
node_modules/@types/node/LICENSE
generated
vendored
Normal file
21
node_modules/@types/node/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
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
|
||||
16
node_modules/@types/node/README.md
generated
vendored
Normal file
16
node_modules/@types/node/README.md
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
# Installation
|
||||
> `npm install --save @types/node`
|
||||
|
||||
# Summary
|
||||
This package contains type definitions for Node.js (http://nodejs.org/).
|
||||
|
||||
# Details
|
||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v15.
|
||||
|
||||
### Additional Details
|
||||
* Last updated: Sat, 03 Jul 2021 00:31:28 GMT
|
||||
* Dependencies: none
|
||||
* Global values: `AbortController`, `AbortSignal`, `Buffer`, `__dirname`, `__filename`, `clearImmediate`, `clearInterval`, `clearTimeout`, `console`, `exports`, `global`, `module`, `process`, `queueMicrotask`, `require`, `setImmediate`, `setInterval`, `setTimeout`
|
||||
|
||||
# Credits
|
||||
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [DefinitelyTyped](https://github.com/DefinitelyTyped), [Alberto Schiabel](https://github.com/jkomyno), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Hoàng Văn Khải](https://github.com/KSXGitHub), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nicolas Even](https://github.com/n-e), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Simon Schick](https://github.com/SimonSchick), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Minh Son Nguyen](https://github.com/nguymin4), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Surasak Chaisurin](https://github.com/Ryan-Willpower), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Jason Kwok](https://github.com/JasonHK), [Victor Perin](https://github.com/victorperin), and [Yongsheng Zhang](https://github.com/ZYSzys).
|
||||
124
node_modules/@types/node/assert.d.ts
generated
vendored
Normal file
124
node_modules/@types/node/assert.d.ts
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
declare module 'assert' {
|
||||
/** An alias of `assert.ok()`. */
|
||||
function assert(value: any, message?: string | Error): asserts value;
|
||||
namespace assert {
|
||||
class AssertionError extends Error {
|
||||
actual: any;
|
||||
expected: any;
|
||||
operator: string;
|
||||
generatedMessage: boolean;
|
||||
code: 'ERR_ASSERTION';
|
||||
|
||||
constructor(options?: {
|
||||
/** If provided, the error message is set to this value. */
|
||||
message?: string;
|
||||
/** The `actual` property on the error instance. */
|
||||
actual?: any;
|
||||
/** The `expected` property on the error instance. */
|
||||
expected?: any;
|
||||
/** The `operator` property on the error instance. */
|
||||
operator?: string;
|
||||
/** If provided, the generated stack trace omits frames before this function. */
|
||||
// tslint:disable-next-line:ban-types
|
||||
stackStartFn?: Function;
|
||||
});
|
||||
}
|
||||
|
||||
class CallTracker {
|
||||
calls(exact?: number): () => void;
|
||||
calls<Func extends (...args: any[]) => any>(fn?: Func, exact?: number): Func;
|
||||
report(): CallTrackerReportInformation[];
|
||||
verify(): void;
|
||||
}
|
||||
interface CallTrackerReportInformation {
|
||||
message: string;
|
||||
/** The actual number of times the function was called. */
|
||||
actual: number;
|
||||
/** The number of times the function was expected to be called. */
|
||||
expected: number;
|
||||
/** The name of the function that is wrapped. */
|
||||
operator: string;
|
||||
/** A stack trace of the function. */
|
||||
stack: object;
|
||||
}
|
||||
|
||||
type AssertPredicate = RegExp | (new () => object) | ((thrown: any) => boolean) | object | Error;
|
||||
|
||||
function fail(message?: string | Error): never;
|
||||
/** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */
|
||||
function fail(
|
||||
actual: any,
|
||||
expected: any,
|
||||
message?: string | Error,
|
||||
operator?: string,
|
||||
// tslint:disable-next-line:ban-types
|
||||
stackStartFn?: Function,
|
||||
): never;
|
||||
function ok(value: any, message?: string | Error): asserts value;
|
||||
/** @deprecated since v9.9.0 - use strictEqual() instead. */
|
||||
function equal(actual: any, expected: any, message?: string | Error): void;
|
||||
/** @deprecated since v9.9.0 - use notStrictEqual() instead. */
|
||||
function notEqual(actual: any, expected: any, message?: string | Error): void;
|
||||
/** @deprecated since v9.9.0 - use deepStrictEqual() instead. */
|
||||
function deepEqual(actual: any, expected: any, message?: string | Error): void;
|
||||
/** @deprecated since v9.9.0 - use notDeepStrictEqual() instead. */
|
||||
function notDeepEqual(actual: any, expected: any, message?: string | Error): void;
|
||||
function strictEqual<T>(actual: any, expected: T, message?: string | Error): asserts actual is T;
|
||||
function notStrictEqual(actual: any, expected: any, message?: string | Error): void;
|
||||
function deepStrictEqual<T>(actual: any, expected: T, message?: string | Error): asserts actual is T;
|
||||
function notDeepStrictEqual(actual: any, expected: any, message?: string | Error): void;
|
||||
|
||||
function throws(block: () => any, message?: string | Error): void;
|
||||
function throws(block: () => any, error: AssertPredicate, message?: string | Error): void;
|
||||
function doesNotThrow(block: () => any, message?: string | Error): void;
|
||||
function doesNotThrow(block: () => any, error: AssertPredicate, message?: string | Error): void;
|
||||
|
||||
function ifError(value: any): asserts value is null | undefined;
|
||||
|
||||
function rejects(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
|
||||
function rejects(
|
||||
block: (() => Promise<any>) | Promise<any>,
|
||||
error: AssertPredicate,
|
||||
message?: string | Error,
|
||||
): Promise<void>;
|
||||
function doesNotReject(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
|
||||
function doesNotReject(
|
||||
block: (() => Promise<any>) | Promise<any>,
|
||||
error: AssertPredicate,
|
||||
message?: string | Error,
|
||||
): Promise<void>;
|
||||
|
||||
function match(value: string, regExp: RegExp, message?: string | Error): void;
|
||||
function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void;
|
||||
|
||||
const strict: Omit<
|
||||
typeof assert,
|
||||
| 'equal'
|
||||
| 'notEqual'
|
||||
| 'deepEqual'
|
||||
| 'notDeepEqual'
|
||||
| 'ok'
|
||||
| 'strictEqual'
|
||||
| 'deepStrictEqual'
|
||||
| 'ifError'
|
||||
| 'strict'
|
||||
> & {
|
||||
(value: any, message?: string | Error): asserts value;
|
||||
equal: typeof strictEqual;
|
||||
notEqual: typeof notStrictEqual;
|
||||
deepEqual: typeof deepStrictEqual;
|
||||
notDeepEqual: typeof notDeepStrictEqual;
|
||||
|
||||
// Mapped types and assertion functions are incompatible?
|
||||
// TS2775: Assertions require every name in the call target
|
||||
// to be declared with an explicit type annotation.
|
||||
ok: typeof ok;
|
||||
strictEqual: typeof strictEqual;
|
||||
deepStrictEqual: typeof deepStrictEqual;
|
||||
ifError: typeof ifError;
|
||||
strict: typeof strict;
|
||||
};
|
||||
}
|
||||
|
||||
export = assert;
|
||||
}
|
||||
4
node_modules/@types/node/assert/strict.d.ts
generated
vendored
Normal file
4
node_modules/@types/node/assert/strict.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
declare module 'assert/strict' {
|
||||
import { strict } from 'assert';
|
||||
export = strict;
|
||||
}
|
||||
226
node_modules/@types/node/async_hooks.d.ts
generated
vendored
Normal file
226
node_modules/@types/node/async_hooks.d.ts
generated
vendored
Normal file
@@ -0,0 +1,226 @@
|
||||
/**
|
||||
* Async Hooks module: https://nodejs.org/api/async_hooks.html
|
||||
*/
|
||||
declare module 'async_hooks' {
|
||||
/**
|
||||
* Returns the asyncId of the current execution context.
|
||||
*/
|
||||
function executionAsyncId(): number;
|
||||
|
||||
/**
|
||||
* The resource representing the current execution.
|
||||
* Useful to store data within the resource.
|
||||
*
|
||||
* Resource objects returned by `executionAsyncResource()` are most often internal
|
||||
* Node.js handle objects with undocumented APIs. Using any functions or properties
|
||||
* on the object is likely to crash your application and should be avoided.
|
||||
*
|
||||
* Using `executionAsyncResource()` in the top-level execution context will
|
||||
* return an empty object as there is no handle or request object to use,
|
||||
* but having an object representing the top-level can be helpful.
|
||||
*/
|
||||
function executionAsyncResource(): object;
|
||||
|
||||
/**
|
||||
* Returns the ID of the resource responsible for calling the callback that is currently being executed.
|
||||
*/
|
||||
function triggerAsyncId(): number;
|
||||
|
||||
interface HookCallbacks {
|
||||
/**
|
||||
* Called when a class is constructed that has the possibility to emit an asynchronous event.
|
||||
* @param asyncId a unique ID for the async resource
|
||||
* @param type the type of the async resource
|
||||
* @param triggerAsyncId the unique ID of the async resource in whose execution context this async resource was created
|
||||
* @param resource reference to the resource representing the async operation, needs to be released during destroy
|
||||
*/
|
||||
init?(asyncId: number, type: string, triggerAsyncId: number, resource: object): void;
|
||||
|
||||
/**
|
||||
* When an asynchronous operation is initiated or completes a callback is called to notify the user.
|
||||
* The before callback is called just before said callback is executed.
|
||||
* @param asyncId the unique identifier assigned to the resource about to execute the callback.
|
||||
*/
|
||||
before?(asyncId: number): void;
|
||||
|
||||
/**
|
||||
* Called immediately after the callback specified in before is completed.
|
||||
* @param asyncId the unique identifier assigned to the resource which has executed the callback.
|
||||
*/
|
||||
after?(asyncId: number): void;
|
||||
|
||||
/**
|
||||
* Called when a promise has resolve() called. This may not be in the same execution id
|
||||
* as the promise itself.
|
||||
* @param asyncId the unique id for the promise that was resolve()d.
|
||||
*/
|
||||
promiseResolve?(asyncId: number): void;
|
||||
|
||||
/**
|
||||
* Called after the resource corresponding to asyncId is destroyed
|
||||
* @param asyncId a unique ID for the async resource
|
||||
*/
|
||||
destroy?(asyncId: number): void;
|
||||
}
|
||||
|
||||
interface AsyncHook {
|
||||
/**
|
||||
* Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop.
|
||||
*/
|
||||
enable(): this;
|
||||
|
||||
/**
|
||||
* Disable the callbacks for a given AsyncHook instance from the global pool of AsyncHook callbacks to be executed. Once a hook has been disabled it will not be called again until enabled.
|
||||
*/
|
||||
disable(): this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers functions to be called for different lifetime events of each async operation.
|
||||
* @param options the callbacks to register
|
||||
* @return an AsyncHooks instance used for disabling and enabling hooks
|
||||
*/
|
||||
function createHook(options: HookCallbacks): AsyncHook;
|
||||
|
||||
interface AsyncResourceOptions {
|
||||
/**
|
||||
* The ID of the execution context that created this async event.
|
||||
* @default executionAsyncId()
|
||||
*/
|
||||
triggerAsyncId?: number;
|
||||
|
||||
/**
|
||||
* Disables automatic `emitDestroy` when the object is garbage collected.
|
||||
* This usually does not need to be set (even if `emitDestroy` is called
|
||||
* manually), unless the resource's `asyncId` is retrieved and the
|
||||
* sensitive API's `emitDestroy` is called with it.
|
||||
* @default false
|
||||
*/
|
||||
requireManualDestroy?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* The class AsyncResource was designed to be extended by the embedder's async resources.
|
||||
* Using this users can easily trigger the lifetime events of their own resources.
|
||||
*/
|
||||
class AsyncResource {
|
||||
/**
|
||||
* AsyncResource() is meant to be extended. Instantiating a
|
||||
* new AsyncResource() also triggers init. If triggerAsyncId is omitted then
|
||||
* async_hook.executionAsyncId() is used.
|
||||
* @param type The type of async event.
|
||||
* @param triggerAsyncId The ID of the execution context that created
|
||||
* this async event (default: `executionAsyncId()`), or an
|
||||
* AsyncResourceOptions object (since 9.3)
|
||||
*/
|
||||
constructor(type: string, triggerAsyncId?: number|AsyncResourceOptions);
|
||||
|
||||
/**
|
||||
* Binds the given function to the current execution context.
|
||||
* @param fn The function to bind to the current execution context.
|
||||
* @param type An optional name to associate with the underlying `AsyncResource`.
|
||||
*/
|
||||
static bind<Func extends (...args: any[]) => any>(fn: Func, type?: string): Func & { asyncResource: AsyncResource };
|
||||
|
||||
/**
|
||||
* Binds the given function to execute to this `AsyncResource`'s scope.
|
||||
* @param fn The function to bind to the current `AsyncResource`.
|
||||
*/
|
||||
bind<Func extends (...args: any[]) => any>(fn: Func): Func & { asyncResource: AsyncResource };
|
||||
|
||||
/**
|
||||
* Call the provided function with the provided arguments in the
|
||||
* execution context of the async resource. This will establish the
|
||||
* context, trigger the AsyncHooks before callbacks, call the function,
|
||||
* trigger the AsyncHooks after callbacks, and then restore the original
|
||||
* execution context.
|
||||
* @param fn The function to call in the execution context of this
|
||||
* async resource.
|
||||
* @param thisArg The receiver to be used for the function call.
|
||||
* @param args Optional arguments to pass to the function.
|
||||
*/
|
||||
runInAsyncScope<This, Result>(fn: (this: This, ...args: any[]) => Result, thisArg?: This, ...args: any[]): Result;
|
||||
|
||||
/**
|
||||
* Call AsyncHooks destroy callbacks.
|
||||
*/
|
||||
emitDestroy(): this;
|
||||
|
||||
/**
|
||||
* @return the unique ID assigned to this AsyncResource instance.
|
||||
*/
|
||||
asyncId(): number;
|
||||
|
||||
/**
|
||||
* @return the trigger ID for this AsyncResource instance.
|
||||
*/
|
||||
triggerAsyncId(): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* When having multiple instances of `AsyncLocalStorage`, they are independent
|
||||
* from each other. It is safe to instantiate this class multiple times.
|
||||
*/
|
||||
class AsyncLocalStorage<T> {
|
||||
/**
|
||||
* This method disables the instance of `AsyncLocalStorage`. All subsequent calls
|
||||
* to `asyncLocalStorage.getStore()` will return `undefined` until
|
||||
* `asyncLocalStorage.run()` is called again.
|
||||
*
|
||||
* When calling `asyncLocalStorage.disable()`, all current contexts linked to the
|
||||
* instance will be exited.
|
||||
*
|
||||
* Calling `asyncLocalStorage.disable()` is required before the
|
||||
* `asyncLocalStorage` can be garbage collected. This does not apply to stores
|
||||
* provided by the `asyncLocalStorage`, as those objects are garbage collected
|
||||
* along with the corresponding async resources.
|
||||
*
|
||||
* This method is to be used when the `asyncLocalStorage` is not in use anymore
|
||||
* in the current process.
|
||||
*/
|
||||
disable(): void;
|
||||
|
||||
/**
|
||||
* This method returns the current store. If this method is called outside of an
|
||||
* asynchronous context initialized by calling `asyncLocalStorage.run`, it will
|
||||
* return `undefined`.
|
||||
*/
|
||||
getStore(): T | undefined;
|
||||
|
||||
/**
|
||||
* This methods runs a function synchronously within a context and return its
|
||||
* return value. The store is not accessible outside of the callback function or
|
||||
* the asynchronous operations created within the callback.
|
||||
*
|
||||
* Optionally, arguments can be passed to the function. They will be passed to the
|
||||
* callback function.
|
||||
*
|
||||
* I the callback function throws an error, it will be thrown by `run` too. The
|
||||
* stacktrace will not be impacted by this call and the context will be exited.
|
||||
*/
|
||||
// TODO: Apply generic vararg once available
|
||||
run<R>(store: T, callback: (...args: any[]) => R, ...args: any[]): R;
|
||||
|
||||
/**
|
||||
* This methods runs a function synchronously outside of a context and return its
|
||||
* return value. The store is not accessible within the callback function or the
|
||||
* asynchronous operations created within the callback.
|
||||
*
|
||||
* Optionally, arguments can be passed to the function. They will be passed to the
|
||||
* callback function.
|
||||
*
|
||||
* If the callback function throws an error, it will be thrown by `exit` too. The
|
||||
* stacktrace will not be impacted by this call and the context will be
|
||||
* re-entered.
|
||||
*/
|
||||
// TODO: Apply generic vararg once available
|
||||
exit<R>(callback: (...args: any[]) => R, ...args: any[]): R;
|
||||
|
||||
/**
|
||||
* Calling `asyncLocalStorage.enterWith(store)` will transition into the context
|
||||
* for the remainder of the current synchronous execution and will persist
|
||||
* through any following asynchronous calls.
|
||||
*/
|
||||
enterWith(store: T): void;
|
||||
}
|
||||
}
|
||||
19
node_modules/@types/node/base.d.ts
generated
vendored
Normal file
19
node_modules/@types/node/base.d.ts
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
// NOTE: These definitions support NodeJS and TypeScript 3.7.
|
||||
|
||||
// NOTE: TypeScript version-specific augmentations can be found in the following paths:
|
||||
// - ~/base.d.ts - Shared definitions common to all TypeScript versions
|
||||
// - ~/index.d.ts - Definitions specific to TypeScript 2.1
|
||||
// - ~/ts3.7/base.d.ts - Definitions specific to TypeScript 3.7
|
||||
// - ~/ts3.7/index.d.ts - Definitions specific to TypeScript 3.7 with assert pulled in
|
||||
|
||||
// Reference required types from the default lib:
|
||||
/// <reference lib="es2018" />
|
||||
/// <reference lib="esnext.asynciterable" />
|
||||
/// <reference lib="esnext.intl" />
|
||||
/// <reference lib="esnext.bigint" />
|
||||
|
||||
// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
|
||||
/// <reference path="ts3.6/base.d.ts" />
|
||||
|
||||
// TypeScript 3.7-specific augmentations:
|
||||
/// <reference path="assert.d.ts" />
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user