@dxtmisha/functional-basic 1.2.2 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.2.3] - 2026-05-16
6
+
7
+ ### Added
8
+ - **Api**: Enhanced `setHeaders` method to support dynamic header resolution via a callback function. These headers are now re-evaluated on every request, allowing for reactive updates like fresh authentication tokens.
9
+ - **Api**: Added support for dynamic evaluation of default request data (`setRequestDefault`) via callback functions, enabling reactive query parameters.
10
+ - **Types**: Introduced `ApiHeadersValue` type and standardized the use of `ApiDefaultValue` across `ApiConfig`, `ApiFetch`, and core API classes for better consistency and maintainability.
11
+
12
+ ## [1.2.2] - 2026-05-16
13
+
14
+ ### Changed / Improved
15
+ - **Cookie**: Refined `getInstance` static method with explicit return type and type casting for better TypeScript compatibility.
16
+ - **Api**: Improved formatting of `ApiDataItem` type definition for better readability.
17
+ - **Maintenance**: Updated package versioning and synchronized with the new monorepo build and publish orchestration system.
18
+
5
19
  ## [1.2.0] - 2026-05-14
6
20
 
7
21
  ### Added
package/dist/library.js CHANGED
@@ -1124,7 +1124,7 @@ var Oe = class {
1124
1124
  return !!this.value;
1125
1125
  }
1126
1126
  get() {
1127
- return this.value;
1127
+ return x(this.value);
1128
1128
  }
1129
1129
  request(e) {
1130
1130
  let t = this.get();
@@ -1151,14 +1151,14 @@ var Oe = class {
1151
1151
  }
1152
1152
  get(e, t = "application/json;charset=UTF-8") {
1153
1153
  if (e === null) return;
1154
- let r = { ...this.headers };
1154
+ let r = { ...x(this.headers) };
1155
1155
  return n(e) && Object.assign(r, e), l(t) && (r["Content-Type"] = t), r;
1156
1156
  }
1157
1157
  getByRequest(e, t, n = "application/json;charset=UTF-8") {
1158
1158
  return e instanceof FormData ? this.get(t, null) : this.get(t, n);
1159
1159
  }
1160
1160
  set(e) {
1161
- return n(e) && (this.headers = e), this;
1161
+ return this.headers = e, this;
1162
1162
  }
1163
1163
  }, Ne = "__ui:api:hydration:id__", Pe = class {
1164
1164
  constructor() {
@@ -1,5 +1,5 @@
1
1
  import { ApiInstance } from './ApiInstance';
2
- import { ApiConfig, ApiFetch, ApiMethodItem, ApiPreparationEnd } from '../types/apiTypes';
2
+ import { ApiConfig, ApiDefaultValue, ApiFetch, ApiHeadersValue, ApiMethodItem, ApiPreparationEnd } from '../types/apiTypes';
3
3
  import { ApiStatus } from './ApiStatus';
4
4
  import { ApiResponse } from './ApiResponse';
5
5
  import { ApiHydration } from './ApiHydration';
@@ -93,7 +93,7 @@ export declare class Api {
93
93
  * @param headers default headers / заголовки по умолчанию
94
94
  * @returns void / ничего не возвращает
95
95
  */
96
- static setHeaders(headers: Record<string, string>): void;
96
+ static setHeaders(headers: ApiHeadersValue): void;
97
97
  /**
98
98
  * Modifies the default request data.
99
99
  *
@@ -101,7 +101,7 @@ export declare class Api {
101
101
  * @param request default request data / данные запроса по умолчанию
102
102
  * @returns void / ничего не возвращает
103
103
  */
104
- static setRequestDefault(request: Record<string, any>): void;
104
+ static setRequestDefault(request: ApiDefaultValue): void;
105
105
  /**
106
106
  * Changes the base path to the script.
107
107
  *
@@ -20,7 +20,7 @@ export declare class ApiDefault {
20
20
  * Получает данные запроса по умолчанию.
21
21
  * @returns default request data or undefined / данные запроса по умолчанию или undefined
22
22
  */
23
- get(): ApiDefaultValue | undefined;
23
+ get(): Record<string, any> | undefined;
24
24
  /**
25
25
  * Adds default data to the request.
26
26
  *
@@ -1,4 +1,4 @@
1
- import { ApiFetch } from '../types/apiTypes';
1
+ import { ApiFetch, ApiHeadersValue } from '../types/apiTypes';
2
2
  /**
3
3
  * Class for managing HTTP request headers.
4
4
  *
@@ -6,7 +6,7 @@ import { ApiFetch } from '../types/apiTypes';
6
6
  */
7
7
  export declare class ApiHeaders {
8
8
  /** Default headers / Заголовки по умолчанию */
9
- protected headers: Record<string, string>;
9
+ protected headers: ApiHeadersValue;
10
10
  /**
11
11
  * Gets the headers for the request.
12
12
  *
@@ -33,5 +33,5 @@ export declare class ApiHeaders {
33
33
  * @param headers list of default headers/ список заголовков по умолчанию
34
34
  * @returns this instance for chaining / текущий экземпляр для цепочки вызовов
35
35
  */
36
- set(headers: Record<string, string>): this;
36
+ set(headers: ApiHeadersValue): this;
37
37
  }
@@ -6,7 +6,7 @@ import { ApiHydration } from './ApiHydration';
6
6
  import { ApiPreparation } from './ApiPreparation';
7
7
  import { ApiStatus } from './ApiStatus';
8
8
  import { ApiResponse } from './ApiResponse';
9
- import { ApiFetch, ApiMethod, ApiPreparationEnd } from '../types/apiTypes';
9
+ import { ApiDefaultValue, ApiFetch, ApiHeadersValue, ApiMethod, ApiPreparationEnd } from '../types/apiTypes';
10
10
  /** Options for the API instance / Опции для экземпляра API */
11
11
  export type ApiInstanceOptions = {
12
12
  /** Class for working with headers / Класс для работы с заголовками */
@@ -134,14 +134,14 @@ export declare class ApiInstance {
134
134
  * Изменяет данные заголовка по умолчанию.
135
135
  * @param headers default headers / заголовки по умолчанию
136
136
  */
137
- setHeaders(headers: Record<string, string>): this;
137
+ setHeaders(headers: ApiHeadersValue): this;
138
138
  /**
139
139
  * Modifies the default request data.
140
140
  *
141
141
  * Изменяет данные запроса по умолчанию.
142
142
  * @param request default request data / данные запроса по умолчанию
143
143
  */
144
- setRequestDefault(request: Record<string, any>): this;
144
+ setRequestDefault(request: ApiDefaultValue): this;
145
145
  /**
146
146
  * Changes the base path to the script.
147
147
  *
@@ -53,9 +53,9 @@ export type ApiConfig = {
53
53
  /** Base origin for API requests (protocol and domain)/ Базовый источник для API-запросов (протокол и домен) */
54
54
  origin?: string;
55
55
  /** Default headers for API requests/ Заголовки по умолчанию для API-запросов */
56
- headers?: Record<string, string>;
56
+ headers?: ApiHeadersValue;
57
57
  /** Default request data for API requests/ Данные запроса по умолчанию для API-запросов */
58
- requestDefault?: Record<string, any>;
58
+ requestDefault?: ApiDefaultValue;
59
59
  /** Function to call before request/ Функция для вызова перед запросом */
60
60
  preparation?: (apiFetch: ApiFetch) => Promise<void>;
61
61
  /** Function to call after request/ Функция для вызова после запроса */
@@ -91,10 +91,14 @@ export type ApiDataItem<T = any> = T & ApiDataValidation & {
91
91
  /** Status object/ Объект статуса */
92
92
  statusObject?: ApiStatusItem;
93
93
  };
94
+ /**
95
+ * Type for API request headers / Тип для заголовков запроса API
96
+ */
97
+ export type ApiHeadersValue = Record<string, string> | (() => Record<string, string>);
94
98
  /**
95
99
  * Default API request data type/ Тип данных запроса API по умолчанию
96
100
  */
97
- export type ApiDefaultValue = Record<string, any>;
101
+ export type ApiDefaultValue = Record<string, any> | (() => Record<string, any>);
98
102
  /**
99
103
  * Options for making API requests/ Опции для выполнения API-запросов
100
104
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dxtmisha/functional-basic",
3
3
  "private": false,
4
- "version": "1.2.2",
4
+ "version": "1.2.4",
5
5
  "type": "module",
6
6
  "description": "Foundational utility library for modern web development — HTTP client, geolocation, i18n, SEO meta tags, caching, storage, DOM utilities, and more. Framework-agnostic, zero dependencies, TypeScript-first.",
7
7
  "keywords": [