@dxtmisha/functional 1.15.8 → 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-description.md +22 -5
- package/ai-mcp-resources.json +38 -0
- package/ai-types.md +707 -202
- package/dist/library.js +20 -21
- package/package.json +4 -4
- package/ai-mcp.json +0 -38
- /package/{ai-prompts → ai-resources}/api-reference.md +0 -0
- /package/{ai-prompts → ai-resources}/localization-seo.md +0 -0
- /package/{ai-prompts → ai-resources}/reactivity-lists.md +0 -0
- /package/{ai-prompts → ai-resources}/storage-state.md +0 -0
package/ai-types.md
CHANGED
|
@@ -1,154 +1,30 @@
|
|
|
1
1
|
All these methods are in the @dxtmisha/functional library.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
import { Datetime, GeoDate, GeoFirstDay, GeoHours, NumberOrStringOrDate, ElementOrString, ElementOrWindow, EventItem, EventListenerDetail, EventOptions, GeoFlag, GeoFlagItem, GeoFlagNational, ItemValue, NumberOrString, GeoItemFull, GeoUnit, ApiInstance, ApiData, ApiDataValidation, ApiErrorStorageList, ApiErrorItem, ApiFetch, FormattersListColumns, FormattersOptionsList, SearchColumns, SearchFormatList, FormattersListProp, FormattersReturn, MetaRobots, Meta, SearchItem, SearchOptions, TranslateInstance, TranslateList, ApiConfig, ErrorCenterCauseList, ErrorCenterHandlerCallback, ErrorCenterHandlerList, IconsConfig, TranslateConfig, ItemList, ApiDefaultValue, ApiMethodItem, Undefined, NumberOrStringOrBoolean, SearchListValue } from '@dxtmisha/functional-basic';
|
|
5
|
-
import { InputSocialIcons } from '@dxtmisha/media';
|
|
6
|
-
import { RouteLocationRaw, Router, _RouterClassic } from 'vue-router';
|
|
7
|
-
export type RefType<T> = ComputedRef<T> | Ref<T>;
|
|
8
|
-
export type RefUndefined<T> = RefType<T | undefined>;
|
|
9
|
-
export type RefOrNormal<T> = RefType<T> | T;
|
|
10
|
-
export type RefOrNormalOrFunction<T> = RefOrNormal<T> | (() => RefOrNormal<T>);
|
|
11
|
-
export type RawChildren = string | number | boolean | VNode | VNodeArrayChildren | (() => any);
|
|
12
|
-
export type RawSlots = {
|
|
13
|
-
[name: string]: unknown;
|
|
14
|
-
$stable?: boolean;
|
|
15
|
-
};
|
|
16
|
-
export type ApiOptions = ApiMethodItem | RefOrNormal<ApiFetch>;
|
|
17
|
-
export type ApiManagementValue = ApiDefaultValue | ApiDefaultValue[];
|
|
18
|
-
export type ApiManagementGet<Return extends ApiManagementValue, Type extends ApiManagementValue = Return> = {
|
|
19
|
-
path?: RefOrNormal<string | undefined>;
|
|
20
|
-
options?: ApiOptions;
|
|
21
|
-
reactivity?: boolean;
|
|
22
|
-
conditions?: RefType<boolean>;
|
|
23
|
-
transformation?: (data: Type, isResponseContractValid?: ApiDataValidation) => ApiData<Return>;
|
|
24
|
-
validateResponseContract?: (data: Type) => ApiDataValidation;
|
|
25
|
-
errorContract?: ApiErrorStorageList;
|
|
26
|
-
typeData?: ((data: Return) => boolean) | any;
|
|
27
|
-
unmounted?: boolean;
|
|
28
|
-
skeleton?: () => Return;
|
|
29
|
-
};
|
|
30
|
-
export type ApiManagementSearch<T extends SearchItem, K extends SearchColumns<T>> = {
|
|
31
|
-
columns: K;
|
|
32
|
-
value?: Ref<string>;
|
|
33
|
-
options?: SearchOptions;
|
|
34
|
-
};
|
|
35
|
-
export type ApiManagementRequest<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>> = {
|
|
36
|
-
path?: RefOrNormal<string | undefined>;
|
|
37
|
-
action?: (data: Return | undefined) => Promise<void> | void;
|
|
38
|
-
transformation?: (data: T) => Return;
|
|
39
|
-
validateRequestContract?: (data: Request) => ApiDataValidation & Return;
|
|
40
|
-
validateResponseContract?: (data: T) => ApiDataValidation & Return;
|
|
41
|
-
errorContract?: ApiErrorStorageList;
|
|
42
|
-
toData?: boolean;
|
|
43
|
-
options?: ApiOptions;
|
|
44
|
-
};
|
|
45
|
-
export type ConstrItem = Record<string, any>;
|
|
46
|
-
export type ConstrValue<T = any> = {
|
|
47
|
-
value?: T;
|
|
48
|
-
};
|
|
49
|
-
export type ConstrComponent = Record<string, any>;
|
|
50
|
-
export type ConstrComponentMod<P extends ConstrItem> = ConstrItem | {
|
|
51
|
-
[K in keyof P]?: RefOrNormal<P[K]>;
|
|
52
|
-
};
|
|
53
|
-
export type ConstrExpose<E extends Element, EXPOSE extends ConstrItem> = EXPOSE & {
|
|
54
|
-
elementHtml?: ComputedRef<E | undefined>;
|
|
55
|
-
};
|
|
56
|
-
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
57
|
-
export type ConstrEmitItem<T extends ConstrItem> = T[keyof T];
|
|
58
|
-
export type ConstrEmit<T extends ConstrItem = ConstrItem> = UnionToIntersection<ConstrEmitItem<{
|
|
59
|
-
[K in keyof T]: (evt: K, ...args: T[K]) => void;
|
|
60
|
-
}>>;
|
|
61
|
-
export type ConstrClassObject = Record<string, boolean | undefined>;
|
|
62
|
-
export type ConstrClass = string | (string | ConstrClass | Undefined)[] | ConstrClassObject;
|
|
63
|
-
export type ConstrClassList = Record<string, ConstrClass>;
|
|
64
|
-
export type ConstrClasses = {
|
|
65
|
-
main: ConstrClass;
|
|
66
|
-
} & ConstrClassList;
|
|
67
|
-
export type ConstrStylesItem = string | null;
|
|
68
|
-
export type ConstrStyles = Record<string, ConstrStylesItem> | ConstrStyles[];
|
|
69
|
-
export type ConstrOptions<COMP extends ConstrComponent, EMITS extends ConstrItem, P extends ConstrItem> = {
|
|
70
|
-
components?: COMP;
|
|
71
|
-
compMod?: ConstrComponentMod<P>;
|
|
72
|
-
emits?: ConstrEmit<EMITS>;
|
|
73
|
-
classes?: RefType<ConstrClasses>;
|
|
74
|
-
styles?: RefType<ConstrStyles>;
|
|
75
|
-
};
|
|
76
|
-
export type ConstrSetup<E extends Element, CLASSES extends ConstrClasses, SETUP extends ConstrItem> = {
|
|
77
|
-
name: string;
|
|
78
|
-
element: Ref<E | undefined>;
|
|
79
|
-
classes: RefType<CLASSES>;
|
|
80
|
-
styles: RefType<ConstrStyles>;
|
|
81
|
-
} & SETUP;
|
|
82
|
-
export type ConstrRegistration = {
|
|
83
|
-
flag?: boolean;
|
|
84
|
-
translate?: Record<string, string>;
|
|
85
|
-
};
|
|
86
|
-
export type ConstrBind<T> = T & Record<string, any> & {
|
|
87
|
-
key?: string;
|
|
88
|
-
class?: ConstrClass;
|
|
89
|
-
style?: ConstrStyles;
|
|
90
|
-
};
|
|
91
|
-
export type ConstrPropItemOptions<T = any> = {
|
|
92
|
-
type?: PropType<T>;
|
|
93
|
-
required?: boolean;
|
|
94
|
-
default?: any;
|
|
95
|
-
validator?(value: any, props: any): boolean;
|
|
96
|
-
};
|
|
97
|
-
export type ConstrPropItem<T = any> = ConstrPropItemOptions<T> | PropType<T>;
|
|
98
|
-
export type ConstrProps<P = Record<string, any>> = {
|
|
99
|
-
[K in keyof P]: ConstrPropItem<P[K]>;
|
|
100
|
-
};
|
|
101
|
-
export type ConstrHrefProps = {
|
|
102
|
-
href?: string;
|
|
103
|
-
};
|
|
104
|
-
export type ListType = 'item' | 'space' | 'line' | 'subtitle' | 'html' | 'menu' | 'menu-group' | 'group';
|
|
105
|
-
export type ListDataBasic = {
|
|
106
|
-
label?: NumberOrString;
|
|
107
|
-
value?: any;
|
|
108
|
-
search?: string;
|
|
109
|
-
};
|
|
110
|
-
export type ListDataItem<Item extends ListDataBasic = ListDataBasic> = ConstrBind<Item & {
|
|
111
|
-
parent?: string;
|
|
112
|
-
type: ListType;
|
|
113
|
-
index: string;
|
|
114
|
-
disabled?: boolean;
|
|
115
|
-
}>;
|
|
116
|
-
export type ListList<Item extends ListDataBasic = ListDataBasic> = ListDataItem<Item>[];
|
|
117
|
-
export type ListRecord<Item extends ListDataBasic = ListDataBasic> = ListList<Item> | Record<string, any>;
|
|
118
|
-
export type ListDataFullItem<Item extends ListDataBasic = ListDataBasic> = ListDataItem<Item> & {
|
|
119
|
-
focus: boolean;
|
|
120
|
-
highlight?: string;
|
|
121
|
-
selected: boolean;
|
|
122
|
-
disabled?: boolean;
|
|
123
|
-
};
|
|
124
|
-
export type ListDataFull<Item extends ListDataBasic = ListDataBasic> = ListDataFullItem<Item>[];
|
|
125
|
-
export type ListListInputItem<Item extends ListDataBasic = ListDataBasic> = ConstrBind<Item>;
|
|
126
|
-
export type ListListInput<Item extends ListDataBasic = ListDataBasic> = ListListInputItem<Item>[] | string[] | Record<string, ListListInputItem<Item>> | Record<string, string>;
|
|
127
|
-
export type ListSelectedItem = NumberOrStringOrBoolean;
|
|
128
|
-
export type ListSelectedList = ListSelectedItem | ListSelectedItem[];
|
|
129
|
-
export type ListName = string | number | undefined;
|
|
130
|
-
export type ListNames = ListName[];
|
|
131
|
-
export type SearchListValueRef<T extends SearchItem> = RefOrNormal<SearchListValue<T>>;
|
|
132
|
-
export type SearchListInput<T extends SearchItem> = SearchListValueRef<T> | (() => SearchListValueRef<T>);
|
|
133
|
-
export type SearchColumnsRef<T extends SearchItem, K extends SearchColumns<T>> = RefOrNormal<K>;
|
|
134
|
-
export type SearchColumnsInput<T extends SearchItem, K extends SearchColumns<T>> = SearchColumnsRef<T, K> | (() => SearchColumnsRef<T, K>);
|
|
3
|
+
/** Base class for working with the constructor. */
|
|
135
4
|
export declare abstract class DesignAbstract<T extends Record<string, any>, C extends Record<string, any>> {
|
|
5
|
+
protected readonly callback?: ((event: C) => void) | undefined;
|
|
136
6
|
constructor(props: T, callback?: ((event: C) => void) | undefined, changed?: string[]);
|
|
137
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;
|
|
138
10
|
makeCallback(compelled?: boolean): void;
|
|
11
|
+
protected makeCallbackItem(): void;
|
|
12
|
+
protected abstract initEvent(): void;
|
|
139
13
|
}
|
|
14
|
+
/**
|
|
140
15
|
export declare abstract class DesignAsyncAbstract<T extends Record<string, any>, C extends Record<string, any>> extends DesignAbstract<T, C> {
|
|
141
16
|
make(compelled?: boolean): this;
|
|
142
17
|
makeCallback(compelled?: boolean): Promise<void>;
|
|
18
|
+
protected abstract initEvent(): Promise<void>;
|
|
143
19
|
}
|
|
144
20
|
export declare class DesignChanged<T extends Record<string, any>> {
|
|
145
21
|
constructor(props: T, watch?: string[]);
|
|
146
22
|
is(name: string | string[]): boolean;
|
|
147
23
|
isChanged(): boolean;
|
|
148
24
|
update(): void;
|
|
25
|
+
protected isDifferent(name: string): boolean;
|
|
149
26
|
}
|
|
150
|
-
export declare class DesignComp<COMP extends ConstrComponent, P extends ConstrItem> extends DesignComponents<COMP, P> {
|
|
151
|
-
}
|
|
27
|
+
export declare class DesignComp<COMP extends ConstrComponent, P extends ConstrItem> extends DesignComponents<COMP, P> {}
|
|
152
28
|
export declare class DesignComponents<COMP extends ConstrComponent, P extends ConstrItem> {
|
|
153
29
|
constructor(components?: COMP, modification?: ConstrComponentMod<P> | undefined);
|
|
154
30
|
is<K extends keyof COMP>(name: K): name is K;
|
|
@@ -157,9 +33,11 @@ export declare class DesignComponents<COMP extends ConstrComponent, P extends Co
|
|
|
157
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[];
|
|
158
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;
|
|
159
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>;
|
|
160
37
|
}
|
|
161
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> {
|
|
162
|
-
constructor(name: string, props: Readonly<P>, options?: ConstrOptions<COMP, EMITS, P> | undefined);
|
|
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 {
|
|
@@ -203,6 +107,10 @@ export declare class GeoFlagRef {
|
|
|
203
107
|
getNational(codes?: RefOrNormal<string[] | undefined>): ComputedRef<GeoFlagNational[]>;
|
|
204
108
|
getNationalLanguage(codes?: RefOrNormal<string[] | undefined>): ComputedRef<GeoFlagNational[]>;
|
|
205
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Reactive class for managing the formatting of numbers and dates.
|
|
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`.
|
|
113
|
+
*/
|
|
206
114
|
export declare class GeoIntlRef {
|
|
207
115
|
constructor(code?: RefOrNormal<string>);
|
|
208
116
|
display(value?: RefOrNormal<string>, typeOptions?: Intl.DisplayNamesOptions['type'] | Intl.DisplayNamesOptions): ComputedRef<string>;
|
|
@@ -303,6 +211,10 @@ export declare class ListDataRef {
|
|
|
303
211
|
getFirstItemByParent(parent: string | undefined): ListDataItem | undefined;
|
|
304
212
|
getLastItemByParent(parent: string | undefined): ListDataItem | undefined;
|
|
305
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;
|
|
306
218
|
}
|
|
307
219
|
export declare class RouterItemRef {
|
|
308
220
|
static get(): _RouterClassic;
|
|
@@ -332,20 +244,21 @@ export declare class ScrollbarWidthRef {
|
|
|
332
244
|
*
|
|
333
245
|
* const userSchema = S.Struct({ id: S.Number, name: S.String })
|
|
334
246
|
*
|
|
247
|
+
* // Data will be pre-fetched on the server during SSR (onServerPrefetch)
|
|
335
248
|
* const { data, loading, errorItem, isResponseContractValid } = useApiAsyncRef(
|
|
336
249
|
* '/users/1',
|
|
337
250
|
* { method: 'GET' },
|
|
338
|
-
* true,
|
|
339
|
-
* undefined,
|
|
340
|
-
* undefined,
|
|
341
|
-
* (data) => {
|
|
251
|
+
* true, // reactivity
|
|
252
|
+
* undefined, // conditions
|
|
253
|
+
* undefined, // transformation
|
|
254
|
+
* (data) => { // validateResponseContract
|
|
342
255
|
* try {
|
|
343
256
|
* return { status: 'success', data: S.decodeUnknownSync(userSchema)(data) }
|
|
344
257
|
* } catch (e) {
|
|
345
258
|
* return { status: 'error', errors: e }
|
|
346
259
|
* }
|
|
347
260
|
* },
|
|
348
|
-
* [
|
|
261
|
+
* [ // errorContract
|
|
349
262
|
* { status: 404, message: 'User not found' }
|
|
350
263
|
* ]
|
|
351
264
|
* )
|
|
@@ -354,29 +267,62 @@ export declare class ScrollbarWidthRef {
|
|
|
354
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>;
|
|
355
268
|
export interface UseApiDeleteSetup<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>> extends Omit<UseApiRequestSetup<T, Request, Return>, 'method'> {
|
|
356
269
|
}
|
|
270
|
+
/**
|
|
271
|
+
* Use API delete request.
|
|
272
|
+
* This is a convenient wrapper over `useApiRequest` that pre-fills the DELETE method.
|
|
273
|
+
*/
|
|
357
274
|
export declare function useApiDelete<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>>(setup: UseApiDeleteSetup<T, Request, Return>): {
|
|
358
275
|
loading: Ref<boolean, boolean>;
|
|
359
276
|
send(request?: Request | undefined): Promise<Return | undefined>;
|
|
360
277
|
};
|
|
361
278
|
export interface UseApiGetSetup<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>> extends Omit<UseApiRequestSetup<T, Request, Return>, 'method'> {
|
|
362
279
|
}
|
|
280
|
+
/**
|
|
281
|
+
* Use API get request.
|
|
282
|
+
* This is a convenient wrapper over `useApiRequest` that pre-fills the GET method.
|
|
283
|
+
*/
|
|
363
284
|
export declare function useApiGet<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>>(setup: UseApiGetSetup<T, Request, Return>): {
|
|
364
285
|
loading: Ref<boolean, boolean>;
|
|
365
286
|
send(request?: Request | undefined): Promise<Return | undefined>;
|
|
366
287
|
};
|
|
288
|
+
import { ApiInstance, ArrayToItem, FormattersListColumns, FormattersOptionsList, SearchColumns, ApiDataValidation, SearchFormatList, ApiData, ApiErrorItem, ApiFetch } from '@dxtmisha/functional-basic';
|
|
289
|
+
import { ComputedRef, Ref } from 'vue';
|
|
367
290
|
/**
|
|
368
291
|
* Asynchronous reactive composable for API management requests with built-in SSR support.
|
|
369
292
|
* Wraps `useApiManagementRef` and immediately calls `initSsr()` to ensure data is pre-fetched on the server side.
|
|
370
293
|
* Use this composable ONLY if you need the request to be executed on the server side during SSR.
|
|
371
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 для выполнения запроса
|
|
372
318
|
*/
|
|
373
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): {
|
|
374
320
|
isValid: ComputedRef<boolean>;
|
|
375
321
|
isResponseContractValid: ComputedRef<boolean>;
|
|
376
|
-
responseValidationResult: ComputedRef<ApiDataValidation | undefined>;
|
|
322
|
+
responseValidationResult: ComputedRef< ApiDataValidation | undefined>;
|
|
377
323
|
list: ComputedRef<SearchFormatList<ItemFormatters, Columns>>;
|
|
378
|
-
readonly data: ComputedRef<ApiData<Return> | undefined>;
|
|
379
|
-
errorItem: ComputedRef<ApiErrorItem | undefined>;
|
|
324
|
+
readonly data: ComputedRef< ApiData<Return> | undefined>;
|
|
325
|
+
errorItem: ComputedRef< ApiErrorItem | undefined>;
|
|
380
326
|
readonly length: ComputedRef<number>;
|
|
381
327
|
lengthData: ComputedRef<number>;
|
|
382
328
|
starting: ComputedRef<boolean>;
|
|
@@ -392,49 +338,77 @@ export declare function useApiManagementAsyncRef<Return extends ApiManagementVal
|
|
|
392
338
|
initSsr: () => void;
|
|
393
339
|
reset: () => Promise<void>;
|
|
394
340
|
abort: () => void;
|
|
395
|
-
sendPost: (request?: ApiFetch["request"]) => Promise<ApiData<Post> | undefined>;
|
|
396
|
-
sendPut: (request?: ApiFetch["request"]) => Promise<ApiData<Put> | undefined>;
|
|
397
|
-
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>;
|
|
398
344
|
};
|
|
399
345
|
/**
|
|
400
346
|
* A powerful composable for comprehensive API request orchestration.
|
|
401
347
|
* It centrally manages data loading (GET), list formatting, client-side searching,
|
|
402
348
|
* and mutations (POST, PUT, DELETE) through a single reactive interface.
|
|
403
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
|
|
359
|
+
*
|
|
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
|
+
*
|
|
404
371
|
* @note This hook is recommended to be used in tandem with `executeUse` for centralized state management.
|
|
405
372
|
* By wrapping `useApiManagementRef` in `executeUseProvide` or `executeUseGlobal`, you can ensure
|
|
406
373
|
* a single source of truth across the component tree or the entire application.
|
|
407
374
|
*
|
|
408
375
|
* @remarks
|
|
409
376
|
* Data formatting guidelines for `formattersOptions`:
|
|
410
|
-
* - Recommended for formatting
|
|
411
|
-
* - Not recommended for formatting
|
|
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.
|
|
412
379
|
*
|
|
413
380
|
* @example
|
|
381
|
+
* // 1. Comprehensive API orchestration
|
|
414
382
|
* const products = useApiManagementRef(
|
|
415
383
|
* {
|
|
416
384
|
* path: '/api/v1/products',
|
|
417
385
|
* skeleton: () => Array(5).fill({ id: 0, name: 'Loading...', price: 0 })
|
|
418
386
|
* },
|
|
419
387
|
* {
|
|
388
|
+
* // Formatters for display
|
|
420
389
|
* price: (v) => `${v} USD`,
|
|
421
390
|
* created_at: (v) => new Date(v).toLocaleDateString()
|
|
422
391
|
* },
|
|
423
392
|
* {
|
|
393
|
+
* // Client-side search setup
|
|
424
394
|
* columns: ['name', 'category']
|
|
425
395
|
* },
|
|
426
|
-
* { path: '/api/v1/products' },
|
|
427
|
-
* { path: (data) => `/api/v1/products/${data.id}` },
|
|
428
|
-
* { path: (data) => `/api/v1/products/${data.id}` }
|
|
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)
|
|
429
399
|
* );
|
|
400
|
+
*
|
|
401
|
+
* // Accessing data:
|
|
402
|
+
* // products.list.value -> processed, formatted, and searched list
|
|
403
|
+
* // products.sendPost({ name: 'New Product', price: 100 }) -> execute mutation
|
|
430
404
|
*/
|
|
431
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): {
|
|
432
406
|
isValid: ComputedRef<boolean>;
|
|
433
407
|
isResponseContractValid: ComputedRef<boolean>;
|
|
434
|
-
responseValidationResult: ComputedRef<ApiDataValidation | undefined>;
|
|
408
|
+
responseValidationResult: ComputedRef< ApiDataValidation | undefined>;
|
|
435
409
|
list: ComputedRef<SearchFormatList<ItemFormatters, Columns>>;
|
|
436
410
|
readonly data: ComputedRef<ApiData<Return> | undefined>;
|
|
437
|
-
errorItem: ComputedRef<ApiErrorItem | undefined>;
|
|
411
|
+
errorItem: ComputedRef< ApiErrorItem | undefined>;
|
|
438
412
|
readonly length: ComputedRef<number>;
|
|
439
413
|
lengthData: ComputedRef<number>;
|
|
440
414
|
starting: ComputedRef<boolean>;
|
|
@@ -456,12 +430,20 @@ export declare function useApiManagementRef<Return extends ApiManagementValue, F
|
|
|
456
430
|
};
|
|
457
431
|
export interface UseApiPostSetup<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>> extends Omit<UseApiRequestSetup<T, Request, Return>, 'method'> {
|
|
458
432
|
}
|
|
433
|
+
/**
|
|
434
|
+
* Use API post request.
|
|
435
|
+
* This is a convenient wrapper over `useApiRequest` that pre-fills the POST method.
|
|
436
|
+
*/
|
|
459
437
|
export declare function useApiPost<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>>(setup: UseApiPostSetup<T, Request, Return>): {
|
|
460
438
|
loading: Ref<boolean, boolean>;
|
|
461
439
|
send(request?: Request | undefined): Promise<Return | undefined>;
|
|
462
440
|
};
|
|
463
441
|
export interface UseApiPutSetup<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>> extends Omit<UseApiRequestSetup<T, Request, Return>, 'method'> {
|
|
464
442
|
}
|
|
443
|
+
/**
|
|
444
|
+
* Use API put request.
|
|
445
|
+
* This is a convenient wrapper over `useApiRequest` that pre-fills the PUT method.
|
|
446
|
+
*/
|
|
465
447
|
export declare function useApiPut<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>>(setup: UseApiPutSetup<T, Request, Return>): {
|
|
466
448
|
loading: Ref<boolean, boolean>;
|
|
467
449
|
send(request?: Request | undefined): Promise<Return | undefined>;
|
|
@@ -495,22 +477,23 @@ export interface UseApiRef<R> {
|
|
|
495
477
|
* import { Schema as S } from '@effect/schema'
|
|
496
478
|
* import { useApiRef } from '@dxtmisha/functional'
|
|
497
479
|
*
|
|
480
|
+
* // Define a schema using @effect/schema
|
|
498
481
|
* const userSchema = S.Struct({ id: S.Number, name: S.String })
|
|
499
482
|
*
|
|
500
483
|
* const { data, loading, errorItem, isResponseContractValid } = useApiRef(
|
|
501
484
|
* '/users/1',
|
|
502
485
|
* { method: 'GET' },
|
|
503
|
-
* true,
|
|
504
|
-
* undefined,
|
|
505
|
-
* (data) => ({ ...data, isTransformed: true }),
|
|
506
|
-
* (data) => {
|
|
486
|
+
* true, // reactivity
|
|
487
|
+
* undefined, // conditions
|
|
488
|
+
* (data) => ({ ...data, isTransformed: true }), // transformation
|
|
489
|
+
* (data) => { // validateResponseContract
|
|
507
490
|
* try {
|
|
508
491
|
* return { status: 'success', data: S.decodeUnknownSync(userSchema)(data) }
|
|
509
492
|
* } catch (e) {
|
|
510
493
|
* return { status: 'error', errors: e }
|
|
511
494
|
* }
|
|
512
495
|
* },
|
|
513
|
-
* [
|
|
496
|
+
* [ // errorContract (ApiErrorStorageList)
|
|
514
497
|
* {
|
|
515
498
|
* status: 404,
|
|
516
499
|
* message: 'User not found'
|
|
@@ -520,17 +503,95 @@ export interface UseApiRef<R> {
|
|
|
520
503
|
* ```
|
|
521
504
|
*/
|
|
522
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
|
+
*/
|
|
523
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
|
+
*/
|
|
524
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
|
+
*/
|
|
525
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
|
+
*/
|
|
526
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
|
+
*/
|
|
527
540
|
action?: (data: Return | undefined) => Promise<void> | void;
|
|
541
|
+
/**
|
|
542
|
+
* Transformation function that modifies the raw response data before returning it.
|
|
543
|
+
*
|
|
544
|
+
* Функция трансформации, которая преобразует исходные данные ответа перед их возвратом.
|
|
545
|
+
*/
|
|
528
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
|
+
*/
|
|
529
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
|
+
*/
|
|
530
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
|
+
*/
|
|
531
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
|
+
*/
|
|
532
583
|
toData?: boolean;
|
|
584
|
+
/**
|
|
585
|
+
* Additional request options (headers, query params, etc.).
|
|
586
|
+
*
|
|
587
|
+
* Дополнительные опции запроса (заголовки, параметры запроса и т.д.).
|
|
588
|
+
*/
|
|
533
589
|
options?: ApiOptions;
|
|
590
|
+
/**
|
|
591
|
+
* Custom Api instance to execute the request on. Defaults to global Api singleton instance.
|
|
592
|
+
*
|
|
593
|
+
* Кастомный экземпляр класса Api для выполнения запроса. По умолчанию используется глобальный синглтон Api.
|
|
594
|
+
*/
|
|
534
595
|
apiInstance?: ApiInstance;
|
|
535
596
|
}
|
|
536
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>): {
|
|
@@ -540,6 +601,11 @@ export declare function useApiRequest<T, Request extends ApiFetch['request'] = A
|
|
|
540
601
|
type BroadcastValueItem<T> = T | string | undefined;
|
|
541
602
|
export declare function useBroadcastValueRef<T>(name: string, defaultValue?: T | string | (() => (T | string))): Ref<BroadcastValueItem<T>>;
|
|
542
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
|
+
*/
|
|
543
609
|
export declare function useFormattersRef<Options extends FormattersOptionsList = FormattersOptionsList, List extends FormattersListProp = FormattersListProp>(list: RefType<List | undefined>, options: Options): {
|
|
544
610
|
listFormat: ComputedRef<FormattersReturn<List, Options>>;
|
|
545
611
|
length: ComputedRef<number>;
|
|
@@ -577,6 +643,10 @@ export declare const useLazyRef: (options?: IntersectionObserverInit) => {
|
|
|
577
643
|
disconnectLazy: () => void | undefined;
|
|
578
644
|
};
|
|
579
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
|
+
*/
|
|
580
650
|
export declare const useMeta: () => Readonly<{
|
|
581
651
|
meta: Meta;
|
|
582
652
|
title: Ref<string, string>;
|
|
@@ -600,7 +670,7 @@ export declare const useMeta: () => Readonly<{
|
|
|
600
670
|
setRobots: (value: MetaRobots) => void;
|
|
601
671
|
setSiteName: (value: string) => void;
|
|
602
672
|
setSuffix: (suffix: string) => void;
|
|
603
|
-
}
|
|
673
|
+
} & {
|
|
604
674
|
init(): Readonly<{
|
|
605
675
|
meta: Meta;
|
|
606
676
|
title: Ref<string, string>;
|
|
@@ -636,6 +706,13 @@ export declare const useRouterList: <T extends ListDataBasic>(list: RefType<Cons
|
|
|
636
706
|
to: (name?: string) => void;
|
|
637
707
|
toMain(): void;
|
|
638
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
|
+
*/
|
|
639
716
|
export declare function useSearchRef<T extends SearchItem, K extends SearchColumns<T>>(list: SearchListInput<T>, columns?: SearchColumnsInput<T, K>, value?: Ref<string>, options?: SearchOptions): {
|
|
640
717
|
isSearch: ComputedRef<boolean>;
|
|
641
718
|
search: Ref<string, string>;
|
|
@@ -643,6 +720,11 @@ export declare function useSearchRef<T extends SearchItem, K extends SearchColum
|
|
|
643
720
|
listSearch: ComputedRef<SearchFormatList<T, K>>;
|
|
644
721
|
length: ComputedRef<number>;
|
|
645
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
|
+
*/
|
|
646
728
|
export declare function useSearchValueRef<T extends SearchItem, K extends SearchColumns<T>>(item: SearchList<T, K>, value?: Ref<string>): {
|
|
647
729
|
search: Ref<string, string>;
|
|
648
730
|
searchDelay: Ref<string, string>;
|
|
@@ -650,87 +732,131 @@ export declare function useSearchValueRef<T extends SearchItem, K extends Search
|
|
|
650
732
|
};
|
|
651
733
|
export declare function useSessionRef<T>(name: string, defaultValue?: T | (() => T)): Ref<T | undefined>;
|
|
652
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';
|
|
653
737
|
/**
|
|
654
738
|
* Getting the translated text by an array of keys or a string with a key.
|
|
655
|
-
*
|
|
739
|
+
*
|
|
740
|
+
* It returns a `ShallowRef` that automatically updates when the global language changes.
|
|
656
741
|
* Use `as const` for arrays to ensure proper TypeScript key inference.
|
|
657
742
|
*
|
|
658
|
-
*
|
|
743
|
+
* ### Examples
|
|
659
744
|
* ```typescript
|
|
745
|
+
* // 1. Using the main composable
|
|
660
746
|
* const translations = useTranslateRef(['home.title', 'home.description'] as const);
|
|
747
|
+
*
|
|
748
|
+
* // 2. Using the shorthand 't'
|
|
661
749
|
* const labels = t(['button.save', 'button.cancel'] as const);
|
|
662
750
|
* ```
|
|
751
|
+
*
|
|
752
|
+
* @param names a string or an array with keys
|
|
753
|
+
* @param translateInstance a translate instance
|
|
663
754
|
*/
|
|
664
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
|
+
*/
|
|
665
762
|
export declare const t: <T extends string[]>(names: T) => ShallowRef<TranslateList<T>>;
|
|
666
763
|
export declare const uiMakeFlags: () => void;
|
|
667
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
|
+
*/
|
|
668
773
|
export declare function computedAsync<R>(getter: (() => Promise<R>) | (() => R) | R, initialState?: (() => R) | R, ignore?: R, debugOptions?: DebuggerOptions): ComputedRef<R | undefined>;
|
|
669
|
-
|
|
670
|
-
export declare function computedEternity<T>(getter: () => Promise<T> | T, initialState?: (() => T) | T): Ref<T, T>;
|
|
671
|
-
export interface FunctionalPluginOptions {
|
|
672
|
-
api?: ApiConfig;
|
|
673
|
-
translate?: TranslateConfig;
|
|
674
|
-
location?: string | (() => string);
|
|
675
|
-
metaSuffix?: string;
|
|
676
|
-
icons?: IconsConfig;
|
|
677
|
-
iconsSocial?: InputSocialIcons;
|
|
678
|
-
router?: Router;
|
|
679
|
-
errorCauses?: ErrorCenterCauseList;
|
|
680
|
-
errorHandlers?: ErrorCenterHandlerList;
|
|
681
|
-
errorCallbacks?: ErrorCenterHandlerCallback[];
|
|
682
|
-
}
|
|
774
|
+
import { ComputedGetter } from 'vue';
|
|
683
775
|
/**
|
|
684
|
-
*
|
|
685
|
-
*
|
|
686
|
-
*
|
|
687
|
-
* @
|
|
688
|
-
*
|
|
689
|
-
* import { createApp } from 'vue'
|
|
690
|
-
* import { dxtFunctionalPlugin } from '@dxtmisha/functional'
|
|
691
|
-
* import router from './router'
|
|
692
|
-
*
|
|
693
|
-
* const app = createApp(App)
|
|
694
|
-
* app.use(dxtFunctionalPlugin, {
|
|
695
|
-
* api: { url: 'https://api.example.com' },
|
|
696
|
-
* metaSuffix: ' | My App',
|
|
697
|
-
* router
|
|
698
|
-
* })
|
|
699
|
-
* ```
|
|
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
|
|
700
781
|
*/
|
|
701
|
-
export declare const dxtFunctionalPlugin: Plugin;
|
|
702
782
|
export declare enum ExecuteUseType {
|
|
703
783
|
global = "global",
|
|
704
784
|
provide = "provide",
|
|
705
785
|
local = "local"
|
|
706
786
|
}
|
|
787
|
+
/**
|
|
788
|
+
* The object returned by the factory function
|
|
789
|
+
*/
|
|
707
790
|
export type ExecuteUseReturn<R> = Readonly<R & {
|
|
708
791
|
init(): Readonly<R>;
|
|
709
792
|
destroyExecute?(): void;
|
|
710
793
|
}>;
|
|
711
794
|
/**
|
|
712
795
|
* Creates a managed singleton that encapsulates initialization logic and access mode.
|
|
713
|
-
*
|
|
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
|
|
714
808
|
*
|
|
715
809
|
* @remarks
|
|
716
|
-
* Use this function
|
|
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.
|
|
717
815
|
*
|
|
718
816
|
* @example
|
|
817
|
+
* // 1. Global API singleton (useApiGet)
|
|
719
818
|
* export const useUserApi = executeUseGlobal(() => {
|
|
720
819
|
* return useApiGet('/api/user');
|
|
721
820
|
* });
|
|
722
821
|
*
|
|
822
|
+
* @example
|
|
823
|
+
* // 2. Shared Reactive State
|
|
723
824
|
* export const useFeatureState = executeUseProvide(() => {
|
|
724
825
|
* const items = [];
|
|
725
826
|
* const addItem = (item) => items.push(item);
|
|
726
827
|
* return { items, addItem };
|
|
727
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();
|
|
728
851
|
*/
|
|
729
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);
|
|
730
|
-
|
|
731
853
|
/**
|
|
732
854
|
* Creates a global singleton.
|
|
733
|
-
*
|
|
855
|
+
*
|
|
856
|
+
* @remarks
|
|
857
|
+
* See {@link executeUse} for more details.
|
|
858
|
+
*
|
|
859
|
+
* @param callback Initialization function
|
|
734
860
|
*/
|
|
735
861
|
export declare function executeUseGlobal<R>(callback: () => R): (() => Readonly<R & {
|
|
736
862
|
init(): Readonly<R>;
|
|
@@ -739,10 +865,14 @@ export declare function executeUseGlobal<R>(callback: () => R): (() => Readonly<
|
|
|
739
865
|
init(): Readonly<R>;
|
|
740
866
|
destroyExecute?(): void;
|
|
741
867
|
}>);
|
|
742
|
-
|
|
743
868
|
/**
|
|
744
869
|
* Creates a component-scoped singleton.
|
|
745
|
-
*
|
|
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
|
|
746
876
|
*/
|
|
747
877
|
export declare function executeUseProvide<R, O extends any[]>(callback: (...args: O) => R): ((...args: O) => Readonly<R & {
|
|
748
878
|
init(): Readonly<R>;
|
|
@@ -751,10 +881,14 @@ export declare function executeUseProvide<R, O extends any[]>(callback: (...args
|
|
|
751
881
|
init(): Readonly<R>;
|
|
752
882
|
destroyExecute?(): void;
|
|
753
883
|
}>);
|
|
754
|
-
|
|
755
884
|
/**
|
|
756
885
|
* Creates a local singleton.
|
|
757
|
-
*
|
|
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
|
|
758
892
|
*/
|
|
759
893
|
export declare function executeUseLocal<R, O extends any[]>(callback: (...args: O) => R): ((...args: O) => Readonly<R & {
|
|
760
894
|
init(): Readonly<R>;
|
|
@@ -762,11 +896,114 @@ export declare function executeUseLocal<R, O extends any[]>(callback: (...args:
|
|
|
762
896
|
}>) | (() => Readonly<R & {
|
|
763
897
|
init(): Readonly<R>;
|
|
764
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;
|
|
765
997
|
}>);
|
|
766
|
-
|
|
767
998
|
export declare function executeUseGlobalInit(): void;
|
|
768
999
|
export declare function getInject<T>(name: string): T | undefined;
|
|
769
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
|
+
*/
|
|
770
1007
|
export declare function executeFunctionRef<T>(data: RefOrNormalOrFunction<T>): T;
|
|
771
1008
|
export declare function getApiErrorRef<R>(data: RefType<ApiData<R> | undefined>): ComputedRef<ApiErrorItem | undefined>;
|
|
772
1009
|
export declare function getBindRef<T, R extends ItemList>(value: RefOrNormal<T | R> | undefined, nameExtra?: RefOrNormal<ItemList> | string, name?: string): ComputedRef<R>;
|
|
@@ -776,6 +1013,274 @@ export declare function setRef<T>(item: Ref<T>, value: T): void;
|
|
|
776
1013
|
export declare function toRefItem<T>(item: RefOrNormal<T>): Ref<T>;
|
|
777
1014
|
export declare function getBind<T, R extends ItemList>(value: T | R | undefined | null, nameExtra?: ItemList | string, name?: string, except?: boolean): ConstrBind<R>;
|
|
778
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
|
+
*/
|
|
779
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
|
+
*/
|
|
780
1033
|
export declare function toBind<R extends ItemList = ItemList>(extra: ItemList, value: ItemList): ConstrBind<R>;
|
|
781
|
-
|
|
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>);
|