@etsoo/shared 1.2.20 → 1.2.21
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/lib/cjs/DataTypes.d.ts +9 -9
- package/lib/cjs/IActionResult.d.ts +2 -2
- package/lib/cjs/Utils.d.ts +3 -3
- package/lib/mjs/DataTypes.d.ts +9 -9
- package/lib/mjs/IActionResult.d.ts +2 -2
- package/lib/mjs/Utils.d.ts +3 -3
- package/package.json +1 -1
- package/src/DataTypes.ts +15 -14
- package/src/IActionResult.ts +4 -5
- package/src/Utils.ts +3 -3
package/lib/cjs/DataTypes.d.ts
CHANGED
|
@@ -133,10 +133,6 @@ export declare namespace DataTypes {
|
|
|
133
133
|
* Placement type
|
|
134
134
|
*/
|
|
135
135
|
type Placement = keyof typeof PlacementEnum;
|
|
136
|
-
/**
|
|
137
|
-
* Number and string combination id type
|
|
138
|
-
*/
|
|
139
|
-
type IdType = number | string;
|
|
140
136
|
/**
|
|
141
137
|
* Add and edit data type
|
|
142
138
|
* ChangedFields for editing case
|
|
@@ -240,7 +236,7 @@ export declare namespace DataTypes {
|
|
|
240
236
|
/**
|
|
241
237
|
* Get specific type keys
|
|
242
238
|
*/
|
|
243
|
-
type Keys<T extends object, R =
|
|
239
|
+
type Keys<T extends object, R = IdType> = {
|
|
244
240
|
[k in keyof T]: T[k] extends R ? k : never;
|
|
245
241
|
}[keyof T];
|
|
246
242
|
/**
|
|
@@ -368,7 +364,7 @@ export declare namespace DataTypes {
|
|
|
368
364
|
* @param key Property name
|
|
369
365
|
* @returns Id value
|
|
370
366
|
*/
|
|
371
|
-
function getIdValue<T extends object, K extends Keys<T,
|
|
367
|
+
function getIdValue<T extends object, K extends Keys<T, IdType>>(data: T, key: K): T[K];
|
|
372
368
|
/**
|
|
373
369
|
* Get object id field value 1
|
|
374
370
|
* @param data Data
|
|
@@ -408,6 +404,10 @@ export declare namespace DataTypes {
|
|
|
408
404
|
*/
|
|
409
405
|
function jsonReplacer(replacer: (this: any, key: string, value: any, path: string) => any): (this: any, key: any, value: any) => any;
|
|
410
406
|
}
|
|
407
|
+
/**
|
|
408
|
+
* Number and string combination id type
|
|
409
|
+
*/
|
|
410
|
+
export type IdType = number | string;
|
|
411
411
|
/**
|
|
412
412
|
* List item with number id type
|
|
413
413
|
*/
|
|
@@ -420,7 +420,7 @@ export type ListType1 = DataTypes.IdLabelItem<string>;
|
|
|
420
420
|
* List item with compatible id and name / label / title
|
|
421
421
|
*/
|
|
422
422
|
export type ListType2 = {
|
|
423
|
-
id:
|
|
423
|
+
id: IdType;
|
|
424
424
|
} & ({
|
|
425
425
|
label: string;
|
|
426
426
|
} | {
|
|
@@ -431,8 +431,8 @@ export type ListType2 = {
|
|
|
431
431
|
/**
|
|
432
432
|
* Id default type
|
|
433
433
|
*/
|
|
434
|
-
export type IdDefaultType<T extends object> = T extends {
|
|
435
|
-
id:
|
|
434
|
+
export type IdDefaultType<T extends object, I extends IdType = IdType> = T extends {
|
|
435
|
+
id: I;
|
|
436
436
|
} ? DataTypes.Keys<T> & 'id' : DataTypes.Keys<T>;
|
|
437
437
|
/**
|
|
438
438
|
* Label default type
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IdType } from './DataTypes';
|
|
2
2
|
/**
|
|
3
3
|
* Result errors
|
|
4
4
|
* Indexable type
|
|
@@ -50,7 +50,7 @@ export interface IActionResult<D extends object = {}> {
|
|
|
50
50
|
/**
|
|
51
51
|
* Action result with id data
|
|
52
52
|
*/
|
|
53
|
-
export type IdActionResult<T extends
|
|
53
|
+
export type IdActionResult<T extends IdType = number> = IActionResult<{
|
|
54
54
|
id: T;
|
|
55
55
|
}>;
|
|
56
56
|
/**
|
package/lib/cjs/Utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataTypes } from './DataTypes';
|
|
1
|
+
import { DataTypes, IdType } from './DataTypes';
|
|
2
2
|
import { ParsedPath } from './types/ParsedPath';
|
|
3
3
|
declare global {
|
|
4
4
|
interface String {
|
|
@@ -102,7 +102,7 @@ export declare namespace Utils {
|
|
|
102
102
|
* @returns Result
|
|
103
103
|
*/
|
|
104
104
|
function exclude<T extends {
|
|
105
|
-
[P in D]:
|
|
105
|
+
[P in D]: IdType;
|
|
106
106
|
}, D extends string = 'id'>(items: T[], field: D, ...excludedValues: T[D][]): T[];
|
|
107
107
|
/**
|
|
108
108
|
* Async exclude specific items
|
|
@@ -112,7 +112,7 @@ export declare namespace Utils {
|
|
|
112
112
|
* @returns Result
|
|
113
113
|
*/
|
|
114
114
|
function excludeAsync<T extends {
|
|
115
|
-
[P in D]:
|
|
115
|
+
[P in D]: IdType;
|
|
116
116
|
}, D extends string = 'id'>(items: Promise<T[] | undefined>, field: D, ...excludedValues: T[D][]): Promise<T[] | undefined>;
|
|
117
117
|
/**
|
|
118
118
|
* Format inital character to lower case or upper case
|
package/lib/mjs/DataTypes.d.ts
CHANGED
|
@@ -133,10 +133,6 @@ export declare namespace DataTypes {
|
|
|
133
133
|
* Placement type
|
|
134
134
|
*/
|
|
135
135
|
type Placement = keyof typeof PlacementEnum;
|
|
136
|
-
/**
|
|
137
|
-
* Number and string combination id type
|
|
138
|
-
*/
|
|
139
|
-
type IdType = number | string;
|
|
140
136
|
/**
|
|
141
137
|
* Add and edit data type
|
|
142
138
|
* ChangedFields for editing case
|
|
@@ -240,7 +236,7 @@ export declare namespace DataTypes {
|
|
|
240
236
|
/**
|
|
241
237
|
* Get specific type keys
|
|
242
238
|
*/
|
|
243
|
-
type Keys<T extends object, R =
|
|
239
|
+
type Keys<T extends object, R = IdType> = {
|
|
244
240
|
[k in keyof T]: T[k] extends R ? k : never;
|
|
245
241
|
}[keyof T];
|
|
246
242
|
/**
|
|
@@ -368,7 +364,7 @@ export declare namespace DataTypes {
|
|
|
368
364
|
* @param key Property name
|
|
369
365
|
* @returns Id value
|
|
370
366
|
*/
|
|
371
|
-
function getIdValue<T extends object, K extends Keys<T,
|
|
367
|
+
function getIdValue<T extends object, K extends Keys<T, IdType>>(data: T, key: K): T[K];
|
|
372
368
|
/**
|
|
373
369
|
* Get object id field value 1
|
|
374
370
|
* @param data Data
|
|
@@ -408,6 +404,10 @@ export declare namespace DataTypes {
|
|
|
408
404
|
*/
|
|
409
405
|
function jsonReplacer(replacer: (this: any, key: string, value: any, path: string) => any): (this: any, key: any, value: any) => any;
|
|
410
406
|
}
|
|
407
|
+
/**
|
|
408
|
+
* Number and string combination id type
|
|
409
|
+
*/
|
|
410
|
+
export type IdType = number | string;
|
|
411
411
|
/**
|
|
412
412
|
* List item with number id type
|
|
413
413
|
*/
|
|
@@ -420,7 +420,7 @@ export type ListType1 = DataTypes.IdLabelItem<string>;
|
|
|
420
420
|
* List item with compatible id and name / label / title
|
|
421
421
|
*/
|
|
422
422
|
export type ListType2 = {
|
|
423
|
-
id:
|
|
423
|
+
id: IdType;
|
|
424
424
|
} & ({
|
|
425
425
|
label: string;
|
|
426
426
|
} | {
|
|
@@ -431,8 +431,8 @@ export type ListType2 = {
|
|
|
431
431
|
/**
|
|
432
432
|
* Id default type
|
|
433
433
|
*/
|
|
434
|
-
export type IdDefaultType<T extends object> = T extends {
|
|
435
|
-
id:
|
|
434
|
+
export type IdDefaultType<T extends object, I extends IdType = IdType> = T extends {
|
|
435
|
+
id: I;
|
|
436
436
|
} ? DataTypes.Keys<T> & 'id' : DataTypes.Keys<T>;
|
|
437
437
|
/**
|
|
438
438
|
* Label default type
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IdType } from './DataTypes';
|
|
2
2
|
/**
|
|
3
3
|
* Result errors
|
|
4
4
|
* Indexable type
|
|
@@ -50,7 +50,7 @@ export interface IActionResult<D extends object = {}> {
|
|
|
50
50
|
/**
|
|
51
51
|
* Action result with id data
|
|
52
52
|
*/
|
|
53
|
-
export type IdActionResult<T extends
|
|
53
|
+
export type IdActionResult<T extends IdType = number> = IActionResult<{
|
|
54
54
|
id: T;
|
|
55
55
|
}>;
|
|
56
56
|
/**
|
package/lib/mjs/Utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataTypes } from './DataTypes';
|
|
1
|
+
import { DataTypes, IdType } from './DataTypes';
|
|
2
2
|
import { ParsedPath } from './types/ParsedPath';
|
|
3
3
|
declare global {
|
|
4
4
|
interface String {
|
|
@@ -102,7 +102,7 @@ export declare namespace Utils {
|
|
|
102
102
|
* @returns Result
|
|
103
103
|
*/
|
|
104
104
|
function exclude<T extends {
|
|
105
|
-
[P in D]:
|
|
105
|
+
[P in D]: IdType;
|
|
106
106
|
}, D extends string = 'id'>(items: T[], field: D, ...excludedValues: T[D][]): T[];
|
|
107
107
|
/**
|
|
108
108
|
* Async exclude specific items
|
|
@@ -112,7 +112,7 @@ export declare namespace Utils {
|
|
|
112
112
|
* @returns Result
|
|
113
113
|
*/
|
|
114
114
|
function excludeAsync<T extends {
|
|
115
|
-
[P in D]:
|
|
115
|
+
[P in D]: IdType;
|
|
116
116
|
}, D extends string = 'id'>(items: Promise<T[] | undefined>, field: D, ...excludedValues: T[D][]): Promise<T[] | undefined>;
|
|
117
117
|
/**
|
|
118
118
|
* Format inital character to lower case or upper case
|
package/package.json
CHANGED
package/src/DataTypes.ts
CHANGED
|
@@ -172,11 +172,6 @@ export namespace DataTypes {
|
|
|
172
172
|
*/
|
|
173
173
|
export type Placement = keyof typeof PlacementEnum;
|
|
174
174
|
|
|
175
|
-
/**
|
|
176
|
-
* Number and string combination id type
|
|
177
|
-
*/
|
|
178
|
-
export type IdType = number | string;
|
|
179
|
-
|
|
180
175
|
/**
|
|
181
176
|
* Add and edit data type
|
|
182
177
|
* ChangedFields for editing case
|
|
@@ -300,7 +295,7 @@ export namespace DataTypes {
|
|
|
300
295
|
/**
|
|
301
296
|
* Get specific type keys
|
|
302
297
|
*/
|
|
303
|
-
export type Keys<T extends object, R =
|
|
298
|
+
export type Keys<T extends object, R = IdType> = {
|
|
304
299
|
[k in keyof T]: T[k] extends R ? k : never;
|
|
305
300
|
}[keyof T];
|
|
306
301
|
|
|
@@ -654,10 +649,10 @@ export namespace DataTypes {
|
|
|
654
649
|
* @param key Property name
|
|
655
650
|
* @returns Id value
|
|
656
651
|
*/
|
|
657
|
-
export function getIdValue<
|
|
658
|
-
T
|
|
659
|
-
K
|
|
660
|
-
|
|
652
|
+
export function getIdValue<T extends object, K extends Keys<T, IdType>>(
|
|
653
|
+
data: T,
|
|
654
|
+
key: K
|
|
655
|
+
): T[K] {
|
|
661
656
|
return data[key];
|
|
662
657
|
}
|
|
663
658
|
|
|
@@ -778,6 +773,11 @@ export namespace DataTypes {
|
|
|
778
773
|
}
|
|
779
774
|
}
|
|
780
775
|
|
|
776
|
+
/**
|
|
777
|
+
* Number and string combination id type
|
|
778
|
+
*/
|
|
779
|
+
export type IdType = number | string;
|
|
780
|
+
|
|
781
781
|
/**
|
|
782
782
|
* List item with number id type
|
|
783
783
|
*/
|
|
@@ -792,15 +792,16 @@ export type ListType1 = DataTypes.IdLabelItem<string>;
|
|
|
792
792
|
* List item with compatible id and name / label / title
|
|
793
793
|
*/
|
|
794
794
|
export type ListType2 = {
|
|
795
|
-
id:
|
|
795
|
+
id: IdType;
|
|
796
796
|
} & ({ label: string } | { name: string } | { title: string });
|
|
797
797
|
|
|
798
798
|
/**
|
|
799
799
|
* Id default type
|
|
800
800
|
*/
|
|
801
|
-
export type IdDefaultType<
|
|
802
|
-
|
|
803
|
-
|
|
801
|
+
export type IdDefaultType<
|
|
802
|
+
T extends object,
|
|
803
|
+
I extends IdType = IdType
|
|
804
|
+
> = T extends { id: I } ? DataTypes.Keys<T> & 'id' : DataTypes.Keys<T>;
|
|
804
805
|
|
|
805
806
|
/**
|
|
806
807
|
* Label default type
|
package/src/IActionResult.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IdType } from './DataTypes';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Result errors
|
|
@@ -61,10 +61,9 @@ export interface IActionResult<D extends object = {}> {
|
|
|
61
61
|
/**
|
|
62
62
|
* Action result with id data
|
|
63
63
|
*/
|
|
64
|
-
export type IdActionResult<T extends
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}>;
|
|
64
|
+
export type IdActionResult<T extends IdType = number> = IActionResult<{
|
|
65
|
+
id: T;
|
|
66
|
+
}>;
|
|
68
67
|
|
|
69
68
|
/**
|
|
70
69
|
* Action result with dynamic data
|
package/src/Utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataTypes } from './DataTypes';
|
|
1
|
+
import { DataTypes, IdType } from './DataTypes';
|
|
2
2
|
import isEqual from 'lodash.isequal';
|
|
3
3
|
import { DateUtils } from './DateUtils';
|
|
4
4
|
import { ParsedPath } from './types/ParsedPath';
|
|
@@ -247,7 +247,7 @@ export namespace Utils {
|
|
|
247
247
|
* @returns Result
|
|
248
248
|
*/
|
|
249
249
|
export function exclude<
|
|
250
|
-
T extends { [P in D]:
|
|
250
|
+
T extends { [P in D]: IdType },
|
|
251
251
|
D extends string = 'id'
|
|
252
252
|
>(items: T[], field: D, ...excludedValues: T[D][]) {
|
|
253
253
|
return items.filter((item) => !excludedValues.includes(item[field]));
|
|
@@ -261,7 +261,7 @@ export namespace Utils {
|
|
|
261
261
|
* @returns Result
|
|
262
262
|
*/
|
|
263
263
|
export async function excludeAsync<
|
|
264
|
-
T extends { [P in D]:
|
|
264
|
+
T extends { [P in D]: IdType },
|
|
265
265
|
D extends string = 'id'
|
|
266
266
|
>(items: Promise<T[] | undefined>, field: D, ...excludedValues: T[D][]) {
|
|
267
267
|
const result = await items;
|