@tstdl/base 0.93.182 → 0.93.184

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 (353) hide show
  1. package/api/server/api-request-token.provider.js +1 -1
  2. package/api/server/gateway.js +6 -1
  3. package/authentication/authentication.api.d.ts +13 -40
  4. package/authentication/authentication.api.js +5 -14
  5. package/authentication/client/authentication.service.d.ts +6 -14
  6. package/authentication/client/authentication.service.js +22 -4
  7. package/authentication/client/module.d.ts +1 -1
  8. package/authentication/client/module.js +4 -4
  9. package/authentication/models/index.d.ts +1 -0
  10. package/authentication/models/index.js +1 -0
  11. package/authentication/models/totp-results.model.d.ts +11 -0
  12. package/authentication/models/totp-results.model.js +37 -0
  13. package/authentication/server/authentication.api-controller.d.ts +3 -3
  14. package/authentication/server/authentication.api-controller.js +31 -4
  15. package/authentication/server/authentication.service.d.ts +5 -14
  16. package/authentication/server/authentication.service.js +6 -4
  17. package/core.d.ts +0 -5
  18. package/core.js +0 -8
  19. package/document-management/api/document-management.api.d.ts +2 -2
  20. package/document-management/service-models/document.service-model.d.ts +1 -1
  21. package/examples/config.d.ts +25 -0
  22. package/examples/config.js +26 -0
  23. package/notification/server/module.d.ts +1 -1
  24. package/notification/server/module.js +1 -1
  25. package/package.json +5 -5
  26. package/signals/api.d.ts +5 -1
  27. package/signals/api.js +3 -1
  28. package/signals/implementation/api.d.ts +10 -1
  29. package/signals/implementation/api.js +7 -1
  30. package/signals/implementation/asserts.d.ts +2 -2
  31. package/signals/implementation/asserts.js +3 -3
  32. package/signals/implementation/computed.d.ts +7 -34
  33. package/signals/implementation/computed.js +14 -83
  34. package/signals/implementation/configure.js +6 -2
  35. package/signals/implementation/effect.d.ts +65 -46
  36. package/signals/implementation/effect.js +97 -62
  37. package/signals/implementation/index.d.ts +2 -4
  38. package/signals/implementation/index.js +2 -4
  39. package/signals/implementation/linked_signal.d.ts +36 -0
  40. package/signals/implementation/linked_signal.js +34 -0
  41. package/signals/implementation/primitive/computed.d.ts +55 -0
  42. package/signals/implementation/primitive/computed.js +107 -0
  43. package/signals/implementation/primitive/effect.d.ts +26 -0
  44. package/signals/implementation/primitive/effect.js +31 -0
  45. package/signals/implementation/{equality.d.ts → primitive/equality.d.ts} +1 -1
  46. package/signals/implementation/{equality.js → primitive/equality.js} +1 -1
  47. package/signals/implementation/primitive/errors.d.ts +10 -0
  48. package/signals/implementation/{errors.js → primitive/errors.js} +3 -4
  49. package/signals/implementation/primitive/formatter.d.ts +19 -0
  50. package/signals/implementation/primitive/formatter.js +136 -0
  51. package/signals/implementation/{graph.d.ts → primitive/graph.d.ts} +68 -36
  52. package/signals/implementation/primitive/graph.js +386 -0
  53. package/signals/implementation/primitive/linked_signal.d.ts +46 -0
  54. package/signals/implementation/primitive/linked_signal.js +110 -0
  55. package/signals/implementation/primitive/signal.d.ts +31 -0
  56. package/signals/implementation/primitive/signal.js +80 -0
  57. package/signals/implementation/primitive/untracked.d.ts +12 -0
  58. package/signals/implementation/primitive/untracked.js +23 -0
  59. package/signals/implementation/{watch.d.ts → primitive/watch.d.ts} +1 -2
  60. package/signals/implementation/{watch.js → primitive/watch.js} +22 -16
  61. package/signals/implementation/resource/api.d.ts +275 -0
  62. package/signals/implementation/resource/api.js +26 -0
  63. package/signals/implementation/resource/debounce.d.ts +13 -0
  64. package/signals/implementation/resource/debounce.js +113 -0
  65. package/signals/implementation/resource/from_snapshots.d.ts +16 -0
  66. package/signals/implementation/resource/from_snapshots.js +44 -0
  67. package/signals/implementation/resource/index.d.ts +11 -0
  68. package/signals/implementation/resource/index.js +11 -0
  69. package/signals/implementation/resource/resource.d.ts +110 -0
  70. package/signals/implementation/resource/resource.js +402 -0
  71. package/signals/implementation/root_effect_scheduler.d.ts +50 -0
  72. package/signals/implementation/root_effect_scheduler.js +66 -0
  73. package/signals/implementation/signal.d.ts +42 -18
  74. package/signals/implementation/signal.js +29 -49
  75. package/signals/implementation/to-observable.d.ts +12 -5
  76. package/signals/implementation/to-observable.js +12 -2
  77. package/signals/implementation/to-signal.d.ts +9 -18
  78. package/signals/implementation/to-signal.js +46 -13
  79. package/signals/implementation/untracked.d.ts +1 -1
  80. package/signals/implementation/untracked.js +3 -11
  81. package/signals/operators/debounce.d.ts +8 -0
  82. package/signals/operators/debounce.js +19 -0
  83. package/signals/operators/derive-async.js +43 -15
  84. package/signals/operators/index.d.ts +2 -0
  85. package/signals/operators/index.js +2 -0
  86. package/signals/operators/throttle.d.ts +8 -0
  87. package/signals/operators/throttle.js +31 -0
  88. package/ai/genkit/tests/multi-region.test.d.ts +0 -2
  89. package/ai/genkit/tests/multi-region.test.js +0 -179
  90. package/ai/genkit/tests/token-limit-fallback.test.d.ts +0 -2
  91. package/ai/genkit/tests/token-limit-fallback.test.js +0 -209
  92. package/ai/prompts/tests/prompt-builder.test.d.ts +0 -1
  93. package/ai/prompts/tests/prompt-builder.test.js +0 -22
  94. package/ai/tests/instructions-formatter.test.d.ts +0 -1
  95. package/ai/tests/instructions-formatter.test.js +0 -116
  96. package/ai/tests/steering.test.d.ts +0 -1
  97. package/ai/tests/steering.test.js +0 -37
  98. package/api/client/tests/api-client.test.d.ts +0 -1
  99. package/api/client/tests/api-client.test.js +0 -194
  100. package/api/server/tests/csrf.middleware.test.d.ts +0 -1
  101. package/api/server/tests/csrf.middleware.test.js +0 -91
  102. package/authentication/tests/authentication-password-requirements.validator.test.d.ts +0 -1
  103. package/authentication/tests/authentication-password-requirements.validator.test.js +0 -29
  104. package/authentication/tests/authentication.api-controller.test.d.ts +0 -1
  105. package/authentication/tests/authentication.api-controller.test.js +0 -156
  106. package/authentication/tests/authentication.api-request-token.provider.test.d.ts +0 -1
  107. package/authentication/tests/authentication.api-request-token.provider.test.js +0 -48
  108. package/authentication/tests/authentication.client-error-handling.test.d.ts +0 -1
  109. package/authentication/tests/authentication.client-error-handling.test.js +0 -123
  110. package/authentication/tests/authentication.client-middleware.test.d.ts +0 -1
  111. package/authentication/tests/authentication.client-middleware.test.js +0 -118
  112. package/authentication/tests/authentication.client-service-methods.test.d.ts +0 -1
  113. package/authentication/tests/authentication.client-service-methods.test.js +0 -177
  114. package/authentication/tests/authentication.client-service-refresh.test.d.ts +0 -1
  115. package/authentication/tests/authentication.client-service-refresh.test.js +0 -153
  116. package/authentication/tests/authentication.client-service.test.d.ts +0 -1
  117. package/authentication/tests/authentication.client-service.test.js +0 -76
  118. package/authentication/tests/authentication.refresh-busy-loop.test.d.ts +0 -1
  119. package/authentication/tests/authentication.refresh-busy-loop.test.js +0 -84
  120. package/authentication/tests/authentication.service.test.d.ts +0 -1
  121. package/authentication/tests/authentication.service.test.js +0 -167
  122. package/authentication/tests/authentication.test-ancillary-service.d.ts +0 -9
  123. package/authentication/tests/authentication.test-ancillary-service.js +0 -27
  124. package/authentication/tests/brute-force-protection.test.d.ts +0 -1
  125. package/authentication/tests/brute-force-protection.test.js +0 -211
  126. package/authentication/tests/helper.test.d.ts +0 -1
  127. package/authentication/tests/helper.test.js +0 -122
  128. package/authentication/tests/password-requirements.error.test.d.ts +0 -1
  129. package/authentication/tests/password-requirements.error.test.js +0 -14
  130. package/authentication/tests/remember.api.test.d.ts +0 -1
  131. package/authentication/tests/remember.api.test.js +0 -117
  132. package/authentication/tests/remember.service.test.d.ts +0 -1
  133. package/authentication/tests/remember.service.test.js +0 -83
  134. package/authentication/tests/subject.service.test.d.ts +0 -1
  135. package/authentication/tests/subject.service.test.js +0 -140
  136. package/authentication/tests/suspended-subject.test.d.ts +0 -1
  137. package/authentication/tests/suspended-subject.test.js +0 -120
  138. package/authentication/tests/totp.enrollment.test.d.ts +0 -1
  139. package/authentication/tests/totp.enrollment.test.js +0 -123
  140. package/authentication/tests/totp.login.test.d.ts +0 -1
  141. package/authentication/tests/totp.login.test.js +0 -213
  142. package/authentication/tests/totp.recovery-codes.test.d.ts +0 -1
  143. package/authentication/tests/totp.recovery-codes.test.js +0 -97
  144. package/authentication/tests/totp.status.test.d.ts +0 -1
  145. package/authentication/tests/totp.status.test.js +0 -72
  146. package/cancellation/tests/coverage.test.d.ts +0 -1
  147. package/cancellation/tests/coverage.test.js +0 -49
  148. package/cancellation/tests/leak.test.d.ts +0 -1
  149. package/cancellation/tests/leak.test.js +0 -35
  150. package/cancellation/tests/token.test.d.ts +0 -1
  151. package/cancellation/tests/token.test.js +0 -136
  152. package/circuit-breaker/tests/circuit-breaker.test.d.ts +0 -1
  153. package/circuit-breaker/tests/circuit-breaker.test.js +0 -116
  154. package/cryptography/tests/cryptography.test.d.ts +0 -1
  155. package/cryptography/tests/cryptography.test.js +0 -175
  156. package/cryptography/tests/jwt.test.d.ts +0 -1
  157. package/cryptography/tests/jwt.test.js +0 -54
  158. package/cryptography/tests/modern.test.d.ts +0 -1
  159. package/cryptography/tests/modern.test.js +0 -105
  160. package/cryptography/tests/module.test.d.ts +0 -1
  161. package/cryptography/tests/module.test.js +0 -100
  162. package/cryptography/tests/totp.test.d.ts +0 -1
  163. package/cryptography/tests/totp.test.js +0 -108
  164. package/document-management/tests/ai-config-hierarchy.test.d.ts +0 -1
  165. package/document-management/tests/ai-config-hierarchy.test.js +0 -59
  166. package/document-management/tests/ai-config-integration.test.d.ts +0 -1
  167. package/document-management/tests/ai-config-integration.test.js +0 -125
  168. package/document-management/tests/ai-config-merge.test.d.ts +0 -1
  169. package/document-management/tests/ai-config-merge.test.js +0 -46
  170. package/document-management/tests/document-management-ai-overrides.test.d.ts +0 -1
  171. package/document-management/tests/document-management-ai-overrides.test.js +0 -63
  172. package/document-management/tests/document-management-core.test.d.ts +0 -1
  173. package/document-management/tests/document-management-core.test.js +0 -157
  174. package/document-management/tests/document-management.api.test.d.ts +0 -1
  175. package/document-management/tests/document-management.api.test.js +0 -101
  176. package/document-management/tests/document-statistics.service.test.d.ts +0 -1
  177. package/document-management/tests/document-statistics.service.test.js +0 -498
  178. package/document-management/tests/document-validation-ai-overrides.test.d.ts +0 -1
  179. package/document-management/tests/document-validation-ai-overrides.test.js +0 -87
  180. package/document-management/tests/document.service.test.d.ts +0 -1
  181. package/document-management/tests/document.service.test.js +0 -143
  182. package/document-management/tests/enum-helpers.test.d.ts +0 -1
  183. package/document-management/tests/enum-helpers.test.js +0 -452
  184. package/document-management/tests/helper.d.ts +0 -24
  185. package/document-management/tests/helper.js +0 -39
  186. package/errors/tests/format.test.d.ts +0 -1
  187. package/errors/tests/format.test.js +0 -84
  188. package/http/tests/server-timing.test.d.ts +0 -1
  189. package/http/tests/server-timing.test.js +0 -42
  190. package/injector/tests/advanced.test.d.ts +0 -1
  191. package/injector/tests/advanced.test.js +0 -116
  192. package/injector/tests/async-init.test.d.ts +0 -1
  193. package/injector/tests/async-init.test.js +0 -77
  194. package/injector/tests/basic.test.d.ts +0 -1
  195. package/injector/tests/basic.test.js +0 -114
  196. package/injector/tests/hierarchical.test.d.ts +0 -1
  197. package/injector/tests/hierarchical.test.js +0 -59
  198. package/injector/tests/leak.test.d.ts +0 -1
  199. package/injector/tests/leak.test.js +0 -45
  200. package/injector/tests/lifecycles.test.d.ts +0 -1
  201. package/injector/tests/lifecycles.test.js +0 -109
  202. package/logger/tests/pretty-print.test.d.ts +0 -1
  203. package/logger/tests/pretty-print.test.js +0 -60
  204. package/notification/tests/notification-api.test.d.ts +0 -1
  205. package/notification/tests/notification-api.test.js +0 -124
  206. package/notification/tests/notification-client.test.d.ts +0 -1
  207. package/notification/tests/notification-client.test.js +0 -101
  208. package/notification/tests/notification-flow.test.d.ts +0 -1
  209. package/notification/tests/notification-flow.test.js +0 -296
  210. package/notification/tests/notification-sse.service.test.d.ts +0 -1
  211. package/notification/tests/notification-sse.service.test.js +0 -43
  212. package/notification/tests/notification-type.service.test.d.ts +0 -1
  213. package/notification/tests/notification-type.service.test.js +0 -41
  214. package/object-storage/s3/tests/s3.object-storage.integration.test.d.ts +0 -1
  215. package/object-storage/s3/tests/s3.object-storage.integration.test.js +0 -303
  216. package/orm/tests/build-jsonb.test.d.ts +0 -1
  217. package/orm/tests/build-jsonb.test.js +0 -39
  218. package/orm/tests/data-types.test.d.ts +0 -1
  219. package/orm/tests/data-types.test.js +0 -39
  220. package/orm/tests/database-extension.test.d.ts +0 -1
  221. package/orm/tests/database-extension.test.js +0 -63
  222. package/orm/tests/database-migration.test.d.ts +0 -1
  223. package/orm/tests/database-migration.test.js +0 -83
  224. package/orm/tests/decorators.test.d.ts +0 -1
  225. package/orm/tests/decorators.test.js +0 -77
  226. package/orm/tests/encryption.test.d.ts +0 -1
  227. package/orm/tests/encryption.test.js +0 -31
  228. package/orm/tests/query-complex.test.d.ts +0 -1
  229. package/orm/tests/query-complex.test.js +0 -172
  230. package/orm/tests/query-converter-complex.test.d.ts +0 -1
  231. package/orm/tests/query-converter-complex.test.js +0 -131
  232. package/orm/tests/query-converter.test.d.ts +0 -1
  233. package/orm/tests/query-converter.test.js +0 -123
  234. package/orm/tests/repository-advanced.test.d.ts +0 -1
  235. package/orm/tests/repository-advanced.test.js +0 -189
  236. package/orm/tests/repository-attributes.test.d.ts +0 -1
  237. package/orm/tests/repository-attributes.test.js +0 -83
  238. package/orm/tests/repository-compound-primary-key.test.d.ts +0 -2
  239. package/orm/tests/repository-compound-primary-key.test.js +0 -226
  240. package/orm/tests/repository-comprehensive.test.d.ts +0 -1
  241. package/orm/tests/repository-comprehensive.test.js +0 -162
  242. package/orm/tests/repository-coverage.test.d.ts +0 -2
  243. package/orm/tests/repository-coverage.test.js +0 -242
  244. package/orm/tests/repository-cti-complex.test.d.ts +0 -1
  245. package/orm/tests/repository-cti-complex.test.js +0 -151
  246. package/orm/tests/repository-cti-embedded.test.d.ts +0 -1
  247. package/orm/tests/repository-cti-embedded.test.js +0 -178
  248. package/orm/tests/repository-cti-extensive.test.d.ts +0 -2
  249. package/orm/tests/repository-cti-extensive.test.js +0 -279
  250. package/orm/tests/repository-cti-mapping.test.d.ts +0 -2
  251. package/orm/tests/repository-cti-mapping.test.js +0 -108
  252. package/orm/tests/repository-cti-search.test.d.ts +0 -1
  253. package/orm/tests/repository-cti-search.test.js +0 -141
  254. package/orm/tests/repository-cti-soft-delete.test.d.ts +0 -2
  255. package/orm/tests/repository-cti-soft-delete.test.js +0 -103
  256. package/orm/tests/repository-cti-transactions.test.d.ts +0 -1
  257. package/orm/tests/repository-cti-transactions.test.js +0 -112
  258. package/orm/tests/repository-cti-upsert-many.test.d.ts +0 -2
  259. package/orm/tests/repository-cti-upsert-many.test.js +0 -115
  260. package/orm/tests/repository-cti.test.d.ts +0 -2
  261. package/orm/tests/repository-cti.test.js +0 -390
  262. package/orm/tests/repository-edge-cases.test.d.ts +0 -1
  263. package/orm/tests/repository-edge-cases.test.js +0 -178
  264. package/orm/tests/repository-expiration.test.d.ts +0 -2
  265. package/orm/tests/repository-expiration.test.js +0 -140
  266. package/orm/tests/repository-extra-coverage.test.d.ts +0 -2
  267. package/orm/tests/repository-extra-coverage.test.js +0 -402
  268. package/orm/tests/repository-mapping.test.d.ts +0 -2
  269. package/orm/tests/repository-mapping.test.js +0 -65
  270. package/orm/tests/repository-regression.test.d.ts +0 -1
  271. package/orm/tests/repository-regression.test.js +0 -288
  272. package/orm/tests/repository-search-coverage.test.d.ts +0 -1
  273. package/orm/tests/repository-search-coverage.test.js +0 -107
  274. package/orm/tests/repository-search.test.d.ts +0 -1
  275. package/orm/tests/repository-search.test.js +0 -105
  276. package/orm/tests/repository-soft-delete.test.d.ts +0 -1
  277. package/orm/tests/repository-soft-delete.test.js +0 -118
  278. package/orm/tests/repository-transactions-nested.test.d.ts +0 -1
  279. package/orm/tests/repository-transactions-nested.test.js +0 -178
  280. package/orm/tests/repository-types.test.d.ts +0 -1
  281. package/orm/tests/repository-types.test.js +0 -184
  282. package/orm/tests/repository-undelete.test.d.ts +0 -2
  283. package/orm/tests/repository-undelete.test.js +0 -201
  284. package/orm/tests/schema-converter.test.d.ts +0 -1
  285. package/orm/tests/schema-converter.test.js +0 -82
  286. package/orm/tests/schema-generation.test.d.ts +0 -2
  287. package/orm/tests/schema-generation.test.js +0 -174
  288. package/orm/tests/sql-helpers.test.d.ts +0 -1
  289. package/orm/tests/sql-helpers.test.js +0 -67
  290. package/orm/tests/transaction-safety.test.d.ts +0 -1
  291. package/orm/tests/transaction-safety.test.js +0 -81
  292. package/orm/tests/transactional.test.d.ts +0 -1
  293. package/orm/tests/transactional.test.js +0 -215
  294. package/orm/tests/utils.test.d.ts +0 -1
  295. package/orm/tests/utils.test.js +0 -70
  296. package/pdf/tests/utils.test.d.ts +0 -1
  297. package/pdf/tests/utils.test.js +0 -187
  298. package/process/tests/spawn.test.d.ts +0 -1
  299. package/process/tests/spawn.test.js +0 -182
  300. package/rate-limit/tests/postgres-rate-limiter.test.d.ts +0 -1
  301. package/rate-limit/tests/postgres-rate-limiter.test.js +0 -84
  302. package/renderer/tests/renderer.test.d.ts +0 -1
  303. package/renderer/tests/renderer.test.js +0 -88
  304. package/rpc/tests/rpc.integration.test.d.ts +0 -1
  305. package/rpc/tests/rpc.integration.test.js +0 -615
  306. package/signals/implementation/errors.d.ts +0 -2
  307. package/signals/implementation/graph.js +0 -312
  308. package/signals/implementation/writable-signal.d.ts +0 -48
  309. package/signals/implementation/writable-signal.js +0 -32
  310. package/task-queue/tests/coverage-branch.test.d.ts +0 -1
  311. package/task-queue/tests/coverage-branch.test.js +0 -395
  312. package/task-queue/tests/coverage-enhancement.test.d.ts +0 -1
  313. package/task-queue/tests/coverage-enhancement.test.js +0 -150
  314. package/task-queue/tests/dag.test.d.ts +0 -1
  315. package/task-queue/tests/dag.test.js +0 -188
  316. package/task-queue/tests/dependencies.test.d.ts +0 -1
  317. package/task-queue/tests/dependencies.test.js +0 -296
  318. package/task-queue/tests/enqueue-batch.test.d.ts +0 -1
  319. package/task-queue/tests/enqueue-batch.test.js +0 -125
  320. package/task-queue/tests/enqueue-item.test.d.ts +0 -1
  321. package/task-queue/tests/enqueue-item.test.js +0 -12
  322. package/task-queue/tests/fan-out-spawning.test.d.ts +0 -1
  323. package/task-queue/tests/fan-out-spawning.test.js +0 -94
  324. package/task-queue/tests/idempotent-replacement.test.d.ts +0 -1
  325. package/task-queue/tests/idempotent-replacement.test.js +0 -114
  326. package/task-queue/tests/missing-idempotent-tasks.test.d.ts +0 -1
  327. package/task-queue/tests/missing-idempotent-tasks.test.js +0 -39
  328. package/task-queue/tests/optimization-edge-cases.test.d.ts +0 -1
  329. package/task-queue/tests/optimization-edge-cases.test.js +0 -124
  330. package/task-queue/tests/queue-generic.test.d.ts +0 -1
  331. package/task-queue/tests/queue-generic.test.js +0 -8
  332. package/task-queue/tests/queue.test.d.ts +0 -1
  333. package/task-queue/tests/queue.test.js +0 -756
  334. package/task-queue/tests/shutdown.test.d.ts +0 -1
  335. package/task-queue/tests/shutdown.test.js +0 -41
  336. package/task-queue/tests/task-context.test.d.ts +0 -1
  337. package/task-queue/tests/task-context.test.js +0 -7
  338. package/task-queue/tests/task-union.test.d.ts +0 -1
  339. package/task-queue/tests/task-union.test.js +0 -18
  340. package/task-queue/tests/transactions.test.d.ts +0 -1
  341. package/task-queue/tests/transactions.test.js +0 -47
  342. package/task-queue/tests/typing.test.d.ts +0 -1
  343. package/task-queue/tests/typing.test.js +0 -9
  344. package/task-queue/tests/worker.test.d.ts +0 -1
  345. package/task-queue/tests/worker.test.js +0 -258
  346. package/task-queue/tests/zombie-parent.test.d.ts +0 -1
  347. package/task-queue/tests/zombie-parent.test.js +0 -45
  348. package/task-queue/tests/zombie-recovery.test.d.ts +0 -1
  349. package/task-queue/tests/zombie-recovery.test.js +0 -51
  350. package/utils/tests/backoff.test.d.ts +0 -1
  351. package/utils/tests/backoff.test.js +0 -41
  352. package/utils/tests/retry-with-backoff.test.d.ts +0 -1
  353. package/utils/tests/retry-with-backoff.test.js +0 -49
@@ -1,279 +0,0 @@
1
- /** biome-ignore-all lint/nursery/noExcessiveClassesPerFile: <explanation> */
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- import { sql } from 'drizzle-orm';
12
- import { beforeAll, describe, expect, test } from 'vitest';
13
- import { NumberProperty, StringProperty } from '../../schema/index.js';
14
- import { setupIntegrationTest } from '../../testing/index.js';
15
- import { ChildEntity, Column, Inheritance, Table } from '../decorators.js';
16
- import { Entity } from '../entity.js';
17
- import { getRepository } from '../server/index.js';
18
- describe('ORM Repository CTI Extensive (Integration)', () => {
19
- let injector;
20
- let db;
21
- let personRepo;
22
- let empRepo;
23
- let mgrRepo;
24
- let cntRepo;
25
- const schema = 'test_orm_cti_extensive';
26
- // --- Entities ---
27
- let Person = class Person extends Entity {
28
- type;
29
- name;
30
- };
31
- __decorate([
32
- StringProperty(),
33
- Column({ name: 'type' }),
34
- __metadata("design:type", String)
35
- ], Person.prototype, "type", void 0);
36
- __decorate([
37
- StringProperty(),
38
- Column({ name: 'name' }),
39
- __metadata("design:type", String)
40
- ], Person.prototype, "name", void 0);
41
- Person = __decorate([
42
- Table('persons', { schema }),
43
- Inheritance({ strategy: 'joined', discriminatorColumn: 'type' })
44
- ], Person);
45
- let Employee = class Employee extends Person {
46
- salary;
47
- };
48
- __decorate([
49
- NumberProperty(),
50
- Column({ name: 'salary' }),
51
- __metadata("design:type", Number)
52
- ], Employee.prototype, "salary", void 0);
53
- Employee = __decorate([
54
- Table('employees', { schema }),
55
- Inheritance({ strategy: 'joined' }),
56
- ChildEntity('employee')
57
- ], Employee);
58
- let Manager = class Manager extends Employee {
59
- department;
60
- };
61
- __decorate([
62
- StringProperty(),
63
- Column({ name: 'department' }),
64
- __metadata("design:type", String)
65
- ], Manager.prototype, "department", void 0);
66
- Manager = __decorate([
67
- Table('managers', { schema }),
68
- ChildEntity('manager')
69
- ], Manager);
70
- let Contractor = class Contractor extends Person {
71
- contractEnd;
72
- };
73
- __decorate([
74
- StringProperty() // Using string for date just for simplicity in this test unless DateProperty handles it well with mapped types, assuming DateProperty -> Date
75
- ,
76
- Column({ name: 'contract_end' }),
77
- __metadata("design:type", String)
78
- ], Contractor.prototype, "contractEnd", void 0);
79
- Contractor = __decorate([
80
- Table('contractors', { schema }),
81
- ChildEntity('contractor')
82
- ], Contractor);
83
- // --- Setup ---
84
- beforeAll(async () => {
85
- ({ injector, database: db } = await setupIntegrationTest({
86
- orm: { schema },
87
- }));
88
- personRepo = injector.resolve(getRepository(Person));
89
- empRepo = injector.resolve(getRepository(Employee));
90
- mgrRepo = injector.resolve(getRepository(Manager));
91
- cntRepo = injector.resolve(getRepository(Contractor));
92
- await db.execute(sql `CREATE SCHEMA IF NOT EXISTS ${sql.identifier(schema)}`);
93
- await db.execute(sql `DROP TABLE IF EXISTS ${sql.identifier(schema)}.${sql.identifier('managers')} CASCADE`);
94
- await db.execute(sql `DROP TABLE IF EXISTS ${sql.identifier(schema)}.${sql.identifier('employees')} CASCADE`);
95
- await db.execute(sql `DROP TABLE IF EXISTS ${sql.identifier(schema)}.${sql.identifier('contractors')} CASCADE`);
96
- await db.execute(sql `DROP TABLE IF EXISTS ${sql.identifier(schema)}.${sql.identifier('persons')} CASCADE`);
97
- await db.execute(sql `
98
- CREATE TABLE ${sql.identifier(schema)}.${sql.identifier('persons')} (
99
- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
100
- type TEXT NOT NULL,
101
- name TEXT NOT NULL,
102
- revision INTEGER NOT NULL,
103
- revision_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
104
- create_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
105
- delete_timestamp TIMESTAMP WITH TIME ZONE,
106
- attributes JSONB NOT NULL DEFAULT '{}',
107
- UNIQUE (id, type)
108
- )
109
- `);
110
- await db.execute(sql `
111
- CREATE TABLE ${sql.identifier(schema)}.${sql.identifier('employees')} (
112
- id UUID PRIMARY KEY,
113
- type TEXT NOT NULL,
114
- salary INTEGER NOT NULL,
115
- UNIQUE (id, type),
116
- FOREIGN KEY (id, type) REFERENCES ${sql.identifier(schema)}.${sql.identifier('persons')} (id, type) ON DELETE CASCADE
117
- )
118
- `);
119
- await db.execute(sql `
120
- CREATE TABLE ${sql.identifier(schema)}.${sql.identifier('managers')} (
121
- id UUID PRIMARY KEY,
122
- type TEXT NOT NULL CHECK (type = 'manager'),
123
- department TEXT NOT NULL,
124
- FOREIGN KEY (id, type) REFERENCES ${sql.identifier(schema)}.${sql.identifier('employees')} (id, type) ON DELETE CASCADE
125
- )
126
- `);
127
- await db.execute(sql `
128
- CREATE TABLE ${sql.identifier(schema)}.${sql.identifier('contractors')} (
129
- id UUID PRIMARY KEY,
130
- type TEXT NOT NULL CHECK (type = 'contractor'),
131
- contract_end TEXT NOT NULL,
132
- FOREIGN KEY (id, type) REFERENCES ${sql.identifier(schema)}.${sql.identifier('persons')} (id, type) ON DELETE CASCADE
133
- )
134
- `);
135
- });
136
- // --- Tests ---
137
- test('should insert different subtypes via specific repositories', async () => {
138
- await db.execute(sql `TRUNCATE TABLE ${sql.identifier(schema)}.${sql.identifier('persons')} CASCADE`);
139
- const e1 = await empRepo.insert(Object.assign(new Employee(), { name: 'E1', salary: 50000 }));
140
- const m1 = await mgrRepo.insert(Object.assign(new Manager(), { name: 'M1', salary: 80000, department: 'IT' }));
141
- const c1 = await cntRepo.insert(Object.assign(new Contractor(), { name: 'C1', contractEnd: '2025-12-31' }));
142
- expect(e1.type).toBe('employee');
143
- expect(m1.type).toBe('manager');
144
- expect(c1.type).toBe('contractor');
145
- });
146
- test('should filter by mixed parent and child properties', async () => {
147
- await db.execute(sql `TRUNCATE TABLE ${sql.identifier(schema)}.${sql.identifier('persons')} CASCADE`);
148
- await mgrRepo.insert(Object.assign(new Manager(), { name: 'Alice', salary: 90000, department: 'IT' }));
149
- await mgrRepo.insert(Object.assign(new Manager(), { name: 'Bob', salary: 90000, department: 'HR' }));
150
- await mgrRepo.insert(Object.assign(new Manager(), { name: 'Charlie', salary: 60000, department: 'IT' }));
151
- // Filter by parent (salary) AND child (department)
152
- const richITManagers = await mgrRepo.loadManyByQuery({
153
- salary: 90000,
154
- department: 'IT',
155
- });
156
- expect(richITManagers).toHaveLength(1);
157
- expect(richITManagers[0].name).toBe('Alice');
158
- });
159
- test('should sort by parent property then child property', async () => {
160
- await db.execute(sql `TRUNCATE TABLE ${sql.identifier(schema)}.${sql.identifier('persons')} CASCADE`);
161
- await mgrRepo.insert(Object.assign(new Manager(), { name: 'A', salary: 50000, department: 'Z' }));
162
- await mgrRepo.insert(Object.assign(new Manager(), { name: 'B', salary: 50000, department: 'A' }));
163
- await mgrRepo.insert(Object.assign(new Manager(), { name: 'C', salary: 90000, department: 'A' }));
164
- // Sort by salary (parent) DESC, then department (child) ASC
165
- const sorted = await mgrRepo.loadManyByQuery({}, {
166
- order: [
167
- ['salary', 'desc'],
168
- ['department', 'asc'],
169
- ],
170
- });
171
- expect(sorted).toHaveLength(3);
172
- expect(sorted[0].name).toBe('C'); // 90000
173
- expect(sorted[1].name).toBe('B'); // 50000, A
174
- expect(sorted[2].name).toBe('A'); // 50000, Z
175
- });
176
- test('should paginate polymorphic results correctly', async () => {
177
- await db.execute(sql `TRUNCATE TABLE ${sql.identifier(schema)}.${sql.identifier('persons')} CASCADE`);
178
- // Insert 5 entities: 2 employees, 2 managers, 1 contractor
179
- // Names ordered: A, B, C, D, E
180
- await empRepo.insert(Object.assign(new Employee(), { name: 'A_Emp', salary: 1000 }));
181
- await mgrRepo.insert(Object.assign(new Manager(), { name: 'B_Mgr', salary: 2000, department: 'D1' }));
182
- await cntRepo.insert(Object.assign(new Contractor(), { name: 'C_Cnt', contractEnd: '2025' }));
183
- await empRepo.insert(Object.assign(new Employee(), { name: 'D_Emp', salary: 1000 }));
184
- await mgrRepo.insert(Object.assign(new Manager(), { name: 'E_Mgr', salary: 2000, department: 'D2' }));
185
- // Load page 1 (size 2) sorted by name
186
- const page1 = await personRepo.loadManyByQuery({}, {
187
- order: [['name', 'asc']],
188
- limit: 2,
189
- offset: 0,
190
- includeSubclasses: [Employee, Manager, Contractor],
191
- });
192
- expect(page1).toHaveLength(2);
193
- expect(page1[0].name).toBe('A_Emp');
194
- expect(page1[0]).toBeInstanceOf(Employee);
195
- expect(page1[1].name).toBe('B_Mgr');
196
- expect(page1[1]).toBeInstanceOf(Manager);
197
- // Load page 2 (size 2)
198
- const page2 = await personRepo.loadManyByQuery({}, {
199
- order: [['name', 'asc']],
200
- limit: 2,
201
- offset: 2,
202
- includeSubclasses: [Employee, Manager, Contractor],
203
- });
204
- expect(page2).toHaveLength(2);
205
- expect(page2[0].name).toBe('C_Cnt');
206
- expect(page2[0]).toBeInstanceOf(Contractor);
207
- expect(page2[1].name).toBe('D_Emp');
208
- expect(page2[1]).toBeInstanceOf(Employee);
209
- // Load page 3 (size 2) - should have 1
210
- const page3 = await personRepo.loadManyByQuery({}, {
211
- order: [['name', 'asc']],
212
- limit: 2,
213
- offset: 4,
214
- includeSubclasses: [Employee, Manager, Contractor],
215
- });
216
- expect(page3).toHaveLength(1);
217
- expect(page3[0].name).toBe('E_Mgr');
218
- });
219
- test('should rollback whole operation if one child insert fails in bulk insert', async () => {
220
- // NOTE: Repositories typically don't support heterogeneous bulk insert via `insertMany` directly if they are typed to one Entity.
221
- // But we can test transactional safety when manually doing multiple inserts or if we were to support it.
222
- // Here we will test doing multiple operations in a transaction and failing one.
223
- await db.execute(sql `TRUNCATE TABLE ${sql.identifier(schema)}.${sql.identifier('persons')} CASCADE`);
224
- try {
225
- await mgrRepo.transaction(async (tx) => {
226
- const txRepo = mgrRepo.withTransaction(tx);
227
- await txRepo.insert(Object.assign(new Manager(), { name: 'TxMgr1', salary: 1000, department: 'D1' }));
228
- // This one should fail due to constraint violation (missing department is not nullable in DB but maybe optional in class?
229
- // In our setup 'department' is NOT NULL.
230
- // Let's force a failure by passing a raw invalid object or similar, or just throwing.
231
- // A better DB constraint failure: Duplicate ID? Or invalid type?
232
- // Let's try inserting a manager with a missing required field using 'any' to bypass TS check.
233
- const invalidMgr = new Manager();
234
- invalidMgr.name = 'TxMgr2';
235
- invalidMgr.salary = 2000;
236
- // Missing department
237
- await txRepo.insert(invalidMgr);
238
- });
239
- }
240
- catch (e) {
241
- // Expected error
242
- }
243
- const { rows } = await db.execute(sql `SELECT * FROM ${sql.identifier(schema)}.${sql.identifier('persons')}`);
244
- expect(rows).toHaveLength(0); // TxMgr1 should not be there
245
- });
246
- test('should load entities correctly when multiple levels of inheritance share column names', async () => {
247
- // It's common to have 'name' or similar fields in child tables (shadowing).
248
- // In our current schema we avoided it, but let's see if we can query based on aliasing if it were to happen?
249
- // Actually, let's test querying with 'OR' condition across parent and child fields.
250
- await db.execute(sql `TRUNCATE TABLE ${sql.identifier(schema)}.${sql.identifier('persons')} CASCADE`);
251
- await mgrRepo.insert(Object.assign(new Manager(), { name: 'MatchName', salary: 1000, department: 'Other' }));
252
- await mgrRepo.insert(Object.assign(new Manager(), { name: 'OtherName', salary: 1000, department: 'MatchDept' }));
253
- await mgrRepo.insert(Object.assign(new Manager(), { name: 'NoMatch', salary: 1000, department: 'Other' }));
254
- // Logic: name = 'MatchName' OR department = 'MatchDept'
255
- // ORM's `loadManyByQuery` usually takes an object for AND.
256
- // We might need to use `loadMany` with a custom query builder or check if `loadManyByQuery` supports arrays for OR?
257
- // If not supported easily, we skip this specific complex query for now, or use `loadMany` with simple filters.
258
- // Let's stick to simple filters that we know are supported: simple object matches (AND).
259
- // Let's test a deeply nested query filter if supported.
260
- const results = await mgrRepo.loadManyByQuery({
261
- department: 'MatchDept',
262
- });
263
- expect(results).toHaveLength(1);
264
- expect(results[0].name).toBe('OtherName');
265
- });
266
- test('should correctly count with subclass inclusion', async () => {
267
- await db.execute(sql `TRUNCATE TABLE ${sql.identifier(schema)}.${sql.identifier('persons')} CASCADE`);
268
- await empRepo.insert(Object.assign(new Employee(), { name: 'E1', salary: 100 }));
269
- await mgrRepo.insert(Object.assign(new Manager(), { name: 'M1', salary: 200, department: 'D1' }));
270
- // Count on Person should see 2
271
- expect(await personRepo.count()).toBe(2);
272
- // Count on Employee should see 2 (Manager IS-A Employee)
273
- // Wait, does 'count()' on Employee include Managers by default?
274
- // Standard CTI usually implies querying the 'employees' table which includes Managers' rows.
275
- expect(await empRepo.count()).toBe(2);
276
- // Count on Manager should see 1
277
- expect(await mgrRepo.count()).toBe(1);
278
- });
279
- });
@@ -1,2 +0,0 @@
1
- /** biome-ignore-all lint/nursery/noExcessiveClassesPerFile: <explanation> */
2
- export {};
@@ -1,108 +0,0 @@
1
- /** biome-ignore-all lint/nursery/noExcessiveClassesPerFile: <explanation> */
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- import { sql } from 'drizzle-orm';
12
- import { beforeAll, describe, expect, test } from 'vitest';
13
- import { StringProperty } from '../../schema/index.js';
14
- import { setupIntegrationTest } from '../../testing/index.js';
15
- import { ChildEntity, Column, Inheritance, Table } from '../decorators.js';
16
- import { Entity } from '../entity.js';
17
- import { getRepository } from '../server/index.js';
18
- describe('ORM Repository CTI Mapping (Integration)', () => {
19
- let injector;
20
- let db;
21
- let repo;
22
- const schema = 'test_orm_cti_mapping';
23
- let MappedParent = class MappedParent extends Entity {
24
- discriminator;
25
- displayName;
26
- };
27
- __decorate([
28
- StringProperty(),
29
- Column({ name: 'discriminator' }),
30
- __metadata("design:type", String)
31
- ], MappedParent.prototype, "discriminator", void 0);
32
- __decorate([
33
- StringProperty(),
34
- Column({ name: 'display_name' }),
35
- __metadata("design:type", String)
36
- ], MappedParent.prototype, "displayName", void 0);
37
- MappedParent = __decorate([
38
- Table('mapped_parents', { schema }),
39
- Inheritance({ strategy: 'joined', discriminatorColumn: 'discriminator' })
40
- ], MappedParent);
41
- let MappedChild = class MappedChild extends MappedParent {
42
- secret;
43
- };
44
- __decorate([
45
- StringProperty(),
46
- Column({ name: 'internal_secret' }),
47
- __metadata("design:type", String)
48
- ], MappedChild.prototype, "secret", void 0);
49
- MappedChild = __decorate([
50
- Table('mapped_children', { schema }),
51
- ChildEntity('child')
52
- ], MappedChild);
53
- beforeAll(async () => {
54
- ({ injector, database: db } = await setupIntegrationTest({
55
- orm: { schema },
56
- }));
57
- repo = injector.resolve(getRepository(MappedChild));
58
- await db.execute(sql `CREATE SCHEMA IF NOT EXISTS ${sql.identifier(schema)}`);
59
- await db.execute(sql `DROP TABLE IF EXISTS ${sql.identifier(schema)}.${sql.identifier('mapped_children')} CASCADE`);
60
- await db.execute(sql `DROP TABLE IF EXISTS ${sql.identifier(schema)}.${sql.identifier('mapped_parents')} CASCADE`);
61
- await db.execute(sql `
62
- CREATE TABLE ${sql.identifier(schema)}.${sql.identifier('mapped_parents')} (
63
- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
64
- discriminator TEXT NOT NULL,
65
- display_name TEXT NOT NULL,
66
- revision INTEGER NOT NULL,
67
- revision_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
68
- create_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
69
- delete_timestamp TIMESTAMP WITH TIME ZONE,
70
- attributes JSONB NOT NULL DEFAULT '{}',
71
- UNIQUE (id, discriminator)
72
- )
73
- `);
74
- await db.execute(sql `
75
- CREATE TABLE ${sql.identifier(schema)}.${sql.identifier('mapped_children')} (
76
- id UUID PRIMARY KEY,
77
- discriminator TEXT NOT NULL CHECK (discriminator = 'child'),
78
- internal_secret TEXT NOT NULL,
79
- FOREIGN KEY (id, discriminator) REFERENCES ${sql.identifier(schema)}.${sql.identifier('mapped_parents')} (id, discriminator) ON DELETE CASCADE
80
- )
81
- `);
82
- });
83
- test('should respect @Column renaming in CTI', async () => {
84
- const child = await repo.insert(Object.assign(new MappedChild(), { displayName: 'Visible', secret: 'Hidden' }));
85
- expect(child.discriminator).toBe('child');
86
- expect(child.displayName).toBe('Visible');
87
- expect(child.secret).toBe('Hidden');
88
- // Verify DB column names
89
- const { rows: parentRows } = await db.execute(sql `SELECT display_name FROM ${sql.identifier(schema)}.${sql.identifier('mapped_parents')} WHERE id = ${child.id}`);
90
- expect(parentRows[0]['display_name']).toBe('Visible');
91
- const { rows: childRows } = await db.execute(sql `SELECT internal_secret FROM ${sql.identifier(schema)}.${sql.identifier('mapped_children')} WHERE id = ${child.id}`);
92
- expect(childRows[0]['internal_secret']).toBe('Hidden');
93
- // Load back
94
- const loaded = await repo.load(child.id);
95
- expect(loaded.displayName).toBe('Visible');
96
- expect(loaded.secret).toBe('Hidden');
97
- });
98
- test('should filter by renamed columns in both tables', async () => {
99
- await repo.insert(Object.assign(new MappedChild(), { displayName: 'A', secret: 'S1' }));
100
- await repo.insert(Object.assign(new MappedChild(), { displayName: 'B', secret: 'S2' }));
101
- const results = await repo.loadManyByQuery({
102
- displayName: 'B',
103
- secret: 'S2'
104
- });
105
- expect(results).toHaveLength(1);
106
- expect(results[0].displayName).toBe('B');
107
- });
108
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,141 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import { sql } from 'drizzle-orm';
11
- import { beforeAll, describe, expect, test } from 'vitest';
12
- import { Injector, runInInjectionContext } from '../../injector/index.js';
13
- import { StringProperty } from '../../schema/index.js';
14
- import { setupIntegrationTest } from '../../testing/index.js';
15
- import { ChildEntity, Column, GeneratedTsVector, Inheritance, Table } from '../decorators.js';
16
- import { Entity } from '../entity.js';
17
- import { injectRepository } from '../server/index.js';
18
- describe('ORM Repository CTI Search (Integration)', () => {
19
- let injector;
20
- let database;
21
- const schema = 'test_orm_cti_search';
22
- let Item = class Item extends Entity {
23
- type;
24
- title;
25
- description;
26
- searchVector;
27
- };
28
- __decorate([
29
- StringProperty(),
30
- Column({ name: 'type' }),
31
- __metadata("design:type", String)
32
- ], Item.prototype, "type", void 0);
33
- __decorate([
34
- StringProperty(),
35
- __metadata("design:type", String)
36
- ], Item.prototype, "title", void 0);
37
- __decorate([
38
- StringProperty(),
39
- __metadata("design:type", String)
40
- ], Item.prototype, "description", void 0);
41
- __decorate([
42
- StringProperty(),
43
- GeneratedTsVector({ sources: ['title', 'description'] }),
44
- __metadata("design:type", Object)
45
- ], Item.prototype, "searchVector", void 0);
46
- Item = __decorate([
47
- Table('items', { schema }),
48
- Inheritance({ strategy: 'joined', discriminatorColumn: 'type' })
49
- ], Item);
50
- let Book = class Book extends Item {
51
- author;
52
- };
53
- __decorate([
54
- StringProperty(),
55
- __metadata("design:type", String)
56
- ], Book.prototype, "author", void 0);
57
- Book = __decorate([
58
- Table('books', { schema }),
59
- ChildEntity('book')
60
- ], Book);
61
- let Electronic = class Electronic extends Item {
62
- brand;
63
- };
64
- __decorate([
65
- StringProperty(),
66
- __metadata("design:type", String)
67
- ], Electronic.prototype, "brand", void 0);
68
- Electronic = __decorate([
69
- Table('electronics', { schema }),
70
- ChildEntity('electronic')
71
- ], Electronic);
72
- beforeAll(async () => {
73
- ({ injector, database } = await setupIntegrationTest({ orm: { schema } }));
74
- await database.execute(sql `CREATE SCHEMA IF NOT EXISTS ${sql.identifier(schema)}`);
75
- await database.execute(sql `DROP TABLE IF EXISTS ${sql.identifier(schema)}.${sql.identifier('books')} CASCADE`);
76
- await database.execute(sql `DROP TABLE IF EXISTS ${sql.identifier(schema)}.${sql.identifier('electronics')} CASCADE`);
77
- await database.execute(sql `DROP TABLE IF EXISTS ${sql.identifier(schema)}.${sql.identifier('items')} CASCADE`);
78
- await database.execute(sql `
79
- CREATE TABLE ${sql.identifier(schema)}.${sql.identifier('items')} (
80
- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
81
- type TEXT NOT NULL,
82
- title TEXT NOT NULL,
83
- description TEXT NOT NULL,
84
- search_vector tsvector GENERATED ALWAYS AS (to_tsvector('simple', title || ' ' || description)) STORED,
85
- revision INTEGER NOT NULL,
86
- revision_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
87
- create_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
88
- delete_timestamp TIMESTAMP WITH TIME ZONE,
89
- attributes JSONB NOT NULL DEFAULT '{}',
90
- UNIQUE (id, type)
91
- )
92
- `);
93
- await database.execute(sql `CREATE INDEX items_search_idx ON ${sql.identifier(schema)}.${sql.identifier('items')} USING GIN (search_vector)`);
94
- await database.execute(sql `
95
- CREATE TABLE ${sql.identifier(schema)}.${sql.identifier('books')} (
96
- id UUID PRIMARY KEY,
97
- type TEXT NOT NULL CHECK (type = 'book'),
98
- author TEXT NOT NULL,
99
- FOREIGN KEY (id, type) REFERENCES ${sql.identifier(schema)}.${sql.identifier('items')} (id, type) ON DELETE CASCADE
100
- )
101
- `);
102
- await database.execute(sql `
103
- CREATE TABLE ${sql.identifier(schema)}.${sql.identifier('electronics')} (
104
- id UUID PRIMARY KEY,
105
- type TEXT NOT NULL CHECK (type = 'electronic'),
106
- brand TEXT NOT NULL,
107
- FOREIGN KEY (id, type) REFERENCES ${sql.identifier(schema)}.${sql.identifier('items')} (id, type) ON DELETE CASCADE
108
- )
109
- `);
110
- });
111
- test('should search polymorphically from base repository', async () => {
112
- await runInInjectionContext(injector, async () => {
113
- const itemRepo = injectRepository(Item);
114
- const bookRepo = injectRepository(Book);
115
- const electronicRepo = injectRepository(Electronic);
116
- await bookRepo.insert(Object.assign(new Book(), { title: 'The Great Gatsby', description: 'A classic novel', author: 'F. Scott Fitzgerald' }));
117
- await electronicRepo.insert(Object.assign(new Electronic(), { title: 'iPhone 15', description: 'Latest smartphone from Apple', brand: 'Apple' }));
118
- // Search for "novel" - should find the book
119
- const results1 = await itemRepo.search({ query: { $tsvector: { fields: ['searchVector'], query: 'novel' } }, includeSubclasses: true });
120
- expect(results1).toHaveLength(1);
121
- expect(results1[0].entity).toBeInstanceOf(Book);
122
- expect(results1[0].entity.title).toBe('The Great Gatsby');
123
- // Search for "smartphone" - should find the electronic
124
- const results2 = await itemRepo.search({ query: { $tsvector: { fields: ['searchVector'], query: 'smartphone' } }, includeSubclasses: true });
125
- expect(results2).toHaveLength(1);
126
- expect(results2[0].entity).toBeInstanceOf(Electronic);
127
- expect(results2[0].entity.title).toBe('iPhone 15');
128
- });
129
- });
130
- test('should search in child repository using base search vector', async () => {
131
- await runInInjectionContext(injector, async () => {
132
- const bookRepo = injectRepository(Book);
133
- await bookRepo.insert(Object.assign(new Book(), { title: 'TypeScript Deep Dive', description: 'Comprehensive guide to TS', author: 'Basarat' }));
134
- await bookRepo.insert(Object.assign(new Book(), { title: 'Learning Rust', description: 'Systems programming with Rust', author: 'Unknown' }));
135
- const results = await bookRepo.search({ query: { $tsvector: { fields: ['searchVector'], query: 'TypeScript' } } });
136
- expect(results).toHaveLength(1);
137
- expect(results[0].entity.title).toBe('TypeScript Deep Dive');
138
- expect((results[0].entity).author).toBe('Basarat');
139
- });
140
- });
141
- });
@@ -1,2 +0,0 @@
1
- /** biome-ignore-all lint/nursery/noExcessiveClassesPerFile: <explanation> */
2
- export {};
@@ -1,103 +0,0 @@
1
- /** biome-ignore-all lint/nursery/noExcessiveClassesPerFile: <explanation> */
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- import { sql } from 'drizzle-orm';
12
- import { beforeAll, describe, expect, test } from 'vitest';
13
- import { StringProperty } from '../../schema/index.js';
14
- import { setupIntegrationTest } from '../../testing/index.js';
15
- import { ChildEntity, Column, Inheritance, Table } from '../decorators.js';
16
- import { Entity } from '../entity.js';
17
- import { getRepository } from '../server/index.js';
18
- describe('ORM Repository CTI Soft Delete (Integration)', () => {
19
- let injector;
20
- let db;
21
- let baseRepo;
22
- let subRepo;
23
- const schema = 'test_orm_cti_soft_delete';
24
- let Base = class Base extends Entity {
25
- type;
26
- baseName;
27
- };
28
- __decorate([
29
- StringProperty(),
30
- Column({ name: 'type' }),
31
- __metadata("design:type", String)
32
- ], Base.prototype, "type", void 0);
33
- __decorate([
34
- StringProperty(),
35
- __metadata("design:type", String)
36
- ], Base.prototype, "baseName", void 0);
37
- Base = __decorate([
38
- Table('bases', { schema }),
39
- Inheritance({ strategy: 'joined', discriminatorColumn: 'type' })
40
- ], Base);
41
- let Subtype = class Subtype extends Base {
42
- subData;
43
- };
44
- __decorate([
45
- StringProperty(),
46
- __metadata("design:type", String)
47
- ], Subtype.prototype, "subData", void 0);
48
- Subtype = __decorate([
49
- Table('subtypes', { schema }),
50
- ChildEntity('subtype')
51
- ], Subtype);
52
- beforeAll(async () => {
53
- ({ injector, database: db } = await setupIntegrationTest({
54
- orm: { schema },
55
- }));
56
- baseRepo = injector.resolve(getRepository(Base));
57
- subRepo = injector.resolve(getRepository(Subtype));
58
- await db.execute(sql `CREATE SCHEMA IF NOT EXISTS ${sql.identifier(schema)}`);
59
- await db.execute(sql `DROP TABLE IF EXISTS ${sql.identifier(schema)}.${sql.identifier('subtypes')} CASCADE`);
60
- await db.execute(sql `DROP TABLE IF EXISTS ${sql.identifier(schema)}.${sql.identifier('bases')} CASCADE`);
61
- await db.execute(sql `
62
- CREATE TABLE ${sql.identifier(schema)}.${sql.identifier('bases')} (
63
- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
64
- type TEXT NOT NULL,
65
- base_name TEXT NOT NULL,
66
- revision INTEGER NOT NULL,
67
- revision_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
68
- create_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
69
- delete_timestamp TIMESTAMP WITH TIME ZONE,
70
- attributes JSONB NOT NULL DEFAULT '{}',
71
- UNIQUE (id, type)
72
- )
73
- `);
74
- await db.execute(sql `
75
- CREATE TABLE ${sql.identifier(schema)}.${sql.identifier('subtypes')} (
76
- id UUID PRIMARY KEY,
77
- type TEXT NOT NULL CHECK (type = 'subtype'),
78
- sub_data TEXT NOT NULL,
79
- FOREIGN KEY (id, type) REFERENCES ${sql.identifier(schema)}.${sql.identifier('bases')} (id, type) ON DELETE CASCADE
80
- )
81
- `);
82
- });
83
- test('should soft delete from subtype repository', async () => {
84
- await db.execute(sql `TRUNCATE TABLE ${sql.identifier(schema)}.${sql.identifier('bases')} CASCADE`);
85
- const entity = await subRepo.insert(Object.assign(new Subtype(), { baseName: 'B1', subData: 'S1' }));
86
- await subRepo.delete(entity.id);
87
- const { rows } = await db.execute(sql `SELECT delete_timestamp FROM ${sql.identifier(schema)}.${sql.identifier('bases')} WHERE id = ${entity.id}`);
88
- expect(rows[0]['delete_timestamp']).not.toBeNull();
89
- expect(await subRepo.has(entity.id)).toBe(false);
90
- expect(await subRepo.loadManyByQuery({ id: entity.id }).then((r) => r[0])).toBeUndefined();
91
- });
92
- test('should polymorphically filter soft deleted entities', async () => {
93
- await db.execute(sql `TRUNCATE TABLE ${sql.identifier(schema)}.${sql.identifier('bases')} CASCADE`);
94
- const s1 = await subRepo.insert(Object.assign(new Subtype(), { baseName: 'Active', subData: 'S1' }));
95
- const s2 = await subRepo.insert(Object.assign(new Subtype(), { baseName: 'Deleted', subData: 'S2' }));
96
- await subRepo.delete(s2.id);
97
- const allActive = await baseRepo.loadAll({ includeSubclasses: true });
98
- expect(allActive).toHaveLength(1);
99
- expect(allActive[0].id).toBe(s1.id);
100
- const allIncludingDeleted = await baseRepo.loadAll({ includeSubclasses: true, withDeleted: true });
101
- expect(allIncludingDeleted).toHaveLength(2);
102
- });
103
- });
@@ -1 +0,0 @@
1
- export {};