@dxtmisha/functional 1.15.7 → 1.15.9

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/ai-types.md CHANGED
@@ -1,155 +1,30 @@
1
- 1) All these methods are in the @dxtmisha/functional library.
1
+ All these methods are in the @dxtmisha/functional library.
2
2
 
3
- import { ComputedRef, Ref, ShallowRef, ToRefs, VNode, DebuggerOptions, ComputedGetter, PropType, VNodeArrayChildren, Plugin } from 'vue';
4
- import { RouteLocationRaw, Router, _RouterClassic } from 'vue-router';
5
- import { InputSocialIcons } from '@dxtmisha/media';
6
- import { Datetime, GeoDate, GeoFirstDay, GeoHours, NumberOrStringOrDate, ElementOrString, ElementOrWindow, EventItem, EventListenerDetail, EventOptions, GeoFlag, GeoFlagItem, GeoFlagNational, ItemValue, NumberOrString, GeoItemFull, GeoUnit, ApiInstance, ApiData, ApiDataValidation, ApiErrorStorageList, ApiFetch, ArrayToItem, FormattersListColumns, FormattersOptionsList, SearchColumns, SearchFormatList, ApiErrorItem, FormattersListProp, FormattersReturn, MetaRobots, Meta, SearchItem, SearchOptions, TranslateInstance, TranslateList, ApiConfig, ErrorCenterCauseList, ErrorCenterHandlerCallback, ErrorCenterHandlerList, IconsConfig, TranslateConfig, Undefined, NumberOrStringOrBoolean, ApiDefaultValue, SearchListValue, ItemList, ApiMethodItem } from '@dxtmisha/functional-basic';
7
- export * from '@dxtmisha/functional-basic';
8
- export type ApiOptions = ApiMethodItem | RefOrNormal<ApiFetch>;
9
- export type ApiManagementValue = ApiDefaultValue | ApiDefaultValue[];
10
- export type ApiManagementGet<Return extends ApiManagementValue, Type extends ApiManagementValue = Return> = {
11
- path?: RefOrNormal<string | undefined>;
12
- options?: ApiOptions;
13
- reactivity?: boolean;
14
- conditions?: RefType<boolean>;
15
- transformation?: (data: Type, isResponseContractValid?: ApiDataValidation) => ApiData<Return>;
16
- validateResponseContract?: (data: Type) => ApiDataValidation;
17
- errorContract?: ApiErrorStorageList;
18
- typeData?: ((data: Return) => boolean) | any;
19
- unmounted?: boolean;
20
- skeleton?: () => Return;
21
- };
22
- export type ApiManagementSearch<T extends SearchItem, K extends SearchColumns<T>> = {
23
- columns: K;
24
- value?: Ref<string>;
25
- options?: SearchOptions;
26
- };
27
- export type ApiManagementRequest<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>> = {
28
- path?: RefOrNormal<string | undefined>;
29
- action?: (data: Return | undefined) => Promise<void> | void;
30
- transformation?: (data: T) => Return;
31
- validateRequestContract?: (data: Request) => ApiDataValidation & Return;
32
- validateResponseContract?: (data: T) => ApiDataValidation & Return;
33
- errorContract?: ApiErrorStorageList;
34
- toData?: boolean;
35
- options?: ApiOptions;
36
- };
37
- export type ConstrItem = Record<string, any>;
38
- export type ConstrValue<T = any> = {
39
- value?: T;
40
- };
41
- export type ConstrComponent = Record<string, any>;
42
- export type ConstrComponentMod<P extends ConstrItem> = ConstrItem | {
43
- [K in keyof P]?: RefOrNormal<P[K]>;
44
- };
45
- export type ConstrExpose<E extends Element, EXPOSE extends ConstrItem> = EXPOSE & {
46
- elementHtml?: ComputedRef<E | undefined>;
47
- };
48
- export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
49
- export type ConstrEmitItem<T extends ConstrItem> = T[keyof T];
50
- export type ConstrEmit<T extends ConstrItem = ConstrItem> = UnionToIntersection<ConstrEmitItem<{
51
- [K in keyof T]: (evt: K, ...args: T[K]) => void;
52
- }>>;
53
- export type ConstrClassObject = Record<string, boolean | undefined>;
54
- export type ConstrClass = string | (string | ConstrClass | Undefined)[] | ConstrClassObject;
55
- export type ConstrClassList = Record<string, ConstrClass>;
56
- export type ConstrClasses = {
57
- main: ConstrClass;
58
- } & ConstrClassList;
59
- export type ConstrStylesItem = string | null;
60
- export type ConstrStyles = Record<string, ConstrStylesItem> | ConstrStyles[];
61
- export type ConstrOptions<COMP extends ConstrComponent, EMITS extends ConstrItem, P extends ConstrItem> = {
62
- components?: COMP;
63
- compMod?: ConstrComponentMod<P>;
64
- emits?: ConstrEmit<EMITS>;
65
- classes?: RefType<ConstrClasses>;
66
- styles?: RefType<ConstrStyles>;
67
- };
68
- export type ConstrSetup<E extends Element, CLASSES extends ConstrClasses, SETUP extends ConstrItem> = {
69
- name: string;
70
- element: Ref<E | undefined>;
71
- classes: RefType<CLASSES>;
72
- styles: RefType<ConstrStyles>;
73
- } & SETUP;
74
- export type ConstrRegistration = {
75
- flag?: boolean;
76
- translate?: Record<string, string>;
77
- };
78
- export type ConstrBind<T> = T & Record<string, any> & {
79
- key?: string;
80
- class?: ConstrClass;
81
- style?: ConstrStyles;
82
- };
83
- export type ConstrPropItemOptions<T = any> = {
84
- type?: PropType<T>;
85
- required?: boolean;
86
- default?: any;
87
- validator?(value: any, props: any): boolean;
88
- };
89
- export type ConstrPropItem<T = any> = ConstrPropItemOptions<T> | PropType<T>;
90
- export type ConstrProps<P = Record<string, any>> = {
91
- [K in keyof P]: ConstrPropItem<P[K]>;
92
- };
93
- export type ConstrHrefProps = {
94
- href?: string;
95
- };
96
- export type ListType = 'item' | 'space' | 'line' | 'subtitle' | 'html' | 'menu' | 'menu-group' | 'group';
97
- export type ListDataBasic = {
98
- label?: NumberOrString;
99
- value?: any;
100
- search?: string;
101
- };
102
- export type ListDataItem<Item extends ListDataBasic = ListDataBasic> = ConstrBind<Item & {
103
- parent?: string;
104
- type: ListType;
105
- index: string;
106
- disabled?: boolean;
107
- }>;
108
- export type ListList<Item extends ListDataBasic = ListDataBasic> = ListDataItem<Item>[];
109
- export type ListRecord<Item extends ListDataBasic = ListDataBasic> = ListList<Item> | Record<string, any>;
110
- export type ListDataFullItem<Item extends ListDataBasic = ListDataBasic> = ListDataItem<Item> & {
111
- focus: boolean;
112
- highlight?: string;
113
- selected: boolean;
114
- disabled?: boolean;
115
- };
116
- export type ListDataFull<Item extends ListDataBasic = ListDataBasic> = ListDataFullItem<Item>[];
117
- export type ListListInputItem<Item extends ListDataBasic = ListDataBasic> = ConstrBind<Item>;
118
- export type ListListInput<Item extends ListDataBasic = ListDataBasic> = ListListInputItem<Item>[] | string[] | Record<string, ListListInputItem<Item>> | Record<string, string>;
119
- export type ListSelectedItem = NumberOrStringOrBoolean;
120
- export type ListSelectedList = ListSelectedItem | ListSelectedItem[];
121
- export type ListName = string | number | undefined;
122
- export type ListNames = ListName[];
123
- export type RefType<T> = ComputedRef<T> | Ref<T>;
124
- export type RefUndefined<T> = RefType<T | undefined>;
125
- export type RefOrNormal<T> = RefType<T> | T;
126
- export type RefOrNormalOrFunction<T> = RefOrNormal<T> | (() => RefOrNormal<T>);
127
- export type RawChildren = string | number | boolean | VNode | VNodeArrayChildren | (() => any);
128
- export type RawSlots = {
129
- [name: string]: unknown;
130
- $stable?: boolean;
131
- };
132
- export type SearchListValueRef<T extends SearchItem> = RefOrNormal<SearchListValue<T>>;
133
- export type SearchListInput<T extends SearchItem> = SearchListValueRef<T> | (() => SearchListValueRef<T>);
134
- export type SearchColumnsRef<T extends SearchItem, K extends SearchColumns<T>> = RefOrNormal<K>;
135
- export type SearchColumnsInput<T extends SearchItem, K extends SearchColumns<T>> = SearchColumnsRef<T, K> | (() => SearchColumnsRef<T, K>);
3
+ /** Base class for working with the constructor. */
136
4
  export declare abstract class DesignAbstract<T extends Record<string, any>, C extends Record<string, any>> {
5
+ protected readonly callback?: ((event: C) => void) | undefined;
137
6
  constructor(props: T, callback?: ((event: C) => void) | undefined, changed?: string[]);
138
7
  make(compelled?: boolean): this;
8
+ protected is<K extends keyof T>(name: K): boolean;
9
+ protected isChanged<K extends keyof C & string, KT extends keyof T & string>(name: K, nameProp?: KT | KT[]): boolean;
139
10
  makeCallback(compelled?: boolean): void;
11
+ protected makeCallbackItem(): void;
12
+ protected abstract initEvent(): void;
140
13
  }
14
+ /**
141
15
  export declare abstract class DesignAsyncAbstract<T extends Record<string, any>, C extends Record<string, any>> extends DesignAbstract<T, C> {
142
16
  make(compelled?: boolean): this;
143
17
  makeCallback(compelled?: boolean): Promise<void>;
18
+ protected abstract initEvent(): Promise<void>;
144
19
  }
145
20
  export declare class DesignChanged<T extends Record<string, any>> {
146
21
  constructor(props: T, watch?: string[]);
147
22
  is(name: string | string[]): boolean;
148
23
  isChanged(): boolean;
149
24
  update(): void;
25
+ protected isDifferent(name: string): boolean;
150
26
  }
151
- export declare class DesignComp<COMP extends ConstrComponent, P extends ConstrItem> extends DesignComponents<COMP, P> {
152
- }
27
+ export declare class DesignComp<COMP extends ConstrComponent, P extends ConstrItem> extends DesignComponents<COMP, P> {}
153
28
  export declare class DesignComponents<COMP extends ConstrComponent, P extends ConstrItem> {
154
29
  constructor(components?: COMP, modification?: ConstrComponentMod<P> | undefined);
155
30
  is<K extends keyof COMP>(name: K): name is K;
@@ -158,8 +33,11 @@ export declare class DesignComponents<COMP extends ConstrComponent, P extends Co
158
33
  render<K extends keyof COMP, PK extends keyof P>(name: K & string, props?: P[PK] & ConstrItem | ConstrItem, children?: RawChildren | RawSlots, index?: PK & string | string): VNode[];
159
34
  renderOne<K extends keyof COMP, PK extends keyof P>(name: K & string, props?: P[PK] & ConstrItem | ConstrItem, children?: RawChildren | RawSlots, index?: PK & string | string): VNode | undefined;
160
35
  renderAdd<K extends keyof COMP, PK extends keyof P>(item: any[], name: K & string, props?: P[PK] & ConstrItem | ConstrItem, children?: RawChildren | RawSlots, index?: PK & string | string): this;
36
+ protected computeModification<K extends keyof P>(index: K & string | string): Record<string, any>;
161
37
  }
162
38
  export declare abstract class DesignConstructorAbstract<E extends Element, COMP extends ConstrComponent, EMITS extends ConstrItem, EXPOSE extends ConstrItem, SLOTS extends ConstrItem, CLASSES extends ConstrClasses, P extends ConstrItem> {
39
+ protected constructor(name: string, props: Readonly<P>, options?: ConstrOptions<COMP, EMITS, P> | undefined);
40
+ protected init(): this;
163
41
  getName(): string;
164
42
  getDesign(): string;
165
43
  getSubClass(name: string | string[]): string;
@@ -168,6 +46,13 @@ export declare abstract class DesignConstructorAbstract<E extends Element, COMP
168
46
  getAttrs(): ConstrItem;
169
47
  expose(): ConstrExpose<E, EXPOSE>;
170
48
  render(): () => VNode | (VNode | any)[] | undefined;
49
+ protected abstract initExpose(): EXPOSE;
50
+ protected abstract initClasses(): Partial<CLASSES>;
51
+ protected abstract initStyles(): ConstrStyles;
52
+ protected abstract initRender(): VNode | (VNode | any)[] | undefined;
53
+ protected initSlot<K extends keyof SLOTS>(name: K, children?: any[], props?: ConstrItem): VNode | undefined;
54
+ protected toClass(classes?: ConstrClass): ConstrClassObject;
55
+ protected toClassName<T extends ConstrItem>(classes?: ConstrItem): T;
171
56
  }
172
57
  export declare class DatetimeRef {
173
58
  constructor(date: RefOrNormal<NumberOrStringOrDate>, type?: RefOrNormal<GeoDate>, code?: RefOrNormal<string>);
@@ -185,11 +70,30 @@ export declare class DatetimeRef {
185
70
  getMaxDay(): ComputedRef<number>;
186
71
  locale(type?: GeoDate, styleOptions?: Intl.DateTimeFormatOptions['month'] | Intl.DateTimeFormatOptions): ComputedRef<string>;
187
72
  standard(timeZone?: boolean): ComputedRef<string>;
73
+ protected updateDate(): this;
188
74
  }
189
75
  export declare class EffectScopeGlobal {
190
76
  static run<T>(fn: () => T): T | undefined;
191
77
  }
78
+ import { ElementOrString, ElementOrWindow, EventItem, EventListenerDetail, EventOptions } from '@dxtmisha/functional-basic';
79
+ /**
80
+ * Class for working with events (Ref).
81
+ *
82
+ * Класс для работа с события (Ref).
83
+ */
192
84
  export declare class EventRef<E extends ElementOrWindow, O extends Event, D extends Record<string, any> = Record<string, any>> extends EventItem<E, O, D> {
85
+ /**
86
+ * Classes Constructor
87
+ * @param elementSelector element/ элемент
88
+ * @param elementSelectorControl control element/ элемент управления
89
+ * @param type type/ тип
90
+ * @param listener the object that receives a notification (an object that implements the
91
+ * Event interface) when an event of the specified type occurs/ объект, который принимает
92
+ * уведомление, когда событие указанного типа произошло
93
+ * @param options object that specifies characteristics/ объект options
94
+ * @param detail an event-dependent value associated with the event/ зависимое от события
95
+ * значение, связанное с событием
96
+ */
193
97
  constructor(elementSelector?: RefOrNormal<ElementOrString<E> | undefined>, elementSelectorControl?: RefOrNormal<ElementOrString<HTMLElement>>, type?: string | string[], listener?: EventListenerDetail<O, D>, options?: EventOptions, detail?: D);
194
98
  }
195
99
  export declare class GeoFlagRef {
@@ -205,10 +109,7 @@ export declare class GeoFlagRef {
205
109
  }
206
110
  /**
207
111
  * Reactive class for managing the formatting of numbers and dates.
208
- *
209
- * @remarks
210
- * Avoid using this reactive class if reactive updates are not required.
211
- * For non-reactive formatting, use the standard `GeoIntl` class from `@dxtmisha/functional-basic`.
112
+ * @remarks Avoid using this reactive class if reactive updates are not required. For non-reactive formatting, use the standard `GeoIntl` class from `@dxtmisha/functional-basic`.
212
113
  */
213
114
  export declare class GeoIntlRef {
214
115
  constructor(code?: RefOrNormal<string>);
@@ -310,6 +211,10 @@ export declare class ListDataRef {
310
211
  getFirstItemByParent(parent: string | undefined): ListDataItem | undefined;
311
212
  getLastItemByParent(parent: string | undefined): ListDataItem | undefined;
312
213
  getSubList(item: ListDataItem): ListDataRef;
214
+ protected isItem(item: ListDataItem): boolean;
215
+ protected isInParent(parent: string | undefined, item: ListDataItem): boolean;
216
+ protected getIndex(index: string | number | undefined, value: any, key: string | number | undefined, label: string | number | undefined): string | number | undefined;
217
+ protected initItem(key: string | number, item: any): ListDataItem;
313
218
  }
314
219
  export declare class RouterItemRef {
315
220
  static get(): _RouterClassic;
@@ -328,35 +233,96 @@ export declare class ScrollbarWidthRef {
328
233
  }
329
234
  /**
330
235
  * Asynchronous reactive composable for API requests with built-in SSR support.
236
+ * Wraps `useApiRef` and immediately calls `initSsr()` to ensure data is pre-fetched on the server side.
237
+ * Use this composable ONLY if you need the request to be executed on the server side during SSR.
238
+ * For all other cases, use `useApiRef`.
331
239
  *
332
240
  * @example
333
241
  * ```typescript
334
242
  * import { Schema as S } from '@effect/schema'
335
243
  * import { useApiAsyncRef } from '@dxtmisha/functional'
244
+ *
336
245
  * const userSchema = S.Struct({ id: S.Number, name: S.String })
337
- * const { data, loading, errorItem } = useApiAsyncRef('/users/1')
246
+ *
247
+ * // Data will be pre-fetched on the server during SSR (onServerPrefetch)
248
+ * const { data, loading, errorItem, isResponseContractValid } = useApiAsyncRef(
249
+ * '/users/1',
250
+ * { method: 'GET' },
251
+ * true, // reactivity
252
+ * undefined, // conditions
253
+ * undefined, // transformation
254
+ * (data) => { // validateResponseContract
255
+ * try {
256
+ * return { status: 'success', data: S.decodeUnknownSync(userSchema)(data) }
257
+ * } catch (e) {
258
+ * return { status: 'error', errors: e }
259
+ * }
260
+ * },
261
+ * [ // errorContract
262
+ * { status: 404, message: 'User not found' }
263
+ * ]
264
+ * )
338
265
  * ```
339
266
  */
340
267
  export declare function useApiAsyncRef<R, T = R>(path?: RefOrNormal<string | undefined>, options?: ApiOptions, reactivity?: boolean, conditions?: RefType<boolean>, transformation?: (data: T, isResponseContractValid?: ApiDataValidation) => ApiData<R>, validateResponseContract?: (data: T) => ApiDataValidation, errorContract?: ApiErrorStorageList, unmounted?: boolean, apiInstance?: ApiInstance): UseApiRef<R>;
341
268
  export interface UseApiDeleteSetup<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>> extends Omit<UseApiRequestSetup<T, Request, Return>, 'method'> {
342
269
  }
270
+ /**
271
+ * Use API delete request.
272
+ * This is a convenient wrapper over `useApiRequest` that pre-fills the DELETE method.
273
+ */
343
274
  export declare function useApiDelete<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>>(setup: UseApiDeleteSetup<T, Request, Return>): {
344
275
  loading: Ref<boolean, boolean>;
345
276
  send(request?: Request | undefined): Promise<Return | undefined>;
346
277
  };
347
278
  export interface UseApiGetSetup<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>> extends Omit<UseApiRequestSetup<T, Request, Return>, 'method'> {
348
279
  }
280
+ /**
281
+ * Use API get request.
282
+ * This is a convenient wrapper over `useApiRequest` that pre-fills the GET method.
283
+ */
349
284
  export declare function useApiGet<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>>(setup: UseApiGetSetup<T, Request, Return>): {
350
285
  loading: Ref<boolean, boolean>;
351
286
  send(request?: Request | undefined): Promise<Return | undefined>;
352
287
  };
288
+ import { ApiInstance, ArrayToItem, FormattersListColumns, FormattersOptionsList, SearchColumns, ApiDataValidation, SearchFormatList, ApiData, ApiErrorItem, ApiFetch } from '@dxtmisha/functional-basic';
289
+ import { ComputedRef, Ref } from 'vue';
290
+ /**
291
+ * Asynchronous reactive composable for API management requests with built-in SSR support.
292
+ * Wraps `useApiManagementRef` and immediately calls `initSsr()` to ensure data is pre-fetched on the server side.
293
+ * Use this composable ONLY if you need the request to be executed on the server side during SSR.
294
+ * For all other cases, use `useApiManagementRef`.
295
+ *
296
+ * Асинхронный реактивный composable для запросов управления API со встроенной поддержкой SSR.
297
+ * Оборачивает `useApiManagementRef` и сразу вызывает `initSsr()`, чтобы гарантировать предзагрузку данных на сервере.
298
+ * Используйте этот composable ТОЛЬКО если вам необходимо, чтобы запрос был выполнен на стороне сервера
299
+ * во время SSR. Во всех остальных случаях используйте обычный `useApiManagementRef`.
300
+ * @template Return type of data returned by the API / тип данных, возвращаемых API
301
+ * @template FormattersOptions optional formatting rules / опциональные правила форматирования
302
+ * @template Post data type for POST creation request / тип данных для POST-запроса создания
303
+ * @template Put data type for PUT update request / тип данных для PUT-запроса обновления
304
+ * @template Delete data type for DELETE removal request / тип данных для DELETE-запроса удаления
305
+ * @template Type original data type (before transformation) / тип исходных данных (до трансформации)
306
+ * @template Item type of a single item in the data list / тип одного элемента из списка данных
307
+ * @template ItemFormatters item type after formatters are applied / тип элемента после применения форматировщиков
308
+ * @template Columns search columns derived from formatting / колонки, по которым производится поиск
309
+ *
310
+ * @param propsGet main GET request settings (path, reactivity, skeleton, etc.) / настройки главного GET-запроса
311
+ * @param formattersOptions optional reactive formatting rules / правила для реактивного форматирования данных
312
+ * @param searchOptions optional client-side search settings / настройки для клиентского поиска по списку
313
+ * @param postRequest optional POST mutation settings / настройки для POST-запроса создания
314
+ * @param putRequest optional PUT mutation settings / настройки для PUT-запроса обновления
315
+ * @param deleteRequest optional DELETE mutation settings / настройки для DELETE-запроса удаления
316
+ * @param action common callback executed after any successful mutation / общий коллбэк после любой успешной мутации
317
+ * @param apiInstance API instance for requests (defaults to Api.getItem()) / экземпляр API для выполнения запроса
318
+ */
353
319
  export declare function useApiManagementAsyncRef<Return extends ApiManagementValue, FormattersOptions extends FormattersOptionsList, Post extends Record<string, any>, Put extends Record<string, any>, Delete extends Record<string, any>, Type extends ApiManagementValue = Return, Item extends ArrayToItem<Return> = ArrayToItem<Return>, ItemFormatters extends FormattersListColumns<Item, FormattersOptions>[number] = FormattersListColumns<Item, FormattersOptions>[number], Columns extends SearchColumns<ItemFormatters> = []>(propsGet: ApiManagementGet<Return, Type>, formattersOptions?: FormattersOptions, searchOptions?: ApiManagementSearch<Item, Columns>, postRequest?: ApiManagementRequest<Post>, putRequest?: ApiManagementRequest<Put>, deleteRequest?: ApiManagementRequest<Delete>, action?: () => Promise<void> | void, apiInstance?: ApiInstance): {
354
320
  isValid: ComputedRef<boolean>;
355
321
  isResponseContractValid: ComputedRef<boolean>;
356
- responseValidationResult: ComputedRef<ApiDataValidation | undefined>;
322
+ responseValidationResult: ComputedRef< ApiDataValidation | undefined>;
357
323
  list: ComputedRef<SearchFormatList<ItemFormatters, Columns>>;
358
- readonly data: ComputedRef<ApiData<Return> | undefined>;
359
- errorItem: ComputedRef<ApiErrorItem | undefined>;
324
+ readonly data: ComputedRef< ApiData<Return> | undefined>;
325
+ errorItem: ComputedRef< ApiErrorItem | undefined>;
360
326
  readonly length: ComputedRef<number>;
361
327
  lengthData: ComputedRef<number>;
362
328
  starting: ComputedRef<boolean>;
@@ -372,38 +338,77 @@ export declare function useApiManagementAsyncRef<Return extends ApiManagementVal
372
338
  initSsr: () => void;
373
339
  reset: () => Promise<void>;
374
340
  abort: () => void;
375
- sendPost: (request?: ApiFetch["request"]) => Promise<ApiData<Post> | undefined>;
376
- sendPut: (request?: ApiFetch["request"]) => Promise<ApiData<Put> | undefined>;
377
- sendDelete: (request?: ApiFetch["request"]) => Promise<ApiData<Delete> | undefined>;
341
+ sendPost: (request?: ApiFetch["request"]) => Promise< ApiData<Post> | undefined>;
342
+ sendPut: (request?: ApiFetch["request"]) => Promise< ApiData<Put> | undefined>;
343
+ sendDelete: (request?: ApiFetch["request"]) => Promise< ApiData<Delete> | undefined>;
378
344
  };
379
345
  /**
380
346
  * A powerful composable for comprehensive API request orchestration.
347
+ * It centrally manages data loading (GET), list formatting, client-side searching,
348
+ * and mutations (POST, PUT, DELETE) through a single reactive interface.
349
+ *
350
+ * @template Return type of data returned by the API
351
+ * @template FormattersOptions optional formatting rules
352
+ * @template Post data type for POST creation request
353
+ * @template Put data type for PUT update request
354
+ * @template Delete data type for DELETE removal request
355
+ * @template Type original data type (before transformation)
356
+ * @template Item type of a single item in the data list
357
+ * @template ItemFormatters item type after formatters are applied
358
+ * @template Columns search columns derived from formatting
381
359
  *
382
- * @note
383
- * This hook is recommended to be used in tandem with `executeUse` for centralized state management.
360
+ * @param propsGet main GET request settings (path, reactivity, skeleton, etc.)
361
+ * @param formattersOptions optional reactive formatting rules
362
+ * @param searchOptions optional client-side search settings
363
+ * @param postRequest optional POST mutation settings
364
+ * @param putRequest optional PUT mutation settings
365
+ * @param deleteRequest optional DELETE mutation settings
366
+ * @param action common callback executed after any successful mutation
367
+ * @param apiInstance API instance for requests (defaults to Api.getItem())
368
+ *
369
+ * @returns reactive API management interface
370
+ *
371
+ * @note This hook is recommended to be used in tandem with `executeUse` for centralized state management.
372
+ * By wrapping `useApiManagementRef` in `executeUseProvide` or `executeUseGlobal`, you can ensure
373
+ * a single source of truth across the component tree or the entire application.
384
374
  *
385
375
  * @remarks
386
376
  * Data formatting guidelines for `formattersOptions`:
387
- * - Recommended for formatting: Numbers that represent values, dates, currency, units, and statuses.
388
- * - Not recommended for formatting: Technical identifiers such as ID, UUID, account numbers, types, or internal codes.
377
+ * - **Recommended for formatting:** Numbers that represent values (prices, counts), dates, currency, units, and statuses.
378
+ * - **Not recommended for formatting:** Technical identifiers such as ID, UUID, account numbers (if used for logic), types, or internal codes.
389
379
  *
390
380
  * @example
391
- * ```typescript
381
+ * // 1. Comprehensive API orchestration
392
382
  * const products = useApiManagementRef(
393
- * { path: '/api/v1/products' },
394
- * { price: (v) => `${v} USD` },
395
- * { columns: ['name', 'category'] },
396
- * { path: '/api/v1/products' }
383
+ * {
384
+ * path: '/api/v1/products',
385
+ * skeleton: () => Array(5).fill({ id: 0, name: 'Loading...', price: 0 })
386
+ * },
387
+ * {
388
+ * // Formatters for display
389
+ * price: (v) => `${v} USD`,
390
+ * created_at: (v) => new Date(v).toLocaleDateString()
391
+ * },
392
+ * {
393
+ * // Client-side search setup
394
+ * columns: ['name', 'category']
395
+ * },
396
+ * { path: '/api/v1/products' }, // POST (create)
397
+ * { path: (data) => `/api/v1/products/${data.id}` }, // PUT (update)
398
+ * { path: (data) => `/api/v1/products/${data.id}` } // DELETE (remove)
397
399
  * );
398
- * ```
400
+ *
401
+ * // Accessing data:
402
+ * // products.list.value -> processed, formatted, and searched list
403
+ * // products.sendPost({ name: 'New Product', price: 100 }) -> execute mutation
399
404
  */
400
405
  export declare function useApiManagementRef<Return extends ApiManagementValue, FormattersOptions extends FormattersOptionsList, Post extends Record<string, any>, Put extends Record<string, any>, Delete extends Record<string, any>, Type extends ApiManagementValue = Return, Item extends ArrayToItem<Return> = ArrayToItem<Return>, ItemFormatters extends FormattersListColumns<Item, FormattersOptions>[number] = FormattersListColumns<Item, FormattersOptions>[number], Columns extends SearchColumns<ItemFormatters> = []>(propsGet: ApiManagementGet<Return, Type>, formattersOptions?: FormattersOptions, searchOptions?: ApiManagementSearch<Item, Columns>, postRequest?: ApiManagementRequest<Post>, putRequest?: ApiManagementRequest<Put>, deleteRequest?: ApiManagementRequest<Delete>, action?: () => Promise<void> | void, apiInstance?: ApiInstance): {
401
406
  isValid: ComputedRef<boolean>;
402
407
  isResponseContractValid: ComputedRef<boolean>;
403
- responseValidationResult: ComputedRef<ApiDataValidation | undefined>;
408
+ responseValidationResult: ComputedRef< ApiDataValidation | undefined>;
404
409
  list: ComputedRef<SearchFormatList<ItemFormatters, Columns>>;
405
410
  readonly data: ComputedRef<ApiData<Return> | undefined>;
406
- errorItem: ComputedRef<ApiErrorItem | undefined>;
411
+ errorItem: ComputedRef< ApiErrorItem | undefined>;
407
412
  readonly length: ComputedRef<number>;
408
413
  lengthData: ComputedRef<number>;
409
414
  starting: ComputedRef<boolean>;
@@ -425,12 +430,20 @@ export declare function useApiManagementRef<Return extends ApiManagementValue, F
425
430
  };
426
431
  export interface UseApiPostSetup<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>> extends Omit<UseApiRequestSetup<T, Request, Return>, 'method'> {
427
432
  }
433
+ /**
434
+ * Use API post request.
435
+ * This is a convenient wrapper over `useApiRequest` that pre-fills the POST method.
436
+ */
428
437
  export declare function useApiPost<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>>(setup: UseApiPostSetup<T, Request, Return>): {
429
438
  loading: Ref<boolean, boolean>;
430
439
  send(request?: Request | undefined): Promise<Return | undefined>;
431
440
  };
432
441
  export interface UseApiPutSetup<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>> extends Omit<UseApiRequestSetup<T, Request, Return>, 'method'> {
433
442
  }
443
+ /**
444
+ * Use API put request.
445
+ * This is a convenient wrapper over `useApiRequest` that pre-fills the PUT method.
446
+ */
434
447
  export declare function useApiPut<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>>(setup: UseApiPutSetup<T, Request, Return>): {
435
448
  loading: Ref<boolean, boolean>;
436
449
  send(request?: Request | undefined): Promise<Return | undefined>;
@@ -457,26 +470,128 @@ export interface UseApiRef<R> {
457
470
  }
458
471
  /**
459
472
  * Main reactive composable for working with API requests in Vue.
473
+ * Automatically handles SSR, reactivity, caching, error storage, data validation, and transformation.
460
474
  *
461
475
  * @example
462
476
  * ```typescript
463
477
  * import { Schema as S } from '@effect/schema'
464
478
  * import { useApiRef } from '@dxtmisha/functional'
465
- * const { data, loading } = useApiRef('/users/1')
479
+ *
480
+ * // Define a schema using @effect/schema
481
+ * const userSchema = S.Struct({ id: S.Number, name: S.String })
482
+ *
483
+ * const { data, loading, errorItem, isResponseContractValid } = useApiRef(
484
+ * '/users/1',
485
+ * { method: 'GET' },
486
+ * true, // reactivity
487
+ * undefined, // conditions
488
+ * (data) => ({ ...data, isTransformed: true }), // transformation
489
+ * (data) => { // validateResponseContract
490
+ * try {
491
+ * return { status: 'success', data: S.decodeUnknownSync(userSchema)(data) }
492
+ * } catch (e) {
493
+ * return { status: 'error', errors: e }
494
+ * }
495
+ * },
496
+ * [ // errorContract (ApiErrorStorageList)
497
+ * {
498
+ * status: 404,
499
+ * message: 'User not found'
500
+ * }
501
+ * ]
502
+ * )
466
503
  * ```
467
504
  */
468
505
  export declare function useApiRef<R, T = R>(path?: RefOrNormal<string | undefined>, options?: ApiOptions, reactivity?: boolean, conditions?: RefType<boolean>, transformation?: (data: T, isResponseContractValid?: ApiDataValidation) => ApiData<R>, validateResponseContract?: (data: T) => ApiDataValidation, errorContract?: ApiErrorStorageList, unmounted?: boolean, apiInstance?: ApiInstance): UseApiRef<R>;
506
+ /**
507
+ * Defines global conditions for the API request.
508
+ *
509
+ * Определяет глобальные условия для API запроса.
510
+ * @param conditions conditions for executing the request/ условия выполнения запроса
511
+ */
469
512
  export declare const setApiRefGlobalConditions: (conditions: RefType<any>) => void;
513
+ import { ApiInstance, ApiMethodItem, ApiData, ApiFetch, ApiErrorStorageList, ApiDataValidation } from '@dxtmisha/functional-basic';
514
+ import { Ref } from 'vue';
515
+ /**
516
+ * Setup interface for API request.
517
+ *
518
+ * Интерфейс настроек для запроса API.
519
+ */
470
520
  export interface UseApiRequestSetup<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>> {
521
+ /**
522
+ * Path to the API endpoint. Can be a reactive Ref or a normal string.
523
+ *
524
+ * Путь к endpoint API. Может быть реактивным Ref или обычной строкой.
525
+ */
471
526
  path?: RefOrNormal<string | undefined>;
527
+ /**
528
+ * HTTP method used for the request (e.g., GET, POST, PUT, DELETE). Defaults to POST.
529
+ *
530
+ * HTTP метод, используемый для запроса (например, GET, POST, PUT, DELETE). По умолчанию POST.
531
+ */
472
532
  method?: ApiMethodItem;
533
+ /**
534
+ * Action/callback to perform after the request has successfully completed.
535
+ * Can return a Promise for asynchronous operations.
536
+ *
537
+ * Действие/колбэк, выполняемое после успешного завершения запроса.
538
+ * Может возвращать Promise для асинхронных операций.
539
+ */
473
540
  action?: (data: Return | undefined) => Promise<void> | void;
541
+ /**
542
+ * Transformation function that modifies the raw response data before returning it.
543
+ *
544
+ * Функция трансформации, которая преобразует исходные данные ответа перед их возвратом.
545
+ */
474
546
  transformation?: (data: T) => Return;
547
+ /**
548
+ * Function to validate the request payload contract. Used to ensure that the API
549
+ * request payload matches the expected structure.
550
+ *
551
+ * Функция для проверки контракта данных запроса. Используется для гарантии того,
552
+ * что отправляемая полезная нагрузка запроса API соответствует ожидаемой структуре.
553
+ */
475
554
  validateRequestContract?: (data: Request) => ApiDataValidation & Return;
555
+ /**
556
+ * Function to validate response data contract. Used to ensure that the API
557
+ * response matches the expected structure. Highly recommended to use with `@effect/schema`.
558
+ * It should return `ApiDataValidation` containing a `status` ('success' or 'error')
559
+ * and the parsed data or errors.
560
+ *
561
+ * Функция для проверки контракта данных ответа. Используется для гарантии того, что ответ API соответствует
562
+ * ожидаемой структуре. Настоятельно рекомендуется использовать с `@effect/schema`. Должна возвращать объект
563
+ * `ApiDataValidation`, содержащий `status` ('success' или 'error') и распарсенные данные или ошибки.
564
+ */
476
565
  validateResponseContract?: (data: T) => ApiDataValidation & Return;
566
+ /**
567
+ * Array of expected error contracts for the request (`ApiErrorStorageList`).
568
+ * Highly recommended to add if there is information about possible request errors. Allows you to predefine
569
+ * possible errors (by code, status, or custom validation) which will be centrally processed by the application.
570
+ *
571
+ * Массив контрактов ожидаемых ошибок для запроса (`ApiErrorStorageList`). Желательно добавлять, если есть
572
+ * информация о возможных ошибках запроса. Позволяет заранее описать возможные ошибки (по коду, статусу или
573
+ * кастомной валидации) для централизованной обработки в приложении.
574
+ */
477
575
  errorContract?: ApiErrorStorageList;
576
+ /**
577
+ * If true, extracts the nested 'data' field from the response object instead of returning the raw envelope.
578
+ * Defaults to true.
579
+ *
580
+ * Если true, извлекает вложенное поле 'data' из объекта ответа вместо возврата исходного конверта.
581
+ * По умолчанию true.
582
+ */
478
583
  toData?: boolean;
584
+ /**
585
+ * Additional request options (headers, query params, etc.).
586
+ *
587
+ * Дополнительные опции запроса (заголовки, параметры запроса и т.д.).
588
+ */
479
589
  options?: ApiOptions;
590
+ /**
591
+ * Custom Api instance to execute the request on. Defaults to global Api singleton instance.
592
+ *
593
+ * Кастомный экземпляр класса Api для выполнения запроса. По умолчанию используется глобальный синглтон Api.
594
+ */
480
595
  apiInstance?: ApiInstance;
481
596
  }
482
597
  export declare function useApiRequest<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>>({ path, method, action, transformation, validateRequestContract, validateResponseContract, errorContract, toData, options, apiInstance }: UseApiRequestSetup<T, Request, Return>): {
@@ -486,6 +601,11 @@ export declare function useApiRequest<T, Request extends ApiFetch['request'] = A
486
601
  type BroadcastValueItem<T> = T | string | undefined;
487
602
  export declare function useBroadcastValueRef<T>(name: string, defaultValue?: T | string | (() => (T | string))): Ref<BroadcastValueItem<T>>;
488
603
  export declare function useCookieRef<T>(name: string, defaultValue?: T | string | (() => (T | string)), options?: CookieOptions): Ref<T | string | undefined>;
604
+ /**
605
+ * Composable for reactive formatting of data lists based on specified rules for each property.
606
+ * @param list source data list (Ref or ComputedRef)
607
+ * @param options formatting settings for each property
608
+ */
489
609
  export declare function useFormattersRef<Options extends FormattersOptionsList = FormattersOptionsList, List extends FormattersListProp = FormattersListProp>(list: RefType<List | undefined>, options: Options): {
490
610
  listFormat: ComputedRef<FormattersReturn<List, Options>>;
491
611
  length: ComputedRef<number>;
@@ -523,6 +643,10 @@ export declare const useLazyRef: (options?: IntersectionObserverInit) => {
523
643
  disconnectLazy: () => void | undefined;
524
644
  };
525
645
  export declare function useLoadingRef(): ShallowRef<boolean, boolean>;
646
+ /**
647
+ * Vue composable for reactive meta tags management with automatic DOM synchronization.
648
+ * Uses singleton pattern - all components share the same meta state.
649
+ */
526
650
  export declare const useMeta: () => Readonly<{
527
651
  meta: Meta;
528
652
  title: Ref<string, string>;
@@ -546,7 +670,7 @@ export declare const useMeta: () => Readonly<{
546
670
  setRobots: (value: MetaRobots) => void;
547
671
  setSiteName: (value: string) => void;
548
672
  setSuffix: (suffix: string) => void;
549
- }> & {
673
+ } & {
550
674
  init(): Readonly<{
551
675
  meta: Meta;
552
676
  title: Ref<string, string>;
@@ -582,6 +706,13 @@ export declare const useRouterList: <T extends ListDataBasic>(list: RefType<Cons
582
706
  to: (name?: string) => void;
583
707
  toMain(): void;
584
708
  };
709
+ /**
710
+ * Composable for handling search logic with reactive data.
711
+ * @param list list of items to search
712
+ * @param columns columns to search in
713
+ * @param value reactive search string
714
+ * @param options search options
715
+ */
585
716
  export declare function useSearchRef<T extends SearchItem, K extends SearchColumns<T>>(list: SearchListInput<T>, columns?: SearchColumnsInput<T, K>, value?: Ref<string>, options?: SearchOptions): {
586
717
  isSearch: ComputedRef<boolean>;
587
718
  search: Ref<string, string>;
@@ -589,6 +720,11 @@ export declare function useSearchRef<T extends SearchItem, K extends SearchColum
589
720
  listSearch: ComputedRef<SearchFormatList<T, K>>;
590
721
  length: ComputedRef<number>;
591
722
  };
723
+ /**
724
+ * Composable for managing search value state and handling delays.
725
+ * @param item search list instance
726
+ * @param value reactive search string (optional)
727
+ */
592
728
  export declare function useSearchValueRef<T extends SearchItem, K extends SearchColumns<T>>(item: SearchList<T, K>, value?: Ref<string>): {
593
729
  search: Ref<string, string>;
594
730
  searchDelay: Ref<string, string>;
@@ -596,50 +732,61 @@ export declare function useSearchValueRef<T extends SearchItem, K extends Search
596
732
  };
597
733
  export declare function useSessionRef<T>(name: string, defaultValue?: T | (() => T)): Ref<T | undefined>;
598
734
  export declare function useStorageRef<T>(name: string, defaultValue?: T | (() => T), cache?: number): Ref<T | undefined>;
735
+ import { ShallowRef } from 'vue';
736
+ import { TranslateInstance, TranslateList } from '@dxtmisha/functional-basic';
599
737
  /**
600
- * Getting translated text by array of keys or key string.
738
+ * Getting the translated text by an array of keys or a string with a key.
601
739
  *
602
- * @example
740
+ * It returns a `ShallowRef` that automatically updates when the global language changes.
741
+ * Use `as const` for arrays to ensure proper TypeScript key inference.
742
+ *
743
+ * ### Examples
603
744
  * ```typescript
745
+ * // 1. Using the main composable
604
746
  * const translations = useTranslateRef(['home.title', 'home.description'] as const);
747
+ *
748
+ * // 2. Using the shorthand 't'
605
749
  * const labels = t(['button.save', 'button.cancel'] as const);
606
750
  * ```
751
+ *
752
+ * @param names a string or an array with keys
753
+ * @param translateInstance a translate instance
607
754
  */
608
755
  export declare function useTranslateRef<T extends (string | string[])[]>(names: T, translateInstance?: TranslateInstance): ShallowRef<TranslateList<T>>;
756
+ /**
757
+ * Shorthand for useTranslateRef.
758
+ * Use `as const` for arrays to ensure proper TypeScript key inference.
759
+ *
760
+ * @param names a string or an array with keys
761
+ */
609
762
  export declare const t: <T extends string[]>(names: T) => ShallowRef<TranslateList<T>>;
610
763
  export declare const uiMakeFlags: () => void;
764
+ export * from '@dxtmisha/functional-basic';
765
+ import { ComputedRef, DebuggerOptions } from 'vue';
766
+ /**
767
+ * Creates a computed property that can handle asynchronous getters.
768
+ * @param getter Asynchronous function, synchronous function, or direct value to compute the result
769
+ * @param initialState initial value of result
770
+ * @param ignore values to be ignored
771
+ * @param debugOptions Used for debugging reactive computations. Supported by Vue.js library
772
+ */
611
773
  export declare function computedAsync<R>(getter: (() => Promise<R>) | (() => R) | R, initialState?: (() => R) | R, ignore?: R, debugOptions?: DebuggerOptions): ComputedRef<R | undefined>;
612
- export declare function computedByLanguage<T, R extends (T | undefined) = T | undefined>(getter: ComputedGetter<R>, getterNone?: R | (() => R), conditions?: () => boolean, debugOptions?: DebuggerOptions): ComputedRef<R>;
613
- export declare function computedEternity<T>(getter: () => Promise<T> | T, initialState?: (() => T) | T): Ref<T, T>;
614
- export interface FunctionalPluginOptions {
615
- api?: ApiConfig;
616
- translate?: TranslateConfig;
617
- location?: string | (() => string);
618
- metaSuffix?: string;
619
- icons?: IconsConfig;
620
- iconsSocial?: InputSocialIcons;
621
- router?: Router;
622
- errorCauses?: ErrorCenterCauseList;
623
- errorHandlers?: ErrorCenterHandlerList;
624
- errorCallbacks?: ErrorCenterHandlerCallback[];
625
- }
774
+ import { ComputedGetter } from 'vue';
626
775
  /**
627
- * Vue plugin for initializing global functional services.
628
- *
629
- * @example
630
- * ```typescript
631
- * import { createApp } from 'vue'
632
- * import { dxtFunctionalPlugin } from '@dxtmisha/functional'
633
- * const app = createApp(App)
634
- * app.use(dxtFunctionalPlugin, { api: { url: 'https://api.example.com' } })
635
- * ```
776
+ * Provides a `computed` reactive property whose value changes based on the current language or other conditions.
777
+ * @param getter A function that provides the main value depending on the current language or other factors.
778
+ * @param getterNone An alternative value returned if conditions are not met or the main getter returns undefined.
779
+ * @param conditions A condition determining when the main getter/**
780
+ * Types of initialization for a singleton
636
781
  */
637
- export declare const dxtFunctionalPlugin: Plugin;
638
782
  export declare enum ExecuteUseType {
639
783
  global = "global",
640
784
  provide = "provide",
641
785
  local = "local"
642
786
  }
787
+ /**
788
+ * The object returned by the factory function
789
+ */
643
790
  export type ExecuteUseReturn<R> = Readonly<R & {
644
791
  init(): Readonly<R>;
645
792
  destroyExecute?(): void;
@@ -647,15 +794,70 @@ export type ExecuteUseReturn<R> = Readonly<R & {
647
794
  /**
648
795
  * Creates a managed singleton that encapsulates initialization logic and access mode.
649
796
  *
797
+ * It supports three initialization strategies:
798
+ * - `global`: A single instance for the entire application.
799
+ * - `provide`: Shared via provide/inject in the component tree (standard for Vue 3).
800
+ * - `local`: A single instance within the closure of the returned function.
801
+ *
802
+ * @template R return type of the factory function
803
+ * @template O argument types for the factory function
804
+ * @template RI instance type with management methods
805
+ * @param callback initialization function
806
+ * @param type initialization strategy (defaults to provide)
807
+ * @returns accessor function for the singleton
808
+ *
650
809
  * @remarks
651
- * Use this function for API services, resource optimization, shared state, or external SDKs.
810
+ * Use this function in the following cases:
811
+ * - **API Services:** Always wrap API clients to ensure a single connection point and unified state.
812
+ * - **Resource Optimization:** For functions where creating multiple instances is undesirable (e.g., heavy objects, event buses).
813
+ * - **Shared State:** To share reactive state within a component tree using the `provide` strategy.
814
+ * - **External SDKs:** Initializing third-party libraries (analytics, maps, charts) that should be singletons.
652
815
  *
653
816
  * @example
654
- * ```typescript
655
- * export const useUserApi = executeUseGlobal(() => useApiGet('/api/user'));
656
- * ```
817
+ * // 1. Global API singleton (useApiGet)
818
+ * export const useUserApi = executeUseGlobal(() => {
819
+ * return useApiGet('/api/user');
820
+ * });
821
+ *
822
+ * @example
823
+ * // 2. Shared Reactive State
824
+ * export const useFeatureState = executeUseProvide(() => {
825
+ * const items = [];
826
+ * const addItem = (item) => items.push(item);
827
+ * return { items, addItem };
828
+ * });
829
+ *
830
+ * @example
831
+ * // 3. Local Caching
832
+ * export const useHeavyResource = executeUseLocal((config) => {
833
+ * return new HeavyResource(config);
834
+ * });
835
+ *
836
+ * @example
837
+ * // 4. Complex API Service (useApiManagementRef)
838
+ * export const useUserManagement = executeUseGlobal(() => {
839
+ * return useApiManagementRef(
840
+ * { path: '/api/users' }, // GET setup
841
+ * { date: (v) => new Date(v).toLocaleString() }, // Formatters
842
+ * { columns: ['name', 'email'] }, // Search
843
+ * { path: '/api/users' }, // POST (create)
844
+ * { path: (o) => `/api/users/${o.id}` }, // PUT (update)
845
+ * { path: (o) => `/api/users/${o.id}` } // DELETE (remove)
846
+ * );
847
+ * });
848
+ *
849
+ * // Usage in component:
850
+ * // const { list, loading, sendPost, sendDelete } = useUserManagement();
657
851
  */
658
852
  export declare function executeUse<R, O extends any[], RI extends ExecuteUseReturn<R> = ExecuteUseReturn<R>>(callback: (...args: O) => R, type?: ExecuteUseType): ((...args: O) => RI) | (() => RI);
853
+ /**
854
+ * Creates a global singleton.
855
+ *
856
+ * @remarks
857
+ * See {@link executeUse} for more details.
858
+ *
859
+ * @param callback Initialization function
860
+ */
659
861
  export declare function executeUseGlobal<R>(callback: () => R): (() => Readonly<R & {
660
862
  init(): Readonly<R>;
661
863
  destroyExecute?(): void;
@@ -663,6 +865,15 @@ export declare function executeUseGlobal<R>(callback: () => R): (() => Readonly<
663
865
  init(): Readonly<R>;
664
866
  destroyExecute?(): void;
665
867
  }>);
868
+ /**
869
+ * Creates a component-scoped singleton.
870
+ *
871
+ * @remarks
872
+ * Best for sharing state within a component sub-tree.
873
+ * See {@link executeUse} for more details.
874
+ *
875
+ * @param callback Initialization function
876
+ */
666
877
  export declare function executeUseProvide<R, O extends any[]>(callback: (...args: O) => R): ((...args: O) => Readonly<R & {
667
878
  init(): Readonly<R>;
668
879
  destroyExecute?(): void;
@@ -670,16 +881,129 @@ export declare function executeUseProvide<R, O extends any[]>(callback: (...args
670
881
  init(): Readonly<R>;
671
882
  destroyExecute?(): void;
672
883
  }>);
884
+ /**
885
+ * Creates a local singleton.
886
+ *
887
+ * @remarks
888
+ * Best for internal state preservation within a closure.
889
+ * See {@link executeUse} for more details.
890
+ *
891
+ * @param callback Initialization function
892
+ */
673
893
  export declare function executeUseLocal<R, O extends any[]>(callback: (...args: O) => R): ((...args: O) => Readonly<R & {
674
894
  init(): Readonly<R>;
675
895
  destroyExecute?(): void;
676
896
  }>) | (() => Readonly<R & {
677
897
  init(): Readonly<R>;
678
898
  destroyExecute?(): void;
899
+ }>);itialization function/ Функция инициализации
900
+ */
901
+ export declare function executeUseGlobal<R>(callback: () => R): (() => Readonly<R & {
902
+ /**
903
+ * Returns the raw instance without management methods/
904
+ * Возвращает чистый экземпляр без методов управления
905
+ */
906
+ init(): Readonly<R>;
907
+ /**
908
+ * Resets the cached instance (available for local and global)/
909
+ * Сбрасывает закешированный экземпляр (доступно для local и global)
910
+ */
911
+ destroyExecute?(): void;
912
+ }>) | (() => Readonly<R & {
913
+ /**
914
+ * Returns the raw instance without management methods/
915
+ * Возвращает чистый экземпляр без методов управления
916
+ */
917
+ init(): Readonly<R>;
918
+ /**
919
+ * Resets the cached instance (available for local and global)/
920
+ * Сбрасывает закешированный экземпляр (доступно для local и global)
921
+ */
922
+ destroyExecute?(): void;
923
+ }>);
924
+ /**
925
+ * Creates a component-scoped singleton.
926
+ *
927
+ * Создает компонентный синглтон.
928
+ *
929
+ * @remarks
930
+ * Best for sharing state within a component sub-tree.
931
+ * See {@link executeUse} for more details.
932
+ *
933
+ * Лучше всего подходит для совместного использования состояния внутри поддерева компонентов.
934
+ * Подробнее см. {@link executeUse}.
935
+ *
936
+ * @param callback Initialization function/ Функция инициализации
937
+ */
938
+ export declare function executeUseProvide<R, O extends any[]>(callback: (...args: O) => R): ((...args: O) => Readonly<R & {
939
+ /**
940
+ * Returns the raw instance without management methods/
941
+ * Возвращает чистый экземпляр без методов управления
942
+ */
943
+ init(): Readonly<R>;
944
+ /**
945
+ * Resets the cached instance (available for local and global)/
946
+ * Сбрасывает закешированный экземпляр (доступно для local и global)
947
+ */
948
+ destroyExecute?(): void;
949
+ }>) | (() => Readonly<R & {
950
+ /**
951
+ * Returns the raw instance without management methods/
952
+ * Возвращает чистый экземпляр без методов управления
953
+ */
954
+ init(): Readonly<R>;
955
+ /**
956
+ * Resets the cached instance (available for local and global)/
957
+ * Сбрасывает закешированный экземпляр (доступно для local и global)
958
+ */
959
+ destroyExecute?(): void;
960
+ }>);
961
+ /**
962
+ * Creates a local singleton.
963
+ *
964
+ * Создает локальный синглтон.
965
+ *
966
+ * @remarks
967
+ * Best for internal state preservation within a closure.
968
+ * See {@link executeUse} for more details.
969
+ *
970
+ * Лучше всего подходит для сохранения внутреннего состояния внутри замыкания.
971
+ * Подробнее см. {@link executeUse}.
972
+ *
973
+ * @param callback Initialization function/ Функция инициализации
974
+ */
975
+ export declare function executeUseLocal<R, O extends any[]>(callback: (...args: O) => R): ((...args: O) => Readonly<R & {
976
+ /**
977
+ * Returns the raw instance without management methods/
978
+ * Возвращает чистый экземпляр без методов управления
979
+ */
980
+ init(): Readonly<R>;
981
+ /**
982
+ * Resets the cached instance (available for local and global)/
983
+ * Сбрасывает закешированный экземпляр (доступно для local и global)
984
+ */
985
+ destroyExecute?(): void;
986
+ }>) | (() => Readonly<R & {
987
+ /**
988
+ * Returns the raw instance without management methods/
989
+ * Возвращает чистый экземпляр без методов управления
990
+ */
991
+ init(): Readonly<R>;
992
+ /**
993
+ * Resets the cached instance (available for local and global)/
994
+ * Сбрасывает закешированный экземпляр (доступно для local и global)
995
+ */
996
+ destroyExecute?(): void;
679
997
  }>);
680
998
  export declare function executeUseGlobalInit(): void;
681
999
  export declare function getInject<T>(name: string): T | undefined;
682
1000
  export declare const getOptions: (options?: ApiOptions) => RefOrNormal<ApiFetch>;
1001
+ /**
1002
+ * Executes a function if the provided argument is a function, and unwraps the resulting Vue Ref if it is reactive.
1003
+ * If the argument is a Vue Ref or a primitive value, it unwraps or returns it directly.
1004
+ * @param data reactive reference, plain value, or a function returning them
1005
+ * @returns the resolved and unwrapped value
1006
+ */
683
1007
  export declare function executeFunctionRef<T>(data: RefOrNormalOrFunction<T>): T;
684
1008
  export declare function getApiErrorRef<R>(data: RefType<ApiData<R> | undefined>): ComputedRef<ApiErrorItem | undefined>;
685
1009
  export declare function getBindRef<T, R extends ItemList>(value: RefOrNormal<T | R> | undefined, nameExtra?: RefOrNormal<ItemList> | string, name?: string): ComputedRef<R>;
@@ -689,6 +1013,274 @@ export declare function setRef<T>(item: Ref<T>, value: T): void;
689
1013
  export declare function toRefItem<T>(item: RefOrNormal<T>): Ref<T>;
690
1014
  export declare function getBind<T, R extends ItemList>(value: T | R | undefined | null, nameExtra?: ItemList | string, name?: string, except?: boolean): ConstrBind<R>;
691
1015
  export declare function getClassName<T extends ItemList>(props?: T): string | undefined;
1016
+ /**
1017
+ * Returns or generates a new element.
1018
+ *
1019
+ * Возвращает или генерирует новый элемент.
1020
+ * @param name name of the component/ названия компонента
1021
+ * @param props property of the component/ свойство компонента
1022
+ * @param index the name of the key/ названия ключа
1023
+ */
692
1024
  export declare function getIndexForRender<T extends ItemList>(name: string | any, props?: T, index?: string): string | undefined;
1025
+ import { ItemList } from '@dxtmisha/functional-basic';
1026
+ /**
1027
+ * Merges two objects with properties, taking into account their classes and styles
1028
+ *
1029
+ * Объединяет два объекта со свойствами с учётом классов и стилей в них
1030
+ * @param extra additional property/ дополнительное свойство
1031
+ * @param value input value/ входное значение
1032
+ */
693
1033
  export declare function toBind<R extends ItemList = ItemList>(extra: ItemList, value: ItemList): ConstrBind<R>;
694
- export declare function toBinds<R extends ItemList = ItemList>(...values: (ItemList | undefined)[]): ConstrBind<R>;
1034
+ import { ItemList } from '@dxtmisha/functional-basic';
1035
+ /**
1036
+ * Merges multiple objects with properties, taking into account their classes and styles
1037
+ *
1038
+ * Объединяет несколько объектов со свойствами с учётом классов и стилей в них
1039
+ * @param values list of input values/ список входных значений
1040
+ */
1041
+ export declare function toBinds<R extends ItemList = ItemList>(...values: (ItemList | undefined)[]): ConstrBind<R>;
1042
+ import { ApiData, ApiDataValidation, ApiDefaultValue, ApiErrorStorageList, ApiFetch, ApiMethodItem, SearchColumns, SearchItem, SearchOptions } from '@dxtmisha/functional-basic';
1043
+ import { Ref } from 'vue';
1044
+ /** Options for api requests/ Опции для запросов api */
1045
+ export type ApiOptions = ApiMethodItem | RefOrNormal<ApiFetch>;
1046
+ /**
1047
+ * Base type for API management values, either a single value or an array.
1048
+ *
1049
+ * Базовый тип для значений управления API: одиночное значение или массив.
1050
+ */
1051
+ export type ApiManagementValue = ApiDefaultValue | ApiDefaultValue[];
1052
+ /**
1053
+ * Configuration for the main GET request in API management.
1054
+ */
1055
+ export type ApiManagementGet<Return extends ApiManagementValue, Type extends ApiManagementValue = Return> = {
1056
+ /** API endpoint path */
1057
+ path?: RefOrNormal<string | undefined>;
1058
+ /** Additional request options */
1059
+ options?: ApiOptions;
1060
+ /** Enable reactive updates when path or options change */
1061
+ reactivity?: boolean;
1062
+ /** Condition to trigger the request */
1063
+ conditions?: RefType<boolean>;
1064
+ /** Custom transformation for the fetched data */
1065
+ transformation?: (data: Type, isResponseContractValid?: ApiDataValidation) => ApiData<Return>;
1066
+ /** Function to validate response data contract */
1067
+ validateResponseContract?: (data: Type) => ApiDataValidation;
1068
+ /** Storage of response error contracts */
1069
+ errorContract?: ApiErrorStorageList;
1070
+ /** Validation function or class constructor for data */
1071
+ typeData?: ((data: Return) => boolean) | any;
1072
+ /** Whether to clear data when the component is unmounted */
1073
+ unmounted?: boolean;
1074
+ /** Function to provide skeleton data during loading */
1075
+ skeleton?: () => Return;
1076
+ };
1077
+ /**
1078
+ * Configuration for client-side search across API data.
1079
+ */
1080
+ export type ApiManagementSearch<T extends SearchItem, K extends SearchColumns<T>> = {
1081
+ /** List of columns to search through */
1082
+ columns: K;
1083
+ /** Reactive search query */
1084
+ value?: Ref<string>;
1085
+ /** Additional search algorithm options */
1086
+ options?: SearchOptions;
1087
+ };
1088
+ /**
1089
+ * Configuration for mutation requests (POST, PUT, DELETE).
1090
+ */
1091
+ export type ApiManagementRequest<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>> = {
1092
+ /** Target API endpoint path */
1093
+ path?: RefOrNormal<string | undefined>;
1094
+ /** Action to perform after a successful request */
1095
+ action?: (data: Return | undefined) => Promise<void> | void;
1096
+ /** Transformation before sending data */
1097
+ transformation?: (data: T) => Return;
1098
+ /** Request contract validation function */
1099
+ validateRequestContract?: (data: Request) => ApiDataValidation & Return;
1100
+ /** Response contract validation function */
1101
+ validateResponseContract?: (data: T) => ApiDataValidation & Return;
1102
+ /** Storage of response error contracts */
1103
+ errorContract?: ApiErrorStorageList;
1104
+ /** Whether to wrap the payload in a 'data' property */
1105
+ toData?: boolean;
1106
+ /** Additional mutation request options */
1107
+ options?: ApiOptions;
1108
+ };
1109
+ import { Ref, PropType, ComputedRef } from 'vue';
1110
+ import { Undefined } from '@dxtmisha/functional-basic';
1111
+ /** Generic record type for constructor items */
1112
+ export type ConstrItem = Record<string, any>;
1113
+ /** Constructor value wrapper with optional value property */
1114
+ export type ConstrValue<T = any> = {
1115
+ /** Optional value of type T */
1116
+ value?: T;
1117
+ };
1118
+ /** Generic record type for constructor components */
1119
+ export type ConstrComponent = Record<string, any>;
1120
+ /** Constructor component modification type with reactive or normal values */
1121
+ export type ConstrComponentMod<P extends ConstrItem> = ConstrItem | {
1122
+ [K in keyof P]?: RefOrNormal<P[K]>;
1123
+ };
1124
+ export type ConstrExpose<E extends Element, EXPOSE extends ConstrItem> = EXPOSE & {
1125
+ elementHtml?: ComputedRef<E | undefined>;
1126
+ };
1127
+ /** Utility type to convert union types to intersection types */
1128
+ export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
1129
+ /** Extract emit item type from constructor item */
1130
+ export type ConstrEmitItem<T extends ConstrItem> = T[keyof T];
1131
+ /** Constructor emit type with proper event handler signatures */
1132
+ export type ConstrEmit<T extends ConstrItem = ConstrItem> = UnionToIntersection<ConstrEmitItem<{
1133
+ [K in keyof T]: (evt: K, ...args: T[K]) => void;
1134
+ }>>;
1135
+ /** Object type for CSS class names with boolean values */
1136
+ export type ConstrClassObject = Record<string, boolean | undefined>;
1137
+ /** Constructor class type supporting strings, arrays, and objects */
1138
+ export type ConstrClass = string | (string | ConstrClass | Undefined)[] | ConstrClassObject;
1139
+ /** Record type for mapping class names to class definitions */
1140
+ export type ConstrClassList = Record<string, ConstrClass>;
1141
+ /** Constructor classes with required main class and additional class list */
1142
+ export type ConstrClasses = {
1143
+ main: ConstrClass;
1144
+ } & ConstrClassList;
1145
+ /** Constructor style item type for individual style properties */
1146
+ export type ConstrStylesItem = string | null;
1147
+ /** Constructor styles type supporting objects and arrays of style definitions */
1148
+ export type ConstrStyles = Record<string, ConstrStylesItem> | ConstrStyles[];
1149
+ /** Constructor options interface for component configuration */
1150
+ export type ConstrOptions<COMP extends ConstrComponent, EMITS extends ConstrItem, P extends ConstrItem> = {
1151
+ /** Optional components configuration */
1152
+ components?: COMP;
1153
+ /** Optional component modifications */
1154
+ compMod?: ConstrComponentMod<P>;
1155
+ /** Optional emit handlers */
1156
+ emits?: ConstrEmit<EMITS>;
1157
+ /** Optional reactive classes */
1158
+ classes?: RefType<ConstrClasses>;
1159
+ /** Optional reactive styles */
1160
+ styles?: RefType<ConstrStyles>;
1161
+ };
1162
+ /** Constructor setup interface for component initialization */
1163
+ export type ConstrSetup<E extends Element, CLASSES extends ConstrClasses, SETUP extends ConstrItem> = {
1164
+ /** Component name */
1165
+ name: string;
1166
+ /** Reactive element reference */
1167
+ element: Ref<E | undefined>;
1168
+ /** Reactive classes */
1169
+ classes: RefType<CLASSES>;
1170
+ /** Reactive styles */
1171
+ styles: RefType<ConstrStyles>;
1172
+ } & SETUP;
1173
+ /** Constructor registration configuration */
1174
+ export type ConstrRegistration = {
1175
+ /** Optional flag for registration */
1176
+ flag?: boolean;
1177
+ /** Optional translation map */
1178
+ translate?: Record<string, string>;
1179
+ };
1180
+ /** Constructor bind type for component binding with class and style support */
1181
+ export type ConstrBind<T> = T & Record<string, any> & {
1182
+ /** Optional key */
1183
+ key?: string;
1184
+ /** Optional CSS classes */
1185
+ class?: ConstrClass;
1186
+ /** Optional styles */
1187
+ style?: ConstrStyles;
1188
+ };
1189
+ /** Constructor prop item options for Vue prop definitions */
1190
+ export type ConstrPropItemOptions<T = any> = {
1191
+ /** Vue prop type */
1192
+ type?: PropType<T>;
1193
+ /** Required flag */
1194
+ required?: boolean;
1195
+ /** Default value */
1196
+ default?: any;
1197
+ /** Custom validator function */
1198
+ validator?(value: any, props: any): boolean;
1199
+ };
1200
+ /** Constructor prop item type with options or direct PropType */
1201
+ export type ConstrPropItem<T = any> = ConstrPropItemOptions<T> | PropType<T>;
1202
+ /** Constructor props type for component prop definitions */
1203
+ export type ConstrProps<P = Record<string, any>> = {
1204
+ [K in keyof P]: ConstrPropItem<P[K]>;
1205
+ };
1206
+ /** Props for link handling */
1207
+ export type ConstrHrefProps = {
1208
+ /** Hyperlink reference */
1209
+ href?: string;
1210
+ };
1211
+ /** Type of list item */
1212
+ export type ListType = 'item' | 'space' | 'line' | 'subtitle' | 'html' | 'menu' | 'menu-group' | 'group';
1213
+ /** Basic data structure for list item */
1214
+ export type ListDataBasic = {
1215
+ /** Optional display label */
1216
+ label?: NumberOrString;
1217
+ /** Any value associated with the item */
1218
+ value?: any;
1219
+ /** Search text for filtering */
1220
+ search?: string;
1221
+ };
1222
+ /** Extended list item with type and index */
1223
+ export type ListDataItem<Item extends ListDataBasic = ListDataBasic> = ConstrBind<Item & {
1224
+ /** Parent item identifier */
1225
+ parent?: string;
1226
+ /** Type of list item */
1227
+ type: ListType;
1228
+ /** Unique item identifier */
1229
+ index: string;
1230
+ /** Whether the item is disabled */
1231
+ disabled?: boolean;
1232
+ }>;
1233
+ /** Array of list data items */
1234
+ export type ListList<Item extends ListDataBasic = ListDataBasic> = ListDataItem<Item>[];
1235
+ /** List or record structure for list data */
1236
+ export type ListRecord<Item extends ListDataBasic = ListDataBasic> = Item[] | Record<string, Item>;
1237
+ /** Extended list item with additional state properties */
1238
+ export type ListDataFullItem<Item extends ListDataBasic = ListDataBasic> = ListDataItem<Item> & {
1239
+ /** Whether the item has focus */
1240
+ focus: boolean;
1241
+ /** Highlighted text portion */
1242
+ highlight?: string;
1243
+ /** Whether the item is selected */
1244
+ selected: boolean;
1245
+ /** Whether the item is disabled */
1246
+ disabled?: boolean;
1247
+ };
1248
+ /** Array of extended list items with state */
1249
+ export type ListDataFull<Item extends ListDataBasic = ListDataBasic> = ListDataFullItem<Item>[];
1250
+ /** Input item for list creation */
1251
+ export type ListListInputItem<Item extends ListDataBasic = ListDataBasic> = ConstrBind<Item>;
1252
+ /** Various input formats for list creation */
1253
+ export type ListListInput<Item extends ListDataBasic = ListDataBasic> = ListListInputItem<Item>[] | string[] | Record<string, ListListInputItem<Item>> | Record<string, string>;
1254
+ /** Single selected item identifier */
1255
+ export type ListSelectedItem = NumberOrStringOrBoolean;
1256
+ /** Single or multiple selected items */
1257
+ export type ListSelectedList = ListSelectedItem | ListSelectedItem[];
1258
+ /** Name of selected list item */
1259
+ export type ListName = string | number | undefined;
1260
+ /** Array of list item names */
1261
+ export type ListNames = ListName[];
1262
+ /** Union type for Vue reactive references (computed or ref) */
1263
+ export type RefType<T> = ComputedRef<T> | Ref<T>;
1264
+ /** Union type for Vue reactive references that can be undefined */
1265
+ export type RefUndefined<T> = RefType<T | undefined>;
1266
+ /** Union type that can be either a Vue reactive reference or a normal value */
1267
+ export type RefOrNormal<T> = RefType<T> | T;
1268
+ /** Union type that can be either a Vue reactive reference or a normal value or a function that returns a Vue reactive reference or a normal value */
1269
+ export type RefOrNormalOrFunction<T> = RefOrNormal<T> | (() => RefOrNormal<T>);
1270
+ /** Union type for Vue raw children content (strings, numbers, booleans, VNodes, arrays, functions) */
1271
+ export type RawChildren = string | number | boolean | VNode | VNodeArrayChildren | (() => any);
1272
+ /** Type for Vue raw slots with optional stability flag */
1273
+ export type RawSlots = {
1274
+ /** Slot name mapping to unknown content */
1275
+ [name: string]: unknown;
1276
+ /** Optional stability flag for performance optimization */
1277
+ $stable?: boolean;
1278
+ };
1279
+ /** Search list data */
1280
+ export type SearchListValueRef<T extends SearchItem> = RefOrNormal<SearchListValue<T>>;
1281
+ /** Search list input */
1282
+ export type SearchListInput<T extends SearchItem> = SearchListValueRef<T> | (() => SearchListValueRef<T>);
1283
+ /** Search columns ref */
1284
+ export type SearchColumnsRef<T extends SearchItem, K extends SearchColumns<T>> = RefOrNormal<K>;
1285
+ /** Search columns input */
1286
+ export type SearchColumnsInput<T extends SearchItem, K extends SearchColumns<T>> = SearchColumnsRef<T, K> | (() => SearchColumnsRef<T, K>);