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