@etohq/utils 1.3.0 → 1.5.0

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 (344) hide show
  1. package/LICENSE +21 -0
  2. package/dist/analytics/abstract-analytics-provider.d.ts +110 -0
  3. package/dist/analytics/abstract-analytics-provider.d.ts.map +1 -0
  4. package/dist/analytics/abstract-analytics-provider.js +107 -0
  5. package/dist/analytics/abstract-analytics-provider.js.map +1 -0
  6. package/dist/analytics/index.d.ts +2 -0
  7. package/dist/analytics/index.d.ts.map +1 -0
  8. package/dist/analytics/index.js +18 -0
  9. package/dist/analytics/index.js.map +1 -0
  10. package/dist/auth/token.d.ts +5 -3
  11. package/dist/auth/token.d.ts.map +1 -1
  12. package/dist/auth/token.js +5 -2
  13. package/dist/auth/token.js.map +1 -1
  14. package/dist/bundles.d.ts +1 -0
  15. package/dist/bundles.d.ts.map +1 -1
  16. package/dist/bundles.js +2 -1
  17. package/dist/bundles.js.map +1 -1
  18. package/dist/common/api-error.d.ts +205 -0
  19. package/dist/common/api-error.d.ts.map +1 -0
  20. package/dist/common/api-error.js +274 -0
  21. package/dist/common/api-error.js.map +1 -0
  22. package/dist/common/build-query.d.ts +1 -1
  23. package/dist/common/build-query.d.ts.map +1 -1
  24. package/dist/common/compress-name.d.ts +2 -0
  25. package/dist/common/compress-name.d.ts.map +1 -0
  26. package/dist/common/compress-name.js +34 -0
  27. package/dist/common/compress-name.js.map +1 -0
  28. package/dist/common/container.d.ts +98 -0
  29. package/dist/common/container.d.ts.map +1 -1
  30. package/dist/common/container.js +94 -0
  31. package/dist/common/container.js.map +1 -1
  32. package/dist/common/create-psql-index-helper.d.ts +1 -1
  33. package/dist/common/define-config.d.ts +4 -4
  34. package/dist/common/define-config.d.ts.map +1 -1
  35. package/dist/common/define-config.js +45 -26
  36. package/dist/common/define-config.js.map +1 -1
  37. package/dist/common/errors.d.ts +6 -4
  38. package/dist/common/errors.d.ts.map +1 -1
  39. package/dist/common/errors.js +25 -5
  40. package/dist/common/errors.js.map +1 -1
  41. package/dist/common/exec-mode.d.ts +2 -0
  42. package/dist/common/exec-mode.d.ts.map +1 -0
  43. package/dist/common/exec-mode.js +15 -0
  44. package/dist/common/exec-mode.js.map +1 -0
  45. package/dist/common/flatten-object-to-key-value-pairs.d.ts.map +1 -1
  46. package/dist/common/flatten-object-to-key-value-pairs.js +214 -72
  47. package/dist/common/flatten-object-to-key-value-pairs.js.map +1 -1
  48. package/dist/common/get-resolved-plugins.d.ts +4 -0
  49. package/dist/common/get-resolved-plugins.d.ts.map +1 -0
  50. package/dist/common/get-resolved-plugins.js +121 -0
  51. package/dist/common/get-resolved-plugins.js.map +1 -0
  52. package/dist/common/get-selects-and-relations-from-object-array.d.ts +2 -1
  53. package/dist/common/get-selects-and-relations-from-object-array.d.ts.map +1 -1
  54. package/dist/common/get-selects-and-relations-from-object-array.js +7 -5
  55. package/dist/common/get-selects-and-relations-from-object-array.js.map +1 -1
  56. package/dist/common/index.d.ts +19 -5
  57. package/dist/common/index.d.ts.map +1 -1
  58. package/dist/common/index.js +19 -5
  59. package/dist/common/index.js.map +1 -1
  60. package/dist/common/load-env.d.ts +3 -0
  61. package/dist/common/load-env.d.ts.map +1 -1
  62. package/dist/common/load-env.js +7 -4
  63. package/dist/common/load-env.js.map +1 -1
  64. package/dist/common/math.d.ts +2 -2
  65. package/dist/common/math.d.ts.map +1 -1
  66. package/dist/common/math.js +13 -6
  67. package/dist/common/math.js.map +1 -1
  68. package/dist/common/merge-metadata.d.ts +15 -0
  69. package/dist/common/merge-metadata.d.ts.map +1 -0
  70. package/dist/common/merge-metadata.js +34 -0
  71. package/dist/common/merge-metadata.js.map +1 -0
  72. package/dist/common/normalize-csv-value.d.ts +6 -0
  73. package/dist/common/normalize-csv-value.d.ts.map +1 -0
  74. package/dist/common/normalize-csv-value.js +14 -0
  75. package/dist/common/normalize-csv-value.js.map +1 -0
  76. package/dist/common/retry-execution.d.ts +18 -0
  77. package/dist/common/retry-execution.d.ts.map +1 -0
  78. package/dist/common/retry-execution.js +50 -0
  79. package/dist/common/retry-execution.js.map +1 -0
  80. package/dist/common/to-unix-slash.d.ts +2 -0
  81. package/dist/common/to-unix-slash.d.ts.map +1 -0
  82. package/dist/common/to-unix-slash.js +11 -0
  83. package/dist/common/to-unix-slash.js.map +1 -0
  84. package/dist/common/try-convert-to-boolean.d.ts +7 -0
  85. package/dist/common/try-convert-to-boolean.d.ts.map +1 -0
  86. package/dist/common/try-convert-to-boolean.js +15 -0
  87. package/dist/common/try-convert-to-boolean.js.map +1 -0
  88. package/dist/common/try-convert-to-number.d.ts +7 -0
  89. package/dist/common/try-convert-to-number.d.ts.map +1 -0
  90. package/dist/common/try-convert-to-number.js +10 -0
  91. package/dist/common/try-convert-to-number.js.map +1 -0
  92. package/dist/common/unflatten-object-keys.d.ts +29 -0
  93. package/dist/common/unflatten-object-keys.d.ts.map +1 -0
  94. package/dist/common/unflatten-object-keys.js +67 -0
  95. package/dist/common/unflatten-object-keys.js.map +1 -0
  96. package/dist/common/validate-module-name.d.ts +2 -0
  97. package/dist/common/validate-module-name.d.ts.map +1 -0
  98. package/dist/common/validate-module-name.js +27 -0
  99. package/dist/common/validate-module-name.js.map +1 -0
  100. package/dist/common/wrap-handler.d.ts +2 -0
  101. package/dist/common/wrap-handler.d.ts.map +1 -0
  102. package/dist/common/wrap-handler.js +40 -0
  103. package/dist/common/wrap-handler.js.map +1 -0
  104. package/dist/core-flows/events.d.ts +57 -0
  105. package/dist/core-flows/events.d.ts.map +1 -1
  106. package/dist/core-flows/events.js +58 -8
  107. package/dist/core-flows/events.js.map +1 -1
  108. package/dist/dal/index.d.ts +1 -0
  109. package/dist/dal/index.d.ts.map +1 -1
  110. package/dist/dal/index.js +1 -0
  111. package/dist/dal/index.js.map +1 -1
  112. package/dist/dal/mikro-orm/big-number-field.d.ts.map +1 -1
  113. package/dist/dal/mikro-orm/big-number-field.js +36 -21
  114. package/dist/dal/mikro-orm/big-number-field.js.map +1 -1
  115. package/dist/dal/mikro-orm/mikro-orm-create-connection.d.ts +10 -4
  116. package/dist/dal/mikro-orm/mikro-orm-create-connection.d.ts.map +1 -1
  117. package/dist/dal/mikro-orm/mikro-orm-create-connection.js +53 -11
  118. package/dist/dal/mikro-orm/mikro-orm-create-connection.js.map +1 -1
  119. package/dist/dal/mikro-orm/mikro-orm-free-text-search-filter.d.ts +3 -6
  120. package/dist/dal/mikro-orm/mikro-orm-free-text-search-filter.d.ts.map +1 -1
  121. package/dist/dal/mikro-orm/mikro-orm-free-text-search-filter.js +16 -21
  122. package/dist/dal/mikro-orm/mikro-orm-free-text-search-filter.js.map +1 -1
  123. package/dist/dal/mikro-orm/mikro-orm-repository.d.ts +4 -7
  124. package/dist/dal/mikro-orm/mikro-orm-repository.d.ts.map +1 -1
  125. package/dist/dal/mikro-orm/mikro-orm-repository.js +94 -79
  126. package/dist/dal/mikro-orm/mikro-orm-repository.js.map +1 -1
  127. package/dist/dal/mikro-orm/mikro-orm-serializer.d.ts +7 -3
  128. package/dist/dal/mikro-orm/mikro-orm-serializer.d.ts.map +1 -1
  129. package/dist/dal/mikro-orm/mikro-orm-serializer.js +18 -15
  130. package/dist/dal/mikro-orm/mikro-orm-serializer.js.map +1 -1
  131. package/dist/dal/mikro-orm/sql-migration-generator.d.ts +6 -4
  132. package/dist/dal/mikro-orm/sql-migration-generator.d.ts.map +1 -1
  133. package/dist/dal/mikro-orm/sql-migration-generator.js +120 -70
  134. package/dist/dal/mikro-orm/sql-migration-generator.js.map +1 -1
  135. package/dist/dal/mikro-orm/utils.d.ts +14 -1
  136. package/dist/dal/mikro-orm/utils.d.ts.map +1 -1
  137. package/dist/dal/mikro-orm/utils.js +82 -38
  138. package/dist/dal/mikro-orm/utils.js.map +1 -1
  139. package/dist/defaults/countries.d.ts.map +1 -1
  140. package/dist/defaults/countries.js +0 -6
  141. package/dist/defaults/countries.js.map +1 -1
  142. package/dist/defaults/currencies.d.ts.map +1 -1
  143. package/dist/defaults/currencies.js +9 -0
  144. package/dist/defaults/currencies.js.map +1 -1
  145. package/dist/dml/entity-builder.d.ts.map +1 -1
  146. package/dist/dml/entity-builder.js.map +1 -1
  147. package/dist/dml/entity.d.ts +4 -5
  148. package/dist/dml/entity.d.ts.map +1 -1
  149. package/dist/dml/entity.js +0 -2
  150. package/dist/dml/entity.js.map +1 -1
  151. package/dist/dml/helpers/create-graphql.d.ts.map +1 -1
  152. package/dist/dml/helpers/create-graphql.js +27 -2
  153. package/dist/dml/helpers/create-graphql.js.map +1 -1
  154. package/dist/dml/helpers/create-mikro-orm-entity.d.ts.map +1 -1
  155. package/dist/dml/helpers/create-mikro-orm-entity.js +9 -6
  156. package/dist/dml/helpers/create-mikro-orm-entity.js.map +1 -1
  157. package/dist/dml/helpers/entity-builder/define-property.d.ts.map +1 -1
  158. package/dist/dml/helpers/entity-builder/define-property.js +9 -7
  159. package/dist/dml/helpers/entity-builder/define-property.js.map +1 -1
  160. package/dist/dml/helpers/entity-builder/define-relationship.d.ts +1 -1
  161. package/dist/dml/helpers/entity-builder/define-relationship.d.ts.map +1 -1
  162. package/dist/dml/helpers/entity-builder/define-relationship.js +41 -25
  163. package/dist/dml/helpers/entity-builder/define-relationship.js.map +1 -1
  164. package/dist/dml/helpers/entity-builder/index.d.ts +1 -0
  165. package/dist/dml/helpers/entity-builder/index.d.ts.map +1 -1
  166. package/dist/dml/helpers/entity-builder/index.js +1 -0
  167. package/dist/dml/helpers/entity-builder/index.js.map +1 -1
  168. package/dist/dml/helpers/entity-builder/relationship-helpers.d.ts +6 -0
  169. package/dist/dml/helpers/entity-builder/relationship-helpers.d.ts.map +1 -0
  170. package/dist/dml/helpers/entity-builder/relationship-helpers.js +12 -0
  171. package/dist/dml/helpers/entity-builder/relationship-helpers.js.map +1 -0
  172. package/dist/dml/helpers/graphql-builder/get-attribute.js +2 -2
  173. package/dist/dml/helpers/graphql-builder/get-attribute.js.map +1 -1
  174. package/dist/dml/index.d.ts +1 -1
  175. package/dist/dml/index.d.ts.map +1 -1
  176. package/dist/dml/index.js +1 -1
  177. package/dist/dml/index.js.map +1 -1
  178. package/dist/dml/integration-tests/utils.js +1 -1
  179. package/dist/dml/integration-tests/utils.js.map +1 -1
  180. package/dist/dml/properties/autoincrement.d.ts +20 -1
  181. package/dist/dml/properties/autoincrement.d.ts.map +1 -1
  182. package/dist/dml/properties/autoincrement.js +19 -0
  183. package/dist/dml/properties/autoincrement.js.map +1 -1
  184. package/dist/dml/properties/number.d.ts +20 -1
  185. package/dist/dml/properties/number.d.ts.map +1 -1
  186. package/dist/dml/properties/number.js +19 -0
  187. package/dist/dml/properties/number.js.map +1 -1
  188. package/dist/event-bus/index.d.ts +1 -1
  189. package/dist/event-bus/index.d.ts.map +1 -1
  190. package/dist/event-bus/index.js +5 -6
  191. package/dist/event-bus/index.js.map +1 -1
  192. package/dist/event-bus/message-aggregator.js +1 -1
  193. package/dist/event-bus/message-aggregator.js.map +1 -1
  194. package/dist/feature-flags/eto-v2.d.ts +3 -0
  195. package/dist/feature-flags/eto-v2.d.ts.map +1 -0
  196. package/dist/feature-flags/eto-v2.js +10 -0
  197. package/dist/feature-flags/eto-v2.js.map +1 -0
  198. package/dist/feature-flags/many-to-many-inventory.d.ts +3 -0
  199. package/dist/feature-flags/many-to-many-inventory.d.ts.map +1 -0
  200. package/dist/feature-flags/many-to-many-inventory.js +10 -0
  201. package/dist/feature-flags/many-to-many-inventory.js.map +1 -0
  202. package/dist/feature-flags/order-editing.d.ts +3 -0
  203. package/dist/feature-flags/order-editing.d.ts.map +1 -0
  204. package/dist/feature-flags/order-editing.js +10 -0
  205. package/dist/feature-flags/order-editing.js.map +1 -0
  206. package/dist/feature-flags/product-categories.d.ts +3 -0
  207. package/dist/feature-flags/product-categories.d.ts.map +1 -0
  208. package/dist/feature-flags/product-categories.js +10 -0
  209. package/dist/feature-flags/product-categories.js.map +1 -0
  210. package/dist/feature-flags/sales-channels.d.ts +3 -0
  211. package/dist/feature-flags/sales-channels.d.ts.map +1 -0
  212. package/dist/feature-flags/sales-channels.js +10 -0
  213. package/dist/feature-flags/sales-channels.js.map +1 -0
  214. package/dist/feature-flags/tax-inclusive-pricing.d.ts +3 -0
  215. package/dist/feature-flags/tax-inclusive-pricing.d.ts.map +1 -0
  216. package/dist/feature-flags/tax-inclusive-pricing.js +10 -0
  217. package/dist/feature-flags/tax-inclusive-pricing.js.map +1 -0
  218. package/dist/file/abstract-file-provider.d.ts +70 -11
  219. package/dist/file/abstract-file-provider.d.ts.map +1 -1
  220. package/dist/file/abstract-file-provider.js +73 -11
  221. package/dist/file/abstract-file-provider.js.map +1 -1
  222. package/dist/graphql/graphql-to-ts-types.d.ts.map +1 -1
  223. package/dist/graphql/graphql-to-ts-types.js +23 -2
  224. package/dist/graphql/graphql-to-ts-types.js.map +1 -1
  225. package/dist/index.d.ts +1 -0
  226. package/dist/index.d.ts.map +1 -1
  227. package/dist/index.js +1 -0
  228. package/dist/index.js.map +1 -1
  229. package/dist/migrations/index.d.ts +8 -0
  230. package/dist/migrations/index.d.ts.map +1 -1
  231. package/dist/migrations/index.js +27 -2
  232. package/dist/migrations/index.js.map +1 -1
  233. package/dist/modules-sdk/build-query.d.ts.map +1 -1
  234. package/dist/modules-sdk/build-query.js +14 -13
  235. package/dist/modules-sdk/build-query.js.map +1 -1
  236. package/dist/modules-sdk/create-pg-connection.d.ts +2 -1
  237. package/dist/modules-sdk/create-pg-connection.d.ts.map +1 -1
  238. package/dist/modules-sdk/create-pg-connection.js +1 -1
  239. package/dist/modules-sdk/decorators/inject-manager.d.ts.map +1 -1
  240. package/dist/modules-sdk/decorators/inject-manager.js +6 -0
  241. package/dist/modules-sdk/decorators/inject-manager.js.map +1 -1
  242. package/dist/modules-sdk/decorators/inject-transaction-manager.js +5 -5
  243. package/dist/modules-sdk/decorators/inject-transaction-manager.js.map +1 -1
  244. package/dist/modules-sdk/define-link.d.ts +2 -0
  245. package/dist/modules-sdk/define-link.d.ts.map +1 -1
  246. package/dist/modules-sdk/define-link.js +16 -0
  247. package/dist/modules-sdk/define-link.js.map +1 -1
  248. package/dist/modules-sdk/definition.d.ts +9 -0
  249. package/dist/modules-sdk/definition.d.ts.map +1 -1
  250. package/dist/modules-sdk/definition.js +5 -2
  251. package/dist/modules-sdk/definition.js.map +1 -1
  252. package/dist/modules-sdk/eto-internal-service.d.ts.map +1 -1
  253. package/dist/modules-sdk/eto-internal-service.js +35 -37
  254. package/dist/modules-sdk/eto-internal-service.js.map +1 -1
  255. package/dist/modules-sdk/eto-service.d.ts.map +1 -1
  256. package/dist/modules-sdk/eto-service.js +25 -41
  257. package/dist/modules-sdk/eto-service.js.map +1 -1
  258. package/dist/modules-sdk/event-builder-factory.js +9 -9
  259. package/dist/modules-sdk/event-builder-factory.js.map +1 -1
  260. package/dist/modules-sdk/joiner-config-builder.js +1 -1
  261. package/dist/modules-sdk/joiner-config-builder.js.map +1 -1
  262. package/dist/modules-sdk/load-module-database-config.d.ts.map +1 -1
  263. package/dist/modules-sdk/load-module-database-config.js +3 -0
  264. package/dist/modules-sdk/load-module-database-config.js.map +1 -1
  265. package/dist/modules-sdk/loaders/mikro-orm-connection-loader.d.ts.map +1 -1
  266. package/dist/modules-sdk/loaders/mikro-orm-connection-loader.js +0 -7
  267. package/dist/modules-sdk/loaders/mikro-orm-connection-loader.js.map +1 -1
  268. package/dist/modules-sdk/migration-scripts/index.d.ts +1 -0
  269. package/dist/modules-sdk/migration-scripts/index.d.ts.map +1 -1
  270. package/dist/modules-sdk/migration-scripts/index.js +1 -0
  271. package/dist/modules-sdk/migration-scripts/index.js.map +1 -1
  272. package/dist/modules-sdk/migration-scripts/migration-down.js +2 -2
  273. package/dist/modules-sdk/migration-scripts/migration-down.js.map +1 -1
  274. package/dist/modules-sdk/migration-scripts/migration-generate.d.ts.map +1 -1
  275. package/dist/modules-sdk/migration-scripts/migration-generate.js +7 -3
  276. package/dist/modules-sdk/migration-scripts/migration-generate.js.map +1 -1
  277. package/dist/modules-sdk/migration-scripts/migration-up.js +2 -2
  278. package/dist/modules-sdk/migration-scripts/migration-up.js.map +1 -1
  279. package/dist/modules-sdk/migration-scripts/service-migration-generate.d.ts +7 -0
  280. package/dist/modules-sdk/migration-scripts/service-migration-generate.d.ts.map +1 -0
  281. package/dist/modules-sdk/migration-scripts/service-migration-generate.js +49 -0
  282. package/dist/modules-sdk/migration-scripts/service-migration-generate.js.map +1 -0
  283. package/dist/modules-sdk/mikro-orm-cli-config-builder.d.ts +0 -1
  284. package/dist/modules-sdk/mikro-orm-cli-config-builder.d.ts.map +1 -1
  285. package/dist/modules-sdk/mikro-orm-cli-config-builder.js +7 -6
  286. package/dist/modules-sdk/mikro-orm-cli-config-builder.js.map +1 -1
  287. package/dist/modules-sdk/module.d.ts.map +1 -1
  288. package/dist/modules-sdk/module.js +12 -14
  289. package/dist/modules-sdk/module.js.map +1 -1
  290. package/dist/modules-sdk/modules-to-container-types.d.ts.map +1 -1
  291. package/dist/modules-sdk/modules-to-container-types.js +30 -3
  292. package/dist/modules-sdk/modules-to-container-types.js.map +1 -1
  293. package/dist/modules-sdk/query-context.d.ts +2 -2
  294. package/dist/modules-sdk/query-context.d.ts.map +1 -1
  295. package/dist/modules-sdk/query-context.js.map +1 -1
  296. package/dist/modules-sdk/types/eto-service.d.ts +34 -10
  297. package/dist/modules-sdk/types/eto-service.d.ts.map +1 -1
  298. package/dist/notification/abstract-notification-provider.d.ts +10 -0
  299. package/dist/notification/abstract-notification-provider.d.ts.map +1 -1
  300. package/dist/notification/abstract-notification-provider.js.map +1 -1
  301. package/dist/payment/abstract-payment-provider.d.ts +253 -263
  302. package/dist/payment/abstract-payment-provider.d.ts.map +1 -1
  303. package/dist/payment/abstract-payment-provider.js +7 -15
  304. package/dist/payment/abstract-payment-provider.js.map +1 -1
  305. package/dist/payment/index.d.ts +0 -2
  306. package/dist/payment/index.d.ts.map +1 -1
  307. package/dist/payment/index.js +0 -2
  308. package/dist/payment/index.js.map +1 -1
  309. package/dist/payment/payment-collection.d.ts +13 -1
  310. package/dist/payment/payment-collection.d.ts.map +1 -1
  311. package/dist/payment/payment-collection.js +12 -0
  312. package/dist/payment/payment-collection.js.map +1 -1
  313. package/dist/payment/webhook.d.ts +13 -1
  314. package/dist/payment/webhook.d.ts.map +1 -1
  315. package/dist/payment/webhook.js +13 -1
  316. package/dist/payment/webhook.js.map +1 -1
  317. package/dist/pg/index.d.ts +1 -1
  318. package/dist/pg/index.d.ts.map +1 -1
  319. package/dist/totals/big-number.d.ts +23 -0
  320. package/dist/totals/big-number.d.ts.map +1 -0
  321. package/dist/totals/big-number.js +115 -0
  322. package/dist/totals/big-number.js.map +1 -0
  323. package/dist/totals/create-raw-properties-from-bignumber.d.ts +5 -0
  324. package/dist/totals/create-raw-properties-from-bignumber.d.ts.map +1 -0
  325. package/dist/totals/create-raw-properties-from-bignumber.js +52 -0
  326. package/dist/totals/create-raw-properties-from-bignumber.js.map +1 -0
  327. package/dist/totals/index.d.ts +6 -0
  328. package/dist/totals/index.d.ts.map +1 -0
  329. package/dist/totals/index.js +22 -0
  330. package/dist/totals/index.js.map +1 -0
  331. package/dist/totals/math.d.ts +24 -0
  332. package/dist/totals/math.d.ts.map +1 -0
  333. package/dist/totals/math.js +106 -0
  334. package/dist/totals/math.js.map +1 -0
  335. package/dist/totals/transform-properties-to-bignumber.d.ts +6 -0
  336. package/dist/totals/transform-properties-to-bignumber.d.ts.map +1 -0
  337. package/dist/totals/transform-properties-to-bignumber.js +40 -0
  338. package/dist/totals/transform-properties-to-bignumber.js.map +1 -0
  339. package/dist/tsconfig.tsbuildinfo +1 -1
  340. package/package.json +41 -38
  341. package/dist/payment/get-smallest-unit.d.ts +0 -17
  342. package/dist/payment/get-smallest-unit.d.ts.map +0 -1
  343. package/dist/payment/get-smallest-unit.js +0 -68
  344. package/dist/payment/get-smallest-unit.js.map +0 -1
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Retry the function to be executed until it succeeds or the max retries is reached.
3
+ *
4
+ * @param fn - The function to be executed.
5
+ * @param options - The options for the retry execution.
6
+ * @param options.shouldRetry - The function to determine if the function should be retried based on the error argument.
7
+ * @param options.maxRetries - The maximum number of retries.
8
+ * @param options.retryDelay - The delay between retries. If a function is provided, it will be called with the current retry count and the maximum number of retries and should return the delay in milliseconds.
9
+ * @param options.onRetry - The function to be called when the function fails to execute.
10
+ * @returns The result of the function.
11
+ */
12
+ export declare function retryExecution<T>(fn: () => Promise<T>, options?: {
13
+ shouldRetry?: (error: any) => boolean;
14
+ onRetry?: (error: any) => void;
15
+ maxRetries?: number;
16
+ retryDelay?: number | ((retries: number, maxRetries: number) => number);
17
+ }): Promise<T>;
18
+ //# sourceMappingURL=retry-execution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry-execution.d.ts","sourceRoot":"","sources":["../../src/common/retry-execution.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAAC,CAAC,EACpC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,GAAE;IACP,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAA;IACrC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAA;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC,CAAA;CAMxE,GACA,OAAO,CAAC,CAAC,CAAC,CAgCZ"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.retryExecution = retryExecution;
4
+ const promises_1 = require("timers/promises");
5
+ const ONE_SECOND = 1000;
6
+ /**
7
+ * Retry the function to be executed until it succeeds or the max retries is reached.
8
+ *
9
+ * @param fn - The function to be executed.
10
+ * @param options - The options for the retry execution.
11
+ * @param options.shouldRetry - The function to determine if the function should be retried based on the error argument.
12
+ * @param options.maxRetries - The maximum number of retries.
13
+ * @param options.retryDelay - The delay between retries. If a function is provided, it will be called with the current retry count and the maximum number of retries and should return the delay in milliseconds.
14
+ * @param options.onRetry - The function to be called when the function fails to execute.
15
+ * @returns The result of the function.
16
+ */
17
+ async function retryExecution(fn, options = {
18
+ shouldRetry: () => true,
19
+ onRetry: () => { },
20
+ maxRetries: 5,
21
+ retryDelay: ONE_SECOND,
22
+ }) {
23
+ let { shouldRetry, onRetry, maxRetries, retryDelay } = options;
24
+ shouldRetry = shouldRetry ?? (() => true);
25
+ maxRetries = maxRetries ?? 5;
26
+ onRetry = onRetry ?? (() => { });
27
+ const retryDelayFn = typeof retryDelay === "function"
28
+ ? retryDelay
29
+ : (retries, maxRetries) => retryDelay;
30
+ let retries = 0;
31
+ while (retries < maxRetries) {
32
+ try {
33
+ return await fn();
34
+ }
35
+ catch (error) {
36
+ if (!shouldRetry(error)) {
37
+ throw error;
38
+ }
39
+ retries++;
40
+ if (retries === maxRetries) {
41
+ throw error;
42
+ }
43
+ onRetry(error);
44
+ await (0, promises_1.setTimeout)(retryDelayFn(retries, maxRetries));
45
+ }
46
+ }
47
+ // This should never be reached
48
+ throw new Error("Retry execution failed. Max retries reached.");
49
+ }
50
+ //# sourceMappingURL=retry-execution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry-execution.js","sourceRoot":"","sources":["../../src/common/retry-execution.ts"],"names":[],"mappings":";;AAeA,wCA6CC;AA5DD,8CAA4C;AAE5C,MAAM,UAAU,GAAG,IAAI,CAAA;AAEvB;;;;;;;;;;GAUG;AACI,KAAK,UAAU,cAAc,CAClC,EAAoB,EACpB,UAKI;IACF,WAAW,EAAE,GAAG,EAAE,CAAC,IAAI;IACvB,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;IACjB,UAAU,EAAE,CAAC;IACb,UAAU,EAAE,UAAU;CACvB;IAED,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,OAAO,CAAA;IAC9D,WAAW,GAAG,WAAW,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAA;IACzC,UAAU,GAAG,UAAU,IAAI,CAAC,CAAA;IAC5B,OAAO,GAAG,OAAO,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;IAE/B,MAAM,YAAY,GAChB,OAAO,UAAU,KAAK,UAAU;QAC9B,CAAC,CAAC,UAAU;QACZ,CAAC,CAAC,CAAC,OAAe,EAAE,UAAkB,EAAE,EAAE,CAAC,UAAU,CAAA;IAEzD,IAAI,OAAO,GAAG,CAAC,CAAA;IACf,OAAO,OAAO,GAAG,UAAU,EAAE,CAAC;QAC5B,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,EAAE,CAAA;QACnB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,WAAW,CAAC,KAAc,CAAC,EAAE,CAAC;gBACjC,MAAM,KAAK,CAAA;YACb,CAAC;YACD,OAAO,EAAE,CAAA;YACT,IAAI,OAAO,KAAK,UAAU,EAAE,CAAC;gBAC3B,MAAM,KAAK,CAAA;YACb,CAAC;YAED,OAAO,CAAC,KAAK,CAAC,CAAA;YAEd,MAAM,IAAA,qBAAU,EAAC,YAAY,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAA;QACrD,CAAC;IACH,CAAC;IAED,+BAA+B;IAC/B,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAA;AACjE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function toUnixSlash(path: string): string;
2
+ //# sourceMappingURL=to-unix-slash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-unix-slash.d.ts","sourceRoot":"","sources":["../../src/common/to-unix-slash.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,UAOvC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toUnixSlash = toUnixSlash;
4
+ function toUnixSlash(path) {
5
+ const isExtendedLengthPath = path.startsWith("\\\\?\\");
6
+ if (isExtendedLengthPath) {
7
+ return path;
8
+ }
9
+ return path.replace(/\\/g, "/");
10
+ }
11
+ //# sourceMappingURL=to-unix-slash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-unix-slash.js","sourceRoot":"","sources":["../../src/common/to-unix-slash.ts"],"names":[],"mappings":";;AAAA,kCAOC;AAPD,SAAgB,WAAW,CAAC,IAAY;IACtC,MAAM,oBAAoB,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;IACvD,IAAI,oBAAoB,EAAE,CAAC;QACzB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;AACjC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Transforms a value to a boolean or returns the default value
3
+ * when original value cannot be casted to a boolean
4
+ */
5
+ export declare function tryConvertToBoolean(value: unknown): boolean | undefined;
6
+ export declare function tryConvertToBoolean<T>(value: unknown, defaultValue: T): boolean | T;
7
+ //# sourceMappingURL=try-convert-to-boolean.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"try-convert-to-boolean.d.ts","sourceRoot":"","sources":["../../src/common/try-convert-to-boolean.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAAA;AACxE,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,KAAK,EAAE,OAAO,EACd,YAAY,EAAE,CAAC,GACd,OAAO,GAAG,CAAC,CAAA"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tryConvertToBoolean = tryConvertToBoolean;
4
+ function tryConvertToBoolean(value, defaultValue) {
5
+ if (typeof value === "string") {
6
+ const normalizedValue = value.toLowerCase();
7
+ return normalizedValue === "true"
8
+ ? true
9
+ : normalizedValue === "false"
10
+ ? false
11
+ : defaultValue ?? undefined;
12
+ }
13
+ return defaultValue ?? undefined;
14
+ }
15
+ //# sourceMappingURL=try-convert-to-boolean.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"try-convert-to-boolean.js","sourceRoot":"","sources":["../../src/common/try-convert-to-boolean.ts"],"names":[],"mappings":";;AASA,kDAaC;AAbD,SAAgB,mBAAmB,CACjC,KAAc,EACd,YAAgB;IAEhB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,eAAe,GAAG,KAAK,CAAC,WAAW,EAAE,CAAA;QAC3C,OAAO,eAAe,KAAK,MAAM;YAC/B,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,eAAe,KAAK,OAAO;gBAC7B,CAAC,CAAC,KAAK;gBACP,CAAC,CAAC,YAAY,IAAI,SAAS,CAAA;IAC/B,CAAC;IACD,OAAO,YAAY,IAAI,SAAS,CAAA;AAClC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Transforms a value to number or returns the default value
3
+ * when original value cannot be casted to number
4
+ */
5
+ export declare function tryConvertToNumber(value: unknown): number | undefined;
6
+ export declare function tryConvertToNumber<T>(value: unknown, defaultValue: T): number | T;
7
+ //# sourceMappingURL=try-convert-to-number.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"try-convert-to-number.d.ts","sourceRoot":"","sources":["../../src/common/try-convert-to-number.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAA;AACtE,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,KAAK,EAAE,OAAO,EACd,YAAY,EAAE,CAAC,GACd,MAAM,GAAG,CAAC,CAAA"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tryConvertToNumber = tryConvertToNumber;
4
+ function tryConvertToNumber(value, defaultValue) {
5
+ const transformedValue = Number(value);
6
+ return Number.isNaN(transformedValue)
7
+ ? defaultValue ?? undefined
8
+ : transformedValue;
9
+ }
10
+ //# sourceMappingURL=try-convert-to-number.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"try-convert-to-number.js","sourceRoot":"","sources":["../../src/common/try-convert-to-number.ts"],"names":[],"mappings":";;AASA,gDAQC;AARD,SAAgB,kBAAkB,CAChC,KAAc,EACd,YAAgB;IAEhB,MAAM,gBAAgB,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IACtC,OAAO,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC;QACnC,CAAC,CAAC,YAAY,IAAI,SAAS;QAC3B,CAAC,CAAC,gBAAgB,CAAA;AACtB,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * unFlatten object keys
3
+ * @example
4
+ * input: {
5
+ * "variants.sku": { $like: "%-1" },
6
+ * "variants.prices.amount": { $gt: 30 },
7
+ * "variants.prices.currency": "USD"
8
+ * }
9
+ *
10
+ * output: {
11
+ * {
12
+ * "variants": {
13
+ * "sku": {
14
+ * "$like": "%-1"
15
+ * },
16
+ * "prices": {
17
+ * "amount": {
18
+ * "$gt": 30
19
+ * },
20
+ * "currency": "USD"
21
+ * }
22
+ * }
23
+ * }
24
+ * }
25
+ *
26
+ * @param input
27
+ */
28
+ export declare function unflattenObjectKeys(flattened: Record<string, any>): Record<string, any>;
29
+ //# sourceMappingURL=unflatten-object-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unflatten-object-keys.d.ts","sourceRoot":"","sources":["../../src/common/unflatten-object-keys.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC7B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAoCrB"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unflattenObjectKeys = unflattenObjectKeys;
4
+ const is_object_1 = require("./is-object");
5
+ /**
6
+ * unFlatten object keys
7
+ * @example
8
+ * input: {
9
+ * "variants.sku": { $like: "%-1" },
10
+ * "variants.prices.amount": { $gt: 30 },
11
+ * "variants.prices.currency": "USD"
12
+ * }
13
+ *
14
+ * output: {
15
+ * {
16
+ * "variants": {
17
+ * "sku": {
18
+ * "$like": "%-1"
19
+ * },
20
+ * "prices": {
21
+ * "amount": {
22
+ * "$gt": 30
23
+ * },
24
+ * "currency": "USD"
25
+ * }
26
+ * }
27
+ * }
28
+ * }
29
+ *
30
+ * @param input
31
+ */
32
+ function unflattenObjectKeys(flattened) {
33
+ const result = {};
34
+ for (const key in flattened) {
35
+ if (!key.includes(".")) {
36
+ if ((0, is_object_1.isObject)(result[key])) {
37
+ result[key] = { ...result[key], ...flattened[key] };
38
+ }
39
+ else {
40
+ result[key] = flattened[key];
41
+ }
42
+ }
43
+ }
44
+ for (const key in flattened) {
45
+ if (key.includes(".")) {
46
+ const value = flattened[key];
47
+ const keys = key.split(".");
48
+ let current = result;
49
+ for (let i = 0; i < keys.length; i++) {
50
+ const part = keys[i];
51
+ if (i === keys.length - 1) {
52
+ if ((0, is_object_1.isObject)(value) && current[part]) {
53
+ current[part] = { ...current[part], ...value };
54
+ }
55
+ else {
56
+ current[part] = value;
57
+ }
58
+ }
59
+ else {
60
+ current = current[part] = current[part] ?? {};
61
+ }
62
+ }
63
+ }
64
+ }
65
+ return result;
66
+ }
67
+ //# sourceMappingURL=unflatten-object-keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unflatten-object-keys.js","sourceRoot":"","sources":["../../src/common/unflatten-object-keys.ts"],"names":[],"mappings":";;AA6BA,kDAsCC;AAnED,2CAAsC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,mBAAmB,CACjC,SAA8B;IAE9B,MAAM,MAAM,GAAwB,EAAE,CAAA;IAEtC,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC5B,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACvB,IAAI,IAAA,oBAAQ,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBAC1B,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,SAAS,CAAC,GAAG,CAAC,EAAE,CAAA;YACrD,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAA;YAC9B,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC5B,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAA;YAC5B,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YAC3B,IAAI,OAAO,GAAG,MAAM,CAAA;YAEpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACrC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;gBAEpB,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC1B,IAAI,IAAA,oBAAQ,EAAC,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;wBACrC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,EAAE,CAAA;oBAChD,CAAC;yBAAM,CAAC;wBACN,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAA;oBACvB,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;gBAC/C,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function validateModuleName(name: string): void;
2
+ //# sourceMappingURL=validate-module-name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-module-name.d.ts","sourceRoot":"","sources":["../../src/common/validate-module-name.ts"],"names":[],"mappings":"AAkBA,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,QAM9C"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateModuleName = validateModuleName;
4
+ /**
5
+ * Validates the module name to be variable safe. Since we generate
6
+ * a lot of code, types under the hood using the module name we
7
+ * have ensure that each module name is variable safe.
8
+ *
9
+ * Ofcourse, we can transform the module name to a variable safe value,
10
+ * but that might result into naming conflicts. For example: There are
11
+ * two module named as
12
+ *
13
+ * - sanity-products
14
+ * - sanity_products
15
+ *
16
+ * After transforming them, they will endup with the same output. This is
17
+ * a very simple example, but cases like these will lead to naming
18
+ * conflicts, so its better to use the names as it is and restrict
19
+ * them to be variable safe
20
+ */
21
+ const RE = /^[a-zA-Z_][0-9a-zA-Z_]*$/;
22
+ function validateModuleName(name) {
23
+ if (!RE.test(name)) {
24
+ throw new Error(`Invalid module name "${name}". Module names must be alpha numeric and may contain an underscore`);
25
+ }
26
+ }
27
+ //# sourceMappingURL=validate-module-name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-module-name.js","sourceRoot":"","sources":["../../src/common/validate-module-name.ts"],"names":[],"mappings":";;AAkBA,gDAMC;AAxBD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,EAAE,GAAG,0BAA0B,CAAA;AACrC,SAAgB,kBAAkB,CAAC,IAAY;IAC7C,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CACb,wBAAwB,IAAI,qEAAqE,CAClG,CAAA;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=wrap-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrap-handler.d.ts","sourceRoot":"","sources":["../../src/common/wrap-handler.ts"],"names":[],"mappings":""}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // import { NextFunction, Request, RequestHandler, Response } from "express"
4
+ //
5
+ // type handler = (req: Request, res: Response) => Promise<void>
6
+ //
7
+ // export const wrapHandler = (fn: handler): RequestHandler => {
8
+ // return async (req: Request, res: Response, next: NextFunction) => {
9
+ // const req_ = req as Request & { errors?: Error[] }
10
+ // if (req_?.errors?.length) {
11
+ // return res.status(400).json({
12
+ // errors: req_.errors,
13
+ // message:
14
+ // "Provided request body contains errors. Please check the data and retry the request",
15
+ // })
16
+ // }
17
+ //
18
+ // try {
19
+ // return await fn(req, res)
20
+ // } catch (err) {
21
+ // next(err)
22
+ // }
23
+ // }
24
+ // }
25
+ //
26
+ // /**
27
+ // * @schema MultipleErrors
28
+ // * title: "Multiple Errors"
29
+ // * type: object
30
+ // * properties:
31
+ // * errors:
32
+ // * type: array
33
+ // * description: Array of errors
34
+ // * items:
35
+ // * $ref: "#/components/schemas/Error"
36
+ // * message:
37
+ // * type: string
38
+ // * default: "Provided request body contains errors. Please check the data and retry the request"
39
+ // */
40
+ //# sourceMappingURL=wrap-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrap-handler.js","sourceRoot":"","sources":["../../src/common/wrap-handler.ts"],"names":[],"mappings":";;AAAA,4EAA4E;AAC5E,EAAE;AACF,gEAAgE;AAChE,EAAE;AACF,gEAAgE;AAChE,wEAAwE;AACxE,yDAAyD;AACzD,kCAAkC;AAClC,sCAAsC;AACtC,+BAA+B;AAC/B,mBAAmB;AACnB,kGAAkG;AAClG,WAAW;AACX,QAAQ;AACR,EAAE;AACF,YAAY;AACZ,kCAAkC;AAClC,sBAAsB;AACtB,kBAAkB;AAClB,QAAQ;AACR,MAAM;AACN,IAAI;AACJ,EAAE;AACF,MAAM;AACN,4BAA4B;AAC5B,8BAA8B;AAC9B,kBAAkB;AAClB,iBAAiB;AACjB,cAAc;AACd,oBAAoB;AACpB,qCAAqC;AACrC,eAAe;AACf,6CAA6C;AAC7C,eAAe;AACf,qBAAqB;AACrB,sGAAsG;AACtG,MAAM"}
@@ -1,9 +1,66 @@
1
+ /**
2
+ * @category User
3
+ * @customNamespace User
4
+ */
1
5
  export declare const UserWorkflowEvents: {
6
+ /**
7
+ * Emitted when users are created.
8
+ *
9
+ * @eventPayload
10
+ * ```ts
11
+ * [{
12
+ * id, // The ID of the user
13
+ * }]
14
+ * ```
15
+ */
2
16
  CREATED: string;
17
+ /**
18
+ * Emitted when users are updated.
19
+ *
20
+ * @eventPayload
21
+ * ```ts
22
+ * [{
23
+ * id, // The ID of the user
24
+ * }]
25
+ * ```
26
+ */
3
27
  UPDATED: string;
28
+ /**
29
+ * Emitted when users are deleted.
30
+ *
31
+ * @eventPayload
32
+ * ```ts
33
+ * [{
34
+ * id, // The ID of the user
35
+ * }]
36
+ * ```
37
+ */
4
38
  DELETED: string;
5
39
  };
40
+ /**
41
+ * @category Auth
42
+ * @customNamespace Auth
43
+ */
6
44
  export declare const AuthWorkflowEvents: {
45
+ /**
46
+ * Emitted when a reset password token is generated. You can listen to this event
47
+ * to send a reset password email to the user or customer, for example.
48
+ *
49
+ * @eventPayload
50
+ * ```ts
51
+ * {
52
+ * entity_id, // The identifier of the user or customer. For example, an email address.
53
+ * actor_type, // The type of actor. For example, "customer", "user", or custom.
54
+ * token, // The generated token.
55
+ * }
56
+ * ```
57
+ */
7
58
  PASSWORD_RESET: string;
8
59
  };
60
+ export declare const InviteWorkflowEvents: {
61
+ ACCEPTED: string;
62
+ CREATED: string;
63
+ DELETED: string;
64
+ RESENT: string;
65
+ };
9
66
  //# sourceMappingURL=events.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/core-flows/events.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB;;;;CAI9B,CAAA;AAED,eAAO,MAAM,kBAAkB;;CAE9B,CAAA"}
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/core-flows/events.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,kBAAkB;IAC7B;;;;;;;;;OASG;;IAEH;;;;;;;;;OASG;;IAEH;;;;;;;;;OASG;;CAEJ,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB;IAC7B;;;;;;;;;;;;OAYG;;CAEJ,CAAA;AAGD,eAAO,MAAM,oBAAoB;;;;;CAKhC,CAAA"}
@@ -1,19 +1,69 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AuthWorkflowEvents = exports.UserWorkflowEvents = void 0;
3
+ exports.InviteWorkflowEvents = exports.AuthWorkflowEvents = exports.UserWorkflowEvents = void 0;
4
+ /**
5
+ * @category User
6
+ * @customNamespace User
7
+ */
4
8
  exports.UserWorkflowEvents = {
9
+ /**
10
+ * Emitted when users are created.
11
+ *
12
+ * @eventPayload
13
+ * ```ts
14
+ * [{
15
+ * id, // The ID of the user
16
+ * }]
17
+ * ```
18
+ */
5
19
  CREATED: "user.created",
20
+ /**
21
+ * Emitted when users are updated.
22
+ *
23
+ * @eventPayload
24
+ * ```ts
25
+ * [{
26
+ * id, // The ID of the user
27
+ * }]
28
+ * ```
29
+ */
6
30
  UPDATED: "user.updated",
31
+ /**
32
+ * Emitted when users are deleted.
33
+ *
34
+ * @eventPayload
35
+ * ```ts
36
+ * [{
37
+ * id, // The ID of the user
38
+ * }]
39
+ * ```
40
+ */
7
41
  DELETED: "user.deleted",
8
42
  };
43
+ /**
44
+ * @category Auth
45
+ * @customNamespace Auth
46
+ */
9
47
  exports.AuthWorkflowEvents = {
48
+ /**
49
+ * Emitted when a reset password token is generated. You can listen to this event
50
+ * to send a reset password email to the user or customer, for example.
51
+ *
52
+ * @eventPayload
53
+ * ```ts
54
+ * {
55
+ * entity_id, // The identifier of the user or customer. For example, an email address.
56
+ * actor_type, // The type of actor. For example, "customer", "user", or custom.
57
+ * token, // The generated token.
58
+ * }
59
+ * ```
60
+ */
10
61
  PASSWORD_RESET: "auth.password_reset",
11
62
  };
12
- // invite and hil shouuld be first class supported.
13
- // export const InviteWorkflowEvents = {
14
- // ACCEPTED: "invite.accepted",
15
- // CREATED: "invite.created",
16
- // DELETED: "invite.deleted",
17
- // RESENT: "invite.resent",
18
- // }
63
+ exports.InviteWorkflowEvents = {
64
+ ACCEPTED: "invite.accepted",
65
+ CREATED: "invite.created",
66
+ DELETED: "invite.deleted",
67
+ RESENT: "invite.resent",
68
+ };
19
69
  //# sourceMappingURL=events.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/core-flows/events.ts"],"names":[],"mappings":";;;AAAa,QAAA,kBAAkB,GAAG;IAChC,OAAO,EAAE,cAAc;IACvB,OAAO,EAAE,cAAc;IACvB,OAAO,EAAE,cAAc;CACxB,CAAA;AAEY,QAAA,kBAAkB,GAAG;IAChC,cAAc,EAAE,qBAAqB;CACtC,CAAA;AAGD,mDAAmD;AACnD,wCAAwC;AACxC,iCAAiC;AACjC,+BAA+B;AAC/B,+BAA+B;AAC/B,6BAA6B;AAC7B,IAAI"}
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/core-flows/events.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,kBAAkB,GAAG;IAChC;;;;;;;;;OASG;IACH,OAAO,EAAE,cAAc;IACvB;;;;;;;;;OASG;IACH,OAAO,EAAE,cAAc;IACvB;;;;;;;;;OASG;IACH,OAAO,EAAE,cAAc;CACxB,CAAA;AAED;;;GAGG;AACU,QAAA,kBAAkB,GAAG;IAChC;;;;;;;;;;;;OAYG;IACH,cAAc,EAAE,qBAAqB;CACtC,CAAA;AAGY,QAAA,oBAAoB,GAAG;IAClC,QAAQ,EAAE,iBAAiB;IAC3B,OAAO,EAAE,gBAAgB;IACzB,OAAO,EAAE,gBAAgB;IACzB,MAAM,EAAE,eAAe;CACxB,CAAA"}
@@ -7,5 +7,6 @@ export * from "./mikro-orm/mikro-orm-serializer";
7
7
  export * from "./mikro-orm/base-entity";
8
8
  export * from "./mikro-orm/utils";
9
9
  export * from "./mikro-orm/decorators/searchable";
10
+ export * from "./mikro-orm/sql-migration-generator";
10
11
  export * from "./utils";
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dal/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA;AAC5C,cAAc,yCAAyC,CAAA;AACvD,cAAc,+CAA+C,CAAA;AAC7D,cAAc,kCAAkC,CAAA;AAChD,cAAc,6CAA6C,CAAA;AAC3D,cAAc,kCAAkC,CAAA;AAChD,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,mCAAmC,CAAA;AACjD,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dal/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA;AAC5C,cAAc,yCAAyC,CAAA;AACvD,cAAc,+CAA+C,CAAA;AAC7D,cAAc,kCAAkC,CAAA;AAChD,cAAc,6CAA6C,CAAA;AAC3D,cAAc,kCAAkC,CAAA;AAChD,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,mCAAmC,CAAA;AACjD,cAAc,qCAAqC,CAAA;AACnD,cAAc,SAAS,CAAA"}
package/dist/dal/index.js CHANGED
@@ -23,5 +23,6 @@ __exportStar(require("./mikro-orm/mikro-orm-serializer"), exports);
23
23
  __exportStar(require("./mikro-orm/base-entity"), exports);
24
24
  __exportStar(require("./mikro-orm/utils"), exports);
25
25
  __exportStar(require("./mikro-orm/decorators/searchable"), exports);
26
+ __exportStar(require("./mikro-orm/sql-migration-generator"), exports);
26
27
  __exportStar(require("./utils"), exports);
27
28
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dal/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+DAA4C;AAC5C,0EAAuD;AACvD,gFAA6D;AAC7D,mEAAgD;AAChD,8EAA2D;AAC3D,mEAAgD;AAChD,0DAAuC;AACvC,oDAAiC;AACjC,oEAAiD;AACjD,0CAAuB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dal/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+DAA4C;AAC5C,0EAAuD;AACvD,gFAA6D;AAC7D,mEAAgD;AAChD,8EAA2D;AAC3D,mEAAgD;AAChD,0DAAuC;AACvC,oDAAiC;AACjC,oEAAiD;AACjD,sEAAmD;AACnD,0CAAuB"}
@@ -1 +1 @@
1
- {"version":3,"file":"big-number-field.d.ts","sourceRoot":"","sources":["../../../src/dal/mikro-orm/big-number-field.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAI1C,wBAAgB,yBAAyB,CACvC,OAAO,GAAE,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG;IACxC,aAAa,CAAC,EAAE,MAAM,CAAA;CAClB,IAEW,QAAQ,GAAG,EAAE,YAAY,MAAM,UA2EjD"}
1
+ {"version":3,"file":"big-number-field.d.ts","sourceRoot":"","sources":["../../../src/dal/mikro-orm/big-number-field.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAI1C,wBAAgB,yBAAyB,CACvC,OAAO,GAAE,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG;IACxC,aAAa,CAAC,EAAE,MAAM,CAAA;CAClB,IAEW,QAAQ,GAAG,EAAE,YAAY,MAAM,UAwFjD"}
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MikroOrmBigNumberProperty = MikroOrmBigNumberProperty;
4
4
  const core_1 = require("@mikro-orm/core");
5
5
  const common_1 = require("../../common");
6
- const big_number_1 = require("../../common/big-number");
6
+ const big_number_1 = require("../../totals/big-number");
7
7
  function MikroOrmBigNumberProperty(options = {}) {
8
8
  return function (target, columnName) {
9
9
  const rawColumnName = options.rawColumnName ?? `raw_${columnName}`;
@@ -20,32 +20,46 @@ function MikroOrmBigNumberProperty(options = {}) {
20
20
  set(value) {
21
21
  if (options?.nullable && !(0, common_1.isPresent)(value)) {
22
22
  this.__helper.__data[columnName] = null;
23
- this.__helper.__data[rawColumnName];
23
+ this.__helper.__data[rawColumnName] = null;
24
24
  this[rawColumnName] = null;
25
25
  }
26
26
  else {
27
- let bigNumber;
28
- if (value instanceof big_number_1.BigNumber) {
29
- bigNumber = value;
30
- }
31
- else if (this[rawColumnName]) {
32
- const precision = this[rawColumnName].precision;
33
- bigNumber = new big_number_1.BigNumber(value, {
34
- precision,
35
- });
27
+ // When mikro orm create and hydrate the entity with partial selection it can happen
28
+ // that null value is being passed.
29
+ if (!options?.nullable && value === null) {
30
+ this.__helper.__data[columnName] = undefined;
31
+ this.__helper.__data[rawColumnName] = undefined;
32
+ this[rawColumnName] = undefined;
36
33
  }
37
34
  else {
38
- bigNumber = new big_number_1.BigNumber(value);
39
- }
40
- const raw = bigNumber.raw;
41
- raw.value = (0, common_1.trimZeros)(raw.value);
42
- // Note: this.__helper isn't present when directly working with the entity
43
- // Adding this in optionally for it not to break.
44
- if ((0, common_1.isDefined)(this.__helper)) {
45
- this.__helper.__data[columnName] = bigNumber.numeric;
46
- this.__helper.__data[rawColumnName] = raw;
35
+ let bigNumber;
36
+ try {
37
+ if (value instanceof big_number_1.BigNumber) {
38
+ bigNumber = value;
39
+ }
40
+ else if (this[rawColumnName]) {
41
+ const precision = this[rawColumnName].precision;
42
+ bigNumber = new big_number_1.BigNumber(value, {
43
+ precision,
44
+ });
45
+ }
46
+ else {
47
+ bigNumber = new big_number_1.BigNumber(value);
48
+ }
49
+ }
50
+ catch (e) {
51
+ throw new Error(`Cannot set value ${value} for ${columnName}.`);
52
+ }
53
+ const raw = bigNumber.raw;
54
+ raw.value = (0, common_1.trimZeros)(raw.value);
55
+ // Note: this.__helper isn't present when directly working with the entity
56
+ // Adding this in optionally for it not to break.
57
+ if ((0, common_1.isDefined)(this.__helper)) {
58
+ this.__helper.__data[columnName] = bigNumber.numeric;
59
+ this.__helper.__data[rawColumnName] = raw;
60
+ }
61
+ this[rawColumnName] = raw;
47
62
  }
48
- this[rawColumnName] = raw;
49
63
  }
50
64
  // Note: this.__helper isn't present when directly working with the entity
51
65
  // Adding this in optionally for it not to break.
@@ -69,6 +83,7 @@ function MikroOrmBigNumberProperty(options = {}) {
69
83
  type: "any",
70
84
  columnType: "numeric",
71
85
  trackChanges: false,
86
+ runtimeType: "any",
72
87
  ...options,
73
88
  })(target, columnName);
74
89
  };