2280 lines
57 KiB
TypeScript
2280 lines
57 KiB
TypeScript
import type { RequestOptions } from "https";
|
|
|
|
import {
|
|
DSQL_DATASQUIREL_API_KEYS,
|
|
DSQL_DATASQUIREL_API_KEYS_SCOPED_RESOURCES,
|
|
DSQL_DATASQUIREL_BACKUPS,
|
|
DSQL_DATASQUIREL_DELEGATED_RESOURCES,
|
|
DSQL_DATASQUIREL_DELEGATED_USERS,
|
|
DSQL_DATASQUIREL_INVITATIONS,
|
|
DSQL_DATASQUIREL_MARIADB_USERS,
|
|
DSQL_DATASQUIREL_PROCESS_QUEUE,
|
|
DSQL_DATASQUIREL_USER_DATABASE_TABLES,
|
|
DSQL_DATASQUIREL_USER_DATABASES,
|
|
DSQL_DATASQUIREL_USER_MEDIA,
|
|
DSQL_DATASQUIREL_USER_PRIVATE_FOLDERS,
|
|
DSQL_DATASQUIREL_USERS,
|
|
} from "./dsql";
|
|
|
|
import { Editor } from "tinymce";
|
|
import sharp from "sharp";
|
|
import DataTypes from "../data/data-types";
|
|
import { IncomingMessage, ServerResponse } from "http";
|
|
import { CookieNames } from "../dict/cookie-names";
|
|
export type DSQL_DatabaseFullName = string;
|
|
|
|
export type DSQL_DATASQUIREL_USER_BACKUPS_JOIN = DSQL_DATASQUIREL_BACKUPS & {
|
|
[k in (typeof UserSelectFields)[number]["alias"]]?: string;
|
|
};
|
|
|
|
export type DSQL_DATASQUIREL_DELEGATED_DATABASES_JOIN =
|
|
DSQL_DATASQUIREL_DELEGATED_RESOURCES &
|
|
DSQL_DATASQUIREL_USER_DATABASES & {
|
|
[k in (typeof UserSelectFields)[number]["alias"]]?: string;
|
|
} & {
|
|
[k in (typeof DelegatedUserSelectFields)[number]["alias"]]?: string;
|
|
};
|
|
|
|
export type DSQL_DATASQUIREL_DELEGATED_USERS_JOIN =
|
|
DSQL_DATASQUIREL_DELEGATED_USERS & {
|
|
[k in (typeof UserSelectFields)[number]["alias"]]?: string;
|
|
} & {
|
|
[k in (typeof DelegatedUserSelectFields)[number]["alias"]]?: string;
|
|
};
|
|
|
|
export const UsersOmitedFields = [
|
|
"password",
|
|
"social_id",
|
|
"verification_status",
|
|
"date_created",
|
|
"date_created_code",
|
|
"date_created_timestamp",
|
|
"date_updated",
|
|
"date_updated_code",
|
|
"date_updated_timestamp",
|
|
] as const;
|
|
|
|
export type DSQL_DATASQUIREL_USERS_FILTERED = Omit<
|
|
DSQL_DATASQUIREL_USERS,
|
|
(typeof UsersOmitedFields)[number]
|
|
>;
|
|
|
|
export type DSQL_DATASQUIREL_INVITATIONS_JOIN = DSQL_DATASQUIREL_INVITATIONS & {
|
|
[k in (typeof UserSelectFields)[number]["alias"]]?: string;
|
|
} & {
|
|
[k in (typeof InvitedUserSelectFields)[number]["alias"]]?: string;
|
|
};
|
|
|
|
export interface DSQL_DatabaseSchemaType {
|
|
id?: string | number;
|
|
dbName?: string;
|
|
dbSlug?: string;
|
|
dbFullName?: string;
|
|
dbDescription?: string;
|
|
dbImage?: string;
|
|
tables: DSQL_TableSchemaType[];
|
|
childrenDatabases?: DSQL_ChildrenDatabaseObject[];
|
|
childDatabase?: boolean;
|
|
childDatabaseDbId?: string | number;
|
|
updateData?: boolean;
|
|
}
|
|
|
|
export interface DSQL_ChildrenDatabaseObject {
|
|
dbId?: string | number;
|
|
}
|
|
|
|
export interface DSQL_TableSchemaType {
|
|
id?: string | number;
|
|
tableName: string;
|
|
tableDescription?: string;
|
|
fields: DSQL_FieldSchemaType[];
|
|
indexes?: DSQL_IndexSchemaType[];
|
|
childrenTables?: DSQL_ChildrenTablesType[];
|
|
childTable?: boolean;
|
|
updateData?: boolean;
|
|
childTableId?: string | number;
|
|
tableNameOld?: string;
|
|
childTableDbId?: string | number;
|
|
}
|
|
|
|
export interface DSQL_ChildrenTablesType {
|
|
tableId?: string | number;
|
|
dbId?: string | number;
|
|
}
|
|
|
|
export const TextFieldTypesArray = [
|
|
{ title: "Plain Text", value: "plain" },
|
|
{ title: "Rich Text", value: "richText" },
|
|
{ title: "JSON", value: "json" },
|
|
{ title: "YAML", value: "yaml" },
|
|
{ title: "HTML", value: "html" },
|
|
{ title: "CSS", value: "css" },
|
|
{ title: "Javascript", value: "javascript" },
|
|
{ title: "Shell", value: "shell" },
|
|
{ title: "Code", value: "code" },
|
|
] as const;
|
|
|
|
export type DSQL_FieldSchemaType = {
|
|
id?: number | string;
|
|
fieldName?: string;
|
|
originName?: string;
|
|
updatedField?: boolean;
|
|
dataType?: string;
|
|
nullValue?: boolean;
|
|
notNullValue?: boolean;
|
|
primaryKey?: boolean;
|
|
encrypted?: boolean;
|
|
autoIncrement?: boolean;
|
|
defaultValue?: string | number;
|
|
defaultValueLiteral?: string;
|
|
foreignKey?: DSQL_ForeignKeyType;
|
|
newTempField?: boolean;
|
|
defaultField?: boolean;
|
|
plainText?: boolean;
|
|
unique?: boolean;
|
|
pattern?: string;
|
|
patternFlags?: string;
|
|
onUpdate?: string;
|
|
onUpdateLiteral?: string;
|
|
onDelete?: string;
|
|
onDeleteLiteral?: string;
|
|
cssFiles?: string[];
|
|
integerLength?: string | number;
|
|
decimals?: string | number;
|
|
moving?: boolean;
|
|
code?: boolean;
|
|
options?: string[];
|
|
} & {
|
|
[key in (typeof TextFieldTypesArray)[number]["value"]]?: boolean;
|
|
};
|
|
|
|
export interface DSQL_ForeignKeyType {
|
|
foreignKeyName?: string;
|
|
destinationTableName?: string;
|
|
destinationTableColumnName?: string;
|
|
destinationTableColumnType?: string;
|
|
cascadeDelete?: boolean;
|
|
cascadeUpdate?: boolean;
|
|
}
|
|
|
|
export interface DSQL_IndexSchemaType {
|
|
id?: string | number;
|
|
indexName?: string;
|
|
indexType?: (typeof IndexTypes)[number];
|
|
indexTableFields?: DSQL_IndexTableFieldType[];
|
|
alias?: string;
|
|
newTempIndex?: boolean;
|
|
}
|
|
|
|
export interface DSQL_IndexTableFieldType {
|
|
value: string;
|
|
dataType: string;
|
|
}
|
|
|
|
export interface DSQL_MYSQL_SHOW_INDEXES_Type {
|
|
Key_name: string;
|
|
Table: string;
|
|
Column_name: string;
|
|
Collation: string;
|
|
Index_type: string;
|
|
Cardinality: string;
|
|
Index_comment: string;
|
|
Comment: string;
|
|
}
|
|
|
|
export interface DSQL_MYSQL_SHOW_COLUMNS_Type {
|
|
Field: string;
|
|
Type: string;
|
|
Null: string;
|
|
Key: string;
|
|
Default: string;
|
|
Extra: string;
|
|
}
|
|
|
|
export interface DSQL_MYSQL_FOREIGN_KEYS_Type {
|
|
CONSTRAINT_NAME: string;
|
|
CONSTRAINT_SCHEMA: string;
|
|
TABLE_NAME: string;
|
|
}
|
|
|
|
export interface DSQL_MYSQL_user_databases_Type {
|
|
id: number;
|
|
user_id: number;
|
|
db_full_name: string;
|
|
db_name: string;
|
|
db_slug: string;
|
|
db_image: string;
|
|
db_description: string;
|
|
active_clone: number;
|
|
active_data: 0 | 1;
|
|
active_clone_parent_db: string;
|
|
remote_connected?: number;
|
|
remote_db_full_name?: string;
|
|
remote_connection_host?: string;
|
|
remote_connection_key?: string;
|
|
remote_connection_type?: string;
|
|
user_priviledge?: string;
|
|
date_created?: string;
|
|
image_thumbnail?: string;
|
|
first_name?: string;
|
|
last_name?: string;
|
|
email?: string;
|
|
}
|
|
|
|
export interface PackageUserLoginRequestBody {
|
|
encryptionKey: string;
|
|
payload: any;
|
|
database: string;
|
|
additionalFields?: string[];
|
|
email_login?: boolean;
|
|
email_login_code?: string;
|
|
email_login_field?: string;
|
|
token?: boolean;
|
|
social?: boolean;
|
|
dbSchema?: DSQL_DatabaseSchemaType;
|
|
skipPassword?: boolean;
|
|
dbUserId: string | number;
|
|
}
|
|
|
|
export interface PackageUserLoginLocalBody {
|
|
payload: any;
|
|
additionalFields?: string[];
|
|
email_login?: boolean;
|
|
email_login_code?: string;
|
|
email_login_field?: string;
|
|
token?: boolean;
|
|
social?: boolean;
|
|
dbSchema?: DSQL_DatabaseSchemaType;
|
|
skipPassword?: boolean;
|
|
}
|
|
|
|
export type ImageInputFileToBase64FunctionReturn = {
|
|
imageBase64?: string;
|
|
imageBase64Full?: string;
|
|
imageName?: string;
|
|
imageSize?: number;
|
|
};
|
|
|
|
export interface GetReqQueryObject {
|
|
db: string;
|
|
query: string;
|
|
queryValues?: string;
|
|
tableName?: string;
|
|
debug?: boolean;
|
|
}
|
|
|
|
export type DATASQUIREL_LoggedInUser = {
|
|
id: number;
|
|
uuid?: string;
|
|
first_name: string;
|
|
last_name: string;
|
|
email: string;
|
|
phone?: string;
|
|
user_type?: string;
|
|
username?: string;
|
|
image?: string;
|
|
image_thumbnail?: string;
|
|
social_login?: number;
|
|
social_platform?: string;
|
|
social_id?: string;
|
|
verification_status?: number;
|
|
csrf_k: string;
|
|
logged_in_status: boolean;
|
|
date: number;
|
|
} & {
|
|
[key: string]: any;
|
|
};
|
|
|
|
export interface AuthenticatedUser {
|
|
success: boolean;
|
|
payload: DATASQUIREL_LoggedInUser | null;
|
|
msg?: string;
|
|
userId?: number;
|
|
cookieNames?: any;
|
|
}
|
|
|
|
export interface SuccessUserObject {
|
|
id: number;
|
|
first_name: string;
|
|
last_name: string;
|
|
email: string;
|
|
}
|
|
|
|
export interface AddUserFunctionReturn {
|
|
success: boolean;
|
|
payload?: SuccessUserObject | null;
|
|
msg?: string;
|
|
sqlResult?: any;
|
|
}
|
|
|
|
export interface GoogleIdentityPromptNotification {
|
|
getMomentType: () => string;
|
|
getDismissedReason: () => string;
|
|
getNotDisplayedReason: () => string;
|
|
getSkippedReason: () => string;
|
|
isDismissedMoment: () => boolean;
|
|
isDisplayMoment: () => boolean;
|
|
isDisplayed: () => boolean;
|
|
isNotDisplayed: () => boolean;
|
|
isSkippedMoment: () => boolean;
|
|
}
|
|
|
|
export type UserDataPayload = {
|
|
first_name: string;
|
|
last_name: string;
|
|
email: string;
|
|
password?: string;
|
|
username?: string;
|
|
} & {
|
|
[key: string]: any;
|
|
};
|
|
|
|
export interface GetUserFunctionReturn {
|
|
success: boolean;
|
|
payload: {
|
|
id: number;
|
|
first_name: string;
|
|
last_name: string;
|
|
username: string;
|
|
email: string;
|
|
phone: string;
|
|
social_id: [string];
|
|
image: string;
|
|
image_thumbnail: string;
|
|
verification_status: [number];
|
|
} | null;
|
|
}
|
|
|
|
export interface ReauthUserFunctionReturn {
|
|
success: boolean;
|
|
payload: DATASQUIREL_LoggedInUser | null;
|
|
msg?: string;
|
|
userId?: number;
|
|
token?: string;
|
|
}
|
|
|
|
export interface UpdateUserFunctionReturn {
|
|
success: boolean;
|
|
payload?: Object[] | string;
|
|
}
|
|
|
|
export interface GetReturn<R extends any = any> {
|
|
success: boolean;
|
|
payload?: R;
|
|
msg?: string;
|
|
error?: string;
|
|
schema?: DSQL_TableSchemaType;
|
|
finalQuery?: string;
|
|
}
|
|
|
|
export interface GetSchemaRequestQuery {
|
|
database?: string;
|
|
table?: string;
|
|
field?: string;
|
|
user_id?: string | number;
|
|
env?: { [k: string]: string };
|
|
}
|
|
|
|
export interface GetSchemaAPICredentialsParam {
|
|
key: string;
|
|
}
|
|
|
|
export type GetSchemaAPIParam = GetSchemaRequestQuery &
|
|
GetSchemaAPICredentialsParam;
|
|
|
|
export interface PostReturn {
|
|
success: boolean;
|
|
payload?: Object[] | string | PostInsertReturn;
|
|
msg?: string;
|
|
error?: any;
|
|
schema?: DSQL_TableSchemaType;
|
|
}
|
|
|
|
export interface PostDataPayload {
|
|
action: "insert" | "update" | "delete";
|
|
table: string;
|
|
data?: object;
|
|
identifierColumnName?: string;
|
|
identifierValue?: string;
|
|
duplicateColumnName?: string;
|
|
duplicateColumnValue?: string;
|
|
update?: boolean;
|
|
}
|
|
|
|
export interface LocalPostReturn {
|
|
success: boolean;
|
|
payload?: any;
|
|
msg?: string;
|
|
error?: string;
|
|
}
|
|
|
|
export interface LocalPostQueryObject {
|
|
query: string | PostDataPayload;
|
|
tableName?: string;
|
|
queryValues?: string[];
|
|
}
|
|
|
|
export interface PostInsertReturn {
|
|
fieldCount: number;
|
|
affectedRows: number;
|
|
insertId: number;
|
|
serverStatus: number;
|
|
warningCount: number;
|
|
message: string;
|
|
protocol41: boolean;
|
|
changedRows: number;
|
|
}
|
|
|
|
export type UserType = DATASQUIREL_LoggedInUser & {
|
|
isSuperUser?: boolean;
|
|
staticHost?: string;
|
|
};
|
|
|
|
export interface ApiKeyDef {
|
|
name: string;
|
|
scope: string;
|
|
date_created: string;
|
|
apiKeyPayload: string;
|
|
}
|
|
|
|
export interface MetricsType {
|
|
dbCount: number;
|
|
tablesCount: number;
|
|
mediaCount: number;
|
|
apiKeysCount: number;
|
|
}
|
|
|
|
export interface DashboardContextType {
|
|
user?: UserType;
|
|
databases?: DSQL_MYSQL_user_databases_Type[];
|
|
setTargetDatabase?: React.Dispatch<
|
|
React.SetStateAction<DSQL_MYSQL_user_databases_Type | undefined>
|
|
>;
|
|
targetDatabase?: DSQL_MYSQL_user_databases_Type;
|
|
metrics?: MetricsType;
|
|
}
|
|
|
|
export interface AddDbContextType {
|
|
user?: UserType;
|
|
databases?: DSQL_MYSQL_user_databases_Type[];
|
|
dbImage?: string | null | ImageObjectType;
|
|
setDbImage?: React.Dispatch<
|
|
React.SetStateAction<string | null | ImageObjectType>
|
|
>;
|
|
query?: any;
|
|
duplicateDb?: DSQL_MYSQL_user_databases_Type;
|
|
}
|
|
|
|
export interface EditDbContextType {
|
|
user?: UserType;
|
|
database?: DSQL_MYSQL_user_databases_Type;
|
|
dbImage?: string | null | ImageObjectType;
|
|
setDbImage?: React.Dispatch<
|
|
React.SetStateAction<string | null | ImageObjectType>
|
|
>;
|
|
}
|
|
|
|
export interface RichTextEditorsRefArray {
|
|
fieldName: string;
|
|
ref: React.MutableRefObject<Editor>;
|
|
}
|
|
|
|
export interface JSONTextEditorsRefArray {
|
|
fieldName: string;
|
|
ref: React.MutableRefObject<AceAjax.Editor>;
|
|
}
|
|
|
|
export interface TableEntriesContextType {
|
|
user: UserType;
|
|
database: DSQL_MYSQL_user_databases_Type;
|
|
table: DSQL_TableSchemaType;
|
|
dbSchemaData: DSQL_DatabaseSchemaType[];
|
|
entries: any[];
|
|
targetEntry?: any;
|
|
setTargetEntry: React.Dispatch<React.SetStateAction<any>>;
|
|
richTextEditors: React.MutableRefObject<RichTextEditorsRefArray[]>;
|
|
jsonTextEditors: React.MutableRefObject<JSONTextEditorsRefArray[]>;
|
|
query?: any;
|
|
confirmedDelegetedUser?: any;
|
|
activeEntries: any[] | null;
|
|
setActiveEntries: React.Dispatch<React.SetStateAction<any[] | null>>;
|
|
targetField: React.MutableRefObject<string>;
|
|
searchTerm: React.MutableRefObject<string | null>;
|
|
entriesCount: number;
|
|
}
|
|
|
|
export interface AddEntryContextType {
|
|
user: UserType;
|
|
database: DSQL_MYSQL_user_databases_Type;
|
|
table: DSQL_TableSchemaType;
|
|
dbSchemaData: DSQL_DatabaseSchemaType[];
|
|
richTextEditors: React.MutableRefObject<RichTextEditorsRefArray[]>;
|
|
jsonTextEditors: React.MutableRefObject<JSONTextEditorsRefArray[]>;
|
|
query: any;
|
|
duplicateEntry: any;
|
|
confirmedDelegetedUser: any;
|
|
}
|
|
|
|
export interface UserDatabasesContextType {
|
|
user: UserType;
|
|
users: any[];
|
|
targetUser: any;
|
|
setTargetUser: React.Dispatch<React.SetStateAction<any>>;
|
|
databases: DSQL_MYSQL_user_databases_Type[];
|
|
}
|
|
|
|
export interface SettingsPageContextType {
|
|
user: UserType;
|
|
image: any;
|
|
setImage: React.Dispatch<React.SetStateAction<any>>;
|
|
activeUser: any;
|
|
}
|
|
|
|
export interface MediaFolderPageContextType {
|
|
user: UserType;
|
|
media: any[];
|
|
targetMedia: any;
|
|
setTargetMedia: React.Dispatch<React.SetStateAction<any>>;
|
|
folders: any[];
|
|
query: any;
|
|
staticHost: string;
|
|
folder: string;
|
|
}
|
|
|
|
export interface TablesContextType {
|
|
user: UserType;
|
|
database: DSQL_MYSQL_user_databases_Type;
|
|
tables: DSQL_DATASQUIREL_USER_DATABASE_TABLES[];
|
|
targetTable: DSQL_DATASQUIREL_USER_DATABASE_TABLES | null;
|
|
setTargetTable: React.Dispatch<
|
|
React.SetStateAction<DSQL_DATASQUIREL_USER_DATABASE_TABLES | null>
|
|
>;
|
|
query: any;
|
|
confirmedDelegetedUser: any;
|
|
}
|
|
|
|
export interface EditTableContextType {
|
|
user: UserType;
|
|
database: DSQL_MYSQL_user_databases_Type;
|
|
table: DSQL_TableSchemaType;
|
|
tableFields: DSQL_FieldSchemaType[];
|
|
setTableFields: React.Dispatch<
|
|
React.SetStateAction<DSQL_FieldSchemaType[]>
|
|
>;
|
|
targetField: DSQL_FieldSchemaType | null;
|
|
setTargetField: React.Dispatch<
|
|
React.SetStateAction<DSQL_FieldSchemaType | null>
|
|
>;
|
|
pageRefresh: number;
|
|
setPageRefresh: React.Dispatch<React.SetStateAction<number>>;
|
|
refreshFieldsListRef: React.MutableRefObject<
|
|
React.Dispatch<React.SetStateAction<number>> | undefined
|
|
>;
|
|
dbSchemaData: DSQL_DatabaseSchemaType[];
|
|
query: any;
|
|
confirmedDelegetedUser: any;
|
|
}
|
|
|
|
export interface SingleDatabaseContextType {
|
|
user: UserType;
|
|
database: DSQL_MYSQL_user_databases_Type;
|
|
tables: DSQL_DATASQUIREL_USER_DATABASE_TABLES[];
|
|
targetTable: DSQL_DATASQUIREL_USER_DATABASE_TABLES | null;
|
|
setTargetTable: React.Dispatch<
|
|
React.SetStateAction<DSQL_DATASQUIREL_USER_DATABASE_TABLES | null>
|
|
>;
|
|
query: any;
|
|
confirmedDelegetedUser: any;
|
|
}
|
|
|
|
export interface ApiKeysContextType {
|
|
user?: UserType;
|
|
apiKeys?: any[];
|
|
setApiKeys?: React.Dispatch<React.SetStateAction<any[]>>;
|
|
targetApiKey?: any | null;
|
|
setTargetApiKey?: React.Dispatch<React.SetStateAction<any | null>>;
|
|
newApiKey?: any | null;
|
|
setNewApiKey?: React.Dispatch<React.SetStateAction<any | null>>;
|
|
}
|
|
|
|
export interface LoginFormContextType {
|
|
user?: UserType | null;
|
|
loading: boolean;
|
|
setLoading: React.Dispatch<React.SetStateAction<boolean>>;
|
|
alert: string | boolean;
|
|
setAlert: React.Dispatch<React.SetStateAction<string | boolean>>;
|
|
}
|
|
|
|
export interface CreateAccountContextType {
|
|
user?: UserType | null;
|
|
query: InviteObjectType;
|
|
invitingUser: any;
|
|
}
|
|
|
|
export interface InviteObjectType {
|
|
invite?: number;
|
|
database_access?: string;
|
|
priviledge?: string;
|
|
email?: string;
|
|
}
|
|
|
|
export interface DocsAsidePageObject {
|
|
id: number;
|
|
title: string;
|
|
slug: string;
|
|
parent_id?: number;
|
|
level?: number;
|
|
}
|
|
|
|
export interface AddSocialLoginContextType {
|
|
user?: UserType;
|
|
database?: DSQL_MYSQL_user_databases_Type;
|
|
query?: any;
|
|
socialLogins?: SocialLoginObjectType[];
|
|
}
|
|
|
|
export interface AddUserUserContextType {
|
|
user: UserType;
|
|
database: DSQL_MYSQL_user_databases_Type;
|
|
table: DSQL_TableSchemaType;
|
|
query: any;
|
|
confirmedDelegetedUser: any;
|
|
}
|
|
|
|
export interface AddUserContextType {
|
|
user: UserType;
|
|
users: DSQL_DATASQUIREL_DELEGATED_USERS[];
|
|
databases: DSQL_MYSQL_user_databases_Type[];
|
|
query: any;
|
|
}
|
|
|
|
export interface MediaContextType {
|
|
user: UserType;
|
|
media: DSQL_DATASQUIREL_USER_MEDIA[];
|
|
targetMedia: DSQL_DATASQUIREL_USER_MEDIA | null;
|
|
setTargetMedia: React.Dispatch<
|
|
React.SetStateAction<DSQL_DATASQUIREL_USER_MEDIA | null>
|
|
>;
|
|
folders: string[];
|
|
staticHost: string;
|
|
}
|
|
|
|
export interface MediaSubFolderContextType {
|
|
user: UserType;
|
|
media: DSQL_DATASQUIREL_USER_MEDIA[];
|
|
targetMedia: DSQL_DATASQUIREL_USER_MEDIA | null;
|
|
setTargetMedia: React.Dispatch<
|
|
React.SetStateAction<DSQL_DATASQUIREL_USER_MEDIA | null>
|
|
>;
|
|
folders: string[];
|
|
query: any;
|
|
folder: string;
|
|
staticHost: string;
|
|
}
|
|
|
|
export interface FieldsContextType {
|
|
user: UserType;
|
|
database: DSQL_MYSQL_user_databases_Type;
|
|
table: DSQL_TableSchemaType;
|
|
dbSchemaData: DSQL_DatabaseSchemaType[];
|
|
targetField: DSQL_FieldSchemaType | null;
|
|
setTargetField: React.Dispatch<
|
|
React.SetStateAction<DSQL_FieldSchemaType | null>
|
|
>;
|
|
refreshFieldsListRef: React.MutableRefObject<
|
|
React.Dispatch<React.SetStateAction<number>> | undefined
|
|
>;
|
|
tableFields: DSQL_FieldSchemaType[];
|
|
setTableFields: React.Dispatch<
|
|
React.SetStateAction<DSQL_FieldSchemaType[]>
|
|
>;
|
|
updateTableAfterFieldsUpdateFunction: () => void;
|
|
query: any;
|
|
confirmedDelegetedUser: any;
|
|
}
|
|
|
|
export interface SingleTableContextType {
|
|
user: UserType;
|
|
database: DSQL_MYSQL_user_databases_Type;
|
|
table: DSQL_TableSchemaType;
|
|
tableRecord: DSQL_DATASQUIREL_USER_DATABASE_TABLES;
|
|
tableFields: DSQL_FieldSchemaType[];
|
|
setTableFields: React.Dispatch<
|
|
React.SetStateAction<DSQL_FieldSchemaType[]>
|
|
>;
|
|
tableIndexes: DSQL_IndexSchemaType[];
|
|
setTableIndexes: React.Dispatch<
|
|
React.SetStateAction<DSQL_IndexSchemaType[]>
|
|
>;
|
|
dbSchemaData: DSQL_DatabaseSchemaType[];
|
|
entries: any[];
|
|
targetEntry: any;
|
|
setTargetEntry: React.Dispatch<React.SetStateAction<any>>;
|
|
richTextEditors: React.MutableRefObject<RichTextEditorsRefArray[]>;
|
|
jsonTextEditors: React.MutableRefObject<JSONTextEditorsRefArray[]>;
|
|
query: any;
|
|
confirmedDelegetedUser: any;
|
|
targetField: DSQL_FieldSchemaType | null;
|
|
setTargetField: React.Dispatch<
|
|
React.SetStateAction<DSQL_FieldSchemaType | null>
|
|
>;
|
|
refreshFieldsListRef: React.MutableRefObject<
|
|
React.Dispatch<React.SetStateAction<number>>
|
|
>;
|
|
updateTableAfterFieldsUpdateFunction: () => void;
|
|
entriesCount: number;
|
|
}
|
|
|
|
export interface SingleEntryContextType {
|
|
user: UserType;
|
|
database: DSQL_MYSQL_user_databases_Type;
|
|
table: DSQL_TableSchemaType;
|
|
dbSchemaData: DSQL_DatabaseSchemaType[];
|
|
entry: any;
|
|
targetEntry: any;
|
|
setTargetEntry: React.Dispatch<React.SetStateAction<any>>;
|
|
richTextEditors: React.MutableRefObject<RichTextEditorsRefArray[]>;
|
|
jsonTextEditors: React.MutableRefObject<JSONTextEditorsRefArray[]>;
|
|
query: any;
|
|
confirmedDelegetedUser: any;
|
|
prevEntry: any;
|
|
nextEntry: any;
|
|
}
|
|
|
|
export interface UserSchemaContextType {
|
|
user: UserType;
|
|
dbSchemaData: DSQL_DatabaseSchemaType[];
|
|
}
|
|
|
|
export interface ConnectContextType {
|
|
user?: UserType;
|
|
query?: any;
|
|
mariadbUserCred?: MariaDBUserCredType;
|
|
mariadbUsers?: MYSQL_mariadb_users_table_def[];
|
|
targetMariadbUser?: MYSQL_mariadb_users_table_def | null;
|
|
setTargetMariadbUser?: React.Dispatch<
|
|
React.SetStateAction<MYSQL_mariadb_users_table_def | null>
|
|
>;
|
|
refresh?: number;
|
|
setRefresh?: React.Dispatch<React.SetStateAction<number>>;
|
|
}
|
|
|
|
export interface MYSQL_mariadb_users_table_def {
|
|
id?: number;
|
|
user_id?: number;
|
|
username?: string;
|
|
host?: string;
|
|
password?: string;
|
|
primary?: number;
|
|
grants?: string;
|
|
date_created?: string;
|
|
date_created_code?: number;
|
|
date_created_timestamp?: string;
|
|
date_updated?: string;
|
|
date_updated_code?: number;
|
|
date_updated_timestamp?: string;
|
|
}
|
|
|
|
export interface DbContextType {
|
|
user?: UserType;
|
|
databases?: DSQL_MYSQL_user_databases_Type[];
|
|
targetDatabase?: DSQL_MYSQL_user_databases_Type;
|
|
setTargetDatabase?: React.Dispatch<
|
|
React.SetStateAction<DSQL_MYSQL_user_databases_Type | undefined>
|
|
>;
|
|
}
|
|
|
|
export interface MariaDBUserCredType {
|
|
mariadb_user?: string;
|
|
mariadb_host?: string;
|
|
mariadb_pass?: string;
|
|
}
|
|
|
|
export interface AddTableContextType {
|
|
user?: UserType;
|
|
dbSchemaData?: DSQL_DatabaseSchemaType[];
|
|
database?: DSQL_MYSQL_user_databases_Type;
|
|
tables?: DSQL_TableSchemaType[];
|
|
tableFields?: DSQL_FieldSchemaType[];
|
|
setTableFields?: React.Dispatch<
|
|
React.SetStateAction<DSQL_FieldSchemaType[]>
|
|
>;
|
|
targetField?: DSQL_FieldSchemaType | null;
|
|
setTargetField?: React.Dispatch<
|
|
React.SetStateAction<DSQL_FieldSchemaType | null>
|
|
>;
|
|
pageRefresh?: number | null;
|
|
setPageRefresh?: React.Dispatch<React.SetStateAction<number>>;
|
|
refreshFieldsListRef?: React.MutableRefObject<
|
|
React.Dispatch<React.SetStateAction<number>> | undefined
|
|
>;
|
|
query?: any;
|
|
}
|
|
|
|
export interface DbSchemaContextType {
|
|
user?: UserType;
|
|
database?: DSQL_MYSQL_user_databases_Type;
|
|
dbImage?: string;
|
|
setDbImage?: React.Dispatch<React.SetStateAction<string>>;
|
|
dbSchemaData?: DSQL_DatabaseSchemaType[];
|
|
tables?: any[];
|
|
}
|
|
|
|
export interface DbShellContextType {
|
|
user?: UserType;
|
|
database?: DSQL_MYSQL_user_databases_Type;
|
|
dbImage?: string;
|
|
setDbImage?: React.Dispatch<React.SetStateAction<string>>;
|
|
dbSchemaData?: DSQL_DatabaseSchemaType[];
|
|
tables?: any[];
|
|
}
|
|
|
|
export interface DbConnectContextType {
|
|
user: UserType;
|
|
database: DSQL_MYSQL_user_databases_Type;
|
|
targetDbSchema: DSQL_DatabaseSchemaType;
|
|
query: any;
|
|
}
|
|
|
|
export interface ImageObjectType {
|
|
imageName?: string;
|
|
mimeType?: keyof sharp.FormatEnum;
|
|
imageSize?: number;
|
|
thumbnailSize?: number;
|
|
private?: boolean;
|
|
imageBase64?: string;
|
|
imageBase64Full?: string;
|
|
}
|
|
|
|
export interface FileObjectType {
|
|
fileName?: string;
|
|
private?: boolean;
|
|
fileType?: string;
|
|
fileSize?: number;
|
|
fileBase64?: string;
|
|
fileBase64Full?: string;
|
|
}
|
|
|
|
export interface SocialLoginObjectType {
|
|
platform?: string;
|
|
paradigm?: string;
|
|
clientId?: string;
|
|
clientSecret?: string;
|
|
callbackUrl?: string;
|
|
domain1?: string;
|
|
domain2?: string;
|
|
domain3?: string;
|
|
}
|
|
|
|
export interface DbConnectType {
|
|
url: string;
|
|
key: string;
|
|
database: DSQL_MYSQL_user_databases_Type;
|
|
dbSchema: DSQL_DatabaseSchemaType;
|
|
type: "pull" | "push";
|
|
remoteDbs?: DSQL_DatabaseSchemaType[];
|
|
targetDb?: DSQL_DatabaseSchemaType;
|
|
}
|
|
|
|
export interface MYSQL_MediaType {
|
|
id?: number;
|
|
user_id?: number;
|
|
media_name?: string;
|
|
folder?: string;
|
|
media_url?: string;
|
|
media_thumbnail_url?: string;
|
|
media_type?: string;
|
|
width?: string;
|
|
height?: string;
|
|
size?: string;
|
|
private?: string;
|
|
}
|
|
|
|
export interface UserFileObject {
|
|
title?: string;
|
|
path?: string;
|
|
data?: string;
|
|
}
|
|
|
|
export interface UserFileObject2 {
|
|
type?: string;
|
|
name?: string;
|
|
root?: string;
|
|
content?: UserFileObject2[];
|
|
}
|
|
|
|
export type ApiKeyObject = {
|
|
id: number;
|
|
user_id?: string | number;
|
|
full_access?: boolean;
|
|
sign?: string;
|
|
date_code?: number;
|
|
error?: string;
|
|
};
|
|
|
|
export type AddApiKeyRequestBody = {
|
|
api_key: DSQL_DATASQUIREL_API_KEYS;
|
|
scoped_resources?: DSQL_DATASQUIREL_API_KEYS_SCOPED_RESOURCES[];
|
|
};
|
|
|
|
export type CheckApiCredentialsFn = (
|
|
param: CheckApiCredentialsFnParam
|
|
) => ApiKeyObject | null | undefined;
|
|
export type CheckApiCredentialsFnParam = {
|
|
key?: string;
|
|
database?: string;
|
|
table?: string;
|
|
user_id?: string | number;
|
|
media?: boolean;
|
|
};
|
|
|
|
export type FetchApiFn = (
|
|
url: string,
|
|
options?: FetchApiOptions,
|
|
csrf?: boolean
|
|
) => Promise<any>;
|
|
|
|
export type FetchApiOptions = RequestInit & {
|
|
method:
|
|
| (typeof DataCrudRequestMethods)[number]
|
|
| (typeof DataCrudRequestMethodsLowerCase)[number];
|
|
body?: object | string;
|
|
headers?: FetchHeader;
|
|
query?: { [key: string]: any };
|
|
};
|
|
|
|
type FetchHeader = HeadersInit & {
|
|
[key: string]: any;
|
|
};
|
|
|
|
export type FetchApiReturn = {
|
|
success: boolean;
|
|
payload: any;
|
|
msg?: string;
|
|
[key: string]: any;
|
|
};
|
|
|
|
export const ServerQueryOperators = ["AND", "OR"] as const;
|
|
export const ServerQueryEqualities = [
|
|
"EQUAL",
|
|
"LIKE",
|
|
"LIKE_RAW",
|
|
"NOT LIKE",
|
|
"NOT LIKE_RAW",
|
|
"NOT EQUAL",
|
|
"REGEXP",
|
|
"FULLTEXT",
|
|
"IN",
|
|
"NOT IN",
|
|
"BETWEEN",
|
|
"NOT BETWEEN",
|
|
"IS NULL",
|
|
"IS NOT NULL",
|
|
"EXISTS",
|
|
"NOT EXISTS",
|
|
"GREATER THAN",
|
|
"GREATER THAN OR EQUAL",
|
|
"LESS THAN",
|
|
"LESS THAN OR EQUAL",
|
|
] as const;
|
|
|
|
export type ServerQueryParam<
|
|
T extends { [k: string]: any } = { [k: string]: any }
|
|
> = {
|
|
selectFields?: (keyof T)[];
|
|
omitFields?: (keyof T)[];
|
|
query?: ServerQueryQueryObject<T>;
|
|
limit?: number;
|
|
page?: number;
|
|
offset?: number;
|
|
order?: {
|
|
field: keyof T;
|
|
strategy: "ASC" | "DESC";
|
|
};
|
|
searchOperator?: (typeof ServerQueryOperators)[number];
|
|
searchEquality?: (typeof ServerQueryEqualities)[number];
|
|
addUserId?: {
|
|
fieldName: keyof T;
|
|
};
|
|
join?: ServerQueryParamsJoin[];
|
|
group?: (keyof T)[];
|
|
[key: string]: any;
|
|
};
|
|
|
|
export type ServerQueryObject<T extends object = { [key: string]: any }> = {
|
|
value?: string | string[];
|
|
nullValue?: boolean;
|
|
notNullValue?: boolean;
|
|
operator?: (typeof ServerQueryOperators)[number];
|
|
equality?: (typeof ServerQueryEqualities)[number];
|
|
tableName?: string;
|
|
__query?: {
|
|
[key in keyof T]: Omit<ServerQueryObject<T>, "__query">;
|
|
};
|
|
};
|
|
|
|
export type ServerQueryQueryObject<T extends object = { [key: string]: any }> =
|
|
{
|
|
[key in keyof T]: ServerQueryObject<T>;
|
|
};
|
|
|
|
export type FetchDataParams = {
|
|
path: string;
|
|
method?: (typeof DataCrudRequestMethods)[number];
|
|
body?: object | string;
|
|
query?: AuthFetchQuery;
|
|
tableName?: string;
|
|
};
|
|
|
|
export type AuthFetchQuery = ServerQueryParam & {
|
|
[key: string]: any;
|
|
};
|
|
|
|
export type ServerQueryParamsJoin<
|
|
Table extends string = string,
|
|
Field extends object = { [key: string]: any }
|
|
> = {
|
|
joinType: "INNER JOIN" | "JOIN" | "LEFT JOIN" | "RIGHT JOIN";
|
|
alias?: string;
|
|
tableName: Table;
|
|
match?:
|
|
| ServerQueryParamsJoinMatchObject<Field>
|
|
| ServerQueryParamsJoinMatchObject<Field>[];
|
|
selectFields?: (
|
|
| keyof Field
|
|
| {
|
|
field: keyof Field;
|
|
alias?: string;
|
|
count?: boolean;
|
|
}
|
|
)[];
|
|
omitFields?: (
|
|
| keyof Field
|
|
| {
|
|
field: keyof Field;
|
|
alias?: string;
|
|
count?: boolean;
|
|
}
|
|
)[];
|
|
operator?: (typeof ServerQueryOperators)[number];
|
|
};
|
|
|
|
export type ServerQueryParamsJoinMatchObject<
|
|
Field extends object = { [key: string]: any }
|
|
> = {
|
|
/** Field name from the **Root Table** */
|
|
source: string | ServerQueryParamsJoinMatchSourceTargetObject;
|
|
/** Field name from the **Join Table** */
|
|
target?: keyof Field | ServerQueryParamsJoinMatchSourceTargetObject;
|
|
/** A literal value: No source and target Needed! */
|
|
targetLiteral?: string;
|
|
};
|
|
|
|
export type ServerQueryParamsJoinMatchSourceTargetObject = {
|
|
tableName: string;
|
|
fieldName: string;
|
|
};
|
|
|
|
export type ApiConnectBody = {
|
|
url: string;
|
|
key: string;
|
|
database: DSQL_MYSQL_user_databases_Type;
|
|
dbSchema: DSQL_DatabaseSchemaType;
|
|
type: "pull" | "push";
|
|
user_id?: string | number;
|
|
};
|
|
|
|
export type SuUserType = {
|
|
email: string;
|
|
password: string;
|
|
authKey: string;
|
|
logged_in_status: boolean;
|
|
date: number;
|
|
};
|
|
|
|
export type MariadbRemoteServerObject = {
|
|
host: string;
|
|
port: number;
|
|
primary?: boolean;
|
|
loadBalanced?: boolean;
|
|
users?: MariadbRemoteServerUserObject[];
|
|
};
|
|
|
|
export type MariadbRemoteServerUserObject = {
|
|
name: string;
|
|
password: string;
|
|
host: string;
|
|
};
|
|
|
|
export type APILoginFunctionParams = {
|
|
encryptionKey: string;
|
|
email?: string;
|
|
username?: string;
|
|
password?: string;
|
|
database: string;
|
|
additionalFields?: string[];
|
|
email_login?: boolean;
|
|
email_login_code?: string;
|
|
email_login_field?: string;
|
|
token?: boolean;
|
|
skipPassword?: boolean;
|
|
social?: boolean;
|
|
dbUserId?: number | string;
|
|
debug?: boolean;
|
|
};
|
|
export type APILoginFunctionReturn = {
|
|
success: boolean;
|
|
msg?: string;
|
|
payload?: DATASQUIREL_LoggedInUser | null;
|
|
userId?: number | string;
|
|
key?: string;
|
|
token?: string;
|
|
csrf?: string;
|
|
cookieNames?: any;
|
|
};
|
|
|
|
export type APICreateUserFunctionParams = {
|
|
encryptionKey?: string;
|
|
payload: any;
|
|
database: string;
|
|
userId?: string | number;
|
|
};
|
|
|
|
export type APICreateUserFunction = (
|
|
params: APICreateUserFunctionParams
|
|
) => Promise<AddUserFunctionReturn>;
|
|
|
|
/**
|
|
* API Get User Function
|
|
*/
|
|
export type APIGetUserFunctionParams = {
|
|
fields: string[];
|
|
dbFullName: string;
|
|
userId: string | number;
|
|
};
|
|
|
|
/**
|
|
* API Google Login Function
|
|
*/
|
|
export type APIGoogleLoginFunctionParams = {
|
|
token: string;
|
|
database?: string;
|
|
additionalFields?: string[];
|
|
additionalData?: { [key: string]: string | number };
|
|
debug?: boolean;
|
|
loginOnly?: boolean;
|
|
};
|
|
|
|
export type APIGoogleLoginFunction = (
|
|
params: APIGoogleLoginFunctionParams
|
|
) => Promise<APILoginFunctionReturn>;
|
|
|
|
/**
|
|
* Handle Social DB Function
|
|
*/
|
|
export type HandleSocialDbFunctionParams = {
|
|
database?: string;
|
|
email: string;
|
|
social_platform: string;
|
|
payload: any;
|
|
invitation?: any;
|
|
supEmail?: string;
|
|
additionalFields?: string[];
|
|
debug?: boolean;
|
|
loginOnly?: boolean;
|
|
social_id?: string | number;
|
|
};
|
|
|
|
export type HandleSocialDbFunctionReturn = {
|
|
success: boolean;
|
|
user?: DATASQUIREL_LoggedInUser | null;
|
|
msg?: string;
|
|
social_id?: string | number;
|
|
social_platform?: string;
|
|
payload?: any;
|
|
alert?: boolean;
|
|
newUser?: any;
|
|
error?: any;
|
|
} | null;
|
|
|
|
/**
|
|
* 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 {HandleSocialDbFunctionParams} params - function parameters inside an object
|
|
*
|
|
* @returns {Promise<HandleSocialDbFunctionReturn>} - Response object
|
|
*/
|
|
export type HandleSocialDbFunction = (
|
|
params: HandleSocialDbFunctionParams
|
|
) => Promise<APILoginFunctionReturn>;
|
|
|
|
export type ApiReauthUserReturn = {
|
|
success: boolean;
|
|
payload?: { [key: string]: any } | null;
|
|
msg?: string;
|
|
userId?: string | number;
|
|
};
|
|
|
|
export type GoogleAccessTokenObject = {
|
|
access_token: string;
|
|
token_type: "Bearer";
|
|
expires_in: number;
|
|
scope: string;
|
|
authuser: string;
|
|
prompt: string;
|
|
};
|
|
|
|
export type GoogleOauth2User = {
|
|
sub: string;
|
|
name: string;
|
|
given_name: string;
|
|
family_name: string;
|
|
picture: string;
|
|
email: string;
|
|
email_verified: boolean;
|
|
};
|
|
|
|
export interface AceEditorOptions {
|
|
animatedScroll?: boolean;
|
|
autoScrollEditorIntoView?: boolean;
|
|
behavioursEnabled?: boolean;
|
|
copyWithEmptySelection?: boolean;
|
|
cursorStyle?: "ace" | "slim" | "smooth" | "wide";
|
|
customScrollbar?: boolean;
|
|
displayIndentGuides?: boolean;
|
|
dragDelay?: number;
|
|
dragEnabled?: boolean;
|
|
enableAutoIndent?: boolean;
|
|
enableBasicAutocompletion?: boolean | any[];
|
|
enableKeyboardAccessibility?: boolean;
|
|
enableLiveAutocompletion?: boolean | any[];
|
|
enableMobileMenu?: boolean;
|
|
enableMultiselect?: boolean;
|
|
enableSnippets?: boolean;
|
|
fadeFoldWidgets?: boolean;
|
|
firstLineNumber?: number;
|
|
fixedWidthGutter?: boolean;
|
|
focusTimeout?: number;
|
|
foldStyle?: "markbegin" | "markbeginend" | "manual";
|
|
fontFamily?: string;
|
|
fontSize?: number;
|
|
hScrollBarAlwaysVisible?: boolean;
|
|
hasCssTransforms?: boolean;
|
|
highlightActiveLine?: boolean;
|
|
highlightGutterLine?: boolean;
|
|
highlightIndentGuides?: boolean;
|
|
highlightSelectedWord?: boolean;
|
|
indentedSoftWrap?: boolean;
|
|
keyboardHandler?: string;
|
|
liveAutocompletionDelay?: number;
|
|
liveAutocompletionThreshold?: number;
|
|
maxLines?: number;
|
|
maxPixelHeight?: number;
|
|
mergeUndoDeltas?: boolean | "always";
|
|
minLines?: number;
|
|
mode?: string;
|
|
navigateWithinSoftTabs?: boolean;
|
|
newLineMode?: AceAjax.NewLineMode;
|
|
overwrite?: boolean;
|
|
placeholder?: string;
|
|
printMargin?: number | boolean;
|
|
printMarginColumn?: number;
|
|
readOnly?: boolean;
|
|
relativeLineNumbers?: boolean;
|
|
scrollPastEnd?: number;
|
|
scrollSpeed?: number;
|
|
selectionStyle?: string;
|
|
session?: any;
|
|
showFoldWidgets?: boolean;
|
|
showFoldedAnnotations?: boolean;
|
|
showGutter?: boolean;
|
|
showInvisibles?: boolean;
|
|
showLineNumbers?: boolean;
|
|
showPrintMargin?: boolean;
|
|
tabSize?: number;
|
|
textInputAriaLabel?: string;
|
|
theme?: string;
|
|
tooltipFollowsMouse?: boolean;
|
|
useSoftTabs?: boolean;
|
|
useSvgGutterIcons?: boolean;
|
|
useWorker?: boolean;
|
|
vScrollBarAlwaysVisible?: boolean;
|
|
value?: string;
|
|
wrap?: number | boolean | "off" | "free" | "printmargin";
|
|
wrapBehavioursEnabled?: boolean;
|
|
wrapMethod?: "code" | "text" | "auto";
|
|
}
|
|
|
|
export type SendOneTimeCodeEmailResponse = {
|
|
success: boolean;
|
|
code?: string;
|
|
createdAt?: number;
|
|
email?: string;
|
|
msg?: string;
|
|
};
|
|
|
|
export type CookieObject = {
|
|
name: string;
|
|
value: string;
|
|
domain?: string;
|
|
path?: string;
|
|
expires?: Date;
|
|
maxAge?: number;
|
|
secure?: boolean;
|
|
httpOnly?: boolean;
|
|
sameSite?: "Strict" | "Lax" | "None";
|
|
priority?: "Low" | "Medium" | "High";
|
|
};
|
|
|
|
export type HttpRequestParams<
|
|
ReqObj extends { [k: string]: any } = { [k: string]: any }
|
|
> = RequestOptions & {
|
|
scheme?: "http" | "https";
|
|
body?: ReqObj;
|
|
query?: ReqObj;
|
|
urlEncodedFormBody?: boolean;
|
|
};
|
|
|
|
export type HttpRequestFunction<
|
|
ReqObj extends { [k: string]: any } = { [k: string]: any },
|
|
ResObj extends { [k: string]: any } = { [k: string]: any }
|
|
> = (param: HttpRequestParams<ReqObj>) => Promise<HttpFunctionResponse<ResObj>>;
|
|
|
|
export type HttpFunctionResponse<
|
|
ResObj extends { [k: string]: any } = { [k: string]: any }
|
|
> = {
|
|
status: number;
|
|
data?: ResObj;
|
|
error?: string;
|
|
str?: string;
|
|
requestedPath?: string;
|
|
};
|
|
|
|
export type ApiGetQueryObject<
|
|
T extends { [k: string]: any } = { [k: string]: any }
|
|
> = {
|
|
query: ServerQueryParam<T>;
|
|
table: string;
|
|
dbFullName?: string;
|
|
};
|
|
|
|
export const DataCrudRequestMethods = [
|
|
"GET",
|
|
"POST",
|
|
"PUT",
|
|
"PATCH",
|
|
"DELETE",
|
|
"OPTIONS",
|
|
] as const;
|
|
|
|
export const DataCrudRequestMethodsLowerCase = [
|
|
"get",
|
|
"post",
|
|
"put",
|
|
"patch",
|
|
"delete",
|
|
"options",
|
|
] as const;
|
|
|
|
export type DsqlMethodCrudParam<
|
|
T extends { [key: string]: any } = { [key: string]: any }
|
|
> = {
|
|
method: (typeof DataCrudRequestMethods)[number];
|
|
body?: T;
|
|
query?: DsqlCrudQueryObject<T>;
|
|
tableName: string;
|
|
addUser?: {
|
|
field: keyof T;
|
|
};
|
|
user?: DATASQUIREL_LoggedInUser;
|
|
extraData?: T;
|
|
transformData?: DsqlCrudTransformDataFunction<T>;
|
|
transformQuery?: DsqlCrudTransformQueryFunction<T>;
|
|
existingData?: T;
|
|
targetId?: string | number;
|
|
sanitize?: ({ data, batchData }: { data?: T; batchData?: T[] }) => T | T[];
|
|
debug?: boolean;
|
|
};
|
|
|
|
export type DsqlCrudTransformDataFunction<
|
|
T extends { [key: string]: any } = { [key: string]: any }
|
|
> = (params: {
|
|
data: T;
|
|
user?: DATASQUIREL_LoggedInUser;
|
|
existingData?: T;
|
|
reqMethod: (typeof DataCrudRequestMethods)[number];
|
|
}) => Promise<T>;
|
|
|
|
export type DsqlCrudTransformQueryFunction<
|
|
T extends { [key: string]: any } = { [key: string]: any }
|
|
> = (params: {
|
|
query: DsqlCrudQueryObject<T>;
|
|
user?: DATASQUIREL_LoggedInUser;
|
|
reqMethod: (typeof DataCrudRequestMethods)[number];
|
|
}) => Promise<DsqlCrudQueryObject<T>>;
|
|
|
|
export const DsqlCrudActions = ["insert", "update", "delete", "get"] as const;
|
|
|
|
export type DsqlCrudQueryObject<
|
|
T extends { [key: string]: any } = { [key: string]: any }
|
|
> = ServerQueryParam<T> & {
|
|
query?: ServerQueryQueryObject<T>;
|
|
};
|
|
|
|
export type SQLDeleteGeneratorParams<
|
|
T extends { [key: string]: any } = { [key: string]: any }
|
|
> = {
|
|
tableName: string;
|
|
deleteKeyValues?: SQLDeleteData<T>[];
|
|
dbFullName?: string;
|
|
data?: any;
|
|
};
|
|
|
|
export type SQLDeleteData<
|
|
T extends { [key: string]: any } = { [key: string]: any }
|
|
> = {
|
|
key: keyof T;
|
|
value: string | number | null | undefined;
|
|
operator?: (typeof ServerQueryEqualities)[number];
|
|
};
|
|
|
|
export type DsqlCrudParam<
|
|
T extends { [key: string]: any } = { [key: string]: any },
|
|
K extends string = string
|
|
> = {
|
|
action: (typeof DsqlCrudActions)[number];
|
|
table: K;
|
|
data?: T;
|
|
batchData?: T[];
|
|
deleteData?: T;
|
|
deleteKeyValues?: SQLDeleteData[];
|
|
targetId?: string | number;
|
|
targetValue?: string | number;
|
|
targetField?: keyof T;
|
|
query?: DsqlCrudQueryObject<T>;
|
|
sanitize?: ({ data, batchData }: { data?: T; batchData?: T[] }) => T | T[];
|
|
debug?: boolean;
|
|
count?: boolean;
|
|
countOnly?: boolean;
|
|
dbFullName?: string;
|
|
dbName?: string;
|
|
};
|
|
|
|
export type ErrorCallback = (title: string, error: Error, data?: any) => void;
|
|
|
|
export interface MariaDBUser {
|
|
Host?: string;
|
|
User?: string;
|
|
Password?: string;
|
|
Select_priv?: string;
|
|
Insert_priv?: string;
|
|
Update_priv?: string;
|
|
Delete_priv?: string;
|
|
Create_priv?: string;
|
|
Drop_priv?: string;
|
|
Reload_priv?: string;
|
|
Shutdown_priv?: string;
|
|
Process_priv?: string;
|
|
File_priv?: string;
|
|
Grant_priv?: string;
|
|
References_priv?: string;
|
|
Index_priv?: string;
|
|
Alter_priv?: string;
|
|
Show_db_priv?: string;
|
|
Super_priv?: string;
|
|
Create_tmp_table_priv?: string;
|
|
Lock_tables_priv?: string;
|
|
Execute_priv?: string;
|
|
Repl_slave_priv?: string;
|
|
Repl_client_priv?: string;
|
|
Create_view_priv?: string;
|
|
Show_view_priv?: string;
|
|
Create_routine_priv?: string;
|
|
Alter_routine_priv?: string;
|
|
Create_user_priv?: string;
|
|
Event_priv?: string;
|
|
Trigger_priv?: string;
|
|
Create_tablespace_priv?: string;
|
|
Delete_history_priv?: string;
|
|
ssl_type?: string;
|
|
ssl_cipher?: string;
|
|
x509_issuer?: string;
|
|
x509_subject?: string;
|
|
max_questions?: number;
|
|
max_updates?: number;
|
|
max_connections?: number;
|
|
max_user_connections?: number;
|
|
plugin?: string;
|
|
authentication_string?: string;
|
|
password_expired?: string;
|
|
is_role?: string;
|
|
default_role?: string;
|
|
max_statement_time?: number;
|
|
}
|
|
|
|
export const QueryFields = [
|
|
"duplicate",
|
|
"user_id",
|
|
"delegated_user_id",
|
|
"db_id",
|
|
"table_id",
|
|
"db_slug",
|
|
] as const;
|
|
|
|
export type PagePropsType = {
|
|
user?: UserType | null;
|
|
pageUrl?: string | null;
|
|
envObject?: { [k in (typeof EnvKeys)[number]]?: string } | null;
|
|
query?: { [k in (typeof QueryFields)[number]]?: string };
|
|
databases?: DSQL_DATASQUIREL_USER_DATABASES[] | null;
|
|
delegatedDatabases?: DSQL_DATASQUIREL_DELEGATED_DATABASES_JOIN[] | null;
|
|
delegatedDatabase?: DSQL_DATASQUIREL_DELEGATED_DATABASES_JOIN | null;
|
|
database?: DSQL_DATASQUIREL_USER_DATABASES | null;
|
|
invitationsSent?: DSQL_DATASQUIREL_INVITATIONS_JOIN[] | null;
|
|
invitationsReceived?: DSQL_DATASQUIREL_INVITATIONS_JOIN[] | null;
|
|
invitationSent?: DSQL_DATASQUIREL_INVITATIONS_JOIN | null;
|
|
invitationReceived?: DSQL_DATASQUIREL_INVITATIONS_JOIN | null;
|
|
databaseTables?: DSQL_DATASQUIREL_USER_DATABASE_TABLES[] | null;
|
|
delegatedUsers?: DSQL_DATASQUIREL_DELEGATED_USERS_JOIN[] | null;
|
|
delegatedUser?: DSQL_DATASQUIREL_DELEGATED_USERS_JOIN | null;
|
|
usersWhoDelegatedMe?: DSQL_DATASQUIREL_DELEGATED_USERS_JOIN[] | null;
|
|
userWhoDelegatedMe?: DSQL_DATASQUIREL_DELEGATED_USERS_JOIN | null;
|
|
databaseTable?: DSQL_DATASQUIREL_USER_DATABASE_TABLES | null;
|
|
singleUser?: DSQL_DATASQUIREL_USERS_FILTERED | null;
|
|
dbCount?: number | null;
|
|
tableCount?: number | null;
|
|
mediaCount?: number | null;
|
|
apiKeysCount?: number | null;
|
|
databaseSchema?: DSQL_DatabaseSchemaType | null;
|
|
clonedDatabaseSchema?: DSQL_DatabaseSchemaType | null;
|
|
tableSchema?: DSQL_TableSchemaType | null;
|
|
userMedia?: DSQL_DATASQUIREL_USER_MEDIA[] | null;
|
|
mediaCurrentFolder?: string | null;
|
|
appData?: DsqlAppData | null;
|
|
staticHost?: string | null;
|
|
folders?: string[] | null;
|
|
activeClonedTable?: boolean | null;
|
|
tableEntries?: DefaultEntryType[] | null;
|
|
tableEntriesCount?: number | null;
|
|
tableEntry?: DefaultEntryType | null;
|
|
apiKeys?: DSQL_DATASQUIREL_API_KEYS[] | null;
|
|
mariadbUsers?: DSQL_DATASQUIREL_MARIADB_USERS[] | null;
|
|
mariadbUser?: DSQL_DATASQUIREL_MARIADB_USERS | null;
|
|
privateFolders?: DSQL_DATASQUIREL_USER_PRIVATE_FOLDERS[] | null;
|
|
privateFolder?: DSQL_DATASQUIREL_USER_PRIVATE_FOLDERS | null;
|
|
appConfig?: SiteConfig | null;
|
|
userConfig?: SiteConfig | null;
|
|
suUsers?: DSQL_DATASQUIREL_USERS[] | null;
|
|
suUsersCount?: number | null;
|
|
suUser?: DSQL_DATASQUIREL_USERS | null;
|
|
dsqlMainSchema?: DSQL_DatabaseSchemaType | null;
|
|
suSQLUsers?: MariaDBUser[] | null;
|
|
suSQLUsersCount?: number | null;
|
|
suSQLUser?: MariaDBUser | null;
|
|
backups?: DSQL_DATASQUIREL_BACKUPS[] | null;
|
|
backup?: DSQL_DATASQUIREL_BACKUPS | null;
|
|
appBackups?: DSQL_DATASQUIREL_BACKUPS[] | null;
|
|
appBackup?: DSQL_DATASQUIREL_BACKUPS | null;
|
|
userBackups?: DSQL_DATASQUIREL_USER_BACKUPS_JOIN[] | null;
|
|
userBackup?: DSQL_DATASQUIREL_USER_BACKUPS_JOIN | null;
|
|
suDatabases?: SQLShowDatabaseObject[] | null;
|
|
suDatabase?: SQLShowDatabaseObject | null;
|
|
isSuperUserPage?: boolean;
|
|
appVersion?: (typeof AppVersions)[number];
|
|
};
|
|
|
|
export type APIResponseObject<T extends any = any> = {
|
|
success: boolean;
|
|
payload?: T;
|
|
payloadBase64?: string;
|
|
payloadThumbnailBase64?: string;
|
|
payloadURL?: string;
|
|
payloadThumbnailURL?: string;
|
|
error?: any;
|
|
msg?: string;
|
|
queryObject?: {
|
|
sql?: string;
|
|
params?: string[];
|
|
};
|
|
status?: number;
|
|
count?: number;
|
|
errors?: DSQLErrorObject[];
|
|
debug?: any;
|
|
batchPayload?: any[][] | null;
|
|
};
|
|
|
|
export const UserTypes = ["su", "admin"] as const;
|
|
|
|
export const SignUpParadigms = [
|
|
{
|
|
name: "email",
|
|
},
|
|
{
|
|
name: "google",
|
|
},
|
|
] as const;
|
|
|
|
export const QueueJobTypes = ["dummy", "import-database"] as const;
|
|
|
|
export const WebSocketEvents = [
|
|
/**
|
|
* # Client Events
|
|
* @description Events sent from Client to Server
|
|
*/
|
|
"client:check-queue",
|
|
"client:dev:queue",
|
|
"client:delete-queue",
|
|
"client:pty-shell",
|
|
|
|
/**
|
|
* # Server Events
|
|
* @description Events sent from Server to Client
|
|
*/
|
|
"server:error",
|
|
"server:message",
|
|
"server:ready",
|
|
"server:success",
|
|
"server:update",
|
|
"server:queue",
|
|
"server:dev:queue",
|
|
"server:queue-deleted",
|
|
"server:pty-shell",
|
|
] as const;
|
|
|
|
export type WebSocketDataType = {
|
|
event: (typeof WebSocketEvents)[number];
|
|
data?: {
|
|
queue?: DSQL_DATASQUIREL_PROCESS_QUEUE;
|
|
};
|
|
error?: string;
|
|
message?: string;
|
|
};
|
|
|
|
export const DatasquirelWindowEvents = [
|
|
"queue-started",
|
|
"queue-complete",
|
|
"queue-running",
|
|
] as const;
|
|
|
|
export type DatasquirelWindowEventPayloadType = {
|
|
event: (typeof DatasquirelWindowEvents)[number];
|
|
data?: {
|
|
queue?: DSQL_DATASQUIREL_PROCESS_QUEUE;
|
|
};
|
|
error?: string;
|
|
message?: string;
|
|
};
|
|
|
|
/**
|
|
* # Docker Compose Types
|
|
*/
|
|
export type DockerCompose = {
|
|
services: DockerComposeServices;
|
|
networks: DockerComposeNetworks;
|
|
name: string;
|
|
};
|
|
|
|
export const DockerComposeServices = [
|
|
"setup",
|
|
"cron",
|
|
"reverse-proxy",
|
|
"webapp",
|
|
"websocket",
|
|
"static",
|
|
"db",
|
|
"maxscale",
|
|
"post-db-setup",
|
|
"web-app-post-db-setup",
|
|
"post-replica-db-setup",
|
|
"db-replica-1",
|
|
"db-replica-2",
|
|
"db-cron",
|
|
"web-app-post-db-setup",
|
|
] as const;
|
|
|
|
export type DockerComposeServices = {
|
|
[key in (typeof DockerComposeServices)[number]]: DockerComposeServiceWithBuildObject;
|
|
};
|
|
|
|
export type DockerComposeNetworks = {
|
|
[k: string]: {
|
|
driver?: "bridge";
|
|
ipam?: {
|
|
config: DockerComposeNetworkConfigObject[];
|
|
};
|
|
external?: boolean;
|
|
};
|
|
};
|
|
|
|
export type DockerComposeNetworkConfigObject = {
|
|
subnet: string;
|
|
gateway: string;
|
|
};
|
|
|
|
export type DockerComposeServiceWithBuildObject = {
|
|
build: DockerComposeServicesBuildObject;
|
|
env_file: string;
|
|
container_name: string;
|
|
hostname: string;
|
|
volumes: string[];
|
|
environment: string[];
|
|
networks?: DockerComposeServiceNetworkObject;
|
|
restart?: string;
|
|
depends_on?: {
|
|
[k: string]: {
|
|
condition: string;
|
|
};
|
|
};
|
|
user?: string;
|
|
};
|
|
|
|
export type DockerComposeServiceWithImage = Omit<
|
|
DockerComposeServiceWithBuildObject,
|
|
"build"
|
|
> & {
|
|
image: string;
|
|
};
|
|
|
|
export type DockerComposeServicesBuildObject = {
|
|
context: string;
|
|
dockerfile: string;
|
|
};
|
|
|
|
export type DockerComposeServiceNetworkObject = {
|
|
[k: string]: {
|
|
ipv4_address: string;
|
|
};
|
|
};
|
|
|
|
/**
|
|
* # Site Setup Types
|
|
*/
|
|
export type SiteSetup = {
|
|
docker: {
|
|
network: {
|
|
subnet: string;
|
|
};
|
|
};
|
|
};
|
|
|
|
export type AppRefObject = {
|
|
currentMariadbUser?: DSQL_DATASQUIREL_MARIADB_USERS;
|
|
};
|
|
|
|
export type DsqlAppData = {
|
|
DSQL_REMOTE_SQL_HOST?: string;
|
|
DSQL_SU_USER_ID?: string;
|
|
DSQL_HOST_ENV?: string;
|
|
DSQL_HOST?: string;
|
|
DSQL_STATIC_HOST?: string;
|
|
DSQL_GOOGLE_CLIENT_ID?: string;
|
|
DSQL_TINY_MCE_API_KEY?: string;
|
|
DSQL_WEBSOCKET_URL?: string;
|
|
DSQL_FACEBOOK_APP_ID?: string;
|
|
DSQL_GITHUB_ID?: string;
|
|
};
|
|
|
|
export const MediaTypes = ["image", "file", "video"] as const;
|
|
|
|
export type MediaUploadDataType = ImageObjectType &
|
|
FileObjectType & {
|
|
private?: boolean;
|
|
privateFolder?: boolean;
|
|
overwrite?: boolean;
|
|
};
|
|
|
|
export const ImageMimeTypes: (keyof sharp.FormatEnum)[] = [
|
|
"webp",
|
|
"gif",
|
|
"svg",
|
|
"png",
|
|
"jpeg",
|
|
"jpg",
|
|
] as const;
|
|
|
|
export const FileMimeTypes = [
|
|
"pdf",
|
|
"csv",
|
|
"json",
|
|
"sql",
|
|
"xlsx",
|
|
"txt",
|
|
"zip",
|
|
"xz",
|
|
"yaml",
|
|
"yml",
|
|
] as const;
|
|
|
|
export const VideoMimeTypes = ["mp4", "wav"] as const;
|
|
|
|
export const CurrentlyEditedFieldActions = [
|
|
"edit-field",
|
|
"edit-index",
|
|
"delete-field",
|
|
"delete-index",
|
|
"new-field",
|
|
"new-index",
|
|
"move-up",
|
|
"move-down",
|
|
"complete",
|
|
] as const;
|
|
|
|
export type CurrentlyEditedTableSchemaType = {
|
|
action: (typeof CurrentlyEditedFieldActions)[number];
|
|
field?: DSQL_FieldSchemaType;
|
|
fieldIndex?: number;
|
|
index?: DSQL_IndexSchemaType;
|
|
indexIndex?: number;
|
|
spliceIndex?: number;
|
|
elRef?: React.RefObject<HTMLDivElement>;
|
|
};
|
|
|
|
export type DataTypesType = {
|
|
title: string;
|
|
name: (typeof DataTypes)[number]["name"];
|
|
value?: string;
|
|
argument?: true;
|
|
description?: string;
|
|
maxValue?: number;
|
|
};
|
|
|
|
export type DefaultSQLValuesLiteralObject = {
|
|
title: string;
|
|
value: string;
|
|
description?: string;
|
|
dataType: (typeof DataTypes)[number]["name"];
|
|
};
|
|
|
|
export const DefaultSQLValuesLiteral: DefaultSQLValuesLiteralObject[] = [
|
|
{
|
|
title: "CURRENT_TIMESTAMP",
|
|
value: "CURRENT_TIMESTAMP",
|
|
description: "",
|
|
dataType: "TIMESTAMP",
|
|
},
|
|
{
|
|
title: "UUID",
|
|
value: "UUID()",
|
|
description: "",
|
|
dataType: "UUID",
|
|
},
|
|
] as const;
|
|
|
|
export type ClonedTableInfo = {
|
|
dbId?: string | number;
|
|
tableId?: string | number;
|
|
keepUpdated?: boolean;
|
|
keepDataUpdated?: boolean;
|
|
};
|
|
|
|
export type DefaultEntryType = {
|
|
id?: number;
|
|
uuid?: string;
|
|
date_created?: string;
|
|
date_created_code?: number;
|
|
date_created_timestamp?: string;
|
|
date_updated?: string;
|
|
date_updated_code?: number;
|
|
date_updated_timestamp?: string;
|
|
} & {
|
|
[k: string]: string | number | null;
|
|
};
|
|
|
|
export const IndexTypes = ["regular", "full_text"] as const;
|
|
|
|
export type LoginUserParam = {
|
|
key?: string;
|
|
database: string;
|
|
payload: {
|
|
email?: string;
|
|
username?: string;
|
|
password?: string;
|
|
};
|
|
additionalFields?: string[];
|
|
request?: IncomingMessage & { [s: string]: any };
|
|
response?: ServerResponse & { [s: string]: any };
|
|
encryptionKey?: string;
|
|
encryptionSalt?: string;
|
|
email_login?: boolean;
|
|
email_login_code?: string;
|
|
temp_code_field?: string;
|
|
token?: boolean;
|
|
user_id?: string | number;
|
|
skipPassword?: boolean;
|
|
debug?: boolean;
|
|
skipWriteAuthFile?: boolean;
|
|
apiUserID?: string | number;
|
|
dbUserId?: string | number;
|
|
cleanupTokens?: boolean;
|
|
secureCookie?: boolean;
|
|
};
|
|
|
|
export const UserSelectFields = [
|
|
{
|
|
field: "first_name",
|
|
alias: "user_first_name",
|
|
},
|
|
{
|
|
field: "last_name",
|
|
alias: "user_last_name",
|
|
},
|
|
{
|
|
field: "email",
|
|
alias: "user_email",
|
|
},
|
|
{
|
|
field: "image_thumbnail",
|
|
alias: "user_image_thumbnail",
|
|
},
|
|
] as const;
|
|
|
|
export const DelegatedUserSelectFields = [
|
|
{
|
|
field: "first_name",
|
|
alias: "delegated_user_first_name",
|
|
},
|
|
{
|
|
field: "last_name",
|
|
alias: "delegated_user_last_name",
|
|
},
|
|
{
|
|
field: "email",
|
|
alias: "delegated_user_email",
|
|
},
|
|
{
|
|
field: "image_thumbnail",
|
|
alias: "delegated_user_image_thumbnail",
|
|
},
|
|
] as const;
|
|
|
|
export const InvitedUserSelectFields = [
|
|
{
|
|
field: "first_name",
|
|
alias: "invited_user_first_name",
|
|
},
|
|
{
|
|
field: "last_name",
|
|
alias: "invited_user_last_name",
|
|
},
|
|
{
|
|
field: "email",
|
|
alias: "invited_user_email",
|
|
},
|
|
{
|
|
field: "image_thumbnail",
|
|
alias: "invited_user_image_thumbnail",
|
|
},
|
|
] as const;
|
|
|
|
export type DefaultLocalResourcesHookParams<
|
|
T extends { [k: string]: any } = { [k: string]: any }
|
|
> = {
|
|
refresh?: number;
|
|
setLoading?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
loadingEndTimeout?: number;
|
|
user?: UserType | null;
|
|
ready?: boolean;
|
|
query?: DsqlCrudQueryObject<T>;
|
|
};
|
|
|
|
export type DelegatedUserPermissionObject = {
|
|
dbId?: string | number;
|
|
tableId?: string | number;
|
|
dbSlug?: string;
|
|
tableSlug?: string;
|
|
permission?: DSQL_DATASQUIREL_DELEGATED_RESOURCES["permission"];
|
|
};
|
|
|
|
export type QueryObject = { [k in (typeof QueryFields)[number]]?: string };
|
|
|
|
export type CookiesObject = {
|
|
[k in (typeof CookieNames)[keyof typeof CookieNames]]?: string;
|
|
};
|
|
|
|
export interface CookieOptions {
|
|
expires?: Date;
|
|
maxAge?: number;
|
|
path?: string;
|
|
domain?: string;
|
|
secure?: boolean;
|
|
httpOnly?: boolean;
|
|
}
|
|
|
|
export type DSQLErrorObject = {
|
|
sql?: string;
|
|
sqlValues?: any[];
|
|
error?: string;
|
|
};
|
|
|
|
export const SQLPermissions = [
|
|
"ALL PRIVILEGES",
|
|
"ALTER",
|
|
"ALTER ROUTINE",
|
|
"CREATE",
|
|
"CREATE ROUTINE",
|
|
"CREATE TEMPORARY TABLES",
|
|
"CREATE VIEW",
|
|
"DELETE",
|
|
"DROP",
|
|
"EVENT",
|
|
"EXECUTE",
|
|
"FILE",
|
|
"INDEX",
|
|
"INSERT",
|
|
"LOCK TABLES",
|
|
"PROCESS",
|
|
"REFERENCES",
|
|
"RELOAD",
|
|
"REPLICATION CLIENT",
|
|
"REPLICATION SLAVE",
|
|
"SELECT",
|
|
"SHOW VIEW",
|
|
"SUPER",
|
|
"TRIGGER",
|
|
"UPDATE",
|
|
"USAGE",
|
|
] as const;
|
|
|
|
export const UserSQLPermissions = [
|
|
"SELECT",
|
|
"ALTER",
|
|
"ALTER ROUTINE",
|
|
"CREATE",
|
|
"CREATE ROUTINE",
|
|
"CREATE TEMPORARY TABLES",
|
|
"CREATE VIEW",
|
|
"DELETE",
|
|
"DROP",
|
|
"EVENT",
|
|
"EXECUTE",
|
|
"FILE",
|
|
"INDEX",
|
|
"INSERT",
|
|
"LOCK TABLES",
|
|
"PROCESS",
|
|
"REFERENCES",
|
|
"RELOAD",
|
|
"SHOW VIEW",
|
|
"SUPER",
|
|
"TRIGGER",
|
|
"UPDATE",
|
|
"USAGE",
|
|
] as const;
|
|
|
|
export type DatabaseScopedAccessObjectAccessedDatabase = {
|
|
dbId?: string | number;
|
|
dbSlug?: string;
|
|
dbSchemaId?: string | number;
|
|
};
|
|
|
|
export type DatabaseScopedAccessObjectTable = {
|
|
dbId?: string | number;
|
|
dbSlug: string;
|
|
dbSchemaId?: string | number;
|
|
tableSlug?: string;
|
|
tableSchemaId?: string | number;
|
|
};
|
|
|
|
export type DatabaseScopedAccessObject = {
|
|
accessedDatabase: DatabaseScopedAccessObjectAccessedDatabase;
|
|
dbSlug: string;
|
|
grants?: UserGrantType[];
|
|
allGrants?: boolean;
|
|
tables?: DatabaseScopedAccessObjectTable[];
|
|
allTables?: boolean;
|
|
};
|
|
|
|
export type UserGrantType = (typeof UserSQLPermissions)[number];
|
|
|
|
export type SiteConfig = {
|
|
main: SiteConfigMain;
|
|
mariadb_servers?: SiteConfigMariadbServers;
|
|
maxscale?: SiteConfigMaxscale;
|
|
};
|
|
|
|
export type SiteConfigMain = {
|
|
max_image_width?: SiteConfigMainValue;
|
|
thumbnail_size?: SiteConfigMainValue;
|
|
sharp_image_quality?: SiteConfigMainValue;
|
|
max_backups?: SiteConfigMainValue;
|
|
max_disk_usage?: SiteConfigMainValue;
|
|
};
|
|
|
|
export type SiteConfigMainValue = {
|
|
value: number | null;
|
|
description?: string | null;
|
|
};
|
|
|
|
export type SiteConfigMariadbServers = {
|
|
primary: SiteConfigMariadbServer;
|
|
replicas: SiteConfigMariadbServer[];
|
|
};
|
|
|
|
export type SiteConfigMariadbServer = {
|
|
server_id: number;
|
|
ip: string;
|
|
proxy_ip?: string;
|
|
master_ip?: string;
|
|
master_port?: number;
|
|
host?: string;
|
|
port: number;
|
|
/**
|
|
* Whether this replica belongs in the
|
|
* same docker compose stack as main
|
|
*/
|
|
is_stack_replica?: boolean;
|
|
users: {
|
|
root: SiteConfigMariadbServerUser;
|
|
replication: SiteConfigMariadbServerUser;
|
|
};
|
|
};
|
|
|
|
export type SiteConfigMariadbServerUser = {
|
|
user: string;
|
|
pass: string;
|
|
host?: string;
|
|
};
|
|
|
|
export type SiteConfigMaxscale = {
|
|
read_write_port: number;
|
|
read_only_port: number;
|
|
admin_port: number;
|
|
};
|
|
|
|
export const APIParadigms = ["crud", "media", "sql"] as const;
|
|
|
|
export const AppVersions = [
|
|
{
|
|
title: "Community",
|
|
value: "community",
|
|
},
|
|
{
|
|
title: "Pro",
|
|
value: "pro",
|
|
},
|
|
{
|
|
title: "Enterprise",
|
|
value: "enterprise",
|
|
},
|
|
{
|
|
title: "Full",
|
|
value: "full",
|
|
},
|
|
] as const;
|
|
|
|
export const EnvKeys = [
|
|
"DSQL_HOST",
|
|
"NEXT_PUBLIC_DSQL_HOST",
|
|
"DSQL_STATIC_HOST",
|
|
"DSQL_SOCKET_DOMAIN",
|
|
"DSQL_HOST_ENV",
|
|
"DSQL_PORT",
|
|
"DSQL_PRODUCTION_PORT",
|
|
"DSQL_STATIC_SERVER_PORT",
|
|
"DSQL_SITE_URL",
|
|
"DSQL_REMOTE_SQL_HOST",
|
|
"NEXT_PUBLIC_DSQL_REMOTE_SQL_HOST",
|
|
"DSQL_DB_TARGET_IP_ADDRESS",
|
|
"NEXT_PUBLIC_VERSION",
|
|
"DSQL_USER_DB_PREFIX",
|
|
"DSQL_USER_DELEGATED_DB_COOKIE_PREFIX",
|
|
"DSQL_NETWORK_IP_PREFIX",
|
|
"DSQL_NETWORK_GATEWAY",
|
|
"DSQL_NETWORK_SUBNET",
|
|
"DSQL_MARIADB_MASTER_HOST",
|
|
"DSQL_DB_HOST",
|
|
"DSQL_WEB_APP_HOST",
|
|
"DSQL_DB_USERNAME",
|
|
"DSQL_DB_PASSWORD",
|
|
"DSQL_MARIADB_ROOT_PASSWORD",
|
|
"DSQL_REPLICATION_USER_PASSWORD",
|
|
"DSQL_DB_NAME",
|
|
"DSQL_MARIADB_REPLICATION_PASSWORD",
|
|
"DSQL_MAXSCALE_PASSWORD",
|
|
"DSQL_DB_READ_ONLY_USERNAME",
|
|
"DSQL_DB_READ_ONLY_PASSWORD",
|
|
"DSQL_DB_FULL_ACCESS_USERNAME",
|
|
"DSQL_DB_FULL_ACCESS_PASSWORD",
|
|
"DSQL_DB_EXPOSED_PORT",
|
|
"DSQL_ENCRYPTION_PASSWORD",
|
|
"DSQL_ENCRYPTION_SALT",
|
|
"DSQL_SU_USER_ID",
|
|
"DSQL_SU_USER_UUID",
|
|
"DSQL_SU_EMAIL",
|
|
"DSQL_GOOGLE_CLIENT_ID",
|
|
"NEXT_PUBLIC_DSQL_GOOGLE_CLIENT_ID",
|
|
"DSQL_FACEBOOK_APP_ID",
|
|
"DSQL_FACEBOOK_SECRET",
|
|
"DSQL_MAIL_HOST",
|
|
"DSQL_MAIL_EMAIL",
|
|
"DSQL_MAIL_PASSWORD",
|
|
"DSQL_TINY_MCE_API_KEY",
|
|
"DSQL_GITHUB_ID",
|
|
"DSQL_GITHUB_SECRET",
|
|
"DSQL_GITHUB_WEBHOOK_SECRET",
|
|
"DSQL_GITHUB_WEBHOOK_URL",
|
|
"DSQL_DEPLOY_SERVER_PORT",
|
|
"DSQL_DOCKERFILE",
|
|
"DSQL_VOLUME_APP",
|
|
"DSQL_VOLUME_STATIC",
|
|
"DSQL_VOLUME_STATIC_CONFIGURATION_FILE",
|
|
"DSQL_VOLUME_DB",
|
|
"DSQL_VOLUME_DB_CONFIG",
|
|
"DSQL_VOLUME_DB_SETUP",
|
|
"DSQL_VOLUME_DB_SSL",
|
|
"DSQL_USER_LOGIN_KEYS_PATH",
|
|
"DSQL_API_KEYS_PATH",
|
|
"DSQL_APP_DIR",
|
|
"DSQL_DATA_DIR",
|
|
"DSQL_CONTACT_EMAIL",
|
|
"DSQL_SSL_DIR",
|
|
"DSQL_DEPLOYMENT_NAME",
|
|
"DSQL_COOKIES_PREFIX",
|
|
"DSQL_COOKIES_KEY_NAME",
|
|
"DSQL_WEB_APP_FAIL_COUNTS",
|
|
"NODE_ARCH",
|
|
"DSQL_WEBSOCKET_PORT",
|
|
"DSQL_WEBSOCKET_URL",
|
|
"NEXT_PUBLIC_DSQL_WEBSOCKET_URL",
|
|
"S3_ACCESS_KEY_ID",
|
|
"S3_SECRET_ACCESS",
|
|
"DSQL_ADDITIONAL_MARIADB_SERVERS",
|
|
"DSQL_ARCJET_KEY",
|
|
] as const;
|
|
|
|
export type SQLShowDatabaseObject = {
|
|
Database?: string;
|
|
};
|
|
|
|
export type AddUpdateMariadbUserAPIReqBody = {
|
|
mariadbUser: DSQL_DATASQUIREL_MARIADB_USERS;
|
|
grants?: UserGrantType[];
|
|
accessedDatabases?: DatabaseScopedAccessObject[];
|
|
isAllGrants?: boolean;
|
|
isAllDbsAccess?: boolean;
|
|
};
|
|
|
|
export type APIGetMediaParams = {
|
|
mediaID?: string | number;
|
|
mediaName?: string;
|
|
folder?: string;
|
|
query?: DsqlCrudQueryObject<DSQL_DATASQUIREL_USER_MEDIA>;
|
|
skipBase64?: "true" | "false";
|
|
stream?: "stream";
|
|
thumbnail?: "true" | "false";
|
|
apiKey?: string;
|
|
};
|
|
|
|
export type AddMediaAPIBody = {
|
|
media: MediaUploadDataType[];
|
|
folder?: string | null;
|
|
type: (typeof MediaTypes)[number];
|
|
apiKey?: string;
|
|
};
|