This commit is contained in:
Benjamin Toby 2024-12-12 07:08:28 +01:00
parent da6b0b43c9
commit 83a8b84890
5 changed files with 109 additions and 19 deletions

12
client/index.d.ts vendored
View File

@ -16,6 +16,13 @@ export namespace fetch {
export { fetchApi };
export { clientFetch };
}
export namespace utils {
export { serializeQuery };
export { serializeCookies };
export { EJSON };
export { numberfy };
export { slugify };
}
import imageInputToBase64 = require("./media/imageInputToBase64");
import imageInputFileToBase64 = require("./media/imageInputFileToBase64");
import inputFileToBase64 = require("./media/inputFileToBase64");
@ -24,3 +31,8 @@ import getGithubAccessToken = require("./auth/github/getAccessToken");
import logout = require("./auth/logout");
import { fetchApi } from "./fetch";
import clientFetch = require("./fetch");
import serializeQuery = require("../package-shared/utils/serialize-query");
import serializeCookies = require("../package-shared/utils/serialize-cookies");
import { EJSON } from "../package-shared/utils";
import { numberfy } from "../package-shared/utils";
import { slugify } from "../package-shared/utils";

View File

@ -11,6 +11,11 @@ const getGithubAccessToken = require("./auth/github/getAccessToken");
const logout = require("./auth/logout");
const { fetchApi } = require("./fetch");
const clientFetch = require("./fetch");
const serializeQuery = require("../package-shared/utils/serialize-query");
const serializeCookies = require("../package-shared/utils/serialize-cookies");
const { EJSON } = require("../package-shared/utils");
const { numberfy } = require("../package-shared/utils");
const { slugify } = require("../package-shared/utils");
////////////////////////////////////////
////////////////////////////////////////
@ -38,6 +43,14 @@ const auth = {
logout: logout,
};
const utils = {
serializeQuery,
serializeCookies,
EJSON,
numberfy,
slugify,
};
/**
* Fetch
*/
@ -49,6 +62,6 @@ const fetch = {
/**
* Main Export
*/
const datasquirelClient = { media, auth, fetch };
const datasquirelClient = { media, auth, fetch, utils };
module.exports = datasquirelClient;

81
index.d.ts vendored
View File

@ -1,12 +1,71 @@
export namespace dsqlUtils {
export { serializeQuery };
export { serializeCookies };
export { EJSON };
export { numberfy };
export { slugify };
import get = require("./utils/get");
import post = require("./utils/post");
export namespace media {
export { uploadImage };
export { uploadFile };
export { deleteFile };
}
import serializeQuery = require("./package-shared/utils/serialize-query");
import serializeCookies = require("./package-shared/utils/serialize-cookies");
import EJSON = require("./package-shared/utils/ejson");
import numberfy = require("./package-shared/utils/numberfy");
import slugify = require("./package-shared/utils/slugify");
export namespace user {
export { createUser };
export let deleteUser: typeof import("./users/delete-user");
export { loginUser };
export { sendEmailCode };
export { logoutUser };
export { userAuth };
export { reAuthUser };
export { updateUser };
export { getUser };
export { getToken };
export { validateToken };
export let validateTempEmailCode: typeof import("./users/validate-temp-email-code");
export namespace social {
export { loginWithGoogle };
export { loginWithGithub };
}
}
import getSchema = require("./utils/get-schema");
import datasquirelClient = require("./client");
export namespace sql {
export { sqlGenerator };
export { sqlInsertGenerator };
export { sqlDeleteGenerator };
export { trimSql as trim };
}
import uploadImage = require("./utils/upload-image");
import uploadFile = require("./utils/upload-file");
import deleteFile = require("./utils/delete-file");
import createUser = require("./users/add-user");
import loginUser = require("./users/login-user");
import sendEmailCode = require("./users/send-email-code");
import logoutUser = require("./users/logout-user");
import userAuth = require("./users/user-auth");
import reAuthUser = require("./users/reauth-user");
import updateUser = require("./users/update-user");
import getUser = require("./users/get-user");
import getToken = require("./users/get-token");
import validateToken = require("./users/validate-token");
import loginWithGoogle = require("./users/social/google-auth");
import loginWithGithub = require("./users/social/github-auth");
import sqlGenerator = require("./package-shared/functions/dsql/sql/sql-generator");
import sqlInsertGenerator = require("./package-shared/functions/dsql/sql/sql-insert-generator");
import sqlDeleteGenerator = require("./package-shared/functions/dsql/sql/sql-delete-generator");
import trimSql = require("./package-shared/utils/trim-sql");
export declare namespace utils {
namespace crypto {
let encrypt: ({ data, encryptionKey, encryptionSalt }: {
data: string;
encryptionKey?: string;
encryptionSalt?: string;
}) => string | null;
let decrypt: ({ encryptedString, encryptionKey, encryptionSalt }: {
encryptedString: string;
encryptionKey?: string;
encryptionSalt?: string;
}) => string;
let hash: ({ password, encryptionKey }: {
password: string;
encryptionKey?: string;
}) => string;
}
}
export { get, post, getSchema, datasquirelClient as client };

View File

@ -103,10 +103,3 @@ const datasquirel = {
};
module.exports = datasquirel;
exports.dsqlUtils = {
serializeQuery,
serializeCookies,
EJSON,
numberfy,
slugify,
};

13
package-shared/utils/index.d.ts vendored Normal file
View File

@ -0,0 +1,13 @@
export const numberfy: (num: any, decimals?: number) => number;
export const slugify: (str: string) => string;
export const serializeCookies: typeof import("./serialize-cookies");
export const serializeQuery: typeof import("./serialize-query");
export const trimSql: typeof import("./trim-sql");
export const EJSON: {
parse: (string: string | null | number, reviver?: (this: any, key: string, value: any) => any) => {
[x: string]: any;
} | {
[x: string]: any;
}[] | undefined;
stringify: (value: any, replacer?: ((this: any, key: string, value: any) => any) | null, space?: string | number) => string | undefined;
};