@tstdl/base 0.92.123 → 0.92.125
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/ai-file.service.js +23 -18
- package/ai/ai.service.d.ts +4 -12
- package/ai/ai.service.js +79 -147
- package/ai/functions.d.ts +1 -1
- package/ai/types.d.ts +3 -1
- package/api/server/gateway.js +6 -6
- package/authentication/authentication.api.js +24 -24
- package/authentication/server/authentication.service.js +20 -20
- package/browser/page-controller.js +1 -1
- package/context/context.js +5 -5
- package/document-management/api/document-management.api.d.ts +60 -215
- package/document-management/api/document-management.api.js +32 -68
- package/document-management/models/document-assignment-scope.model.d.ts +11 -0
- package/document-management/models/{document-request-assignment-task-collection.model.js → document-assignment-scope.model.js} +14 -10
- package/document-management/models/document-assignment-task.model.d.ts +13 -0
- package/document-management/models/document-assignment-task.model.js +38 -0
- package/document-management/models/document-category.model.d.ts +2 -0
- package/document-management/models/document-category.model.js +7 -1
- package/document-management/models/{document-collection-document.model.d.ts → document-collection-assignment.model.d.ts} +1 -1
- package/document-management/models/{document-collection-document.model.js → document-collection-assignment.model.js} +7 -7
- package/document-management/models/document-collection.model.d.ts +2 -0
- package/document-management/models/document-collection.model.js +10 -0
- package/document-management/models/document-property-value.model.d.ts +3 -11
- package/document-management/models/document-property-value.model.js +15 -46
- package/document-management/models/document-property.model.d.ts +2 -1
- package/document-management/models/document-property.model.js +2 -2
- package/document-management/models/document-request-submission.model.d.ts +7 -0
- package/document-management/models/document-request-submission.model.js +34 -0
- package/document-management/models/document-request-template.d.ts +2 -4
- package/document-management/models/document-request-template.js +3 -8
- package/document-management/models/document-request.model.d.ts +14 -6
- package/document-management/models/document-request.model.js +22 -12
- package/document-management/models/document-type-validation.model.d.ts +6 -0
- package/document-management/models/document-type-validation.model.js +34 -0
- package/document-management/models/document-type.model.d.ts +0 -1
- package/document-management/models/document-type.model.js +0 -5
- package/document-management/models/document-validation-definition.model.d.ts +10 -0
- package/document-management/models/document-validation-definition.model.js +39 -0
- package/document-management/models/document-validation-execution-related-document.model.d.ts +7 -0
- package/document-management/models/document-validation-execution-related-document.model.js +34 -0
- package/document-management/models/document-validation-execution.model.d.ts +26 -0
- package/document-management/models/document-validation-execution.model.js +72 -0
- package/document-management/models/document-workflow.model.d.ts +35 -0
- package/document-management/models/document-workflow.model.js +70 -0
- package/document-management/models/document.model.d.ts +12 -1
- package/document-management/models/document.model.js +21 -5
- package/document-management/models/index.d.ts +10 -5
- package/document-management/models/index.js +10 -5
- package/document-management/models/service-models/categories-and-types.view-model.d.ts +3 -3
- package/document-management/models/service-models/categories-and-types.view-model.js +2 -21
- package/document-management/models/service-models/document-folders.view-model.d.ts +7 -14
- package/document-management/models/service-models/document-folders.view-model.js +20 -44
- package/document-management/models/service-models/document-management.view-model.d.ts +41 -0
- package/document-management/models/service-models/{document.view-model.js → document-management.view-model.js} +43 -26
- package/document-management/models/service-models/document.service-model.d.ts +51 -81
- package/document-management/models/service-models/document.service-model.js +30 -28
- package/document-management/models/service-models/enriched/enriched-document-assignment.view.d.ts +11 -0
- package/document-management/models/service-models/enriched/enriched-document-assignment.view.js +12 -0
- package/document-management/models/service-models/enriched/enriched-document-category.view.d.ts +13 -0
- package/document-management/models/service-models/enriched/enriched-document-category.view.js +47 -0
- package/document-management/models/service-models/enriched/enriched-document-collection.view.d.ts +22 -0
- package/document-management/models/service-models/enriched/enriched-document-collection.view.js +89 -0
- package/document-management/models/service-models/enriched/enriched-document-file.view.d.ts +12 -0
- package/document-management/models/service-models/enriched/enriched-document-file.view.js +16 -0
- package/document-management/models/service-models/enriched/enriched-document-management-data.view.d.ts +41 -0
- package/document-management/models/service-models/enriched/enriched-document-management-data.view.js +130 -0
- package/document-management/models/service-models/enriched/enriched-document-request.view.d.ts +17 -0
- package/document-management/models/service-models/enriched/enriched-document-request.view.js +52 -0
- package/document-management/models/service-models/enriched/enriched-document-type.view.d.ts +9 -0
- package/document-management/models/service-models/enriched/enriched-document-type.view.js +10 -0
- package/document-management/models/service-models/enriched/enriched-document.view.d.ts +28 -0
- package/document-management/models/service-models/enriched/enriched-document.view.js +77 -0
- package/document-management/models/service-models/enriched/enriched.d.ts +18 -0
- package/document-management/models/service-models/enriched/enriched.js +39 -0
- package/document-management/models/service-models/enriched/index.d.ts +9 -0
- package/document-management/models/service-models/enriched/index.js +9 -0
- package/document-management/models/service-models/index.d.ts +2 -2
- package/document-management/models/service-models/index.js +2 -2
- package/document-management/models/service-models/normalized-requests-template-data.model.d.ts +12 -10
- package/document-management/models/service-models/normalized-requests-template-data.model.js +5 -4
- package/document-management/models/service-models/stats.view-model.d.ts +7 -5
- package/document-management/models/service-models/stats.view-model.js +19 -9
- package/document-management/server/module.d.ts +2 -2
- package/document-management/server/module.js +3 -7
- package/document-management/server/schemas.d.ts +18 -23
- package/document-management/server/schemas.js +18 -23
- package/document-management/server/services/document-category-type.service.d.ts +25 -0
- package/document-management/server/services/document-category-type.service.js +66 -0
- package/document-management/server/services/document-collection.service.d.ts +13 -0
- package/document-management/server/services/document-collection.service.js +41 -0
- package/document-management/server/services/document-file.service.d.ts +17 -0
- package/document-management/server/services/document-file.service.js +204 -0
- package/document-management/server/services/document-management-ai.service.d.ts +22 -0
- package/document-management/server/services/document-management-ai.service.js +340 -0
- package/document-management/server/services/document-management-ancillary.service.d.ts +127 -3
- package/document-management/server/services/document-management-ancillary.service.js +24 -0
- package/document-management/server/services/document-management.service.d.ts +10 -122
- package/document-management/server/services/document-management.service.js +106 -888
- package/document-management/server/services/document-property.service.d.ts +84 -0
- package/document-management/server/services/document-property.service.js +87 -0
- package/document-management/server/services/document-request.service.d.ts +30 -0
- package/document-management/server/services/document-request.service.js +138 -0
- package/document-management/server/services/document-validation.service.d.ts +20 -0
- package/document-management/server/services/document-validation.service.js +145 -0
- package/document-management/server/services/document-workflow.service.d.ts +20 -0
- package/document-management/server/services/document-workflow.service.js +132 -0
- package/document-management/server/services/document.service.d.ts +16 -0
- package/document-management/server/services/document.service.js +81 -0
- package/document-management/server/services/index.d.ts +9 -0
- package/document-management/server/services/index.js +9 -0
- package/document-management/server/validators/ai-validation-executor.d.ts +19 -0
- package/document-management/server/validators/ai-validation-executor.js +51 -0
- package/document-management/server/validators/index.d.ts +2 -0
- package/document-management/server/validators/index.js +2 -0
- package/document-management/server/validators/single-document-validation-executor.d.ts +16 -0
- package/document-management/server/validators/single-document-validation-executor.js +20 -0
- package/document-management/server/validators/validator.d.ts +21 -0
- package/document-management/server/validators/validator.js +2 -0
- package/eslint.config.js +31 -17
- package/examples/document-management/main.d.ts +18 -3
- package/examples/document-management/main.js +28 -12
- package/file/mime-type.js +2 -9
- package/formats.d.ts +5 -2
- package/formats.js +32 -23
- package/http/client/http-client.js +1 -1
- package/injector/injector.js +2 -2
- package/object-storage/s3/s3.object-storage.js +1 -1
- package/orm/data-types/bytea.d.ts +8 -0
- package/orm/data-types/bytea.js +8 -0
- package/orm/data-types/index.d.ts +4 -0
- package/orm/data-types/index.js +4 -0
- package/orm/data-types/numeric-date.d.ts +9 -0
- package/orm/data-types/numeric-date.js +9 -0
- package/orm/data-types/timestamp.d.ts +9 -0
- package/orm/data-types/timestamp.js +9 -0
- package/orm/decorators.d.ts +139 -5
- package/orm/decorators.js +50 -0
- package/orm/entity.d.ts +19 -0
- package/orm/entity.js +19 -0
- package/orm/index.d.ts +5 -0
- package/orm/index.js +5 -0
- package/orm/query.d.ts +51 -0
- package/orm/query.js +6 -0
- package/orm/repository.types.d.ts +54 -2
- package/orm/server/database-schema.d.ts +34 -0
- package/orm/server/database-schema.js +29 -0
- package/orm/server/database.d.ts +19 -1
- package/orm/server/database.js +17 -3
- package/orm/server/drizzle/schema-converter.d.ts +2 -1
- package/orm/server/drizzle/schema-converter.js +12 -1
- package/orm/server/encryption.d.ts +16 -0
- package/orm/server/encryption.js +29 -4
- package/orm/server/index.d.ts +7 -0
- package/orm/server/index.js +7 -0
- package/orm/server/module.d.ts +20 -0
- package/orm/server/module.js +9 -0
- package/orm/server/query-converter.d.ts +17 -0
- package/orm/server/query-converter.js +66 -11
- package/orm/server/repository.d.ts +324 -18
- package/orm/server/repository.js +344 -73
- package/orm/server/transaction.d.ts +5 -5
- package/orm/server/transaction.js +5 -5
- package/orm/server/transactional.d.ts +75 -0
- package/orm/server/transactional.js +134 -0
- package/orm/server/types.d.ts +1 -0
- package/orm/sqls.d.ts +55 -0
- package/orm/sqls.js +60 -0
- package/orm/types.d.ts +67 -4
- package/orm/utils.d.ts +19 -3
- package/orm/utils.js +12 -0
- package/package.json +32 -31
- package/password/password-check-result.model.d.ts +9 -7
- package/password/password-check-result.model.js +8 -8
- package/password/password-check.js +5 -7
- package/password/password-check.localization.js +12 -12
- package/pdf/pdf.service.js +1 -1
- package/pdf/utils.d.ts +9 -0
- package/pdf/utils.js +19 -2
- package/process/spawn.d.ts +11 -4
- package/process/spawn.js +42 -5
- package/queue/postgres/queue.js +5 -5
- package/queue/queue.d.ts +6 -4
- package/queue/queue.js +6 -6
- package/schema/schemas/one-or-many.d.ts +2 -1
- package/schema/schemas/one-or-many.js +1 -1
- package/search-index/elastic/model/index-mapping.d.ts +1 -1
- package/search-index/elastic/model/index-mapping.js +0 -1
- package/search-index/elastic/search-index.d.ts +1 -2
- package/search-index/elastic/search-index.js +3 -3
- package/types.d.ts +1 -0
- package/utils/async-hook/async-hook.d.ts +9 -0
- package/utils/async-hook/async-hook.js +21 -0
- package/utils/async-hook/index.d.ts +1 -0
- package/utils/async-hook/index.js +1 -0
- package/utils/compression.js +1 -1
- package/utils/function/class.d.ts +6 -0
- package/utils/function/class.js +9 -0
- package/utils/function/index.d.ts +1 -0
- package/utils/function/index.js +1 -0
- package/utils/function/memoize.d.ts +18 -0
- package/utils/function/memoize.js +41 -2
- package/utils/jwt.d.ts +1 -1
- package/utils/jwt.js +5 -5
- package/utils/object/forward-ref.d.ts +3 -2
- package/utils/object/forward-ref.js +12 -12
- package/utils/object/lazy-property.js +2 -2
- package/utils/proxy.js +1 -1
- package/utils/stream/{readable-stream-from-promise.d.ts → from-promise.d.ts} +1 -0
- package/utils/stream/from-promise.js +27 -0
- package/utils/stream/index.d.ts +1 -1
- package/utils/stream/index.js +1 -1
- package/utils/stream/stream-reader.js +71 -31
- package/document-management/models/document-request-assignment-task-collection.model.d.ts +0 -7
- package/document-management/models/document-request-assignment-task.model.d.ts +0 -14
- package/document-management/models/document-request-assignment-task.model.js +0 -77
- package/document-management/models/document-request-file.model.d.ts +0 -16
- package/document-management/models/document-request-file.model.js +0 -86
- package/document-management/models/service-models/document.view-model.d.ts +0 -41
- package/document-management/models/service-models/normalized-document-collection-view.model.d.ts +0 -73
- package/document-management/models/service-models/normalized-document-collection-view.model.js +0 -110
- package/utils/stream/readable-stream-from-promise.js +0 -8
package/utils/function/index.js
CHANGED
|
@@ -16,3 +16,21 @@ export type MemoizeOptions = {
|
|
|
16
16
|
export declare function memoizeSingle<Fn extends (parameter: any) => any>(fn: Fn, options?: MemoizeOptions): Fn;
|
|
17
17
|
export declare function memoizeClass<T extends Constructor>(type: T, options?: MemoizeOptions): (...parameters: ConstructorParameters<T>) => InstanceType<T>;
|
|
18
18
|
export declare function memoizeClassSingle<T extends Constructor<any, [any]>>(type: T, options?: MemoizeOptions): (...parameters: ConstructorParameters<T>) => InstanceType<T>;
|
|
19
|
+
/**
|
|
20
|
+
* Memoizes an accessor (getter)
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* class MyClass {
|
|
25
|
+
* @Memoize()
|
|
26
|
+
* get myValue() {
|
|
27
|
+
* // expensive calculation
|
|
28
|
+
* return 123;
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* The getter will be called only once for each instance of the class.
|
|
35
|
+
*/
|
|
36
|
+
export declare function Memoize(): MethodDecorator;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { IterableWeakMap } from '../../data-structures/iterable-weak-map.js';
|
|
2
2
|
import { MultiKeyMap } from '../../data-structures/multi-key-map.js';
|
|
3
|
+
import { createAccessorDecorator } from '../../reflection/index.js';
|
|
4
|
+
import { assertDefinedPass } from '../type-guards.js';
|
|
3
5
|
/**
|
|
4
6
|
* Memoizes a function with an arbitrary number of parameters. If you only need a single parameter, {@link memoizeSingle} is faster
|
|
5
7
|
* @param fn function memoize
|
|
@@ -15,7 +17,7 @@ import { MultiKeyMap } from '../../data-structures/multi-key-map.js';
|
|
|
15
17
|
const result = fn.call(this, ...parameters);
|
|
16
18
|
cache.set(parameters, result);
|
|
17
19
|
return result;
|
|
18
|
-
}
|
|
20
|
+
},
|
|
19
21
|
}[name];
|
|
20
22
|
}
|
|
21
23
|
/**
|
|
@@ -34,7 +36,7 @@ export function memoizeSingle(fn, options = {}) {
|
|
|
34
36
|
const result = fn.call(this, parameter);
|
|
35
37
|
cache.set(parameter, result);
|
|
36
38
|
return result;
|
|
37
|
-
}
|
|
39
|
+
},
|
|
38
40
|
}[name];
|
|
39
41
|
}
|
|
40
42
|
export function memoizeClass(type, options = {}) {
|
|
@@ -43,6 +45,43 @@ export function memoizeClass(type, options = {}) {
|
|
|
43
45
|
export function memoizeClassSingle(type, options = {}) {
|
|
44
46
|
return memoizeSingle((parameter) => new type(parameter), options);
|
|
45
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Memoizes an accessor (getter)
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* class MyClass {
|
|
54
|
+
* @Memoize()
|
|
55
|
+
* get myValue() {
|
|
56
|
+
* // expensive calculation
|
|
57
|
+
* return 123;
|
|
58
|
+
* }
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* The getter will be called only once for each instance of the class.
|
|
64
|
+
*/
|
|
65
|
+
export function Memoize() {
|
|
66
|
+
const cache = new WeakMap();
|
|
67
|
+
return createAccessorDecorator({
|
|
68
|
+
handler: (data) => {
|
|
69
|
+
const getter = assertDefinedPass(data.descriptor.get, 'Memoize requires an getter for accessors.'); // eslint-disable-line @typescript-eslint/unbound-method
|
|
70
|
+
function cachedGetter() {
|
|
71
|
+
if (cache.has(this)) {
|
|
72
|
+
return cache.get(this); // eslint-disable-line @typescript-eslint/no-unsafe-return
|
|
73
|
+
}
|
|
74
|
+
const value = getter.call(this);
|
|
75
|
+
cache.set(this, value);
|
|
76
|
+
return value; // eslint-disable-line @typescript-eslint/no-unsafe-return
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
writable: false,
|
|
80
|
+
get: cachedGetter,
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
}
|
|
46
85
|
function getMemoizedName(fn) {
|
|
47
86
|
return `memoized${fn.name[0]?.toUpperCase() ?? ''}${fn.name.slice(1)}`;
|
|
48
87
|
}
|
package/utils/jwt.d.ts
CHANGED
|
@@ -28,5 +28,5 @@ export type JwtTokenParseResult<T extends JwtToken = JwtToken> = {
|
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
30
|
export declare function parseJwtTokenString<T extends JwtToken = JwtToken>(tokenString: string): JwtTokenParseResult<T>;
|
|
31
|
-
export declare function createJwtTokenString
|
|
31
|
+
export declare function createJwtTokenString(jwtToken: JwtToken, key: Key | string): Promise<string>;
|
|
32
32
|
export declare function parseAndValidateJwtTokenString<T extends JwtToken = JwtToken>(tokenString: string, allowedAlgorithms: OneOrMany<JwtTokenAlgorithm>, key: Key | string): Promise<T>;
|
package/utils/jwt.js
CHANGED
|
@@ -15,30 +15,30 @@ export function parseJwtTokenString(tokenString) {
|
|
|
15
15
|
const encoded = {
|
|
16
16
|
header: encodedHeader,
|
|
17
17
|
payload: encodedPayload,
|
|
18
|
-
signature: encodedSignature
|
|
18
|
+
signature: encodedSignature,
|
|
19
19
|
};
|
|
20
20
|
const bytes = {
|
|
21
21
|
header: decodeBase64Url(encodedHeader),
|
|
22
22
|
payload: decodeBase64Url(encodedPayload),
|
|
23
|
-
signature: decodeBase64Url(encodedSignature)
|
|
23
|
+
signature: decodeBase64Url(encodedSignature),
|
|
24
24
|
};
|
|
25
25
|
const string = {
|
|
26
26
|
header: textDecoder.decode(bytes.header),
|
|
27
|
-
payload: textDecoder.decode(bytes.payload)
|
|
27
|
+
payload: textDecoder.decode(bytes.payload),
|
|
28
28
|
};
|
|
29
29
|
try {
|
|
30
30
|
const header = JSON.parse(string.header);
|
|
31
31
|
const payload = JSON.parse(string.payload);
|
|
32
32
|
const token = {
|
|
33
33
|
header,
|
|
34
|
-
payload
|
|
34
|
+
payload,
|
|
35
35
|
};
|
|
36
36
|
return {
|
|
37
37
|
raw: tokenString,
|
|
38
38
|
token: token,
|
|
39
39
|
encoded,
|
|
40
40
|
bytes,
|
|
41
|
-
string
|
|
41
|
+
string,
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
catch {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import type { AbstractConstructor } from '../../types.js';
|
|
1
2
|
declare const isForwardRef: unique symbol;
|
|
2
|
-
export type ForwardRefTypeHint = 'object' | 'function';
|
|
3
|
+
export type ForwardRefTypeHint = 'object' | 'function' | AbstractConstructor;
|
|
3
4
|
export type ForwardRefOptions<T extends object = object> = {
|
|
4
5
|
reference?: T;
|
|
5
6
|
initializer?: () => T;
|
|
6
|
-
/** Due to limitations of Proxy, there can be some issues if proxy is created with a target of the "wrong" type. If possible, you should specify the type
|
|
7
|
+
/** Due to limitations of Proxy, there can be some issues if proxy is created with a target of the "wrong" type. If possible, you should specify the type the forward ref is going to forward to. */
|
|
7
8
|
typeHint?: ForwardRefTypeHint;
|
|
8
9
|
};
|
|
9
10
|
export type ForwardRef<T extends object = object> = T & {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
2
|
+
import { getClassOfName } from '../function/index.js';
|
|
2
3
|
import { propertyReflectMethods, reflectMethods } from '../proxy.js';
|
|
3
|
-
import { assert, isDefined, isUndefined } from '../type-guards.js';
|
|
4
|
-
import { lazyObject } from './lazy-property.js';
|
|
4
|
+
import { assert, isDefined, isFunction, isUndefined } from '../type-guards.js';
|
|
5
|
+
import { lazyObject, lazyObjectValue } from './lazy-property.js';
|
|
5
6
|
const contexts = new WeakMap();
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-redeclare, @typescript-eslint/naming-convention
|
|
7
7
|
export const ForwardRef = {
|
|
8
8
|
create(options) {
|
|
9
9
|
const context = getContext(options);
|
|
@@ -30,24 +30,26 @@ export const ForwardRef = {
|
|
|
30
30
|
setRef(forwardRef, reference) {
|
|
31
31
|
assert(ForwardRef.isForwardRef(forwardRef), 'provided value is not a ForwardRef');
|
|
32
32
|
contexts.get(forwardRef).reference = reference;
|
|
33
|
-
}
|
|
33
|
+
},
|
|
34
34
|
};
|
|
35
35
|
function getForwardRefProxy(context) {
|
|
36
|
-
const target = (context.typeHint
|
|
37
|
-
?
|
|
38
|
-
:
|
|
36
|
+
const target = isFunction(context.typeHint)
|
|
37
|
+
? new (getClassOfName(`${context.typeHint.name}ForwardRef`))()
|
|
38
|
+
: (context.typeHint == 'function')
|
|
39
|
+
? function forwardRef() { }
|
|
40
|
+
: { forwardRef: true };
|
|
39
41
|
const handler = {};
|
|
40
42
|
for (const method of reflectMethods) {
|
|
41
43
|
handler[method] = {
|
|
42
44
|
[method](_originalTarget, ...args) {
|
|
43
45
|
if (isUndefined(context.reference)) {
|
|
44
46
|
const message = propertyReflectMethods.has(method)
|
|
45
|
-
? `cannot forward "${method}" to property "${args[0]
|
|
47
|
+
? `cannot forward "${method}" to property "${String(args[0])}" on a ForwardRef which has no reference`
|
|
46
48
|
: `cannot forward "${method}" on a ForwardRef which has no reference`;
|
|
47
49
|
throw new Error(message);
|
|
48
50
|
}
|
|
49
51
|
return Reflect[method](context.reference, ...args);
|
|
50
|
-
}
|
|
52
|
+
},
|
|
51
53
|
}[method];
|
|
52
54
|
}
|
|
53
55
|
return new Proxy(target, handler);
|
|
@@ -58,7 +60,5 @@ function getContext(options) {
|
|
|
58
60
|
: isDefined(options?.initializer)
|
|
59
61
|
? { initializer: options.initializer }
|
|
60
62
|
: { value: undefined };
|
|
61
|
-
return lazyObject({
|
|
62
|
-
reference
|
|
63
|
-
});
|
|
63
|
+
return lazyObject({ reference, typeHint: lazyObjectValue(options?.typeHint) });
|
|
64
64
|
}
|
|
@@ -33,7 +33,7 @@ export function lazyProperty(object, propertyKey, initializer, descriptor = {})
|
|
|
33
33
|
}
|
|
34
34
|
: undefined,
|
|
35
35
|
enumerable,
|
|
36
|
-
configurable
|
|
36
|
+
configurable,
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
export function lazyObject(initializers) {
|
|
@@ -61,7 +61,7 @@ export function lazyObject(initializers) {
|
|
|
61
61
|
const descriptor = {
|
|
62
62
|
configurable: definition.configurable,
|
|
63
63
|
enumerable: definition.enumerable,
|
|
64
|
-
writable: definition.writable
|
|
64
|
+
writable: definition.writable,
|
|
65
65
|
};
|
|
66
66
|
if (hasInitializer) {
|
|
67
67
|
lazyProperty(object, key, definition.initializer, descriptor);
|
package/utils/proxy.js
CHANGED
|
@@ -12,7 +12,7 @@ export const reflectMethodsMap = {
|
|
|
12
12
|
ownKeys: true,
|
|
13
13
|
preventExtensions: true,
|
|
14
14
|
set: true,
|
|
15
|
-
setPrototypeOf: true
|
|
15
|
+
setPrototypeOf: true,
|
|
16
16
|
};
|
|
17
17
|
export const reflectMethods = objectKeys(reflectMethodsMap);
|
|
18
18
|
export const propertyReflectMethods = new Set(['defineProperty', 'deleteProperty', 'get', 'getOwnPropertyDescriptor', 'has', 'set']);
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { type ValueOrProvider } from '../value-or-provider.js';
|
|
2
2
|
export declare function readableStreamFromPromise<T>(promiseOrProvider: ValueOrProvider<Promise<ReadableStream<T>>>): ReadableStream<T>;
|
|
3
|
+
export declare function transformStreamFromPromise<I, O>(promiseOrProvider: ValueOrProvider<Promise<TransformStream<I, O>>>): TransformStream<I, O>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { resolveValueOrProvider } from '../value-or-provider.js';
|
|
2
|
+
export function readableStreamFromPromise(promiseOrProvider) {
|
|
3
|
+
const stream = new TransformStream();
|
|
4
|
+
resolveValueOrProvider(promiseOrProvider)
|
|
5
|
+
.then(async (readable) => readable.pipeTo(stream.writable))
|
|
6
|
+
.catch(async (error) => stream.writable.abort(error).catch(() => { }));
|
|
7
|
+
return stream.readable;
|
|
8
|
+
}
|
|
9
|
+
export function transformStreamFromPromise(promiseOrProvider) {
|
|
10
|
+
const incoming = new TransformStream();
|
|
11
|
+
const outgoing = new TransformStream();
|
|
12
|
+
void (async () => {
|
|
13
|
+
try {
|
|
14
|
+
const sourceTransformer = await resolveValueOrProvider(promiseOrProvider);
|
|
15
|
+
await incoming.readable.pipeTo(sourceTransformer.writable);
|
|
16
|
+
await sourceTransformer.readable.pipeTo(outgoing.writable);
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
await incoming.writable.abort(e).catch(() => { });
|
|
20
|
+
await outgoing.writable.abort(e).catch(() => { });
|
|
21
|
+
}
|
|
22
|
+
})();
|
|
23
|
+
return {
|
|
24
|
+
writable: incoming.writable,
|
|
25
|
+
readable: outgoing.readable,
|
|
26
|
+
};
|
|
27
|
+
}
|
package/utils/stream/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './finalize-stream.js';
|
|
2
2
|
export * from './readable-stream-adapter.js';
|
|
3
|
-
export * from './
|
|
3
|
+
export * from './from-promise.js';
|
|
4
4
|
export * from './size-limited-stream.js';
|
|
5
5
|
export * from './slice.js';
|
|
6
6
|
export * from './stream-helper-types.js';
|
package/utils/stream/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './finalize-stream.js';
|
|
2
2
|
export * from './readable-stream-adapter.js';
|
|
3
|
-
export * from './
|
|
3
|
+
export * from './from-promise.js';
|
|
4
4
|
export * from './size-limited-stream.js';
|
|
5
5
|
export * from './slice.js';
|
|
6
6
|
export * from './stream-helper-types.js';
|
|
@@ -14,51 +14,87 @@ export async function readBinaryStream(iterableOrStream, { length, onLengthExcee
|
|
|
14
14
|
: getReadableStreamFromIterable(iterableOrStream);
|
|
15
15
|
if (isDefined(length)) {
|
|
16
16
|
const reader = stream.getReader({ mode: 'byob' });
|
|
17
|
-
let buffer = new ArrayBuffer(length + 1);
|
|
17
|
+
let buffer = new ArrayBuffer(length + 1); // To read one extra byte for exceed detection
|
|
18
18
|
let bytesRead = 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
let shouldCancelReaderAtEnd = true;
|
|
20
|
+
try {
|
|
21
|
+
while (true) {
|
|
22
|
+
const view = new Uint8Array(buffer, bytesRead, buffer.byteLength - bytesRead);
|
|
23
|
+
const result = await reader.read(view);
|
|
24
|
+
buffer = result.value.buffer;
|
|
25
|
+
bytesRead += result.value.byteLength;
|
|
26
|
+
if (result.done) {
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
// Check if we have read more data than the specified 'length'.
|
|
30
|
+
// This implies bytesRead is at least length + 1.
|
|
31
|
+
if (bytesRead > length) {
|
|
32
|
+
switch (onLengthExceed) {
|
|
33
|
+
case 'error':
|
|
34
|
+
await reader.cancel();
|
|
35
|
+
shouldCancelReaderAtEnd = false;
|
|
36
|
+
throw new MaxBytesExceededError('Size of stream is greater than provided length.');
|
|
37
|
+
case 'close':
|
|
38
|
+
await reader.cancel();
|
|
39
|
+
shouldCancelReaderAtEnd = false;
|
|
40
|
+
break;
|
|
41
|
+
case 'leave-open':
|
|
42
|
+
reader.releaseLock();
|
|
43
|
+
shouldCancelReaderAtEnd = false;
|
|
44
|
+
break;
|
|
45
|
+
default:
|
|
46
|
+
await reader.cancel();
|
|
47
|
+
shouldCancelReaderAtEnd = false;
|
|
48
|
+
throw new NotSupportedError(`Action ${onLengthExceed} not supported.`);
|
|
49
|
+
}
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
25
52
|
}
|
|
26
|
-
if (bytesRead
|
|
27
|
-
switch (
|
|
53
|
+
if (bytesRead < length) { // Stream ended before specified length was read
|
|
54
|
+
switch (onLengthSubceed) {
|
|
28
55
|
case 'error':
|
|
29
|
-
|
|
30
|
-
|
|
56
|
+
if (shouldCancelReaderAtEnd) {
|
|
57
|
+
await reader.cancel();
|
|
58
|
+
}
|
|
59
|
+
shouldCancelReaderAtEnd = false;
|
|
60
|
+
throw new BadRequestError('Size of stream was less than provided length.');
|
|
31
61
|
case 'close':
|
|
32
|
-
|
|
62
|
+
if (shouldCancelReaderAtEnd) {
|
|
63
|
+
await reader.cancel();
|
|
64
|
+
}
|
|
65
|
+
shouldCancelReaderAtEnd = false;
|
|
33
66
|
break;
|
|
34
67
|
case 'leave-open':
|
|
35
|
-
|
|
68
|
+
if (shouldCancelReaderAtEnd) {
|
|
69
|
+
reader.releaseLock();
|
|
70
|
+
}
|
|
71
|
+
shouldCancelReaderAtEnd = false;
|
|
36
72
|
break;
|
|
37
73
|
default:
|
|
38
|
-
|
|
74
|
+
if (shouldCancelReaderAtEnd) {
|
|
75
|
+
await reader.cancel();
|
|
76
|
+
}
|
|
77
|
+
shouldCancelReaderAtEnd = false;
|
|
78
|
+
throw new NotSupportedError(`Action ${onLengthSubceed} not supported.`);
|
|
39
79
|
}
|
|
40
80
|
}
|
|
41
|
-
if (
|
|
42
|
-
|
|
81
|
+
if (shouldCancelReaderAtEnd) {
|
|
82
|
+
await reader.cancel();
|
|
43
83
|
}
|
|
84
|
+
return new Uint8Array(buffer, 0, Math.min(length, bytesRead));
|
|
44
85
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
await reader.cancel();
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
reader.releaseLock();
|
|
55
|
-
break;
|
|
56
|
-
default:
|
|
57
|
-
throw new NotSupportedError(`Action ${onLengthSubceed} not supported.`);
|
|
86
|
+
catch (error) {
|
|
87
|
+
// If an error occurred (e.g., network, or thrown by logic above)
|
|
88
|
+
// and reader hasn't been handled, try to cancel it.
|
|
89
|
+
// This is a "best effort" cleanup.
|
|
90
|
+
if (shouldCancelReaderAtEnd && reader) {
|
|
91
|
+
try {
|
|
92
|
+
await reader.cancel(error); // Pass the error reason
|
|
93
|
+
}
|
|
94
|
+
catch { /* ignore */ }
|
|
58
95
|
}
|
|
96
|
+
throw error;
|
|
59
97
|
}
|
|
60
|
-
await reader.cancel();
|
|
61
|
-
return new Uint8Array(buffer, 0, Math.min(length, bytesRead));
|
|
62
98
|
}
|
|
63
99
|
let totalLength = 0;
|
|
64
100
|
const reader = stream.getReader();
|
|
@@ -66,6 +102,10 @@ export async function readBinaryStream(iterableOrStream, { length, onLengthExcee
|
|
|
66
102
|
while (true) {
|
|
67
103
|
const result = await reader.read();
|
|
68
104
|
if (result.done) {
|
|
105
|
+
if (isDefined(result.value)) {
|
|
106
|
+
views.push(result.value);
|
|
107
|
+
totalLength += result.value.byteLength;
|
|
108
|
+
}
|
|
69
109
|
break;
|
|
70
110
|
}
|
|
71
111
|
views.push(result.value);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Entity } from '../../orm/entity.js';
|
|
2
|
-
import { Uuid } from '../../orm/types.js';
|
|
3
|
-
export declare class DocumentRequestAssignmentTaskCollection extends Entity {
|
|
4
|
-
static readonly entityName: 'DocumentRequestAssignmentTaskCollection';
|
|
5
|
-
requestAssignmentTaskId: Uuid;
|
|
6
|
-
collectionId: Uuid;
|
|
7
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Entity } from '../../orm/entity.js';
|
|
2
|
-
import { NumericDate, Uuid } from '../../orm/types.js';
|
|
3
|
-
export declare class DocumentRequestAssignmentTask extends Entity {
|
|
4
|
-
fileId: Uuid;
|
|
5
|
-
assignedRequestFileId: Uuid | null;
|
|
6
|
-
typeId: Uuid | null;
|
|
7
|
-
title: string | null;
|
|
8
|
-
subtitle: string | null;
|
|
9
|
-
pages: number | null;
|
|
10
|
-
date: NumericDate | null;
|
|
11
|
-
summary: string | null;
|
|
12
|
-
tags: string[] | null;
|
|
13
|
-
assignmentTries: number;
|
|
14
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
import { References } from '../../orm/decorators.js';
|
|
11
|
-
import { Entity } from '../../orm/entity.js';
|
|
12
|
-
import { NumericDate, Unique, Uuid } from '../../orm/types.js';
|
|
13
|
-
import { Array, Integer, string, StringProperty } from '../../schema/index.js';
|
|
14
|
-
import { DocumentFile } from './document-file.model.js';
|
|
15
|
-
import { DocumentManagementTable } from './document-management-table.js';
|
|
16
|
-
import { DocumentRequestFile } from './document-request-file.model.js';
|
|
17
|
-
import { DocumentType } from './document-type.model.js';
|
|
18
|
-
let DocumentRequestAssignmentTask = class DocumentRequestAssignmentTask extends Entity {
|
|
19
|
-
fileId;
|
|
20
|
-
assignedRequestFileId;
|
|
21
|
-
typeId;
|
|
22
|
-
title;
|
|
23
|
-
subtitle;
|
|
24
|
-
pages;
|
|
25
|
-
date;
|
|
26
|
-
summary;
|
|
27
|
-
tags;
|
|
28
|
-
assignmentTries;
|
|
29
|
-
};
|
|
30
|
-
__decorate([
|
|
31
|
-
Uuid(),
|
|
32
|
-
References(() => DocumentFile),
|
|
33
|
-
Unique(undefined, { naming: 'abbreviated-table' }),
|
|
34
|
-
__metadata("design:type", String)
|
|
35
|
-
], DocumentRequestAssignmentTask.prototype, "fileId", void 0);
|
|
36
|
-
__decorate([
|
|
37
|
-
Uuid({ nullable: true }),
|
|
38
|
-
References(() => DocumentRequestFile),
|
|
39
|
-
__metadata("design:type", Object)
|
|
40
|
-
], DocumentRequestAssignmentTask.prototype, "assignedRequestFileId", void 0);
|
|
41
|
-
__decorate([
|
|
42
|
-
Uuid({ nullable: true }),
|
|
43
|
-
References(() => DocumentType),
|
|
44
|
-
__metadata("design:type", Object)
|
|
45
|
-
], DocumentRequestAssignmentTask.prototype, "typeId", void 0);
|
|
46
|
-
__decorate([
|
|
47
|
-
StringProperty({ nullable: true }),
|
|
48
|
-
__metadata("design:type", Object)
|
|
49
|
-
], DocumentRequestAssignmentTask.prototype, "title", void 0);
|
|
50
|
-
__decorate([
|
|
51
|
-
StringProperty({ nullable: true }),
|
|
52
|
-
__metadata("design:type", Object)
|
|
53
|
-
], DocumentRequestAssignmentTask.prototype, "subtitle", void 0);
|
|
54
|
-
__decorate([
|
|
55
|
-
Integer({ nullable: true }),
|
|
56
|
-
__metadata("design:type", Object)
|
|
57
|
-
], DocumentRequestAssignmentTask.prototype, "pages", void 0);
|
|
58
|
-
__decorate([
|
|
59
|
-
NumericDate({ nullable: true }),
|
|
60
|
-
__metadata("design:type", Object)
|
|
61
|
-
], DocumentRequestAssignmentTask.prototype, "date", void 0);
|
|
62
|
-
__decorate([
|
|
63
|
-
StringProperty({ nullable: true }),
|
|
64
|
-
__metadata("design:type", Object)
|
|
65
|
-
], DocumentRequestAssignmentTask.prototype, "summary", void 0);
|
|
66
|
-
__decorate([
|
|
67
|
-
Array(string(), { nullable: true }),
|
|
68
|
-
__metadata("design:type", Object)
|
|
69
|
-
], DocumentRequestAssignmentTask.prototype, "tags", void 0);
|
|
70
|
-
__decorate([
|
|
71
|
-
Integer(),
|
|
72
|
-
__metadata("design:type", Number)
|
|
73
|
-
], DocumentRequestAssignmentTask.prototype, "assignmentTries", void 0);
|
|
74
|
-
DocumentRequestAssignmentTask = __decorate([
|
|
75
|
-
DocumentManagementTable()
|
|
76
|
-
], DocumentRequestAssignmentTask);
|
|
77
|
-
export { DocumentRequestAssignmentTask };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Entity } from '../../orm/entity.js';
|
|
2
|
-
import { NumericDate, Timestamp, Uuid } from '../../orm/types.js';
|
|
3
|
-
export declare class DocumentRequestFile extends Entity {
|
|
4
|
-
requestId: Uuid;
|
|
5
|
-
fileId: Uuid;
|
|
6
|
-
title: string | null;
|
|
7
|
-
subtitle: string | null;
|
|
8
|
-
pages: number | null;
|
|
9
|
-
date: NumericDate | null;
|
|
10
|
-
summary: string | null;
|
|
11
|
-
tags: string[] | null;
|
|
12
|
-
createdDocumentId: Uuid | null;
|
|
13
|
-
approval: boolean | null;
|
|
14
|
-
approvalComment: string | null;
|
|
15
|
-
approvalTimestamp: Timestamp | null;
|
|
16
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
import { References } from '../../orm/decorators.js';
|
|
11
|
-
import { Entity } from '../../orm/entity.js';
|
|
12
|
-
import { NumericDate, Timestamp, Uuid } from '../../orm/types.js';
|
|
13
|
-
import { Array, BooleanProperty, Integer, string, StringProperty } from '../../schema/index.js';
|
|
14
|
-
import { DocumentFile } from './document-file.model.js';
|
|
15
|
-
import { DocumentManagementTable } from './document-management-table.js';
|
|
16
|
-
import { DocumentRequest } from './document-request.model.js';
|
|
17
|
-
import { Document } from './document.model.js';
|
|
18
|
-
let DocumentRequestFile = class DocumentRequestFile extends Entity {
|
|
19
|
-
requestId;
|
|
20
|
-
fileId;
|
|
21
|
-
title;
|
|
22
|
-
subtitle;
|
|
23
|
-
pages;
|
|
24
|
-
date;
|
|
25
|
-
summary;
|
|
26
|
-
tags;
|
|
27
|
-
createdDocumentId;
|
|
28
|
-
approval;
|
|
29
|
-
approvalComment;
|
|
30
|
-
approvalTimestamp;
|
|
31
|
-
};
|
|
32
|
-
__decorate([
|
|
33
|
-
Uuid(),
|
|
34
|
-
References(() => DocumentRequest),
|
|
35
|
-
__metadata("design:type", String)
|
|
36
|
-
], DocumentRequestFile.prototype, "requestId", void 0);
|
|
37
|
-
__decorate([
|
|
38
|
-
Uuid(),
|
|
39
|
-
References(() => DocumentFile),
|
|
40
|
-
__metadata("design:type", String)
|
|
41
|
-
], DocumentRequestFile.prototype, "fileId", void 0);
|
|
42
|
-
__decorate([
|
|
43
|
-
StringProperty({ nullable: true }),
|
|
44
|
-
__metadata("design:type", Object)
|
|
45
|
-
], DocumentRequestFile.prototype, "title", void 0);
|
|
46
|
-
__decorate([
|
|
47
|
-
StringProperty({ nullable: true }),
|
|
48
|
-
__metadata("design:type", Object)
|
|
49
|
-
], DocumentRequestFile.prototype, "subtitle", void 0);
|
|
50
|
-
__decorate([
|
|
51
|
-
Integer({ nullable: true }),
|
|
52
|
-
__metadata("design:type", Object)
|
|
53
|
-
], DocumentRequestFile.prototype, "pages", void 0);
|
|
54
|
-
__decorate([
|
|
55
|
-
NumericDate({ nullable: true }),
|
|
56
|
-
__metadata("design:type", Object)
|
|
57
|
-
], DocumentRequestFile.prototype, "date", void 0);
|
|
58
|
-
__decorate([
|
|
59
|
-
StringProperty({ nullable: true }),
|
|
60
|
-
__metadata("design:type", Object)
|
|
61
|
-
], DocumentRequestFile.prototype, "summary", void 0);
|
|
62
|
-
__decorate([
|
|
63
|
-
Array(string(), { nullable: true }),
|
|
64
|
-
__metadata("design:type", Object)
|
|
65
|
-
], DocumentRequestFile.prototype, "tags", void 0);
|
|
66
|
-
__decorate([
|
|
67
|
-
Uuid({ nullable: true }),
|
|
68
|
-
References(() => Document),
|
|
69
|
-
__metadata("design:type", Object)
|
|
70
|
-
], DocumentRequestFile.prototype, "createdDocumentId", void 0);
|
|
71
|
-
__decorate([
|
|
72
|
-
BooleanProperty({ nullable: true }),
|
|
73
|
-
__metadata("design:type", Object)
|
|
74
|
-
], DocumentRequestFile.prototype, "approval", void 0);
|
|
75
|
-
__decorate([
|
|
76
|
-
StringProperty({ nullable: true }),
|
|
77
|
-
__metadata("design:type", Object)
|
|
78
|
-
], DocumentRequestFile.prototype, "approvalComment", void 0);
|
|
79
|
-
__decorate([
|
|
80
|
-
Timestamp({ nullable: true }),
|
|
81
|
-
__metadata("design:type", Object)
|
|
82
|
-
], DocumentRequestFile.prototype, "approvalTimestamp", void 0);
|
|
83
|
-
DocumentRequestFile = __decorate([
|
|
84
|
-
DocumentManagementTable()
|
|
85
|
-
], DocumentRequestFile);
|
|
86
|
-
export { DocumentRequestFile };
|