@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.
Files changed (84) hide show
  1. package/ai/data-extracting.d.ts +35 -0
  2. package/ai/data-extracting.js +195 -41
  3. package/document-management/api/document-management.api.d.ts +377 -0
  4. package/document-management/api/document-management.api.js +15 -1
  5. package/document-management/index.d.ts +3 -0
  6. package/document-management/index.js +3 -0
  7. package/file/mime-type.d.ts +1 -1
  8. package/file/mime-type.js +8 -6
  9. package/file/mime-types.js +5 -32
  10. package/orm/schemas/numeric-date.d.ts +1 -1
  11. package/orm/schemas/timestamp.d.ts +1 -1
  12. package/package.json +2 -1
  13. package/schema/converters/index.d.ts +1 -0
  14. package/schema/converters/index.js +1 -0
  15. package/schema/converters/openapi-converter.d.ts +3 -0
  16. package/schema/converters/openapi-converter.js +113 -0
  17. package/schema/decorators/description.d.ts +3 -0
  18. package/schema/decorators/description.js +10 -0
  19. package/schema/decorators/property.d.ts +3 -1
  20. package/schema/decorators/property.js +13 -5
  21. package/schema/decorators/types.d.ts +5 -5
  22. package/schema/schema.d.ts +7 -0
  23. package/schema/schema.js +6 -0
  24. package/schema/schemas/any.d.ts +4 -3
  25. package/schema/schemas/any.js +4 -4
  26. package/schema/schemas/array.d.ts +10 -5
  27. package/schema/schemas/array.js +7 -3
  28. package/schema/schemas/bigint.d.ts +6 -6
  29. package/schema/schemas/bigint.js +30 -13
  30. package/schema/schemas/boolean.d.ts +1 -1
  31. package/schema/schemas/boolean.js +2 -2
  32. package/schema/schemas/date.d.ts +1 -1
  33. package/schema/schemas/date.js +2 -2
  34. package/schema/schemas/defaulted.d.ts +5 -4
  35. package/schema/schemas/defaulted.js +6 -6
  36. package/schema/schemas/deferred.d.ts +1 -1
  37. package/schema/schemas/deferred.js +2 -2
  38. package/schema/schemas/enumeration.d.ts +5 -4
  39. package/schema/schemas/enumeration.js +4 -2
  40. package/schema/schemas/function.d.ts +3 -3
  41. package/schema/schemas/function.js +5 -4
  42. package/schema/schemas/instance.d.ts +5 -4
  43. package/schema/schemas/instance.js +6 -6
  44. package/schema/schemas/literal.d.ts +5 -4
  45. package/schema/schemas/literal.js +6 -6
  46. package/schema/schemas/never.d.ts +3 -2
  47. package/schema/schemas/never.js +2 -2
  48. package/schema/schemas/nullable.d.ts +1 -1
  49. package/schema/schemas/nullable.js +1 -1
  50. package/schema/schemas/number.d.ts +4 -2
  51. package/schema/schemas/number.js +6 -3
  52. package/schema/schemas/object.d.ts +2 -2
  53. package/schema/schemas/object.js +12 -7
  54. package/schema/schemas/one-or-many.d.ts +5 -4
  55. package/schema/schemas/one-or-many.js +6 -6
  56. package/schema/schemas/optional.d.ts +1 -1
  57. package/schema/schemas/optional.js +1 -1
  58. package/schema/schemas/readable-stream.d.ts +1 -1
  59. package/schema/schemas/readable-stream.js +2 -2
  60. package/schema/schemas/regexp.d.ts +1 -1
  61. package/schema/schemas/regexp.js +2 -2
  62. package/schema/schemas/simple.d.ts +3 -3
  63. package/schema/schemas/simple.js +1 -1
  64. package/schema/schemas/string.d.ts +1 -1
  65. package/schema/schemas/string.js +2 -2
  66. package/schema/schemas/symbol.d.ts +6 -6
  67. package/schema/schemas/symbol.js +8 -13
  68. package/schema/schemas/uint8-array.d.ts +1 -1
  69. package/schema/schemas/uint8-array.js +2 -2
  70. package/schema/schemas/union.js +3 -3
  71. package/schema/schemas/unknown.d.ts +4 -3
  72. package/schema/schemas/unknown.js +4 -4
  73. package/search-index/memory/memory-search-index.js +1 -1
  74. package/types.d.ts +1 -1
  75. package/utils/helpers.d.ts +0 -40
  76. package/utils/helpers.js +0 -29
  77. package/utils/index.d.ts +1 -0
  78. package/utils/index.js +1 -0
  79. package/utils/string/index.d.ts +1 -0
  80. package/utils/string/index.js +1 -0
  81. package/utils/string/normalize.d.ts +50 -0
  82. package/utils/string/normalize.js +39 -0
  83. package/utils/try-ignore.d.ts +2 -0
  84. 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';
@@ -1,4 +1,5 @@
1
1
  export * from './hypenate.js';
2
+ export * from './normalize.js';
2
3
  export * from './snake-case.js';
3
4
  export * from './title-case.js';
4
5
  export * from './trim.js';
@@ -1,4 +1,5 @@
1
1
  export * from './hypenate.js';
2
+ export * from './normalize.js';
2
3
  export * from './snake-case.js';
3
4
  export * from './title-case.js';
4
5
  export * from './trim.js';
@@ -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
+ }
@@ -0,0 +1,2 @@
1
+ export declare function tryIgnore(fn: () => any): void;
2
+ export declare function tryIgnoreAsync(fn: () => Promise<any>): Promise<void>;
@@ -0,0 +1,12 @@
1
+ export function tryIgnore(fn) {
2
+ try {
3
+ fn();
4
+ }
5
+ catch { /* ignore */ }
6
+ }
7
+ export async function tryIgnoreAsync(fn) {
8
+ try {
9
+ await fn();
10
+ }
11
+ catch { /* ignore */ }
12
+ }