@tstdl/base 0.91.49 → 0.91.51
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 +1 -0
- package/ai/data-extracting.js +62 -0
- package/authentication/server/authentication.api-controller.js +4 -4
- package/cancellation/token.d.ts +1 -2
- package/cancellation/token.js +1 -1
- package/core.d.ts +1 -1
- package/core.js +1 -1
- package/document-management/api/document-management.api.d.ts +376 -0
- package/document-management/api/document-management.api.js +208 -0
- package/document-management/api/index.d.ts +1 -0
- package/document-management/api/index.js +1 -0
- package/document-management/drizzle/0000_wakeful_firebrand.sql +228 -0
- package/document-management/drizzle/meta/0000_snapshot.json +1538 -0
- package/document-management/drizzle/meta/_journal.json +13 -0
- package/document-management/drizzle.config.d.ts +2 -0
- package/document-management/drizzle.config.js +11 -0
- package/document-management/index.d.ts +2 -0
- package/document-management/index.js +2 -0
- package/document-management/localizations/english.d.ts +2 -0
- package/document-management/localizations/english.js +9 -0
- package/document-management/localizations/german.d.ts +2 -0
- package/document-management/localizations/german.js +9 -0
- package/document-management/localizations/index.d.ts +5 -0
- package/document-management/localizations/index.js +9 -0
- package/document-management/localizations/localization.d.ts +9 -0
- package/document-management/localizations/localization.js +2 -0
- package/document-management/models/document-category.model.d.ts +4 -0
- package/document-management/models/document-category.model.js +18 -0
- package/document-management/models/document-collection-document.model.d.ts +7 -0
- package/document-management/models/document-collection-document.model.js +33 -0
- package/document-management/models/document-collection.model.d.ts +3 -0
- package/document-management/models/document-collection.model.js +14 -0
- package/document-management/models/document-file.model.d.ts +7 -0
- package/document-management/models/document-file.model.js +33 -0
- package/document-management/models/document-property-value.model.d.ts +21 -0
- package/document-management/models/document-property-value.model.js +58 -0
- package/document-management/models/document-property.model.d.ts +11 -0
- package/document-management/models/document-property.model.js +30 -0
- package/document-management/models/document-request-collection.model.d.ts +6 -0
- package/document-management/models/document-request-collection.model.js +28 -0
- package/document-management/models/document-request-file.model.d.ts +11 -0
- package/document-management/models/document-request-file.model.js +56 -0
- package/document-management/models/document-request-template.d.ts +10 -0
- package/document-management/models/document-request-template.js +39 -0
- package/document-management/models/document-request.model.d.ts +9 -0
- package/document-management/models/document-request.model.js +37 -0
- package/document-management/models/document-requests-template.d.ts +5 -0
- package/document-management/models/document-requests-template.js +23 -0
- package/document-management/models/document-type-property.model.d.ts +6 -0
- package/document-management/models/document-type-property.model.js +28 -0
- package/document-management/models/document-type.model.d.ts +7 -0
- package/document-management/models/document-type.model.js +32 -0
- package/document-management/models/document.model.d.ts +9 -0
- package/document-management/models/document.model.js +44 -0
- package/document-management/models/index.d.ts +15 -0
- package/document-management/models/index.js +15 -0
- package/document-management/models/schemas.d.ts +33 -0
- package/document-management/models/schemas.js +34 -0
- package/document-management/models/service-models/categories-and-types.view-model.d.ts +6 -0
- package/document-management/models/service-models/categories-and-types.view-model.js +24 -0
- package/document-management/models/service-models/document-folders.view-model.d.ts +22 -0
- package/document-management/models/service-models/document-folders.view-model.js +56 -0
- package/document-management/models/service-models/document-requests-template.view-model.d.ts +8 -0
- package/document-management/models/service-models/document-requests-template.view-model.js +26 -0
- package/document-management/models/service-models/document.service-model.d.ts +262 -0
- package/document-management/models/service-models/document.service-model.js +50 -0
- package/document-management/models/service-models/document.view-model.d.ts +33 -0
- package/document-management/models/service-models/document.view-model.js +99 -0
- package/document-management/models/service-models/index.d.ts +8 -0
- package/document-management/models/service-models/index.js +8 -0
- package/document-management/models/service-models/normalized-document-collection-view.model.d.ts +73 -0
- package/document-management/models/service-models/normalized-document-collection-view.model.js +110 -0
- package/document-management/models/service-models/normalized-requests-template-data.model.d.ts +16 -0
- package/document-management/models/service-models/normalized-requests-template-data.model.js +13 -0
- package/document-management/models/service-models/stats.view-model.d.ts +6 -0
- package/document-management/models/service-models/stats.view-model.js +32 -0
- package/document-management/module.d.ts +11 -0
- package/document-management/module.js +27 -0
- package/document-management/services/document-management.service.d.ts +65 -0
- package/document-management/services/document-management.service.js +376 -0
- package/document-management/services/index.d.ts +1 -0
- package/document-management/services/index.js +1 -0
- package/examples/document-management/main.d.ts +1 -0
- package/examples/document-management/main.js +30 -0
- package/examples/orm/drizzle.config.js +2 -1
- package/examples/orm/schemas.d.ts +1 -1
- package/examples/orm/user.model.d.ts +1 -2
- package/examples/orm/user.model.js +0 -1
- package/http/server/node/node-http-server.js +5 -5
- package/injector/injector.d.ts +4 -1
- package/injector/injector.js +4 -1
- package/injector/interfaces.d.ts +3 -3
- package/json-path/json-path.d.ts +2 -0
- package/json-path/json-path.js +7 -0
- package/message-bus/message-bus.d.ts +4 -6
- package/orm/database-schema.d.ts +3 -0
- package/orm/database-schema.js +6 -2
- package/orm/database.d.ts +6 -0
- package/orm/database.js +14 -0
- package/orm/decorators.d.ts +25 -2
- package/orm/decorators.js +15 -0
- package/orm/drizzle/index.d.ts +1 -0
- package/orm/drizzle/index.js +1 -0
- package/orm/drizzle/schema-converter.d.ts +37 -8
- package/orm/drizzle/schema-converter.js +121 -40
- package/orm/entity.d.ts +15 -12
- package/orm/entity.js +24 -11
- package/orm/index.d.ts +3 -2
- package/orm/index.js +3 -2
- package/orm/module.d.ts +6 -0
- package/orm/module.js +15 -0
- package/orm/query-converter.d.ts +5 -0
- package/orm/query-converter.js +114 -0
- package/orm/query.d.ts +15 -13
- package/orm/repository.d.ts +90 -31
- package/orm/repository.js +357 -55
- package/orm/schemas/index.d.ts +3 -0
- package/orm/schemas/index.js +3 -0
- package/orm/schemas/json.d.ts +9 -0
- package/orm/schemas/json.js +19 -0
- package/orm/schemas/numeric-date.d.ts +8 -0
- package/orm/schemas/numeric-date.js +13 -0
- package/orm/schemas/timestamp.d.ts +10 -0
- package/orm/schemas/timestamp.js +20 -0
- package/orm/transaction.d.ts +29 -0
- package/orm/transaction.js +73 -0
- package/orm/types.d.ts +15 -8
- package/orm/types.js +3 -2
- package/package.json +22 -12
- package/{rxjs → rxjs-utils}/reject-error.d.ts +1 -1
- package/{rxjs → rxjs-utils}/retry-backoff.d.ts +2 -2
- package/{rxjs → rxjs-utils}/slow-array.d.ts +7 -7
- package/{rxjs → rxjs-utils}/slow-array.js +2 -2
- package/{rxjs → rxjs-utils}/start-with-provider.d.ts +1 -1
- package/{rxjs → rxjs-utils}/teardown.d.ts +1 -1
- package/{rxjs → rxjs-utils}/untrack.d.ts +1 -1
- package/schema/decorators/types.d.ts +2 -2
- package/schema/schemas/number.d.ts +1 -1
- package/signals/pipe.d.ts +1 -1
- package/signals/pipe.js +1 -2
- package/sse/server-sent-events.d.ts +54 -0
- package/sse/server-sent-events.js +54 -0
- package/types.d.ts +6 -2
- package/utils/comparison.d.ts +2 -1
- package/utils/comparison.js +4 -3
- package/utils/compression.d.ts +4 -4
- package/utils/compression.js +35 -43
- package/utils/object/dereference.d.ts +6 -4
- package/utils/object/dereference.js +20 -8
- package/utils/object/object.d.ts +2 -0
- package/utils/object/object.js +20 -0
- /package/{rxjs → rxjs-utils}/cast.d.ts +0 -0
- /package/{rxjs → rxjs-utils}/cast.js +0 -0
- /package/{rxjs → rxjs-utils}/index.d.ts +0 -0
- /package/{rxjs → rxjs-utils}/index.js +0 -0
- /package/{rxjs → rxjs-utils}/noop.d.ts +0 -0
- /package/{rxjs → rxjs-utils}/noop.js +0 -0
- /package/{rxjs → rxjs-utils}/reject-error.js +0 -0
- /package/{rxjs → rxjs-utils}/retry-backoff.js +0 -0
- /package/{rxjs → rxjs-utils}/start-with-provider.js +0 -0
- /package/{rxjs → rxjs-utils}/teardown.js +0 -0
- /package/{rxjs → rxjs-utils}/timing.d.ts +0 -0
- /package/{rxjs → rxjs-utils}/timing.js +0 -0
- /package/{rxjs → rxjs-utils}/untrack.js +0 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { and, eq, gt, gte, inArray, isNotNull, isNull, isSQLWrapper, lt, lte, ne, not, notInArray, or, SQL, sql } from 'drizzle-orm';
|
|
2
|
+
import { NotSupportedError } from '../errors/not-supported.error.js';
|
|
3
|
+
import { hasOwnProperty, objectEntries } from '../utils/object/object.js';
|
|
4
|
+
import { assertDefinedPass, isPrimitive, isRegExp, isString, isUndefined } from '../utils/type-guards.js';
|
|
5
|
+
const sqlTrue = sql `true`;
|
|
6
|
+
export function convertQuery(query, table, columnDefinitionsMap) {
|
|
7
|
+
if (query instanceof SQL) {
|
|
8
|
+
return query;
|
|
9
|
+
}
|
|
10
|
+
if (isSQLWrapper(query)) {
|
|
11
|
+
return sql `${query}`;
|
|
12
|
+
}
|
|
13
|
+
const queryEntries = objectEntries(query);
|
|
14
|
+
if (queryEntries.length == 0) {
|
|
15
|
+
return sqlTrue;
|
|
16
|
+
}
|
|
17
|
+
// eslint-disable-next-line no-unreachable-loop
|
|
18
|
+
for (const [property, value] of queryEntries) {
|
|
19
|
+
const isPrimitiveValue = isPrimitive(value);
|
|
20
|
+
if (property == '$and') {
|
|
21
|
+
if (queryEntries.length > 1) {
|
|
22
|
+
throw new Error('only one logical operator per level allowed');
|
|
23
|
+
}
|
|
24
|
+
const andQuery = and(...query.$and.map((item) => convertQuery(item, table, columnDefinitionsMap)));
|
|
25
|
+
if (isUndefined(andQuery)) {
|
|
26
|
+
return sqlTrue;
|
|
27
|
+
}
|
|
28
|
+
return andQuery;
|
|
29
|
+
}
|
|
30
|
+
if (property == '$or') {
|
|
31
|
+
if (queryEntries.length > 1) {
|
|
32
|
+
throw new Error('only one logical operator per level allowed');
|
|
33
|
+
}
|
|
34
|
+
const orQuery = or(...query.$or.map((item) => convertQuery(item, table, columnDefinitionsMap)));
|
|
35
|
+
if (isUndefined(orQuery)) {
|
|
36
|
+
return sqlTrue;
|
|
37
|
+
}
|
|
38
|
+
return orQuery;
|
|
39
|
+
}
|
|
40
|
+
if (property == '$nor') {
|
|
41
|
+
if (queryEntries.length > 1) {
|
|
42
|
+
throw new Error('only one logical operator per level allowed');
|
|
43
|
+
}
|
|
44
|
+
const orQuery = or(...query.$nor.map((item) => convertQuery(item, table, columnDefinitionsMap)));
|
|
45
|
+
if (isUndefined(orQuery)) {
|
|
46
|
+
return sqlTrue;
|
|
47
|
+
}
|
|
48
|
+
return not(orQuery);
|
|
49
|
+
}
|
|
50
|
+
const columnDef = assertDefinedPass(columnDefinitionsMap.get(property), `Could not map property ${property} to column.`);
|
|
51
|
+
const column = table[columnDef.name];
|
|
52
|
+
if (isPrimitiveValue || hasOwnProperty(value, '$eq')) {
|
|
53
|
+
const queryValue = isPrimitiveValue ? value : value.$eq;
|
|
54
|
+
if (queryValue === null) {
|
|
55
|
+
return isNull(column);
|
|
56
|
+
}
|
|
57
|
+
return eq(column, queryValue);
|
|
58
|
+
}
|
|
59
|
+
if (hasOwnProperty(value, '$neq')) {
|
|
60
|
+
const queryValue = value.$neq;
|
|
61
|
+
if (queryValue === null) {
|
|
62
|
+
return isNotNull(column);
|
|
63
|
+
}
|
|
64
|
+
return ne(column, queryValue);
|
|
65
|
+
}
|
|
66
|
+
if (hasOwnProperty(value, '$exists')) {
|
|
67
|
+
throw new NotSupportedError('$exists is not supported.');
|
|
68
|
+
}
|
|
69
|
+
if (hasOwnProperty(value, '$in')) {
|
|
70
|
+
const queryValue = value.$in;
|
|
71
|
+
return inArray(column, queryValue);
|
|
72
|
+
}
|
|
73
|
+
if (hasOwnProperty(value, '$nin')) {
|
|
74
|
+
const queryValue = value.$nin;
|
|
75
|
+
return notInArray(column, queryValue);
|
|
76
|
+
}
|
|
77
|
+
if (hasOwnProperty(value, '$lt')) {
|
|
78
|
+
const queryValue = value.$lt;
|
|
79
|
+
return lt(column, queryValue);
|
|
80
|
+
}
|
|
81
|
+
if (hasOwnProperty(value, '$lte')) {
|
|
82
|
+
const queryValue = value.$lte;
|
|
83
|
+
return lte(column, queryValue);
|
|
84
|
+
}
|
|
85
|
+
if (hasOwnProperty(value, '$gt')) {
|
|
86
|
+
const queryValue = value.$gt;
|
|
87
|
+
return gt(column, queryValue);
|
|
88
|
+
}
|
|
89
|
+
if (hasOwnProperty(value, '$gte')) {
|
|
90
|
+
const queryValue = value.$gte;
|
|
91
|
+
return gte(column, queryValue);
|
|
92
|
+
}
|
|
93
|
+
if (hasOwnProperty(value, '$regex')) {
|
|
94
|
+
const queryValue = value.$regex;
|
|
95
|
+
const regexp = isString(queryValue)
|
|
96
|
+
? ({ value: queryValue })
|
|
97
|
+
: isRegExp(queryValue)
|
|
98
|
+
? ({ flags: queryValue.flags, value: queryValue.source })
|
|
99
|
+
: ({ flags: queryValue.flags, value: queryValue.pattern });
|
|
100
|
+
return sql `regexp_like(${column}, ${regexp.value}, ${regexp.flags})`;
|
|
101
|
+
}
|
|
102
|
+
if (hasOwnProperty(value, '$text')) {
|
|
103
|
+
throw new NotSupportedError('$text is not supported.');
|
|
104
|
+
}
|
|
105
|
+
if (hasOwnProperty(value, '$geoShape')) {
|
|
106
|
+
throw new NotSupportedError('$geoShape is not supported.');
|
|
107
|
+
}
|
|
108
|
+
if (hasOwnProperty(value, '$geoDistance')) {
|
|
109
|
+
throw new NotSupportedError('$geoDistance is not supported.');
|
|
110
|
+
}
|
|
111
|
+
throw new Error(`Unsupported query type "${property}".`);
|
|
112
|
+
}
|
|
113
|
+
throw new Error('Unsupported query.');
|
|
114
|
+
}
|
package/orm/query.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SQLWrapper } from 'drizzle-orm';
|
|
2
|
+
import type { Flatten, Record, Untagged } from '../types.js';
|
|
2
3
|
import type { Geometry } from '../types/geo-json.js';
|
|
3
4
|
export type LogicalQuery<T = any> = LogicalAndQuery<T> | LogicalOrQuery<T> | LogicalNorQuery<T>;
|
|
4
5
|
export type LogicalQueryTypes = keyof (LogicalAndQuery & LogicalOrQuery & LogicalNorQuery);
|
|
@@ -6,14 +7,15 @@ export declare const allLogicalQueryTypes: LogicalQueryTypes[];
|
|
|
6
7
|
export type ComparisonQueryBody<T = any> = {
|
|
7
8
|
[P in keyof T]?: ComparisonQueryOrValue<T[P]>;
|
|
8
9
|
} & Record<ComparisonQueryOrValue>;
|
|
9
|
-
export type ComparisonQueryOrValue<T = any> = ComparisonQuery<T> |
|
|
10
|
+
export type ComparisonQueryOrValue<T = any> = ComparisonQuery<T> | ComparisonValue<T>;
|
|
10
11
|
export type ComparisonQuery<T = any> = Partial<ComparisonNotQuery<T> & ComparisonEqualsQuery<T> & ComparisonNotEqualsQuery<T> & ComparisonExistsQuery & ComparisonItemQuery<T> & ComparisonInQuery<T> & ComparisonNotInQuery<T> & ComparisonAllQuery<T> & ComparisonGreaterThanQuery<T> & ComparisonGreaterThanOrEqualsQuery<T> & ComparisonLessThanQuery<T> & ComparisonLessThanOrEqualsQuery<T> & ComparisonRegexQuery & ComparisonTextQuery & ComparisonGeoShapeQuery & ComparisonGeoDistanceQuery>;
|
|
11
12
|
export type ComparisonQueryTypes = keyof ComparisonQuery;
|
|
12
13
|
export declare const allComparisonQueryTypes: ComparisonQueryTypes[];
|
|
13
14
|
export type SpecialQuery<T = any> = Partial<TextSpanQuery<T>>;
|
|
14
15
|
export type SpecialQueryTypes = keyof SpecialQuery;
|
|
15
16
|
export declare const allSpecialQueryTypes: SpecialQueryTypes[];
|
|
16
|
-
export type Query<T = any> =
|
|
17
|
+
export type Query<T = any> = SQLWrapper | QueryObject<T>;
|
|
18
|
+
export type QueryObject<T> = LogicalQuery<T> | (ComparisonQueryBody<T> & SpecialQuery<T>);
|
|
17
19
|
export type QueryTypes = LogicalQueryTypes | ComparisonQueryTypes | SpecialQueryTypes;
|
|
18
20
|
export declare const allQueryTypes: ("$and" | "$or" | "$nor" | "$not" | "$eq" | "$neq" | "$exists" | "$item" | "$in" | "$nin" | "$all" | "$gt" | "$gte" | "$lt" | "$lte" | "$regex" | "$text" | "$geoShape" | "$geoDistance" | "$textSpan")[];
|
|
19
21
|
export type Order = 'asc' | 'desc';
|
|
@@ -21,16 +23,16 @@ export declare const allOrders: Order[];
|
|
|
21
23
|
export type Operator = 'and' | 'or';
|
|
22
24
|
export declare const allOperators: Operator[];
|
|
23
25
|
export type LogicalAndQuery<T = any> = {
|
|
24
|
-
$and: Query<T>[];
|
|
26
|
+
$and: readonly Query<T>[];
|
|
25
27
|
};
|
|
26
28
|
export type LogicalOrQuery<T = any> = {
|
|
27
|
-
$or: Query<T>[];
|
|
29
|
+
$or: readonly Query<T>[];
|
|
28
30
|
};
|
|
29
31
|
export type LogicalNorQuery<T = any> = {
|
|
30
|
-
$nor: Query<T>[];
|
|
32
|
+
$nor: readonly Query<T>[];
|
|
31
33
|
};
|
|
32
|
-
export type ComparisonValue<T> = T | Flatten<T
|
|
33
|
-
export type ComparisonValueWithRegex<T> = T extends string ? ComparisonValue<T | RegExp> : T extends string[] ? ComparisonValue<(Flatten<T> | RegExp)[]> : (T | Flatten<T>);
|
|
34
|
+
export type ComparisonValue<T> = Untagged<T | Flatten<T>>;
|
|
35
|
+
export type ComparisonValueWithRegex<T> = T extends string ? ComparisonValue<T | RegExp> : T extends readonly string[] ? ComparisonValue<readonly (Flatten<T> | RegExp)[]> : (T | Flatten<T>);
|
|
34
36
|
export type ComparisonNotQuery<T = any> = {
|
|
35
37
|
$not: ComparisonQuery<T>;
|
|
36
38
|
};
|
|
@@ -44,16 +46,16 @@ export type ComparisonExistsQuery = {
|
|
|
44
46
|
$exists: ComparisonValue<boolean>;
|
|
45
47
|
};
|
|
46
48
|
export type ComparisonItemQuery<T = any> = {
|
|
47
|
-
$item: T extends (infer U)[] ? U extends Record
|
|
49
|
+
$item: T extends readonly (infer U)[] ? U extends Record ? Query<U> : ComparisonQuery<U> : never;
|
|
48
50
|
};
|
|
49
51
|
export type ComparisonInQuery<T = any> = {
|
|
50
|
-
$in: ComparisonValueWithRegex<T>[];
|
|
52
|
+
$in: readonly ComparisonValueWithRegex<T>[];
|
|
51
53
|
};
|
|
52
54
|
export type ComparisonNotInQuery<T = any> = {
|
|
53
|
-
$nin: ComparisonValueWithRegex<T>[];
|
|
55
|
+
$nin: readonly ComparisonValueWithRegex<T>[];
|
|
54
56
|
};
|
|
55
57
|
export type ComparisonAllQuery<T = any> = {
|
|
56
|
-
$all: ComparisonValueWithRegex<T>[];
|
|
58
|
+
$all: readonly ComparisonValueWithRegex<T>[];
|
|
57
59
|
};
|
|
58
60
|
export type ComparisonGreaterThanQuery<T = any> = {
|
|
59
61
|
$gt: ComparisonValue<T>;
|
|
@@ -104,7 +106,7 @@ export type TextSpanQueryMode = 'best' | 'most' | 'cross';
|
|
|
104
106
|
export declare const allTextSpanQueryModes: TextSpanQueryMode[];
|
|
105
107
|
export type TextSpanQuery<T = any> = {
|
|
106
108
|
$textSpan: {
|
|
107
|
-
fields: (Extract<keyof T, string>)[];
|
|
109
|
+
fields: readonly (Extract<keyof T, string>)[];
|
|
108
110
|
text: string;
|
|
109
111
|
mode?: TextSpanQueryMode;
|
|
110
112
|
operator?: Operator;
|
package/orm/repository.d.ts
CHANGED
|
@@ -1,53 +1,112 @@
|
|
|
1
|
-
import type { Paths, TypedOmit } from '../types.js';
|
|
2
1
|
import { SQL } from 'drizzle-orm';
|
|
3
|
-
import
|
|
2
|
+
import { PgTransaction as DrizzlePgTransaction, PgColumn, PgInsertValue, PgQueryResultHKT, PgUpdateSetSource } from 'drizzle-orm/pg-core';
|
|
3
|
+
import { PartialDeep } from 'type-fest';
|
|
4
|
+
import { Resolvable, resolveArgumentType } from '../injector/interfaces.js';
|
|
5
|
+
import type { DeepPartial, OneOrMany, Paths, Record, Type, TypedOmit, UntaggedDeep } from '../types.js';
|
|
6
|
+
import { Database } from './database.js';
|
|
7
|
+
import { ColumnDefinition, type PgTableFromType } from './drizzle/schema-converter.js';
|
|
8
|
+
import type { Entity, EntityMetadata, EntityMetadataAttributes, EntityType, NewEntity } from './entity.js';
|
|
4
9
|
import type { Query } from './query.js';
|
|
10
|
+
import { Transaction, TransactionConfig } from './transaction.js';
|
|
11
|
+
type PgTransaction = DrizzlePgTransaction<PgQueryResultHKT, Record, Record>;
|
|
5
12
|
export declare const repositoryType: unique symbol;
|
|
6
13
|
export type OrderOptions<T extends Entity> = {
|
|
7
|
-
order?:
|
|
8
|
-
[P in Paths<T>]?: 1 | -1 | 'asc' | 'desc';
|
|
9
|
-
};
|
|
14
|
+
order?: Partial<Record<Paths<T>, 1 | -1 | 'asc' | 'desc'>>;
|
|
10
15
|
};
|
|
11
16
|
export type LoadOptions<T extends Entity> = OrderOptions<T> & {
|
|
12
17
|
offset?: number;
|
|
18
|
+
withDeleted?: boolean;
|
|
13
19
|
};
|
|
14
20
|
export type LoadManyOptions<T extends Entity> = LoadOptions<T> & {
|
|
15
21
|
limit?: number;
|
|
16
22
|
};
|
|
17
|
-
export type
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export declare
|
|
23
|
+
export type UpdateOptions<T extends Entity> = LoadOptions<T>;
|
|
24
|
+
export type EntityMetadataUpdate = Partial<UntaggedDeep<Pick<EntityMetadata, 'attributes'>>>;
|
|
25
|
+
export type EntityUpdate<T extends Entity> = PartialDeep<UntaggedDeep<TypedOmit<T, 'metadata'> & {
|
|
26
|
+
metadata: EntityMetadataUpdate;
|
|
27
|
+
}>>;
|
|
28
|
+
export declare class EntityRepositoryConfig {
|
|
29
|
+
schema: string;
|
|
30
|
+
}
|
|
31
|
+
export type TransactionHandler<T extends Entity, R> = (repository: EntityRepository<T>, transaction: Transaction) => Promise<R>;
|
|
32
|
+
export declare class EntityRepository<T extends Entity = Entity> implements Resolvable<EntityType<T>> {
|
|
33
|
+
#private;
|
|
23
34
|
readonly type: EntityType<T>;
|
|
24
|
-
readonly
|
|
25
|
-
readonly
|
|
26
|
-
|
|
27
|
-
|
|
35
|
+
readonly table: PgTableFromType<string, EntityType>;
|
|
36
|
+
readonly columnDefinitions: ColumnDefinition[];
|
|
37
|
+
readonly columnDefinitionsMap: Map<string, ColumnDefinition>;
|
|
38
|
+
readonly session: Database | PgTransaction;
|
|
39
|
+
readonly isInTransaction: boolean;
|
|
40
|
+
get tx(): PgTransaction;
|
|
41
|
+
readonly [resolveArgumentType]: EntityType<T>;
|
|
42
|
+
constructor(type?: EntityType<T>, table?: PgTableFromType<string, EntityType>, columnDefinitions?: ColumnDefinition[], columnDefinitionsMap?: Map<string, ColumnDefinition>, session?: Database | PgTransaction);
|
|
43
|
+
withOptionalTransaction(transaction: Transaction | undefined): EntityRepository<T>;
|
|
44
|
+
withTransaction(transaction: Transaction): EntityRepository<T>;
|
|
45
|
+
startTransaction(config?: TransactionConfig): Promise<Transaction>;
|
|
46
|
+
useTransaction<R>(transaction: Transaction | undefined, handler: TransactionHandler<T, R>): Promise<R>;
|
|
47
|
+
transaction<R>(handler: TransactionHandler<T, R>, config?: TransactionConfig): Promise<R>;
|
|
28
48
|
load(id: string): Promise<T>;
|
|
29
49
|
tryLoad(id: string): Promise<T | undefined>;
|
|
30
|
-
loadByQuery(query: Query<T
|
|
31
|
-
tryLoadByQuery(query: Query<T
|
|
50
|
+
loadByQuery(query: Query<T>, options?: LoadOptions<T>): Promise<T>;
|
|
51
|
+
tryLoadByQuery(query: Query<T>, options?: LoadOptions<T>): Promise<T | undefined>;
|
|
32
52
|
loadMany(ids: string[], options?: LoadManyOptions<T>): Promise<T[]>;
|
|
33
53
|
loadManyCursor(ids: string[], options?: LoadManyOptions<T>): AsyncIterableIterator<T>;
|
|
34
|
-
loadManyByQuery(query: Query<T
|
|
35
|
-
loadManyByQueryCursor(query: Query<T
|
|
54
|
+
loadManyByQuery(query: Query<T>, options?: LoadManyOptions<T>): Promise<T[]>;
|
|
55
|
+
loadManyByQueryCursor(query: Query<T>, options?: LoadManyOptions<T>): AsyncIterableIterator<T>;
|
|
36
56
|
loadAll(options?: LoadManyOptions<T>): Promise<T[]>;
|
|
37
57
|
loadAllCursor(options?: LoadManyOptions<T>): AsyncIterableIterator<T>;
|
|
38
58
|
count(): Promise<number>;
|
|
39
|
-
countByQuery(query: Query<T>
|
|
59
|
+
countByQuery(query: Query<T>): Promise<number>;
|
|
40
60
|
has(id: string): Promise<boolean>;
|
|
41
|
-
hasByQuery(query: Query<T>
|
|
61
|
+
hasByQuery(query: Query<T>): Promise<boolean>;
|
|
42
62
|
hasAll(ids: string[]): Promise<boolean>;
|
|
43
|
-
insert(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
63
|
+
insert(entity: NewEntity<T>): Promise<T>;
|
|
64
|
+
insertMany(entities: NewEntity<T>[]): Promise<T[]>;
|
|
65
|
+
upsert(target: OneOrMany<Extract<keyof T, string>>, entity: NewEntity<T>, update?: EntityUpdate<T>): Promise<T>;
|
|
66
|
+
upsertMany(target: OneOrMany<Extract<keyof T, string>>, entities: NewEntity<T>[], update: EntityUpdate<T>): Promise<T[]>;
|
|
67
|
+
update(id: string, update: EntityUpdate<T>): Promise<T>;
|
|
68
|
+
tryUpdate(id: string, update: EntityUpdate<T>): Promise<T | undefined>;
|
|
69
|
+
updateByQuery(query: Query<T>, update: EntityUpdate<T>): Promise<T>;
|
|
70
|
+
tryUpdateByQuery(query: Query<T>, update: EntityUpdate<T>): Promise<T | undefined>;
|
|
71
|
+
updateMany(ids: string[], update: EntityUpdate<T>): Promise<T[]>;
|
|
72
|
+
updateManyByQuery(query: Query<T>, update: EntityUpdate<T>): Promise<T[]>;
|
|
73
|
+
delete(id: string, metadataUpdate?: EntityMetadataUpdate): Promise<T>;
|
|
74
|
+
tryDelete(id: string, metadataUpdate?: EntityMetadataUpdate): Promise<T | undefined>;
|
|
75
|
+
deleteByQuery(query: Query<T>, metadataUpdate?: EntityMetadataUpdate): Promise<T>;
|
|
76
|
+
tryDeleteByQuery(query: Query<T>, metadataUpdate?: EntityMetadataUpdate): Promise<T | undefined>;
|
|
77
|
+
deleteMany(ids: string[], metadataUpdate?: EntityMetadataUpdate): Promise<T[]>;
|
|
78
|
+
deleteManyByQuery(query: Query<T>, metadataUpdate?: EntityMetadataUpdate): Promise<T[]>;
|
|
79
|
+
hardDelete(id: string): Promise<void>;
|
|
80
|
+
tryHardDelete(id: string): Promise<boolean>;
|
|
81
|
+
hardDeleteByQuery(query: Query<T>): Promise<boolean>;
|
|
82
|
+
hardDeleteMany(ids: string[]): Promise<number>;
|
|
83
|
+
hardDeleteManyByQuery(query: Query<T>): Promise<number>;
|
|
84
|
+
protected convertQuery(query: Query<T>): SQL;
|
|
85
|
+
protected mapToEntity(columns: this['table']['$inferSelect']): T;
|
|
86
|
+
protected mapToColumns(obj: DeepPartial<T> | NewEntity<T>): PgInsertValue<PgTableFromType<string, EntityType>>;
|
|
87
|
+
protected mapToInsertColumns(obj: DeepPartial<T> | NewEntity<T>): PgInsertValue<PgTableFromType<string, EntityType>>;
|
|
88
|
+
protected mapUpdate(update: EntityUpdate<T>): PgUpdateSetSource<PgTableFromType<string, EntityType>>;
|
|
89
|
+
protected getIdLimitQuery(query: Query<T>): import("drizzle-orm/pg-core").WithSubqueryWithSelection<{
|
|
90
|
+
id: PgColumn<{
|
|
91
|
+
name: string;
|
|
92
|
+
tableName: string;
|
|
93
|
+
dataType: "string";
|
|
94
|
+
columnType: "PgUUID";
|
|
95
|
+
data: string;
|
|
96
|
+
driverParam: string;
|
|
97
|
+
notNull: true;
|
|
98
|
+
hasDefault: true;
|
|
99
|
+
isPrimaryKey: true;
|
|
100
|
+
isAutoincrement: false;
|
|
101
|
+
hasRuntimeDefault: false;
|
|
102
|
+
enumValues: undefined;
|
|
103
|
+
baseColumn: never;
|
|
104
|
+
identity: undefined;
|
|
105
|
+
generated: undefined;
|
|
106
|
+
}, {}, {}>;
|
|
107
|
+
}, "id">;
|
|
108
|
+
protected getAttributesUpdate(attributes: EntityMetadataAttributes | undefined): SQL<unknown> | undefined;
|
|
53
109
|
}
|
|
110
|
+
export declare function injectRepository<T extends Entity>(type: EntityType<T>): EntityRepository<T>;
|
|
111
|
+
export declare function getRepository<T extends Entity>(type: EntityType<T>, config: EntityRepositoryConfig): Type<EntityRepository<T>>;
|
|
112
|
+
export {};
|