@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,6 +1,13 @@
1
+ /**
2
+ * @module
3
+ * Barrel file exporting core server-side ORM functionalities.
4
+ * Includes database connection, schema management, repositories, transactions,
5
+ * and query conversion utilities.
6
+ */
1
7
  export * from './database-schema.js';
2
8
  export * from './database.js';
3
9
  export * from './module.js';
4
10
  export * from './query-converter.js';
5
11
  export * from './repository.js';
6
12
  export * from './transaction.js';
13
+ export * from './transactional.js';
@@ -1,12 +1,32 @@
1
+ /**
2
+ * @module
3
+ * Provides configuration options and setup for the ORM module.
4
+ * Allows configuring database connection, repository settings, and encryption secrets
5
+ * via dependency injection.
6
+ */
1
7
  import type { PoolConfig } from 'pg';
2
8
  import { EntityRepositoryConfig } from './repository.js';
9
+ /**
10
+ * Configuration class for the database connection.
11
+ * Holds the `pg.PoolConfig`.
12
+ */
3
13
  export declare class DatabaseConfig {
14
+ /** Optional PostgreSQL pool configuration. */
4
15
  connection?: PoolConfig;
5
16
  }
17
+ /**
18
+ * Options for configuring the ORM module using `configureOrm`.
19
+ */
6
20
  export type OrmModuleOptions = {
21
+ /** Optional PostgreSQL pool configuration. */
7
22
  connection?: PoolConfig;
23
+ /** Optional configuration for entity repositories. */
8
24
  repositoryConfig?: EntityRepositoryConfig;
9
25
  };
26
+ /**
27
+ * Configures the ORM module by registering necessary providers in the dependency injector.
28
+ * @param options - Configuration options including connection details, repository settings, and the encryption secret.
29
+ */
10
30
  export declare function configureOrm(options: OrmModuleOptions & {
11
31
  encryptionSecret?: Uint8Array;
12
32
  }): void;
@@ -2,9 +2,18 @@ import { Injector } from '../../injector/injector.js';
2
2
  import { isDefined } from '../../utils/type-guards.js';
3
3
  import { EntityRepositoryConfig } from './repository.js';
4
4
  import { ENCRYPTION_SECRET } from './tokens.js';
5
+ /**
6
+ * Configuration class for the database connection.
7
+ * Holds the `pg.PoolConfig`.
8
+ */
5
9
  export class DatabaseConfig {
10
+ /** Optional PostgreSQL pool configuration. */
6
11
  connection;
7
12
  }
13
+ /**
14
+ * Configures the ORM module by registering necessary providers in the dependency injector.
15
+ * @param options - Configuration options including connection details, repository settings, and the encryption secret.
16
+ */
8
17
  export function configureOrm(options) {
9
18
  if (isDefined(options.connection)) {
10
19
  Injector.register(DatabaseConfig, { useValue: { connection: options.connection } });
@@ -1,4 +1,21 @@
1
+ /**
2
+ * @module
3
+ * Converts a generic query object structure into a Drizzle ORM SQL condition.
4
+ * Supports logical operators ($and, $or, $nor) and various comparison operators
5
+ * ($eq, $neq, $in, $nin, $lt, $lte, $gt, $gte, $regex).
6
+ */
1
7
  import { SQL } from 'drizzle-orm';
2
8
  import type { Query } from '../query.js';
3
9
  import type { ColumnDefinition, PgTableFromType } from './types.js';
10
+ /**
11
+ * Converts a query object into a Drizzle SQL condition.
12
+ * Recursively handles nested logical operators and maps property names to database columns.
13
+ * @param query The query object to convert. Can be a Drizzle SQL object, SQLWrapper, or a custom query object.
14
+ * @param table The Drizzle table object.
15
+ * @param columnDefinitionsMap A map from property names to column definitions.
16
+ * @returns A Drizzle SQL condition representing the query.
17
+ * @throws {Error} If multiple logical operators are used at the same level.
18
+ * @throws {Error} If a property cannot be mapped to a column.
19
+ * @throws {Error} If an unsupported query type is encountered.
20
+ */
4
21
  export declare function convertQuery(query: Query, table: PgTableFromType, columnDefinitionsMap: Map<string, ColumnDefinition>): SQL;
@@ -1,118 +1,173 @@
1
+ /**
2
+ * @module
3
+ * Converts a generic query object structure into a Drizzle ORM SQL condition.
4
+ * Supports logical operators ($and, $or, $nor) and various comparison operators
5
+ * ($eq, $neq, $in, $nin, $lt, $lte, $gt, $gte, $regex).
6
+ */
1
7
  import { and, eq, gt, gte, inArray, isNotNull, isNull, isSQLWrapper, lt, lte, ne, not, notInArray, or, SQL, sql } from 'drizzle-orm';
2
8
  import { NotSupportedError } from '../../errors/not-supported.error.js';
3
9
  import { hasOwnProperty, objectEntries } from '../../utils/object/object.js';
4
10
  import { assertDefinedPass, isPrimitive, isRegExp, isString, isUndefined } from '../../utils/type-guards.js';
11
+ /** SQL fragment representing `true`. */
5
12
  const sqlTrue = sql `true`;
13
+ /**
14
+ * Converts a query object into a Drizzle SQL condition.
15
+ * Recursively handles nested logical operators and maps property names to database columns.
16
+ * @param query The query object to convert. Can be a Drizzle SQL object, SQLWrapper, or a custom query object.
17
+ * @param table The Drizzle table object.
18
+ * @param columnDefinitionsMap A map from property names to column definitions.
19
+ * @returns A Drizzle SQL condition representing the query.
20
+ * @throws {Error} If multiple logical operators are used at the same level.
21
+ * @throws {Error} If a property cannot be mapped to a column.
22
+ * @throws {Error} If an unsupported query type is encountered.
23
+ */
6
24
  export function convertQuery(query, table, columnDefinitionsMap) {
25
+ // If the query is already a Drizzle SQL object, return it directly.
7
26
  if (query instanceof SQL) {
8
27
  return query;
9
28
  }
29
+ // If the query is a SQLWrapper, convert it to a Drizzle SQL object.
10
30
  if (isSQLWrapper(query)) {
11
31
  return sql `${query}`;
12
32
  }
13
33
  const queryEntries = objectEntries(query);
34
+ // If the query object is empty, return true.
14
35
  if (queryEntries.length == 0) {
15
36
  return sqlTrue;
16
37
  }
17
38
  const conditions = [];
18
39
  for (const [property, value] of queryEntries) {
40
+ // Handle logical AND operator
19
41
  if (property == '$and') {
20
42
  if (queryEntries.length > 1) {
21
43
  throw new Error('only one logical operator per level allowed');
22
44
  }
23
45
  const andQuery = and(...query.$and.map((item) => convertQuery(item, table, columnDefinitionsMap)));
46
+ // If $and array is empty or results in no conditions, return true.
24
47
  if (isUndefined(andQuery)) {
25
48
  return sqlTrue;
26
49
  }
27
50
  return andQuery;
28
51
  }
52
+ // Handle logical OR operator
29
53
  if (property == '$or') {
30
54
  if (queryEntries.length > 1) {
31
55
  throw new Error('only one logical operator per level allowed');
32
56
  }
33
57
  const orQuery = or(...query.$or.map((item) => convertQuery(item, table, columnDefinitionsMap)));
58
+ // If $or array is empty or results in no conditions, return true.
34
59
  if (isUndefined(orQuery)) {
35
60
  return sqlTrue;
36
61
  }
37
62
  return orQuery;
38
63
  }
64
+ // Handle logical NOR operator
39
65
  if (property == '$nor') {
40
66
  if (queryEntries.length > 1) {
41
67
  throw new Error('only one logical operator per level allowed');
42
68
  }
43
69
  const orQuery = or(...query.$nor.map((item) => convertQuery(item, table, columnDefinitionsMap)));
70
+ // If $nor array is empty or results in no conditions, return true (NOT false -> true).
44
71
  if (isUndefined(orQuery)) {
45
72
  return sqlTrue;
46
73
  }
47
74
  return not(orQuery);
48
75
  }
76
+ // Map property name to column definition and get the Drizzle column object.
49
77
  const columnDef = assertDefinedPass(columnDefinitionsMap.get(property), `Could not map property ${property} to column.`);
50
78
  const column = table[columnDef.name];
79
+ // Get the condition for the current property and value.
51
80
  const condition = getCondition(property, value, column);
52
81
  conditions.push(condition);
53
82
  }
83
+ // Combine all conditions with AND.
54
84
  return and(...conditions);
55
85
  }
86
+ /**
87
+ * Generates a Drizzle SQL condition based on a property, its value, and the corresponding column.
88
+ * Handles various comparison operators.
89
+ * @param property The property name (used for error messages).
90
+ * @param value The value or comparison object for the property.
91
+ * @param column The Drizzle column object.
92
+ * @returns A Drizzle SQL condition.
93
+ * @throws {NotSupportedError} If an unsupported operator like $exists, $text, $geoShape, or $geoDistance is used.
94
+ * @throws {Error} If the value structure is not a recognized comparison operator.
95
+ */
56
96
  function getCondition(property, value, column) {
57
97
  const isPrimitiveValue = isPrimitive(value);
98
+ // Handle equality ($eq or direct primitive value)
58
99
  if (isPrimitiveValue || hasOwnProperty(value, '$eq')) {
59
100
  const queryValue = isPrimitiveValue ? value : value.$eq;
60
101
  if (queryValue === null) {
61
- return isNull(column);
102
+ return isNull(column); // IS NULL
62
103
  }
63
- return eq(column, queryValue);
104
+ return eq(column, queryValue); // = value
64
105
  }
106
+ // Handle inequality ($neq)
65
107
  if (hasOwnProperty(value, '$neq')) {
66
108
  const queryValue = value.$neq;
67
109
  if (queryValue === null) {
68
- return isNotNull(column);
110
+ return isNotNull(column); // IS NOT NULL
69
111
  }
70
- return ne(column, queryValue);
112
+ return ne(column, queryValue); // != value
71
113
  }
114
+ // $exists is not supported
72
115
  if (hasOwnProperty(value, '$exists')) {
73
116
  throw new NotSupportedError('$exists is not supported.');
74
117
  }
118
+ // Handle $in operator
75
119
  if (hasOwnProperty(value, '$in')) {
76
120
  const queryValue = value.$in;
77
- return inArray(column, queryValue);
121
+ return inArray(column, queryValue); // IN (values)
78
122
  }
123
+ // Handle $nin operator
79
124
  if (hasOwnProperty(value, '$nin')) {
80
125
  const queryValue = value.$nin;
81
- return notInArray(column, queryValue);
126
+ return notInArray(column, queryValue); // NOT IN (values)
82
127
  }
128
+ // Handle $lt operator
83
129
  if (hasOwnProperty(value, '$lt')) {
84
130
  const queryValue = value.$lt;
85
- return lt(column, queryValue);
131
+ return lt(column, queryValue); // < value
86
132
  }
133
+ // Handle $lte operator
87
134
  if (hasOwnProperty(value, '$lte')) {
88
135
  const queryValue = value.$lte;
89
- return lte(column, queryValue);
136
+ return lte(column, queryValue); // <= value
90
137
  }
138
+ // Handle $gt operator
91
139
  if (hasOwnProperty(value, '$gt')) {
92
140
  const queryValue = value.$gt;
93
- return gt(column, queryValue);
141
+ return gt(column, queryValue); // > value
94
142
  }
143
+ // Handle $gte operator
95
144
  if (hasOwnProperty(value, '$gte')) {
96
145
  const queryValue = value.$gte;
97
- return gte(column, queryValue);
146
+ return gte(column, queryValue); // >= value
98
147
  }
148
+ // Handle $regex operator (using PostgreSQL regexp_like)
99
149
  if (hasOwnProperty(value, '$regex')) {
100
150
  const queryValue = value.$regex;
151
+ // Normalize RegExp or string input
101
152
  const regexp = isString(queryValue)
102
153
  ? ({ value: queryValue })
103
154
  : isRegExp(queryValue)
104
155
  ? ({ flags: queryValue.flags, value: queryValue.source })
105
156
  : ({ flags: queryValue.flags, value: queryValue.pattern });
106
- return sql `regexp_like(${column}, ${regexp.value}, ${regexp.flags})`;
157
+ return sql `regexp_like(${column}, ${regexp.value}, ${regexp.flags})`; // Uses regexp_like function
107
158
  }
159
+ // $text is not supported
108
160
  if (hasOwnProperty(value, '$text')) {
109
161
  throw new NotSupportedError('$text is not supported.');
110
162
  }
163
+ // $geoShape is not supported
111
164
  if (hasOwnProperty(value, '$geoShape')) {
112
165
  throw new NotSupportedError('$geoShape is not supported.');
113
166
  }
167
+ // $geoDistance is not supported
114
168
  if (hasOwnProperty(value, '$geoDistance')) {
115
169
  throw new NotSupportedError('$geoDistance is not supported.');
116
170
  }
171
+ // Throw if the query structure is unrecognized
117
172
  throw new Error(`Unsupported query type "${property}".`);
118
173
  }