@endge/utils 0.23.0 → 0.24.1
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/dist/index.d.ts +151 -1
- package/dist/utils.js +840 -433
- package/package.json +12 -10
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ClassConstructor } from 'class-transformer';
|
|
2
|
+
import { DateTime } from 'ts-luxon';
|
|
2
3
|
import { ExposeOptions } from 'class-transformer';
|
|
3
4
|
import { Ref } from 'vue';
|
|
4
5
|
import { StoreDefinition } from 'pinia';
|
|
5
6
|
import { ValidationOptions } from 'class-validator';
|
|
7
|
+
import { Zone } from 'ts-luxon';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Тип для активного состояния с вычисляемым значением.
|
|
@@ -14,6 +16,11 @@ export declare type ActiveState<T> = {
|
|
|
14
16
|
|
|
15
17
|
export declare function AfterDeserialize(target: any, propertyKey: string, _descriptor: PropertyDescriptor): void;
|
|
16
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Backward-compatible loose object record.
|
|
21
|
+
*/
|
|
22
|
+
export declare type AnyRecord = Record<string, any>;
|
|
23
|
+
|
|
17
24
|
export declare const AppBus: EventBus<GlobalEvents, Record<string, any>>;
|
|
18
25
|
|
|
19
26
|
/**
|
|
@@ -193,6 +200,12 @@ export declare function DeserializeId(): PropertyDecorator;
|
|
|
193
200
|
*/
|
|
194
201
|
export declare type Dictionary<T = any> = Record<string, T>;
|
|
195
202
|
|
|
203
|
+
export declare function diffDuration(d1: Date, d2: Date): string;
|
|
204
|
+
|
|
205
|
+
export declare function diffDurationTable(d1: Date, d2: Date): string;
|
|
206
|
+
|
|
207
|
+
export declare const dt: (date: Date) => DateTime;
|
|
208
|
+
|
|
196
209
|
/**
|
|
197
210
|
* EventBus реализует паттерн подписки на события.
|
|
198
211
|
*
|
|
@@ -228,7 +241,7 @@ export declare class EventBus<StaticEvents extends Record<string, any>, CustomEv
|
|
|
228
241
|
/**
|
|
229
242
|
* Создает экземпляр EventBus и подготавливает базовое состояние.
|
|
230
243
|
*/
|
|
231
|
-
constructor(predefinedEvents
|
|
244
|
+
constructor(predefinedEvents?: Array<keyof StaticEvents>);
|
|
232
245
|
/**
|
|
233
246
|
* Обрабатывает входящее событие EventBus.
|
|
234
247
|
*/
|
|
@@ -326,12 +339,19 @@ export declare function formatDatetime(date: Date, formatString?: string, option
|
|
|
326
339
|
|
|
327
340
|
export declare function formatDatetimeTZ(date: Date | string | object, formatString?: string, options?: {}, isLocalTime?: boolean): string;
|
|
328
341
|
|
|
342
|
+
export declare function formatDatetimeTZSpecial(date?: Date | string | object | null, formatString?: string, options?: {}): string;
|
|
343
|
+
|
|
329
344
|
export declare function formatDateToMSK(date: any): string;
|
|
330
345
|
|
|
331
346
|
export declare const generateUUID: () => string;
|
|
332
347
|
|
|
333
348
|
export declare function GenericExpose(options: ExposeOptions): (target: object, propertyKey: string | symbol) => void;
|
|
334
349
|
|
|
350
|
+
export declare function getDateOnlyDiffFactor(d1: Date, d2: Date): {
|
|
351
|
+
variant: 'red' | 'blue';
|
|
352
|
+
value: string;
|
|
353
|
+
} | null;
|
|
354
|
+
|
|
335
355
|
export declare function getDayOfWeek(date: any): string;
|
|
336
356
|
|
|
337
357
|
export declare function getOnDeserializedMethod<T>(instance: T): (() => void) | null;
|
|
@@ -583,6 +603,10 @@ export declare function isNullOrUndefined<T>(value: T | null | undefined): value
|
|
|
583
603
|
|
|
584
604
|
export declare function IsOptionalTransformed(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
|
|
585
605
|
|
|
606
|
+
export declare function isoToDateInput(value: unknown): string;
|
|
607
|
+
|
|
608
|
+
export declare function isoToDateTimeLocalInput(value: unknown): string;
|
|
609
|
+
|
|
586
610
|
/**
|
|
587
611
|
* Декоратор для преобразования JSON-поля:
|
|
588
612
|
* - сериализует объект → строку
|
|
@@ -594,6 +618,8 @@ export declare function IsOptionalTransformed(validationOptions?: ValidationOpti
|
|
|
594
618
|
*/
|
|
595
619
|
export declare function Json(): PropertyDecorator;
|
|
596
620
|
|
|
621
|
+
export declare function JsonString(): PropertyDecorator;
|
|
622
|
+
|
|
597
623
|
export declare interface KeyCombo {
|
|
598
624
|
ctrl?: boolean;
|
|
599
625
|
alt?: boolean;
|
|
@@ -687,6 +713,8 @@ export declare type Override<Base, Overrides> = Omit<Base, keyof Overrides> & Ov
|
|
|
687
713
|
|
|
688
714
|
export declare const parseDate: (isoString: string) => "" | Date;
|
|
689
715
|
|
|
716
|
+
export declare function parseDuration(duration: string): string;
|
|
717
|
+
|
|
690
718
|
/**
|
|
691
719
|
* Возвращает первую найденную IANA-таймзону с данным смещением (например, "+03:00").
|
|
692
720
|
*/
|
|
@@ -699,6 +727,21 @@ export declare type PartialDeep<T> = T extends (...args: Array<any>) => any ? T
|
|
|
699
727
|
[K in keyof T]?: PartialDeep<T[K]>;
|
|
700
728
|
} : T;
|
|
701
729
|
|
|
730
|
+
export declare interface PayloadClientOptions {
|
|
731
|
+
baseUrl: string;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
export declare class PayloadHttpClient {
|
|
735
|
+
private readonly baseUrl;
|
|
736
|
+
constructor(opts: PayloadClientOptions);
|
|
737
|
+
private buildUrl;
|
|
738
|
+
private buildHeaders;
|
|
739
|
+
get<T>(path: string, query?: Record<string, unknown>, extraHeaders?: HeadersInit): Promise<T>;
|
|
740
|
+
post<T>(path: string, body?: unknown, extraHeaders?: HeadersInit): Promise<T>;
|
|
741
|
+
patch<T>(path: string, body?: unknown, extraHeaders?: HeadersInit): Promise<T>;
|
|
742
|
+
delete<T>(path: string, extraHeaders?: HeadersInit): Promise<T>;
|
|
743
|
+
}
|
|
744
|
+
|
|
702
745
|
export declare function profile<T>(label: string, fn: () => T): T;
|
|
703
746
|
|
|
704
747
|
export declare function randomString(length: number): string;
|
|
@@ -712,6 +755,21 @@ export declare interface ReadonlyIndexCollection<T extends IndexCollectionEntity
|
|
|
712
755
|
forEach(callback: (item: T) => void): void;
|
|
713
756
|
}
|
|
714
757
|
|
|
758
|
+
export declare function removeTime(date?: Date): Date;
|
|
759
|
+
|
|
760
|
+
export declare class RingBuffer<T> {
|
|
761
|
+
private readonly _cap;
|
|
762
|
+
private readonly _buf;
|
|
763
|
+
private _head;
|
|
764
|
+
private _len;
|
|
765
|
+
constructor(capacity: number);
|
|
766
|
+
get capacity(): number;
|
|
767
|
+
get length(): number;
|
|
768
|
+
push(value: T): void;
|
|
769
|
+
clear(): void;
|
|
770
|
+
toArray(): Array<T>;
|
|
771
|
+
}
|
|
772
|
+
|
|
715
773
|
/**
|
|
716
774
|
* Декоратор для хранения текста скрипта:
|
|
717
775
|
* - сериализует как обычную строку
|
|
@@ -775,6 +833,34 @@ export declare type SharedMaybe<T> = T | null | undefined;
|
|
|
775
833
|
|
|
776
834
|
export declare type Side = 'left' | 'right' | 'top' | 'bottom';
|
|
777
835
|
|
|
836
|
+
export declare class SSEManager {
|
|
837
|
+
private readonly _url;
|
|
838
|
+
private readonly _retryInterval;
|
|
839
|
+
private _abortController;
|
|
840
|
+
private _isConnected;
|
|
841
|
+
private _reconnectTimeout;
|
|
842
|
+
private readonly _options;
|
|
843
|
+
constructor(options: SSEManagerOptions);
|
|
844
|
+
start(): void;
|
|
845
|
+
stop(): void;
|
|
846
|
+
private _scheduleReconnect;
|
|
847
|
+
private _clearReconnect;
|
|
848
|
+
private _buildHeaders;
|
|
849
|
+
private _connect;
|
|
850
|
+
get isConnected(): boolean;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
export declare interface SSEManagerOptions {
|
|
854
|
+
url: string;
|
|
855
|
+
retryInterval?: number;
|
|
856
|
+
headers?: Record<string, string>;
|
|
857
|
+
getToken?: () => string | undefined;
|
|
858
|
+
onEvent: (data: any) => void;
|
|
859
|
+
onError?: (error: Error) => void;
|
|
860
|
+
onOpen?: () => void;
|
|
861
|
+
onClose?: () => void;
|
|
862
|
+
}
|
|
863
|
+
|
|
778
864
|
/**
|
|
779
865
|
* Структурированная запись лога.
|
|
780
866
|
*
|
|
@@ -975,8 +1061,27 @@ export declare class Subscribable {
|
|
|
975
1061
|
notify(): void;
|
|
976
1062
|
}
|
|
977
1063
|
|
|
1064
|
+
export declare const SystemClock: {
|
|
1065
|
+
DateTime: typeof DateTime;
|
|
1066
|
+
toDateTime(jsDate: Date): DateTime;
|
|
1067
|
+
fromFormat(text: string, format: string, opts: any): DateTime;
|
|
1068
|
+
fromISO(text: string, opts?: any): DateTime | null;
|
|
1069
|
+
getNow(): DateTime;
|
|
1070
|
+
getNowUTC(): DateTime;
|
|
1071
|
+
getToday(): DateTime;
|
|
1072
|
+
getTime(format?: string): string;
|
|
1073
|
+
getUTCTime(format?: string): string;
|
|
1074
|
+
getZone(): Zone;
|
|
1075
|
+
};
|
|
1076
|
+
|
|
1077
|
+
export declare function timeToTimeInput(value: unknown): string;
|
|
1078
|
+
|
|
978
1079
|
export declare function toInstance<T>(ctor: ClassConstructor<T>, json: object): T;
|
|
979
1080
|
|
|
1081
|
+
export declare function toIsoZDate(value: string): string | null;
|
|
1082
|
+
|
|
1083
|
+
export declare function toIsoZDateTime(value: string): string | null;
|
|
1084
|
+
|
|
980
1085
|
export declare const TooltipAttribute = "x-collection-tooltip-id";
|
|
981
1086
|
|
|
982
1087
|
export declare interface TooltipInstance {
|
|
@@ -989,8 +1094,36 @@ export declare interface TooltipInstance {
|
|
|
989
1094
|
maxWidth?: string | number;
|
|
990
1095
|
}
|
|
991
1096
|
|
|
1097
|
+
export declare function TooltipRegistrator(h: TooltipRenderFunction, props: TooltipRegistratorProps): any;
|
|
1098
|
+
|
|
1099
|
+
export declare interface TooltipRegistratorProps {
|
|
1100
|
+
id?: string;
|
|
1101
|
+
data?: unknown;
|
|
1102
|
+
template?: unknown;
|
|
1103
|
+
location?: unknown;
|
|
1104
|
+
disabled?: boolean;
|
|
1105
|
+
maxWidth?: string;
|
|
1106
|
+
customClass?: string;
|
|
1107
|
+
justifyClass?: string;
|
|
1108
|
+
slots?: {
|
|
1109
|
+
default?: () => any;
|
|
1110
|
+
};
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
export declare type TooltipRenderFunction = (tag: string, props?: Record<string, unknown>, children?: any) => any;
|
|
1114
|
+
|
|
992
1115
|
export declare function toPlain<T>(obj: T): object;
|
|
993
1116
|
|
|
1117
|
+
export declare function toTimeHHMMSS(value: unknown): string | null;
|
|
1118
|
+
|
|
1119
|
+
export declare interface TreeViewNode {
|
|
1120
|
+
id: string;
|
|
1121
|
+
label: string;
|
|
1122
|
+
icon?: string;
|
|
1123
|
+
expanded?: boolean;
|
|
1124
|
+
children?: Array<TreeViewNode>;
|
|
1125
|
+
}
|
|
1126
|
+
|
|
994
1127
|
/**
|
|
995
1128
|
* Тип, исключающий falsy-значения.
|
|
996
1129
|
*/
|
|
@@ -1115,6 +1248,15 @@ export declare function TypeRecord<V>(valueType: ClassConstructor<V>): PropertyD
|
|
|
1115
1248
|
*/
|
|
1116
1249
|
export declare type Undefinable<T> = T | undefined;
|
|
1117
1250
|
|
|
1251
|
+
export declare class UPSMeter_Service {
|
|
1252
|
+
private _currentCount;
|
|
1253
|
+
private _lastResetTime;
|
|
1254
|
+
private _lastEventsPerSecond;
|
|
1255
|
+
count(): void;
|
|
1256
|
+
get rate(): number;
|
|
1257
|
+
reset(): void;
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1118
1260
|
export declare const useCookie: (name: any, _opts?: any) => Ref<string, string>;
|
|
1119
1261
|
|
|
1120
1262
|
export declare function useStorageDebounced<T>(key: string, initial: T, fromJSON?: (data: any) => T, toJSON?: (data: T) => any, delay?: number): Ref<T>;
|
|
@@ -1127,6 +1269,8 @@ export declare const useSubscribableRef: <T extends Subscribable>(obj: T) => {
|
|
|
1127
1269
|
unsubscribe: () => void;
|
|
1128
1270
|
};
|
|
1129
1271
|
|
|
1272
|
+
export declare const useSubscribableRefAuto: <T extends Subscribable>(obj: T) => Ref<T>;
|
|
1273
|
+
|
|
1130
1274
|
export declare const useTooltipStore: StoreDefinition<"tooltip", Pick<{
|
|
1131
1275
|
tooltips: Record<string, TooltipInstance>;
|
|
1132
1276
|
activeId: Ref<string | null, string | null>;
|
|
@@ -1161,4 +1305,10 @@ clearActiveTooltipId: () => void;
|
|
|
1161
1305
|
*/
|
|
1162
1306
|
export declare type VoidFn = () => void;
|
|
1163
1307
|
|
|
1308
|
+
/**
|
|
1309
|
+
* Backward-compatible alias used by legacy packages.
|
|
1310
|
+
*/
|
|
1311
|
+
declare type VoidFunction_2 = VoidFn;
|
|
1312
|
+
export { VoidFunction_2 as VoidFunction }
|
|
1313
|
+
|
|
1164
1314
|
export { }
|