Updates
This commit is contained in:
Vendored
+1
-1
@@ -7,4 +7,4 @@ export default function clientCrudFetch<T extends {
|
||||
[k: string]: any;
|
||||
} = {
|
||||
[k: string]: any;
|
||||
}>({ table, basePath, body, query, targetId, method, apiOrigin, }: ClientCrudFetchParams<T, P>): Promise<APIResponseObject<PostInsertReturn | R[]>>;
|
||||
}>({ table, basePath, body, query, targetId, method, apiOrigin, headers, }: ClientCrudFetchParams<T, P>): Promise<APIResponseObject<PostInsertReturn | R[]>>;
|
||||
|
||||
Vendored
+2
-1
@@ -17,7 +17,7 @@ const path_1 = __importDefault(require("path"));
|
||||
const serialize_query_1 = __importDefault(require("../../package-shared/utils/serialize-query"));
|
||||
const fetch_1 = __importDefault(require("../fetch"));
|
||||
function clientCrudFetch(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ table, basePath, body, query, targetId, method = "GET", apiOrigin, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ table, basePath, body, query, targetId, method = "GET", apiOrigin, headers, }) {
|
||||
try {
|
||||
let pathname = basePath || ``;
|
||||
pathname = path_1.default.join(pathname, String(table));
|
||||
@@ -33,6 +33,7 @@ function clientCrudFetch(_a) {
|
||||
const res = yield (0, fetch_1.default)(pathname, {
|
||||
method,
|
||||
body,
|
||||
headers,
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
Vendored
+3
-10
@@ -1,3 +1,4 @@
|
||||
import { DSQLClientFetchHeader } from "../../package-shared/types";
|
||||
type FetchApiOptions<T extends {
|
||||
[k: string]: any;
|
||||
} = {
|
||||
@@ -5,10 +6,7 @@ type FetchApiOptions<T extends {
|
||||
}> = {
|
||||
method: "POST" | "GET" | "DELETE" | "PUT" | "PATCH" | "post" | "get" | "delete" | "put" | "patch";
|
||||
body?: T | string;
|
||||
headers?: FetchHeader;
|
||||
};
|
||||
type FetchHeader = HeadersInit & {
|
||||
[key: string]: string | null;
|
||||
headers?: DSQLClientFetchHeader;
|
||||
};
|
||||
export type FetchApiReturn = {
|
||||
success: boolean;
|
||||
@@ -27,10 +25,5 @@ export default function fetchApi<T extends {
|
||||
/**
|
||||
* Key to use to grab local Storage csrf value.
|
||||
*/
|
||||
localStorageCSRFKey?: string,
|
||||
/**
|
||||
* Key with which to set the request header csrf
|
||||
* value
|
||||
*/
|
||||
csrfHeaderKey?: string): Promise<R>;
|
||||
localStorageCSRFKey?: string): Promise<R>;
|
||||
export {};
|
||||
|
||||
Vendored
+1
-6
@@ -21,12 +21,7 @@ function fetchApi(url, options, csrf,
|
||||
/**
|
||||
* Key to use to grab local Storage csrf value.
|
||||
*/
|
||||
localStorageCSRFKey,
|
||||
/**
|
||||
* Key with which to set the request header csrf
|
||||
* value
|
||||
*/
|
||||
csrfHeaderKey) {
|
||||
localStorageCSRFKey) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let data;
|
||||
const csrfKey = "x-dsql-csrf-key";
|
||||
|
||||
Vendored
+3
-3
@@ -792,12 +792,12 @@ export type FetchApiFn = (url: string, options?: FetchApiOptions, csrf?: boolean
|
||||
export type FetchApiOptions = RequestInit & {
|
||||
method: (typeof DataCrudRequestMethods)[number] | (typeof DataCrudRequestMethodsLowerCase)[number];
|
||||
body?: object | string;
|
||||
headers?: FetchHeader;
|
||||
headers?: DSQLClientFetchHeader;
|
||||
query?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
};
|
||||
type FetchHeader = HeadersInit & {
|
||||
export type DSQLClientFetchHeader = HeadersInit & {
|
||||
[key: string]: any;
|
||||
};
|
||||
export type FetchApiReturn = {
|
||||
@@ -2298,5 +2298,5 @@ export type ClientCrudFetchParams<T extends {
|
||||
basePath?: string;
|
||||
targetId?: string | number | null;
|
||||
apiOrigin?: string;
|
||||
headers?: DSQLClientFetchHeader;
|
||||
};
|
||||
export {};
|
||||
|
||||
Reference in New Issue
Block a user