@etsoo/shared 1.2.56 → 1.2.58

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.
@@ -89,6 +89,7 @@ declare global {
89
89
  * Utilities
90
90
  */
91
91
  export declare namespace Utils {
92
+ const IgnoredProperty: "changedFields";
92
93
  /**
93
94
  * Add blank item to collection
94
95
  * @param options Options
@@ -96,19 +97,19 @@ export declare namespace Utils {
96
97
  * @param labelField Label field, default is label
97
98
  * @param blankLabel Blank label, default is ---
98
99
  */
99
- function addBlankItem<T extends object>(options: T[], idField?: string | keyof T, labelField?: unknown, blankLabel?: string): T[];
100
+ export function addBlankItem<T extends object>(options: T[], idField?: string | keyof T, labelField?: unknown, blankLabel?: string): T[];
100
101
  /**
101
102
  * Base64 chars to number
102
103
  * @param base64Chars Base64 chars
103
104
  * @returns Number
104
105
  */
105
- function charsToNumber(base64Chars: string): number;
106
+ export function charsToNumber(base64Chars: string): number;
106
107
  /**
107
108
  * Correct object's property value type
108
109
  * @param input Input object
109
110
  * @param fields Fields to correct
110
111
  */
111
- function correctTypes<T extends object, F extends {
112
+ export function correctTypes<T extends object, F extends {
112
113
  [P in keyof T]?: DataTypes.BasicNames;
113
114
  }>(input: T, fields: F): void;
114
115
  /**
@@ -117,7 +118,7 @@ export declare namespace Utils {
117
118
  * @param v2 Value 2
118
119
  * @param strict Strict level, 0 with ==, 1 === but null equal undefined, 2 ===
119
120
  */
120
- function equals(v1: unknown, v2: unknown, strict?: number): boolean;
121
+ export function equals(v1: unknown, v2: unknown, strict?: number): boolean;
121
122
  /**
122
123
  * Exclude specific items
123
124
  * @param items Items
@@ -125,7 +126,7 @@ export declare namespace Utils {
125
126
  * @param excludedValues Excluded values
126
127
  * @returns Result
127
128
  */
128
- function exclude<T extends {
129
+ export function exclude<T extends {
129
130
  [P in D]: IdType;
130
131
  }, D extends string = "id">(items: T[], field: D, ...excludedValues: T[D][]): T[];
131
132
  /**
@@ -135,7 +136,7 @@ export declare namespace Utils {
135
136
  * @param excludedValues Excluded values
136
137
  * @returns Result
137
138
  */
138
- function excludeAsync<T extends {
139
+ export function excludeAsync<T extends {
139
140
  [P in D]: IdType;
140
141
  }, D extends string = "id">(items: Promise<T[] | undefined>, field: D, ...excludedValues: T[D][]): Promise<T[] | undefined>;
141
142
  /**
@@ -143,75 +144,75 @@ export declare namespace Utils {
143
144
  * @param input Input string
144
145
  * @param upperCase To upper case or lower case
145
146
  */
146
- function formatInitial(input: string, upperCase?: boolean): string;
147
+ export function formatInitial(input: string, upperCase?: boolean): string;
147
148
  /**
148
149
  * Format string with parameters
149
150
  * @param template Template with {0}, {1}, ...
150
151
  * @param parameters Parameters to fill the template
151
152
  * @returns Result
152
153
  */
153
- function formatString(template: string, ...parameters: string[]): string;
154
+ export function formatString(template: string, ...parameters: string[]): string;
154
155
  /**
155
- * Get data changed fields with input data updated
156
+ * Get data changed fields (ignored changedFields) with input data updated
156
157
  * @param input Input data
157
158
  * @param initData Initial data
158
159
  * @param ignoreFields Ignore fields
159
160
  * @returns
160
161
  */
161
- function getDataChanges<T extends object>(input: T, initData: object, ignoreFields?: string[]): (keyof T & string)[];
162
+ export function getDataChanges<T extends object>(input: T, initData: object, ignoreFields?: string[]): Exclude<keyof T & string, typeof IgnoredProperty>[];
162
163
  /**
163
164
  * Get nested value from object
164
165
  * @param data Data
165
166
  * @param name Field name, support property chain like 'jsonData.logSize'
166
167
  * @returns Result
167
168
  */
168
- function getNestedValue(data: object, name: string): any;
169
+ export function getNestedValue(data: object, name: string): any;
169
170
  /**
170
171
  * Get input function or value result
171
172
  * @param input Input function or value
172
173
  * @param args Arguments
173
174
  * @returns Result
174
175
  */
175
- const getResult: <R, T = R | DataTypes.Func<R>>(input: T, ...args: T extends DataTypes.Func<R> ? Parameters<typeof input> : never | []) => T extends DataTypes.Func<R> ? ReturnType<T> : T;
176
+ export const getResult: <R, T = R | DataTypes.Func<R>>(input: T, ...args: T extends DataTypes.Func<R> ? Parameters<typeof input> : never | []) => T extends DataTypes.Func<R> ? ReturnType<T> : T;
176
177
  /**
177
178
  * Get time zone
178
179
  * @returns Timezone
179
180
  */
180
- const getTimeZone: () => string | undefined;
181
+ export const getTimeZone: () => string | undefined;
181
182
  /**
182
183
  * Is digits string
183
184
  * @param input Input string
184
185
  * @param minLength Minimum length
185
186
  * @returns Result
186
187
  */
187
- const isDigits: (input?: string, minLength?: number) => boolean;
188
+ export const isDigits: (input?: string, minLength?: number) => boolean;
188
189
  /**
189
190
  * Is email string
190
191
  * @param input Input string
191
192
  * @returns Result
192
193
  */
193
- const isEmail: (input?: string) => boolean;
194
+ export const isEmail: (input?: string) => boolean;
194
195
  /**
195
196
  * Join items as a string
196
197
  * @param items Items
197
198
  * @param joinPart Join string
198
199
  */
199
- const joinItems: (items: (string | undefined)[], joinPart?: string) => string;
200
+ export const joinItems: (items: (string | undefined)[], joinPart?: string) => string;
200
201
  /**
201
202
  * Merge class names
202
203
  * @param classNames Class names
203
204
  */
204
- const mergeClasses: (...classNames: (string | undefined)[]) => string;
205
+ export const mergeClasses: (...classNames: (string | undefined)[]) => string;
205
206
  /**
206
207
  * Create a GUID
207
208
  */
208
- function newGUID(): string;
209
+ export function newGUID(): string;
209
210
  /**
210
211
  * Number to base64 chars
211
212
  * @param num Input number
212
213
  * @returns Result
213
214
  */
214
- function numberToChars(num: number): string;
215
+ export function numberToChars(num: number): string;
215
216
  /**
216
217
  * Test two objects are equal or not
217
218
  * @param obj1 Object 1
@@ -220,7 +221,7 @@ export declare namespace Utils {
220
221
  * @param strict Strict level, 0 with ==, 1 === but null equal undefined, 2 ===
221
222
  * @returns Result
222
223
  */
223
- function objectEqual(obj1: object, obj2: object, ignoreFields?: string[], strict?: number): boolean;
224
+ export function objectEqual(obj1: object, obj2: object, ignoreFields?: string[], strict?: number): boolean;
224
225
  /**
225
226
  * Get two object's unqiue properties
226
227
  * @param obj1 Object 1
@@ -228,7 +229,7 @@ export declare namespace Utils {
228
229
  * @param ignoreFields Ignored fields
229
230
  * @returns Unique properties
230
231
  */
231
- function objectKeys(obj1: object, obj2: object, ignoreFields?: string[]): Set<string>;
232
+ export function objectKeys(obj1: object, obj2: object, ignoreFields?: string[]): Set<string>;
232
233
  /**
233
234
  * Get the new object's updated fields contrast to the previous object
234
235
  * @param objNew New object
@@ -237,21 +238,21 @@ export declare namespace Utils {
237
238
  * @param strict Strict level, 0 with ==, 1 === but null equal undefined, 2 ===
238
239
  * @returns Updated fields
239
240
  */
240
- function objectUpdated(objNew: object, objPrev: object, ignoreFields?: string[], strict?: number): string[];
241
+ export function objectUpdated(objNew: object, objPrev: object, ignoreFields?: string[], strict?: number): string[];
241
242
  /**
242
243
  * Try to parse JSON input to array
243
244
  * @param input JSON input
244
245
  * @param checkValue Type check value
245
246
  * @returns Result
246
247
  */
247
- function parseJsonArray<T>(input: string, checkValue?: T): T[] | undefined;
248
+ export function parseJsonArray<T>(input: string, checkValue?: T): T[] | undefined;
248
249
  /**
249
250
  * Parse string (JSON) to specific type, no type conversion
250
251
  * For type conversion, please use DataTypes.convert
251
252
  * @param input Input string
252
253
  * @returns Parsed value
253
254
  */
254
- function parseString<T>(input: string | undefined | null): T | undefined;
255
+ export function parseString<T>(input: string | undefined | null): T | undefined;
255
256
  /**
256
257
  * Parse string (JSON) to specific type, no type conversion
257
258
  * For type conversion, please use DataTypes.convert
@@ -259,38 +260,38 @@ export declare namespace Utils {
259
260
  * @param defaultValue Default value
260
261
  * @returns Parsed value
261
262
  */
262
- function parseString<T>(input: string | undefined | null, defaultValue: T): T;
263
+ export function parseString<T>(input: string | undefined | null, defaultValue: T): T;
263
264
  /**
264
265
  * Remove empty values (null, undefined, '') from the input object
265
266
  * @param input Input object
266
267
  */
267
- function removeEmptyValues(input: object): void;
268
+ export function removeEmptyValues(input: object): void;
268
269
  /**
269
270
  * Remove non letters
270
271
  * @param input Input string
271
272
  * @returns Result
272
273
  */
273
- const removeNonLetters: (input?: string) => string | undefined;
274
+ export const removeNonLetters: (input?: string) => string | undefined;
274
275
  /**
275
276
  * Replace null or empty with default value
276
277
  * @param input Input string
277
278
  * @param defaultValue Default value
278
279
  * @returns Result
279
280
  */
280
- const replaceNullOrEmpty: (input: string | null | undefined, defaultValue: string) => string;
281
+ export const replaceNullOrEmpty: (input: string | null | undefined, defaultValue: string) => string;
281
282
  /**
282
283
  * Set source with new labels
283
284
  * @param source Source
284
285
  * @param labels Labels
285
286
  * @param reference Key reference dictionary
286
287
  */
287
- const setLabels: (source: DataTypes.StringRecord, labels: DataTypes.StringRecord, reference?: Readonly<DataTypes.StringDictionary>) => void;
288
+ export const setLabels: (source: DataTypes.StringRecord, labels: DataTypes.StringRecord, reference?: Readonly<DataTypes.StringDictionary>) => void;
288
289
  /**
289
290
  * Snake name to works, 'snake_name' to 'Snake Name'
290
291
  * @param name Name text
291
292
  * @param firstOnly Only convert the first word to upper case
292
293
  */
293
- const snakeNameToWord: (name: string, firstOnly?: boolean) => string;
294
+ export const snakeNameToWord: (name: string, firstOnly?: boolean) => string;
294
295
  /**
295
296
  * Set nested value to object
296
297
  * @param data Data
@@ -298,19 +299,19 @@ export declare namespace Utils {
298
299
  * @param value Value
299
300
  * @param keepNull Keep null value or not
300
301
  */
301
- function setNestedValue(data: object, name: string, value: unknown, keepNull?: boolean): void;
302
+ export function setNestedValue(data: object, name: string, value: unknown, keepNull?: boolean): void;
302
303
  /**
303
304
  * Parse path similar with node.js path.parse
304
305
  * @param path Input path
305
306
  */
306
- const parsePath: (path: string) => ParsedPath;
307
+ export const parsePath: (path: string) => ParsedPath;
307
308
  /**
308
309
  * Sort array by favored values
309
310
  * @param items Items
310
311
  * @param favored Favored values
311
312
  * @returns Sorted array
312
313
  */
313
- const sortByFavor: <T>(items: T[], favored: T[]) => T[];
314
+ export const sortByFavor: <T>(items: T[], favored: T[]) => T[];
314
315
  /**
315
316
  * Sort array by favored field values
316
317
  * @param items Items
@@ -318,26 +319,27 @@ export declare namespace Utils {
318
319
  * @param favored Favored field values
319
320
  * @returns Sorted array
320
321
  */
321
- const sortByFieldFavor: <T, F extends keyof T>(items: T[], field: F, favored: T[F][]) => T[];
322
+ export const sortByFieldFavor: <T, F extends keyof T>(items: T[], field: F, favored: T[F][]) => T[];
322
323
  /**
323
324
  * Trim chars
324
325
  * @param input Input string
325
326
  * @param chars Trim chars
326
327
  * @returns Result
327
328
  */
328
- const trim: (input: string, ...chars: string[]) => string;
329
+ export const trim: (input: string, ...chars: string[]) => string;
329
330
  /**
330
331
  * Trim end chars
331
332
  * @param input Input string
332
333
  * @param chars Trim chars
333
334
  * @returns Result
334
335
  */
335
- const trimEnd: (input: string, ...chars: string[]) => string;
336
+ export const trimEnd: (input: string, ...chars: string[]) => string;
336
337
  /**
337
338
  * Trim start chars
338
339
  * @param input Input string
339
340
  * @param chars Trim chars
340
341
  * @returns Result
341
342
  */
342
- const trimStart: (input: string, ...chars: string[]) => string;
343
+ export const trimStart: (input: string, ...chars: string[]) => string;
344
+ export {};
343
345
  }
package/lib/cjs/Utils.js CHANGED
@@ -133,6 +133,7 @@ String.prototype.removeNonLetters = function () {
133
133
  */
134
134
  var Utils;
135
135
  (function (Utils) {
136
+ const IgnoredProperty = "changedFields";
136
137
  /**
137
138
  * Add blank item to collection
138
139
  * @param options Options
@@ -253,7 +254,7 @@ var Utils;
253
254
  }
254
255
  Utils.formatString = formatString;
255
256
  /**
256
- * Get data changed fields with input data updated
257
+ * Get data changed fields (ignored changedFields) with input data updated
257
258
  * @param input Input data
258
259
  * @param initData Initial data
259
260
  * @param ignoreFields Ignore fields
@@ -264,7 +265,7 @@ var Utils;
264
265
  const changes = [];
265
266
  Object.entries(input).forEach(([key, value]) => {
266
267
  // Ignore fields, no process
267
- if (ignoreFields.includes(key))
268
+ if (key === IgnoredProperty || ignoreFields.includes(key))
268
269
  return;
269
270
  // Compare with init value
270
271
  const initValue = Reflect.get(initData, key);
@@ -147,7 +147,7 @@ export declare namespace DataTypes {
147
147
  }, D extends string = "id"> = (Omit<T, D> & {
148
148
  [key in D]?: undefined | never;
149
149
  }) | (Partial<T> & Readonly<Pick<T, D>> & {
150
- changedFields?: string[];
150
+ changedFields?: (keyof T & string)[];
151
151
  });
152
152
  /**
153
153
  * Add or edit conditional type
@@ -158,7 +158,7 @@ export declare namespace DataTypes {
158
158
  }, // Entity modal
159
159
  E extends boolean, // Editing or not
160
160
  D extends string = "id"> = E extends false ? Optional<T, D> : Partial<T> & Readonly<Pick<T, D>> & {
161
- changedFields?: string[];
161
+ changedFields?: (keyof T & string)[];
162
162
  };
163
163
  /**
164
164
  * Key collection, like { key1: {}, key2: {} }
@@ -89,6 +89,7 @@ declare global {
89
89
  * Utilities
90
90
  */
91
91
  export declare namespace Utils {
92
+ const IgnoredProperty: "changedFields";
92
93
  /**
93
94
  * Add blank item to collection
94
95
  * @param options Options
@@ -96,19 +97,19 @@ export declare namespace Utils {
96
97
  * @param labelField Label field, default is label
97
98
  * @param blankLabel Blank label, default is ---
98
99
  */
99
- function addBlankItem<T extends object>(options: T[], idField?: string | keyof T, labelField?: unknown, blankLabel?: string): T[];
100
+ export function addBlankItem<T extends object>(options: T[], idField?: string | keyof T, labelField?: unknown, blankLabel?: string): T[];
100
101
  /**
101
102
  * Base64 chars to number
102
103
  * @param base64Chars Base64 chars
103
104
  * @returns Number
104
105
  */
105
- function charsToNumber(base64Chars: string): number;
106
+ export function charsToNumber(base64Chars: string): number;
106
107
  /**
107
108
  * Correct object's property value type
108
109
  * @param input Input object
109
110
  * @param fields Fields to correct
110
111
  */
111
- function correctTypes<T extends object, F extends {
112
+ export function correctTypes<T extends object, F extends {
112
113
  [P in keyof T]?: DataTypes.BasicNames;
113
114
  }>(input: T, fields: F): void;
114
115
  /**
@@ -117,7 +118,7 @@ export declare namespace Utils {
117
118
  * @param v2 Value 2
118
119
  * @param strict Strict level, 0 with ==, 1 === but null equal undefined, 2 ===
119
120
  */
120
- function equals(v1: unknown, v2: unknown, strict?: number): boolean;
121
+ export function equals(v1: unknown, v2: unknown, strict?: number): boolean;
121
122
  /**
122
123
  * Exclude specific items
123
124
  * @param items Items
@@ -125,7 +126,7 @@ export declare namespace Utils {
125
126
  * @param excludedValues Excluded values
126
127
  * @returns Result
127
128
  */
128
- function exclude<T extends {
129
+ export function exclude<T extends {
129
130
  [P in D]: IdType;
130
131
  }, D extends string = "id">(items: T[], field: D, ...excludedValues: T[D][]): T[];
131
132
  /**
@@ -135,7 +136,7 @@ export declare namespace Utils {
135
136
  * @param excludedValues Excluded values
136
137
  * @returns Result
137
138
  */
138
- function excludeAsync<T extends {
139
+ export function excludeAsync<T extends {
139
140
  [P in D]: IdType;
140
141
  }, D extends string = "id">(items: Promise<T[] | undefined>, field: D, ...excludedValues: T[D][]): Promise<T[] | undefined>;
141
142
  /**
@@ -143,75 +144,75 @@ export declare namespace Utils {
143
144
  * @param input Input string
144
145
  * @param upperCase To upper case or lower case
145
146
  */
146
- function formatInitial(input: string, upperCase?: boolean): string;
147
+ export function formatInitial(input: string, upperCase?: boolean): string;
147
148
  /**
148
149
  * Format string with parameters
149
150
  * @param template Template with {0}, {1}, ...
150
151
  * @param parameters Parameters to fill the template
151
152
  * @returns Result
152
153
  */
153
- function formatString(template: string, ...parameters: string[]): string;
154
+ export function formatString(template: string, ...parameters: string[]): string;
154
155
  /**
155
- * Get data changed fields with input data updated
156
+ * Get data changed fields (ignored changedFields) with input data updated
156
157
  * @param input Input data
157
158
  * @param initData Initial data
158
159
  * @param ignoreFields Ignore fields
159
160
  * @returns
160
161
  */
161
- function getDataChanges<T extends object>(input: T, initData: object, ignoreFields?: string[]): (keyof T & string)[];
162
+ export function getDataChanges<T extends object>(input: T, initData: object, ignoreFields?: string[]): Exclude<keyof T & string, typeof IgnoredProperty>[];
162
163
  /**
163
164
  * Get nested value from object
164
165
  * @param data Data
165
166
  * @param name Field name, support property chain like 'jsonData.logSize'
166
167
  * @returns Result
167
168
  */
168
- function getNestedValue(data: object, name: string): any;
169
+ export function getNestedValue(data: object, name: string): any;
169
170
  /**
170
171
  * Get input function or value result
171
172
  * @param input Input function or value
172
173
  * @param args Arguments
173
174
  * @returns Result
174
175
  */
175
- const getResult: <R, T = R | DataTypes.Func<R>>(input: T, ...args: T extends DataTypes.Func<R> ? Parameters<typeof input> : never | []) => T extends DataTypes.Func<R> ? ReturnType<T> : T;
176
+ export const getResult: <R, T = R | DataTypes.Func<R>>(input: T, ...args: T extends DataTypes.Func<R> ? Parameters<typeof input> : never | []) => T extends DataTypes.Func<R> ? ReturnType<T> : T;
176
177
  /**
177
178
  * Get time zone
178
179
  * @returns Timezone
179
180
  */
180
- const getTimeZone: () => string | undefined;
181
+ export const getTimeZone: () => string | undefined;
181
182
  /**
182
183
  * Is digits string
183
184
  * @param input Input string
184
185
  * @param minLength Minimum length
185
186
  * @returns Result
186
187
  */
187
- const isDigits: (input?: string, minLength?: number) => boolean;
188
+ export const isDigits: (input?: string, minLength?: number) => boolean;
188
189
  /**
189
190
  * Is email string
190
191
  * @param input Input string
191
192
  * @returns Result
192
193
  */
193
- const isEmail: (input?: string) => boolean;
194
+ export const isEmail: (input?: string) => boolean;
194
195
  /**
195
196
  * Join items as a string
196
197
  * @param items Items
197
198
  * @param joinPart Join string
198
199
  */
199
- const joinItems: (items: (string | undefined)[], joinPart?: string) => string;
200
+ export const joinItems: (items: (string | undefined)[], joinPart?: string) => string;
200
201
  /**
201
202
  * Merge class names
202
203
  * @param classNames Class names
203
204
  */
204
- const mergeClasses: (...classNames: (string | undefined)[]) => string;
205
+ export const mergeClasses: (...classNames: (string | undefined)[]) => string;
205
206
  /**
206
207
  * Create a GUID
207
208
  */
208
- function newGUID(): string;
209
+ export function newGUID(): string;
209
210
  /**
210
211
  * Number to base64 chars
211
212
  * @param num Input number
212
213
  * @returns Result
213
214
  */
214
- function numberToChars(num: number): string;
215
+ export function numberToChars(num: number): string;
215
216
  /**
216
217
  * Test two objects are equal or not
217
218
  * @param obj1 Object 1
@@ -220,7 +221,7 @@ export declare namespace Utils {
220
221
  * @param strict Strict level, 0 with ==, 1 === but null equal undefined, 2 ===
221
222
  * @returns Result
222
223
  */
223
- function objectEqual(obj1: object, obj2: object, ignoreFields?: string[], strict?: number): boolean;
224
+ export function objectEqual(obj1: object, obj2: object, ignoreFields?: string[], strict?: number): boolean;
224
225
  /**
225
226
  * Get two object's unqiue properties
226
227
  * @param obj1 Object 1
@@ -228,7 +229,7 @@ export declare namespace Utils {
228
229
  * @param ignoreFields Ignored fields
229
230
  * @returns Unique properties
230
231
  */
231
- function objectKeys(obj1: object, obj2: object, ignoreFields?: string[]): Set<string>;
232
+ export function objectKeys(obj1: object, obj2: object, ignoreFields?: string[]): Set<string>;
232
233
  /**
233
234
  * Get the new object's updated fields contrast to the previous object
234
235
  * @param objNew New object
@@ -237,21 +238,21 @@ export declare namespace Utils {
237
238
  * @param strict Strict level, 0 with ==, 1 === but null equal undefined, 2 ===
238
239
  * @returns Updated fields
239
240
  */
240
- function objectUpdated(objNew: object, objPrev: object, ignoreFields?: string[], strict?: number): string[];
241
+ export function objectUpdated(objNew: object, objPrev: object, ignoreFields?: string[], strict?: number): string[];
241
242
  /**
242
243
  * Try to parse JSON input to array
243
244
  * @param input JSON input
244
245
  * @param checkValue Type check value
245
246
  * @returns Result
246
247
  */
247
- function parseJsonArray<T>(input: string, checkValue?: T): T[] | undefined;
248
+ export function parseJsonArray<T>(input: string, checkValue?: T): T[] | undefined;
248
249
  /**
249
250
  * Parse string (JSON) to specific type, no type conversion
250
251
  * For type conversion, please use DataTypes.convert
251
252
  * @param input Input string
252
253
  * @returns Parsed value
253
254
  */
254
- function parseString<T>(input: string | undefined | null): T | undefined;
255
+ export function parseString<T>(input: string | undefined | null): T | undefined;
255
256
  /**
256
257
  * Parse string (JSON) to specific type, no type conversion
257
258
  * For type conversion, please use DataTypes.convert
@@ -259,38 +260,38 @@ export declare namespace Utils {
259
260
  * @param defaultValue Default value
260
261
  * @returns Parsed value
261
262
  */
262
- function parseString<T>(input: string | undefined | null, defaultValue: T): T;
263
+ export function parseString<T>(input: string | undefined | null, defaultValue: T): T;
263
264
  /**
264
265
  * Remove empty values (null, undefined, '') from the input object
265
266
  * @param input Input object
266
267
  */
267
- function removeEmptyValues(input: object): void;
268
+ export function removeEmptyValues(input: object): void;
268
269
  /**
269
270
  * Remove non letters
270
271
  * @param input Input string
271
272
  * @returns Result
272
273
  */
273
- const removeNonLetters: (input?: string) => string | undefined;
274
+ export const removeNonLetters: (input?: string) => string | undefined;
274
275
  /**
275
276
  * Replace null or empty with default value
276
277
  * @param input Input string
277
278
  * @param defaultValue Default value
278
279
  * @returns Result
279
280
  */
280
- const replaceNullOrEmpty: (input: string | null | undefined, defaultValue: string) => string;
281
+ export const replaceNullOrEmpty: (input: string | null | undefined, defaultValue: string) => string;
281
282
  /**
282
283
  * Set source with new labels
283
284
  * @param source Source
284
285
  * @param labels Labels
285
286
  * @param reference Key reference dictionary
286
287
  */
287
- const setLabels: (source: DataTypes.StringRecord, labels: DataTypes.StringRecord, reference?: Readonly<DataTypes.StringDictionary>) => void;
288
+ export const setLabels: (source: DataTypes.StringRecord, labels: DataTypes.StringRecord, reference?: Readonly<DataTypes.StringDictionary>) => void;
288
289
  /**
289
290
  * Snake name to works, 'snake_name' to 'Snake Name'
290
291
  * @param name Name text
291
292
  * @param firstOnly Only convert the first word to upper case
292
293
  */
293
- const snakeNameToWord: (name: string, firstOnly?: boolean) => string;
294
+ export const snakeNameToWord: (name: string, firstOnly?: boolean) => string;
294
295
  /**
295
296
  * Set nested value to object
296
297
  * @param data Data
@@ -298,19 +299,19 @@ export declare namespace Utils {
298
299
  * @param value Value
299
300
  * @param keepNull Keep null value or not
300
301
  */
301
- function setNestedValue(data: object, name: string, value: unknown, keepNull?: boolean): void;
302
+ export function setNestedValue(data: object, name: string, value: unknown, keepNull?: boolean): void;
302
303
  /**
303
304
  * Parse path similar with node.js path.parse
304
305
  * @param path Input path
305
306
  */
306
- const parsePath: (path: string) => ParsedPath;
307
+ export const parsePath: (path: string) => ParsedPath;
307
308
  /**
308
309
  * Sort array by favored values
309
310
  * @param items Items
310
311
  * @param favored Favored values
311
312
  * @returns Sorted array
312
313
  */
313
- const sortByFavor: <T>(items: T[], favored: T[]) => T[];
314
+ export const sortByFavor: <T>(items: T[], favored: T[]) => T[];
314
315
  /**
315
316
  * Sort array by favored field values
316
317
  * @param items Items
@@ -318,26 +319,27 @@ export declare namespace Utils {
318
319
  * @param favored Favored field values
319
320
  * @returns Sorted array
320
321
  */
321
- const sortByFieldFavor: <T, F extends keyof T>(items: T[], field: F, favored: T[F][]) => T[];
322
+ export const sortByFieldFavor: <T, F extends keyof T>(items: T[], field: F, favored: T[F][]) => T[];
322
323
  /**
323
324
  * Trim chars
324
325
  * @param input Input string
325
326
  * @param chars Trim chars
326
327
  * @returns Result
327
328
  */
328
- const trim: (input: string, ...chars: string[]) => string;
329
+ export const trim: (input: string, ...chars: string[]) => string;
329
330
  /**
330
331
  * Trim end chars
331
332
  * @param input Input string
332
333
  * @param chars Trim chars
333
334
  * @returns Result
334
335
  */
335
- const trimEnd: (input: string, ...chars: string[]) => string;
336
+ export const trimEnd: (input: string, ...chars: string[]) => string;
336
337
  /**
337
338
  * Trim start chars
338
339
  * @param input Input string
339
340
  * @param chars Trim chars
340
341
  * @returns Result
341
342
  */
342
- const trimStart: (input: string, ...chars: string[]) => string;
343
+ export const trimStart: (input: string, ...chars: string[]) => string;
344
+ export {};
343
345
  }
package/lib/mjs/Utils.js CHANGED
@@ -127,6 +127,7 @@ String.prototype.removeNonLetters = function () {
127
127
  */
128
128
  export var Utils;
129
129
  (function (Utils) {
130
+ const IgnoredProperty = "changedFields";
130
131
  /**
131
132
  * Add blank item to collection
132
133
  * @param options Options
@@ -247,7 +248,7 @@ export var Utils;
247
248
  }
248
249
  Utils.formatString = formatString;
249
250
  /**
250
- * Get data changed fields with input data updated
251
+ * Get data changed fields (ignored changedFields) with input data updated
251
252
  * @param input Input data
252
253
  * @param initData Initial data
253
254
  * @param ignoreFields Ignore fields
@@ -258,7 +259,7 @@ export var Utils;
258
259
  const changes = [];
259
260
  Object.entries(input).forEach(([key, value]) => {
260
261
  // Ignore fields, no process
261
- if (ignoreFields.includes(key))
262
+ if (key === IgnoredProperty || ignoreFields.includes(key))
262
263
  return;
263
264
  // Compare with init value
264
265
  const initValue = Reflect.get(initData, key);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/shared",
3
- "version": "1.2.56",
3
+ "version": "1.2.58",
4
4
  "description": "TypeScript shared utilities and functions",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -36,7 +36,6 @@
36
36
  },
37
37
  "homepage": "https://github.com/ETSOO/Shared#readme",
38
38
  "devDependencies": {
39
- "@types/jest": "^29.5.14",
40
39
  "@types/lodash.isequal": "^4.5.8",
41
40
  "@vitejs/plugin-react": "^4.3.4",
42
41
  "jsdom": "^26.0.0",