Add .d.ts files

This commit is contained in:
Benjamin Toby
2024-11-08 16:44:31 +01:00
parent afd50caf42
commit 4e42a1f895
69 changed files with 1870 additions and 1 deletions
+4
View File
@@ -0,0 +1,4 @@
declare function _exports({ dbSchema }: {
dbSchema: import("../../package-shared/types").DSQL_DatabaseSchemaType | undefined;
}): Promise<any>;
export = _exports;
+12
View File
@@ -0,0 +1,12 @@
export = camelJoinedtoCamelSpace;
/**
* Convert Camel Joined Text to Camel Spaced Text
* ==============================================================================
* @description this function takes a camel cased text without spaces, and returns
* a camel-case-spaced text
*
* @param {string} text - text string without spaces
*
* @returns {string | null}
*/
declare function camelJoinedtoCamelSpace(text: string): string | null;
+8
View File
@@ -0,0 +1,8 @@
declare function _exports({ query, values, database, dbSchema, tableName, }: {
query: string;
values?: (string | number)[];
dbSchema?: import("../../../package-shared/types").DSQL_DatabaseSchemaType;
database?: string;
tableName?: string;
}): Promise<any>;
export = _exports;
+8
View File
@@ -0,0 +1,8 @@
export = defaultFieldsRegexp;
/**
* Regular expression to match default fields
*
* @description Regular expression to match default fields
* @type {RegExp}
*/
declare const defaultFieldsRegexp: RegExp;
+5
View File
@@ -0,0 +1,5 @@
declare function _exports({ unparsedResults, tableSchema, }: {
unparsedResults: any[];
tableSchema?: import("../../../package-shared/types").DSQL_TableSchemaType;
}): Promise<object[] | null>;
export = _exports;
+23
View File
@@ -0,0 +1,23 @@
declare namespace _exports {
export { VarDbHandlerParam };
}
declare function _exports({ queryString, queryValuesArray, database, tableSchema, }: VarDbHandlerParam): Promise<any>;
export = _exports;
type VarDbHandlerParam = {
/**
* - SQL string
*/
queryString: string;
/**
* - Values Array
*/
queryValuesArray?: string[];
/**
* - Database name
*/
database: string;
/**
* - Table schema
*/
tableSchema?: import("../../../package-shared/types").DSQL_TableSchemaType;
};
+64
View File
@@ -0,0 +1,64 @@
export = localGet;
/**
* @typedef {Object} LocalGetReturn
* @property {boolean} success - Did the function run successfully?
* @property {*} [payload] - GET request results
* @property {string} [msg] - Message
* @property {string} [error] - Error Message
*/
/**
* @typedef {Object} LocalQueryObject
* @property {string} query - Table Name
* @property {string} [tableName] - Table Name
* @property {string[]} [queryValues] - GET request results
*/
/**
* Make a get request to Datasquirel API
* ==============================================================================
* @async
*
* @param {Object} params - Single object passed
* @param {LocalQueryObject} params.options - SQL Query
* @param {import("../../package-shared/types").DSQL_DatabaseSchemaType | undefined} [params.dbSchema] - Name of the table to query
*
* @returns { Promise<LocalGetReturn> } - Return Object
*/
declare function localGet({ options, dbSchema }: {
options: LocalQueryObject;
dbSchema?: import("../../package-shared/types").DSQL_DatabaseSchemaType | undefined;
}): Promise<LocalGetReturn>;
declare namespace localGet {
export { LocalGetReturn, LocalQueryObject };
}
type LocalGetReturn = {
/**
* - Did the function run successfully?
*/
success: boolean;
/**
* - GET request results
*/
payload?: any;
/**
* - Message
*/
msg?: string;
/**
* - Error Message
*/
error?: string;
};
type LocalQueryObject = {
/**
* - Table Name
*/
query: string;
/**
* - Table Name
*/
tableName?: string;
/**
* - GET request results
*/
queryValues?: string[];
};
+16
View File
@@ -0,0 +1,16 @@
export = localPost;
/**
* Make a get request to Datasquirel API
* ==============================================================================
* @async
*
* @param {Object} params - Single object passed
* @param {import("../../package-shared/types").LocalPostQueryObject} params.options
* @param {import("../../package-shared/types").DSQL_DatabaseSchemaType | undefined} [params.dbSchema]
*
* @returns { Promise<import("../../package-shared/types").LocalPostReturn> }
*/
declare function localPost({ options, dbSchema }: {
options: import("../../package-shared/types").LocalPostQueryObject;
dbSchema?: import("../../package-shared/types").DSQL_DatabaseSchemaType | undefined;
}): Promise<import("../../package-shared/types").LocalPostReturn>;
+38
View File
@@ -0,0 +1,38 @@
export = updateApiSchemaFromLocalDb;
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/**
* @typedef {Object} PostReturn
* @property {boolean} success - Did the function run successfully?
* @property {*} [payload] - The Y Coordinate
* @property {string} [error] - The Y Coordinate
*/
/**
* # Update API Schema From Local DB
*
* @async
*
* @returns { Promise<PostReturn> } - Return Object
*/
declare function updateApiSchemaFromLocalDb(): Promise<PostReturn>;
declare namespace updateApiSchemaFromLocalDb {
export { PostReturn };
}
type PostReturn = {
/**
* - Did the function run successfully?
*/
success: boolean;
/**
* - The Y Coordinate
*/
payload?: any;
/**
* - The Y Coordinate
*/
error?: string;
};
+20
View File
@@ -0,0 +1,20 @@
export = localAddUser;
/**
* Make a get request to Datasquirel API
* ==============================================================================
* @async
*
* @param {Object} params - Single object passed
* @param {import("../../package-shared/types").UserDataPayload} params.payload - SQL Query
* @param {import("../../package-shared/types").DSQL_DatabaseSchemaType | undefined} params.dbSchema - Name of the table to query
* @param {string} [params.encryptionKey]
* @param {string} [params.encryptionSalt]
*
* @returns { Promise<import("../../package-shared/types").AddUserFunctionReturn> } - Return Object
*/
declare function localAddUser({ payload, dbSchema, encryptionKey, encryptionSalt, }: {
payload: import("../../package-shared/types").UserDataPayload;
dbSchema: import("../../package-shared/types").DSQL_DatabaseSchemaType | undefined;
encryptionKey?: string;
encryptionSalt?: string;
}): Promise<import("../../package-shared/types").AddUserFunctionReturn>;
+22
View File
@@ -0,0 +1,22 @@
export = getLocalUser;
/**
*
* @param {object} param0
* @param {number} param0.userId
* @param {string[]} param0.fields
* @param {import("../../package-shared/types").DSQL_DatabaseSchemaType | undefined} [param0.dbSchema]
* @returns
*/
declare function getLocalUser({ userId, fields, dbSchema }: {
userId: number;
fields: string[];
dbSchema?: import("../../package-shared/types").DSQL_DatabaseSchemaType | undefined;
}): Promise<{
success: boolean;
payload: any;
msg: string;
} | {
success: boolean;
payload: any;
msg?: undefined;
}>;
+39
View File
@@ -0,0 +1,39 @@
export = loginLocalUser;
/**
*
* @param {import("../../package-shared/types").PackageUserLoginLocalBody} param0
* @returns
*/
declare function loginLocalUser({ payload, additionalFields, dbSchema, email_login, email_login_code, email_login_field, }: import("../../package-shared/types").PackageUserLoginLocalBody): Promise<{
success: boolean;
msg: string;
payload?: undefined;
userId?: undefined;
} | {
success: boolean;
payload: any;
msg: string;
userId?: undefined;
} | {
success: boolean;
msg: string;
payload: {
id: any;
first_name: any;
last_name: any;
username: any;
email: any;
phone: any;
social_id: any;
image: any;
image_thumbnail: any;
verification_status: any;
social_login: any;
social_platform: any;
csrf_k: string;
more_data: any;
logged_in_status: boolean;
date: number;
};
userId: string;
}>;
+46
View File
@@ -0,0 +1,46 @@
export = localReauthUser;
/**
*
* @param {object} param0
* @param {*} param0.existingUser
* @param {string[]} [param0.additionalFields]
* @param {import("../../package-shared/types").DSQL_DatabaseSchemaType | undefined} [param0.dbSchema]
* @returns
*/
declare function localReauthUser({ existingUser, additionalFields, dbSchema }: {
existingUser: any;
additionalFields?: string[];
dbSchema?: import("../../package-shared/types").DSQL_DatabaseSchemaType | undefined;
}): Promise<{
success: boolean;
payload: any;
msg: string;
userId?: undefined;
} | {
success: boolean;
msg: string;
payload: {
id: any;
first_name: any;
last_name: any;
username: any;
email: any;
phone: any;
social_id: any;
image: any;
image_thumbnail: any;
verification_status: any;
social_login: any;
social_platform: any;
csrf_k: string;
more_data: any;
logged_in_status: boolean;
date: number;
};
userId: string;
} | {
success: boolean;
msg: string;
payload?: undefined;
userId?: undefined;
}>;
+32
View File
@@ -0,0 +1,32 @@
export = localSendEmailCode;
/**
*
* @param {object} param0
* @param {string} param0.email
* @param {import("../../package-shared/types").DSQL_DatabaseSchemaType | undefined} [param0.dbSchema]
* @param {string} param0.email_login_field
* @param {string} [param0.mail_domain]
* @param {string} [param0.mail_username]
* @param {string} [param0.mail_password]
* @param {number} [param0.mail_port]
* @param {string} [param0.sender]
* @returns
*/
declare function localSendEmailCode({ email, dbSchema, email_login_field, mail_domain, mail_username, mail_password, mail_port, sender, }: {
email: string;
dbSchema?: import("../../package-shared/types").DSQL_DatabaseSchemaType | undefined;
email_login_field: string;
mail_domain?: string;
mail_username?: string;
mail_password?: string;
mail_port?: number;
sender?: string;
}): Promise<{
success: boolean;
msg: string;
payload?: undefined;
} | {
success: boolean;
payload: any;
msg: string;
}>;
+71
View File
@@ -0,0 +1,71 @@
export = localGithubAuth;
/**
* SERVER FUNCTION: Login with google Function
* ==============================================================================
*
* @async
*
* @param {object} params - main params object
* @param {http.ServerResponse} params.res - HTTPS response object
* @param {string} params.code
* @param {string} [params.email]
* @param {string} params.clientId
* @param {string} params.clientSecret
* @param {object} [params.additionalFields]
* @param {import("../../../package-shared/types").DSQL_DatabaseSchemaType} params.dbSchema
*/
declare function localGithubAuth({ res, code, email, clientId, clientSecret, additionalFields, dbSchema, }: {
res: http.ServerResponse;
code: string;
email?: string;
clientId: string;
clientSecret: string;
additionalFields?: object;
dbSchema: import("../../../package-shared/types").DSQL_DatabaseSchemaType;
}): Promise<{
success: boolean;
msg: string;
} | {
dsqlUserId: string;
/**
* - Did the operation complete successfully or not?
*/
success: boolean;
/**
* - User payload object: or "null"
*/
user: {
id: number;
first_name: string;
last_name: string;
} | null;
/**
* - Message
*/
msg?: string;
/**
* - Error Message
*/
error?: string;
/**
* - Social Id
*/
social_id?: string | number;
/**
* - Social Platform
*/
social_platform?: string;
/**
* - Payload
*/
payload?: object;
/**
* - Alert
*/
alert?: boolean;
/**
* - New User
*/
newUser?: any;
}>;
import http = require("http");
+28
View File
@@ -0,0 +1,28 @@
export = localGoogleAuth;
/**
* SERVER FUNCTION: Login with google Function
* ==============================================================================
*
* @async
*
* @param {object} params - main params object
* @param {string} params.token - Google access token gotten from the client side
* @param {string} params.clientId - Google client id
* @param {http.ServerResponse} params.response - HTTPS response object
* @param {object} [params.additionalFields] - Additional Fields to be added to the user object
* @param {import("../../../package-shared/types").DSQL_DatabaseSchemaType} [params.dbSchema] - Database Schema
*
* @returns { Promise<FunctionReturn> }
*/
declare function localGoogleAuth({ dbSchema, token, clientId, response, additionalFields, }: {
token: string;
clientId: string;
response: http.ServerResponse;
additionalFields?: object;
dbSchema?: import("../../../package-shared/types").DSQL_DatabaseSchemaType;
}): Promise<FunctionReturn>;
declare namespace localGoogleAuth {
export { FunctionReturn };
}
import http = require("http");
type FunctionReturn = object | null;
+182
View File
@@ -0,0 +1,182 @@
export = githubLogin;
/**
*
* @typedef {object} GithubUserPayload
* @property {string} login - Full name merged eg. "JohnDoe"
* @property {number} id - github user id
* @property {string} node_id - Some other id
* @property {string} avatar_url - profile picture
* @property {string} gravatar_id - some other id
* @property {string} url - Github user URL
* @property {string} html_url - User html URL - whatever that means
* @property {string} followers_url - Followers URL
* @property {string} following_url - Following URL
* @property {string} gists_url - Gists URL
* @property {string} starred_url - Starred URL
* @property {string} subscriptions_url - Subscriptions URL
* @property {string} organizations_url - Organizations URL
* @property {string} repos_url - Repositories URL
* @property {string} received_events_url - Received Events URL
* @property {string} type - Common value => "User"
* @property {boolean} site_admin - Is site admin or not? Boolean
* @property {string} name - More like "username"
* @property {string} company - User company
* @property {string} blog - User blog URL
* @property {string} location - User Location
* @property {string} email - User Email
* @property {string} hireable - Is user hireable
* @property {string} bio - User bio
* @property {string} twitter_username - User twitter username
* @property {number} public_repos - Number of public repositories
* @property {number} public_gists - Number of public gists
* @property {number} followers - Number of followers
* @property {number} following - Number of following
* @property {string} created_at - Date created
* @property {string} updated_at - Date updated
*/
/**
* Login/signup a github user
* ==============================================================================
* @async
*
* @param {Object} params - foundUser if any
* @param {string} params.code - github auth token
* @param {string} params.clientId - github client Id
* @param {string} params.clientSecret - github client Secret
*
* @returns {Promise<GithubUserPayload|null>}
*/
declare function githubLogin({ code, clientId, clientSecret }: {
code: string;
clientId: string;
clientSecret: string;
}): Promise<GithubUserPayload | null>;
declare namespace githubLogin {
export { GithubUserPayload };
}
type GithubUserPayload = {
/**
* - Full name merged eg. "JohnDoe"
*/
login: string;
/**
* - github user id
*/
id: number;
/**
* - Some other id
*/
node_id: string;
/**
* - profile picture
*/
avatar_url: string;
/**
* - some other id
*/
gravatar_id: string;
/**
* - Github user URL
*/
url: string;
/**
* - User html URL - whatever that means
*/
html_url: string;
/**
* - Followers URL
*/
followers_url: string;
/**
* - Following URL
*/
following_url: string;
/**
* - Gists URL
*/
gists_url: string;
/**
* - Starred URL
*/
starred_url: string;
/**
* - Subscriptions URL
*/
subscriptions_url: string;
/**
* - Organizations URL
*/
organizations_url: string;
/**
* - Repositories URL
*/
repos_url: string;
/**
* - Received Events URL
*/
received_events_url: string;
/**
* - Common value => "User"
*/
type: string;
/**
* - Is site admin or not? Boolean
*/
site_admin: boolean;
/**
* - More like "username"
*/
name: string;
/**
* - User company
*/
company: string;
/**
* - User blog URL
*/
blog: string;
/**
* - User Location
*/
location: string;
/**
* - User Email
*/
email: string;
/**
* - Is user hireable
*/
hireable: string;
/**
* - User bio
*/
bio: string;
/**
* - User twitter username
*/
twitter_username: string;
/**
* - Number of public repositories
*/
public_repos: number;
/**
* - Number of public gists
*/
public_gists: number;
/**
* - Number of followers
*/
followers: number;
/**
* - Number of following
*/
following: number;
/**
* - Date created
*/
created_at: string;
/**
* - Date updated
*/
updated_at: string;
};
+99
View File
@@ -0,0 +1,99 @@
export = handleSocialDb;
/**
* Handle Social User Auth on Datasquirel Database
* ==============================================================================
*
* @description This function handles all social login logic after the social user
* has been authenticated and userpayload is present. The payload MUST contain the
* specified fields because this funciton will create a new user if the authenticated
* user does not exist.
*
* @param {{
* database: string|null|undefined,
* social_id: string|number,
* email: string,
* social_platform: string,
* payload: {
* social_id: string | number,
* email: string,
* social_platform: string,
* first_name: string,
* last_name: string,
* image: string,
* image_thumbnail: string,
* username: string,
* },
* res: http.ServerResponse,
* supEmail?: string | null,
* additionalFields?: object,
* dbSchema: import("../../../../package-shared/types").DSQL_DatabaseSchemaType | undefined
* }} params - function parameters inside an object
*
* @returns {Promise<FunctionReturn>} - Response object
*/
declare function handleSocialDb({ social_id, email, social_platform, payload, res, supEmail, additionalFields, dbSchema, }: {
database: string | null | undefined;
social_id: string | number;
email: string;
social_platform: string;
payload: {
social_id: string | number;
email: string;
social_platform: string;
first_name: string;
last_name: string;
image: string;
image_thumbnail: string;
username: string;
};
res: http.ServerResponse;
supEmail?: string | null;
additionalFields?: object;
dbSchema: import("../../../../package-shared/types").DSQL_DatabaseSchemaType | undefined;
}): Promise<FunctionReturn>;
declare namespace handleSocialDb {
export { FunctionReturn };
}
import http = require("http");
type FunctionReturn = {
/**
* - Did the operation complete successfully or not?
*/
success: boolean;
/**
* - User payload object: or "null"
*/
user: {
id: number;
first_name: string;
last_name: string;
} | null;
/**
* - Message
*/
msg?: string;
/**
* - Error Message
*/
error?: string;
/**
* - Social Id
*/
social_id?: string | number;
/**
* - Social Platform
*/
social_platform?: string;
/**
* - Payload
*/
payload?: object;
/**
* - Alert
*/
alert?: boolean;
/**
* - New User
*/
newUser?: any;
};
+23
View File
@@ -0,0 +1,23 @@
export = httpsRequest;
/**
* Main Function
* ==============================================================================
* @param {{
* url?: string,
* method: string,
* hostname: string,
* path?: string,
* href?: string,
* headers?: object,
* body?: object,
* }} params - params
*/
declare function httpsRequest({ url, method, hostname, path, href, headers, body }: {
url?: string;
method: string;
hostname: string;
path?: string;
href?: string;
headers?: object;
body?: object;
}): Promise<any>;
+44
View File
@@ -0,0 +1,44 @@
export = localUpdateUser;
/**
* @typedef {Object} LocalPostReturn
* @property {boolean} success - Did the function run successfully?
* @property {*} [payload] - GET request results
* @property {string} [msg] - Message
* @property {string} [error] - Error Message
*/
/**
* Make a get request to Datasquirel API
* ==============================================================================
* @async
*
* @param {Object} params - Single object passed
* @param {*} params.payload - SQL Query
* @param {import("../../package-shared/types").DSQL_DatabaseSchemaType | undefined} params.dbSchema - Name of the table to query
*
* @returns { Promise<LocalPostReturn> } - Return Object
*/
declare function localUpdateUser({ payload, dbSchema }: {
payload: any;
dbSchema: import("../../package-shared/types").DSQL_DatabaseSchemaType | undefined;
}): Promise<LocalPostReturn>;
declare namespace localUpdateUser {
export { LocalPostReturn };
}
type LocalPostReturn = {
/**
* - Did the function run successfully?
*/
success: boolean;
/**
* - GET request results
*/
payload?: any;
/**
* - Message
*/
msg?: string;
/**
* - Error Message
*/
error?: string;
};