diff --git a/client/fetch/index.ts b/client/fetch/index.ts index 1c4a1c6..ba94498 100644 --- a/client/fetch/index.ts +++ b/client/fetch/index.ts @@ -3,13 +3,14 @@ import { DSQLClientFetchHeader, DSQLFetchApiOptions, } from "../../package-shared/types"; +import serializeQuery from "../../package-shared/utils/serialize-query"; /** * # Fetch API */ export default async function fetchApi< T extends { [k: string]: any } = { [k: string]: any }, - R extends any = any + R extends any = any, >(url: string, options?: DSQLFetchApiOptions): Promise { let data; @@ -21,13 +22,19 @@ export default async function fetchApi< finalHeaders[options.csrfKey] = options.csrfValue; } + let finalURL = url; + + if (options?.query) { + finalURL += serializeQuery(options.query); + } + if (typeof options === "string") { try { let fetchData; switch (options) { case "post": - fetchData = await fetch(url, { + fetchData = await fetch(finalURL, { method: options, headers: finalHeaders, } as RequestInit); @@ -35,7 +42,7 @@ export default async function fetchApi< break; default: - fetchData = await fetch(url); + fetchData = await fetch(finalURL); data = fetchData.json(); break; } @@ -60,7 +67,7 @@ export default async function fetchApi< fetchOptions = _.merge(fetchOptions, options.fetchOptions); - fetchData = await fetch(url, fetchOptions); + fetchData = await fetch(finalURL, fetchOptions); data = fetchData.json(); } catch (error: any) { console.log("FetchAPI error #2:", error.message); @@ -68,7 +75,7 @@ export default async function fetchApi< } } else { try { - let fetchData = await fetch(url); + let fetchData = await fetch(finalURL); data = await fetchData.json(); } catch (error: any) { console.log("FetchAPI error #3:", error.message); diff --git a/dist/client/fetch/index.js b/dist/client/fetch/index.js index 50ced04..e6705cd 100644 --- a/dist/client/fetch/index.js +++ b/dist/client/fetch/index.js @@ -14,6 +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 serialize_query_1 = __importDefault(require("../../package-shared/utils/serialize-query")); /** * # Fetch API */ @@ -26,19 +27,23 @@ function fetchApi(url, options) { if ((options === null || options === void 0 ? void 0 : options.csrfKey) && options.csrfValue) { finalHeaders[options.csrfKey] = options.csrfValue; } + let finalURL = url; + if (options === null || options === void 0 ? void 0 : options.query) { + finalURL += (0, serialize_query_1.default)(options.query); + } if (typeof options === "string") { try { let fetchData; switch (options) { case "post": - fetchData = yield fetch(url, { + fetchData = yield fetch(finalURL, { method: options, headers: finalHeaders, }); data = fetchData.json(); break; default: - fetchData = yield fetch(url); + fetchData = yield fetch(finalURL); data = fetchData.json(); break; } @@ -60,7 +65,7 @@ function fetchApi(url, options) { } fetchOptions.headers = lodash_1.default.merge(finalHeaders, options.headers || {}); fetchOptions = lodash_1.default.merge(fetchOptions, options.fetchOptions); - fetchData = yield fetch(url, fetchOptions); + fetchData = yield fetch(finalURL, fetchOptions); data = fetchData.json(); } catch (error) { @@ -70,7 +75,7 @@ function fetchApi(url, options) { } else { try { - let fetchData = yield fetch(url); + let fetchData = yield fetch(finalURL); data = yield fetchData.json(); } catch (error) { diff --git a/dist/package-shared/types/index.d.ts b/dist/package-shared/types/index.d.ts index 3f8b6f3..ec4fb7b 100644 --- a/dist/package-shared/types/index.d.ts +++ b/dist/package-shared/types/index.d.ts @@ -60,6 +60,7 @@ export interface DSQL_TableSchemaType { tableNameOld?: string; childTableDbId?: string | number; collation?: (typeof MariaDBCollations)[number]; + isVector?: boolean; } export interface DSQL_ChildrenTablesType { tableId?: string | number; @@ -127,6 +128,8 @@ export type DSQL_FieldSchemaType = { moving?: boolean; code?: boolean; options?: string[]; + isVector?: boolean; + vectorSize?: number; } & { [key in (typeof TextFieldTypesArray)[number]["value"]]?: boolean; }; @@ -2381,6 +2384,7 @@ export type DSQLFetchApiOptions