@tstdl/base 0.91.51 → 0.92.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.
- package/ai/data-extracting.d.ts +35 -0
- package/ai/data-extracting.js +195 -41
- package/document-management/api/document-management.api.d.ts +377 -0
- package/document-management/api/document-management.api.js +15 -1
- package/document-management/index.d.ts +3 -0
- package/document-management/index.js +3 -0
- package/file/mime-type.d.ts +1 -1
- package/file/mime-type.js +8 -6
- package/file/mime-types.js +5 -32
- package/orm/schemas/numeric-date.d.ts +1 -1
- package/orm/schemas/timestamp.d.ts +1 -1
- package/package.json +2 -1
- package/schema/converters/index.d.ts +1 -0
- package/schema/converters/index.js +1 -0
- package/schema/converters/openapi-converter.d.ts +3 -0
- package/schema/converters/openapi-converter.js +113 -0
- package/schema/decorators/description.d.ts +3 -0
- package/schema/decorators/description.js +10 -0
- package/schema/decorators/property.d.ts +3 -1
- package/schema/decorators/property.js +13 -5
- package/schema/decorators/types.d.ts +5 -5
- package/schema/schema.d.ts +7 -0
- package/schema/schema.js +6 -0
- package/schema/schemas/any.d.ts +4 -3
- package/schema/schemas/any.js +4 -4
- package/schema/schemas/array.d.ts +10 -5
- package/schema/schemas/array.js +7 -3
- package/schema/schemas/bigint.d.ts +6 -6
- package/schema/schemas/bigint.js +30 -13
- package/schema/schemas/boolean.d.ts +1 -1
- package/schema/schemas/boolean.js +2 -2
- package/schema/schemas/date.d.ts +1 -1
- package/schema/schemas/date.js +2 -2
- package/schema/schemas/defaulted.d.ts +5 -4
- package/schema/schemas/defaulted.js +6 -6
- package/schema/schemas/deferred.d.ts +1 -1
- package/schema/schemas/deferred.js +2 -2
- package/schema/schemas/enumeration.d.ts +5 -4
- package/schema/schemas/enumeration.js +4 -2
- package/schema/schemas/function.d.ts +3 -3
- package/schema/schemas/function.js +5 -4
- package/schema/schemas/instance.d.ts +5 -4
- package/schema/schemas/instance.js +6 -6
- package/schema/schemas/literal.d.ts +5 -4
- package/schema/schemas/literal.js +6 -6
- package/schema/schemas/never.d.ts +3 -2
- package/schema/schemas/never.js +2 -2
- package/schema/schemas/nullable.d.ts +1 -1
- package/schema/schemas/nullable.js +1 -1
- package/schema/schemas/number.d.ts +4 -2
- package/schema/schemas/number.js +6 -3
- package/schema/schemas/object.d.ts +2 -2
- package/schema/schemas/object.js +12 -7
- package/schema/schemas/one-or-many.d.ts +5 -4
- package/schema/schemas/one-or-many.js +6 -6
- package/schema/schemas/optional.d.ts +1 -1
- package/schema/schemas/optional.js +1 -1
- package/schema/schemas/readable-stream.d.ts +1 -1
- package/schema/schemas/readable-stream.js +2 -2
- package/schema/schemas/regexp.d.ts +1 -1
- package/schema/schemas/regexp.js +2 -2
- package/schema/schemas/simple.d.ts +3 -3
- package/schema/schemas/simple.js +1 -1
- package/schema/schemas/string.d.ts +1 -1
- package/schema/schemas/string.js +2 -2
- package/schema/schemas/symbol.d.ts +6 -6
- package/schema/schemas/symbol.js +8 -13
- package/schema/schemas/uint8-array.d.ts +1 -1
- package/schema/schemas/uint8-array.js +2 -2
- package/schema/schemas/union.js +3 -3
- package/schema/schemas/unknown.d.ts +4 -3
- package/schema/schemas/unknown.js +4 -4
- package/search-index/memory/memory-search-index.js +1 -1
- package/types.d.ts +1 -1
- package/utils/helpers.d.ts +0 -40
- package/utils/helpers.js +0 -29
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/string/index.d.ts +1 -0
- package/utils/string/index.js +1 -0
- package/utils/string/normalize.d.ts +50 -0
- package/utils/string/normalize.js +39 -0
- package/utils/try-ignore.d.ts +2 -0
- package/utils/try-ignore.js +12 -0
package/utils/helpers.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { supportsNotification } from '../supports.js';
|
|
2
2
|
import { DetailsError } from '../errors/details.error.js';
|
|
3
3
|
import { decycle } from './object/decycle.js';
|
|
4
|
-
import { isDefined } from './type-guards.js';
|
|
5
4
|
/**
|
|
6
5
|
* Create an structured clone of an value using Notification if available, otherwise history state (may alters history)
|
|
7
6
|
*
|
|
@@ -68,34 +67,6 @@ export function parseFirstAndFamilyName(name) {
|
|
|
68
67
|
familyName: familyName.length > 0 ? familyName : undefined
|
|
69
68
|
};
|
|
70
69
|
}
|
|
71
|
-
/**
|
|
72
|
-
* Trims, lowercases, replaces multi-character whitespace with a single space and unicode normalization
|
|
73
|
-
* @param text text to normalize
|
|
74
|
-
* @param options specify what to normalize. Defaults to all except unicode
|
|
75
|
-
* @returns normalized text
|
|
76
|
-
*/
|
|
77
|
-
export function normalizeText(text, options = { trim: true, lowercase: true, multipleWhitespace: true, diacritics: true, ligatures: true }) {
|
|
78
|
-
let normalized = text;
|
|
79
|
-
if (options.trim == true) {
|
|
80
|
-
normalized = normalized.trim();
|
|
81
|
-
}
|
|
82
|
-
if (options.lowercase == true) {
|
|
83
|
-
normalized = normalized.toLowerCase();
|
|
84
|
-
}
|
|
85
|
-
if (options.multipleWhitespace == true) {
|
|
86
|
-
normalized = normalized.replace(/\s+/ug, ' ');
|
|
87
|
-
}
|
|
88
|
-
if (options.diacritics == true) {
|
|
89
|
-
normalized = normalized.normalize('NFD').replace(/\p{Diacritic}/ug, '');
|
|
90
|
-
}
|
|
91
|
-
if (options.ligatures == true) {
|
|
92
|
-
normalized = normalized.normalize('NFKC');
|
|
93
|
-
}
|
|
94
|
-
if (isDefined(options.unicode)) {
|
|
95
|
-
normalized = normalized.normalize(options.unicode);
|
|
96
|
-
}
|
|
97
|
-
return normalized;
|
|
98
|
-
}
|
|
99
70
|
export function iif(condition, trueFn, falseFn) {
|
|
100
71
|
return condition ? trueFn() : falseFn();
|
|
101
72
|
}
|
package/utils/index.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ export * from './sort.js';
|
|
|
49
49
|
export * from './throw.js';
|
|
50
50
|
export * from './timer.js';
|
|
51
51
|
export * from './timing.js';
|
|
52
|
+
export * from './try-ignore.js';
|
|
52
53
|
export * from './type-guards.js';
|
|
53
54
|
export * from './type-of.js';
|
|
54
55
|
export * from './type/index.js';
|
package/utils/index.js
CHANGED
|
@@ -49,6 +49,7 @@ export * from './sort.js';
|
|
|
49
49
|
export * from './throw.js';
|
|
50
50
|
export * from './timer.js';
|
|
51
51
|
export * from './timing.js';
|
|
52
|
+
export * from './try-ignore.js';
|
|
52
53
|
export * from './type-guards.js';
|
|
53
54
|
export * from './type-of.js';
|
|
54
55
|
export * from './type/index.js';
|
package/utils/string/index.d.ts
CHANGED
package/utils/string/index.js
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export type NormalizeTextOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* Remove leading and trailing whitespace
|
|
4
|
+
*/
|
|
5
|
+
trim?: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Lowercase all characters
|
|
8
|
+
*/
|
|
9
|
+
lowercase?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Remove multiple consecutive whitespace characters
|
|
12
|
+
*/
|
|
13
|
+
multipleWhitespace?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Remove diacritics (è -> e)
|
|
16
|
+
*
|
|
17
|
+
* applies unicode NFD normalization and removes diacritics
|
|
18
|
+
* @see unicode option
|
|
19
|
+
*/
|
|
20
|
+
diacritics?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Replace ligatures with their consecutive characters (æ -> ae)
|
|
23
|
+
*
|
|
24
|
+
* applies unicode NFKC normalization
|
|
25
|
+
* @see unicode option
|
|
26
|
+
*/
|
|
27
|
+
ligatures?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Unicode normalization
|
|
30
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
|
|
31
|
+
*/
|
|
32
|
+
unicode?: 'NFC' | 'NFD' | 'NFKC' | 'NFKD';
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Trims, lowercases, replaces multi-character whitespace with a single space and unicode normalization
|
|
36
|
+
* @param text text to normalize
|
|
37
|
+
* @param options specify what to normalize. Defaults to all except unicode
|
|
38
|
+
* @returns normalized text
|
|
39
|
+
*/
|
|
40
|
+
export declare function normalizeText(text: string, options?: NormalizeTextOptions): string;
|
|
41
|
+
/**
|
|
42
|
+
* Normalizes text input by trimming whitespace and returning null if text is empty.
|
|
43
|
+
*
|
|
44
|
+
* @param text The input text to normalize
|
|
45
|
+
* @param allowNull If true, null or undefined input (or input that becomes empty after trimming) will return null. If false, an error will be thrown in these cases. Defaults to true.
|
|
46
|
+
* @returns The trimmed string. If allowNull is true and the input is null, undefined, or empty after trimming, returns null.
|
|
47
|
+
* @throws {Error} If allowNull is false and the input is null, undefined, or empty after trimming.
|
|
48
|
+
*/
|
|
49
|
+
export declare function normalizeTextInput(text: string | null | undefined, allowNull?: true): string | null;
|
|
50
|
+
export declare function normalizeTextInput(text: string | null | undefined, allowNull: false): string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { isDefined, isNullOrUndefined } from '../type-guards.js';
|
|
2
|
+
/**
|
|
3
|
+
* Trims, lowercases, replaces multi-character whitespace with a single space and unicode normalization
|
|
4
|
+
* @param text text to normalize
|
|
5
|
+
* @param options specify what to normalize. Defaults to all except unicode
|
|
6
|
+
* @returns normalized text
|
|
7
|
+
*/
|
|
8
|
+
export function normalizeText(text, options = { trim: true, lowercase: true, multipleWhitespace: true, diacritics: true, ligatures: true }) {
|
|
9
|
+
let normalized = text;
|
|
10
|
+
if (options.trim == true) {
|
|
11
|
+
normalized = normalized.trim();
|
|
12
|
+
}
|
|
13
|
+
if (options.lowercase == true) {
|
|
14
|
+
normalized = normalized.toLowerCase();
|
|
15
|
+
}
|
|
16
|
+
if (options.multipleWhitespace == true) {
|
|
17
|
+
normalized = normalized.replace(/\s+/ug, ' ');
|
|
18
|
+
}
|
|
19
|
+
if (options.diacritics == true) {
|
|
20
|
+
normalized = normalized.normalize('NFD').replace(/\p{Diacritic}/ug, '');
|
|
21
|
+
}
|
|
22
|
+
if (options.ligatures == true) {
|
|
23
|
+
normalized = normalized.normalize('NFKC');
|
|
24
|
+
}
|
|
25
|
+
if (isDefined(options.unicode)) {
|
|
26
|
+
normalized = normalized.normalize(options.unicode);
|
|
27
|
+
}
|
|
28
|
+
return normalized;
|
|
29
|
+
}
|
|
30
|
+
export function normalizeTextInput(text, allowNull) {
|
|
31
|
+
const normalized = text?.trim();
|
|
32
|
+
if (isNullOrUndefined(normalized) || (normalized.length == 0)) {
|
|
33
|
+
if (allowNull == false) {
|
|
34
|
+
throw new Error('Invalid input.');
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return normalized;
|
|
39
|
+
}
|