This commit is contained in:
Benjamin Toby
2025-04-18 12:06:15 +01:00
parent 8d38f99bf1
commit 6593047efd
180 changed files with 3965 additions and 2 deletions
+18
View File
@@ -0,0 +1,18 @@
interface Return {
success: boolean;
payload: {
urlPath: string;
urlThumbnailPath: string;
} | null;
msg?: string;
}
type Param = {
key: string;
url: string;
user_id?: string | number;
};
/**
* # Delete File via API
*/
export default function deleteFile({ key, url, user_id, }: Param): Promise<Return>;
export {};
+1
View File
@@ -0,0 +1 @@
export default function getCsrfHeaderName(): string;
+10
View File
@@ -0,0 +1,10 @@
import { DSQL_DatabaseSchemaType, DSQL_FieldSchemaType, DSQL_TableSchemaType, GetSchemaAPIParam } from "../types";
type GetSchemaReturn = {
success: boolean;
payload?: DSQL_DatabaseSchemaType | DSQL_TableSchemaType | DSQL_FieldSchemaType | null;
};
/**
* # Get Schema for Database, table, or field *
*/
export default function getSchema({ key, database, field, table, user_id, env, }: GetSchemaAPIParam): Promise<GetSchemaReturn>;
export {};
+25
View File
@@ -0,0 +1,25 @@
import { ApiGetQueryObject, GetReturn } from "../types";
type Param<T extends {
[k: string]: any;
} = {
[k: string]: any;
}> = {
key?: string;
db?: string;
query: string | ApiGetQueryObject<T>;
queryValues?: string[];
tableName?: string;
user_id?: string | number;
debug?: boolean;
forceLocal?: boolean;
};
export type ApiGetParams = Param;
/**
* # Make a get request to Datasquirel API
*/
export default function get<T extends {
[k: string]: any;
} = {
[k: string]: any;
}>({ key, db, query, queryValues, tableName, user_id, debug, forceLocal, }: Param<T>): Promise<GetReturn>;
export {};
+15
View File
@@ -0,0 +1,15 @@
import { PostDataPayload, PostReturn } from "../types";
type Param = {
key?: string;
database?: string;
query: string | PostDataPayload;
queryValues?: any[];
tableName?: string;
user_id?: boolean;
forceLocal?: boolean;
};
/**
* # Make a post request to Datasquirel API
*/
export default function post({ key, query, queryValues, database, tableName, user_id, forceLocal, }: Param): Promise<PostReturn>;
export {};
+23
View File
@@ -0,0 +1,23 @@
interface Return {
success: boolean;
payload: {
urlPath: string;
} | null;
msg?: string;
}
type Param = {
key: string;
payload: {
fileData: string;
fileName: string;
mimeType?: string;
folder?: string;
isPrivate?: boolean;
};
user_id?: boolean;
};
/**
* # Upload File via API
*/
export default function uploadImage({ key, payload, user_id, }: Param): Promise<Return>;
export {};
+25
View File
@@ -0,0 +1,25 @@
interface FunctionReturn {
success: boolean;
payload: {
urlPath: string;
urlThumbnailPath: string;
} | null;
msg?: string;
}
type Param = {
key?: string;
payload: {
imageData: string;
imageName: string;
mimeType?: string;
thumbnailSize?: number;
folder?: string;
isPrivate?: boolean;
};
user_id?: boolean;
};
/**
* # Upload Image via API
*/
export default function uploadImage({ key, payload, user_id, }: Param): Promise<FunctionReturn>;
export {};
+15
View File
@@ -0,0 +1,15 @@
import { AddUserFunctionReturn, UserDataPayload } from "../../types";
type Param = {
key?: string;
database?: string;
payload: UserDataPayload;
encryptionKey?: string;
encryptionSalt?: string;
user_id?: string | number;
apiUserId?: string | number;
};
/**
* # Add User to Database
*/
export default function addUser({ key, payload, database, encryptionKey, user_id, apiUserId, }: Param): Promise<AddUserFunctionReturn>;
export {};
+12
View File
@@ -0,0 +1,12 @@
import { UpdateUserFunctionReturn } from "../../types";
type Param = {
key?: string;
database?: string;
deletedUserId: string | number;
user_id?: boolean;
};
/**
* # Update User
*/
export default function deleteUser({ key, database, user_id, deletedUserId, }: Param): Promise<UpdateUserFunctionReturn>;
export {};
+20
View File
@@ -0,0 +1,20 @@
import http from "http";
type Param = {
request?: http.IncomingMessage;
cookieString?: string;
encryptionKey: string;
encryptionSalt: string;
database: string;
};
type Return = {
key: string | undefined;
csrf: string | undefined;
};
/**
* Get just the access token for user
* ==============================================================================
* @description This Function takes in a request object and returns a user token
* string and csrf token string
*/
export default function getToken({ request, encryptionKey, encryptionSalt, cookieString, }: Param): Return;
export {};
+13
View File
@@ -0,0 +1,13 @@
import { GetUserFunctionReturn } from "../../types";
type Param = {
key: string;
database: string;
userId: number;
fields?: string[];
apiUserId?: boolean;
};
/**
* # Get User
*/
export default function getUser({ key, userId, database, fields, apiUserId, }: Param): Promise<GetUserFunctionReturn>;
export {};
+37
View File
@@ -0,0 +1,37 @@
import http from "http";
import { APILoginFunctionReturn } from "../../types";
type Param = {
key?: string;
database: string;
payload: {
email?: string;
username?: string;
password?: string;
};
additionalFields?: string[];
request?: http.IncomingMessage & {
[s: string]: any;
};
response?: http.ServerResponse & {
[s: string]: any;
};
encryptionKey?: string;
encryptionSalt?: string;
email_login?: boolean;
email_login_code?: string;
temp_code_field?: string;
token?: boolean;
user_id?: string | number;
skipPassword?: boolean;
debug?: boolean;
skipWriteAuthFile?: boolean;
apiUserID?: string | number;
dbUserId?: string | number;
cleanupTokens?: boolean;
secureCookie?: boolean;
};
/**
* # Login A user
*/
export default function loginUser({ key, payload, database, additionalFields, response, encryptionKey, encryptionSalt, email_login, email_login_code, temp_code_field, token, user_id, skipPassword, apiUserID, skipWriteAuthFile, dbUserId, debug, cleanupTokens, secureCookie, request, }: Param): Promise<APILoginFunctionReturn>;
export {};
+24
View File
@@ -0,0 +1,24 @@
import http from "http";
type Param = {
encryptedUserString?: string;
request?: http.IncomingMessage & {
[s: string]: any;
};
response?: http.ServerResponse & {
[s: string]: any;
};
cookieString?: string;
database?: string;
dsqlUserId?: string | number;
debug?: boolean;
};
type Return = {
success: boolean;
msg: string;
cookieNames?: any;
};
/**
* # Logout user
*/
export default function logoutUser({ response, database, dsqlUserId, encryptedUserString, request, cookieString, debug, }: Param): Return;
export {};
+20
View File
@@ -0,0 +1,20 @@
import http from "http";
import { APILoginFunctionReturn } from "../../types";
type Param = {
key?: string;
database?: string;
response?: http.ServerResponse;
request?: http.IncomingMessage;
level?: "deep" | "normal";
encryptionKey?: string;
encryptionSalt?: string;
additionalFields?: string[];
encryptedUserString?: string;
user_id?: string | number;
secureCookie?: boolean;
};
/**
* # Reauthorize User
*/
export default function reauthUser({ key, database, response, request, level, encryptionKey, encryptionSalt, additionalFields, encryptedUserString, user_id, secureCookie, }: Param): Promise<APILoginFunctionReturn>;
export {};
+23
View File
@@ -0,0 +1,23 @@
import http from "http";
import { SendOneTimeCodeEmailResponse } from "../../types";
type Param = {
key?: string;
database?: string;
email: string;
temp_code_field_name?: string;
response?: http.ServerResponse & {
[s: string]: any;
};
mail_domain?: string;
mail_username?: string;
mail_password?: string;
mail_port?: number;
sender?: string;
user_id?: boolean;
extraCookies?: import("../../types").CookieObject[];
};
/**
* # Send Email Code to a User
*/
export default function sendEmailCode({ key, email, database, temp_code_field_name, mail_domain, mail_password, mail_username, mail_port, sender, user_id, response, extraCookies, }: Param): Promise<SendOneTimeCodeEmailResponse>;
export {};
@@ -0,0 +1,35 @@
import http from "http";
interface FunctionReturn {
success: boolean;
user: {
id: number;
first_name: string;
last_name: string;
csrf_k: string;
social_id: string;
} | null;
dsqlUserId?: number;
msg?: string;
}
type Param = {
key: string;
code: string;
email: string | null;
database: string;
clientId: string;
clientSecret: string;
response: http.ServerResponse;
encryptionKey: string;
encryptionSalt: string;
additionalFields?: string[];
additionalData?: {
[s: string]: string | number;
};
user_id?: boolean;
secureCookie?: boolean;
};
/**
* # SERVER FUNCTION: Login with google Function
*/
export default function githubAuth({ key, code, email, database, clientId, clientSecret, response, encryptionKey, encryptionSalt, additionalFields, user_id, additionalData, secureCookie, }: Param): Promise<FunctionReturn | undefined>;
export {};
@@ -0,0 +1,22 @@
import http from "http";
import { APILoginFunctionReturn } from "../../../types";
type Param = {
key?: string;
token: string;
database?: string;
response?: http.ServerResponse;
encryptionKey?: string;
encryptionSalt?: string;
additionalFields?: string[];
additionalData?: {
[s: string]: string | number;
};
apiUserID?: string | number;
debug?: boolean;
secureCookie?: boolean;
};
/**
* # SERVER FUNCTION: Login with google Function
*/
export default function googleAuth({ key, token, database, response, encryptionKey, encryptionSalt, additionalFields, additionalData, apiUserID, debug, secureCookie, }: Param): Promise<APILoginFunctionReturn>;
export {};
+15
View File
@@ -0,0 +1,15 @@
import { UpdateUserFunctionReturn } from "../../types";
type Param = {
key?: string;
database?: string;
updatedUserId: string | number;
payload: {
[s: string]: any;
};
user_id?: boolean;
};
/**
* # Update User
*/
export default function updateUser({ key, payload, database, user_id, updatedUserId, }: Param): Promise<UpdateUserFunctionReturn>;
export {};
+28
View File
@@ -0,0 +1,28 @@
import http from "http";
import { AuthenticatedUser } from "../../types";
type Param = {
request?: http.IncomingMessage & {
[s: string]: any;
};
req?: http.IncomingMessage & {
[s: string]: any;
};
cookieString?: string;
encryptedUserString?: string;
encryptionKey?: string;
encryptionSalt?: string;
level?: "deep" | "normal";
database?: string;
dsqlUserId?: string | number;
expiry?: number;
csrfHeaderName?: string;
debug?: boolean;
};
/**
* Authenticate User from request
* ==============================================================================
* @description This Function takes in a request object and returns a user object
* with the user's data
*/
export default function userAuth({ request, req, encryptionKey, encryptionSalt, level, database, dsqlUserId, encryptedUserString, expiry, cookieString, csrfHeaderName, debug, }: Param): AuthenticatedUser;
export {};
@@ -0,0 +1,14 @@
import http from "http";
import { SendOneTimeCodeEmailResponse } from "../../types";
type Param = {
request?: http.IncomingMessage & {
[s: string]: any;
};
cookieString?: string;
email?: string;
};
/**
* # Verify the temp email code sent to the user's email address
*/
export default function validateTempEmailCode({ request, email, cookieString, }: Param): Promise<SendOneTimeCodeEmailResponse | null>;
export {};
+15
View File
@@ -0,0 +1,15 @@
import { DATASQUIREL_LoggedInUser } from "../../types";
type Param = {
token: string;
encryptionKey: string;
encryptionSalt: string;
level?: ("deep" | "normal") | null;
database: string;
};
/**
* Validate Token
* ======================================
* @description This Function takes in a encrypted token and returns a user object
*/
export default function validateToken({ token, encryptionKey, encryptionSalt, }: Param): DATASQUIREL_LoggedInUser | null;
export {};