@solidxai/core 0.1.11-beta.1 → 0.1.11-beta.11

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 (244) hide show
  1. package/.claude/settings.local.json +16 -0
  2. package/CLAUDE.md +26 -0
  3. package/dist/commands/migrate-removed-fields.command.d.ts +19 -0
  4. package/dist/commands/migrate-removed-fields.command.d.ts.map +1 -0
  5. package/dist/commands/migrate-removed-fields.command.js +77 -0
  6. package/dist/commands/migrate-removed-fields.command.js.map +1 -0
  7. package/dist/controllers/datasource-introspection.controller.d.ts +46 -1
  8. package/dist/controllers/datasource-introspection.controller.d.ts.map +1 -1
  9. package/dist/controllers/datasource-introspection.controller.js +38 -0
  10. package/dist/controllers/datasource-introspection.controller.js.map +1 -1
  11. package/dist/controllers/service.controller.d.ts +1 -0
  12. package/dist/controllers/service.controller.d.ts.map +1 -1
  13. package/dist/controllers/service.controller.js +2 -2
  14. package/dist/controllers/service.controller.js.map +1 -1
  15. package/dist/dtos/datasource-introspection-mapping.dto.d.ts +5 -0
  16. package/dist/dtos/datasource-introspection-mapping.dto.d.ts.map +1 -1
  17. package/dist/dtos/datasource-introspection-mapping.dto.js +24 -2
  18. package/dist/dtos/datasource-introspection-mapping.dto.js.map +1 -1
  19. package/dist/entities/{legacy-common-with-id.entity.d.ts → legacy-common-with-generated-id.entity.d.ts} +2 -2
  20. package/dist/entities/legacy-common-with-generated-id.entity.d.ts.map +1 -0
  21. package/dist/entities/{legacy-common-with-id.entity.js → legacy-common-with-generated-id.entity.js} +4 -4
  22. package/dist/entities/legacy-common-with-generated-id.entity.js.map +1 -0
  23. package/dist/entities/{legacy-common.entity.d.ts → legacy-common.entity-with-existing-id.entity.d.ts} +1 -1
  24. package/dist/entities/legacy-common.entity-with-existing-id.entity.d.ts.map +1 -0
  25. package/dist/entities/{legacy-common.entity.js → legacy-common.entity-with-existing-id.entity.js} +1 -1
  26. package/dist/entities/legacy-common.entity-with-existing-id.entity.js.map +1 -0
  27. package/dist/helpers/command.service.d.ts +2 -0
  28. package/dist/helpers/command.service.d.ts.map +1 -1
  29. package/dist/helpers/command.service.js +6 -2
  30. package/dist/helpers/command.service.js.map +1 -1
  31. package/dist/helpers/environment.helper.d.ts +1 -0
  32. package/dist/helpers/environment.helper.d.ts.map +1 -1
  33. package/dist/helpers/environment.helper.js +4 -0
  34. package/dist/helpers/environment.helper.js.map +1 -1
  35. package/dist/helpers/field-crud-managers/IntFieldCrudManager.d.ts.map +1 -1
  36. package/dist/helpers/field-crud-managers/IntFieldCrudManager.js +4 -1
  37. package/dist/helpers/field-crud-managers/IntFieldCrudManager.js.map +1 -1
  38. package/dist/helpers/model-metadata-helper.service.d.ts +2 -1
  39. package/dist/helpers/model-metadata-helper.service.d.ts.map +1 -1
  40. package/dist/helpers/model-metadata-helper.service.js +9 -5
  41. package/dist/helpers/model-metadata-helper.service.js.map +1 -1
  42. package/dist/helpers/nodemon-heartbeat.d.ts +5 -0
  43. package/dist/helpers/nodemon-heartbeat.d.ts.map +1 -0
  44. package/dist/helpers/nodemon-heartbeat.js +67 -0
  45. package/dist/helpers/nodemon-heartbeat.js.map +1 -0
  46. package/dist/helpers/solid-registry.d.ts +2 -1
  47. package/dist/helpers/solid-registry.d.ts.map +1 -1
  48. package/dist/helpers/solid-registry.js.map +1 -1
  49. package/dist/helpers/typeorm-db-helper.d.ts +1 -0
  50. package/dist/helpers/typeorm-db-helper.d.ts.map +1 -1
  51. package/dist/helpers/typeorm-db-helper.js +12 -0
  52. package/dist/helpers/typeorm-db-helper.js.map +1 -1
  53. package/dist/index.d.ts +3 -2
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +3 -2
  56. package/dist/index.js.map +1 -1
  57. package/dist/interfaces/datasource-introspection-provider.interface.d.ts +1 -0
  58. package/dist/interfaces/datasource-introspection-provider.interface.d.ts.map +1 -1
  59. package/dist/interfaces/datasource-introspection-provider.interface.js.map +1 -1
  60. package/dist/interfaces.d.ts +1 -0
  61. package/dist/interfaces.d.ts.map +1 -1
  62. package/dist/interfaces.js.map +1 -1
  63. package/dist/repository/scheduled-job.repository.d.ts +2 -2
  64. package/dist/repository/scheduled-job.repository.d.ts.map +1 -1
  65. package/dist/repository/scheduled-job.repository.js +6 -3
  66. package/dist/repository/scheduled-job.repository.js.map +1 -1
  67. package/dist/repository/security-rule.repository.d.ts +2 -2
  68. package/dist/repository/security-rule.repository.d.ts.map +1 -1
  69. package/dist/repository/security-rule.repository.js +6 -3
  70. package/dist/repository/security-rule.repository.js.map +1 -1
  71. package/dist/seeders/module-metadata-seeder.service.d.ts +11 -1
  72. package/dist/seeders/module-metadata-seeder.service.d.ts.map +1 -1
  73. package/dist/seeders/module-metadata-seeder.service.js +163 -3
  74. package/dist/seeders/module-metadata-seeder.service.js.map +1 -1
  75. package/dist/seeders/seed-data/solid-core-metadata.json +128 -34
  76. package/dist/services/api-key.service.d.ts.map +1 -1
  77. package/dist/services/api-key.service.js.map +1 -1
  78. package/dist/services/authentication.service.d.ts +2 -0
  79. package/dist/services/authentication.service.d.ts.map +1 -1
  80. package/dist/services/authentication.service.js +32 -11
  81. package/dist/services/authentication.service.js.map +1 -1
  82. package/dist/services/computed-fields/entity/alpha-num-external-id-computed-field-provider.d.ts.map +1 -1
  83. package/dist/services/computed-fields/entity/alpha-num-external-id-computed-field-provider.js +7 -5
  84. package/dist/services/computed-fields/entity/alpha-num-external-id-computed-field-provider.js.map +1 -1
  85. package/dist/services/computed-fields/entity/concat-entity-computed-field-provider.service.d.ts +4 -0
  86. package/dist/services/computed-fields/entity/concat-entity-computed-field-provider.service.d.ts.map +1 -1
  87. package/dist/services/computed-fields/entity/concat-entity-computed-field-provider.service.js +18 -1
  88. package/dist/services/computed-fields/entity/concat-entity-computed-field-provider.service.js.map +1 -1
  89. package/dist/services/crud-helper.service.d.ts.map +1 -1
  90. package/dist/services/crud-helper.service.js +25 -12
  91. package/dist/services/crud-helper.service.js.map +1 -1
  92. package/dist/services/crud.service.d.ts +1 -0
  93. package/dist/services/crud.service.d.ts.map +1 -1
  94. package/dist/services/crud.service.js +27 -0
  95. package/dist/services/crud.service.js.map +1 -1
  96. package/dist/services/datasource-introspection/mssql-datasource-introspection-provider.service.d.ts.map +1 -1
  97. package/dist/services/datasource-introspection/mssql-datasource-introspection-provider.service.js +12 -0
  98. package/dist/services/datasource-introspection/mssql-datasource-introspection-provider.service.js.map +1 -1
  99. package/dist/services/datasource-introspection/mysql-datasource-introspection-provider.service.d.ts.map +1 -1
  100. package/dist/services/datasource-introspection/mysql-datasource-introspection-provider.service.js +2 -0
  101. package/dist/services/datasource-introspection/mysql-datasource-introspection-provider.service.js.map +1 -1
  102. package/dist/services/datasource-introspection/postgres-datasource-introspection-provider.service.d.ts.map +1 -1
  103. package/dist/services/datasource-introspection/postgres-datasource-introspection-provider.service.js +28 -15
  104. package/dist/services/datasource-introspection/postgres-datasource-introspection-provider.service.js.map +1 -1
  105. package/dist/services/datasource-introspection.service.d.ts +62 -2
  106. package/dist/services/datasource-introspection.service.d.ts.map +1 -1
  107. package/dist/services/datasource-introspection.service.js +654 -186
  108. package/dist/services/datasource-introspection.service.js.map +1 -1
  109. package/dist/services/import-transaction.service.d.ts.map +1 -1
  110. package/dist/services/import-transaction.service.js +3 -0
  111. package/dist/services/import-transaction.service.js.map +1 -1
  112. package/dist/services/locale.service.d.ts +14 -0
  113. package/dist/services/locale.service.d.ts.map +1 -1
  114. package/dist/services/locale.service.js +83 -0
  115. package/dist/services/locale.service.js.map +1 -1
  116. package/dist/services/mediaStorageProviders/file-s3-storage-provider.js +10 -10
  117. package/dist/services/mediaStorageProviders/file-s3-storage-provider.js.map +1 -1
  118. package/dist/services/menu-item-metadata.service.d.ts.map +1 -1
  119. package/dist/services/menu-item-metadata.service.js +1 -0
  120. package/dist/services/menu-item-metadata.service.js.map +1 -1
  121. package/dist/services/model-metadata.service.d.ts +3 -0
  122. package/dist/services/model-metadata.service.d.ts.map +1 -1
  123. package/dist/services/model-metadata.service.js +78 -0
  124. package/dist/services/model-metadata.service.js.map +1 -1
  125. package/dist/services/module-metadata.service.d.ts.map +1 -1
  126. package/dist/services/module-metadata.service.js +28 -0
  127. package/dist/services/module-metadata.service.js.map +1 -1
  128. package/dist/services/removed-field-migration.service.d.ts +30 -0
  129. package/dist/services/removed-field-migration.service.d.ts.map +1 -0
  130. package/dist/services/removed-field-migration.service.js +319 -0
  131. package/dist/services/removed-field-migration.service.js.map +1 -0
  132. package/dist/services/role-metadata.service.d.ts +1 -0
  133. package/dist/services/role-metadata.service.d.ts.map +1 -1
  134. package/dist/services/role-metadata.service.js +23 -2
  135. package/dist/services/role-metadata.service.js.map +1 -1
  136. package/dist/services/settings/default-settings-provider.service.d.ts +244 -0
  137. package/dist/services/settings/default-settings-provider.service.d.ts.map +1 -1
  138. package/dist/services/settings/default-settings-provider.service.js +120 -0
  139. package/dist/services/settings/default-settings-provider.service.js.map +1 -1
  140. package/dist/services/solid-ts-morph.service.d.ts +6 -0
  141. package/dist/services/solid-ts-morph.service.d.ts.map +1 -1
  142. package/dist/services/solid-ts-morph.service.js +43 -0
  143. package/dist/services/solid-ts-morph.service.js.map +1 -1
  144. package/dist/services/view-metadata.service.d.ts.map +1 -1
  145. package/dist/services/view-metadata.service.js +4 -7
  146. package/dist/services/view-metadata.service.js.map +1 -1
  147. package/dist/solid-core.module.d.ts.map +1 -1
  148. package/dist/solid-core.module.js +4 -0
  149. package/dist/solid-core.module.js.map +1 -1
  150. package/dist/subscribers/audit.subscriber.d.ts +5 -1
  151. package/dist/subscribers/audit.subscriber.d.ts.map +1 -1
  152. package/dist/subscribers/audit.subscriber.js +76 -12
  153. package/dist/subscribers/audit.subscriber.js.map +1 -1
  154. package/dist/subscribers/computed-entity-field.subscriber.d.ts +9 -1
  155. package/dist/subscribers/computed-entity-field.subscriber.d.ts.map +1 -1
  156. package/dist/subscribers/computed-entity-field.subscriber.js +45 -11
  157. package/dist/subscribers/computed-entity-field.subscriber.js.map +1 -1
  158. package/dist/subscribers/created-by-updated-by.subscriber.d.ts.map +1 -1
  159. package/dist/subscribers/created-by-updated-by.subscriber.js.map +1 -1
  160. package/dist/subscribers/field-metadata.subscriber.d.ts.map +1 -1
  161. package/dist/subscribers/field-metadata.subscriber.js.map +1 -1
  162. package/dist/subscribers/scheduled-job.subscriber.d.ts.map +1 -1
  163. package/dist/subscribers/scheduled-job.subscriber.js +3 -2
  164. package/dist/subscribers/scheduled-job.subscriber.js.map +1 -1
  165. package/dist/subscribers/security-rule.subscriber.d.ts.map +1 -1
  166. package/dist/subscribers/security-rule.subscriber.js +5 -3
  167. package/dist/subscribers/security-rule.subscriber.js.map +1 -1
  168. package/package.json +1 -1
  169. package/src/commands/migrate-removed-fields.command.ts +81 -0
  170. package/src/controllers/datasource-introspection.controller.ts +27 -1
  171. package/src/controllers/service.controller.ts +3 -2
  172. package/src/dtos/datasource-introspection-mapping.dto.ts +15 -0
  173. package/src/entities/{legacy-common-with-id.entity.ts → legacy-common-with-generated-id.entity.ts} +1 -1
  174. package/src/helpers/command.service.ts +10 -2
  175. package/src/helpers/environment.helper.ts +11 -0
  176. package/src/helpers/field-crud-managers/IntFieldCrudManager.ts +4 -1
  177. package/src/helpers/model-metadata-helper.service.ts +8 -3
  178. package/src/helpers/nodemon-heartbeat.ts +59 -0
  179. package/src/helpers/solid-registry.ts +7 -1
  180. package/src/helpers/typeorm-db-helper.ts +15 -0
  181. package/src/index.ts +3 -2
  182. package/src/interfaces/datasource-introspection-provider.interface.ts +1 -0
  183. package/src/interfaces.ts +1 -0
  184. package/src/repository/scheduled-job.repository.ts +10 -4
  185. package/src/repository/security-rule.repository.ts +10 -4
  186. package/src/seeders/module-metadata-seeder.service.ts +192 -2
  187. package/src/seeders/seed-data/solid-core-metadata.json +128 -34
  188. package/src/services/1.js +6 -0
  189. package/src/services/api-key.service.ts +36 -36
  190. package/src/services/authentication.service.ts +46 -12
  191. package/src/services/computed-fields/entity/alpha-num-external-id-computed-field-provider.ts +11 -5
  192. package/src/services/computed-fields/entity/concat-entity-computed-field-provider.service.ts +15 -1
  193. package/src/services/crud-helper.service.ts +25 -12
  194. package/src/services/crud.service.ts +36 -11
  195. package/src/services/datasource-introspection/mssql-datasource-introspection-provider.service.ts +12 -0
  196. package/src/services/datasource-introspection/mysql-datasource-introspection-provider.service.ts +2 -0
  197. package/src/services/datasource-introspection/postgres-datasource-introspection-provider.service.ts +28 -15
  198. package/src/services/datasource-introspection.service.ts +811 -161
  199. package/src/services/import-transaction.service.ts +5 -0
  200. package/src/services/locale.service.ts +111 -3
  201. package/src/services/mediaStorageProviders/file-s3-storage-provider.ts +2 -2
  202. package/src/services/menu-item-metadata.service.ts +2 -1
  203. package/src/services/model-metadata.service.ts +109 -1
  204. package/src/services/module-metadata.service.ts +36 -0
  205. package/src/services/removed-field-migration.service.ts +334 -0
  206. package/src/services/role-metadata.service.ts +26 -2
  207. package/src/services/settings/default-settings-provider.service.ts +120 -0
  208. package/src/services/solid-ts-morph.service.ts +61 -1
  209. package/src/services/view-metadata.service.ts +4 -8
  210. package/src/solid-core.module.ts +4 -0
  211. package/src/subscribers/audit.subscriber.ts +101 -18
  212. package/src/subscribers/computed-entity-field.subscriber.ts +81 -28
  213. package/src/subscribers/created-by-updated-by.subscriber.ts +3 -0
  214. package/src/subscribers/field-metadata.subscriber.ts +3 -0
  215. package/src/subscribers/scheduled-job.subscriber.ts +3 -2
  216. package/src/subscribers/security-rule.subscriber.ts +8 -3
  217. package/dist/entities/legacy-common-with-id.entity.d.ts.map +0 -1
  218. package/dist/entities/legacy-common-with-id.entity.js.map +0 -1
  219. package/dist/entities/legacy-common.entity.d.ts.map +0 -1
  220. package/dist/entities/legacy-common.entity.js.map +0 -1
  221. package/dist-tests/api/authenticate.spec.js +0 -119
  222. package/dist-tests/api/authenticate.spec.js.map +0 -1
  223. package/dist-tests/api/crud-service.findOne.cityMaster.spec.js +0 -97
  224. package/dist-tests/api/crud-service.findOne.cityMaster.spec.js.map +0 -1
  225. package/dist-tests/api/ping.spec.js +0 -21
  226. package/dist-tests/api/ping.spec.js.map +0 -1
  227. package/dist-tests/helpers/auth.js +0 -41
  228. package/dist-tests/helpers/auth.js.map +0 -1
  229. package/dist-tests/helpers/env.js +0 -11
  230. package/dist-tests/helpers/env.js.map +0 -1
  231. package/docs/agent-hub-grooming.md +0 -301
  232. package/docs/dashboards/AGENTIC_DASHBOARD_IMPLEMENTATION_PLAN.md +0 -438
  233. package/docs/dashboards/dashboard-curl-smoke-tests.txt +0 -146
  234. package/docs/dashboards/delete-legacy-dashboard-metadata.sql +0 -172
  235. package/docs/datasource-introspection-ddl-analysis.md +0 -326
  236. package/docs/datasource-introspection-implementation-plan.md +0 -306
  237. package/docs/grouping-enhancements.md +0 -89
  238. package/docs/java-spring/README.md +0 -3
  239. package/docs/java-spring/solid-core-module-deep-dive-report.md +0 -1317
  240. package/docs/module-package-import-handoff.md +0 -691
  241. package/docs/seed-changes.md +0 -65
  242. package/docs/test-data-workflow.md +0 -200
  243. package/docs/type-declaration-import-issue.md +0 -24
  244. /package/src/entities/{legacy-common.entity.ts → legacy-common.entity-with-existing-id.entity.ts} +0 -0
@@ -1077,15 +1077,24 @@
1077
1077
  {
1078
1078
  "name": "type",
1079
1079
  "displayName": "Type",
1080
- "type": "shortText",
1080
+ "type": "selectionStatic",
1081
1081
  "ormType": "varchar",
1082
+ "length": 256,
1082
1083
  "required": true,
1083
1084
  "unique": false,
1084
1085
  "index": true,
1085
1086
  "private": false,
1086
1087
  "encrypt": false,
1087
1088
  "columnName": "type",
1088
- "isSystem": true
1089
+ "isSystem": true,
1090
+ "selectionValueType": "string",
1091
+ "selectionStaticValues": [
1092
+ "list:List",
1093
+ "form:Form",
1094
+ "tree:Tree",
1095
+ "kanban:Kanban",
1096
+ "card:Card"
1097
+ ]
1089
1098
  },
1090
1099
  {
1091
1100
  "name": "context",
@@ -1584,7 +1593,7 @@
1584
1593
  "name": "roles",
1585
1594
  "displayName": "Roles",
1586
1595
  "type": "relation",
1587
- "required": true,
1596
+ "required": false,
1588
1597
  "unique": false,
1589
1598
  "index": true,
1590
1599
  "private": false,
@@ -5244,6 +5253,13 @@
5244
5253
  }
5245
5254
  ]
5246
5255
  },
5256
+ "locales": [
5257
+ {
5258
+ "locale": "en",
5259
+ "displayName": "English",
5260
+ "isDefault": true
5261
+ }
5262
+ ],
5247
5263
  "permissions": [
5248
5264
  "mcp:invoke",
5249
5265
  "agent:invoke",
@@ -8730,12 +8746,15 @@
8730
8746
  48
8731
8747
  ],
8732
8748
  "enableGlobalSearch": true,
8733
- "create": true,
8734
- "edit": true,
8749
+ "create": false,
8750
+ "edit": false,
8735
8751
  "delete": true,
8752
+ "import": false,
8753
+ "export": false,
8736
8754
  "allowedViews": [
8737
8755
  "list",
8738
- "card"
8756
+ "card",
8757
+ "tree"
8739
8758
  ]
8740
8759
  },
8741
8760
  "children": [
@@ -8996,7 +9015,13 @@
8996
9015
  "enableGlobalSearch": true,
8997
9016
  "create": false,
8998
9017
  "edit": false,
8999
- "delete": false
9018
+ "delete": false,
9019
+ "import": false,
9020
+ "export": false,
9021
+ "allowedViews": [
9022
+ "list",
9023
+ "tree"
9024
+ ]
9000
9025
  },
9001
9026
  "children": [
9002
9027
  {
@@ -10088,15 +10113,11 @@
10088
10113
  "swimlanesCount": 5,
10089
10114
  "recordsInSwimlane": 10,
10090
10115
  "enableGlobalSearch": true,
10091
- "create": true,
10092
- "edit": true,
10093
- "delete": true,
10116
+ "create": false,
10117
+ "edit": false,
10118
+ "delete": false,
10094
10119
  "groupBy": "stage",
10095
- "draggable": false,
10096
- "allowedViews": [
10097
- "list",
10098
- "kanban"
10099
- ]
10120
+ "draggable": false
10100
10121
  },
10101
10122
  "children": [
10102
10123
  {
@@ -11922,7 +11943,11 @@
11922
11943
  "edit": false,
11923
11944
  "delete": false,
11924
11945
  "import": false,
11925
- "export": false
11946
+ "export": false,
11947
+ "allowedViews": [
11948
+ "list",
11949
+ "tree"
11950
+ ]
11926
11951
  },
11927
11952
  "children": [
11928
11953
  {
@@ -13417,7 +13442,13 @@
13417
13442
  "enableGlobalSearch": true,
13418
13443
  "create": false,
13419
13444
  "edit": true,
13420
- "delete": false
13445
+ "delete": false,
13446
+ "import": false,
13447
+ "export": false,
13448
+ "allowedViews": [
13449
+ "list",
13450
+ "tree"
13451
+ ]
13421
13452
  },
13422
13453
  "children": [
13423
13454
  {
@@ -13492,7 +13523,13 @@
13492
13523
  "enableGlobalSearch": true,
13493
13524
  "create": false,
13494
13525
  "edit": false,
13495
- "delete": false
13526
+ "delete": false,
13527
+ "import": false,
13528
+ "export": false,
13529
+ "allowedViews": [
13530
+ "list",
13531
+ "tree"
13532
+ ]
13496
13533
  },
13497
13534
  "children": [
13498
13535
  {
@@ -13576,7 +13613,13 @@
13576
13613
  "enableGlobalSearch": true,
13577
13614
  "create": false,
13578
13615
  "edit": false,
13579
- "delete": false
13616
+ "delete": false,
13617
+ "import": false,
13618
+ "export": false,
13619
+ "allowedViews": [
13620
+ "list",
13621
+ "tree"
13622
+ ]
13580
13623
  },
13581
13624
  "children": [
13582
13625
  {
@@ -13638,7 +13681,13 @@
13638
13681
  "enableGlobalSearch": true,
13639
13682
  "create": false,
13640
13683
  "edit": false,
13641
- "delete": false
13684
+ "delete": false,
13685
+ "import": false,
13686
+ "export": false,
13687
+ "allowedViews": [
13688
+ "list",
13689
+ "tree"
13690
+ ]
13642
13691
  },
13643
13692
  "children": [
13644
13693
  {
@@ -13707,7 +13756,13 @@
13707
13756
  "enableGlobalSearch": true,
13708
13757
  "create": false,
13709
13758
  "edit": false,
13710
- "delete": false
13759
+ "delete": true,
13760
+ "import": false,
13761
+ "export": false,
13762
+ "allowedViews": [
13763
+ "list",
13764
+ "tree"
13765
+ ]
13711
13766
  },
13712
13767
  "children": [
13713
13768
  {
@@ -13777,7 +13832,14 @@
13777
13832
  "enableGlobalSearch": true,
13778
13833
  "create": false,
13779
13834
  "edit": false,
13780
- "delete": false
13835
+ "delete": true,
13836
+ "import": false,
13837
+ "export": false,
13838
+ "allowedViews": [
13839
+ "list",
13840
+ "card",
13841
+ "tree"
13842
+ ]
13781
13843
  },
13782
13844
  "children": [
13783
13845
  {
@@ -13843,11 +13905,14 @@
13843
13905
  50
13844
13906
  ],
13845
13907
  "enableGlobalSearch": true,
13846
- "create": false,
13847
- "edit": false,
13848
- "delete": false,
13849
- "import": false,
13850
- "export": false
13908
+ "create": true,
13909
+ "edit": true,
13910
+ "delete": true,
13911
+ "import": true,
13912
+ "export": true,
13913
+ "allowedViews": [
13914
+ "list"
13915
+ ]
13851
13916
  },
13852
13917
  "children": [
13853
13918
  {
@@ -13882,7 +13947,11 @@
13882
13947
  "edit": false,
13883
13948
  "delete": false,
13884
13949
  "import": false,
13885
- "export": false
13950
+ "export": false,
13951
+ "allowedViews": [
13952
+ "list",
13953
+ "tree"
13954
+ ]
13886
13955
  },
13887
13956
  "children": [
13888
13957
  {
@@ -13944,7 +14013,11 @@
13944
14013
  "edit": false,
13945
14014
  "delete": false,
13946
14015
  "import": false,
13947
- "export": false
14016
+ "export": false,
14017
+ "allowedViews": [
14018
+ "list",
14019
+ "tree"
14020
+ ]
13948
14021
  },
13949
14022
  "children": [
13950
14023
  {
@@ -14013,7 +14086,11 @@
14013
14086
  "edit": true,
14014
14087
  "delete": true,
14015
14088
  "import": true,
14016
- "export": true
14089
+ "export": true,
14090
+ "allowedViews": [
14091
+ "list",
14092
+ "tree"
14093
+ ]
14017
14094
  },
14018
14095
  "children": [
14019
14096
  {
@@ -14073,7 +14150,11 @@
14073
14150
  "edit": false,
14074
14151
  "delete": false,
14075
14152
  "import": false,
14076
- "export": false
14153
+ "export": false,
14154
+ "allowedViews": [
14155
+ "list",
14156
+ "tree"
14157
+ ]
14077
14158
  },
14078
14159
  "children": [
14079
14160
  {
@@ -14133,7 +14214,11 @@
14133
14214
  "edit": false,
14134
14215
  "delete": false,
14135
14216
  "import": false,
14136
- "export": false
14217
+ "export": false,
14218
+ "allowedViews": [
14219
+ "list",
14220
+ "tree"
14221
+ ]
14137
14222
  },
14138
14223
  "children": [
14139
14224
  {
@@ -14203,7 +14288,11 @@
14203
14288
  "edit": false,
14204
14289
  "delete": false,
14205
14290
  "import": false,
14206
- "export": false
14291
+ "export": false,
14292
+ "allowedViews": [
14293
+ "list",
14294
+ "tree"
14295
+ ]
14207
14296
  },
14208
14297
  "children": [
14209
14298
  {
@@ -14272,7 +14361,12 @@
14272
14361
  "enableGlobalSearch": true,
14273
14362
  "create": true,
14274
14363
  "edit": true,
14275
- "delete": true
14364
+ "delete": true,
14365
+ "import": true,
14366
+ "export": true,
14367
+ "allowedViews": [
14368
+ "list"
14369
+ ]
14276
14370
  },
14277
14371
  "children": [
14278
14372
  {
@@ -1 +1 @@
1
- {"version":3,"file":"api-key.service.d.ts","sourceRoot":"","sources":["../../src/services/api-key.service.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAE9D,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,qBACa,aAAa;IAIlB,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,yBAAyB;IAC1C,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IACtC,OAAO,CAAC,QAAQ,CAAC,cAAc;IANnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkC;gBAGpC,gBAAgB,EAAE,oBAAoB,EACtC,yBAAyB,EAAE,yBAAyB,EACpD,qBAAqB,EAAE,qBA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AAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;aAC7C;YACD,GAAG,MAAM;SACZ,CAAA;IACL,CAAC;IAEO,IAAI,CAAC,MAAc;QACvB,OAAO,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC;CACJ,CAAA;AApIY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAK8B,8CAAoB;QACX,uDAAyB;QAC7B,8CAAqB;QAC5B,gCAAc;GAP1C,aAAa,CAoIzB","sourcesContent":["import {\n ForbiddenException,\n Injectable,\n Logger,\n NotFoundException,\n UnauthorizedException,\n} from '@nestjs/common';\nimport { createHash, randomBytes } from 'crypto';\nimport { ERROR_MESSAGES } from 'src/constants/error-messages';\nimport { CreateApiKeyDto } from 'src/dtos/create-api-key.dto';\nimport { UpdateApiKeyDto } from 'src/dtos/update-api-key.dto';\nimport { UserApiKey } from 'src/entities/user-api-key.entity';\nimport { User } from 'src/entities/user.entity';\nimport { ActiveUserData } from 'src/interfaces/active-user-data.interface';\nimport { UserApiKeyRepository } from 'src/repository/user-api-key.repository';\nimport { PermissionMetadataService } from 'src/services/permission-metadata.service';\nimport { AuthenticationService } from './authentication.service';\nimport { UserRepository } from 'src/repository/user.repository';\n\n@Injectable()\nexport class ApiKeyService {\n private readonly logger = new Logger(ApiKeyService.name);\n\n constructor(\n private readonly apiKeyRepository: UserApiKeyRepository,\n private readonly permissionMetadataService: PermissionMetadataService,\n private readonly authenticationService: AuthenticationService,\n private readonly userRepository: UserRepository,\n ) {}\n\n async generate(userId: number, dto: CreateApiKeyDto): Promise < { apiKey: string; record: UserApiKey } > {\n const user = await this.apiKeyRepository.manager.findOne(User, {\n where: { id: userId },\n select: ['id', 'isAllowedToGenerateApiKeys'],\n });\n\n if(!user?.isAllowedToGenerateApiKeys) {\n throw new ForbiddenException('You are not allowed to generate API keys');\n }\n\n const rawKey = 'sldx_' + randomBytes(32).toString('hex');\n const hashedKey = this.hash(rawKey);\n const maskedKey = 'sldx_****' + rawKey.slice(-4);\n\n const record = this.apiKeyRepository.create({\n name: dto.name,\n hashedKey,\n maskedKey,\n isActive: true,\n expiresAt: dto.expiresAt ? new Date(dto.expiresAt) : null,\n user,\n });\n\n await this.apiKeyRepository.save(record);\n\n // Strip hashedKey from the returned record — maskedKey is all the UI needs\n delete(record as any).hashedKey;\n\n return { apiKey: rawKey, record };\n }\n\n async validate(rawKey: string): Promise < ActiveUserData > {\n const hashedKey = this.hash(rawKey);\n\n // Bypass security rules for auth validation — must find the key regardless of caller context\n const keyRecord = await this.apiKeyRepository.findOne({\n where: { hashedKey, isActive: true },\n relations: ['user', 'user.roles'],\n });\n\n if(!keyRecord) {\n throw new UnauthorizedException();\n }\n\n if(keyRecord.expiresAt && keyRecord.expiresAt < new Date()) {\n throw new UnauthorizedException('API key expired');\n }\n\n // Fire-and-forget — does not need security rule context\n this.apiKeyRepository.update(keyRecord.id, { lastUsedAt: new Date() }).catch((err) => {\n this.logger.warn(`Failed to update lastUsedAt for key ${keyRecord.id}: ${err.message}`);\n });\n\n const roles = (keyRecord.user.roles ?? []).map((r) => r.name);\n const permissions = await this.permissionMetadataService.findAllUsingRoles(roles);\n\n return {\n sub: keyRecord.user.id,\n username: keyRecord.user.username,\n email: keyRecord.user.email,\n roles,\n permissions: permissions.map((p) => p.name),\n };\n }\n\n async updateKey(id: number, userId: number, dto: UpdateApiKeyDto): Promise<void> {\n const keyRecord = await this.apiKeyRepository.findOne({\n where: { id, user: { id: userId } },\n });\n\n if (!keyRecord) {\n throw new NotFoundException('API key not found');\n }\n\n await this.apiKeyRepository.manager\n .createQueryBuilder()\n .update(UserApiKey)\n .set({ isActive: dto.isActive })\n .where('id = :id', { id })\n .execute();\n }\n\n\n async apiKeyMe(apiKey: string) {\n\n const hasedKey = this.hash(apiKey);\n const apiKeyRecord = await this.apiKeyRepository.findOne({\n where: {\n hashedKey: hasedKey,\n },\n relations: {\n user: {\n roles: true\n }\n }\n });\n\n if (!apiKeyRecord) {\n throw new UnauthorizedException(ERROR_MESSAGES.INVALID_CREDENTIALS);\n }\n\n const user = apiKeyRecord.user;\n\n const tokens = await this.authenticationService.generateTokens(user);\n\n\n return {\n user: {\n email: user.email,\n mobile: user.mobile,\n username: user.username,\n forcePasswordChange: user.forcePasswordChange,\n id: user.id,\n roles: user.roles.map((role) => role.name)\n },\n ...tokens\n }\n }\n\n private hash(rawKey: string): string {\n return createHash('sha256').update(rawKey).digest('hex');\n }\n}\n"]}
1
+ {"version":3,"file":"api-key.service.js","sourceRoot":"","sources":["../../src/services/api-key.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAMwB;AACxB,mCAAiD;AACjD,gEAA8D;AAG9D,yEAA8D;AAC9D,yDAAgD;AAEhD,mFAA8E;AAC9E,+EAAqF;AACrF,qEAAiE;AACjE,mEAAgE;AAGzD,IAAM,aAAa,qBAAnB,MAAM,aAAa;IAGtB,YACqB,gBAAsC,EACtC,yBAAoD,EACpD,qBAA4C,EAC5C,cAA8B;QAH9B,qBAAgB,GAAhB,gBAAgB,CAAsB;QACtC,8BAAyB,GAAzB,yBAAyB,CAA2B;QACpD,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,mBAAc,GAAd,cAAc,CAAgB;QANlC,WAAM,GAAG,IAAI,eAAM,CAAC,eAAa,CAAC,IAAI,CAAC,CAAC;IAOrD,CAAC;IAEL,KAAK,CAAC,QAAQ,CAAC,MAAc,EAAE,GAAoB;QAC/C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAI,EAAE;YAC3D,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE;YACrB,MAAM,EAAE,CAAC,IAAI,EAAE,4BAA4B,CAAC;SAC/C,CAAC,CAAC;QAEH,IAA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YACD,GAAG,MAAM;SACZ,CAAA;IACL,CAAC;IAEO,IAAI,CAAC,MAAc;QACvB,OAAO,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC;CACJ,CAAA;AApIY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAK8B,8CAAoB;QACX,uDAAyB;QAC7B,8CAAqB;QAC5B,gCAAc;GAP1C,aAAa,CAoIzB","sourcesContent":["import {\n ForbiddenException,\n Injectable,\n Logger,\n NotFoundException,\n UnauthorizedException,\n} from '@nestjs/common';\nimport { createHash, randomBytes } from 'crypto';\nimport { ERROR_MESSAGES } from 'src/constants/error-messages';\nimport { CreateApiKeyDto } from 'src/dtos/create-api-key.dto';\nimport { UpdateApiKeyDto } from 'src/dtos/update-api-key.dto';\nimport { UserApiKey } from 'src/entities/user-api-key.entity';\nimport { User } from 'src/entities/user.entity';\nimport { ActiveUserData } from 'src/interfaces/active-user-data.interface';\nimport { UserApiKeyRepository } from 'src/repository/user-api-key.repository';\nimport { PermissionMetadataService } from 'src/services/permission-metadata.service';\nimport { AuthenticationService } from './authentication.service';\nimport { UserRepository } from 'src/repository/user.repository';\n\n@Injectable()\nexport class ApiKeyService {\n private readonly logger = new Logger(ApiKeyService.name);\n\n constructor(\n private readonly apiKeyRepository: UserApiKeyRepository,\n private readonly permissionMetadataService: PermissionMetadataService,\n private readonly authenticationService: AuthenticationService,\n private readonly userRepository: UserRepository,\n ) { }\n\n async generate(userId: number, dto: CreateApiKeyDto): Promise<{ apiKey: string; record: UserApiKey }> {\n const user = await this.apiKeyRepository.manager.findOne(User, {\n where: { id: userId },\n select: ['id', 'isAllowedToGenerateApiKeys'],\n });\n\n if (!user?.isAllowedToGenerateApiKeys) {\n throw new ForbiddenException('You are not allowed to generate API keys');\n }\n\n const rawKey = 'sldx_' + randomBytes(32).toString('hex');\n const hashedKey = this.hash(rawKey);\n const maskedKey = 'sldx_****' + rawKey.slice(-4);\n\n const record = this.apiKeyRepository.create({\n name: dto.name,\n hashedKey,\n maskedKey,\n isActive: true,\n expiresAt: dto.expiresAt ? new Date(dto.expiresAt) : null,\n user,\n });\n\n await this.apiKeyRepository.save(record);\n\n // Strip hashedKey from the returned record — maskedKey is all the UI needs\n delete (record as any).hashedKey;\n\n return { apiKey: rawKey, record };\n }\n\n async validate(rawKey: string): Promise<ActiveUserData> {\n const hashedKey = this.hash(rawKey);\n\n // Bypass security rules for auth validation — must find the key regardless of caller context\n const keyRecord = await this.apiKeyRepository.findOne({\n where: { hashedKey, isActive: true },\n relations: ['user', 'user.roles'],\n });\n\n if (!keyRecord) {\n throw new UnauthorizedException();\n }\n\n if (keyRecord.expiresAt && keyRecord.expiresAt < new Date()) {\n throw new UnauthorizedException('API key expired');\n }\n\n // Fire-and-forget — does not need security rule context\n this.apiKeyRepository.update(keyRecord.id, { lastUsedAt: new Date() }).catch((err) => {\n this.logger.warn(`Failed to update lastUsedAt for key ${keyRecord.id}: ${err.message}`);\n });\n\n const roles = (keyRecord.user.roles ?? []).map((r) => r.name);\n const permissions = await this.permissionMetadataService.findAllUsingRoles(roles);\n\n return {\n sub: keyRecord.user.id,\n username: keyRecord.user.username,\n email: keyRecord.user.email,\n roles,\n permissions: permissions.map((p) => p.name),\n };\n }\n\n async updateKey(id: number, userId: number, dto: UpdateApiKeyDto): Promise<void> {\n const keyRecord = await this.apiKeyRepository.findOne({\n where: { id, user: { id: userId } },\n });\n\n if (!keyRecord) {\n throw new NotFoundException('API key not found');\n }\n\n await this.apiKeyRepository.manager\n .createQueryBuilder()\n .update(UserApiKey)\n .set({ isActive: dto.isActive })\n .where('id = :id', { id })\n .execute();\n }\n\n\n async apiKeyMe(apiKey: string) {\n\n const hasedKey = this.hash(apiKey);\n const apiKeyRecord = await this.apiKeyRepository.findOne({\n where: {\n hashedKey: hasedKey,\n },\n relations: {\n user: {\n roles: true\n }\n }\n });\n\n if (!apiKeyRecord) {\n throw new UnauthorizedException(ERROR_MESSAGES.INVALID_CREDENTIALS);\n }\n\n const user = apiKeyRecord.user;\n\n const tokens = await this.authenticationService.generateTokens(user);\n\n\n return {\n user: {\n email: user.email,\n mobile: user.mobile,\n username: user.username,\n forcePasswordChange: user.forcePasswordChange,\n id: user.id,\n roles: user.roles.map((role) => role.name)\n },\n ...tokens\n }\n }\n\n private hash(rawKey: string): string {\n return createHash('sha256').update(rawKey).digest('hex');\n }\n}\n"]}
@@ -112,8 +112,10 @@ export declare class AuthenticationService {
112
112
  }>;
113
113
  private resolveLoginType;
114
114
  private findUserForLogin;
115
+ private findUserForLoginOrNull;
115
116
  private assignLoginOtp;
116
117
  private buildLoginOtpResponse;
118
+ private buildMaskedLoginIdentifier;
117
119
  private notifyUserOnOtpInititateLogin;
118
120
  otpConfirmLogin(confirmSignInDto: OTPConfirmOTPDto): Promise<{
119
121
  accessToken: string;
@@ -1 +1 @@
1
- {"version":3,"file":"authentication.service.d.ts","sourceRoot":"","sources":["../../src/services/authentication.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAY5C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOzC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAO9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EA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C,IAAI,EAAE,IAAI;IA0CpD,mCAAmC,CAAC,UAAU,EAAE,MAAM;;;;;;;;;;;IAoCtD,gBAAgB,CAAC,UAAU,EAAE,MAAM;;;;;;;;;;;YAkC3B,iCAAiC;IAO/C,OAAO,CAAC,mBAAmB;YAab,uBAAuB;YAQvB,mBAAmB;IAa3B,MAAM,CAAC,YAAY,EAAE,MAAM;;;IAuC3B,YAAY,CAAC,MAAM,EAAE,MAAM;IAS3B,EAAE,CAAC,UAAU,EAAE,cAAc;;;;;;;;;;IA+B7B,eAAe,CACnB,UAAU,EAAE,cAAc,EAC1B,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAgBzB,eAAe,CAAC,IAAI,EAAE,MAAM;;;;;;;;;;;;CAYnC"}
@@ -635,13 +635,15 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
635
635
  throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.PASSWORDLESS_REGISTRATION_DISABLED);
636
636
  }
637
637
  const type = this.resolveLoginType(signInDto);
638
- const user = await this.findUserForLogin(type, signInDto.identifier);
639
- const dummyOtp = this.getDummyOtpForUser(user);
640
- if (!dummyOtp) {
641
- await this.assignLoginOtp(user, type);
642
- await this.notifyUserOnOtpInititateLogin(user, type);
638
+ const user = await this.findUserForLoginOrNull(type, signInDto.identifier);
639
+ if (user) {
640
+ const dummyOtp = this.getDummyOtpForUser(user);
641
+ if (!dummyOtp) {
642
+ await this.assignLoginOtp(user, type);
643
+ await this.notifyUserOnOtpInititateLogin(user, type);
644
+ }
643
645
  }
644
- return this.buildLoginOtpResponse(user, type);
646
+ return this.buildLoginOtpResponse(type, signInDto.identifier, user);
645
647
  }
646
648
  resolveLoginType(signInDto) {
647
649
  const setting = this.settingService.getConfigValue("passwordlessLoginValidateWhat");
@@ -674,6 +676,19 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
674
676
  }
675
677
  return user;
676
678
  }
679
+ async findUserForLoginOrNull(type, identifier, options = {}) {
680
+ try {
681
+ return await this.findUserForLogin(type, identifier, options);
682
+ }
683
+ catch (error) {
684
+ if (error instanceof common_1.UnauthorizedException &&
685
+ (error.message === error_messages_1.ERROR_MESSAGES.USER_NOT_FOUND ||
686
+ error.message === error_messages_1.ERROR_MESSAGES.USER_INACTIVE)) {
687
+ return null;
688
+ }
689
+ throw error;
690
+ }
691
+ }
677
692
  async assignLoginOtp(user, type) {
678
693
  const { token, expiresAt } = await this.otp();
679
694
  if (type === constants_1.PasswordlessLoginValidateWhatSources.EMAIL) {
@@ -693,15 +708,18 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
693
708
  });
694
709
  }
695
710
  }
696
- buildLoginOtpResponse(user, type) {
697
- const maskedIdentifier = type === constants_1.PasswordlessLoginValidateWhatSources.EMAIL
698
- ? { email: this.maskEmail(user.email) }
699
- : { mobile: this.maskMobile(user.mobile) };
711
+ buildLoginOtpResponse(type, identifier, user) {
712
+ const maskedIdentifier = this.buildMaskedLoginIdentifier(type, user?.email ?? user?.mobile ?? identifier);
700
713
  return {
701
714
  message: success_messages_1.SUCCESS_MESSAGES.OTP_SENT_SUCCESS_LOGIN,
702
715
  user: maskedIdentifier,
703
716
  };
704
717
  }
718
+ buildMaskedLoginIdentifier(type, identifier) {
719
+ return type === constants_1.PasswordlessLoginValidateWhatSources.EMAIL
720
+ ? { email: this.maskEmail(identifier) }
721
+ : { mobile: this.maskMobile(identifier) };
722
+ }
705
723
  async notifyUserOnOtpInititateLogin(user, loginType) {
706
724
  const companyLogo = await this.getCompanyLogo();
707
725
  const dummyOtp = this.getDummyOtpForUser(user);
@@ -778,9 +796,12 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
778
796
  type !== constants_1.PasswordlessLoginValidateWhatSources.MOBILE) {
779
797
  throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.INVALID_VERIFICATION_TYPE);
780
798
  }
781
- const user = await this.findUserForLogin(type, identifier, {
799
+ const user = await this.findUserForLoginOrNull(type, identifier, {
782
800
  withRoles: true,
783
801
  });
802
+ if (!user) {
803
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_OTP);
804
+ }
784
805
  this.checkAccountBlocked(user);
785
806
  const dummyOtp = this.getDummyOtpForUser(user);
786
807
  if (dummyOtp) {