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