@autofleet/sadot 1.6.18-beta.4 → 1.6.18-beta.7

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 (308) hide show
  1. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/decorate.cjs +11 -0
  2. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/decorateMetadata.cjs +8 -0
  3. package/dist/_virtual/rolldown_runtime.cjs +43 -0
  4. package/dist/_virtual/rolldown_runtime.js +1 -2
  5. package/dist/api/index.cjs +12 -0
  6. package/dist/api/v1/definition/index.cjs +113 -0
  7. package/dist/api/v1/definition/validations.cjs +128 -0
  8. package/dist/api/v1/errors.cjs +14 -0
  9. package/dist/api/v1/field-policies/index.cjs +84 -0
  10. package/dist/api/v1/field-policies/index.js +83 -0
  11. package/dist/api/v1/index.cjs +16 -0
  12. package/dist/{packages/sadot/src/api → api}/v1/index.js +2 -2
  13. package/dist/api/v1/validator/index.cjs +115 -0
  14. package/dist/api/v1/validator/validations.cjs +40 -0
  15. package/dist/api/v1/validator/validations.d.ts +22 -0
  16. package/dist/errors/index.cjs +62 -0
  17. package/dist/events/index.cjs +52 -0
  18. package/dist/hooks/enrich.cjs +175 -0
  19. package/dist/hooks/find.cjs +22 -0
  20. package/dist/hooks/hooks.cjs +310 -0
  21. package/dist/hooks/index.cjs +3 -0
  22. package/dist/hooks/utils/updateInstanceValues.cjs +27 -0
  23. package/dist/index.cjs +83 -0
  24. package/dist/index.d.cts +25 -0
  25. package/dist/index.d.ts +13 -13
  26. package/dist/index.js +19 -23
  27. package/dist/init-state.cjs +56 -0
  28. package/dist/init-state.d.ts +35 -0
  29. package/dist/mat-path-state.cjs +10 -0
  30. package/dist/migrations/001-create-core-tables.cjs +70 -0
  31. package/dist/migrations/002-create-custom-field-entries.cjs +27 -0
  32. package/dist/migrations/003-create-custom-field-model-type-map.cjs +35 -0
  33. package/dist/migrations/004-create-field-policy-tables.cjs +29 -0
  34. package/dist/migrations/index.cjs +88 -0
  35. package/dist/{packages/sadot/src/migrations → migrations}/index.js +1 -1
  36. package/dist/models/CustomFieldDefinition.cjs +147 -0
  37. package/dist/models/CustomFieldDefinition.d.cts +40 -0
  38. package/dist/{packages/sadot/src/models → models}/CustomFieldDefinition.js +2 -2
  39. package/dist/models/CustomFieldEntries.cjs +71 -0
  40. package/dist/models/CustomFieldEntries.d.cts +15 -0
  41. package/dist/{packages/sadot/src/models → models}/CustomFieldEntries.js +2 -2
  42. package/dist/models/CustomFieldModelTypeMap.cjs +62 -0
  43. package/dist/models/CustomFieldModelTypeMap.d.cts +14 -0
  44. package/dist/{packages/sadot/src/models → models}/CustomFieldModelTypeMap.js +2 -2
  45. package/dist/models/CustomFieldValue.cjs +109 -0
  46. package/dist/models/CustomFieldValue.d.cts +20 -0
  47. package/dist/{packages/sadot/src/models → models}/CustomFieldValue.js +2 -2
  48. package/dist/models/CustomValidator.cjs +68 -0
  49. package/dist/models/CustomValidator.d.cts +18 -0
  50. package/dist/{packages/sadot/src/models → models}/CustomValidator.js +2 -2
  51. package/dist/models/FieldPolicy.cjs +50 -0
  52. package/dist/models/FieldPolicy.d.ts +23 -0
  53. package/dist/{packages/sadot/src/models → models}/FieldPolicy.js +2 -2
  54. package/dist/models/index.cjs +163 -0
  55. package/dist/{packages/sadot/src/models → models}/index.d.ts +4 -0
  56. package/dist/models/tests/AssociatedTestModel.cjs +51 -0
  57. package/dist/models/tests/AssociatedTestModel.d.ts +2 -0
  58. package/dist/{packages/sadot/src/models → models}/tests/AssociatedTestModel.js +2 -2
  59. package/dist/models/tests/TestModel.cjs +43 -0
  60. package/dist/models/tests/TestModel.d.ts +2 -0
  61. package/dist/{packages/sadot/src/models → models}/tests/TestModel.js +2 -2
  62. package/dist/models/tests/contextAwareModels/ContextAwareTestModel.cjs +35 -0
  63. package/dist/models/tests/contextAwareModels/ContextAwareTestModel.d.ts +2 -0
  64. package/dist/{packages/sadot/src/models → models}/tests/contextAwareModels/ContextAwareTestModel.js +2 -2
  65. package/dist/models/tests/contextAwareModels/ContextTestModel.cjs +33 -0
  66. package/dist/models/tests/contextAwareModels/ContextTestModel.d.ts +1 -0
  67. package/dist/{packages/sadot/src/models → models}/tests/contextAwareModels/ContextTestModel.js +2 -2
  68. package/dist/repository/definition.cjs +221 -0
  69. package/dist/repository/entries.cjs +69 -0
  70. package/dist/repository/field-policy.cjs +46 -0
  71. package/dist/repository/field-policy.d.cts +31 -0
  72. package/dist/{packages/sadot/src/repository → repository}/field-policy.d.ts +3 -1
  73. package/dist/{packages/sadot/src/repository → repository}/field-policy.js +6 -2
  74. package/dist/repository/utils/formatValues.cjs +14 -0
  75. package/dist/repository/validator.cjs +58 -0
  76. package/dist/repository/value.cjs +77 -0
  77. package/dist/scopes/filter.cjs +56 -0
  78. package/dist/scopes/filter.d.cts +22 -0
  79. package/dist/scopes/helpers/filter.helpers.cjs +152 -0
  80. package/dist/scopes/helpers/filter.helpers.d.ts +16 -0
  81. package/dist/scopes/index.cjs +1 -0
  82. package/dist/types/index.d.cts +69 -0
  83. package/dist/utils/constants/index.cjs +32 -0
  84. package/dist/utils/constants/index.d.ts +23 -0
  85. package/dist/utils/db/index.cjs +15 -0
  86. package/dist/utils/helpers/index.cjs +23 -0
  87. package/dist/utils/helpers/index.d.cts +30 -0
  88. package/dist/utils/init.cjs +115 -0
  89. package/dist/utils/logger/index.cjs +15 -0
  90. package/dist/utils/scopeAttributes.cjs +12 -0
  91. package/dist/utils/validations/index.cjs +34 -0
  92. package/dist/utils/validations/schema/custom-fields.cjs +9 -0
  93. package/dist/utils/validations/schema/custom-fields.d.ts +6 -0
  94. package/dist/utils/validations/schema/validator-schema.cjs +102 -0
  95. package/dist/utils/validations/validators/index.cjs +45 -0
  96. package/dist/utils/validations/validators/multi-select-dropdown.validator.cjs +7 -0
  97. package/dist/utils/validations/validators/multi-select-status.validator.cjs +10 -0
  98. package/dist/utils/validations/validators/multi-select.helpers.cjs +12 -0
  99. package/dist/utils/validations/validators/select.validator.cjs +12 -0
  100. package/dist/utils/validations/validators/status.validator.cjs +12 -0
  101. package/package.json +2 -2
  102. package/dist/node_modules/accepts/index.js +0 -175
  103. package/dist/node_modules/array-flatten/array-flatten.js +0 -56
  104. package/dist/node_modules/body-parser/index.js +0 -135
  105. package/dist/node_modules/body-parser/lib/read.js +0 -164
  106. package/dist/node_modules/body-parser/lib/types/json.js +0 -200
  107. package/dist/node_modules/body-parser/lib/types/raw.js +0 -85
  108. package/dist/node_modules/body-parser/lib/types/text.js +0 -101
  109. package/dist/node_modules/body-parser/lib/types/urlencoded.js +0 -217
  110. package/dist/node_modules/body-parser/node_modules/qs/lib/formats.js +0 -29
  111. package/dist/node_modules/body-parser/node_modules/qs/lib/index.js +0 -21
  112. package/dist/node_modules/body-parser/node_modules/qs/lib/parse.js +0 -182
  113. package/dist/node_modules/body-parser/node_modules/qs/lib/stringify.js +0 -187
  114. package/dist/node_modules/body-parser/node_modules/qs/lib/utils.js +0 -173
  115. package/dist/node_modules/bytes/index.js +0 -121
  116. package/dist/node_modules/call-bind-apply-helpers/actualApply.js +0 -20
  117. package/dist/node_modules/call-bind-apply-helpers/functionApply.js +0 -12
  118. package/dist/node_modules/call-bind-apply-helpers/functionCall.js +0 -12
  119. package/dist/node_modules/call-bind-apply-helpers/index.js +0 -23
  120. package/dist/node_modules/call-bind-apply-helpers/reflectApply.js +0 -12
  121. package/dist/node_modules/call-bound/index.js +0 -22
  122. package/dist/node_modules/content-disposition/index.js +0 -309
  123. package/dist/node_modules/content-type/index.js +0 -151
  124. package/dist/node_modules/cookie/index.js +0 -245
  125. package/dist/node_modules/cookie-signature/index.js +0 -48
  126. package/dist/node_modules/debug/node_modules/has-flag/index.js +0 -17
  127. package/dist/node_modules/debug/node_modules/supports-color/index.js +0 -70
  128. package/dist/node_modules/debug/src/browser.js +0 -203
  129. package/dist/node_modules/debug/src/common.js +0 -209
  130. package/dist/node_modules/debug/src/index.js +0 -18
  131. package/dist/node_modules/debug/src/node.js +0 -215
  132. package/dist/node_modules/depd/index.js +0 -316
  133. package/dist/node_modules/destroy/index.js +0 -155
  134. package/dist/node_modules/dunder-proto/get.js +0 -27
  135. package/dist/node_modules/ee-first/index.js +0 -75
  136. package/dist/node_modules/encodeurl/index.js +0 -56
  137. package/dist/node_modules/es-define-property/index.js +0 -18
  138. package/dist/node_modules/es-errors/eval.js +0 -12
  139. package/dist/node_modules/es-errors/index.js +0 -12
  140. package/dist/node_modules/es-errors/range.js +0 -12
  141. package/dist/node_modules/es-errors/ref.js +0 -12
  142. package/dist/node_modules/es-errors/syntax.js +0 -12
  143. package/dist/node_modules/es-errors/type.js +0 -12
  144. package/dist/node_modules/es-errors/uri.js +0 -12
  145. package/dist/node_modules/es-object-atoms/index.js +0 -12
  146. package/dist/node_modules/escape-html/index.js +0 -67
  147. package/dist/node_modules/etag/index.js +0 -82
  148. package/dist/node_modules/express/index.js +0 -19
  149. package/dist/node_modules/express/lib/application.js +0 -503
  150. package/dist/node_modules/express/lib/express.js +0 -114
  151. package/dist/node_modules/express/lib/middleware/init.js +0 -44
  152. package/dist/node_modules/express/lib/middleware/query.js +0 -47
  153. package/dist/node_modules/express/lib/request.js +0 -422
  154. package/dist/node_modules/express/lib/response.js +0 -867
  155. package/dist/node_modules/express/lib/router/index.js +0 -424
  156. package/dist/node_modules/express/lib/router/layer.js +0 -140
  157. package/dist/node_modules/express/lib/router/route.js +0 -158
  158. package/dist/node_modules/express/lib/utils.js +0 -247
  159. package/dist/node_modules/express/lib/view.js +0 -135
  160. package/dist/node_modules/express/node_modules/qs/lib/formats.js +0 -29
  161. package/dist/node_modules/express/node_modules/qs/lib/index.js +0 -21
  162. package/dist/node_modules/express/node_modules/qs/lib/parse.js +0 -182
  163. package/dist/node_modules/express/node_modules/qs/lib/stringify.js +0 -187
  164. package/dist/node_modules/express/node_modules/qs/lib/utils.js +0 -173
  165. package/dist/node_modules/finalhandler/index.js +0 -234
  166. package/dist/node_modules/forwarded/index.js +0 -67
  167. package/dist/node_modules/fresh/index.js +0 -96
  168. package/dist/node_modules/function-bind/implementation.js +0 -58
  169. package/dist/node_modules/function-bind/index.js +0 -13
  170. package/dist/node_modules/get-intrinsic/index.js +0 -357
  171. package/dist/node_modules/get-proto/Object.getPrototypeOf.js +0 -14
  172. package/dist/node_modules/get-proto/Reflect.getPrototypeOf.js +0 -12
  173. package/dist/node_modules/get-proto/index.js +0 -25
  174. package/dist/node_modules/gopd/gOPD.js +0 -12
  175. package/dist/node_modules/gopd/index.js +0 -19
  176. package/dist/node_modules/has-symbols/index.js +0 -21
  177. package/dist/node_modules/has-symbols/shams.js +0 -35
  178. package/dist/node_modules/hasown/index.js +0 -16
  179. package/dist/node_modules/http-errors/index.js +0 -207
  180. package/dist/node_modules/iconv-lite/encodings/dbcs-codec.js +0 -321
  181. package/dist/node_modules/iconv-lite/encodings/dbcs-data.js +0 -126
  182. package/dist/node_modules/iconv-lite/encodings/index.js +0 -32
  183. package/dist/node_modules/iconv-lite/encodings/internal.js +0 -135
  184. package/dist/node_modules/iconv-lite/encodings/sbcs-codec.js +0 -53
  185. package/dist/node_modules/iconv-lite/encodings/sbcs-data-generated.js +0 -458
  186. package/dist/node_modules/iconv-lite/encodings/sbcs-data.js +0 -150
  187. package/dist/node_modules/iconv-lite/encodings/tables/big5-added.js +0 -172
  188. package/dist/node_modules/iconv-lite/encodings/tables/cp936.js +0 -2587
  189. package/dist/node_modules/iconv-lite/encodings/tables/cp949.js +0 -2223
  190. package/dist/node_modules/iconv-lite/encodings/tables/cp950.js +0 -230
  191. package/dist/node_modules/iconv-lite/encodings/tables/eucjp.js +0 -428
  192. package/dist/node_modules/iconv-lite/encodings/tables/gb18030-ranges.js +0 -430
  193. package/dist/node_modules/iconv-lite/encodings/tables/gbk-added.js +0 -232
  194. package/dist/node_modules/iconv-lite/encodings/tables/shiftjis.js +0 -295
  195. package/dist/node_modules/iconv-lite/encodings/utf16.js +0 -107
  196. package/dist/node_modules/iconv-lite/encodings/utf7.js +0 -183
  197. package/dist/node_modules/iconv-lite/lib/bom-handling.js +0 -45
  198. package/dist/node_modules/iconv-lite/lib/extend-node.js +0 -150
  199. package/dist/node_modules/iconv-lite/lib/index.js +0 -96
  200. package/dist/node_modules/iconv-lite/lib/streams.js +0 -97
  201. package/dist/node_modules/inherits/inherits.js +0 -20
  202. package/dist/node_modules/inherits/inherits_browser.js +0 -30
  203. package/dist/node_modules/ipaddr.js/lib/ipaddr.js +0 -677
  204. package/dist/node_modules/math-intrinsics/abs.js +0 -12
  205. package/dist/node_modules/math-intrinsics/floor.js +0 -12
  206. package/dist/node_modules/math-intrinsics/isNaN.js +0 -14
  207. package/dist/node_modules/math-intrinsics/max.js +0 -12
  208. package/dist/node_modules/math-intrinsics/min.js +0 -12
  209. package/dist/node_modules/math-intrinsics/pow.js +0 -12
  210. package/dist/node_modules/math-intrinsics/round.js +0 -12
  211. package/dist/node_modules/math-intrinsics/sign.js +0 -17
  212. package/dist/node_modules/merge-descriptors/index.js +0 -46
  213. package/dist/node_modules/methods/index.js +0 -69
  214. package/dist/node_modules/mime/mime.js +0 -79
  215. package/dist/node_modules/mime/types.js +0 -1104
  216. package/dist/node_modules/mime-types/index.js +0 -123
  217. package/dist/node_modules/mime-types/node_modules/mime-db/db.js +0 -7051
  218. package/dist/node_modules/mime-types/node_modules/mime-db/index.js +0 -21
  219. package/dist/node_modules/ms/index.js +0 -124
  220. package/dist/node_modules/negotiator/index.js +0 -76
  221. package/dist/node_modules/negotiator/lib/charset.js +0 -132
  222. package/dist/node_modules/negotiator/lib/encoding.js +0 -143
  223. package/dist/node_modules/negotiator/lib/language.js +0 -138
  224. package/dist/node_modules/negotiator/lib/mediaType.js +0 -200
  225. package/dist/node_modules/object-inspect/index.js +0 -389
  226. package/dist/node_modules/object-inspect/util.inspect.js +0 -11
  227. package/dist/node_modules/on-finished/index.js +0 -178
  228. package/dist/node_modules/parseurl/index.js +0 -111
  229. package/dist/node_modules/path-to-regexp/index.js +0 -118
  230. package/dist/node_modules/proxy-addr/index.js +0 -212
  231. package/dist/node_modules/range-parser/index.js +0 -110
  232. package/dist/node_modules/raw-body/index.js +0 -209
  233. package/dist/node_modules/safe-buffer/index.js +0 -46
  234. package/dist/node_modules/safer-buffer/safer.js +0 -48
  235. package/dist/node_modules/send/index.js +0 -801
  236. package/dist/node_modules/send/node_modules/encodeurl/index.js +0 -56
  237. package/dist/node_modules/serve-static/index.js +0 -134
  238. package/dist/node_modules/setprototypeof/index.js +0 -19
  239. package/dist/node_modules/side-channel/index.js +0 -45
  240. package/dist/node_modules/side-channel-list/index.js +0 -84
  241. package/dist/node_modules/side-channel-map/index.js +0 -62
  242. package/dist/node_modules/side-channel-weakmap/index.js +0 -73
  243. package/dist/node_modules/statuses/codes.js +0 -75
  244. package/dist/node_modules/statuses/index.js +0 -108
  245. package/dist/node_modules/toidentifier/index.js +0 -32
  246. package/dist/node_modules/type-is/index.js +0 -179
  247. package/dist/node_modules/type-is/node_modules/media-typer/index.js +0 -186
  248. package/dist/node_modules/unpipe/index.js +0 -50
  249. package/dist/node_modules/utils-merge/index.js +0 -28
  250. package/dist/node_modules/vary/index.js +0 -95
  251. package/dist/packages/sadot/src/api/v1/templates/index.js +0 -76
  252. /package/dist/{packages/sadot/src/api → api}/index.js +0 -0
  253. /package/dist/{packages/sadot/src/api → api}/v1/definition/index.js +0 -0
  254. /package/dist/{packages/sadot/src/api → api}/v1/definition/validations.js +0 -0
  255. /package/dist/{packages/sadot/src/api → api}/v1/errors.js +0 -0
  256. /package/dist/{packages/sadot/src/api → api}/v1/validator/index.js +0 -0
  257. /package/dist/{packages/sadot/src/api/v1/validator/validations.d.ts → api/v1/validator/validations.d.cts} +0 -0
  258. /package/dist/{packages/sadot/src/api → api}/v1/validator/validations.js +0 -0
  259. /package/dist/{packages/sadot/src/errors → errors}/index.js +0 -0
  260. /package/dist/{packages/sadot/src/events → events}/index.js +0 -0
  261. /package/dist/{packages/sadot/src/hooks → hooks}/enrich.js +0 -0
  262. /package/dist/{packages/sadot/src/hooks → hooks}/find.js +0 -0
  263. /package/dist/{packages/sadot/src/hooks → hooks}/hooks.js +0 -0
  264. /package/dist/{packages/sadot/src/hooks → hooks}/index.js +0 -0
  265. /package/dist/{packages/sadot/src/hooks → hooks}/utils/updateInstanceValues.js +0 -0
  266. /package/dist/{packages/sadot/src/init-state.d.ts → init-state.d.cts} +0 -0
  267. /package/dist/{packages/sadot/src/init-state.js → init-state.js} +0 -0
  268. /package/dist/{packages/sadot/src/mat-path-state.js → mat-path-state.js} +0 -0
  269. /package/dist/{packages/sadot/src/migrations → migrations}/001-create-core-tables.js +0 -0
  270. /package/dist/{packages/sadot/src/migrations → migrations}/002-create-custom-field-entries.js +0 -0
  271. /package/dist/{packages/sadot/src/migrations → migrations}/003-create-custom-field-model-type-map.js +0 -0
  272. /package/dist/{packages/sadot/src/migrations → migrations}/004-create-field-policy-tables.js +0 -0
  273. /package/dist/{packages/sadot/src/models → models}/CustomFieldDefinition.d.ts +0 -0
  274. /package/dist/{packages/sadot/src/models → models}/CustomFieldEntries.d.ts +0 -0
  275. /package/dist/{packages/sadot/src/models → models}/CustomFieldModelTypeMap.d.ts +0 -0
  276. /package/dist/{packages/sadot/src/models → models}/CustomFieldValue.d.ts +0 -0
  277. /package/dist/{packages/sadot/src/models → models}/CustomValidator.d.ts +0 -0
  278. /package/dist/{packages/sadot/src/models/FieldPolicy.d.ts → models/FieldPolicy.d.cts} +0 -0
  279. /package/dist/{packages/sadot/src/models → models}/index.js +0 -0
  280. /package/dist/{packages/sadot/src/repository → repository}/definition.js +0 -0
  281. /package/dist/{packages/sadot/src/repository → repository}/entries.js +0 -0
  282. /package/dist/{packages/sadot/src/repository → repository}/utils/formatValues.js +0 -0
  283. /package/dist/{packages/sadot/src/repository → repository}/validator.js +0 -0
  284. /package/dist/{packages/sadot/src/repository → repository}/value.js +0 -0
  285. /package/dist/{packages/sadot/src/scopes → scopes}/filter.d.ts +0 -0
  286. /package/dist/{packages/sadot/src/scopes → scopes}/filter.js +0 -0
  287. /package/dist/{packages/sadot/src/scopes/helpers/filter.helpers.d.ts → scopes/helpers/filter.helpers.d.cts} +0 -0
  288. /package/dist/{packages/sadot/src/scopes → scopes}/helpers/filter.helpers.js +0 -0
  289. /package/dist/{packages/sadot/src/scopes → scopes}/index.js +0 -0
  290. /package/dist/{packages/sadot/src/types → types}/index.d.ts +0 -0
  291. /package/dist/{packages/sadot/src/utils/constants/index.d.ts → utils/constants/index.d.cts} +0 -0
  292. /package/dist/{packages/sadot/src/utils → utils}/constants/index.js +0 -0
  293. /package/dist/{packages/sadot/src/utils → utils}/db/index.js +0 -0
  294. /package/dist/{packages/sadot/src/utils → utils}/helpers/index.d.ts +0 -0
  295. /package/dist/{packages/sadot/src/utils → utils}/helpers/index.js +0 -0
  296. /package/dist/{packages/sadot/src/utils → utils}/init.js +0 -0
  297. /package/dist/{packages/sadot/src/utils → utils}/logger/index.js +0 -0
  298. /package/dist/{packages/sadot/src/utils → utils}/scopeAttributes.js +0 -0
  299. /package/dist/{packages/sadot/src/utils → utils}/validations/index.js +0 -0
  300. /package/dist/{packages/sadot/src/utils/validations/schema/custom-fields.d.ts → utils/validations/schema/custom-fields.d.cts} +0 -0
  301. /package/dist/{packages/sadot/src/utils → utils}/validations/schema/custom-fields.js +0 -0
  302. /package/dist/{packages/sadot/src/utils → utils}/validations/schema/validator-schema.js +0 -0
  303. /package/dist/{packages/sadot/src/utils → utils}/validations/validators/index.js +0 -0
  304. /package/dist/{packages/sadot/src/utils → utils}/validations/validators/multi-select-dropdown.validator.js +0 -0
  305. /package/dist/{packages/sadot/src/utils → utils}/validations/validators/multi-select-status.validator.js +0 -0
  306. /package/dist/{packages/sadot/src/utils → utils}/validations/validators/multi-select.helpers.js +0 -0
  307. /package/dist/{packages/sadot/src/utils → utils}/validations/validators/select.validator.js +0 -0
  308. /package/dist/{packages/sadot/src/utils → utils}/validations/validators/status.validator.js +0 -0
@@ -0,0 +1,11 @@
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;
@@ -0,0 +1,8 @@
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;
@@ -0,0 +1,43 @@
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 __export = (all, symbols) => {
9
+ let target = {};
10
+ for (var name in all) {
11
+ __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
15
+ }
16
+ if (symbols) {
17
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
18
+ }
19
+ return target;
20
+ };
21
+ var __copyProps = (to, from, except, desc) => {
22
+ if (from && typeof from === "object" || typeof from === "function") {
23
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
24
+ key = keys[i];
25
+ if (!__hasOwnProp.call(to, key) && key !== except) {
26
+ __defProp(to, key, {
27
+ get: ((k) => from[k]).bind(null, key),
28
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
29
+ });
30
+ }
31
+ }
32
+ }
33
+ return to;
34
+ };
35
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
36
+ value: mod,
37
+ enumerable: true
38
+ }) : target, mod));
39
+
40
+ //#endregion
41
+
42
+ exports.__export = __export;
43
+ exports.__toESM = __toESM;
@@ -2,7 +2,6 @@ import { createRequire } from "node:module";
2
2
 
3
3
  //#region rolldown:runtime
4
4
  var __defProp = Object.defineProperty;
5
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
6
5
  var __export = (all, symbols) => {
7
6
  let target = {};
8
7
  for (var name in all) {
@@ -19,4 +18,4 @@ var __export = (all, symbols) => {
19
18
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
20
19
 
21
20
  //#endregion
22
- export { __commonJSMin, __export, __require };
21
+ export { __export, __require };
@@ -0,0 +1,12 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_index = require('../utils/logger/index.cjs');
3
+ const require_index$1 = require('./v1/index.cjs');
4
+ let _autofleet_node_common = require("@autofleet/node-common");
5
+
6
+ //#region src/api/index.ts
7
+ const router = (0, _autofleet_node_common.Router)({ logger: require_index.default });
8
+ router.use("/v1", require_index$1.default);
9
+ var api_default = router;
10
+
11
+ //#endregion
12
+ exports.default = api_default;
@@ -0,0 +1,113 @@
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ const require_index = require('../../../utils/logger/index.cjs');
3
+ const require_definition = require('../../../repository/definition.cjs');
4
+ const require_errors = require('../errors.cjs');
5
+ const require_validations = require('./validations.cjs');
6
+ const require_mat_path_state = require('../../../mat-path-state.cjs');
7
+ let _autofleet_errors = require("@autofleet/errors");
8
+ let _autofleet_node_common = require("@autofleet/node-common");
9
+
10
+ //#region src/api/v1/definition/index.ts
11
+ const router = (0, _autofleet_node_common.Router)({ logger: require_index.default });
12
+ const ENTITY = "CustomFieldDefinition";
13
+ const toPascalCase = (str) => str.replace(/(^\w|-\w)/g, (subStr) => subStr.replace(/-/, "").toUpperCase());
14
+ /**
15
+ * Create
16
+ */
17
+ router.post("/", async (req, res) => {
18
+ const { modelName } = req.params;
19
+ const modelType = toPascalCase(modelName);
20
+ try {
21
+ const validatedPayload = await require_validations.validateCustomFieldDefinitionCreation(req.body);
22
+ const customFieldDefinition = await require_definition.create({
23
+ ...validatedPayload,
24
+ modelType
25
+ });
26
+ return res.status(201).json(customFieldDefinition);
27
+ } catch (err) {
28
+ require_index.default.error("Failed to create custom field definition", err);
29
+ return require_errors.default(err, res, {
30
+ logger: require_index.default,
31
+ message: `Error in create ${ENTITY} request`
32
+ });
33
+ }
34
+ });
35
+ /**
36
+ * Get by id
37
+ */
38
+ router.get("/:customFieldDefinitionId", async (req, res) => {
39
+ const { customFieldDefinitionId } = req.params;
40
+ try {
41
+ const customFieldDefinition = await require_definition.findById(customFieldDefinitionId);
42
+ if (!customFieldDefinition) throw new _autofleet_errors.ResourceNotFoundError();
43
+ return res.json(customFieldDefinition);
44
+ } catch (err) {
45
+ require_index.default.error("Failed to fetch custom field definition", err);
46
+ return require_errors.default(err, res, {
47
+ logger: require_index.default,
48
+ message: `Error in get ${ENTITY} request`
49
+ });
50
+ }
51
+ });
52
+ /**
53
+ * Get all
54
+ */
55
+ router.get("/", async (req, res) => {
56
+ const { params: { modelName }, query: { entityIds, modelTypeId } } = req;
57
+ const modelType = toPascalCase(modelName);
58
+ try {
59
+ const applyEntityIdsFilter = !require_mat_path_state.matPathState.isMatPathEnabled?.() && entityIds && entityIds.length > 0;
60
+ if (modelTypeId) {
61
+ const customFieldDefinitions$1 = await require_definition.findByModelTypeId(modelTypeId, {
62
+ withDisabled: true,
63
+ modelType,
64
+ entityIds: applyEntityIdsFilter ? entityIds : void 0
65
+ });
66
+ return res.json(customFieldDefinitions$1);
67
+ }
68
+ const where = {
69
+ modelType,
70
+ ...applyEntityIdsFilter && { entityId: entityIds }
71
+ };
72
+ const customFieldDefinitions = await require_definition.findAll(where, {
73
+ withDisabled: true,
74
+ enrichWithModelTypeIds: true
75
+ });
76
+ return res.json(customFieldDefinitions);
77
+ } catch (err) {
78
+ require_index.default.error("Failed to fetch custom field definitions", err);
79
+ return require_errors.default(err, res, {
80
+ logger: require_index.default,
81
+ message: `Error in get all ${ENTITY} request`
82
+ });
83
+ }
84
+ });
85
+ /**
86
+ * Update
87
+ */
88
+ router.patch("/:customFieldDefinitionId", async (req, res) => {
89
+ const { customFieldDefinitionId, modelName } = req.params;
90
+ const modelType = toPascalCase(modelName);
91
+ try {
92
+ const validatedPayload = await require_validations.validateCustomFieldDefinitionUpdate(req.body);
93
+ if (!await require_definition.findByWhere({
94
+ id: customFieldDefinitionId,
95
+ modelType
96
+ })) throw new _autofleet_errors.ResourceNotFoundError();
97
+ const updatedCustomFieldDefinition = await require_definition.update(customFieldDefinitionId, {
98
+ ...validatedPayload,
99
+ modelType
100
+ });
101
+ return res.status(200).json(updatedCustomFieldDefinition);
102
+ } catch (err) {
103
+ require_index.default.error("Failed to patch custom field definition", err);
104
+ return require_errors.default(err, res, {
105
+ logger: require_index.default,
106
+ message: `Error in update ${ENTITY} request`
107
+ });
108
+ }
109
+ });
110
+ var definition_default = router;
111
+
112
+ //#endregion
113
+ exports.default = definition_default;
@@ -0,0 +1,128 @@
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ const require_index = require('../../../utils/constants/index.cjs');
3
+ let joi = require("joi");
4
+ joi = require_rolldown_runtime.__toESM(joi);
5
+
6
+ //#region src/api/v1/definition/validations.ts
7
+ const FileValidationSchema = joi.default.object({
8
+ name: joi.default.string().required(),
9
+ type: joi.default.string(),
10
+ size: joi.default.string(),
11
+ addedBy: joi.default.string().uuid()
12
+ });
13
+ const statusValidationObject = joi.default.object({
14
+ value: joi.default.string().required(),
15
+ color: joi.default.string().required()
16
+ });
17
+ const stringOptionsSchema = joi.default.array().required().items(joi.default.string()).min(1).unique();
18
+ const statusOptionsSchema = joi.default.array().required().items(statusValidationObject).min(1).unique("value");
19
+ /**
20
+ * Schema for the validation of custom field definition
21
+ * The only custom validation is for
22
+ * {@link CustomFieldDefinitionType.SELECT SELECT},
23
+ * {@link CustomFieldDefinitionType.MULTI_SELECT_DROPDOWN MULTI_SELECT_DROPDOWN},
24
+ * {@link CustomFieldDefinitionType.STATUS STATUS},
25
+ * and
26
+ * {@link CustomFieldDefinitionType.MULTI_SELECT_STATUS MULTI_SELECT_STATUS}
27
+ * field types.
28
+ * The rest of the field types are validated by Joi
29
+ */
30
+ const ValidationSchema = joi.default.when("fieldType", {
31
+ switch: [
32
+ {
33
+ is: require_index.CustomFieldDefinitionType.SELECT,
34
+ then: stringOptionsSchema
35
+ },
36
+ {
37
+ is: require_index.CustomFieldDefinitionType.MULTI_SELECT_DROPDOWN,
38
+ then: stringOptionsSchema
39
+ },
40
+ {
41
+ is: require_index.CustomFieldDefinitionType.STATUS,
42
+ then: statusOptionsSchema
43
+ },
44
+ {
45
+ is: require_index.CustomFieldDefinitionType.MULTI_SELECT_STATUS,
46
+ then: statusOptionsSchema
47
+ }
48
+ ],
49
+ otherwise: joi.default.forbidden()
50
+ });
51
+ const multiSelectDefaultValueSchema = joi.default.array().items(joi.default.string()).unique().allow(null);
52
+ const DefaultValueSchema = joi.default.when("fieldType", { switch: [
53
+ {
54
+ is: require_index.CustomFieldDefinitionType.BOOLEAN,
55
+ then: joi.default.boolean().allow(null)
56
+ },
57
+ {
58
+ is: require_index.CustomFieldDefinitionType.DATE,
59
+ then: joi.default.date().allow(null)
60
+ },
61
+ {
62
+ is: require_index.CustomFieldDefinitionType.DATETIME,
63
+ then: joi.default.date().allow(null)
64
+ },
65
+ {
66
+ is: require_index.CustomFieldDefinitionType.FILE,
67
+ then: joi.default.array().items(FileValidationSchema).allow(null)
68
+ },
69
+ {
70
+ is: require_index.CustomFieldDefinitionType.IMAGE,
71
+ then: joi.default.array().items(joi.default.string().uri()).allow(null)
72
+ },
73
+ {
74
+ is: require_index.CustomFieldDefinitionType.NUMBER,
75
+ then: joi.default.number().allow(null)
76
+ },
77
+ {
78
+ is: require_index.CustomFieldDefinitionType.SELECT,
79
+ then: joi.default.string().allow(null)
80
+ },
81
+ {
82
+ is: require_index.CustomFieldDefinitionType.STATUS,
83
+ then: joi.default.string().allow(null)
84
+ },
85
+ {
86
+ is: require_index.CustomFieldDefinitionType.TEXT,
87
+ then: joi.default.string().allow(null)
88
+ },
89
+ {
90
+ is: require_index.CustomFieldDefinitionType.MULTI_SELECT_STATUS,
91
+ then: multiSelectDefaultValueSchema
92
+ },
93
+ {
94
+ is: require_index.CustomFieldDefinitionType.MULTI_SELECT_DROPDOWN,
95
+ then: multiSelectDefaultValueSchema
96
+ }
97
+ ] });
98
+ const CustomFieldDefinitionCreationSchema = joi.default.object({
99
+ name: joi.default.string().required(),
100
+ displayName: joi.default.string().required(),
101
+ validation: ValidationSchema,
102
+ defaultValue: DefaultValueSchema,
103
+ fieldType: joi.default.string().valid(...Object.values(require_index.CustomFieldDefinitionType)).required(),
104
+ entityId: joi.default.string().guid().required(),
105
+ entityType: joi.default.string().required(),
106
+ description: joi.default.string(),
107
+ required: joi.default.boolean(),
108
+ disabled: joi.default.boolean(),
109
+ blockEditingFromUI: joi.default.boolean(),
110
+ modelTypeIds: joi.default.array().items(joi.default.string().guid())
111
+ }).oxor("required", "blockEditingFromUI", { isPresent: (value) => value === true });
112
+ const CustomFieldDefinitionUpdateSchema = joi.default.object({
113
+ displayName: joi.default.string(),
114
+ validation: ValidationSchema,
115
+ defaultValue: DefaultValueSchema,
116
+ fieldType: joi.default.string().valid(...Object.values(require_index.CustomFieldDefinitionType)),
117
+ description: joi.default.string().allow(null),
118
+ required: joi.default.boolean(),
119
+ disabled: joi.default.boolean(),
120
+ blockEditingFromUI: joi.default.boolean(),
121
+ modelTypeIds: joi.default.array().items(joi.default.string().guid())
122
+ }).oxor("required", "blockEditingFromUI", { isPresent: (value) => value === true });
123
+ const validateCustomFieldDefinitionCreation = (payload) => CustomFieldDefinitionCreationSchema.validateAsync(payload, { abortEarly: false });
124
+ const validateCustomFieldDefinitionUpdate = (payload) => CustomFieldDefinitionUpdateSchema.validateAsync(payload, { abortEarly: false });
125
+
126
+ //#endregion
127
+ exports.validateCustomFieldDefinitionCreation = validateCustomFieldDefinitionCreation;
128
+ exports.validateCustomFieldDefinitionUpdate = validateCustomFieldDefinitionUpdate;
@@ -0,0 +1,14 @@
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+ let sequelize = require("sequelize");
3
+ let joi = require("joi");
4
+ let _autofleet_errors = require("@autofleet/errors");
5
+
6
+ //#region src/api/v1/errors.ts
7
+ var errors_default = (err, res, additionalData) => {
8
+ let error = err;
9
+ if ([joi.ValidationError, sequelize.ValidationError].some((ErrClass) => err instanceof ErrClass)) error = new _autofleet_errors.BadRequest([err]);
10
+ return (0, _autofleet_errors.handleError)(error, res, additionalData);
11
+ };
12
+
13
+ //#endregion
14
+ exports.default = errors_default;
@@ -0,0 +1,84 @@
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ const require_index = require('../../../utils/logger/index.cjs');
3
+ const require_errors = require('../errors.cjs');
4
+ const require_field_policy = require('../../../repository/field-policy.cjs');
5
+ let sequelize = require("sequelize");
6
+ let _autofleet_node_common = require("@autofleet/node-common");
7
+
8
+ //#region src/api/v1/field-policies/index.ts
9
+ const router = (0, _autofleet_node_common.Router)({ logger: require_index.default });
10
+ router.get("/", async (_req, res) => {
11
+ try {
12
+ const policies = await require_field_policy.findAll();
13
+ res.status(200).json(policies);
14
+ } catch (err) {
15
+ require_errors.default(err, res, {
16
+ logger: require_index.default,
17
+ message: "Error in get field policies request"
18
+ });
19
+ }
20
+ });
21
+ router.post("/", async (req, res) => {
22
+ const { contextId, name, fields, models } = req.body;
23
+ if (!contextId || !name) {
24
+ res.status(400).json({ error: "contextId and name are required" });
25
+ return;
26
+ }
27
+ try {
28
+ const policy = await require_field_policy.create({
29
+ contextId,
30
+ name,
31
+ fields,
32
+ models
33
+ });
34
+ res.status(201).json(policy);
35
+ } catch (err) {
36
+ if (err instanceof sequelize.UniqueConstraintError) {
37
+ res.status(409).json({ error: "A field policy for this contextId and name already exists" });
38
+ return;
39
+ }
40
+ require_errors.default(err, res, {
41
+ logger: require_index.default,
42
+ message: "Error in create field policy request"
43
+ });
44
+ }
45
+ });
46
+ router.put("/:policyId", async (req, res) => {
47
+ const { policyId } = req.params;
48
+ const { fields, models } = req.body;
49
+ try {
50
+ const updated = await require_field_policy.update(policyId, {
51
+ fields,
52
+ models
53
+ });
54
+ if (!updated) {
55
+ res.status(404).json({ error: "Field policy not found" });
56
+ return;
57
+ }
58
+ res.status(200).json(updated);
59
+ } catch (err) {
60
+ require_errors.default(err, res, {
61
+ logger: require_index.default,
62
+ message: "Error in update field policy request"
63
+ });
64
+ }
65
+ });
66
+ router.delete("/:policyId", async (req, res) => {
67
+ const { policyId } = req.params;
68
+ try {
69
+ if (!await require_field_policy.remove(policyId)) {
70
+ res.status(404).json({ error: "Field policy not found" });
71
+ return;
72
+ }
73
+ res.status(204).send();
74
+ } catch (err) {
75
+ require_errors.default(err, res, {
76
+ logger: require_index.default,
77
+ message: "Error in delete field policy request"
78
+ });
79
+ }
80
+ });
81
+ var field_policies_default = router;
82
+
83
+ //#endregion
84
+ exports.default = field_policies_default;
@@ -0,0 +1,83 @@
1
+ import logger_default from "../../../utils/logger/index.js";
2
+ import errors_default from "../errors.js";
3
+ import { create, findAll, remove, update } from "../../../repository/field-policy.js";
4
+ import { UniqueConstraintError } from "sequelize";
5
+ import { Router } from "@autofleet/node-common";
6
+
7
+ //#region src/api/v1/field-policies/index.ts
8
+ const router = Router({ logger: logger_default });
9
+ router.get("/", async (_req, res) => {
10
+ try {
11
+ const policies = await findAll();
12
+ res.status(200).json(policies);
13
+ } catch (err) {
14
+ errors_default(err, res, {
15
+ logger: logger_default,
16
+ message: "Error in get field policies request"
17
+ });
18
+ }
19
+ });
20
+ router.post("/", async (req, res) => {
21
+ const { contextId, name, fields, models } = req.body;
22
+ if (!contextId || !name) {
23
+ res.status(400).json({ error: "contextId and name are required" });
24
+ return;
25
+ }
26
+ try {
27
+ const policy = await create({
28
+ contextId,
29
+ name,
30
+ fields,
31
+ models
32
+ });
33
+ res.status(201).json(policy);
34
+ } catch (err) {
35
+ if (err instanceof UniqueConstraintError) {
36
+ res.status(409).json({ error: "A field policy for this contextId and name already exists" });
37
+ return;
38
+ }
39
+ errors_default(err, res, {
40
+ logger: logger_default,
41
+ message: "Error in create field policy request"
42
+ });
43
+ }
44
+ });
45
+ router.put("/:policyId", async (req, res) => {
46
+ const { policyId } = req.params;
47
+ const { fields, models } = req.body;
48
+ try {
49
+ const updated = await update(policyId, {
50
+ fields,
51
+ models
52
+ });
53
+ if (!updated) {
54
+ res.status(404).json({ error: "Field policy not found" });
55
+ return;
56
+ }
57
+ res.status(200).json(updated);
58
+ } catch (err) {
59
+ errors_default(err, res, {
60
+ logger: logger_default,
61
+ message: "Error in update field policy request"
62
+ });
63
+ }
64
+ });
65
+ router.delete("/:policyId", async (req, res) => {
66
+ const { policyId } = req.params;
67
+ try {
68
+ if (!await remove(policyId)) {
69
+ res.status(404).json({ error: "Field policy not found" });
70
+ return;
71
+ }
72
+ res.status(204).send();
73
+ } catch (err) {
74
+ errors_default(err, res, {
75
+ logger: logger_default,
76
+ message: "Error in delete field policy request"
77
+ });
78
+ }
79
+ });
80
+ var field_policies_default = router;
81
+
82
+ //#endregion
83
+ export { field_policies_default as default };
@@ -0,0 +1,16 @@
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+ const require_index = require('../../utils/logger/index.cjs');
3
+ const require_index$1 = require('./definition/index.cjs');
4
+ const require_index$2 = require('./validator/index.cjs');
5
+ const require_index$3 = require('./field-policies/index.cjs');
6
+ let _autofleet_node_common = require("@autofleet/node-common");
7
+
8
+ //#region src/api/v1/index.ts
9
+ const router = (0, _autofleet_node_common.Router)({ logger: require_index.default });
10
+ router.use("/custom-field-definitions/:modelName", require_index$1.default);
11
+ router.use("/custom-validators/:modelName", require_index$2.default);
12
+ router.use("/field-policies/:modelName", require_index$3.default);
13
+ var v1_default = router;
14
+
15
+ //#endregion
16
+ exports.default = v1_default;
@@ -1,14 +1,14 @@
1
1
  import logger_default from "../../utils/logger/index.js";
2
2
  import definition_default from "./definition/index.js";
3
3
  import validator_default from "./validator/index.js";
4
- import templates_default from "./templates/index.js";
4
+ import field_policies_default from "./field-policies/index.js";
5
5
  import { Router } from "@autofleet/node-common";
6
6
 
7
7
  //#region src/api/v1/index.ts
8
8
  const router = Router({ logger: logger_default });
9
9
  router.use("/custom-field-definitions/:modelName", definition_default);
10
10
  router.use("/custom-validators/:modelName", validator_default);
11
- router.use("/templates", templates_default);
11
+ router.use("/field-policies/:modelName", field_policies_default);
12
12
  var v1_default = router;
13
13
 
14
14
  //#endregion
@@ -0,0 +1,115 @@
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ const require_index = require('../../../utils/logger/index.cjs');
3
+ const require_errors = require('../errors.cjs');
4
+ const require_mat_path_state = require('../../../mat-path-state.cjs');
5
+ const require_validator = require('../../../repository/validator.cjs');
6
+ const require_validations = require('./validations.cjs');
7
+ const require_validator_schema = require('../../../utils/validations/schema/validator-schema.cjs');
8
+ let _autofleet_errors = require("@autofleet/errors");
9
+ let _autofleet_node_common = require("@autofleet/node-common");
10
+ let http_status_codes = require("http-status-codes");
11
+
12
+ //#region src/api/v1/validator/index.ts
13
+ const router = (0, _autofleet_node_common.Router)({ logger: require_index.default });
14
+ const ENTITY = "CustomValidator";
15
+ /**
16
+ * Create
17
+ */
18
+ router.post("/", async (req, res) => {
19
+ const { modelName } = req.params;
20
+ try {
21
+ const validatedPayload = await require_validations.default.create.validateAsync(req.body);
22
+ require_validator_schema.validateValidatorSchema(validatedPayload.schema);
23
+ const validator = await require_validator.create({
24
+ ...validatedPayload,
25
+ modelType: modelName
26
+ });
27
+ return res.status(http_status_codes.StatusCodes.CREATED).json(validator);
28
+ } catch (err) {
29
+ return require_errors.default(err, res, {
30
+ logger: require_index.default,
31
+ message: `Error in create ${ENTITY} request`
32
+ });
33
+ }
34
+ });
35
+ /**
36
+ * Get all
37
+ */
38
+ router.get("/", async (req, res) => {
39
+ try {
40
+ const { modelName } = req.params;
41
+ const { entityId, entityType } = req.query;
42
+ const applyEntityFilters = !require_mat_path_state.matPathState.isMatPathEnabled?.();
43
+ const where = {
44
+ modelType: modelName,
45
+ ...applyEntityFilters && entityId && { entityId },
46
+ ...applyEntityFilters && entityType && { entityType }
47
+ };
48
+ const validators = await require_validator.findAll(where);
49
+ return res.status(http_status_codes.StatusCodes.OK).json({ validators });
50
+ } catch (err) {
51
+ return require_errors.default(err, res, {
52
+ logger: require_index.default,
53
+ message: `Error in get all ${ENTITY} request`
54
+ });
55
+ }
56
+ });
57
+ /**
58
+ * Get by id
59
+ */
60
+ router.get("/:validatorId", async (req, res) => {
61
+ try {
62
+ const { validatorId, modelName } = req.params;
63
+ const validators = await require_validator.findAll({
64
+ id: validatorId,
65
+ modelType: modelName
66
+ }, { withDisabled: true });
67
+ if (!validators.length) throw new _autofleet_errors.ResourceNotFoundError("Validator not found");
68
+ return res.status(http_status_codes.StatusCodes.OK).json(validators[0]);
69
+ } catch (err) {
70
+ return require_errors.default(err, res, {
71
+ logger: require_index.default,
72
+ message: `Error in get ${ENTITY} request`
73
+ });
74
+ }
75
+ });
76
+ /**
77
+ * Update
78
+ */
79
+ router.patch("/:validatorId", async (req, res) => {
80
+ try {
81
+ const { validatorId } = req.params;
82
+ const validatedPayload = await require_validations.default.update.validateAsync(req.body);
83
+ if (validatedPayload.schema) require_validator_schema.validateValidatorSchema(validatedPayload.schema);
84
+ if (!(await require_validator.findAll({ id: validatorId }, { withDisabled: true })).length) throw new _autofleet_errors.ResourceNotFoundError("Validator not found");
85
+ const [count, validators] = await require_validator.update(validatorId, validatedPayload);
86
+ if (!count) throw new _autofleet_errors.ResourceNotFoundError("Validator not found");
87
+ return res.status(http_status_codes.StatusCodes.OK).json(validators[0]);
88
+ } catch (err) {
89
+ return require_errors.default(err, res, {
90
+ logger: require_index.default,
91
+ message: `Error in update ${ENTITY} request`
92
+ });
93
+ }
94
+ });
95
+ /**
96
+ * Delete (disable)
97
+ */
98
+ router.delete("/:validatorId", async (req, res) => {
99
+ try {
100
+ const { validatorId } = req.params;
101
+ if (!(await require_validator.findAll({ id: validatorId }, { withDisabled: true })).length) throw new _autofleet_errors.ResourceNotFoundError("Validator not found");
102
+ const [count] = await require_validator.disable(validatorId);
103
+ if (!count) throw new _autofleet_errors.ResourceNotFoundError("Validator failed to be disabled");
104
+ return res.status(http_status_codes.StatusCodes.NO_CONTENT).send();
105
+ } catch (err) {
106
+ return require_errors.default(err, res, {
107
+ logger: require_index.default,
108
+ message: `Error in delete ${ENTITY} request`
109
+ });
110
+ }
111
+ });
112
+ var validator_default = router;
113
+
114
+ //#endregion
115
+ exports.default = validator_default;