@tstdl/base 0.93.87 → 0.93.89

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 (314) hide show
  1. package/ai/genkit/helpers.d.ts +3 -1
  2. package/ai/genkit/helpers.js +3 -3
  3. package/api/server/gateway.d.ts +3 -0
  4. package/api/server/gateway.js +15 -4
  5. package/api/server/middlewares/catch-error.middleware.js +2 -4
  6. package/api/server/middlewares/cors.middleware.js +2 -3
  7. package/api/server/middlewares/csrf.middleware.d.ts +41 -0
  8. package/api/server/middlewares/csrf.middleware.js +108 -0
  9. package/api/server/middlewares/index.d.ts +1 -0
  10. package/api/server/middlewares/index.js +1 -0
  11. package/api/server/module.d.ts +8 -2
  12. package/api/server/module.js +14 -8
  13. package/api/server/tests/csrf.middleware.test.js +91 -0
  14. package/audit/drizzle/{0000_bored_stick.sql → 0000_lumpy_thunderball.sql} +3 -3
  15. package/audit/drizzle/meta/0000_snapshot.json +4 -4
  16. package/audit/drizzle/meta/_journal.json +2 -9
  17. package/audit/module.d.ts +4 -1
  18. package/audit/module.js +3 -2
  19. package/audit/schemas.d.ts +1 -1
  20. package/audit/types.d.ts +1 -1
  21. package/audit/types.js +1 -1
  22. package/authentication/client/authentication.service.d.ts +14 -1
  23. package/authentication/client/authentication.service.js +82 -23
  24. package/authentication/client/http-client.middleware.d.ts +6 -0
  25. package/authentication/client/http-client.middleware.js +36 -0
  26. package/authentication/client/module.js +8 -2
  27. package/authentication/models/service-account.model.d.ts +2 -2
  28. package/authentication/models/service-account.model.js +10 -5
  29. package/authentication/models/subject.model.d.ts +19 -5
  30. package/authentication/models/subject.model.js +25 -29
  31. package/authentication/models/system-account.model.d.ts +3 -2
  32. package/authentication/models/system-account.model.js +11 -5
  33. package/authentication/models/user.model.d.ts +2 -11
  34. package/authentication/models/user.model.js +5 -16
  35. package/authentication/server/authentication-api-request-token.provider.d.ts +0 -2
  36. package/authentication/server/authentication-api-request-token.provider.js +3 -11
  37. package/authentication/server/authentication.api-controller.d.ts +1 -2
  38. package/authentication/server/authentication.api-controller.js +8 -9
  39. package/authentication/server/authentication.audit.d.ts +3 -2
  40. package/authentication/server/authentication.service.d.ts +27 -1
  41. package/authentication/server/authentication.service.js +67 -18
  42. package/authentication/server/drizzle/{0000_normal_paper_doll.sql → 0000_soft_tag.sql} +25 -32
  43. package/authentication/server/drizzle/meta/0000_snapshot.json +180 -205
  44. package/authentication/server/drizzle/meta/_journal.json +2 -2
  45. package/authentication/server/helper.js +9 -2
  46. package/authentication/server/module.d.ts +4 -1
  47. package/authentication/server/module.js +9 -5
  48. package/authentication/server/schemas.d.ts +2 -1
  49. package/authentication/server/schemas.js +2 -2
  50. package/authentication/server/subject.service.d.ts +14 -8
  51. package/authentication/server/subject.service.js +86 -84
  52. package/authentication/tests/authentication-ancillary.service.test.d.ts +1 -0
  53. package/authentication/tests/authentication-ancillary.service.test.js +13 -0
  54. package/authentication/tests/authentication-secret-requirements.validator.test.d.ts +1 -0
  55. package/authentication/tests/authentication-secret-requirements.validator.test.js +29 -0
  56. package/authentication/tests/authentication.api-controller.test.d.ts +1 -0
  57. package/authentication/tests/authentication.api-controller.test.js +88 -0
  58. package/authentication/tests/authentication.api-request-token.provider.test.d.ts +1 -0
  59. package/authentication/tests/authentication.api-request-token.provider.test.js +48 -0
  60. package/authentication/tests/authentication.client-middleware.test.d.ts +1 -0
  61. package/authentication/tests/authentication.client-middleware.test.js +23 -0
  62. package/authentication/tests/authentication.client-service.test.d.ts +1 -0
  63. package/authentication/tests/authentication.client-service.test.js +70 -0
  64. package/authentication/tests/authentication.service.test.d.ts +1 -0
  65. package/authentication/tests/authentication.service.test.js +186 -0
  66. package/authentication/tests/authentication.test-ancillary-service.d.ts +9 -0
  67. package/authentication/tests/authentication.test-ancillary-service.js +27 -0
  68. package/authentication/tests/helper.test.d.ts +1 -0
  69. package/authentication/tests/helper.test.js +107 -0
  70. package/authentication/tests/secret-requirements.error.test.d.ts +1 -0
  71. package/authentication/tests/secret-requirements.error.test.js +14 -0
  72. package/authentication/tests/subject.service.test.d.ts +1 -0
  73. package/authentication/tests/subject.service.test.js +140 -0
  74. package/circuit-breaker/postgres/drizzle/meta/0000_snapshot.json +1 -1
  75. package/circuit-breaker/postgres/drizzle/meta/_journal.json +2 -2
  76. package/circuit-breaker/postgres/module.d.ts +7 -1
  77. package/circuit-breaker/postgres/module.js +8 -6
  78. package/circuit-breaker/tests/circuit-breaker.test.js +2 -22
  79. package/document-management/api/document-management.api.js +2 -6
  80. package/document-management/server/services/document-validation.service.js +6 -5
  81. package/document-management/server/services/document-workflow.service.js +5 -5
  82. package/document-management/service-models/document-folders.view-model.d.ts +5 -2
  83. package/document-management/service-models/document-folders.view-model.js +42 -9
  84. package/document-management/service-models/enriched/enriched-document-management-data.view.js +1 -1
  85. package/examples/document-management/main.js +4 -4
  86. package/http/client/adapters/undici.adapter.d.ts +7 -5
  87. package/http/client/adapters/undici.adapter.js +13 -10
  88. package/http/client/module.d.ts +3 -1
  89. package/http/client/module.js +8 -9
  90. package/http/server/http-server.d.ts +2 -0
  91. package/http/server/node/module.d.ts +6 -2
  92. package/http/server/node/module.js +6 -4
  93. package/http/server/node/node-http-server.d.ts +2 -0
  94. package/http/server/node/node-http-server.js +7 -0
  95. package/http/types.d.ts +1 -1
  96. package/key-value-store/postgres/module.d.ts +7 -1
  97. package/key-value-store/postgres/module.js +7 -3
  98. package/lock/postgres/lock.js +0 -1
  99. package/lock/postgres/module.d.ts +7 -1
  100. package/lock/postgres/module.js +9 -5
  101. package/logger/formatter.d.ts +2 -0
  102. package/logger/formatters/json.js +2 -2
  103. package/logger/formatters/pretty-print.js +8 -10
  104. package/logger/logger.d.ts +1 -1
  105. package/logger/logger.js +15 -12
  106. package/message-bus/local/module.d.ts +5 -2
  107. package/message-bus/local/module.js +5 -4
  108. package/module/module.d.ts +2 -1
  109. package/module/module.js +3 -0
  110. package/module/modules/web-server.module.d.ts +11 -6
  111. package/module/modules/web-server.module.js +15 -10
  112. package/orm/decorators.d.ts +24 -1
  113. package/orm/decorators.js +40 -4
  114. package/orm/query/base.d.ts +17 -17
  115. package/orm/query/base.js +1 -1
  116. package/orm/repository.types.d.ts +45 -1
  117. package/orm/schemas/tsvector.js +1 -1
  118. package/orm/server/drizzle/schema-converter.d.ts +3 -1
  119. package/orm/server/drizzle/schema-converter.js +120 -14
  120. package/orm/server/index.d.ts +1 -0
  121. package/orm/server/index.js +1 -0
  122. package/orm/server/module.d.ts +4 -2
  123. package/orm/server/module.js +6 -5
  124. package/orm/server/query-converter.d.ts +6 -3
  125. package/orm/server/query-converter.js +32 -20
  126. package/orm/server/repository-config.d.ts +8 -0
  127. package/orm/server/repository-config.js +8 -0
  128. package/orm/server/repository.d.ts +117 -43
  129. package/orm/server/repository.js +757 -253
  130. package/orm/server/transaction.d.ts +4 -2
  131. package/orm/server/transaction.js +14 -5
  132. package/orm/server/transactional.d.ts +6 -2
  133. package/orm/server/transactional.js +39 -9
  134. package/orm/server/types.d.ts +2 -0
  135. package/orm/sqls/case-when.d.ts +3 -3
  136. package/orm/sqls/case-when.js +2 -2
  137. package/orm/sqls/sqls.d.ts +31 -5
  138. package/orm/sqls/sqls.js +69 -6
  139. package/orm/tests/data-types.test.d.ts +1 -0
  140. package/orm/tests/data-types.test.js +39 -0
  141. package/orm/tests/decorators.test.d.ts +1 -0
  142. package/orm/tests/decorators.test.js +77 -0
  143. package/orm/tests/encryption.test.d.ts +1 -0
  144. package/orm/tests/encryption.test.js +34 -0
  145. package/orm/tests/query-complex.test.d.ts +1 -0
  146. package/orm/tests/query-complex.test.js +203 -0
  147. package/orm/tests/query-converter-complex.test.d.ts +1 -0
  148. package/orm/tests/query-converter-complex.test.js +126 -0
  149. package/orm/tests/query-converter.test.d.ts +1 -0
  150. package/orm/tests/query-converter.test.js +123 -0
  151. package/orm/tests/repository-advanced.test.d.ts +1 -0
  152. package/orm/tests/repository-advanced.test.js +232 -0
  153. package/orm/tests/repository-attributes.test.d.ts +1 -0
  154. package/orm/tests/repository-attributes.test.js +99 -0
  155. package/orm/tests/repository-comprehensive.test.d.ts +1 -0
  156. package/orm/tests/repository-comprehensive.test.js +187 -0
  157. package/orm/tests/repository-coverage.test.d.ts +1 -0
  158. package/orm/tests/repository-coverage.test.js +303 -0
  159. package/orm/tests/repository-cti-complex.test.d.ts +1 -0
  160. package/orm/tests/repository-cti-complex.test.js +170 -0
  161. package/orm/tests/repository-cti-embedded.test.d.ts +1 -0
  162. package/orm/tests/repository-cti-embedded.test.js +188 -0
  163. package/orm/tests/repository-cti-extensive.test.d.ts +1 -0
  164. package/orm/tests/repository-cti-extensive.test.js +308 -0
  165. package/orm/tests/repository-cti-mapping.test.d.ts +1 -0
  166. package/orm/tests/repository-cti-mapping.test.js +121 -0
  167. package/orm/tests/repository-cti-search.test.d.ts +1 -0
  168. package/orm/tests/repository-cti-search.test.js +152 -0
  169. package/orm/tests/repository-cti-soft-delete.test.d.ts +1 -0
  170. package/orm/tests/repository-cti-soft-delete.test.js +115 -0
  171. package/orm/tests/repository-cti-transactions.test.d.ts +1 -0
  172. package/orm/tests/repository-cti-transactions.test.js +126 -0
  173. package/orm/tests/repository-cti-upsert-many.test.d.ts +1 -0
  174. package/orm/tests/repository-cti-upsert-many.test.js +127 -0
  175. package/orm/tests/repository-cti.test.d.ts +1 -0
  176. package/orm/tests/repository-cti.test.js +456 -0
  177. package/orm/tests/repository-edge-cases.test.d.ts +1 -0
  178. package/orm/tests/repository-edge-cases.test.js +216 -0
  179. package/orm/tests/repository-expiration.test.d.ts +1 -0
  180. package/orm/tests/repository-expiration.test.js +153 -0
  181. package/orm/tests/repository-extra-coverage.test.d.ts +1 -0
  182. package/orm/tests/repository-extra-coverage.test.js +546 -0
  183. package/orm/tests/repository-mapping.test.d.ts +1 -0
  184. package/orm/tests/repository-mapping.test.js +71 -0
  185. package/orm/tests/repository-regression.test.d.ts +1 -0
  186. package/orm/tests/repository-regression.test.js +330 -0
  187. package/orm/tests/repository-search-coverage.test.d.ts +1 -0
  188. package/orm/tests/repository-search-coverage.test.js +129 -0
  189. package/orm/tests/repository-search.test.d.ts +1 -0
  190. package/orm/tests/repository-search.test.js +116 -0
  191. package/orm/tests/repository-soft-delete.test.d.ts +1 -0
  192. package/orm/tests/repository-soft-delete.test.js +143 -0
  193. package/orm/tests/repository-transactions-nested.test.d.ts +1 -0
  194. package/orm/tests/repository-transactions-nested.test.js +202 -0
  195. package/orm/tests/repository-types.test.d.ts +1 -0
  196. package/orm/tests/repository-types.test.js +218 -0
  197. package/orm/tests/schema-converter.test.d.ts +1 -0
  198. package/orm/tests/schema-converter.test.js +81 -0
  199. package/orm/tests/schema-generation.test.d.ts +1 -0
  200. package/orm/tests/schema-generation.test.js +127 -0
  201. package/orm/tests/sql-helpers.test.d.ts +1 -0
  202. package/orm/tests/sql-helpers.test.js +67 -0
  203. package/orm/tests/transaction-safety.test.d.ts +1 -0
  204. package/orm/tests/transaction-safety.test.js +81 -0
  205. package/orm/tests/transactional.test.d.ts +1 -0
  206. package/orm/tests/transactional.test.js +224 -0
  207. package/orm/tests/utils.test.d.ts +1 -0
  208. package/orm/tests/utils.test.js +70 -0
  209. package/orm/utils.d.ts +7 -0
  210. package/orm/utils.js +26 -6
  211. package/package.json +12 -7
  212. package/pool/pool.js +1 -1
  213. package/rate-limit/index.d.ts +2 -0
  214. package/rate-limit/index.js +2 -0
  215. package/rate-limit/postgres/drizzle/0000_watery_rage.sql +7 -0
  216. package/{queue → rate-limit}/postgres/drizzle/meta/0000_snapshot.json +14 -39
  217. package/rate-limit/postgres/drizzle/meta/_journal.json +13 -0
  218. package/{queue → rate-limit}/postgres/drizzle.config.js +1 -1
  219. package/rate-limit/postgres/index.d.ts +4 -0
  220. package/rate-limit/postgres/index.js +4 -0
  221. package/rate-limit/postgres/module.d.ts +12 -0
  222. package/rate-limit/postgres/module.js +28 -0
  223. package/rate-limit/postgres/postgres-rate-limiter.d.ts +9 -0
  224. package/rate-limit/postgres/postgres-rate-limiter.js +56 -0
  225. package/rate-limit/postgres/rate-limit.model.d.ts +8 -0
  226. package/rate-limit/postgres/rate-limit.model.js +35 -0
  227. package/rate-limit/postgres/rate-limiter.provider.d.ts +6 -0
  228. package/rate-limit/postgres/rate-limiter.provider.js +21 -0
  229. package/rate-limit/postgres/schemas.d.ts +3 -0
  230. package/rate-limit/postgres/schemas.js +4 -0
  231. package/rate-limit/provider.d.ts +9 -0
  232. package/rate-limit/provider.js +2 -0
  233. package/rate-limit/rate-limiter.d.ts +35 -0
  234. package/rate-limit/rate-limiter.js +3 -0
  235. package/rate-limit/tests/postgres-rate-limiter.test.d.ts +1 -0
  236. package/rate-limit/tests/postgres-rate-limiter.test.js +92 -0
  237. package/signals/implementation/configure.d.ts +3 -0
  238. package/signals/implementation/configure.js +3 -0
  239. package/sse/data-stream-source.d.ts +1 -1
  240. package/sse/data-stream-source.js +6 -6
  241. package/task-queue/enqueue-batch.d.ts +17 -0
  242. package/task-queue/enqueue-batch.js +24 -0
  243. package/{queue → task-queue}/index.d.ts +1 -1
  244. package/{queue → task-queue}/index.js +1 -1
  245. package/task-queue/postgres/drizzle/0000_thin_black_panther.sql +74 -0
  246. package/task-queue/postgres/drizzle/meta/0000_snapshot.json +592 -0
  247. package/task-queue/postgres/drizzle/meta/_journal.json +13 -0
  248. package/task-queue/postgres/drizzle.config.d.ts +2 -0
  249. package/task-queue/postgres/drizzle.config.js +11 -0
  250. package/task-queue/postgres/index.d.ts +4 -0
  251. package/task-queue/postgres/index.js +4 -0
  252. package/task-queue/postgres/module.d.ts +12 -0
  253. package/task-queue/postgres/module.js +28 -0
  254. package/task-queue/postgres/schemas.d.ts +16 -0
  255. package/task-queue/postgres/schemas.js +8 -0
  256. package/task-queue/postgres/task-queue.d.ts +83 -0
  257. package/task-queue/postgres/task-queue.js +1054 -0
  258. package/task-queue/postgres/task-queue.provider.d.ts +7 -0
  259. package/{queue/postgres/queue.provider.js → task-queue/postgres/task-queue.provider.js} +8 -8
  260. package/task-queue/postgres/task.model.d.ts +39 -0
  261. package/task-queue/postgres/task.model.js +178 -0
  262. package/{queue → task-queue}/provider.d.ts +3 -3
  263. package/task-queue/provider.js +2 -0
  264. package/{queue → task-queue}/task-context.d.ts +7 -7
  265. package/{queue → task-queue}/task-context.js +8 -8
  266. package/{queue/queue.d.ts → task-queue/task-queue.d.ts} +128 -59
  267. package/task-queue/task-queue.js +200 -0
  268. package/task-queue/tests/complex.test.d.ts +1 -0
  269. package/task-queue/tests/complex.test.js +299 -0
  270. package/task-queue/tests/dependencies.test.d.ts +1 -0
  271. package/task-queue/tests/dependencies.test.js +174 -0
  272. package/task-queue/tests/queue.test.d.ts +1 -0
  273. package/task-queue/tests/queue.test.js +334 -0
  274. package/task-queue/tests/worker.test.d.ts +1 -0
  275. package/task-queue/tests/worker.test.js +163 -0
  276. package/test1.js +1 -1
  277. package/test4.js +2 -2
  278. package/unit-test/index.d.ts +1 -0
  279. package/unit-test/index.js +1 -0
  280. package/unit-test/integration-setup.d.ts +55 -0
  281. package/unit-test/integration-setup.js +182 -0
  282. package/utils/patterns.d.ts +3 -0
  283. package/utils/patterns.js +6 -1
  284. package/audit/drizzle/0001_previous_network.sql +0 -2
  285. package/audit/drizzle/meta/0001_snapshot.json +0 -195
  286. package/queue/enqueue-batch.d.ts +0 -17
  287. package/queue/enqueue-batch.js +0 -18
  288. package/queue/postgres/drizzle/0000_zippy_moondragon.sql +0 -11
  289. package/queue/postgres/drizzle/0001_certain_wild_pack.sql +0 -2
  290. package/queue/postgres/drizzle/0002_dear_meggan.sql +0 -2
  291. package/queue/postgres/drizzle/0003_tricky_venom.sql +0 -30
  292. package/queue/postgres/drizzle/meta/0001_snapshot.json +0 -103
  293. package/queue/postgres/drizzle/meta/0002_snapshot.json +0 -90
  294. package/queue/postgres/drizzle/meta/0003_snapshot.json +0 -288
  295. package/queue/postgres/drizzle/meta/_journal.json +0 -34
  296. package/queue/postgres/index.d.ts +0 -4
  297. package/queue/postgres/index.js +0 -4
  298. package/queue/postgres/module.d.ts +0 -9
  299. package/queue/postgres/module.js +0 -29
  300. package/queue/postgres/queue.d.ts +0 -60
  301. package/queue/postgres/queue.js +0 -681
  302. package/queue/postgres/queue.provider.d.ts +0 -7
  303. package/queue/postgres/schemas.d.ts +0 -14
  304. package/queue/postgres/schemas.js +0 -6
  305. package/queue/postgres/task.model.d.ts +0 -24
  306. package/queue/postgres/task.model.js +0 -115
  307. package/queue/provider.js +0 -2
  308. package/queue/queue.js +0 -131
  309. package/queue/tests/queue.test.js +0 -623
  310. package/test3.d.ts +0 -1
  311. package/test3.js +0 -47
  312. /package/{queue/tests/queue.test.d.ts → api/server/tests/csrf.middleware.test.d.ts} +0 -0
  313. /package/circuit-breaker/postgres/drizzle/{0000_hard_shocker.sql → 0000_cooing_korath.sql} +0 -0
  314. /package/{queue → rate-limit}/postgres/drizzle.config.d.ts +0 -0
@@ -14,7 +14,7 @@ import { injectionToken } from '../../../injector/token.js';
14
14
  import { Logger } from '../../../logger/logger.js';
15
15
  import { getEntityIds } from '../../../orm/index.js';
16
16
  import { injectRepository } from '../../../orm/server/index.js';
17
- import { Queue } from '../../../queue/queue.js';
17
+ import { TaskQueue, TaskResult } from '../../../task-queue/task-queue.js';
18
18
  import { currentTimestamp } from '../../../utils/date-time.js';
19
19
  import { isNull, isUndefined } from '../../../utils/type-guards.js';
20
20
  import { millisecondsPerMinute } from '../../../utils/units.js';
@@ -37,7 +37,7 @@ let DocumentValidationService = DocumentValidationService_1 = class DocumentVali
37
37
  #validationExecutionService = injectRepository(DocumentValidationExecution);
38
38
  #validationExecutionRelatedDocumentService = injectRepository(DocumentValidationExecutionRelatedDocument);
39
39
  #documentTypeValidationService = injectRepository(DocumentTypeValidation);
40
- #queue = inject((Queue), { name: 'DocumentManagement: validation', processTimeout: 5 * millisecondsPerMinute, maxTries: 3 });
40
+ #taskQueue = inject((TaskQueue), { namespace: 'DocumentManagement:validation', visibilityTimeout: 5 * millisecondsPerMinute, maxTries: 3 });
41
41
  #executors = injectAll(DOCUMENT_VALIDATION_EXECUTORS);
42
42
  #logger = inject(Logger, DocumentValidationService_1.name);
43
43
  #executorMap = new Map(this.#executors.map((executor) => [executor.identifier, executor]));
@@ -45,10 +45,11 @@ let DocumentValidationService = DocumentValidationService_1 = class DocumentVali
45
45
  this.processQueue(cancellationSignal);
46
46
  }
47
47
  processQueue(cancellationSignal) {
48
- this.#queue.process({ concurrency: 5, cancellationSignal }, async (job) => {
48
+ this.#taskQueue.process({ concurrency: 5, cancellationSignal }, async (job) => {
49
49
  this.#logger.verbose(`Processing validation execution "${job.data.executionId}"`);
50
50
  await this.processValidationExecution(job.data.tenantId, job.data.executionId);
51
- }, this.#logger);
51
+ return TaskResult.Complete();
52
+ });
52
53
  }
53
54
  async startValidationWorkflow(tenantId, documentId) {
54
55
  const document = await this.#documentService.loadByQuery({ tenantId, id: documentId });
@@ -69,7 +70,7 @@ let DocumentValidationService = DocumentValidationService_1 = class DocumentVali
69
70
  startedAt: null,
70
71
  completedAt: null,
71
72
  });
72
- await this.#queue.enqueue({ tenantId, executionId: execution.id });
73
+ await this.#taskQueue.enqueue('validate', { tenantId, executionId: execution.id });
73
74
  }
74
75
  }
75
76
  async setExecutionRunning(tenantId, executionId) {
@@ -13,7 +13,7 @@ import { inject } from '../../../injector/inject.js';
13
13
  import { afterResolve } from '../../../injector/interfaces.js';
14
14
  import { Logger } from '../../../logger/index.js';
15
15
  import { injectRepository, injectTransactional, Transactional } from '../../../orm/server/index.js';
16
- import { Queue } from '../../../queue/queue.js';
16
+ import { TaskQueue, TaskResult } from '../../../task-queue/task-queue.js';
17
17
  import { toArray } from '../../../utils/array/array.js';
18
18
  import { currentTimestamp } from '../../../utils/date-time.js';
19
19
  import { _throw } from '../../../utils/throw.js';
@@ -37,7 +37,7 @@ let DocumentWorkflowService = DocumentWorkflowService_1 = class DocumentWorkflow
37
37
  #documentAssignmentTaskRepository = injectRepository(DocumentAssignmentTask);
38
38
  #documentAssignmentScopeRepository = injectRepository(DocumentAssignmentScope);
39
39
  #observationService = inject(DocumentManagementObservationService);
40
- #queue = inject((Queue), { name: 'DocumentWorkflow', processTimeout: 5 * 60 * 1000, maxTries: 3 });
40
+ #taskQueue = inject((TaskQueue), { namespace: 'DocumentManagement:DocumentWorkflow', visibilityTimeout: 5 * 60 * 1000, maxTries: 3 });
41
41
  #logger = inject(Logger, DocumentWorkflowService_1.name);
42
42
  documentService = inject(DocumentService, undefined, { forwardRef: true });
43
43
  repository = injectRepository(DocumentWorkflow);
@@ -45,7 +45,7 @@ let DocumentWorkflowService = DocumentWorkflowService_1 = class DocumentWorkflow
45
45
  if (this.isInTransaction) {
46
46
  return;
47
47
  }
48
- this.#queue.process({ concurrency: 5, cancellationSignal }, async (taskContext) => await this.processWorkflowJob(taskContext), this.#logger);
48
+ this.#taskQueue.process({ concurrency: 5, cancellationSignal }, async (taskContext) => await this.processWorkflowJob(taskContext));
49
49
  }
50
50
  async loadLatestWorkflow(tenantId, documentId) {
51
51
  return await this.repository.loadByQuery({ tenantId, documentId }, { order: { 'metadata.createTimestamp': 'desc' } });
@@ -82,7 +82,7 @@ let DocumentWorkflowService = DocumentWorkflowService_1 = class DocumentWorkflow
82
82
  }
83
83
  async initiateWorkflow(tenantId, documentId, step) {
84
84
  const workflow = await this.repository.insert({ tenantId, documentId, step, state: 'pending', failReason: null, completeTimestamp: null, completeUserId: null });
85
- await this.#queue.enqueue({ workflowId: workflow.id });
85
+ await this.#taskQueue.enqueue('workflow', { workflowId: workflow.id });
86
86
  this.#observationService.documentChange(workflow.id, this.session);
87
87
  return workflow;
88
88
  }
@@ -109,7 +109,7 @@ let DocumentWorkflowService = DocumentWorkflowService_1 = class DocumentWorkflow
109
109
  else {
110
110
  await this.setWorkflowState(workflow.id, DocumentWorkflowState.Review);
111
111
  }
112
- await task.acknowledge();
112
+ return TaskResult.Complete();
113
113
  }
114
114
  catch (error) {
115
115
  if (task.triesLeft == 0) {
@@ -1,9 +1,12 @@
1
1
  import type { EnrichedDocumentManagementData } from './enriched/enriched-document-management-data.view.js';
2
2
  export type DocumentManagementFolder = {
3
3
  id: string;
4
- type: 'collection' | 'category' | 'virtual';
4
+ type: 'collection' | 'category' | 'collection-group';
5
5
  label: string;
6
6
  subFolders: DocumentManagementFolder[];
7
7
  };
8
- export declare function getDocumentManagementFolders(data: EnrichedDocumentManagementData): DocumentManagementFolder[];
8
+ export type GetDocumentManagementFoldersOptions = {
9
+ wrapCollections?: boolean;
10
+ };
11
+ export declare function getDocumentManagementFolders(data: EnrichedDocumentManagementData, options?: GetDocumentManagementFoldersOptions): DocumentManagementFolder[];
9
12
  export declare function getFlatFolders(folders: DocumentManagementFolder[]): DocumentManagementFolder[];
@@ -1,19 +1,52 @@
1
1
  import { isNotNull } from '../../utils/type-guards.js';
2
- export function getDocumentManagementFolders(data) {
3
- function getCategoryFolder(category) {
4
- const subFolders = category.children.map(getCategoryFolder).filter(isNotNull);
5
- const categoryFolder = {
2
+ export function getDocumentManagementFolders(data, options = {}) {
3
+ const { wrapCollections = (data.collections.length > 1) } = options;
4
+ function getCategoryFolder(category, collectionId) {
5
+ const subFolders = category.children.map((child) => getCategoryFolder(child, collectionId)).filter(isNotNull);
6
+ const documents = (collectionId == null)
7
+ ? category.documents
8
+ : category.documents.filter((document) => document.assignments.collections.some((assignment) => assignment.collection.id == collectionId));
9
+ if ((documents.length + subFolders.length) == 0) {
10
+ return null;
11
+ }
12
+ return {
6
13
  id: category.id,
7
14
  type: 'category',
8
15
  label: category.label,
9
16
  subFolders,
10
17
  };
11
- if ((category.documents.length + categoryFolder.subFolders.length) == 0) {
12
- return null;
13
- }
14
- return categoryFolder;
15
18
  }
16
- return data.rootCategories.map(getCategoryFolder).filter(isNotNull);
19
+ if (wrapCollections) {
20
+ return data.collectionGroups.flatMap((group) => {
21
+ const collectionFolders = group.collections.map((collection) => {
22
+ const subFolders = data.rootCategories.map((category) => getCategoryFolder(category, collection.id)).filter(isNotNull);
23
+ if (subFolders.length == 0) {
24
+ return null;
25
+ }
26
+ return {
27
+ id: collection.id,
28
+ type: 'collection',
29
+ label: collection.name,
30
+ subFolders,
31
+ };
32
+ }).filter(isNotNull);
33
+ if (collectionFolders.length == 0) {
34
+ return [];
35
+ }
36
+ if (group.group == null) {
37
+ return collectionFolders;
38
+ }
39
+ return [
40
+ {
41
+ id: `group:${group.group}`,
42
+ type: 'collection-group',
43
+ label: group.group,
44
+ subFolders: collectionFolders,
45
+ },
46
+ ];
47
+ });
48
+ }
49
+ return data.rootCategories.map((category) => getCategoryFolder(category)).filter(isNotNull);
17
50
  }
18
51
  export function getFlatFolders(folders) {
19
52
  return [...folders, ...folders.flatMap((folder) => getFlatFolders(folder.subFolders))];
@@ -56,7 +56,7 @@ export class EnrichedDocumentManagementData {
56
56
  return this.rawData.collections.map((collection) => collection.id);
57
57
  }
58
58
  get rootCollections() {
59
- return this.rootCollections.filter((collection) => isNull(collection.parent));
59
+ return this.collections.filter((collection) => isNull(collection.parentId));
60
60
  }
61
61
  get collections() {
62
62
  return this.rawData.collections.map((collection) => new EnrichedDocumentCollection(this, collection));
@@ -11,6 +11,7 @@ import { MockApiRequestTokenProvider } from '../../api/server/api-request-token.
11
11
  import { configureApiServer } from '../../api/server/module.js';
12
12
  import { Application } from '../../application/application.js';
13
13
  import { provideInitializer, provideModule, provideSignalHandler } from '../../application/index.js';
14
+ import { configurePostgresCircuitBreaker, migratePostgresCircuitBreaker } from '../../circuit-breaker/postgres/module.js';
14
15
  import { DocumentManagementAuthorizationService } from '../../document-management/index.js';
15
16
  import { configureDocumentManagement } from '../../document-management/server/configure.js';
16
17
  import { DocumentCategoryTypeService, DocumentCollectionService, DocumentManagementAncillaryService, DocumentManagementApiController, DocumentRequestService } from '../../document-management/server/index.js';
@@ -24,11 +25,10 @@ import { configureLocalMessageBus } from '../../message-bus/index.js';
24
25
  import { WebServerModule } from '../../module/index.js';
25
26
  import { configureS3ObjectStorage } from '../../object-storage/index.js';
26
27
  import { configureOrm } from '../../orm/server/index.js';
27
- import { configurePostgresQueue, migratePostgresQueueSchema } from '../../queue/postgres/index.js';
28
28
  import { configureDefaultSignalsImplementation } from '../../signals/implementation/configure.js';
29
+ import { configurePostgresTaskQueue, migratePostgresTaskQueueSchema } from '../../task-queue/postgres/index.js';
29
30
  import { boolean, positiveInteger, string } from '../../utils/config-parser.js';
30
31
  import { TstdlCategoryParents, TstdlDocumentCategoryLabels, TstdlDocumentPropertyConfiguration, TstdlDocumentTypeCategories, TstdlDocumentTypeLabels, TstdlDocumentTypeProperties } from './categories-and-types.js';
31
- import { configurePostgresCircuitBreaker, migratePostgresCircuitBreaker } from '../../circuit-breaker/postgres/module.js';
32
32
  const config = {
33
33
  database: {
34
34
  host: string('DATABASE_HOST', '127.0.0.1'),
@@ -87,7 +87,7 @@ export { AllowAllDocumentManagementAuthorizationService };
87
87
  async function bootstrap() {
88
88
  const injector = inject(Injector);
89
89
  configureNodeHttpServer();
90
- configurePostgresQueue();
90
+ configurePostgresTaskQueue();
91
91
  configurePostgresCircuitBreaker();
92
92
  configureLocalMessageBus();
93
93
  configureDefaultSignalsImplementation();
@@ -138,7 +138,7 @@ async function bootstrap() {
138
138
  });
139
139
  await runInInjectionContext(injector, migrateDocumentManagementSchema);
140
140
  await runInInjectionContext(injector, migratePostgresCircuitBreaker);
141
- await runInInjectionContext(injector, migratePostgresQueueSchema);
141
+ await runInInjectionContext(injector, migratePostgresTaskQueueSchema);
142
142
  }
143
143
  async function main() {
144
144
  const tenantId = '00000000-0000-0000-0000-000000000000';
@@ -1,20 +1,22 @@
1
1
  import type { Dispatcher } from 'undici';
2
2
  import type { Resolvable } from '../../../injector/index.js';
3
3
  import { resolveArgumentType } from '../../../injector/index.js';
4
+ import { Injector } from '../../../injector/injector.js';
4
5
  import type { HttpClientRequest } from '../http-client-request.js';
5
6
  import { HttpClientResponse } from '../http-client-response.js';
6
7
  import { HttpClientAdapter } from '../http-client.adapter.js';
7
- export type UndiciHttpClientAdapterOptions = {
8
+ export declare class UndiciHttpClientAdapterOptions {
8
9
  dispatcher?: Dispatcher;
9
- };
10
+ }
10
11
  export declare class UndiciHttpClientAdapter extends HttpClientAdapter implements Resolvable<UndiciHttpClientAdapterOptions> {
11
12
  private readonly options;
12
13
  readonly [resolveArgumentType]: UndiciHttpClientAdapterOptions;
13
14
  call(httpClientRequest: HttpClientRequest): Promise<HttpClientResponse>;
14
15
  }
15
16
  /**
16
- * @param register whether to register for {@link HttpClientAdapter}
17
+ * configure undici http client adapter module
18
+ * @param options adapter configuration
17
19
  */
18
- export declare function configureUndiciHttpClientAdapter(options?: UndiciHttpClientAdapterOptions & {
19
- register?: boolean;
20
+ export declare function configureUndiciHttpClientAdapter({ injector, ...options }?: UndiciHttpClientAdapterOptions & {
21
+ injector?: Injector;
20
22
  }): void;
@@ -8,15 +8,18 @@ import { Readable } from 'node:stream';
8
8
  import { request, errors as undiciErrors } from 'undici';
9
9
  import { HttpHeaders } from '../../../http/http-headers.js';
10
10
  import { HttpError, HttpErrorReason } from '../../../http/http.error.js';
11
- import { Singleton, injectArgument, resolveArgumentType } from '../../../injector/index.js';
11
+ import { Singleton, inject, resolveArgumentType } from '../../../injector/index.js';
12
12
  import { Injector } from '../../../injector/injector.js';
13
13
  import { toArray } from '../../../utils/array/array.js';
14
14
  import { isBlob, isDefined, isUint8Array } from '../../../utils/type-guards.js';
15
15
  import { HttpClientResponse } from '../http-client-response.js';
16
16
  import { HttpClientAdapter } from '../http-client.adapter.js';
17
- let defaultOptions = {};
17
+ export class UndiciHttpClientAdapterOptions {
18
+ dispatcher;
19
+ }
20
+ ;
18
21
  let UndiciHttpClientAdapter = class UndiciHttpClientAdapter extends HttpClientAdapter {
19
- options = injectArgument(this);
22
+ options = inject(UndiciHttpClientAdapterOptions, undefined, { optional: true }) ?? {};
20
23
  // eslint-disable-next-line max-lines-per-function, max-statements
21
24
  async call(httpClientRequest) {
22
25
  let body;
@@ -78,17 +81,17 @@ let UndiciHttpClientAdapter = class UndiciHttpClientAdapter extends HttpClientAd
78
81
  }
79
82
  };
80
83
  UndiciHttpClientAdapter = __decorate([
81
- Singleton({ defaultArgumentProvider: () => defaultOptions })
84
+ Singleton()
82
85
  ], UndiciHttpClientAdapter);
83
86
  export { UndiciHttpClientAdapter };
84
87
  /**
85
- * @param register whether to register for {@link HttpClientAdapter}
88
+ * configure undici http client adapter module
89
+ * @param options adapter configuration
86
90
  */
87
- export function configureUndiciHttpClientAdapter(options = {}) {
88
- defaultOptions = options;
89
- if (options.register ?? true) {
90
- Injector.register(HttpClientAdapter, { useToken: UndiciHttpClientAdapter });
91
- }
91
+ export function configureUndiciHttpClientAdapter({ injector, ...options } = {}) {
92
+ const targetInjector = injector ?? Injector;
93
+ targetInjector.register(UndiciHttpClientAdapterOptions, { useValue: options });
94
+ targetInjector.register(HttpClientAdapter, { useToken: UndiciHttpClientAdapter });
92
95
  }
93
96
  function getHttpErrorReason(error) {
94
97
  switch (error.code) {
@@ -1,3 +1,4 @@
1
+ import { Injector } from '../../injector/injector.js';
1
2
  import type { OneOrMany, Type } from '../../types/index.js';
2
3
  import { HttpClientOptions } from './http-client-options.js';
3
4
  import { HttpClientAdapter } from './http-client.adapter.js';
@@ -8,5 +9,6 @@ export type HttpClientModuleConfig = HttpClientOptions & {
8
9
  * Middlewares to add
9
10
  */
10
11
  middleware?: OneOrMany<HttpClientMiddleware>;
12
+ injector?: Injector;
11
13
  };
12
- export declare function configureHttpClient({ adapter, middleware, ...rest }: HttpClientModuleConfig): void;
14
+ export declare function configureHttpClient({ adapter, middleware, injector, ...rest }?: HttpClientModuleConfig): void;
@@ -4,20 +4,19 @@ import { isDefined } from '../../utils/type-guards.js';
4
4
  import { HttpClientOptions } from './http-client-options.js';
5
5
  import { HttpClientAdapter } from './http-client.adapter.js';
6
6
  import { HTTP_CLIENT_MIDDLEWARE } from './tokens.js';
7
- let options = {};
8
- export function configureHttpClient({ adapter, middleware, ...rest }) {
7
+ export function configureHttpClient({ adapter, middleware, injector, ...rest } = {}) {
8
+ const targetInjector = injector ?? Injector;
9
9
  if (isDefined(adapter)) {
10
- Injector.register(HttpClientAdapter, { useToken: adapter });
10
+ targetInjector.register(HttpClientAdapter, { useToken: adapter });
11
11
  }
12
- options = {
13
- ...options,
14
- baseUrl: rest.baseUrl ?? options.baseUrl,
15
- enableErrorHandling: rest.enableErrorHandling ?? options.enableErrorHandling
12
+ const options = {
13
+ baseUrl: rest.baseUrl,
14
+ enableErrorHandling: rest.enableErrorHandling,
16
15
  };
17
16
  if (isDefined(middleware)) {
18
17
  for (const m of toArray(middleware)) {
19
- Injector.register(HTTP_CLIENT_MIDDLEWARE, { useValue: m }, { multi: true });
18
+ targetInjector.register(HTTP_CLIENT_MIDDLEWARE, { useValue: m }, { multi: true });
20
19
  }
21
20
  }
22
- Injector.register(HttpClientOptions, { useValue: options });
21
+ targetInjector.register(HttpClientOptions, { useValue: options });
23
22
  }
@@ -7,6 +7,8 @@ export type HttpServerRequestContext<Context = unknown> = {
7
7
  };
8
8
  export declare abstract class HttpServer<Context = unknown> implements AsyncIterable<HttpServerRequestContext<Context>>, AsyncDisposable {
9
9
  abstract readonly connectedSocketsCount: number;
10
+ abstract readonly port: number;
11
+ abstract readonly address: string;
10
12
  abstract listen(port: number): Promise<void>;
11
13
  abstract close(timeout: number): Promise<void>;
12
14
  abstract [Symbol.asyncIterator](): AsyncIterator<HttpServerRequestContext<Context>>;
@@ -1,7 +1,11 @@
1
+ import { Injector } from '../../../injector/injector.js';
1
2
  export declare class NodeHttpServerConfiguration {
2
3
  trustedProxiesCount: number;
3
4
  }
4
5
  /**
5
- * registers {@link HttpServer} in global container
6
+ * registers {@link HttpServer} in container
7
+ * @param configuration server configuration
6
8
  */
7
- export declare function configureNodeHttpServer(configuration?: Partial<NodeHttpServerConfiguration>): void;
9
+ export declare function configureNodeHttpServer({ injector, ...configuration }?: Partial<NodeHttpServerConfiguration> & {
10
+ injector?: Injector;
11
+ }): void;
@@ -6,13 +6,15 @@ export class NodeHttpServerConfiguration {
6
6
  }
7
7
  ;
8
8
  /**
9
- * registers {@link HttpServer} in global container
9
+ * registers {@link HttpServer} in container
10
+ * @param configuration server configuration
10
11
  */
11
- export function configureNodeHttpServer(configuration = {}) {
12
- Injector.register(NodeHttpServerConfiguration, {
12
+ export function configureNodeHttpServer({ injector, ...configuration } = {}) {
13
+ const targetInjector = injector ?? Injector;
14
+ targetInjector.register(NodeHttpServerConfiguration, {
13
15
  useValue: {
14
16
  trustedProxiesCount: configuration.trustedProxiesCount ?? 0,
15
17
  },
16
18
  });
17
- Injector.registerSingleton(HttpServer, { useToken: NodeHttpServer });
19
+ targetInjector.registerSingleton(HttpServer, { useToken: NodeHttpServer });
18
20
  }
@@ -9,6 +9,8 @@ export declare class NodeHttpServer extends HttpServer<NodeHttpServerContext> im
9
9
  #private;
10
10
  private untrackConnectedSockets?;
11
11
  get connectedSocketsCount(): number;
12
+ get port(): number;
13
+ get address(): string;
12
14
  [afterResolve](): void;
13
15
  [Symbol.asyncDispose](): Promise<void>;
14
16
  listen(port: number): Promise<void>;
@@ -34,6 +34,12 @@ let NodeHttpServer = NodeHttpServer_1 = class NodeHttpServer extends HttpServer
34
34
  get connectedSocketsCount() {
35
35
  return this.#sockets.size;
36
36
  }
37
+ get port() {
38
+ return this.#httpServer.address().port;
39
+ }
40
+ get address() {
41
+ return this.#httpServer.address().address;
42
+ }
37
43
  [afterResolve]() {
38
44
  this.#httpServer.on('request', (request, response) => this.#requestIterable.feed({ request, response }));
39
45
  }
@@ -85,6 +91,7 @@ let NodeHttpServer = NodeHttpServer_1 = class NodeHttpServer extends HttpServer
85
91
  await cancelableTimeout(250, CancellationToken.from(close$));
86
92
  }
87
93
  }
94
+ this.#requestIterable.end();
88
95
  this.untrackConnectedSockets?.();
89
96
  this.untrackConnectedSockets = undefined;
90
97
  }
package/http/types.d.ts CHANGED
@@ -3,7 +3,7 @@ export type HttpValue = string | number | boolean | null;
3
3
  export type NormalizedHttpValue = string;
4
4
  export type HttpValueObject = Record<string, OneOrMany<HttpValue>>;
5
5
  export type NormalizedHttpValueObject = Record<string, WritableOneOrMany<string>>;
6
- export type HttpMethod = 'HEAD' | 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS';
6
+ export type HttpMethod = 'HEAD' | 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'TRACE';
7
7
  export declare function normalizeHttpValue(value: OneOrMany<HttpValue>): WritableOneOrMany<string>;
8
8
  export declare function normalizeSingleHttpValue(value: HttpValue): string;
9
9
  export declare function denormalizeHttpValue(value: OneOrMany<HttpValue>): OneOrMany<HttpValue>;
@@ -1,6 +1,12 @@
1
+ import { Injector } from '../../injector/index.js';
1
2
  import { type DatabaseConfig } from '../../orm/server/index.js';
2
3
  export declare class PostgresKeyValueStoreModuleConfig {
3
4
  database?: DatabaseConfig;
4
5
  }
5
- export declare function configurePostgresKeyValueStore(config?: PostgresKeyValueStoreModuleConfig): void;
6
+ /**
7
+ * configure key-value store module
8
+ */
9
+ export declare function configurePostgresKeyValueStore({ injector, ...config }?: PostgresKeyValueStoreModuleConfig & {
10
+ injector?: Injector;
11
+ }): void;
6
12
  export declare function migratePostgresKeyValueStoreSchema(): Promise<void>;
@@ -6,11 +6,15 @@ import { PostgresKeyValueStore } from './key-value-store.service.js';
6
6
  export class PostgresKeyValueStoreModuleConfig {
7
7
  database;
8
8
  }
9
- export function configurePostgresKeyValueStore(config) {
9
+ /**
10
+ * configure key-value store module
11
+ */
12
+ export function configurePostgresKeyValueStore({ injector, ...config } = {}) {
13
+ const targetInjector = injector ?? Injector;
10
14
  if (isDefined(config)) {
11
- Injector.register(PostgresKeyValueStoreModuleConfig, { useValue: config });
15
+ targetInjector.register(PostgresKeyValueStoreModuleConfig, { useValue: config });
12
16
  }
13
- Injector.registerSingleton(KeyValueStore, { useToken: PostgresKeyValueStore });
17
+ targetInjector.registerSingleton(KeyValueStore, { useToken: PostgresKeyValueStore });
14
18
  }
15
19
  export async function migratePostgresKeyValueStoreSchema() {
16
20
  const connection = inject(PostgresKeyValueStoreModuleConfig, undefined, { optional: true })?.database?.connection;
@@ -84,7 +84,6 @@ let PostgresLockAdapter = class PostgresLockAdapter extends Lock {
84
84
  setWhere: lte(lock.expiration, TRANSACTION_TIMESTAMP),
85
85
  })
86
86
  .returning({ expiration: lock.expiration });
87
- console.log(upsertQuery.toSQL());
88
87
  const [result] = await upsertQuery;
89
88
  if (isUndefined(result)) {
90
89
  return false;
@@ -1,6 +1,12 @@
1
+ import { Injector } from '../../injector/index.js';
1
2
  import { type DatabaseConfig } from '../../orm/server/index.js';
2
3
  export declare class PostgresLockModuleConfig {
3
4
  database?: DatabaseConfig;
4
5
  }
5
- export declare function configurePostgresLock(config?: PostgresLockModuleConfig): void;
6
+ /**
7
+ * configure lock module
8
+ */
9
+ export declare function configurePostgresLock({ injector, ...config }?: PostgresLockModuleConfig & {
10
+ injector?: Injector;
11
+ }): void;
6
12
  export declare function migratePostgresLockSchema(): Promise<void>;
@@ -3,17 +3,21 @@ import { Database, migrate } from '../../orm/server/index.js';
3
3
  import { isDefined } from '../../utils/type-guards.js';
4
4
  import { Lock } from '../lock.js';
5
5
  import { LockProvider } from '../provider.js';
6
- import { PostgresLockProvider } from './provider.js';
7
6
  import { PostgresLockAdapter } from './lock.js';
7
+ import { PostgresLockProvider } from './provider.js';
8
8
  export class PostgresLockModuleConfig {
9
9
  database;
10
10
  }
11
- export function configurePostgresLock(config) {
11
+ /**
12
+ * configure lock module
13
+ */
14
+ export function configurePostgresLock({ injector, ...config } = {}) {
15
+ const targetInjector = injector ?? Injector;
12
16
  if (isDefined(config)) {
13
- Injector.register(PostgresLockModuleConfig, { useValue: config });
17
+ targetInjector.register(PostgresLockModuleConfig, { useValue: config });
14
18
  }
15
- Injector.registerSingleton(LockProvider, { useToken: PostgresLockProvider });
16
- Injector.registerSingleton(Lock, { useToken: PostgresLockAdapter });
19
+ targetInjector.registerSingleton(LockProvider, { useToken: PostgresLockProvider });
20
+ targetInjector.registerSingleton(Lock, { useToken: PostgresLockAdapter });
17
21
  }
18
22
  export async function migratePostgresLockSchema() {
19
23
  const connection = inject(PostgresLockModuleConfig, undefined, { optional: true })?.database?.connection;
@@ -5,7 +5,9 @@ export type LogPayload = {
5
5
  level: LogLevel;
6
6
  module: string[];
7
7
  message: string;
8
+ interpolationKeys: string[];
8
9
  context: Record<string>;
10
+ error?: unknown;
9
11
  };
10
12
  /** Formats a log payload for a transport. */
11
13
  export declare abstract class LogFormatter {
@@ -21,8 +21,8 @@ let JsonLogFormatter = class JsonLogFormatter extends LogFormatter {
21
21
  ...payload.context,
22
22
  };
23
23
  // Special handling for error objects to make them serializable
24
- if (isNotNullOrUndefined(logObject['error'])) {
25
- logObject['error'] = formatError(logObject['error'], { includeStack: true });
24
+ if (isNotNullOrUndefined(payload.error)) {
25
+ logObject['error'] = formatError(payload.error, { includeStack: true });
26
26
  }
27
27
  return JSON.stringify(logObject);
28
28
  }
@@ -8,6 +8,7 @@ import { Singleton } from '../../injector/decorators.js';
8
8
  import { supportsColoredStdout } from '../../supports.js';
9
9
  import { enumValueName } from '../../utils/enum.js';
10
10
  import { formatError } from '../../utils/format-error.js';
11
+ import { objectKeys } from '../../utils/object/object.js';
11
12
  import { isNotNullOrUndefined } from '../../utils/type-guards.js';
12
13
  import { LogFormatter } from '../formatter.js';
13
14
  import { LogLevel } from '../level.js';
@@ -28,23 +29,20 @@ let PrettyPrintLogFormatter = class PrettyPrintLogFormatter extends LogFormatter
28
29
  const levelName = enumValueName(LogLevel, payload.level).toUpperCase();
29
30
  const levelString = `${levelName}:`.padEnd(8);
30
31
  const moduleString = payload.module.map((m) => `[${m}]`).join(' ');
31
- const metadata = { ...payload.context };
32
32
  let metadataString = '';
33
33
  let errorString = '';
34
- if (Object.keys(metadata).length > 0) {
34
+ if (objectKeys(payload.context).length > 0) {
35
35
  const displayMeta = {};
36
- // Don't display metadata used in interpolation
37
- const interpolationKeys = Array.from(payload.message.matchAll(/{([^{}]+)}/g)).map((match) => match[1]);
38
- for (const key in metadata) {
39
- if (!interpolationKeys.includes(key)) {
40
- displayMeta[key] = metadata[key];
36
+ for (const key in payload.context) {
37
+ if (!payload.interpolationKeys.includes(key)) {
38
+ displayMeta[key] = payload.context[key];
41
39
  }
42
40
  }
43
- if (Object.keys(displayMeta).length > 0) {
41
+ if (objectKeys(displayMeta).length > 0) {
44
42
  metadataString = ` ${dimColor}${JSON.stringify(displayMeta)}${resetColor}`;
45
43
  }
46
- if (isNotNullOrUndefined(metadata['error'])) {
47
- errorString += `\n${formatError(metadata['error'], { includeStack: true })}`;
44
+ if (isNotNullOrUndefined(payload.error)) {
45
+ errorString += `\n${formatError(payload.error, { includeStack: true })}`;
48
46
  }
49
47
  }
50
48
  return `${dimColor}${payload.timestamp.toISOString()}${resetColor} ${color}${levelString}${resetColor} ${moduleString}${moduleString.length > 0 ? ' ' : ''}${payload.message}${metadataString}${errorString}`;
@@ -18,7 +18,7 @@ export declare class Logger implements Resolvable<LoggerArgument> {
18
18
  readonly context: Record<string>;
19
19
  readonly level: LogLevel | undefined;
20
20
  readonly [resolveArgumentType]: LoggerArgument;
21
- error(message: string, context?: Record<string>): void;
21
+ error(message: string, error: unknown, context?: Record<string>): void;
22
22
  error(error: unknown, context?: Record<string>): void;
23
23
  warn(message: string, context?: Record<string>): void;
24
24
  info(message: string, context?: Record<string>): void;