Updates
This commit is contained in:
Vendored
+1
-1
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = fetchApi;
|
||||
const lodash_1 = __importDefault(require("lodash"));
|
||||
const get_csrf_header_name_1 = __importDefault(require("../../utils/get-csrf-header-name"));
|
||||
const get_csrf_header_name_1 = __importDefault(require("../../package-shared/actions/get-csrf-header-name"));
|
||||
/**
|
||||
* # Fetch API
|
||||
*/
|
||||
|
||||
Vendored
+38
-23
@@ -5,27 +5,24 @@ declare global {
|
||||
var DSQL_FULL_ACCESS_DB_CONN: ServerlessMysql | undefined;
|
||||
var DSQL_USE_LOCAL: boolean | undefined;
|
||||
}
|
||||
/**
|
||||
* Imports
|
||||
*/
|
||||
import get from "./utils/get";
|
||||
import post from "./utils/post";
|
||||
import getSchema from "./utils/get-schema";
|
||||
import uploadImage from "./utils/upload-image";
|
||||
import uploadFile from "./utils/upload-file";
|
||||
import deleteFile from "./utils/delete-file";
|
||||
import createUser from "./users/add-user";
|
||||
import updateUser from "./users/update-user";
|
||||
import loginUser from "./users/login-user";
|
||||
import sendEmailCode from "./users/send-email-code";
|
||||
import logoutUser from "./users/logout-user";
|
||||
import userAuth from "./users/user-auth";
|
||||
import reAuthUser from "./users/reauth-user";
|
||||
import getUser from "./users/get-user";
|
||||
import loginWithGoogle from "./users/social/google-auth";
|
||||
import loginWithGithub from "./users/social/github-auth";
|
||||
import getToken from "./users/get-token";
|
||||
import validateToken from "./users/validate-token";
|
||||
import get from "./package-shared/actions/get";
|
||||
import post from "./package-shared/actions/post";
|
||||
import getSchema from "./package-shared/actions/get-schema";
|
||||
import uploadImage from "./package-shared/actions/upload-image";
|
||||
import uploadFile from "./package-shared/actions/upload-file";
|
||||
import deleteFile from "./package-shared/actions/delete-file";
|
||||
import createUser from "./package-shared/actions/users/add-user";
|
||||
import updateUser from "./package-shared/actions/users/update-user";
|
||||
import loginUser from "./package-shared/actions/users/login-user";
|
||||
import sendEmailCode from "./package-shared/actions/users/send-email-code";
|
||||
import logoutUser from "./package-shared/actions/users/logout-user";
|
||||
import userAuth from "./package-shared/actions/users/user-auth";
|
||||
import reAuthUser from "./package-shared/actions/users/reauth-user";
|
||||
import getUser from "./package-shared/actions/users/get-user";
|
||||
import loginWithGoogle from "./package-shared/actions/users/social/google-auth";
|
||||
import loginWithGithub from "./package-shared/actions/users/social/github-auth";
|
||||
import getToken from "./package-shared/actions/users/get-token";
|
||||
import validateToken from "./package-shared/actions/users/validate-token";
|
||||
import sqlGenerator from "./package-shared/functions/dsql/sql/sql-generator";
|
||||
import sqlInsertGenerator from "./package-shared/functions/dsql/sql/sql-insert-generator";
|
||||
import sqlDeleteGenerator from "./package-shared/functions/dsql/sql/sql-delete-generator";
|
||||
@@ -36,13 +33,21 @@ import connDbHandler from "./package-shared/utils/db/conn-db-handler";
|
||||
import encrypt from "./package-shared/functions/dsql/encrypt";
|
||||
import decrypt from "./package-shared/functions/dsql/decrypt";
|
||||
import hashPassword from "./package-shared/functions/dsql/hashPassword";
|
||||
import validateTempEmailCode from "./users/validate-temp-email-code";
|
||||
import deleteUser from "./users/delete-user";
|
||||
import validateTempEmailCode from "./package-shared/actions/users/validate-temp-email-code";
|
||||
import deleteUser from "./package-shared/actions/users/delete-user";
|
||||
import dsqlCrud from "./package-shared/utils/data-fetching/crud";
|
||||
import dsqlMethodCrud from "./package-shared/utils/data-fetching/method-crud";
|
||||
/**
|
||||
* Main Export
|
||||
*/
|
||||
declare const datasquirel: {
|
||||
/**
|
||||
* Get Action
|
||||
*/
|
||||
get: typeof get;
|
||||
/**
|
||||
* Post Action
|
||||
*/
|
||||
post: typeof post;
|
||||
media: {
|
||||
uploadImage: typeof uploadImage;
|
||||
@@ -119,5 +124,15 @@ declare const datasquirel: {
|
||||
httpRequest: typeof httpRequest;
|
||||
connDbHandler: typeof connDbHandler;
|
||||
};
|
||||
/**
|
||||
* Run Crud actions `get`, `insert`, `update`, `delete`
|
||||
* @note *Requires global variables `DSQL_USE_LOCAL` and `DSQL_DB_CONN`
|
||||
*/
|
||||
crud: typeof dsqlCrud;
|
||||
/**
|
||||
* Run Crud based on request Methods `GET`, `POST`, `PUT`, `PATCH`
|
||||
* @note *Requires global variables `DSQL_USE_LOCAL` and `DSQL_DB_CONN`
|
||||
*/
|
||||
methodCrud: typeof dsqlMethodCrud;
|
||||
};
|
||||
export default datasquirel;
|
||||
|
||||
Vendored
+38
-26
@@ -3,27 +3,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
/**
|
||||
* Imports
|
||||
*/
|
||||
const get_1 = __importDefault(require("./utils/get"));
|
||||
const post_1 = __importDefault(require("./utils/post"));
|
||||
const get_schema_1 = __importDefault(require("./utils/get-schema"));
|
||||
const upload_image_1 = __importDefault(require("./utils/upload-image"));
|
||||
const upload_file_1 = __importDefault(require("./utils/upload-file"));
|
||||
const delete_file_1 = __importDefault(require("./utils/delete-file"));
|
||||
const add_user_1 = __importDefault(require("./users/add-user"));
|
||||
const update_user_1 = __importDefault(require("./users/update-user"));
|
||||
const login_user_1 = __importDefault(require("./users/login-user"));
|
||||
const send_email_code_1 = __importDefault(require("./users/send-email-code"));
|
||||
const logout_user_1 = __importDefault(require("./users/logout-user"));
|
||||
const user_auth_1 = __importDefault(require("./users/user-auth"));
|
||||
const reauth_user_1 = __importDefault(require("./users/reauth-user"));
|
||||
const get_user_1 = __importDefault(require("./users/get-user"));
|
||||
const google_auth_1 = __importDefault(require("./users/social/google-auth"));
|
||||
const github_auth_1 = __importDefault(require("./users/social/github-auth"));
|
||||
const get_token_1 = __importDefault(require("./users/get-token"));
|
||||
const validate_token_1 = __importDefault(require("./users/validate-token"));
|
||||
const get_1 = __importDefault(require("./package-shared/actions/get"));
|
||||
const post_1 = __importDefault(require("./package-shared/actions/post"));
|
||||
const get_schema_1 = __importDefault(require("./package-shared/actions/get-schema"));
|
||||
const upload_image_1 = __importDefault(require("./package-shared/actions/upload-image"));
|
||||
const upload_file_1 = __importDefault(require("./package-shared/actions/upload-file"));
|
||||
const delete_file_1 = __importDefault(require("./package-shared/actions/delete-file"));
|
||||
const add_user_1 = __importDefault(require("./package-shared/actions/users/add-user"));
|
||||
const update_user_1 = __importDefault(require("./package-shared/actions/users/update-user"));
|
||||
const login_user_1 = __importDefault(require("./package-shared/actions/users/login-user"));
|
||||
const send_email_code_1 = __importDefault(require("./package-shared/actions/users/send-email-code"));
|
||||
const logout_user_1 = __importDefault(require("./package-shared/actions/users/logout-user"));
|
||||
const user_auth_1 = __importDefault(require("./package-shared/actions/users/user-auth"));
|
||||
const reauth_user_1 = __importDefault(require("./package-shared/actions/users/reauth-user"));
|
||||
const get_user_1 = __importDefault(require("./package-shared/actions/users/get-user"));
|
||||
const google_auth_1 = __importDefault(require("./package-shared/actions/users/social/google-auth"));
|
||||
const github_auth_1 = __importDefault(require("./package-shared/actions/users/social/github-auth"));
|
||||
const get_token_1 = __importDefault(require("./package-shared/actions/users/get-token"));
|
||||
const validate_token_1 = __importDefault(require("./package-shared/actions/users/validate-token"));
|
||||
const client_1 = __importDefault(require("./client"));
|
||||
const sql_generator_1 = __importDefault(require("./package-shared/functions/dsql/sql/sql-generator"));
|
||||
const sql_insert_generator_1 = __importDefault(require("./package-shared/functions/dsql/sql/sql-insert-generator"));
|
||||
@@ -35,11 +32,10 @@ const conn_db_handler_1 = __importDefault(require("./package-shared/utils/db/con
|
||||
const encrypt_1 = __importDefault(require("./package-shared/functions/dsql/encrypt"));
|
||||
const decrypt_1 = __importDefault(require("./package-shared/functions/dsql/decrypt"));
|
||||
const hashPassword_1 = __importDefault(require("./package-shared/functions/dsql/hashPassword"));
|
||||
const validate_temp_email_code_1 = __importDefault(require("./users/validate-temp-email-code"));
|
||||
const delete_user_1 = __importDefault(require("./users/delete-user"));
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
const validate_temp_email_code_1 = __importDefault(require("./package-shared/actions/users/validate-temp-email-code"));
|
||||
const delete_user_1 = __importDefault(require("./package-shared/actions/users/delete-user"));
|
||||
const crud_1 = __importDefault(require("./package-shared/utils/data-fetching/crud"));
|
||||
const method_crud_1 = __importDefault(require("./package-shared/utils/data-fetching/method-crud"));
|
||||
/**
|
||||
* User Functions Object
|
||||
*/
|
||||
@@ -82,7 +78,13 @@ const sql = {
|
||||
* Main Export
|
||||
*/
|
||||
const datasquirel = {
|
||||
/**
|
||||
* Get Action
|
||||
*/
|
||||
get: get_1.default,
|
||||
/**
|
||||
* Post Action
|
||||
*/
|
||||
post: post_1.default,
|
||||
media,
|
||||
user,
|
||||
@@ -99,5 +101,15 @@ const datasquirel = {
|
||||
httpRequest: httpRequest_1.default,
|
||||
connDbHandler: conn_db_handler_1.default,
|
||||
},
|
||||
/**
|
||||
* Run Crud actions `get`, `insert`, `update`, `delete`
|
||||
* @note *Requires global variables `DSQL_USE_LOCAL` and `DSQL_DB_CONN`
|
||||
*/
|
||||
crud: crud_1.default,
|
||||
/**
|
||||
* Run Crud based on request Methods `GET`, `POST`, `PUT`, `PATCH`
|
||||
* @note *Requires global variables `DSQL_USE_LOCAL` and `DSQL_DB_CONN`
|
||||
*/
|
||||
methodCrud: method_crud_1.default,
|
||||
};
|
||||
exports.default = datasquirel;
|
||||
|
||||
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = deleteFile;
|
||||
const grab_host_names_1 = __importDefault(require("../package-shared/utils/grab-host-names"));
|
||||
const grab_host_names_1 = __importDefault(require("../utils/grab-host-names"));
|
||||
/**
|
||||
* # Delete File via API
|
||||
*/
|
||||
Vendored
@@ -1,4 +1,4 @@
|
||||
import { DSQL_DatabaseSchemaType, DSQL_FieldSchemaType, DSQL_TableSchemaType, GetSchemaAPIParam } from "../package-shared/types";
|
||||
import { DSQL_DatabaseSchemaType, DSQL_FieldSchemaType, DSQL_TableSchemaType, GetSchemaAPIParam } from "../types";
|
||||
type GetSchemaReturn = {
|
||||
success: boolean;
|
||||
payload?: DSQL_DatabaseSchemaType | DSQL_TableSchemaType | DSQL_FieldSchemaType | null;
|
||||
@@ -1,5 +1,4 @@
|
||||
"use strict";
|
||||
// @ts-check
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
@@ -14,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = getSchema;
|
||||
const grab_host_names_1 = __importDefault(require("../package-shared/utils/grab-host-names"));
|
||||
const grab_host_names_1 = __importDefault(require("../utils/grab-host-names"));
|
||||
/**
|
||||
* # Get Schema for Database, table, or field *
|
||||
*/
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ApiGetQueryObject, GetReturn } from "../package-shared/types";
|
||||
import { ApiGetQueryObject, GetReturn } from "../types";
|
||||
type Param<T extends {
|
||||
[k: string]: any;
|
||||
} = {
|
||||
+4
-4
@@ -15,10 +15,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = get;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const grab_host_names_1 = __importDefault(require("../package-shared/utils/grab-host-names"));
|
||||
const get_1 = __importDefault(require("../package-shared/functions/api/query/get"));
|
||||
const serialize_query_1 = __importDefault(require("../package-shared/utils/serialize-query"));
|
||||
const grab_query_and_values_1 = __importDefault(require("../package-shared/utils/grab-query-and-values"));
|
||||
const grab_host_names_1 = __importDefault(require("../utils/grab-host-names"));
|
||||
const get_1 = __importDefault(require("../functions/api/query/get"));
|
||||
const serialize_query_1 = __importDefault(require("../utils/serialize-query"));
|
||||
const grab_query_and_values_1 = __importDefault(require("../utils/grab-query-and-values"));
|
||||
/**
|
||||
* # Make a get request to Datasquirel API
|
||||
*/
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PostDataPayload, PostReturn } from "../package-shared/types";
|
||||
import { PostDataPayload, PostReturn } from "../types";
|
||||
type Param = {
|
||||
key?: string;
|
||||
database?: string;
|
||||
@@ -16,8 +16,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = post;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const grab_host_names_1 = __importDefault(require("../package-shared/utils/grab-host-names"));
|
||||
const post_1 = __importDefault(require("../package-shared/functions/api/query/post"));
|
||||
const grab_host_names_1 = __importDefault(require("../utils/grab-host-names"));
|
||||
const post_1 = __importDefault(require("../functions/api/query/post"));
|
||||
/**
|
||||
* # Make a post request to Datasquirel API
|
||||
*/
|
||||
@@ -36,7 +36,7 @@ function post(_a) {
|
||||
(DSQL_DB_PASSWORD === null || DSQL_DB_PASSWORD === void 0 ? void 0 : DSQL_DB_PASSWORD.match(/./)) &&
|
||||
(DSQL_DB_NAME === null || DSQL_DB_NAME === void 0 ? void 0 : DSQL_DB_NAME.match(/./)) &&
|
||||
global.DSQL_USE_LOCAL) {
|
||||
/** @type {import("../package-shared/types").DSQL_DatabaseSchemaType | undefined} */
|
||||
/** @type {import("../types").DSQL_DatabaseSchemaType | undefined} */
|
||||
let dbSchema;
|
||||
try {
|
||||
const localDbSchemaPath = path_1.default.resolve(process.cwd(), "dsql.schema.json");
|
||||
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = uploadImage;
|
||||
const grab_host_names_1 = __importDefault(require("../package-shared/utils/grab-host-names"));
|
||||
const grab_host_names_1 = __importDefault(require("../utils/grab-host-names"));
|
||||
/**
|
||||
* # Upload File via API
|
||||
*/
|
||||
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = uploadImage;
|
||||
const grab_host_names_1 = __importDefault(require("../package-shared/utils/grab-host-names"));
|
||||
const grab_host_names_1 = __importDefault(require("../utils/grab-host-names"));
|
||||
/**
|
||||
* # Upload Image via API
|
||||
*/
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AddUserFunctionReturn, UserDataPayload } from "../package-shared/types";
|
||||
import { AddUserFunctionReturn, UserDataPayload } from "../../types";
|
||||
type Param = {
|
||||
key?: string;
|
||||
database?: string;
|
||||
@@ -15,8 +15,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = addUser;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const grab_host_names_1 = __importDefault(require("../package-shared/utils/grab-host-names"));
|
||||
const api_create_user_1 = __importDefault(require("../package-shared/functions/api/users/api-create-user"));
|
||||
const grab_host_names_1 = __importDefault(require("../../utils/grab-host-names"));
|
||||
const api_create_user_1 = __importDefault(require("../../functions/api/users/api-create-user"));
|
||||
/**
|
||||
* # Add User to Database
|
||||
*/
|
||||
@@ -35,7 +35,7 @@ function addUser(_a) {
|
||||
(DSQL_DB_PASSWORD === null || DSQL_DB_PASSWORD === void 0 ? void 0 : DSQL_DB_PASSWORD.match(/./)) &&
|
||||
(DSQL_DB_NAME === null || DSQL_DB_NAME === void 0 ? void 0 : DSQL_DB_NAME.match(/./)) &&
|
||||
global.DSQL_USE_LOCAL) {
|
||||
/** @type {import("../package-shared/types").DSQL_DatabaseSchemaType | undefined} */
|
||||
/** @type {import("../../types").DSQL_DatabaseSchemaType | undefined} */
|
||||
let dbSchema;
|
||||
try {
|
||||
const localDbSchemaPath = path_1.default.resolve(process.cwd(), "dsql.schema.json");
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { UpdateUserFunctionReturn } from "../package-shared/types";
|
||||
import { UpdateUserFunctionReturn } from "../../types";
|
||||
type Param = {
|
||||
key?: string;
|
||||
database?: string;
|
||||
+3
-3
@@ -15,8 +15,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = deleteUser;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const grab_host_names_1 = __importDefault(require("../package-shared/utils/grab-host-names"));
|
||||
const api_delete_user_1 = __importDefault(require("../package-shared/functions/api/users/api-delete-user"));
|
||||
const grab_host_names_1 = __importDefault(require("../../utils/grab-host-names"));
|
||||
const api_delete_user_1 = __importDefault(require("../../functions/api/users/api-delete-user"));
|
||||
/**
|
||||
* # Update User
|
||||
*/
|
||||
@@ -35,7 +35,7 @@ function deleteUser(_a) {
|
||||
(DSQL_DB_PASSWORD === null || DSQL_DB_PASSWORD === void 0 ? void 0 : DSQL_DB_PASSWORD.match(/./)) &&
|
||||
(DSQL_DB_NAME === null || DSQL_DB_NAME === void 0 ? void 0 : DSQL_DB_NAME.match(/./)) &&
|
||||
global.DSQL_USE_LOCAL) {
|
||||
/** @type {import("../package-shared/types").DSQL_DatabaseSchemaType | undefined} */
|
||||
/** @type {import("../../types").DSQL_DatabaseSchemaType | undefined} */
|
||||
let dbSchema;
|
||||
try {
|
||||
const localDbSchemaPath = path_1.default.resolve(process.cwd(), "dsql.schema.json");
|
||||
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = getToken;
|
||||
const decrypt_1 = __importDefault(require("../package-shared/functions/dsql/decrypt"));
|
||||
const get_auth_cookie_names_1 = __importDefault(require("../package-shared/functions/backend/cookies/get-auth-cookie-names"));
|
||||
const parseCookies_1 = __importDefault(require("../package-shared/utils/backend/parseCookies"));
|
||||
const decrypt_1 = __importDefault(require("../../functions/dsql/decrypt"));
|
||||
const get_auth_cookie_names_1 = __importDefault(require("../../functions/backend/cookies/get-auth-cookie-names"));
|
||||
const parseCookies_1 = __importDefault(require("../../utils/backend/parseCookies"));
|
||||
/**
|
||||
* Get just the access token for user
|
||||
* ==============================================================================
|
||||
@@ -1,4 +1,4 @@
|
||||
import { GetUserFunctionReturn } from "../package-shared/types";
|
||||
import { GetUserFunctionReturn } from "../../types";
|
||||
type Param = {
|
||||
key: string;
|
||||
database: string;
|
||||
@@ -15,8 +15,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = getUser;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const grab_host_names_1 = __importDefault(require("../package-shared/utils/grab-host-names"));
|
||||
const api_get_user_1 = __importDefault(require("../package-shared/functions/api/users/api-get-user"));
|
||||
const grab_host_names_1 = __importDefault(require("../../utils/grab-host-names"));
|
||||
const api_get_user_1 = __importDefault(require("../../functions/api/users/api-get-user"));
|
||||
/**
|
||||
* # Get User
|
||||
*/
|
||||
@@ -60,7 +60,7 @@ function getUser(_a) {
|
||||
(DSQL_DB_PASSWORD === null || DSQL_DB_PASSWORD === void 0 ? void 0 : DSQL_DB_PASSWORD.match(/./)) &&
|
||||
(DSQL_DB_NAME === null || DSQL_DB_NAME === void 0 ? void 0 : DSQL_DB_NAME.match(/./)) &&
|
||||
global.DSQL_USE_LOCAL) {
|
||||
/** @type {import("../package-shared/types").DSQL_DatabaseSchemaType | undefined} */
|
||||
/** @type {import("../../types").DSQL_DatabaseSchemaType | undefined} */
|
||||
let dbSchema;
|
||||
try {
|
||||
const localDbSchemaPath = path_1.default.resolve(process.cwd(), "dsql.schema.json");
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import http from "http";
|
||||
import { APILoginFunctionReturn } from "../package-shared/types";
|
||||
import { APILoginFunctionReturn } from "../../types";
|
||||
type Param = {
|
||||
key?: string;
|
||||
database: string;
|
||||
@@ -15,11 +15,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = loginUser;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const encrypt_1 = __importDefault(require("../package-shared/functions/dsql/encrypt"));
|
||||
const grab_host_names_1 = __importDefault(require("../package-shared/utils/grab-host-names"));
|
||||
const api_login_1 = __importDefault(require("../package-shared/functions/api/users/api-login"));
|
||||
const get_auth_cookie_names_1 = __importDefault(require("../package-shared/functions/backend/cookies/get-auth-cookie-names"));
|
||||
const write_auth_files_1 = require("../package-shared/functions/backend/auth/write-auth-files");
|
||||
const encrypt_1 = __importDefault(require("../../functions/dsql/encrypt"));
|
||||
const grab_host_names_1 = __importDefault(require("../../utils/grab-host-names"));
|
||||
const api_login_1 = __importDefault(require("../../functions/api/users/api-login"));
|
||||
const get_auth_cookie_names_1 = __importDefault(require("../../functions/backend/cookies/get-auth-cookie-names"));
|
||||
const write_auth_files_1 = require("../../functions/backend/auth/write-auth-files");
|
||||
/**
|
||||
* # Login A user
|
||||
*/
|
||||
@@ -67,7 +67,7 @@ function loginUser(_a) {
|
||||
/**
|
||||
* Initialize HTTP response variable
|
||||
*/
|
||||
/** @type {import("../package-shared/types").APILoginFunctionReturn} */
|
||||
/** @type {import("../../types").APILoginFunctionReturn} */
|
||||
let httpResponse = {
|
||||
success: false,
|
||||
};
|
||||
+6
-6
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = logoutUser;
|
||||
const get_auth_cookie_names_1 = __importDefault(require("../package-shared/functions/backend/cookies/get-auth-cookie-names"));
|
||||
const decrypt_1 = __importDefault(require("../package-shared/functions/dsql/decrypt"));
|
||||
const ejson_1 = __importDefault(require("../package-shared/utils/ejson"));
|
||||
const write_auth_files_1 = require("../package-shared/functions/backend/auth/write-auth-files");
|
||||
const parseCookies_1 = __importDefault(require("../package-shared/utils/backend/parseCookies"));
|
||||
const grab_host_names_1 = __importDefault(require("../package-shared/utils/grab-host-names"));
|
||||
const get_auth_cookie_names_1 = __importDefault(require("../../functions/backend/cookies/get-auth-cookie-names"));
|
||||
const decrypt_1 = __importDefault(require("../../functions/dsql/decrypt"));
|
||||
const ejson_1 = __importDefault(require("../../utils/ejson"));
|
||||
const write_auth_files_1 = require("../../functions/backend/auth/write-auth-files");
|
||||
const parseCookies_1 = __importDefault(require("../../utils/backend/parseCookies"));
|
||||
const grab_host_names_1 = __importDefault(require("../../utils/grab-host-names"));
|
||||
/**
|
||||
* # Logout user
|
||||
*/
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import http from "http";
|
||||
import { APILoginFunctionReturn } from "../package-shared/types";
|
||||
import { APILoginFunctionReturn } from "../../types";
|
||||
type Param = {
|
||||
key?: string;
|
||||
database?: string;
|
||||
+6
-6
@@ -15,12 +15,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = reauthUser;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const encrypt_1 = __importDefault(require("../package-shared/functions/dsql/encrypt"));
|
||||
const encrypt_1 = __importDefault(require("../../functions/dsql/encrypt"));
|
||||
const user_auth_1 = __importDefault(require("./user-auth"));
|
||||
const grab_host_names_1 = __importDefault(require("../package-shared/utils/grab-host-names"));
|
||||
const api_reauth_user_1 = __importDefault(require("../package-shared/functions/api/users/api-reauth-user"));
|
||||
const write_auth_files_1 = require("../package-shared/functions/backend/auth/write-auth-files");
|
||||
const get_auth_cookie_names_1 = __importDefault(require("../package-shared/functions/backend/cookies/get-auth-cookie-names"));
|
||||
const grab_host_names_1 = __importDefault(require("../../utils/grab-host-names"));
|
||||
const api_reauth_user_1 = __importDefault(require("../../functions/api/users/api-reauth-user"));
|
||||
const write_auth_files_1 = require("../../functions/backend/auth/write-auth-files");
|
||||
const get_auth_cookie_names_1 = __importDefault(require("../../functions/backend/cookies/get-auth-cookie-names"));
|
||||
/**
|
||||
* # Reauthorize User
|
||||
*/
|
||||
@@ -66,7 +66,7 @@ function reauthUser(_a) {
|
||||
(DSQL_DB_PASSWORD === null || DSQL_DB_PASSWORD === void 0 ? void 0 : DSQL_DB_PASSWORD.match(/./)) &&
|
||||
(DSQL_DB_NAME === null || DSQL_DB_NAME === void 0 ? void 0 : DSQL_DB_NAME.match(/./)) &&
|
||||
global.DSQL_USE_LOCAL) {
|
||||
/** @type {import("../package-shared/types").DSQL_DatabaseSchemaType | undefined} */
|
||||
/** @type {import("../../types").DSQL_DatabaseSchemaType | undefined} */
|
||||
let dbSchema;
|
||||
try {
|
||||
const localDbSchemaPath = path_1.default.resolve(process.cwd(), "dsql.schema.json");
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import http from "http";
|
||||
import { SendOneTimeCodeEmailResponse } from "../package-shared/types";
|
||||
import { SendOneTimeCodeEmailResponse } from "../../types";
|
||||
type Param = {
|
||||
key?: string;
|
||||
database?: string;
|
||||
@@ -14,7 +14,7 @@ type Param = {
|
||||
mail_port?: number;
|
||||
sender?: string;
|
||||
user_id?: boolean;
|
||||
extraCookies?: import("../package-shared/types").CookieObject[];
|
||||
extraCookies?: import("../../types").CookieObject[];
|
||||
};
|
||||
/**
|
||||
* # Send Email Code to a User
|
||||
+4
-4
@@ -15,8 +15,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = sendEmailCode;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const grab_host_names_1 = __importDefault(require("../package-shared/utils/grab-host-names"));
|
||||
const api_send_email_code_1 = __importDefault(require("../package-shared/functions/api/users/api-send-email-code"));
|
||||
const grab_host_names_1 = __importDefault(require("../../utils/grab-host-names"));
|
||||
const api_send_email_code_1 = __importDefault(require("../../functions/api/users/api-send-email-code"));
|
||||
/**
|
||||
* # Send Email Code to a User
|
||||
*/
|
||||
@@ -40,7 +40,7 @@ function sendEmailCode(_a) {
|
||||
(DSQL_DB_PASSWORD === null || DSQL_DB_PASSWORD === void 0 ? void 0 : DSQL_DB_PASSWORD.match(/./)) &&
|
||||
(DSQL_DB_NAME === null || DSQL_DB_NAME === void 0 ? void 0 : DSQL_DB_NAME.match(/./)) &&
|
||||
global.DSQL_USE_LOCAL) {
|
||||
/** @type {import("../package-shared/types").DSQL_DatabaseSchemaType | undefined} */
|
||||
/** @type {import("../../types").DSQL_DatabaseSchemaType | undefined} */
|
||||
let dbSchema;
|
||||
try {
|
||||
const localDbSchemaPath = path_1.default.resolve(process.cwd(), "dsql.schema.json");
|
||||
@@ -67,7 +67,7 @@ function sendEmailCode(_a) {
|
||||
*
|
||||
* @description make a request to datasquirel.com
|
||||
*
|
||||
* @type {import("../package-shared/types").SendOneTimeCodeEmailResponse}
|
||||
* @type {import("../../types").SendOneTimeCodeEmailResponse}
|
||||
*/
|
||||
const httpResponse = yield new Promise((resolve, reject) => {
|
||||
const reqPayload = JSON.stringify({
|
||||
Vendored
+4
-4
@@ -15,9 +15,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = githubAuth;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const encrypt_1 = __importDefault(require("../../package-shared/functions/dsql/encrypt"));
|
||||
const grab_host_names_1 = __importDefault(require("../../package-shared/utils/grab-host-names"));
|
||||
const api_github_login_1 = __importDefault(require("../../package-shared/functions/api/users/social/api-github-login"));
|
||||
const encrypt_1 = __importDefault(require("../../../functions/dsql/encrypt"));
|
||||
const grab_host_names_1 = __importDefault(require("../../../utils/grab-host-names"));
|
||||
const api_github_login_1 = __importDefault(require("../../../functions/api/users/social/api-github-login"));
|
||||
/**
|
||||
* # SERVER FUNCTION: Login with google Function
|
||||
*/
|
||||
@@ -65,7 +65,7 @@ function githubAuth(_a) {
|
||||
(DSQL_DB_USERNAME === null || DSQL_DB_USERNAME === void 0 ? void 0 : DSQL_DB_USERNAME.match(/./)) &&
|
||||
(DSQL_DB_PASSWORD === null || DSQL_DB_PASSWORD === void 0 ? void 0 : DSQL_DB_PASSWORD.match(/./)) &&
|
||||
(DSQL_DB_NAME === null || DSQL_DB_NAME === void 0 ? void 0 : DSQL_DB_NAME.match(/./))) {
|
||||
/** @type {import("../../package-shared/types").DSQL_DatabaseSchemaType | undefined | undefined} */
|
||||
/** @type {import("../../../types").DSQL_DatabaseSchemaType | undefined | undefined} */
|
||||
let dbSchema;
|
||||
try {
|
||||
const localDbSchemaPath = path_1.default.resolve(process.cwd(), "dsql.schema.json");
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
import http from "http";
|
||||
import { APILoginFunctionReturn } from "../../package-shared/types";
|
||||
import { APILoginFunctionReturn } from "../../../types";
|
||||
type Param = {
|
||||
key?: string;
|
||||
token: string;
|
||||
+6
-6
@@ -13,11 +13,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = googleAuth;
|
||||
const encrypt_1 = __importDefault(require("../../package-shared/functions/dsql/encrypt"));
|
||||
const grab_host_names_1 = __importDefault(require("../../package-shared/utils/grab-host-names"));
|
||||
const api_google_login_1 = __importDefault(require("../../package-shared/functions/api/users/social/api-google-login"));
|
||||
const get_auth_cookie_names_1 = __importDefault(require("../../package-shared/functions/backend/cookies/get-auth-cookie-names"));
|
||||
const write_auth_files_1 = require("../../package-shared/functions/backend/auth/write-auth-files");
|
||||
const encrypt_1 = __importDefault(require("../../../functions/dsql/encrypt"));
|
||||
const grab_host_names_1 = __importDefault(require("../../../utils/grab-host-names"));
|
||||
const api_google_login_1 = __importDefault(require("../../../functions/api/users/social/api-google-login"));
|
||||
const get_auth_cookie_names_1 = __importDefault(require("../../../functions/backend/cookies/get-auth-cookie-names"));
|
||||
const write_auth_files_1 = require("../../../functions/backend/auth/write-auth-files");
|
||||
/**
|
||||
* # SERVER FUNCTION: Login with google Function
|
||||
*/
|
||||
@@ -88,7 +88,7 @@ function googleAuth(_a) {
|
||||
* Make https request
|
||||
*
|
||||
* @description make a request to datasquirel.com
|
||||
* @type {{ success: boolean, user: import("../../package-shared/types").DATASQUIREL_LoggedInUser | null, msg?: string, dsqlUserId?: number } | null } - Https response object
|
||||
* @type {{ success: boolean, user: import("../../../types").DATASQUIREL_LoggedInUser | null, msg?: string, dsqlUserId?: number } | null } - Https response object
|
||||
*/
|
||||
httpResponse = yield new Promise((resolve, reject) => {
|
||||
const reqPayload = JSON.stringify({
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { UpdateUserFunctionReturn } from "../package-shared/types";
|
||||
import { UpdateUserFunctionReturn } from "../../types";
|
||||
type Param = {
|
||||
key?: string;
|
||||
database?: string;
|
||||
+3
-3
@@ -15,8 +15,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = updateUser;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const grab_host_names_1 = __importDefault(require("../package-shared/utils/grab-host-names"));
|
||||
const api_update_user_1 = __importDefault(require("../package-shared/functions/api/users/api-update-user"));
|
||||
const grab_host_names_1 = __importDefault(require("../../utils/grab-host-names"));
|
||||
const api_update_user_1 = __importDefault(require("../../functions/api/users/api-update-user"));
|
||||
/**
|
||||
* # Update User
|
||||
*/
|
||||
@@ -35,7 +35,7 @@ function updateUser(_a) {
|
||||
(DSQL_DB_PASSWORD === null || DSQL_DB_PASSWORD === void 0 ? void 0 : DSQL_DB_PASSWORD.match(/./)) &&
|
||||
(DSQL_DB_NAME === null || DSQL_DB_NAME === void 0 ? void 0 : DSQL_DB_NAME.match(/./)) &&
|
||||
global.DSQL_USE_LOCAL) {
|
||||
/** @type {import("../package-shared/types").DSQL_DatabaseSchemaType | undefined} */
|
||||
/** @type {import("../../types").DSQL_DatabaseSchemaType | undefined} */
|
||||
let dbSchema;
|
||||
try {
|
||||
const localDbSchemaPath = path_1.default.resolve(process.cwd(), "dsql.schema.json");
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import http from "http";
|
||||
import { AuthenticatedUser } from "../package-shared/types";
|
||||
import { AuthenticatedUser } from "../../types";
|
||||
type Param = {
|
||||
request?: http.IncomingMessage & {
|
||||
[s: string]: any;
|
||||
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = userAuth;
|
||||
const decrypt_1 = __importDefault(require("../package-shared/functions/dsql/decrypt"));
|
||||
const get_auth_cookie_names_1 = __importDefault(require("../package-shared/functions/backend/cookies/get-auth-cookie-names"));
|
||||
const write_auth_files_1 = require("../package-shared/functions/backend/auth/write-auth-files");
|
||||
const parseCookies_1 = __importDefault(require("../package-shared/utils/backend/parseCookies"));
|
||||
const get_csrf_header_name_1 = __importDefault(require("../utils/get-csrf-header-name"));
|
||||
const grab_host_names_1 = __importDefault(require("../package-shared/utils/grab-host-names"));
|
||||
const decrypt_1 = __importDefault(require("../../functions/dsql/decrypt"));
|
||||
const get_auth_cookie_names_1 = __importDefault(require("../../functions/backend/cookies/get-auth-cookie-names"));
|
||||
const write_auth_files_1 = require("../../functions/backend/auth/write-auth-files");
|
||||
const parseCookies_1 = __importDefault(require("../../utils/backend/parseCookies"));
|
||||
const get_csrf_header_name_1 = __importDefault(require("../../actions/get-csrf-header-name"));
|
||||
const grab_host_names_1 = __importDefault(require("../../utils/grab-host-names"));
|
||||
const minuteInMilliseconds = 60000;
|
||||
const hourInMilliseconds = minuteInMilliseconds * 60;
|
||||
const dayInMilliseconds = hourInMilliseconds * 24;
|
||||
@@ -76,7 +76,7 @@ function userAuth({ request, req, encryptionKey, encryptionSalt, level, database
|
||||
*
|
||||
* @description Grab the payload
|
||||
*/
|
||||
/** @type {import("../package-shared/types").DATASQUIREL_LoggedInUser} */
|
||||
/** @type {import("../../types").DATASQUIREL_LoggedInUser} */
|
||||
let userObject = JSON.parse(userPayloadJSON);
|
||||
if (debug) {
|
||||
console.log("userAuth:userObject:", userObject);
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import http from "http";
|
||||
import { SendOneTimeCodeEmailResponse } from "../package-shared/types";
|
||||
import { SendOneTimeCodeEmailResponse } from "../../types";
|
||||
type Param = {
|
||||
request?: http.IncomingMessage & {
|
||||
[s: string]: any;
|
||||
+4
-4
@@ -13,10 +13,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = validateTempEmailCode;
|
||||
const get_auth_cookie_names_1 = __importDefault(require("../package-shared/functions/backend/cookies/get-auth-cookie-names"));
|
||||
const parseCookies_1 = __importDefault(require("../package-shared/utils/backend/parseCookies"));
|
||||
const decrypt_1 = __importDefault(require("../package-shared/functions/dsql/decrypt"));
|
||||
const ejson_1 = __importDefault(require("../package-shared/utils/ejson"));
|
||||
const get_auth_cookie_names_1 = __importDefault(require("../../functions/backend/cookies/get-auth-cookie-names"));
|
||||
const parseCookies_1 = __importDefault(require("../../utils/backend/parseCookies"));
|
||||
const decrypt_1 = __importDefault(require("../../functions/dsql/decrypt"));
|
||||
const ejson_1 = __importDefault(require("../../utils/ejson"));
|
||||
/**
|
||||
* # Verify the temp email code sent to the user's email address
|
||||
*/
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { DATASQUIREL_LoggedInUser } from "../package-shared/types";
|
||||
import { DATASQUIREL_LoggedInUser } from "../../types";
|
||||
type Param = {
|
||||
token: string;
|
||||
encryptionKey: string;
|
||||
+1
-1
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = validateToken;
|
||||
const decrypt_1 = __importDefault(require("../package-shared/functions/dsql/decrypt"));
|
||||
const decrypt_1 = __importDefault(require("../../functions/dsql/decrypt"));
|
||||
/**
|
||||
* Validate Token
|
||||
* ======================================
|
||||
@@ -29,7 +29,6 @@ function apiPost(_a) {
|
||||
((_b = query === null || query === void 0 ? void 0 : query.action) === null || _b === void 0 ? void 0 : _b.match(/^create |^alter |^drop /i))) {
|
||||
return { success: false, msg: "Wrong Input" };
|
||||
}
|
||||
/** @type {any} */
|
||||
let results;
|
||||
/**
|
||||
* Create new user folder and file
|
||||
|
||||
@@ -35,7 +35,6 @@ function apiDeleteUser(_a) {
|
||||
}
|
||||
const deleteUser = yield (0, deleteDbEntry_1.default)({
|
||||
dbContext: "Dsql User",
|
||||
paradigm: "Full Access",
|
||||
dbFullName,
|
||||
tableName: "users",
|
||||
identifierColumnName: "id",
|
||||
|
||||
@@ -68,7 +68,6 @@ function apiUpdateUser(_a) {
|
||||
})();
|
||||
const updateUser = yield (0, updateDbEntry_1.default)({
|
||||
dbContext: "Dsql User",
|
||||
paradigm: "Full Access",
|
||||
dbFullName,
|
||||
tableName: "users",
|
||||
identifierColumnName: "id",
|
||||
|
||||
+5
-1
@@ -16,6 +16,7 @@ exports.default = dbHandler;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const serverError_1 = __importDefault(require("./serverError"));
|
||||
const grab_dsql_connection_1 = __importDefault(require("../../utils/grab-dsql-connection"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
/**
|
||||
* # Main DB Handler Function
|
||||
*/
|
||||
@@ -44,7 +45,10 @@ function dbHandler(...args) {
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
fs_1.default.appendFileSync("./.tmp/dbErrorLogs.txt", JSON.stringify(error, null, 4) + "\n" + Date() + "\n\n\n", "utf8");
|
||||
const tmpFolder = path_1.default.resolve(process.cwd(), "./.tmp");
|
||||
if (!fs_1.default.existsSync(tmpFolder))
|
||||
fs_1.default.mkdirSync(tmpFolder, { recursive: true });
|
||||
fs_1.default.appendFileSync(path_1.default.resolve(tmpFolder, "./dbErrorLogs.txt"), JSON.stringify(error, null, 4) + "\n" + Date() + "\n\n\n", "utf8");
|
||||
results = null;
|
||||
(0, serverError_1.default)({
|
||||
component: "dbHandler",
|
||||
|
||||
+4
-1
@@ -39,7 +39,10 @@ function dbHandler(_a) {
|
||||
console.log("ERROR in dbHandler =>", error.message);
|
||||
console.log(error);
|
||||
console.log(CONNECTION.config());
|
||||
fs_1.default.appendFileSync(path_1.default.resolve(__dirname, "../.tmp/dbErrorLogs.txt"), JSON.stringify(error, null, 4) + "\n" + Date() + "\n\n\n", "utf8");
|
||||
const tmpFolder = path_1.default.resolve(process.cwd(), "./.tmp");
|
||||
if (!fs_1.default.existsSync(tmpFolder))
|
||||
fs_1.default.mkdirSync(tmpFolder, { recursive: true });
|
||||
fs_1.default.appendFileSync(path_1.default.resolve(tmpFolder, "./dbErrorLogs.txt"), JSON.stringify(error, null, 4) + "\n" + Date() + "\n\n\n", "utf8");
|
||||
results = null;
|
||||
}
|
||||
finally {
|
||||
|
||||
Vendored
+29
-9
@@ -34,7 +34,29 @@ export interface DSQL_ChildrenTablesType {
|
||||
tableName: string;
|
||||
tableNameFull?: string;
|
||||
}
|
||||
export interface DSQL_FieldSchemaType {
|
||||
export declare const TextFieldTypesArray: readonly [{
|
||||
readonly title: "Plain Text";
|
||||
readonly value: "plain";
|
||||
}, {
|
||||
readonly title: "Rich Text";
|
||||
readonly value: "richText";
|
||||
}, {
|
||||
readonly title: "JSON";
|
||||
readonly value: "json";
|
||||
}, {
|
||||
readonly title: "YAML";
|
||||
readonly value: "yaml";
|
||||
}, {
|
||||
readonly title: "HTML";
|
||||
readonly value: "html";
|
||||
}, {
|
||||
readonly title: "CSS";
|
||||
readonly value: "css";
|
||||
}, {
|
||||
readonly title: "Javascript";
|
||||
readonly value: "javascript";
|
||||
}];
|
||||
export type DSQL_FieldSchemaType = {
|
||||
fieldName?: string;
|
||||
originName?: string;
|
||||
updatedField?: boolean;
|
||||
@@ -47,13 +69,6 @@ export interface DSQL_FieldSchemaType {
|
||||
defaultValue?: string | number;
|
||||
defaultValueLiteral?: string;
|
||||
foreignKey?: DSQL_ForeignKeyType;
|
||||
richText?: boolean;
|
||||
json?: boolean;
|
||||
yaml?: boolean;
|
||||
html?: boolean;
|
||||
css?: boolean;
|
||||
javascript?: boolean;
|
||||
shell?: boolean;
|
||||
newTempField?: boolean;
|
||||
defaultField?: boolean;
|
||||
plainText?: boolean;
|
||||
@@ -65,7 +80,11 @@ export interface DSQL_FieldSchemaType {
|
||||
onDelete?: string;
|
||||
onDeleteLiteral?: string;
|
||||
cssFiles?: string[];
|
||||
}
|
||||
integerLength?: string | number;
|
||||
decimals?: string | number;
|
||||
} & {
|
||||
[key in (typeof TextFieldTypesArray)[number]["value"]]?: boolean;
|
||||
};
|
||||
export interface DSQL_ForeignKeyType {
|
||||
foreignKeyName?: string;
|
||||
destinationTableName?: string;
|
||||
@@ -784,6 +803,7 @@ export interface MYSQL_user_database_tables_table_def {
|
||||
table_slug?: string;
|
||||
table_description?: string;
|
||||
child_table?: number;
|
||||
active_data?: 0 | 1;
|
||||
child_table_parent_database?: string;
|
||||
child_table_parent_table?: string;
|
||||
date_created?: string;
|
||||
|
||||
Vendored
+10
-1
@@ -1,5 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ServerQueryEqualities = exports.ServerQueryOperators = void 0;
|
||||
exports.ServerQueryEqualities = exports.ServerQueryOperators = exports.TextFieldTypesArray = void 0;
|
||||
exports.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" },
|
||||
];
|
||||
exports.ServerQueryOperators = ["AND", "OR"];
|
||||
exports.ServerQueryEqualities = ["EQUAL", "LIKE", "NOT EQUAL"];
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import sqlGenerator from "../../functions/dsql/sql/sql-generator";
|
||||
import { PostReturn, ServerQueryParam, ServerQueryQueryObject } from "../../types";
|
||||
export declare const DsqlCrudActions: readonly ["insert", "update", "delete", "get"];
|
||||
export type CrudQueryObject<T extends object = {
|
||||
[key: string]: any;
|
||||
}> = ServerQueryParam & {
|
||||
query: ServerQueryQueryObject<T>;
|
||||
};
|
||||
export type CrudParam<T extends object = {
|
||||
[key: string]: any;
|
||||
}> = {
|
||||
action: (typeof DsqlCrudActions)[number];
|
||||
table: string;
|
||||
data?: T;
|
||||
targetId?: string | number;
|
||||
query?: CrudQueryObject<T>;
|
||||
sanitize?: (data?: T) => T;
|
||||
};
|
||||
export default function dsqlCrud<T extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}>({ action, data, table, targetId, query, sanitize, }: CrudParam<T>): Promise<(PostReturn & {
|
||||
queryObject?: ReturnType<Awaited<typeof sqlGenerator>>;
|
||||
}) | null>;
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DsqlCrudActions = void 0;
|
||||
exports.default = dsqlCrud;
|
||||
const get_1 = __importDefault(require("../../actions/get"));
|
||||
const post_1 = __importDefault(require("../../actions/post"));
|
||||
const sql_generator_1 = __importDefault(require("../../functions/dsql/sql/sql-generator"));
|
||||
exports.DsqlCrudActions = ["insert", "update", "delete", "get"];
|
||||
function dsqlCrud(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ action, data, table, targetId, query, sanitize, }) {
|
||||
const finalData = sanitize ? sanitize(data) : data;
|
||||
const finalId = targetId;
|
||||
let queryObject;
|
||||
switch (action) {
|
||||
case "get":
|
||||
queryObject = (0, sql_generator_1.default)({
|
||||
tableName: table,
|
||||
genObject: query,
|
||||
});
|
||||
const GET_RES = yield (0, get_1.default)({
|
||||
query: (queryObject === null || queryObject === void 0 ? void 0 : queryObject.string) || "",
|
||||
queryValues: (queryObject === null || queryObject === void 0 ? void 0 : queryObject.values) || [],
|
||||
});
|
||||
return Object.assign(Object.assign({}, GET_RES), { queryObject });
|
||||
case "insert":
|
||||
return yield (0, post_1.default)({
|
||||
query: {
|
||||
action: "insert",
|
||||
table,
|
||||
data: finalData,
|
||||
},
|
||||
});
|
||||
case "update":
|
||||
data === null || data === void 0 ? true : delete data.id;
|
||||
return yield (0, post_1.default)({
|
||||
query: {
|
||||
action: "update",
|
||||
table,
|
||||
identifierColumnName: "id",
|
||||
identifierValue: String(finalId),
|
||||
data: finalData,
|
||||
},
|
||||
});
|
||||
case "delete":
|
||||
return yield (0, post_1.default)({
|
||||
query: {
|
||||
action: "delete",
|
||||
table,
|
||||
identifierColumnName: "id",
|
||||
identifierValue: String(finalId),
|
||||
},
|
||||
});
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import { DATASQUIREL_LoggedInUser, ServerQueryParam } from "../../types";
|
||||
export declare const DataCrudRequestMethods: readonly ["GET", "POST", "PUT", "DELETE"];
|
||||
export type APIDataCrudQuery = ServerQueryParam & {
|
||||
page?: number;
|
||||
};
|
||||
export type CRUDResponseObject<P extends any = any> = {
|
||||
success: boolean;
|
||||
payload?: P;
|
||||
msg?: string;
|
||||
error?: string;
|
||||
};
|
||||
export type ApiDataCrudParam<T extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}> = {
|
||||
method: (typeof DataCrudRequestMethods)[number];
|
||||
body?: T;
|
||||
query?: string | T;
|
||||
tableName: string;
|
||||
addUser?: {
|
||||
field: string;
|
||||
};
|
||||
user?: DATASQUIREL_LoggedInUser;
|
||||
extraData?: T;
|
||||
transform?: ({ data, existingData, user, }: {
|
||||
user?: DATASQUIREL_LoggedInUser;
|
||||
data: T;
|
||||
existingData?: T;
|
||||
reqMethod: (typeof DataCrudRequestMethods)[number];
|
||||
}) => Promise<T>;
|
||||
existingData?: T;
|
||||
};
|
||||
export default function dsqlMethodCrud<T extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}, P extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}>({ method, tableName, addUser, user, extraData, transform, existingData, body, query, }: ApiDataCrudParam<T>): Promise<CRUDResponseObject<P>>;
|
||||
@@ -0,0 +1,122 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DataCrudRequestMethods = void 0;
|
||||
exports.default = dsqlMethodCrud;
|
||||
const ejson_1 = __importDefault(require("../ejson"));
|
||||
const crud_1 = __importDefault(require("./crud"));
|
||||
exports.DataCrudRequestMethods = ["GET", "POST", "PUT", "DELETE"];
|
||||
function dsqlMethodCrud(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ method, tableName, addUser, user, extraData, transform, existingData, body, query, }) {
|
||||
let result = {
|
||||
success: false,
|
||||
};
|
||||
try {
|
||||
let finalBody = body;
|
||||
let finalQuery = query;
|
||||
Object.keys(finalQuery).forEach((key) => {
|
||||
const value = finalQuery[key];
|
||||
if (typeof value == "string" && value.match(/^\{|^\[/)) {
|
||||
finalQuery[key] = ejson_1.default.stringify(value);
|
||||
}
|
||||
if (value == "true") {
|
||||
finalQuery[key] = true;
|
||||
}
|
||||
if (value == "false") {
|
||||
finalQuery[key] = false;
|
||||
}
|
||||
});
|
||||
const LIMIT = finalQuery.limit || 10;
|
||||
const PAGE = finalQuery.page || 1;
|
||||
const OFFSET = (PAGE - 1) * LIMIT;
|
||||
let finalData = Object.assign(Object.assign({}, finalBody.data), extraData);
|
||||
if (user && addUser) {
|
||||
finalData = Object.assign(Object.assign({}, finalData), { [addUser.field]: String(user.id) });
|
||||
}
|
||||
if (transform) {
|
||||
finalData = yield transform({
|
||||
data: finalData,
|
||||
existingData: existingData,
|
||||
user,
|
||||
reqMethod: method,
|
||||
});
|
||||
}
|
||||
switch (method) {
|
||||
case "GET":
|
||||
const GET_RESULT = yield (0, crud_1.default)({
|
||||
action: "get",
|
||||
table: tableName,
|
||||
query: Object.assign(Object.assign({}, finalQuery), { query: Object.assign(Object.assign({}, finalQuery.query), { user_id: user
|
||||
? {
|
||||
value: String(user.id),
|
||||
}
|
||||
: undefined }), limit: LIMIT, offset: OFFSET || undefined }),
|
||||
});
|
||||
result = {
|
||||
success: Boolean(GET_RESULT === null || GET_RESULT === void 0 ? void 0 : GET_RESULT.success),
|
||||
payload: GET_RESULT === null || GET_RESULT === void 0 ? void 0 : GET_RESULT.payload,
|
||||
msg: GET_RESULT === null || GET_RESULT === void 0 ? void 0 : GET_RESULT.msg,
|
||||
error: GET_RESULT === null || GET_RESULT === void 0 ? void 0 : GET_RESULT.error,
|
||||
};
|
||||
break;
|
||||
case "POST":
|
||||
const POST_RESULT = yield (0, crud_1.default)({
|
||||
action: "insert",
|
||||
table: tableName,
|
||||
data: finalData,
|
||||
});
|
||||
result = {
|
||||
success: Boolean(POST_RESULT === null || POST_RESULT === void 0 ? void 0 : POST_RESULT.success),
|
||||
payload: POST_RESULT === null || POST_RESULT === void 0 ? void 0 : POST_RESULT.payload,
|
||||
msg: POST_RESULT === null || POST_RESULT === void 0 ? void 0 : POST_RESULT.msg,
|
||||
error: POST_RESULT === null || POST_RESULT === void 0 ? void 0 : POST_RESULT.error,
|
||||
};
|
||||
break;
|
||||
case "PUT":
|
||||
const PUT_RESULT = yield (0, crud_1.default)({
|
||||
action: "update",
|
||||
table: tableName,
|
||||
data: finalData,
|
||||
targetId: finalBody.data.id,
|
||||
});
|
||||
result = {
|
||||
success: Boolean(PUT_RESULT === null || PUT_RESULT === void 0 ? void 0 : PUT_RESULT.success),
|
||||
payload: PUT_RESULT === null || PUT_RESULT === void 0 ? void 0 : PUT_RESULT.payload,
|
||||
msg: PUT_RESULT === null || PUT_RESULT === void 0 ? void 0 : PUT_RESULT.msg,
|
||||
error: PUT_RESULT === null || PUT_RESULT === void 0 ? void 0 : PUT_RESULT.error,
|
||||
};
|
||||
break;
|
||||
case "DELETE":
|
||||
const DELETE_RESULT = yield (0, crud_1.default)({
|
||||
action: "delete",
|
||||
table: tableName,
|
||||
targetId: finalBody.data.id,
|
||||
});
|
||||
result = {
|
||||
success: Boolean(DELETE_RESULT === null || DELETE_RESULT === void 0 ? void 0 : DELETE_RESULT.success),
|
||||
payload: DELETE_RESULT === null || DELETE_RESULT === void 0 ? void 0 : DELETE_RESULT.payload,
|
||||
msg: DELETE_RESULT === null || DELETE_RESULT === void 0 ? void 0 : DELETE_RESULT.msg,
|
||||
error: DELETE_RESULT === null || DELETE_RESULT === void 0 ? void 0 : DELETE_RESULT.error,
|
||||
};
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (error) {
|
||||
return result;
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user