mirror of
https://github.com/xfarrow/blink
synced 2025-06-27 09:03:02 +02:00
Change endpoint from persons to people
This commit is contained in:
13
backend/apis/nodejs/node_modules/knex/lib/util/finally-mixin.js
generated
vendored
Normal file
13
backend/apis/nodejs/node_modules/knex/lib/util/finally-mixin.js
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
const noop = require('./noop');
|
||||
|
||||
const finallyMixin = (prototype) =>
|
||||
Object.assign(prototype, {
|
||||
finally(onFinally) {
|
||||
return this.then().finally(onFinally);
|
||||
},
|
||||
});
|
||||
|
||||
// FYI: Support for `Promise.prototype.finally` was not introduced until Node 9.
|
||||
// Therefore, Knex will need to conditionally inject support for `.finally(..)`
|
||||
// until support for Node 8 is officially dropped.
|
||||
module.exports = Promise.prototype.finally ? finallyMixin : noop;
|
95
backend/apis/nodejs/node_modules/knex/lib/util/helpers.js
generated
vendored
Normal file
95
backend/apis/nodejs/node_modules/knex/lib/util/helpers.js
generated
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
const isPlainObject = require('lodash/isPlainObject');
|
||||
const isTypedArray = require('lodash/isTypedArray');
|
||||
const { CLIENT_ALIASES } = require('../constants');
|
||||
const { isFunction } = require('./is');
|
||||
|
||||
// Check if the first argument is an array, otherwise uses all arguments as an
|
||||
// array.
|
||||
function normalizeArr(...args) {
|
||||
if (Array.isArray(args[0])) {
|
||||
return args[0];
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
function containsUndefined(mixed) {
|
||||
let argContainsUndefined = false;
|
||||
|
||||
if (isTypedArray(mixed)) return false;
|
||||
|
||||
if (mixed && isFunction(mixed.toSQL)) {
|
||||
//Any QueryBuilder or Raw will automatically be validated during compile.
|
||||
return argContainsUndefined;
|
||||
}
|
||||
|
||||
if (Array.isArray(mixed)) {
|
||||
for (let i = 0; i < mixed.length; i++) {
|
||||
if (argContainsUndefined) break;
|
||||
argContainsUndefined = containsUndefined(mixed[i]);
|
||||
}
|
||||
} else if (isPlainObject(mixed)) {
|
||||
Object.keys(mixed).forEach((key) => {
|
||||
if (!argContainsUndefined) {
|
||||
argContainsUndefined = containsUndefined(mixed[key]);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
argContainsUndefined = mixed === undefined;
|
||||
}
|
||||
|
||||
return argContainsUndefined;
|
||||
}
|
||||
|
||||
function getUndefinedIndices(mixed) {
|
||||
const indices = [];
|
||||
|
||||
if (Array.isArray(mixed)) {
|
||||
mixed.forEach((item, index) => {
|
||||
if (containsUndefined(item)) {
|
||||
indices.push(index);
|
||||
}
|
||||
});
|
||||
} else if (isPlainObject(mixed)) {
|
||||
Object.keys(mixed).forEach((key) => {
|
||||
if (containsUndefined(mixed[key])) {
|
||||
indices.push(key);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
indices.push(0);
|
||||
}
|
||||
|
||||
return indices;
|
||||
}
|
||||
|
||||
function addQueryContext(Target) {
|
||||
// Stores or returns (if called with no arguments) context passed to
|
||||
// wrapIdentifier and postProcessResponse hooks
|
||||
Target.prototype.queryContext = function (context) {
|
||||
if (context === undefined) {
|
||||
return this._queryContext;
|
||||
}
|
||||
this._queryContext = context;
|
||||
return this;
|
||||
};
|
||||
}
|
||||
|
||||
function resolveClientNameWithAliases(clientName) {
|
||||
return CLIENT_ALIASES[clientName] || clientName;
|
||||
}
|
||||
|
||||
function toNumber(val, fallback) {
|
||||
if (val === undefined || val === null) return fallback;
|
||||
const number = parseInt(val, 10);
|
||||
return isNaN(number) ? fallback : number;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
addQueryContext,
|
||||
containsUndefined,
|
||||
getUndefinedIndices,
|
||||
normalizeArr,
|
||||
resolveClientNameWithAliases,
|
||||
toNumber,
|
||||
};
|
32
backend/apis/nodejs/node_modules/knex/lib/util/is.js
generated
vendored
Normal file
32
backend/apis/nodejs/node_modules/knex/lib/util/is.js
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
function isString(value) {
|
||||
return typeof value === 'string';
|
||||
}
|
||||
|
||||
function isNumber(value) {
|
||||
return typeof value === 'number';
|
||||
}
|
||||
|
||||
function isBoolean(value) {
|
||||
return typeof value === 'boolean';
|
||||
}
|
||||
|
||||
function isUndefined(value) {
|
||||
return typeof value === 'undefined';
|
||||
}
|
||||
|
||||
function isObject(value) {
|
||||
return typeof value === 'object' && value !== null;
|
||||
}
|
||||
|
||||
function isFunction(value) {
|
||||
return typeof value === 'function';
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isString,
|
||||
isNumber,
|
||||
isBoolean,
|
||||
isUndefined,
|
||||
isObject,
|
||||
isFunction,
|
||||
};
|
40
backend/apis/nodejs/node_modules/knex/lib/util/nanoid.js
generated
vendored
Normal file
40
backend/apis/nodejs/node_modules/knex/lib/util/nanoid.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
// This alphabet uses `A-Za-z0-9_-` symbols. The genetic algorithm helped
|
||||
// optimize the gzip compression for this alphabet.
|
||||
const urlAlphabet =
|
||||
'ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW';
|
||||
|
||||
const numberAlphabet = '0123456789';
|
||||
|
||||
/**
|
||||
* Generate URL-friendly unique ID. This method uses the non-secure
|
||||
* predictable random generator with bigger collision probability.
|
||||
* Based on https://github.com/ai/nanoid
|
||||
*
|
||||
* ```js
|
||||
* model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
|
||||
* ```
|
||||
*
|
||||
* @param size Size of the ID. The default size is 21.
|
||||
* @returns A random string.
|
||||
*/
|
||||
function nanoid(size = 21) {
|
||||
let id = '';
|
||||
// A compact alternative for `for (var i = 0; i < step; i++)`.
|
||||
let i = size;
|
||||
while (i--) {
|
||||
// `| 0` is more compact and faster than `Math.floor()`.
|
||||
id += urlAlphabet[(Math.random() * 64) | 0];
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
function nanonum(size = 21) {
|
||||
let id = '';
|
||||
let i = size;
|
||||
while (i--) {
|
||||
id += numberAlphabet[(Math.random() * 10) | 0];
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
module.exports = { nanoid, nanonum };
|
1
backend/apis/nodejs/node_modules/knex/lib/util/noop.js
generated
vendored
Normal file
1
backend/apis/nodejs/node_modules/knex/lib/util/noop.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = function () {};
|
14
backend/apis/nodejs/node_modules/knex/lib/util/save-async-stack.js
generated
vendored
Normal file
14
backend/apis/nodejs/node_modules/knex/lib/util/save-async-stack.js
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
module.exports = function saveAsyncStack(instance, lines) {
|
||||
if (instance.client.config.asyncStackTraces) {
|
||||
// a hack to get a callstack into the client code despite this
|
||||
// node.js bug https://github.com/nodejs/node/issues/11865
|
||||
|
||||
// Save error here but not error trace
|
||||
// reading trace with '--enable-source-maps' flag on node can be very costly
|
||||
|
||||
instance._asyncStack = {
|
||||
error: new Error(),
|
||||
lines,
|
||||
};
|
||||
}
|
||||
};
|
26
backend/apis/nodejs/node_modules/knex/lib/util/security.js
generated
vendored
Normal file
26
backend/apis/nodejs/node_modules/knex/lib/util/security.js
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Sets a hidden (non-enumerable) property on the `target` object, copying it
|
||||
* from `source`.
|
||||
*
|
||||
* This is useful when we want to protect certain data from being accidentally
|
||||
* leaked through logs, also when the property is non-enumerable on the `source`
|
||||
* object and we want to ensure that it is properly copied.
|
||||
*
|
||||
* @param {object} target
|
||||
* @param {object} source - default: target
|
||||
* @param {string} propertyName - default: 'password'
|
||||
*/
|
||||
function setHiddenProperty(target, source, propertyName = 'password') {
|
||||
if (!source) {
|
||||
source = target;
|
||||
}
|
||||
|
||||
Object.defineProperty(target, propertyName, {
|
||||
enumerable: false,
|
||||
value: source[propertyName],
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
setHiddenProperty,
|
||||
};
|
190
backend/apis/nodejs/node_modules/knex/lib/util/string.js
generated
vendored
Normal file
190
backend/apis/nodejs/node_modules/knex/lib/util/string.js
generated
vendored
Normal file
@ -0,0 +1,190 @@
|
||||
/*eslint max-len: 0, no-var:0 */
|
||||
|
||||
const charsRegex = /[\0\b\t\n\r\x1a"'\\]/g; // eslint-disable-line no-control-regex
|
||||
const charsMap = {
|
||||
'\0': '\\0',
|
||||
'\b': '\\b',
|
||||
'\t': '\\t',
|
||||
'\n': '\\n',
|
||||
'\r': '\\r',
|
||||
'\x1a': '\\Z',
|
||||
'"': '\\"',
|
||||
"'": "\\'",
|
||||
'\\': '\\\\',
|
||||
};
|
||||
|
||||
function wrapEscape(escapeFn) {
|
||||
return function finalEscape(val, ctx = {}) {
|
||||
return escapeFn(val, finalEscape, ctx);
|
||||
};
|
||||
}
|
||||
|
||||
function makeEscape(config = {}) {
|
||||
const finalEscapeDate = config.escapeDate || dateToString;
|
||||
const finalEscapeArray = config.escapeArray || arrayToList;
|
||||
const finalEscapeBuffer = config.escapeBuffer || bufferToString;
|
||||
const finalEscapeString = config.escapeString || escapeString;
|
||||
const finalEscapeObject = config.escapeObject || escapeObject;
|
||||
const finalWrap = config.wrap || wrapEscape;
|
||||
|
||||
function escapeFn(val, finalEscape, ctx) {
|
||||
if (val === undefined || val === null) {
|
||||
return 'NULL';
|
||||
}
|
||||
switch (typeof val) {
|
||||
case 'boolean':
|
||||
return val ? 'true' : 'false';
|
||||
case 'number':
|
||||
return val + '';
|
||||
case 'object':
|
||||
if (val instanceof Date) {
|
||||
val = finalEscapeDate(val, finalEscape, ctx);
|
||||
} else if (Array.isArray(val)) {
|
||||
return finalEscapeArray(val, finalEscape, ctx);
|
||||
} else if (Buffer.isBuffer(val)) {
|
||||
return finalEscapeBuffer(val, finalEscape, ctx);
|
||||
} else {
|
||||
return finalEscapeObject(val, finalEscape, ctx);
|
||||
}
|
||||
}
|
||||
return finalEscapeString(val, finalEscape, ctx);
|
||||
}
|
||||
|
||||
return finalWrap ? finalWrap(escapeFn) : escapeFn;
|
||||
}
|
||||
|
||||
function escapeObject(val, finalEscape, ctx) {
|
||||
if (val && typeof val.toSQL === 'function') {
|
||||
return val.toSQL(ctx);
|
||||
} else {
|
||||
return JSON.stringify(val);
|
||||
}
|
||||
}
|
||||
|
||||
function arrayToList(array, finalEscape, ctx) {
|
||||
let sql = '';
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const val = array[i];
|
||||
if (Array.isArray(val)) {
|
||||
sql +=
|
||||
(i === 0 ? '' : ', ') + '(' + arrayToList(val, finalEscape, ctx) + ')';
|
||||
} else {
|
||||
sql += (i === 0 ? '' : ', ') + finalEscape(val, ctx);
|
||||
}
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
function bufferToString(buffer) {
|
||||
return 'X' + escapeString(buffer.toString('hex'));
|
||||
}
|
||||
|
||||
function escapeString(val, finalEscape, ctx) {
|
||||
let chunkIndex = (charsRegex.lastIndex = 0);
|
||||
let escapedVal = '';
|
||||
let match;
|
||||
|
||||
while ((match = charsRegex.exec(val))) {
|
||||
escapedVal += val.slice(chunkIndex, match.index) + charsMap[match[0]];
|
||||
chunkIndex = charsRegex.lastIndex;
|
||||
}
|
||||
|
||||
if (chunkIndex === 0) {
|
||||
// Nothing was escaped
|
||||
return "'" + val + "'";
|
||||
}
|
||||
|
||||
if (chunkIndex < val.length) {
|
||||
return "'" + escapedVal + val.slice(chunkIndex) + "'";
|
||||
}
|
||||
|
||||
return "'" + escapedVal + "'";
|
||||
}
|
||||
|
||||
function dateToString(date, finalEscape, ctx = {}) {
|
||||
const timeZone = ctx.timeZone || 'local';
|
||||
|
||||
const dt = new Date(date);
|
||||
let year;
|
||||
let month;
|
||||
let day;
|
||||
let hour;
|
||||
let minute;
|
||||
let second;
|
||||
let millisecond;
|
||||
|
||||
if (timeZone === 'local') {
|
||||
year = dt.getFullYear();
|
||||
month = dt.getMonth() + 1;
|
||||
day = dt.getDate();
|
||||
hour = dt.getHours();
|
||||
minute = dt.getMinutes();
|
||||
second = dt.getSeconds();
|
||||
millisecond = dt.getMilliseconds();
|
||||
} else {
|
||||
const tz = convertTimezone(timeZone);
|
||||
|
||||
if (tz !== false && tz !== 0) {
|
||||
dt.setTime(dt.getTime() + tz * 60000);
|
||||
}
|
||||
|
||||
year = dt.getUTCFullYear();
|
||||
month = dt.getUTCMonth() + 1;
|
||||
day = dt.getUTCDate();
|
||||
hour = dt.getUTCHours();
|
||||
minute = dt.getUTCMinutes();
|
||||
second = dt.getUTCSeconds();
|
||||
millisecond = dt.getUTCMilliseconds();
|
||||
}
|
||||
|
||||
// YYYY-MM-DD HH:mm:ss.mmm
|
||||
return (
|
||||
zeroPad(year, 4) +
|
||||
'-' +
|
||||
zeroPad(month, 2) +
|
||||
'-' +
|
||||
zeroPad(day, 2) +
|
||||
' ' +
|
||||
zeroPad(hour, 2) +
|
||||
':' +
|
||||
zeroPad(minute, 2) +
|
||||
':' +
|
||||
zeroPad(second, 2) +
|
||||
'.' +
|
||||
zeroPad(millisecond, 3)
|
||||
);
|
||||
}
|
||||
|
||||
function zeroPad(number, length) {
|
||||
number = number.toString();
|
||||
while (number.length < length) {
|
||||
number = '0' + number;
|
||||
}
|
||||
return number;
|
||||
}
|
||||
|
||||
function convertTimezone(tz) {
|
||||
if (tz === 'Z') {
|
||||
return 0;
|
||||
}
|
||||
const m = tz.match(/([+\-\s])(\d\d):?(\d\d)?/);
|
||||
if (m) {
|
||||
return (
|
||||
(m[1] == '-' ? -1 : 1) *
|
||||
(parseInt(m[2], 10) + (m[3] ? parseInt(m[3], 10) : 0) / 60) *
|
||||
60
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
arrayToList,
|
||||
bufferToString,
|
||||
dateToString,
|
||||
escapeString,
|
||||
charsRegex,
|
||||
charsMap,
|
||||
escapeObject,
|
||||
makeEscape,
|
||||
};
|
29
backend/apis/nodejs/node_modules/knex/lib/util/timeout.js
generated
vendored
Normal file
29
backend/apis/nodejs/node_modules/knex/lib/util/timeout.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
class KnexTimeoutError extends Error {
|
||||
constructor(message) {
|
||||
super(message);
|
||||
this.name = 'KnexTimeoutError';
|
||||
}
|
||||
}
|
||||
|
||||
function timeout(promise, ms) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
const id = setTimeout(function () {
|
||||
reject(new KnexTimeoutError('operation timed out'));
|
||||
}, ms);
|
||||
|
||||
function wrappedResolve(value) {
|
||||
clearTimeout(id);
|
||||
resolve(value);
|
||||
}
|
||||
|
||||
function wrappedReject(err) {
|
||||
clearTimeout(id);
|
||||
reject(err);
|
||||
}
|
||||
|
||||
promise.then(wrappedResolve, wrappedReject);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.KnexTimeoutError = KnexTimeoutError;
|
||||
module.exports.timeout = timeout;
|
Reference in New Issue
Block a user