@etsoo/shared 1.1.59 → 1.1.61
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/README.md +1 -0
- package/lib/cjs/DataTypes.d.ts +9 -3
- package/lib/mjs/DataTypes.d.ts +9 -3
- package/package.json +7 -7
- package/src/DataTypes.ts +14 -4
package/README.md
CHANGED
|
@@ -103,6 +103,7 @@ Data type definitions and type safe functions. ListItemType and ListItemType1 ar
|
|
|
103
103
|
|IdNameItem|Item with id and name|
|
|
104
104
|
|KeyCollection|Key collection, like { key1: {}, key2: {} }|
|
|
105
105
|
|Keys|Get specific type keys|
|
|
106
|
+
|MConstructor|Mixins constructor|
|
|
106
107
|
|ObjType|Generic object type|
|
|
107
108
|
|RequireAtLeastOne|Require at least one property of the keys|
|
|
108
109
|
|Simple|Basic or basic array type|
|
package/lib/cjs/DataTypes.d.ts
CHANGED
|
@@ -120,11 +120,13 @@ export declare namespace DataTypes {
|
|
|
120
120
|
type IdType = number | string;
|
|
121
121
|
/**
|
|
122
122
|
* Add or edit conditional type for same data model
|
|
123
|
-
* Dynamic add changedFields for editing case
|
|
123
|
+
* Dynamic add id and changedFields for editing case
|
|
124
124
|
*/
|
|
125
|
-
type AddOrEditType<T, Editing extends boolean> =
|
|
125
|
+
type AddOrEditType<T extends object, Editing extends boolean, D extends string = 'id'> = Editing extends true ? Partial<T> & {
|
|
126
|
+
[key in D]: number | string;
|
|
127
|
+
} & {
|
|
126
128
|
changedFields?: string[];
|
|
127
|
-
};
|
|
129
|
+
} : T;
|
|
128
130
|
/**
|
|
129
131
|
* Key collection, like { key1: {}, key2: {} }
|
|
130
132
|
*/
|
|
@@ -143,6 +145,10 @@ export declare namespace DataTypes {
|
|
|
143
145
|
* Function type
|
|
144
146
|
*/
|
|
145
147
|
type Func<R> = (...args: any[]) => R;
|
|
148
|
+
/**
|
|
149
|
+
* Mixins constructor
|
|
150
|
+
*/
|
|
151
|
+
type MConstructor<T = {}> = new (...args: any[]) => T;
|
|
146
152
|
/**
|
|
147
153
|
* String key, unknown value Record
|
|
148
154
|
*/
|
package/lib/mjs/DataTypes.d.ts
CHANGED
|
@@ -120,11 +120,13 @@ export declare namespace DataTypes {
|
|
|
120
120
|
type IdType = number | string;
|
|
121
121
|
/**
|
|
122
122
|
* Add or edit conditional type for same data model
|
|
123
|
-
* Dynamic add changedFields for editing case
|
|
123
|
+
* Dynamic add id and changedFields for editing case
|
|
124
124
|
*/
|
|
125
|
-
type AddOrEditType<T, Editing extends boolean> =
|
|
125
|
+
type AddOrEditType<T extends object, Editing extends boolean, D extends string = 'id'> = Editing extends true ? Partial<T> & {
|
|
126
|
+
[key in D]: number | string;
|
|
127
|
+
} & {
|
|
126
128
|
changedFields?: string[];
|
|
127
|
-
};
|
|
129
|
+
} : T;
|
|
128
130
|
/**
|
|
129
131
|
* Key collection, like { key1: {}, key2: {} }
|
|
130
132
|
*/
|
|
@@ -143,6 +145,10 @@ export declare namespace DataTypes {
|
|
|
143
145
|
* Function type
|
|
144
146
|
*/
|
|
145
147
|
type Func<R> = (...args: any[]) => R;
|
|
148
|
+
/**
|
|
149
|
+
* Mixins constructor
|
|
150
|
+
*/
|
|
151
|
+
type MConstructor<T = {}> = new (...args: any[]) => T;
|
|
146
152
|
/**
|
|
147
153
|
* String key, unknown value Record
|
|
148
154
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/shared",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.61",
|
|
4
4
|
"description": "TypeScript shared utilities and functions",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -54,14 +54,14 @@
|
|
|
54
54
|
},
|
|
55
55
|
"homepage": "https://github.com/ETSOO/Shared#readme",
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@types/jest": "^29.1.
|
|
58
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
59
|
-
"@typescript-eslint/parser": "^5.
|
|
60
|
-
"eslint": "^8.
|
|
57
|
+
"@types/jest": "^29.1.2",
|
|
58
|
+
"@typescript-eslint/eslint-plugin": "^5.40.0",
|
|
59
|
+
"@typescript-eslint/parser": "^5.40.0",
|
|
60
|
+
"eslint": "^8.25.0",
|
|
61
61
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
62
62
|
"eslint-plugin-import": "^2.26.0",
|
|
63
|
-
"jest": "^29.
|
|
64
|
-
"jest-environment-jsdom": "^29.
|
|
63
|
+
"jest": "^29.2.0",
|
|
64
|
+
"jest-environment-jsdom": "^29.2.0",
|
|
65
65
|
"ts-jest": "^29.0.3",
|
|
66
66
|
"typescript": "^4.8.4"
|
|
67
67
|
}
|
package/src/DataTypes.ts
CHANGED
|
@@ -155,12 +155,17 @@ export namespace DataTypes {
|
|
|
155
155
|
|
|
156
156
|
/**
|
|
157
157
|
* Add or edit conditional type for same data model
|
|
158
|
-
* Dynamic add changedFields for editing case
|
|
158
|
+
* Dynamic add id and changedFields for editing case
|
|
159
159
|
*/
|
|
160
160
|
export type AddOrEditType<
|
|
161
|
-
T,
|
|
162
|
-
Editing extends boolean
|
|
163
|
-
|
|
161
|
+
T extends object,
|
|
162
|
+
Editing extends boolean,
|
|
163
|
+
D extends string = 'id'
|
|
164
|
+
> = Editing extends true
|
|
165
|
+
? Partial<T> & { [key in D]: number | string } & {
|
|
166
|
+
changedFields?: string[];
|
|
167
|
+
}
|
|
168
|
+
: T;
|
|
164
169
|
|
|
165
170
|
/**
|
|
166
171
|
* Key collection, like { key1: {}, key2: {} }
|
|
@@ -184,6 +189,11 @@ export namespace DataTypes {
|
|
|
184
189
|
*/
|
|
185
190
|
export type Func<R> = (...args: any[]) => R;
|
|
186
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Mixins constructor
|
|
194
|
+
*/
|
|
195
|
+
export type MConstructor<T = {}> = new (...args: any[]) => T;
|
|
196
|
+
|
|
187
197
|
/**
|
|
188
198
|
* String key, unknown value Record
|
|
189
199
|
*/
|