@nu-art/ts-common 0.201.42 → 0.201.43
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/db/types.d.ts +13 -3
- package/package.json +1 -1
- package/utils/string-tools.d.ts +1 -0
- package/utils/string-tools.js +5 -1
package/db/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DB_Object, OmitDBObject, SubsetObjectByKeys, UniqueId } from '../utils/types';
|
|
1
|
+
import { DB_Object, OmitDBObject, SubsetKeys, SubsetObjectByKeys, UniqueId } from '../utils/types';
|
|
2
2
|
import { ValidatorTypeResolver } from '../validator/validator-core';
|
|
3
3
|
export type DBIndex<T extends DB_Object> = {
|
|
4
4
|
id: string;
|
|
@@ -14,13 +14,23 @@ export type VersionsDeclaration<T extends DB_Object, Versions extends VersionTyp
|
|
|
14
14
|
versions: Versions;
|
|
15
15
|
types: Types;
|
|
16
16
|
};
|
|
17
|
-
export type
|
|
17
|
+
export type InnerDependencies<T extends DB_Object, K extends SubsetKeys<keyof T, T, string | string[]>, Proto extends DBProto<any>> = {
|
|
18
|
+
key: K;
|
|
19
|
+
proto: Proto;
|
|
20
|
+
};
|
|
21
|
+
type Exact<T, Shape> = T & {
|
|
22
|
+
[K in Exclude<keyof Shape, keyof T>]?: never;
|
|
23
|
+
};
|
|
24
|
+
export type Proto_DB_Object<T extends DB_Object, GeneratedKeys extends keyof T | never, Versions extends VersionsDeclaration<T, any, any>, UniqueKeys extends keyof T = Default_UniqueKey, Dependencies extends Exact<{
|
|
25
|
+
[K in SubsetKeys<keyof T, T, string | string[]>]?: DBProto<any>;
|
|
26
|
+
}, Dependencies> = never> = {
|
|
18
27
|
type: T;
|
|
19
28
|
generatedKeys: GeneratedKeys;
|
|
20
29
|
versions: Versions;
|
|
21
30
|
uniqueKeys: UniqueKeys;
|
|
31
|
+
dependencies: Dependencies;
|
|
22
32
|
};
|
|
23
|
-
export type DBProto<P extends Proto_DB_Object<any, any, any, any>, ModifiableSubType = Omit<P['type'], P['generatedKeys'] | keyof DB_Object>, GeneratedSubType = SubsetObjectByKeys<P['type'], P['generatedKeys']>> = {
|
|
33
|
+
export type DBProto<P extends Proto_DB_Object<any, any, any, any, any>, ModifiableSubType = Omit<P['type'], P['generatedKeys'] | keyof DB_Object>, GeneratedSubType = SubsetObjectByKeys<P['type'], P['generatedKeys']>> = {
|
|
24
34
|
uiType: ModifiableSubType & Partial<GeneratedSubType> & Partial<DB_Object>;
|
|
25
35
|
dbType: P['type'];
|
|
26
36
|
generatedPropsValidator: ValidatorTypeResolver<GeneratedSubType>;
|
package/package.json
CHANGED
package/utils/string-tools.d.ts
CHANGED
|
@@ -8,3 +8,4 @@ export declare function capitalizeFirstLetter(value: string): string;
|
|
|
8
8
|
export declare function createLevenshteinDistanceMatrix(str1: string, str2: string): number[][];
|
|
9
9
|
export declare function levenshteinDistance(str1: string, str2: string): number;
|
|
10
10
|
export declare function normalizeString(string: string): string;
|
|
11
|
+
export declare function convertUpperCamelCase(upperCamelCase: string, delimiter?: string): string;
|
package/utils/string-tools.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.normalizeString = exports.levenshteinDistance = exports.createLevenshteinDistanceMatrix = exports.capitalizeFirstLetter = exports.capitalizeAllFirstLetters = exports.replaceStringAt = exports.stringFormat = exports.escape_RegExp = exports.stringToHashCode = exports.padNumber = void 0;
|
|
20
|
+
exports.convertUpperCamelCase = exports.normalizeString = exports.levenshteinDistance = exports.createLevenshteinDistanceMatrix = exports.capitalizeFirstLetter = exports.capitalizeAllFirstLetters = exports.replaceStringAt = exports.stringFormat = exports.escape_RegExp = exports.stringToHashCode = exports.padNumber = void 0;
|
|
21
21
|
function padNumber(num, length) {
|
|
22
22
|
const _num = num.toString();
|
|
23
23
|
return _num.length < length ? padNumber('0' + _num, length) : _num;
|
|
@@ -96,3 +96,7 @@ function normalizeString(string) {
|
|
|
96
96
|
return string.replace(/–/g, '-').replace(/\n/g, '').replace(/\s+/g, ' ').replace(/’/g, '\'').trim();
|
|
97
97
|
}
|
|
98
98
|
exports.normalizeString = normalizeString;
|
|
99
|
+
function convertUpperCamelCase(upperCamelCase, delimiter = ' ') {
|
|
100
|
+
return upperCamelCase.replace(/([a-z0-9])([A-Z])/g, `$1${delimiter}$2`);
|
|
101
|
+
}
|
|
102
|
+
exports.convertUpperCamelCase = convertUpperCamelCase;
|