@tstdl/base 0.93.86 → 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 (318) 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/index.d.ts +1 -1
  115. package/orm/index.js +1 -1
  116. package/orm/query/base.d.ts +17 -17
  117. package/orm/query/base.js +1 -1
  118. package/orm/repository.types.d.ts +46 -2
  119. package/orm/schemas/tsvector.js +1 -1
  120. package/orm/server/drizzle/schema-converter.d.ts +3 -1
  121. package/orm/server/drizzle/schema-converter.js +120 -14
  122. package/orm/server/index.d.ts +1 -0
  123. package/orm/server/index.js +1 -0
  124. package/orm/server/module.d.ts +4 -2
  125. package/orm/server/module.js +6 -5
  126. package/orm/server/query-converter.d.ts +6 -3
  127. package/orm/server/query-converter.js +33 -21
  128. package/orm/server/repository-config.d.ts +8 -0
  129. package/orm/server/repository-config.js +8 -0
  130. package/orm/server/repository.d.ts +117 -43
  131. package/orm/server/repository.js +758 -254
  132. package/orm/server/transaction.d.ts +4 -2
  133. package/orm/server/transaction.js +14 -5
  134. package/orm/server/transactional.d.ts +6 -2
  135. package/orm/server/transactional.js +39 -9
  136. package/orm/server/types.d.ts +2 -0
  137. package/orm/sqls/case-when.d.ts +25 -0
  138. package/orm/sqls/case-when.js +54 -0
  139. package/orm/sqls/index.d.ts +2 -0
  140. package/orm/sqls/index.js +2 -0
  141. package/orm/{sqls.d.ts → sqls/sqls.d.ts} +67 -19
  142. package/orm/{sqls.js → sqls/sqls.js} +116 -22
  143. package/orm/tests/data-types.test.d.ts +1 -0
  144. package/orm/tests/data-types.test.js +39 -0
  145. package/orm/tests/decorators.test.d.ts +1 -0
  146. package/orm/tests/decorators.test.js +77 -0
  147. package/orm/tests/encryption.test.d.ts +1 -0
  148. package/orm/tests/encryption.test.js +34 -0
  149. package/orm/tests/query-complex.test.d.ts +1 -0
  150. package/orm/tests/query-complex.test.js +203 -0
  151. package/orm/tests/query-converter-complex.test.d.ts +1 -0
  152. package/orm/tests/query-converter-complex.test.js +126 -0
  153. package/orm/tests/query-converter.test.d.ts +1 -0
  154. package/orm/tests/query-converter.test.js +123 -0
  155. package/orm/tests/repository-advanced.test.d.ts +1 -0
  156. package/orm/tests/repository-advanced.test.js +232 -0
  157. package/orm/tests/repository-attributes.test.d.ts +1 -0
  158. package/orm/tests/repository-attributes.test.js +99 -0
  159. package/orm/tests/repository-comprehensive.test.d.ts +1 -0
  160. package/orm/tests/repository-comprehensive.test.js +187 -0
  161. package/orm/tests/repository-coverage.test.d.ts +1 -0
  162. package/orm/tests/repository-coverage.test.js +303 -0
  163. package/orm/tests/repository-cti-complex.test.d.ts +1 -0
  164. package/orm/tests/repository-cti-complex.test.js +170 -0
  165. package/orm/tests/repository-cti-embedded.test.d.ts +1 -0
  166. package/orm/tests/repository-cti-embedded.test.js +188 -0
  167. package/orm/tests/repository-cti-extensive.test.d.ts +1 -0
  168. package/orm/tests/repository-cti-extensive.test.js +308 -0
  169. package/orm/tests/repository-cti-mapping.test.d.ts +1 -0
  170. package/orm/tests/repository-cti-mapping.test.js +121 -0
  171. package/orm/tests/repository-cti-search.test.d.ts +1 -0
  172. package/orm/tests/repository-cti-search.test.js +152 -0
  173. package/orm/tests/repository-cti-soft-delete.test.d.ts +1 -0
  174. package/orm/tests/repository-cti-soft-delete.test.js +115 -0
  175. package/orm/tests/repository-cti-transactions.test.d.ts +1 -0
  176. package/orm/tests/repository-cti-transactions.test.js +126 -0
  177. package/orm/tests/repository-cti-upsert-many.test.d.ts +1 -0
  178. package/orm/tests/repository-cti-upsert-many.test.js +127 -0
  179. package/orm/tests/repository-cti.test.d.ts +1 -0
  180. package/orm/tests/repository-cti.test.js +456 -0
  181. package/orm/tests/repository-edge-cases.test.d.ts +1 -0
  182. package/orm/tests/repository-edge-cases.test.js +216 -0
  183. package/orm/tests/repository-expiration.test.d.ts +1 -0
  184. package/orm/tests/repository-expiration.test.js +153 -0
  185. package/orm/tests/repository-extra-coverage.test.d.ts +1 -0
  186. package/orm/tests/repository-extra-coverage.test.js +546 -0
  187. package/orm/tests/repository-mapping.test.d.ts +1 -0
  188. package/orm/tests/repository-mapping.test.js +71 -0
  189. package/orm/tests/repository-regression.test.d.ts +1 -0
  190. package/orm/tests/repository-regression.test.js +330 -0
  191. package/orm/tests/repository-search-coverage.test.d.ts +1 -0
  192. package/orm/tests/repository-search-coverage.test.js +129 -0
  193. package/orm/tests/repository-search.test.d.ts +1 -0
  194. package/orm/tests/repository-search.test.js +116 -0
  195. package/orm/tests/repository-soft-delete.test.d.ts +1 -0
  196. package/orm/tests/repository-soft-delete.test.js +143 -0
  197. package/orm/tests/repository-transactions-nested.test.d.ts +1 -0
  198. package/orm/tests/repository-transactions-nested.test.js +202 -0
  199. package/orm/tests/repository-types.test.d.ts +1 -0
  200. package/orm/tests/repository-types.test.js +218 -0
  201. package/orm/tests/schema-converter.test.d.ts +1 -0
  202. package/orm/tests/schema-converter.test.js +81 -0
  203. package/orm/tests/schema-generation.test.d.ts +1 -0
  204. package/orm/tests/schema-generation.test.js +127 -0
  205. package/orm/tests/sql-helpers.test.d.ts +1 -0
  206. package/orm/tests/sql-helpers.test.js +67 -0
  207. package/orm/tests/transaction-safety.test.d.ts +1 -0
  208. package/orm/tests/transaction-safety.test.js +81 -0
  209. package/orm/tests/transactional.test.d.ts +1 -0
  210. package/orm/tests/transactional.test.js +224 -0
  211. package/orm/tests/utils.test.d.ts +1 -0
  212. package/orm/tests/utils.test.js +70 -0
  213. package/orm/utils.d.ts +7 -0
  214. package/orm/utils.js +26 -6
  215. package/package.json +12 -7
  216. package/pool/pool.js +1 -1
  217. package/rate-limit/index.d.ts +2 -0
  218. package/rate-limit/index.js +2 -0
  219. package/rate-limit/postgres/drizzle/0000_watery_rage.sql +7 -0
  220. package/{queue → rate-limit}/postgres/drizzle/meta/0000_snapshot.json +14 -39
  221. package/rate-limit/postgres/drizzle/meta/_journal.json +13 -0
  222. package/{queue → rate-limit}/postgres/drizzle.config.js +1 -1
  223. package/rate-limit/postgres/index.d.ts +4 -0
  224. package/rate-limit/postgres/index.js +4 -0
  225. package/rate-limit/postgres/module.d.ts +12 -0
  226. package/rate-limit/postgres/module.js +28 -0
  227. package/rate-limit/postgres/postgres-rate-limiter.d.ts +9 -0
  228. package/rate-limit/postgres/postgres-rate-limiter.js +56 -0
  229. package/rate-limit/postgres/rate-limit.model.d.ts +8 -0
  230. package/rate-limit/postgres/rate-limit.model.js +35 -0
  231. package/rate-limit/postgres/rate-limiter.provider.d.ts +6 -0
  232. package/rate-limit/postgres/rate-limiter.provider.js +21 -0
  233. package/rate-limit/postgres/schemas.d.ts +3 -0
  234. package/rate-limit/postgres/schemas.js +4 -0
  235. package/rate-limit/provider.d.ts +9 -0
  236. package/rate-limit/provider.js +2 -0
  237. package/rate-limit/rate-limiter.d.ts +35 -0
  238. package/rate-limit/rate-limiter.js +3 -0
  239. package/rate-limit/tests/postgres-rate-limiter.test.d.ts +1 -0
  240. package/rate-limit/tests/postgres-rate-limiter.test.js +92 -0
  241. package/signals/implementation/configure.d.ts +3 -0
  242. package/signals/implementation/configure.js +3 -0
  243. package/sse/data-stream-source.d.ts +1 -1
  244. package/sse/data-stream-source.js +6 -6
  245. package/task-queue/enqueue-batch.d.ts +17 -0
  246. package/task-queue/enqueue-batch.js +24 -0
  247. package/{queue → task-queue}/index.d.ts +1 -1
  248. package/{queue → task-queue}/index.js +1 -1
  249. package/task-queue/postgres/drizzle/0000_thin_black_panther.sql +74 -0
  250. package/task-queue/postgres/drizzle/meta/0000_snapshot.json +592 -0
  251. package/task-queue/postgres/drizzle/meta/_journal.json +13 -0
  252. package/task-queue/postgres/drizzle.config.d.ts +2 -0
  253. package/task-queue/postgres/drizzle.config.js +11 -0
  254. package/task-queue/postgres/index.d.ts +4 -0
  255. package/task-queue/postgres/index.js +4 -0
  256. package/task-queue/postgres/module.d.ts +12 -0
  257. package/task-queue/postgres/module.js +28 -0
  258. package/task-queue/postgres/schemas.d.ts +16 -0
  259. package/task-queue/postgres/schemas.js +8 -0
  260. package/task-queue/postgres/task-queue.d.ts +83 -0
  261. package/task-queue/postgres/task-queue.js +1054 -0
  262. package/task-queue/postgres/task-queue.provider.d.ts +7 -0
  263. package/{queue/postgres/queue.provider.js → task-queue/postgres/task-queue.provider.js} +8 -8
  264. package/task-queue/postgres/task.model.d.ts +39 -0
  265. package/task-queue/postgres/task.model.js +178 -0
  266. package/{queue → task-queue}/provider.d.ts +3 -3
  267. package/task-queue/provider.js +2 -0
  268. package/{queue → task-queue}/task-context.d.ts +7 -7
  269. package/{queue → task-queue}/task-context.js +8 -8
  270. package/{queue/queue.d.ts → task-queue/task-queue.d.ts} +128 -59
  271. package/task-queue/task-queue.js +200 -0
  272. package/task-queue/tests/complex.test.d.ts +1 -0
  273. package/task-queue/tests/complex.test.js +299 -0
  274. package/task-queue/tests/dependencies.test.d.ts +1 -0
  275. package/task-queue/tests/dependencies.test.js +174 -0
  276. package/task-queue/tests/queue.test.d.ts +1 -0
  277. package/task-queue/tests/queue.test.js +334 -0
  278. package/task-queue/tests/worker.test.d.ts +1 -0
  279. package/task-queue/tests/worker.test.js +163 -0
  280. package/test1.js +1 -1
  281. package/test4.js +2 -2
  282. package/unit-test/index.d.ts +1 -0
  283. package/unit-test/index.js +1 -0
  284. package/unit-test/integration-setup.d.ts +55 -0
  285. package/unit-test/integration-setup.js +182 -0
  286. package/utils/patterns.d.ts +3 -0
  287. package/utils/patterns.js +6 -1
  288. package/audit/drizzle/0001_previous_network.sql +0 -2
  289. package/audit/drizzle/meta/0001_snapshot.json +0 -195
  290. package/queue/enqueue-batch.d.ts +0 -17
  291. package/queue/enqueue-batch.js +0 -18
  292. package/queue/postgres/drizzle/0000_zippy_moondragon.sql +0 -11
  293. package/queue/postgres/drizzle/0001_certain_wild_pack.sql +0 -2
  294. package/queue/postgres/drizzle/0002_dear_meggan.sql +0 -2
  295. package/queue/postgres/drizzle/0003_tricky_venom.sql +0 -30
  296. package/queue/postgres/drizzle/meta/0001_snapshot.json +0 -103
  297. package/queue/postgres/drizzle/meta/0002_snapshot.json +0 -90
  298. package/queue/postgres/drizzle/meta/0003_snapshot.json +0 -288
  299. package/queue/postgres/drizzle/meta/_journal.json +0 -34
  300. package/queue/postgres/index.d.ts +0 -4
  301. package/queue/postgres/index.js +0 -4
  302. package/queue/postgres/module.d.ts +0 -9
  303. package/queue/postgres/module.js +0 -29
  304. package/queue/postgres/queue.d.ts +0 -60
  305. package/queue/postgres/queue.js +0 -681
  306. package/queue/postgres/queue.provider.d.ts +0 -7
  307. package/queue/postgres/schemas.d.ts +0 -14
  308. package/queue/postgres/schemas.js +0 -6
  309. package/queue/postgres/task.model.d.ts +0 -24
  310. package/queue/postgres/task.model.js +0 -115
  311. package/queue/provider.js +0 -2
  312. package/queue/queue.js +0 -131
  313. package/queue/tests/queue.test.js +0 -623
  314. package/test3.d.ts +0 -1
  315. package/test3.js +0 -47
  316. /package/{queue/tests/queue.test.d.ts → api/server/tests/csrf.middleware.test.d.ts} +0 -0
  317. /package/circuit-breaker/postgres/drizzle/{0000_hard_shocker.sql → 0000_cooing_korath.sql} +0 -0
  318. /package/{queue → rate-limit}/postgres/drizzle.config.d.ts +0 -0
@@ -1,5 +1,5 @@
1
1
  {
2
- "id": "685f89da-0f2a-4523-9cbc-c9daea5f70c2",
2
+ "id": "f52c7376-609d-4fca-a0c2-ee14442d3399",
3
3
  "prevId": "00000000-0000-0000-0000-000000000000",
4
4
  "version": "7",
5
5
  "dialect": "postgresql",
@@ -254,52 +254,52 @@
254
254
  "primaryKey": false,
255
255
  "notNull": true
256
256
  },
257
- "description": {
258
- "name": "description",
259
- "type": "text",
260
- "primaryKey": false,
261
- "notNull": true
262
- },
263
- "parent": {
264
- "name": "parent",
265
- "type": "uuid",
266
- "primaryKey": false,
267
- "notNull": false
268
- },
269
- "revision": {
270
- "name": "revision",
271
- "type": "integer",
257
+ "type": {
258
+ "name": "type",
259
+ "type": "subject_type",
260
+ "typeSchema": "authentication",
272
261
  "primaryKey": false,
273
262
  "notNull": true
274
263
  },
275
- "revision_timestamp": {
276
- "name": "revision_timestamp",
277
- "type": "timestamp with time zone",
264
+ "display_name": {
265
+ "name": "display_name",
266
+ "type": "text",
278
267
  "primaryKey": false,
279
268
  "notNull": true
280
269
  },
281
- "create_timestamp": {
282
- "name": "create_timestamp",
283
- "type": "timestamp with time zone",
270
+ "description": {
271
+ "name": "description",
272
+ "type": "text",
284
273
  "primaryKey": false,
285
274
  "notNull": true
286
275
  },
287
- "delete_timestamp": {
288
- "name": "delete_timestamp",
289
- "type": "timestamp with time zone",
276
+ "parent": {
277
+ "name": "parent",
278
+ "type": "uuid",
290
279
  "primaryKey": false,
291
280
  "notNull": false
292
- },
293
- "attributes": {
294
- "name": "attributes",
295
- "type": "jsonb",
296
- "primaryKey": false,
297
- "notNull": true,
298
- "default": "'{}'::jsonb"
299
281
  }
300
282
  },
301
283
  "indexes": {},
302
284
  "foreignKeys": {
285
+ "service_account_tenantId_type_id_subject_fkey": {
286
+ "name": "service_account_tenantId_type_id_subject_fkey",
287
+ "tableFrom": "service_account",
288
+ "tableTo": "subject",
289
+ "schemaTo": "authentication",
290
+ "columnsFrom": [
291
+ "tenant_id",
292
+ "type",
293
+ "id"
294
+ ],
295
+ "columnsTo": [
296
+ "tenant_id",
297
+ "type",
298
+ "id"
299
+ ],
300
+ "onDelete": "cascade",
301
+ "onUpdate": "no action"
302
+ },
303
303
  "service_account_id_subject_fkey": {
304
304
  "name": "service_account_id_subject_fkey",
305
305
  "tableFrom": "service_account",
@@ -326,9 +326,31 @@
326
326
  ]
327
327
  }
328
328
  },
329
- "uniqueConstraints": {},
329
+ "uniqueConstraints": {
330
+ "service_account_tenant_id_type_id_unique": {
331
+ "name": "service_account_tenant_id_type_id_unique",
332
+ "nullsNotDistinct": false,
333
+ "columns": [
334
+ "tenant_id",
335
+ "type",
336
+ "id"
337
+ ]
338
+ },
339
+ "service_account_id_unique": {
340
+ "name": "service_account_id_unique",
341
+ "nullsNotDistinct": false,
342
+ "columns": [
343
+ "id"
344
+ ]
345
+ }
346
+ },
330
347
  "policies": {},
331
- "checkConstraints": {},
348
+ "checkConstraints": {
349
+ "service_account_type_check": {
350
+ "name": "service_account_type_check",
351
+ "value": "\"authentication\".\"service_account\".\"type\" = 'service-account'"
352
+ }
353
+ },
332
354
  "isRLSEnabled": false
333
355
  },
334
356
  "authentication.subject": {
@@ -355,27 +377,16 @@
355
377
  "primaryKey": false,
356
378
  "notNull": true
357
379
  },
358
- "display_name": {
359
- "name": "display_name",
360
- "type": "text",
380
+ "status": {
381
+ "name": "status",
382
+ "type": "subject_status",
383
+ "typeSchema": "authentication",
361
384
  "primaryKey": false,
362
385
  "notNull": true
363
386
  },
364
- "system_account_id": {
365
- "name": "system_account_id",
366
- "type": "uuid",
367
- "primaryKey": false,
368
- "notNull": false
369
- },
370
- "user_id": {
371
- "name": "user_id",
372
- "type": "uuid",
373
- "primaryKey": false,
374
- "notNull": false
375
- },
376
- "service_account_id": {
377
- "name": "service_account_id",
378
- "type": "uuid",
387
+ "last_activity_timestamp": {
388
+ "name": "last_activity_timestamp",
389
+ "type": "timestamp with time zone",
379
390
  "primaryKey": false,
380
391
  "notNull": false
381
392
  },
@@ -412,56 +423,7 @@
412
423
  }
413
424
  },
414
425
  "indexes": {},
415
- "foreignKeys": {
416
- "subject_id_system_account_fkey": {
417
- "name": "subject_id_system_account_fkey",
418
- "tableFrom": "subject",
419
- "tableTo": "system_account",
420
- "schemaTo": "authentication",
421
- "columnsFrom": [
422
- "tenant_id",
423
- "system_account_id"
424
- ],
425
- "columnsTo": [
426
- "tenant_id",
427
- "id"
428
- ],
429
- "onDelete": "no action",
430
- "onUpdate": "no action"
431
- },
432
- "subject_id_user_fkey": {
433
- "name": "subject_id_user_fkey",
434
- "tableFrom": "subject",
435
- "tableTo": "user",
436
- "schemaTo": "authentication",
437
- "columnsFrom": [
438
- "tenant_id",
439
- "user_id"
440
- ],
441
- "columnsTo": [
442
- "tenant_id",
443
- "id"
444
- ],
445
- "onDelete": "no action",
446
- "onUpdate": "no action"
447
- },
448
- "subject_id_service_account_fkey": {
449
- "name": "subject_id_service_account_fkey",
450
- "tableFrom": "subject",
451
- "tableTo": "service_account",
452
- "schemaTo": "authentication",
453
- "columnsFrom": [
454
- "tenant_id",
455
- "service_account_id"
456
- ],
457
- "columnsTo": [
458
- "tenant_id",
459
- "id"
460
- ],
461
- "onDelete": "no action",
462
- "onUpdate": "no action"
463
- }
464
- },
426
+ "foreignKeys": {},
465
427
  "compositePrimaryKeys": {
466
428
  "subject_tenant_id_id_pk": {
467
429
  "name": "subject_tenant_id_id_pk",
@@ -472,28 +434,13 @@
472
434
  }
473
435
  },
474
436
  "uniqueConstraints": {
475
- "subject_tenant_id_service_account_id_unique": {
476
- "name": "subject_tenant_id_service_account_id_unique",
477
- "nullsNotDistinct": false,
478
- "columns": [
479
- "tenant_id",
480
- "service_account_id"
481
- ]
482
- },
483
- "subject_tenant_id_user_id_unique": {
484
- "name": "subject_tenant_id_user_id_unique",
437
+ "subject_tenant_id_type_id_unique": {
438
+ "name": "subject_tenant_id_type_id_unique",
485
439
  "nullsNotDistinct": false,
486
440
  "columns": [
487
441
  "tenant_id",
488
- "user_id"
489
- ]
490
- },
491
- "subject_tenant_id_system_account_id_unique": {
492
- "name": "subject_tenant_id_system_account_id_unique",
493
- "nullsNotDistinct": false,
494
- "columns": [
495
- "tenant_id",
496
- "system_account_id"
442
+ "type",
443
+ "id"
497
444
  ]
498
445
  },
499
446
  "subject_id_unique": {
@@ -505,12 +452,7 @@
505
452
  }
506
453
  },
507
454
  "policies": {},
508
- "checkConstraints": {
509
- "authentication_subject_reference_check": {
510
- "name": "authentication_subject_reference_check",
511
- "value": "num_nonnulls(\"authentication\".\"subject\".\"system_account_id\", \"authentication\".\"subject\".\"user_id\", \"authentication\".\"subject\".\"service_account_id\") = 1"
512
- }
513
- },
455
+ "checkConstraints": {},
514
456
  "isRLSEnabled": false
515
457
  },
516
458
  "authentication.system_account": {
@@ -530,46 +472,47 @@
530
472
  "primaryKey": false,
531
473
  "notNull": true
532
474
  },
533
- "identifier": {
534
- "name": "identifier",
535
- "type": "text",
536
- "primaryKey": false,
537
- "notNull": true
538
- },
539
- "revision": {
540
- "name": "revision",
541
- "type": "integer",
475
+ "type": {
476
+ "name": "type",
477
+ "type": "subject_type",
478
+ "typeSchema": "authentication",
542
479
  "primaryKey": false,
543
480
  "notNull": true
544
481
  },
545
- "revision_timestamp": {
546
- "name": "revision_timestamp",
547
- "type": "timestamp with time zone",
482
+ "identifier": {
483
+ "name": "identifier",
484
+ "type": "text",
548
485
  "primaryKey": false,
549
486
  "notNull": true
550
487
  },
551
- "create_timestamp": {
552
- "name": "create_timestamp",
553
- "type": "timestamp with time zone",
488
+ "display_name": {
489
+ "name": "display_name",
490
+ "type": "text",
554
491
  "primaryKey": false,
555
492
  "notNull": true
556
- },
557
- "delete_timestamp": {
558
- "name": "delete_timestamp",
559
- "type": "timestamp with time zone",
560
- "primaryKey": false,
561
- "notNull": false
562
- },
563
- "attributes": {
564
- "name": "attributes",
565
- "type": "jsonb",
566
- "primaryKey": false,
567
- "notNull": true,
568
- "default": "'{}'::jsonb"
569
493
  }
570
494
  },
571
495
  "indexes": {},
572
- "foreignKeys": {},
496
+ "foreignKeys": {
497
+ "system_account_tenantId_type_id_subject_fkey": {
498
+ "name": "system_account_tenantId_type_id_subject_fkey",
499
+ "tableFrom": "system_account",
500
+ "tableTo": "subject",
501
+ "schemaTo": "authentication",
502
+ "columnsFrom": [
503
+ "tenant_id",
504
+ "type",
505
+ "id"
506
+ ],
507
+ "columnsTo": [
508
+ "tenant_id",
509
+ "type",
510
+ "id"
511
+ ],
512
+ "onDelete": "cascade",
513
+ "onUpdate": "no action"
514
+ }
515
+ },
573
516
  "compositePrimaryKeys": {
574
517
  "system_account_tenant_id_id_pk": {
575
518
  "name": "system_account_tenant_id_id_pk",
@@ -580,16 +523,38 @@
580
523
  }
581
524
  },
582
525
  "uniqueConstraints": {
583
- "system_account_identifier_unique": {
584
- "name": "system_account_identifier_unique",
526
+ "system_account_tenant_id_type_id_unique": {
527
+ "name": "system_account_tenant_id_type_id_unique",
585
528
  "nullsNotDistinct": false,
586
529
  "columns": [
530
+ "tenant_id",
531
+ "type",
532
+ "id"
533
+ ]
534
+ },
535
+ "system_account_tenant_id_identifier_unique": {
536
+ "name": "system_account_tenant_id_identifier_unique",
537
+ "nullsNotDistinct": false,
538
+ "columns": [
539
+ "tenant_id",
587
540
  "identifier"
588
541
  ]
542
+ },
543
+ "system_account_id_unique": {
544
+ "name": "system_account_id_unique",
545
+ "nullsNotDistinct": false,
546
+ "columns": [
547
+ "id"
548
+ ]
589
549
  }
590
550
  },
591
551
  "policies": {},
592
- "checkConstraints": {},
552
+ "checkConstraints": {
553
+ "system_account_type_check": {
554
+ "name": "system_account_type_check",
555
+ "value": "\"authentication\".\"system_account\".\"type\" = 'system'"
556
+ }
557
+ },
593
558
  "isRLSEnabled": false
594
559
  },
595
560
  "authentication.user": {
@@ -609,9 +574,9 @@
609
574
  "primaryKey": false,
610
575
  "notNull": true
611
576
  },
612
- "status": {
613
- "name": "status",
614
- "type": "user_status",
577
+ "type": {
578
+ "name": "type",
579
+ "type": "subject_type",
615
580
  "typeSchema": "authentication",
616
581
  "primaryKey": false,
617
582
  "notNull": true
@@ -633,41 +598,29 @@
633
598
  "type": "text",
634
599
  "primaryKey": false,
635
600
  "notNull": true
636
- },
637
- "revision": {
638
- "name": "revision",
639
- "type": "integer",
640
- "primaryKey": false,
641
- "notNull": true
642
- },
643
- "revision_timestamp": {
644
- "name": "revision_timestamp",
645
- "type": "timestamp with time zone",
646
- "primaryKey": false,
647
- "notNull": true
648
- },
649
- "create_timestamp": {
650
- "name": "create_timestamp",
651
- "type": "timestamp with time zone",
652
- "primaryKey": false,
653
- "notNull": true
654
- },
655
- "delete_timestamp": {
656
- "name": "delete_timestamp",
657
- "type": "timestamp with time zone",
658
- "primaryKey": false,
659
- "notNull": false
660
- },
661
- "attributes": {
662
- "name": "attributes",
663
- "type": "jsonb",
664
- "primaryKey": false,
665
- "notNull": true,
666
- "default": "'{}'::jsonb"
667
601
  }
668
602
  },
669
603
  "indexes": {},
670
- "foreignKeys": {},
604
+ "foreignKeys": {
605
+ "user_tenantId_type_id_subject_fkey": {
606
+ "name": "user_tenantId_type_id_subject_fkey",
607
+ "tableFrom": "user",
608
+ "tableTo": "subject",
609
+ "schemaTo": "authentication",
610
+ "columnsFrom": [
611
+ "tenant_id",
612
+ "type",
613
+ "id"
614
+ ],
615
+ "columnsTo": [
616
+ "tenant_id",
617
+ "type",
618
+ "id"
619
+ ],
620
+ "onDelete": "cascade",
621
+ "onUpdate": "no action"
622
+ }
623
+ },
671
624
  "compositePrimaryKeys": {
672
625
  "user_tenant_id_id_pk": {
673
626
  "name": "user_tenant_id_id_pk",
@@ -678,6 +631,15 @@
678
631
  }
679
632
  },
680
633
  "uniqueConstraints": {
634
+ "user_tenant_id_type_id_unique": {
635
+ "name": "user_tenant_id_type_id_unique",
636
+ "nullsNotDistinct": false,
637
+ "columns": [
638
+ "tenant_id",
639
+ "type",
640
+ "id"
641
+ ]
642
+ },
681
643
  "user_tenant_id_email_unique": {
682
644
  "name": "user_tenant_id_email_unique",
683
645
  "nullsNotDistinct": false,
@@ -685,14 +647,37 @@
685
647
  "tenant_id",
686
648
  "email"
687
649
  ]
650
+ },
651
+ "user_id_unique": {
652
+ "name": "user_id_unique",
653
+ "nullsNotDistinct": false,
654
+ "columns": [
655
+ "id"
656
+ ]
688
657
  }
689
658
  },
690
659
  "policies": {},
691
- "checkConstraints": {},
660
+ "checkConstraints": {
661
+ "user_type_check": {
662
+ "name": "user_type_check",
663
+ "value": "\"authentication\".\"user\".\"type\" = 'user'"
664
+ }
665
+ },
692
666
  "isRLSEnabled": false
693
667
  }
694
668
  },
695
669
  "enums": {
670
+ "authentication.subject_status": {
671
+ "name": "subject_status",
672
+ "schema": "authentication",
673
+ "values": [
674
+ "active",
675
+ "inactive",
676
+ "suspended",
677
+ "pending-approval",
678
+ "invited"
679
+ ]
680
+ },
696
681
  "authentication.subject_type": {
697
682
  "name": "subject_type",
698
683
  "schema": "authentication",
@@ -701,16 +686,6 @@
701
686
  "user",
702
687
  "service-account"
703
688
  ]
704
- },
705
- "authentication.user_status": {
706
- "name": "user_status",
707
- "schema": "authentication",
708
- "values": [
709
- "active",
710
- "suspended",
711
- "pending-approval",
712
- "invited"
713
- ]
714
689
  }
715
690
  },
716
691
  "schemas": {},
@@ -5,8 +5,8 @@
5
5
  {
6
6
  "idx": 0,
7
7
  "version": "7",
8
- "when": 1767839299143,
9
- "tag": "0000_normal_paper_doll",
8
+ "when": 1768668305913,
9
+ "tag": "0000_soft_tag",
10
10
  "breakpoints": true
11
11
  }
12
12
  ]
@@ -11,8 +11,15 @@ import { isArray, isDefined, isUndefined } from '../../utils/type-guards.js';
11
11
  * @returns The token string or undefined if not found.
12
12
  */
13
13
  export function tryGetAuthorizationTokenStringFromRequest(request, cookieName = 'authorization', fromCookieOnly = false) {
14
- const authorizationHeaders = (fromCookieOnly || (cookieName.toLocaleLowerCase() != 'authorization')) ? undefined : request.headers.tryGet('Authorization');
15
- const authorizationString = (isArray(authorizationHeaders) ? authorizationHeaders[0] : authorizationHeaders)
14
+ const headerName = (cookieName.toLocaleLowerCase() == 'authorization')
15
+ ? 'Authorization'
16
+ : (cookieName.toLocaleLowerCase() == 'refreshtoken')
17
+ ? 'X-Refresh-Token'
18
+ : (cookieName.toLocaleLowerCase() == 'impersonatorrefreshtoken')
19
+ ? 'X-Impersonator-Refresh-Token'
20
+ : undefined;
21
+ const headerValue = (fromCookieOnly || isUndefined(headerName)) ? undefined : request.headers.tryGet(headerName);
22
+ const authorizationString = (isArray(headerValue) ? headerValue[0] : headerValue)
16
23
  ?? request.cookies.tryGet(cookieName);
17
24
  if (isDefined(authorizationString)) {
18
25
  const authorizationSchemeEnd = authorizationString.indexOf(' ');
@@ -1,3 +1,4 @@
1
+ import { Injector } from '../../injector/injector.js';
1
2
  import type { Provider } from '../../injector/provider.js';
2
3
  import type { InjectionToken } from '../../injector/token.js';
3
4
  import { type DatabaseConfig } from '../../orm/server/index.js';
@@ -29,7 +30,9 @@ export declare class AuthenticationModuleConfig {
29
30
  * Configures authentication server services.
30
31
  * @param config Configuration.
31
32
  */
32
- export declare function configureAuthenticationServer(config: AuthenticationModuleConfig): void;
33
+ export declare function configureAuthenticationServer({ injector, ...config }: AuthenticationModuleConfig & {
34
+ injector?: Injector;
35
+ }): void;
33
36
  /**
34
37
  * Migrates the authentication schema.
35
38
  */
@@ -1,9 +1,11 @@
1
+ import { ApiRequestTokenProvider } from '../../api/server/api-request-token.provider.js';
1
2
  import { inject } from '../../injector/index.js';
2
3
  import { Injector } from '../../injector/injector.js';
3
4
  import { isProvider } from '../../injector/provider.js';
4
5
  import { Database, migrate } from '../../orm/server/index.js';
5
6
  import { isDefined } from '../../utils/type-guards.js';
6
7
  import { AuthenticationAncillaryService } from './authentication-ancillary.service.js';
8
+ import { AuthenticationApiRequestTokenProvider } from './authentication-api-request-token.provider.js';
7
9
  import { AuthenticationService, AuthenticationServiceOptions } from './authentication.service.js';
8
10
  /**
9
11
  * Configuration for {@link configureAuthenticationServer}.
@@ -31,14 +33,16 @@ export class AuthenticationModuleConfig {
31
33
  * Configures authentication server services.
32
34
  * @param config Configuration.
33
35
  */
34
- export function configureAuthenticationServer(config) {
35
- Injector.register(AuthenticationModuleConfig, { useValue: config });
36
- Injector.register(AuthenticationServiceOptions, isProvider(config.serviceOptions) ? config.serviceOptions : { useValue: config.serviceOptions });
36
+ export function configureAuthenticationServer({ injector, ...config }) {
37
+ const targetInjector = injector ?? Injector;
38
+ targetInjector.register(AuthenticationModuleConfig, { useValue: config });
39
+ targetInjector.register(AuthenticationServiceOptions, isProvider(config.serviceOptions) ? config.serviceOptions : { useValue: config.serviceOptions });
40
+ targetInjector.register(ApiRequestTokenProvider, { useToken: AuthenticationApiRequestTokenProvider });
37
41
  if (isDefined(config.authenticationService)) {
38
- Injector.registerSingleton(AuthenticationService, { useToken: config.authenticationService });
42
+ targetInjector.registerSingleton(AuthenticationService, { useToken: config.authenticationService });
39
43
  }
40
44
  if (isDefined(config.authenticationAncillaryService)) {
41
- Injector.registerSingleton(AuthenticationAncillaryService, { useToken: config.authenticationAncillaryService });
45
+ targetInjector.registerSingleton(AuthenticationAncillaryService, { useToken: config.authenticationAncillaryService });
42
46
  }
43
47
  }
44
48
  /**
@@ -5,8 +5,9 @@ export declare const subjectType: import("../../orm/enums.js").PgEnumFromEnumera
5
5
  readonly User: "user";
6
6
  readonly ServiceAccount: "service-account";
7
7
  }>;
8
- export declare const userStatus: import("../../orm/enums.js").PgEnumFromEnumeration<{
8
+ export declare const subjectStatus: import("../../orm/enums.js").PgEnumFromEnumeration<{
9
9
  readonly Active: "active";
10
+ readonly Inactive: "inactive";
10
11
  readonly Suspended: "suspended";
11
12
  readonly PendingApproval: "pending-approval";
12
13
  readonly Invited: "invited";
@@ -1,8 +1,8 @@
1
1
  import { databaseSchema } from '../../orm/server/index.js';
2
- import { AuthenticationCredentials, AuthenticationSession, ServiceAccount, Subject, SubjectType, SystemAccount, User, UserStatus } from '../models/index.js';
2
+ import { AuthenticationCredentials, AuthenticationSession, ServiceAccount, Subject, SubjectStatus, SubjectType, SystemAccount, User } from '../models/index.js';
3
3
  export const authenticationSchema = databaseSchema('authentication');
4
4
  export const subjectType = authenticationSchema.getEnum(SubjectType);
5
- export const userStatus = authenticationSchema.getEnum(UserStatus);
5
+ export const subjectStatus = authenticationSchema.getEnum(SubjectStatus);
6
6
  export const authenticationCredentials = authenticationSchema.getTable(AuthenticationCredentials);
7
7
  export const authenticationSession = authenticationSchema.getTable(AuthenticationSession);
8
8
  export const serviceAccount = authenticationSchema.getTable(ServiceAccount);
@@ -1,22 +1,28 @@
1
- import { ServiceAccount, Subject, User } from '../models/index.js';
1
+ import type { LoadOptions } from '../../orm/repository.types.js';
2
+ import { ServiceAccount, Subject, SystemAccount, User } from '../models/index.js';
2
3
  export type CreateUser = Pick<User, 'tenantId' | 'email' | 'firstName' | 'lastName'> & Partial<Pick<User, 'status'>>;
3
- export type CreateServiceAccount = Pick<ServiceAccount, 'tenantId' | 'description' | 'parent'>;
4
+ export type CreateServiceAccount = Pick<ServiceAccount, 'tenantId' | 'displayName' | 'description' | 'parent'> & Partial<Pick<ServiceAccount, 'status'>>;
4
5
  export declare class SubjectService {
5
6
  #private;
6
- getSubject(id: string): Promise<Subject>;
7
- tryGetSubject(id: string): Promise<Subject | undefined>;
8
- getSystemAccountSubject(tenantId: string, identifier: string): Promise<Subject>;
7
+ getSubject(id: string, options?: LoadOptions<Subject>): Promise<Subject>;
8
+ tryGetSubject(id: string, options?: LoadOptions<Subject>): Promise<Subject | undefined>;
9
+ getSystemAccount(tenantId: string, identifier: string): Promise<SystemAccount>;
9
10
  createUser(data: CreateUser): Promise<User>;
10
11
  updateUser(tenantId: string, userId: string, data: Partial<Pick<User, 'firstName' | 'lastName' | 'status'>>): Promise<void>;
11
12
  updateUserEmail(tenantId: string, userId: string, email: string): Promise<void>;
12
- getUserSubject(tenantId: string, userId: string): Promise<Subject>;
13
+ getUser(tenantId: string, userId: string): Promise<User>;
13
14
  getUserByEmail(tenantId: string, email: string): Promise<User>;
14
15
  tryGetUserByEmail(tenantId: string, email: string): Promise<User | undefined>;
15
16
  hasUserByEmail(tenantId: string, email: string): Promise<boolean>;
16
17
  getUserBySubject(subject: Subject): Promise<User>;
17
18
  loadManyUsersByEmails(tenantId: string, emails: string[]): Promise<User[]>;
18
19
  createServiceAccount(data: CreateServiceAccount): Promise<ServiceAccount>;
19
- updateServiceAccount(tenantId: string, serviceAccountId: string, data: Partial<Pick<ServiceAccount, 'description'>> & Partial<Pick<Subject, 'displayName'>>): Promise<void>;
20
- getServiceAccountSubject(tenantId: string, serviceAccountId: string): Promise<Subject>;
20
+ updateServiceAccount(tenantId: string, serviceAccountId: string, data: Partial<Pick<ServiceAccount, 'description' | 'displayName' | 'status'>>): Promise<void>;
21
+ getServiceAccount(tenantId: string, serviceAccountId: string): Promise<ServiceAccount>;
21
22
  getServiceAccountBySubject(subject: Subject): Promise<ServiceAccount>;
23
+ exists(tenantId: string, id: string): Promise<boolean>;
24
+ deleteUser(tenantId: string, userId: string): Promise<void>;
25
+ deleteServiceAccount(tenantId: string, serviceAccountId: string): Promise<void>;
26
+ listUsers(tenantId: string): Promise<User[]>;
27
+ listServiceAccounts(tenantId: string): Promise<ServiceAccount[]>;
22
28
  }