@autofleet/sadot 1.6.18-beta.5 → 1.6.18

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 (659) hide show
  1. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/decorate.cjs +1 -11
  2. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/decorate.js +1 -10
  3. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/decorateMetadata.cjs +1 -8
  4. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/decorateMetadata.js +1 -7
  5. package/dist/_virtual/rolldown_runtime.cjs +1 -45
  6. package/dist/_virtual/rolldown_runtime.js +1 -22
  7. package/dist/api/index.cjs +2 -0
  8. package/dist/api/index.cjs.map +1 -0
  9. package/dist/api/index.js +2 -0
  10. package/dist/api/index.js.map +1 -0
  11. package/dist/api/v1/definition/index.cjs +2 -0
  12. package/dist/api/v1/definition/index.cjs.map +1 -0
  13. package/dist/api/v1/definition/index.js +2 -0
  14. package/dist/api/v1/definition/index.js.map +1 -0
  15. package/dist/api/v1/definition/validations.cjs +2 -0
  16. package/dist/api/v1/definition/validations.cjs.map +1 -0
  17. package/dist/api/v1/definition/validations.js +2 -0
  18. package/dist/api/v1/definition/validations.js.map +1 -0
  19. package/dist/api/v1/errors.cjs +2 -0
  20. package/dist/api/v1/errors.cjs.map +1 -0
  21. package/dist/api/v1/errors.js +2 -0
  22. package/dist/api/v1/errors.js.map +1 -0
  23. package/dist/api/v1/index.cjs +2 -0
  24. package/dist/api/v1/index.cjs.map +1 -0
  25. package/dist/api/v1/index.js +2 -0
  26. package/dist/api/v1/index.js.map +1 -0
  27. package/dist/api/v1/validator/index.cjs +2 -0
  28. package/dist/api/v1/validator/index.cjs.map +1 -0
  29. package/dist/api/v1/validator/index.js +2 -0
  30. package/dist/api/v1/validator/index.js.map +1 -0
  31. package/dist/api/v1/validator/validations.cjs +2 -0
  32. package/dist/api/v1/validator/validations.cjs.map +1 -0
  33. package/dist/api/v1/validator/validations.d.cts +2 -1
  34. package/dist/{packages/sadot/src/api → api}/v1/validator/validations.d.ts +2 -1
  35. package/dist/api/v1/validator/validations.js +2 -0
  36. package/dist/api/v1/validator/validations.js.map +1 -0
  37. package/dist/errors/index.cjs +3 -0
  38. package/dist/errors/index.cjs.map +1 -0
  39. package/dist/errors/index.js +3 -0
  40. package/dist/errors/index.js.map +1 -0
  41. package/dist/events/index.cjs +2 -0
  42. package/dist/events/index.cjs.map +1 -0
  43. package/dist/events/index.js +2 -0
  44. package/dist/events/index.js.map +1 -0
  45. package/dist/hooks/enrich.cjs +2 -0
  46. package/dist/hooks/enrich.cjs.map +1 -0
  47. package/dist/hooks/enrich.js +2 -0
  48. package/dist/hooks/enrich.js.map +1 -0
  49. package/dist/hooks/find.cjs +2 -0
  50. package/dist/hooks/find.cjs.map +1 -0
  51. package/dist/hooks/find.js +2 -0
  52. package/dist/hooks/find.js.map +1 -0
  53. package/dist/hooks/hooks.cjs +2 -0
  54. package/dist/hooks/hooks.cjs.map +1 -0
  55. package/dist/hooks/hooks.js +2 -0
  56. package/dist/hooks/hooks.js.map +1 -0
  57. package/dist/hooks/index.cjs +1 -0
  58. package/dist/hooks/index.js +1 -0
  59. package/dist/hooks/utils/updateInstanceValues.cjs +2 -0
  60. package/dist/hooks/utils/updateInstanceValues.cjs.map +1 -0
  61. package/dist/hooks/utils/updateInstanceValues.js +2 -0
  62. package/dist/hooks/utils/updateInstanceValues.js.map +1 -0
  63. package/dist/index.cjs +2 -87
  64. package/dist/index.cjs.map +1 -0
  65. package/dist/index.d.cts +3 -3
  66. package/dist/index.d.ts +13 -14
  67. package/dist/index.js +2 -66
  68. package/dist/index.js.map +1 -0
  69. package/dist/init-state.cjs +2 -0
  70. package/dist/init-state.cjs.map +1 -0
  71. package/dist/init-state.d.cts +2 -1
  72. package/dist/{packages/sadot/src/init-state.d.ts → init-state.d.ts} +2 -1
  73. package/dist/init-state.js +2 -0
  74. package/dist/init-state.js.map +1 -0
  75. package/dist/mat-path-state.cjs +2 -0
  76. package/dist/mat-path-state.cjs.map +1 -0
  77. package/dist/mat-path-state.js +2 -0
  78. package/dist/mat-path-state.js.map +1 -0
  79. package/dist/{packages/sadot/src/migrations → migrations}/001-create-core-tables.cjs +7 -25
  80. package/dist/migrations/001-create-core-tables.cjs.map +1 -0
  81. package/dist/{packages/sadot/src/migrations → migrations}/001-create-core-tables.js +7 -23
  82. package/dist/migrations/001-create-core-tables.js.map +1 -0
  83. package/dist/{packages/sadot/src/migrations → migrations}/002-create-custom-field-entries.cjs +4 -16
  84. package/dist/migrations/002-create-custom-field-entries.cjs.map +1 -0
  85. package/dist/{packages/sadot/src/migrations → migrations}/002-create-custom-field-entries.js +4 -14
  86. package/dist/migrations/002-create-custom-field-entries.js.map +1 -0
  87. package/dist/{packages/sadot/src/migrations → migrations}/003-create-custom-field-model-type-map.cjs +6 -20
  88. package/dist/migrations/003-create-custom-field-model-type-map.cjs.map +1 -0
  89. package/dist/{packages/sadot/src/migrations → migrations}/003-create-custom-field-model-type-map.js +6 -18
  90. package/dist/migrations/003-create-custom-field-model-type-map.js.map +1 -0
  91. package/dist/migrations/index.cjs +2 -0
  92. package/dist/migrations/index.cjs.map +1 -0
  93. package/dist/migrations/index.js +2 -0
  94. package/dist/migrations/index.js.map +1 -0
  95. package/dist/models/CustomFieldDefinition.cjs +2 -0
  96. package/dist/models/CustomFieldDefinition.cjs.map +1 -0
  97. package/dist/models/CustomFieldDefinition.d.cts +2 -1
  98. package/dist/{packages/sadot/src/models → models}/CustomFieldDefinition.d.ts +2 -1
  99. package/dist/models/CustomFieldDefinition.js +2 -0
  100. package/dist/models/CustomFieldDefinition.js.map +1 -0
  101. package/dist/models/CustomFieldEntries.cjs +2 -0
  102. package/dist/models/CustomFieldEntries.cjs.map +1 -0
  103. package/dist/models/CustomFieldEntries.d.cts +2 -1
  104. package/dist/{packages/sadot/src/models → models}/CustomFieldEntries.d.ts +2 -1
  105. package/dist/models/CustomFieldEntries.js +2 -0
  106. package/dist/models/CustomFieldEntries.js.map +1 -0
  107. package/dist/models/CustomFieldModelTypeMap.cjs +2 -0
  108. package/dist/models/CustomFieldModelTypeMap.cjs.map +1 -0
  109. package/dist/models/CustomFieldModelTypeMap.d.cts +2 -1
  110. package/dist/{packages/sadot/src/models → models}/CustomFieldModelTypeMap.d.ts +2 -1
  111. package/dist/models/CustomFieldModelTypeMap.js +2 -0
  112. package/dist/models/CustomFieldModelTypeMap.js.map +1 -0
  113. package/dist/models/CustomFieldValue.cjs +2 -0
  114. package/dist/models/CustomFieldValue.cjs.map +1 -0
  115. package/dist/models/CustomFieldValue.d.cts +2 -1
  116. package/dist/{packages/sadot/src/models → models}/CustomFieldValue.d.ts +2 -1
  117. package/dist/models/CustomFieldValue.js +2 -0
  118. package/dist/models/CustomFieldValue.js.map +1 -0
  119. package/dist/models/CustomValidator.cjs +2 -0
  120. package/dist/models/CustomValidator.cjs.map +1 -0
  121. package/dist/models/CustomValidator.d.cts +2 -1
  122. package/dist/{packages/sadot/src/models → models}/CustomValidator.d.ts +2 -1
  123. package/dist/models/CustomValidator.js +2 -0
  124. package/dist/models/CustomValidator.js.map +1 -0
  125. package/dist/models/index.cjs +2 -0
  126. package/dist/models/index.cjs.map +1 -0
  127. package/dist/models/index.d.cts +7 -0
  128. package/dist/models/index.js +2 -0
  129. package/dist/models/index.js.map +1 -0
  130. package/dist/models/tests/AssociatedTestModel.cjs +2 -0
  131. package/dist/models/tests/AssociatedTestModel.cjs.map +1 -0
  132. package/dist/models/tests/AssociatedTestModel.js +2 -0
  133. package/dist/models/tests/AssociatedTestModel.js.map +1 -0
  134. package/dist/models/tests/TestModel.cjs +2 -0
  135. package/dist/models/tests/TestModel.cjs.map +1 -0
  136. package/dist/models/tests/TestModel.js +2 -0
  137. package/dist/models/tests/TestModel.js.map +1 -0
  138. package/dist/models/tests/contextAwareModels/ContextAwareTestModel.cjs +2 -0
  139. package/dist/models/tests/contextAwareModels/ContextAwareTestModel.cjs.map +1 -0
  140. package/dist/models/tests/contextAwareModels/ContextAwareTestModel.js +2 -0
  141. package/dist/models/tests/contextAwareModels/ContextAwareTestModel.js.map +1 -0
  142. package/dist/models/tests/contextAwareModels/ContextTestModel.cjs +2 -0
  143. package/dist/models/tests/contextAwareModels/ContextTestModel.cjs.map +1 -0
  144. package/dist/models/tests/contextAwareModels/ContextTestModel.js +2 -0
  145. package/dist/models/tests/contextAwareModels/ContextTestModel.js.map +1 -0
  146. package/dist/repository/definition.cjs +2 -0
  147. package/dist/repository/definition.cjs.map +1 -0
  148. package/dist/repository/definition.js +2 -0
  149. package/dist/repository/definition.js.map +1 -0
  150. package/dist/repository/entries.cjs +2 -0
  151. package/dist/repository/entries.cjs.map +1 -0
  152. package/dist/repository/entries.js +2 -0
  153. package/dist/repository/entries.js.map +1 -0
  154. package/dist/repository/utils/formatValues.cjs +2 -0
  155. package/dist/repository/utils/formatValues.cjs.map +1 -0
  156. package/dist/repository/utils/formatValues.js +2 -0
  157. package/dist/repository/utils/formatValues.js.map +1 -0
  158. package/dist/repository/validator.cjs +2 -0
  159. package/dist/repository/validator.cjs.map +1 -0
  160. package/dist/repository/validator.js +2 -0
  161. package/dist/repository/validator.js.map +1 -0
  162. package/dist/repository/value.cjs +2 -0
  163. package/dist/repository/value.cjs.map +1 -0
  164. package/dist/repository/value.js +2 -0
  165. package/dist/repository/value.js.map +1 -0
  166. package/dist/scopes/filter.cjs +2 -0
  167. package/dist/scopes/filter.cjs.map +1 -0
  168. package/dist/scopes/filter.d.cts +2 -1
  169. package/dist/{packages/sadot/src/scopes → scopes}/filter.d.ts +2 -1
  170. package/dist/scopes/filter.js +2 -0
  171. package/dist/scopes/filter.js.map +1 -0
  172. package/dist/scopes/helpers/filter.helpers.cjs +46 -0
  173. package/dist/scopes/helpers/filter.helpers.cjs.map +1 -0
  174. package/dist/scopes/helpers/filter.helpers.d.cts +2 -1
  175. package/dist/{packages/sadot/src/scopes → scopes}/helpers/filter.helpers.d.ts +2 -1
  176. package/dist/scopes/helpers/filter.helpers.js +46 -0
  177. package/dist/scopes/helpers/filter.helpers.js.map +1 -0
  178. package/dist/scopes/index.cjs +1 -0
  179. package/dist/scopes/index.js +1 -0
  180. package/dist/types/index.d.cts +4 -2
  181. package/dist/{packages/sadot/src/types → types}/index.d.ts +4 -2
  182. package/dist/utils/constants/index.cjs +2 -0
  183. package/dist/utils/constants/index.cjs.map +1 -0
  184. package/dist/utils/constants/index.d.cts +2 -1
  185. package/dist/{packages/sadot/src/utils → utils}/constants/index.d.ts +2 -1
  186. package/dist/utils/constants/index.js +2 -0
  187. package/dist/utils/constants/index.js.map +1 -0
  188. package/dist/utils/db/index.cjs +2 -0
  189. package/dist/utils/db/index.cjs.map +1 -0
  190. package/dist/utils/db/index.js +2 -0
  191. package/dist/utils/db/index.js.map +1 -0
  192. package/dist/utils/helpers/index.cjs +2 -0
  193. package/dist/utils/helpers/index.cjs.map +1 -0
  194. package/dist/utils/helpers/index.d.cts +2 -1
  195. package/dist/{packages/sadot/src/utils → utils}/helpers/index.d.ts +2 -1
  196. package/dist/utils/helpers/index.js +2 -0
  197. package/dist/utils/helpers/index.js.map +1 -0
  198. package/dist/utils/init.cjs +2 -0
  199. package/dist/utils/init.cjs.map +1 -0
  200. package/dist/utils/init.js +2 -0
  201. package/dist/utils/init.js.map +1 -0
  202. package/dist/utils/logger/index.cjs +2 -0
  203. package/dist/utils/logger/index.cjs.map +1 -0
  204. package/dist/utils/logger/index.js +2 -0
  205. package/dist/utils/logger/index.js.map +1 -0
  206. package/dist/utils/scopeAttributes.cjs +2 -0
  207. package/dist/utils/scopeAttributes.cjs.map +1 -0
  208. package/dist/utils/scopeAttributes.js +2 -0
  209. package/dist/utils/scopeAttributes.js.map +1 -0
  210. package/dist/utils/validations/index.cjs +2 -0
  211. package/dist/utils/validations/index.cjs.map +1 -0
  212. package/dist/utils/validations/index.js +2 -0
  213. package/dist/utils/validations/index.js.map +1 -0
  214. package/dist/utils/validations/schema/custom-fields.cjs +2 -0
  215. package/dist/utils/validations/schema/custom-fields.cjs.map +1 -0
  216. package/dist/utils/validations/schema/custom-fields.d.cts +2 -1
  217. package/dist/{packages/sadot/src/utils → utils}/validations/schema/custom-fields.d.ts +2 -1
  218. package/dist/utils/validations/schema/custom-fields.js +2 -0
  219. package/dist/utils/validations/schema/custom-fields.js.map +1 -0
  220. package/dist/utils/validations/schema/validator-schema.cjs +2 -0
  221. package/dist/utils/validations/schema/validator-schema.cjs.map +1 -0
  222. package/dist/utils/validations/schema/validator-schema.js +2 -0
  223. package/dist/utils/validations/schema/validator-schema.js.map +1 -0
  224. package/dist/utils/validations/validators/index.cjs +2 -0
  225. package/dist/utils/validations/validators/index.cjs.map +1 -0
  226. package/dist/utils/validations/validators/index.js +2 -0
  227. package/dist/utils/validations/validators/index.js.map +1 -0
  228. package/dist/utils/validations/validators/multi-select-dropdown.validator.cjs +2 -0
  229. package/dist/utils/validations/validators/multi-select-dropdown.validator.cjs.map +1 -0
  230. package/dist/utils/validations/validators/multi-select-dropdown.validator.js +2 -0
  231. package/dist/utils/validations/validators/multi-select-dropdown.validator.js.map +1 -0
  232. package/dist/utils/validations/validators/multi-select-status.validator.cjs +2 -0
  233. package/dist/utils/validations/validators/multi-select-status.validator.cjs.map +1 -0
  234. package/dist/utils/validations/validators/multi-select-status.validator.js +2 -0
  235. package/dist/utils/validations/validators/multi-select-status.validator.js.map +1 -0
  236. package/dist/utils/validations/validators/multi-select.helpers.cjs +2 -0
  237. package/dist/utils/validations/validators/multi-select.helpers.cjs.map +1 -0
  238. package/dist/utils/validations/validators/multi-select.helpers.js +2 -0
  239. package/dist/utils/validations/validators/multi-select.helpers.js.map +1 -0
  240. package/dist/utils/validations/validators/select.validator.cjs +2 -0
  241. package/dist/utils/validations/validators/select.validator.cjs.map +1 -0
  242. package/dist/utils/validations/validators/select.validator.js +2 -0
  243. package/dist/utils/validations/validators/select.validator.js.map +1 -0
  244. package/dist/utils/validations/validators/status.validator.cjs +2 -0
  245. package/dist/utils/validations/validators/status.validator.cjs.map +1 -0
  246. package/dist/utils/validations/validators/status.validator.js +2 -0
  247. package/dist/utils/validations/validators/status.validator.js.map +1 -0
  248. package/package.json +4 -4
  249. package/dist/models/FieldPolicy.d.cts +0 -23
  250. package/dist/node_modules/accepts/index.cjs +0 -180
  251. package/dist/node_modules/accepts/index.js +0 -175
  252. package/dist/node_modules/array-flatten/array-flatten.cjs +0 -61
  253. package/dist/node_modules/array-flatten/array-flatten.js +0 -56
  254. package/dist/node_modules/body-parser/index.cjs +0 -140
  255. package/dist/node_modules/body-parser/index.js +0 -135
  256. package/dist/node_modules/body-parser/lib/read.cjs +0 -169
  257. package/dist/node_modules/body-parser/lib/read.js +0 -164
  258. package/dist/node_modules/body-parser/lib/types/json.cjs +0 -205
  259. package/dist/node_modules/body-parser/lib/types/json.js +0 -200
  260. package/dist/node_modules/body-parser/lib/types/raw.cjs +0 -90
  261. package/dist/node_modules/body-parser/lib/types/raw.js +0 -85
  262. package/dist/node_modules/body-parser/lib/types/text.cjs +0 -106
  263. package/dist/node_modules/body-parser/lib/types/text.js +0 -101
  264. package/dist/node_modules/body-parser/lib/types/urlencoded.cjs +0 -222
  265. package/dist/node_modules/body-parser/lib/types/urlencoded.js +0 -217
  266. package/dist/node_modules/body-parser/node_modules/qs/lib/formats.cjs +0 -34
  267. package/dist/node_modules/body-parser/node_modules/qs/lib/formats.js +0 -29
  268. package/dist/node_modules/body-parser/node_modules/qs/lib/index.cjs +0 -26
  269. package/dist/node_modules/body-parser/node_modules/qs/lib/index.js +0 -21
  270. package/dist/node_modules/body-parser/node_modules/qs/lib/parse.cjs +0 -187
  271. package/dist/node_modules/body-parser/node_modules/qs/lib/parse.js +0 -182
  272. package/dist/node_modules/body-parser/node_modules/qs/lib/stringify.cjs +0 -192
  273. package/dist/node_modules/body-parser/node_modules/qs/lib/stringify.js +0 -187
  274. package/dist/node_modules/body-parser/node_modules/qs/lib/utils.cjs +0 -178
  275. package/dist/node_modules/body-parser/node_modules/qs/lib/utils.js +0 -173
  276. package/dist/node_modules/bytes/index.cjs +0 -126
  277. package/dist/node_modules/bytes/index.js +0 -121
  278. package/dist/node_modules/call-bind-apply-helpers/actualApply.cjs +0 -25
  279. package/dist/node_modules/call-bind-apply-helpers/actualApply.js +0 -20
  280. package/dist/node_modules/call-bind-apply-helpers/functionApply.cjs +0 -17
  281. package/dist/node_modules/call-bind-apply-helpers/functionApply.js +0 -12
  282. package/dist/node_modules/call-bind-apply-helpers/functionCall.cjs +0 -17
  283. package/dist/node_modules/call-bind-apply-helpers/functionCall.js +0 -12
  284. package/dist/node_modules/call-bind-apply-helpers/index.cjs +0 -28
  285. package/dist/node_modules/call-bind-apply-helpers/index.js +0 -23
  286. package/dist/node_modules/call-bind-apply-helpers/reflectApply.cjs +0 -17
  287. package/dist/node_modules/call-bind-apply-helpers/reflectApply.js +0 -12
  288. package/dist/node_modules/call-bound/index.cjs +0 -27
  289. package/dist/node_modules/call-bound/index.js +0 -22
  290. package/dist/node_modules/content-disposition/index.cjs +0 -314
  291. package/dist/node_modules/content-disposition/index.js +0 -309
  292. package/dist/node_modules/content-type/index.cjs +0 -156
  293. package/dist/node_modules/content-type/index.js +0 -151
  294. package/dist/node_modules/cookie/index.cjs +0 -250
  295. package/dist/node_modules/cookie/index.js +0 -245
  296. package/dist/node_modules/cookie-signature/index.cjs +0 -51
  297. package/dist/node_modules/cookie-signature/index.js +0 -48
  298. package/dist/node_modules/debug/node_modules/has-flag/index.cjs +0 -22
  299. package/dist/node_modules/debug/node_modules/has-flag/index.js +0 -17
  300. package/dist/node_modules/debug/node_modules/supports-color/index.cjs +0 -75
  301. package/dist/node_modules/debug/node_modules/supports-color/index.js +0 -70
  302. package/dist/node_modules/debug/src/browser.cjs +0 -206
  303. package/dist/node_modules/debug/src/browser.js +0 -203
  304. package/dist/node_modules/debug/src/common.cjs +0 -212
  305. package/dist/node_modules/debug/src/common.js +0 -209
  306. package/dist/node_modules/debug/src/index.cjs +0 -21
  307. package/dist/node_modules/debug/src/index.js +0 -18
  308. package/dist/node_modules/debug/src/node.cjs +0 -218
  309. package/dist/node_modules/debug/src/node.js +0 -215
  310. package/dist/node_modules/depd/index.cjs +0 -319
  311. package/dist/node_modules/depd/index.js +0 -316
  312. package/dist/node_modules/destroy/index.cjs +0 -160
  313. package/dist/node_modules/destroy/index.js +0 -155
  314. package/dist/node_modules/dunder-proto/get.cjs +0 -32
  315. package/dist/node_modules/dunder-proto/get.js +0 -27
  316. package/dist/node_modules/ee-first/index.cjs +0 -80
  317. package/dist/node_modules/ee-first/index.js +0 -75
  318. package/dist/node_modules/encodeurl/index.cjs +0 -61
  319. package/dist/node_modules/encodeurl/index.js +0 -56
  320. package/dist/node_modules/es-define-property/index.cjs +0 -23
  321. package/dist/node_modules/es-define-property/index.js +0 -18
  322. package/dist/node_modules/es-errors/eval.cjs +0 -17
  323. package/dist/node_modules/es-errors/eval.js +0 -12
  324. package/dist/node_modules/es-errors/index.cjs +0 -17
  325. package/dist/node_modules/es-errors/index.js +0 -12
  326. package/dist/node_modules/es-errors/range.cjs +0 -17
  327. package/dist/node_modules/es-errors/range.js +0 -12
  328. package/dist/node_modules/es-errors/ref.cjs +0 -17
  329. package/dist/node_modules/es-errors/ref.js +0 -12
  330. package/dist/node_modules/es-errors/syntax.cjs +0 -17
  331. package/dist/node_modules/es-errors/syntax.js +0 -12
  332. package/dist/node_modules/es-errors/type.cjs +0 -17
  333. package/dist/node_modules/es-errors/type.js +0 -12
  334. package/dist/node_modules/es-errors/uri.cjs +0 -17
  335. package/dist/node_modules/es-errors/uri.js +0 -12
  336. package/dist/node_modules/es-object-atoms/index.cjs +0 -17
  337. package/dist/node_modules/es-object-atoms/index.js +0 -12
  338. package/dist/node_modules/escape-html/index.cjs +0 -72
  339. package/dist/node_modules/escape-html/index.js +0 -67
  340. package/dist/node_modules/etag/index.cjs +0 -87
  341. package/dist/node_modules/etag/index.js +0 -82
  342. package/dist/node_modules/express/index.cjs +0 -24
  343. package/dist/node_modules/express/index.js +0 -19
  344. package/dist/node_modules/express/lib/application.cjs +0 -508
  345. package/dist/node_modules/express/lib/application.js +0 -503
  346. package/dist/node_modules/express/lib/express.cjs +0 -119
  347. package/dist/node_modules/express/lib/express.js +0 -114
  348. package/dist/node_modules/express/lib/middleware/init.cjs +0 -49
  349. package/dist/node_modules/express/lib/middleware/init.js +0 -44
  350. package/dist/node_modules/express/lib/middleware/query.cjs +0 -52
  351. package/dist/node_modules/express/lib/middleware/query.js +0 -47
  352. package/dist/node_modules/express/lib/request.cjs +0 -427
  353. package/dist/node_modules/express/lib/request.js +0 -422
  354. package/dist/node_modules/express/lib/response.cjs +0 -872
  355. package/dist/node_modules/express/lib/response.js +0 -867
  356. package/dist/node_modules/express/lib/router/index.cjs +0 -429
  357. package/dist/node_modules/express/lib/router/index.js +0 -424
  358. package/dist/node_modules/express/lib/router/layer.cjs +0 -145
  359. package/dist/node_modules/express/lib/router/layer.js +0 -140
  360. package/dist/node_modules/express/lib/router/route.cjs +0 -163
  361. package/dist/node_modules/express/lib/router/route.js +0 -158
  362. package/dist/node_modules/express/lib/utils.cjs +0 -252
  363. package/dist/node_modules/express/lib/utils.js +0 -247
  364. package/dist/node_modules/express/lib/view.cjs +0 -140
  365. package/dist/node_modules/express/lib/view.js +0 -135
  366. package/dist/node_modules/express/node_modules/qs/lib/formats.cjs +0 -34
  367. package/dist/node_modules/express/node_modules/qs/lib/formats.js +0 -29
  368. package/dist/node_modules/express/node_modules/qs/lib/index.cjs +0 -26
  369. package/dist/node_modules/express/node_modules/qs/lib/index.js +0 -21
  370. package/dist/node_modules/express/node_modules/qs/lib/parse.cjs +0 -187
  371. package/dist/node_modules/express/node_modules/qs/lib/parse.js +0 -182
  372. package/dist/node_modules/express/node_modules/qs/lib/stringify.cjs +0 -192
  373. package/dist/node_modules/express/node_modules/qs/lib/stringify.js +0 -187
  374. package/dist/node_modules/express/node_modules/qs/lib/utils.cjs +0 -178
  375. package/dist/node_modules/express/node_modules/qs/lib/utils.js +0 -173
  376. package/dist/node_modules/finalhandler/index.cjs +0 -239
  377. package/dist/node_modules/finalhandler/index.js +0 -234
  378. package/dist/node_modules/forwarded/index.cjs +0 -72
  379. package/dist/node_modules/forwarded/index.js +0 -67
  380. package/dist/node_modules/fresh/index.cjs +0 -101
  381. package/dist/node_modules/fresh/index.js +0 -96
  382. package/dist/node_modules/function-bind/implementation.cjs +0 -63
  383. package/dist/node_modules/function-bind/implementation.js +0 -58
  384. package/dist/node_modules/function-bind/index.cjs +0 -18
  385. package/dist/node_modules/function-bind/index.js +0 -13
  386. package/dist/node_modules/get-intrinsic/index.cjs +0 -362
  387. package/dist/node_modules/get-intrinsic/index.js +0 -357
  388. package/dist/node_modules/get-proto/Object.getPrototypeOf.cjs +0 -19
  389. package/dist/node_modules/get-proto/Object.getPrototypeOf.js +0 -14
  390. package/dist/node_modules/get-proto/Reflect.getPrototypeOf.cjs +0 -17
  391. package/dist/node_modules/get-proto/Reflect.getPrototypeOf.js +0 -12
  392. package/dist/node_modules/get-proto/index.cjs +0 -30
  393. package/dist/node_modules/get-proto/index.js +0 -25
  394. package/dist/node_modules/gopd/gOPD.cjs +0 -17
  395. package/dist/node_modules/gopd/gOPD.js +0 -12
  396. package/dist/node_modules/gopd/index.cjs +0 -24
  397. package/dist/node_modules/gopd/index.js +0 -19
  398. package/dist/node_modules/has-symbols/index.cjs +0 -26
  399. package/dist/node_modules/has-symbols/index.js +0 -21
  400. package/dist/node_modules/has-symbols/shams.cjs +0 -40
  401. package/dist/node_modules/has-symbols/shams.js +0 -35
  402. package/dist/node_modules/hasown/index.cjs +0 -21
  403. package/dist/node_modules/hasown/index.js +0 -16
  404. package/dist/node_modules/http-errors/index.cjs +0 -212
  405. package/dist/node_modules/http-errors/index.js +0 -207
  406. package/dist/node_modules/iconv-lite/encodings/dbcs-codec.cjs +0 -326
  407. package/dist/node_modules/iconv-lite/encodings/dbcs-codec.js +0 -321
  408. package/dist/node_modules/iconv-lite/encodings/dbcs-data.cjs +0 -131
  409. package/dist/node_modules/iconv-lite/encodings/dbcs-data.js +0 -126
  410. package/dist/node_modules/iconv-lite/encodings/index.cjs +0 -37
  411. package/dist/node_modules/iconv-lite/encodings/index.js +0 -32
  412. package/dist/node_modules/iconv-lite/encodings/internal.cjs +0 -140
  413. package/dist/node_modules/iconv-lite/encodings/internal.js +0 -135
  414. package/dist/node_modules/iconv-lite/encodings/sbcs-codec.cjs +0 -58
  415. package/dist/node_modules/iconv-lite/encodings/sbcs-codec.js +0 -53
  416. package/dist/node_modules/iconv-lite/encodings/sbcs-data-generated.cjs +0 -463
  417. package/dist/node_modules/iconv-lite/encodings/sbcs-data-generated.js +0 -458
  418. package/dist/node_modules/iconv-lite/encodings/sbcs-data.cjs +0 -155
  419. package/dist/node_modules/iconv-lite/encodings/sbcs-data.js +0 -150
  420. package/dist/node_modules/iconv-lite/encodings/tables/big5-added.cjs +0 -175
  421. package/dist/node_modules/iconv-lite/encodings/tables/big5-added.js +0 -172
  422. package/dist/node_modules/iconv-lite/encodings/tables/cp936.cjs +0 -2590
  423. package/dist/node_modules/iconv-lite/encodings/tables/cp936.js +0 -2587
  424. package/dist/node_modules/iconv-lite/encodings/tables/cp949.cjs +0 -2226
  425. package/dist/node_modules/iconv-lite/encodings/tables/cp949.js +0 -2223
  426. package/dist/node_modules/iconv-lite/encodings/tables/cp950.cjs +0 -233
  427. package/dist/node_modules/iconv-lite/encodings/tables/cp950.js +0 -230
  428. package/dist/node_modules/iconv-lite/encodings/tables/eucjp.cjs +0 -431
  429. package/dist/node_modules/iconv-lite/encodings/tables/eucjp.js +0 -428
  430. package/dist/node_modules/iconv-lite/encodings/tables/gb18030-ranges.cjs +0 -433
  431. package/dist/node_modules/iconv-lite/encodings/tables/gb18030-ranges.js +0 -430
  432. package/dist/node_modules/iconv-lite/encodings/tables/gbk-added.cjs +0 -235
  433. package/dist/node_modules/iconv-lite/encodings/tables/gbk-added.js +0 -232
  434. package/dist/node_modules/iconv-lite/encodings/tables/shiftjis.cjs +0 -298
  435. package/dist/node_modules/iconv-lite/encodings/tables/shiftjis.js +0 -295
  436. package/dist/node_modules/iconv-lite/encodings/utf16.cjs +0 -112
  437. package/dist/node_modules/iconv-lite/encodings/utf16.js +0 -107
  438. package/dist/node_modules/iconv-lite/encodings/utf7.cjs +0 -188
  439. package/dist/node_modules/iconv-lite/encodings/utf7.js +0 -183
  440. package/dist/node_modules/iconv-lite/lib/bom-handling.cjs +0 -50
  441. package/dist/node_modules/iconv-lite/lib/bom-handling.js +0 -45
  442. package/dist/node_modules/iconv-lite/lib/extend-node.cjs +0 -155
  443. package/dist/node_modules/iconv-lite/lib/extend-node.js +0 -150
  444. package/dist/node_modules/iconv-lite/lib/index.cjs +0 -101
  445. package/dist/node_modules/iconv-lite/lib/index.js +0 -96
  446. package/dist/node_modules/iconv-lite/lib/streams.cjs +0 -102
  447. package/dist/node_modules/iconv-lite/lib/streams.js +0 -97
  448. package/dist/node_modules/inherits/inherits.cjs +0 -23
  449. package/dist/node_modules/inherits/inherits.js +0 -20
  450. package/dist/node_modules/inherits/inherits_browser.cjs +0 -33
  451. package/dist/node_modules/inherits/inherits_browser.js +0 -30
  452. package/dist/node_modules/ipaddr.js/lib/ipaddr.cjs +0 -680
  453. package/dist/node_modules/ipaddr.js/lib/ipaddr.js +0 -677
  454. package/dist/node_modules/math-intrinsics/abs.cjs +0 -17
  455. package/dist/node_modules/math-intrinsics/abs.js +0 -12
  456. package/dist/node_modules/math-intrinsics/floor.cjs +0 -17
  457. package/dist/node_modules/math-intrinsics/floor.js +0 -12
  458. package/dist/node_modules/math-intrinsics/isNaN.cjs +0 -19
  459. package/dist/node_modules/math-intrinsics/isNaN.js +0 -14
  460. package/dist/node_modules/math-intrinsics/max.cjs +0 -17
  461. package/dist/node_modules/math-intrinsics/max.js +0 -12
  462. package/dist/node_modules/math-intrinsics/min.cjs +0 -17
  463. package/dist/node_modules/math-intrinsics/min.js +0 -12
  464. package/dist/node_modules/math-intrinsics/pow.cjs +0 -17
  465. package/dist/node_modules/math-intrinsics/pow.js +0 -12
  466. package/dist/node_modules/math-intrinsics/round.cjs +0 -17
  467. package/dist/node_modules/math-intrinsics/round.js +0 -12
  468. package/dist/node_modules/math-intrinsics/sign.cjs +0 -22
  469. package/dist/node_modules/math-intrinsics/sign.js +0 -17
  470. package/dist/node_modules/merge-descriptors/index.cjs +0 -51
  471. package/dist/node_modules/merge-descriptors/index.js +0 -46
  472. package/dist/node_modules/methods/index.cjs +0 -74
  473. package/dist/node_modules/methods/index.js +0 -69
  474. package/dist/node_modules/mime/mime.cjs +0 -82
  475. package/dist/node_modules/mime/mime.js +0 -79
  476. package/dist/node_modules/mime/types.cjs +0 -1107
  477. package/dist/node_modules/mime/types.js +0 -1104
  478. package/dist/node_modules/mime-types/index.cjs +0 -128
  479. package/dist/node_modules/mime-types/index.js +0 -123
  480. package/dist/node_modules/mime-types/node_modules/mime-db/db.cjs +0 -7054
  481. package/dist/node_modules/mime-types/node_modules/mime-db/db.js +0 -7051
  482. package/dist/node_modules/mime-types/node_modules/mime-db/index.cjs +0 -24
  483. package/dist/node_modules/mime-types/node_modules/mime-db/index.js +0 -21
  484. package/dist/node_modules/ms/index.cjs +0 -127
  485. package/dist/node_modules/ms/index.js +0 -124
  486. package/dist/node_modules/negotiator/index.cjs +0 -81
  487. package/dist/node_modules/negotiator/index.js +0 -76
  488. package/dist/node_modules/negotiator/lib/charset.cjs +0 -137
  489. package/dist/node_modules/negotiator/lib/charset.js +0 -132
  490. package/dist/node_modules/negotiator/lib/encoding.cjs +0 -148
  491. package/dist/node_modules/negotiator/lib/encoding.js +0 -143
  492. package/dist/node_modules/negotiator/lib/language.cjs +0 -143
  493. package/dist/node_modules/negotiator/lib/language.js +0 -138
  494. package/dist/node_modules/negotiator/lib/mediaType.cjs +0 -205
  495. package/dist/node_modules/negotiator/lib/mediaType.js +0 -200
  496. package/dist/node_modules/object-inspect/index.cjs +0 -392
  497. package/dist/node_modules/object-inspect/index.js +0 -389
  498. package/dist/node_modules/object-inspect/util.inspect.cjs +0 -14
  499. package/dist/node_modules/object-inspect/util.inspect.js +0 -11
  500. package/dist/node_modules/on-finished/index.cjs +0 -183
  501. package/dist/node_modules/on-finished/index.js +0 -178
  502. package/dist/node_modules/parseurl/index.cjs +0 -116
  503. package/dist/node_modules/parseurl/index.js +0 -111
  504. package/dist/node_modules/path-to-regexp/index.cjs +0 -121
  505. package/dist/node_modules/path-to-regexp/index.js +0 -118
  506. package/dist/node_modules/proxy-addr/index.cjs +0 -217
  507. package/dist/node_modules/proxy-addr/index.js +0 -212
  508. package/dist/node_modules/range-parser/index.cjs +0 -115
  509. package/dist/node_modules/range-parser/index.js +0 -110
  510. package/dist/node_modules/raw-body/index.cjs +0 -214
  511. package/dist/node_modules/raw-body/index.js +0 -209
  512. package/dist/node_modules/safe-buffer/index.cjs +0 -49
  513. package/dist/node_modules/safe-buffer/index.js +0 -46
  514. package/dist/node_modules/safer-buffer/safer.cjs +0 -53
  515. package/dist/node_modules/safer-buffer/safer.js +0 -48
  516. package/dist/node_modules/send/index.cjs +0 -806
  517. package/dist/node_modules/send/index.js +0 -801
  518. package/dist/node_modules/send/node_modules/encodeurl/index.cjs +0 -61
  519. package/dist/node_modules/send/node_modules/encodeurl/index.js +0 -56
  520. package/dist/node_modules/serve-static/index.cjs +0 -139
  521. package/dist/node_modules/serve-static/index.js +0 -134
  522. package/dist/node_modules/setprototypeof/index.cjs +0 -24
  523. package/dist/node_modules/setprototypeof/index.js +0 -19
  524. package/dist/node_modules/side-channel/index.cjs +0 -50
  525. package/dist/node_modules/side-channel/index.js +0 -45
  526. package/dist/node_modules/side-channel-list/index.cjs +0 -89
  527. package/dist/node_modules/side-channel-list/index.js +0 -84
  528. package/dist/node_modules/side-channel-map/index.cjs +0 -67
  529. package/dist/node_modules/side-channel-map/index.js +0 -62
  530. package/dist/node_modules/side-channel-weakmap/index.cjs +0 -78
  531. package/dist/node_modules/side-channel-weakmap/index.js +0 -73
  532. package/dist/node_modules/statuses/codes.cjs +0 -78
  533. package/dist/node_modules/statuses/codes.js +0 -75
  534. package/dist/node_modules/statuses/index.cjs +0 -113
  535. package/dist/node_modules/statuses/index.js +0 -108
  536. package/dist/node_modules/toidentifier/index.cjs +0 -37
  537. package/dist/node_modules/toidentifier/index.js +0 -32
  538. package/dist/node_modules/type-is/index.cjs +0 -184
  539. package/dist/node_modules/type-is/index.js +0 -179
  540. package/dist/node_modules/type-is/node_modules/media-typer/index.cjs +0 -189
  541. package/dist/node_modules/type-is/node_modules/media-typer/index.js +0 -186
  542. package/dist/node_modules/unpipe/index.cjs +0 -55
  543. package/dist/node_modules/unpipe/index.js +0 -50
  544. package/dist/node_modules/utils-merge/index.cjs +0 -31
  545. package/dist/node_modules/utils-merge/index.js +0 -28
  546. package/dist/node_modules/vary/index.cjs +0 -100
  547. package/dist/node_modules/vary/index.js +0 -95
  548. package/dist/packages/sadot/src/api/index.cjs +0 -12
  549. package/dist/packages/sadot/src/api/index.js +0 -11
  550. package/dist/packages/sadot/src/api/v1/definition/index.cjs +0 -113
  551. package/dist/packages/sadot/src/api/v1/definition/index.js +0 -112
  552. package/dist/packages/sadot/src/api/v1/definition/validations.cjs +0 -128
  553. package/dist/packages/sadot/src/api/v1/definition/validations.js +0 -125
  554. package/dist/packages/sadot/src/api/v1/errors.cjs +0 -14
  555. package/dist/packages/sadot/src/api/v1/errors.js +0 -13
  556. package/dist/packages/sadot/src/api/v1/index.cjs +0 -16
  557. package/dist/packages/sadot/src/api/v1/index.js +0 -15
  558. package/dist/packages/sadot/src/api/v1/templates/index.cjs +0 -77
  559. package/dist/packages/sadot/src/api/v1/templates/index.js +0 -76
  560. package/dist/packages/sadot/src/api/v1/validator/index.cjs +0 -115
  561. package/dist/packages/sadot/src/api/v1/validator/index.js +0 -114
  562. package/dist/packages/sadot/src/api/v1/validator/validations.cjs +0 -40
  563. package/dist/packages/sadot/src/api/v1/validator/validations.js +0 -38
  564. package/dist/packages/sadot/src/errors/index.cjs +0 -62
  565. package/dist/packages/sadot/src/errors/index.js +0 -55
  566. package/dist/packages/sadot/src/events/index.cjs +0 -52
  567. package/dist/packages/sadot/src/events/index.js +0 -50
  568. package/dist/packages/sadot/src/hooks/enrich.cjs +0 -175
  569. package/dist/packages/sadot/src/hooks/enrich.js +0 -175
  570. package/dist/packages/sadot/src/hooks/find.cjs +0 -22
  571. package/dist/packages/sadot/src/hooks/find.js +0 -22
  572. package/dist/packages/sadot/src/hooks/hooks.cjs +0 -310
  573. package/dist/packages/sadot/src/hooks/hooks.js +0 -302
  574. package/dist/packages/sadot/src/hooks/index.cjs +0 -3
  575. package/dist/packages/sadot/src/hooks/index.js +0 -5
  576. package/dist/packages/sadot/src/hooks/utils/updateInstanceValues.cjs +0 -27
  577. package/dist/packages/sadot/src/hooks/utils/updateInstanceValues.js +0 -27
  578. package/dist/packages/sadot/src/init-state.cjs +0 -56
  579. package/dist/packages/sadot/src/init-state.js +0 -55
  580. package/dist/packages/sadot/src/mat-path-state.cjs +0 -10
  581. package/dist/packages/sadot/src/mat-path-state.js +0 -9
  582. package/dist/packages/sadot/src/migrations/004-create-field-policy-tables.cjs +0 -29
  583. package/dist/packages/sadot/src/migrations/004-create-field-policy-tables.js +0 -27
  584. package/dist/packages/sadot/src/migrations/index.cjs +0 -88
  585. package/dist/packages/sadot/src/migrations/index.js +0 -89
  586. package/dist/packages/sadot/src/models/CustomFieldDefinition.cjs +0 -147
  587. package/dist/packages/sadot/src/models/CustomFieldDefinition.js +0 -146
  588. package/dist/packages/sadot/src/models/CustomFieldEntries.cjs +0 -71
  589. package/dist/packages/sadot/src/models/CustomFieldEntries.js +0 -70
  590. package/dist/packages/sadot/src/models/CustomFieldModelTypeMap.cjs +0 -62
  591. package/dist/packages/sadot/src/models/CustomFieldModelTypeMap.js +0 -61
  592. package/dist/packages/sadot/src/models/CustomFieldValue.cjs +0 -109
  593. package/dist/packages/sadot/src/models/CustomFieldValue.js +0 -108
  594. package/dist/packages/sadot/src/models/CustomValidator.cjs +0 -68
  595. package/dist/packages/sadot/src/models/CustomValidator.js +0 -67
  596. package/dist/packages/sadot/src/models/FieldPolicy.cjs +0 -50
  597. package/dist/packages/sadot/src/models/FieldPolicy.d.ts +0 -23
  598. package/dist/packages/sadot/src/models/FieldPolicy.js +0 -49
  599. package/dist/packages/sadot/src/models/index.cjs +0 -163
  600. package/dist/packages/sadot/src/models/index.js +0 -161
  601. package/dist/packages/sadot/src/models/tests/AssociatedTestModel.cjs +0 -51
  602. package/dist/packages/sadot/src/models/tests/AssociatedTestModel.js +0 -50
  603. package/dist/packages/sadot/src/models/tests/TestModel.cjs +0 -43
  604. package/dist/packages/sadot/src/models/tests/TestModel.js +0 -42
  605. package/dist/packages/sadot/src/models/tests/contextAwareModels/ContextAwareTestModel.cjs +0 -35
  606. package/dist/packages/sadot/src/models/tests/contextAwareModels/ContextAwareTestModel.js +0 -34
  607. package/dist/packages/sadot/src/models/tests/contextAwareModels/ContextTestModel.cjs +0 -33
  608. package/dist/packages/sadot/src/models/tests/contextAwareModels/ContextTestModel.js +0 -32
  609. package/dist/packages/sadot/src/repository/definition.cjs +0 -221
  610. package/dist/packages/sadot/src/repository/definition.js +0 -212
  611. package/dist/packages/sadot/src/repository/entries.cjs +0 -69
  612. package/dist/packages/sadot/src/repository/entries.js +0 -67
  613. package/dist/packages/sadot/src/repository/field-policy.cjs +0 -42
  614. package/dist/packages/sadot/src/repository/field-policy.d.ts +0 -29
  615. package/dist/packages/sadot/src/repository/field-policy.js +0 -33
  616. package/dist/packages/sadot/src/repository/utils/formatValues.cjs +0 -14
  617. package/dist/packages/sadot/src/repository/utils/formatValues.js +0 -14
  618. package/dist/packages/sadot/src/repository/validator.cjs +0 -58
  619. package/dist/packages/sadot/src/repository/validator.js +0 -54
  620. package/dist/packages/sadot/src/repository/value.cjs +0 -77
  621. package/dist/packages/sadot/src/repository/value.js +0 -76
  622. package/dist/packages/sadot/src/scopes/filter.cjs +0 -56
  623. package/dist/packages/sadot/src/scopes/filter.js +0 -54
  624. package/dist/packages/sadot/src/scopes/helpers/filter.helpers.cjs +0 -152
  625. package/dist/packages/sadot/src/scopes/helpers/filter.helpers.js +0 -147
  626. package/dist/packages/sadot/src/scopes/index.cjs +0 -1
  627. package/dist/packages/sadot/src/scopes/index.js +0 -3
  628. package/dist/packages/sadot/src/utils/constants/index.cjs +0 -32
  629. package/dist/packages/sadot/src/utils/constants/index.js +0 -29
  630. package/dist/packages/sadot/src/utils/db/index.cjs +0 -15
  631. package/dist/packages/sadot/src/utils/db/index.js +0 -14
  632. package/dist/packages/sadot/src/utils/helpers/index.cjs +0 -23
  633. package/dist/packages/sadot/src/utils/helpers/index.js +0 -21
  634. package/dist/packages/sadot/src/utils/init.cjs +0 -115
  635. package/dist/packages/sadot/src/utils/init.js +0 -111
  636. package/dist/packages/sadot/src/utils/logger/index.cjs +0 -15
  637. package/dist/packages/sadot/src/utils/logger/index.js +0 -12
  638. package/dist/packages/sadot/src/utils/scopeAttributes.cjs +0 -12
  639. package/dist/packages/sadot/src/utils/scopeAttributes.js +0 -11
  640. package/dist/packages/sadot/src/utils/validations/index.cjs +0 -34
  641. package/dist/packages/sadot/src/utils/validations/index.js +0 -32
  642. package/dist/packages/sadot/src/utils/validations/schema/custom-fields.cjs +0 -9
  643. package/dist/packages/sadot/src/utils/validations/schema/custom-fields.js +0 -7
  644. package/dist/packages/sadot/src/utils/validations/schema/validator-schema.cjs +0 -102
  645. package/dist/packages/sadot/src/utils/validations/schema/validator-schema.js +0 -99
  646. package/dist/packages/sadot/src/utils/validations/validators/index.cjs +0 -45
  647. package/dist/packages/sadot/src/utils/validations/validators/index.js +0 -42
  648. package/dist/packages/sadot/src/utils/validations/validators/multi-select-dropdown.validator.cjs +0 -7
  649. package/dist/packages/sadot/src/utils/validations/validators/multi-select-dropdown.validator.js +0 -7
  650. package/dist/packages/sadot/src/utils/validations/validators/multi-select-status.validator.cjs +0 -10
  651. package/dist/packages/sadot/src/utils/validations/validators/multi-select-status.validator.js +0 -10
  652. package/dist/packages/sadot/src/utils/validations/validators/multi-select.helpers.cjs +0 -12
  653. package/dist/packages/sadot/src/utils/validations/validators/multi-select.helpers.js +0 -10
  654. package/dist/packages/sadot/src/utils/validations/validators/select.validator.cjs +0 -12
  655. package/dist/packages/sadot/src/utils/validations/validators/select.validator.js +0 -10
  656. package/dist/packages/sadot/src/utils/validations/validators/status.validator.cjs +0 -12
  657. package/dist/packages/sadot/src/utils/validations/validators/status.validator.js +0 -10
  658. package/dist/repository/field-policy.d.cts +0 -29
  659. /package/dist/{packages/sadot/src/models → models}/index.d.ts +0 -0
@@ -1,11 +1 @@
1
-
2
- //#region \0@oxc-project+runtime@0.103.0/helpers/decorate.js
3
- function __decorate(decorators, target, key, desc) {
4
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
6
- 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;
7
- return c > 3 && r && Object.defineProperty(target, key, r), r;
8
- }
9
-
10
- //#endregion
11
- exports.__decorate = __decorate;
1
+ function e(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}exports.__decorate=e;
@@ -1,10 +1 @@
1
- //#region \0@oxc-project+runtime@0.103.0/helpers/decorate.js
2
- function __decorate(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
-
9
- //#endregion
10
- export { __decorate };
1
+ function e(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}export{e as __decorate};
@@ -1,8 +1 @@
1
-
2
- //#region \0@oxc-project+runtime@0.103.0/helpers/decorateMetadata.js
3
- function __decorateMetadata(k, v) {
4
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
5
- }
6
-
7
- //#endregion
8
- exports.__decorateMetadata = __decorateMetadata;
1
+ function e(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}exports.__decorateMetadata=e;
@@ -1,7 +1 @@
1
- //#region \0@oxc-project+runtime@0.103.0/helpers/decorateMetadata.js
2
- function __decorateMetadata(k, v) {
3
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4
- }
5
-
6
- //#endregion
7
- export { __decorateMetadata };
1
+ function e(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}export{e as __decorateMetadata};
@@ -1,45 +1 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
9
- var __export = (all, symbols) => {
10
- let target = {};
11
- for (var name in all) {
12
- __defProp(target, name, {
13
- get: all[name],
14
- enumerable: true
15
- });
16
- }
17
- if (symbols) {
18
- __defProp(target, Symbol.toStringTag, { value: "Module" });
19
- }
20
- return target;
21
- };
22
- var __copyProps = (to, from, except, desc) => {
23
- if (from && typeof from === "object" || typeof from === "function") {
24
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
25
- key = keys[i];
26
- if (!__hasOwnProp.call(to, key) && key !== except) {
27
- __defProp(to, key, {
28
- get: ((k) => from[k]).bind(null, key),
29
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
30
- });
31
- }
32
- }
33
- }
34
- return to;
35
- };
36
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
37
- value: mod,
38
- enumerable: true
39
- }) : target, mod));
40
-
41
- //#endregion
42
-
43
- exports.__commonJSMin = __commonJSMin;
44
- exports.__export = __export;
45
- exports.__toESM = __toESM;
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
@@ -1,22 +1 @@
1
- import { createRequire } from "node:module";
2
-
3
- //#region rolldown:runtime
4
- var __defProp = Object.defineProperty;
5
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
6
- var __export = (all, symbols) => {
7
- let target = {};
8
- for (var name in all) {
9
- __defProp(target, name, {
10
- get: all[name],
11
- enumerable: true
12
- });
13
- }
14
- if (symbols) {
15
- __defProp(target, Symbol.toStringTag, { value: "Module" });
16
- }
17
- return target;
18
- };
19
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
20
-
21
- //#endregion
22
- export { __commonJSMin, __export, __require };
1
+ import{createRequire as e}from"node:module";var t=e(import.meta.url);export{t as __require};
@@ -0,0 +1,2 @@
1
+ const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`../utils/logger/index.cjs`),n=require(`./v1/index.cjs`);let r=require(`@autofleet/node-common`);const i=(0,r.Router)({logger:t.default});i.use(`/v1`,n.default);var a=i;exports.default=a;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["router: ReturnType<typeof Router>","v1"],"sources":["../../src/api/index.ts"],"sourcesContent":["// export the api object\nimport { Router } from '@autofleet/node-common';\nimport v1 from './v1';\nimport logger from '../utils/logger';\n\nconst router: ReturnType<typeof Router> = Router({ logger });\n\nrouter.use('/v1', v1);\n\nexport default router;\n"],"mappings":"+JAKA,MAAMA,GAAAA,EAAAA,EAAAA,QAA2C,CAAE,OAAA,EAAA,QAAQ,CAAC,CAE5D,EAAO,IAAI,MAAOC,EAAAA,QAAG,CAErB,IAAA,EAAe"}
@@ -0,0 +1,2 @@
1
+ import e from"../utils/logger/index.js";import t from"./v1/index.js";import{Router as n}from"@autofleet/node-common";const r=n({logger:e});r.use(`/v1`,t);var i=r;export{i as default};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["router: ReturnType<typeof Router>","v1"],"sources":["../../src/api/index.ts"],"sourcesContent":["// export the api object\nimport { Router } from '@autofleet/node-common';\nimport v1 from './v1';\nimport logger from '../utils/logger';\n\nconst router: ReturnType<typeof Router> = Router({ logger });\n\nrouter.use('/v1', v1);\n\nexport default router;\n"],"mappings":"qHAKA,MAAMA,EAAoC,EAAO,CAAE,OAAA,EAAQ,CAAC,CAE5D,EAAO,IAAI,MAAOC,EAAG,CAErB,IAAA,EAAe"}
@@ -0,0 +1,2 @@
1
+ const e=require(`../../../_virtual/rolldown_runtime.cjs`),t=require(`../../../utils/logger/index.cjs`),n=require(`../../../repository/definition.cjs`),r=require(`../errors.cjs`),i=require(`./validations.cjs`),a=require(`../../../mat-path-state.cjs`);let o=require(`@autofleet/errors`),s=require(`@autofleet/node-common`);const c=(0,s.Router)({logger:t.default}),l=`CustomFieldDefinition`,u=e=>e.replace(/(^\w|-\w)/g,e=>e.replace(/-/,``).toUpperCase());c.post(`/`,async(e,a)=>{let{modelName:o}=e.params,s=u(o);try{let t=await i.validateCustomFieldDefinitionCreation(e.body),r=await n.create({...t,modelType:s});return a.status(201).json(r)}catch(e){return t.default.error(`Failed to create custom field definition`,e),r.default(e,a,{logger:t.default,message:`Error in create ${l} request`})}}),c.get(`/:customFieldDefinitionId`,async(e,i)=>{let{customFieldDefinitionId:a}=e.params;try{let e=await n.findById(a);if(!e)throw new o.ResourceNotFoundError;return i.json(e)}catch(e){return t.default.error(`Failed to fetch custom field definition`,e),r.default(e,i,{logger:t.default,message:`Error in get ${l} request`})}}),c.get(`/`,async(e,i)=>{let{params:{modelName:o},query:{entityIds:s,modelTypeId:c}}=e,d=u(o);try{let e=!a.matPathState.isMatPathEnabled?.()&&s&&s.length>0;if(c){let t=await n.findByModelTypeId(c,{withDisabled:!0,modelType:d,entityIds:e?s:void 0});return i.json(t)}let t={modelType:d,...e&&{entityId:s}},r=await n.findAll(t,{withDisabled:!0,enrichWithModelTypeIds:!0});return i.json(r)}catch(e){return t.default.error(`Failed to fetch custom field definitions`,e),r.default(e,i,{logger:t.default,message:`Error in get all ${l} request`})}}),c.patch(`/:customFieldDefinitionId`,async(e,a)=>{let{customFieldDefinitionId:s,modelName:c}=e.params,d=u(c);try{let t=await i.validateCustomFieldDefinitionUpdate(e.body);if(!await n.findByWhere({id:s,modelType:d}))throw new o.ResourceNotFoundError;let r=await n.update(s,{...t,modelType:d});return a.status(200).json(r)}catch(e){return t.default.error(`Failed to patch custom field definition`,e),r.default(e,a,{logger:t.default,message:`Error in update ${l} request`})}});var d=c;exports.default=d;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["router: ReturnType<typeof Router>","validatedPayload: CreateCustomFieldDefinition","validateCustomFieldDefinitionCreation","handleError","ResourceNotFoundError","matPathState","customFieldDefinitions","validatedPayload: UpdateCustomFieldDefinition","validateCustomFieldDefinitionUpdate"],"sources":["../../../../src/api/v1/definition/index.ts"],"sourcesContent":["import { ResourceNotFoundError } from '@autofleet/errors';\nimport { Router } from '@autofleet/node-common';\nimport handleError from '../errors';\nimport * as DefinitionRepo from '../../../repository/definition';\nimport type { CreateCustomFieldDefinition, UpdateCustomFieldDefinition } from '../../../types/definition';\nimport { validateCustomFieldDefinitionCreation, validateCustomFieldDefinitionUpdate } from './validations';\nimport logger from '../../../utils/logger';\nimport type { CustomFieldDefinition } from '../../../models';\nimport { matPathState } from '../../../mat-path-state';\n\nconst router: ReturnType<typeof Router> = Router({ logger });\nconst ENTITY = 'CustomFieldDefinition';\n\nconst toPascalCase = (str: string): string => str.replace(/(^\\w|-\\w)/g, subStr => subStr.replace(/-/, '').toUpperCase());\n\n/**\n * Create\n */\nrouter.post<{ modelName: string; }>('/', async (req, res) => {\n const { modelName } = req.params;\n const modelType = toPascalCase(modelName);\n try {\n const validatedPayload: CreateCustomFieldDefinition = await validateCustomFieldDefinitionCreation(req.body);\n\n const customFieldDefinition = await DefinitionRepo.create({\n ...validatedPayload,\n modelType,\n });\n return res.status(201).json(customFieldDefinition);\n } catch (err) {\n logger.error('Failed to create custom field definition', err);\n return handleError(err as Error, res, { logger, message: `Error in create ${ENTITY} request` });\n }\n});\n\n/**\n * Get by id\n */\nrouter.get<{ modelName: string; customFieldDefinitionId: string; }, CustomFieldDefinition>('/:customFieldDefinitionId', async (req, res) => {\n const { customFieldDefinitionId } = req.params;\n try {\n const customFieldDefinition = await DefinitionRepo.findById(customFieldDefinitionId);\n\n if (!customFieldDefinition) {\n throw new ResourceNotFoundError();\n }\n\n return res.json(customFieldDefinition);\n } catch (err) {\n logger.error('Failed to fetch custom field definition', err);\n return handleError(err as Error, res, { logger, message: `Error in get ${ENTITY} request` });\n }\n});\n\n/**\n * Get all\n */\nrouter.get<{ modelName: string; }, CustomFieldDefinition[], never, { entityIds?: string[]; modelTypeId?: string; }>('/', async (req, res) => {\n const { params: { modelName }, query: { entityIds, modelTypeId } } = req;\n\n const modelType = toPascalCase(modelName);\n try {\n // When mat-path is active, drop the explicit `entityId IN (entityIds)` WHERE filter — RLS\n // on `custom_field_definitions` (applied via decorateModelMethods) restricts the result\n // to the caller's visible scope (fleet + ancestor partners). If the WHERE clause kept the\n // requested entityIds, partner CFDs (whose entity_id differs from the requested fleet's\n // entityId) would be filtered out by the WHERE before RLS could include them.\n const applyEntityIdsFilter = !matPathState.isMatPathEnabled?.() && entityIds && entityIds.length > 0;\n\n // If modelTypeId is provided, get definitions applicable to that specific type instance\n if (modelTypeId) {\n const customFieldDefinitions = await DefinitionRepo.findByModelTypeId(modelTypeId, {\n withDisabled: true,\n modelType,\n entityIds: applyEntityIdsFilter ? entityIds : undefined,\n });\n return res.json(customFieldDefinitions);\n }\n\n const where = {\n modelType,\n ...(applyEntityIdsFilter && { entityId: entityIds }),\n };\n const customFieldDefinitions = await DefinitionRepo.findAll(where, { withDisabled: true, enrichWithModelTypeIds: true });\n return res.json(customFieldDefinitions);\n } catch (err) {\n logger.error('Failed to fetch custom field definitions', err);\n return handleError(err as Error, res, { logger, message: `Error in get all ${ENTITY} request` });\n }\n});\n\n/**\n * Update\n */\nrouter.patch<{ modelName: string; customFieldDefinitionId: string; }, CustomFieldDefinition>('/:customFieldDefinitionId', async (req, res) => {\n const { customFieldDefinitionId, modelName } = req.params;\n const modelType = toPascalCase(modelName);\n try {\n const validatedPayload: UpdateCustomFieldDefinition = await validateCustomFieldDefinitionUpdate(req.body);\n\n const customFieldDefinition = await DefinitionRepo.findByWhere({\n id: customFieldDefinitionId,\n modelType,\n });\n\n if (!customFieldDefinition) {\n throw new ResourceNotFoundError();\n }\n\n const updatedCustomFieldDefinition = await DefinitionRepo.update(\n customFieldDefinitionId,\n { ...validatedPayload, modelType },\n );\n\n return res.status(200).json(updatedCustomFieldDefinition);\n } catch (err) {\n logger.error('Failed to patch custom field definition', err);\n return handleError(err as Error, res, { logger, message: `Error in update ${ENTITY} request` });\n }\n});\n\nexport default router;\n"],"mappings":"iUAUA,MAAMA,GAAAA,EAAAA,EAAAA,QAA2C,CAAE,OAAA,EAAA,QAAQ,CAAC,CACtD,EAAS,wBAET,EAAgB,GAAwB,EAAI,QAAQ,aAAc,GAAU,EAAO,QAAQ,IAAK,GAAG,CAAC,aAAa,CAAC,CAKxH,EAAO,KAA6B,IAAK,MAAO,EAAK,IAAQ,CAC3D,GAAM,CAAE,aAAc,EAAI,OACpB,EAAY,EAAa,EAAU,CACzC,GAAI,CACF,IAAMC,EAAgD,MAAMC,EAAAA,sCAAsC,EAAI,KAAK,CAErG,EAAwB,MAAA,EAAA,OAA4B,CACxD,GAAG,EACH,YACD,CAAC,CACF,OAAO,EAAI,OAAO,IAAI,CAAC,KAAK,EAAsB,OAC3C,EAAK,CAEZ,OADA,EAAA,QAAO,MAAM,2CAA4C,EAAI,CACtDC,EAAAA,QAAY,EAAc,EAAK,CAAE,OAAA,EAAA,QAAQ,QAAS,mBAAmB,EAAO,UAAW,CAAC,GAEjG,CAKF,EAAO,IAAoF,4BAA6B,MAAO,EAAK,IAAQ,CAC1I,GAAM,CAAE,2BAA4B,EAAI,OACxC,GAAI,CACF,IAAM,EAAwB,MAAA,EAAA,SAA8B,EAAwB,CAEpF,GAAI,CAAC,EACH,MAAM,IAAIC,EAAAA,sBAGZ,OAAO,EAAI,KAAK,EAAsB,OAC/B,EAAK,CA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K,EAA6B,OAClD,EAAK,CAEZ,OADA,EAAA,QAAO,MAAM,0CAA2C,EAAI,CACrDD,EAAAA,QAAY,EAAc,EAAK,CAAE,OAAA,EAAA,QAAQ,QAAS,mBAAmB,EAAO,UAAW,CAAC,GAEjG,CAEF,IAAA,EAAe"}
@@ -0,0 +1,2 @@
1
+ import e from"../../../utils/logger/index.js";import{create as t,findAll as n,findById as r,findByModelTypeId as i,findByWhere as a,update as o}from"../../../repository/definition.js";import s from"../errors.js";import{validateCustomFieldDefinitionCreation as c,validateCustomFieldDefinitionUpdate as l}from"./validations.js";import{matPathState as u}from"../../../mat-path-state.js";import{ResourceNotFoundError as d}from"@autofleet/errors";import{Router as f}from"@autofleet/node-common";const p=f({logger:e}),m=`CustomFieldDefinition`,h=e=>e.replace(/(^\w|-\w)/g,e=>e.replace(/-/,``).toUpperCase());p.post(`/`,async(n,r)=>{let{modelName:i}=n.params,a=h(i);try{let e=await t({...await c(n.body),modelType:a});return r.status(201).json(e)}catch(t){return e.error(`Failed to create custom field definition`,t),s(t,r,{logger:e,message:`Error in create ${m} request`})}}),p.get(`/:customFieldDefinitionId`,async(t,n)=>{let{customFieldDefinitionId:i}=t.params;try{let e=await r(i);if(!e)throw new d;return n.json(e)}catch(t){return e.error(`Failed to fetch custom field definition`,t),s(t,n,{logger:e,message:`Error in get ${m} request`})}}),p.get(`/`,async(t,r)=>{let{params:{modelName:a},query:{entityIds:o,modelTypeId:c}}=t,l=h(a);try{let e=!u.isMatPathEnabled?.()&&o&&o.length>0;if(c){let t=await i(c,{withDisabled:!0,modelType:l,entityIds:e?o:void 0});return r.json(t)}let t=await n({modelType:l,...e&&{entityId:o}},{withDisabled:!0,enrichWithModelTypeIds:!0});return r.json(t)}catch(t){return e.error(`Failed to fetch custom field definitions`,t),s(t,r,{logger:e,message:`Error in get all ${m} request`})}}),p.patch(`/:customFieldDefinitionId`,async(t,n)=>{let{customFieldDefinitionId:r,modelName:i}=t.params,c=h(i);try{let e=await l(t.body);if(!await a({id:r,modelType:c}))throw new d;let i=await o(r,{...e,modelType:c});return n.status(200).json(i)}catch(t){return e.error(`Failed to patch custom field definition`,t),s(t,n,{logger:e,message:`Error in update ${m} request`})}});var g=p;export{g as default};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["router: ReturnType<typeof Router>","validatedPayload: CreateCustomFieldDefinition","DefinitionRepo.create","handleError","DefinitionRepo.findById","customFieldDefinitions","DefinitionRepo.findByModelTypeId","DefinitionRepo.findAll","validatedPayload: UpdateCustomFieldDefinition","DefinitionRepo.findByWhere","DefinitionRepo.update"],"sources":["../../../../src/api/v1/definition/index.ts"],"sourcesContent":["import { ResourceNotFoundError } from '@autofleet/errors';\nimport { Router } from '@autofleet/node-common';\nimport handleError from '../errors';\nimport * as DefinitionRepo from '../../../repository/definition';\nimport type { CreateCustomFieldDefinition, UpdateCustomFieldDefinition } from '../../../types/definition';\nimport { validateCustomFieldDefinitionCreation, validateCustomFieldDefinitionUpdate } from './validations';\nimport logger from '../../../utils/logger';\nimport type { CustomFieldDefinition } from '../../../models';\nimport { matPathState } from '../../../mat-path-state';\n\nconst router: ReturnType<typeof Router> = Router({ logger });\nconst ENTITY = 'CustomFieldDefinition';\n\nconst toPascalCase = (str: string): string => str.replace(/(^\\w|-\\w)/g, subStr => subStr.replace(/-/, '').toUpperCase());\n\n/**\n * Create\n */\nrouter.post<{ modelName: string; }>('/', async (req, res) => {\n const { modelName } = req.params;\n const modelType = toPascalCase(modelName);\n try {\n const validatedPayload: CreateCustomFieldDefinition = await validateCustomFieldDefinitionCreation(req.body);\n\n const customFieldDefinition = await DefinitionRepo.create({\n ...validatedPayload,\n modelType,\n });\n return res.status(201).json(customFieldDefinition);\n } catch (err) {\n logger.error('Failed to create custom field definition', err);\n return handleError(err as Error, res, { logger, message: `Error in create ${ENTITY} request` });\n }\n});\n\n/**\n * Get by id\n */\nrouter.get<{ modelName: string; customFieldDefinitionId: string; }, CustomFieldDefinition>('/:customFieldDefinitionId', async (req, res) => {\n const { customFieldDefinitionId } = req.params;\n try {\n const customFieldDefinition = await DefinitionRepo.findById(customFieldDefinitionId);\n\n if (!customFieldDefinition) {\n throw new ResourceNotFoundError();\n }\n\n return res.json(customFieldDefinition);\n } catch (err) {\n logger.error('Failed to fetch custom field definition', err);\n return handleError(err as Error, res, { logger, message: `Error in get ${ENTITY} request` });\n }\n});\n\n/**\n * Get all\n */\nrouter.get<{ modelName: string; }, CustomFieldDefinition[], never, { entityIds?: string[]; modelTypeId?: string; }>('/', async (req, res) => {\n const { params: { modelName }, query: { entityIds, modelTypeId } } = req;\n\n const modelType = toPascalCase(modelName);\n try {\n // When mat-path is active, drop the explicit `entityId IN (entityIds)` WHERE filter — RLS\n // on `custom_field_definitions` (applied via decorateModelMethods) restricts the result\n // to the caller's visible scope (fleet + ancestor partners). If the WHERE clause kept the\n // requested entityIds, partner CFDs (whose entity_id differs from the requested fleet's\n // entityId) would be filtered out by the WHERE before RLS could include them.\n const applyEntityIdsFilter = !matPathState.isMatPathEnabled?.() && entityIds && entityIds.length > 0;\n\n // If modelTypeId is provided, get definitions applicable to that specific type instance\n if (modelTypeId) {\n const customFieldDefinitions = await DefinitionRepo.findByModelTypeId(modelTypeId, {\n withDisabled: true,\n modelType,\n entityIds: applyEntityIdsFilter ? entityIds : undefined,\n });\n return res.json(customFieldDefinitions);\n }\n\n const where = {\n modelType,\n ...(applyEntityIdsFilter && { entityId: entityIds }),\n };\n const customFieldDefinitions = await DefinitionRepo.findAll(where, { withDisabled: true, enrichWithModelTypeIds: true });\n return res.json(customFieldDefinitions);\n } catch (err) {\n logger.error('Failed to fetch custom field definitions', err);\n return handleError(err as Error, res, { logger, message: `Error in get all ${ENTITY} request` });\n }\n});\n\n/**\n * Update\n */\nrouter.patch<{ modelName: string; customFieldDefinitionId: string; }, CustomFieldDefinition>('/:customFieldDefinitionId', async (req, res) => {\n const { customFieldDefinitionId, modelName } = req.params;\n const modelType = toPascalCase(modelName);\n try {\n const validatedPayload: UpdateCustomFieldDefinition = await validateCustomFieldDefinitionUpdate(req.body);\n\n const customFieldDefinition = await DefinitionRepo.findByWhere({\n id: customFieldDefinitionId,\n modelType,\n });\n\n if (!customFieldDefinition) {\n throw new ResourceNotFoundError();\n }\n\n const updatedCustomFieldDefinition = await DefinitionRepo.update(\n customFieldDefinitionId,\n { ...validatedPayload, modelType },\n );\n\n return res.status(200).json(updatedCustomFieldDefinition);\n } catch (err) {\n logger.error('Failed to patch custom field definition', err);\n return handleError(err as Error, res, { logger, message: `Error in update ${ENTITY} request` });\n }\n});\n\nexport default router;\n"],"mappings":"0eAUA,MAAMA,EAAoC,EAAO,CAAE,OAAA,EAAQ,CAAC,CACtD,EAAS,wBAET,EAAgB,GAAwB,EAAI,QAAQ,aAAc,GAAU,EAAO,QAAQ,IAAK,GAAG,CAAC,aAAa,CAAC,CAKxH,EAAO,KAA6B,IAAK,MAAO,EAAK,IAAQ,CAC3D,GAAM,CAAE,aAAc,EAAI,OACpB,EAAY,EAAa,EAAU,CACzC,GAAI,CAGF,IAAM,EAAwB,MAAME,EAAsB,CACxD,GAHoD,MAAM,EAAsC,EAAI,KAAK,CAIzG,YACD,CAAC,CACF,OAAO,EAAI,OAAO,IAAI,CAAC,KAAK,EAAsB,OAC3C,EAAK,CAEZ,OADA,EAAO,MAAM,2CAA4C,EAAI,CACtDC,EAAY,EAAc,EAAK,CAAE,OAAA,EAAQ,QAAS,mBAAmB,EAAO,UAAW,CAAC,GAEjG,CAKF,EAAO,IAAoF,4BAA6B,MAAO,EAAK,IAAQ,CAC1I,GAAM,CAAE,2BAA4B,EAAI,OACxC,GAAI,CACF,IAAM,EAAwB,MAAMC,EAAwB,EAAwB,CAEpF,GAAI,CAAC,EACH,MAAM,IAAI,EAGZ,OAAO,EAAI,KAAK,EAAsB,OAC/B,EAAK,CAEZ,OADA,EAAO,MAAM,0CAA2C,EAAI,CACrDD,EAAY,EAAc,EAAK,CAAE,OAAA,EAAQ,QAA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1
+ const e=require(`../../../_virtual/rolldown_runtime.cjs`),t=require(`../../../utils/constants/index.cjs`);let n=require(`joi`);n=e.__toESM(n);const r=n.default.object({name:n.default.string().required(),type:n.default.string(),size:n.default.string(),addedBy:n.default.string().uuid()}),i=n.default.object({value:n.default.string().required(),color:n.default.string().required()}),a=n.default.array().required().items(n.default.string()).min(1).unique(),o=n.default.array().required().items(i).min(1).unique(`value`),s=n.default.when(`fieldType`,{switch:[{is:t.CustomFieldDefinitionType.SELECT,then:a},{is:t.CustomFieldDefinitionType.MULTI_SELECT_DROPDOWN,then:a},{is:t.CustomFieldDefinitionType.STATUS,then:o},{is:t.CustomFieldDefinitionType.MULTI_SELECT_STATUS,then:o}],otherwise:n.default.forbidden()}),c=n.default.array().items(n.default.string()).unique().allow(null),l=n.default.when(`fieldType`,{switch:[{is:t.CustomFieldDefinitionType.BOOLEAN,then:n.default.boolean().allow(null)},{is:t.CustomFieldDefinitionType.DATE,then:n.default.date().allow(null)},{is:t.CustomFieldDefinitionType.DATETIME,then:n.default.date().allow(null)},{is:t.CustomFieldDefinitionType.FILE,then:n.default.array().items(r).allow(null)},{is:t.CustomFieldDefinitionType.IMAGE,then:n.default.array().items(n.default.string().uri()).allow(null)},{is:t.CustomFieldDefinitionType.NUMBER,then:n.default.number().allow(null)},{is:t.CustomFieldDefinitionType.SELECT,then:n.default.string().allow(null)},{is:t.CustomFieldDefinitionType.STATUS,then:n.default.string().allow(null)},{is:t.CustomFieldDefinitionType.TEXT,then:n.default.string().allow(null)},{is:t.CustomFieldDefinitionType.MULTI_SELECT_STATUS,then:c},{is:t.CustomFieldDefinitionType.MULTI_SELECT_DROPDOWN,then:c}]}),u=n.default.object({name:n.default.string().required(),displayName:n.default.string().required(),validation:s,defaultValue:l,fieldType:n.default.string().valid(...Object.values(t.CustomFieldDefinitionType)).required(),entityId:n.default.string().guid().required(),entityType:n.default.string().required(),description:n.default.string(),required:n.default.boolean(),disabled:n.default.boolean(),blockEditingFromUI:n.default.boolean(),modelTypeIds:n.default.array().items(n.default.string().guid())}).oxor(`required`,`blockEditingFromUI`,{isPresent:e=>e===!0}),d=n.default.object({displayName:n.default.string(),validation:s,defaultValue:l,fieldType:n.default.string().valid(...Object.values(t.CustomFieldDefinitionType)),description:n.default.string().allow(null),required:n.default.boolean(),disabled:n.default.boolean(),blockEditingFromUI:n.default.boolean(),modelTypeIds:n.default.array().items(n.default.string().guid())}).oxor(`required`,`blockEditingFromUI`,{isPresent:e=>e===!0}),f=e=>u.validateAsync(e,{abortEarly:!1}),p=e=>d.validateAsync(e,{abortEarly:!1});exports.validateCustomFieldDefinitionCreation=f,exports.validateCustomFieldDefinitionUpdate=p;
2
+ //# sourceMappingURL=validations.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validations.cjs","names":["Joi","CustomFieldDefinitionType"],"sources":["../../../../src/api/v1/definition/validations.ts"],"sourcesContent":["import Joi from 'joi';\nimport { CustomFieldDefinitionType } from '../../../utils/constants';\nimport type { CreateCustomFieldDefinition, UpdateCustomFieldDefinition } from '../../../types/definition';\n\nconst FileValidationSchema = Joi.object({\n name: Joi.string().required(),\n type: Joi.string(),\n size: Joi.string(),\n addedBy: Joi.string().uuid(),\n});\nconst statusValidationObject = Joi.object({\n value: Joi.string().required(),\n color: Joi.string().required(),\n});\n\nconst stringOptionsSchema = Joi.array().required().items(Joi.string()).min(1)\n .unique();\nconst statusOptionsSchema = Joi.array().required().items(statusValidationObject).min(1)\n .unique('value');\n\n/**\n * Schema for the validation of custom field definition\n * The only custom validation is for\n * {@link CustomFieldDefinitionType.SELECT SELECT},\n * {@link CustomFieldDefinitionType.MULTI_SELECT_DROPDOWN MULTI_SELECT_DROPDOWN},\n * {@link CustomFieldDefinitionType.STATUS STATUS},\n * and\n * {@link CustomFieldDefinitionType.MULTI_SELECT_STATUS MULTI_SELECT_STATUS}\n * field types.\n * The rest of the field types are validated by Joi\n */\nconst ValidationSchema = Joi.when('fieldType', {\n switch: [\n { is: CustomFieldDefinitionType.SELECT, then: stringOptionsSchema },\n { is: CustomFieldDefinitionType.MULTI_SELECT_DROPDOWN, then: stringOptionsSchema },\n { is: CustomFieldDefinitionType.STATUS, then: statusOptionsSchema },\n { is: CustomFieldDefinitionType.MULTI_SELECT_STATUS, then: statusOptionsSchema },\n ],\n otherwise: Joi.forbidden(),\n});\n\nconst multiSelectDefaultValueSchema = Joi.array().items(Joi.string()).unique().allow(null);\n\nconst DefaultValueSchema = Joi.when('fieldType', {\n switch: [\n { is: CustomFieldDefinitionType.BOOLEAN, then: Joi.boolean().allow(null) },\n { is: CustomFieldDefinitionType.DATE, then: Joi.date().allow(null) },\n { is: CustomFieldDefinitionType.DATETIME, then: Joi.date().allow(null) },\n { is: CustomFieldDefinitionType.FILE, then: Joi.array().items(FileValidationSchema).allow(null) },\n { is: CustomFieldDefinitionType.IMAGE, then: Joi.array().items(Joi.string().uri()).allow(null) },\n { is: CustomFieldDefinitionType.NUMBER, then: Joi.number().allow(null) },\n { is: CustomFieldDefinitionType.SELECT, then: Joi.string().allow(null) },\n { is: CustomFieldDefinitionType.STATUS, then: Joi.string().allow(null) },\n { is: CustomFieldDefinitionType.TEXT, then: Joi.string().allow(null) },\n { is: CustomFieldDefinitionType.MULTI_SELECT_STATUS, then: multiSelectDefaultValueSchema },\n { is: CustomFieldDefinitionType.MULTI_SELECT_DROPDOWN, then: multiSelectDefaultValueSchema },\n ],\n});\n\nconst CustomFieldDefinitionCreationSchema = Joi.object({\n name: Joi.string().required(),\n displayName: Joi.string().required(),\n validation: ValidationSchema,\n defaultValue: DefaultValueSchema,\n fieldType: Joi.string().valid(...Object.values(CustomFieldDefinitionType)).required(),\n entityId: Joi.string().guid().required(),\n entityType: Joi.string().required(),\n description: Joi.string(),\n required: Joi.boolean(),\n disabled: Joi.boolean(),\n blockEditingFromUI: Joi.boolean(),\n modelTypeIds: Joi.array().items(Joi.string().guid()),\n}).oxor('required', 'blockEditingFromUI', { isPresent: value => value === true });\n\nconst CustomFieldDefinitionUpdateSchema = Joi.object({\n displayName: Joi.string(),\n validation: ValidationSchema,\n defaultValue: DefaultValueSchema,\n fieldType: Joi.string().valid(...Object.values(CustomFieldDefinitionType)),\n description: Joi.string().allow(null),\n required: Joi.boolean(),\n disabled: Joi.boolean(),\n blockEditingFromUI: Joi.boolean(),\n modelTypeIds: Joi.array().items(Joi.string().guid()),\n}).oxor('required', 'blockEditingFromUI', { isPresent: value => value === true });\n\nexport const validateCustomFieldDefinitionCreation = (payload: unknown): Promise<CreateCustomFieldDefinition> =>\n CustomFieldDefinitionCreationSchema.validateAsync(payload, { abortEarly: false });\n\nexport const validateCustomFieldDefinitionUpdate = (payload: unknown): Promise<UpdateCustomFieldDefinition> =>\n CustomFieldDefinitionUpdateSchema.validateAsync(payload, { abortEarly: false });\n"],"mappings":"8IAIA,MAAM,EAAuBA,EAAAA,QAAI,OAAO,CACtC,KAAMA,EAAAA,QAAI,QAAQ,CAAC,UAAU,CAC7B,KAAMA,EAAAA,QAAI,QAAQ,CAClB,KAAMA,EAAAA,QAAI,QAAQ,CAClB,QAASA,EAAAA,QAAI,QAAQ,CAAC,MAAM,CAC7B,CAAC,CACI,EAAyBA,EAAAA,QAAI,OAAO,CACxC,MAAOA,EAAAA,QAAI,QAAQ,CAAC,UAAU,CAC9B,MAAOA,EAAAA,QAAI,QAAQ,CAAC,UAAU,CAC/B,CAAC,CAEI,EAAsBA,EAAAA,QAAI,OAAO,CAAC,UAAU,CAAC,MAAMA,EAAAA,QAAI,QAAQ,CAAC,CAAC,IAAI,EAAE,CAC1E,QAAQ,CACL,EAAsBA,EAAAA,QAAI,OAAO,CAAC,UAAU,CAAC,MAAM,EAAuB,CAAC,IAAI,EAAE,CACpF,OAAO,QAAQ,CAaZ,EAAmBA,EAAAA,QAAI,KAAK,YAAa,CAC7C,OAAQ,CACN,CAAE,GAAIC,EAAAA,0BAA0B,OAAQ,KAAM,EAAqB,CACnE,CAAE,GAAIA,EAAAA,0BAA0B,sBAAuB,KAAM,EAAqB,CACl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AAS,IAAU,GAAM,CAAC,CAEpE,EAAyC,GACpD,EAAoC,cAAc,EAAS,CAAE,WAAY,GAAO,CAAC,CAEtE,EAAuC,GAClD,EAAkC,cAAc,EAAS,CAAE,WAAY,GAAO,CAAC"}
@@ -0,0 +1,2 @@
1
+ import{CustomFieldDefinitionType as e}from"../../../utils/constants/index.js";import t from"joi";const n=t.object({name:t.string().required(),type:t.string(),size:t.string(),addedBy:t.string().uuid()}),r=t.object({value:t.string().required(),color:t.string().required()}),i=t.array().required().items(t.string()).min(1).unique(),a=t.array().required().items(r).min(1).unique(`value`),o=t.when(`fieldType`,{switch:[{is:e.SELECT,then:i},{is:e.MULTI_SELECT_DROPDOWN,then:i},{is:e.STATUS,then:a},{is:e.MULTI_SELECT_STATUS,then:a}],otherwise:t.forbidden()}),s=t.array().items(t.string()).unique().allow(null),c=t.when(`fieldType`,{switch:[{is:e.BOOLEAN,then:t.boolean().allow(null)},{is:e.DATE,then:t.date().allow(null)},{is:e.DATETIME,then:t.date().allow(null)},{is:e.FILE,then:t.array().items(n).allow(null)},{is:e.IMAGE,then:t.array().items(t.string().uri()).allow(null)},{is:e.NUMBER,then:t.number().allow(null)},{is:e.SELECT,then:t.string().allow(null)},{is:e.STATUS,then:t.string().allow(null)},{is:e.TEXT,then:t.string().allow(null)},{is:e.MULTI_SELECT_STATUS,then:s},{is:e.MULTI_SELECT_DROPDOWN,then:s}]}),l=t.object({name:t.string().required(),displayName:t.string().required(),validation:o,defaultValue:c,fieldType:t.string().valid(...Object.values(e)).required(),entityId:t.string().guid().required(),entityType:t.string().required(),description:t.string(),required:t.boolean(),disabled:t.boolean(),blockEditingFromUI:t.boolean(),modelTypeIds:t.array().items(t.string().guid())}).oxor(`required`,`blockEditingFromUI`,{isPresent:e=>e===!0}),u=t.object({displayName:t.string(),validation:o,defaultValue:c,fieldType:t.string().valid(...Object.values(e)),description:t.string().allow(null),required:t.boolean(),disabled:t.boolean(),blockEditingFromUI:t.boolean(),modelTypeIds:t.array().items(t.string().guid())}).oxor(`required`,`blockEditingFromUI`,{isPresent:e=>e===!0}),d=e=>l.validateAsync(e,{abortEarly:!1}),f=e=>u.validateAsync(e,{abortEarly:!1});export{d as validateCustomFieldDefinitionCreation,f as validateCustomFieldDefinitionUpdate};
2
+ //# sourceMappingURL=validations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validations.js","names":[],"sources":["../../../../src/api/v1/definition/validations.ts"],"sourcesContent":["import Joi from 'joi';\nimport { CustomFieldDefinitionType } from '../../../utils/constants';\nimport type { CreateCustomFieldDefinition, UpdateCustomFieldDefinition } from '../../../types/definition';\n\nconst FileValidationSchema = Joi.object({\n name: Joi.string().required(),\n type: Joi.string(),\n size: Joi.string(),\n addedBy: Joi.string().uuid(),\n});\nconst statusValidationObject = Joi.object({\n value: Joi.string().required(),\n color: Joi.string().required(),\n});\n\nconst stringOptionsSchema = Joi.array().required().items(Joi.string()).min(1)\n .unique();\nconst statusOptionsSchema = Joi.array().required().items(statusValidationObject).min(1)\n .unique('value');\n\n/**\n * Schema for the validation of custom field definition\n * The only custom validation is for\n * {@link CustomFieldDefinitionType.SELECT SELECT},\n * {@link CustomFieldDefinitionType.MULTI_SELECT_DROPDOWN MULTI_SELECT_DROPDOWN},\n * {@link CustomFieldDefinitionType.STATUS STATUS},\n * and\n * {@link CustomFieldDefinitionType.MULTI_SELECT_STATUS MULTI_SELECT_STATUS}\n * field types.\n * The rest of the field types are validated by Joi\n */\nconst ValidationSchema = Joi.when('fieldType', {\n switch: [\n { is: CustomFieldDefinitionType.SELECT, then: stringOptionsSchema },\n { is: CustomFieldDefinitionType.MULTI_SELECT_DROPDOWN, then: stringOptionsSchema },\n { is: CustomFieldDefinitionType.STATUS, then: statusOptionsSchema },\n { is: CustomFieldDefinitionType.MULTI_SELECT_STATUS, then: statusOptionsSchema },\n ],\n otherwise: Joi.forbidden(),\n});\n\nconst multiSelectDefaultValueSchema = Joi.array().items(Joi.string()).unique().allow(null);\n\nconst DefaultValueSchema = Joi.when('fieldType', {\n switch: [\n { is: CustomFieldDefinitionType.BOOLEAN, then: Joi.boolean().allow(null) },\n { is: CustomFieldDefinitionType.DATE, then: Joi.date().allow(null) },\n { is: CustomFieldDefinitionType.DATETIME, then: Joi.date().allow(null) },\n { is: CustomFieldDefinitionType.FILE, then: Joi.array().items(FileValidationSchema).allow(null) },\n { is: CustomFieldDefinitionType.IMAGE, then: Joi.array().items(Joi.string().uri()).allow(null) },\n { is: CustomFieldDefinitionType.NUMBER, then: Joi.number().allow(null) },\n { is: CustomFieldDefinitionType.SELECT, then: Joi.string().allow(null) },\n { is: CustomFieldDefinitionType.STATUS, then: Joi.string().allow(null) },\n { is: CustomFieldDefinitionType.TEXT, then: Joi.string().allow(null) },\n { is: CustomFieldDefinitionType.MULTI_SELECT_STATUS, then: multiSelectDefaultValueSchema },\n { is: CustomFieldDefinitionType.MULTI_SELECT_DROPDOWN, then: multiSelectDefaultValueSchema },\n ],\n});\n\nconst CustomFieldDefinitionCreationSchema = Joi.object({\n name: Joi.string().required(),\n displayName: Joi.string().required(),\n validation: ValidationSchema,\n defaultValue: DefaultValueSchema,\n fieldType: Joi.string().valid(...Object.values(CustomFieldDefinitionType)).required(),\n entityId: Joi.string().guid().required(),\n entityType: Joi.string().required(),\n description: Joi.string(),\n required: Joi.boolean(),\n disabled: Joi.boolean(),\n blockEditingFromUI: Joi.boolean(),\n modelTypeIds: Joi.array().items(Joi.string().guid()),\n}).oxor('required', 'blockEditingFromUI', { isPresent: value => value === true });\n\nconst CustomFieldDefinitionUpdateSchema = Joi.object({\n displayName: Joi.string(),\n validation: ValidationSchema,\n defaultValue: DefaultValueSchema,\n fieldType: Joi.string().valid(...Object.values(CustomFieldDefinitionType)),\n description: Joi.string().allow(null),\n required: Joi.boolean(),\n disabled: Joi.boolean(),\n blockEditingFromUI: Joi.boolean(),\n modelTypeIds: Joi.array().items(Joi.string().guid()),\n}).oxor('required', 'blockEditingFromUI', { isPresent: value => value === true });\n\nexport const validateCustomFieldDefinitionCreation = (payload: unknown): Promise<CreateCustomFieldDefinition> =>\n CustomFieldDefinitionCreationSchema.validateAsync(payload, { abortEarly: false });\n\nexport const validateCustomFieldDefinitionUpdate = (payload: unknown): Promise<UpdateCustomFieldDefinition> =>\n CustomFieldDefinitionUpdateSchema.validateAsync(payload, { abortEarly: false });\n"],"mappings":"iGAIA,MAAM,EAAuB,EAAI,OAAO,CACtC,KAAM,EAAI,QAAQ,CAAC,UAAU,CAC7B,KAAM,EAAI,QAAQ,CAClB,KAAM,EAAI,QAAQ,CAClB,QAAS,EAAI,QAAQ,CAAC,MAAM,CAC7B,CAAC,CACI,EAAyB,EAAI,OAAO,CACxC,MAAO,EAAI,QAAQ,CAAC,UAAU,CAC9B,MAAO,EAAI,QAAQ,CAAC,UAAU,CAC/B,CAAC,CAEI,EAAsB,EAAI,OAAO,CAAC,UAAU,CAAC,MAAM,EAAI,QAAQ,CAAC,CAAC,IAAI,EAAE,CAC1E,QAAQ,CACL,EAAsB,EAAI,OAAO,CAAC,UAAU,CAAC,MAAM,EAAuB,CAAC,IAAI,EAAE,CACpF,OAAO,QAAQ,CAaZ,EAAmB,EAAI,KAAK,YAAa,CAC7C,OAAQ,CACN,CAAE,GAAI,EAA0B,OAAQ,KAAM,EAAqB,CACnE,CAAE,GAAI,EAA0B,sBAAuB,KAAM,EAAqB,CAClF,CAAE,GAAI,EAA0B,OAAQ,KAAM,EAAqB,CACnE,CAAE,GAAI,EAA0B,oBAAqB,KAAM,EAAqB,CACjF,CACD,UAAW,EAAI,WAAW,CAC3B,CAAC,CAEI,EAAgC,EAAI,OAAO,CAAC,MAAM,EAAI,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,KAAK,CAEpF,EAAqB,EAAI,KAAK,YAAa,CAC/C,OAAQ,CACN,CAAE,GAAI,EAA0B,QAAS,KAAM,EAAI,SAAS,CAAC,MAAM,KAAK,CAAE,CAC1E,CAAE,GAAI,EAA0B,KAAM,KAAM,EAAI,MAAM,CAAC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IAAU,GAAM,CAAC,CAE3E,EAAoC,EAAI,OAAO,CACnD,YAAa,EAAI,QAAQ,CACzB,WAAY,EACZ,aAAc,EACd,UAAW,EAAI,QAAQ,CAAC,MAAM,GAAG,OAAO,OAAO,EAA0B,CAAC,CAC1E,YAAa,EAAI,QAAQ,CAAC,MAAM,KAAK,CACrC,SAAU,EAAI,SAAS,CACvB,SAAU,EAAI,SAAS,CACvB,mBAAoB,EAAI,SAAS,CACjC,aAAc,EAAI,OAAO,CAAC,MAAM,EAAI,QAAQ,CAAC,MAAM,CAAC,CACrD,CAAC,CAAC,KAAK,WAAY,qBAAsB,CAAE,UAAW,GAAS,IAAU,GAAM,CAAC,CAEpE,EAAyC,GACpD,EAAoC,cAAc,EAAS,CAAE,WAAY,GAAO,CAAC,CAEtE,EAAuC,GAClD,EAAkC,cAAc,EAAS,CAAE,WAAY,GAAO,CAAC"}
@@ -0,0 +1,2 @@
1
+ const e=require(`../../_virtual/rolldown_runtime.cjs`);let t=require(`sequelize`),n=require(`joi`),r=require(`@autofleet/errors`);var i=(e,i,a)=>{let o=e;return[n.ValidationError,t.ValidationError].some(t=>e instanceof t)&&(o=new r.BadRequest([e])),(0,r.handleError)(o,i,a)};exports.default=i;
2
+ //# sourceMappingURL=errors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.cjs","names":["InputValidationError","DatabaseValidationError","BadRequest"],"sources":["../../../src/api/v1/errors.ts"],"sourcesContent":["import type { Response } from 'express';\nimport { handleError, BadRequest, type LogPayload } from '@autofleet/errors';\nimport { ValidationError as InputValidationError } from 'joi';\nimport { ValidationError as DatabaseValidationError } from 'sequelize';\n\nexport default (err: Error, res: Response, additionalData: LogPayload): void => {\n let error = err;\n if ([InputValidationError, DatabaseValidationError].some(ErrClass => err instanceof ErrClass)) {\n error = new BadRequest([err]);\n }\n\n return handleError(error, res, additionalData);\n};\n"],"mappings":"kIAKA,IAAA,GAAgB,EAAY,EAAe,IAAqC,CAC9E,IAAI,EAAQ,EAKZ,MAJI,CAACA,EAAAA,gBAAsBC,EAAAA,gBAAwB,CAAC,KAAK,GAAY,aAAe,EAAS,GAC3F,EAAQ,IAAIC,EAAAA,WAAW,CAAC,EAAI,CAAC,GAG/B,EAAA,EAAA,aAAmB,EAAO,EAAK,EAAe"}
@@ -0,0 +1,2 @@
1
+ import{ValidationError as e}from"sequelize";import{ValidationError as t}from"joi";import{BadRequest as n,handleError as r}from"@autofleet/errors";var i=(i,a,o)=>{let s=i;return[t,e].some(e=>i instanceof e)&&(s=new n([i])),r(s,a,o)};export{i as default};
2
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","names":["InputValidationError","DatabaseValidationError"],"sources":["../../../src/api/v1/errors.ts"],"sourcesContent":["import type { Response } from 'express';\nimport { handleError, BadRequest, type LogPayload } from '@autofleet/errors';\nimport { ValidationError as InputValidationError } from 'joi';\nimport { ValidationError as DatabaseValidationError } from 'sequelize';\n\nexport default (err: Error, res: Response, additionalData: LogPayload): void => {\n let error = err;\n if ([InputValidationError, DatabaseValidationError].some(ErrClass => err instanceof ErrClass)) {\n error = new BadRequest([err]);\n }\n\n return handleError(error, res, additionalData);\n};\n"],"mappings":"kJAKA,IAAA,GAAgB,EAAY,EAAe,IAAqC,CAC9E,IAAI,EAAQ,EAKZ,MAJI,CAACA,EAAsBC,EAAwB,CAAC,KAAK,GAAY,aAAe,EAAS,GAC3F,EAAQ,IAAI,EAAW,CAAC,EAAI,CAAC,EAGxB,EAAY,EAAO,EAAK,EAAe"}
@@ -0,0 +1,2 @@
1
+ const e=require(`../../_virtual/rolldown_runtime.cjs`),t=require(`../../utils/logger/index.cjs`),n=require(`./definition/index.cjs`),r=require(`./validator/index.cjs`);let i=require(`@autofleet/node-common`);const a=(0,i.Router)({logger:t.default});a.use(`/custom-field-definitions/:modelName`,n.default),a.use(`/custom-validators/:modelName`,r.default);var o=a;exports.default=o;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["router: ReturnType<typeof Router>","definitionRouter","validatorRouter"],"sources":["../../../src/api/v1/index.ts"],"sourcesContent":["import { Router } from '@autofleet/node-common';\nimport logger from '../../utils/logger';\nimport definitionRouter from './definition';\nimport validatorRouter from './validator';\n\nconst router: ReturnType<typeof Router> = Router({ logger });\n\nrouter.use('/custom-field-definitions/:modelName', definitionRouter);\nrouter.use('/custom-validators/:modelName', validatorRouter);\n\nexport default router;\n"],"mappings":"gNAKA,MAAMA,GAAAA,EAAAA,EAAAA,QAA2C,CAAE,OAAA,EAAA,QAAQ,CAAC,CAE5D,EAAO,IAAI,uCAAwCC,EAAAA,QAAiB,CACpE,EAAO,IAAI,gCAAiCC,EAAAA,QAAgB,CAE5D,IAAA,EAAe"}
@@ -0,0 +1,2 @@
1
+ import e from"../../utils/logger/index.js";import t from"./definition/index.js";import n from"./validator/index.js";import{Router as r}from"@autofleet/node-common";const i=r({logger:e});i.use(`/custom-field-definitions/:modelName`,t),i.use(`/custom-validators/:modelName`,n);var a=i;export{a as default};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["router: ReturnType<typeof Router>","definitionRouter","validatorRouter"],"sources":["../../../src/api/v1/index.ts"],"sourcesContent":["import { Router } from '@autofleet/node-common';\nimport logger from '../../utils/logger';\nimport definitionRouter from './definition';\nimport validatorRouter from './validator';\n\nconst router: ReturnType<typeof Router> = Router({ logger });\n\nrouter.use('/custom-field-definitions/:modelName', definitionRouter);\nrouter.use('/custom-validators/:modelName', validatorRouter);\n\nexport default router;\n"],"mappings":"oKAKA,MAAMA,EAAoC,EAAO,CAAE,OAAA,EAAQ,CAAC,CAE5D,EAAO,IAAI,uCAAwCC,EAAiB,CACpE,EAAO,IAAI,gCAAiCC,EAAgB,CAE5D,IAAA,EAAe"}
@@ -0,0 +1,2 @@
1
+ const e=require(`../../../_virtual/rolldown_runtime.cjs`),t=require(`../../../utils/logger/index.cjs`),n=require(`../errors.cjs`),r=require(`../../../mat-path-state.cjs`),i=require(`../../../repository/validator.cjs`),a=require(`./validations.cjs`),o=require(`../../../utils/validations/schema/validator-schema.cjs`);let s=require(`@autofleet/errors`),c=require(`@autofleet/node-common`),l=require(`http-status-codes`);const u=(0,c.Router)({logger:t.default}),d=`CustomValidator`;u.post(`/`,async(e,r)=>{let{modelName:s}=e.params;try{let t=await a.default.create.validateAsync(e.body);o.validateValidatorSchema(t.schema);let n=await i.create({...t,modelType:s});return r.status(l.StatusCodes.CREATED).json(n)}catch(e){return n.default(e,r,{logger:t.default,message:`Error in create ${d} request`})}}),u.get(`/`,async(e,a)=>{try{let{modelName:t}=e.params,{entityId:n,entityType:o}=e.query,s=!r.matPathState.isMatPathEnabled?.(),c={modelType:t,...s&&n&&{entityId:n},...s&&o&&{entityType:o}},u=await i.findAll(c);return a.status(l.StatusCodes.OK).json({validators:u})}catch(e){return n.default(e,a,{logger:t.default,message:`Error in get all ${d} request`})}}),u.get(`/:validatorId`,async(e,r)=>{try{let{validatorId:t,modelName:n}=e.params,a=await i.findAll({id:t,modelType:n},{withDisabled:!0});if(!a.length)throw new s.ResourceNotFoundError(`Validator not found`);return r.status(l.StatusCodes.OK).json(a[0])}catch(e){return n.default(e,r,{logger:t.default,message:`Error in get ${d} request`})}}),u.patch(`/:validatorId`,async(e,r)=>{try{let{validatorId:t}=e.params,n=await a.default.update.validateAsync(e.body);if(n.schema&&o.validateValidatorSchema(n.schema),!(await i.findAll({id:t},{withDisabled:!0})).length)throw new s.ResourceNotFoundError(`Validator not found`);let[c,u]=await i.update(t,n);if(!c)throw new s.ResourceNotFoundError(`Validator not found`);return r.status(l.StatusCodes.OK).json(u[0])}catch(e){return n.default(e,r,{logger:t.default,message:`Error in update ${d} request`})}}),u.delete(`/:validatorId`,async(e,r)=>{try{let{validatorId:t}=e.params;if(!(await i.findAll({id:t},{withDisabled:!0})).length)throw new s.ResourceNotFoundError(`Validator not found`);let[n]=await i.disable(t);if(!n)throw new s.ResourceNotFoundError(`Validator failed to be disabled`);return r.status(l.StatusCodes.NO_CONTENT).send()}catch(e){return n.default(e,r,{logger:t.default,message:`Error in delete ${d} request`})}});var f=u;exports.default=f;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["router: ReturnType<typeof Router>","validations","StatusCodes","handleError","matPathState","ResourceNotFoundError"],"sources":["../../../../src/api/v1/validator/index.ts"],"sourcesContent":["import { ResourceNotFoundError } from '@autofleet/errors';\nimport { Router } from '@autofleet/node-common';\nimport { StatusCodes } from 'http-status-codes';\nimport handleError from '../errors';\nimport * as ValidatorRepo from '../../../repository/validator';\nimport validations from './validations';\nimport logger from '../../../utils/logger';\nimport { validateValidatorSchema } from '../../../utils/validations/schema/validator-schema';\nimport type { CustomValidator } from '../../../models';\nimport { matPathState } from '../../../mat-path-state';\n\nconst router: ReturnType<typeof Router> = Router({ logger });\nconst ENTITY = 'CustomValidator';\n\n/**\n * Create\n */\nrouter.post<{ modelName: string; }>('/', async (req, res) => {\n const { modelName } = req.params;\n try {\n // Validate the request body\n const validatedPayload = await validations.create.validateAsync(req.body);\n\n // Validate that the schema is a valid AJV schema\n validateValidatorSchema(validatedPayload.schema);\n\n const validator = await ValidatorRepo.create({\n ...validatedPayload,\n modelType: modelName,\n });\n\n return res.status(StatusCodes.CREATED).json(validator);\n } catch (err) {\n return handleError(err as Error, res, { logger, message: `Error in create ${ENTITY} request` });\n }\n});\n\n/**\n * Get all\n */\nrouter.get<\n { modelName: string; },\n { validators: CustomValidator[]; },\n never,\n { entityId?: string; entityType?: string; }\n>('/', async (req, res) => {\n try {\n const { modelName } = req.params;\n const { entityId, entityType } = req.query;\n\n // When mat-path is active, drop the explicit `entityId`/`entityType` WHERE filters — RLS\n // on `custom_validators` restricts the result to the caller's visible scope (fleet +\n // ancestor partners). Keeping the filters would exclude partner-level validators whose\n // entityId differs from the requested fleet's entityId.\n const applyEntityFilters = !matPathState.isMatPathEnabled?.();\n\n const where = {\n modelType: modelName,\n ...(applyEntityFilters && entityId && { entityId }),\n ...(applyEntityFilters && entityType && { entityType }),\n };\n\n const validators = await ValidatorRepo.findAll(where);\n\n return res.status(StatusCodes.OK).json({ validators });\n } catch (err) {\n return handleError(err as Error, res, { logger, message: `Error in get all ${ENTITY} request` });\n }\n});\n\n/**\n * Get by id\n */\nrouter.get<{ modelName: string; validatorId: string; }, CustomValidator>('/:validatorId', async (req, res) => {\n try {\n const { validatorId, modelName } = req.params;\n // Include disabled validators when fetching by ID\n const validators = await ValidatorRepo.findAll({ id: validatorId, modelType: modelName }, { withDisabled: true });\n\n if (!validators.length) {\n throw new ResourceNotFoundError('Validator not found');\n }\n\n return res.status(StatusCodes.OK).json(validators[0]);\n } catch (err) {\n return handleError(err as Error, res, { logger, message: `Error in get ${ENTITY} request` });\n }\n});\n\n/**\n * Update\n */\nrouter.patch<{ modelName: string; validatorId: string; }, CustomValidator>('/:validatorId', async (req, res) => {\n try {\n const { validatorId } = req.params;\n\n // Validate the request body\n const validatedPayload = await validations.update.validateAsync(req.body);\n\n // If schema is included in the update, validate that it's a valid AJV schema\n if (validatedPayload.schema) {\n validateValidatorSchema(validatedPayload.schema);\n }\n\n // First verify the validator exists, including disabled ones\n const existingValidators = await ValidatorRepo.findAll({ id: validatorId }, { withDisabled: true });\n if (!existingValidators.length) {\n throw new ResourceNotFoundError('Validator not found');\n }\n\n const [count, validators] = await ValidatorRepo.update(validatorId, validatedPayload as any);\n\n if (!count) {\n throw new ResourceNotFoundError('Validator not found');\n }\n\n return res.status(StatusCodes.OK).json(validators[0]);\n } catch (err) {\n return handleError(err as Error, res, { logger, message: `Error in update ${ENTITY} request` });\n }\n});\n\n/**\n * Delete (disable)\n */\nrouter.delete<{ modelName: string; validatorId: string; }>('/:validatorId', async (req, res) => {\n try {\n const { validatorId } = req.params;\n\n // First verify the validator exists, including disabled ones\n const existingValidators = await ValidatorRepo.findAll({ id: validatorId }, { withDisabled: true });\n if (!existingValidators.length) {\n throw new ResourceNotFoundError('Validator not found');\n }\n\n const [count] = await ValidatorRepo.disable(validatorId);\n\n if (!count) {\n throw new ResourceNotFoundError('Validator failed to be disabled');\n }\n\n return res.status(StatusCodes.NO_CONTENT).send();\n } catch (err) {\n return handleError(err as Error, res, { logger, message: `Error in delete ${ENTITY} request` });\n }\n});\n\nexport default router;\n"],"mappings":"maAWA,MAAMA,GAAAA,EAAAA,EAAAA,QAA2C,CAAE,OAAA,EAAA,QAAQ,CAAC,CACtD,EAAS,kBAKf,EAAO,KAA6B,IAAK,MAAO,EAAK,IAAQ,CAC3D,GAAM,CAAE,aAAc,EAAI,OAC1B,GAAI,CAEF,IAAM,EAAmB,MAAMC,EAAAA,QAAY,OAAO,cAAc,EAAI,KAAK,CAGzE,EAAA,wBAAwB,EAAiB,OAAO,CAEhD,IAAM,EAAY,MAAA,EAAA,OAA2B,CAC3C,GAAG,EACH,UAAW,EACZ,CAAC,CAEF,OAAO,EAAI,OAAOC,EAAAA,YAAY,QAAQ,CAAC,KAAK,EAAU,OAC/C,EAAK,CACZ,OAAOC,EAAAA,QAAY,EAAc,EAAK,CAAE,OAAA,EAAA,QAAQ,QAAS,mBAAmB,EAAO,UAAW,CAAC,GAEjG,CAKF,EAAO,IAKL,IAAK,MAAO,EAAK,IAAQ,CACzB,GAAI,CACF,GAAM,CAAE,aAAc,EAAI,OACpB,CAAE,WAAU,cAAe,EAAI,MAM/B,EAAqB,CAACC,EAAAA,aAAa,oBAAoB,CAEvD,EAAQ,CACZ,UAAW,EACX,GAAI,GAAsB,GAAY,CAAE,WAAU,CAClD,GAAI,GAAsB,GAAc,CAAE,aAAY,CACvD,CAEK,EAAa,MAAA,EAAA,QAA4B,EAAM,CAErD,OAAO,EAAI,OAAOF,EAAAA,YAAY,GAAG,CAAC,KAAK,CAAE,aAAY,CAAC,OAC/C,EAAK,CACZ,OAAOC,EAAAA,QAAY,EAAc,EAAK,CAAE,OAAA,EAAA,QAAQ,QAAS,oBAA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,QAA4B,CAAE,GAAI,EAAa,CAAE,CAAE,aAAc,GAAM,CAAC,EAC3E,OACtB,MAAM,IAAIE,EAAAA,sBAAsB,sBAAsB,CAGxD,GAAM,CAAC,GAAS,MAAA,EAAA,QAA4B,EAAY,CAExD,GAAI,CAAC,EACH,MAAM,IAAIA,EAAAA,sBAAsB,kCAAkC,CAGpE,OAAO,EAAI,OAAOH,EAAAA,YAAY,WAAW,CAAC,MAAM,OACzC,EAAK,CACZ,OAAOC,EAAAA,QAAY,EAAc,EAAK,CAAE,OAAA,EAAA,QAAQ,QAAS,mBAAmB,EAAO,UAAW,CAAC,GAEjG,CAEF,IAAA,EAAe"}
@@ -0,0 +1,2 @@
1
+ import e from"../../../utils/logger/index.js";import t from"../errors.js";import{matPathState as n}from"../../../mat-path-state.js";import{create as r,disable as i,findAll as a,update as o}from"../../../repository/validator.js";import s from"./validations.js";import{validateValidatorSchema as c}from"../../../utils/validations/schema/validator-schema.js";import{ResourceNotFoundError as l}from"@autofleet/errors";import{Router as u}from"@autofleet/node-common";import{StatusCodes as d}from"http-status-codes";const f=u({logger:e}),p=`CustomValidator`;f.post(`/`,async(n,i)=>{let{modelName:a}=n.params;try{let e=await s.create.validateAsync(n.body);c(e.schema);let t=await r({...e,modelType:a});return i.status(d.CREATED).json(t)}catch(n){return t(n,i,{logger:e,message:`Error in create ${p} request`})}}),f.get(`/`,async(r,i)=>{try{let{modelName:e}=r.params,{entityId:t,entityType:o}=r.query,s=!n.isMatPathEnabled?.(),c=await a({modelType:e,...s&&t&&{entityId:t},...s&&o&&{entityType:o}});return i.status(d.OK).json({validators:c})}catch(n){return t(n,i,{logger:e,message:`Error in get all ${p} request`})}}),f.get(`/:validatorId`,async(n,r)=>{try{let{validatorId:e,modelName:t}=n.params,i=await a({id:e,modelType:t},{withDisabled:!0});if(!i.length)throw new l(`Validator not found`);return r.status(d.OK).json(i[0])}catch(n){return t(n,r,{logger:e,message:`Error in get ${p} request`})}}),f.patch(`/:validatorId`,async(n,r)=>{try{let{validatorId:e}=n.params,t=await s.update.validateAsync(n.body);if(t.schema&&c(t.schema),!(await a({id:e},{withDisabled:!0})).length)throw new l(`Validator not found`);let[i,u]=await o(e,t);if(!i)throw new l(`Validator not found`);return r.status(d.OK).json(u[0])}catch(n){return t(n,r,{logger:e,message:`Error in update ${p} request`})}}),f.delete(`/:validatorId`,async(n,r)=>{try{let{validatorId:e}=n.params;if(!(await a({id:e},{withDisabled:!0})).length)throw new l(`Validator not found`);let[t]=await i(e);if(!t)throw new l(`Validator failed to be disabled`);return r.status(d.NO_CONTENT).send()}catch(n){return t(n,r,{logger:e,message:`Error in delete ${p} request`})}});var m=f;export{m as default};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["router: ReturnType<typeof Router>","validations","ValidatorRepo.create","handleError","ValidatorRepo.findAll","ValidatorRepo.update","ValidatorRepo.disable"],"sources":["../../../../src/api/v1/validator/index.ts"],"sourcesContent":["import { ResourceNotFoundError } from '@autofleet/errors';\nimport { Router } from '@autofleet/node-common';\nimport { StatusCodes } from 'http-status-codes';\nimport handleError from '../errors';\nimport * as ValidatorRepo from '../../../repository/validator';\nimport validations from './validations';\nimport logger from '../../../utils/logger';\nimport { validateValidatorSchema } from '../../../utils/validations/schema/validator-schema';\nimport type { CustomValidator } from '../../../models';\nimport { matPathState } from '../../../mat-path-state';\n\nconst router: ReturnType<typeof Router> = Router({ logger });\nconst ENTITY = 'CustomValidator';\n\n/**\n * Create\n */\nrouter.post<{ modelName: string; }>('/', async (req, res) => {\n const { modelName } = req.params;\n try {\n // Validate the request body\n const validatedPayload = await validations.create.validateAsync(req.body);\n\n // Validate that the schema is a valid AJV schema\n validateValidatorSchema(validatedPayload.schema);\n\n const validator = await ValidatorRepo.create({\n ...validatedPayload,\n modelType: modelName,\n });\n\n return res.status(StatusCodes.CREATED).json(validator);\n } catch (err) {\n return handleError(err as Error, res, { logger, message: `Error in create ${ENTITY} request` });\n }\n});\n\n/**\n * Get all\n */\nrouter.get<\n { modelName: string; },\n { validators: CustomValidator[]; },\n never,\n { entityId?: string; entityType?: string; }\n>('/', async (req, res) => {\n try {\n const { modelName } = req.params;\n const { entityId, entityType } = req.query;\n\n // When mat-path is active, drop the explicit `entityId`/`entityType` WHERE filters — RLS\n // on `custom_validators` restricts the result to the caller's visible scope (fleet +\n // ancestor partners). Keeping the filters would exclude partner-level validators whose\n // entityId differs from the requested fleet's entityId.\n const applyEntityFilters = !matPathState.isMatPathEnabled?.();\n\n const where = {\n modelType: modelName,\n ...(applyEntityFilters && entityId && { entityId }),\n ...(applyEntityFilters && entityType && { entityType }),\n };\n\n const validators = await ValidatorRepo.findAll(where);\n\n return res.status(StatusCodes.OK).json({ validators });\n } catch (err) {\n return handleError(err as Error, res, { logger, message: `Error in get all ${ENTITY} request` });\n }\n});\n\n/**\n * Get by id\n */\nrouter.get<{ modelName: string; validatorId: string; }, CustomValidator>('/:validatorId', async (req, res) => {\n try {\n const { validatorId, modelName } = req.params;\n // Include disabled validators when fetching by ID\n const validators = await ValidatorRepo.findAll({ id: validatorId, modelType: modelName }, { withDisabled: true });\n\n if (!validators.length) {\n throw new ResourceNotFoundError('Validator not found');\n }\n\n return res.status(StatusCodes.OK).json(validators[0]);\n } catch (err) {\n return handleError(err as Error, res, { logger, message: `Error in get ${ENTITY} request` });\n }\n});\n\n/**\n * Update\n */\nrouter.patch<{ modelName: string; validatorId: string; }, CustomValidator>('/:validatorId', async (req, res) => {\n try {\n const { validatorId } = req.params;\n\n // Validate the request body\n const validatedPayload = await validations.update.validateAsync(req.body);\n\n // If schema is included in the update, validate that it's a valid AJV schema\n if (validatedPayload.schema) {\n validateValidatorSchema(validatedPayload.schema);\n }\n\n // First verify the validator exists, including disabled ones\n const existingValidators = await ValidatorRepo.findAll({ id: validatorId }, { withDisabled: true });\n if (!existingValidators.length) {\n throw new ResourceNotFoundError('Validator not found');\n }\n\n const [count, validators] = await ValidatorRepo.update(validatorId, validatedPayload as any);\n\n if (!count) {\n throw new ResourceNotFoundError('Validator not found');\n }\n\n return res.status(StatusCodes.OK).json(validators[0]);\n } catch (err) {\n return handleError(err as Error, res, { logger, message: `Error in update ${ENTITY} request` });\n }\n});\n\n/**\n * Delete (disable)\n */\nrouter.delete<{ modelName: string; validatorId: string; }>('/:validatorId', async (req, res) => {\n try {\n const { validatorId } = req.params;\n\n // First verify the validator exists, including disabled ones\n const existingValidators = await ValidatorRepo.findAll({ id: validatorId }, { withDisabled: true });\n if (!existingValidators.length) {\n throw new ResourceNotFoundError('Validator not found');\n }\n\n const [count] = await ValidatorRepo.disable(validatorId);\n\n if (!count) {\n throw new ResourceNotFoundError('Validator failed to be disabled');\n }\n\n return res.status(StatusCodes.NO_CONTENT).send();\n } catch (err) {\n return handleError(err as Error, res, { logger, message: `Error in delete ${ENTITY} request` });\n }\n});\n\nexport default router;\n"],"mappings":"8fAWA,MAAMA,EAAoC,EAAO,CAAE,OAAA,EAAQ,CAAC,CACtD,EAAS,kBAKf,EAAO,KAA6B,IAAK,MAAO,EAAK,IAAQ,CAC3D,GAAM,CAAE,aAAc,EAAI,OAC1B,GAAI,CAEF,IAAM,EAAmB,MAAMC,EAAY,OAAO,cAAc,EAAI,KAAK,CAGzE,EAAwB,EAAiB,OAAO,CAEhD,IAAM,EAAY,MAAMC,EAAqB,CAC3C,GAAG,EACH,UAAW,EACZ,CAAC,CAEF,OAAO,EAAI,OAAO,EAAY,QAAQ,CAAC,KAAK,EAAU,OAC/C,EAAK,CACZ,OAAOC,EAAY,EAAc,EAAK,CAAE,OAAA,EAAQ,QAAS,mBAAmB,EAAO,UAAW,CAAC,GAEjG,CAKF,EAAO,IAKL,IAAK,MAAO,EAAK,IAAQ,CACzB,GAAI,CACF,GAAM,CAAE,aAAc,EAAI,OACpB,CAAE,WAAU,cAAe,EAAI,MAM/B,EAAqB,CAAC,EAAa,oBAAoB,CAQvD,EAAa,MAAMC,EANX,CACZ,UAAW,EACX,GAAI,GAAsB,GAAY,CAA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BAAiB,MAAO,EAAK,IAAQ,CAC9F,GAAI,CACF,GAAM,CAAE,eAAgB,EAAI,OAI5B,GAAI,EADuB,MAAMC,EAAsB,CAAE,GAAI,EAAa,CAAE,CAAE,aAAc,GAAM,CAAC,EAC3E,OACtB,MAAM,IAAI,EAAsB,sBAAsB,CAGxD,GAAM,CAAC,GAAS,MAAME,EAAsB,EAAY,CAExD,GAAI,CAAC,EACH,MAAM,IAAI,EAAsB,kCAAkC,CAGpE,OAAO,EAAI,OAAO,EAAY,WAAW,CAAC,MAAM,OACzC,EAAK,CACZ,OAAOH,EAAY,EAAc,EAAK,CAAE,OAAA,EAAQ,QAAS,mBAAmB,EAAO,UAAW,CAAC,GAEjG,CAEF,IAAA,EAAe"}
@@ -0,0 +1,2 @@
1
+ const e=require(`../../../_virtual/rolldown_runtime.cjs`);let t=require(`joi`);t=e.__toESM(t);const n=t.default.object().unknown(!0),r=t.default.object({type:t.default.string().valid(`object`),properties:t.default.object({before:n,after:n}).required(),required:t.default.array().items(t.default.string()),allOf:t.default.array().items(t.default.object()),anyOf:t.default.array().items(t.default.object()),oneOf:t.default.array().items(t.default.object()),additionalProperties:t.default.alternatives().try(t.default.boolean(),t.default.object()),$id:t.default.string(),$schema:t.default.string(),if:t.default.object(),then:t.default.object(),else:t.default.object()}),i={create:t.default.object({entityId:t.default.string().uuid().required(),entityType:t.default.string().required(),schema:r.required()}),update:t.default.object({entityId:t.default.string().uuid(),entityType:t.default.string(),schema:r,disabled:t.default.boolean()}).min(1)};var a=i;exports.default=a;
2
+ //# sourceMappingURL=validations.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validations.cjs","names":["Joi","validationSchemas: ValidationSchemas"],"sources":["../../../../src/api/v1/validator/validations.ts"],"sourcesContent":["import Joi from 'joi';\n\nconst jsonSchemaValidation = Joi.object().unknown(true);\n\nexport interface SchemaObject {\n type: 'object';\n properties?: {\n before?: object;\n after?: object;\n };\n required?: string[];\n allOf?: object[];\n anyOf?: object[];\n oneOf?: object[];\n additionalProperties?: boolean | object;\n $id?: string;\n $schema?: string;\n if?: object;\n then?: object;\n else?: object;\n}\n\nconst schemaObject = Joi.object<SchemaObject>({\n type: Joi.string().valid('object'),\n properties: Joi.object({\n before: jsonSchemaValidation,\n after: jsonSchemaValidation,\n }).required(),\n required: Joi.array().items(Joi.string()),\n allOf: Joi.array().items(Joi.object()),\n anyOf: Joi.array().items(Joi.object()),\n oneOf: Joi.array().items(Joi.object()),\n additionalProperties: Joi.alternatives().try(Joi.boolean(), Joi.object()),\n $id: Joi.string(),\n $schema: Joi.string(),\n if: Joi.object(),\n then: Joi.object(),\n else: Joi.object(),\n});\n\nexport interface CreateValidatorPayload {\n entityId: string;\n entityType: string;\n schema: SchemaObject;\n}\n\nexport interface UpdateValidatorPayload extends Partial<CreateValidatorPayload> {\n disabled?: boolean;\n}\n\ninterface ValidationSchemas {\n create: Joi.ObjectSchema<CreateValidatorPayload>;\n update: Joi.ObjectSchema<UpdateValidatorPayload>;\n}\n\nconst validationSchemas: ValidationSchemas = {\n create: Joi.object<CreateValidatorPayload>({\n entityId: Joi.string().uuid().required(),\n entityType: Joi.string().required(),\n schema: schemaObject.required(),\n }),\n\n update: Joi.object<UpdateValidatorPayload>({\n entityId: Joi.string().uuid(),\n entityType: Joi.string(),\n schema: schemaObject,\n disabled: Joi.boolean(),\n }).min(1),\n};\n\nexport default validationSchemas;\n"],"mappings":"8FAEA,MAAM,EAAuBA,EAAAA,QAAI,QAAQ,CAAC,QAAQ,GAAK,CAoBjD,EAAeA,EAAAA,QAAI,OAAqB,CAC5C,KAAMA,EAAAA,QAAI,QAAQ,CAAC,MAAM,SAAS,CAClC,WAAYA,EAAAA,QAAI,OAAO,CACrB,OAAQ,EACR,MAAO,EACR,CAAC,CAAC,UAAU,CACb,SAAUA,EAAAA,QAAI,OAAO,CAAC,MAAMA,EAAAA,QAAI,QAAQ,CAAC,CACzC,MAAOA,EAAAA,QAAI,OAAO,CAAC,MAAMA,EAAAA,QAAI,QAAQ,CAAC,CACtC,MAAOA,EAAAA,QAAI,OAAO,CAAC,MAAMA,EAAAA,QAAI,QAAQ,CAAC,CACtC,MAAOA,EAAAA,QAAI,OAAO,CAAC,MAAMA,EAAAA,QAAI,QAAQ,CAAC,CACtC,qBAAsBA,EAAAA,QAAI,cAAc,CAAC,IAAIA,EAAAA,QAAI,SAAS,CAAEA,EAAAA,QAAI,QAAQ,CAAC,CACzE,IAAKA,EAAAA,QAAI,QAAQ,CACjB,QAASA,EAAAA,QAAI,QAAQ,CACrB,GAAIA,EAAAA,QAAI,QAAQ,CAChB,KAAMA,EAAAA,QAAI,QAAQ,CAClB,KAAMA,EAAAA,QAAI,QAAQ,CACnB,CAAC,CAiBIC,EAAuC,CAC3C,OAAQD,EAAAA,QAAI,OAA+B,CACzC,SAAUA,EAAAA,QAAI,QAAQ,CAAC,MAAM,CAAC,UAAU,CACxC,WAAYA,EAAAA,QAAI,QAAQ,CAAC,UAAU,CACnC,OAAQ,EAAa,UAAU,CAChC,CAAC,CAEF,OAAQA,EAAAA,QAAI,OAA+B,CACzC,SAAUA,EAAAA,QAAI,QAAQ,CAAC,MAAM,CAC7B,WAAYA,EAAAA,QAAI,QAAQ,CACxB,OAAQ,EACR,SAAUA,EAAAA,QAAI,SAAS,CACxB,CAAC,CAAC,IAAI,EAAE,CACV,CAED,IAAA,EAAe"}
@@ -19,4 +19,5 @@ interface SchemaObject {
19
19
  else?: object;
20
20
  }
21
21
  //#endregion
22
- export { SchemaObject };
22
+ export { SchemaObject };
23
+ //# sourceMappingURL=validations.d.cts.map
@@ -19,4 +19,5 @@ interface SchemaObject {
19
19
  else?: object;
20
20
  }
21
21
  //#endregion
22
- export { SchemaObject };
22
+ export { SchemaObject };
23
+ //# sourceMappingURL=validations.d.ts.map
@@ -0,0 +1,2 @@
1
+ import e from"joi";const t=e.object().unknown(!0),n=e.object({type:e.string().valid(`object`),properties:e.object({before:t,after:t}).required(),required:e.array().items(e.string()),allOf:e.array().items(e.object()),anyOf:e.array().items(e.object()),oneOf:e.array().items(e.object()),additionalProperties:e.alternatives().try(e.boolean(),e.object()),$id:e.string(),$schema:e.string(),if:e.object(),then:e.object(),else:e.object()});var r={create:e.object({entityId:e.string().uuid().required(),entityType:e.string().required(),schema:n.required()}),update:e.object({entityId:e.string().uuid(),entityType:e.string(),schema:n,disabled:e.boolean()}).min(1)};export{r as default};
2
+ //# sourceMappingURL=validations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validations.js","names":["validationSchemas: ValidationSchemas"],"sources":["../../../../src/api/v1/validator/validations.ts"],"sourcesContent":["import Joi from 'joi';\n\nconst jsonSchemaValidation = Joi.object().unknown(true);\n\nexport interface SchemaObject {\n type: 'object';\n properties?: {\n before?: object;\n after?: object;\n };\n required?: string[];\n allOf?: object[];\n anyOf?: object[];\n oneOf?: object[];\n additionalProperties?: boolean | object;\n $id?: string;\n $schema?: string;\n if?: object;\n then?: object;\n else?: object;\n}\n\nconst schemaObject = Joi.object<SchemaObject>({\n type: Joi.string().valid('object'),\n properties: Joi.object({\n before: jsonSchemaValidation,\n after: jsonSchemaValidation,\n }).required(),\n required: Joi.array().items(Joi.string()),\n allOf: Joi.array().items(Joi.object()),\n anyOf: Joi.array().items(Joi.object()),\n oneOf: Joi.array().items(Joi.object()),\n additionalProperties: Joi.alternatives().try(Joi.boolean(), Joi.object()),\n $id: Joi.string(),\n $schema: Joi.string(),\n if: Joi.object(),\n then: Joi.object(),\n else: Joi.object(),\n});\n\nexport interface CreateValidatorPayload {\n entityId: string;\n entityType: string;\n schema: SchemaObject;\n}\n\nexport interface UpdateValidatorPayload extends Partial<CreateValidatorPayload> {\n disabled?: boolean;\n}\n\ninterface ValidationSchemas {\n create: Joi.ObjectSchema<CreateValidatorPayload>;\n update: Joi.ObjectSchema<UpdateValidatorPayload>;\n}\n\nconst validationSchemas: ValidationSchemas = {\n create: Joi.object<CreateValidatorPayload>({\n entityId: Joi.string().uuid().required(),\n entityType: Joi.string().required(),\n schema: schemaObject.required(),\n }),\n\n update: Joi.object<UpdateValidatorPayload>({\n entityId: Joi.string().uuid(),\n entityType: Joi.string(),\n schema: schemaObject,\n disabled: Joi.boolean(),\n }).min(1),\n};\n\nexport default validationSchemas;\n"],"mappings":"mBAEA,MAAM,EAAuB,EAAI,QAAQ,CAAC,QAAQ,GAAK,CAoBjD,EAAe,EAAI,OAAqB,CAC5C,KAAM,EAAI,QAAQ,CAAC,MAAM,SAAS,CAClC,WAAY,EAAI,OAAO,CACrB,OAAQ,EACR,MAAO,EACR,CAAC,CAAC,UAAU,CACb,SAAU,EAAI,OAAO,CAAC,MAAM,EAAI,QAAQ,CAAC,CACzC,MAAO,EAAI,OAAO,CAAC,MAAM,EAAI,QAAQ,CAAC,CACtC,MAAO,EAAI,OAAO,CAAC,MAAM,EAAI,QAAQ,CAAC,CACtC,MAAO,EAAI,OAAO,CAAC,MAAM,EAAI,QAAQ,CAAC,CACtC,qBAAsB,EAAI,cAAc,CAAC,IAAI,EAAI,SAAS,CAAE,EAAI,QAAQ,CAAC,CACzE,IAAK,EAAI,QAAQ,CACjB,QAAS,EAAI,QAAQ,CACrB,GAAI,EAAI,QAAQ,CAChB,KAAM,EAAI,QAAQ,CAClB,KAAM,EAAI,QAAQ,CACnB,CAAC,CAgCF,IAAA,EAf6C,CAC3C,OAAQ,EAAI,OAA+B,CACzC,SAAU,EAAI,QAAQ,CAAC,MAAM,CAAC,UAAU,CACxC,WAAY,EAAI,QAAQ,CAAC,UAAU,CACnC,OAAQ,EAAa,UAAU,CAChC,CAAC,CAEF,OAAQ,EAAI,OAA+B,CACzC,SAAU,EAAI,QAAQ,CAAC,MAAM,CAC7B,WAAY,EAAI,QAAQ,CACxB,OAAQ,EACR,SAAU,EAAI,SAAS,CACxB,CAAC,CAAC,IAAI,EAAE,CACV"}
@@ -0,0 +1,3 @@
1
+ const e=require(`../_virtual/rolldown_runtime.cjs`);let t=require(`@autofleet/errors`);var n=class extends t.BadRequest{constructor(e){let t=Error(`The following custom fields are required: ${e.join(`,`)}`);super([t],void 0,e),this.message=`MISSING_REQUIRED_CUSTOM_FIELDS`}},r=class extends t.BadRequest{constructor(e){let t=Error(`Type "${e}" is not supported`);super([t],void 0,null),this.message=`UNSUPPORTED_CUSTOM_FIELD_TYPE`}},i=class extends t.BadRequest{constructor(e){let t=Error(`Validation for "${e}" is not supported`);super([t],void 0,null),this.message=`UNSUPPORTED_CUSTOM_VALIDATION_TYPE`}},a=class extends t.BadRequest{constructor(e){let t=Error(`Invalid field type ${e}`);super([t],void 0,null),this.message=`INVALID_FIELD_TYPE`}},o=class extends t.BadRequest{constructor(e,t,n){let r=`Invalid Value on field '${t}'. ${n.message.replace(/"/g,``).replace(`value`,`'${t}'`)}. received: '${typeof e==`object`?JSON.stringify(e):e}'`;super([Error(r)],void 0,null),this.message=r}},s=class extends t.BadRequest{constructor(e,t){let n=t.map(e=>new o(e.value,e.fieldDefinitionName,e.joiValidationError));super(n,void 0,null),this.message=`Invalid entries on ${e}\n${t.map(e=>`${e.fieldDefinitionName} - ${e.joiValidationError.message}`).join(`
2
+ `)}`}},c=class extends t.BadRequest{constructor(e){let t=Error(`Missing custom field definition for field ${e.join(`,`)}`);super([t],void 0,null),this.message=`MISSING_DEFINITION`}};exports.InvalidEntriesError=s,exports.InvalidFieldTypeError=a,exports.InvalidValueError=o,exports.MissingDefinitionError=c,exports.MissingRequiredCustomFieldError=n,exports.UnsupportedCustomFieldTypeError=r,exports.UnsupportedCustomValidationError=i;
3
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["BadRequest"],"sources":["../../src/errors/index.ts"],"sourcesContent":["import { BadRequest } from '@autofleet/errors';\nimport type { ValidationError } from 'joi';\nimport type { EntriesValidationError } from '../types/entries';\n\nexport class MissingRequiredCustomFieldError extends BadRequest {\n constructor(missingFields: string[]) {\n const err = new Error(`The following custom fields are required: ${missingFields.join(',')}`);\n super([err], undefined, missingFields);\n this.message = 'MISSING_REQUIRED_CUSTOM_FIELDS';\n }\n}\n\nexport class UnsupportedCustomFieldTypeError extends BadRequest {\n constructor(fieldType: string) {\n const err = new Error(`Type \"${fieldType}\" is not supported`);\n super([err], undefined, null);\n this.message = 'UNSUPPORTED_CUSTOM_FIELD_TYPE';\n }\n}\n\nexport class UnsupportedCustomValidationError extends BadRequest {\n constructor(fieldType: string) {\n const err = new Error(`Validation for \"${fieldType}\" is not supported`);\n super([err], undefined, null);\n this.message = 'UNSUPPORTED_CUSTOM_VALIDATION_TYPE';\n }\n}\n\nexport class InvalidFieldTypeError extends BadRequest {\n constructor(fieldType: string) {\n const err = new Error(`Invalid field type ${fieldType}`);\n super([err], undefined, null);\n this.message = 'INVALID_FIELD_TYPE';\n }\n}\n\nexport class InvalidValueError extends BadRequest {\n constructor(value: any, fieldDefinitionName: string, joiValidationError: ValidationError) {\n const formattedErrorMessage = joiValidationError.message\n .replace(/\"/g, '')\n .replace('value', `'${fieldDefinitionName}'`);\n\n const formattedValue = typeof value === 'object' ? JSON.stringify(value) : value;\n\n const invalidValueMessage = `Invalid Value on field '${fieldDefinitionName}'. ${formattedErrorMessage}. received: '${formattedValue}'`;\n\n const err = new Error(invalidValueMessage);\n super([err], undefined, null);\n this.message = invalidValueMessage;\n }\n}\n\nexport class InvalidEntriesError extends BadRequest {\n constructor(modelId: string, validationErrors: EntriesValidationError[]) {\n const errors = validationErrors.map(validationError => new InvalidValueError(validationError.value, validationError.fieldDefinitionName, validationError.joiValidationError));\n super(errors, undefined, null);\n this.message = `Invalid entries on ${modelId}\\n${validationErrors.map(validationError => (\n `${validationError.fieldDefinitionName} - ${validationError.joiValidationError.message}`\n )).join('\\n')}`;\n }\n}\n\nexport class MissingDefinitionError extends BadRequest {\n constructor(fieldNames: string[]) {\n const err = new Error(`Missing custom field definition for field ${fieldNames.join(',')}`);\n super([err], undefined, null);\n this.message = 'MISSING_DEFINITION';\n }\n}\n"],"mappings":"uFAIA,IAAa,EAAb,cAAqDA,EAAAA,UAA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GACpE,GAAG,EAAgB,oBAAoB,KAAK,EAAgB,mBAAmB,UAC/E,CAAC,KAAK;EAAK,KAIJ,EAAb,cAA4CA,EAAAA,UAAW,CACrD,YAAY,EAAsB,CAChC,IAAM,EAAU,MAAM,6CAA6C,EAAW,KAAK,IAAI,GAAG,CAC1F,MAAM,CAAC,EAAI,CAAE,IAAA,GAAW,KAAK,CAC7B,KAAK,QAAU"}
@@ -0,0 +1,3 @@
1
+ import{BadRequest as e}from"@autofleet/errors";var t=class extends e{constructor(e){let t=Error(`The following custom fields are required: ${e.join(`,`)}`);super([t],void 0,e),this.message=`MISSING_REQUIRED_CUSTOM_FIELDS`}},n=class extends e{constructor(e){let t=Error(`Type "${e}" is not supported`);super([t],void 0,null),this.message=`UNSUPPORTED_CUSTOM_FIELD_TYPE`}},r=class extends e{constructor(e){let t=Error(`Validation for "${e}" is not supported`);super([t],void 0,null),this.message=`UNSUPPORTED_CUSTOM_VALIDATION_TYPE`}},i=class extends e{constructor(e){let t=Error(`Invalid field type ${e}`);super([t],void 0,null),this.message=`INVALID_FIELD_TYPE`}},a=class extends e{constructor(e,t,n){let r=`Invalid Value on field '${t}'. ${n.message.replace(/"/g,``).replace(`value`,`'${t}'`)}. received: '${typeof e==`object`?JSON.stringify(e):e}'`;super([Error(r)],void 0,null),this.message=r}},o=class extends e{constructor(e,t){let n=t.map(e=>new a(e.value,e.fieldDefinitionName,e.joiValidationError));super(n,void 0,null),this.message=`Invalid entries on ${e}\n${t.map(e=>`${e.fieldDefinitionName} - ${e.joiValidationError.message}`).join(`
2
+ `)}`}},s=class extends e{constructor(e){let t=Error(`Missing custom field definition for field ${e.join(`,`)}`);super([t],void 0,null),this.message=`MISSING_DEFINITION`}};export{o as InvalidEntriesError,i as InvalidFieldTypeError,a as InvalidValueError,s as MissingDefinitionError,t as MissingRequiredCustomFieldError,n as UnsupportedCustomFieldTypeError,r as UnsupportedCustomValidationError};
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/errors/index.ts"],"sourcesContent":["import { BadRequest } from '@autofleet/errors';\nimport type { ValidationError } from 'joi';\nimport type { EntriesValidationError } from '../types/entries';\n\nexport class MissingRequiredCustomFieldError extends BadRequest {\n constructor(missingFields: string[]) {\n const err = new Error(`The following custom fields are required: ${missingFields.join(',')}`);\n super([err], undefined, missingFields);\n this.message = 'MISSING_REQUIRED_CUSTOM_FIELDS';\n }\n}\n\nexport class UnsupportedCustomFieldTypeError extends BadRequest {\n constructor(fieldType: string) {\n const err = new Error(`Type \"${fieldType}\" is not supported`);\n super([err], undefined, null);\n this.message = 'UNSUPPORTED_CUSTOM_FIELD_TYPE';\n }\n}\n\nexport class UnsupportedCustomValidationError extends BadRequest {\n constructor(fieldType: string) {\n const err = new Error(`Validation for \"${fieldType}\" is not supported`);\n super([err], undefined, null);\n this.message = 'UNSUPPORTED_CUSTOM_VALIDATION_TYPE';\n }\n}\n\nexport class InvalidFieldTypeError extends BadRequest {\n constructor(fieldType: string) {\n const err = new Error(`Invalid field type ${fieldType}`);\n super([err], undefined, null);\n this.message = 'INVALID_FIELD_TYPE';\n }\n}\n\nexport class InvalidValueError extends BadRequest {\n constructor(value: any, fieldDefinitionName: string, joiValidationError: ValidationError) {\n const formattedErrorMessage = joiValidationError.message\n .replace(/\"/g, '')\n .replace('value', `'${fieldDefinitionName}'`);\n\n const formattedValue = typeof value === 'object' ? JSON.stringify(value) : value;\n\n const invalidValueMessage = `Invalid Value on field '${fieldDefinitionName}'. ${formattedErrorMessage}. received: '${formattedValue}'`;\n\n const err = new Error(invalidValueMessage);\n super([err], undefined, null);\n this.message = invalidValueMessage;\n }\n}\n\nexport class InvalidEntriesError extends BadRequest {\n constructor(modelId: string, validationErrors: EntriesValidationError[]) {\n const errors = validationErrors.map(validationError => new InvalidValueError(validationError.value, validationError.fieldDefinitionName, validationError.joiValidationError));\n super(errors, undefined, null);\n this.message = `Invalid entries on ${modelId}\\n${validationErrors.map(validationError => (\n `${validationError.fieldDefinitionName} - ${validationError.joiValidationError.message}`\n )).join('\\n')}`;\n }\n}\n\nexport class MissingDefinitionError extends BadRequest {\n constructor(fieldNames: string[]) {\n const err = new Error(`Missing custom field definition for field ${fieldNames.join(',')}`);\n super([err], undefined, null);\n this.message = 'MISSING_DEFINITION';\n }\n}\n"],"mappings":"+CAIA,IAAa,EAAb,cAAqD,CAAW,CAC9D,YAAY,EAAyB,CACnC,IAAM,EAAU,MAAM,6CAA6C,EAAc,KAAK,IAAI,GAAG,CAC7F,MAAM,CAAC,EAAI,CAAE,IAAA,GAAW,EAAc,CACtC,KAAK,QAAU,mCAIN,EAAb,cAAqD,CAAW,CAC9D,YAAY,EAAmB,CAC7B,IAAM,EAAU,MAAM,SAAS,EAAU,oBAAoB,CAC7D,MAAM,CAAC,EAAI,CAAE,IAAA,GAAW,KAAK,CAC7B,KAAK,QAAU,kCAIN,EAAb,cAAsD,CAAW,CAC/D,YAAY,EAAmB,CAC7B,IAAM,EAAU,MAAM,mBAAmB,EAAU,oBAAoB,CACvE,MAAM,CAAC,EAAI,CAAE,IAAA,GAAW,KAAK,CAC7B,KAAK,QAAU,uCAIN,EAAb,cAA2C,CAAW,CACpD,YAAY,EAAmB,CAC7B,IAAM,EAAU,MAAM,sBAAsB,IAAY,CACxD,MAAM,CAAC,EAAI,CAAE,IAAA,GAAW,KAAK,CAC7B,KAAK,QAAU,uBAIN,EAAb,cAAuC,CAAW,CAChD,YAAY,EAAY,EAA6B,EAAqC,CAOxF,IAAM,EAAsB,2BAA2B,EAAoB,KAN7C,EAAmB,QAC9C,QAAQ,KAAM,GAAG,CACjB,QAAQ,QAAS,IAAI,EAAoB,GAAG,CAIuD,eAF/E,OAAO,GAAU,SAAW,KAAK,UAAU,EAAM,CAAG,EAEyD,GAGpI,MAAM,CADU,MAAM,EAAoB,CAC/B,CAAE,IAAA,GAAW,KAAK,CAC7B,KAAK,QAAU,IAIN,EAAb,cAAyC,CAAW,CAClD,YAAY,EAAiB,EAA4C,CACvE,IAAM,EAAS,EAAiB,IAAI,GAAmB,IAAI,EAAkB,EAAgB,MAAO,EAAgB,oBAAqB,EAAgB,mBAAmB,CAAC,CAC7K,MAAM,EAAQ,IAAA,GAAW,KAAK,CAC9B,KAAK,QAAU,sBAAsB,EAAQ,IAAI,EAAiB,IAAI,GACpE,GAAG,EAAgB,oBAAoB,KAAK,EAAgB,mBAAmB,UAC/E,CAAC,KAAK;EAAK,KAIJ,EAAb,cAA4C,CAAW,CACrD,YAAY,EAAsB,CAChC,IAAM,EAAU,MAAM,6CAA6C,EAAW,KAAK,IAAI,GAAG,CAC1F,MAAM,CAAC,EAAI,CAAE,IAAA,GAAW,KAAK,CAC7B,KAAK,QAAU"}
@@ -0,0 +1,2 @@
1
+ const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`../utils/logger/index.cjs`);let n=require(`@autofleet/zehut`),r=require(`@autofleet/events`);r=e.__toESM(r);const i=new r.default({logger:t.default,getUserId:e=>e?.user_id??(0,n.getUser)()?.id??null}),a=[`value`,`defaultValue`,`blockEditingFromUI`],o=(e,t)=>{let n=new Set(Object.keys(e));return t.every(e=>!n.has(e))?e:{...e,...Object.fromEntries(t.map(t=>[t,typeof e[t]==`boolean`?e[t].toString():e[t]]))}},s={CustomFieldDefinition:{tableName:`dim_custom_field_definition`,eventVersion:`1`},CustomFieldValue:{tableName:`dim_custom_field_value`,eventVersion:`1`},CustomFieldEntries:{tableName:`dim_custom_field_entries`,eventVersion:`1`}},c=e=>{let n=s[e.constructor.name];if(!n)return;let r=e.get();try{r=o(e.get(),a)}catch(e){t.default.error(`Failed to convert booleans in dim event payload`,e)}i.sendObject(n.tableName,n.eventVersion,r).catch(()=>null)};exports.sendDimEvent=c;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["events: Events","Events"],"sources":["../../src/events/index.ts"],"sourcesContent":["import Events from '@autofleet/events';\nimport { getUser } from '@autofleet/zehut';\nimport logger from '../utils/logger';\nimport type {\n CustomFieldDefinition,\n CustomFieldEntries,\n CustomFieldValue,\n CustomValidator,\n} from '../models';\n\nconst events: Events = new Events({\n logger,\n getUserId: payload => payload?.user_id ?? getUser()?.id ?? null,\n});\n\nconst KEYS_TO_CONVERT = ['value', 'defaultValue', 'blockEditingFromUI'];\n\nconst stringifyBooleans = (savedObject: any, keysToConvert: string[]) => {\n const savedObjectKeySet = new Set(Object.keys(savedObject));\n if (keysToConvert.every(key => !savedObjectKeySet.has(key))) {\n return savedObject;\n }\n return {\n ...savedObject,\n ...Object.fromEntries(keysToConvert.map(key => [key, typeof savedObject[key] === 'boolean' ? savedObject[key].toString() : savedObject[key]])),\n };\n};\n\nconst modelTableMapping = {\n CustomFieldDefinition: {\n tableName: 'dim_custom_field_definition',\n eventVersion: '1',\n },\n CustomFieldValue: {\n tableName: 'dim_custom_field_value',\n eventVersion: '1',\n },\n CustomFieldEntries: {\n tableName: 'dim_custom_field_entries',\n eventVersion: '1',\n },\n};\n\nexport const sendDimEvent = (instance: CustomFieldDefinition | CustomFieldValue | CustomFieldEntries | CustomValidator): void => {\n const mapping = modelTableMapping[instance.constructor.name as keyof typeof modelTableMapping];\n if (!mapping) {\n return;\n }\n let objectToSend = instance.get();\n try {\n objectToSend = stringifyBooleans(instance.get(), KEYS_TO_CONVERT);\n } catch (err) {\n logger.error('Failed to convert booleans in dim event payload', err);\n }\n\n events.sendObject(\n mapping.tableName,\n mapping.eventVersion,\n objectToSend,\n ).catch(() => null);\n};\n\nexport default events;\n"],"mappings":"2KAUA,MAAMA,EAAiB,IAAIC,EAAAA,QAAO,CAChC,OAAA,EAAA,QACA,UAAW,GAAW,GAAS,UAAA,EAAA,EAAA,UAAoB,EAAE,IAAM,KAC5D,CAAC,CAEI,EAAkB,CAAC,QAAS,eAAgB,qBAAqB,CAEjE,GAAqB,EAAkB,IAA4B,CACvE,IAAM,EAAoB,IAAI,IAAI,OAAO,KAAK,EAAY,CAAC,CAI3D,OAHI,EAAc,MAAM,GAAO,CAAC,EAAkB,IAAI,EAAI,CAAC,CAClD,EAEF,CACL,GAAG,EACH,GAAG,OAAO,YAAY,EAAc,IAAI,GAAO,CAAC,EAAK,OAAO,EAAY,IAAS,UAAY,EAAY,GAAK,UAAU,CAAG,EAAY,GAAK,CAAC,CAAC,CAC/I,EAGG,EAAoB,CACxB,sBAAuB,CACrB,UAAW,8BACX,aAAc,IACf,CACD,iBAAkB,CAChB,UAAW,yBACX,aAAc,IACf,CACD,mBAAoB,CAClB,UAAW,2BACX,aAAc,IACf,CACF,CAEY,EAAgB,GAAoG,CAC/H,IAAM,EAAU,EAAkB,EAAS,YAAY,MACvD,GAAI,CAAC,EACH,OAEF,IAAI,EAAe,EAAS,KAAK,CACjC,GAAI,CACF,EAAe,EAAkB,EAAS,KAAK,CAAE,EAAgB,OAC1D,EAAK,CACZ,EAAA,QAAO,MAAM,kDAAmD,EAAI,CAGtE,EAAO,WACL,EAAQ,UACR,EAAQ,aACR,EACD,CAAC,UAAY,KAAK"}
@@ -0,0 +1,2 @@
1
+ import e from"../utils/logger/index.js";import{getUser as t}from"@autofleet/zehut";import n from"@autofleet/events";const r=new n({logger:e,getUserId:e=>e?.user_id??t()?.id??null}),i=[`value`,`defaultValue`,`blockEditingFromUI`],a=(e,t)=>{let n=new Set(Object.keys(e));return t.every(e=>!n.has(e))?e:{...e,...Object.fromEntries(t.map(t=>[t,typeof e[t]==`boolean`?e[t].toString():e[t]]))}},o={CustomFieldDefinition:{tableName:`dim_custom_field_definition`,eventVersion:`1`},CustomFieldValue:{tableName:`dim_custom_field_value`,eventVersion:`1`},CustomFieldEntries:{tableName:`dim_custom_field_entries`,eventVersion:`1`}},s=t=>{let n=o[t.constructor.name];if(!n)return;let s=t.get();try{s=a(t.get(),i)}catch(t){e.error(`Failed to convert booleans in dim event payload`,t)}r.sendObject(n.tableName,n.eventVersion,s).catch(()=>null)};export{s as sendDimEvent};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["events: Events"],"sources":["../../src/events/index.ts"],"sourcesContent":["import Events from '@autofleet/events';\nimport { getUser } from '@autofleet/zehut';\nimport logger from '../utils/logger';\nimport type {\n CustomFieldDefinition,\n CustomFieldEntries,\n CustomFieldValue,\n CustomValidator,\n} from '../models';\n\nconst events: Events = new Events({\n logger,\n getUserId: payload => payload?.user_id ?? getUser()?.id ?? null,\n});\n\nconst KEYS_TO_CONVERT = ['value', 'defaultValue', 'blockEditingFromUI'];\n\nconst stringifyBooleans = (savedObject: any, keysToConvert: string[]) => {\n const savedObjectKeySet = new Set(Object.keys(savedObject));\n if (keysToConvert.every(key => !savedObjectKeySet.has(key))) {\n return savedObject;\n }\n return {\n ...savedObject,\n ...Object.fromEntries(keysToConvert.map(key => [key, typeof savedObject[key] === 'boolean' ? savedObject[key].toString() : savedObject[key]])),\n };\n};\n\nconst modelTableMapping = {\n CustomFieldDefinition: {\n tableName: 'dim_custom_field_definition',\n eventVersion: '1',\n },\n CustomFieldValue: {\n tableName: 'dim_custom_field_value',\n eventVersion: '1',\n },\n CustomFieldEntries: {\n tableName: 'dim_custom_field_entries',\n eventVersion: '1',\n },\n};\n\nexport const sendDimEvent = (instance: CustomFieldDefinition | CustomFieldValue | CustomFieldEntries | CustomValidator): void => {\n const mapping = modelTableMapping[instance.constructor.name as keyof typeof modelTableMapping];\n if (!mapping) {\n return;\n }\n let objectToSend = instance.get();\n try {\n objectToSend = stringifyBooleans(instance.get(), KEYS_TO_CONVERT);\n } catch (err) {\n logger.error('Failed to convert booleans in dim event payload', err);\n }\n\n events.sendObject(\n mapping.tableName,\n mapping.eventVersion,\n objectToSend,\n ).catch(() => null);\n};\n\nexport default events;\n"],"mappings":"oHAUA,MAAMA,EAAiB,IAAI,EAAO,CAChC,OAAA,EACA,UAAW,GAAW,GAAS,SAAW,GAAS,EAAE,IAAM,KAC5D,CAAC,CAEI,EAAkB,CAAC,QAAS,eAAgB,qBAAqB,CAEjE,GAAqB,EAAkB,IAA4B,CACvE,IAAM,EAAoB,IAAI,IAAI,OAAO,KAAK,EAAY,CAAC,CAI3D,OAHI,EAAc,MAAM,GAAO,CAAC,EAAkB,IAAI,EAAI,CAAC,CAClD,EAEF,CACL,GAAG,EACH,GAAG,OAAO,YAAY,EAAc,IAAI,GAAO,CAAC,EAAK,OAAO,EAAY,IAAS,UAAY,EAAY,GAAK,UAAU,CAAG,EAAY,GAAK,CAAC,CAAC,CAC/I,EAGG,EAAoB,CACxB,sBAAuB,CACrB,UAAW,8BACX,aAAc,IACf,CACD,iBAAkB,CAChB,UAAW,yBACX,aAAc,IACf,CACD,mBAAoB,CAClB,UAAW,2BACX,aAAc,IACf,CACF,CAEY,EAAgB,GAAoG,CAC/H,IAAM,EAAU,EAAkB,EAAS,YAAY,MACvD,GAAI,CAAC,EACH,OAEF,IAAI,EAAe,EAAS,KAAK,CACjC,GAAI,CACF,EAAe,EAAkB,EAAS,KAAK,CAAE,EAAgB,OAC1D,EAAK,CACZ,EAAO,MAAM,kDAAmD,EAAI,CAGtE,EAAO,WACL,EAAQ,UACR,EAAQ,aACR,EACD,CAAC,UAAY,KAAK"}
@@ -0,0 +1,2 @@
1
+ const e=require(`../repository/definition.cjs`),t=require(`../repository/value.cjs`),n=require(`../repository/entries.cjs`),r=require(`../utils/scopeAttributes.cjs`),i=[`id`,`name`,`entityId`,`fieldType`,`displayName`,`validation`,`entityType`,`modelType`,`required`,`disabled`,`defaultValue`],a=async({instancesIds:e,options:t,sadotOptions:r})=>{if(!r.useCustomFieldsEntries)return{};let i=await n.findEntriesByModelIds(e,t??{}),a=Object.fromEntries(i.map(e=>{let{modelId:t,customFields:n}=e?.dataValues??{};if(t)return[t,n]}).filter(e=>e!==void 0));return e.forEach(e=>{a[e]??={}}),a},o=async({instancesIds:e,options:n,sadotOptions:r})=>r.useCustomFieldsEntries?{}:(await t.findValuesByModelIds(e,n??{})).reduce((e,t)=>{let{modelId:n}=t;return e[n]??=[],e[n].push(t),e},{}),s=(e,t)=>e.reduce((e,n)=>({...e,...t[n.customFieldDefinitionId]&&{[t[n.customFieldDefinitionId].name]:n.value}}),{}),c=(t,n,c,l={},u={useCustomFieldsEntries:!1,hasTypeId:!1})=>async(d,f)=>{if(f.originalAttributes?.length>0&&!f.originalAttributes?.includes?.(`customFields`))return;let p=Array.isArray(d)?d:[d];p=p.filter(Boolean);let m=r.default(p,n),h=[...new Set(m)].filter(Boolean),g=h.reduce((e,t)=>({...e,[t]:[]}),{}),_,v;f.transaction&&(f.transaction.definitionCache??=new Map,v=`${t}:${h.slice().sort().join(`,`)}`,_=f.transaction.definitionCache.get(v));let y;if(!_){let n=u.hasTypeId&&p.length>0&&p[0].typeId;_=(async(r=f.transaction)=>{if(n){let n=[...new Set(p.map(e=>e.typeId).filter(Boolean))];y=new Map,n.forEach(e=>y.set(e,new Set));let i=(await Promise.all(n.map(async n=>{let i=await e.findByModelTypeId(n,{withDisabled:!1,entityIds:h,modelType:t,modelOptions:l,transaction:r});return i.forEach(e=>y.get(n).add(e.id)),i}))).flat(),a=new Map;return i.forEach(e=>{a.set(e.id,e)}),Array.from(a.values())}return e.findByEntityIds(t,h,{transaction:r,modelOptions:l,attributes:i})})(),n||f.transaction?.definitionCache?.set(v,_)}let b=await _;if(b.length===0){p.forEach(e=>{e.customFields={}});return}l?.include&&l.useEntityIdFromInclude&&l.include(m).forEach(({model:e})=>{b.forEach(t=>{let n=t[e.name]?.entityId||t[`${e.name}.entityId`];n&&!g[n]&&(g[n]=[])})});let x=b.reduce((e,t)=>({...e,[t.id]:t}),{});b.forEach(e=>{let t=e.entityId;if(l?.useEntityIdFromInclude&&l.include){let n=l.include(m);for(let{model:r}of n){let n=e[r.name]?.entityId||e[`${r.name}.entityId`];if(n){t=n;break}}}g[t]&&g[t].push(e)});let S=p.map(e=>e.id),[C,w]=await Promise.all([o({instancesIds:S,options:f,sadotOptions:u}),a({instancesIds:S,options:f,sadotOptions:u})]);p.forEach(e=>{let{id:t}=e,r=C[t],i=r?s(r,x):{},a=u.useCustomFieldsEntries?w[t]:i;n.forEach(t=>{let n=g[e[t]];n&&n.length>0&&n.forEach(t=>{y&&!y.get(e.typeId)?.has(t.id)||a[t.name]===void 0&&(a[t.name]=null)})}),e.customFields=a,f.attributesToRemove?.forEach?.(t=>{delete e.dataValues?.[t],delete e?.[t]}),c===`afterFind`&&e?.changed?.(`customFields`,!1)})};var l=c;exports.default=l;
2
+ //# sourceMappingURL=enrich.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enrich.cjs","names":["applyScopeToInstance","cacheKey: string | undefined","modelTypeDefinitionsMap: Map<string, Set<string>> | undefined"],"sources":["../../src/hooks/enrich.ts"],"sourcesContent":["import * as ValueRepo from '../repository/value';\nimport * as DefinitionRepo from '../repository/definition';\nimport * as EntriesRepo from '../repository/entries';\nimport type CustomFieldValue from '../models/CustomFieldValue';\nimport type CustomFieldDefinition from '../models/CustomFieldDefinition';\nimport type { SerializedCustomFields } from '../types/definition';\nimport type { CustomFieldOptions, ModelOptions, TransactionOptions } from '../types';\nimport applyScopeToInstance from '../utils/scopeAttributes';\n\n// Include all required fields for proper functioning\nconst CUSTOM_FIELD_DEFINITION_ATTRIBUTES_TO_PULL = [\n 'id',\n 'name',\n 'entityId',\n 'fieldType',\n 'displayName',\n 'validation',\n 'entityType',\n 'modelType',\n 'required',\n 'disabled',\n 'defaultValue',\n];\n\ntype SupportedHookTypes = 'afterFind' | 'afterCreate' | 'afterUpdate';\n\ntype CustomFieldEntries = Record<string, any>;\n\n// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style\ninterface GetValuesGroupByInstanceResponse {\n [modelId: string]: CustomFieldValue[];\n}\n\n// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style\ninterface GetCustomFieldEntriesByInstanceIdResponse {\n [modelId: string]: CustomFieldEntries;\n}\n\nexport const getCustomFieldEntriesByInstanceId = async ({\n instancesIds,\n options,\n sadotOptions,\n}: {\n instancesIds: string[];\n options?: TransactionOptions;\n sadotOptions: Pick<CustomFieldOptions, 'useCustomFieldsEntries'>;\n}): Promise<GetCustomFieldEntriesByInstanceIdResponse> => {\n if (!sadotOptions.useCustomFieldsEntries) {\n return {};\n }\n\n const customFieldEntries = await EntriesRepo.findEntriesByModelIds(\n instancesIds,\n options ?? {},\n );\n\n const customFieldEntriesByInstanceId = Object.fromEntries(customFieldEntries.map((instanceEntries) => {\n const { modelId, customFields } = instanceEntries?.dataValues ?? {};\n if (!modelId) {\n return undefined;\n }\n return [modelId, customFields];\n }).filter(v => v !== undefined));\n\n instancesIds.forEach((instanceId) => {\n customFieldEntriesByInstanceId[instanceId] ??= {};\n });\n\n return customFieldEntriesByInstanceId;\n};\n\nexport const getValuesGroupByInstance = async ({\n instancesIds,\n options,\n sadotOptions,\n}: {\n instancesIds: string[];\n options?: TransactionOptions;\n sadotOptions: Pick<CustomFieldOptions, 'useCustomFieldsEntries'>;\n}): Promise<GetValuesGroupByInstanceResponse> => {\n if (sadotOptions.useCustomFieldsEntries) {\n return {};\n }\n\n const customFieldValues = await ValueRepo.findValuesByModelIds(\n instancesIds,\n options ?? {},\n );\n\n // Group fields by modelId\n return customFieldValues.reduce<Record<string, CustomFieldValue[]>>((acc, v) => {\n const { modelId } = v;\n acc[modelId] ??= [];\n acc[modelId].push(v);\n return acc;\n }, {});\n};\n\n/**\n * Serialize custom fields value into the format of {[name] -> [fieldData]}\n */\nconst serializeCustomFields = (\n customFieldValues: CustomFieldValue[],\n customFieldDefinitionsHash: Record<string, CustomFieldDefinition>,\n): SerializedCustomFields => {\n const customFields = customFieldValues.reduce((acc, cfv) => ({\n ...acc,\n ...(\n customFieldDefinitionsHash[cfv.customFieldDefinitionId]\n && { [customFieldDefinitionsHash[cfv.customFieldDefinitionId].name]: cfv.value }\n ),\n }), {});\n return customFields;\n};\n/**\n * A hook to attach the custom fields when fetching a model instances.\n */\nconst enrichResults = (\n modelType: string,\n scopeAttributes: string[],\n hookType?: SupportedHookTypes,\n modelOptions: ModelOptions = {},\n sadotOptions: Pick<CustomFieldOptions, 'useCustomFieldsEntries' | 'hasTypeId'> = { useCustomFieldsEntries: false, hasTypeId: false },\n) => async (\n instancesOrInstance: any | any[],\n options: TransactionOptions,\n): Promise<void> => {\n if (options.originalAttributes?.length > 0 && !options.originalAttributes?.includes?.('customFields')) {\n return;\n }\n\n const primaryKey = 'id';\n let instances = Array.isArray(instancesOrInstance)\n ? instancesOrInstance\n : [instancesOrInstance];\n\n instances = instances.filter(Boolean);\n\n const identifiers = applyScopeToInstance(instances, scopeAttributes);\n\n const uniqueIdentifiers = [...new Set(identifiers)].filter(Boolean);\n\n const identifierCustomFieldDefinitionsMapping = uniqueIdentifiers.reduce((map, identifier) => ({\n ...map,\n [identifier]: [],\n }), {});\n\n // Cache for definitions by model type and transaction to avoid redundant DB queries\n let customFieldDefinitionsPromise;\n let cacheKey: string | undefined;\n\n if (options.transaction) {\n // Initialize definition cache Map if not already present directly on the transaction object\n options.transaction.definitionCache ??= new Map();\n cacheKey = `${modelType}:${uniqueIdentifiers.slice().sort().join(',')}`;\n customFieldDefinitionsPromise = options.transaction.definitionCache.get(cacheKey);\n }\n\n let modelTypeDefinitionsMap: Map<string, Set<string>> | undefined;\n\n // Fetch from database (either first time in this transaction or no transaction).\n if (!customFieldDefinitionsPromise) {\n const shouldApplyTypeFiltering = sadotOptions.hasTypeId && instances.length > 0 && instances[0].typeId;\n\n const fetchDefinitions = async (transaction = options.transaction) => {\n if (shouldApplyTypeFiltering) {\n const uniqueTypeIds = [...new Set(instances.map(instance => instance.typeId).filter(Boolean))];\n\n modelTypeDefinitionsMap = new Map<string, Set<string>>();\n uniqueTypeIds.forEach(typeId => modelTypeDefinitionsMap!.set(typeId, new Set()));\n\n const definitionsResults = await Promise.all(\n uniqueTypeIds.map(async (typeId) => {\n const defs = await DefinitionRepo.findByModelTypeId(typeId, { withDisabled: false, entityIds: uniqueIdentifiers, modelType, modelOptions, transaction });\n defs.forEach(def => modelTypeDefinitionsMap!.get(typeId)!.add(def.id));\n return defs;\n }),\n );\n\n const allDefinitions = definitionsResults.flat();\n const uniqueDefinitionsMap = new Map();\n allDefinitions.forEach((def) => {\n uniqueDefinitionsMap.set(def.id, def);\n });\n return Array.from(uniqueDefinitionsMap.values());\n }\n return DefinitionRepo.findByEntityIds(\n modelType,\n uniqueIdentifiers,\n { transaction, modelOptions, attributes: CUSTOM_FIELD_DEFINITION_ATTRIBUTES_TO_PULL },\n );\n };\n\n customFieldDefinitionsPromise = fetchDefinitions();\n\n if (!shouldApplyTypeFiltering) {\n options.transaction?.definitionCache?.set(cacheKey!, customFieldDefinitionsPromise);\n }\n }\n const customFieldDefinitions = await customFieldDefinitionsPromise;\n\n if (customFieldDefinitions.length === 0) {\n // if no custom fields, we can return\n instances.forEach((instance) => {\n instance.customFields = {};\n });\n return;\n }\n\n if (modelOptions?.include && modelOptions.useEntityIdFromInclude) {\n // if we pass useEntityIdFromInclude,\n // map the entity from the options to the identifierCustomFieldDefinitionsMapping\n modelOptions.include(identifiers).forEach(({ model }) => {\n customFieldDefinitions.forEach((cfd: any) => {\n // try 2 ways to get the entityId from the joined model - for raw and non-raw\n const entityId = cfd[model!.name]?.entityId || cfd[`${model!.name}.entityId` as keyof CustomFieldDefinition];\n if (entityId && !identifierCustomFieldDefinitionsMapping[entityId]) {\n identifierCustomFieldDefinitionsMapping[entityId] = [];\n }\n });\n });\n }\n\n const definitionsMap = customFieldDefinitions.reduce((map, definition) => ({\n ...map,\n [definition.id]: definition,\n }), {});\n\n customFieldDefinitions.forEach((cfd: any) => {\n let entityIdToUse = cfd.entityId;\n\n if (modelOptions?.useEntityIdFromInclude && modelOptions.include) {\n const contextIncludes = modelOptions.include(identifiers);\n for (const { model } of contextIncludes) {\n const joinedEntityId = cfd[model!.name]?.entityId || cfd[`${model!.name}.entityId` as keyof CustomFieldDefinition];\n if (joinedEntityId) {\n entityIdToUse = joinedEntityId;\n break;\n }\n }\n }\n\n if (identifierCustomFieldDefinitionsMapping[entityIdToUse]) {\n identifierCustomFieldDefinitionsMapping[entityIdToUse].push(cfd);\n }\n });\n\n // Get the values per instates ids:\n const instancesIds = instances.map(i => i[primaryKey]);\n\n // Group fields by modelId\n const [valuesGroupByInstance, customFieldEntriesByInstanceId] = await Promise.all([\n getValuesGroupByInstance({\n instancesIds,\n options,\n sadotOptions,\n }),\n getCustomFieldEntriesByInstanceId({\n instancesIds,\n options,\n sadotOptions,\n }),\n ]);\n\n // Attach custom fields to the instances\n instances.forEach((instance) => {\n const { id } = instance;\n\n const instanceValues = valuesGroupByInstance[id];\n const serializedCustomFieldsValues = instanceValues ? serializeCustomFields(instanceValues, definitionsMap) : {};\n\n const customFields = sadotOptions.useCustomFieldsEntries\n ? customFieldEntriesByInstanceId[id]\n : serializedCustomFieldsValues;\n\n scopeAttributes.forEach((attribute) => {\n const identifier = instance[attribute];\n\n const entityCustomFieldDefinitions = identifierCustomFieldDefinitionsMapping[identifier] as CustomFieldDefinition[] | undefined;\n if (entityCustomFieldDefinitions && entityCustomFieldDefinitions.length > 0) {\n entityCustomFieldDefinitions.forEach((customFieldDefinition) => {\n if (modelTypeDefinitionsMap) {\n const applicableDefinitionIds = modelTypeDefinitionsMap.get(instance.typeId);\n if (!applicableDefinitionIds?.has(customFieldDefinition.id)) {\n return;\n }\n }\n\n if (customFields[customFieldDefinition.name] === undefined) {\n customFields[customFieldDefinition.name] = null;\n }\n });\n }\n });\n instance.customFields = customFields;\n (options.attributesToRemove as string[] | undefined)?.forEach?.((attribute) => {\n delete instance.dataValues?.[attribute];\n // if raw:\n delete instance?.[attribute];\n });\n // sequelize will think customFields changed also in 'find', so we need to mark it as unchanged\n if (hookType === 'afterFind') {\n // changed() could be undefined, i.e in raw: true\n instance?.changed?.('customFields', false);\n }\n });\n};\n\nexport default enrichResults;\n"],"mappings":"sKAUM,EAA6C,CACjD,KACA,OACA,WACA,YACA,cACA,aACA,aACA,YACA,WACA,WACA,eACD,CAgBY,EAAoC,MAAO,CACtD,eACA,UACA,kBAKwD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EAAsB,MAAQ,OAE7C,EAEJ,CACF,EAAS,aAAe,EACvB,EAAQ,oBAA6C,UAAW,GAAc,CAC7E,OAAO,EAAS,aAAa,GAE7B,OAAO,IAAW,IAClB,CAEE,IAAa,aAEf,GAAU,UAAU,eAAgB,GAAM,EAE5C,EAGJ,IAAA,EAAe"}
@@ -0,0 +1,2 @@
1
+ import{findByEntityIds as e,findByModelTypeId as t}from"../repository/definition.js";import{findValuesByModelIds as n}from"../repository/value.js";import{findEntriesByModelIds as r}from"../repository/entries.js";import i from"../utils/scopeAttributes.js";const a=[`id`,`name`,`entityId`,`fieldType`,`displayName`,`validation`,`entityType`,`modelType`,`required`,`disabled`,`defaultValue`],o=async({instancesIds:e,options:t,sadotOptions:n})=>{if(!n.useCustomFieldsEntries)return{};let i=await r(e,t??{}),a=Object.fromEntries(i.map(e=>{let{modelId:t,customFields:n}=e?.dataValues??{};if(t)return[t,n]}).filter(e=>e!==void 0));return e.forEach(e=>{a[e]??={}}),a},s=async({instancesIds:e,options:t,sadotOptions:r})=>r.useCustomFieldsEntries?{}:(await n(e,t??{})).reduce((e,t)=>{let{modelId:n}=t;return e[n]??=[],e[n].push(t),e},{}),c=(e,t)=>e.reduce((e,n)=>({...e,...t[n.customFieldDefinitionId]&&{[t[n.customFieldDefinitionId].name]:n.value}}),{});var l=(n,r,l,u={},d={useCustomFieldsEntries:!1,hasTypeId:!1})=>async(f,p)=>{if(p.originalAttributes?.length>0&&!p.originalAttributes?.includes?.(`customFields`))return;let m=Array.isArray(f)?f:[f];m=m.filter(Boolean);let h=i(m,r),g=[...new Set(h)].filter(Boolean),_=g.reduce((e,t)=>({...e,[t]:[]}),{}),v,y;p.transaction&&(p.transaction.definitionCache??=new Map,y=`${n}:${g.slice().sort().join(`,`)}`,v=p.transaction.definitionCache.get(y));let b;if(!v){let r=d.hasTypeId&&m.length>0&&m[0].typeId;v=(async(i=p.transaction)=>{if(r){let e=[...new Set(m.map(e=>e.typeId).filter(Boolean))];b=new Map,e.forEach(e=>b.set(e,new Set));let r=(await Promise.all(e.map(async e=>{let r=await t(e,{withDisabled:!1,entityIds:g,modelType:n,modelOptions:u,transaction:i});return r.forEach(t=>b.get(e).add(t.id)),r}))).flat(),a=new Map;return r.forEach(e=>{a.set(e.id,e)}),Array.from(a.values())}return e(n,g,{transaction:i,modelOptions:u,attributes:a})})(),r||p.transaction?.definitionCache?.set(y,v)}let x=await v;if(x.length===0){m.forEach(e=>{e.customFields={}});return}u?.include&&u.useEntityIdFromInclude&&u.include(h).forEach(({model:e})=>{x.forEach(t=>{let n=t[e.name]?.entityId||t[`${e.name}.entityId`];n&&!_[n]&&(_[n]=[])})});let S=x.reduce((e,t)=>({...e,[t.id]:t}),{});x.forEach(e=>{let t=e.entityId;if(u?.useEntityIdFromInclude&&u.include){let n=u.include(h);for(let{model:r}of n){let n=e[r.name]?.entityId||e[`${r.name}.entityId`];if(n){t=n;break}}}_[t]&&_[t].push(e)});let C=m.map(e=>e.id),[w,T]=await Promise.all([s({instancesIds:C,options:p,sadotOptions:d}),o({instancesIds:C,options:p,sadotOptions:d})]);m.forEach(e=>{let{id:t}=e,n=w[t],i=n?c(n,S):{},a=d.useCustomFieldsEntries?T[t]:i;r.forEach(t=>{let n=_[e[t]];n&&n.length>0&&n.forEach(t=>{b&&!b.get(e.typeId)?.has(t.id)||a[t.name]===void 0&&(a[t.name]=null)})}),e.customFields=a,p.attributesToRemove?.forEach?.(t=>{delete e.dataValues?.[t],delete e?.[t]}),l===`afterFind`&&e?.changed?.(`customFields`,!1)})};export{l as default};
2
+ //# sourceMappingURL=enrich.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enrich.js","names":["EntriesRepo.findEntriesByModelIds","ValueRepo.findValuesByModelIds","applyScopeToInstance","cacheKey: string | undefined","modelTypeDefinitionsMap: Map<string, Set<string>> | undefined","DefinitionRepo.findByModelTypeId","DefinitionRepo.findByEntityIds"],"sources":["../../src/hooks/enrich.ts"],"sourcesContent":["import * as ValueRepo from '../repository/value';\nimport * as DefinitionRepo from '../repository/definition';\nimport * as EntriesRepo from '../repository/entries';\nimport type CustomFieldValue from '../models/CustomFieldValue';\nimport type CustomFieldDefinition from '../models/CustomFieldDefinition';\nimport type { SerializedCustomFields } from '../types/definition';\nimport type { CustomFieldOptions, ModelOptions, TransactionOptions } from '../types';\nimport applyScopeToInstance from '../utils/scopeAttributes';\n\n// Include all required fields for proper functioning\nconst CUSTOM_FIELD_DEFINITION_ATTRIBUTES_TO_PULL = [\n 'id',\n 'name',\n 'entityId',\n 'fieldType',\n 'displayName',\n 'validation',\n 'entityType',\n 'modelType',\n 'required',\n 'disabled',\n 'defaultValue',\n];\n\ntype SupportedHookTypes = 'afterFind' | 'afterCreate' | 'afterUpdate';\n\ntype CustomFieldEntries = Record<string, any>;\n\n// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style\ninterface GetValuesGroupByInstanceResponse {\n [modelId: string]: CustomFieldValue[];\n}\n\n// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style\ninterface GetCustomFieldEntriesByInstanceIdResponse {\n [modelId: string]: CustomFieldEntries;\n}\n\nexport const getCustomFieldEntriesByInstanceId = async ({\n instancesIds,\n options,\n sadotOptions,\n}: {\n instancesIds: string[];\n options?: TransactionOptions;\n sadotOptions: Pick<CustomFieldOptions, 'useCustomFieldsEntries'>;\n}): Promise<GetCustomFieldEntriesByInstanceIdResponse> => {\n if (!sadotOptions.useCustomFieldsEntries) {\n return {};\n }\n\n const customFieldEntries = await EntriesRepo.findEntriesByModelIds(\n instancesIds,\n options ?? {},\n );\n\n const customFieldEntriesByInstanceId = Object.fromEntries(customFieldEntries.map((instanceEntries) => {\n const { modelId, customFields } = instanceEntries?.dataValues ?? {};\n if (!modelId) {\n return undefined;\n }\n return [modelId, customFields];\n }).filter(v => v !== undefined));\n\n instancesIds.forEach((instanceId) => {\n customFieldEntriesByInstanceId[instanceId] ??= {};\n });\n\n return customFieldEntriesByInstanceId;\n};\n\nexport const getValuesGroupByInstance = async ({\n instancesIds,\n options,\n sadotOptions,\n}: {\n instancesIds: string[];\n options?: TransactionOptions;\n sadotOptions: Pick<CustomFieldOptions, 'useCustomFieldsEntries'>;\n}): Promise<GetValuesGroupByInstanceResponse> => {\n if (sadotOptions.useCustomFieldsEntries) {\n return {};\n }\n\n const customFieldValues = await ValueRepo.findValuesByModelIds(\n instancesIds,\n options ?? {},\n );\n\n // Group fields by modelId\n return customFieldValues.reduce<Record<string, CustomFieldValue[]>>((acc, v) => {\n const { modelId } = v;\n acc[modelId] ??= [];\n acc[modelId].push(v);\n return acc;\n }, {});\n};\n\n/**\n * Serialize custom fields value into the format of {[name] -> [fieldData]}\n */\nconst serializeCustomFields = (\n customFieldValues: CustomFieldValue[],\n customFieldDefinitionsHash: Record<string, CustomFieldDefinition>,\n): SerializedCustomFields => {\n const customFields = customFieldValues.reduce((acc, cfv) => ({\n ...acc,\n ...(\n customFieldDefinitionsHash[cfv.customFieldDefinitionId]\n && { [customFieldDefinitionsHash[cfv.customFieldDefinitionId].name]: cfv.value }\n ),\n }), {});\n return customFields;\n};\n/**\n * A hook to attach the custom fields when fetching a model instances.\n */\nconst enrichResults = (\n modelType: string,\n scopeAttributes: string[],\n hookType?: SupportedHookTypes,\n modelOptions: ModelOptions = {},\n sadotOptions: Pick<CustomFieldOptions, 'useCustomFieldsEntries' | 'hasTypeId'> = { useCustomFieldsEntries: false, hasTypeId: false },\n) => async (\n instancesOrInstance: any | any[],\n options: TransactionOptions,\n): Promise<void> => {\n if (options.originalAttributes?.length > 0 && !options.originalAttributes?.includes?.('customFields')) {\n return;\n }\n\n const primaryKey = 'id';\n let instances = Array.isArray(instancesOrInstance)\n ? instancesOrInstance\n : [instancesOrInstance];\n\n instances = instances.filter(Boolean);\n\n const identifiers = applyScopeToInstance(instances, scopeAttributes);\n\n const uniqueIdentifiers = [...new Set(identifiers)].filter(Boolean);\n\n const identifierCustomFieldDefinitionsMapping = uniqueIdentifiers.reduce((map, identifier) => ({\n ...map,\n [identifier]: [],\n }), {});\n\n // Cache for definitions by model type and transaction to avoid redundant DB queries\n let customFieldDefinitionsPromise;\n let cacheKey: string | undefined;\n\n if (options.transaction) {\n // Initialize definition cache Map if not already present directly on the transaction object\n options.transaction.definitionCache ??= new Map();\n cacheKey = `${modelType}:${uniqueIdentifiers.slice().sort().join(',')}`;\n customFieldDefinitionsPromise = options.transaction.definitionCache.get(cacheKey);\n }\n\n let modelTypeDefinitionsMap: Map<string, Set<string>> | undefined;\n\n // Fetch from database (either first time in this transaction or no transaction).\n if (!customFieldDefinitionsPromise) {\n const shouldApplyTypeFiltering = sadotOptions.hasTypeId && instances.length > 0 && instances[0].typeId;\n\n const fetchDefinitions = async (transaction = options.transaction) => {\n if (shouldApplyTypeFiltering) {\n const uniqueTypeIds = [...new Set(instances.map(instance => instance.typeId).filter(Boolean))];\n\n modelTypeDefinitionsMap = new Map<string, Set<string>>();\n uniqueTypeIds.forEach(typeId => modelTypeDefinitionsMap!.set(typeId, new Set()));\n\n const definitionsResults = await Promise.all(\n uniqueTypeIds.map(async (typeId) => {\n const defs = await DefinitionRepo.findByModelTypeId(typeId, { withDisabled: false, entityIds: uniqueIdentifiers, modelType, modelOptions, transaction });\n defs.forEach(def => modelTypeDefinitionsMap!.get(typeId)!.add(def.id));\n return defs;\n }),\n );\n\n const allDefinitions = definitionsResults.flat();\n const uniqueDefinitionsMap = new Map();\n allDefinitions.forEach((def) => {\n uniqueDefinitionsMap.set(def.id, def);\n });\n return Array.from(uniqueDefinitionsMap.values());\n }\n return DefinitionRepo.findByEntityIds(\n modelType,\n uniqueIdentifiers,\n { transaction, modelOptions, attributes: CUSTOM_FIELD_DEFINITION_ATTRIBUTES_TO_PULL },\n );\n };\n\n customFieldDefinitionsPromise = fetchDefinitions();\n\n if (!shouldApplyTypeFiltering) {\n options.transaction?.definitionCache?.set(cacheKey!, customFieldDefinitionsPromise);\n }\n }\n const customFieldDefinitions = await customFieldDefinitionsPromise;\n\n if (customFieldDefinitions.length === 0) {\n // if no custom fields, we can return\n instances.forEach((instance) => {\n instance.customFields = {};\n });\n return;\n }\n\n if (modelOptions?.include && modelOptions.useEntityIdFromInclude) {\n // if we pass useEntityIdFromInclude,\n // map the entity from the options to the identifierCustomFieldDefinitionsMapping\n modelOptions.include(identifiers).forEach(({ model }) => {\n customFieldDefinitions.forEach((cfd: any) => {\n // try 2 ways to get the entityId from the joined model - for raw and non-raw\n const entityId = cfd[model!.name]?.entityId || cfd[`${model!.name}.entityId` as keyof CustomFieldDefinition];\n if (entityId && !identifierCustomFieldDefinitionsMapping[entityId]) {\n identifierCustomFieldDefinitionsMapping[entityId] = [];\n }\n });\n });\n }\n\n const definitionsMap = customFieldDefinitions.reduce((map, definition) => ({\n ...map,\n [definition.id]: definition,\n }), {});\n\n customFieldDefinitions.forEach((cfd: any) => {\n let entityIdToUse = cfd.entityId;\n\n if (modelOptions?.useEntityIdFromInclude && modelOptions.include) {\n const contextIncludes = modelOptions.include(identifiers);\n for (const { model } of contextIncludes) {\n const joinedEntityId = cfd[model!.name]?.entityId || cfd[`${model!.name}.entityId` as keyof CustomFieldDefinition];\n if (joinedEntityId) {\n entityIdToUse = joinedEntityId;\n break;\n }\n }\n }\n\n if (identifierCustomFieldDefinitionsMapping[entityIdToUse]) {\n identifierCustomFieldDefinitionsMapping[entityIdToUse].push(cfd);\n }\n });\n\n // Get the values per instates ids:\n const instancesIds = instances.map(i => i[primaryKey]);\n\n // Group fields by modelId\n const [valuesGroupByInstance, customFieldEntriesByInstanceId] = await Promise.all([\n getValuesGroupByInstance({\n instancesIds,\n options,\n sadotOptions,\n }),\n getCustomFieldEntriesByInstanceId({\n instancesIds,\n options,\n sadotOptions,\n }),\n ]);\n\n // Attach custom fields to the instances\n instances.forEach((instance) => {\n const { id } = instance;\n\n const instanceValues = valuesGroupByInstance[id];\n const serializedCustomFieldsValues = instanceValues ? serializeCustomFields(instanceValues, definitionsMap) : {};\n\n const customFields = sadotOptions.useCustomFieldsEntries\n ? customFieldEntriesByInstanceId[id]\n : serializedCustomFieldsValues;\n\n scopeAttributes.forEach((attribute) => {\n const identifier = instance[attribute];\n\n const entityCustomFieldDefinitions = identifierCustomFieldDefinitionsMapping[identifier] as CustomFieldDefinition[] | undefined;\n if (entityCustomFieldDefinitions && entityCustomFieldDefinitions.length > 0) {\n entityCustomFieldDefinitions.forEach((customFieldDefinition) => {\n if (modelTypeDefinitionsMap) {\n const applicableDefinitionIds = modelTypeDefinitionsMap.get(instance.typeId);\n if (!applicableDefinitionIds?.has(customFieldDefinition.id)) {\n return;\n }\n }\n\n if (customFields[customFieldDefinition.name] === undefined) {\n customFields[customFieldDefinition.name] = null;\n }\n });\n }\n });\n instance.customFields = customFields;\n (options.attributesToRemove as string[] | undefined)?.forEach?.((attribute) => {\n delete instance.dataValues?.[attribute];\n // if raw:\n delete instance?.[attribute];\n });\n // sequelize will think customFields changed also in 'find', so we need to mark it as unchanged\n if (hookType === 'afterFind') {\n // changed() could be undefined, i.e in raw: true\n instance?.changed?.('customFields', false);\n }\n });\n};\n\nexport default enrichResults;\n"],"mappings":"+PAUA,MAAM,EAA6C,CACjD,KACA,OACA,WACA,YACA,cACA,aACA,aACA,YACA,WACA,WACA,eACD,CAgBY,EAAoC,MAAO,CACtD,eACA,UACA,kBAKwD,CACxD,GAAI,CAAC,EAAa,uBAChB,MAAO,EAAE,CAGX,IAAM,EAAqB,MAAMA,EAC/B,EACA,GAAW,EAAE,CACd,CAEK,EAAiC,OAAO,YAAY,EAAmB,IAAK,GAAoB,CACpG,GAAM,CAAE,UAAS,gBAAiB,GAAiB,YAAc,EAAE,CAC9D,KAGL,MAAO,CAAC,EAAS,EAAa,EAC9B,CAAC,OAAO,GAAK,IAAM,IAAA,GAAU,CAAC,CAMhC,OAJA,EAAa,QAAS,GAAe,CACnC,EAA+B,KAAgB,EAAE,EACjD,CAEK,GAGI,EAA2B,MAAO,CAC7C,eACA,UACA,kBAMI,EAAa,uBACR,EAAE,EAGe,MAAMC,EAC9B,EACA,GAAW,EA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GAAM,CAAE,WAAW,EAAiB,CACvC,IAAM,EAAiB,EAAI,EAAO,OAAO,UAAY,EAAI,GAAG,EAAO,KAAK,YACxE,GAAI,EAAgB,CAClB,EAAgB,EAChB,QAKF,EAAwC,IAC1C,EAAwC,GAAe,KAAK,EAAI,EAElE,CAGF,IAAM,EAAe,EAAU,IAAI,GAAK,EAAE,GAAY,CAGhD,CAAC,EAAuB,GAAkC,MAAM,QAAQ,IAAI,CAChF,EAAyB,CACvB,eACA,UACA,eACD,CAAC,CACF,EAAkC,CAChC,eACA,UACA,eACD,CAAC,CACH,CAAC,CAGF,EAAU,QAAS,GAAa,CAC9B,GAAM,CAAE,MAAO,EAET,EAAiB,EAAsB,GACvC,EAA+B,EAAiB,EAAsB,EAAgB,EAAe,CAAG,EAAE,CAE1G,EAAe,EAAa,uBAC9B,EAA+B,GAC/B,EAEJ,EAAgB,QAAS,GAAc,CAGrC,IAAM,EAA+B,EAFlB,EAAS,IAGxB,GAAgC,EAA6B,OAAS,GACxE,EAA6B,QAAS,GAA0B,CAC1D,GAEE,CAD4B,EAAwB,IAAI,EAAS,OAAO,EAC9C,IAAI,EAAsB,GAAG,EAKzD,EAAa,EAAsB,QAAU,IAAA,KAC/C,EAAa,EAAsB,MAAQ,OAE7C,EAEJ,CACF,EAAS,aAAe,EACvB,EAAQ,oBAA6C,UAAW,GAAc,CAC7E,OAAO,EAAS,aAAa,GAE7B,OAAO,IAAW,IAClB,CAEE,IAAa,aAEf,GAAU,UAAU,eAAgB,GAAM,EAE5C"}
@@ -0,0 +1,2 @@
1
+ const e=require(`../utils/logger/index.cjs`),t=(e,t)=>{let n=e.filter(e=>!t.includes(e));return t.includes?.(`id`)||n.push(`id`),n},n=n=>r=>{let{attributes:i}=r;if(i?.includes?.(`customFields`)){let a=t(n,i);e.default.debug(`sadot - before find hook`),a?.length>0&&(i.push(...a),r.attributesToRemove=a)}};exports.beforeFind=n;
2
+ //# sourceMappingURL=find.cjs.map