Updates
This commit is contained in:
Vendored
+9
-4
@@ -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) {
|
||||
|
||||
Vendored
+4
@@ -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<T extends {
|
||||
csrfValue?: string;
|
||||
csrfKey?: string;
|
||||
fetchOptions?: RequestInit;
|
||||
query?: T;
|
||||
};
|
||||
export type AddDbEntryParam<T extends {
|
||||
[k: string]: any;
|
||||
|
||||
Reference in New Issue
Block a user