1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-22 02:12:40 +01:00

Drop ajv patch, update setup script

This commit is contained in:
TheArcaneBrony 2022-08-20 03:14:11 +02:00
parent 9071cbdc25
commit 0232c592ed
No known key found for this signature in database
GPG Key ID: 32FC5AAADAD75A22
11 changed files with 9041 additions and 30130 deletions

2
.gitignore vendored
View File

@ -22,3 +22,5 @@ tmp/
assets/cache/
*.generated
initial.json
.yarn/
.yarnrc.yml

16
build.json Normal file
View File

@ -0,0 +1,16 @@
{
"compiler": "tsc",
"verbose": true,
"writeBuildLog": true,
"writeAnsiBuildLog": true,
"logErrors": true,
"tsc": {
"prettyErrors": true
},
"clean": true,
"quiet": false,
"steps": {
"pre": ["clean"],
"post": ["remap_imports"]
}
}

22796
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -39,7 +39,6 @@
"@types/bcrypt": "^5.0.0",
"@types/bcryptjs": "^2.4.2",
"@types/body-parser": "^1.19.0",
"@types/dotenv": "^8.2.0",
"@types/express": "^4.17.12",
"@types/i18next-node-fs-backend": "^2.1.0",
"@types/jsonwebtoken": "^8.5.8",
@ -63,10 +62,9 @@
"@babel/preset-typescript": "^7.15.0",
"@sentry/node": "^7.7.0",
"@sentry/tracing": "^7.7.0",
"ajv": "^8.6.2",
"ajv": "^8.11.0",
"ajv-formats": "^2.1.1",
"amqplib": "^0.10.1",
"bcrypt": "^5.0.1",
"bcryptjs": "^2.4.3",
"body-parser": "^1.19.0",
"cheerio": "^1.0.0-rc.10",
@ -92,13 +90,13 @@
"proxy-agent": "^5.0.0",
"reflect-metadata": "^0.1.13",
"typeorm": "^0.3.7",
"typescript": "^4.1.2",
"typescript": "^4.2.3",
"ws": "^8.8.1"
},
"packageManager": "yarn@3.2.2",
"optionalDependencies": {
"bcrypt": "^5.0.1",
"canvas": "^2.9.3",
"mysql2": "^2.3.3",
"pg": "^8.7.3",
"sqlite3": "^5.0.11"
"pg": "^8.7.3"
}
}

View File

@ -1,249 +0,0 @@
diff --git a/node_modules/ajv/dist/compile/jtd/parse.js b/node_modules/ajv/dist/compile/jtd/parse.js
index 1eeb1be..7684121 100644
--- a/node_modules/ajv/dist/compile/jtd/parse.js
+++ b/node_modules/ajv/dist/compile/jtd/parse.js
@@ -239,6 +239,9 @@ function parseType(cxt) {
gen.if(fail, () => parsingError(cxt, codegen_1.str `invalid timestamp`));
break;
}
+ case "bigint":
+ parseBigInt(cxt);
+ break
case "float32":
case "float64":
parseNumber(cxt);
@@ -284,6 +287,15 @@ function parseNumber(cxt, maxDigits) {
skipWhitespace(cxt);
gen.if(codegen_1._ `"-0123456789".indexOf(${jsonSlice(1)}) < 0`, () => jsonSyntaxError(cxt), () => parseWith(cxt, parseJson_1.parseJsonNumber, maxDigits));
}
+function parseBigInt(cxt, maxDigits) {
+ const {gen} = cxt
+ skipWhitespace(cxt)
+ gen.if(
+ _`"-0123456789".indexOf(${jsonSlice(1)}) < 0`,
+ () => jsonSyntaxError(cxt),
+ () => parseWith(cxt, parseJson_1.parseJsonBigInt, maxDigits)
+ )
+}
function parseBooleanToken(bool, fail) {
return (cxt) => {
const { gen, data } = cxt;
diff --git a/node_modules/ajv/dist/compile/rules.js b/node_modules/ajv/dist/compile/rules.js
index 82a591f..1ebd8fe 100644
--- a/node_modules/ajv/dist/compile/rules.js
+++ b/node_modules/ajv/dist/compile/rules.js
@@ -1,7 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRules = exports.isJSONType = void 0;
-const _jsonTypes = ["string", "number", "integer", "boolean", "null", "object", "array"];
+const _jsonTypes = ["string", "number", "integer", "boolean", "null", "object", "array","bigint"];
const jsonTypes = new Set(_jsonTypes);
function isJSONType(x) {
return typeof x == "string" && jsonTypes.has(x);
@@ -13,10 +13,11 @@ function getRules() {
string: { type: "string", rules: [] },
array: { type: "array", rules: [] },
object: { type: "object", rules: [] },
+ bigint: {type: "bigint", rules: []}
};
return {
- types: { ...groups, integer: true, boolean: true, null: true },
- rules: [{ rules: [] }, groups.number, groups.string, groups.array, groups.object],
+ types: { ...groups, integer: true, boolean: true, null: true, bigint: true },
+ rules: [{ rules: [] }, groups.number, groups.string, groups.array, groups.object, groups.bigint],
post: { rules: [] },
all: {},
keywords: {},
diff --git a/node_modules/ajv/dist/compile/validate/dataType.js b/node_modules/ajv/dist/compile/validate/dataType.js
index 6319e76..8b50b4c 100644
--- a/node_modules/ajv/dist/compile/validate/dataType.js
+++ b/node_modules/ajv/dist/compile/validate/dataType.js
@@ -52,7 +52,7 @@ function coerceAndCheckDataType(it, types) {
return checkTypes;
}
exports.coerceAndCheckDataType = coerceAndCheckDataType;
-const COERCIBLE = new Set(["string", "number", "integer", "boolean", "null"]);
+const COERCIBLE = new Set(["string", "number", "integer", "boolean", "null","bigint"]);
function coerceToTypes(types, coerceTypes) {
return coerceTypes
? types.filter((t) => COERCIBLE.has(t) || (coerceTypes === "array" && t === "array"))
@@ -83,6 +83,14 @@ function coerceData(it, types, coerceTo) {
});
function coerceSpecificType(t) {
switch (t) {
+ case "bigint":
+ gen
+ .elseIf(
+ codegen_1._`${dataType} == "boolean" || ${data} === null
+ || (${dataType} == "string" && ${data} && ${data} == BigInt(${data}))`
+ )
+ .assign(coerced, codegen_1._`BigInt(${data})`)
+ return
case "string":
gen
.elseIf(codegen_1._ `${dataType} == "number" || ${dataType} == "boolean"`)
@@ -143,6 +151,9 @@ function checkDataType(dataType, data, strictNums, correct = DataType.Correct) {
case "number":
cond = numCond();
break;
+ case "bigint":
+ cond = codegen_1._`typeof ${data} == "bigint" && isFinite(${data})`
+ break
default:
return codegen_1._ `typeof ${data} ${EQ} ${dataType}`;
}
diff --git a/node_modules/ajv/dist/refs/json-schema-2019-09/meta/validation.json b/node_modules/ajv/dist/refs/json-schema-2019-09/meta/validation.json
index 7027a12..25679c8 100644
--- a/node_modules/ajv/dist/refs/json-schema-2019-09/meta/validation.json
+++ b/node_modules/ajv/dist/refs/json-schema-2019-09/meta/validation.json
@@ -78,7 +78,7 @@
"default": 0
},
"simpleTypes": {
- "enum": ["array", "boolean", "integer", "null", "number", "object", "string"]
+ "enum": ["array", "boolean", "integer", "null", "number", "object", "string","bigint"]
},
"stringArray": {
"type": "array",
diff --git a/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.json b/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.json
index e0ae13d..57c9036 100644
--- a/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.json
+++ b/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.json
@@ -78,7 +78,7 @@
"default": 0
},
"simpleTypes": {
- "enum": ["array", "boolean", "integer", "null", "number", "object", "string"]
+ "enum": ["array", "boolean", "integer", "null", "number", "object", "string","bigint"]
},
"stringArray": {
"type": "array",
diff --git a/node_modules/ajv/dist/refs/json-schema-draft-06.json b/node_modules/ajv/dist/refs/json-schema-draft-06.json
index 5410064..774435b 100644
--- a/node_modules/ajv/dist/refs/json-schema-draft-06.json
+++ b/node_modules/ajv/dist/refs/json-schema-draft-06.json
@@ -16,7 +16,7 @@
"allOf": [{"$ref": "#/definitions/nonNegativeInteger"}, {"default": 0}]
},
"simpleTypes": {
- "enum": ["array", "boolean", "integer", "null", "number", "object", "string"]
+ "enum": ["array", "boolean", "integer", "null", "number", "object", "string","bigint"]
},
"stringArray": {
"type": "array",
diff --git a/node_modules/ajv/dist/refs/json-schema-draft-07.json b/node_modules/ajv/dist/refs/json-schema-draft-07.json
index 6a74851..fc6dd7d 100644
--- a/node_modules/ajv/dist/refs/json-schema-draft-07.json
+++ b/node_modules/ajv/dist/refs/json-schema-draft-07.json
@@ -16,7 +16,7 @@
"allOf": [{"$ref": "#/definitions/nonNegativeInteger"}, {"default": 0}]
},
"simpleTypes": {
- "enum": ["array", "boolean", "integer", "null", "number", "object", "string"]
+ "enum": ["array", "boolean", "integer", "null", "number", "object", "string","bigint"]
},
"stringArray": {
"type": "array",
diff --git a/node_modules/ajv/dist/refs/jtd-schema.js b/node_modules/ajv/dist/refs/jtd-schema.js
index 1ee940a..1148887 100644
--- a/node_modules/ajv/dist/refs/jtd-schema.js
+++ b/node_modules/ajv/dist/refs/jtd-schema.js
@@ -38,6 +38,7 @@ const typeForm = (root) => ({
"uint16",
"int32",
"uint32",
+ "bigint",
],
},
},
diff --git a/node_modules/ajv/dist/runtime/parseJson.js b/node_modules/ajv/dist/runtime/parseJson.js
index 2576a6e..e7447b1 100644
--- a/node_modules/ajv/dist/runtime/parseJson.js
+++ b/node_modules/ajv/dist/runtime/parseJson.js
@@ -97,6 +97,71 @@ exports.parseJsonNumber = parseJsonNumber;
parseJsonNumber.message = undefined;
parseJsonNumber.position = 0;
parseJsonNumber.code = 'require("ajv/dist/runtime/parseJson").parseJsonNumber';
+
+function parseJsonBigInt(s, pos, maxDigits) {
+ let numStr = "";
+ let c;
+ parseJsonBigInt.message = undefined;
+ if (s[pos] === "-") {
+ numStr += "-";
+ pos++;
+ }
+ if (s[pos] === "0") {
+ numStr += "0";
+ pos++;
+ }
+ else {
+ if (!parseDigits(maxDigits)) {
+ errorMessage();
+ return undefined;
+ }
+ }
+ if (maxDigits) {
+ parseJsonBigInt.position = pos;
+ return BigInt(numStr);
+ }
+ if (s[pos] === ".") {
+ numStr += ".";
+ pos++;
+ if (!parseDigits()) {
+ errorMessage();
+ return undefined;
+ }
+ }
+ if (((c = s[pos]), c === "e" || c === "E")) {
+ numStr += "e";
+ pos++;
+ if (((c = s[pos]), c === "+" || c === "-")) {
+ numStr += c;
+ pos++;
+ }
+ if (!parseDigits()) {
+ errorMessage();
+ return undefined;
+ }
+ }
+ parseJsonBigInt.position = pos;
+ return BigInt(numStr);
+ function parseDigits(maxLen) {
+ let digit = false;
+ while (((c = s[pos]), c >= "0" && c <= "9" && (maxLen === undefined || maxLen-- > 0))) {
+ digit = true;
+ numStr += c;
+ pos++;
+ }
+ return digit;
+ }
+ function errorMessage() {
+ parseJsonBigInt.position = pos;
+ parseJsonBigInt.message = pos < s.length ? `unexpected token ${s[pos]}` : "unexpected end";
+ }
+}
+exports.parseJsonBigInt = parseJsonBigInt;
+parseJsonBigInt.message = undefined;
+parseJsonBigInt.position = 0;
+parseJsonBigInt.code = 'require("ajv/dist/runtime/parseJson").parseJsonBigInt';
+
+
const escapedChars = {
b: "\b",
f: "\f",
diff --git a/node_modules/ajv/dist/vocabularies/jtd/type.js b/node_modules/ajv/dist/vocabularies/jtd/type.js
index 428bddb..fbc3070 100644
--- a/node_modules/ajv/dist/vocabularies/jtd/type.js
+++ b/node_modules/ajv/dist/vocabularies/jtd/type.js
@@ -45,6 +45,9 @@ const def = {
cond = timestampCode(cxt);
break;
}
+ case "bigint":
+ cond = codegen_1._`typeof ${data} == "bigint" || typeof ${data} == "string"`
+ break
case "float32":
case "float64":
cond = codegen_1._ `typeof ${data} == "number"`;

View File

@ -2,16 +2,25 @@ const path = require("path");
const fs = require("fs");
const { stdout, exit } = require("process");
const readline = require("readline");
const { execIn } = require("./utils.js");
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
const data = { env: [], config: { register: {} } };
const data = { env: [], config: { register: {} }, extra_pkgs: [] };
let rights = [];
process.on('SIGINT', function() {
console.log("Caught interrupt signal");
process.exit();
});
console.log("Welcome to Fosscord!");
console.log("Please remember this is pre-release software!");
console.log("We will guide you through some important setup steps.");
console.log();
if(fs.existsSync("package-lock.json")) fs.rmSync("package-lock.json");
if(fs.existsSync("yarn.lock")) fs.rmSync("yarn.lock");
async function main() {
printTitle("Step 1: Database setup");
console.log("1. PostgreSQL (recommended)");
@ -22,10 +31,13 @@ async function main() {
let answer = await ask("Please select a database type: ");
if (answer == "1") {
data.db = "postgres";
data.extra_pkgs.push("pg");
} else if (answer == "2") {
data.db = "mariadb";
data.extra_pkgs.push("mysql2");
} else if (answer == "3") {
data.db = "sqlite";
data.extra_pkgs.push("sqlite3");
} else {
console.log("Invalid choice!");
}
@ -62,7 +74,7 @@ async function main() {
data.domain = await ask("Domain (default=localhost): ");
if (!data.domain) data.domain = "localhost";
else data.ssl = /y?/i.test(await ask("SSL/HTTPS (Y/n): ")).toLowerCase();
else data.ssl = /y?/i.test(await ask("SSL/HTTPS (Y/n): "));
data.port = await ask("Port (default=3001): ");
if (!data.port) data.port = "3001";
@ -70,6 +82,7 @@ async function main() {
if (data.db != "sqlite")
data.env.push(`DATABASE=${data.db}://${data.db_user}:${data.db_pass}@${data.db_host}:${data.db_port}/${data.db_name}`);
data.env.push(`PORT=${data.port}`);
data.env.push('THREADS=1')
printTitle("Step 4: Default rights");
console.log("Please enter the default rights for new users.");
@ -111,9 +124,32 @@ async function main() {
},
...data.config
};
printTitle("Step 5: extra options");
if(/y?/i.test(await ask("Use fast BCrypt implementation (requires a compiler) (Y/n): "))) data.extra_pkgs.push("bcrypt");
if(/y?/.test(await ask("Enable support for widgets (requires compiler, known to fail on some ARM devices.) (Y/n): "))) data.extra_pkgs.push("canvas");
printTitle("Step 6: finalizing...");
//save
console.log("==> Writing .env...");
fs.writeFileSync(".env", data.env.join("\n"));
console.log("==> Writing initial.json");
fs.writeFileSync("initial.json", JSON.stringify(data.config, (space = 4)));
//install packages...
console.log("==> Installing packages...");
console.log(" ==> Ensuring yarn is up to date (v3, not v1)...");
execIn("npx yarn set version stable", process.cwd());
console.log(" ==> Installing base packages");
execIn("npx --yes yarn install", process.cwd(), {stdio: "inherit"});
console.log(` ==> Installing extra packages: ${data.extra_pkgs.join(', ')}...`);
execIn(`npx --yes yarn add -O ${data.extra_pkgs.join(' ')}`, process.cwd(), {stdio: "inherit"});
console.log('==> Building...')
execIn('npx --yes yarn run build', process.cwd(), {stdio: "inherit"});
printTitle("Step 6: run your instance!");
console.log("Installation is complete!");
console.log("You can now start your instance by running 'npm run start:bundle'!");
exit(0);
}
main();

View File

@ -1,5 +0,0 @@
#rm -rf dist/
#mkdir dist
rm -rfv *.js *.js.map
ln -s ../../bundle/node_modules node_modules
tsc -p .

View File

@ -1,7 +0,0 @@
/*import { Plugin } from "@fosscord/util"
export default class TestPlugin extends Plugin {
onPluginLoaded(): void {
console.log("Hello from test plugin! IT WORKS!!!!!!!");
}
}*/

View File

@ -1,9 +0,0 @@
{
"id": "example-plugin",
"name": "Fosscord example plugin",
"authors": [
"The Arcane Brony"
],
"repository": "https://github.com/fosscord/fosscord-server",
"license": ""
}

View File

@ -1,85 +0,0 @@
{
"include": ["./**/*.ts"],
"exclude": [],
"compilerOptions": {
/* Basic Options */
"incremental": false /* Enable incremental compilation */,
"target": "ESNext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
"lib": [
"ESNext"
] /* Specify library files to be included in the compilation. */,
"allowJs": true /* Allow javascript files to be compiled. */,
"checkJs": true /* Report errors in .js files. */,
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
"declaration": false /* Generates corresponding '.d.ts' file. */,
"declarationMap": false /* Generates a sourcemap for each corresponding '.d.ts' file. */,
"sourceMap": true /* Generates corresponding '.map' file. */,
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./dist/" /* Redirect output structure to the directory. */,
"rootDir": "./" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true /* Enable all strict type-checking options. */,
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
"strictNullChecks": true /* Enable strict null checks. */,
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
"strictPropertyInitialization": false /* Enable strict checking of property initialization in classes. */,
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
"alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */,
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
"types": [
"node"
] /* Type declaration files to be included in compilation. */,
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true /* Skip type checking of declaration files. */,
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"baseUrl": "../../bundle/dist/",
"paths": {
"@fosscord/api": ["../../api/src/index"],
"@fosscord/gateway": ["../../gateway/src/index"],
"@fosscord/cdn": ["../../cdn/src/index"],
"@fosscord/util": ["../../util/src/index"]
},
"plugins": [{ "transform": "@ovos-media/ts-transform-paths" }],
"noEmitHelpers": true,
"importHelpers": true
}
}

15950
yarn.lock

File diff suppressed because it is too large Load Diff