@creatio-devkit/common 0.803.0-rc.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 (250) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/LICENSE.md +6 -0
  3. package/README.md +31 -0
  4. package/creatio-devkit-common.d.ts +2034 -0
  5. package/esm2020/creatio-devkit-common.mjs +5 -0
  6. package/esm2020/index.mjs +2 -0
  7. package/esm2020/lib/external/functions/aggregation-adapter.mjs +24 -0
  8. package/esm2020/lib/external/functions/index.mjs +2 -0
  9. package/esm2020/lib/external/models/attribute-value-config.mjs +2 -0
  10. package/esm2020/lib/external/models/date-time/grouped-date-value.mjs +2 -0
  11. package/esm2020/lib/external/models/date-time/index.mjs +2 -0
  12. package/esm2020/lib/external/models/file-value.model.mjs +2 -0
  13. package/esm2020/lib/external/models/index.mjs +5 -0
  14. package/esm2020/lib/external/models/model-init-config.mjs +2 -0
  15. package/esm2020/lib/index.mjs +20 -0
  16. package/esm2020/lib/internal/constants/index.mjs +2 -0
  17. package/esm2020/lib/internal/constants/metadata.const.mjs +13 -0
  18. package/esm2020/lib/internal/decorators/converter/converter.decorator.mjs +11 -0
  19. package/esm2020/lib/internal/decorators/converter/index.mjs +2 -0
  20. package/esm2020/lib/internal/decorators/design-time-view-element/design-time-view-element.decorator.mjs +14 -0
  21. package/esm2020/lib/internal/decorators/design-time-view-element/index.mjs +2 -0
  22. package/esm2020/lib/internal/decorators/implement-using-handler-chain/implement-using-handler-chain.decorator.mjs +24 -0
  23. package/esm2020/lib/internal/decorators/implement-using-handler-chain/index.mjs +2 -0
  24. package/esm2020/lib/internal/decorators/index.mjs +6 -0
  25. package/esm2020/lib/internal/decorators/request/index.mjs +2 -0
  26. package/esm2020/lib/internal/decorators/request/request.decorator.mjs +15 -0
  27. package/esm2020/lib/internal/decorators/request-handler/index.mjs +2 -0
  28. package/esm2020/lib/internal/decorators/request-handler/request-handler.decorator.mjs +15 -0
  29. package/esm2020/lib/internal/enums/data-source-scope.enum.mjs +9 -0
  30. package/esm2020/lib/internal/enums/designer-group-type.enum.mjs +14 -0
  31. package/esm2020/lib/internal/enums/index.mjs +5 -0
  32. package/esm2020/lib/internal/enums/model-in-page-action.enum.mjs +10 -0
  33. package/esm2020/lib/internal/enums/view-element-group-type.enum.mjs +13 -0
  34. package/esm2020/lib/internal/esq/data-model/index.mjs +3 -0
  35. package/esm2020/lib/internal/esq/data-model/metadata-provider/metadata-provider.mjs +2 -0
  36. package/esm2020/lib/internal/esq/data-model/queries/base-filterable-query.mjs +15 -0
  37. package/esm2020/lib/internal/esq/data-model/queries/base-query.mjs +20 -0
  38. package/esm2020/lib/internal/esq/data-model/queries/delete-query.mjs +12 -0
  39. package/esm2020/lib/internal/esq/data-model/queries/entity-schema-query.mjs +211 -0
  40. package/esm2020/lib/internal/esq/data-model/queries/index.mjs +8 -0
  41. package/esm2020/lib/internal/esq/data-model/queries/insert-query.mjs +37 -0
  42. package/esm2020/lib/internal/esq/data-model/queries/query-operation-type.mjs +15 -0
  43. package/esm2020/lib/internal/esq/data-model/queries/update-query.mjs +37 -0
  44. package/esm2020/lib/internal/esq/index.mjs +2 -0
  45. package/esm2020/lib/internal/handlers/base-request-handler.mjs +26 -0
  46. package/esm2020/lib/internal/handlers/index.mjs +2 -0
  47. package/esm2020/lib/internal/model/data-source-config.mjs +2 -0
  48. package/esm2020/lib/internal/model/index.mjs +2 -0
  49. package/esm2020/lib/internal/models/design-time-view-element-registry-item.mjs +2 -0
  50. package/esm2020/lib/internal/models/handler-chain-service-registry-item.mjs +2 -0
  51. package/esm2020/lib/internal/models/index.mjs +12 -0
  52. package/esm2020/lib/internal/models/interface-designer-item/base-interface-designer-item-registration-config.mjs +2 -0
  53. package/esm2020/lib/internal/models/interface-designer-item/index.mjs +4 -0
  54. package/esm2020/lib/internal/models/interface-designer-item/interface-designer-item-registration-config.model.mjs +6 -0
  55. package/esm2020/lib/internal/models/interface-designer-item/toolbar-view-element-config.mjs +2 -0
  56. package/esm2020/lib/internal/models/interface-designer-registry-item.mjs +2 -0
  57. package/esm2020/lib/internal/models/internal-interface-designer-item-registration-config.model.mjs +2 -0
  58. package/esm2020/lib/internal/models/request/index.mjs +3 -0
  59. package/esm2020/lib/internal/models/request/method-invoke-request.mjs +12 -0
  60. package/esm2020/lib/internal/models/request/request-registration-config.model.mjs +2 -0
  61. package/esm2020/lib/internal/models/request-handler/index.mjs +4 -0
  62. package/esm2020/lib/internal/models/request-handler/request-handler-factory.mjs +2 -0
  63. package/esm2020/lib/internal/models/request-handler/request-handler-registration-config.model.mjs +2 -0
  64. package/esm2020/lib/internal/models/request-handler/request-handler.mjs +2 -0
  65. package/esm2020/lib/internal/models/validation/crt-control.mjs +2 -0
  66. package/esm2020/lib/internal/models/validation/crt-validator-fn.mjs +2 -0
  67. package/esm2020/lib/internal/models/validation/index.mjs +3 -0
  68. package/esm2020/lib/internal/models/validator-config.model.mjs +2 -0
  69. package/esm2020/lib/internal/models/view-element/angular-view-element-registration-config.model.mjs +2 -0
  70. package/esm2020/lib/internal/models/view-element/index.mjs +2 -0
  71. package/esm2020/lib/internal/models/view-element-registry-item.mjs +2 -0
  72. package/esm2020/lib/internal/services/base-handler-chain.service.mjs +3 -0
  73. package/esm2020/lib/internal/services/base-registry/base-registry.mjs +25 -0
  74. package/esm2020/lib/internal/services/base-registry/index.mjs +2 -0
  75. package/esm2020/lib/internal/services/bootstrap-notifier/bootstrap-notifier.mjs +28 -0
  76. package/esm2020/lib/internal/services/bootstrap-notifier/index.mjs +2 -0
  77. package/esm2020/lib/internal/services/design-time-view-element-registry/design-time-view-element-registry.mjs +31 -0
  78. package/esm2020/lib/internal/services/design-time-view-element-registry/index.mjs +2 -0
  79. package/esm2020/lib/internal/services/element-registration-checker/element-registration-checker.mjs +53 -0
  80. package/esm2020/lib/internal/services/element-registration-checker/index.mjs +2 -0
  81. package/esm2020/lib/internal/services/global-converters-registry/global-converters-registry.service.mjs +23 -0
  82. package/esm2020/lib/internal/services/global-converters-registry/index.mjs +2 -0
  83. package/esm2020/lib/internal/services/handler-chain-services-registry/handler-chain-services-registry.mjs +25 -0
  84. package/esm2020/lib/internal/services/handler-chain-services-registry/index.mjs +2 -0
  85. package/esm2020/lib/internal/services/index.mjs +11 -0
  86. package/esm2020/lib/internal/services/interface-designer-item-registry/index.mjs +2 -0
  87. package/esm2020/lib/internal/services/interface-designer-item-registry/interface-designer-item-registry.mjs +26 -0
  88. package/esm2020/lib/internal/services/request-handler-registry/index.mjs +2 -0
  89. package/esm2020/lib/internal/services/request-handler-registry/request-handler-registry.service.mjs +72 -0
  90. package/esm2020/lib/internal/services/request-registry/index.mjs +2 -0
  91. package/esm2020/lib/internal/services/request-registry/request-registry.service.mjs +33 -0
  92. package/esm2020/lib/internal/services/view-element-registry/index.mjs +2 -0
  93. package/esm2020/lib/internal/services/view-element-registry/view-element-registry.mjs +27 -0
  94. package/esm2020/lib/internal/utils/index.mjs +4 -0
  95. package/esm2020/lib/internal/utils/localization-utils.mjs +24 -0
  96. package/esm2020/lib/internal/utils/metadata-utils.mjs +150 -0
  97. package/esm2020/lib/internal/utils/object-deep-keys/index.mjs +2 -0
  98. package/esm2020/lib/internal/utils/object-deep-keys/object-deep-keys.mjs +13 -0
  99. package/esm2020/lib/public/decorators/index.mjs +7 -0
  100. package/esm2020/lib/public/decorators/input/index.mjs +2 -0
  101. package/esm2020/lib/public/decorators/input/input.decorator.mjs +25 -0
  102. package/esm2020/lib/public/decorators/interface-designer-item/index.mjs +2 -0
  103. package/esm2020/lib/public/decorators/interface-designer-item/interface-designer-item.decorator.mjs +50 -0
  104. package/esm2020/lib/public/decorators/module/index.mjs +2 -0
  105. package/esm2020/lib/public/decorators/module/module.decorator.mjs +25 -0
  106. package/esm2020/lib/public/decorators/output/index.mjs +2 -0
  107. package/esm2020/lib/public/decorators/output/output.decorator.mjs +19 -0
  108. package/esm2020/lib/public/decorators/validation-input/index.mjs +2 -0
  109. package/esm2020/lib/public/decorators/validation-input/validation-input.decorator.mjs +27 -0
  110. package/esm2020/lib/public/decorators/view-element/index.mjs +2 -0
  111. package/esm2020/lib/public/decorators/view-element/view-element.decorator.mjs +32 -0
  112. package/esm2020/lib/public/enums/aggregation-function.enum.mjs +18 -0
  113. package/esm2020/lib/public/enums/aggregation-type.enum.mjs +18 -0
  114. package/esm2020/lib/public/enums/data-value-type.enum.mjs +44 -0
  115. package/esm2020/lib/public/enums/index.mjs +4 -0
  116. package/esm2020/lib/public/esq/data-model/columns/arithmetic/arithmetic-query-column.mjs +9 -0
  117. package/esm2020/lib/public/esq/data-model/columns/base-query-column.mjs +45 -0
  118. package/esm2020/lib/public/esq/data-model/columns/entity-column/entity-query-column.mjs +9 -0
  119. package/esm2020/lib/public/esq/data-model/columns/functions/aggregation-function-column.mjs +13 -0
  120. package/esm2020/lib/public/esq/data-model/columns/functions/date-part-function-column.mjs +17 -0
  121. package/esm2020/lib/public/esq/data-model/columns/functions/length-function-column.mjs +9 -0
  122. package/esm2020/lib/public/esq/data-model/columns/functions/macros-function-column.mjs +9 -0
  123. package/esm2020/lib/public/esq/data-model/columns/functions/window-function-column.mjs +9 -0
  124. package/esm2020/lib/public/esq/data-model/columns/index.mjs +12 -0
  125. package/esm2020/lib/public/esq/data-model/columns/parameters/parameter-query-column.mjs +9 -0
  126. package/esm2020/lib/public/esq/data-model/columns/sub-queries/aggregation-sub-query-column.mjs +15 -0
  127. package/esm2020/lib/public/esq/data-model/columns/sub-queries/sub-query-column.mjs +9 -0
  128. package/esm2020/lib/public/esq/data-model/enums/aggregation-eval-type.enum.mjs +10 -0
  129. package/esm2020/lib/public/esq/data-model/enums/arithmetic-operation.enum.mjs +12 -0
  130. package/esm2020/lib/public/esq/data-model/enums/comparison-type.enum.mjs +21 -0
  131. package/esm2020/lib/public/esq/data-model/enums/date-part-type.enum.mjs +20 -0
  132. package/esm2020/lib/public/esq/data-model/enums/expression-type.enum.mjs +9 -0
  133. package/esm2020/lib/public/esq/data-model/enums/filter-type.enum.mjs +11 -0
  134. package/esm2020/lib/public/esq/data-model/enums/function-type.enum.mjs +15 -0
  135. package/esm2020/lib/public/esq/data-model/enums/index.mjs +12 -0
  136. package/esm2020/lib/public/esq/data-model/enums/logical-operator-type.enum.mjs +6 -0
  137. package/esm2020/lib/public/esq/data-model/enums/order-direction.enum.mjs +7 -0
  138. package/esm2020/lib/public/esq/data-model/enums/query-macros-type.enum.mjs +74 -0
  139. package/esm2020/lib/public/esq/data-model/expressions/arithmetic/arithmetic-expression.mjs +15 -0
  140. package/esm2020/lib/public/esq/data-model/expressions/arithmetic/index.mjs +2 -0
  141. package/esm2020/lib/public/esq/data-model/expressions/base-expression.mjs +7 -0
  142. package/esm2020/lib/public/esq/data-model/expressions/columns/column-expression.mjs +13 -0
  143. package/esm2020/lib/public/esq/data-model/expressions/columns/index.mjs +2 -0
  144. package/esm2020/lib/public/esq/data-model/expressions/functions/aggregation-function-expression.mjs +14 -0
  145. package/esm2020/lib/public/esq/data-model/expressions/functions/argument-function-expression.mjs +8 -0
  146. package/esm2020/lib/public/esq/data-model/expressions/functions/date-part-function-expression.mjs +13 -0
  147. package/esm2020/lib/public/esq/data-model/expressions/functions/function-expression.mjs +9 -0
  148. package/esm2020/lib/public/esq/data-model/expressions/functions/index.mjs +8 -0
  149. package/esm2020/lib/public/esq/data-model/expressions/functions/length-function-expression.mjs +12 -0
  150. package/esm2020/lib/public/esq/data-model/expressions/functions/macros-function-expression.mjs +13 -0
  151. package/esm2020/lib/public/esq/data-model/expressions/functions/window-function-expression.mjs +12 -0
  152. package/esm2020/lib/public/esq/data-model/expressions/index.mjs +8 -0
  153. package/esm2020/lib/public/esq/data-model/expressions/mocks/expression.mock.mjs +17 -0
  154. package/esm2020/lib/public/esq/data-model/expressions/mocks/index.mjs +2 -0
  155. package/esm2020/lib/public/esq/data-model/expressions/parameters/index.mjs +2 -0
  156. package/esm2020/lib/public/esq/data-model/expressions/parameters/parameter-expression.mjs +81 -0
  157. package/esm2020/lib/public/esq/data-model/expressions/sub-queries/aggregation-sub-query-expression.mjs +11 -0
  158. package/esm2020/lib/public/esq/data-model/expressions/sub-queries/index.mjs +3 -0
  159. package/esm2020/lib/public/esq/data-model/expressions/sub-queries/sub-query-expression.mjs +17 -0
  160. package/esm2020/lib/public/esq/data-model/filters/base-filter.mjs +8 -0
  161. package/esm2020/lib/public/esq/data-model/filters/between-filter.mjs +13 -0
  162. package/esm2020/lib/public/esq/data-model/filters/compare-filter.mjs +12 -0
  163. package/esm2020/lib/public/esq/data-model/filters/exists-filter.mjs +13 -0
  164. package/esm2020/lib/public/esq/data-model/filters/filter-group.mjs +91 -0
  165. package/esm2020/lib/public/esq/data-model/filters/in-filter.mjs +12 -0
  166. package/esm2020/lib/public/esq/data-model/filters/index.mjs +10 -0
  167. package/esm2020/lib/public/esq/data-model/filters/isnull-filter.mjs +21 -0
  168. package/esm2020/lib/public/esq/data-model/filters/mocks/filter.mock.mjs +16 -0
  169. package/esm2020/lib/public/esq/data-model/filters/mocks/index.mjs +2 -0
  170. package/esm2020/lib/public/esq/data-model/filters/single-filter.mjs +9 -0
  171. package/esm2020/lib/public/esq/data-model/index.mjs +5 -0
  172. package/esm2020/lib/public/esq/index.mjs +2 -0
  173. package/esm2020/lib/public/exceptions/argument-empty-exception.mjs +7 -0
  174. package/esm2020/lib/public/exceptions/argument-out-of-range-exception.mjs +7 -0
  175. package/esm2020/lib/public/exceptions/index.mjs +6 -0
  176. package/esm2020/lib/public/exceptions/item-not-found-exception.mjs +7 -0
  177. package/esm2020/lib/public/exceptions/next-handler-already-specified-exception.mjs +9 -0
  178. package/esm2020/lib/public/exceptions/validation-utilities.mjs +32 -0
  179. package/esm2020/lib/public/functions/bootstrap-crt-module.mjs +97 -0
  180. package/esm2020/lib/public/functions/index.mjs +4 -0
  181. package/esm2020/lib/public/functions/localize.mjs +29 -0
  182. package/esm2020/lib/public/functions/register-view-element.mjs +21 -0
  183. package/esm2020/lib/public/models/base-response.model.mjs +2 -0
  184. package/esm2020/lib/public/models/converter.model.mjs +2 -0
  185. package/esm2020/lib/public/models/entity.model.mjs +2 -0
  186. package/esm2020/lib/public/models/error-info.model.mjs +2 -0
  187. package/esm2020/lib/public/models/image-value.model.mjs +2 -0
  188. package/esm2020/lib/public/models/index.mjs +17 -0
  189. package/esm2020/lib/public/models/input/index.mjs +2 -0
  190. package/esm2020/lib/public/models/input/input-registration-config.model.mjs +6 -0
  191. package/esm2020/lib/public/models/interface-designer-item/index.mjs +2 -0
  192. package/esm2020/lib/public/models/interface-designer-item/interface-designer-item-definition.mjs +2 -0
  193. package/esm2020/lib/public/models/interfaces/data-source-save-result.interface.mjs +2 -0
  194. package/esm2020/lib/public/models/localizable-value.mjs +9 -0
  195. package/esm2020/lib/public/models/lookup-value.model.mjs +2 -0
  196. package/esm2020/lib/public/models/mask-settings.mjs +2 -0
  197. package/esm2020/lib/public/models/module-definition.mjs +2 -0
  198. package/esm2020/lib/public/models/request/base-request-config.mjs +8 -0
  199. package/esm2020/lib/public/models/request/base-request.mjs +9 -0
  200. package/esm2020/lib/public/models/request/data-source-request.mjs +11 -0
  201. package/esm2020/lib/public/models/request/index.mjs +4 -0
  202. package/esm2020/lib/public/models/validation/crt-validation-errors.mjs +2 -0
  203. package/esm2020/lib/public/models/validation/index.mjs +3 -0
  204. package/esm2020/lib/public/models/validation/validation-info.mjs +2 -0
  205. package/esm2020/lib/public/models/view-element/base-view-element-registration-config.mjs +2 -0
  206. package/esm2020/lib/public/models/view-element/index.mjs +3 -0
  207. package/esm2020/lib/public/models/view-element/view-element-registration-config.mjs +2 -0
  208. package/esm2020/lib/public/models/view-model-context.mjs +2 -0
  209. package/esm2020/lib/public/services/feature/feature.service.mjs +27 -0
  210. package/esm2020/lib/public/services/feature/index.mjs +2 -0
  211. package/esm2020/lib/public/services/handler-chain/handler-chain.service.mjs +45 -0
  212. package/esm2020/lib/public/services/handler-chain/index.mjs +2 -0
  213. package/esm2020/lib/public/services/handler-chain/internal-handler-chain.mjs +93 -0
  214. package/esm2020/lib/public/services/http-client/http-client.service.mjs +74 -0
  215. package/esm2020/lib/public/services/http-client/http-headers.mjs +2 -0
  216. package/esm2020/lib/public/services/http-client/http-response.mjs +2 -0
  217. package/esm2020/lib/public/services/http-client/index.mjs +4 -0
  218. package/esm2020/lib/public/services/index.mjs +9 -0
  219. package/esm2020/lib/public/services/mask-service/index.mjs +2 -0
  220. package/esm2020/lib/public/services/mask-service/mask.service.mjs +27 -0
  221. package/esm2020/lib/public/services/model/data-source-aggregation-config.mjs +2 -0
  222. package/esm2020/lib/public/services/model/data-source-attribute.mjs +2 -0
  223. package/esm2020/lib/public/services/model/data-source-can-execute-operation.mjs +2 -0
  224. package/esm2020/lib/public/services/model/data-source-paging-config.mjs +2 -0
  225. package/esm2020/lib/public/services/model/data-source-parameter.mjs +12 -0
  226. package/esm2020/lib/public/services/model/data-source-save-result.mjs +2 -0
  227. package/esm2020/lib/public/services/model/data-source-sorting-config.mjs +2 -0
  228. package/esm2020/lib/public/services/model/index.mjs +11 -0
  229. package/esm2020/lib/public/services/model/model-load-options.mjs +2 -0
  230. package/esm2020/lib/public/services/model/model.mjs +66 -0
  231. package/esm2020/lib/public/services/rights/index.mjs +2 -0
  232. package/esm2020/lib/public/services/rights/rights.service.mjs +27 -0
  233. package/esm2020/lib/public/services/sys-settings/index.mjs +3 -0
  234. package/esm2020/lib/public/services/sys-settings/sys-setting.model.mjs +23 -0
  235. package/esm2020/lib/public/services/sys-settings/sys-settings.service.mjs +35 -0
  236. package/esm2020/lib/public/services/sys-values/index.mjs +3 -0
  237. package/esm2020/lib/public/services/sys-values/sys-values.mjs +2 -0
  238. package/esm2020/lib/public/services/sys-values/sys-values.service.mjs +23 -0
  239. package/esm2020/lib/public/types/entity-column-value.mjs +2 -0
  240. package/esm2020/lib/public/types/guid.type.mjs +53 -0
  241. package/esm2020/lib/public/types/index.mjs +7 -0
  242. package/esm2020/lib/public/types/json-data.type.mjs +2 -0
  243. package/esm2020/lib/public/types/localize-fn.type.mjs +2 -0
  244. package/esm2020/lib/public/types/sort-direction.type.mjs +2 -0
  245. package/esm2020/lib/public/types/type.mjs +2 -0
  246. package/fesm2015/creatio-devkit-common.mjs +2687 -0
  247. package/fesm2015/creatio-devkit-common.mjs.map +1 -0
  248. package/fesm2020/creatio-devkit-common.mjs +2709 -0
  249. package/fesm2020/creatio-devkit-common.mjs.map +1 -0
  250. package/package.json +33 -0
@@ -0,0 +1,2687 @@
1
+ import 'reflect-metadata';
2
+ import { upperFirst, camelCase, isEqual, get, set, cloneDeep } from 'lodash';
3
+ import { __awaiter, __decorate, __metadata } from 'tslib';
4
+ import { Exclude, Expose, classToPlain } from 'class-transformer';
5
+
6
+ /**
7
+ * @internal
8
+ */
9
+ const crtInputPrefix = 'crtInput:';
10
+ /**
11
+ * @internal
12
+ */
13
+ const crtOutputPrefix = 'crtOutput:';
14
+ /**
15
+ * @internal
16
+ */
17
+ const crtValidationInputPrefix = 'crtValidationInput:';
18
+
19
+ /**
20
+ * @public
21
+ * @description Creatio platform interacts with input's of user-defined component through CrtInput decorator.
22
+ * @param config {@link CrtInputRegistrationConfig}
23
+ *
24
+ * @example
25
+ * export class AppComponent {
26
+ * @CrtInput()
27
+ * public value!: string;
28
+ * }
29
+ */
30
+ // eslint-disable-next-line @typescript-eslint/naming-convention
31
+ function CrtInput(config) {
32
+ return function (target, propertyKey) {
33
+ if (!config) {
34
+ config = {
35
+ propertyBindable: false,
36
+ };
37
+ }
38
+ Reflect.defineMetadata(crtInputPrefix + propertyKey.toString(), config, target.constructor);
39
+ };
40
+ }
41
+
42
+ /**
43
+ * @public
44
+ * @description User-defined components could notify Creatio platform about changes through CrtOutput decorator.
45
+ * @example
46
+ * export class AppComponent {
47
+ * @Input()
48
+ * @CrtOutput()
49
+ * public valueChange;
50
+ * }
51
+ */
52
+ // eslint-disable-next-line @typescript-eslint/naming-convention
53
+ function CrtOutput() {
54
+ return function (target, propertyKey) {
55
+ Reflect.defineMetadata(crtOutputPrefix + propertyKey.toString(), {}, target.constructor);
56
+ };
57
+ }
58
+
59
+ /**
60
+ * @public
61
+ * @description User-defined components receive validationInfo changes through CrtValidationInput decorator.
62
+ * Make sure you have defined input for every validationInfo input.
63
+ * To properly declare validationInfo field:
64
+ * 1. Declare input field inside inputs section. For example `value`
65
+ * 2. In validationInputs section declare same field which ends with ValidationInfo.
66
+ * For previous example `valueValidationInfo`
67
+ *
68
+ * @example
69
+ * export class AppComponent {
70
+ * @CrtInput()
71
+ public value;
72
+ *
73
+ * @CrtValidationInput()
74
+ * public valueValidationInfo;
75
+ * }
76
+ */
77
+ // eslint-disable-next-line @typescript-eslint/naming-convention
78
+ function CrtValidationInput() {
79
+ return function (target, propertyKey) {
80
+ Reflect.defineMetadata(crtValidationInputPrefix + propertyKey.toString(), {}, target.constructor);
81
+ };
82
+ }
83
+
84
+ /**
85
+ * @internal
86
+ */
87
+ function checkTypeNameFormat(type, element) {
88
+ const typeParts = type.split('.');
89
+ if (typeParts.length < 2) {
90
+ throw new Error(`Error when register ${type}. Type property should have format "VendorPrefix.${element}"`);
91
+ }
92
+ }
93
+ /**
94
+ * @internal
95
+ */
96
+ function checkTypeNamePascalCase(type) {
97
+ const [vendor, typeName] = type.split('.');
98
+ const pascalTypeName = toPascalCase(typeName);
99
+ if (!vendor || pascalTypeName !== typeName) {
100
+ throw new Error(`Error when register ${type}. Type property should have Pascal case, e.g. ${vendor + '.' + pascalTypeName}. ` + 'The first letter of each word in a compound word should be capitalized');
101
+ }
102
+ }
103
+ /**
104
+ * @internal
105
+ */
106
+ function checkCrtTypeNamePascalCase(type) {
107
+ const [vendor, typeName] = type.split('.');
108
+ const pascalTypeName = toPascalCase(typeName);
109
+ if (vendor.toLowerCase() === 'crt' && pascalTypeName !== typeName) {
110
+ throw new Error(`Error when register ${type}. Type property should have Pascal case, e.g. ${vendor + '.' + pascalTypeName}. ` + 'The first letter of each word in a compound word should be capitalized');
111
+ }
112
+ }
113
+ /**
114
+ * @internal
115
+ */
116
+ function toPascalCase(source) {
117
+ return upperFirst(camelCase(source));
118
+ }
119
+ /**
120
+ * @internal
121
+ */
122
+ function checkIfTypeRegistered(type, item) {
123
+ if (!item) {
124
+ throw new Error(`Error when resolve ${type}. Type was not registered.`);
125
+ }
126
+ }
127
+ /**
128
+ * @internal
129
+ */
130
+ function checkOnlyOneRegistration(type, item, map) {
131
+ if (map.has(type) && !isEqual(map.get(type), item)) {
132
+ throw new Error(`Error when register ${type}. Element with this type has already exist`);
133
+ }
134
+ }
135
+
136
+ /**
137
+ * @internal
138
+ */
139
+ class InternalRequestHandlerRegistryType {
140
+ static get requestHandlersMap() {
141
+ return this._requestHandlersMap;
142
+ }
143
+ static onAddRequestHandler(handler) {
144
+ this._addItemListeners.push(handler);
145
+ return () => {
146
+ this._addItemListeners.splice(this._addItemListeners.indexOf(handler), 1);
147
+ };
148
+ }
149
+ static onRemoveRequestHandler(handler) {
150
+ this._removeItemListeners.push(handler);
151
+ return () => {
152
+ this._removeItemListeners.splice(this._removeItemListeners.indexOf(handler), 1);
153
+ };
154
+ }
155
+ static addRequestHandler(handlerType, config) {
156
+ if (!this._requestHandlersMap.has(handlerType)) {
157
+ this._requestHandlersMap.set(handlerType, config);
158
+ for (const listener of this._addItemListeners) {
159
+ listener(handlerType, config);
160
+ }
161
+ }
162
+ }
163
+ static removeRequestHandler(handlerType) {
164
+ const config = this._requestHandlersMap.get(handlerType);
165
+ if (config) {
166
+ this._requestHandlersMap.delete(handlerType);
167
+ for (const listener of this._removeItemListeners) {
168
+ listener(handlerType, config);
169
+ }
170
+ }
171
+ }
172
+ }
173
+ InternalRequestHandlerRegistryType._addItemListeners = [];
174
+ InternalRequestHandlerRegistryType._removeItemListeners = [];
175
+ InternalRequestHandlerRegistryType._requestHandlersMap = new Map();
176
+ const global$3 = window;
177
+ global$3.internalRequestHandlerRegistry = InternalRequestHandlerRegistryType;
178
+ /**
179
+ * @internal
180
+ */
181
+ // eslint-disable-next-line @typescript-eslint/naming-convention
182
+ const InternalRequestHandlerRegistry = InternalRequestHandlerRegistryType;
183
+ /**
184
+ * @internal
185
+ */
186
+ class RequestHandlerRegistryService {
187
+ /**
188
+ * Register request handler class.
189
+ * @param config Request handler registration config.
190
+ * @param type Request handler type.
191
+ */
192
+ static register(config, type) {
193
+ const requestType = config.requestType;
194
+ const requestHandlerType = config.type;
195
+ if (!requestType) {
196
+ throw new Error(`Error when register ${requestHandlerType}. Request type not specified.`);
197
+ }
198
+ const requestHandlerMapValue = {
199
+ instanceType: type,
200
+ instanceConfig: config,
201
+ };
202
+ RequestHandlerRegistryService._internalRegistry.addRequestHandler(requestHandlerType, requestHandlerMapValue);
203
+ }
204
+ }
205
+ RequestHandlerRegistryService._internalRegistry = global$3.internalRequestHandlerRegistry ||
206
+ (global$3.internalRequestHandlerRegistry = InternalRequestHandlerRegistryType);
207
+
208
+ /**
209
+ * @internal
210
+ */
211
+ class RequestRegistryService {
212
+ static get requestsRegistrationInfos() {
213
+ return this._requestsRegistrationInfos;
214
+ }
215
+ /**
216
+ * Registers a specified request class.
217
+ * @param config Request registration config.
218
+ * @param type Request type.
219
+ */
220
+ static register(config, type) {
221
+ const requestType = config.type;
222
+ // TODO RND-21723
223
+ RequestRegistryService._requestsMap.set(requestType, type);
224
+ RequestRegistryService._requestsRegistrationInfos.set(requestType, config);
225
+ }
226
+ /**
227
+ * Creates request instance by specified registered request type.
228
+ * @param type Request type.
229
+ * @returns The instance of registered request.
230
+ */
231
+ static get(type) {
232
+ const requestInstanceConstructor = RequestRegistryService._requestsMap.get(type);
233
+ checkIfTypeRegistered(type, requestInstanceConstructor);
234
+ return requestInstanceConstructor && new requestInstanceConstructor();
235
+ }
236
+ }
237
+ RequestRegistryService._requestsMap = new Map();
238
+ RequestRegistryService._requestsRegistrationInfos = new Map();
239
+
240
+ /**
241
+ * @internal
242
+ */
243
+ class GlobalConvertersRegistryService {
244
+ static get(type) {
245
+ if (!this._converters.has(type)) {
246
+ throw new Error(`'${type}' converter doesn't exist`);
247
+ }
248
+ return this._converters.get(type);
249
+ }
250
+ static register(type, ctor) {
251
+ checkTypeNameFormat(type, 'ConverterTypeName');
252
+ checkCrtTypeNamePascalCase(type);
253
+ // TODO RND-21723
254
+ this._converters.set(type, new ctor());
255
+ }
256
+ static clear() {
257
+ this._converters.clear();
258
+ }
259
+ }
260
+ GlobalConvertersRegistryService._converters = new Map();
261
+
262
+ const global$2 = window;
263
+ /**
264
+ * @internal
265
+ */
266
+ class BaseRegistry {
267
+ constructor() {
268
+ this.store = {
269
+ typeInfos: new Map(),
270
+ };
271
+ }
272
+ static get store() {
273
+ if (!this._instance) {
274
+ let globalInstance = get(global$2, this._prefix + this.registryKey);
275
+ if (!globalInstance) {
276
+ globalInstance = new this();
277
+ set(global$2, this._prefix + this.registryKey, globalInstance);
278
+ }
279
+ this._instance = globalInstance;
280
+ }
281
+ return this._instance.store;
282
+ }
283
+ }
284
+ BaseRegistry._prefix = 'creatio.registry.';
285
+
286
+ /**
287
+ * @internal
288
+ */
289
+ const viewElementRegistryKey = 'ViewElementRegistry';
290
+ /**
291
+ * @internal
292
+ */
293
+ class ViewElementRegistry extends BaseRegistry {
294
+ static validate(config) {
295
+ checkTypeNameFormat(config.type, 'ViewElementTypeName');
296
+ checkOnlyOneRegistration(config.type, config, ViewElementRegistry.viewElements);
297
+ }
298
+ static get viewElements() {
299
+ return this.store.typeInfos;
300
+ }
301
+ static register(config) {
302
+ this.viewElements.set(config.type, config);
303
+ }
304
+ static getFormControlRelatesAttribute(type) {
305
+ var _a;
306
+ const config = this.store.typeInfos.get(type);
307
+ return (config && 'formControlConfig' in config && ((_a = config.formControlConfig) === null || _a === void 0 ? void 0 : _a.relatesTo)) || null;
308
+ }
309
+ }
310
+ ViewElementRegistry.registryKey = viewElementRegistryKey;
311
+
312
+ /**
313
+ * @internal
314
+ */
315
+ const interfaceDesignerItemRegistryKey = 'InterfaceDesignerItemRegistry';
316
+ /**
317
+ * @internal
318
+ */
319
+ class InterfaceDesignerItemRegistry extends BaseRegistry {
320
+ static validate(config) {
321
+ checkTypeNameFormat(config.type, 'InterfaceDesignerItemTypeName');
322
+ checkCrtTypeNamePascalCase(config.type);
323
+ checkOnlyOneRegistration(config.type, config, this.interfaceDesignerItemRegistrationInfos);
324
+ }
325
+ static register(config) {
326
+ this.interfaceDesignerItemRegistrationInfos.set(config.type, config);
327
+ }
328
+ static get interfaceDesignerItemRegistrationInfos() {
329
+ return this.store.typeInfos;
330
+ }
331
+ static get(type) {
332
+ return this.interfaceDesignerItemRegistrationInfos.get(type);
333
+ }
334
+ }
335
+ InterfaceDesignerItemRegistry.registryKey = interfaceDesignerItemRegistryKey;
336
+
337
+ const global$1 = window;
338
+ /**
339
+ * @internal
340
+ */
341
+ class BootstrapNotifier {
342
+ constructor() {
343
+ this._subscribers = new Set();
344
+ }
345
+ static get instance() {
346
+ if (!global$1.__crtModuleBootstrapNotifier) {
347
+ global$1.__crtModuleBootstrapNotifier = new BootstrapNotifier();
348
+ }
349
+ return global$1.__crtModuleBootstrapNotifier;
350
+ }
351
+ notify(moduleType) {
352
+ for (const subscriber of this._subscribers.values()) {
353
+ subscriber(moduleType);
354
+ }
355
+ }
356
+ subscribe(subscriber) {
357
+ this._subscribers.add(subscriber);
358
+ const subscription = {
359
+ unsubscribe: () => this._subscribers.delete(subscriber),
360
+ };
361
+ return subscription;
362
+ }
363
+ }
364
+
365
+ /**
366
+ * @internal
367
+ */
368
+ class HandlerChainServicesRegistry extends BaseRegistry {
369
+ static validate({ requestType }) {
370
+ checkTypeNameFormat(requestType, this.registryKey);
371
+ checkCrtTypeNamePascalCase(requestType);
372
+ this.checkUniqueRequestType(requestType);
373
+ }
374
+ static checkUniqueRequestType(requestType) {
375
+ if (this.services.get(requestType)) {
376
+ throw new Error(`${requestType} already registered`);
377
+ }
378
+ }
379
+ static register(config) {
380
+ this.validate(config);
381
+ this.services.set(config.requestType, config);
382
+ }
383
+ static get services() {
384
+ return this.store.typeInfos;
385
+ }
386
+ }
387
+ HandlerChainServicesRegistry.registryKey = 'HandlerChainServicesRegistry';
388
+
389
+ /**
390
+ * @internal
391
+ */
392
+ const designTimeViewElementRegistryKey = 'DesignTimeViewElementRegistry';
393
+ /**
394
+ * @internal
395
+ */
396
+ class DesignTimeViewElementRegistry extends BaseRegistry {
397
+ static validate(config) {
398
+ checkTypeNameFormat(config.type, 'DesignTimeViewElementRegistryItemTypeName');
399
+ checkCrtTypeNamePascalCase(config.type);
400
+ checkOnlyOneRegistration(config.type, config, this.infos);
401
+ }
402
+ static register(config) {
403
+ this.infos.set(config.type, config);
404
+ }
405
+ static getByOverriddenType(type) {
406
+ const item = Array.from(this.infos).find(([_, info]) => info.overrideType === type);
407
+ if (item) {
408
+ return item[1];
409
+ }
410
+ return null;
411
+ }
412
+ static get infos() {
413
+ return this.store.typeInfos;
414
+ }
415
+ }
416
+ DesignTimeViewElementRegistry.registryKey = designTimeViewElementRegistryKey;
417
+
418
+ /**
419
+ * @internal
420
+ */
421
+ function objectDeepKeys(obj) {
422
+ if (obj === null || typeof obj !== 'object') {
423
+ return [];
424
+ }
425
+ return Object.keys(obj)
426
+ .filter((key) => obj[key] instanceof Object)
427
+ .map((key) => objectDeepKeys(obj[key]).map((k) => [key, ...k]))
428
+ .reduce((x, y) => [...x, ...y], Object.keys(obj).map((x) => [x]));
429
+ }
430
+
431
+ const moduleMetadataKey = 'module';
432
+ const viewElementMetadataKey = 'viewElement';
433
+ const interfaceDesignerItemMetadataKey = 'interfaceDesignerItem';
434
+ const requestHandlerMetadataKey = 'requestHandler';
435
+ const designTimeViewElementMetadataKey = 'designTimeViewElement';
436
+ /**
437
+ * @internal
438
+ */
439
+ function setModuleMetadata(metadata, type) {
440
+ Reflect.defineMetadata(moduleMetadataKey, metadata, type);
441
+ registerHandlerChainServices(metadata.handlerChainServices);
442
+ }
443
+ /**
444
+ * @internal
445
+ */
446
+ function registerHandlerChainServices(types) {
447
+ if (types === null || types === void 0 ? void 0 : types.length) {
448
+ types.forEach((type) => {
449
+ const registrationConfig = getHandlerChainServiceMetadata(type);
450
+ HandlerChainServicesRegistry.register(registrationConfig);
451
+ });
452
+ }
453
+ }
454
+ /**
455
+ * @internal
456
+ */
457
+ function getModuleMetadata(type) {
458
+ const metadata = Reflect.getMetadata(moduleMetadataKey, type);
459
+ if (!metadata) {
460
+ throw new Error(`Module metadata was not found on '${type.name}' class`);
461
+ }
462
+ return metadata;
463
+ }
464
+ /**
465
+ * @internal
466
+ */
467
+ function setViewElementMetadata(metadata, type) {
468
+ Reflect.defineMetadata(viewElementMetadataKey, metadata, type);
469
+ }
470
+ /**
471
+ * @internal
472
+ */
473
+ function getViewElementMetadata(type) {
474
+ const metadata = Reflect.getMetadata(viewElementMetadataKey, type);
475
+ if (!metadata) {
476
+ throw new Error(`View element metadata was not found on '${type.name}' class`);
477
+ }
478
+ return metadata;
479
+ }
480
+ /**
481
+ * @internal
482
+ */
483
+ function setInterfaceDesignerItemMetadata(metadata, type) {
484
+ Reflect.defineMetadata(interfaceDesignerItemMetadataKey, metadata, type);
485
+ }
486
+ /**
487
+ * @internal
488
+ */
489
+ function getInterfaceDesignerItemMetadata(type) {
490
+ const metadata = Reflect.getOwnMetadata(interfaceDesignerItemMetadataKey, type);
491
+ if (!metadata) {
492
+ throw new Error(`Interface designer item metadata was not found on '${type.name}' class`);
493
+ }
494
+ return metadata;
495
+ }
496
+ /**
497
+ * @internal
498
+ */
499
+ function setDesignTimeViewElementMetadata(metadata, type) {
500
+ Reflect.defineMetadata(designTimeViewElementMetadataKey, metadata, type);
501
+ }
502
+ /**
503
+ * @internal
504
+ */
505
+ function getDesignTimeViewElementMetadata(type) {
506
+ const metadata = Reflect.getOwnMetadata(designTimeViewElementMetadataKey, type);
507
+ if (!metadata) {
508
+ throw new Error(`Design time view element metadata was not found on '${type.name}' class`);
509
+ }
510
+ return metadata;
511
+ }
512
+ /**
513
+ * @internal
514
+ */
515
+ function hasInterfaceDesignerItemMetadata(type) {
516
+ return Reflect.hasOwnMetadata(interfaceDesignerItemMetadataKey, type);
517
+ }
518
+ /**
519
+ * @internal
520
+ */
521
+ function setRequestHandlerMetadata(metadata, type) {
522
+ Reflect.defineMetadata(requestHandlerMetadataKey, metadata, type);
523
+ }
524
+ /**
525
+ * @internal
526
+ */
527
+ function getRequestHandlerMetadata(type) {
528
+ const metadata = Reflect.getMetadata(requestHandlerMetadataKey, type);
529
+ if (!metadata) {
530
+ throw new Error(`Request handler metadata was not found on '${type.name}' class`);
531
+ }
532
+ return metadata;
533
+ }
534
+ /**
535
+ * @internal
536
+ */
537
+ function getHandlerChainServiceMetadata(typeRef) {
538
+ const requestType = Reflect.getMetadata('requestType', typeRef);
539
+ if (!requestType) {
540
+ throw new Error(`requestType was not found on '${typeRef.name}' class`);
541
+ }
542
+ return { requestType, typeRef };
543
+ }
544
+ /**
545
+ * @internal
546
+ */
547
+ function getCrtInputsMetadata(type) {
548
+ const keys = Reflect.getMetadataKeys(type);
549
+ const crtInputKeys = keys.filter((x) => x.startsWith(crtInputPrefix));
550
+ return Object.fromEntries(crtInputKeys.map((key) => {
551
+ const data = Reflect.getMetadata(key, type);
552
+ return [key.replace(crtInputPrefix, ''), data];
553
+ }));
554
+ }
555
+ /**
556
+ * @internal
557
+ */
558
+ function getCrtOutputsMetadata(type) {
559
+ const keys = Reflect.getMetadataKeys(type);
560
+ const crtOutputKeys = keys.filter((x) => x.startsWith(crtOutputPrefix));
561
+ return Object.fromEntries(crtOutputKeys.map((key) => {
562
+ const data = Reflect.getMetadata(key, type);
563
+ return [key.replace(crtOutputPrefix, ''), data];
564
+ }));
565
+ }
566
+ /**
567
+ * @internal
568
+ */
569
+ function getCrtValidationInputsMetadata(type) {
570
+ const keys = Reflect.getMetadataKeys(type);
571
+ const crtValidationInputKeys = keys.filter((x) => x.startsWith(crtValidationInputPrefix));
572
+ return Object.fromEntries(crtValidationInputKeys.map((key) => {
573
+ const data = Reflect.getMetadata(key, type);
574
+ return [key.replace(crtValidationInputPrefix, ''), data];
575
+ }));
576
+ }
577
+
578
+ /**
579
+ * @public
580
+ */
581
+ class CrtInputRegistrationConfig {
582
+ }
583
+
584
+ /**
585
+ * @public
586
+ * @class BaseRequest
587
+ * @describe Base definition of request.
588
+ * @template TEvent
589
+ */
590
+ class BaseRequest {
591
+ }
592
+
593
+ /**
594
+ * @public
595
+ * @class DataRequest
596
+ * @description Definition of data source request.
597
+ * @extends {BaseRequest} {@link BaseRequest}
598
+ * @property {string} dataSourceName - name of assigned data source.
599
+ */
600
+ class DataRequest extends BaseRequest {
601
+ }
602
+
603
+ /**
604
+ * @public
605
+ */
606
+ class LocalizableValue {
607
+ constructor(key) {
608
+ this.key = key;
609
+ }
610
+ }
611
+
612
+ /**
613
+ * @internal
614
+ */
615
+ function applyLocalizeMetadataFn(obj, localizeMetadata) {
616
+ const localizableEntries = objectDeepKeys(obj)
617
+ .map((path) => ({ path, value: get(obj, path) }))
618
+ .filter(({ value }) => value instanceof LocalizableValue);
619
+ if (localizableEntries.length === 0) {
620
+ return obj;
621
+ }
622
+ const localized = cloneDeep(obj);
623
+ if (!localizeMetadata) {
624
+ console.error("Unable to localize metadata. 'localizeMetadata' bootstrap option was not provided.");
625
+ }
626
+ localizableEntries.forEach(({ path, value }) => {
627
+ var _a;
628
+ const localizedValue = (_a = localizeMetadata === null || localizeMetadata === void 0 ? void 0 : localizeMetadata(value.key)) !== null && _a !== void 0 ? _a : value.key;
629
+ set(localized, path, localizedValue);
630
+ });
631
+ return localized;
632
+ }
633
+
634
+ // noinspection ES6PreferShortImport
635
+ /**
636
+ * @public
637
+ * @description CrtViewElement decorator allows user to declare components in Creatio platform.
638
+ * Make sure component is specified in viewElements section of CrtModule.
639
+ * @param config - registration config. {@link ViewElementRegistrationConfig}.
640
+ *
641
+ * @example
642
+ * @CrtViewElement({
643
+ * type: 'usr.Example',
644
+ * selector: 'usr-example',
645
+ * })
646
+ * export class AppComponent {
647
+ * @Input()
648
+ * @CrtInput()
649
+ * public value!: string;
650
+ * }
651
+ */
652
+ // eslint-disable-next-line @typescript-eslint/naming-convention
653
+ function CrtViewElement(config) {
654
+ return function (type) {
655
+ checkTypeNamePascalCase(config.type);
656
+ const inputs = getCrtInputsMetadata(type);
657
+ const outputs = getCrtOutputsMetadata(type);
658
+ const validationInputs = getCrtValidationInputsMetadata(type);
659
+ const registrationConfig = Object.assign(Object.assign({}, config), { inputs, outputs, validationInputs });
660
+ setViewElementMetadata(registrationConfig, type);
661
+ };
662
+ }
663
+
664
+ /**
665
+ * @public
666
+ * @description CrtModule decorator is a 'container' where user actually setup elements.
667
+ * In could contain viewElements, definitions of other CrtModules.
668
+ * @param moduleDefinition - {@link ModuleDefinition}
669
+ *
670
+ * @example
671
+ * @CrtModule({
672
+ * viewElements: [AppComponent],
673
+ * })
674
+ * @NgModule({
675
+ * declarations: [AppComponent],
676
+ * imports: [BrowserModule],
677
+ * providers: [],
678
+ * })
679
+ * export class AppModule {}
680
+ */
681
+ function CrtModule(moduleDefinition) {
682
+ return (type) => {
683
+ setModuleMetadata(moduleDefinition, type);
684
+ };
685
+ }
686
+
687
+ /**
688
+ * @internal
689
+ */
690
+ var ViewElementGroupType;
691
+ (function (ViewElementGroupType) {
692
+ ViewElementGroupType["Charts"] = "Charts";
693
+ ViewElementGroupType["Components"] = "Components";
694
+ ViewElementGroupType["LayoutElements"] = "LayoutElements";
695
+ ViewElementGroupType["Inputs"] = "Inputs";
696
+ ViewElementGroupType["CustomElements"] = "CustomElements";
697
+ ViewElementGroupType["None"] = "None";
698
+ })(ViewElementGroupType || (ViewElementGroupType = {}));
699
+
700
+ /**
701
+ * @internal
702
+ */
703
+ var ViewElementDataGroupType;
704
+ (function (ViewElementDataGroupType) {
705
+ ViewElementDataGroupType["Data"] = "Data";
706
+ })(ViewElementDataGroupType || (ViewElementDataGroupType = {}));
707
+ /**
708
+ * @internal
709
+ */
710
+ // eslint-disable-next-line @typescript-eslint/naming-convention
711
+ const DesignerToolGroupType = Object.assign(Object.assign({}, ViewElementDataGroupType), ViewElementGroupType);
712
+
713
+ /**
714
+ * @internal
715
+ */
716
+ var DataSourceScope;
717
+ (function (DataSourceScope) {
718
+ DataSourceScope["ViewElement"] = "viewElement";
719
+ DataSourceScope["Page"] = "page";
720
+ })(DataSourceScope || (DataSourceScope = {}));
721
+
722
+ /**
723
+ * @internal
724
+ */
725
+ var ModelInPageAction;
726
+ (function (ModelInPageAction) {
727
+ ModelInPageAction["Edit"] = "edit";
728
+ ModelInPageAction["Add"] = "add";
729
+ ModelInPageAction["Copy"] = "copy";
730
+ })(ModelInPageAction || (ModelInPageAction = {}));
731
+
732
+ // noinspection ES6PreferShortImport
733
+ /**
734
+ * @public
735
+ * @description Decorator to declare design time configuration for view element.
736
+ * @param config - registration config {@link InterfaceDesignerItemDefinition}.
737
+ *
738
+ * @example
739
+ * @CrtViewElement({
740
+ * type: "usr.Example',
741
+ * selector: 'usr-example',
742
+ * })
743
+ * @CrtInterfaceDesignerItem({
744
+ * toolbarConfig: {
745
+ * caption: 'usrExampleCaption',
746
+ * name: 'usrExampleName',
747
+ * icon: require(`!!raw-loader?{esModule:false}!../assets/icon.svg`)
748
+ * hint: 'usrExampleHint',
749
+ * defaultPropertyValues: {
750
+ * value: 'This is default value',
751
+ * },
752
+ * },
753
+ * })
754
+ * @Component({
755
+ * selector: 'usr-example',
756
+ * templateUrl: './app.component.html',
757
+ * styleUrls: ['./app.component.scss'],
758
+ * encapsulation: ViewEncapsulation.ShadowDom,
759
+ * })
760
+ * export class AppComponent {
761
+ * @Input()
762
+ * @CrtInput()
763
+ * public value!: string;
764
+ * }
765
+ */
766
+ // eslint-disable-next-line @typescript-eslint/naming-convention
767
+ function CrtInterfaceDesignerItem(config) {
768
+ return function (type) {
769
+ const registrationConfig = Object.assign(Object.assign({}, config), { typeRef: type });
770
+ registrationConfig.viewElementGroupType = ViewElementGroupType.CustomElements;
771
+ registrationConfig.toolbarConfig.groupType = registrationConfig.viewElementGroupType;
772
+ registrationConfig.typeCaption = registrationConfig.toolbarConfig.caption;
773
+ setInterfaceDesignerItemMetadata(registrationConfig, type);
774
+ };
775
+ }
776
+
777
+ /**
778
+ * @internal
779
+ */
780
+ class NextHandlerAlreadySpecifiedException extends Error {
781
+ constructor() {
782
+ super('Next handler already specified');
783
+ }
784
+ }
785
+
786
+ class ArgumentEmptyException extends Error {
787
+ // region Constructors: Public
788
+ constructor(argumentName) {
789
+ super(`Argument with name '${argumentName}' is empty.`);
790
+ }
791
+ }
792
+
793
+ class ArgumentOutOfRangeException extends Error {
794
+ // region Constructors: Public
795
+ constructor(argumentName) {
796
+ super(`Argument with name '${argumentName}' is out of range.`);
797
+ }
798
+ }
799
+
800
+ class ItemNotFoundException extends Error {
801
+ // region Constructors: Public
802
+ constructor(key) {
803
+ super(`Item with key '${key}' does not exist.`);
804
+ }
805
+ }
806
+
807
+ class ValidationUtilities {
808
+ // region Methods: Public
809
+ static checkArgumentEmpty(argumentName, argumentValue) {
810
+ if (argumentValue === undefined || argumentValue === null) {
811
+ throw new ArgumentEmptyException(argumentName);
812
+ }
813
+ }
814
+ static checkArrayEmpty(argumentName, argumentValue) {
815
+ ValidationUtilities.checkArgumentEmpty(argumentName, argumentValue);
816
+ if (argumentValue.length === 0) {
817
+ throw new ArgumentEmptyException(argumentName);
818
+ }
819
+ }
820
+ static checkStringIsNotEmpty(argumentName, argumentValue) {
821
+ this.checkArgumentEmpty(argumentName, argumentValue);
822
+ if (argumentValue === '') {
823
+ throw new ArgumentEmptyException(argumentName);
824
+ }
825
+ return argumentValue;
826
+ }
827
+ static checkArgumentOutOfRange(argumentName, argumentValue, range) {
828
+ if (range.begin && argumentValue < range.begin) {
829
+ throw new ArgumentOutOfRangeException(argumentName);
830
+ }
831
+ if (range.end && argumentValue > range.end) {
832
+ throw new ArgumentOutOfRangeException(argumentName);
833
+ }
834
+ }
835
+ }
836
+
837
+ /**
838
+ * @internal
839
+ */
840
+ class InternalHandlerChain {
841
+ constructor() {
842
+ this._handlers = [];
843
+ this._handlersCache = new Map();
844
+ this.handlerChain$ = {
845
+ process: (request) => __awaiter(this, void 0, void 0, function* () {
846
+ const handler = this._getHandler(request);
847
+ return handler === null || handler === void 0 ? void 0 : handler.handle(request);
848
+ }),
849
+ register: (info) => {
850
+ this._handlersCache.delete(info.requestType);
851
+ this._handlers.push(info);
852
+ return () => {
853
+ const index = this._handlers.indexOf(info);
854
+ if (index > -1) {
855
+ this._handlers.splice(index, 1);
856
+ this._handlersCache.delete(info.requestType);
857
+ }
858
+ else {
859
+ console.warn(`${info === null || info === void 0 ? void 0 : info.requestType} not found to unsubscribe`);
860
+ }
861
+ };
862
+ },
863
+ };
864
+ }
865
+ _getHandler(request) {
866
+ return this._hasCacheHandler(request) ? this._getCacheHandler(request) : this._buildHandlersChain(request);
867
+ }
868
+ _getCacheHandler(request) {
869
+ const map = this._handlersCache.get(request.type);
870
+ const key = this._getCacheScopesKey(request.scopes);
871
+ return map.get(key);
872
+ }
873
+ _hasCacheHandler(request) {
874
+ const map = this._handlersCache.get(request.type);
875
+ const key = this._getCacheScopesKey(request.scopes);
876
+ return map && map.has(key);
877
+ }
878
+ _getCacheScopesKey(scopes) {
879
+ return (scopes || ['']).join('_');
880
+ }
881
+ _setCacheHandler(request, handler) {
882
+ const map = this._handlersCache.has(request.type)
883
+ ? this._handlersCache.get(request.type)
884
+ : new Map();
885
+ const key = this._getCacheScopesKey(request.scopes);
886
+ map.set(key, handler);
887
+ this._handlersCache.set(request.type, map);
888
+ }
889
+ _buildHandlersChain(request) {
890
+ var _a;
891
+ const handlers = this._handlers.filter((x) => request.type === x.requestType);
892
+ const scopedHandlers = handlers.filter((x) => { var _a; return x.scopes && ((_a = x.scopes) === null || _a === void 0 ? void 0 : _a.length) > 0; });
893
+ const chain = [];
894
+ const requestScopes = [...(request.scopes || [])].reverse();
895
+ for (const requestScope of requestScopes) {
896
+ for (let i = 0; i < scopedHandlers.length; i++) {
897
+ const handler = scopedHandlers[i];
898
+ if ((_a = handler.scopes) === null || _a === void 0 ? void 0 : _a.includes(requestScope)) {
899
+ chain.push(handler);
900
+ scopedHandlers.splice(scopedHandlers.indexOf(handler), 1);
901
+ i--;
902
+ }
903
+ }
904
+ }
905
+ const globalHandlers = handlers.filter((x) => !x.scopes || x.scopes.length === 0);
906
+ chain.push(...globalHandlers);
907
+ const handlerInstances = chain.map((handlerConfig) => handlerConfig.createHandler());
908
+ this._joinHandlersInChain(handlerInstances);
909
+ const result = handlerInstances[0];
910
+ this._setCacheHandler(request, result);
911
+ return result;
912
+ }
913
+ _joinHandlersInChain(handlers) {
914
+ for (let index = 0; index < handlers.length - 1; index++) {
915
+ try {
916
+ handlers[index].setNext(handlers[index + 1]);
917
+ }
918
+ catch (error) {
919
+ if (error instanceof NextHandlerAlreadySpecifiedException) {
920
+ throw new Error('Handler factory should return new instance of ' +
921
+ 'BaseRequestHandler class or its subclass ' +
922
+ '(next handler should not be specified)');
923
+ }
924
+ throw error;
925
+ }
926
+ }
927
+ }
928
+ }
929
+
930
+ const global = window;
931
+ /**
932
+ * @public
933
+ * @class HandlerChainService
934
+ * @classdesc Service to design handlers in chain.
935
+ */
936
+ class HandlerChainService {
937
+ constructor() {
938
+ if (!this._chain) {
939
+ this._createGlobalHandlerChain();
940
+ }
941
+ }
942
+ get _chain() {
943
+ return global.handlerChain;
944
+ }
945
+ set _chain(value) {
946
+ global.handlerChain = value;
947
+ }
948
+ static get instance() {
949
+ return HandlerChainService._instance || (HandlerChainService._instance = new HandlerChainService());
950
+ }
951
+ _createGlobalHandlerChain() {
952
+ this._chain = new InternalHandlerChain();
953
+ }
954
+ /**
955
+ * @internal
956
+ */
957
+ register(requestType, handlerFactory, ...scopes) {
958
+ return this._chain.handlerChain$.register({
959
+ createHandler: handlerFactory,
960
+ requestType,
961
+ scopes,
962
+ });
963
+ }
964
+ /**
965
+ * @description Method to process passed request
966
+ * @param request - {@link BaseRequest}
967
+ * @return `Promise<unknown>`
968
+ */
969
+ process(request) {
970
+ return this._chain.handlerChain$.process(request);
971
+ }
972
+ }
973
+
974
+ /**
975
+ * @internal
976
+ */
977
+ // eslint-disable-next-line @typescript-eslint/naming-convention
978
+ function ImplementUsingHandlerChain(config) {
979
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
980
+ return function (target, method, descriptor) {
981
+ const methodImplementation = function (...args) {
982
+ return HandlerChainService.instance.process({
983
+ type: (config === null || config === void 0 ? void 0 : config.requestType) ? config.requestType : this.requestType,
984
+ method: (config === null || config === void 0 ? void 0 : config.methodName) ? config.methodName : method,
985
+ args,
986
+ });
987
+ };
988
+ if (descriptor) {
989
+ descriptor.value = methodImplementation;
990
+ }
991
+ else {
992
+ target[method] = methodImplementation;
993
+ }
994
+ };
995
+ }
996
+
997
+ /**
998
+ * @internal
999
+ */
1000
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1001
+ function CrtRequestHandler(config) {
1002
+ return function (type) {
1003
+ checkTypeNameFormat(config.type, 'RequestHandlerTypeName');
1004
+ checkCrtTypeNamePascalCase(config.type);
1005
+ setRequestHandlerMetadata(config, type);
1006
+ };
1007
+ }
1008
+
1009
+ /**
1010
+ * @internal
1011
+ */
1012
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1013
+ function CrtRequest(config) {
1014
+ return function (type) {
1015
+ checkTypeNameFormat(config.type, 'RequestTypeName');
1016
+ checkCrtTypeNamePascalCase(config.type);
1017
+ RequestRegistryService.register(config, type);
1018
+ };
1019
+ }
1020
+
1021
+ /**
1022
+ * @internal
1023
+ */
1024
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1025
+ function CrtConverter(name) {
1026
+ return function (type) {
1027
+ GlobalConvertersRegistryService.register(name, type);
1028
+ };
1029
+ }
1030
+
1031
+ /**
1032
+ * @internal
1033
+ */
1034
+ function CrtDesignTimeViewElement(config) {
1035
+ return function (type) {
1036
+ const registrationConfig = Object.assign(Object.assign({}, config), { typeRef: type });
1037
+ setDesignTimeViewElementMetadata(registrationConfig, type);
1038
+ };
1039
+ }
1040
+
1041
+ var DataValueType;
1042
+ (function (DataValueType) {
1043
+ DataValueType[DataValueType["Guid"] = 0] = "Guid";
1044
+ DataValueType[DataValueType["Text"] = 1] = "Text";
1045
+ DataValueType[DataValueType["Integer"] = 4] = "Integer";
1046
+ DataValueType[DataValueType["Float"] = 5] = "Float";
1047
+ DataValueType[DataValueType["Money"] = 6] = "Money";
1048
+ DataValueType[DataValueType["DateTime"] = 7] = "DateTime";
1049
+ DataValueType[DataValueType["Date"] = 8] = "Date";
1050
+ DataValueType[DataValueType["Time"] = 9] = "Time";
1051
+ DataValueType[DataValueType["Lookup"] = 10] = "Lookup";
1052
+ DataValueType[DataValueType["Enum"] = 11] = "Enum";
1053
+ DataValueType[DataValueType["Boolean"] = 12] = "Boolean";
1054
+ DataValueType[DataValueType["Blob"] = 13] = "Blob";
1055
+ DataValueType[DataValueType["Image"] = 14] = "Image";
1056
+ DataValueType[DataValueType["CUSTOM_OBJECT"] = 15] = "CUSTOM_OBJECT";
1057
+ DataValueType[DataValueType["IMAGELOOKUP"] = 16] = "IMAGELOOKUP";
1058
+ DataValueType[DataValueType["COLLECTION"] = 17] = "COLLECTION";
1059
+ DataValueType[DataValueType["COLOR"] = 18] = "COLOR";
1060
+ DataValueType[DataValueType["LOCALIZABLE_STRING"] = 19] = "LOCALIZABLE_STRING";
1061
+ DataValueType[DataValueType["ENTITY"] = 20] = "ENTITY";
1062
+ DataValueType[DataValueType["ENTITY_COLLECTION"] = 21] = "ENTITY_COLLECTION";
1063
+ DataValueType[DataValueType["ENTITY_COLUMN_MAPPING_COLLECTION"] = 22] = "ENTITY_COLUMN_MAPPING_COLLECTION";
1064
+ DataValueType[DataValueType["HASH_TEXT"] = 23] = "HASH_TEXT";
1065
+ DataValueType[DataValueType["SECURE_TEXT"] = 24] = "SECURE_TEXT";
1066
+ DataValueType[DataValueType["FILE"] = 25] = "FILE";
1067
+ DataValueType[DataValueType["MAPPING"] = 26] = "MAPPING";
1068
+ DataValueType[DataValueType["SHORT_TEXT"] = 27] = "SHORT_TEXT";
1069
+ DataValueType[DataValueType["MEDIUM_TEXT"] = 28] = "MEDIUM_TEXT";
1070
+ DataValueType[DataValueType["MAXSIZE_TEXT"] = 29] = "MAXSIZE_TEXT";
1071
+ DataValueType[DataValueType["LONG_TEXT"] = 30] = "LONG_TEXT";
1072
+ DataValueType[DataValueType["FLOAT1"] = 31] = "FLOAT1";
1073
+ DataValueType[DataValueType["FLOAT2"] = 32] = "FLOAT2";
1074
+ DataValueType[DataValueType["FLOAT3"] = 33] = "FLOAT3";
1075
+ DataValueType[DataValueType["FLOAT4"] = 34] = "FLOAT4";
1076
+ DataValueType[DataValueType["LOCALIZABLE_PARAMETER_VALUES_LIST"] = 35] = "LOCALIZABLE_PARAMETER_VALUES_LIST";
1077
+ DataValueType[DataValueType["METADATA_TEXT"] = 36] = "METADATA_TEXT";
1078
+ DataValueType[DataValueType["STAGE_INDICATOR"] = 37] = "STAGE_INDICATOR";
1079
+ DataValueType[DataValueType["OBJECT_LIST"] = 38] = "OBJECT_LIST";
1080
+ DataValueType[DataValueType["COMPOSITE_OBJECT_LIST"] = 39] = "COMPOSITE_OBJECT_LIST";
1081
+ DataValueType[DataValueType["FLOAT8"] = 40] = "FLOAT8";
1082
+ DataValueType[DataValueType["PHONE_TEXT"] = 42] = "PHONE_TEXT";
1083
+ })(DataValueType || (DataValueType = {}));
1084
+
1085
+ var AggregationType;
1086
+ (function (AggregationType) {
1087
+ /** Aggregation function type not defined. */
1088
+ AggregationType[AggregationType["None"] = 0] = "None";
1089
+ /** Aggregation function type not defined. */
1090
+ AggregationType[AggregationType["Count"] = 1] = "Count";
1091
+ /** Sum of values of all elements. */
1092
+ AggregationType[AggregationType["Sum"] = 2] = "Sum";
1093
+ /** Average value for all elements. */
1094
+ AggregationType[AggregationType["Avg"] = 3] = "Avg";
1095
+ /** The minimum value among all elements. */
1096
+ AggregationType[AggregationType["Min"] = 4] = "Min";
1097
+ /** The maximum value among all elements. */
1098
+ AggregationType[AggregationType["Max"] = 5] = "Max";
1099
+ /** Top one record from collection. */
1100
+ AggregationType[AggregationType["TopOne"] = 6] = "TopOne";
1101
+ })(AggregationType || (AggregationType = {}));
1102
+
1103
+ var AggregationFunction;
1104
+ (function (AggregationFunction) {
1105
+ /** Aggregation function type not defined. */
1106
+ AggregationFunction["None"] = "";
1107
+ /** Aggregation function type not defined. */
1108
+ AggregationFunction["Count"] = "Count";
1109
+ /** Sum of values of all elements. */
1110
+ AggregationFunction["Sum"] = "Sum";
1111
+ /** Average value for all elements. */
1112
+ AggregationFunction["Avg"] = "Avg";
1113
+ /** The minimum value among all elements. */
1114
+ AggregationFunction["Min"] = "Min";
1115
+ /** The maximum value among all elements. */
1116
+ AggregationFunction["Max"] = "Max";
1117
+ /** Top one record from collection. */
1118
+ AggregationFunction["TopOne"] = "TopOne";
1119
+ })(AggregationFunction || (AggregationFunction = {}));
1120
+
1121
+ var LogicalOperatorType;
1122
+ (function (LogicalOperatorType) {
1123
+ LogicalOperatorType[LogicalOperatorType["And"] = 0] = "And";
1124
+ LogicalOperatorType[LogicalOperatorType["Or"] = 1] = "Or";
1125
+ })(LogicalOperatorType || (LogicalOperatorType = {}));
1126
+
1127
+ var AggregationEvalType;
1128
+ (function (AggregationEvalType) {
1129
+ /** The scope of the aggregating function is not defined. */
1130
+ AggregationEvalType[AggregationEvalType["None"] = 0] = "None";
1131
+ /** Applies to all elements. */
1132
+ AggregationEvalType[AggregationEvalType["All"] = 1] = "All";
1133
+ /** Applies to unique values. */
1134
+ AggregationEvalType[AggregationEvalType["Distinct"] = 2] = "Distinct";
1135
+ })(AggregationEvalType || (AggregationEvalType = {}));
1136
+
1137
+ var ArithmeticOperation;
1138
+ (function (ArithmeticOperation) {
1139
+ /** Addition. */
1140
+ ArithmeticOperation[ArithmeticOperation["Addition"] = 0] = "Addition";
1141
+ /** Subtraction. */
1142
+ ArithmeticOperation[ArithmeticOperation["Subtraction"] = 1] = "Subtraction";
1143
+ /** Multiplication. */
1144
+ ArithmeticOperation[ArithmeticOperation["Multiplication"] = 2] = "Multiplication";
1145
+ /** Division. */
1146
+ ArithmeticOperation[ArithmeticOperation["Division"] = 3] = "Division";
1147
+ })(ArithmeticOperation || (ArithmeticOperation = {}));
1148
+
1149
+ var ComparisonType;
1150
+ (function (ComparisonType) {
1151
+ ComparisonType[ComparisonType["Between"] = 0] = "Between";
1152
+ ComparisonType[ComparisonType["Contain"] = 11] = "Contain";
1153
+ ComparisonType[ComparisonType["End_with"] = 13] = "End_with";
1154
+ ComparisonType[ComparisonType["Equal"] = 3] = "Equal";
1155
+ ComparisonType[ComparisonType["Exists"] = 15] = "Exists";
1156
+ ComparisonType[ComparisonType["Greater"] = 7] = "Greater";
1157
+ ComparisonType[ComparisonType["Greater_or_equal"] = 8] = "Greater_or_equal";
1158
+ ComparisonType[ComparisonType["Is_not_null"] = 2] = "Is_not_null";
1159
+ ComparisonType[ComparisonType["Is_null"] = 1] = "Is_null";
1160
+ ComparisonType[ComparisonType["Less"] = 5] = "Less";
1161
+ ComparisonType[ComparisonType["Less_or_equal"] = 6] = "Less_or_equal";
1162
+ ComparisonType[ComparisonType["Not_contain"] = 12] = "Not_contain";
1163
+ ComparisonType[ComparisonType["Not_end_with"] = 14] = "Not_end_with";
1164
+ ComparisonType[ComparisonType["Not_equal"] = 4] = "Not_equal";
1165
+ ComparisonType[ComparisonType["Not_exists"] = 16] = "Not_exists";
1166
+ ComparisonType[ComparisonType["Not_start_with"] = 10] = "Not_start_with";
1167
+ ComparisonType[ComparisonType["Start_with"] = 9] = "Start_with";
1168
+ })(ComparisonType || (ComparisonType = {}));
1169
+
1170
+ var DatePartType;
1171
+ (function (DatePartType) {
1172
+ /** Empty value. */
1173
+ DatePartType[DatePartType["None"] = 0] = "None";
1174
+ /** Day. */
1175
+ DatePartType[DatePartType["Day"] = 1] = "Day";
1176
+ /** Week. */
1177
+ DatePartType[DatePartType["Week"] = 2] = "Week";
1178
+ /** Month. */
1179
+ DatePartType[DatePartType["Month"] = 3] = "Month";
1180
+ /** Year. */
1181
+ DatePartType[DatePartType["Year"] = 4] = "Year";
1182
+ /** Day of the week. */
1183
+ DatePartType[DatePartType["WeekDay"] = 5] = "WeekDay";
1184
+ /** Hour. */
1185
+ DatePartType[DatePartType["Hour"] = 6] = "Hour";
1186
+ /** Minute. */
1187
+ DatePartType[DatePartType["HourMinute"] = 7] = "HourMinute";
1188
+ })(DatePartType || (DatePartType = {}));
1189
+
1190
+ var ExpressionType;
1191
+ (function (ExpressionType) {
1192
+ ExpressionType[ExpressionType["SchemaColumn"] = 0] = "SchemaColumn";
1193
+ ExpressionType[ExpressionType["Function"] = 1] = "Function";
1194
+ ExpressionType[ExpressionType["Parameter"] = 2] = "Parameter";
1195
+ ExpressionType[ExpressionType["SubQuery"] = 3] = "SubQuery";
1196
+ ExpressionType[ExpressionType["ArithmeticOperation"] = 4] = "ArithmeticOperation";
1197
+ })(ExpressionType || (ExpressionType = {}));
1198
+
1199
+ var FilterType;
1200
+ (function (FilterType) {
1201
+ FilterType[FilterType["None"] = 0] = "None";
1202
+ FilterType[FilterType["Compare"] = 1] = "Compare";
1203
+ FilterType[FilterType["IsNull"] = 2] = "IsNull";
1204
+ FilterType[FilterType["Between"] = 3] = "Between";
1205
+ FilterType[FilterType["In"] = 4] = "In";
1206
+ FilterType[FilterType["Exists"] = 5] = "Exists";
1207
+ FilterType[FilterType["FilterGroup"] = 6] = "FilterGroup";
1208
+ })(FilterType || (FilterType = {}));
1209
+
1210
+ var FunctionType;
1211
+ (function (FunctionType) {
1212
+ FunctionType[FunctionType["None"] = 0] = "None";
1213
+ /** Substitution by macro. */
1214
+ FunctionType[FunctionType["Macros"] = 1] = "Macros";
1215
+ /** Aggregating function. */
1216
+ FunctionType[FunctionType["Aggregation"] = 2] = "Aggregation";
1217
+ /** Date fragment. */
1218
+ FunctionType[FunctionType["DatePart"] = 3] = "DatePart";
1219
+ /** The size of the value in bytes, used for binary data. */
1220
+ FunctionType[FunctionType["Length"] = 4] = "Length";
1221
+ /** Window query function */
1222
+ FunctionType[FunctionType["Window"] = 5] = "Window";
1223
+ })(FunctionType || (FunctionType = {}));
1224
+
1225
+ var OrderDirection;
1226
+ (function (OrderDirection) {
1227
+ OrderDirection[OrderDirection["None"] = 0] = "None";
1228
+ OrderDirection[OrderDirection["Asc"] = 1] = "Asc";
1229
+ OrderDirection[OrderDirection["Desc"] = 2] = "Desc";
1230
+ })(OrderDirection || (OrderDirection = {}));
1231
+
1232
+ var QueryMacrosType;
1233
+ (function (QueryMacrosType) {
1234
+ /** Macro type not defined. */
1235
+ QueryMacrosType[QueryMacrosType["None"] = 0] = "None";
1236
+ /** Current user. */
1237
+ QueryMacrosType[QueryMacrosType["CurrentUser"] = 1] = "CurrentUser";
1238
+ /** Current user contact. */
1239
+ QueryMacrosType[QueryMacrosType["CurrentUserContact"] = 2] = "CurrentUserContact";
1240
+ /** Yesterday. */
1241
+ QueryMacrosType[QueryMacrosType["Yesterday"] = 3] = "Yesterday";
1242
+ /** Today. */
1243
+ QueryMacrosType[QueryMacrosType["Today"] = 4] = "Today";
1244
+ /** Tomorrow. */
1245
+ QueryMacrosType[QueryMacrosType["Tomorrow"] = 5] = "Tomorrow";
1246
+ /** Previous week. */
1247
+ QueryMacrosType[QueryMacrosType["PreviousWeek"] = 6] = "PreviousWeek";
1248
+ /** This week. */
1249
+ QueryMacrosType[QueryMacrosType["CurrentWeek"] = 7] = "CurrentWeek";
1250
+ /** Next week. */
1251
+ QueryMacrosType[QueryMacrosType["NextWeek"] = 8] = "NextWeek";
1252
+ /** Previous month. */
1253
+ QueryMacrosType[QueryMacrosType["PreviousMonth"] = 9] = "PreviousMonth";
1254
+ /** Current month. */
1255
+ QueryMacrosType[QueryMacrosType["CurrentMonth"] = 10] = "CurrentMonth";
1256
+ /** Next month. */
1257
+ QueryMacrosType[QueryMacrosType["NextMonth"] = 11] = "NextMonth";
1258
+ /** Previous quarter. */
1259
+ QueryMacrosType[QueryMacrosType["PreviousQuarter"] = 12] = "PreviousQuarter";
1260
+ /** Current quarter. */
1261
+ QueryMacrosType[QueryMacrosType["CurrentQuarter"] = 13] = "CurrentQuarter";
1262
+ /** Next quarter. */
1263
+ QueryMacrosType[QueryMacrosType["NextQuarter"] = 14] = "NextQuarter";
1264
+ /** Previous half of the year. */
1265
+ QueryMacrosType[QueryMacrosType["PreviousHalfYear"] = 15] = "PreviousHalfYear";
1266
+ /** Current half-year. */
1267
+ QueryMacrosType[QueryMacrosType["CurrentHalfYear"] = 16] = "CurrentHalfYear";
1268
+ /** Next half-year. */
1269
+ QueryMacrosType[QueryMacrosType["NextHalfYear"] = 17] = "NextHalfYear";
1270
+ /** Last year. */
1271
+ QueryMacrosType[QueryMacrosType["PreviousYear"] = 18] = "PreviousYear";
1272
+ /** This year. */
1273
+ QueryMacrosType[QueryMacrosType["CurrentYear"] = 19] = "CurrentYear";
1274
+ /** Previous hour. */
1275
+ QueryMacrosType[QueryMacrosType["PreviousHour"] = 20] = "PreviousHour";
1276
+ /** Current hour. */
1277
+ QueryMacrosType[QueryMacrosType["CurrentHour"] = 21] = "CurrentHour";
1278
+ /** Next hour. */
1279
+ QueryMacrosType[QueryMacrosType["NextHour"] = 22] = "NextHour";
1280
+ /** Next year. */
1281
+ QueryMacrosType[QueryMacrosType["NextYear"] = 23] = "NextYear";
1282
+ /** Next N Days. */
1283
+ QueryMacrosType[QueryMacrosType["NextNDays"] = 24] = "NextNDays";
1284
+ /** Previous N days. */
1285
+ QueryMacrosType[QueryMacrosType["PreviousNDays"] = 25] = "PreviousNDays";
1286
+ /** Next N hours. */
1287
+ QueryMacrosType[QueryMacrosType["NextNHours"] = 26] = "NextNHours";
1288
+ /** Previous N hours. */
1289
+ QueryMacrosType[QueryMacrosType["PreviousNHours"] = 27] = "PreviousNHours";
1290
+ /** Primary column. */
1291
+ QueryMacrosType[QueryMacrosType["PrimaryColumn"] = 34] = "PrimaryColumn";
1292
+ /** Primary displayed column. */
1293
+ QueryMacrosType[QueryMacrosType["PrimaryDisplayColumn"] = 35] = "PrimaryDisplayColumn";
1294
+ /** Primary image display column. */
1295
+ QueryMacrosType[QueryMacrosType["PrimaryImageColumn"] = 36] = "PrimaryImageColumn";
1296
+ /** Anniversary today. */
1297
+ QueryMacrosType[QueryMacrosType["DayOfYearToday"] = 37] = "DayOfYearToday";
1298
+ /** Anniversary on the date computed as today plus days offset. */
1299
+ QueryMacrosType[QueryMacrosType["DayOfYearTodayPlusDaysOffset"] = 38] = "DayOfYearTodayPlusDaysOffset";
1300
+ /** Anniversary on the next several days. */
1301
+ QueryMacrosType[QueryMacrosType["NextNDaysOfYear"] = 39] = "NextNDaysOfYear";
1302
+ /** Anniversary on the previous several days. */
1303
+ QueryMacrosType[QueryMacrosType["PreviousNDaysOfYear"] = 40] = "PreviousNDaysOfYear";
1304
+ })(QueryMacrosType || (QueryMacrosType = {}));
1305
+
1306
+ class BaseExpression {
1307
+ constructor(config) {
1308
+ this.isBlock = false;
1309
+ this.isBlock = config === null || config === void 0 ? void 0 : config.isBlock;
1310
+ }
1311
+ }
1312
+
1313
+ class ArithmeticExpression extends BaseExpression {
1314
+ constructor(config) {
1315
+ super(config);
1316
+ this.expressionType = ExpressionType.ArithmeticOperation;
1317
+ this.arithmeticOperation = config === null || config === void 0 ? void 0 : config.arithmeticOperation;
1318
+ this.leftArithmeticOperand = config === null || config === void 0 ? void 0 : config.leftArithmeticOperand.clone();
1319
+ this.rightArithmeticOperand = config === null || config === void 0 ? void 0 : config.rightArithmeticOperand.clone();
1320
+ }
1321
+ clone() {
1322
+ return new ArithmeticExpression(this);
1323
+ }
1324
+ }
1325
+
1326
+ class ColumnExpression extends BaseExpression {
1327
+ constructor(config) {
1328
+ super(config);
1329
+ this.expressionType = ExpressionType.SchemaColumn;
1330
+ this.columnPath = config === null || config === void 0 ? void 0 : config.columnPath;
1331
+ }
1332
+ clone() {
1333
+ return new ColumnExpression(this);
1334
+ }
1335
+ }
1336
+
1337
+ class FunctionExpression extends BaseExpression {
1338
+ constructor(config) {
1339
+ super(config);
1340
+ this.expressionType = ExpressionType.Function;
1341
+ }
1342
+ }
1343
+
1344
+ class ArgumentFunctionExpression extends FunctionExpression {
1345
+ constructor(config) {
1346
+ super(config);
1347
+ this.functionArgument = config === null || config === void 0 ? void 0 : config.functionArgument.clone();
1348
+ }
1349
+ }
1350
+
1351
+ class AggregationFunctionExpression extends ArgumentFunctionExpression {
1352
+ constructor(config) {
1353
+ super(config);
1354
+ this.functionType = FunctionType.Aggregation;
1355
+ this.aggregationType = config === null || config === void 0 ? void 0 : config.aggregationType;
1356
+ this.aggregationEvalType = config === null || config === void 0 ? void 0 : config.aggregationEvalType;
1357
+ }
1358
+ clone() {
1359
+ return new AggregationFunctionExpression(this);
1360
+ }
1361
+ }
1362
+
1363
+ class DatePartFunctionExpression extends ArgumentFunctionExpression {
1364
+ constructor(config) {
1365
+ super(config);
1366
+ this.functionType = FunctionType.DatePart;
1367
+ this.datePartType = config === null || config === void 0 ? void 0 : config.datePartType;
1368
+ }
1369
+ clone() {
1370
+ return new DatePartFunctionExpression(this);
1371
+ }
1372
+ }
1373
+
1374
+ class LengthFunctionExpression extends ArgumentFunctionExpression {
1375
+ constructor(config) {
1376
+ super(config);
1377
+ this.functionType = FunctionType.Length;
1378
+ }
1379
+ clone() {
1380
+ return new LengthFunctionExpression(this);
1381
+ }
1382
+ }
1383
+
1384
+ class MacrosFunctionExpression extends FunctionExpression {
1385
+ constructor(config) {
1386
+ super(config);
1387
+ this.functionType = FunctionType.Macros;
1388
+ this.macrosType = config === null || config === void 0 ? void 0 : config.macrosType;
1389
+ }
1390
+ clone() {
1391
+ return new MacrosFunctionExpression(this);
1392
+ }
1393
+ }
1394
+
1395
+ class WindowFunctionExpression extends ArgumentFunctionExpression {
1396
+ constructor(config) {
1397
+ super(config);
1398
+ this.functionType = FunctionType.Window;
1399
+ }
1400
+ clone() {
1401
+ return new WindowFunctionExpression(this);
1402
+ }
1403
+ }
1404
+
1405
+ class ParameterExpression extends BaseExpression {
1406
+ constructor(config) {
1407
+ var _a;
1408
+ super(config);
1409
+ this.expressionType = ExpressionType.Parameter;
1410
+ const value = config === null || config === void 0 ? void 0 : config.value;
1411
+ if (value instanceof Date) {
1412
+ const cloneDate = new Date();
1413
+ cloneDate.setTime(value.getTime());
1414
+ this.value = cloneDate;
1415
+ }
1416
+ else if (!value) {
1417
+ this.value = value;
1418
+ }
1419
+ else {
1420
+ this.value = typeof value === 'object' ? Object.assign({}, value) : value;
1421
+ }
1422
+ this.dataValueType = (_a = config === null || config === void 0 ? void 0 : config.dataValueType) !== null && _a !== void 0 ? _a : DataValueType.Text;
1423
+ }
1424
+ get parameter() {
1425
+ return Object.assign({ dataValueType: this.dataValueType }, this._getParameterValueMetadata());
1426
+ }
1427
+ _convertStringToBlobArray(str) {
1428
+ const out = [];
1429
+ let position = 0;
1430
+ for (let i = 0; i < str.length; i++) {
1431
+ const code = str.charCodeAt(i);
1432
+ if (code < 128) {
1433
+ out[position++] = String.fromCharCode(code);
1434
+ }
1435
+ else if (code < 2048) {
1436
+ /* eslint-disable no-bitwise */
1437
+ out[position++] = String.fromCharCode((code >> 6) | 192);
1438
+ out[position++] = String.fromCharCode((code & 63) | 128);
1439
+ }
1440
+ else {
1441
+ out[position++] = String.fromCharCode((code >> 12) | 224);
1442
+ out[position++] = String.fromCharCode(((code >> 6) & 63) | 128);
1443
+ out[position++] = String.fromCharCode((code & 63) | 128);
1444
+ /* eslint-enable no-bitwise */
1445
+ }
1446
+ }
1447
+ return out;
1448
+ }
1449
+ _getParameterValueMetadata() {
1450
+ if (this.dataValueType === DataValueType.Blob) {
1451
+ return {
1452
+ arrayValue: !this.value ? [] : this._convertStringToBlobArray(this.value),
1453
+ };
1454
+ }
1455
+ else {
1456
+ return {
1457
+ value: this.value,
1458
+ };
1459
+ }
1460
+ }
1461
+ clone() {
1462
+ return new ParameterExpression(this);
1463
+ }
1464
+ }
1465
+ __decorate([
1466
+ Exclude(),
1467
+ __metadata("design:type", Object)
1468
+ ], ParameterExpression.prototype, "value", void 0);
1469
+ __decorate([
1470
+ Exclude(),
1471
+ __metadata("design:type", Number)
1472
+ ], ParameterExpression.prototype, "dataValueType", void 0);
1473
+ __decorate([
1474
+ Expose(),
1475
+ __metadata("design:type", Object),
1476
+ __metadata("design:paramtypes", [])
1477
+ ], ParameterExpression.prototype, "parameter", null);
1478
+
1479
+ class SubQueryExpression extends BaseExpression {
1480
+ constructor(config) {
1481
+ super(config);
1482
+ this.expressionType = ExpressionType.SubQuery;
1483
+ this.columnPath = config === null || config === void 0 ? void 0 : config.columnPath;
1484
+ const subFilter = config === null || config === void 0 ? void 0 : config.subFilters;
1485
+ this.subFilters = typeof (subFilter === null || subFilter === void 0 ? void 0 : subFilter.clone) === 'function' ? subFilter.clone() : subFilter;
1486
+ this.subOrderDirection = config.subOrderDirection;
1487
+ this.subOrderColumn = config.subOrderColumn;
1488
+ }
1489
+ clone() {
1490
+ return new SubQueryExpression(this);
1491
+ }
1492
+ }
1493
+
1494
+ class AggregationSubQueryExpression extends SubQueryExpression {
1495
+ constructor(config) {
1496
+ super(config);
1497
+ this.aggregationType = config === null || config === void 0 ? void 0 : config.aggregationType;
1498
+ }
1499
+ clone() {
1500
+ return new AggregationSubQueryExpression(this);
1501
+ }
1502
+ }
1503
+
1504
+ const EXPRESSION_TYPE_MOCK = -1;
1505
+ class ExpressionMock extends BaseExpression {
1506
+ constructor(config) {
1507
+ super(config || {});
1508
+ this.expressionType = EXPRESSION_TYPE_MOCK;
1509
+ }
1510
+ // eslint-disable-next-line @typescript-eslint/ban-types
1511
+ get plainObject() {
1512
+ return classToPlain(this, { exposeUnsetFields: false, excludePrefixes: ['_'] });
1513
+ }
1514
+ clone() {
1515
+ return new ExpressionMock(this);
1516
+ }
1517
+ }
1518
+
1519
+ class BaseFilter {
1520
+ constructor(filterType) {
1521
+ this.isEnabled = true;
1522
+ this.trimDateTimeParameterToDate = false;
1523
+ this.filterType = filterType;
1524
+ }
1525
+ }
1526
+
1527
+ class FilterMock extends BaseFilter {
1528
+ constructor(filterType = FilterType.None) {
1529
+ super(filterType);
1530
+ }
1531
+ // eslint-disable-next-line @typescript-eslint/ban-types
1532
+ get plainObject() {
1533
+ return classToPlain(this, { exposeUnsetFields: false, excludePrefixes: ['_'] });
1534
+ }
1535
+ clone() {
1536
+ return new FilterMock(this.filterType);
1537
+ }
1538
+ }
1539
+
1540
+ class SingleFilter extends BaseFilter {
1541
+ constructor(filterType, comparisonType, leftExpression) {
1542
+ super(filterType);
1543
+ this.comparisonType = comparisonType;
1544
+ this.leftExpression = leftExpression.clone();
1545
+ }
1546
+ }
1547
+
1548
+ class CompareFilter extends SingleFilter {
1549
+ constructor(comparisonType, leftExpression, rightExpression) {
1550
+ super(FilterType.Compare, comparisonType, leftExpression);
1551
+ this.rightExpression = rightExpression.clone();
1552
+ }
1553
+ clone() {
1554
+ return new CompareFilter(this.comparisonType, this.leftExpression, this.rightExpression);
1555
+ }
1556
+ }
1557
+
1558
+ /**
1559
+ * Empty Guid constant.
1560
+ * @internal
1561
+ */
1562
+ const EMPTY_GUID = '00000000-0000-0000-0000-000000000000';
1563
+ /**
1564
+ * Regular expression for Guid validation.
1565
+ * @internal
1566
+ */
1567
+ const validator = new RegExp('^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$', 'i');
1568
+ /**
1569
+ * Generates guid part.
1570
+ * @param length Part length.
1571
+ * @internal
1572
+ */
1573
+ function generateGuidPart(length) {
1574
+ let out = '';
1575
+ for (let i = 0; i < length; i++) {
1576
+ // eslint-disable-next-line no-bitwise
1577
+ out += (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
1578
+ }
1579
+ return out;
1580
+ }
1581
+ /**
1582
+ * Generates new Guid.
1583
+ * @internal
1584
+ */
1585
+ function generateGuid() {
1586
+ return [
1587
+ generateGuidPart(2),
1588
+ generateGuidPart(1),
1589
+ generateGuidPart(1),
1590
+ generateGuidPart(1),
1591
+ generateGuidPart(3),
1592
+ ].join('-');
1593
+ }
1594
+ /**
1595
+ * Checks if value is Guid.
1596
+ * @param value Value for check.
1597
+ * @internal
1598
+ */
1599
+ function isGuid(value) {
1600
+ return value && validator.test(value);
1601
+ }
1602
+ /**
1603
+ * Checks if Guid is empty value or equal to EMPTY_GUID.
1604
+ * @param guid Guid for check.
1605
+ * @internal
1606
+ */
1607
+ function isEmptyGuid(guid) {
1608
+ return !guid || guid === EMPTY_GUID;
1609
+ }
1610
+
1611
+ class ExistsFilter extends SingleFilter {
1612
+ constructor(leftExpression, subFilters, comparisonType = ComparisonType.Exists, isAggregative = true) {
1613
+ super(FilterType.Exists, comparisonType, leftExpression);
1614
+ this.subFilters = subFilters === null || subFilters === void 0 ? void 0 : subFilters.clone();
1615
+ this.isAggregative = isAggregative;
1616
+ }
1617
+ clone() {
1618
+ return new ExistsFilter(this.leftExpression, this.subFilters, this.comparisonType, this.isAggregative);
1619
+ }
1620
+ }
1621
+
1622
+ class InFilter extends SingleFilter {
1623
+ constructor(comparisonType, leftExpression, rightExpressions) {
1624
+ super(FilterType.In, comparisonType, leftExpression);
1625
+ this.rightExpressions = rightExpressions.map((expression) => expression.clone());
1626
+ }
1627
+ clone() {
1628
+ return new InFilter(this.comparisonType, this.leftExpression, this.rightExpressions);
1629
+ }
1630
+ }
1631
+
1632
+ class IsNullFilter extends SingleFilter {
1633
+ constructor(comparisonType, leftExpression) {
1634
+ super(FilterType.IsNull, comparisonType, leftExpression);
1635
+ }
1636
+ get isNull() {
1637
+ return this.comparisonType === ComparisonType.Is_null;
1638
+ }
1639
+ clone() {
1640
+ return new IsNullFilter(this.comparisonType, this.leftExpression);
1641
+ }
1642
+ }
1643
+ __decorate([
1644
+ Expose(),
1645
+ __metadata("design:type", Boolean),
1646
+ __metadata("design:paramtypes", [])
1647
+ ], IsNullFilter.prototype, "isNull", null);
1648
+
1649
+ class FilterGroup extends BaseFilter {
1650
+ constructor(logicalOperation = LogicalOperatorType.And) {
1651
+ super(FilterType.FilterGroup);
1652
+ this.filters = new Map();
1653
+ this.logicalOperation = logicalOperation;
1654
+ }
1655
+ get items() {
1656
+ return classToPlain(this.filters, {
1657
+ exposeUnsetFields: false,
1658
+ excludePrefixes: ['_'],
1659
+ });
1660
+ }
1661
+ /**
1662
+ * Returns filter item by index.
1663
+ * @param index Item index.
1664
+ * @returns Filter.
1665
+ */
1666
+ getItemByIndex(index) {
1667
+ return this.items[Object.keys(this.items)[index]];
1668
+ }
1669
+ addSchemaColumnFilterWithParameter(comparisonType, columnPath, parameterValue) {
1670
+ const leftExpression = new ColumnExpression({ columnPath });
1671
+ const rightExpression = new ParameterExpression({ value: parameterValue });
1672
+ const filter = new CompareFilter(comparisonType, leftExpression, rightExpression);
1673
+ this.add(filter);
1674
+ }
1675
+ addSchemaColumnInFilterWithParameters(comparisonType, columnPath, parameterValues) {
1676
+ const leftExpression = new ColumnExpression({ columnPath });
1677
+ const expressions = parameterValues.map((singleParameterValue) => new ParameterExpression({
1678
+ value: singleParameterValue,
1679
+ }));
1680
+ const filter = new InFilter(comparisonType, leftExpression, expressions);
1681
+ this.add(filter);
1682
+ }
1683
+ addSchemaColumnIsNullFilter(columnPath) {
1684
+ const leftExpression = new ColumnExpression({ columnPath });
1685
+ const filter = new IsNullFilter(ComparisonType.Is_null, leftExpression);
1686
+ this.add(filter);
1687
+ }
1688
+ addSchemaColumnIsNotNullFilter(columnPath) {
1689
+ const leftExpression = new ColumnExpression({ columnPath });
1690
+ const filter = new IsNullFilter(ComparisonType.Is_not_null, leftExpression);
1691
+ this.add(filter);
1692
+ }
1693
+ addExistsFilter(columnPath, subFilters) {
1694
+ const leftExpression = new ColumnExpression({ columnPath });
1695
+ const filter = new ExistsFilter(leftExpression, subFilters);
1696
+ this.add(filter);
1697
+ }
1698
+ addNotExistsFilter(columnPath, subFilters) {
1699
+ const leftExpression = new ColumnExpression({ columnPath });
1700
+ const filter = new ExistsFilter(leftExpression, subFilters, ComparisonType.Not_exists);
1701
+ this.add(filter);
1702
+ }
1703
+ add(filter, filterKey) {
1704
+ ValidationUtilities.checkArgumentEmpty('filter', filter);
1705
+ const key = filterKey || generateGuid();
1706
+ this.filters.set(key, filter);
1707
+ }
1708
+ clone() {
1709
+ const filterGroup = new FilterGroup(this.logicalOperation);
1710
+ this.filters.forEach((filter, filterKey) => {
1711
+ filterGroup.filters.set(filterKey, filter.clone());
1712
+ });
1713
+ return filterGroup;
1714
+ }
1715
+ }
1716
+ __decorate([
1717
+ Exclude(),
1718
+ __metadata("design:type", Object)
1719
+ ], FilterGroup.prototype, "filters", void 0);
1720
+ __decorate([
1721
+ Expose(),
1722
+ __metadata("design:type", Object),
1723
+ __metadata("design:paramtypes", [])
1724
+ ], FilterGroup.prototype, "items", null);
1725
+
1726
+ class BetweenFilter extends SingleFilter {
1727
+ constructor(leftExpression, rightLessExpression, rightGreaterExpression) {
1728
+ super(FilterType.Between, ComparisonType.Between, leftExpression);
1729
+ this.rightLessExpression = rightLessExpression.clone();
1730
+ this.rightGreaterExpression = rightGreaterExpression.clone();
1731
+ }
1732
+ clone() {
1733
+ return new BetweenFilter(this.leftExpression, this.rightLessExpression, this.rightGreaterExpression);
1734
+ }
1735
+ }
1736
+
1737
+ class BaseQueryColumn {
1738
+ constructor(expression) {
1739
+ this.orderDirection = OrderDirection.None;
1740
+ this.orderPosition = -1;
1741
+ this.isVisible = true;
1742
+ this.expression = expression;
1743
+ }
1744
+ /**
1745
+ * Adds ordering options.
1746
+ * @param orderDirection Direction.
1747
+ * @param orderPosition Position.
1748
+ * @returns Self.
1749
+ */
1750
+ withOrdering(orderDirection, orderPosition) {
1751
+ ValidationUtilities.checkArgumentEmpty('orderDirection', orderDirection);
1752
+ ValidationUtilities.checkArgumentEmpty('orderPosition', orderPosition);
1753
+ ValidationUtilities.checkArgumentOutOfRange('orderPosition', orderPosition, { begin: -1 });
1754
+ this.orderDirection = orderDirection;
1755
+ this.orderPosition = orderPosition;
1756
+ return this;
1757
+ }
1758
+ /**
1759
+ * Adds options.
1760
+ * @param options Options.
1761
+ * @returns Self.
1762
+ */
1763
+ withOptions(options) {
1764
+ var _a;
1765
+ ValidationUtilities.checkArgumentEmpty('options', options);
1766
+ this.isVisible = (_a = options.isVisible) !== null && _a !== void 0 ? _a : true;
1767
+ return this;
1768
+ }
1769
+ /**
1770
+ * Adds caption.
1771
+ * @param caption Caption.
1772
+ * @returns Self.
1773
+ */
1774
+ withCaption(caption) {
1775
+ ValidationUtilities.checkArgumentEmpty('caption', caption);
1776
+ this.caption = caption;
1777
+ return this;
1778
+ }
1779
+ }
1780
+
1781
+ class ArithmeticQueryColumn extends BaseQueryColumn {
1782
+ // region Constructors: Public
1783
+ constructor(arithmeticOperation, leftArithmeticOperand, rightArithmeticOperand) {
1784
+ super(new ArithmeticExpression({ arithmeticOperation, leftArithmeticOperand, rightArithmeticOperand }));
1785
+ }
1786
+ }
1787
+
1788
+ class EntityQueryColumn extends BaseQueryColumn {
1789
+ // region Constructors: Public
1790
+ constructor(columnPath) {
1791
+ super(new ColumnExpression({ columnPath }));
1792
+ }
1793
+ }
1794
+
1795
+ class ParameterQueryColumn extends BaseQueryColumn {
1796
+ // region Constructors: Public
1797
+ constructor(value, dataValueType) {
1798
+ super(new ParameterExpression({ value, dataValueType }));
1799
+ }
1800
+ }
1801
+
1802
+ class AggregationSubQueryColumn extends BaseQueryColumn {
1803
+ // region Constructors: Public
1804
+ constructor(columnPath, aggregationType, subFilters, subOrderDirection, subOrderColumn) {
1805
+ super(new AggregationSubQueryExpression({
1806
+ aggregationType,
1807
+ columnPath,
1808
+ subFilters,
1809
+ subOrderDirection,
1810
+ subOrderColumn,
1811
+ }));
1812
+ }
1813
+ }
1814
+
1815
+ class SubQueryColumn extends BaseQueryColumn {
1816
+ // region Constructors: Public
1817
+ constructor(columnPath, subFilters) {
1818
+ super(new SubQueryExpression({ columnPath, subFilters }));
1819
+ }
1820
+ }
1821
+
1822
+ class AggregationFunctionColumn extends BaseQueryColumn {
1823
+ // region Constructors: Public
1824
+ constructor(aggregationType, aggregationEvalType, functionArgument) {
1825
+ super(new AggregationFunctionExpression({
1826
+ aggregationType,
1827
+ aggregationEvalType,
1828
+ functionArgument,
1829
+ }));
1830
+ }
1831
+ }
1832
+
1833
+ class DatePartFunctionColumn extends BaseQueryColumn {
1834
+ // region Constructors: Public
1835
+ constructor(datePartType, functionArgument) {
1836
+ super(new DatePartFunctionExpression({
1837
+ datePartType,
1838
+ functionArgument,
1839
+ }));
1840
+ }
1841
+ // endregion
1842
+ // region Properties: Public
1843
+ get datePartType() {
1844
+ var _a;
1845
+ return (_a = this.expression) === null || _a === void 0 ? void 0 : _a.datePartType;
1846
+ }
1847
+ }
1848
+
1849
+ class LengthFunctionColumn extends BaseQueryColumn {
1850
+ // region Constructors: Public
1851
+ constructor(functionArgument) {
1852
+ super(new LengthFunctionExpression({ functionArgument }));
1853
+ }
1854
+ }
1855
+
1856
+ class MacrosFunctionColumn extends BaseQueryColumn {
1857
+ // region Constructors: Public
1858
+ constructor(macrosType) {
1859
+ super(new MacrosFunctionExpression({ macrosType }));
1860
+ }
1861
+ }
1862
+
1863
+ class WindowFunctionColumn extends BaseQueryColumn {
1864
+ // region Constructors: Public
1865
+ constructor(functionArgument) {
1866
+ super(new WindowFunctionExpression({ functionArgument }));
1867
+ }
1868
+ }
1869
+
1870
+ /**
1871
+ * @internal
1872
+ */
1873
+ class BaseQuery {
1874
+ // region Constructors: Protected
1875
+ constructor(operationType, rootSchemaName) {
1876
+ this.operationType = operationType;
1877
+ this.rootSchemaName = rootSchemaName;
1878
+ ValidationUtilities.checkArgumentEmpty('_operationType', operationType);
1879
+ ValidationUtilities.checkArgumentEmpty('_rootSchemaName', rootSchemaName);
1880
+ }
1881
+ // endregion
1882
+ // region Methods: Public
1883
+ getMetadata() {
1884
+ return classToPlain(this, { exposeUnsetFields: false, excludePrefixes: ['_'] });
1885
+ }
1886
+ }
1887
+
1888
+ /**
1889
+ * @internal
1890
+ */
1891
+ class BaseFilterableQuery extends BaseQuery {
1892
+ // endregion
1893
+ // region Constructors: Protected
1894
+ constructor(operationType, rootSchemaName) {
1895
+ super(operationType, rootSchemaName);
1896
+ // region Properties: Public
1897
+ this.filters = new FilterGroup();
1898
+ }
1899
+ }
1900
+
1901
+ /**
1902
+ * @internal
1903
+ */
1904
+ var QueryOperationType;
1905
+ (function (QueryOperationType) {
1906
+ QueryOperationType[QueryOperationType["Select"] = 0] = "Select";
1907
+ QueryOperationType[QueryOperationType["Insert"] = 1] = "Insert";
1908
+ QueryOperationType[QueryOperationType["Update"] = 2] = "Update";
1909
+ QueryOperationType[QueryOperationType["Delete"] = 3] = "Delete";
1910
+ // Batch,
1911
+ // ListSelect,
1912
+ // FilteredSelect,
1913
+ // LookupSelect
1914
+ })(QueryOperationType || (QueryOperationType = {}));
1915
+
1916
+ /**
1917
+ * @internal
1918
+ */
1919
+ class DeleteQuery extends BaseFilterableQuery {
1920
+ // region Constructors: Public
1921
+ constructor(rootSchemaName) {
1922
+ super(QueryOperationType.Delete, rootSchemaName);
1923
+ }
1924
+ }
1925
+
1926
+ /**
1927
+ * @internal
1928
+ */
1929
+ class EntitySchemaQuery extends BaseFilterableQuery {
1930
+ // endregion
1931
+ // region Constructors: Public
1932
+ constructor(rootSchemaName) {
1933
+ super(QueryOperationType.Select, rootSchemaName);
1934
+ // region Properties: Private
1935
+ this._columns = new Map();
1936
+ // endregion
1937
+ // region Properties: Public
1938
+ this.isDistinct = false;
1939
+ /**
1940
+ * Number of rows to select.
1941
+ */
1942
+ this.rowCount = -1;
1943
+ /**
1944
+ * Rows count to skip.
1945
+ */
1946
+ this.rowsOffset = -1;
1947
+ this._getIsPageable = () => this.rowCount > 0 && this.rowsOffset > -1;
1948
+ }
1949
+ // endregion
1950
+ // region Methods: Private
1951
+ internalAddColumn(key, column) {
1952
+ if (!this._columns.has(key)) {
1953
+ this._columns.set(key, column);
1954
+ }
1955
+ }
1956
+ // endregion
1957
+ // region Methods: Public
1958
+ /**
1959
+ * Returns column instance by column alias.
1960
+ * @param columnAlias Column alias.
1961
+ * @returns [BaseQueryColumn] Column instance.
1962
+ */
1963
+ getColumn(columnAlias) {
1964
+ if (!this._columns.has(columnAlias)) {
1965
+ throw new ItemNotFoundException(columnAlias);
1966
+ }
1967
+ return this.findColumn(columnAlias);
1968
+ }
1969
+ /**
1970
+ * Returns column instance by column alias if not found returns null.
1971
+ */
1972
+ findColumn(columnAlias) {
1973
+ return this._columns.get(columnAlias);
1974
+ }
1975
+ /**
1976
+ * @inheritDoc
1977
+ */
1978
+ getMetadata() {
1979
+ return Object.assign(Object.assign({}, super.getMetadata()), { columns: {
1980
+ items: classToPlain(this._columns, { exposeUnsetFields: false, excludePrefixes: ['_'] }),
1981
+ }, allColumns: false, isDistinct: this.isDistinct, ignoreDisplayValues: false, rowCount: this.rowCount, rowsOffset: this.rowsOffset, isPageable: this._getIsPageable(),
1982
+ // TODO: CRM-61150: https://tscore-task/browse/CRM-61150
1983
+ conditionalValues: this.conditionalValues ? this.conditionalValues : null, isHierarchical: false, hierarchicalMaxDepth: 0, hierarchicalColumnName: null, hierarchicalColumnValue: null, useLocalization: true, useRecordDeactivation: false });
1984
+ }
1985
+ /**
1986
+ * Add column.
1987
+ * @param column Column path.
1988
+ * @param columnAlias Column alias.
1989
+ * @returns [BaseQueryColumn] Column instance.
1990
+ */
1991
+ addColumn(column, columnAlias) {
1992
+ this.internalAddColumn(columnAlias, column);
1993
+ return column;
1994
+ }
1995
+ /**
1996
+ * Add column by column path.
1997
+ * @param columnPath Column path.
1998
+ * @param columnAlias Column alias.
1999
+ * @returns [EntityQueryColumn] Column instance.
2000
+ */
2001
+ addSchemaColumn(columnPath, columnAlias) {
2002
+ ValidationUtilities.checkArgumentEmpty('columnPath', columnPath);
2003
+ const column = new EntityQueryColumn(columnPath);
2004
+ this.internalAddColumn(columnAlias || columnPath, column);
2005
+ return column;
2006
+ }
2007
+ /**
2008
+ * Add aggregation sub query column.
2009
+ * @param columnPath Column path.
2010
+ * @param aggregationType Aggregation type.
2011
+ * @param subFilters Sub query filters.
2012
+ * @param columnAlias Column alias.
2013
+ * @returns [AggregationSubQueryColumn] Column instance.
2014
+ */
2015
+ addAggregationSubQueryColumn(columnPath, aggregationType, aggregationConfig, columnAlias) {
2016
+ const column = new AggregationSubQueryColumn(columnPath, aggregationType, aggregationConfig.filter, aggregationConfig.sortByDirection, aggregationConfig.sortByColumn);
2017
+ this.internalAddColumn(columnAlias || columnPath, column);
2018
+ return column;
2019
+ }
2020
+ /**
2021
+ * Add parameter column.
2022
+ * @param value Parameter value.
2023
+ * @param dataValueType Parameter data value type.
2024
+ * @param columnAlias Column alias.
2025
+ * @returns [ParameterQueryColumn] Column instance.
2026
+ */
2027
+ addParameterColumn(value, dataValueType, columnAlias) {
2028
+ const column = new ParameterQueryColumn(value, dataValueType);
2029
+ this.internalAddColumn(columnAlias, column);
2030
+ return column;
2031
+ }
2032
+ /**
2033
+ * Add arithmetic column.
2034
+ * @param arithmeticOperation Arithmetic operation.
2035
+ * @param leftArithmeticOperand Left arithmetic operand expression.
2036
+ * @param rightArithmeticOperand Right arithmetic operand expression.
2037
+ * @param columnAlias Column alias.
2038
+ * @returns [ArithmeticQueryColumn] Column instance.
2039
+ */
2040
+ addArithmeticColumn(arithmeticOperation, leftArithmeticOperand, rightArithmeticOperand, columnAlias) {
2041
+ const column = new ArithmeticQueryColumn(arithmeticOperation, leftArithmeticOperand, rightArithmeticOperand);
2042
+ this.internalAddColumn(columnAlias, column);
2043
+ return column;
2044
+ }
2045
+ /**
2046
+ * Add macros function column.
2047
+ * @param queryMacrosType Macros type.
2048
+ * @param columnAlias Column alias.
2049
+ * @returns [MacrosFunctionColumn] Column instance.
2050
+ */
2051
+ addMacrosFunctionColumn(queryMacrosType, columnAlias) {
2052
+ const column = new MacrosFunctionColumn(queryMacrosType);
2053
+ this.internalAddColumn(columnAlias, column);
2054
+ return column;
2055
+ }
2056
+ /**
2057
+ * Add date part function column.
2058
+ * @param columnPath Column path.
2059
+ * @param datePartType Date part type.
2060
+ * @param columnAlias Column alias.
2061
+ * @returns [DatePartFunctionColumn] Column instance.
2062
+ */
2063
+ addDatePartFunctionColumn(columnPath, datePartType, columnAlias) {
2064
+ const functionArgument = new ColumnExpression({ columnPath });
2065
+ const column = new DatePartFunctionColumn(datePartType, functionArgument);
2066
+ this.internalAddColumn(columnAlias, column);
2067
+ return column;
2068
+ }
2069
+ /**
2070
+ * Add aggregation function column.
2071
+ * @param columnPath Column path.
2072
+ * @param aggregationType Aggregation type.
2073
+ * @param columnAlias Column alias.
2074
+ * @param aggregationEvalType Aggregation eval type.
2075
+ * @returns [AggregationFunctionColumn] Column instance.
2076
+ */
2077
+ addAggregationFunctionColumn(columnPath, aggregationType, columnAlias, aggregationEvalType = AggregationEvalType.None) {
2078
+ const functionArgument = new ColumnExpression({ columnPath });
2079
+ const column = new AggregationFunctionColumn(aggregationType, aggregationEvalType, functionArgument);
2080
+ this.internalAddColumn(columnAlias, column);
2081
+ return column;
2082
+ }
2083
+ /**
2084
+ * Add length function column.
2085
+ * @param columnPath Column path.
2086
+ * @param columnAlias Column alias.
2087
+ * @returns [LengthFunctionColumn] Column instance.
2088
+ */
2089
+ addLengthFunctionColumn(columnPath, columnAlias) {
2090
+ const functionArgument = new ColumnExpression({ columnPath });
2091
+ const column = new LengthFunctionColumn(functionArgument);
2092
+ this.internalAddColumn(columnAlias, column);
2093
+ return column;
2094
+ }
2095
+ /**
2096
+ * Add window function column.
2097
+ * @param columnPath Column path.
2098
+ * @param aggregationType Aggregation type.
2099
+ * @param columnAlias Column alias.
2100
+ * @param aggregationEvalType Aggregation eval type.
2101
+ * @returns [WindowFunctionColumn] Column instance.
2102
+ */
2103
+ addWindowFunctionColumn(columnPath, aggregationType, columnAlias, aggregationEvalType = AggregationEvalType.None) {
2104
+ const functionArgument = new AggregationFunctionExpression({
2105
+ aggregationType,
2106
+ aggregationEvalType,
2107
+ functionArgument: new ColumnExpression({ columnPath }),
2108
+ });
2109
+ const column = new WindowFunctionColumn(functionArgument);
2110
+ this.internalAddColumn(columnAlias, column);
2111
+ return column;
2112
+ }
2113
+ }
2114
+
2115
+ /**
2116
+ * @internal
2117
+ */
2118
+ class InsertQuery extends BaseQuery {
2119
+ // endregion
2120
+ // region Constructors: Public
2121
+ constructor(rootSchemaName) {
2122
+ super(QueryOperationType.Insert, rootSchemaName);
2123
+ // region Fields: Private
2124
+ this._columnValues = new Map();
2125
+ }
2126
+ // endregion
2127
+ // region Properties: Public
2128
+ get columnValues() {
2129
+ return {
2130
+ items: classToPlain(this._columnValues),
2131
+ };
2132
+ }
2133
+ // endregion
2134
+ // region Methods: Public
2135
+ addColumn(columnName, columnValue, dataValueType) {
2136
+ ValidationUtilities.checkArgumentEmpty('columnName', columnName);
2137
+ this._columnValues.set(columnName, new ParameterExpression({ value: columnValue, dataValueType }));
2138
+ }
2139
+ }
2140
+ __decorate([
2141
+ Expose(),
2142
+ __metadata("design:type", Object),
2143
+ __metadata("design:paramtypes", [])
2144
+ ], InsertQuery.prototype, "columnValues", null);
2145
+
2146
+ /**
2147
+ * @internal
2148
+ */
2149
+ class UpdateQuery extends BaseFilterableQuery {
2150
+ // endregion
2151
+ // region Constructors: Public
2152
+ constructor(rootSchemaName) {
2153
+ super(QueryOperationType.Update, rootSchemaName);
2154
+ // region Fields: Private
2155
+ this._columnValues = new Map();
2156
+ }
2157
+ // endregion
2158
+ // region Properties: Public
2159
+ get columnValues() {
2160
+ return {
2161
+ items: classToPlain(this._columnValues),
2162
+ };
2163
+ }
2164
+ // endregion
2165
+ // region Methods: Public
2166
+ addColumn(columnName, columnValue, dataValueType) {
2167
+ ValidationUtilities.checkArgumentEmpty('columnName', columnName);
2168
+ this._columnValues.set(columnName, new ParameterExpression({ value: columnValue, dataValueType }));
2169
+ }
2170
+ }
2171
+ __decorate([
2172
+ Expose(),
2173
+ __metadata("design:type", Object),
2174
+ __metadata("design:paramtypes", [])
2175
+ ], UpdateQuery.prototype, "columnValues", null);
2176
+
2177
+ /**
2178
+ * @public
2179
+ * @description Function allows to register user-defined component as view element in Creatio platform.
2180
+ * @param config - registration config. {@link ViewElementRegistrationConfig}
2181
+ * @example
2182
+ * sdk.registerViewElement({
2183
+ * type: 'usr.Timeline',
2184
+ * selector: 'usr-timeline',
2185
+ * inputs: {
2186
+ * primaryColumnValue: {},
2187
+ * cardSchemaName: {},
2188
+ * entitySchemaName: {}
2189
+ * }
2190
+ * });
2191
+ */
2192
+ function registerViewElement(config) {
2193
+ ViewElementRegistry.validate(config);
2194
+ ViewElementRegistry.register(config);
2195
+ }
2196
+
2197
+ /**
2198
+ * @internal
2199
+ */
2200
+ function resistantForEach(items, callback) {
2201
+ items.forEach((item) => {
2202
+ try {
2203
+ callback(item);
2204
+ }
2205
+ catch (error) {
2206
+ console.error(error);
2207
+ }
2208
+ });
2209
+ }
2210
+ /**
2211
+ * @internal
2212
+ */
2213
+ function registerViewElements(types) {
2214
+ resistantForEach(types, (type) => {
2215
+ const registrationConfig = getViewElementMetadata(type);
2216
+ ViewElementRegistry.validate(registrationConfig);
2217
+ ViewElementRegistry.register(registrationConfig);
2218
+ });
2219
+ }
2220
+ /**
2221
+ * @internal
2222
+ */
2223
+ function registerInterfaceDesignerItems(types, localizeFn) {
2224
+ resistantForEach(types, (type) => {
2225
+ if (!hasInterfaceDesignerItemMetadata(type) || !getInterfaceDesignerItemMetadata(type)) {
2226
+ return;
2227
+ }
2228
+ let config = getInterfaceDesignerItemMetadata(type);
2229
+ config = applyLocalizeMetadataFn(config, localizeFn);
2230
+ const viewElementMetadata = getViewElementMetadata(type);
2231
+ config.type = viewElementMetadata.type;
2232
+ InterfaceDesignerItemRegistry.validate(config);
2233
+ InterfaceDesignerItemRegistry.register(config);
2234
+ });
2235
+ }
2236
+ /**
2237
+ * @internal
2238
+ */
2239
+ function registerDesignTimeViewElements(types) {
2240
+ resistantForEach(types, (type) => {
2241
+ const registrationConfig = getDesignTimeViewElementMetadata(type);
2242
+ DesignTimeViewElementRegistry.validate(registrationConfig);
2243
+ DesignTimeViewElementRegistry.register(registrationConfig);
2244
+ });
2245
+ }
2246
+ /**
2247
+ * @internal
2248
+ */
2249
+ function registerRequestHandlers(types) {
2250
+ resistantForEach(types, (type) => {
2251
+ const registrationConfig = getRequestHandlerMetadata(type);
2252
+ RequestHandlerRegistryService.register(registrationConfig, type);
2253
+ });
2254
+ }
2255
+ /**
2256
+ * @internal
2257
+ */
2258
+ function _bootstrapCrtModule(type, options) {
2259
+ var _a;
2260
+ try {
2261
+ const moduleDefinition = getModuleMetadata(type);
2262
+ if (moduleDefinition.viewElements) {
2263
+ registerViewElements(moduleDefinition.viewElements);
2264
+ registerInterfaceDesignerItems(moduleDefinition.viewElements, options === null || options === void 0 ? void 0 : options.localizeMetadata);
2265
+ }
2266
+ if (moduleDefinition.designTimeViewElements) {
2267
+ registerDesignTimeViewElements(moduleDefinition.designTimeViewElements);
2268
+ }
2269
+ if (moduleDefinition.requestHandlers) {
2270
+ registerRequestHandlers(moduleDefinition.requestHandlers);
2271
+ }
2272
+ (_a = moduleDefinition.includes) === null || _a === void 0 ? void 0 : _a.forEach((t) => _bootstrapCrtModule(t, options));
2273
+ }
2274
+ catch (error) {
2275
+ console.error(error);
2276
+ }
2277
+ }
2278
+ /**
2279
+ * @public
2280
+ * @description Function required to bootstrapping elements defined in CrtModules.
2281
+ * Call this function as soon as possible during bootstrapping your application.
2282
+ * @param type - module type
2283
+ * @param options - {@link BootstrapOptions}
2284
+ *
2285
+ * @example
2286
+ * bootstrapCrtModule(AppModule)
2287
+ */
2288
+ function bootstrapCrtModule(type, options) {
2289
+ _bootstrapCrtModule(type, options);
2290
+ BootstrapNotifier.instance.notify(type);
2291
+ }
2292
+
2293
+ /**
2294
+ * @public
2295
+ * @description Use this function in decorators to indicate that a value should be localized.
2296
+ * Note that the "localizeMetadata" bootstrap option should be provided,
2297
+ * otherwise the value cannot be localized.
2298
+ *
2299
+ * @example
2300
+ *
2301
+ * ### Using 'localize' in decorator
2302
+ * ```ts
2303
+ * @CrtInterfaceDesignerItem({
2304
+ * toolbarConfig: {
2305
+ * caption: localize('MyElement.Caption')
2306
+ * }
2307
+ * })
2308
+ * class MyElement {}
2309
+ * ```
2310
+ * ### Passing 'localizeMetadata' bootstrap option
2311
+ * ```ts
2312
+ * bootstrapCrtModule(MyModule, {
2313
+ * localizeMetadata: (key: string) => thirdPartyTranslateService.translate(key)
2314
+ * });
2315
+ * ```
2316
+ */
2317
+ function localize(key) {
2318
+ return new LocalizableValue(key);
2319
+ }
2320
+
2321
+ class BaseHandlerChainService {
2322
+ }
2323
+
2324
+ /**
2325
+ * @public
2326
+ * @class FeatureService
2327
+ * @classdesc Service to working with Creatio platform features using handler chain
2328
+ * @extends {BaseHandlerChainService}
2329
+ */
2330
+ class FeatureService extends BaseHandlerChainService {
2331
+ constructor() {
2332
+ super(...arguments);
2333
+ /**
2334
+ * @internal
2335
+ */
2336
+ this.requestType = 'crt.FeatureService';
2337
+ }
2338
+ }
2339
+ __decorate([
2340
+ ImplementUsingHandlerChain(),
2341
+ __metadata("design:type", Function)
2342
+ ], FeatureService.prototype, "getFeatureState", void 0);
2343
+ __decorate([
2344
+ ImplementUsingHandlerChain(),
2345
+ __metadata("design:type", Function)
2346
+ ], FeatureService.prototype, "getFeaturesState", void 0);
2347
+
2348
+ /**
2349
+ * @public
2350
+ * @class RightsService
2351
+ * @classdesc Service to working rights using handler chain
2352
+ * @extends {BaseHandlerChainService}
2353
+ */
2354
+ class RightsService extends BaseHandlerChainService {
2355
+ constructor() {
2356
+ super(...arguments);
2357
+ /**
2358
+ * @internal
2359
+ */
2360
+ this.requestType = 'crt.RightsService';
2361
+ }
2362
+ }
2363
+ __decorate([
2364
+ ImplementUsingHandlerChain(),
2365
+ __metadata("design:type", Function)
2366
+ ], RightsService.prototype, "getCanExecuteOperation", void 0);
2367
+ __decorate([
2368
+ ImplementUsingHandlerChain(),
2369
+ __metadata("design:type", Function)
2370
+ ], RightsService.prototype, "getCanExecuteOperations", void 0);
2371
+
2372
+ /**
2373
+ * @public
2374
+ * @class SysSettingsService
2375
+ * @classdesc Service to working with system settings using handler chain
2376
+ * @extends {BaseHandlerChainService}
2377
+ */
2378
+ class SysSettingsService extends BaseHandlerChainService {
2379
+ constructor() {
2380
+ super(...arguments);
2381
+ /**
2382
+ * @internal
2383
+ */
2384
+ this.requestType = 'crt.SysSettingsService';
2385
+ }
2386
+ }
2387
+ __decorate([
2388
+ ImplementUsingHandlerChain(),
2389
+ __metadata("design:type", Function)
2390
+ ], SysSettingsService.prototype, "getByCodes", void 0);
2391
+ __decorate([
2392
+ ImplementUsingHandlerChain(),
2393
+ __metadata("design:type", Function)
2394
+ ], SysSettingsService.prototype, "getByCode", void 0);
2395
+ __decorate([
2396
+ ImplementUsingHandlerChain(),
2397
+ __metadata("design:type", Function)
2398
+ ], SysSettingsService.prototype, "update", void 0);
2399
+ __decorate([
2400
+ ImplementUsingHandlerChain(),
2401
+ __metadata("design:type", Function)
2402
+ ], SysSettingsService.prototype, "updateMany", void 0);
2403
+
2404
+ /**
2405
+ * @public
2406
+ * @class SysSetting
2407
+ * @classdesc Class contains info related system setting
2408
+ * @property {Guid} id - id of system setting.
2409
+ * @property {string} name - name of system setting.
2410
+ * @property {string} code - code of system setting.
2411
+ * @property {isCacheable} boolean - indicator whether system setting is cacheable
2412
+ * @property {any} value - value of system setting
2413
+ * @property {DataValueType} dataValueType - system setting {@link DataValueType}
2414
+ */
2415
+ class SysSetting {
2416
+ }
2417
+ /**
2418
+ * @public
2419
+ * @class SysSettingValue
2420
+ * @classdesc Shape to describe system setting value
2421
+ * @property {string} code - code of system setting
2422
+ * @property {any} value - value of system setting
2423
+ */
2424
+ class SysSettingValue {
2425
+ }
2426
+
2427
+ /**
2428
+ * @public
2429
+ * @classdesc
2430
+ * @class SysValuesService Service to working with system values using handler chain
2431
+ * @extends {BaseHandlerChainService}
2432
+ */
2433
+ class SysValuesService extends BaseHandlerChainService {
2434
+ constructor() {
2435
+ super(...arguments);
2436
+ /**
2437
+ * @internal
2438
+ */
2439
+ this.requestType = 'crt.SysValuesService';
2440
+ }
2441
+ }
2442
+ __decorate([
2443
+ ImplementUsingHandlerChain(),
2444
+ __metadata("design:type", Function)
2445
+ ], SysValuesService.prototype, "loadSysValues", void 0);
2446
+
2447
+ /**
2448
+ * @public
2449
+ * @class HttpClientService
2450
+ * @classdesc Http service to perform Http requests
2451
+ * @extends {BaseHandlerChainService}
2452
+ */
2453
+ class HttpClientService extends BaseHandlerChainService {
2454
+ constructor() {
2455
+ super(...arguments);
2456
+ /**
2457
+ * @internal
2458
+ */
2459
+ this.requestType = 'crt.HttpClientService';
2460
+ }
2461
+ /**
2462
+ * @description HTTP GET request.
2463
+ * @return `Promise<HttpResponse> | void` {(Promise<HttpResponse> | void)}
2464
+ */
2465
+ get() { }
2466
+ /**
2467
+ * @description HTTP POST request.
2468
+ * @return `Promise<HttpResponse> | void` {(Promise<HttpResponse> | void)}
2469
+ */
2470
+ post() { }
2471
+ /**
2472
+ * @description HTTP DELETE request.
2473
+ * @return `Promise<HttpResponse> | void` {(Promise<HttpResponse> | void)}
2474
+ */
2475
+ delete() { }
2476
+ /**
2477
+ * @description HTTP PUT request.
2478
+ * @return `Promise<HttpResponse> | void`` {(Promise<HttpResponse> | void)}
2479
+ */
2480
+ put() { }
2481
+ /**
2482
+ * @description HTTP PATCH request.
2483
+ * @return `Promise<HttpResponse> | void` {(Promise<HttpResponse> | void)}
2484
+ */
2485
+ patch() { }
2486
+ }
2487
+ __decorate([
2488
+ ImplementUsingHandlerChain(),
2489
+ __metadata("design:type", Function),
2490
+ __metadata("design:paramtypes", []),
2491
+ __metadata("design:returntype", Object)
2492
+ ], HttpClientService.prototype, "get", null);
2493
+ __decorate([
2494
+ ImplementUsingHandlerChain(),
2495
+ __metadata("design:type", Function),
2496
+ __metadata("design:paramtypes", []),
2497
+ __metadata("design:returntype", Object)
2498
+ ], HttpClientService.prototype, "post", null);
2499
+ __decorate([
2500
+ ImplementUsingHandlerChain(),
2501
+ __metadata("design:type", Function),
2502
+ __metadata("design:paramtypes", []),
2503
+ __metadata("design:returntype", Object)
2504
+ ], HttpClientService.prototype, "delete", null);
2505
+ __decorate([
2506
+ ImplementUsingHandlerChain(),
2507
+ __metadata("design:type", Function),
2508
+ __metadata("design:paramtypes", []),
2509
+ __metadata("design:returntype", Object)
2510
+ ], HttpClientService.prototype, "put", null);
2511
+ __decorate([
2512
+ ImplementUsingHandlerChain(),
2513
+ __metadata("design:type", Function),
2514
+ __metadata("design:paramtypes", []),
2515
+ __metadata("design:returntype", Object)
2516
+ ], HttpClientService.prototype, "patch", null);
2517
+
2518
+ /**
2519
+ * @public
2520
+ * @class MaskService
2521
+ * @classdesc Service to working with mask using handler chain
2522
+ * @extends {BaseHandlerChainService}
2523
+ */
2524
+ class MaskService extends BaseHandlerChainService {
2525
+ constructor() {
2526
+ super(...arguments);
2527
+ /**
2528
+ * @internal
2529
+ */
2530
+ this.requestType = 'crt.MaskService';
2531
+ }
2532
+ }
2533
+ __decorate([
2534
+ ImplementUsingHandlerChain(),
2535
+ __metadata("design:type", Function)
2536
+ ], MaskService.prototype, "showBodyMask", void 0);
2537
+ __decorate([
2538
+ ImplementUsingHandlerChain(),
2539
+ __metadata("design:type", Function)
2540
+ ], MaskService.prototype, "hideBodyMask", void 0);
2541
+
2542
+ /**
2543
+ * @public
2544
+ */
2545
+ class Model extends BaseHandlerChainService {
2546
+ constructor(crtModel) {
2547
+ super();
2548
+ /**
2549
+ * @internal
2550
+ */
2551
+ this.requestType = 'crt.ModelGenerator';
2552
+ this._crtModel = crtModel;
2553
+ }
2554
+ static get instance() {
2555
+ if (!this._instance) {
2556
+ this._instance = new Model();
2557
+ }
2558
+ return this._instance;
2559
+ }
2560
+ static create(dataSchema) {
2561
+ return __awaiter(this, void 0, void 0, function* () {
2562
+ const crtModel = yield this.instance._create({
2563
+ type: 'crt.EntityDataSource',
2564
+ config: {
2565
+ entitySchemaName: dataSchema,
2566
+ },
2567
+ }, '');
2568
+ return new Model(crtModel);
2569
+ });
2570
+ }
2571
+ // TODO RND-23725
2572
+ getSchema() {
2573
+ return this._crtModel.getSchema().toPromise();
2574
+ }
2575
+ load(config) {
2576
+ return this._crtModel.load(config).toPromise();
2577
+ }
2578
+ insert(dto) {
2579
+ return this._crtModel.insert(dto).toPromise();
2580
+ }
2581
+ update(dto, parameters) {
2582
+ return this._crtModel.update(dto, parameters).toPromise();
2583
+ }
2584
+ copy(primaryColumnValue, data = {}) {
2585
+ return this._crtModel.copy(primaryColumnValue, data).toPromise();
2586
+ }
2587
+ create(data = {}) {
2588
+ return this._crtModel.create(data).toPromise();
2589
+ }
2590
+ delete(parameters) {
2591
+ return this._crtModel.delete(parameters).toPromise();
2592
+ }
2593
+ canSave(params) {
2594
+ return this._crtModel.canSave(params).toPromise();
2595
+ }
2596
+ canDelete(params) {
2597
+ return this._crtModel.canDelete(params).toPromise();
2598
+ }
2599
+ }
2600
+ __decorate([
2601
+ ImplementUsingHandlerChain({
2602
+ methodName: 'generateOne',
2603
+ }),
2604
+ __metadata("design:type", Function)
2605
+ ], Model.prototype, "_create", void 0);
2606
+
2607
+ /**
2608
+ * @public
2609
+ */
2610
+ var ModelParameterType;
2611
+ (function (ModelParameterType) {
2612
+ ModelParameterType["PrimaryColumnValue"] = "primaryColumnValue";
2613
+ ModelParameterType["Filter"] = "filter";
2614
+ ModelParameterType["PrimaryDisplayValueFilter"] = "primaryDisplayValueFilter";
2615
+ ModelParameterType["Empty"] = "empty";
2616
+ ModelParameterType["Never"] = "never";
2617
+ })(ModelParameterType || (ModelParameterType = {}));
2618
+
2619
+ /**
2620
+ * @internal
2621
+ * @abstract
2622
+ * @classdesc Class for designing request handlers.
2623
+ */
2624
+ class BaseRequestHandler {
2625
+ constructor() {
2626
+ this.handlerChain = HandlerChainService.instance;
2627
+ }
2628
+ get next() {
2629
+ return this._next;
2630
+ }
2631
+ /**
2632
+ * @description Method to set request handler to handler chain.
2633
+ * @param next - link for next request handler - {@link RequestHandler}
2634
+ */
2635
+ setNext(next) {
2636
+ if (this._next) {
2637
+ throw new NextHandlerAlreadySpecifiedException();
2638
+ }
2639
+ this._next = next;
2640
+ }
2641
+ }
2642
+
2643
+ /**
2644
+ * @internal
2645
+ */
2646
+ class InterfaceDesignerItemRegistrationConfig {
2647
+ }
2648
+
2649
+ /**
2650
+ * @internal
2651
+ * @class MethodInvokeRequest
2652
+ * @description Definition of invoke method request.
2653
+ * @extends {BaseRequest} {@link BaseRequest}
2654
+ * @property {string} method - method name.
2655
+ * @property {unknown[]} args - arguments passing to the method.
2656
+ */
2657
+ class MethodInvokeRequest extends BaseRequest {
2658
+ }
2659
+
2660
+ /**
2661
+ * @internal
2662
+ */
2663
+ function toAggregationType(aggregationFunction) {
2664
+ switch (aggregationFunction) {
2665
+ case AggregationFunction.Count:
2666
+ return AggregationType.Count;
2667
+ case AggregationFunction.Sum:
2668
+ return AggregationType.Sum;
2669
+ case AggregationFunction.Avg:
2670
+ return AggregationType.Avg;
2671
+ case AggregationFunction.Min:
2672
+ return AggregationType.Min;
2673
+ case AggregationFunction.Max:
2674
+ return AggregationType.Max;
2675
+ case AggregationFunction.TopOne:
2676
+ return AggregationType.TopOne;
2677
+ default:
2678
+ return AggregationType.None;
2679
+ }
2680
+ }
2681
+
2682
+ /**
2683
+ * Generated bundle index. Do not edit.
2684
+ */
2685
+
2686
+ export { AggregationEvalType, AggregationFunction, AggregationFunctionColumn, AggregationFunctionExpression, AggregationSubQueryColumn, AggregationSubQueryExpression, AggregationType, ArgumentEmptyException, ArgumentFunctionExpression, ArgumentOutOfRangeException, ArithmeticExpression, ArithmeticOperation, ArithmeticQueryColumn, BaseExpression, BaseFilter, BaseFilterableQuery, BaseQuery, BaseQueryColumn, BaseRegistry, BaseRequest, BaseRequestHandler, BetweenFilter, BootstrapNotifier, ColumnExpression, CompareFilter, ComparisonType, CrtConverter, CrtDesignTimeViewElement, CrtInput, CrtInputRegistrationConfig, CrtInterfaceDesignerItem, CrtModule, CrtOutput, CrtRequest, CrtRequestHandler, CrtValidationInput, CrtViewElement, DataRequest, DataSourceScope, DataValueType, DatePartFunctionColumn, DatePartFunctionExpression, DatePartType, DeleteQuery, DesignTimeViewElementRegistry, DesignerToolGroupType, EMPTY_GUID, EXPRESSION_TYPE_MOCK, EntityQueryColumn, EntitySchemaQuery, ExistsFilter, ExpressionMock, ExpressionType, FeatureService, FilterGroup, FilterMock, FilterType, FunctionExpression, FunctionType, GlobalConvertersRegistryService, HandlerChainService, HandlerChainServicesRegistry, HttpClientService, ImplementUsingHandlerChain, InFilter, InsertQuery, InterfaceDesignerItemRegistrationConfig, InterfaceDesignerItemRegistry, InternalRequestHandlerRegistry, InternalRequestHandlerRegistryType, IsNullFilter, ItemNotFoundException, LengthFunctionColumn, LengthFunctionExpression, LocalizableValue, LogicalOperatorType, MacrosFunctionColumn, MacrosFunctionExpression, MaskService, MethodInvokeRequest, Model, ModelInPageAction, ModelParameterType, NextHandlerAlreadySpecifiedException, OrderDirection, ParameterExpression, ParameterQueryColumn, QueryMacrosType, QueryOperationType, RequestHandlerRegistryService, RequestRegistryService, RightsService, SingleFilter, SubQueryColumn, SubQueryExpression, SysSetting, SysSettingValue, SysSettingsService, SysValuesService, UpdateQuery, ValidationUtilities, ViewElementDataGroupType, ViewElementGroupType, ViewElementRegistry, WindowFunctionColumn, WindowFunctionExpression, _bootstrapCrtModule, applyLocalizeMetadataFn, bootstrapCrtModule, checkCrtTypeNamePascalCase, checkIfTypeRegistered, checkOnlyOneRegistration, checkTypeNameFormat, checkTypeNamePascalCase, crtInputPrefix, crtOutputPrefix, crtValidationInputPrefix, designTimeViewElementRegistryKey, generateGuid, getCrtInputsMetadata, getCrtOutputsMetadata, getCrtValidationInputsMetadata, getDesignTimeViewElementMetadata, getHandlerChainServiceMetadata, getInterfaceDesignerItemMetadata, getModuleMetadata, getRequestHandlerMetadata, getViewElementMetadata, hasInterfaceDesignerItemMetadata, interfaceDesignerItemRegistryKey, isEmptyGuid, isGuid, localize, objectDeepKeys, registerHandlerChainServices, registerViewElement, setDesignTimeViewElementMetadata, setInterfaceDesignerItemMetadata, setModuleMetadata, setRequestHandlerMetadata, setViewElementMetadata, toAggregationType, toPascalCase, viewElementRegistryKey };
2687
+ //# sourceMappingURL=creatio-devkit-common.mjs.map