summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/benchmark/connections.js4
-rw-r--r--scripts/benchmark/index.js4
-rw-r--r--scripts/benchmark/users.js4
-rw-r--r--scripts/changelog.js4
-rw-r--r--scripts/openapi.js34
-rw-r--r--scripts/rights.js4
-rw-r--r--scripts/schema.js40
-rw-r--r--scripts/stagingMigration/index.js4
-rw-r--r--scripts/stagingMigration/maria/1672833135670-staging.js4
-rw-r--r--scripts/stagingMigration/mysql/1672833135670-staging.js4
-rw-r--r--scripts/stagingMigration/postgres/1672815835837-staging.js4
-rw-r--r--scripts/stresstest/index.js4
-rw-r--r--scripts/stresstest/src/login/index.js4
-rw-r--r--scripts/stresstest/src/message/send.js4
-rw-r--r--scripts/stresstest/src/register/index.js4
-rw-r--r--scripts/syncronise.js4
-rw-r--r--scripts/util/getRouteDescriptions.js4
-rw-r--r--scripts/util/licensePreamble.txt4
-rw-r--r--scripts/util/walk.js4
19 files changed, 96 insertions, 46 deletions
diff --git a/scripts/benchmark/connections.js b/scripts/benchmark/connections.js

index 6e65b8c7..4246c646 100644 --- a/scripts/benchmark/connections.js +++ b/scripts/benchmark/connections.js
@@ -1,6 +1,6 @@ /* - Fosscord: A FOSS re-implementation and extension of the Discord.com backend. - Copyright (C) 2023 Fosscord and Fosscord Contributors + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2023 Spacebar and Spacebar Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/scripts/benchmark/index.js b/scripts/benchmark/index.js
index e56d6f06..ca799a85 100644 --- a/scripts/benchmark/index.js +++ b/scripts/benchmark/index.js
@@ -1,6 +1,6 @@ /* - Fosscord: A FOSS re-implementation and extension of the Discord.com backend. - Copyright (C) 2023 Fosscord and Fosscord Contributors + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2023 Spacebar and Spacebar Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/scripts/benchmark/users.js b/scripts/benchmark/users.js
index ac927aab..20f9f7c3 100644 --- a/scripts/benchmark/users.js +++ b/scripts/benchmark/users.js
@@ -1,6 +1,6 @@ /* - Fosscord: A FOSS re-implementation and extension of the Discord.com backend. - Copyright (C) 2023 Fosscord and Fosscord Contributors + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2023 Spacebar and Spacebar Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/scripts/changelog.js b/scripts/changelog.js
index 9f564bcd..221864b4 100644 --- a/scripts/changelog.js +++ b/scripts/changelog.js
@@ -1,6 +1,6 @@ /* - Fosscord: A FOSS re-implementation and extension of the Discord.com backend. - Copyright (C) 2023 Fosscord and Fosscord Contributors + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2023 Spacebar and Spacebar Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/scripts/openapi.js b/scripts/openapi.js
index f280eba4..b5001829 100644 --- a/scripts/openapi.js +++ b/scripts/openapi.js
@@ -1,6 +1,6 @@ /* - Fosscord: A FOSS re-implementation and extension of the Discord.com backend. - Copyright (C) 2023 Fosscord and Fosscord Contributors + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2023 Spacebar and Spacebar Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published @@ -16,6 +16,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ +/* eslint-env node */ + require("module-alias/register"); const getRouteDescriptions = require("./util/getRouteDescriptions"); const path = require("path"); @@ -27,7 +29,31 @@ require("missing-native-js-functions"); const openapiPath = path.join(__dirname, "..", "assets", "openapi.json"); const SchemaPath = path.join(__dirname, "..", "assets", "schemas.json"); -const schemas = JSON.parse(fs.readFileSync(SchemaPath, { encoding: "utf8" })); +let schemas = JSON.parse(fs.readFileSync(SchemaPath, { encoding: "utf8" })); + +for (var schema in schemas) { + const part = schemas[schema]; + for (var key in part.properties) { + if (part.properties[key].anyOf) { + const nullIndex = part.properties[key].anyOf.findIndex( + (x) => x.type == "null", + ); + if (nullIndex != -1) { + part.properties[key].nullable = true; + part.properties[key].anyOf.splice(nullIndex, 1); + + if (part.properties[key].anyOf.length == 1) { + Object.assign( + part.properties[key], + part.properties[key].anyOf[0], + ); + delete part.properties[key].anyOf; + } + } + } + } +} + const specification = JSON.parse( fs.readFileSync(openapiPath, { encoding: "utf8" }), ); @@ -109,7 +135,7 @@ function apiRoutes() { return x.test(path); }) ) { - obj.security = [{ bearer: true }]; + obj.security = [{ bearer: [] }]; } if (route.body) { diff --git a/scripts/rights.js b/scripts/rights.js
index 473d4850..bf79ef79 100644 --- a/scripts/rights.js +++ b/scripts/rights.js
@@ -1,6 +1,6 @@ /* - Fosscord: A FOSS re-implementation and extension of the Discord.com backend. - Copyright (C) 2023 Fosscord and Fosscord Contributors + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2023 Spacebar and Spacebar Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/scripts/schema.js b/scripts/schema.js
index be1a7a3f..12e3cdb5 100644 --- a/scripts/schema.js +++ b/scripts/schema.js
@@ -1,6 +1,6 @@ /* - Fosscord: A FOSS re-implementation and extension of the Discord.com backend. - Copyright (C) 2023 Fosscord and Fosscord Contributors + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2023 Spacebar and Spacebar Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published @@ -20,6 +20,8 @@ Regenerates the `fosscord-server/assets/schemas.json` file, used for API/Gateway input validation. */ +/* eslint-env node */ + const path = require("path"); const fs = require("fs"); const TJS = require("typescript-json-schema"); @@ -91,9 +93,9 @@ function main() { if (!part) continue; // this is a hack. want some want to check if its a @column, instead - if (part.properties) - Object.keys(part.properties) - .filter((key) => + if (part.properties) { + for (let key in part.properties) { + if ( [ // BaseClass methods "toJSON", @@ -104,9 +106,31 @@ function main() { "recover", "reload", "assign", - ].includes(key), - ) - .forEach((key) => delete part.properties[key]); + ].includes(key) + ) { + delete part.properties[key]; + continue; + } + + // if (part.properties[key].anyOf) { + // const nullIndex = part.properties[key].anyOf.findIndex( + // (x) => x.type == "null", + // ); + // if (nullIndex != -1) { + // part.properties[key].nullable = true; + // part.properties[key].anyOf.splice(nullIndex, 1); + + // if (part.properties[key].anyOf.length == 1) { + // Object.assign( + // part.properties[key], + // part.properties[key].anyOf[0], + // ); + // delete part.properties[key].anyOf; + // } + // } + // } + } + } definitions = { ...definitions, [name]: { ...part } }; } diff --git a/scripts/stagingMigration/index.js b/scripts/stagingMigration/index.js
index 505405c8..8ba3daa0 100644 --- a/scripts/stagingMigration/index.js +++ b/scripts/stagingMigration/index.js
@@ -1,6 +1,6 @@ /* - Fosscord: A FOSS re-implementation and extension of the Discord.com backend. - Copyright (C) 2023 Fosscord and Fosscord Contributors + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2023 Spacebar and Spacebar Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/scripts/stagingMigration/maria/1672833135670-staging.js b/scripts/stagingMigration/maria/1672833135670-staging.js
index fc04ba58..0da731dc 100644 --- a/scripts/stagingMigration/maria/1672833135670-staging.js +++ b/scripts/stagingMigration/maria/1672833135670-staging.js
@@ -1,6 +1,6 @@ /* - Fosscord: A FOSS re-implementation and extension of the Discord.com backend. - Copyright (C) 2023 Fosscord and Fosscord Contributors + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2023 Spacebar and Spacebar Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/scripts/stagingMigration/mysql/1672833135670-staging.js b/scripts/stagingMigration/mysql/1672833135670-staging.js
index fc04ba58..0da731dc 100644 --- a/scripts/stagingMigration/mysql/1672833135670-staging.js +++ b/scripts/stagingMigration/mysql/1672833135670-staging.js
@@ -1,6 +1,6 @@ /* - Fosscord: A FOSS re-implementation and extension of the Discord.com backend. - Copyright (C) 2023 Fosscord and Fosscord Contributors + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2023 Spacebar and Spacebar Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/scripts/stagingMigration/postgres/1672815835837-staging.js b/scripts/stagingMigration/postgres/1672815835837-staging.js
index 64031e5f..8c10eedf 100644 --- a/scripts/stagingMigration/postgres/1672815835837-staging.js +++ b/scripts/stagingMigration/postgres/1672815835837-staging.js
@@ -1,6 +1,6 @@ /* - Fosscord: A FOSS re-implementation and extension of the Discord.com backend. - Copyright (C) 2023 Fosscord and Fosscord Contributors + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2023 Spacebar and Spacebar Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/scripts/stresstest/index.js b/scripts/stresstest/index.js
index 07e17de7..bb8c72e4 100644 --- a/scripts/stresstest/index.js +++ b/scripts/stresstest/index.js
@@ -1,6 +1,6 @@ /* - Fosscord: A FOSS re-implementation and extension of the Discord.com backend. - Copyright (C) 2023 Fosscord and Fosscord Contributors + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2023 Spacebar and Spacebar Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/scripts/stresstest/src/login/index.js b/scripts/stresstest/src/login/index.js
index fb68c8b2..128a477b 100644 --- a/scripts/stresstest/src/login/index.js +++ b/scripts/stresstest/src/login/index.js
@@ -1,6 +1,6 @@ /* - Fosscord: A FOSS re-implementation and extension of the Discord.com backend. - Copyright (C) 2023 Fosscord and Fosscord Contributors + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2023 Spacebar and Spacebar Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/scripts/stresstest/src/message/send.js b/scripts/stresstest/src/message/send.js
index 622fc1fb..ca6af62c 100644 --- a/scripts/stresstest/src/message/send.js +++ b/scripts/stresstest/src/message/send.js
@@ -1,6 +1,6 @@ /* - Fosscord: A FOSS re-implementation and extension of the Discord.com backend. - Copyright (C) 2023 Fosscord and Fosscord Contributors + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2023 Spacebar and Spacebar Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/scripts/stresstest/src/register/index.js b/scripts/stresstest/src/register/index.js
index 4097d854..f1e56813 100644 --- a/scripts/stresstest/src/register/index.js +++ b/scripts/stresstest/src/register/index.js
@@ -1,6 +1,6 @@ /* - Fosscord: A FOSS re-implementation and extension of the Discord.com backend. - Copyright (C) 2023 Fosscord and Fosscord Contributors + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2023 Spacebar and Spacebar Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/scripts/syncronise.js b/scripts/syncronise.js
index b1658deb..34cd0ddd 100644 --- a/scripts/syncronise.js +++ b/scripts/syncronise.js
@@ -1,6 +1,6 @@ /* - Fosscord: A FOSS re-implementation and extension of the Discord.com backend. - Copyright (C) 2023 Fosscord and Fosscord Contributors + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2023 Spacebar and Spacebar Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/scripts/util/getRouteDescriptions.js b/scripts/util/getRouteDescriptions.js
index 649cafaf..fe36c238 100644 --- a/scripts/util/getRouteDescriptions.js +++ b/scripts/util/getRouteDescriptions.js
@@ -1,6 +1,6 @@ /* - Fosscord: A FOSS re-implementation and extension of the Discord.com backend. - Copyright (C) 2023 Fosscord and Fosscord Contributors + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2023 Spacebar and Spacebar Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/scripts/util/licensePreamble.txt b/scripts/util/licensePreamble.txt
index f6c70e00..2f76a3c5 100644 --- a/scripts/util/licensePreamble.txt +++ b/scripts/util/licensePreamble.txt
@@ -1,5 +1,5 @@ -Fosscord: A FOSS re-implementation and extension of the Discord.com backend. -Copyright (C) 2023 Fosscord and Fosscord Contributors +Spacebar: A FOSS re-implementation and extension of the Discord.com backend. +Copyright (C) 2023 Spacebar and Spacebar Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/scripts/util/walk.js b/scripts/util/walk.js
index 66e98447..be59023d 100644 --- a/scripts/util/walk.js +++ b/scripts/util/walk.js
@@ -1,6 +1,6 @@ /* - Fosscord: A FOSS re-implementation and extension of the Discord.com backend. - Copyright (C) 2023 Fosscord and Fosscord Contributors + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2023 Spacebar and Spacebar Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published