From 5caa604b8f77a7badb3145a085543994afa88528 Mon Sep 17 00:00:00 2001 From: Benjamin Toby Date: Fri, 26 Dec 2025 12:08:45 +0100 Subject: [PATCH] Updates --- client/crud-fetch/index.ts | 2 ++ client/fetch/index.ts | 16 ++++------------ dist/client/crud-fetch/index.d.ts | 2 +- dist/client/crud-fetch/index.js | 3 ++- dist/client/fetch/index.d.ts | 13 +++---------- dist/client/fetch/index.js | 7 +------ dist/package-shared/types/index.d.ts | 6 +++--- package-shared/types/index.ts | 5 +++-- package.json | 2 +- 9 files changed, 20 insertions(+), 36 deletions(-) diff --git a/client/crud-fetch/index.ts b/client/crud-fetch/index.ts index 950518d..0940acb 100644 --- a/client/crud-fetch/index.ts +++ b/client/crud-fetch/index.ts @@ -19,6 +19,7 @@ export default async function clientCrudFetch< targetId, method = "GET", apiOrigin, + headers, }: ClientCrudFetchParams) { try { let pathname = basePath || ``; @@ -43,6 +44,7 @@ export default async function clientCrudFetch< >(pathname, { method, body, + headers, }); return res; diff --git a/client/fetch/index.ts b/client/fetch/index.ts index 38201e9..c338ce0 100644 --- a/client/fetch/index.ts +++ b/client/fetch/index.ts @@ -1,4 +1,5 @@ import _ from "lodash"; +import { DSQLClientFetchHeader } from "../../package-shared/types"; type FetchApiOptions = { method: @@ -13,11 +14,7 @@ type FetchApiOptions = { | "put" | "patch"; body?: T | string; - headers?: FetchHeader; -}; - -type FetchHeader = HeadersInit & { - [key: string]: string | null; + headers?: DSQLClientFetchHeader; }; export type FetchApiReturn = { @@ -40,12 +37,7 @@ export default async function fetchApi< /** * Key to use to grab local Storage csrf value. */ - localStorageCSRFKey?: string, - /** - * Key with which to set the request header csrf - * value - */ - csrfHeaderKey?: string + localStorageCSRFKey?: string ): Promise { let data; @@ -54,7 +46,7 @@ export default async function fetchApi< let finalHeaders = { "Content-Type": "application/json", - } as FetchHeader; + } as DSQLClientFetchHeader; if (csrf && csrfValue) { finalHeaders[localStorageCSRFKey || csrfKey] = csrfValue; diff --git a/dist/client/crud-fetch/index.d.ts b/dist/client/crud-fetch/index.d.ts index d0b8635..a9ead9c 100644 --- a/dist/client/crud-fetch/index.d.ts +++ b/dist/client/crud-fetch/index.d.ts @@ -7,4 +7,4 @@ export default function clientCrudFetch({ table, basePath, body, query, targetId, method, apiOrigin, }: ClientCrudFetchParams): Promise>; +}>({ table, basePath, body, query, targetId, method, apiOrigin, headers, }: ClientCrudFetchParams): Promise>; diff --git a/dist/client/crud-fetch/index.js b/dist/client/crud-fetch/index.js index 706ff7d..a7c214a 100644 --- a/dist/client/crud-fetch/index.js +++ b/dist/client/crud-fetch/index.js @@ -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; } diff --git a/dist/client/fetch/index.d.ts b/dist/client/fetch/index.d.ts index 0c01b2b..ba73f3a 100644 --- a/dist/client/fetch/index.d.ts +++ b/dist/client/fetch/index.d.ts @@ -1,3 +1,4 @@ +import { DSQLClientFetchHeader } from "../../package-shared/types"; type FetchApiOptions = { 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; +localStorageCSRFKey?: string): Promise; export {}; diff --git a/dist/client/fetch/index.js b/dist/client/fetch/index.js index c3f49c4..1a68b22 100644 --- a/dist/client/fetch/index.js +++ b/dist/client/fetch/index.js @@ -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"; diff --git a/dist/package-shared/types/index.d.ts b/dist/package-shared/types/index.d.ts index 14a2c11..4f2c0b7 100644 --- a/dist/package-shared/types/index.d.ts +++ b/dist/package-shared/types/index.d.ts @@ -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