From 6be3ede31aac00dc87ccba03eb1d9b1d3bc487b8 Mon Sep 17 00:00:00 2001 From: Benjamin Toby Date: Thu, 12 Dec 2024 14:43:25 +0100 Subject: [PATCH] Updates --- .../api/users/social/api-github-login.d.ts | 2 +- .../api/users/social/api-github-login.js | 2 +- package-shared/types/index.d.ts | 5 +---- package-shared/types/index.ts | 8 +------- package-shared/utils/serialize-query.d.ts | 2 +- package-shared/utils/serialize-query.js | 16 +++++++++++++++- package.json | 2 +- 7 files changed, 21 insertions(+), 16 deletions(-) diff --git a/package-shared/functions/api/users/social/api-github-login.d.ts b/package-shared/functions/api/users/social/api-github-login.d.ts index b63c820..13ff3ea 100644 --- a/package-shared/functions/api/users/social/api-github-login.d.ts +++ b/package-shared/functions/api/users/social/api-github-login.d.ts @@ -7,5 +7,5 @@ declare function _exports({ code, clientId, clientSecret, database, additionalFi res?: any; email?: string; userId?: string | number; -}): Promise; +}): Promise; export = _exports; diff --git a/package-shared/functions/api/users/social/api-github-login.js b/package-shared/functions/api/users/social/api-github-login.js index e7843e1..0254848 100644 --- a/package-shared/functions/api/users/social/api-github-login.js +++ b/package-shared/functions/api/users/social/api-github-login.js @@ -16,7 +16,7 @@ const camelJoinedtoCamelSpace = require("../../../../utils/camelJoinedtoCamelSpa * @param {string} [param.email] * @param {string | number} [param.userId] * - * @returns {Promise} + * @returns {Promise} */ module.exports = async function apiGithubLogin({ code, diff --git a/package-shared/types/index.d.ts b/package-shared/types/index.d.ts index 38e6726..9b91c91 100644 --- a/package-shared/types/index.d.ts +++ b/package-shared/types/index.d.ts @@ -159,10 +159,7 @@ export interface GetReqQueryObject { queryValues?: string; tableName?: string; } -export type SerializeQueryFnType = (param0: SerializeQueryParams) => string; -export interface SerializeQueryParams { - query: any; -} +export type SerializeQueryFnType = (query: any) => string; export type DATASQUIREL_LoggedInUser = { id: number; uuid?: string; diff --git a/package-shared/types/index.ts b/package-shared/types/index.ts index 3c638f8..6856e02 100644 --- a/package-shared/types/index.ts +++ b/package-shared/types/index.ts @@ -188,13 +188,7 @@ export interface GetReqQueryObject { tableName?: string; } -export type SerializeQueryFnType = (param0: SerializeQueryParams) => string; - -export interface SerializeQueryParams { - query: any; -} - -// @ts-check +export type SerializeQueryFnType = (query: any) => string; export type DATASQUIREL_LoggedInUser = { id: number; diff --git a/package-shared/utils/serialize-query.d.ts b/package-shared/utils/serialize-query.d.ts index a9d19db..3cfd046 100644 --- a/package-shared/utils/serialize-query.d.ts +++ b/package-shared/utils/serialize-query.d.ts @@ -1,2 +1,2 @@ export = serializeQuery; -declare function serializeQuery(param0: import("../types").SerializeQueryParams): string; +declare function serializeQuery(query: any): string; diff --git a/package-shared/utils/serialize-query.js b/package-shared/utils/serialize-query.js index d2a8f47..9a8a497 100644 --- a/package-shared/utils/serialize-query.js +++ b/package-shared/utils/serialize-query.js @@ -3,8 +3,22 @@ const EJSON = require("./ejson"); /** @type {import("../types").SerializeQueryFnType} */ -function serializeQuery({ query }) { +function serializeQuery(query) { let str = "?"; + + if (typeof query !== "object") { + console.log("Invalid Query type"); + return str; + } + if (Array.isArray(query)) { + console.log("Query is an Array. This is invalid."); + return str; + } + if (!query) { + console.log("No Query provided."); + return str; + } + const keys = Object.keys(query); /** @type {string[]} */ diff --git a/package.json b/package.json index f309a8d..5751917 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@moduletrace/datasquirel", - "version": "3.0.8", + "version": "3.0.9", "description": "Cloud-based SQL data management tool", "main": "index.js", "bin": {