diff --git a/assets/openapi.json b/assets/openapi.json
index 26c330a5..7d506bab 100644
--- a/assets/openapi.json
+++ b/assets/openapi.json
@@ -3446,6 +3446,107 @@
"view_nsfw_guilds"
]
},
+ "SessionsLogoutSchema": {
+ "type": "object",
+ "properties": {
+ "session_ids": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "session_id_hashes": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "GetSessionsResponse": {
+ "type": "object",
+ "properties": {
+ "user_sessions": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "id_hash": {
+ "type": "string"
+ },
+ "status": {
+ "type": "string"
+ },
+ "activities": {
+ "type": "array",
+ "items": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Activity"
+ }
+ }
+ },
+ "client_status": {
+ "$ref": "#/components/schemas/ClientStatus"
+ },
+ "approx_last_used_time": {
+ "type": "string"
+ },
+ "client_info": {
+ "type": "object",
+ "properties": {
+ "client": {
+ "type": "string"
+ },
+ "os": {
+ "type": "string"
+ },
+ "version": {
+ "type": "integer"
+ },
+ "location": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "client",
+ "location",
+ "os",
+ "version"
+ ]
+ },
+ "last_seen": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "last_seen_ip": {
+ "type": "string"
+ },
+ "last_seen_location": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "activities",
+ "approx_last_used_time",
+ "client_info",
+ "client_status",
+ "id",
+ "id_hash",
+ "status"
+ ]
+ }
+ }
+ },
+ "required": [
+ "user_sessions"
+ ]
+ },
"GuildProfileResponse": {
"type": "object",
"properties": {
@@ -7179,6 +7280,9 @@
"name": {
"type": "string"
},
+ "id": {
+ "type": "string"
+ },
"type": {
"enum": [
0,
@@ -7204,9 +7308,6 @@
],
"type": "number"
},
- "id": {
- "type": "string"
- },
"flags": {
"type": "integer"
},
@@ -7342,107 +7443,6 @@
"name"
]
},
- "SessionsLogoutSchema": {
- "type": "object",
- "properties": {
- "session_ids": {
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- "session_id_hashes": {
- "type": "array",
- "items": {
- "type": "string"
- }
- }
- }
- },
- "GetSessionsResponse": {
- "type": "object",
- "properties": {
- "user_sessions": {
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "id": {
- "type": "string"
- },
- "id_hash": {
- "type": "string"
- },
- "status": {
- "type": "string"
- },
- "activities": {
- "type": "array",
- "items": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Activity"
- }
- }
- },
- "client_status": {
- "$ref": "#/components/schemas/ClientStatus"
- },
- "approx_last_used_time": {
- "type": "string"
- },
- "client_info": {
- "type": "object",
- "properties": {
- "client": {
- "type": "string"
- },
- "os": {
- "type": "string"
- },
- "version": {
- "type": "integer"
- },
- "location": {
- "type": "string"
- }
- },
- "additionalProperties": false,
- "required": [
- "client",
- "location",
- "os",
- "version"
- ]
- },
- "last_seen": {
- "type": "string",
- "format": "date-time"
- },
- "last_seen_ip": {
- "type": "string"
- },
- "last_seen_location": {
- "type": "string"
- }
- },
- "additionalProperties": false,
- "required": [
- "activities",
- "approx_last_used_time",
- "client_info",
- "client_status",
- "id",
- "id_hash",
- "status"
- ]
- }
- }
- },
- "required": [
- "user_sessions"
- ]
- },
"ApplicationCommandOption": {
"type": "object",
"properties": {
diff --git a/assets/schemas.json b/assets/schemas.json
index 89841e86..9f1d70fd 100644
--- a/assets/schemas.json
+++ b/assets/schemas.json
@@ -3653,6 +3653,111 @@
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
+ "SessionsLogoutSchema": {
+ "type": "object",
+ "properties": {
+ "session_ids": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "session_id_hashes": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ "additionalProperties": false,
+ "$schema": "http://json-schema.org/draft-07/schema#"
+ },
+ "GetSessionsResponse": {
+ "type": "object",
+ "properties": {
+ "user_sessions": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "id_hash": {
+ "type": "string"
+ },
+ "status": {
+ "type": "string"
+ },
+ "activities": {
+ "type": "array",
+ "items": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Activity"
+ }
+ }
+ },
+ "client_status": {
+ "$ref": "#/definitions/ClientStatus"
+ },
+ "approx_last_used_time": {
+ "type": "string"
+ },
+ "client_info": {
+ "type": "object",
+ "properties": {
+ "client": {
+ "type": "string"
+ },
+ "os": {
+ "type": "string"
+ },
+ "version": {
+ "type": "integer"
+ },
+ "location": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "client",
+ "location",
+ "os",
+ "version"
+ ]
+ },
+ "last_seen": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "last_seen_ip": {
+ "type": "string"
+ },
+ "last_seen_location": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "activities",
+ "approx_last_used_time",
+ "client_info",
+ "client_status",
+ "id",
+ "id_hash",
+ "status"
+ ]
+ }
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "user_sessions"
+ ],
+ "$schema": "http://json-schema.org/draft-07/schema#"
+ },
"GuildProfileResponse": {
"type": "object",
"properties": {
@@ -7643,6 +7748,9 @@
"name": {
"type": "string"
},
+ "id": {
+ "type": "string"
+ },
"type": {
"enum": [
0,
@@ -7668,9 +7776,6 @@
],
"type": "number"
},
- "id": {
- "type": "string"
- },
"flags": {
"type": "integer"
},
@@ -7819,111 +7924,6 @@
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
- "SessionsLogoutSchema": {
- "type": "object",
- "properties": {
- "session_ids": {
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- "session_id_hashes": {
- "type": "array",
- "items": {
- "type": "string"
- }
- }
- },
- "additionalProperties": false,
- "$schema": "http://json-schema.org/draft-07/schema#"
- },
- "GetSessionsResponse": {
- "type": "object",
- "properties": {
- "user_sessions": {
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "id": {
- "type": "string"
- },
- "id_hash": {
- "type": "string"
- },
- "status": {
- "type": "string"
- },
- "activities": {
- "type": "array",
- "items": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/Activity"
- }
- }
- },
- "client_status": {
- "$ref": "#/definitions/ClientStatus"
- },
- "approx_last_used_time": {
- "type": "string"
- },
- "client_info": {
- "type": "object",
- "properties": {
- "client": {
- "type": "string"
- },
- "os": {
- "type": "string"
- },
- "version": {
- "type": "integer"
- },
- "location": {
- "type": "string"
- }
- },
- "additionalProperties": false,
- "required": [
- "client",
- "location",
- "os",
- "version"
- ]
- },
- "last_seen": {
- "type": "string",
- "format": "date-time"
- },
- "last_seen_ip": {
- "type": "string"
- },
- "last_seen_location": {
- "type": "string"
- }
- },
- "additionalProperties": false,
- "required": [
- "activities",
- "approx_last_used_time",
- "client_info",
- "client_status",
- "id",
- "id_hash",
- "status"
- ]
- }
- }
- },
- "additionalProperties": false,
- "required": [
- "user_sessions"
- ],
- "$schema": "http://json-schema.org/draft-07/schema#"
- },
"ApplicationCommandOption": {
"type": "object",
"properties": {
diff --git a/src/database/Database.ts b/src/database/Database.ts
index a1d39478..3fabc179 100644
--- a/src/database/Database.ts
+++ b/src/database/Database.ts
@@ -16,13 +16,10 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-import { config } from "dotenv";
import path from "node:path";
+import fs from "node:fs";
import { green, red, yellow } from "picocolors";
import { DataSource } from "typeorm";
-// noinspection ES6PreferShortImport
-import { ConfigEntity } from "@spacebar/database/entities/Config";
-import fs from "node:fs";
import { ProcessLifecycle } from "../util/util/ProcessLifecycle";
// UUID extension option is only supported with postgres
@@ -34,7 +31,7 @@ let isHeadlessProcess = false;
// For typeorm cli
if (!process.env) {
isHeadlessProcess = true;
- config({ quiet: true });
+ require("dotenv").config({ quiet: true });
}
if (process.argv[1]?.endsWith("scripts/openapi.js")) isHeadlessProcess = true;
@@ -100,7 +97,8 @@ export async function initDatabase(): Promise<DataSource> {
// Crude way of detecting if the migrations table exists.
const dbExists = async () => {
try {
- await ConfigEntity.count();
+ // do not globally import to avoid circular references
+ await require("./entities/Config").ConfigEntity.count();
return true;
} catch (e) {
return false;
|