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

View File

@ -0,0 +1,7 @@
declare function _exports({ clientId, redirectUrl, setLoading, scopes }: {
clientId: string;
redirectUrl: string;
setLoading?: (arg0: boolean) => void;
scopes?: string[];
}): void;
export = _exports;

View File

@ -0,0 +1,7 @@
declare function _exports({ clientId, element, triggerPrompt, readyStateDispatch, }: {
clientId: string;
element: HTMLElement;
triggerPrompt: boolean;
readyStateDispatch?: () => void;
}): Promise<boolean>;
export = _exports;

2
client/auth/logout.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
declare function _exports(params: object | null): Promise<boolean>;
export = _exports;

5
client/fetch/index.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
export = clientFetch;
declare function clientFetch(url: string, options?: import("../../package-shared/types").FetchApiOptions, csrf?: boolean): Promise<any>;
declare namespace clientFetch {
export { clientFetch as fetchApi };
}

26
client/index.d.ts vendored Normal file
View File

@ -0,0 +1,26 @@
export namespace media {
export { imageInputToBase64 };
export { imageInputFileToBase64 };
export { inputFileToBase64 };
}
export namespace auth {
export namespace google {
export { getAccessToken };
}
export namespace github {
export { getGithubAccessToken as getAccessToken };
}
export { logout };
}
export namespace fetch {
export { fetchApi };
export { clientFetch };
}
import imageInputToBase64 = require("./media/imageInputToBase64");
import imageInputFileToBase64 = require("./media/imageInputFileToBase64");
import inputFileToBase64 = require("./media/inputFileToBase64");
import getAccessToken = require("./auth/google/getAccessToken");
import getGithubAccessToken = require("./auth/github/getAccessToken");
import logout = require("./auth/logout");
import { fetchApi } from "./fetch";
import clientFetch = require("./fetch");

View File

@ -0,0 +1,8 @@
declare function _exports({ imageInputFile, maxWidth, imagePreviewNode, }: {
imageInputFile: {
name: string;
};
maxWidth?: number;
imagePreviewNode?: HTMLImageElement;
}): Promise<any>;
export = _exports;

14
client/media/imageInputToBase64.d.ts vendored Normal file
View File

@ -0,0 +1,14 @@
declare namespace _exports {
export { FunctionReturn };
}
declare function _exports({ imageInput, maxWidth, mimeType, }: {
imageInput: HTMLInputElement;
maxWidth?: number;
mimeType?: [string];
}): Promise<FunctionReturn>;
export = _exports;
type FunctionReturn = {
imageBase64: string;
imageBase64Full: string;
imageName: string;
};

19
client/media/inputFileToBase64.d.ts vendored Normal file
View File

@ -0,0 +1,19 @@
declare namespace _exports {
export { FunctionReturn };
}
declare function _exports({ inputFile, allowedRegex }: {
inputFile: {
name: string;
size: number;
type: string;
};
allowedRegex?: RegExp;
}): Promise<FunctionReturn>;
export = _exports;
type FunctionReturn = {
fileBase64: string;
fileBase64Full: string;
fileName: string;
fileSize: number;
fileType: string;
};

2
client/utils/parseClientCookies.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
declare function _exports(): {} | null;
export = _exports;

4
engine/engine/addUsersTableToDb.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
declare function _exports({ dbSchema }: {
dbSchema: import("../../package-shared/types").DSQL_DatabaseSchemaType | undefined;
}): Promise<any>;
export = _exports;

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
engine/engine/utils/dbHandler.d.ts vendored Normal file
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;

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;

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;

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
engine/query/get.d.ts vendored Normal file
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
engine/query/post.d.ts vendored Normal file
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>;

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
engine/user/add-user.d.ts vendored Normal file
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
engine/user/get-user.d.ts vendored Normal file
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
engine/user/login-user.d.ts vendored Normal file
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
engine/user/reauth-user.d.ts vendored Normal file
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
engine/user/send-email-code.d.ts vendored Normal file
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
engine/user/social/github-auth.d.ts vendored Normal file
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
engine/user/social/google-auth.d.ts vendored Normal file
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;

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;
};

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;
};

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
engine/user/update-user.d.ts vendored Normal file
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;
};

14
functions/decrypt.d.ts vendored Normal file
View File

@ -0,0 +1,14 @@
export = decrypt;
/**
*
* @param {object} param0
* @param {string} param0.encryptedString
* @param {string} param0.encryptionKey
* @param {string} param0.encryptionSalt
* @returns
*/
declare function decrypt({ encryptedString, encryptionKey, encryptionSalt }: {
encryptedString: string;
encryptionKey: string;
encryptionSalt: string;
}): string;

14
functions/encrypt.d.ts vendored Normal file
View File

@ -0,0 +1,14 @@
export = encrypt;
/**
*
* @param {object} param0
* @param {string} param0.data
* @param {string} param0.encryptionKey
* @param {string} param0.encryptionSalt
* @returns {string | null}
*/
declare function encrypt({ data, encryptionKey, encryptionSalt }: {
data: string;
encryptionKey: string;
encryptionSalt: string;
}): string | null;

5
functions/hashPassword.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
declare function _exports({ password, encryptionKey }: {
password: string;
encryptionKey: string;
}): string;
export = _exports;

View File

@ -0,0 +1,37 @@
export = addDbEntry;
/**
* Add a db Entry Function
* ==============================================================================
* @description Description
* @async
*
* @param {object} params - An object containing the function parameters.
* @param {("Master" | "Dsql User")} [params.dbContext] - What is the database context? "Master"
* or "Dsql User". Defaults to "Master"
* @param {("Read Only" | "Full Access")} [params.paradigm] - What is the paradigm for "Dsql User"?
* "Read only" or "Full Access"? Defaults to "Read Only"
* @param {string} [params.dbFullName] - Database full name
* @param {string} params.tableName - Table name
* @param {any} params.data - Data to add
* @param {import("../../../types").DSQL_TableSchemaType} [params.tableSchema] - Table schema
* @param {string} [params.duplicateColumnName] - Duplicate column name
* @param {string} [params.duplicateColumnValue] - Duplicate column value
* @param {boolean} [params.update] - Update this row if it exists
* @param {string} [params.encryptionKey] - Update this row if it exists
* @param {string} [params.encryptionSalt] - Update this row if it exists
*
* @returns {Promise<any>}
*/
declare function addDbEntry({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, duplicateColumnName, duplicateColumnValue, update, encryptionKey, encryptionSalt, }: {
dbContext?: ("Master" | "Dsql User");
paradigm?: ("Read Only" | "Full Access");
dbFullName?: string;
tableName: string;
data: any;
tableSchema?: import("../../../types").DSQL_TableSchemaType;
duplicateColumnName?: string;
duplicateColumnValue?: string;
update?: boolean;
encryptionKey?: string;
encryptionSalt?: string;
}): Promise<any>;

View File

@ -0,0 +1,32 @@
export = deleteDbEntry;
/**
* Imports: Handle imports
*/
/**
* Delete DB Entry Function
* ==============================================================================
* @description Description
* @async
*
* @param {object} params - An object containing the function parameters.
* @param {string} [params.dbContext] - What is the database context? "Master"
* or "Dsql User". Defaults to "Master"
* @param {("Read Only" | "Full Access")} [params.paradigm] - What is the paradigm for "Dsql User"?
* "Read only" or "Full Access"? Defaults to "Read Only"
* @param {string} params.dbFullName - Database full name
* @param {string} params.tableName - Table name
* @param {import("../../../types").DSQL_TableSchemaType} [params.tableSchema] - Table schema
* @param {string} params.identifierColumnName - Update row identifier column name
* @param {string|number} params.identifierValue - Update row identifier column value
*
* @returns {Promise<object|null>}
*/
declare function deleteDbEntry({ dbContext, paradigm, dbFullName, tableName, identifierColumnName, identifierValue, }: {
dbContext?: string;
paradigm?: ("Read Only" | "Full Access");
dbFullName: string;
tableName: string;
tableSchema?: import("../../../types").DSQL_TableSchemaType;
identifierColumnName: string;
identifierValue: string | number;
}): Promise<object | null>;

View File

@ -0,0 +1,30 @@
export = runQuery;
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/**
* Run DSQL users queries
* ==============================================================================
* @param {object} params - An object containing the function parameters.
* @param {string} params.dbFullName - Database full name. Eg. "datasquire_user_2_test"
* @param {string | any} params.query - Query string or object
* @param {boolean} [params.readOnly] - Is this operation read only?
* @param {boolean} [params.local] - Is this operation read only?
* @param {import("../../../types").DSQL_DatabaseSchemaType} [params.dbSchema] - Database schema
* @param {string[]} [params.queryValuesArray] - An optional array of query values if "?" is used in the query string
* @param {string} [params.tableName] - Table Name
*
* @return {Promise<any>}
*/
declare function runQuery({ dbFullName, query, readOnly, dbSchema, queryValuesArray, tableName, local, }: {
dbFullName: string;
query: string | any;
readOnly?: boolean;
local?: boolean;
dbSchema?: import("../../../types").DSQL_DatabaseSchemaType;
queryValuesArray?: string[];
tableName?: string;
}): Promise<any>;

View File

@ -0,0 +1,35 @@
export = updateDbEntry;
/**
* Update DB Function
* ==============================================================================
* @description Description
* @async
*
* @param {object} params - An object containing the function parameters.
* @param {("Master" | "Dsql User")} [params.dbContext] - What is the database context? "Master"
* or "Dsql User". Defaults to "Master"
* @param {("Read Only" | "Full Access")} [params.paradigm] - What is the paradigm for "Dsql User"?
* "Read only" or "Full Access"? Defaults to "Read Only"
* @param {string} [params.dbFullName] - Database full name
* @param {string} params.tableName - Table name
* @param {string} [params.encryptionKey]
* @param {string} [params.encryptionSalt]
* @param {any} params.data - Data to add
* @param {import("../../../types").DSQL_TableSchemaType} [params.tableSchema] - Table schema
* @param {string} params.identifierColumnName - Update row identifier column name
* @param {string | number} params.identifierValue - Update row identifier column value
*
* @returns {Promise<object|null>}
*/
declare function updateDbEntry({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, encryptionKey, encryptionSalt, }: {
dbContext?: ("Master" | "Dsql User");
paradigm?: ("Read Only" | "Full Access");
dbFullName?: string;
tableName: string;
encryptionKey?: string;
encryptionSalt?: string;
data: any;
tableSchema?: import("../../../types").DSQL_TableSchemaType;
identifierColumnName: string;
identifierValue: string | number;
}): Promise<object | null>;

View File

@ -0,0 +1,6 @@
export = decrypt;
/**
* @param {string} encryptedString
* @returns {string | null}
*/
declare function decrypt(encryptedString: string): string | null;

View File

@ -0,0 +1,7 @@
export = defaultFieldsRegexp;
/**
* Regular expression to match default fields
*
* @description Regular expression to match default fields
*/
declare const defaultFieldsRegexp: RegExp;

View File

@ -0,0 +1,9 @@
export = encrypt;
/**
* @async
* @param {string} data
* @param {string} [encryptionKey]
* @param {string} [encryptionSalt]
* @returns {string | null}
*/
declare function encrypt(data: string, encryptionKey?: string, encryptionSalt?: string): string | null;

View File

@ -0,0 +1,8 @@
declare function _exports({ queryString, database, tableSchema, queryValuesArray, local, }: {
queryString: string;
database: string;
local?: boolean;
tableSchema?: import("../../types").DSQL_TableSchemaType | null;
queryValuesArray?: string[];
}): Promise<any>;
export = _exports;

View File

@ -0,0 +1,6 @@
export let allowedTags: string[];
export let allowedAttributes: {
a: string[];
img: string[];
"*": string[];
};

View File

@ -0,0 +1,5 @@
declare function _exports({ unparsedResults, tableSchema, }: {
unparsedResults: any[];
tableSchema?: import("../../types").DSQL_TableSchemaType;
}): Promise<object[] | null>;
export = _exports;

View File

@ -0,0 +1,12 @@
declare function _exports({ user, message, component, noMail, }: {
user?: {
id?: number | string;
first_name?: string;
last_name?: string;
email?: string;
} & any;
message: string;
component?: string;
noMail?: boolean;
}): Promise<void>;
export = _exports;

View File

@ -0,0 +1,7 @@
declare function _exports({ queryString, database, queryValuesArray, tableSchema, }: {
queryString: string;
database: string;
queryValuesArray?: string[];
tableSchema?: import("../../types").DSQL_TableSchemaType;
}): Promise<any>;
export = _exports;

View File

@ -0,0 +1,9 @@
export = DB_HANDLER;
/**
* DSQL user read-only DB handler
* @param {object} params
* @param {string} params.paradigm
* @param {string} params.database
* @param {string} params.queryString
* @param {string[]} [params.queryValues]
*/ declare function DB_HANDLER(...args: any[]): Promise<any>;

View File

@ -0,0 +1,18 @@
export = DSQL_USER_DB_HANDLER;
/**
* DSQL user read-only DB handler
* @param {object} params
* @param {"Full Access" | "FA" | "Read Only"} params.paradigm
* @param {string} params.database
* @param {string} params.queryString
* @param {string[]} [params.queryValues]
*/
declare function DSQL_USER_DB_HANDLER({ paradigm, database, queryString, queryValues, }: {
paradigm: "Full Access" | "FA" | "Read Only";
database: string;
queryString: string;
queryValues?: string[];
}): Promise<any> | {
success: boolean;
error: any;
};

View File

@ -0,0 +1,4 @@
declare function _exports(): string | (import("tls").SecureContextOptions & {
rejectUnauthorized?: boolean | undefined;
}) | undefined;
export = _exports;

View File

@ -1,6 +1,6 @@
{ {
"name": "datasquirel", "name": "datasquirel",
"version": "2.4.4", "version": "2.4.5",
"description": "Cloud-based SQL data management tool", "description": "Cloud-based SQL data management tool",
"main": "index.js", "main": "index.js",
"bin": { "bin": {
@ -8,6 +8,7 @@
"dsql-dump": "./engine/dump.js" "dsql-dump": "./engine/dump.js"
}, },
"scripts": { "scripts": {
"compile": "tsc --declaration --allowJs --emitDeclarationOnly --resolveJsonModule index.js",
"compile-tsc": "rm -rf dist && tsc --declaration --allowJs --outDir dist --emitDeclarationOnly --resolveJsonModule index.js && cat ./dist/index.d.ts > ./index.d.ts" "compile-tsc": "rm -rf dist && tsc --declaration --allowJs --outDir dist --emitDeclarationOnly --resolveJsonModule index.js && cat ./dist/index.d.ts > ./index.d.ts"
}, },
"repository": { "repository": {

28
users/add-user.d.ts vendored Normal file
View File

@ -0,0 +1,28 @@
export = addUser;
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/**
* Add User to Database
* ==============================================================================
* @async
*
* @param {object} props - Single object passed
* @param {string} props.key - FULL ACCESS API Key
* @param {string} props.database - Database Name
* @param {import("../package-shared/types").UserDataPayload} props.payload - User Data Payload
* @param {string} props.encryptionKey
* @param {string} [props.encryptionSalt]
*
* @returns { Promise<import("../package-shared/types").AddUserFunctionReturn> }
*/
declare function addUser({ key, payload, database, encryptionKey, encryptionSalt, }: {
key: string;
database: string;
payload: import("../package-shared/types").UserDataPayload;
encryptionKey: string;
encryptionSalt?: string;
}): Promise<import("../package-shared/types").AddUserFunctionReturn>;

31
users/get-token.d.ts vendored Normal file
View File

@ -0,0 +1,31 @@
export = getToken;
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/**
* 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
*
* @param {Object} params - Arg
* @param {http.IncomingMessage} params.request - Http request object
* @param {string} params.encryptionKey - Encryption Key
* @param {string} params.encryptionSalt - Encryption Salt
* @param {string} params.database - Database Name
*
* @returns {{ key: string | undefined, csrf: string | undefined }}
*/
declare function getToken({ request, encryptionKey, encryptionSalt, database }: {
request: http.IncomingMessage;
encryptionKey: string;
encryptionSalt: string;
database: string;
}): {
key: string | undefined;
csrf: string | undefined;
};
import http = require("http");

27
users/get-user.d.ts vendored Normal file
View File

@ -0,0 +1,27 @@
export = getUser;
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/**
* ==============================================================================
* Main Function
* ==============================================================================
* @async
*
* @param {object} params - Single Param object containing params
* @param {String} params.key - API Key
* @param {String} params.database - Target Database
* @param {number} params.userId - user id
* @param {string[]} [params.fields] - fields to select
*
* @returns { Promise<import("../types/user.td").GetUserFunctionReturn>}
*/
declare function getUser({ key, userId, database, fields }: {
key: string;
database: string;
userId: number;
fields?: string[];
}): Promise<any>;

49
users/login-user.d.ts vendored Normal file
View File

@ -0,0 +1,49 @@
export = loginUser;
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/**
* Login A user
* ==============================================================================
* @async
*
* @param {object} params - Single Param object containing params
* @param {String} params.key - FULL ACCESS API Key
* @param {String} params.database - Target Database
* @param {{
* email?: string,
* username?: string,
* password: string,
* }} params.payload Login Email/Username and Password
* @param {string[]} [params.additionalFields] - Additional Fields to be added to the user object
* @param {http.ServerResponse} params.response - Http response object
* @param {String} params.encryptionKey - Encryption Key
* @param {String} params.encryptionSalt - Encryption Salt
* @param {boolean} [params.email_login] - Email only Login
* @param {string} [params.email_login_code] - Email login code
* @param {string} [params.temp_code_field] - Database table field name for temporary code
* @param {boolean} [params.token] - Send access key as part of response body?
*
* @returns { Promise<import("../package-shared/types").AuthenticatedUser>}
*/
declare function loginUser({ key, payload, database, additionalFields, response, encryptionKey, encryptionSalt, email_login, email_login_code, temp_code_field, token, }: {
key: string;
database: string;
payload: {
email?: string;
username?: string;
password: string;
};
additionalFields?: string[];
response: http.ServerResponse;
encryptionKey: string;
encryptionSalt: string;
email_login?: boolean;
email_login_code?: string;
temp_code_field?: string;
token?: boolean;
}): Promise<import("../package-shared/types").AuthenticatedUser>;
import http = require("http");

22
users/logout-user.d.ts vendored Normal file
View File

@ -0,0 +1,22 @@
export = logoutUser;
/**
* Logout user
* ==============================================================================
* @param {object} params - Single Param object containing params
* @param {http.IncomingMessage} params.request - Http request object
* @param {http.ServerResponse} params.response - Http response object
* @param {string} [params.database] - Target database name(slug): optional => If you don't
* include this you will be logged out of all datasquirel websites instead of just the target
* database
*
* @returns {{success: boolean, payload: string}}
*/
declare function logoutUser({ request, response, database }: {
request: http.IncomingMessage;
response: http.ServerResponse;
database?: string;
}): {
success: boolean;
payload: string;
};
import http = require("http");

38
users/reauth-user.d.ts vendored Normal file
View File

@ -0,0 +1,38 @@
export = reauthUser;
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/**
* ==============================================================================
* Main Function
* ==============================================================================
* @async
*
* @param {object} params - Single Param object containing params
* @param {String} params.key - API Key
* @param {String} params.database - Target Database
* @param {http.ServerResponse} params.response - Http response object
* @param {http.IncomingMessage} params.request - Http request object
* @param {("deep" | "normal")} [params.level] - Authentication level
* @param {String} params.encryptionKey - Encryption Key
* @param {String} params.encryptionSalt - Encryption Salt
* @param {string[]} [params.additionalFields] - Additional Fields to be added to the user object
* @param {string} [params.token] - access token to use instead of getting from cookie header
*
* @returns { Promise<import("../package-shared/types").ReauthUserFunctionReturn> }
*/
declare function reauthUser({ key, database, response, request, level, encryptionKey, encryptionSalt, additionalFields, token, }: {
key: string;
database: string;
response: http.ServerResponse;
request: http.IncomingMessage;
level?: ("deep" | "normal");
encryptionKey: string;
encryptionSalt: string;
additionalFields?: string[];
token?: string;
}): Promise<import("../package-shared/types").ReauthUserFunctionReturn>;
import http = require("http");

43
users/send-email-code.d.ts vendored Normal file
View File

@ -0,0 +1,43 @@
export = sendEmailCode;
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/**
* Send Email Code to a User
* ==============================================================================
* @async
*
* @param {object} params - Single Param object containing params
* @param {String} params.key - FULL ACCESS API Key
* @param {String} params.database - Target Database
* @param {string} params.email Login Email/Username and Password
* @param {http.ServerResponse} params.response - Http response object
* @param {String} params.encryptionKey - Encryption Key
* @param {String} params.encryptionSalt - Encryption Salt
* @param {string} [params.temp_code_field] - Database table field name for temporary code
* @param {string} [params.mail_domain]
* @param {string} [params.mail_username]
* @param {string} [params.mail_password]
* @param {number} [params.mail_port]
* @param {string} [params.sender]
*
* @returns { Promise<boolean>}
*/
declare function sendEmailCode({ key, email, database, encryptionKey, encryptionSalt, temp_code_field, mail_domain, mail_password, mail_username, mail_port, sender, }: {
key: string;
database: string;
email: string;
response: http.ServerResponse;
encryptionKey: string;
encryptionSalt: string;
temp_code_field?: string;
mail_domain?: string;
mail_username?: string;
mail_password?: string;
mail_port?: number;
sender?: string;
}): Promise<boolean>;
import http = require("http");

74
users/social/github-auth.d.ts vendored Normal file
View File

@ -0,0 +1,74 @@
export = githubAuth;
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/**
* @typedef {object} FunctionReturn
* @property {boolean} success - Did the function run successfully?
* @property {{id: number, first_name: string, last_name: string, csrf_k: string, social_id: string} | null} user - Returned User
* @property {number} [dsqlUserId] - Dsql User Id
* @property {string} [msg] - Response message
*/
/**
* SERVER FUNCTION: Login with google Function
* ==============================================================================
*
* @async
*
* @param {object} params - main params object
* @param {string} params.key - API full access key
* @param {string} params.code - Github access code gotten from the client side
* @param {string?} params.email - Email gotten from the client side if available
* @param {string} params.database - Target database name(slug)
* @param {string} params.clientId - Github client id
* @param {string} params.clientSecret - Github client Secret
* @param {http.ServerResponse} params.response - HTTPS response object
* @param {string} params.encryptionKey - Encryption key
* @param {string} params.encryptionSalt - Encryption salt
* @param {object} [params.additionalFields] - Additional Fields to be added to the user object
*
* @returns { Promise<FunctionReturn | undefined> }
*/
declare function githubAuth({ key, code, email, database, clientId, clientSecret, response, encryptionKey, encryptionSalt, additionalFields, }: {
key: string;
code: string;
email: string | null;
database: string;
clientId: string;
clientSecret: string;
response: http.ServerResponse;
encryptionKey: string;
encryptionSalt: string;
additionalFields?: object;
}): Promise<FunctionReturn | undefined>;
declare namespace githubAuth {
export { FunctionReturn };
}
import http = require("http");
type FunctionReturn = {
/**
* - Did the function run successfully?
*/
success: boolean;
/**
* - Returned User
*/
user: {
id: number;
first_name: string;
last_name: string;
csrf_k: string;
social_id: string;
} | null;
/**
* - Dsql User Id
*/
dsqlUserId?: number;
/**
* - Response message
*/
msg?: string;
};

47
users/social/google-auth.d.ts vendored Normal file
View File

@ -0,0 +1,47 @@
export = googleAuth;
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/**
* @typedef {object | null} FunctionReturn
* @property {boolean} success - Did the function run successfully?
* @property {import("../../types/user.td").DATASQUIREL_LoggedInUser | null} user - Returned User
* @property {number} [dsqlUserId] - Dsql User Id
* @property {string} [msg] - Response message
*/
/**
* SERVER FUNCTION: Login with google Function
* ==============================================================================
*
* @async
*
* @param {object} params - main params object
* @param {string} params.key - API full access key
* @param {string} params.token - Google access token gotten from the client side
* @param {string} params.database - Target database name(slug)
* @param {string} params.clientId - Google client id
* @param {http.ServerResponse} params.response - HTTPS response object
* @param {string} params.encryptionKey - Encryption key
* @param {string} params.encryptionSalt - Encryption salt
* @param {object} [params.additionalFields] - Additional Fields to be added to the user object
*
* @returns { Promise<FunctionReturn> }
*/
declare function googleAuth({ key, token, database, clientId, response, encryptionKey, encryptionSalt, additionalFields, }: {
key: string;
token: string;
database: string;
clientId: string;
response: http.ServerResponse;
encryptionKey: string;
encryptionSalt: string;
additionalFields?: object;
}): Promise<FunctionReturn>;
declare namespace googleAuth {
export { FunctionReturn };
}
import http = require("http");
type FunctionReturn = object | null;

29
users/update-user.d.ts vendored Normal file
View File

@ -0,0 +1,29 @@
export = updateUser;
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/**
* ==============================================================================
* Main Function
* ==============================================================================
* @async
*
* @param {object} params - API Key
* @param {String} params.key - API Key
* @param {String} params.database - Target Database
* @param {{ id: number } & Object.<string, any>} params.payload - User Object: ID is required
*
* @returns { Promise<import("../package-shared/types").UpdateUserFunctionReturn>}
*/
declare function updateUser({ key, payload, database }: {
key: string;
database: string;
payload: {
id: number;
} & {
[x: string]: any;
};
}): Promise<import("../package-shared/types").UpdateUserFunctionReturn>;

32
users/user-auth.d.ts vendored Normal file
View File

@ -0,0 +1,32 @@
export = userAuth;
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/**
* Authenticate User from request
* ==============================================================================
* @description This Function takes in a request object and returns a user object
* with the user's data
*
* @param {Object} params - Arg
* @param {http.IncomingMessage} params.request - Http request object
* @param {string} params.encryptionKey - Encryption Key
* @param {string} params.encryptionSalt - Encryption Salt
* @param {("deep" | "normal")} [params.level] - Optional. "Deep" value indicates an extra layer of security
* @param {string} params.database - Database Name
* @param {string} [params.token] - access token to use instead of getting from cookie header
*
* @returns { import("../package-shared/types").AuthenticatedUser }
*/
declare function userAuth({ request, encryptionKey, encryptionSalt, level, database, token, }: {
request: http.IncomingMessage;
encryptionKey: string;
encryptionSalt: string;
level?: ("deep" | "normal");
database: string;
token?: string;
}): import("../package-shared/types").AuthenticatedUser;
import http = require("http");

28
users/validate-token.d.ts vendored Normal file
View File

@ -0,0 +1,28 @@
export = validateToken;
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/**
* Validate Token
* ==============================================================================
* @description This Function takes in a encrypted token and returns a user object
*
* @param {Object} params - Arg
* @param {string} params.token - Encrypted Token
* @param {string} params.encryptionKey - Encryption Key
* @param {string} params.encryptionSalt - Encryption Salt
* @param {("deep" | "normal")?} [params.level] - Optional. "Deep" value indicates an extra layer of security
* @param {string} params.database - Database Name
*
* @returns { import("../package-shared/types").DATASQUIREL_LoggedInUser | null}
*/
declare function validateToken({ token, encryptionKey, encryptionSalt }: {
token: string;
encryptionKey: string;
encryptionSalt: string;
level?: ("deep" | "normal") | null;
database: string;
}): import("../package-shared/types").DATASQUIREL_LoggedInUser | null;

52
utils/delete-file.d.ts vendored Normal file
View File

@ -0,0 +1,52 @@
export = uploadImage;
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/**
* @typedef {Object} FunctionReturn
* @property {boolean} success - Did the function run successfully?
* @property {{
* urlPath: string,
* urlThumbnailPath: string
* }} payload - Payload containing the url for the image and its thumbnail
* @property {string} [msg] - An optional message
*/
/**
* ==============================================================================
* Main Function
* ==============================================================================
* @async
*
* @param {Object} params - Single Param object containing params
* @param {String} params.key - *FULL ACCESS API Key
* @param { string } params.url - File URL
*
* @returns { Promise<FunctionReturn> } - Image Url
*/
declare function uploadImage({ key, url }: {
key: string;
url: string;
}): Promise<FunctionReturn>;
declare namespace uploadImage {
export { FunctionReturn };
}
type FunctionReturn = {
/**
* - Did the function run successfully?
*/
success: boolean;
/**
* - Payload containing the url for the image and its thumbnail
*/
payload: {
urlPath: string;
urlThumbnailPath: string;
};
/**
* - An optional message
*/
msg?: string;
};

5
utils/functions/parseCookies.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
declare function _exports({ request }: {
request: http.IncomingMessage;
}): any | null;
export = _exports;
import http = require("http");

13
utils/functions/sanitizeSql.d.ts vendored Normal file
View File

@ -0,0 +1,13 @@
export = sanitizeSql;
/**
* Sanitize SQL function
* ==============================================================================
* @description this function takes in a text(or number) or object or array or
* boolean and returns a sanitized version of the same input.
*
* @param {string|number|object|boolean} input - Text or number or object or boolean
* @param {boolean?} spaces - Allow spaces?
*
* @returns {string|number|object|boolean}
*/
declare function sanitizeSql(input: string | number | object | boolean, spaces: boolean | null): string | number | object | boolean;

2
utils/functions/serialize-query.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
export = serializeQuery;
declare function serializeQuery(param0: import("../../package-shared/types").SerializeQueryParams): string;

32
utils/get-schema.d.ts vendored Normal file
View File

@ -0,0 +1,32 @@
export = getSchema;
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/**
* @typedef {Object} GetSchemaReturn
* @property {boolean} success - Did the function run successfully?
* @property {import("../package-shared/types").DSQL_DatabaseSchemaType | import("../package-shared/types").DSQL_TableSchemaType | import("../package-shared/types").DSQL_FieldSchemaType | null} payload - Response payload
*/
/**
* # Get Schema for Database, table, or field *
* @param {import("../package-shared/types").GetSchemaAPIParam} params
*
* @returns { Promise<GetSchemaReturn> } - Return Object
*/
declare function getSchema({ key, database, field, table }: import("../package-shared/types").GetSchemaAPIParam): Promise<GetSchemaReturn>;
declare namespace getSchema {
export { GetSchemaReturn };
}
type GetSchemaReturn = {
/**
* - Did the function run successfully?
*/
success: boolean;
/**
* - Response payload
*/
payload: import("../package-shared/types").DSQL_DatabaseSchemaType | import("../package-shared/types").DSQL_TableSchemaType | import("../package-shared/types").DSQL_FieldSchemaType | null;
};

28
utils/get.d.ts vendored Normal file
View File

@ -0,0 +1,28 @@
export = get;
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/**
* Make a get request to Datasquirel API
* ==============================================================================
* @async
*
* @param {Object} params - Single object passed
* @param {string} [params.key] - API Key
* @param {string} [params.db] - Database Name
* @param {string} params.query - SQL Query
* @param {string[]} [params.queryValues] - An array of query values if using "?" placeholders
* @param {string} [params.tableName] - Name of the table to query
*
* @returns { Promise<import("../package-shared/types").GetReturn> } - Return Object
*/
declare function get({ key, db, query, queryValues, tableName }: {
key?: string;
db?: string;
query: string;
queryValues?: string[];
tableName?: string;
}): Promise<import("../package-shared/types").GetReturn>;

28
utils/post.d.ts vendored Normal file
View File

@ -0,0 +1,28 @@
export = post;
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/**
* Make a post request to Datasquirel API
* ==============================================================================
* @async
*
* @param {Object} params - Single object passed
* @param {string} [params.key] - FULL ACCESS API Key
* @param {string} [params.database] - Database Name
* @param {import("../package-shared/types").PostDataPayload | string} params.query - SQL query String or Request Object
* @param {any[]} [params.queryValues] - Query Values if using "?" placeholders
* @param {string} [params.tableName] - Name of the table to query
*
* @returns { Promise<import("../package-shared/types").PostReturn> } - Return Object
*/
declare function post({ key, query, queryValues, database, tableName }: {
key?: string;
database?: string;
query: import("../package-shared/types").PostDataPayload | string;
queryValues?: any[];
tableName?: string;
}): Promise<import("../package-shared/types").PostReturn>;

62
utils/upload-file.d.ts vendored Normal file
View File

@ -0,0 +1,62 @@
export = uploadImage;
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/**
* @typedef {Object} FunctionReturn
* @property {boolean} success - Did the function run successfully?
* @property {{
* urlPath: string,
* } | null} payload - Payload containing the url for the image and its thumbnail
* @property {string} [msg] - An optional message
*/
/**
* ==============================================================================
* Main Function
* ==============================================================================
* @async
*
* @param {Object} params - Single Param object containing params
* @param {String} params.key - *FULL ACCESS API Key
* @param {{
* fileData: string,
* fileName: string,
* mimeType?: string,
* folder?: string,
* isPrivate?: boolean,
* }} params.payload - Image Data Eg.
*
* @returns { Promise<FunctionReturn> } - Return Object
*/
declare function uploadImage({ key, payload }: {
key: string;
payload: {
fileData: string;
fileName: string;
mimeType?: string;
folder?: string;
isPrivate?: boolean;
};
}): Promise<FunctionReturn>;
declare namespace uploadImage {
export { FunctionReturn };
}
type FunctionReturn = {
/**
* - Did the function run successfully?
*/
success: boolean;
/**
* - Payload containing the url for the image and its thumbnail
*/
payload: {
urlPath: string;
} | null;
/**
* - An optional message
*/
msg?: string;
};

66
utils/upload-image.d.ts vendored Normal file
View File

@ -0,0 +1,66 @@
export = uploadImage;
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/** ****************************************************************************** */
/**
* @typedef {Object} FunctionReturn
* @property {boolean} success - Did the function run successfully?
* @property {{
* urlPath: string,
* urlThumbnailPath: string
* } | null} payload - Payload containing the url for the image and its thumbnail
* @property {string} [msg] - An optional message
*/
/**
* ==============================================================================
* Main Function
* ==============================================================================
* @async
*
* @param {Object} params - Single Param object containing params
* @param {String} params.key - *FULL ACCESS API Key
* @param {{
* imageData: string,
* imageName: string,
* mimeType?: string,
* thumbnailSize?: number,
* folder?: string,
* isPrivate?: boolean,
* }} params.payload - Image Data Eg.
*
* @returns { Promise<FunctionReturn> } - Return Object
*/
declare function uploadImage({ key, payload }: {
key: string;
payload: {
imageData: string;
imageName: string;
mimeType?: string;
thumbnailSize?: number;
folder?: string;
isPrivate?: boolean;
};
}): Promise<FunctionReturn>;
declare namespace uploadImage {
export { FunctionReturn };
}
type FunctionReturn = {
/**
* - Did the function run successfully?
*/
success: boolean;
/**
* - Payload containing the url for the image and its thumbnail
*/
payload: {
urlPath: string;
urlThumbnailPath: string;
} | null;
/**
* - An optional message
*/
msg?: string;
};