@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.
Files changed (221) hide show
  1. package/ai/ai-file.service.js +23 -18
  2. package/ai/ai.service.d.ts +4 -12
  3. package/ai/ai.service.js +79 -147
  4. package/ai/functions.d.ts +1 -1
  5. package/ai/types.d.ts +3 -1
  6. package/api/server/gateway.js +6 -6
  7. package/authentication/authentication.api.js +24 -24
  8. package/authentication/server/authentication.service.js +20 -20
  9. package/browser/page-controller.js +1 -1
  10. package/context/context.js +5 -5
  11. package/document-management/api/document-management.api.d.ts +60 -215
  12. package/document-management/api/document-management.api.js +32 -68
  13. package/document-management/models/document-assignment-scope.model.d.ts +11 -0
  14. package/document-management/models/{document-request-assignment-task-collection.model.js → document-assignment-scope.model.js} +14 -10
  15. package/document-management/models/document-assignment-task.model.d.ts +13 -0
  16. package/document-management/models/document-assignment-task.model.js +38 -0
  17. package/document-management/models/document-category.model.d.ts +2 -0
  18. package/document-management/models/document-category.model.js +7 -1
  19. package/document-management/models/{document-collection-document.model.d.ts → document-collection-assignment.model.d.ts} +1 -1
  20. package/document-management/models/{document-collection-document.model.js → document-collection-assignment.model.js} +7 -7
  21. package/document-management/models/document-collection.model.d.ts +2 -0
  22. package/document-management/models/document-collection.model.js +10 -0
  23. package/document-management/models/document-property-value.model.d.ts +3 -11
  24. package/document-management/models/document-property-value.model.js +15 -46
  25. package/document-management/models/document-property.model.d.ts +2 -1
  26. package/document-management/models/document-property.model.js +2 -2
  27. package/document-management/models/document-request-submission.model.d.ts +7 -0
  28. package/document-management/models/document-request-submission.model.js +34 -0
  29. package/document-management/models/document-request-template.d.ts +2 -4
  30. package/document-management/models/document-request-template.js +3 -8
  31. package/document-management/models/document-request.model.d.ts +14 -6
  32. package/document-management/models/document-request.model.js +22 -12
  33. package/document-management/models/document-type-validation.model.d.ts +6 -0
  34. package/document-management/models/document-type-validation.model.js +34 -0
  35. package/document-management/models/document-type.model.d.ts +0 -1
  36. package/document-management/models/document-type.model.js +0 -5
  37. package/document-management/models/document-validation-definition.model.d.ts +10 -0
  38. package/document-management/models/document-validation-definition.model.js +39 -0
  39. package/document-management/models/document-validation-execution-related-document.model.d.ts +7 -0
  40. package/document-management/models/document-validation-execution-related-document.model.js +34 -0
  41. package/document-management/models/document-validation-execution.model.d.ts +26 -0
  42. package/document-management/models/document-validation-execution.model.js +72 -0
  43. package/document-management/models/document-workflow.model.d.ts +35 -0
  44. package/document-management/models/document-workflow.model.js +70 -0
  45. package/document-management/models/document.model.d.ts +12 -1
  46. package/document-management/models/document.model.js +21 -5
  47. package/document-management/models/index.d.ts +10 -5
  48. package/document-management/models/index.js +10 -5
  49. package/document-management/models/service-models/categories-and-types.view-model.d.ts +3 -3
  50. package/document-management/models/service-models/categories-and-types.view-model.js +2 -21
  51. package/document-management/models/service-models/document-folders.view-model.d.ts +7 -14
  52. package/document-management/models/service-models/document-folders.view-model.js +20 -44
  53. package/document-management/models/service-models/document-management.view-model.d.ts +41 -0
  54. package/document-management/models/service-models/{document.view-model.js → document-management.view-model.js} +43 -26
  55. package/document-management/models/service-models/document.service-model.d.ts +51 -81
  56. package/document-management/models/service-models/document.service-model.js +30 -28
  57. package/document-management/models/service-models/enriched/enriched-document-assignment.view.d.ts +11 -0
  58. package/document-management/models/service-models/enriched/enriched-document-assignment.view.js +12 -0
  59. package/document-management/models/service-models/enriched/enriched-document-category.view.d.ts +13 -0
  60. package/document-management/models/service-models/enriched/enriched-document-category.view.js +47 -0
  61. package/document-management/models/service-models/enriched/enriched-document-collection.view.d.ts +22 -0
  62. package/document-management/models/service-models/enriched/enriched-document-collection.view.js +89 -0
  63. package/document-management/models/service-models/enriched/enriched-document-file.view.d.ts +12 -0
  64. package/document-management/models/service-models/enriched/enriched-document-file.view.js +16 -0
  65. package/document-management/models/service-models/enriched/enriched-document-management-data.view.d.ts +41 -0
  66. package/document-management/models/service-models/enriched/enriched-document-management-data.view.js +130 -0
  67. package/document-management/models/service-models/enriched/enriched-document-request.view.d.ts +17 -0
  68. package/document-management/models/service-models/enriched/enriched-document-request.view.js +52 -0
  69. package/document-management/models/service-models/enriched/enriched-document-type.view.d.ts +9 -0
  70. package/document-management/models/service-models/enriched/enriched-document-type.view.js +10 -0
  71. package/document-management/models/service-models/enriched/enriched-document.view.d.ts +28 -0
  72. package/document-management/models/service-models/enriched/enriched-document.view.js +77 -0
  73. package/document-management/models/service-models/enriched/enriched.d.ts +18 -0
  74. package/document-management/models/service-models/enriched/enriched.js +39 -0
  75. package/document-management/models/service-models/enriched/index.d.ts +9 -0
  76. package/document-management/models/service-models/enriched/index.js +9 -0
  77. package/document-management/models/service-models/index.d.ts +2 -2
  78. package/document-management/models/service-models/index.js +2 -2
  79. package/document-management/models/service-models/normalized-requests-template-data.model.d.ts +12 -10
  80. package/document-management/models/service-models/normalized-requests-template-data.model.js +5 -4
  81. package/document-management/models/service-models/stats.view-model.d.ts +7 -5
  82. package/document-management/models/service-models/stats.view-model.js +19 -9
  83. package/document-management/server/module.d.ts +2 -2
  84. package/document-management/server/module.js +3 -7
  85. package/document-management/server/schemas.d.ts +18 -23
  86. package/document-management/server/schemas.js +18 -23
  87. package/document-management/server/services/document-category-type.service.d.ts +25 -0
  88. package/document-management/server/services/document-category-type.service.js +66 -0
  89. package/document-management/server/services/document-collection.service.d.ts +13 -0
  90. package/document-management/server/services/document-collection.service.js +41 -0
  91. package/document-management/server/services/document-file.service.d.ts +17 -0
  92. package/document-management/server/services/document-file.service.js +204 -0
  93. package/document-management/server/services/document-management-ai.service.d.ts +22 -0
  94. package/document-management/server/services/document-management-ai.service.js +340 -0
  95. package/document-management/server/services/document-management-ancillary.service.d.ts +127 -3
  96. package/document-management/server/services/document-management-ancillary.service.js +24 -0
  97. package/document-management/server/services/document-management.service.d.ts +10 -122
  98. package/document-management/server/services/document-management.service.js +106 -888
  99. package/document-management/server/services/document-property.service.d.ts +84 -0
  100. package/document-management/server/services/document-property.service.js +87 -0
  101. package/document-management/server/services/document-request.service.d.ts +30 -0
  102. package/document-management/server/services/document-request.service.js +138 -0
  103. package/document-management/server/services/document-validation.service.d.ts +20 -0
  104. package/document-management/server/services/document-validation.service.js +145 -0
  105. package/document-management/server/services/document-workflow.service.d.ts +20 -0
  106. package/document-management/server/services/document-workflow.service.js +132 -0
  107. package/document-management/server/services/document.service.d.ts +16 -0
  108. package/document-management/server/services/document.service.js +81 -0
  109. package/document-management/server/services/index.d.ts +9 -0
  110. package/document-management/server/services/index.js +9 -0
  111. package/document-management/server/validators/ai-validation-executor.d.ts +19 -0
  112. package/document-management/server/validators/ai-validation-executor.js +51 -0
  113. package/document-management/server/validators/index.d.ts +2 -0
  114. package/document-management/server/validators/index.js +2 -0
  115. package/document-management/server/validators/single-document-validation-executor.d.ts +16 -0
  116. package/document-management/server/validators/single-document-validation-executor.js +20 -0
  117. package/document-management/server/validators/validator.d.ts +21 -0
  118. package/document-management/server/validators/validator.js +2 -0
  119. package/eslint.config.js +31 -17
  120. package/examples/document-management/main.d.ts +18 -3
  121. package/examples/document-management/main.js +28 -12
  122. package/file/mime-type.js +2 -9
  123. package/formats.d.ts +5 -2
  124. package/formats.js +32 -23
  125. package/http/client/http-client.js +1 -1
  126. package/injector/injector.js +2 -2
  127. package/object-storage/s3/s3.object-storage.js +1 -1
  128. package/orm/data-types/bytea.d.ts +8 -0
  129. package/orm/data-types/bytea.js +8 -0
  130. package/orm/data-types/index.d.ts +4 -0
  131. package/orm/data-types/index.js +4 -0
  132. package/orm/data-types/numeric-date.d.ts +9 -0
  133. package/orm/data-types/numeric-date.js +9 -0
  134. package/orm/data-types/timestamp.d.ts +9 -0
  135. package/orm/data-types/timestamp.js +9 -0
  136. package/orm/decorators.d.ts +139 -5
  137. package/orm/decorators.js +50 -0
  138. package/orm/entity.d.ts +19 -0
  139. package/orm/entity.js +19 -0
  140. package/orm/index.d.ts +5 -0
  141. package/orm/index.js +5 -0
  142. package/orm/query.d.ts +51 -0
  143. package/orm/query.js +6 -0
  144. package/orm/repository.types.d.ts +54 -2
  145. package/orm/server/database-schema.d.ts +34 -0
  146. package/orm/server/database-schema.js +29 -0
  147. package/orm/server/database.d.ts +19 -1
  148. package/orm/server/database.js +17 -3
  149. package/orm/server/drizzle/schema-converter.d.ts +2 -1
  150. package/orm/server/drizzle/schema-converter.js +12 -1
  151. package/orm/server/encryption.d.ts +16 -0
  152. package/orm/server/encryption.js +29 -4
  153. package/orm/server/index.d.ts +7 -0
  154. package/orm/server/index.js +7 -0
  155. package/orm/server/module.d.ts +20 -0
  156. package/orm/server/module.js +9 -0
  157. package/orm/server/query-converter.d.ts +17 -0
  158. package/orm/server/query-converter.js +66 -11
  159. package/orm/server/repository.d.ts +324 -18
  160. package/orm/server/repository.js +344 -73
  161. package/orm/server/transaction.d.ts +5 -5
  162. package/orm/server/transaction.js +5 -5
  163. package/orm/server/transactional.d.ts +75 -0
  164. package/orm/server/transactional.js +134 -0
  165. package/orm/server/types.d.ts +1 -0
  166. package/orm/sqls.d.ts +55 -0
  167. package/orm/sqls.js +60 -0
  168. package/orm/types.d.ts +67 -4
  169. package/orm/utils.d.ts +19 -3
  170. package/orm/utils.js +12 -0
  171. package/package.json +32 -31
  172. package/password/password-check-result.model.d.ts +9 -7
  173. package/password/password-check-result.model.js +8 -8
  174. package/password/password-check.js +5 -7
  175. package/password/password-check.localization.js +12 -12
  176. package/pdf/pdf.service.js +1 -1
  177. package/pdf/utils.d.ts +9 -0
  178. package/pdf/utils.js +19 -2
  179. package/process/spawn.d.ts +11 -4
  180. package/process/spawn.js +42 -5
  181. package/queue/postgres/queue.js +5 -5
  182. package/queue/queue.d.ts +6 -4
  183. package/queue/queue.js +6 -6
  184. package/schema/schemas/one-or-many.d.ts +2 -1
  185. package/schema/schemas/one-or-many.js +1 -1
  186. package/search-index/elastic/model/index-mapping.d.ts +1 -1
  187. package/search-index/elastic/model/index-mapping.js +0 -1
  188. package/search-index/elastic/search-index.d.ts +1 -2
  189. package/search-index/elastic/search-index.js +3 -3
  190. package/types.d.ts +1 -0
  191. package/utils/async-hook/async-hook.d.ts +9 -0
  192. package/utils/async-hook/async-hook.js +21 -0
  193. package/utils/async-hook/index.d.ts +1 -0
  194. package/utils/async-hook/index.js +1 -0
  195. package/utils/compression.js +1 -1
  196. package/utils/function/class.d.ts +6 -0
  197. package/utils/function/class.js +9 -0
  198. package/utils/function/index.d.ts +1 -0
  199. package/utils/function/index.js +1 -0
  200. package/utils/function/memoize.d.ts +18 -0
  201. package/utils/function/memoize.js +41 -2
  202. package/utils/jwt.d.ts +1 -1
  203. package/utils/jwt.js +5 -5
  204. package/utils/object/forward-ref.d.ts +3 -2
  205. package/utils/object/forward-ref.js +12 -12
  206. package/utils/object/lazy-property.js +2 -2
  207. package/utils/proxy.js +1 -1
  208. package/utils/stream/{readable-stream-from-promise.d.ts → from-promise.d.ts} +1 -0
  209. package/utils/stream/from-promise.js +27 -0
  210. package/utils/stream/index.d.ts +1 -1
  211. package/utils/stream/index.js +1 -1
  212. package/utils/stream/stream-reader.js +71 -31
  213. package/document-management/models/document-request-assignment-task-collection.model.d.ts +0 -7
  214. package/document-management/models/document-request-assignment-task.model.d.ts +0 -14
  215. package/document-management/models/document-request-assignment-task.model.js +0 -77
  216. package/document-management/models/document-request-file.model.d.ts +0 -16
  217. package/document-management/models/document-request-file.model.js +0 -86
  218. package/document-management/models/service-models/document.view-model.d.ts +0 -41
  219. package/document-management/models/service-models/normalized-document-collection-view.model.d.ts +0 -73
  220. package/document-management/models/service-models/normalized-document-collection-view.model.js +0 -110
  221. package/utils/stream/readable-stream-from-promise.js +0 -8
@@ -1,51 +1,142 @@
1
1
  import { SQL } from 'drizzle-orm';
2
- import { PgTransaction as DrizzlePgTransaction, type PgColumn, type PgInsertValue, type PgQueryResultHKT, type PgUpdateSetSource } from 'drizzle-orm/pg-core';
2
+ import type { PgColumn, PgInsertValue, PgUpdateSetSource } from 'drizzle-orm/pg-core';
3
3
  import { type Resolvable, resolveArgumentType } from '../../injector/interfaces.js';
4
- import type { DeepPartial, OneOrMany, Paths, Record, Type } from '../../types.js';
4
+ import type { DeepPartial, OneOrMany, Paths, Type } from '../../types.js';
5
5
  import type { UntaggedDeep } from '../../types/index.js';
6
6
  import { Entity, type EntityMetadataAttributes, type EntityType, type EntityWithoutMetadata } from '../entity.js';
7
7
  import type { Query } from '../query.js';
8
- import type { EntityMetadataUpdate, EntityUpdate, LoadManyOptions, LoadOptions, NewEntity, Order } from '../repository.types.js';
9
- import { Database } from './database.js';
10
- import { type Transaction, type TransactionConfig } from './transaction.js';
8
+ import type { EntityMetadataUpdate, EntityUpdate, LoadManyOptions, LoadOptions, NewEntity, Order, TargetColumnPaths } from '../repository.types.js';
9
+ import { Transactional } from './transactional.js';
11
10
  import type { ColumnDefinition, PgTableFromType, TransformContext } from './types.js';
12
- type PgTransaction = DrizzlePgTransaction<PgQueryResultHKT, Record, Record>;
13
11
  export declare const repositoryType: unique symbol;
12
+ /**
13
+ * Configuration class for EntityRepository.
14
+ * Specifies the database schema to be used.
15
+ */
14
16
  export declare class EntityRepositoryConfig {
17
+ /** The name of the database schema. */
15
18
  schema: string;
16
19
  }
17
- export type TransactionHandler<T extends EntityRepository<any>, R> = (repository: T, transaction: Transaction) => Promise<R>;
20
+ type EntityRepositoryContext = {
21
+ type: EntityType;
22
+ table: PgTableFromType;
23
+ columnDefinitions: ColumnDefinition[];
24
+ columnDefinitionsMap: Map<string, ColumnDefinition>;
25
+ encryptionSecret: Uint8Array | undefined;
26
+ transformContext: TransformContext | Promise<TransformContext> | undefined;
27
+ };
18
28
  type InferSelect<T extends Entity | EntityWithoutMetadata = Entity | EntityWithoutMetadata> = PgTableFromType<EntityType<T>>['$inferSelect'];
19
- export declare class EntityRepository<T extends Entity | EntityWithoutMetadata = EntityWithoutMetadata> implements Resolvable<EntityType<T>> {
29
+ export declare class EntityRepository<T extends Entity | EntityWithoutMetadata = EntityWithoutMetadata> extends Transactional<EntityRepositoryContext> implements Resolvable<EntityType<T>> {
20
30
  #private;
21
31
  readonly type: EntityType<T>;
22
32
  readonly typeName: string;
23
- readonly session: Database | PgTransaction;
24
- readonly isInTransaction: boolean;
25
33
  readonly hasMetadata: boolean;
34
+ /**
35
+ * Gets the Drizzle table definition for the entity type.
36
+ */
26
37
  get table(): PgTableFromType<EntityType<T>>;
27
- protected get isFork(): boolean;
28
38
  readonly [resolveArgumentType]: EntityType<T>;
29
- constructor();
30
- withOptionalTransaction(transaction: Transaction | undefined): this;
31
- withTransaction(transaction: Transaction): this;
32
- startTransaction(config?: TransactionConfig): Promise<Transaction>;
33
- useTransaction<R>(transaction: Transaction | undefined, handler: TransactionHandler<this, R>): Promise<R>;
34
- transaction<R>(handler: TransactionHandler<this, R>, config?: TransactionConfig): Promise<R>;
39
+ protected getTransactionalContextData(): EntityRepositoryContext;
40
+ /**
41
+ * Loads a single entity by its ID.
42
+ * Throws `NotFoundError` if the entity is not found.
43
+ * @param id The ID of the entity to load.
44
+ * @returns A promise that resolves to the loaded entity.
45
+ * @throws {NotFoundError} If the entity with the given ID is not found.
46
+ */
35
47
  load(id: string): Promise<T>;
48
+ /**
49
+ * Tries to load a single entity by its ID.
50
+ * Returns `undefined` if the entity is not found.
51
+ * @param id The ID of the entity to load.
52
+ * @returns A promise that resolves to the loaded entity or `undefined` if not found.
53
+ */
36
54
  tryLoad(id: string): Promise<T | undefined>;
55
+ /**
56
+ * Loads a single entity based on a query.
57
+ * Throws `NotFoundError` if no entity matches the query.
58
+ * @param query The query to filter entities.
59
+ * @param options Optional loading options (e.g., offset, order).
60
+ * @returns A promise that resolves to the loaded entity.
61
+ * @throws {NotFoundError} If no entity matches the query.
62
+ */
37
63
  loadByQuery(query: Query<T>, options?: LoadOptions<T>): Promise<T>;
64
+ /**
65
+ * Tries to load a single entity based on a query.
66
+ * Returns `undefined` if no entity matches the query.
67
+ * @param query The query to filter entities.
68
+ * @param options Optional loading options (e.g., offset, order).
69
+ * @returns A promise that resolves to the loaded entity or `undefined` if not found.
70
+ */
38
71
  tryLoadByQuery(query: Query<T>, options?: LoadOptions<T>): Promise<T | undefined>;
72
+ /**
73
+ * Loads multiple entities by their IDs.
74
+ * @param ids An array of entity IDs to load.
75
+ * @param options Optional loading options (e.g., offset, limit, order).
76
+ * @returns A promise that resolves to an array of loaded entities.
77
+ */
39
78
  loadMany(ids: string[], options?: LoadManyOptions<T>): Promise<T[]>;
79
+ /**
80
+ * Loads multiple entities by their IDs and returns them as an async iterable cursor.
81
+ * @param ids An array of entity IDs to load.
82
+ * @param options Optional loading options (e.g., offset, limit, order).
83
+ * @returns An async iterable iterator of loaded entities.
84
+ */
40
85
  loadManyCursor(ids: string[], options?: LoadManyOptions<T>): AsyncIterableIterator<T>;
86
+ /**
87
+ * Loads multiple entities based on a query.
88
+ * @param query The query to filter entities.
89
+ * @param options Optional loading options (e.g., offset, limit, order).
90
+ * @returns A promise that resolves to an array of loaded entities.
91
+ */
41
92
  loadManyByQuery(query: Query<T>, options?: LoadManyOptions<T>): Promise<T[]>;
93
+ /**
94
+ * Loads multiple entities based on a query and returns them as an async iterable cursor.
95
+ * @param query The query to filter entities.
96
+ * @param options Optional loading options (e.g., offset, limit, order).
97
+ * @returns An async iterable iterator of loaded entities.
98
+ */
42
99
  loadManyByQueryCursor(query: Query<T>, options?: LoadManyOptions<T>): AsyncIterableIterator<T>;
100
+ /**
101
+ * Loads all entities of the repository's type.
102
+ * @param options Optional loading options (e.g., offset, limit, order).
103
+ * @returns A promise that resolves to an array of all entities.
104
+ */
43
105
  loadAll(options?: LoadManyOptions<T>): Promise<T[]>;
106
+ /**
107
+ * Loads all entities of the repository's type and returns them as an async iterable cursor.
108
+ * @param options Optional loading options (e.g., offset, limit, order).
109
+ * @returns An async iterable iterator of all entities.
110
+ */
44
111
  loadAllCursor(options?: LoadManyOptions<T>): AsyncIterableIterator<T>;
112
+ /**
113
+ * Counts the total number of entities of the repository's type.
114
+ * @returns A promise that resolves to the total count.
115
+ */
45
116
  count(): Promise<number>;
117
+ /**
118
+ * Counts the number of entities matching a query.
119
+ * @param query The query to filter entities.
120
+ * @returns A promise that resolves to the count of matching entities.
121
+ */
46
122
  countByQuery(query: Query<T>): Promise<number>;
123
+ /**
124
+ * Checks if an entity with the given ID exists.
125
+ * @param id The ID of the entity to check.
126
+ * @returns A promise that resolves to `true` if the entity exists, `false` otherwise.
127
+ */
47
128
  has(id: string): Promise<boolean>;
129
+ /**
130
+ * Checks if any entity matches the given query.
131
+ * @param query The query to filter entities.
132
+ * @returns A promise that resolves to `true` if at least one entity matches the query, `false` otherwise.
133
+ */
48
134
  hasByQuery(query: Query<T>): Promise<boolean>;
135
+ /**
136
+ * Checks if all entities with the given IDs exist.
137
+ * @param ids An array of entity IDs to check.
138
+ * @returns A promise that resolves to `true` if all entities exist, `false` otherwise.
139
+ */
49
140
  hasAll(ids: string[]): Promise<boolean>;
50
141
  /**
51
142
  * Tries to insert using ON CONFLICT DO NOTHING
@@ -53,40 +144,243 @@ export declare class EntityRepository<T extends Entity | EntityWithoutMetadata =
53
144
  * @returns entity if inserted, undefined on conflict
54
145
  */
55
146
  tryInsert(entity: NewEntity<T>): Promise<T | undefined>;
147
+ /**
148
+ * Inserts a new entity into the database.
149
+ * @param entity The entity to insert.
150
+ * @returns A promise that resolves to the inserted entity.
151
+ */
56
152
  insert(entity: NewEntity<T>): Promise<T>;
153
+ /**
154
+ * Inserts multiple new entities into the database.
155
+ * @param entities An array of entities to insert.
156
+ * @returns A promise that resolves to an array of the inserted entities.
157
+ */
57
158
  insertMany(entities: NewEntity<T>[]): Promise<T[]>;
159
+ /**
160
+ * Inserts an entity or updates it if a conflict occurs based on the target columns.
161
+ * @param target The column(s) to use for conflict detection.
162
+ * @param entity The entity to insert.
163
+ * @param update Optional update to apply if a conflict occurs. Defaults to the inserted entity's values.
164
+ * @returns A promise that resolves to the inserted or updated entity.
165
+ */
58
166
  upsert(target: OneOrMany<Paths<UntaggedDeep<T>>>, entity: NewEntity<T>, update?: EntityUpdate<T>): Promise<T>;
167
+ /**
168
+ * Inserts multiple entities or updates them if a conflict occurs based on the target columns.
169
+ * @param target The column(s) to use for conflict detection.
170
+ * @param entities An array of entities to insert.
171
+ * @param update Optional update to apply if a conflict occurs. Defaults to the inserted entity's values.
172
+ * @returns A promise that resolves to an array of the inserted or updated entities.
173
+ */
59
174
  upsertMany(target: OneOrMany<Paths<UntaggedDeep<T>>>, entities: NewEntity<T>[], update?: EntityUpdate<T>): Promise<T[]>;
175
+ /**
176
+ * Updates an entity by its ID.
177
+ * Throws `NotFoundError` if the entity is not found.
178
+ * @param id The ID of the entity to update.
179
+ * @param update The update to apply to the entity.
180
+ * @returns A promise that resolves to the updated entity.
181
+ * @throws {NotFoundError} If the entity with the given ID is not found.
182
+ */
60
183
  update(id: string, update: EntityUpdate<T>): Promise<T>;
184
+ /**
185
+ * Tries to update an entity by its ID.
186
+ * Returns `undefined` if the entity is not found.
187
+ * @param id The ID of the entity to update.
188
+ * @param update The update to apply to the entity.
189
+ * @returns A promise that resolves to the updated entity or `undefined` if not found.
190
+ */
61
191
  tryUpdate(id: string, update: EntityUpdate<T>): Promise<T | undefined>;
192
+ /**
193
+ * Updates a single entity matching a query.
194
+ * Throws `NotFoundError` if no entity matches the query.
195
+ * @param query The query to filter entities.
196
+ * @param update The update to apply to the entity.
197
+ * @returns A promise that resolves to the updated entity.
198
+ * @throws {NotFoundError} If no entity matches the query.
199
+ */
62
200
  updateByQuery(query: Query<T>, update: EntityUpdate<T>): Promise<T>;
201
+ /**
202
+ * Tries to update a single entity matching a query.
203
+ * Returns `undefined` if no entity matches the query.
204
+ * @param query The query to filter entities.
205
+ * @param update The update to apply to the entity.
206
+ * @returns A promise that resolves to the updated entity or `undefined` if not found.
207
+ */
63
208
  tryUpdateByQuery(query: Query<T>, update: EntityUpdate<T>): Promise<T | undefined>;
209
+ /**
210
+ * Updates multiple entities by their IDs.
211
+ * @param ids An array of entity IDs to update.
212
+ * @param update The update to apply to the entities.
213
+ * @returns A promise that resolves to an array of the updated entities.
214
+ */
64
215
  updateMany(ids: string[], update: EntityUpdate<T>): Promise<T[]>;
216
+ /**
217
+ * Updates multiple entities matching a query.
218
+ * @param query The query to filter entities.
219
+ * @param update The update to apply to the entities.
220
+ * @returns A promise that resolves to an array of the updated entities.
221
+ */
65
222
  updateManyByQuery(query: Query<T>, update: EntityUpdate<T>): Promise<T[]>;
223
+ /**
224
+ * Deletes an entity by its ID (soft delete if metadata is available).
225
+ * Throws `NotFoundError` if the entity is not found.
226
+ * @param id The ID of the entity to delete.
227
+ * @param metadataUpdate Optional metadata update to apply during soft delete.
228
+ * @returns A promise that resolves to the deleted entity.
229
+ * @throws {NotFoundError} If the entity with the given ID is not found.
230
+ */
66
231
  delete(id: string, metadataUpdate?: EntityMetadataUpdate): Promise<T>;
232
+ /**
233
+ * Tries to delete an entity by its ID (soft delete if metadata is available).
234
+ * Returns `undefined` if the entity is not found.
235
+ * @param id The ID of the entity to delete.
236
+ * @param metadataUpdate Optional metadata update to apply during soft delete.
237
+ * @returns A promise that resolves to the deleted entity or `undefined` if not found.
238
+ */
67
239
  tryDelete(id: string, metadataUpdate?: EntityMetadataUpdate): Promise<T | undefined>;
240
+ /**
241
+ * Deletes a single entity matching a query (soft delete if metadata is available).
242
+ * Throws `NotFoundError` if no entity matches the query.
243
+ * @param query The query to filter entities.
244
+ * @param metadataUpdate Optional metadata update to apply during soft delete.
245
+ * @returns A promise that resolves to the deleted entity.
246
+ * @throws {NotFoundError} If no entity matches the query.
247
+ */
68
248
  deleteByQuery(query: Query<T>, metadataUpdate?: EntityMetadataUpdate): Promise<T>;
249
+ /**
250
+ * Tries to delete a single entity matching a query (soft delete if metadata is available).
251
+ * Returns `undefined` if no entity matches the query.
252
+ * @param query The query to filter entities.
253
+ * @param metadataUpdate Optional metadata update to apply during soft delete.
254
+ * @returns A promise that resolves to the deleted entity or `undefined` if not found.
255
+ */
69
256
  tryDeleteByQuery(query: Query<T>, metadataUpdate?: EntityMetadataUpdate): Promise<T | undefined>;
257
+ /**
258
+ * Deletes multiple entities by their IDs (soft delete if metadata is available).
259
+ * @param ids An array of entity IDs to delete.
260
+ * @param metadataUpdate Optional metadata update to apply during soft delete.
261
+ * @returns A promise that resolves to an array of the deleted entities.
262
+ */
70
263
  deleteMany(ids: string[], metadataUpdate?: EntityMetadataUpdate): Promise<T[]>;
264
+ /**
265
+ * Deletes multiple entities matching a query (soft delete if metadata is available).
266
+ * @param query The query to filter entities.
267
+ * @param metadataUpdate Optional metadata update to apply during soft delete.
268
+ * @returns A promise that resolves to an array of the deleted entities.
269
+ */
71
270
  deleteManyByQuery(query: Query<T>, metadataUpdate?: EntityMetadataUpdate): Promise<T[]>;
271
+ /**
272
+ * Hard deletes an entity by its ID (removes from the database).
273
+ * Throws `NotFoundError` if the entity is not found.
274
+ * @param id The ID of the entity to hard delete.
275
+ * @returns A promise that resolves to the hard deleted entity.
276
+ * @throws {NotFoundError} If the entity with the given ID is not found.
277
+ */
72
278
  hardDelete(id: string): Promise<T>;
279
+ /**
280
+ * Tries to hard delete an entity by its ID (removes from the database).
281
+ * Returns `undefined` if the entity is not found.
282
+ * @param id The ID of the entity to hard delete.
283
+ * @returns A promise that resolves to the hard deleted entity or `undefined` if not found.
284
+ */
73
285
  tryHardDelete(id: string): Promise<T | undefined>;
286
+ /**
287
+ * Hard deletes a single entity matching a query (removes from the database).
288
+ * Throws `NotFoundError` if no entity matches the query.
289
+ * @param query The query to filter entities.
290
+ * @returns A promise that resolves to the hard deleted entity.
291
+ * @throws {NotFoundError} If no entity matches the query.
292
+ */
74
293
  hardDeleteByQuery(query: Query<T>): Promise<T>;
294
+ /**
295
+ * Tries to hard delete a single entity matching a query (removes from the database).
296
+ * Returns `undefined` if no entity matches the query.
297
+ * @param query The query to filter entities.
298
+ * @returns A promise that resolves to the hard deleted entity or `undefined` if not found.
299
+ */
75
300
  tryHardDeleteByQuery(query: Query<T>): Promise<T | undefined>;
301
+ /**
302
+ * Hard deletes multiple entities by their IDs (removes from the database).
303
+ * @param ids An array of entity IDs to hard delete.
304
+ * @returns A promise that resolves to an array of the hard deleted entities.
305
+ */
76
306
  hardDeleteMany(ids: string[]): Promise<T[]>;
307
+ /**
308
+ * Hard deletes multiple entities matching a query (removes from the database).
309
+ * @param query The query to filter entities.
310
+ * @returns A promise that resolves to an array of the hard deleted entities.
311
+ */
77
312
  hardDeleteManyByQuery(query: Query<T>): Promise<T[]>;
78
- getColumn(pathOrColumn: Paths<UntaggedDeep<T>> | ColumnDefinition): PgColumn;
313
+ /**
314
+ * Retrieves the Drizzle PgColumn for a given object path or column definition.
315
+ * @param pathOrColumn The object path or column definition.
316
+ * @returns The corresponding PgColumn.
317
+ */
318
+ getColumn(pathOrColumn: TargetColumnPaths<T> | ColumnDefinition): PgColumn;
319
+ getColumns(pathOrColumns: (TargetColumnPaths<T> | ColumnDefinition)[]): PgColumn[];
320
+ /**
321
+ * Converts an Order object to an array of Drizzle SQL order expressions.
322
+ * @param order The order object.
323
+ * @returns An array of SQL order expressions.
324
+ */
79
325
  convertOrderBy(order: Order<T>): SQL[];
326
+ /**
327
+ * Converts a Query object to a Drizzle SQL where clause.
328
+ * Automatically filters out soft-deleted entities unless `withDeleted` is true.
329
+ * @param query The query object.
330
+ * @param options Optional options, including `withDeleted` to include soft-deleted entities.
331
+ * @returns A Drizzle SQL condition.
332
+ */
80
333
  convertQuery(query: Query<T>, options?: {
81
334
  withDeleted?: boolean;
82
335
  }): SQL;
336
+ /**
337
+ * Maps multiple database rows to an array of entities.
338
+ * @param columns An array of database rows.
339
+ * @returns A promise that resolves to an array of entities.
340
+ */
83
341
  mapManyToEntity(columns: InferSelect[]): Promise<T[]>;
342
+ /**
343
+ * Maps a single database row to an entity.
344
+ * @param columns A database row.
345
+ * @returns A promise that resolves to an entity.
346
+ */
84
347
  mapToEntity(columns: InferSelect): Promise<T>;
348
+ /**
349
+ * Maps multiple entity-like objects to database column values for insertion or update.
350
+ * @param objects An array of entity-like objects.
351
+ * @returns A promise that resolves to an array of database column values.
352
+ */
85
353
  mapManyToColumns(objects: (DeepPartial<T> | NewEntity<T>)[]): Promise<PgInsertValue<PgTableFromType>[]>;
354
+ /**
355
+ * Maps a single entity-like object to database column values for insertion or update.
356
+ * @param obj An entity-like object.
357
+ * @returns A promise that resolves to database column values.
358
+ */
86
359
  mapToColumns(obj: DeepPartial<T> | NewEntity<T>): Promise<PgInsertValue<PgTableFromType>>;
360
+ /**
361
+ * Maps multiple new entity objects to database column values for insertion.
362
+ * @param objects An array of new entity objects.
363
+ * @returns A promise that resolves to an array of database column values for insertion.
364
+ */
87
365
  mapManyToInsertColumns(objects: (DeepPartial<T> | NewEntity<T>)[]): Promise<PgInsertValue<PgTableFromType>[]>;
366
+ /**
367
+ * Maps a new entity object to database column values for insertion.
368
+ * @param obj A new entity object.
369
+ * @returns A promise that resolves to database column values for insertion.
370
+ */
88
371
  mapToInsertColumns(obj: DeepPartial<T> | NewEntity<T>): Promise<PgInsertValue<PgTableFromType>>;
372
+ /**
373
+ * Maps an entity update object to database column values for updating.
374
+ * @param update The entity update object.
375
+ * @returns A promise that resolves to database column values for updating.
376
+ */
89
377
  mapUpdate(update: EntityUpdate<T>): Promise<PgUpdateSetSource<PgTableFromType>>;
378
+ /**
379
+ * Gets a Drizzle select query for the ID of a single entity matching the provided query, limited to 1 result.
380
+ * Useful for subqueries in update/delete operations targeting a single entity.
381
+ * @param query The query to filter entities.
382
+ * @returns A Drizzle select query for the entity ID.
383
+ */
90
384
  getIdLimitQuery(query: Query<T>): Omit<import("drizzle-orm/pg-core").PgSelectBase<string, {
91
385
  id: PgColumn<{
92
386
  name: string;
@@ -176,6 +470,18 @@ export declare class EntityRepository<T extends Entity | EntityWithoutMetadata =
176
470
  }>, "where" | "limit">;
177
471
  protected getTransformContext(): Promise<TransformContext>;
178
472
  }
473
+ /**
474
+ * Injects an EntityRepository instance for the specified entity type.
475
+ * @template T The entity type.
476
+ * @param type The entity type.
477
+ * @returns An EntityRepository instance for the specified type.
478
+ */
179
479
  export declare function injectRepository<T extends Entity | EntityWithoutMetadata>(type: EntityType<T>): EntityRepository<T>;
480
+ /**
481
+ * Gets or creates a singleton EntityRepository class for the specified entity type.
482
+ * @template T The entity type.
483
+ * @param type The entity type.
484
+ * @returns A singleton EntityRepository class for the specified type.
485
+ */
180
486
  export declare function getRepository<T extends Entity | EntityWithoutMetadata>(type: EntityType<T>): Type<EntityRepository<T>>;
181
487
  export {};