@flarehr/apollo-benefits 1.2.97 → 1.3.54109

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 (376) hide show
  1. package/README.md +19 -0
  2. package/dist/assets/@splitsoftware-7d799540.js +18 -0
  3. package/dist/assets/all_tab_color-548783b9.svg +21 -0
  4. package/dist/assets/all_tab_gray-a5051313.svg +6 -0
  5. package/dist/assets/check-57fe1dcb.svg +15 -0
  6. package/dist/assets/datadog-9aa4bf28.js +5 -0
  7. package/dist/assets/date-fns-c5d8fbc0.js +1 -0
  8. package/dist/assets/default_backdrop-fdd955b8.png +0 -0
  9. package/dist/assets/external_link-599a0aec.svg +3 -0
  10. package/dist/assets/external_link_white-55111b2e.svg +3 -0
  11. package/dist/assets/framer-motion-bb8d6b82.js +1 -0
  12. package/dist/assets/index-18cd5088.js +35 -0
  13. package/dist/assets/index-cfa25e28.css +1 -0
  14. package/dist/assets/index-e4f1c441.js +5 -0
  15. package/dist/assets/lodash-5d893f8c.js +1 -0
  16. package/dist/assets/logo-a34e9b4b.png +0 -0
  17. package/dist/assets/oidc-client-6f6e47c2.js +101 -0
  18. package/dist/assets/padlock-8c081120.svg +26 -0
  19. package/dist/assets/suitcase-6471ad05.svg +17 -0
  20. package/dist/assets/vendor-2d0139ca.js +788 -0
  21. package/dist/assets/warning-a7f1af23.svg +14 -0
  22. package/dist/assets/welcome_image_mobile-dbde6c80.png +0 -0
  23. package/dist/assets/welcome_image_v2-869c59e4.png +0 -0
  24. package/dist/assets/wellbeing_banner-6903d615.png +0 -0
  25. package/dist/assets/workplace_link_banner_mobile-6ebaa24b.png +0 -0
  26. package/dist/assets/workplace_link_banner_v2-c81ed849.png +0 -0
  27. package/dist/config.json +14 -0
  28. package/dist/favicon.ico +0 -0
  29. package/dist/icons/android-chrome-192x192.png +0 -0
  30. package/dist/icons/android-chrome-512x512.png +0 -0
  31. package/dist/icons/apple-touch-icon.png +0 -0
  32. package/dist/icons/favicon-16x16.png +0 -0
  33. package/dist/icons/favicon-32x32.png +0 -0
  34. package/dist/index.html +114 -0
  35. package/dist/manifest.json +21 -0
  36. package/dist/sw-esm.js +16 -0
  37. package/package.json +127 -69
  38. package/LICENSE +0 -21
  39. package/dist/lib/apollo-benefits/apollo-benefits.esm.js +0 -1
  40. package/dist/lib/apollo-benefits/assets/Hero_Background.png +0 -0
  41. package/dist/lib/apollo-benefits/assets/car-placeholder.svg +0 -5
  42. package/dist/lib/apollo-benefits/assets/check.svg +0 -13
  43. package/dist/lib/apollo-benefits/common-assets/icon-info.svg +0 -4
  44. package/dist/lib/apollo-benefits/index.esm.js +0 -0
  45. package/dist/lib/apollo-benefits/p-054d1471.js +0 -1
  46. package/dist/lib/apollo-benefits/p-066d8e7b.js +0 -15
  47. package/dist/lib/apollo-benefits/p-08376428.entry.js +0 -1
  48. package/dist/lib/apollo-benefits/p-1d7ab1b9.entry.js +0 -1
  49. package/dist/lib/apollo-benefits/p-25a89275.entry.js +0 -1
  50. package/dist/lib/apollo-benefits/p-26d363c9.entry.js +0 -1
  51. package/dist/lib/apollo-benefits/p-337ce3df.js +0 -1
  52. package/dist/lib/apollo-benefits/p-3dc9a379.js +0 -1
  53. package/dist/lib/apollo-benefits/p-4376366b.js +0 -46
  54. package/dist/lib/apollo-benefits/p-4e2d34f4.entry.js +0 -1
  55. package/dist/lib/apollo-benefits/p-50bbf713.js +0 -1
  56. package/dist/lib/apollo-benefits/p-53c5e861.entry.js +0 -1
  57. package/dist/lib/apollo-benefits/p-556fdb43.js +0 -1
  58. package/dist/lib/apollo-benefits/p-57d4702d.entry.js +0 -1
  59. package/dist/lib/apollo-benefits/p-58ee670f.js +0 -1
  60. package/dist/lib/apollo-benefits/p-6a54654f.entry.js +0 -11
  61. package/dist/lib/apollo-benefits/p-6bd33850.js +0 -1
  62. package/dist/lib/apollo-benefits/p-79c3b633.entry.js +0 -1
  63. package/dist/lib/apollo-benefits/p-7f3a2f3b.entry.js +0 -1
  64. package/dist/lib/apollo-benefits/p-82d42c2b.js +0 -1
  65. package/dist/lib/apollo-benefits/p-9b3e978e.js +0 -1
  66. package/dist/lib/apollo-benefits/p-a1dd0cba.entry.js +0 -1
  67. package/dist/lib/apollo-benefits/p-aa379cfe.entry.js +0 -1
  68. package/dist/lib/apollo-benefits/p-aaf0e527.entry.js +0 -1
  69. package/dist/lib/apollo-benefits/p-b0b9425b.js +0 -1
  70. package/dist/lib/apollo-benefits/p-d0ef83f8.entry.js +0 -1
  71. package/dist/lib/apollo-benefits/p-db4a65f0.entry.js +0 -1
  72. package/dist/lib/apollo-benefits/p-dc67f942.entry.js +0 -1
  73. package/dist/lib/apollo-benefits/p-e1fd79bb.entry.js +0 -1
  74. package/dist/lib/apollo-benefits/p-ea120e31.js +0 -1
  75. package/dist/lib/apollo-benefits/p-ef5f33ca.js +0 -1
  76. package/dist/lib/apollo-benefits/p-f5254031.js +0 -1
  77. package/dist/lib/apollo-benefits/p-f63d9d89.js +0 -1
  78. package/dist/lib/apollo-benefits/p-fcfa5255.entry.js +0 -1
  79. package/dist/lib/cjs/Option-98dab0b8.js +0 -1988
  80. package/dist/lib/cjs/active-router-90429847.js +0 -75
  81. package/dist/lib/cjs/ap-ben-asset_5.cjs.entry.js +0 -1856
  82. package/dist/lib/cjs/ap-ben-benefit-card.cjs.entry.js +0 -45
  83. package/dist/lib/cjs/ap-ben-benefit-list-item.cjs.entry.js +0 -56
  84. package/dist/lib/cjs/ap-ben-benefit-url_27.cjs.entry.js +0 -48767
  85. package/dist/lib/cjs/ap-ben-benefits-list_3.cjs.entry.js +0 -55
  86. package/dist/lib/cjs/ap-ben-benefits-page.cjs.entry.js +0 -55
  87. package/dist/lib/cjs/ap-ben-choose-vehicle-section_4.cjs.entry.js +0 -2779
  88. package/dist/lib/cjs/ap-ben-notifications-section.cjs.entry.js +0 -243
  89. package/dist/lib/cjs/ap-ben-oidc-callback-page.cjs.entry.js +0 -40
  90. package/dist/lib/cjs/apollo-benefits.cjs.js +0 -25
  91. package/dist/lib/cjs/app-globals-e04ab04b.js +0 -12
  92. package/dist/lib/cjs/authentication.service-11c30071.js +0 -237
  93. package/dist/lib/cjs/benefits.api-b46ee2ea.js +0 -35
  94. package/dist/lib/cjs/cars-calculator-app.cjs.entry.js +0 -60
  95. package/dist/lib/cjs/cars-calculator.service-a8beab79.js +0 -166
  96. package/dist/lib/cjs/context-consumer.cjs.entry.js +0 -29
  97. package/dist/lib/cjs/datorama-akita-792b4d1d.js +0 -2553
  98. package/dist/lib/cjs/delay-e91dba76.js +0 -206
  99. package/dist/lib/cjs/event-tracking.service-6f723d9c.js +0 -155
  100. package/dist/lib/cjs/event-tracking.service-d6f9a51c.js +0 -259
  101. package/dist/lib/cjs/filter-c38164e6.js +0 -378
  102. package/dist/lib/cjs/fl-dropdown-async.cjs.entry.js +0 -422
  103. package/dist/lib/cjs/fl-dropdown.cjs.entry.js +0 -232
  104. package/dist/lib/cjs/fl-style-guide.cjs.entry.js +0 -91
  105. package/dist/lib/cjs/index-4f00f593.js +0 -994
  106. package/dist/lib/cjs/index-6e643fec.js +0 -1734
  107. package/dist/lib/cjs/index-889ce6c6.js +0 -27
  108. package/dist/lib/cjs/index.cjs.js +0 -2
  109. package/dist/lib/cjs/loader.cjs.js +0 -27
  110. package/dist/lib/cjs/scheduleArray-0ba3d6f8.js +0 -753
  111. package/dist/lib/cjs/stencil-async-content.cjs.entry.js +0 -32
  112. package/dist/lib/cjs/stencil-route-title.cjs.entry.js +0 -32
  113. package/dist/lib/cjs/stencil-router-prompt.cjs.entry.js +0 -59
  114. package/dist/lib/cjs/stencil-router-redirect.cjs.entry.js +0 -32
  115. package/dist/lib/cjs/view.service-ec43dea6.js +0 -21
  116. package/dist/lib/collection/assets/image/complete.svg +0 -122
  117. package/dist/lib/collection/collection-manifest.json +0 -81
  118. package/dist/lib/collection/components/benefits-app/apis/api-client.js +0 -16
  119. package/dist/lib/collection/components/benefits-app/apis/benefits-api/benefits-api.dto.js +0 -16
  120. package/dist/lib/collection/components/benefits-app/apis/benefits-api/benefits.api.js +0 -30
  121. package/dist/lib/collection/components/benefits-app/apis/event-tracking-api/event-tracking-api.dto.js +0 -1
  122. package/dist/lib/collection/components/benefits-app/apis/event-tracking-api/event-tracking-api.js +0 -7
  123. package/dist/lib/collection/components/benefits-app/apis/user-api/user-api.dto.js +0 -8
  124. package/dist/lib/collection/components/benefits-app/apis/user-api/user.api.js +0 -16
  125. package/dist/lib/collection/components/benefits-app/benefits-app.css +0 -399
  126. package/dist/lib/collection/components/benefits-app/benefits-app.js +0 -216
  127. package/dist/lib/collection/components/benefits-app/pages/benefits-page/benefits-list/benefit-list-item.css +0 -23
  128. package/dist/lib/collection/components/benefits-app/pages/benefits-page/benefits-list/benefits-list-item.js +0 -80
  129. package/dist/lib/collection/components/benefits-app/pages/benefits-page/benefits-list/benefits-list.js +0 -32
  130. package/dist/lib/collection/components/benefits-app/pages/benefits-page/benefits-page.js +0 -47
  131. package/dist/lib/collection/components/benefits-app/pages/benefits-page/hero-banner/assets/Hero_Background.png +0 -0
  132. package/dist/lib/collection/components/benefits-app/pages/benefits-page/hero-banner/hero-banner.css +0 -8
  133. package/dist/lib/collection/components/benefits-app/pages/benefits-page/hero-banner/hero-banner.js +0 -53
  134. package/dist/lib/collection/components/benefits-app/pages/benefits-page/promoted-benefits/benefit-card.css +0 -3
  135. package/dist/lib/collection/components/benefits-app/pages/benefits-page/promoted-benefits/benefit-card.js +0 -62
  136. package/dist/lib/collection/components/benefits-app/pages/benefits-page/promoted-benefits/promoted-benefits.js +0 -33
  137. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/api/manage-benefits-api.dto.js +0 -36
  138. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/api/manage-benefits.api.js +0 -23
  139. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/confirm-dialog.js +0 -158
  140. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-form/benefit-url.css +0 -8
  141. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-form/benefit-url.js +0 -126
  142. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-form/edit-benefit-form.js +0 -138
  143. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-form/upload-benefit-icon.css +0 -24
  144. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-form/upload-benefit-icon.js +0 -102
  145. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-form/upload-file.css +0 -18
  146. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-form/upload-file.js +0 -120
  147. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-page.js +0 -154
  148. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit.query.js +0 -18
  149. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit.service.js +0 -155
  150. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/empty-benefits.js +0 -36
  151. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/manage-benefits-header-row.js +0 -13
  152. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/manage-benefits-page.css +0 -3
  153. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/manage-benefits-page.js +0 -88
  154. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/manage-benefits-page.routes.js +0 -24
  155. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/manage-benefits.service.js +0 -37
  156. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/managed-benefit-item/managed-benefit-item.css +0 -10
  157. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/managed-benefit-item/managed-benefit-item.js +0 -89
  158. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/store/manage-benefits.query.js +0 -11
  159. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/store/manage-benefits.store.js +0 -51
  160. package/dist/lib/collection/components/benefits-app/pages/role-management-page/api/role-management.api.js +0 -21
  161. package/dist/lib/collection/components/benefits-app/pages/role-management-page/role-editors-section/role-editors-section.js +0 -104
  162. package/dist/lib/collection/components/benefits-app/pages/role-management-page/role-management-page.js +0 -50
  163. package/dist/lib/collection/components/benefits-app/pages/role-management-page/role-management.service.js +0 -44
  164. package/dist/lib/collection/components/benefits-app/pages/role-management-page/role-owner-section/role-owner-section.js +0 -40
  165. package/dist/lib/collection/components/benefits-app/pages/role-management-page/store/role-management.query.js +0 -13
  166. package/dist/lib/collection/components/benefits-app/pages/role-management-page/store/role-management.store.js +0 -42
  167. package/dist/lib/collection/components/benefits-app/services/benefits-app.service.js +0 -36
  168. package/dist/lib/collection/components/benefits-app/services/benefits.service.js +0 -11
  169. package/dist/lib/collection/components/benefits-app/services/event-tracking.service.js +0 -40
  170. package/dist/lib/collection/components/benefits-app/services/navigation.service.js +0 -34
  171. package/dist/lib/collection/components/benefits-app/store/benefits-app.query.js +0 -13
  172. package/dist/lib/collection/components/benefits-app/store/benefits-app.store.js +0 -24
  173. package/dist/lib/collection/components/benefits-app-host/benefits-app-host.js +0 -48
  174. package/dist/lib/collection/components/benefits-app-host/loading-page.js +0 -9
  175. package/dist/lib/collection/components/benefits-app-host/oidc-callback-page/oidc-callback-page.js +0 -65
  176. package/dist/lib/collection/components/benefits-app-host/oidc-callback-page/oidc-callback-page.routes.js +0 -11
  177. package/dist/lib/collection/components/benefits-app-host/services/app-configuration.query.js +0 -18
  178. package/dist/lib/collection/components/benefits-app-host/services/app-configuration.service.js +0 -23
  179. package/dist/lib/collection/components/benefits-app-host/services/authentication.query.js +0 -21
  180. package/dist/lib/collection/components/benefits-app-host/services/authentication.service.js +0 -96
  181. package/dist/lib/collection/components/benefits-app-host/services/session.store.js +0 -33
  182. package/dist/lib/collection/components/cars-calculator-app/api/api-client.js +0 -5
  183. package/dist/lib/collection/components/cars-calculator-app/api/cars-calculator-events.model.js +0 -1
  184. package/dist/lib/collection/components/cars-calculator-app/api/cars-calculator.api.js +0 -45
  185. package/dist/lib/collection/components/cars-calculator-app/api/event-tracking.api.js +0 -7
  186. package/dist/lib/collection/components/cars-calculator-app/cars-calculator-app.css +0 -22
  187. package/dist/lib/collection/components/cars-calculator-app/cars-calculator-app.js +0 -97
  188. package/dist/lib/collection/components/cars-calculator-app/notifications-section/notifications-section.js +0 -25
  189. package/dist/lib/collection/components/cars-calculator-app/pages/asset.component.js +0 -27
  190. package/dist/lib/collection/components/cars-calculator-app/pages/assets/car-placeholder.svg +0 -5
  191. package/dist/lib/collection/components/cars-calculator-app/pages/assets/check.svg +0 -13
  192. package/dist/lib/collection/components/cars-calculator-app/pages/choose-vehicle-section.component.js +0 -234
  193. package/dist/lib/collection/components/cars-calculator-app/pages/common-assets/icon-info.svg +0 -4
  194. package/dist/lib/collection/components/cars-calculator-app/pages/complete-section.component.js +0 -38
  195. package/dist/lib/collection/components/cars-calculator-app/pages/cost-breakdown-section.component.js +0 -45
  196. package/dist/lib/collection/components/cars-calculator-app/pages/model-variants-section.component.css +0 -34
  197. package/dist/lib/collection/components/cars-calculator-app/pages/model-variants-section.component.js +0 -93
  198. package/dist/lib/collection/components/cars-calculator-app/pages/personal-info-section.component.js +0 -71
  199. package/dist/lib/collection/components/cars-calculator-app/pages/quote-result-section.component.js +0 -117
  200. package/dist/lib/collection/components/cars-calculator-app/pages/submit-quote-section.component.js +0 -87
  201. package/dist/lib/collection/components/cars-calculator-app/services/app-configuration.service.js +0 -13
  202. package/dist/lib/collection/components/cars-calculator-app/services/cars-calculator.service.js +0 -117
  203. package/dist/lib/collection/components/cars-calculator-app/services/event-tracking.service.js +0 -37
  204. package/dist/lib/collection/components/cars-calculator-app/services/notifications.service.js +0 -37
  205. package/dist/lib/collection/components/cars-calculator-app/services/notifications.store.js +0 -3
  206. package/dist/lib/collection/components/cars-calculator-app/services/session.query.js +0 -38
  207. package/dist/lib/collection/components/cars-calculator-app/services/session.store.js +0 -80
  208. package/dist/lib/collection/components/cars-calculator-app/services/view.service.js +0 -16
  209. package/dist/lib/collection/components/shared/file-icon/file-icon.css +0 -15
  210. package/dist/lib/collection/components/shared/file-icon/file-icon.js +0 -84
  211. package/dist/lib/collection/components/shared/icon.js +0 -77
  212. package/dist/lib/collection/components/shared/icons-library.js +0 -11
  213. package/dist/lib/collection/components/shared/modal-section.js +0 -138
  214. package/dist/lib/collection/components/shared/tooltip.css +0 -3
  215. package/dist/lib/collection/components/shared/tooltip.js +0 -115
  216. package/dist/lib/collection/components/shared/ui-container/ui-container.css +0 -39
  217. package/dist/lib/collection/components/shared/ui-container/ui-container.js +0 -27
  218. package/dist/lib/collection/global/config.js +0 -2
  219. package/dist/lib/collection/global/main.dev.js +0 -31
  220. package/dist/lib/collection/global/main.js +0 -5
  221. package/dist/lib/collection/index.js +0 -2
  222. package/dist/lib/collection/utils/config.js +0 -2
  223. package/dist/lib/collection/utils/index.js +0 -28
  224. package/dist/lib/collection/utils/lazy.js +0 -29
  225. package/dist/lib/collection/utils/promise.js +0 -7
  226. package/dist/lib/esm/Option-53ef163a.js +0 -1982
  227. package/dist/lib/esm/active-router-134fe07f.js +0 -73
  228. package/dist/lib/esm/ap-ben-asset_5.entry.js +0 -1848
  229. package/dist/lib/esm/ap-ben-benefit-card.entry.js +0 -41
  230. package/dist/lib/esm/ap-ben-benefit-list-item.entry.js +0 -52
  231. package/dist/lib/esm/ap-ben-benefit-url_27.entry.js +0 -48737
  232. package/dist/lib/esm/ap-ben-benefits-list_3.entry.js +0 -49
  233. package/dist/lib/esm/ap-ben-benefits-page.entry.js +0 -51
  234. package/dist/lib/esm/ap-ben-choose-vehicle-section_4.entry.js +0 -2772
  235. package/dist/lib/esm/ap-ben-notifications-section.entry.js +0 -239
  236. package/dist/lib/esm/ap-ben-oidc-callback-page.entry.js +0 -36
  237. package/dist/lib/esm/apollo-benefits.js +0 -23
  238. package/dist/lib/esm/app-globals-ff43b669.js +0 -10
  239. package/dist/lib/esm/authentication.service-4dbff8a5.js +0 -232
  240. package/dist/lib/esm/benefits.api-5a0c5fa7.js +0 -33
  241. package/dist/lib/esm/cars-calculator-app.entry.js +0 -56
  242. package/dist/lib/esm/cars-calculator.service-1278f563.js +0 -163
  243. package/dist/lib/esm/context-consumer.entry.js +0 -25
  244. package/dist/lib/esm/datorama-akita-e42d9911.js +0 -2547
  245. package/dist/lib/esm/delay-d08c267f.js +0 -200
  246. package/dist/lib/esm/event-tracking.service-27d79066.js +0 -253
  247. package/dist/lib/esm/event-tracking.service-429d997c.js +0 -146
  248. package/dist/lib/esm/filter-aeb65cac.js +0 -370
  249. package/dist/lib/esm/fl-dropdown-async.entry.js +0 -418
  250. package/dist/lib/esm/fl-dropdown.entry.js +0 -228
  251. package/dist/lib/esm/fl-style-guide.entry.js +0 -87
  252. package/dist/lib/esm/index-1351f893.js +0 -979
  253. package/dist/lib/esm/index-8676bf1e.js +0 -22
  254. package/dist/lib/esm/index-d4b319a7.js +0 -1702
  255. package/dist/lib/esm/index.js +0 -1
  256. package/dist/lib/esm/loader.js +0 -23
  257. package/dist/lib/esm/polyfills/core-js.js +0 -11
  258. package/dist/lib/esm/polyfills/css-shim.js +0 -1
  259. package/dist/lib/esm/polyfills/dom.js +0 -79
  260. package/dist/lib/esm/polyfills/es5-html-element.js +0 -1
  261. package/dist/lib/esm/polyfills/index.js +0 -34
  262. package/dist/lib/esm/polyfills/system.js +0 -6
  263. package/dist/lib/esm/scheduleArray-b9669898.js +0 -738
  264. package/dist/lib/esm/stencil-async-content.entry.js +0 -28
  265. package/dist/lib/esm/stencil-route-title.entry.js +0 -28
  266. package/dist/lib/esm/stencil-router-prompt.entry.js +0 -55
  267. package/dist/lib/esm/stencil-router-redirect.entry.js +0 -28
  268. package/dist/lib/esm/view.service-6adbec31.js +0 -19
  269. package/dist/lib/index.cjs.js +0 -1
  270. package/dist/lib/index.js +0 -1
  271. package/dist/lib/loader/cdn.js +0 -3
  272. package/dist/lib/loader/index.cjs.js +0 -3
  273. package/dist/lib/loader/index.d.ts +0 -13
  274. package/dist/lib/loader/index.es2017.js +0 -3
  275. package/dist/lib/loader/index.js +0 -4
  276. package/dist/lib/loader/package.json +0 -10
  277. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/button/button.css +0 -118
  278. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/dropdown/dropdown.css +0 -9
  279. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/dropdown-async/dropdown-async.css +0 -9
  280. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/loading-indicator/loading-indicator.css +0 -141
  281. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/promise-button/promise-button.css +0 -5
  282. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/style-guide/style-guide.css +0 -0
  283. package/dist/lib/node_modules/@stencil/router/dist/collection/components/route/route.css +0 -3
  284. package/dist/lib/types/components/benefits-app/apis/api-client.d.ts +0 -7
  285. package/dist/lib/types/components/benefits-app/apis/benefits-api/benefits-api.dto.d.ts +0 -44
  286. package/dist/lib/types/components/benefits-app/apis/benefits-api/benefits.api.d.ts +0 -9
  287. package/dist/lib/types/components/benefits-app/apis/event-tracking-api/event-tracking-api.d.ts +0 -6
  288. package/dist/lib/types/components/benefits-app/apis/event-tracking-api/event-tracking-api.dto.d.ts +0 -18
  289. package/dist/lib/types/components/benefits-app/apis/user-api/user-api.dto.d.ts +0 -30
  290. package/dist/lib/types/components/benefits-app/apis/user-api/user.api.d.ts +0 -8
  291. package/dist/lib/types/components/benefits-app/benefits-app.d.ts +0 -22
  292. package/dist/lib/types/components/benefits-app/pages/benefits-page/benefits-list/benefits-list-item.d.ts +0 -10
  293. package/dist/lib/types/components/benefits-app/pages/benefits-page/benefits-list/benefits-list.d.ts +0 -5
  294. package/dist/lib/types/components/benefits-app/pages/benefits-page/benefits-page.d.ts +0 -10
  295. package/dist/lib/types/components/benefits-app/pages/benefits-page/hero-banner/hero-banner.d.ts +0 -5
  296. package/dist/lib/types/components/benefits-app/pages/benefits-page/promoted-benefits/benefit-card.d.ts +0 -8
  297. package/dist/lib/types/components/benefits-app/pages/benefits-page/promoted-benefits/promoted-benefits.d.ts +0 -5
  298. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/api/manage-benefits-api.dto.d.ts +0 -39
  299. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/api/manage-benefits.api.d.ts +0 -9
  300. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/confirm-dialog.d.ts +0 -16
  301. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-form/benefit-url.d.ts +0 -21
  302. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-form/edit-benefit-form.d.ts +0 -12
  303. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-form/upload-benefit-icon.d.ts +0 -16
  304. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-form/upload-file.d.ts +0 -17
  305. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-page.d.ts +0 -24
  306. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit.query.d.ts +0 -16
  307. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit.service.d.ts +0 -20
  308. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/empty-benefits.d.ts +0 -5
  309. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/manage-benefits-header-row.d.ts +0 -3
  310. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/manage-benefits-page.d.ts +0 -16
  311. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/manage-benefits-page.routes.d.ts +0 -6
  312. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/manage-benefits.service.d.ts +0 -8
  313. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/managed-benefit-item/managed-benefit-item.d.ts +0 -11
  314. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/store/manage-benefits.query.d.ts +0 -10
  315. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/store/manage-benefits.store.d.ts +0 -51
  316. package/dist/lib/types/components/benefits-app/pages/role-management-page/api/role-management.api.d.ts +0 -7
  317. package/dist/lib/types/components/benefits-app/pages/role-management-page/role-editors-section/role-editors-section.d.ts +0 -15
  318. package/dist/lib/types/components/benefits-app/pages/role-management-page/role-management-page.d.ts +0 -9
  319. package/dist/lib/types/components/benefits-app/pages/role-management-page/role-management.service.d.ts +0 -11
  320. package/dist/lib/types/components/benefits-app/pages/role-management-page/role-owner-section/role-owner-section.d.ts +0 -5
  321. package/dist/lib/types/components/benefits-app/pages/role-management-page/store/role-management.query.d.ts +0 -12
  322. package/dist/lib/types/components/benefits-app/pages/role-management-page/store/role-management.store.d.ts +0 -17
  323. package/dist/lib/types/components/benefits-app/services/benefits-app.service.d.ts +0 -13
  324. package/dist/lib/types/components/benefits-app/services/benefits.service.d.ts +0 -8
  325. package/dist/lib/types/components/benefits-app/services/event-tracking.service.d.ts +0 -11
  326. package/dist/lib/types/components/benefits-app/services/navigation.service.d.ts +0 -14
  327. package/dist/lib/types/components/benefits-app/store/benefits-app.query.d.ts +0 -12
  328. package/dist/lib/types/components/benefits-app/store/benefits-app.store.d.ts +0 -31
  329. package/dist/lib/types/components/benefits-app-host/benefits-app-host.d.ts +0 -9
  330. package/dist/lib/types/components/benefits-app-host/loading-page.d.ts +0 -3
  331. package/dist/lib/types/components/benefits-app-host/oidc-callback-page/oidc-callback-page.d.ts +0 -8
  332. package/dist/lib/types/components/benefits-app-host/oidc-callback-page/oidc-callback-page.routes.d.ts +0 -1
  333. package/dist/lib/types/components/benefits-app-host/services/app-configuration.query.d.ts +0 -11
  334. package/dist/lib/types/components/benefits-app-host/services/app-configuration.service.d.ts +0 -9
  335. package/dist/lib/types/components/benefits-app-host/services/authentication.query.d.ts +0 -13
  336. package/dist/lib/types/components/benefits-app-host/services/authentication.service.d.ts +0 -25
  337. package/dist/lib/types/components/benefits-app-host/services/session.store.d.ts +0 -25
  338. package/dist/lib/types/components/cars-calculator-app/api/api-client.d.ts +0 -2
  339. package/dist/lib/types/components/cars-calculator-app/api/cars-calculator-events.model.d.ts +0 -39
  340. package/dist/lib/types/components/cars-calculator-app/api/cars-calculator.api.d.ts +0 -100
  341. package/dist/lib/types/components/cars-calculator-app/api/event-tracking.api.d.ts +0 -6
  342. package/dist/lib/types/components/cars-calculator-app/cars-calculator-app.d.ts +0 -18
  343. package/dist/lib/types/components/cars-calculator-app/notifications-section/notifications-section.d.ts +0 -5
  344. package/dist/lib/types/components/cars-calculator-app/pages/asset.component.d.ts +0 -4
  345. package/dist/lib/types/components/cars-calculator-app/pages/choose-vehicle-section.component.d.ts +0 -23
  346. package/dist/lib/types/components/cars-calculator-app/pages/complete-section.component.d.ts +0 -5
  347. package/dist/lib/types/components/cars-calculator-app/pages/cost-breakdown-section.component.d.ts +0 -6
  348. package/dist/lib/types/components/cars-calculator-app/pages/model-variants-section.component.d.ts +0 -12
  349. package/dist/lib/types/components/cars-calculator-app/pages/personal-info-section.component.d.ts +0 -10
  350. package/dist/lib/types/components/cars-calculator-app/pages/quote-result-section.component.d.ts +0 -16
  351. package/dist/lib/types/components/cars-calculator-app/pages/submit-quote-section.component.d.ts +0 -12
  352. package/dist/lib/types/components/cars-calculator-app/services/app-configuration.service.d.ts +0 -7
  353. package/dist/lib/types/components/cars-calculator-app/services/cars-calculator.service.d.ts +0 -11
  354. package/dist/lib/types/components/cars-calculator-app/services/event-tracking.service.d.ts +0 -13
  355. package/dist/lib/types/components/cars-calculator-app/services/notifications.service.d.ts +0 -15
  356. package/dist/lib/types/components/cars-calculator-app/services/notifications.store.d.ts +0 -14
  357. package/dist/lib/types/components/cars-calculator-app/services/session.query.d.ts +0 -26
  358. package/dist/lib/types/components/cars-calculator-app/services/session.store.d.ts +0 -78
  359. package/dist/lib/types/components/cars-calculator-app/services/view.service.d.ts +0 -8
  360. package/dist/lib/types/components/shared/file-icon/file-icon.d.ts +0 -11
  361. package/dist/lib/types/components/shared/icon.d.ts +0 -7
  362. package/dist/lib/types/components/shared/icons-library.d.ts +0 -1
  363. package/dist/lib/types/components/shared/modal-section.d.ts +0 -16
  364. package/dist/lib/types/components/shared/tooltip.d.ts +0 -13
  365. package/dist/lib/types/components/shared/ui-container/ui-container.d.ts +0 -5
  366. package/dist/lib/types/components.d.ts +0 -606
  367. package/dist/lib/types/global/config.d.ts +0 -2
  368. package/dist/lib/types/global/main.d.ts +0 -1
  369. package/dist/lib/types/global/main.dev.d.ts +0 -1
  370. package/dist/lib/types/index.d.ts +0 -2
  371. package/dist/lib/types/stencil-public-runtime.d.ts +0 -1555
  372. package/dist/lib/types/utils/config.d.ts +0 -2
  373. package/dist/lib/types/utils/index.d.ts +0 -10
  374. package/dist/lib/types/utils/lazy.d.ts +0 -12
  375. package/dist/lib/types/utils/promise.d.ts +0 -1
  376. package/readme.md +0 -1
@@ -1,2553 +0,0 @@
1
- 'use strict';
2
-
3
- const scheduleArray = require('./scheduleArray-0ba3d6f8.js');
4
- const delay = require('./delay-e91dba76.js');
5
- const filter = require('./filter-c38164e6.js');
6
-
7
- const ArgumentOutOfRangeErrorImpl = (() => {
8
- function ArgumentOutOfRangeErrorImpl() {
9
- Error.call(this);
10
- this.message = 'argument out of range';
11
- this.name = 'ArgumentOutOfRangeError';
12
- return this;
13
- }
14
- ArgumentOutOfRangeErrorImpl.prototype = Object.create(Error.prototype);
15
- return ArgumentOutOfRangeErrorImpl;
16
- })();
17
- const ArgumentOutOfRangeError = ArgumentOutOfRangeErrorImpl;
18
-
19
- function take(count) {
20
- return (source) => {
21
- if (count === 0) {
22
- return delay.empty();
23
- }
24
- else {
25
- return source.lift(new TakeOperator(count));
26
- }
27
- };
28
- }
29
- class TakeOperator {
30
- constructor(total) {
31
- this.total = total;
32
- if (this.total < 0) {
33
- throw new ArgumentOutOfRangeError;
34
- }
35
- }
36
- call(subscriber, source) {
37
- return source.subscribe(new TakeSubscriber(subscriber, this.total));
38
- }
39
- }
40
- class TakeSubscriber extends scheduleArray.Subscriber {
41
- constructor(destination, total) {
42
- super(destination);
43
- this.total = total;
44
- this.count = 0;
45
- }
46
- _next(value) {
47
- const total = this.total;
48
- const count = ++this.count;
49
- if (count <= total) {
50
- this.destination.next(value);
51
- if (count === total) {
52
- this.destination.complete();
53
- this.unsubscribe();
54
- }
55
- }
56
- }
57
- }
58
-
59
- const ObjectUnsubscribedErrorImpl = (() => {
60
- function ObjectUnsubscribedErrorImpl() {
61
- Error.call(this);
62
- this.message = 'object unsubscribed';
63
- this.name = 'ObjectUnsubscribedError';
64
- return this;
65
- }
66
- ObjectUnsubscribedErrorImpl.prototype = Object.create(Error.prototype);
67
- return ObjectUnsubscribedErrorImpl;
68
- })();
69
- const ObjectUnsubscribedError = ObjectUnsubscribedErrorImpl;
70
-
71
- class SubjectSubscription extends scheduleArray.Subscription {
72
- constructor(subject, subscriber) {
73
- super();
74
- this.subject = subject;
75
- this.subscriber = subscriber;
76
- this.closed = false;
77
- }
78
- unsubscribe() {
79
- if (this.closed) {
80
- return;
81
- }
82
- this.closed = true;
83
- const subject = this.subject;
84
- const observers = subject.observers;
85
- this.subject = null;
86
- if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
87
- return;
88
- }
89
- const subscriberIndex = observers.indexOf(this.subscriber);
90
- if (subscriberIndex !== -1) {
91
- observers.splice(subscriberIndex, 1);
92
- }
93
- }
94
- }
95
-
96
- class SubjectSubscriber extends scheduleArray.Subscriber {
97
- constructor(destination) {
98
- super(destination);
99
- this.destination = destination;
100
- }
101
- }
102
- class Subject extends scheduleArray.Observable {
103
- constructor() {
104
- super();
105
- this.observers = [];
106
- this.closed = false;
107
- this.isStopped = false;
108
- this.hasError = false;
109
- this.thrownError = null;
110
- }
111
- [scheduleArray.rxSubscriber]() {
112
- return new SubjectSubscriber(this);
113
- }
114
- lift(operator) {
115
- const subject = new AnonymousSubject(this, this);
116
- subject.operator = operator;
117
- return subject;
118
- }
119
- next(value) {
120
- if (this.closed) {
121
- throw new ObjectUnsubscribedError();
122
- }
123
- if (!this.isStopped) {
124
- const { observers } = this;
125
- const len = observers.length;
126
- const copy = observers.slice();
127
- for (let i = 0; i < len; i++) {
128
- copy[i].next(value);
129
- }
130
- }
131
- }
132
- error(err) {
133
- if (this.closed) {
134
- throw new ObjectUnsubscribedError();
135
- }
136
- this.hasError = true;
137
- this.thrownError = err;
138
- this.isStopped = true;
139
- const { observers } = this;
140
- const len = observers.length;
141
- const copy = observers.slice();
142
- for (let i = 0; i < len; i++) {
143
- copy[i].error(err);
144
- }
145
- this.observers.length = 0;
146
- }
147
- complete() {
148
- if (this.closed) {
149
- throw new ObjectUnsubscribedError();
150
- }
151
- this.isStopped = true;
152
- const { observers } = this;
153
- const len = observers.length;
154
- const copy = observers.slice();
155
- for (let i = 0; i < len; i++) {
156
- copy[i].complete();
157
- }
158
- this.observers.length = 0;
159
- }
160
- unsubscribe() {
161
- this.isStopped = true;
162
- this.closed = true;
163
- this.observers = null;
164
- }
165
- _trySubscribe(subscriber) {
166
- if (this.closed) {
167
- throw new ObjectUnsubscribedError();
168
- }
169
- else {
170
- return super._trySubscribe(subscriber);
171
- }
172
- }
173
- _subscribe(subscriber) {
174
- if (this.closed) {
175
- throw new ObjectUnsubscribedError();
176
- }
177
- else if (this.hasError) {
178
- subscriber.error(this.thrownError);
179
- return scheduleArray.Subscription.EMPTY;
180
- }
181
- else if (this.isStopped) {
182
- subscriber.complete();
183
- return scheduleArray.Subscription.EMPTY;
184
- }
185
- else {
186
- this.observers.push(subscriber);
187
- return new SubjectSubscription(this, subscriber);
188
- }
189
- }
190
- asObservable() {
191
- const observable = new scheduleArray.Observable();
192
- observable.source = this;
193
- return observable;
194
- }
195
- }
196
- Subject.create = (destination, source) => {
197
- return new AnonymousSubject(destination, source);
198
- };
199
- class AnonymousSubject extends Subject {
200
- constructor(destination, source) {
201
- super();
202
- this.destination = destination;
203
- this.source = source;
204
- }
205
- next(value) {
206
- const { destination } = this;
207
- if (destination && destination.next) {
208
- destination.next(value);
209
- }
210
- }
211
- error(err) {
212
- const { destination } = this;
213
- if (destination && destination.error) {
214
- this.destination.error(err);
215
- }
216
- }
217
- complete() {
218
- const { destination } = this;
219
- if (destination && destination.complete) {
220
- this.destination.complete();
221
- }
222
- }
223
- _subscribe(subscriber) {
224
- const { source } = this;
225
- if (source) {
226
- return this.source.subscribe(subscriber);
227
- }
228
- else {
229
- return scheduleArray.Subscription.EMPTY;
230
- }
231
- }
232
- }
233
-
234
- class ObserveOnSubscriber extends scheduleArray.Subscriber {
235
- constructor(destination, scheduler, delay = 0) {
236
- super(destination);
237
- this.scheduler = scheduler;
238
- this.delay = delay;
239
- }
240
- static dispatch(arg) {
241
- const { notification, destination } = arg;
242
- notification.observe(destination);
243
- this.unsubscribe();
244
- }
245
- scheduleMessage(notification) {
246
- const destination = this.destination;
247
- destination.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination)));
248
- }
249
- _next(value) {
250
- this.scheduleMessage(delay.Notification.createNext(value));
251
- }
252
- _error(err) {
253
- this.scheduleMessage(delay.Notification.createError(err));
254
- this.unsubscribe();
255
- }
256
- _complete() {
257
- this.scheduleMessage(delay.Notification.createComplete());
258
- this.unsubscribe();
259
- }
260
- }
261
- class ObserveOnMessage {
262
- constructor(notification, destination) {
263
- this.notification = notification;
264
- this.destination = destination;
265
- }
266
- }
267
-
268
- class BehaviorSubject extends Subject {
269
- constructor(_value) {
270
- super();
271
- this._value = _value;
272
- }
273
- get value() {
274
- return this.getValue();
275
- }
276
- _subscribe(subscriber) {
277
- const subscription = super._subscribe(subscriber);
278
- if (subscription && !subscription.closed) {
279
- subscriber.next(this._value);
280
- }
281
- return subscription;
282
- }
283
- getValue() {
284
- if (this.hasError) {
285
- throw this.thrownError;
286
- }
287
- else if (this.closed) {
288
- throw new ObjectUnsubscribedError();
289
- }
290
- else {
291
- return this._value;
292
- }
293
- }
294
- next(value) {
295
- super.next(this._value = value);
296
- }
297
- }
298
-
299
- class QueueAction extends scheduleArray.AsyncAction {
300
- constructor(scheduler, work) {
301
- super(scheduler, work);
302
- this.scheduler = scheduler;
303
- this.work = work;
304
- }
305
- schedule(state, delay = 0) {
306
- if (delay > 0) {
307
- return super.schedule(state, delay);
308
- }
309
- this.delay = delay;
310
- this.state = state;
311
- this.scheduler.flush(this);
312
- return this;
313
- }
314
- execute(state, delay) {
315
- return (delay > 0 || this.closed) ?
316
- super.execute(state, delay) :
317
- this._execute(state, delay);
318
- }
319
- requestAsyncId(scheduler, id, delay = 0) {
320
- if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
321
- return super.requestAsyncId(scheduler, id, delay);
322
- }
323
- return scheduler.flush(this);
324
- }
325
- }
326
-
327
- class QueueScheduler extends scheduleArray.AsyncScheduler {
328
- }
329
-
330
- const queueScheduler = new QueueScheduler(QueueAction);
331
- const queue = queueScheduler;
332
-
333
- class ReplaySubject extends Subject {
334
- constructor(bufferSize = Number.POSITIVE_INFINITY, windowTime = Number.POSITIVE_INFINITY, scheduler) {
335
- super();
336
- this.scheduler = scheduler;
337
- this._events = [];
338
- this._infiniteTimeWindow = false;
339
- this._bufferSize = bufferSize < 1 ? 1 : bufferSize;
340
- this._windowTime = windowTime < 1 ? 1 : windowTime;
341
- if (windowTime === Number.POSITIVE_INFINITY) {
342
- this._infiniteTimeWindow = true;
343
- this.next = this.nextInfiniteTimeWindow;
344
- }
345
- else {
346
- this.next = this.nextTimeWindow;
347
- }
348
- }
349
- nextInfiniteTimeWindow(value) {
350
- if (!this.isStopped) {
351
- const _events = this._events;
352
- _events.push(value);
353
- if (_events.length > this._bufferSize) {
354
- _events.shift();
355
- }
356
- }
357
- super.next(value);
358
- }
359
- nextTimeWindow(value) {
360
- if (!this.isStopped) {
361
- this._events.push(new ReplayEvent(this._getNow(), value));
362
- this._trimBufferThenGetEvents();
363
- }
364
- super.next(value);
365
- }
366
- _subscribe(subscriber) {
367
- const _infiniteTimeWindow = this._infiniteTimeWindow;
368
- const _events = _infiniteTimeWindow ? this._events : this._trimBufferThenGetEvents();
369
- const scheduler = this.scheduler;
370
- const len = _events.length;
371
- let subscription;
372
- if (this.closed) {
373
- throw new ObjectUnsubscribedError();
374
- }
375
- else if (this.isStopped || this.hasError) {
376
- subscription = scheduleArray.Subscription.EMPTY;
377
- }
378
- else {
379
- this.observers.push(subscriber);
380
- subscription = new SubjectSubscription(this, subscriber);
381
- }
382
- if (scheduler) {
383
- subscriber.add(subscriber = new ObserveOnSubscriber(subscriber, scheduler));
384
- }
385
- if (_infiniteTimeWindow) {
386
- for (let i = 0; i < len && !subscriber.closed; i++) {
387
- subscriber.next(_events[i]);
388
- }
389
- }
390
- else {
391
- for (let i = 0; i < len && !subscriber.closed; i++) {
392
- subscriber.next(_events[i].value);
393
- }
394
- }
395
- if (this.hasError) {
396
- subscriber.error(this.thrownError);
397
- }
398
- else if (this.isStopped) {
399
- subscriber.complete();
400
- }
401
- return subscription;
402
- }
403
- _getNow() {
404
- return (this.scheduler || queue).now();
405
- }
406
- _trimBufferThenGetEvents() {
407
- const now = this._getNow();
408
- const _bufferSize = this._bufferSize;
409
- const _windowTime = this._windowTime;
410
- const _events = this._events;
411
- const eventsCount = _events.length;
412
- let spliceCount = 0;
413
- while (spliceCount < eventsCount) {
414
- if ((now - _events[spliceCount].time) < _windowTime) {
415
- break;
416
- }
417
- spliceCount++;
418
- }
419
- if (eventsCount > _bufferSize) {
420
- spliceCount = Math.max(spliceCount, eventsCount - _bufferSize);
421
- }
422
- if (spliceCount > 0) {
423
- _events.splice(0, spliceCount);
424
- }
425
- return _events;
426
- }
427
- }
428
- class ReplayEvent {
429
- constructor(time, value) {
430
- this.time = time;
431
- this.value = value;
432
- }
433
- }
434
-
435
- function skip(count) {
436
- return (source) => source.lift(new SkipOperator(count));
437
- }
438
- class SkipOperator {
439
- constructor(total) {
440
- this.total = total;
441
- }
442
- call(subscriber, source) {
443
- return source.subscribe(new SkipSubscriber(subscriber, this.total));
444
- }
445
- }
446
- class SkipSubscriber extends scheduleArray.Subscriber {
447
- constructor(destination, total) {
448
- super(destination);
449
- this.total = total;
450
- this.count = 0;
451
- }
452
- _next(x) {
453
- if (++this.count > this.total) {
454
- this.destination.next(x);
455
- }
456
- }
457
- }
458
-
459
- function switchMap(project, resultSelector) {
460
- if (typeof resultSelector === 'function') {
461
- return (source) => source.pipe(switchMap((a, i) => filter.from(project(a, i)).pipe(filter.map((b, ii) => resultSelector(a, b, i, ii)))));
462
- }
463
- return (source) => source.lift(new SwitchMapOperator(project));
464
- }
465
- class SwitchMapOperator {
466
- constructor(project) {
467
- this.project = project;
468
- }
469
- call(subscriber, source) {
470
- return source.subscribe(new SwitchMapSubscriber(subscriber, this.project));
471
- }
472
- }
473
- class SwitchMapSubscriber extends filter.SimpleOuterSubscriber {
474
- constructor(destination, project) {
475
- super(destination);
476
- this.project = project;
477
- this.index = 0;
478
- }
479
- _next(value) {
480
- let result;
481
- const index = this.index++;
482
- try {
483
- result = this.project(value, index);
484
- }
485
- catch (error) {
486
- this.destination.error(error);
487
- return;
488
- }
489
- this._innerSub(result);
490
- }
491
- _innerSub(result) {
492
- const innerSubscription = this.innerSubscription;
493
- if (innerSubscription) {
494
- innerSubscription.unsubscribe();
495
- }
496
- const innerSubscriber = new filter.SimpleInnerSubscriber(this);
497
- const destination = this.destination;
498
- destination.add(innerSubscriber);
499
- this.innerSubscription = filter.innerSubscribe(result, innerSubscriber);
500
- if (this.innerSubscription !== innerSubscriber) {
501
- destination.add(this.innerSubscription);
502
- }
503
- }
504
- _complete() {
505
- const { innerSubscription } = this;
506
- if (!innerSubscription || innerSubscription.closed) {
507
- super._complete();
508
- }
509
- this.unsubscribe();
510
- }
511
- _unsubscribe() {
512
- this.innerSubscription = undefined;
513
- }
514
- notifyComplete() {
515
- this.innerSubscription = undefined;
516
- if (this.isStopped) {
517
- super._complete();
518
- }
519
- }
520
- notifyNext(innerValue) {
521
- this.destination.next(innerValue);
522
- }
523
- }
524
-
525
- function isObservable(obj) {
526
- return !!obj && (obj instanceof scheduleArray.Observable || (typeof obj.lift === 'function' && typeof obj.subscribe === 'function'));
527
- }
528
-
529
- /*! *****************************************************************************
530
- Copyright (c) Microsoft Corporation.
531
-
532
- Permission to use, copy, modify, and/or distribute this software for any
533
- purpose with or without fee is hereby granted.
534
-
535
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
536
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
537
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
538
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
539
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
540
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
541
- PERFORMANCE OF THIS SOFTWARE.
542
- ***************************************************************************** */
543
-
544
- function __rest(s, e) {
545
- var t = {};
546
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
547
- t[p] = s[p];
548
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
549
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
550
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
551
- t[p[i]] = s[p[i]];
552
- }
553
- return t;
554
- }
555
-
556
- function __decorate(decorators, target, key, desc) {
557
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
558
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
559
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
560
- return c > 3 && r && Object.defineProperty(target, key, r), r;
561
- }
562
-
563
- function __metadata(metadataKey, metadataValue) {
564
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
565
- }
566
-
567
- const currentAction = {
568
- type: null,
569
- entityIds: null,
570
- skip: false,
571
- payload: null
572
- };
573
- let customActionActive = false;
574
- function resetCustomAction() {
575
- customActionActive = false;
576
- }
577
- // public API for custom actions. Custom action always wins
578
- function logAction(type, entityIds, payload) {
579
- setAction(type, entityIds, payload);
580
- customActionActive = true;
581
- }
582
- function setAction(type, entityIds, payload) {
583
- if (customActionActive === false) {
584
- currentAction.type = type;
585
- currentAction.entityIds = entityIds;
586
- currentAction.payload = payload;
587
- }
588
- }
589
- function action(action, entityIds) {
590
- return function (target, propertyKey, descriptor) {
591
- const originalMethod = descriptor.value;
592
- descriptor.value = function (...args) {
593
- logAction(action, entityIds);
594
- return originalMethod.apply(this, args);
595
- };
596
- return descriptor;
597
- };
598
- }
599
-
600
- // @internal
601
- function hasEntity(entities, id) {
602
- return entities.hasOwnProperty(id);
603
- }
604
-
605
- // @internal
606
- function isArray(value) {
607
- return Array.isArray(value);
608
- }
609
-
610
- // @internal
611
- function hasActiveState(state) {
612
- return state.hasOwnProperty('active');
613
- }
614
- // @internal
615
- function isMultiActiveState(active) {
616
- return isArray(active);
617
- }
618
- // @internal
619
- function resolveActiveEntity({ active, ids, entities }) {
620
- if (isMultiActiveState(active)) {
621
- return getExitingActives(active, ids);
622
- }
623
- if (hasEntity(entities, active) === false) {
624
- return null;
625
- }
626
- return active;
627
- }
628
- // @internal
629
- function getExitingActives(currentActivesIds, newIds) {
630
- const filtered = currentActivesIds.filter(id => newIds.indexOf(id) > -1);
631
- /** Return the same reference if nothing has changed */
632
- if (filtered.length === currentActivesIds.length) {
633
- return currentActivesIds;
634
- }
635
- return filtered;
636
- }
637
-
638
- // @internal
639
- function addEntities({ state, entities, idKey, options = {}, preAddEntity }) {
640
- let newEntities = {};
641
- let newIds = [];
642
- let hasNewEntities = false;
643
- for (const entity of entities) {
644
- if (hasEntity(state.entities, entity[idKey]) === false) {
645
- // evaluate the middleware first to support dynamic ids
646
- const current = preAddEntity(entity);
647
- const entityId = current[idKey];
648
- newEntities[entityId] = current;
649
- if (options.prepend)
650
- newIds.unshift(entityId);
651
- else
652
- newIds.push(entityId);
653
- hasNewEntities = true;
654
- }
655
- }
656
- return hasNewEntities
657
- ? {
658
- newState: Object.assign(Object.assign({}, state), { entities: Object.assign(Object.assign({}, state.entities), newEntities), ids: options.prepend ? [...newIds, ...state.ids] : [...state.ids, ...newIds] }),
659
- newIds
660
- }
661
- : null;
662
- }
663
-
664
- // @internal
665
- function isNil(v) {
666
- return v === null || v === undefined;
667
- }
668
-
669
- // @internal
670
- function coerceArray(value) {
671
- if (isNil(value)) {
672
- return [];
673
- }
674
- return Array.isArray(value) ? value : [value];
675
- }
676
-
677
- const DEFAULT_ID_KEY = 'id';
678
-
679
- // @internal
680
- function isFunction(value) {
681
- return typeof value === 'function';
682
- }
683
-
684
- // @internal
685
- function isEmpty(arr) {
686
- if (isArray(arr)) {
687
- return arr.length === 0;
688
- }
689
- return false;
690
- }
691
-
692
- // @internal
693
- function isObject(value) {
694
- const type = typeof value;
695
- return value != null && (type == 'object' || type == 'function');
696
- }
697
-
698
- let CONFIG = {
699
- resettable: false,
700
- ttl: null,
701
- producerFn: undefined
702
- };
703
- // @internal
704
- function getAkitaConfig() {
705
- return CONFIG;
706
- }
707
- function getGlobalProducerFn() {
708
- return CONFIG.producerFn;
709
- }
710
-
711
- // @internal
712
- function isDefined(val) {
713
- return isNil(val) === false;
714
- }
715
-
716
- // @internal
717
- const $$deleteStore = new Subject();
718
- // @internal
719
- const $$addStore = new ReplaySubject(50, 5000);
720
- // @internal
721
- const $$updateStore = new Subject();
722
- // @internal
723
- function dispatchDeleted(storeName) {
724
- $$deleteStore.next(storeName);
725
- }
726
- // @internal
727
- function dispatchAdded(storeName) {
728
- $$addStore.next(storeName);
729
- }
730
- // @internal
731
- function dispatchUpdate(storeName, action) {
732
- $$updateStore.next({ storeName, action });
733
- }
734
-
735
- const isBrowser = typeof window !== 'undefined';
736
- const isNotBrowser = !isBrowser;
737
- // export const isNativeScript = typeof global !== 'undefined' && (<any>global).__runtimeVersion !== 'undefined'; TODO is this used?
738
- const hasLocalStorage = () => {
739
- try {
740
- return typeof localStorage !== 'undefined';
741
- }
742
- catch (_a) {
743
- return false;
744
- }
745
- };
746
- const hasSessionStorage = () => {
747
- try {
748
- return typeof sessionStorage !== 'undefined';
749
- }
750
- catch (_a) {
751
- return false;
752
- }
753
- };
754
-
755
- // @internal
756
- const __stores__ = {};
757
- // @internal
758
- const __queries__ = {};
759
- if (isBrowser) {
760
- window.$$stores = __stores__;
761
- window.$$queries = __queries__;
762
- }
763
-
764
- var Order;
765
- (function (Order) {
766
- Order["ASC"] = "asc";
767
- Order["DESC"] = "desc";
768
- })(Order || (Order = {}));
769
-
770
- var EntityActions;
771
- (function (EntityActions) {
772
- EntityActions["Set"] = "Set";
773
- EntityActions["Add"] = "Add";
774
- EntityActions["Update"] = "Update";
775
- EntityActions["Remove"] = "Remove";
776
- })(EntityActions || (EntityActions = {}));
777
-
778
- let __DEV__ = true;
779
- function enableAkitaProdMode() {
780
- __DEV__ = false;
781
- if (isBrowser) {
782
- delete window.$$stores;
783
- delete window.$$queries;
784
- }
785
- }
786
- // @internal
787
- function isDev() {
788
- return __DEV__;
789
- }
790
-
791
- // @internal
792
- function getActiveEntities(idOrOptions, ids, currentActive) {
793
- let result;
794
- if (isArray(idOrOptions)) {
795
- result = idOrOptions;
796
- }
797
- else {
798
- if (isObject(idOrOptions)) {
799
- if (isNil(currentActive))
800
- return;
801
- idOrOptions = Object.assign({ wrap: true }, idOrOptions);
802
- const currentIdIndex = ids.indexOf(currentActive);
803
- if (idOrOptions.prev) {
804
- const isFirst = currentIdIndex === 0;
805
- if (isFirst && !idOrOptions.wrap)
806
- return;
807
- result = isFirst ? ids[ids.length - 1] : ids[currentIdIndex - 1];
808
- }
809
- else if (idOrOptions.next) {
810
- const isLast = ids.length === currentIdIndex + 1;
811
- if (isLast && !idOrOptions.wrap)
812
- return;
813
- result = isLast ? ids[0] : ids[currentIdIndex + 1];
814
- }
815
- }
816
- else {
817
- if (idOrOptions === currentActive)
818
- return;
819
- result = idOrOptions;
820
- }
821
- }
822
- return result;
823
- }
824
-
825
- // @internal
826
- const getInitialEntitiesState = () => ({
827
- entities: {},
828
- ids: [],
829
- loading: true,
830
- error: null
831
- });
832
-
833
- // @internal
834
- function isUndefined(value) {
835
- return value === undefined;
836
- }
837
-
838
- // @internal
839
- function removeEntities({ state, ids }) {
840
- if (isNil(ids))
841
- return removeAllEntities(state);
842
- const entities = state.entities;
843
- let newEntities = {};
844
- for (const id of state.ids) {
845
- if (ids.includes(id) === false) {
846
- newEntities[id] = entities[id];
847
- }
848
- }
849
- const newState = Object.assign(Object.assign({}, state), { entities: newEntities, ids: state.ids.filter(current => ids.includes(current) === false) });
850
- if (hasActiveState(state)) {
851
- newState.active = resolveActiveEntity(newState);
852
- }
853
- return newState;
854
- }
855
- // @internal
856
- function removeAllEntities(state) {
857
- return Object.assign(Object.assign({}, state), { entities: {}, ids: [], active: isMultiActiveState(state.active) ? [] : null });
858
- }
859
-
860
- // @internal
861
- function toEntitiesObject(entities, idKey, preAddEntity) {
862
- const acc = {
863
- entities: {},
864
- ids: []
865
- };
866
- for (const entity of entities) {
867
- // evaluate the middleware first to support dynamic ids
868
- const current = preAddEntity(entity);
869
- acc.entities[current[idKey]] = current;
870
- acc.ids.push(current[idKey]);
871
- }
872
- return acc;
873
- }
874
-
875
- // @internal
876
- function isEntityState(state) {
877
- return state.entities && state.ids;
878
- }
879
- // @internal
880
- function applyMiddleware(entities, preAddEntity) {
881
- let mapped = {};
882
- for (const id of Object.keys(entities)) {
883
- mapped[id] = preAddEntity(entities[id]);
884
- }
885
- return mapped;
886
- }
887
- // @internal
888
- function setEntities({ state, entities, idKey, preAddEntity, isNativePreAdd }) {
889
- let newEntities;
890
- let newIds;
891
- if (isArray(entities)) {
892
- const resolve = toEntitiesObject(entities, idKey, preAddEntity);
893
- newEntities = resolve.entities;
894
- newIds = resolve.ids;
895
- }
896
- else if (isEntityState(entities)) {
897
- newEntities = isNativePreAdd ? entities.entities : applyMiddleware(entities.entities, preAddEntity);
898
- newIds = entities.ids;
899
- }
900
- else {
901
- // it's an object
902
- newEntities = isNativePreAdd ? entities : applyMiddleware(entities, preAddEntity);
903
- newIds = Object.keys(newEntities).map(id => (isNaN(id) ? id : Number(id)));
904
- }
905
- const newState = Object.assign(Object.assign({}, state), { entities: newEntities, ids: newIds, loading: false });
906
- if (hasActiveState(state)) {
907
- newState.active = resolveActiveEntity(newState);
908
- }
909
- return newState;
910
- }
911
-
912
- // @internal
913
- function deepFreeze(o) {
914
- Object.freeze(o);
915
- const oIsFunction = typeof o === 'function';
916
- const hasOwnProp = Object.prototype.hasOwnProperty;
917
- Object.getOwnPropertyNames(o).forEach(function (prop) {
918
- if (hasOwnProp.call(o, prop) &&
919
- (oIsFunction ? prop !== 'caller' && prop !== 'callee' && prop !== 'arguments' : true) &&
920
- o[prop] !== null &&
921
- (typeof o[prop] === 'object' || typeof o[prop] === 'function') &&
922
- !Object.isFrozen(o[prop])) {
923
- deepFreeze(o[prop]);
924
- }
925
- });
926
- return o;
927
- }
928
- // @internal
929
- function assertStoreHasName(name, className) {
930
- if (!name) {
931
- console.error(`@StoreConfig({ name }) is missing in ${className}`);
932
- }
933
- }
934
-
935
- // @internal
936
- function toBoolean(value) {
937
- return value != null && `${value}` !== 'false';
938
- }
939
-
940
- // @internal
941
- function isPlainObject(value) {
942
- return toBoolean(value) && value.constructor.name === 'Object';
943
- }
944
-
945
- const configKey = 'akitaConfig';
946
- function StoreConfig(metadata) {
947
- return function (constructor) {
948
- constructor[configKey] = { idKey: 'id' };
949
- for (let i = 0, keys = Object.keys(metadata); i < keys.length; i++) {
950
- const key = keys[i];
951
- /* name is preserved read only key */
952
- if (key === 'name') {
953
- constructor[configKey]['storeName'] = metadata[key];
954
- }
955
- else {
956
- constructor[configKey][key] = metadata[key];
957
- }
958
- }
959
- };
960
- }
961
-
962
- // @internal
963
- const transactionFinished = new Subject();
964
- // @internal
965
- const transactionInProcess = new BehaviorSubject(false);
966
- // @internal
967
- const transactionManager = {
968
- activeTransactions: 0,
969
- batchTransaction: null
970
- };
971
- // @internal
972
- function startBatch() {
973
- if (!isTransactionInProcess()) {
974
- transactionManager.batchTransaction = new Subject();
975
- }
976
- transactionManager.activeTransactions++;
977
- transactionInProcess.next(true);
978
- }
979
- // @internal
980
- function endBatch() {
981
- if (--transactionManager.activeTransactions === 0) {
982
- transactionManager.batchTransaction.next(true);
983
- transactionManager.batchTransaction.complete();
984
- transactionInProcess.next(false);
985
- transactionFinished.next(true);
986
- }
987
- }
988
- // @internal
989
- function isTransactionInProcess() {
990
- return transactionManager.activeTransactions > 0;
991
- }
992
- // @internal
993
- function commit() {
994
- return transactionManager.batchTransaction ? transactionManager.batchTransaction.asObservable() : delay.of(true);
995
- }
996
- /**
997
- * A logical transaction.
998
- * Use this transaction to optimize the dispatch of all the stores.
999
- * The following code will update the store, BUT emits only once
1000
- *
1001
- * @example
1002
- * applyTransaction(() => {
1003
- * this.todosStore.add(new Todo(1, title));
1004
- * this.todosStore.add(new Todo(2, title));
1005
- * });
1006
- *
1007
- */
1008
- function applyTransaction(action, thisArg = undefined) {
1009
- startBatch();
1010
- try {
1011
- return action.apply(thisArg);
1012
- }
1013
- finally {
1014
- logAction('@Transaction');
1015
- endBatch();
1016
- }
1017
- }
1018
- /**
1019
- * A logical transaction.
1020
- * Use this transaction to optimize the dispatch of all the stores.
1021
- *
1022
- * The following code will update the store, BUT emits only once.
1023
- *
1024
- * @example
1025
- * @transaction
1026
- * addTodos() {
1027
- * this.todosStore.add(new Todo(1, title));
1028
- * this.todosStore.add(new Todo(2, title));
1029
- * }
1030
- *
1031
- *
1032
- */
1033
- function transaction() {
1034
- return function (target, propertyKey, descriptor) {
1035
- const originalMethod = descriptor.value;
1036
- descriptor.value = function (...args) {
1037
- return applyTransaction(() => {
1038
- return originalMethod.apply(this, args);
1039
- }, this);
1040
- };
1041
- return descriptor;
1042
- };
1043
- }
1044
-
1045
- /**
1046
- *
1047
- * Store for managing any type of data
1048
- *
1049
- * @example
1050
- *
1051
- * export interface SessionState {
1052
- * token: string;
1053
- * userDetails: UserDetails
1054
- * }
1055
- *
1056
- * export function createInitialState(): SessionState {
1057
- * return {
1058
- * token: '',
1059
- * userDetails: null
1060
- * };
1061
- * }
1062
- *
1063
- * @StoreConfig({ name: 'session' })
1064
- * export class SessionStore extends Store<SessionState> {
1065
- * constructor() {
1066
- * super(createInitialState());
1067
- * }
1068
- * }
1069
- */
1070
- class Store {
1071
- constructor(initialState, options = {}) {
1072
- this.options = options;
1073
- this.inTransaction = false;
1074
- this.cache = {
1075
- active: new BehaviorSubject(false),
1076
- ttl: null,
1077
- };
1078
- this.onInit(initialState);
1079
- }
1080
- /**
1081
- * Set the loading state
1082
- *
1083
- * @example
1084
- *
1085
- * store.setLoading(true)
1086
- *
1087
- */
1088
- setLoading(loading = false) {
1089
- if (loading !== this._value().loading) {
1090
- isDev() && setAction('Set Loading');
1091
- this._setState((state) => (Object.assign(Object.assign({}, state), { loading })));
1092
- }
1093
- }
1094
- /**
1095
- *
1096
- * Set whether the data is cached
1097
- *
1098
- * @example
1099
- *
1100
- * store.setHasCache(true)
1101
- * store.setHasCache(false)
1102
- * store.setHasCache(true, { restartTTL: true })
1103
- *
1104
- */
1105
- setHasCache(hasCache, options = { restartTTL: false }) {
1106
- if (hasCache !== this.cache.active.value) {
1107
- this.cache.active.next(hasCache);
1108
- }
1109
- if (options.restartTTL) {
1110
- const ttlConfig = this.getCacheTTL();
1111
- if (ttlConfig) {
1112
- if (this.cache.ttl !== null) {
1113
- clearTimeout(this.cache.ttl);
1114
- }
1115
- this.cache.ttl = setTimeout(() => this.setHasCache(false), ttlConfig);
1116
- }
1117
- }
1118
- }
1119
- /**
1120
- *
1121
- * Sometimes we need to access the store value from a store
1122
- *
1123
- * @example middleware
1124
- *
1125
- */
1126
- getValue() {
1127
- return this.storeValue;
1128
- }
1129
- /**
1130
- * Set the error state
1131
- *
1132
- * @example
1133
- *
1134
- * store.setError({text: 'unable to load data' })
1135
- *
1136
- */
1137
- setError(error) {
1138
- if (error !== this._value().error) {
1139
- isDev() && setAction('Set Error');
1140
- this._setState((state) => (Object.assign(Object.assign({}, state), { error })));
1141
- }
1142
- }
1143
- // @internal
1144
- _select(project) {
1145
- return this.store.asObservable().pipe(filter.map((snapshot) => project(snapshot.state)), filter.distinctUntilChanged());
1146
- }
1147
- // @internal
1148
- _value() {
1149
- return this.storeValue;
1150
- }
1151
- // @internal
1152
- _cache() {
1153
- return this.cache.active;
1154
- }
1155
- // @internal
1156
- get config() {
1157
- return this.constructor[configKey] || {};
1158
- }
1159
- // @internal
1160
- get storeName() {
1161
- return this.config.storeName || this.options.storeName || this.options.name;
1162
- }
1163
- // @internal
1164
- get deepFreeze() {
1165
- return this.config.deepFreezeFn || this.options.deepFreezeFn || deepFreeze;
1166
- }
1167
- // @internal
1168
- get cacheConfig() {
1169
- return this.config.cache || this.options.cache;
1170
- }
1171
- get _producerFn() {
1172
- return this.config.producerFn || this.options.producerFn || getGlobalProducerFn();
1173
- }
1174
- // @internal
1175
- get resettable() {
1176
- return isDefined(this.config.resettable) ? this.config.resettable : this.options.resettable;
1177
- }
1178
- // @internal
1179
- _setState(newState, _dispatchAction = true) {
1180
- if (isFunction(newState)) {
1181
- const _newState = newState(this._value());
1182
- this.storeValue = __DEV__ ? this.deepFreeze(_newState) : _newState;
1183
- }
1184
- else {
1185
- this.storeValue = newState;
1186
- }
1187
- if (!this.store) {
1188
- this.store = new BehaviorSubject({ state: this.storeValue });
1189
- if (isDev()) {
1190
- this.store.subscribe(({ action }) => {
1191
- if (action) {
1192
- dispatchUpdate(this.storeName, action);
1193
- }
1194
- });
1195
- }
1196
- return;
1197
- }
1198
- if (isTransactionInProcess()) {
1199
- this.handleTransaction();
1200
- return;
1201
- }
1202
- this.dispatch(this.storeValue, _dispatchAction);
1203
- }
1204
- /**
1205
- *
1206
- * Reset the current store back to the initial value
1207
- *
1208
- * @example
1209
- *
1210
- * store.reset()
1211
- *
1212
- */
1213
- reset() {
1214
- if (this.isResettable()) {
1215
- isDev() && setAction('Reset');
1216
- this._setState(() => Object.assign({}, this._initialState));
1217
- this.setHasCache(false);
1218
- }
1219
- else {
1220
- isDev() && console.warn(`You need to enable the reset functionality`);
1221
- }
1222
- }
1223
- update(stateOrCallback) {
1224
- isDev() && setAction('Update');
1225
- let newState;
1226
- const currentState = this._value();
1227
- if (isFunction(stateOrCallback)) {
1228
- newState = isFunction(this._producerFn) ? this._producerFn(currentState, stateOrCallback) : stateOrCallback(currentState);
1229
- }
1230
- else {
1231
- newState = stateOrCallback;
1232
- }
1233
- const withHook = this.akitaPreUpdate(currentState, Object.assign(Object.assign({}, currentState), newState));
1234
- const resolved = isPlainObject(currentState) ? withHook : new currentState.constructor(withHook);
1235
- this._setState(resolved);
1236
- }
1237
- updateStoreConfig(newOptions) {
1238
- this.options = Object.assign(Object.assign({}, this.options), newOptions);
1239
- }
1240
- // @internal
1241
- akitaPreUpdate(_, nextState) {
1242
- return nextState;
1243
- }
1244
- ngOnDestroy() {
1245
- this.destroy();
1246
- }
1247
- /**
1248
- *
1249
- * Destroy the store
1250
- *
1251
- * @example
1252
- *
1253
- * store.destroy()
1254
- *
1255
- */
1256
- destroy() {
1257
- const hmrEnabled = isBrowser ? window.hmrEnabled : false;
1258
- if (!hmrEnabled && this === __stores__[this.storeName]) {
1259
- delete __stores__[this.storeName];
1260
- dispatchDeleted(this.storeName);
1261
- this.setHasCache(false);
1262
- this.cache.active.complete();
1263
- this.store.complete();
1264
- }
1265
- }
1266
- onInit(initialState) {
1267
- __stores__[this.storeName] = this;
1268
- this._setState(() => initialState);
1269
- dispatchAdded(this.storeName);
1270
- if (this.isResettable()) {
1271
- this._initialState = initialState;
1272
- }
1273
- isDev() && assertStoreHasName(this.storeName, this.constructor.name);
1274
- }
1275
- dispatch(state, _dispatchAction = true) {
1276
- let action = undefined;
1277
- if (_dispatchAction) {
1278
- action = currentAction;
1279
- resetCustomAction();
1280
- }
1281
- this.store.next({ state, action });
1282
- }
1283
- watchTransaction() {
1284
- commit().subscribe(() => {
1285
- this.inTransaction = false;
1286
- this.dispatch(this._value());
1287
- });
1288
- }
1289
- isResettable() {
1290
- if (this.resettable === false) {
1291
- return false;
1292
- }
1293
- return this.resettable || getAkitaConfig().resettable;
1294
- }
1295
- handleTransaction() {
1296
- if (!this.inTransaction) {
1297
- this.watchTransaction();
1298
- this.inTransaction = true;
1299
- }
1300
- }
1301
- getCacheTTL() {
1302
- return (this.cacheConfig && this.cacheConfig.ttl) || getAkitaConfig().ttl;
1303
- }
1304
- }
1305
-
1306
- // @internal
1307
- function updateEntities({ state, ids, idKey, newStateOrFn, preUpdateEntity, producerFn, onEntityIdChanges }) {
1308
- const updatedEntities = {};
1309
- let isUpdatingIdKey = false;
1310
- let idToUpdate;
1311
- for (const id of ids) {
1312
- // if the entity doesn't exist don't do anything
1313
- if (hasEntity(state.entities, id) === false) {
1314
- continue;
1315
- }
1316
- const oldEntity = state.entities[id];
1317
- let newState;
1318
- if (isFunction(newStateOrFn)) {
1319
- newState = isFunction(producerFn) ? producerFn(oldEntity, newStateOrFn) : newStateOrFn(oldEntity);
1320
- }
1321
- else {
1322
- newState = newStateOrFn;
1323
- }
1324
- const isIdChanged = newState.hasOwnProperty(idKey) && newState[idKey] !== oldEntity[idKey];
1325
- let newEntity;
1326
- idToUpdate = id;
1327
- if (isIdChanged) {
1328
- isUpdatingIdKey = true;
1329
- idToUpdate = newState[idKey];
1330
- }
1331
- const merged = Object.assign(Object.assign({}, oldEntity), newState);
1332
- if (isPlainObject(oldEntity)) {
1333
- newEntity = merged;
1334
- }
1335
- else {
1336
- /**
1337
- * In case that new state is class of it's own, there's
1338
- * a possibility that it will be different than the old
1339
- * class.
1340
- * For example, Old state is an instance of animal class
1341
- * and new state is instance of person class.
1342
- * To avoid run over new person class with the old animal
1343
- * class we check if the new state is a class of it's own.
1344
- * If so, use it. Otherwise, use the old state class
1345
- */
1346
- if (isPlainObject(newState)) {
1347
- newEntity = new oldEntity.constructor(merged);
1348
- }
1349
- else {
1350
- newEntity = new newState.constructor(merged);
1351
- }
1352
- }
1353
- updatedEntities[idToUpdate] = preUpdateEntity(oldEntity, newEntity);
1354
- }
1355
- let updatedIds = state.ids;
1356
- let stateEntities = state.entities;
1357
- if (isUpdatingIdKey) {
1358
- const [id] = ids;
1359
- const _a = state.entities, _b = id, rest = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
1360
- stateEntities = rest;
1361
- updatedIds = state.ids.map((current) => (current === id ? idToUpdate : current));
1362
- onEntityIdChanges(id, idToUpdate);
1363
- }
1364
- return Object.assign(Object.assign({}, state), { entities: Object.assign(Object.assign({}, stateEntities), updatedEntities), ids: updatedIds });
1365
- }
1366
-
1367
- var _b;
1368
- /**
1369
- *
1370
- * Store for managing a collection of entities
1371
- *
1372
- * @example
1373
- *
1374
- * export interface WidgetsState extends EntityState<Widget> { }
1375
- *
1376
- * @StoreConfig({ name: 'widgets' })
1377
- * export class WidgetsStore extends EntityStore<WidgetsState> {
1378
- * constructor() {
1379
- * super();
1380
- * }
1381
- * }
1382
- *
1383
- *
1384
- */
1385
- class EntityStore extends Store {
1386
- constructor(initialState = {}, options = {}) {
1387
- super(Object.assign(Object.assign({}, getInitialEntitiesState()), initialState), options);
1388
- this.options = options;
1389
- this.entityActions = new Subject();
1390
- this.entityIdChanges = new Subject();
1391
- }
1392
- // @internal
1393
- get selectEntityAction$() {
1394
- return this.entityActions.asObservable();
1395
- }
1396
- // @internal
1397
- get selectEntityIdChanges$() {
1398
- return this.entityIdChanges.asObservable();
1399
- }
1400
- // @internal
1401
- get idKey() {
1402
- return this.config.idKey || this.options.idKey || DEFAULT_ID_KEY;
1403
- }
1404
- /**
1405
- *
1406
- * Replace current collection with provided collection
1407
- *
1408
- * @example
1409
- *
1410
- * this.store.set([Entity, Entity])
1411
- * this.store.set({ids: [], entities: {}})
1412
- * this.store.set({ 1: {}, 2: {}})
1413
- *
1414
- */
1415
- set(entities, options = {}) {
1416
- if (isNil(entities))
1417
- return;
1418
- isDev() && setAction('Set Entity');
1419
- const isNativePreAdd = this.akitaPreAddEntity === EntityStore.prototype.akitaPreAddEntity;
1420
- this.setHasCache(true, { restartTTL: true });
1421
- this._setState((state) => {
1422
- const newState = setEntities({
1423
- state,
1424
- entities,
1425
- idKey: this.idKey,
1426
- preAddEntity: this.akitaPreAddEntity,
1427
- isNativePreAdd,
1428
- });
1429
- if (isUndefined(options.activeId) === false) {
1430
- newState.active = options.activeId;
1431
- }
1432
- return newState;
1433
- });
1434
- if (this.hasInitialUIState()) {
1435
- this.handleUICreation();
1436
- }
1437
- this.entityActions.next({ type: EntityActions.Set, ids: this.ids });
1438
- }
1439
- /**
1440
- * Add entities
1441
- *
1442
- * @example
1443
- *
1444
- * this.store.add([Entity, Entity])
1445
- * this.store.add(Entity)
1446
- * this.store.add(Entity, { prepend: true })
1447
- *
1448
- * this.store.add(Entity, { loading: false })
1449
- */
1450
- add(entities, options = { loading: false }) {
1451
- const collection = coerceArray(entities);
1452
- if (isEmpty(collection))
1453
- return;
1454
- const data = addEntities({
1455
- state: this._value(),
1456
- preAddEntity: this.akitaPreAddEntity,
1457
- entities: collection,
1458
- idKey: this.idKey,
1459
- options,
1460
- });
1461
- if (data) {
1462
- isDev() && setAction('Add Entity');
1463
- data.newState.loading = options.loading;
1464
- this._setState(() => data.newState);
1465
- if (this.hasInitialUIState()) {
1466
- this.handleUICreation(true);
1467
- }
1468
- this.entityActions.next({ type: EntityActions.Add, ids: data.newIds });
1469
- }
1470
- }
1471
- update(idsOrFnOrState, newStateOrFn) {
1472
- if (isUndefined(newStateOrFn)) {
1473
- super.update(idsOrFnOrState);
1474
- return;
1475
- }
1476
- let ids = [];
1477
- if (isFunction(idsOrFnOrState)) {
1478
- // We need to filter according the predicate function
1479
- ids = this.ids.filter((id) => idsOrFnOrState(this.entities[id]));
1480
- }
1481
- else {
1482
- // If it's nil we want all of them
1483
- ids = isNil(idsOrFnOrState) ? this.ids : coerceArray(idsOrFnOrState);
1484
- }
1485
- if (isEmpty(ids))
1486
- return;
1487
- isDev() && setAction('Update Entity', ids);
1488
- let entityIdChanged;
1489
- this._setState((state) => updateEntities({
1490
- idKey: this.idKey,
1491
- ids,
1492
- preUpdateEntity: this.akitaPreUpdateEntity,
1493
- state,
1494
- newStateOrFn,
1495
- producerFn: this._producerFn,
1496
- onEntityIdChanges: (oldId, newId) => {
1497
- entityIdChanged = { oldId, newId };
1498
- this.entityIdChanges.next(Object.assign(Object.assign({}, entityIdChanged), { pending: true }));
1499
- },
1500
- }));
1501
- if (entityIdChanged) {
1502
- this.entityIdChanges.next(Object.assign(Object.assign({}, entityIdChanged), { pending: false }));
1503
- }
1504
- this.entityActions.next({ type: EntityActions.Update, ids });
1505
- }
1506
- upsert(ids, newState, onCreate, options = {}) {
1507
- const toArray = coerceArray(ids);
1508
- const predicate = (isUpdate) => (id) => hasEntity(this.entities, id) === isUpdate;
1509
- const baseClass = isFunction(onCreate) ? options.baseClass : onCreate ? onCreate.baseClass : undefined;
1510
- const isClassBased = isFunction(baseClass);
1511
- const updateIds = toArray.filter(predicate(true));
1512
- const newEntities = toArray.filter(predicate(false)).map((id) => {
1513
- const newStateObj = typeof newState === 'function' ? newState({}) : newState;
1514
- const entity = isFunction(onCreate) ? onCreate(id, newStateObj) : newStateObj;
1515
- const withId = Object.assign(Object.assign({}, entity), { [this.idKey]: id });
1516
- if (isClassBased) {
1517
- return new baseClass(withId);
1518
- }
1519
- return withId;
1520
- });
1521
- // it can be any of the three types
1522
- this.update(updateIds, newState);
1523
- this.add(newEntities);
1524
- isDev() && logAction('Upsert Entity');
1525
- }
1526
- /**
1527
- *
1528
- * Upsert entity collection (idKey must be present)
1529
- *
1530
- * @example
1531
- *
1532
- * store.upsertMany([ { id: 1 }, { id: 2 }]);
1533
- *
1534
- * store.upsertMany([ { id: 1 }, { id: 2 }], { loading: true });
1535
- * store.upsertMany([ { id: 1 }, { id: 2 }], { baseClass: Todo });
1536
- *
1537
- */
1538
- upsertMany(entities, options = {}) {
1539
- const addedIds = [];
1540
- const updatedIds = [];
1541
- const updatedEntities = {};
1542
- // Update the state directly to optimize performance
1543
- for (const entity of entities) {
1544
- const withPreCheckHook = this.akitaPreCheckEntity(entity);
1545
- const id = withPreCheckHook[this.idKey];
1546
- if (hasEntity(this.entities, id)) {
1547
- const prev = this._value().entities[id];
1548
- const merged = Object.assign(Object.assign({}, this._value().entities[id]), withPreCheckHook);
1549
- const next = options.baseClass ? new options.baseClass(merged) : merged;
1550
- const withHook = this.akitaPreUpdateEntity(prev, next);
1551
- const nextId = withHook[this.idKey];
1552
- updatedEntities[nextId] = withHook;
1553
- updatedIds.push(nextId);
1554
- }
1555
- else {
1556
- const newEntity = options.baseClass ? new options.baseClass(withPreCheckHook) : withPreCheckHook;
1557
- const withHook = this.akitaPreAddEntity(newEntity);
1558
- const nextId = withHook[this.idKey];
1559
- addedIds.push(nextId);
1560
- updatedEntities[nextId] = withHook;
1561
- }
1562
- }
1563
- isDev() && logAction('Upsert Many');
1564
- this._setState((state) => (Object.assign(Object.assign({}, state), { ids: addedIds.length ? [...state.ids, ...addedIds] : state.ids, entities: Object.assign(Object.assign({}, state.entities), updatedEntities), loading: !!options.loading })));
1565
- updatedIds.length && this.entityActions.next({ type: EntityActions.Update, ids: updatedIds });
1566
- addedIds.length && this.entityActions.next({ type: EntityActions.Add, ids: addedIds });
1567
- if (addedIds.length && this.hasUIStore()) {
1568
- this.handleUICreation(true);
1569
- }
1570
- }
1571
- /**
1572
- *
1573
- * Replace one or more entities (except the id property)
1574
- *
1575
- *
1576
- * @example
1577
- *
1578
- * this.store.replace(5, newEntity)
1579
- * this.store.replace([1,2,3], newEntity)
1580
- */
1581
- replace(ids, newState) {
1582
- const toArray = coerceArray(ids);
1583
- if (isEmpty(toArray))
1584
- return;
1585
- const replaced = {};
1586
- for (const id of toArray) {
1587
- replaced[id] = Object.assign(Object.assign({}, newState), { [this.idKey]: id });
1588
- }
1589
- isDev() && setAction('Replace Entity', ids);
1590
- this._setState((state) => (Object.assign(Object.assign({}, state), { entities: Object.assign(Object.assign({}, state.entities), replaced) })));
1591
- }
1592
- /**
1593
- *
1594
- * Move entity inside the collection
1595
- *
1596
- *
1597
- * @example
1598
- *
1599
- * this.store.move(fromIndex, toIndex)
1600
- */
1601
- move(from, to) {
1602
- const ids = this.ids.slice();
1603
- ids.splice(to < 0 ? ids.length + to : to, 0, ids.splice(from, 1)[0]);
1604
- isDev() && setAction('Move Entity');
1605
- this._setState((state) => (Object.assign(Object.assign({}, state), {
1606
- // Change the entities reference so that selectAll emit
1607
- entities: Object.assign({}, state.entities), ids })));
1608
- }
1609
- remove(idsOrFn) {
1610
- if (isEmpty(this.ids))
1611
- return;
1612
- const idPassed = isDefined(idsOrFn);
1613
- // null means remove all
1614
- let ids = [];
1615
- if (isFunction(idsOrFn)) {
1616
- ids = this.ids.filter((entityId) => idsOrFn(this.entities[entityId]));
1617
- }
1618
- else {
1619
- ids = idPassed ? coerceArray(idsOrFn) : this.ids;
1620
- }
1621
- if (isEmpty(ids))
1622
- return;
1623
- isDev() && setAction('Remove Entity', ids);
1624
- this._setState((state) => removeEntities({ state, ids }));
1625
- if (!idPassed) {
1626
- this.setHasCache(false);
1627
- }
1628
- this.handleUIRemove(ids);
1629
- this.entityActions.next({ type: EntityActions.Remove, ids });
1630
- }
1631
- /**
1632
- *
1633
- * Update the active entity
1634
- *
1635
- * @example
1636
- *
1637
- * this.store.updateActive({ completed: true })
1638
- * this.store.updateActive(active => {
1639
- * return {
1640
- * config: {
1641
- * ..active.config,
1642
- * date
1643
- * }
1644
- * }
1645
- * })
1646
- */
1647
- updateActive(newStateOrCallback) {
1648
- const ids = coerceArray(this.active);
1649
- isDev() && setAction('Update Active', ids);
1650
- this.update(ids, newStateOrCallback);
1651
- }
1652
- setActive(idOrOptions) {
1653
- const active = getActiveEntities(idOrOptions, this.ids, this.active);
1654
- if (active === undefined) {
1655
- return;
1656
- }
1657
- isDev() && setAction('Set Active', active);
1658
- this._setActive(active);
1659
- }
1660
- /**
1661
- * Add active entities
1662
- *
1663
- * @example
1664
- *
1665
- * store.addActive(2);
1666
- * store.addActive([3, 4, 5]);
1667
- */
1668
- addActive(ids) {
1669
- const toArray = coerceArray(ids);
1670
- if (isEmpty(toArray))
1671
- return;
1672
- const everyExist = toArray.every((id) => this.active.indexOf(id) > -1);
1673
- if (everyExist)
1674
- return;
1675
- isDev() && setAction('Add Active', ids);
1676
- this._setState((state) => {
1677
- /** Protect against case that one of the items in the array exist */
1678
- const uniques = Array.from(new Set([...state.active, ...toArray]));
1679
- return Object.assign(Object.assign({}, state), { active: uniques });
1680
- });
1681
- }
1682
- /**
1683
- * Remove active entities
1684
- *
1685
- * @example
1686
- *
1687
- * store.removeActive(2)
1688
- * store.removeActive([3, 4, 5])
1689
- */
1690
- removeActive(ids) {
1691
- const toArray = coerceArray(ids);
1692
- if (isEmpty(toArray))
1693
- return;
1694
- const someExist = toArray.some((id) => this.active.indexOf(id) > -1);
1695
- if (!someExist)
1696
- return;
1697
- isDev() && setAction('Remove Active', ids);
1698
- this._setState((state) => {
1699
- return Object.assign(Object.assign({}, state), { active: Array.isArray(state.active) ? state.active.filter((currentId) => toArray.indexOf(currentId) === -1) : null });
1700
- });
1701
- }
1702
- /**
1703
- * Toggle active entities
1704
- *
1705
- * @example
1706
- *
1707
- * store.toggle(2)
1708
- * store.toggle([3, 4, 5])
1709
- */
1710
- toggleActive(ids) {
1711
- const toArray = coerceArray(ids);
1712
- const filterExists = (remove) => (id) => this.active.includes(id) === remove;
1713
- const remove = toArray.filter(filterExists(true));
1714
- const add = toArray.filter(filterExists(false));
1715
- this.removeActive(remove);
1716
- this.addActive(add);
1717
- isDev() && logAction('Toggle Active');
1718
- }
1719
- /**
1720
- *
1721
- * Create sub UI store for managing Entity's UI state
1722
- *
1723
- * @example
1724
- *
1725
- * export type ProductUI = {
1726
- * isLoading: boolean;
1727
- * isOpen: boolean
1728
- * }
1729
- *
1730
- * interface ProductsUIState extends EntityState<ProductUI> {}
1731
- *
1732
- * export class ProductsStore EntityStore<ProductsState, Product> {
1733
- * ui: EntityUIStore<ProductsUIState, ProductUI>;
1734
- *
1735
- * constructor() {
1736
- * super();
1737
- * this.createUIStore();
1738
- * }
1739
- *
1740
- * }
1741
- */
1742
- createUIStore(initialState = {}, storeConfig = {}) {
1743
- const defaults = { name: `UI/${this.storeName}`, idKey: this.idKey };
1744
- this.ui = new EntityUIStore(initialState, Object.assign(Object.assign({}, defaults), storeConfig));
1745
- return this.ui;
1746
- }
1747
- // @internal
1748
- destroy() {
1749
- super.destroy();
1750
- if (this.ui instanceof EntityStore) {
1751
- this.ui.destroy();
1752
- }
1753
- this.entityActions.complete();
1754
- }
1755
- // @internal
1756
- akitaPreUpdateEntity(_, nextEntity) {
1757
- return nextEntity;
1758
- }
1759
- // @internal
1760
- akitaPreAddEntity(newEntity) {
1761
- return newEntity;
1762
- }
1763
- // @internal
1764
- akitaPreCheckEntity(newEntity) {
1765
- return newEntity;
1766
- }
1767
- get ids() {
1768
- return this._value().ids;
1769
- }
1770
- get entities() {
1771
- return this._value().entities;
1772
- }
1773
- get active() {
1774
- return this._value().active;
1775
- }
1776
- _setActive(ids) {
1777
- this._setState((state) => {
1778
- return Object.assign(Object.assign({}, state), { active: ids });
1779
- });
1780
- }
1781
- handleUICreation(add = false) {
1782
- const ids = this.ids;
1783
- const isFunc = isFunction(this.ui._akitaCreateEntityFn);
1784
- let uiEntities;
1785
- const createFn = (id) => {
1786
- const current = this.entities[id];
1787
- const ui = isFunc ? this.ui._akitaCreateEntityFn(current) : this.ui._akitaCreateEntityFn;
1788
- return Object.assign({ [this.idKey]: current[this.idKey] }, ui);
1789
- };
1790
- if (add) {
1791
- uiEntities = this.ids.filter((id) => isUndefined(this.ui.entities[id])).map(createFn);
1792
- }
1793
- else {
1794
- uiEntities = ids.map(createFn);
1795
- }
1796
- add ? this.ui.add(uiEntities) : this.ui.set(uiEntities);
1797
- }
1798
- hasInitialUIState() {
1799
- return this.hasUIStore() && isUndefined(this.ui._akitaCreateEntityFn) === false;
1800
- }
1801
- handleUIRemove(ids) {
1802
- if (this.hasUIStore()) {
1803
- this.ui.remove(ids);
1804
- }
1805
- }
1806
- hasUIStore() {
1807
- return this.ui instanceof EntityUIStore;
1808
- }
1809
- }
1810
- __decorate([
1811
- transaction(),
1812
- __metadata("design:type", Function),
1813
- __metadata("design:paramtypes", [Object, Object, Object, Object]),
1814
- __metadata("design:returntype", void 0)
1815
- ], EntityStore.prototype, "upsert", null);
1816
- __decorate([
1817
- transaction(),
1818
- __metadata("design:type", Function),
1819
- __metadata("design:paramtypes", [typeof (_b = typeof T !== "undefined" && T) === "function" ? _b : Object]),
1820
- __metadata("design:returntype", void 0)
1821
- ], EntityStore.prototype, "toggleActive", null);
1822
- // @internal
1823
- class EntityUIStore extends EntityStore {
1824
- constructor(initialState = {}, storeConfig = {}) {
1825
- super(initialState, storeConfig);
1826
- }
1827
- /**
1828
- *
1829
- * Set the initial UI entity state. This function will determine the entity's
1830
- * initial state when we call `set()` or `add()`.
1831
- *
1832
- * @example
1833
- *
1834
- * constructor() {
1835
- * super();
1836
- * this.createUIStore().setInitialEntityState(entity => ({ isLoading: false, isOpen: true }));
1837
- * this.createUIStore().setInitialEntityState({ isLoading: false, isOpen: true });
1838
- * }
1839
- *
1840
- */
1841
- setInitialEntityState(createFn) {
1842
- this._akitaCreateEntityFn = createFn;
1843
- }
1844
- }
1845
- /**
1846
- * @example
1847
- *
1848
- * query.selectEntity(2).pipe(filterNilValue())
1849
- */
1850
- function filterNilValue() {
1851
- return filter.filter((value) => value !== null && value !== undefined);
1852
- }
1853
-
1854
- const queryConfigKey = 'akitaQueryConfig';
1855
-
1856
- // @internal
1857
- function isString(value) {
1858
- return typeof value === 'string';
1859
- }
1860
-
1861
- function compareKeys(keysOrFuncs) {
1862
- return function (prevState, currState) {
1863
- const isFns = isFunction(keysOrFuncs[0]);
1864
- // Return when they are NOT changed
1865
- return keysOrFuncs.some(keyOrFunc => {
1866
- if (isFns) {
1867
- return keyOrFunc(prevState) !== keyOrFunc(currState);
1868
- }
1869
- return prevState[keyOrFunc] !== currState[keyOrFunc];
1870
- }) === false;
1871
- };
1872
- }
1873
-
1874
- class Query {
1875
- constructor(store) {
1876
- this.store = store;
1877
- this.__store__ = store;
1878
- if (isDev()) {
1879
- // @internal
1880
- __queries__[store.storeName] = this;
1881
- }
1882
- }
1883
- select(project) {
1884
- let mapFn;
1885
- if (isFunction(project)) {
1886
- mapFn = project;
1887
- }
1888
- else if (isString(project)) {
1889
- mapFn = state => state[project];
1890
- }
1891
- else if (Array.isArray(project)) {
1892
- return this.store
1893
- ._select(state => state)
1894
- .pipe(filter.distinctUntilChanged(compareKeys(project)), filter.map(state => {
1895
- if (isFunction(project[0])) {
1896
- return project.map(func => func(state));
1897
- }
1898
- return project.reduce((acc, k) => {
1899
- acc[k] = state[k];
1900
- return acc;
1901
- }, {});
1902
- }));
1903
- }
1904
- else {
1905
- mapFn = state => state;
1906
- }
1907
- return this.store._select(mapFn);
1908
- }
1909
- /**
1910
- * Select the loading state
1911
- *
1912
- * @example
1913
- *
1914
- * this.query.selectLoading().subscribe(isLoading => {})
1915
- */
1916
- selectLoading() {
1917
- return this.select(state => state.loading);
1918
- }
1919
- /**
1920
- * Select the error state
1921
- *
1922
- * @example
1923
- *
1924
- * this.query.selectError().subscribe(error => {})
1925
- */
1926
- selectError() {
1927
- return this.select(state => state.error);
1928
- }
1929
- /**
1930
- * Get the store's value
1931
- *
1932
- * @example
1933
- *
1934
- * this.query.getValue()
1935
- *
1936
- */
1937
- getValue() {
1938
- return this.store._value();
1939
- }
1940
- /**
1941
- * Select the cache state
1942
- *
1943
- * @example
1944
- *
1945
- * this.query.selectHasCache().pipe(
1946
- * switchMap(hasCache => {
1947
- * return hasCache ? of() : http().pipe(res => store.set(res))
1948
- * })
1949
- * )
1950
- */
1951
- selectHasCache() {
1952
- return this.store._cache().asObservable();
1953
- }
1954
- /**
1955
- * Whether we've cached data
1956
- *
1957
- * @example
1958
- *
1959
- * this.query.getHasCache()
1960
- *
1961
- */
1962
- getHasCache() {
1963
- return this.store._cache().value;
1964
- }
1965
- // @internal
1966
- get config() {
1967
- return this.constructor[queryConfigKey];
1968
- }
1969
- }
1970
-
1971
- /**
1972
- * @internal
1973
- *
1974
- * @example
1975
- *
1976
- * getValue(state, 'todos.ui')
1977
- *
1978
- */
1979
- function getValue(obj, prop) {
1980
- /** return the whole state */
1981
- if (prop.split('.').length === 1) {
1982
- return obj;
1983
- }
1984
- const removeStoreName = prop
1985
- .split('.')
1986
- .slice(1)
1987
- .join('.');
1988
- return removeStoreName.split('.').reduce((acc, part) => acc && acc[part], obj);
1989
- }
1990
-
1991
- /**
1992
- * @internal
1993
- *
1994
- * @example
1995
- * setValue(state, 'todos.ui', { filter: {} })
1996
- */
1997
- function setValue(obj, prop, val, replace = false) {
1998
- const split = prop.split('.');
1999
- if (split.length === 1) {
2000
- return Object.assign(Object.assign({}, obj), val);
2001
- }
2002
- obj = Object.assign({}, obj);
2003
- const lastIndex = split.length - 2;
2004
- const removeStoreName = prop.split('.').slice(1);
2005
- removeStoreName.reduce((acc, part, index) => {
2006
- if (index !== lastIndex) {
2007
- acc[part] = Object.assign({}, acc[part]);
2008
- return acc && acc[part];
2009
- }
2010
- acc[part] = replace || Array.isArray(acc[part]) || !isObject(acc[part]) ? val : Object.assign(Object.assign({}, acc[part]), val);
2011
- return acc && acc[part];
2012
- }, obj);
2013
- return obj;
2014
- }
2015
-
2016
- let skipStorageUpdate = false;
2017
- const _persistStateInit = new ReplaySubject(1);
2018
- function getSkipStorageUpdate() {
2019
- return skipStorageUpdate;
2020
- }
2021
- function isPromise(v) {
2022
- return v && isFunction(v.then);
2023
- }
2024
- function observify(asyncOrValue) {
2025
- if (isPromise(asyncOrValue) || isObservable(asyncOrValue)) {
2026
- return filter.from(asyncOrValue);
2027
- }
2028
- return delay.of(asyncOrValue);
2029
- }
2030
- function persistState(params) {
2031
- const defaults = {
2032
- key: 'AkitaStores',
2033
- enableInNonBrowser: false,
2034
- storage: !hasLocalStorage() ? params.storage : localStorage,
2035
- deserialize: JSON.parse,
2036
- serialize: JSON.stringify,
2037
- include: [],
2038
- select: [],
2039
- persistOnDestroy: false,
2040
- preStorageUpdate: function (storeName, state) {
2041
- return state;
2042
- },
2043
- preStoreUpdate: function (storeName, state) {
2044
- return state;
2045
- },
2046
- skipStorageUpdate: getSkipStorageUpdate,
2047
- preStorageUpdateOperator: () => (source) => source,
2048
- };
2049
- const { storage, enableInNonBrowser, deserialize, serialize, include, select, key, preStorageUpdate, persistOnDestroy, preStorageUpdateOperator, preStoreUpdate, skipStorageUpdate } = Object.assign({}, defaults, params);
2050
- if ((isNotBrowser && !enableInNonBrowser) || !storage)
2051
- return;
2052
- const hasInclude = include.length > 0;
2053
- const hasSelect = select.length > 0;
2054
- let includeStores;
2055
- let selectStores;
2056
- if (hasInclude) {
2057
- includeStores = include.reduce((acc, path) => {
2058
- if (isFunction(path)) {
2059
- acc.fns.push(path);
2060
- }
2061
- else {
2062
- const storeName = path.split('.')[0];
2063
- acc[storeName] = path;
2064
- }
2065
- return acc;
2066
- }, { fns: [] });
2067
- }
2068
- if (hasSelect) {
2069
- selectStores = select.reduce((acc, selectFn) => {
2070
- acc[selectFn.storeName] = selectFn;
2071
- return acc;
2072
- }, {});
2073
- }
2074
- let stores = {};
2075
- let acc = {};
2076
- let subscriptions = [];
2077
- const buffer = [];
2078
- function _save(v) {
2079
- observify(v).subscribe(() => {
2080
- const next = buffer.shift();
2081
- next && _save(next);
2082
- });
2083
- }
2084
- // when we use the local/session storage we perform the serialize, otherwise we let the passed storage implementation to do it
2085
- const isLocalStorage = (hasLocalStorage() && storage === localStorage) || (hasSessionStorage() && storage === sessionStorage);
2086
- observify(storage.getItem(key)).subscribe((value) => {
2087
- let storageState = isObject(value) ? value : deserialize(value || '{}');
2088
- function save(storeCache) {
2089
- storageState['$cache'] = Object.assign(Object.assign({}, (storageState['$cache'] || {})), storeCache);
2090
- storageState = Object.assign({}, storageState, acc);
2091
- buffer.push(storage.setItem(key, isLocalStorage ? serialize(storageState) : storageState));
2092
- _save(buffer.shift());
2093
- }
2094
- function subscribe(storeName, path) {
2095
- stores[storeName] = __stores__[storeName]
2096
- ._select((state) => getValue(state, path))
2097
- .pipe(skip(1), filter.map((store) => {
2098
- if (hasSelect && selectStores[storeName]) {
2099
- return selectStores[storeName](store);
2100
- }
2101
- return store;
2102
- }), filter.filter(() => skipStorageUpdate() === false), preStorageUpdateOperator())
2103
- .subscribe((data) => {
2104
- acc[storeName] = preStorageUpdate(storeName, data);
2105
- Promise.resolve().then(() => save({ [storeName]: __stores__[storeName]._cache().getValue() }));
2106
- });
2107
- }
2108
- function setInitial(storeName, store, path) {
2109
- if (storeName in storageState) {
2110
- setAction('@PersistState');
2111
- store._setState((state) => {
2112
- return setValue(state, path, preStoreUpdate(storeName, storageState[storeName], state));
2113
- });
2114
- const hasCache = storageState['$cache'] ? storageState['$cache'][storeName] : false;
2115
- __stores__[storeName].setHasCache(hasCache, { restartTTL: true });
2116
- }
2117
- }
2118
- subscriptions.push($$deleteStore.subscribe((storeName) => {
2119
- if (stores[storeName]) {
2120
- if (persistOnDestroy === false) {
2121
- save({ [storeName]: false });
2122
- }
2123
- stores[storeName].unsubscribe();
2124
- delete stores[storeName];
2125
- }
2126
- }));
2127
- subscriptions.push($$addStore.subscribe((storeName) => {
2128
- if (storeName === 'router') {
2129
- return;
2130
- }
2131
- const store = __stores__[storeName];
2132
- if (hasInclude) {
2133
- let path = includeStores[storeName];
2134
- if (!path) {
2135
- const passPredicate = includeStores.fns.some((fn) => fn(storeName));
2136
- if (passPredicate) {
2137
- path = storeName;
2138
- }
2139
- else {
2140
- return;
2141
- }
2142
- }
2143
- setInitial(storeName, store, path);
2144
- subscribe(storeName, path);
2145
- }
2146
- else {
2147
- setInitial(storeName, store, storeName);
2148
- subscribe(storeName, storeName);
2149
- }
2150
- }));
2151
- _persistStateInit.next();
2152
- });
2153
- return {
2154
- destroy() {
2155
- subscriptions.forEach((s) => s.unsubscribe());
2156
- for (let i = 0, keys = Object.keys(stores); i < keys.length; i++) {
2157
- const storeName = keys[i];
2158
- stores[storeName].unsubscribe();
2159
- }
2160
- stores = {};
2161
- },
2162
- clear() {
2163
- storage.clear();
2164
- },
2165
- clearStore(storeName) {
2166
- if (isNil(storeName)) {
2167
- const value = observify(storage.setItem(key, '{}'));
2168
- value.subscribe();
2169
- return;
2170
- }
2171
- const value = storage.getItem(key);
2172
- observify(value).subscribe((v) => {
2173
- const storageState = deserialize(v || '{}');
2174
- if (storageState[storeName]) {
2175
- delete storageState[storeName];
2176
- const value = observify(storage.setItem(key, serialize(storageState)));
2177
- value.subscribe();
2178
- }
2179
- });
2180
- },
2181
- };
2182
- }
2183
-
2184
- class AkitaPlugin {
2185
- constructor(query, config) {
2186
- this.query = query;
2187
- if (config && config.resetFn) {
2188
- if (getAkitaConfig().resettable) {
2189
- this.onReset(config.resetFn);
2190
- }
2191
- }
2192
- }
2193
- /** This method is responsible for getting access to the query. */
2194
- getQuery() {
2195
- return this.query;
2196
- }
2197
- /** This method is responsible for getting access to the store. */
2198
- getStore() {
2199
- return this.getQuery().__store__;
2200
- }
2201
- /** This method is responsible tells whether the plugin is entityBased or not. */
2202
- isEntityBased(entityId) {
2203
- return toBoolean(entityId);
2204
- }
2205
- /** This method is responsible for selecting the source; it can be the whole store or one entity. */
2206
- selectSource(entityId, property) {
2207
- if (this.isEntityBased(entityId)) {
2208
- return this.getQuery().selectEntity(entityId).pipe(filterNilValue());
2209
- }
2210
- if (property) {
2211
- return this.getQuery().select((state) => getValue(state, this.withStoreName(property)));
2212
- }
2213
- return this.getQuery().select();
2214
- }
2215
- getSource(entityId, property) {
2216
- if (this.isEntityBased(entityId)) {
2217
- return this.getQuery().getEntity(entityId);
2218
- }
2219
- const state = this.getQuery().getValue();
2220
- if (property) {
2221
- return getValue(state, this.withStoreName(property));
2222
- }
2223
- return state;
2224
- }
2225
- withStoreName(prop) {
2226
- return `${this.storeName}.${prop}`;
2227
- }
2228
- get storeName() {
2229
- return this.getStore().storeName;
2230
- }
2231
- /** This method is responsible for updating the store or one entity; it can be the whole store or one entity. */
2232
- updateStore(newState, entityId, property, replace = false) {
2233
- if (this.isEntityBased(entityId)) {
2234
- const store = this.getStore();
2235
- replace ? store.replace(entityId, newState) : store.update(entityId, newState);
2236
- }
2237
- else {
2238
- if (property) {
2239
- this.getStore()._setState((state) => {
2240
- return setValue(state, this.withStoreName(property), newState, true);
2241
- });
2242
- return;
2243
- }
2244
- const nextState = replace ? newState : (state) => (Object.assign(Object.assign({}, state), newState));
2245
- this.getStore()._setState(nextState);
2246
- }
2247
- }
2248
- /**
2249
- * Function to invoke upon reset
2250
- */
2251
- onReset(fn) {
2252
- const original = this.getStore().reset;
2253
- this.getStore().reset = (...params) => {
2254
- /** It should run after the plugin destroy method */
2255
- setTimeout(() => {
2256
- original.apply(this.getStore(), params);
2257
- fn();
2258
- });
2259
- };
2260
- }
2261
- }
2262
-
2263
- const paginatorDefaults = {
2264
- pagesControls: false,
2265
- range: false,
2266
- startWith: 1,
2267
- cacheTimeout: undefined,
2268
- clearStoreWithCache: true,
2269
- };
2270
- class PaginatorPlugin extends AkitaPlugin {
2271
- constructor(query, config = {}) {
2272
- super(query, {
2273
- resetFn: () => {
2274
- this.initial = false;
2275
- this.destroy({ clearCache: true, currentPage: 1 });
2276
- },
2277
- });
2278
- this.query = query;
2279
- this.config = config;
2280
- /** Save current filters, sorting, etc. in cache */
2281
- this.metadata = new Map();
2282
- this.pages = new Map();
2283
- this.pagination = {
2284
- currentPage: 1,
2285
- perPage: 0,
2286
- total: 0,
2287
- lastPage: 0,
2288
- data: [],
2289
- };
2290
- /**
2291
- * When the user navigates to a different page and return
2292
- * we don't want to call `clearCache` on first time.
2293
- */
2294
- this.initial = true;
2295
- /**
2296
- * Proxy to the query loading
2297
- */
2298
- this.isLoading$ = this.query.selectLoading().pipe(delay.delay(0));
2299
- this.config = Object.assign(Object.assign({}, paginatorDefaults), config);
2300
- const { startWith, cacheTimeout } = this.config;
2301
- this.page = new BehaviorSubject(startWith);
2302
- if (isObservable(cacheTimeout)) {
2303
- this.clearCacheSubscription = cacheTimeout.subscribe(() => this.clearCache());
2304
- }
2305
- }
2306
- /**
2307
- * Listen to page changes
2308
- */
2309
- get pageChanges() {
2310
- return this.page.asObservable();
2311
- }
2312
- /**
2313
- * Get the current page number
2314
- */
2315
- get currentPage() {
2316
- return this.pagination.currentPage;
2317
- }
2318
- /**
2319
- * Check if current page is the first one
2320
- */
2321
- get isFirst() {
2322
- return this.currentPage === 1;
2323
- }
2324
- /**
2325
- * Check if current page is the last one
2326
- */
2327
- get isLast() {
2328
- return this.currentPage === this.pagination.lastPage;
2329
- }
2330
- /**
2331
- * Whether to generate an array of pages for *ngFor
2332
- * [1, 2, 3, 4]
2333
- */
2334
- withControls() {
2335
- this.config.pagesControls = true;
2336
- return this;
2337
- }
2338
- /**
2339
- * Whether to generate the `from` and `to` keys
2340
- * [1, 2, 3, 4]
2341
- */
2342
- withRange() {
2343
- this.config.range = true;
2344
- return this;
2345
- }
2346
- /**
2347
- * Set the loading state
2348
- */
2349
- setLoading(value = true) {
2350
- this.getStore().setLoading(value);
2351
- }
2352
- /**
2353
- * Update the pagination object and add the page
2354
- */
2355
- update(response) {
2356
- this.pagination = response;
2357
- this.addPage(response.data);
2358
- }
2359
- /**
2360
- *
2361
- * Set the ids and add the page to store
2362
- */
2363
- addPage(data) {
2364
- this.pages.set(this.currentPage, { ids: data.map((entity) => entity[this.getStore().idKey]) });
2365
- this.getStore().upsertMany(data);
2366
- }
2367
- /**
2368
- * Clear the cache.
2369
- */
2370
- clearCache(options = {}) {
2371
- if (!this.initial) {
2372
- logAction('@Pagination - Clear Cache');
2373
- if (options.clearStore !== false && (this.config.clearStoreWithCache || options.clearStore)) {
2374
- this.getStore().remove();
2375
- }
2376
- this.pages = new Map();
2377
- this.metadata = new Map();
2378
- }
2379
- this.initial = false;
2380
- }
2381
- clearPage(page) {
2382
- this.pages.delete(page);
2383
- }
2384
- /**
2385
- * Clear the cache timeout and optionally the pages
2386
- */
2387
- destroy({ clearCache, currentPage } = {}) {
2388
- if (this.clearCacheSubscription) {
2389
- this.clearCacheSubscription.unsubscribe();
2390
- }
2391
- if (clearCache) {
2392
- this.clearCache();
2393
- }
2394
- if (!isUndefined(currentPage)) {
2395
- this.setPage(currentPage);
2396
- }
2397
- this.initial = true;
2398
- }
2399
- /**
2400
- * Whether the provided page is active
2401
- */
2402
- isPageActive(page) {
2403
- return this.currentPage === page;
2404
- }
2405
- /**
2406
- * Set the current page
2407
- */
2408
- setPage(page) {
2409
- if (page !== this.currentPage || !this.hasPage(page)) {
2410
- this.page.next((this.pagination.currentPage = page));
2411
- }
2412
- }
2413
- /**
2414
- * Increment current page
2415
- */
2416
- nextPage() {
2417
- if (this.currentPage !== this.pagination.lastPage) {
2418
- this.setPage(this.pagination.currentPage + 1);
2419
- }
2420
- }
2421
- /**
2422
- * Decrement current page
2423
- */
2424
- prevPage() {
2425
- if (this.pagination.currentPage > 1) {
2426
- this.setPage(this.pagination.currentPage - 1);
2427
- }
2428
- }
2429
- /**
2430
- * Set current page to last
2431
- */
2432
- setLastPage() {
2433
- this.setPage(this.pagination.lastPage);
2434
- }
2435
- /**
2436
- * Set current page to first
2437
- */
2438
- setFirstPage() {
2439
- this.setPage(1);
2440
- }
2441
- /**
2442
- * Check if page exists in cache
2443
- */
2444
- hasPage(page) {
2445
- return this.pages.has(page);
2446
- }
2447
- /**
2448
- * Get the current page if it's in cache, otherwise invoke the request
2449
- */
2450
- getPage(req) {
2451
- let page = this.pagination.currentPage;
2452
- if (this.hasPage(page)) {
2453
- return this.selectPage(page);
2454
- }
2455
- else {
2456
- this.setLoading(true);
2457
- return filter.from(req()).pipe(switchMap((config) => {
2458
- page = config.currentPage;
2459
- applyTransaction(() => {
2460
- this.setLoading(false);
2461
- this.update(config);
2462
- });
2463
- return this.selectPage(page);
2464
- }));
2465
- }
2466
- }
2467
- getQuery() {
2468
- return this.query;
2469
- }
2470
- refreshCurrentPage() {
2471
- if (isNil(this.currentPage) === false) {
2472
- this.clearPage(this.currentPage);
2473
- this.setPage(this.currentPage);
2474
- }
2475
- }
2476
- getFrom() {
2477
- if (this.isFirst) {
2478
- return 1;
2479
- }
2480
- return (this.currentPage - 1) * this.pagination.perPage + 1;
2481
- }
2482
- getTo() {
2483
- if (this.isLast) {
2484
- return this.pagination.total;
2485
- }
2486
- return this.currentPage * this.pagination.perPage;
2487
- }
2488
- /**
2489
- * Select the page
2490
- */
2491
- selectPage(page) {
2492
- return this.query.selectAll({ asObject: true }).pipe(take(1), filter.map((entities) => {
2493
- const response = Object.assign(Object.assign({}, this.pagination), { data: this.pages.get(page).ids.map((id) => entities[id]) });
2494
- const { range, pagesControls } = this.config;
2495
- /** If no total - calc it */
2496
- if (isNaN(this.pagination.total)) {
2497
- if (response.lastPage === 1) {
2498
- response.total = response.data ? response.data.length : 0;
2499
- }
2500
- else {
2501
- response.total = response.perPage * response.lastPage;
2502
- }
2503
- this.pagination.total = response.total;
2504
- }
2505
- if (range) {
2506
- response.from = this.getFrom();
2507
- response.to = this.getTo();
2508
- }
2509
- if (pagesControls) {
2510
- response.pageControls = generatePages(this.pagination.total, this.pagination.perPage);
2511
- }
2512
- return response;
2513
- }));
2514
- }
2515
- }
2516
- __decorate([
2517
- action('@Pagination - New Page'),
2518
- __metadata("design:type", Function),
2519
- __metadata("design:paramtypes", [Object]),
2520
- __metadata("design:returntype", void 0)
2521
- ], PaginatorPlugin.prototype, "update", null);
2522
- /**
2523
- * Generate an array so we can ngFor them to navigate between pages
2524
- */
2525
- function generatePages(total, perPage) {
2526
- const len = Math.ceil(total / perPage);
2527
- const arr = [];
2528
- for (let i = 0; i < len; i++) {
2529
- arr.push(i + 1);
2530
- }
2531
- return arr;
2532
- }
2533
-
2534
- var StoreAction;
2535
- (function (StoreAction) {
2536
- StoreAction["Update"] = "UPDATE";
2537
- })(StoreAction || (StoreAction = {}));
2538
- var EntityStoreAction;
2539
- (function (EntityStoreAction) {
2540
- EntityStoreAction["Update"] = "UPDATE";
2541
- EntityStoreAction["AddEntities"] = "ADD_ENTITIES";
2542
- EntityStoreAction["SetEntities"] = "SET_ENTITIES";
2543
- EntityStoreAction["UpdateEntities"] = "UPDATE_ENTITIES";
2544
- EntityStoreAction["RemoveEntities"] = "REMOVE_ENTITIES";
2545
- EntityStoreAction["UpsertEntities"] = "UPSERT_ENTITIES";
2546
- EntityStoreAction["UpsertManyEntities"] = "UPSERT_MANY_ENTITIES";
2547
- })(EntityStoreAction || (EntityStoreAction = {}));
2548
-
2549
- exports.Query = Query;
2550
- exports.Store = Store;
2551
- exports.StoreConfig = StoreConfig;
2552
- exports.enableAkitaProdMode = enableAkitaProdMode;
2553
- exports.persistState = persistState;