Refactor types

This commit is contained in:
Benjamin Toby
2024-10-14 07:49:01 +01:00
parent 11a4c1f4d9
commit d84b15c35c
46 changed files with 696 additions and 376 deletions
+1 -1
View File
@@ -64,7 +64,7 @@ async function addUser({
DSQL_PASS?.match(/./) &&
DSQL_DB_NAME?.match(/./)
) {
/** @type {import("../types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
/** @type {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
let dbSchema;
try {
+1 -1
View File
@@ -83,7 +83,7 @@ async function getUser({ key, userId, database, fields }) {
DSQL_PASS?.match(/./) &&
DSQL_DB_NAME?.match(/./)
) {
/** @type {import("../types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
/** @type {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
let dbSchema;
try {
+11 -6
View File
@@ -65,7 +65,7 @@ async function loginUser({
? temp_code_field
? temp_code_field
: defaultTempLoginFieldName
: null;
: undefined;
/**
* Check Encryption Keys
@@ -126,7 +126,7 @@ async function loginUser({
DSQL_PASS?.match(/./) &&
DSQL_DB_NAME?.match(/./)
) {
/** @type {import("../types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
/** @type {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
let dbSchema;
try {
@@ -145,6 +145,7 @@ async function loginUser({
email_login,
email_login_code,
email_login_field: emailLoginTempCodeFieldName,
token,
});
}
} else {
@@ -156,7 +157,8 @@ async function loginUser({
* @type {{ success: boolean, payload: import("../types/user.td").DATASQUIREL_LoggedInUser | null, userId?: number, msg?: string }}
*/
httpResponse = await new Promise((resolve, reject) => {
const reqPayload = JSON.stringify({
/** @type {PackageUserLoginRequestBody} */
const reqPayload = {
encryptionKey,
payload,
database,
@@ -164,7 +166,10 @@ async function loginUser({
email_login,
email_login_code,
email_login_field: emailLoginTempCodeFieldName,
});
token,
};
const reqPayloadJSON = JSON.stringify(reqPayload);
const httpsRequest = (
scheme?.match(/^http$/i) ? http : https
@@ -173,7 +178,7 @@ async function loginUser({
method: "POST",
headers: {
"Content-Type": "application/json",
"Content-Length": Buffer.from(reqPayload).length,
"Content-Length": Buffer.from(reqPayloadJSON).length,
Authorization: key,
},
port: localHostPort || 443,
@@ -203,7 +208,7 @@ async function loginUser({
}
);
httpsRequest.write(reqPayload);
httpsRequest.write(reqPayloadJSON);
httpsRequest.end();
});
}
+1 -1
View File
@@ -103,7 +103,7 @@ async function reauthUser({
DSQL_PASS?.match(/./) &&
DSQL_DB_NAME?.match(/./)
) {
/** @type {import("../types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
/** @type {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
let dbSchema;
try {
+1 -1
View File
@@ -114,7 +114,7 @@ async function sendEmailCode({
DSQL_PASS?.match(/./) &&
DSQL_DB_NAME?.match(/./)
) {
/** @type {import("../types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
/** @type {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
let dbSchema;
try {
+1 -1
View File
@@ -154,7 +154,7 @@ async function githubAuth({
DSQL_PASS?.match(/./) &&
DSQL_DB_NAME?.match(/./)
) {
/** @type {import("../../types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
/** @type {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined | undefined} */
let dbSchema;
try {
+1 -1
View File
@@ -150,7 +150,7 @@ async function googleAuth({
DSQL_PASS?.match(/./) &&
DSQL_DB_NAME?.match(/./)
) {
/** @type {import("../../types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
/** @type {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined | undefined} */
let dbSchema;
try {
+1 -1
View File
@@ -57,7 +57,7 @@ async function updateUser({ key, payload, database }) {
DSQL_PASS?.match(/./) &&
DSQL_DB_NAME?.match(/./)
) {
/** @type {import("../types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
/** @type {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
let dbSchema;
try {