@netwo/devkit 0.0.0-stage → 1.0.0

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.
@@ -0,0 +1,781 @@
1
+ import { PhoneNumber, PhoneNumberUtil } from 'google-libphonenumber';
2
+ import * as rxjs from 'rxjs';
3
+ import { Observable, ObservableInput, OperatorFunction, ObservedValueOf, SchedulerLike, MonoTypeOperatorFunction, TruthyTypesOf } from 'rxjs';
4
+ import { DateTime } from 'luxon';
5
+
6
+ declare function parseNumber(value: string): number | undefined;
7
+ declare function coerceNumber(value: string | number): number | undefined;
8
+
9
+ type Writeable<T> = {
10
+ -readonly [P in keyof T]: T[P];
11
+ };
12
+ type ExcludeProps<Obj, Key extends keyof Obj> = Pick<Obj, Exclude<keyof Obj, Key>>;
13
+ type PartialProps<Obj, Key extends keyof Obj> = ExcludeProps<Obj, Key> & Partial<Obj>;
14
+ type OptionalProps<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
15
+ type EmptyChildren<T> = {
16
+ [K in keyof T]: keyof T[K] extends never ? K : never;
17
+ }[keyof T];
18
+ type PartialEmptyChildren<T> = PartialProps<T, EmptyChildren<T>>;
19
+ type PrefixKeys<Obj, Prefix extends string> = {
20
+ [Key in keyof Obj as `${Prefix}${Capitalize<Key & string>}`]: Obj[Key];
21
+ };
22
+ /**
23
+ * Enforces that at least one property in an object can be defined.
24
+ */
25
+ type RequireAtLeastOne<TObj> = {
26
+ [K in keyof TObj]-?: Required<Pick<TObj, K>> & Partial<Pick<TObj, Exclude<keyof TObj, K>>>;
27
+ }[keyof TObj];
28
+ type IsNullable<T, K extends keyof T> = T[K] extends null | undefined ? true : false;
29
+ type IfNullabe<T, K extends keyof T, TTrue, TFalse> = IsNullable<T, K> extends true ? TTrue : TFalse;
30
+ type IsNever<T> = [T] extends [never] ? true : false;
31
+ type IfNever<T, TTrue, TFalse> = IsNever<T> extends true ? TTrue : TFalse;
32
+ type IsUnknown<T> = unknown extends T ? T extends unknown ? true : false : false;
33
+ type IfUnknown<T, TTrue, TFalse> = IsUnknown<T> extends true ? TTrue : TFalse;
34
+ /**
35
+ * Enforces that only one property in an object can be defined.
36
+ *
37
+ * @template TObj - The object type to apply the restriction to.
38
+ * @template TDiscriminator - The name of the added property that stores the required key name. Defaults to `never`.
39
+ */
40
+ type _RequireOnlyOne<TObj, TDiscriminator extends string = never> = {
41
+ [K in keyof TObj]-?: Required<Pick<TObj, K>> & Partial<Record<Exclude<keyof TObj, K>, undefined>> & IfNever<TDiscriminator, object, Record<TDiscriminator, K>>;
42
+ }[keyof TObj];
43
+ /**
44
+ * Extends `_RequireOnlyOne` by allowing a specific key to always be required and optionally by adding a property to represent the name of the required key.
45
+ */
46
+ type RequireOnlyOne<TObj, TKey extends keyof TObj = never, TDiscriminator extends string = never> = IfNever<TKey, _RequireOnlyOne<TObj, TDiscriminator>, Required<Pick<TObj, TKey>> & IfNever<TDiscriminator, object, Record<TDiscriminator, TKey>>>;
47
+ type Nullable<T> = T | null | undefined;
48
+ type EmptyObj = Record<string, never>;
49
+ type ExtractPropertyType<Obj, Prop extends keyof Obj> = Pick<Obj, Prop>[Prop];
50
+ /**
51
+ * KeysOfValueType<Example, string | number > will be equal to "propA" | "propC" | "propD"
52
+ */
53
+ type KeysOfValueType<T, V> = keyof {
54
+ [P in keyof T as T[P] extends V ? P : never]: P;
55
+ };
56
+ type PropPathSelector<T, P extends string> = P extends `${infer K}.${infer Rest}` ? K extends keyof T ? PropPathSelector<T[K], Rest> : never : P extends keyof T ? T[P] : never;
57
+ type NullableObject<T> = {
58
+ [P in keyof T]: T[P] | undefined;
59
+ };
60
+ type DeepPartial<T> = T extends object ? {
61
+ [P in keyof T]?: DeepPartial<T[P]>;
62
+ } : T;
63
+
64
+ declare const FIRSTNAME: readonly ["firstname", "firstName", "Firstname", "FirstName", "first_name"];
65
+ declare const LASTNAME: readonly ["lastname", "lastName", "Lastname", "LastName", "last_name"];
66
+ type Firstname = (typeof FIRSTNAME)[number];
67
+ type Lastname = (typeof LASTNAME)[number];
68
+ type FirstnameObj = Record<Firstname, string>;
69
+ type LastnameObj = Record<Lastname, string>;
70
+ type FirstnameObjOnlyOne = RequireOnlyOne<FirstnameObj>;
71
+ type LastnameObjOnlyOne = RequireOnlyOne<LastnameObj>;
72
+ type FullnameObj = FirstnameObjOnlyOne & LastnameObjOnlyOne;
73
+ /**
74
+ * A couple object of firstname/lastname
75
+ * where the properties name are equal to one of the value
76
+ * in the tables FIRSTNAME/LASTNAME
77
+ * The object can contains only one property for firstname
78
+ * and one for lastname
79
+ * Example :
80
+ * { firstname: '', lastname: '' } => OK
81
+ * { firstName: '', LastName: '' } => OK
82
+ * { FirstName: '', firstName: '' } => NOK
83
+ */
84
+ type UserInput = FullnameObj;
85
+ declare function coerceUserName(input: UserInput): {
86
+ readonly firstname: string;
87
+ readonly lastname: string;
88
+ };
89
+
90
+ declare class CircularQueue<T> {
91
+ private readonly capacity;
92
+ private readonly storage;
93
+ get length(): number;
94
+ constructor(capacity?: number);
95
+ enqueue(item: T): T | undefined;
96
+ dequeue(): T | undefined;
97
+ toArray(): T[];
98
+ remove(item: T): boolean;
99
+ clear(): T[];
100
+ }
101
+
102
+ type Comparer<T> = (v1: T, v2: T) => number;
103
+ type BinaryComparer<T> = (v1: T, v2: T) => boolean;
104
+
105
+ type ValueOrFn<T, Args extends unknown[] = []> = T | ((...args: Args) => T);
106
+ declare function resolveValueOrFn<T, Args extends unknown[] = []>(valueOrFn: ValueOrFn<T, Args>, ...args: Args): T;
107
+
108
+ interface TreeNode<T> {
109
+ readonly id: string;
110
+ readonly value: T;
111
+ readonly level: number;
112
+ readonly children: TreeNode<T>[];
113
+ }
114
+ interface FlatTreeNode<T> {
115
+ readonly id: string;
116
+ readonly value: T;
117
+ readonly level: number;
118
+ readonly parentId: string | undefined;
119
+ }
120
+ interface FlatTreeOptions<T> {
121
+ readonly sortComparer?: Comparer<FlatTreeNode<T>>;
122
+ }
123
+ interface FlatTreeRemoveOptions {
124
+ readonly removeParentIfEmpty?: boolean;
125
+ }
126
+ declare class FlatTree<T> {
127
+ private readonly options?;
128
+ readonly nodes: FlatTreeNode<T>[];
129
+ private constructor();
130
+ static create<T>(options?: FlatTreeOptions<T>): FlatTree<T>;
131
+ with(options: RequireAtLeastOne<FlatTreeOptions<T>>): FlatTree<T>;
132
+ add(id: string, value: T, parentId?: string): FlatTree<T>;
133
+ addAll(values: [id: string, value: T, parentId?: string][]): FlatTree<T>;
134
+ remove(id: string, options?: FlatTreeRemoveOptions): FlatTree<T>;
135
+ removeAll(ids: string[], options?: FlatTreeRemoveOptions): FlatTree<T>;
136
+ update(id: string, changes: ValueOrFn<T, [T]>): FlatTree<T>;
137
+ updateAll(payload: [id: string, changes: ValueOrFn<T, [T]>][]): FlatTree<T>;
138
+ get(id: string): FlatTreeNode<T> | undefined;
139
+ getParent(id: string): FlatTreeNode<T> | undefined;
140
+ getChildren(id: string): FlatTreeNode<T>[];
141
+ getAscendants(id: string): FlatTreeNode<T>[];
142
+ getDescendants(id: string): FlatTreeNode<T>[];
143
+ getSiblings(id: string): FlatTreeNode<T>[];
144
+ getAtLevel(level: number): FlatTreeNode<T>[];
145
+ getLeaf(): FlatTreeNode<T>[];
146
+ getDeepestLeaf(): FlatTreeNode<T>[];
147
+ buildHierarchyFromTop(id: string): TreeNode<T> | undefined;
148
+ buildHierarchyFromBottom(ids: string[], options?: {
149
+ untilLevel?: number;
150
+ }): TreeNode<T>[];
151
+ private buildHierarchyChildren;
152
+ }
153
+
154
+ declare class LazyWeakMap<K extends object, V> {
155
+ private readonly factory;
156
+ private readonly map;
157
+ constructor(factory: (key: K) => V);
158
+ get(key: K): V;
159
+ delete(key: K): boolean;
160
+ }
161
+
162
+ declare function formatAddress(address: {
163
+ streetNumber: string | undefined;
164
+ street: string | undefined;
165
+ zipCode: string | undefined;
166
+ city: string | undefined;
167
+ } | undefined): string;
168
+
169
+ declare function formatFileSize(value: number): string;
170
+
171
+ declare function parseFrenchPhoneNumber(value: string): string | null;
172
+ declare function formatFrenchPhoneNumber(value?: string): string | undefined;
173
+
174
+ declare function linkify(value: string, options?: {
175
+ target?: '_self' | '_blank';
176
+ classList?: string[];
177
+ text?: string | ((url: string) => string);
178
+ }): string;
179
+
180
+ declare function num2digit(n: number | string): string;
181
+
182
+ declare function formatPhoneNumber(value: PhoneNumber | string): string | undefined;
183
+
184
+ interface PrettyBytesOptions {
185
+ readonly signed?: boolean;
186
+ readonly locale?: string;
187
+ readonly bits?: boolean;
188
+ readonly binary?: boolean;
189
+ readonly minimumFractionDigits?: number;
190
+ readonly maximumFractionDigits?: number;
191
+ readonly space?: boolean;
192
+ }
193
+ declare function prettyBytes(number: number, options?: PrettyBytesOptions): string;
194
+
195
+ declare function truncate(value: string, length?: number): string;
196
+ declare function capitalize(value: string): string;
197
+ declare function strictTitleCase(value: string): string;
198
+ declare function initial(firstname: string, lastname: string): string;
199
+ declare function toCamelCase(value: string): string;
200
+
201
+ /**
202
+ * Formats a duration in seconds to a human-readable string in the format "1j 2h 45 min"
203
+ * @param durationInSeconds The duration in seconds to format
204
+ * @returns A formatted string representation of the duration, or "0 min" if duration is 0
205
+ *
206
+ * @example
207
+ * formatDuration(3665) // "1h 1 min"
208
+ * formatDuration(86400) // "1j"
209
+ * formatDuration(7380) // "2h 3 min"
210
+ * formatDuration(0) // "0 min"
211
+ */
212
+ declare function formatDuration(durationInSeconds: number): string;
213
+ /**
214
+ * Formats a period between two dates without repeating the date if start day and en day are the same
215
+ *
216
+ * @param startDate The start date of the period
217
+ * @param endDate The end date of the period
218
+ * @returns A formatted string representation of the period in French format
219
+ *
220
+ * @example
221
+ * // Different dates
222
+ * formatPeriod(
223
+ * new Date('2024-01-15T09:30:00'),
224
+ * new Date('2024-01-16T17:00:00')
225
+ * )
226
+ * // Returns: "15/01/2024 09:30 - 16/01/2024 17h"
227
+ *
228
+ * @example
229
+ * // Same date
230
+ * formatPeriod(
231
+ * new Date('2024-01-15T09:30:00'),
232
+ * new Date('2024-01-15T17:00:00')
233
+ * )
234
+ * // Returns: "15/01/2024 09:30-17h"
235
+ *
236
+ * @example
237
+ * // Round hours (no minutes)
238
+ * formatPeriod(
239
+ * new Date('2024-01-15T09:00:00'),
240
+ * new Date('2024-01-15T17:00:00')
241
+ * )
242
+ * // Returns: "15/01/2024 09h-17h"
243
+ */
244
+ declare function formatPeriod(startDate: Date, endDate: Date): string;
245
+
246
+ declare function formatUserInitial(value: UserInput): string;
247
+
248
+ declare function formatUserName(value: UserInput): string;
249
+
250
+ type ActionRefInput<T> = ObservableInput<T>;
251
+ declare class ActionRefError<Failure> extends Error {
252
+ readonly source: Failure;
253
+ constructor(payload: {
254
+ message?: string;
255
+ source: Failure;
256
+ });
257
+ }
258
+ declare class ActionRef<Success, Failure, Cancelled = never> {
259
+ private readonly sucess$;
260
+ private readonly failure$;
261
+ private readonly cancelled$;
262
+ readonly afterSuccess$: Observable<Success>;
263
+ readonly afterFailure$: Observable<Failure>;
264
+ readonly afterCancelled$: Observable<Cancelled>;
265
+ readonly afterEvent$: Observable<Success>;
266
+ private constructor();
267
+ static of<Success, Failure, Cancelled = never>(task: () => void, events: {
268
+ success: ActionRefInput<Success>;
269
+ failure: ActionRefInput<Failure>;
270
+ cancelled?: ActionRefInput<Cancelled>;
271
+ }): ActionRef<Success, Failure, Cancelled>;
272
+ private static resolveInput;
273
+ }
274
+
275
+ type InferArr<T> = T extends Array<infer O> ? O : never;
276
+ type NonEmptyArray<T> = [T, ...T[]];
277
+ interface CompleteDiffResult<T> {
278
+ readonly added: T[];
279
+ readonly removed: T[];
280
+ readonly unchanged: T[];
281
+ }
282
+
283
+ type Mapper<I, O, Args extends unknown[] = []> = (value: I, ...args: Args) => O;
284
+ type Into<I, O> = Mapper<I, O>;
285
+ type BooleanInto<T> = Into<T, boolean>;
286
+ type StringInto<T> = Into<T, string>;
287
+ type NumberInto<T> = Into<T, number>;
288
+
289
+ declare function assertNonEmpty<T>(array: T[]): asserts array is NonEmptyArray<T>;
290
+ declare function mapNonEmptyArray<T, U>(nonEmptyArray: NonEmptyArray<T>, fn: (value: T, index: number, array: NonEmptyArray<T>) => U): NonEmptyArray<U>;
291
+ declare function insertAt<T>(arr: T[], index: number, ...items: T[]): T[];
292
+ /**
293
+ * Slices an array into chunks of specified size.
294
+ * @param items The array to be sliced.
295
+ * @param chunkSize The size of each chunk.
296
+ * @returns An array of arrays, each containing elements of the original array sliced into chunks.
297
+ */
298
+ declare function sliceIntoChunks<T>(items: T[], chunkSize: number): T[][];
299
+ declare function groupBy<K, V>(items: V[], keyGetter: (item: V) => K): Map<K, V[]>;
300
+ declare function intersect(arr1: string[], arr2: string[]): string[];
301
+ declare function intersect<T>(arr1: T[], arr2: T[], fn: StringInto<T>): T[];
302
+ declare function diff(arr1: string[], arr2: string[]): string[];
303
+ declare function diff<T>(arr1: T[], arr2: T[], comparer?: BinaryComparer<T>): T[];
304
+ declare function distinct<T>(arr: T[], comparer?: BinaryComparer<T>): T[];
305
+ declare function dropLast<T>(arr: T[]): T[];
306
+ declare function safeCastFromStringArr<T extends string>(target: string | undefined, values: readonly T[]): T | undefined;
307
+ declare function getCenteredSlice<T>(arr: T[], currentIndex: number, size: number): T[];
308
+ declare function completeDiff<T>(oldArray: T[], newArray: T[], comparer?: BinaryComparer<T>): CompleteDiffResult<T>;
309
+
310
+ type EntityId = string | number;
311
+ interface SelectEntityId<T> {
312
+ (entity: T): EntityId;
313
+ }
314
+ interface ArrayUpdater<T> {
315
+ id: EntityId;
316
+ changes: ValueOrFn<Partial<T>, [T]>;
317
+ }
318
+ interface ArrayConfInput<T> {
319
+ selectId?: SelectEntityId<NoInfer<T>>;
320
+ sortComparer?: Comparer<NoInfer<T>>;
321
+ type: T;
322
+ }
323
+ interface ArrayConf<T> {
324
+ selectId: SelectEntityId<T>;
325
+ sortComparer?: Comparer<T>;
326
+ }
327
+ declare function arrayConf<T>(conf: ArrayConfInput<T>): ArrayConf<T>;
328
+ /**
329
+ * Adds an entity to the collection.
330
+ * If the entity collection has an entity with the same ID, it is not overridden.
331
+ */
332
+ declare function addOne<T>(array: T[], entity: T, conf: ArrayConf<T>): T[];
333
+ /**
334
+ * Adds multiple entities to the collection.
335
+ * If the entity collection has entities with the same IDs, they are not overridden .
336
+ */
337
+ declare function addMany<T>(array: T[], entities: T[], conf: ArrayConf<T>): T[];
338
+ /**
339
+ * Adds or replaces an entity in the collection.
340
+ */
341
+ declare function setOne<T>(array: T[], entity: T, conf: ArrayConf<T>): T[];
342
+ /**
343
+ * Adds or replaces multiple entities in the collection.
344
+ */
345
+ declare function setMany<T>(array: T[], entities: T[], conf: ArrayConf<T>): T[];
346
+ /**
347
+ * Removes an entity from the collection by ID.
348
+ */
349
+ declare function removeOne<T>(array: T[], idOrPredicate: EntityId | ((item: T) => boolean), conf: ArrayConf<T>): T[];
350
+ /**
351
+ * Removes multiple entities from the collection by IDs or predicate.
352
+ */
353
+ declare function removeMany<T>(array: T[], idsOrPredicate: EntityId[] | ((item: T) => boolean), conf: ArrayConf<T>): T[];
354
+ /**
355
+ * Updates an entity in the collection by ID.
356
+ * Supports partial updates.
357
+ */
358
+ declare function updateOne<T>(array: T[], update: ArrayUpdater<T>, conf: ArrayConf<T>): T[];
359
+ /**
360
+ * Updates multiple entities in the collection by IDs or predicate.
361
+ * Supports partial updates.
362
+ */
363
+ declare function updateMany<T>(array: T[], updates: ArrayUpdater<T>[], conf: ArrayConf<T>): T[];
364
+
365
+ declare function assertNonNullable<T>(value: T, label: string): asserts value is NonNullable<T>;
366
+ declare function assertValid(condition: boolean, message: string): asserts condition;
367
+
368
+ declare function ascComparer(): Comparer<number>;
369
+ declare function ascComparer<T>(into: NumberInto<T>): Comparer<T>;
370
+ declare function descComparer(): Comparer<number>;
371
+ declare function descComparer<T>(into: NumberInto<T>): Comparer<T>;
372
+ declare function localeComparer<T>(options?: Intl.CollatorOptions & {
373
+ readonly stringify?: StringInto<T>;
374
+ }): Comparer<T>;
375
+ declare function composeComparer<T>(c1: Comparer<T>, c2: Comparer<T>, ...more: Comparer<T>[]): Comparer<T>;
376
+ declare const NUM_COMPARER_MAP: {
377
+ asc: typeof ascComparer;
378
+ desc: typeof descComparer;
379
+ };
380
+ interface Options<T, S> {
381
+ readonly into?: Into<T, S>;
382
+ readonly type?: keyof typeof NUM_COMPARER_MAP;
383
+ }
384
+ declare function compareUsingTemplate<T>(orderedArr: readonly T[], option?: Omit<Options<T, T>, 'into'>): Comparer<T>;
385
+ declare function compareUsingTemplate<T, S>(orderedArr: readonly S[], option: Options<T, S> & Required<Pick<Options<T, S>, 'into'>>): Comparer<T>;
386
+ declare function strictComparer<T>(into?: Into<T, unknown>): BinaryComparer<T>;
387
+ declare function deepEqualComparer<T>(into?: Into<T, unknown>): BinaryComparer<T>;
388
+ declare function stringifyComparer<T>(into?: Into<T, unknown>): BinaryComparer<T>;
389
+ declare function wrapNullishComparer<T>(comparer: BinaryComparer<T>): BinaryComparer<T | undefined>;
390
+
391
+ declare const OpaqueTagSymbol: unique symbol;
392
+ declare class OpaqueTag<S> {
393
+ private [OpaqueTagSymbol];
394
+ }
395
+ type Opaque<T, S> = T & OpaqueTag<S>;
396
+
397
+ declare const OctetSymbol: unique symbol;
398
+ declare const KoSymbol: unique symbol;
399
+ declare const MoSymbol: unique symbol;
400
+ declare const GoSymbol: unique symbol;
401
+ declare const ToSymbol: unique symbol;
402
+ type Octet = typeof OctetSymbol;
403
+ type Ko = typeof KoSymbol;
404
+ type Mo = typeof MoSymbol;
405
+ type Go = typeof GoSymbol;
406
+ type To = typeof ToSymbol;
407
+ type DataVolumeUnit = Octet | Ko | Mo | Go | To;
408
+ type DataVolume<Unit extends DataVolumeUnit> = Opaque<number, Unit>;
409
+ declare function asDataVolume<Unit extends DataVolumeUnit>(n: number): DataVolume<Unit>;
410
+ declare function koToOctet(n: DataVolume<Ko>): DataVolume<Octet>;
411
+ declare function moToOctet(n: DataVolume<Mo>): DataVolume<Octet>;
412
+ declare function goToOctet(n: DataVolume<Go>): DataVolume<Octet>;
413
+ declare function toToOctet(n: DataVolume<To>): DataVolume<Octet>;
414
+ declare function toKo(n: DataVolume<Octet>): DataVolume<Ko>;
415
+ declare function toMo(n: DataVolume<Octet>): DataVolume<Mo>;
416
+ declare function toGo(n: DataVolume<Octet>): DataVolume<Go>;
417
+ declare function toTo(n: DataVolume<Octet>): DataVolume<To>;
418
+ type DataVolumeUnitName = 'Octet' | 'Ko' | 'Mo' | 'Go' | 'To';
419
+ interface ReadableVolumeObject<Unit extends DataVolumeUnit, UnitName extends DataVolumeUnitName> {
420
+ volume: DataVolume<Unit>;
421
+ comparedVolume?: DataVolume<Unit>;
422
+ unit: UnitName;
423
+ }
424
+ type ReadableVolume = ReadableVolumeObject<To, 'To'> | ReadableVolumeObject<Go, 'Go'> | ReadableVolumeObject<Mo, 'Mo'> | ReadableVolumeObject<Ko, 'Ko'> | ReadableVolumeObject<Octet, 'Octet'>;
425
+ type ToReadableVolumeArg = DataVolume<Octet> | {
426
+ comparedVolume: DataVolume<Octet>;
427
+ volume: DataVolume<Octet>;
428
+ };
429
+ declare function toReadableVolume(data: ToReadableVolumeArg): ReadableVolume;
430
+
431
+ type DateRange = [start: Date | undefined, end: Date | undefined];
432
+
433
+ declare function isDateInRange(range: DateRange, target?: Date, useTime?: boolean): boolean;
434
+ declare function clampDate(date: Date, min?: Date, max?: Date): Date;
435
+ declare function isBefore(date: Date, dateToCompareWith: Date): boolean;
436
+ declare function isBeforeNow(date: Date): boolean;
437
+ declare const isWorkingDay: (date: DateTime, holidays: DateTime[], includeSaturday?: boolean) => boolean;
438
+ declare const addWorkingDays: (date: DateTime, numberOfWorkingDays: number, holidays: DateTime[], includeSaturday?: boolean) => DateTime;
439
+
440
+ declare function deepEqual<T>(a: T, b: T, ...moreConditions: BinaryComparer<unknown>[]): boolean;
441
+ declare function withDuration(): BinaryComparer<unknown>;
442
+ declare function withPhoneNumber(): BinaryComparer<unknown>;
443
+
444
+ declare function getDeepest<T>(root: T, deepSelector: (item: T) => Nullable<T>): T;
445
+
446
+ declare function isEmail(value: string): boolean;
447
+
448
+ declare function mapFileToBase64(file: File): Promise<string>;
449
+ declare function isBase64Image(data: string): boolean;
450
+
451
+ declare function makeSafe<Fn extends (...args: any) => any>(fn: Fn, errHandler?: (err: unknown, ...args: Parameters<Fn>) => void): (...args: Parameters<Fn>) => ReturnType<Fn> | undefined;
452
+ declare function withDefault<Fn extends (...args: any) => any>(fn: Fn, defaultValue: NonNullable<ReturnType<Fn>>): (...args: Parameters<Fn>) => NonNullable<ReturnType<Fn>>;
453
+ declare function createDebouncedFn<T extends (...args: any[]) => void>(fn: T, delay?: number): T & {
454
+ cancel: () => void;
455
+ };
456
+
457
+ declare function isNotUndefined<T>(obj: T | undefined): obj is T;
458
+ declare function isUndefined<T>(obj: T | undefined): obj is undefined;
459
+ declare function isNotNull<T>(obj: T | null): obj is T;
460
+ declare function isNull<T>(obj: T | null): obj is null;
461
+ declare function isNotNullable<T>(obj: Nullable<T>): obj is NonNullable<T>;
462
+ declare function isNullable<T>(obj: Nullable<T>): obj is null | undefined;
463
+ declare function isObject(obj: unknown): obj is object;
464
+ declare function isError(obj: unknown): obj is Error;
465
+ declare function isString(obj: unknown): obj is string;
466
+ declare function isNumber(obj: unknown): obj is number;
467
+ declare function isArray(obj: unknown): obj is unknown[];
468
+ declare function isDate(obj: unknown): obj is Date;
469
+ declare function isStringArray(value: unknown): value is string[];
470
+ declare function isNumberArray(value: unknown): value is number[];
471
+ declare function isBoolArray(value: unknown): value is boolean[];
472
+ declare function isBoolean(obj: unknown): obj is boolean;
473
+ declare function isFn(obj: unknown): obj is Function;
474
+ declare function isKey<Target extends string, Key extends Target>(key: Target, target: Key): key is Key;
475
+
476
+ declare function getIpv4HostAddress(networkAddress: string, offset: number): string;
477
+ declare function cidrIsNetworkAddress(cidr: string): boolean;
478
+ declare function ipv4BelongsToCidr(ipAddress: string, cidr: string): boolean;
479
+ declare function getIpv4NetworkAddressFromCidr(cidr: string): string;
480
+ declare function cidrComparer(aCidr: string, bCidr: string): number;
481
+
482
+ interface IterationMeta {
483
+ readonly even: boolean;
484
+ readonly first: boolean;
485
+ readonly index: number;
486
+ readonly last: boolean;
487
+ readonly odd: boolean;
488
+ }
489
+
490
+ declare function getIterationMeta<T>(item: T, source: readonly T[]): IterationMeta;
491
+
492
+ declare function luhn(value: string): boolean;
493
+
494
+ declare function mapValues<K, V, R>(map: Map<K, V>, mapper: (value: V, key: K) => R): Map<K, R>;
495
+
496
+ declare const identity: <T>(value: T) => T;
497
+ declare const defaultStringify: <T>(value: T) => string;
498
+ declare const alwaysFalse: <T>(_value: T) => boolean;
499
+ declare const alwaysTrue: <T>(_value: T) => boolean;
500
+
501
+ /**
502
+ * Default handler for matching stringified version of an item and a search query
503
+ * @param item arbitrary element to match with a string
504
+ * @param matchValue search query
505
+ * @param stringify handler to turn item into a string
506
+ */
507
+ declare const defaultMatcher: <T>(item: T, matchValue: string, stringify?: StringInto<T>) => boolean;
508
+
509
+ declare function clamp(value: number, min: number, max: number): number;
510
+ declare function ensureSafeNumber(value: number): number;
511
+ declare function percentage(value: number, total: number): number;
512
+ declare function separateIntegerDecimal(value: number): {
513
+ integerPart: number;
514
+ decimalPart: number;
515
+ };
516
+
517
+ declare function setAtPath<T, P extends string, V extends PropPathSelector<T, P>>(obj: T, path: P, value: V): T;
518
+ declare function deleteImmutable<T, K extends keyof T = keyof T>(obj: T, key: K): Omit<T, K>;
519
+ declare function mergeWith<T extends object>(base: T, ...objs: T[]): T;
520
+ declare function diffWith<T extends object>(o1: T, o2: T, comparer: BinaryComparer<T[keyof T]>): Partial<T>;
521
+ declare function compareKeysWith<T extends object>(o1: T, o2: T, comparer: BinaryComparer<T[keyof T]>): Record<keyof T, boolean>;
522
+ declare function entries<T extends object, K extends keyof T>(obj: T): [K, T[K]][];
523
+ declare function hasNonNullValues<T extends object>(obj: T): boolean;
524
+ declare function zipToObject<T, R>(values: T[], keys: string[], mapper: Into<T, R>): Record<string, R>;
525
+
526
+ interface Handler<In extends string | PhoneNumber, Out> {
527
+ (phone: In, regionCode?: string): Out;
528
+ }
529
+ type Parser = Handler<string, PhoneNumber>;
530
+ type Formatter = Handler<string | PhoneNumber, string>;
531
+ declare function coerce(input: string | PhoneNumber): PhoneNumber;
532
+ declare const phoneNumber: Parser & {
533
+ coerce: typeof coerce;
534
+ e164: Formatter;
535
+ international: Formatter;
536
+ national: Formatter;
537
+ safe: ((phone: string, regionCode?: string | undefined) => PhoneNumber | undefined) & {
538
+ coerce: (input: string | PhoneNumber) => PhoneNumber | undefined;
539
+ e164: (phone: string | PhoneNumber, regionCode?: string | undefined) => string | undefined;
540
+ international: (phone: string | PhoneNumber, regionCode?: string | undefined) => string | undefined;
541
+ national: (phone: string | PhoneNumber, regionCode?: string | undefined) => string | undefined;
542
+ };
543
+ };
544
+
545
+ /**
546
+ * Lazily returns the shared `PhoneNumberUtil` instance.
547
+ *
548
+ * Never call `PhoneNumberUtil.getInstance()` at module level: that call runs as
549
+ * soon as the module loads, which stops bundlers from tree-shaking
550
+ * google-libphonenumber (~600 kB) out of apps that never use phone helpers.
551
+ */
552
+ declare function getPhoneNumberUtil(): PhoneNumberUtil;
553
+
554
+ declare class Deferred<T> extends Promise<T> {
555
+ readonly resolve: (value: T | PromiseLike<T>) => void;
556
+ readonly reject: (reason?: unknown) => void;
557
+ constructor();
558
+ asPromise(): Promise<T>;
559
+ }
560
+ declare function isPromise<T>(value: unknown): value is Promise<T>;
561
+ declare function isPromiseFulfilled<T>(promise: PromiseSettledResult<T>): promise is PromiseFulfilledResult<T>;
562
+ declare function isPromiseRejected<T>(promise: PromiseSettledResult<T>): promise is PromiseRejectedResult;
563
+ declare function waitTime(ms: number, signal?: AbortSignal): Promise<void>;
564
+
565
+ interface RealmOption {
566
+ readonly realm: string;
567
+ readonly hostname: string;
568
+ }
569
+ type RealmConfig = RealmOption[];
570
+ type RealmConfigInput = RealmOption[] | string;
571
+
572
+ declare function resolveRealmConfig(config: RealmConfigInput, hostname: string): string;
573
+
574
+ declare const DEFAULT_EMPTY_STRING_VALUE = "\u2013";
575
+ declare function ignoreAccent(value: string): string;
576
+ declare function normalize(value: string): string;
577
+ declare function stringChunks(value: string, size: number): string[];
578
+ declare function joinNonEmpty(...values: string[]): string;
579
+ declare function joinNonEmpty(...valuesAndOptions: [...string[], {
580
+ sep: string;
581
+ }]): string;
582
+ declare function isNonEmpty(value: Nullable<string>): value is string;
583
+ type EmptyString = null | undefined | '';
584
+ declare function isEmpty(value: Nullable<string>): value is EmptyString;
585
+ declare function toNonEmpty(value: Nullable<string>): string | undefined;
586
+
587
+ declare function removeFrontSlash(url: string): string;
588
+ declare function removeTrailingSlash(url: string): string;
589
+
590
+ declare function reduceAndOfBoolArr(): OperatorFunction<boolean[], boolean>;
591
+
592
+ declare function reduceOrOfBoolArr(): OperatorFunction<boolean[], boolean>;
593
+
594
+ /**
595
+ * Operator function to map each array element into an observable sequence,
596
+ * emitting results in chunks based on the specified chunk size.
597
+ * @param project A function to apply to each element of the source array.
598
+ * @param conf Optional conf
599
+ * @returns An operator function that maps input arrays to observable sequences,
600
+ * emitting results in chunks based on the specified chunk size.
601
+ */
602
+ declare function chunksMap<I, O extends ObservableInput<any>>(project: (value: I, index: number) => O, conf?: Partial<{
603
+ readonly chunkSize: number;
604
+ }>): OperatorFunction<I[], ObservedValueOf<O>[]>;
605
+
606
+ type ValueOrObs<T> = T | Observable<T>;
607
+ declare function resolveValueOrObs<T>(valueOrObs: ValueOrObs<T>, scheduler?: SchedulerLike): Observable<T>;
608
+
609
+ declare function concatOfArr<T>(external: ValueOrObs<T[]>): MonoTypeOperatorFunction<T[]>;
610
+
611
+ declare function everyOfArr<T>(fn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): OperatorFunction<T[], boolean>;
612
+
613
+ declare function filterOfArr<T, S extends T>(fn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): OperatorFunction<T[], S[]>;
614
+ declare function filterOfArr<T>(fn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): MonoTypeOperatorFunction<T[]>;
615
+
616
+ declare function findOfArr<T, S extends T>(fn: (this: void, value: T, index: number, obj: T[]) => value is S, thisArg?: any): OperatorFunction<T[], S | undefined>;
617
+ declare function findOfArr<T>(fn: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): OperatorFunction<T[], T | undefined>;
618
+
619
+ declare function firstOfArr<T>(defaultValue: T): OperatorFunction<T[], T>;
620
+ declare function firstOfArr<T>(): OperatorFunction<T[], T | undefined>;
621
+
622
+ declare function flatMapOfArr<T, U>(fn: (value: T, index: number, array: T[]) => U | ReadonlyArray<U>, thisArg?: any): OperatorFunction<T[], U[]>;
623
+
624
+ declare function groupByOfArr<K, V>(keyGetter: (item: V) => K): OperatorFunction<V[], Map<K, V[]>>;
625
+
626
+ declare function includesOfArr<T>(searchElement: T, fromIndex?: number): OperatorFunction<T[], boolean>;
627
+
628
+ declare function indexOfArr<T>(searchElement: T, fromIndex?: number): OperatorFunction<T[], number>;
629
+
630
+ declare function joinOfArr<T>(separator?: string): OperatorFunction<T[], string>;
631
+
632
+ declare function lastOfArr<T>(defaultValue: T): OperatorFunction<T[], T>;
633
+ declare function lastOfArr<T>(): OperatorFunction<T[], T | undefined>;
634
+
635
+ declare function lastIndexOfArr<T>(searchElement: T, fromIndex?: number): OperatorFunction<T[], number>;
636
+
637
+ declare function lengthOfArr<T>(): OperatorFunction<T[], number>;
638
+
639
+ declare function mapOfArr<T, U>(fn: (value: T, index: number, array: T[]) => U, thisArg?: any): OperatorFunction<T[], U[]>;
640
+
641
+ declare function operationOfArr(operand: (previousValue: number, currentValue: number) => number): OperatorFunction<number[], number>;
642
+
643
+ declare function subOfArr(): OperatorFunction<number[], number>;
644
+
645
+ declare function sumOfArr(): OperatorFunction<number[], number>;
646
+
647
+ declare function reduceOfArr<T, U>(fn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: () => U): OperatorFunction<T[], U>;
648
+ declare function reduceOfArr<T>(fn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: () => T): OperatorFunction<T[], T>;
649
+
650
+ declare function reverseOfArr<T>(): MonoTypeOperatorFunction<T[]>;
651
+
652
+ declare function sliceOfArr<T>(start?: number, end?: number): MonoTypeOperatorFunction<T[]>;
653
+
654
+ declare function someOfArr<T>(fn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): OperatorFunction<T[], boolean>;
655
+
656
+ declare function sortOfArr<T>(fn?: Comparer<T>): MonoTypeOperatorFunction<T[]>;
657
+
658
+ declare function switchMapOfArr<T, R>(fn: (value: T, index: number) => Observable<R>): OperatorFunction<T[], R[]>;
659
+
660
+ declare function tapOfArr<T>(fn: (value: T, index: number, array: T[]) => void, thisArg?: any): MonoTypeOperatorFunction<T[]>;
661
+
662
+ /**
663
+ * filter the falsy value
664
+ */
665
+ declare function filterFalsy(): OperatorFunction<boolean, void>;
666
+
667
+ /**
668
+ * filter the truthy value
669
+ */
670
+ declare function filterTruthy(): OperatorFunction<boolean, void>;
671
+
672
+ declare function delayOrNoop<T>(time: number): MonoTypeOperatorFunction<T>;
673
+
674
+ declare function documentVisibilityState(document: Document): Observable<DocumentVisibilityState>;
675
+
676
+ declare function exhaustMapBy<T, O extends ObservableInput<unknown>>(selector: (value: T) => unknown, project: (value: T, index: number) => O): OperatorFunction<T, ObservedValueOf<O>>;
677
+
678
+ interface Pagination {
679
+ readonly page: number;
680
+ readonly pageSize: number;
681
+ }
682
+ interface PaginatedResult<T> {
683
+ readonly items: T[];
684
+ readonly total: number;
685
+ }
686
+
687
+ interface FetchAllPaginatedElementsEvent<T> {
688
+ readonly page: PaginatedResult<T>;
689
+ readonly pagination: Pagination;
690
+ readonly chunkIndex: number;
691
+ }
692
+ interface FetchAllPaginatedElementsOptions<T> {
693
+ readonly pageSize?: number;
694
+ readonly chunkSize?: number;
695
+ readonly onEvent?: (event: FetchAllPaginatedElementsEvent<T>, abort: () => void) => void;
696
+ }
697
+ /** Fetches and aggregates every page returned by a paginated source. */
698
+ declare function fetchAllPaginatedElements<T>(source: (pagination: Pagination, chunkIndex: number) => ObservableInput<PaginatedResult<T>>, options?: FetchAllPaginatedElementsOptions<T>): Observable<T[]>;
699
+
700
+ declare function filterMasked<T>(predicate: (value: T) => boolean): OperatorFunction<T, void>;
701
+
702
+ declare function filterNotNullable<T>(): OperatorFunction<T | null | undefined, T>;
703
+
704
+ declare function filterNullable<T>(): OperatorFunction<T | null | undefined, null | undefined>;
705
+
706
+ declare function inactivity(dueTime: number, document: Document): rxjs.Observable<void>;
707
+
708
+ declare function mapToVoid<T>(): OperatorFunction<T, void>;
709
+
710
+ declare function minShowTime(minTrueDelay: number, // delay before emitting true
711
+ minTrueVisible: number): MonoTypeOperatorFunction<boolean>;
712
+
713
+ declare function maxOfNum(max$: ValueOrObs<number>): OperatorFunction<number, number>;
714
+
715
+ declare function observeMutation(element: Element, options?: MutationObserverInit): Observable<void>;
716
+
717
+ declare function observeResize(element: Element, options?: ResizeObserverOptions): Observable<void>;
718
+
719
+ declare const ONCE: Observable<void>;
720
+
721
+ declare function switchMapBy<T, O extends ObservableInput<unknown>>(selector: (value: T) => unknown, project: (value: T, index: number) => O): OperatorFunction<T, ObservedValueOf<O>>;
722
+
723
+ declare function switchMapConcurrent<T, R>(project: (value: T) => Observable<R>, conf?: {
724
+ abort$?: () => Observable<unknown>;
725
+ concurrent?: number;
726
+ onEmpty?: () => void;
727
+ }): OperatorFunction<T, R>;
728
+
729
+ declare function throwIfNot<T, S extends T>(predicate: (value: T) => value is S, errorFactory?: () => Error): OperatorFunction<T, S>;
730
+ declare function throwIfNot<T>(predicate: BooleanConstructor, errorFactory?: () => Error): OperatorFunction<T, TruthyTypesOf<T>>;
731
+ declare function throwIfNot<T>(predicate: (value: T) => boolean, errorFactory?: () => Error): MonoTypeOperatorFunction<T>;
732
+
733
+ declare function throwIfNullable<T>(errorFactory?: () => Error): OperatorFunction<T | null | undefined, T>;
734
+
735
+ interface Changes<TNext, TPrev = TNext> {
736
+ readonly previous: TPrev;
737
+ readonly next: TNext;
738
+ }
739
+
740
+ type Constructor<T> = new (...args: any[]) => T;
741
+ type AbstractConstructor<T = object> = abstract new (...args: any[]) => T;
742
+
743
+ type VoidFn<TArgs extends unknown[] = []> = (...args: TArgs) => void;
744
+
745
+ type I18nPluralMap = Record<string, string>;
746
+
747
+ type Matcher<T, Args extends unknown[] = []> = Mapper<T, boolean, Args>;
748
+ type StringMatcher<T> = Matcher<T, [
749
+ matchValue: string,
750
+ stringify: StringInto<T>
751
+ ]>;
752
+
753
+ type Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] extends N ? Acc[number] : Enumerate<N, [...Acc, Acc['length']]>;
754
+ type IntRange<Start extends number, End extends number> = Exclude<Enumerate<End>, Enumerate<Start>>;
755
+ interface MinMaxRange {
756
+ readonly min: number | null;
757
+ readonly max: number | null;
758
+ }
759
+
760
+ type SortDirection = 'asc' | 'desc';
761
+ interface Sort {
762
+ readonly active: string;
763
+ readonly direction: SortDirection;
764
+ }
765
+
766
+ type StateUpdater<T> = ValueOrFn<Partial<T>, [T]>;
767
+
768
+ type CamelCase<T extends string> = T extends `${infer Head}-${infer Tail}` ? `${Head}${Capitalize<CamelCase<Tail>>}` : T;
769
+
770
+ type Class = string | string[] | Set<string> | Record<string, unknown> | null | undefined;
771
+
772
+ type TrackBy<I, O> = (index: number, value: I) => O;
773
+
774
+ type ValueOrArr<T> = T | T[];
775
+ declare function resolveValueOrArr<T>(prop: ValueOrArr<T>): T[];
776
+
777
+ type ValueOrPromise<T> = T | Promise<T>;
778
+ declare function resolveValueOrPromise<T>(valueOrPromise: ValueOrPromise<T>): Promise<T>;
779
+
780
+ export { ActionRef, ActionRefError, CircularQueue, DEFAULT_EMPTY_STRING_VALUE, Deferred, FlatTree, GoSymbol, KoSymbol, LazyWeakMap, MoSymbol, ONCE, OctetSymbol, OpaqueTag, OpaqueTagSymbol, ToSymbol, addMany, addOne, addWorkingDays, alwaysFalse, alwaysTrue, arrayConf, asDataVolume, ascComparer, assertNonEmpty, assertNonNullable, assertValid, capitalize, chunksMap, cidrComparer, cidrIsNetworkAddress, clamp, clampDate, coerceNumber, coerceUserName, compareKeysWith, compareUsingTemplate, completeDiff, composeComparer, concatOfArr, createDebouncedFn, deepEqual, deepEqualComparer, defaultMatcher, defaultStringify, delayOrNoop, deleteImmutable, descComparer, diff, diffWith, distinct, documentVisibilityState, dropLast, ensureSafeNumber, entries, everyOfArr, exhaustMapBy, fetchAllPaginatedElements, filterFalsy, filterMasked, filterNotNullable, filterNullable, filterOfArr, filterTruthy, findOfArr, firstOfArr, flatMapOfArr, formatAddress, formatDuration, formatFileSize, formatFrenchPhoneNumber, formatPeriod, formatPhoneNumber, formatUserInitial, formatUserName, getCenteredSlice, getDeepest, getIpv4HostAddress, getIpv4NetworkAddressFromCidr, getIterationMeta, getPhoneNumberUtil, goToOctet, groupBy, groupByOfArr, hasNonNullValues, identity, ignoreAccent, inactivity, includesOfArr, indexOfArr, initial, insertAt, intersect, ipv4BelongsToCidr, isArray, isBase64Image, isBefore, isBeforeNow, isBoolArray, isBoolean, isDate, isDateInRange, isEmail, isEmpty, isError, isFn, isKey, isNonEmpty, isNotNull, isNotNullable, isNotUndefined, isNull, isNullable, isNumber, isNumberArray, isObject, isPromise, isPromiseFulfilled, isPromiseRejected, isString, isStringArray, isUndefined, isWorkingDay, joinNonEmpty, joinOfArr, koToOctet, lastIndexOfArr, lastOfArr, lengthOfArr, linkify, localeComparer, luhn, makeSafe, mapFileToBase64, mapNonEmptyArray, mapOfArr, mapToVoid, mapValues, maxOfNum, mergeWith, minShowTime, moToOctet, normalize, num2digit, observeMutation, observeResize, operationOfArr, parseFrenchPhoneNumber, parseNumber, percentage, phoneNumber, prettyBytes, reduceAndOfBoolArr, reduceOfArr, reduceOrOfBoolArr, removeFrontSlash, removeMany, removeOne, removeTrailingSlash, resolveRealmConfig, resolveValueOrArr, resolveValueOrFn, resolveValueOrObs, resolveValueOrPromise, reverseOfArr, safeCastFromStringArr, separateIntegerDecimal, setAtPath, setMany, setOne, sliceIntoChunks, sliceOfArr, someOfArr, sortOfArr, strictComparer, strictTitleCase, stringChunks, stringifyComparer, subOfArr, sumOfArr, switchMapBy, switchMapConcurrent, switchMapOfArr, tapOfArr, throwIfNot, throwIfNullable, toCamelCase, toGo, toKo, toMo, toNonEmpty, toReadableVolume, toTo, toToOctet, truncate, updateMany, updateOne, waitTime, withDefault, withDuration, withPhoneNumber, wrapNullishComparer, zipToObject };
781
+ export type { AbstractConstructor, ActionRefInput, ArrayConf, ArrayConfInput, ArrayUpdater, BinaryComparer, BooleanInto, CamelCase, Changes, Class, Comparer, CompleteDiffResult, Constructor, DataVolume, DataVolumeUnit, DataVolumeUnitName, DateRange, DeepPartial, EmptyObj, ExcludeProps, ExtractPropertyType, FetchAllPaginatedElementsEvent, FetchAllPaginatedElementsOptions, FlatTreeNode, FlatTreeOptions, FlatTreeRemoveOptions, Go, I18nPluralMap, IfNever, IfNullabe, IfUnknown, InferArr, IntRange, Into, IsNever, IsNullable, IsUnknown, IterationMeta, KeysOfValueType, Ko, Mapper, Matcher, MinMaxRange, Mo, NonEmptyArray, Nullable, NullableObject, NumberInto, Octet, Opaque, OptionalProps, PaginatedResult, Pagination, PartialEmptyChildren, PartialProps, PrefixKeys, PrettyBytesOptions, PropPathSelector, ReadableVolume, RealmConfig, RealmConfigInput, RealmOption, RequireAtLeastOne, RequireOnlyOne, SelectEntityId, Sort, SortDirection, StateUpdater, StringInto, StringMatcher, To, ToReadableVolumeArg, TrackBy, TreeNode, UserInput, ValueOrArr, ValueOrFn, ValueOrObs, ValueOrPromise, VoidFn, Writeable };