@tstdl/base 0.93.97 → 0.93.98
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/audit/auditor.d.ts +1 -1
- package/cookie/cookie.js +5 -1
- package/css/css-variables.d.ts +38 -0
- package/css/css-variables.js +38 -0
- package/document-management/api/document-management.api.d.ts +15 -1
- package/document-management/api/document-management.api.js +8 -1
- package/document-management/models/document-category.model.js +0 -1
- package/document-management/models/document-property.model.js +0 -1
- package/document-management/server/api/document-management.api.d.ts +1 -0
- package/document-management/server/api/document-management.api.js +13 -1
- package/document-management/server/drizzle/{0000_needy_steel_serpent.sql → 0000_silly_chimera.sql} +0 -2
- package/document-management/server/drizzle/meta/0000_snapshot.json +1 -15
- package/document-management/server/drizzle/meta/_journal.json +2 -2
- package/document-management/server/services/document-statistics.service.d.ts +6 -0
- package/document-management/server/services/document-statistics.service.js +167 -0
- package/document-management/server/services/index.d.ts +1 -0
- package/document-management/server/services/index.js +1 -0
- package/document-management/service-models/document-statistics.view-model.d.ts +38 -0
- package/document-management/service-models/document-statistics.view-model.js +160 -0
- package/document-management/service-models/index.d.ts +1 -0
- package/document-management/service-models/index.js +1 -0
- package/document-management/tests/document-management-core.test.js +2 -2
- package/document-management/tests/document-management.api.test.d.ts +1 -0
- package/document-management/tests/document-management.api.test.js +102 -0
- package/document-management/tests/document-statistics.service.test.d.ts +1 -0
- package/document-management/tests/document-statistics.service.test.js +495 -0
- package/document-management/tests/enum-helpers.test.js +3 -2
- package/enumeration/enumeration.d.ts +24 -0
- package/enumeration/enumeration.js +20 -0
- package/examples/document-management/main.js +1 -1
- package/intl/number-parser.d.ts +16 -9
- package/intl/number-parser.js +31 -19
- package/module/module.js +3 -0
- package/object-storage/google/google.object-storage-provider.d.ts +0 -1
- package/object-storage/google/google.object-storage-provider.js +0 -1
- package/object-storage/index.d.ts +0 -1
- package/object-storage/index.js +0 -1
- package/object-storage/s3/s3.object-storage-provider.d.ts +0 -1
- package/object-storage/s3/s3.object-storage-provider.js +0 -1
- package/package.json +1 -1
- package/pool/pool.d.ts +1 -1
- package/promise/cancelable-promise.d.ts +1 -0
- package/promise/cancelable-promise.js +1 -0
- package/promise/index.d.ts +1 -0
- package/promise/index.js +1 -0
- package/random/number-generator/index.d.ts +1 -0
- package/random/number-generator/index.js +1 -0
- package/sse/data-stream.js +16 -3
package/intl/number-parser.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { createArray } from '../utils/array/array.js';
|
|
2
2
|
import { memoizeClassSingle } from '../utils/function/memoize.js';
|
|
3
3
|
export class NumberParser {
|
|
4
|
-
group;
|
|
5
|
-
decimal;
|
|
6
|
-
numeral;
|
|
7
|
-
loosePattern;
|
|
8
|
-
numeralIndex;
|
|
9
|
-
numeralReplacer;
|
|
4
|
+
#group;
|
|
5
|
+
#decimal;
|
|
6
|
+
#numeral;
|
|
7
|
+
#loosePattern;
|
|
8
|
+
#numeralIndex;
|
|
9
|
+
#numeralReplacer;
|
|
10
10
|
locale;
|
|
11
11
|
constructor(locale) {
|
|
12
12
|
this.locale = locale;
|
|
@@ -14,28 +14,40 @@ export class NumberParser {
|
|
|
14
14
|
const parts = format.formatToParts(12345.6);
|
|
15
15
|
const numerals = createArray(10, (i) => format.format(i));
|
|
16
16
|
const numeralPattern = `[${numerals.join('')}]`;
|
|
17
|
-
this
|
|
18
|
-
this
|
|
19
|
-
this
|
|
20
|
-
this
|
|
21
|
-
this
|
|
22
|
-
this
|
|
17
|
+
this.#numeralIndex = new Map(numerals.map((d, i) => [d, i.toString()]));
|
|
18
|
+
this.#group = parts.find((part) => part.type == 'group').value;
|
|
19
|
+
this.#decimal = parts.find((part) => part.type == 'decimal').value;
|
|
20
|
+
this.#numeral = new RegExp(numeralPattern, 'ug');
|
|
21
|
+
this.#loosePattern = new RegExp(`[^${numerals.join()}${this.#group}${this.#decimal}]`, 'ug');
|
|
22
|
+
this.#numeralReplacer = (numeral) => this.#numeralIndex.get(numeral);
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
* Parse a string
|
|
26
|
-
* @param value Value to parse
|
|
27
|
-
* @param loose Try to parse an invalid string by removing unsupported characters. Might produce incorrect results, depending on input
|
|
25
|
+
* Parse a string.
|
|
26
|
+
* @param value Value to parse.
|
|
27
|
+
* @param loose Try to parse an invalid string by removing unsupported characters. Might produce incorrect results, depending on input.
|
|
28
28
|
*/
|
|
29
29
|
parse(value, loose = false) {
|
|
30
|
-
const source = loose ? value.replaceAll(this
|
|
30
|
+
const source = loose ? value.replaceAll(this.#loosePattern, '') : value;
|
|
31
31
|
const normalized = source.trim()
|
|
32
|
-
.replaceAll(this
|
|
33
|
-
.replaceAll(this
|
|
34
|
-
.replaceAll(this
|
|
32
|
+
.replaceAll(this.#group, '')
|
|
33
|
+
.replaceAll(this.#decimal, '.')
|
|
34
|
+
.replaceAll(this.#numeral, this.#numeralReplacer);
|
|
35
35
|
return Number(normalized);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Get a memoized {@link NumberParser} instance for a given locale.
|
|
40
|
+
* @param locale The locale to get the parser for.
|
|
41
|
+
* @returns A {@link NumberParser} instance.
|
|
42
|
+
*/
|
|
38
43
|
export const getNumberParser = memoizeClassSingle(NumberParser);
|
|
44
|
+
/**
|
|
45
|
+
* Parses a localized number string into a standard JavaScript number.
|
|
46
|
+
* @param locale The locale of the number string.
|
|
47
|
+
* @param value The string to parse.
|
|
48
|
+
* @param loose Whether to use loose parsing (stripping non-numeric characters).
|
|
49
|
+
* @returns The parsed number, or `NaN` if parsing fails.
|
|
50
|
+
*/
|
|
39
51
|
export function parseNumber(locale, value, loose) {
|
|
40
52
|
return getNumberParser(locale).parse(value, loose);
|
|
41
53
|
}
|
package/module/module.js
CHANGED
|
@@ -29,7 +29,6 @@ export declare class GoogleObjectStorageProviderConfig {
|
|
|
29
29
|
*/
|
|
30
30
|
bucketPerModule?: boolean;
|
|
31
31
|
}
|
|
32
|
-
export declare const bucketPerModule: unique symbol;
|
|
33
32
|
export declare class GoogleObjectStorageProvider extends ObjectStorageProvider<GoogleObjectStorage> {
|
|
34
33
|
private readonly client;
|
|
35
34
|
private readonly bucket;
|
|
@@ -39,7 +39,6 @@ export class GoogleObjectStorageProviderConfig {
|
|
|
39
39
|
*/
|
|
40
40
|
bucketPerModule;
|
|
41
41
|
}
|
|
42
|
-
export const bucketPerModule = Symbol('bucket per module');
|
|
43
42
|
let GoogleObjectStorageProvider = class GoogleObjectStorageProvider extends ObjectStorageProvider {
|
|
44
43
|
client;
|
|
45
44
|
bucket;
|
package/object-storage/index.js
CHANGED
|
@@ -26,7 +26,6 @@ export declare class S3ObjectStorageProviderConfig {
|
|
|
26
26
|
*/
|
|
27
27
|
secretKey: string;
|
|
28
28
|
}
|
|
29
|
-
export declare const bucketPerModule: unique symbol;
|
|
30
29
|
export declare class S3ObjectStorageProvider extends ObjectStorageProvider<S3ObjectStorage> {
|
|
31
30
|
private readonly client;
|
|
32
31
|
private readonly bucket;
|
package/package.json
CHANGED
package/pool/pool.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export type CancelablePromiseResult<T, R> = {
|
|
|
10
10
|
};
|
|
11
11
|
export declare class CancelablePromise<T, R = void> extends CustomPromise<CancelablePromiseResult<T, R>> {
|
|
12
12
|
#private;
|
|
13
|
+
readonly [Symbol.toStringTag] = "CancelablePromise";
|
|
13
14
|
constructor(executor: CancelablePromiseExecutor<T>);
|
|
14
15
|
cancel(reason: R): void;
|
|
15
16
|
}
|
package/promise/index.d.ts
CHANGED
package/promise/index.js
CHANGED
package/sse/data-stream.js
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import { patch } from 'jsondiffpatch';
|
|
2
|
+
import { isErrorResponse, parseErrorResponse } from '../api/response.js';
|
|
2
3
|
import { hasOwnProperty } from '../utils/object/object.js';
|
|
3
|
-
import { finalize, map, merge, scan } from 'rxjs';
|
|
4
|
+
import { finalize, map, merge, scan, switchMap, throwError } from 'rxjs';
|
|
4
5
|
export class DataStream {
|
|
5
6
|
static parse(eventSource) {
|
|
6
7
|
const data$ = eventSource.message$('data').pipe(map((message) => ({ data: JSON.parse(message.data) })));
|
|
7
8
|
const delta$ = eventSource.message$('delta').pipe(map((message) => ({ delta: JSON.parse(message.data) })));
|
|
8
|
-
|
|
9
|
+
const stream$ = merge(data$, delta$).pipe(scan((data, message) => {
|
|
9
10
|
if (hasOwnProperty(message, 'data')) {
|
|
10
11
|
return message.data;
|
|
11
12
|
}
|
|
12
13
|
return patch(structuredClone(data), message.delta);
|
|
13
|
-
}, undefined)
|
|
14
|
+
}, undefined));
|
|
15
|
+
const error$ = eventSource.message$('error').pipe(switchMap((message) => throwError(() => {
|
|
16
|
+
try {
|
|
17
|
+
const dataJson = JSON.parse(message.data);
|
|
18
|
+
if (isErrorResponse(dataJson)) {
|
|
19
|
+
return parseErrorResponse(dataJson);
|
|
20
|
+
}
|
|
21
|
+
return new Error(`Data stream error`, { cause: dataJson });
|
|
22
|
+
}
|
|
23
|
+
catch { /* ignore json parse errors */ }
|
|
24
|
+
return new Error(`Data stream error`, { cause: message.data });
|
|
25
|
+
})));
|
|
26
|
+
return merge(stream$, error$).pipe(finalize(() => eventSource.close()));
|
|
14
27
|
}
|
|
15
28
|
}
|