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
+25
View File
@@ -0,0 +1,25 @@
import { DbContextsArray } from "../../backend/db/runQuery";
import { ApiGetQueryObject } from "../../../types";
type Param<T extends {
[key: string]: any;
} = {
[key: string]: any;
}> = {
query: string | ApiGetQueryObject<T>;
queryValues?: (string | number)[];
dbFullName: string;
tableName?: string;
dbSchema?: import("../../../types").DSQL_DatabaseSchemaType;
debug?: boolean;
dbContext?: (typeof DbContextsArray)[number];
forceLocal?: boolean;
};
/**
* # Get Function FOr API
*/
export default function apiGet<T extends {
[key: string]: any;
} = {
[key: string]: any;
}>({ query, dbFullName, queryValues, tableName, dbSchema, debug, dbContext, forceLocal, }: Param<T>): Promise<import("../../../types").GetReturn>;
export {};
+16
View File
@@ -0,0 +1,16 @@
import { DbContextsArray } from "../../backend/db/runQuery";
import { DSQL_DatabaseSchemaType, PostReturn } from "../../../types";
type Param = {
query: any;
queryValues?: (string | number)[];
dbFullName: string;
tableName?: string;
dbSchema?: DSQL_DatabaseSchemaType;
dbContext?: (typeof DbContextsArray)[number];
forceLocal?: boolean;
};
/**
* # Post Function For API
*/
export default function apiPost({ query, dbFullName, queryValues, tableName, dbSchema, dbContext, forceLocal, }: Param): Promise<PostReturn>;
export {};
@@ -0,0 +1,8 @@
import { UserType } from "../../../types";
/**
* # Facebook Login
*/
export default function facebookLogin({ usertype, body, }: {
body: any;
usertype: UserType;
}): Promise<any>;
@@ -0,0 +1,43 @@
export interface GithubUserPayload {
login: string;
id: number;
node_id: string;
avatar_url: string;
gravatar_id: string;
url: string;
html_url: string;
followers_url: string;
following_url: string;
gists_url: string;
starred_url: string;
subscriptions_url: string;
organizations_url: string;
repos_url: string;
received_events_url: string;
type: string;
site_admin: boolean;
name: string;
company: string;
blog: string;
location: string;
email: string;
hireable: string;
bio: string;
twitter_username: string;
public_repos: number;
public_gists: number;
followers: number;
following: number;
created_at: string;
updated_at: string;
}
type Param = {
code: string;
clientId: string;
clientSecret: string;
};
/**
* # Login/signup a github user
*/
export default function githubLogin({ code, clientId, clientSecret, }: Param): Promise<GithubUserPayload | null | undefined>;
export {};
@@ -0,0 +1,22 @@
type Param = {
usertype: string;
foundUser: any;
isSocialValidated: boolean;
isUserValid: boolean;
reqBody: any;
serverRes: any;
loginFailureReason: any;
};
/**
* # Google Login
*/
export default function googleLogin({ usertype, foundUser, isSocialValidated, isUserValid, reqBody, serverRes, loginFailureReason, }: Param): Promise<{
isGoogleAuthValid: boolean;
newFoundUser: null;
loginFailureReason: any;
} | {
isGoogleAuthValid: boolean;
newFoundUser: any;
loginFailureReason?: undefined;
} | undefined>;
export {};
@@ -0,0 +1,5 @@
import { APILoginFunctionReturn, HandleSocialDbFunctionParams } from "../../../types";
/**
* # Handle Social DB
*/
export default function handleSocialDb({ database, social_id, email, social_platform, payload, invitation, supEmail, additionalFields, debug, }: HandleSocialDbFunctionParams): Promise<APILoginFunctionReturn>;
@@ -0,0 +1,22 @@
import { APILoginFunctionReturn } from "../../../types";
type Param = {
user: {
first_name: string;
last_name: string;
email: string;
social_id: string | number;
};
social_platform: string;
invitation?: any;
database?: string;
additionalFields?: string[];
debug?: boolean;
};
/**
* Function to login social user
* ==============================================================================
* @description This function logs in the user after 'handleSocialDb' function finishes
* the user creation or confirmation process
*/
export default function loginSocialUser({ user, social_platform, invitation, database, additionalFields, debug, }: Param): Promise<APILoginFunctionReturn>;
export {};
@@ -0,0 +1,25 @@
import { APICreateUserFunctionParams } from "../../../types";
/**
* # API Create User
*/
export default function apiCreateUser({ encryptionKey, payload, database, userId, }: APICreateUserFunctionParams): Promise<{
success: boolean;
msg: string;
payload?: undefined;
sqlResult?: undefined;
} | {
success: boolean;
msg: string | undefined;
payload: null;
sqlResult?: undefined;
} | {
success: boolean;
payload: any;
msg?: undefined;
sqlResult?: undefined;
} | {
success: boolean;
msg: string;
sqlResult: any;
payload: null;
}>;
@@ -0,0 +1,14 @@
type Param = {
dbFullName: string;
deletedUserId: string | number;
};
type Return = {
success: boolean;
result?: any;
msg?: string;
};
/**
* # Update API User Function
*/
export default function apiDeleteUser({ dbFullName, deletedUserId, }: Param): Promise<Return>;
export {};
@@ -0,0 +1,5 @@
import { APIGetUserFunctionParams, GetUserFunctionReturn } from "../../../types";
/**
* # API Get User
*/
export default function apiGetUser({ fields, dbFullName, userId, }: APIGetUserFunctionParams): Promise<GetUserFunctionReturn>;
@@ -0,0 +1,5 @@
import { APILoginFunctionParams, APILoginFunctionReturn } from "../../../types";
/**
* # API Login
*/
export default function apiLoginUser({ encryptionKey, email, username, password, database, additionalFields, email_login, email_login_code, email_login_field, skipPassword, social, dbUserId, debug, }: APILoginFunctionParams): Promise<APILoginFunctionReturn>;
@@ -0,0 +1,13 @@
import { APILoginFunctionReturn } from "../../../types";
type Param = {
existingUser: {
[s: string]: any;
};
database?: string;
additionalFields?: string[];
};
/**
* # Re-authenticate API user
*/
export default function apiReauthUser({ existingUser, database, additionalFields, }: Param): Promise<APILoginFunctionReturn>;
export {};
@@ -0,0 +1,22 @@
import http from "http";
import { SendOneTimeCodeEmailResponse } from "../../../types";
type Param = {
email: string;
database: string;
email_login_field?: string;
mail_domain?: string;
mail_port?: number;
sender?: string;
mail_username?: string;
mail_password?: string;
html: string;
response?: http.ServerResponse & {
[s: string]: any;
};
extraCookies?: import("../../../../package-shared/types").CookieObject[];
};
/**
* # Send Email Login Code
*/
export default function apiSendEmailCode({ email, database, email_login_field, mail_domain, mail_port, sender, mail_username, mail_password, html, response, extraCookies, }: Param): Promise<SendOneTimeCodeEmailResponse>;
export {};
@@ -0,0 +1,18 @@
type Param = {
payload: {
[s: string]: any;
};
dbFullName: string;
updatedUserId: string | number;
dbSchema?: import("../../../types").DSQL_DatabaseSchemaType;
};
type Return = {
success: boolean;
payload?: any;
msg?: string;
};
/**
* # Update API User Function
*/
export default function apiUpdateUser({ payload, dbFullName, updatedUserId, dbSchema, }: Param): Promise<Return>;
export {};
@@ -0,0 +1,11 @@
type Param = {
email: string;
encryptionKey?: string;
encryptionSalt?: string;
};
export type EncryptResetPasswordObject = {
email: string;
createdAt: number;
};
export default function encryptReserPasswordUrl({ email, encryptionKey, encryptionSalt, }: Param): void;
export {};
@@ -0,0 +1,22 @@
type Return = {
success: boolean;
msg?: string;
error?: string;
};
type Param = {
key?: string;
database: string;
email: string;
encryptionKey?: string;
encryptionSalt?: string;
debug?: boolean;
apiUserID?: string | number;
dbUserId?: string | number;
};
/**
* # API Login
*/
export default function apiSendResetPasswordLink({ database, email, dbUserId, debug, }: Param): Promise<Return>;
export type SendResetPasswordParam = Param;
export type SendResetPasswordReturn = Return;
export {};
@@ -0,0 +1,17 @@
import { APILoginFunctionReturn } from "../../../../types";
type Param = {
code?: string;
clientId?: string;
clientSecret?: string;
database?: string;
additionalFields?: string[];
additionalData?: {
[s: string]: string | number;
};
email?: string;
};
/**
* # API Login with Github
*/
export default function apiGithubLogin({ code, clientId, clientSecret, database, additionalFields, email, additionalData, }: Param): Promise<APILoginFunctionReturn>;
export {};
@@ -0,0 +1,5 @@
import { APIGoogleLoginFunctionParams, APILoginFunctionReturn } from "../../../../types";
/**
* # API google login
*/
export default function apiGoogleLogin({ token, database, additionalFields, additionalData, debug, }: APIGoogleLoginFunctionParams): Promise<APILoginFunctionReturn>;