diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2731fef..7d2a1ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,14 +16,14 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up nodejs uses: actions/setup-node@v3 with: - node-version: '16.16.0' + node-version: 'lts/*' cache: 'npm' - name: npm CI diff --git a/.github/workflows/update-license-year.yml b/.github/workflows/update-license-year.yml index 13aaac8..7e0a945 100644 --- a/.github/workflows/update-license-year.yml +++ b/.github/workflows/update-license-year.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -24,7 +24,7 @@ jobs: run: "echo PREVIOUS=$(($CURRENT-1)) >> $GITHUB_ENV" - name: Update LICENSE - uses: jacobtomlinson/gha-find-replace@v2 + uses: jacobtomlinson/gha-find-replace@v3 with: find: ${{ env.PREVIOUS }} replace: ${{ env.CURRENT }} @@ -38,7 +38,7 @@ jobs: git commit -m "Updated License Year" -a - name: Create Pull Request - uses: peter-evans/create-pull-request@v3 + uses: peter-evans/create-pull-request@v5 with: token: ${{ secrets.GITHUB_TOKEN }} title: Update License Year diff --git a/.gitignore b/.gitignore index 83482d5..3c9ac65 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ node_modules lib es +types coverage examples .vscode diff --git a/.nvmrc b/.nvmrc index f274881..b009dfb 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v16.16.0 +lts/* diff --git a/CHANGES.txt b/CHANGES.txt index 365c02b..9c8c840 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,9 @@ +1.11.0 (April 3, 2024) + - Added `sideEffects: false` property in the package.json file to allow tree shaking. + - Updated Redux-Thunk peer dependency range to include redux-thunk@3.x.x. + - Updated the build process and added the `tslib` package as an explicit dependency to import TypeScript helpers, thereby avoiding duplicated helper code in the output files. + - Updated @splitsoftware/splitio package to version 10.25.2, which includes vulnerability fixes and other improvements. + 1.10.0 (December 18, 2023) - Added support for Flag Sets on the SDK, which enables grouping feature flags and interacting with the group rather than individually (more details in our documentation): - Added a new optional `flagSets` property to the param object of the `getTreatments` action creator, to support evaluating flags in given flag set/s. Either `splitNames` or `flagSets` must be provided to the function. If both are provided, `splitNames` will be used. diff --git a/LICENSE b/LICENSE index 65f5999..c022e92 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright © 2023 Split Software, Inc. +Copyright © 2024 Split Software, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 3728b10..c0b56a7 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,7 @@ Split has built and maintains SDKs for: * .NET [Github](https://github.com/splitio/dotnet-client) [Docs](https://help.split.io/hc/en-us/articles/360020240172--NET-SDK) * Android [Github](https://github.com/splitio/android-client) [Docs](https://help.split.io/hc/en-us/articles/360020343291-Android-SDK) * Angular [Github](https://github.com/splitio/angular-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/6495326064397-Angular-utilities) +* Flutter [Github](https://github.com/splitio/flutter-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/8096158017165-Flutter-plugin) * GO [Github](https://github.com/splitio/go-client) [Docs](https://help.split.io/hc/en-us/articles/360020093652-Go-SDK) * iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK) * Java [Github](https://github.com/splitio/java-client) [Docs](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK) @@ -100,6 +101,7 @@ Split has built and maintains SDKs for: * JavaScript for Browser [Github](https://github.com/splitio/javascript-browser-client) [Docs](https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK) * Node [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK) * PHP [Github](https://github.com/splitio/php-client) [Docs](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK) +* PHP thin-client [Github](https://github.com/splitio/php-thin-client) [Docs](https://help.split.io/hc/en-us/articles/18305128673933-PHP-Thin-Client-SDK) * Python [Github](https://github.com/splitio/python-client) [Docs](https://help.split.io/hc/en-us/articles/360020359652-Python-SDK) * React [Github](https://github.com/splitio/react-client) [Docs](https://help.split.io/hc/en-us/articles/360038825091-React-SDK) * React Native [Github](https://github.com/splitio/react-native-client) [Docs](https://help.split.io/hc/en-us/articles/4406066357901-React-Native-SDK) diff --git a/package-lock.json b/package-lock.json index 8fb3d00..76d7aff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,16 @@ { "name": "@splitsoftware/splitio-redux", - "version": "1.10.0", + "version": "1.11.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@splitsoftware/splitio-redux", - "version": "1.10.0", + "version": "1.11.0", "license": "Apache-2.0", "dependencies": { - "@splitsoftware/splitio": "10.24.1" + "@splitsoftware/splitio": "10.25.2", + "tslib": "^2.3.1" }, "devDependencies": { "@testing-library/jest-dom": "^5.16.5", @@ -17,9 +18,7 @@ "@types/jest": "^27.0.0", "@types/react": "^18.0.0", "@types/react-dom": "^18.0.0", - "@types/react-redux": "^7.1.5", "@types/redux-mock-store": "^1.0.1", - "@types/redux-thunk": "^2.1.0", "@typescript-eslint/eslint-plugin": "^5.55.0", "@typescript-eslint/parser": "^5.55.0", "eslint": "^8.36.0", @@ -30,10 +29,10 @@ "jest": "^27.2.3", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-redux": "^8.0.0", - "redux": "^4.2.0", + "react-redux": "9.0.0", + "redux": "^5.0.1", "redux-mock-store": "^1.5.4", - "redux-thunk": "^2.3.0", + "redux-thunk": "^3.1.0", "replace": "^1.2.1", "rimraf": "^3.0.0", "ts-jest": "^27.0.5", @@ -42,7 +41,7 @@ "peerDependencies": { "react-redux": ">=4.0.0", "redux": ">=2.0.0", - "redux-thunk": "^2.0.0" + "redux-thunk": ">=2.0.0" }, "peerDependenciesMeta": { "react-redux": { @@ -1504,17 +1503,18 @@ } }, "node_modules/@splitsoftware/splitio": { - "version": "10.24.1", - "resolved": "https://registry.npmjs.org/@splitsoftware/splitio/-/splitio-10.24.1.tgz", - "integrity": "sha512-WzVZrP2IAqzNBywNXgmLxiS60qumkcnu6u1lUPlNgdVek82TzWeqyqW+htKmDMJ/ifsJPWrgT1VLMZJvOnBsVA==", + "version": "10.25.2", + "resolved": "https://registry.npmjs.org/@splitsoftware/splitio/-/splitio-10.25.2.tgz", + "integrity": "sha512-lX06PSoA+hcw66c889RxK9t9cd8evguBFk+x1pw2L4J/58+7XHxp/z1Nnbtb3AOw8s/sX4h87qlTiZqMGPmcmA==", "dependencies": { - "@splitsoftware/splitio-commons": "1.12.1", + "@splitsoftware/splitio-commons": "1.13.1", "@types/google.analytics": "0.0.40", "@types/ioredis": "^4.28.0", "bloom-filters": "^3.0.0", "ioredis": "^4.28.0", "js-yaml": "^3.13.1", - "node-fetch": "^2.6.7", + "node-fetch": "^2.7.0", + "tslib": "^2.3.1", "unfetch": "^4.2.0" }, "engines": { @@ -1526,9 +1526,9 @@ } }, "node_modules/@splitsoftware/splitio-commons": { - "version": "1.12.1", - "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-1.12.1.tgz", - "integrity": "sha512-EkCcqlYvVafazs9c5i+pmhf6rIyj3A70dqQ4U3BKE646t7tf6mxGzqZz1sAl540xNyYI7CA/iIqisEWvDtJc0A==", + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-1.13.1.tgz", + "integrity": "sha512-xGu94sLx+tJb6PeM26vH8/LEElsaVbh2BjoLvL5twR4gKsVezie5ZtHhejWT1+iCVCtJuhjZxKwOm4HGYoVIHQ==", "dependencies": { "tslib": "^2.3.1" }, @@ -1541,11 +1541,6 @@ } } }, - "node_modules/@splitsoftware/splitio-commons/node_modules/tslib": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", - "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" - }, "node_modules/@testing-library/dom": { "version": "9.0.1", "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-9.0.1.tgz", @@ -1812,16 +1807,6 @@ "@types/node": "*" } }, - "node_modules/@types/hoist-non-react-statics": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz", - "integrity": "sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA==", - "dev": true, - "dependencies": { - "@types/react": "*", - "hoist-non-react-statics": "^3.3.0" - } - }, "node_modules/@types/ioredis": { "version": "4.28.10", "resolved": "https://registry.npmjs.org/@types/ioredis/-/ioredis-4.28.10.tgz", @@ -1900,37 +1885,24 @@ "dev": true }, "node_modules/@types/react": { - "version": "18.0.28", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.28.tgz", - "integrity": "sha512-RD0ivG1kEztNBdoAK7lekI9M+azSnitIn85h4iOiaLjaTrMjzslhaqCGaI4IyCJ1RljWiLCEu4jyrLLgqxBTew==", + "version": "18.2.72", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.72.tgz", + "integrity": "sha512-/e7GWxGzXQF7OJAua7UAYqYi/4VpXEfbGtmYQcAQwP3SjjjAXfybTf/JK5S+SaetB/ChXl8Y2g1hCsj7jDXxcg==", "dev": true, "dependencies": { "@types/prop-types": "*", - "@types/scheduler": "*", "csstype": "^3.0.2" } }, "node_modules/@types/react-dom": { - "version": "18.0.11", - "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.0.11.tgz", - "integrity": "sha512-O38bPbI2CWtgw/OoQoY+BRelw7uysmXbWvw3nLWO21H1HSh+GOlqPuXshJfjmpNlKiiSDG9cc1JZAaMmVdcTlw==", + "version": "18.2.22", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.2.22.tgz", + "integrity": "sha512-fHkBXPeNtfvri6gdsMYyW+dW7RXFo6Ad09nLFK0VQWR7yGLai/Cyvyj696gbwYvBnhGtevUG9cET0pmUbMtoPQ==", "dev": true, "dependencies": { "@types/react": "*" } }, - "node_modules/@types/react-redux": { - "version": "7.1.25", - "resolved": "https://registry.npmjs.org/@types/react-redux/-/react-redux-7.1.25.tgz", - "integrity": "sha512-bAGh4e+w5D8dajd6InASVIyCo4pZLJ66oLb80F9OBLO1gKESbZcRCJpTT6uLXX+HAB57zw1WTdwJdAsewuTweg==", - "dev": true, - "dependencies": { - "@types/hoist-non-react-statics": "^3.3.0", - "@types/react": "*", - "hoist-non-react-statics": "^3.3.0", - "redux": "^4.0.0" - } - }, "node_modules/@types/redux-mock-store": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@types/redux-mock-store/-/redux-mock-store-1.0.1.tgz", @@ -1940,22 +1912,15 @@ "redux": "^4.0.0" } }, - "node_modules/@types/redux-thunk": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@types/redux-thunk/-/redux-thunk-2.1.0.tgz", - "integrity": "sha1-vCtulylhgxr7gqm/TwZybjUflBY=", - "deprecated": "This is a stub types definition for Redux Thunk (https://github.com/gaearon/redux-thunk). Redux Thunk provides its own type definitions, so you don't need @types/redux-thunk installed!", + "node_modules/@types/redux-mock-store/node_modules/redux": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/redux/-/redux-4.2.1.tgz", + "integrity": "sha512-LAUYz4lc+Do8/g7aeRa8JkyDErK6ekstQaqWQrNRW//MY1TvCEpMtpTWvlQ+FPbWCx+Xixu/6SHt5N0HR+SB4w==", "dev": true, "dependencies": { - "redux-thunk": "*" + "@babel/runtime": "^7.9.2" } }, - "node_modules/@types/scheduler": { - "version": "0.16.2", - "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz", - "integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==", - "dev": true - }, "node_modules/@types/semver": { "version": "7.3.13", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.13.tgz", @@ -4782,15 +4747,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/hoist-non-react-statics": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", - "integrity": "sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==", - "dev": true, - "dependencies": { - "react-is": "^16.7.0" - } - }, "node_modules/hosted-git-info": { "version": "2.8.9", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", @@ -7885,9 +7841,9 @@ "dev": true }, "node_modules/node-fetch": { - "version": "2.6.7", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", - "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", "dependencies": { "whatwg-url": "^5.0.0" }, @@ -8489,25 +8445,21 @@ "dev": true }, "node_modules/react-redux": { - "version": "8.0.5", - "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-8.0.5.tgz", - "integrity": "sha512-Q2f6fCKxPFpkXt1qNRZdEDLlScsDWyrgSj0mliK59qU6W5gvBiKkdMEG2lJzhd1rCctf0hb6EtePPLZ2e0m1uw==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.0.0.tgz", + "integrity": "sha512-/X/wiza+G2IXbz1Ow9Gs5qK7KNdoEnzzsR7ne7jcOWJMBOx9wvraPZwFddCs84xqwilvYaoENHowQMiW0axbsQ==", "dev": true, "dependencies": { - "@babel/runtime": "^7.12.1", - "@types/hoist-non-react-statics": "^3.3.1", "@types/use-sync-external-store": "^0.0.3", - "hoist-non-react-statics": "^3.3.2", - "react-is": "^18.0.0", "use-sync-external-store": "^1.0.0" }, "peerDependencies": { - "@types/react": "^16.8 || ^17.0 || ^18.0", - "@types/react-dom": "^16.8 || ^17.0 || ^18.0", - "react": "^16.8 || ^17.0 || ^18.0", - "react-dom": "^16.8 || ^17.0 || ^18.0", - "react-native": ">=0.59", - "redux": "^4" + "@types/react": "^18.2.41", + "@types/react-dom": "^18.2.17", + "react": "^18.0", + "react-dom": "^18.0", + "react-native": ">=0.71", + "redux": "^5.0.0-rc" }, "peerDependenciesMeta": { "@types/react": { @@ -8527,12 +8479,6 @@ } } }, - "node_modules/react-redux/node_modules/react-is": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", - "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", - "dev": true - }, "node_modules/redent": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz", @@ -8571,13 +8517,10 @@ } }, "node_modules/redux": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/redux/-/redux-4.2.1.tgz", - "integrity": "sha512-LAUYz4lc+Do8/g7aeRa8JkyDErK6ekstQaqWQrNRW//MY1TvCEpMtpTWvlQ+FPbWCx+Xixu/6SHt5N0HR+SB4w==", - "dev": true, - "dependencies": { - "@babel/runtime": "^7.9.2" - } + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz", + "integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==", + "dev": true }, "node_modules/redux-mock-store": { "version": "1.5.4", @@ -8589,10 +8532,13 @@ } }, "node_modules/redux-thunk": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-2.3.0.tgz", - "integrity": "sha512-km6dclyFnmcvxhAcrQV2AkZmPQjzPDjgVlQtR0EQjxZPyJ0BnMf3in1ryuR8A2qU0HldVRfxYXbFSKlI3N7Slw==", - "dev": true + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-3.1.0.tgz", + "integrity": "sha512-NW2r5T6ksUKXCabzhL9z+h206HQw/NJkcLm1GPImRQ8IzfXwRGqjVhKJGauHirT0DAuyy6hjdnMZaRoAcy0Klw==", + "dev": true, + "peerDependencies": { + "redux": "^5.0.0" + } }, "node_modules/reflect-metadata": { "version": "0.1.13", @@ -9493,10 +9439,9 @@ } }, "node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" }, "node_modules/tsutils": { "version": "3.21.0", @@ -9513,6 +9458,12 @@ "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" } }, + "node_modules/tsutils/node_modules/tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + }, "node_modules/type-check": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", @@ -11105,34 +11056,28 @@ } }, "@splitsoftware/splitio": { - "version": "10.24.1", - "resolved": "https://registry.npmjs.org/@splitsoftware/splitio/-/splitio-10.24.1.tgz", - "integrity": "sha512-WzVZrP2IAqzNBywNXgmLxiS60qumkcnu6u1lUPlNgdVek82TzWeqyqW+htKmDMJ/ifsJPWrgT1VLMZJvOnBsVA==", + "version": "10.25.2", + "resolved": "https://registry.npmjs.org/@splitsoftware/splitio/-/splitio-10.25.2.tgz", + "integrity": "sha512-lX06PSoA+hcw66c889RxK9t9cd8evguBFk+x1pw2L4J/58+7XHxp/z1Nnbtb3AOw8s/sX4h87qlTiZqMGPmcmA==", "requires": { - "@splitsoftware/splitio-commons": "1.12.1", + "@splitsoftware/splitio-commons": "1.13.1", "@types/google.analytics": "0.0.40", "@types/ioredis": "^4.28.0", "bloom-filters": "^3.0.0", "eventsource": "^1.1.2", "ioredis": "^4.28.0", "js-yaml": "^3.13.1", - "node-fetch": "^2.6.7", + "node-fetch": "^2.7.0", + "tslib": "^2.3.1", "unfetch": "^4.2.0" } }, "@splitsoftware/splitio-commons": { - "version": "1.12.1", - "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-1.12.1.tgz", - "integrity": "sha512-EkCcqlYvVafazs9c5i+pmhf6rIyj3A70dqQ4U3BKE646t7tf6mxGzqZz1sAl540xNyYI7CA/iIqisEWvDtJc0A==", + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-1.13.1.tgz", + "integrity": "sha512-xGu94sLx+tJb6PeM26vH8/LEElsaVbh2BjoLvL5twR4gKsVezie5ZtHhejWT1+iCVCtJuhjZxKwOm4HGYoVIHQ==", "requires": { "tslib": "^2.3.1" - }, - "dependencies": { - "tslib": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", - "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" - } } }, "@testing-library/dom": { @@ -11348,16 +11293,6 @@ "@types/node": "*" } }, - "@types/hoist-non-react-statics": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz", - "integrity": "sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA==", - "dev": true, - "requires": { - "@types/react": "*", - "hoist-non-react-statics": "^3.3.0" - } - }, "@types/ioredis": { "version": "4.28.10", "resolved": "https://registry.npmjs.org/@types/ioredis/-/ioredis-4.28.10.tgz", @@ -11436,37 +11371,24 @@ "dev": true }, "@types/react": { - "version": "18.0.28", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.28.tgz", - "integrity": "sha512-RD0ivG1kEztNBdoAK7lekI9M+azSnitIn85h4iOiaLjaTrMjzslhaqCGaI4IyCJ1RljWiLCEu4jyrLLgqxBTew==", + "version": "18.2.72", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.72.tgz", + "integrity": "sha512-/e7GWxGzXQF7OJAua7UAYqYi/4VpXEfbGtmYQcAQwP3SjjjAXfybTf/JK5S+SaetB/ChXl8Y2g1hCsj7jDXxcg==", "dev": true, "requires": { "@types/prop-types": "*", - "@types/scheduler": "*", "csstype": "^3.0.2" } }, "@types/react-dom": { - "version": "18.0.11", - "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.0.11.tgz", - "integrity": "sha512-O38bPbI2CWtgw/OoQoY+BRelw7uysmXbWvw3nLWO21H1HSh+GOlqPuXshJfjmpNlKiiSDG9cc1JZAaMmVdcTlw==", + "version": "18.2.22", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.2.22.tgz", + "integrity": "sha512-fHkBXPeNtfvri6gdsMYyW+dW7RXFo6Ad09nLFK0VQWR7yGLai/Cyvyj696gbwYvBnhGtevUG9cET0pmUbMtoPQ==", "dev": true, "requires": { "@types/react": "*" } }, - "@types/react-redux": { - "version": "7.1.25", - "resolved": "https://registry.npmjs.org/@types/react-redux/-/react-redux-7.1.25.tgz", - "integrity": "sha512-bAGh4e+w5D8dajd6InASVIyCo4pZLJ66oLb80F9OBLO1gKESbZcRCJpTT6uLXX+HAB57zw1WTdwJdAsewuTweg==", - "dev": true, - "requires": { - "@types/hoist-non-react-statics": "^3.3.0", - "@types/react": "*", - "hoist-non-react-statics": "^3.3.0", - "redux": "^4.0.0" - } - }, "@types/redux-mock-store": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@types/redux-mock-store/-/redux-mock-store-1.0.1.tgz", @@ -11474,23 +11396,19 @@ "dev": true, "requires": { "redux": "^4.0.0" + }, + "dependencies": { + "redux": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/redux/-/redux-4.2.1.tgz", + "integrity": "sha512-LAUYz4lc+Do8/g7aeRa8JkyDErK6ekstQaqWQrNRW//MY1TvCEpMtpTWvlQ+FPbWCx+Xixu/6SHt5N0HR+SB4w==", + "dev": true, + "requires": { + "@babel/runtime": "^7.9.2" + } + } } }, - "@types/redux-thunk": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@types/redux-thunk/-/redux-thunk-2.1.0.tgz", - "integrity": "sha1-vCtulylhgxr7gqm/TwZybjUflBY=", - "dev": true, - "requires": { - "redux-thunk": "*" - } - }, - "@types/scheduler": { - "version": "0.16.2", - "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz", - "integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==", - "dev": true - }, "@types/semver": { "version": "7.3.13", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.13.tgz", @@ -13578,15 +13496,6 @@ "has-symbols": "^1.0.2" } }, - "hoist-non-react-statics": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", - "integrity": "sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==", - "dev": true, - "requires": { - "react-is": "^16.7.0" - } - }, "hosted-git-info": { "version": "2.8.9", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", @@ -15884,9 +15793,9 @@ "dev": true }, "node-fetch": { - "version": "2.6.7", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", - "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", "requires": { "whatwg-url": "^5.0.0" }, @@ -16332,25 +16241,13 @@ "dev": true }, "react-redux": { - "version": "8.0.5", - "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-8.0.5.tgz", - "integrity": "sha512-Q2f6fCKxPFpkXt1qNRZdEDLlScsDWyrgSj0mliK59qU6W5gvBiKkdMEG2lJzhd1rCctf0hb6EtePPLZ2e0m1uw==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.0.0.tgz", + "integrity": "sha512-/X/wiza+G2IXbz1Ow9Gs5qK7KNdoEnzzsR7ne7jcOWJMBOx9wvraPZwFddCs84xqwilvYaoENHowQMiW0axbsQ==", "dev": true, "requires": { - "@babel/runtime": "^7.12.1", - "@types/hoist-non-react-statics": "^3.3.1", "@types/use-sync-external-store": "^0.0.3", - "hoist-non-react-statics": "^3.3.2", - "react-is": "^18.0.0", "use-sync-external-store": "^1.0.0" - }, - "dependencies": { - "react-is": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", - "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", - "dev": true - } } }, "redent": { @@ -16382,13 +16279,10 @@ } }, "redux": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/redux/-/redux-4.2.1.tgz", - "integrity": "sha512-LAUYz4lc+Do8/g7aeRa8JkyDErK6ekstQaqWQrNRW//MY1TvCEpMtpTWvlQ+FPbWCx+Xixu/6SHt5N0HR+SB4w==", - "dev": true, - "requires": { - "@babel/runtime": "^7.9.2" - } + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz", + "integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==", + "dev": true }, "redux-mock-store": { "version": "1.5.4", @@ -16400,10 +16294,11 @@ } }, "redux-thunk": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-2.3.0.tgz", - "integrity": "sha512-km6dclyFnmcvxhAcrQV2AkZmPQjzPDjgVlQtR0EQjxZPyJ0BnMf3in1ryuR8A2qU0HldVRfxYXbFSKlI3N7Slw==", - "dev": true + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-3.1.0.tgz", + "integrity": "sha512-NW2r5T6ksUKXCabzhL9z+h206HQw/NJkcLm1GPImRQ8IzfXwRGqjVhKJGauHirT0DAuyy6hjdnMZaRoAcy0Klw==", + "dev": true, + "requires": {} }, "reflect-metadata": { "version": "0.1.13", @@ -17087,10 +16982,9 @@ } }, "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" }, "tsutils": { "version": "3.21.0", @@ -17099,6 +16993,14 @@ "dev": true, "requires": { "tslib": "^1.8.1" + }, + "dependencies": { + "tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + } } }, "type-check": { diff --git a/package.json b/package.json index a27c6a1..87d07c6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@splitsoftware/splitio-redux", - "version": "1.10.0", + "version": "1.11.0", "description": "A library to easily use Split JS SDK with Redux and React Redux", "main": "lib/index.js", "module": "es/index.js", @@ -59,7 +59,8 @@ }, "homepage": "https://github.com/splitio/redux-client#readme", "dependencies": { - "@splitsoftware/splitio": "10.24.1" + "@splitsoftware/splitio": "10.25.2", + "tslib": "^2.3.1" }, "devDependencies": { "@testing-library/jest-dom": "^5.16.5", @@ -67,9 +68,7 @@ "@types/jest": "^27.0.0", "@types/react": "^18.0.0", "@types/react-dom": "^18.0.0", - "@types/react-redux": "^7.1.5", "@types/redux-mock-store": "^1.0.1", - "@types/redux-thunk": "^2.1.0", "@typescript-eslint/eslint-plugin": "^5.55.0", "@typescript-eslint/parser": "^5.55.0", "eslint": "^8.36.0", @@ -80,10 +79,10 @@ "jest": "^27.2.3", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-redux": "^8.0.0", - "redux": "^4.2.0", + "react-redux": "9.0.0", + "redux": "^5.0.1", "redux-mock-store": "^1.5.4", - "redux-thunk": "^2.3.0", + "redux-thunk": "^3.1.0", "replace": "^1.2.1", "rimraf": "^3.0.0", "ts-jest": "^27.0.5", @@ -92,7 +91,7 @@ "peerDependencies": { "react-redux": ">=4.0.0", "redux": ">=2.0.0", - "redux-thunk": "^2.0.0" + "redux-thunk": ">=2.0.0" }, "peerDependenciesMeta": { "react-redux": { @@ -104,5 +103,6 @@ "pre-commit": "npm run check", "pre-push": "npm test && npm run build" } - } + }, + "sideEffects": false } diff --git a/src/__tests__/utils/mockStore.ts b/src/__tests__/utils/mockStore.ts index 7758742..48c720c 100644 --- a/src/__tests__/utils/mockStore.ts +++ b/src/__tests__/utils/mockStore.ts @@ -1,6 +1,7 @@ -import thunk from 'redux-thunk'; +import { thunk } from 'redux-thunk'; import configureMockStore from 'redux-mock-store'; -const middlewares = [thunk]; + +const middlewares: any[] = [thunk]; /** * Utils to not call requires files every time that we need mock the store diff --git a/src/reducer.ts b/src/reducer.ts index 1bb80e4..2b930de 100644 --- a/src/reducer.ts +++ b/src/reducer.ts @@ -73,49 +73,49 @@ export const splitReducer: Reducer = function ( ) { switch (action.type) { case SPLIT_READY: - return setReady(state, action.payload.timestamp); + return setReady(state, (action as any).payload.timestamp); case SPLIT_READY_FROM_CACHE: - return setReadyFromCache(state, action.payload.timestamp); + return setReadyFromCache(state, (action as any).payload.timestamp); case SPLIT_TIMEDOUT: return { ...state, isTimedout: true, hasTimedout: true, - lastUpdate: action.payload.timestamp, + lastUpdate: (action as any).payload.timestamp, }; case SPLIT_UPDATE: - return setUpdated(state, action.payload.timestamp); + return setUpdated(state, (action as any).payload.timestamp); case SPLIT_DESTROY: return { ...state, isDestroyed: true, - lastUpdate: action.payload.timestamp, + lastUpdate: (action as any).payload.timestamp, }; case ADD_TREATMENTS: { - const { key, treatments } = action.payload; + const { key, treatments } = (action as any).payload; const result = { ...state }; return assignTreatments(result, key, treatments); } case SPLIT_READY_WITH_EVALUATIONS: { - const { key, treatments, timestamp } = action.payload; + const { key, treatments, timestamp } = (action as any).payload; const result = setReady(state, timestamp); return assignTreatments(result, key, treatments); } case SPLIT_READY_FROM_CACHE_WITH_EVALUATIONS: { - const { key, treatments, timestamp } = action.payload; + const { key, treatments, timestamp } = (action as any).payload; const result = setReadyFromCache(state, timestamp); return assignTreatments(result, key, treatments); } case SPLIT_UPDATE_WITH_EVALUATIONS: { - const { key, treatments, timestamp } = action.payload; + const { key, treatments, timestamp } = (action as any).payload; const result = setUpdated(state, timestamp); return assignTreatments(result, key, treatments); } diff --git a/tsconfig.json b/tsconfig.json index d807e1d..52a0e77 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,24 +3,22 @@ /* Basic Options */ // "incremental": true, /* Enable incremental compilation */ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ - "module": "es6", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ + "module": "es6", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation. */ // "allowJs": true, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ - // "jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - "declaration": false, /* Generates corresponding '.d.ts' file. */ + // "jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + "declaration": false, /* Generates corresponding '.d.ts' file. */ // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ + "sourceMap": false, /* Generates corresponding '.map' file. */ // "outFile": "./", /* Concatenate and emit output to single file. */ - "outDir": "es", /* Redirect output structure to the directory. */ + "outDir": "es", /* Redirect output structure to the directory. */ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ // "composite": true, /* Enable project compilation */ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ // "removeComments": true, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ - - // @TODO uncomment the following when migrating to JS-commons and Rollup, to avoid duplicated helpers code in builds. - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + "importHelpers": true, /* Import emit helpers from 'tslib'. */ // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ @@ -62,6 +60,10 @@ // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ }, - "include": ["src"], - "exclude": ["./src/__tests__"] + "include": [ + "src" + ], + "exclude": [ + "./src/__tests__" + ] } diff --git a/types/actions.d.ts b/types/actions.d.ts deleted file mode 100644 index 50a97c6..0000000 --- a/types/actions.d.ts +++ /dev/null @@ -1,61 +0,0 @@ -export declare function splitReady(): { - type: string; - payload: { - timestamp: number; - }; -}; -export declare function splitReadyWithEvaluations(key: SplitIO.SplitKey, treatments: SplitIO.TreatmentsWithConfig): { - type: string; - payload: { - timestamp: number; - key: string; - treatments: import("@splitsoftware/splitio/types/splitio").TreatmentsWithConfig; - }; -}; -export declare function splitReadyFromCache(): { - type: string; - payload: { - timestamp: number; - }; -}; -export declare function splitReadyFromCacheWithEvaluations(key: SplitIO.SplitKey, treatments: SplitIO.TreatmentsWithConfig): { - type: string; - payload: { - timestamp: number; - key: string; - treatments: import("@splitsoftware/splitio/types/splitio").TreatmentsWithConfig; - }; -}; -export declare function splitUpdate(): { - type: string; - payload: { - timestamp: number; - }; -}; -export declare function splitUpdateWithEvaluations(key: SplitIO.SplitKey, treatments: SplitIO.TreatmentsWithConfig): { - type: string; - payload: { - timestamp: number; - key: string; - treatments: import("@splitsoftware/splitio/types/splitio").TreatmentsWithConfig; - }; -}; -export declare function splitTimedout(): { - type: string; - payload: { - timestamp: number; - }; -}; -export declare function splitDestroy(): { - type: string; - payload: { - timestamp: number; - }; -}; -export declare function addTreatments(key: SplitIO.SplitKey, treatments: SplitIO.TreatmentsWithConfig): { - type: string; - payload: { - key: string; - treatments: import("@splitsoftware/splitio/types/splitio").TreatmentsWithConfig; - }; -}; diff --git a/types/asyncActions.d.ts b/types/asyncActions.d.ts deleted file mode 100644 index 1498a97..0000000 --- a/types/asyncActions.d.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { Dispatch, Action } from 'redux'; -import { IInitSplitSdkParams, IGetTreatmentsParams, IDestroySplitSdkParams, ISplitFactoryBuilder } from './types'; -/** - * Internal object SplitSdk. This object should not be accessed or - * modified by the user, since it is not considered part of the public API - * and may break without notice. It is used by the library for its operation. - */ -export interface ISplitSdk { - config: SplitIO.IBrowserSettings | SplitIO.INodeSettings; - splitio: ISplitFactoryBuilder; - factory: SplitIO.ISDK; - sharedClients: { - [stringKey: string]: SplitIO.IClient; - }; - isDetached: boolean; - dispatch: Dispatch; -} -export declare const splitSdk: ISplitSdk; -/** - * This action creator initializes the Split SDK. It dispatches a Thunk (async) action. - * - * @param {IInitSplitSdkParams} params - */ -export declare function initSplitSdk(params: IInitSplitSdkParams): (dispatch: Dispatch) => Promise; -/** - * This action creator performs a treatment evaluation, i.e., it invokes the actual `client.getTreatment*` methods. - * - * @param {IGetTreatmentsParams} params - */ -export declare function getTreatments(params: IGetTreatmentsParams): Action | (() => void); -/** - * Interface of SDK client for not detached execution (browser). - */ -interface IClientNotDetached extends SplitIO.IClient { - _trackingStatus?: boolean; - /** - * stored evaluations to execute on SDK update. It is an object because we might - * want to change the evaluation parameters (i.e. attributes) per each feature flag name or flag set. - */ - evalOnUpdate: { - [name: string]: IGetTreatmentsParams; - }; - /** - * stored evaluations to execute when the SDK is ready. It is an array, so if multiple evaluations - * are set with the same feature flag name, the result (i.e. treatment) of the last one is the stored one. - */ - evalOnReady: IGetTreatmentsParams[]; - /** - * Similar to evalOnReady: stored evaluations to execute when the SDK is ready from cache. - */ - evalOnReadyFromCache: IGetTreatmentsParams[]; -} -/** - * Used in not detached version (browser). It gets an SDK client and enhances it with `evalOnUpdate`, `evalOnReady` and `evalOnReadyFromCache` lists. - * These lists are used by `getTreatments` action creator to schedule evaluation of feature flags on SDK_UPDATE, SDK_READY and SDK_READY_FROM_CACHE events. - * It is exported for testing purposes only. - * - * @param splitSdk it contains the Split factory, the store dispatch function, and other internal properties - * @param key optional user key - * @returns SDK client with `evalOnUpdate`, `evalOnReady` and `evalOnReadyFromCache` action lists. - */ -export declare function getClient(splitSdk: ISplitSdk, key?: SplitIO.SplitKey): IClientNotDetached; -/** - * This action creator destroy the Split SDK. It dispatches a Thunk (async) action. - * Once the action is resolved, any subsequent dispatch of `getTreatments` - * will update your treatments at the store with the `control` value. - */ -export declare function destroySplitSdk(params?: IDestroySplitSdkParams): (dispatch: Dispatch) => Promise; -export {}; diff --git a/types/constants.d.ts b/types/constants.d.ts deleted file mode 100644 index 9817bac..0000000 --- a/types/constants.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -export declare const DEFAULT_SPLIT_STATE_SLICE = "splitio"; -export declare const VERSION: string; -export declare const ON: SplitIO.Treatment; -export declare const OFF: SplitIO.Treatment; -export declare const CONTROL: SplitIO.Treatment; -export declare const CONTROL_WITH_CONFIG: SplitIO.TreatmentWithConfig; -export declare const getControlTreatmentsWithConfig: (featureFlagNames: string[]) => SplitIO.TreatmentsWithConfig; -export declare const SPLIT_READY = "SPLIT_READY"; -export declare const SPLIT_READY_WITH_EVALUATIONS = "SPLIT_READY_WITH_EVALUATIONS"; -export declare const SPLIT_READY_FROM_CACHE = "SPLIT_READY_FROM_CACHE"; -export declare const SPLIT_READY_FROM_CACHE_WITH_EVALUATIONS = "SPLIT_READY_FROM_CACHE_WITH_EVALUATIONS"; -export declare const SPLIT_UPDATE = "SPLIT_UPDATE"; -export declare const SPLIT_UPDATE_WITH_EVALUATIONS = "SPLIT_UPDATE_WITH_EVALUATIONS"; -export declare const SPLIT_TIMEDOUT = "SPLIT_TIMEDOUT"; -export declare const SPLIT_DESTROY = "SPLIT_DESTROY"; -export declare const ADD_TREATMENTS = "ADD_TREATMENTS"; -export declare const ERROR_GETT_NO_INITSPLITSDK = "[ERROR] To use \"getTreatments\" the SDK must be first initialized with an \"initSplitSdk\" action"; -export declare const ERROR_DESTROY_NO_INITSPLITSDK = "[ERROR] To use \"destroySplitSdk\" the SDK must be first initialized with an \"initSplitSdk\" action"; -export declare const ERROR_TRACK_NO_INITSPLITSDK = "[ERROR] To use \"track\" the SDK must be first initialized with an \"initSplitSdk\" action"; -export declare const ERROR_MANAGER_NO_INITSPLITSDK = "[ERROR] To use the manager, the SDK must be first initialized with an \"initSplitSdk\" action"; -export declare const ERROR_SELECTOR_NO_SPLITSTATE = "[ERROR] When using selectors, \"splitState\" value must be a proper splitio piece of state"; -export declare const ERROR_GETT_NO_PARAM_OBJECT = "[ERROR] \"getTreatments\" must be called with a param object containing a valid splitNames or flagSets properties"; -export declare const WARN_FEATUREFLAGS_AND_FLAGSETS = "[WARN] Both splitNames and flagSets properties were provided. flagSets will be ignored"; diff --git a/types/helpers.d.ts b/types/helpers.d.ts deleted file mode 100644 index 344c8da..0000000 --- a/types/helpers.d.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { ITrackParams } from './types'; -/** - * This function track events, i.e., it invokes the actual `client.track*` methods. - * This function is not an action creator, but rather a simple access to `client.track()`. - * - * @param {ITrackParams} params - * - * @see {@link https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK#track} - */ -export declare function track(params: ITrackParams): boolean; -/** - * Get the array of feature flag names. - * - * @returns {string[]} The list of feature flag names. The list might be empty if the SDK was not initialized or if it's not ready yet. - * - * @see {@link https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK#manager} - */ -export declare function getSplitNames(): string[]; -/** - * Get the data of a split in SplitView format. - * - * @param {string} featureFlagName The name of the split we wan't to get info of. - * @returns {SplitView} The SplitIO.SplitView of the given split, or null if split does not exist or the SDK was not initialized or is not ready. - * - * @see {@link https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK#manager} - */ -export declare function getSplit(featureFlagName: string): SplitIO.SplitView; -/** - * Get the array of feature flags data in SplitView format. - * - * @returns {SplitViews} The list of SplitIO.SplitView. The list might be empty if the SDK was not initialized or if it's not ready yet - * - * @see {@link https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK#manager} - */ -export declare function getSplits(): SplitIO.SplitViews; diff --git a/types/index.d.ts b/types/index.d.ts deleted file mode 100644 index 797a995..0000000 --- a/types/index.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export { splitReducer } from './reducer'; -export { initSplitSdk, getTreatments, destroySplitSdk, splitSdk } from './asyncActions'; -export { track, getSplitNames, getSplit, getSplits } from './helpers'; -export { selectTreatmentValue, selectTreatmentWithConfig } from './selectors'; -export { connectSplit } from './react-redux/connectSplit'; -export { connectToggler, mapTreatmentToProps, mapIsFeatureOnToProps } from './react-redux/connectToggler'; -export { ISplitState } from './types'; diff --git a/types/react-redux/connectSplit.d.ts b/types/react-redux/connectSplit.d.ts deleted file mode 100644 index 12309f8..0000000 --- a/types/react-redux/connectSplit.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { getTreatments } from '../asyncActions'; -import { ISplitState, IGetSplitState } from '../types'; -/** - * This decorator connects your components with: - * - The Split state at Redux, under the prop key `split`. - * - The action creator `getTreatments`, binded to the `dispatch` of your store. - * - * @param {IGetSplitState} getSplitState optional function that takes the entire Redux state and returns - * the state slice which corresponds to where the Split reducer was mounted. This functionality is rarely - * needed, and defaults to assuming that the reducer is mounted under the `splitio` key. - */ -export declare function connectSplit(getSplitState?: IGetSplitState): import("react-redux").InferableComponentEnhancerWithProps<{ - splitio: ISplitState; -} & { - getTreatments: typeof getTreatments; -}, {}>; diff --git a/types/react-redux/connectToggler.d.ts b/types/react-redux/connectToggler.d.ts deleted file mode 100644 index 49e354e..0000000 --- a/types/react-redux/connectToggler.d.ts +++ /dev/null @@ -1,40 +0,0 @@ -/// -import { IGetSplitState } from '../types'; -/** - * Looks on the features of the Split piece of state, and maps to isFeatureOn - * depending if this feature is ON or not - * - * @param {string} featureFlagName feature flag name - * @param {SplitIO.SplitKey} key user key - * @param {IGetSplitState} getSplitState function that extract the Split piece of state from the Redux state. - */ -export declare function mapIsFeatureOnToProps(featureFlagName: string, key?: SplitIO.SplitKey, getSplitState?: IGetSplitState): (state: any) => { - isFeatureOn: boolean; -}; -/** - * Looks on the features of the Split piece of state, and maps to feature - * the value of this feature - * - * @param {string} featureFlagName feature flag name - * @param {SplitIO.SplitKey} key user key - * @param {IGetSplitState} getSplitState function that extract the Split piece of state from the Redux state. - */ -export declare function mapTreatmentToProps(featureFlagName: string, key?: SplitIO.SplitKey, getSplitState?: IGetSplitState): (state: any) => { - feature: string; -}; -/** - * - * Returns a connected component that wraps the toggler - * The idea of this is to send the isFeatureOn prop to the toggler - * - * So connect send the global state and the toggler decide which to render - * - * @param {string} featureFlagtName feature flag name - * @param {SplitIO.SplitKey} key user key - * @param {IGetSplitState} getSplitState function that extract the Split piece of state from the Redux state. - */ -export declare function connectToggler(featureFlagName: string, key?: SplitIO.SplitKey, getSplitState?: IGetSplitState): (ComponentOn: React.ComponentType, ComponentDefault?: React.ComponentType) => import("react-redux").ConnectedComponent<({ isFeatureOn, ...props }: { - isFeatureOn: boolean; -}) => import("react").ReactElement<{}, string | import("react").JSXElementConstructor>, { - [x: string]: any; -}>; diff --git a/types/reducer.d.ts b/types/reducer.d.ts deleted file mode 100644 index 667ef80..0000000 --- a/types/reducer.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Reducer } from 'redux'; -import { ISplitState } from './types'; -/** - * Split reducer. - * It updates the Split's slice of state. - */ -export declare const splitReducer: Reducer; diff --git a/types/selectors.d.ts b/types/selectors.d.ts deleted file mode 100644 index 4984e59..0000000 --- a/types/selectors.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { ISplitState } from './types'; -export declare const getStateSlice: (sliceName: string) => (state: any) => any; -export declare const defaultGetSplitState: (state: any) => any; -/** - * Selector function to extract a treatment evaluation from the Split state. It returns the treatment string value. - * - * @param {ISplitState} splitState - * @param {string} featureFlagName - * @param {SplitIO.SplitKey} key - * @param {string} defaultValue - */ -export declare function selectTreatmentValue(splitState: ISplitState, featureFlagName: string, key?: SplitIO.SplitKey, defaultValue?: string): string; -/** - * Selector function to extract a treatment evaluation from the Split state. It returns a treatment object containing its value and configuration. - * - * @param {ISplitState} splitState - * @param {string} featureFlagName - * @param {SplitIO.SplitKey} key - * @param {TreatmentWithConfig} defaultValue - */ -export declare function selectTreatmentWithConfig(splitState: ISplitState, featureFlagName: string, key?: SplitIO.SplitKey, defaultValue?: SplitIO.TreatmentWithConfig): SplitIO.TreatmentWithConfig; diff --git a/types/types.d.ts b/types/types.d.ts deleted file mode 100644 index 56b5b79..0000000 --- a/types/types.d.ts +++ /dev/null @@ -1,156 +0,0 @@ -/** Type for Split reducer's slice of state */ -export interface ISplitState { - /** - * isReady indicates if Split SDK is ready, i.e., if it has emitted an SDK_READY event. - * @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#advanced-subscribe-to-events-and-changes} - */ - isReady: boolean; - /** - * isReadyFromCache indicates if Split SDK has emitted an SDK_READY_FROM_CACHE event, what means that the SDK is ready to - * evaluate using LocalStorage cached data (which might be stale). - * This flag only applies for the Browser if using LOCALSTORAGE as storage type. - * @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#advanced-subscribe-to-events-and-changes} - */ - isReadyFromCache: boolean; - /** - * isTimedout indicates if the Split SDK has emitted an SDK_READY_TIMED_OUT event and is not ready. - * @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#advanced-subscribe-to-events-and-changes} - */ - isTimedout: boolean; - /** - * hasTimedout indicates if the Split SDK has ever emitted an SDK_READY_TIMED_OUT event. - * It's meant to keep a reference that the SDK emitted a timeout at some point, not the current state. - * @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#advanced-subscribe-to-events-and-changes} - */ - hasTimedout: boolean; - /** - * isDestroyed indicates if the Split SDK has been destroyed by dispatching a `destroySplitSdk` action. - * @see {@link https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK#shutdown} - */ - isDestroyed: boolean; - /** - * lastUpdate is the timestamp of the last Split SDK event (SDK_READY, SDK_READY_TIMED_OUT or SDK_UPDATE). - * @see {@link https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK#advanced-subscribe-to-events-and-changes} - */ - lastUpdate: number; - /** - * `treatments` is a nested object property that contains the evaluations of feature flags. - * Each evaluation (treatment) is associated with a feature flag name and a key (e.g., unique user identifier, such as a user id). - * Thus the property has 3 levels: feature flag name, key, and finally the treatment that was evaluated for that specific feature flag and key. - */ - treatments: { - [featureFlagName: string]: { - [key: string]: SplitIO.TreatmentWithConfig; - }; - }; -} -export declare type IGetSplitState = (state: any) => ISplitState; -/** - * Type of the param object passed to `initSplitSdk` action creator. - */ -export interface IInitSplitSdkParams { - /** - * Setting object used to initialize the Split factory. - * @see {@link https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK#configuration} - */ - config: SplitIO.IBrowserSettings | SplitIO.INodeSettings; - /** - * Optional param to provide a Split factory initializer to use instead of SplitFactory from '@splitsoftware/splitio'. - * It can be useful when the Split factory is imported from the UMD bundle in a HTML script. - */ - splitio?: ISplitFactoryBuilder; - /** - * optional callback to be invoked on SDK_READY event - */ - onReady?: () => any; - /** - * optional callback to be invoked on SDK_READY_FROM_CACHE event - */ - onReadyFromCache?: () => any; - /** - * optional callback to be invoked on SDK_READY_TIMED_OUT event - */ - onTimedout?: () => any; - /** - * optional callback to be invoked on SDK_UPDATE event - */ - onUpdate?: () => any; -} -/** - * Type of the param object passed to `getTreatments` action creator. - */ -export declare type IGetTreatmentsParams = { - /** - * user key used to evaluate. It is mandatory for node but optional for browser. If not provided in browser, - * it defaults to the key defined in the SDK config, i.e., the config object passed to `initSplitSdk`. - */ - key?: SplitIO.SplitKey; - /** - * optional map of attributes passed to the actual `client.getTreatment*` methods. - * @see {@link https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK#attribute-syntax} - */ - attributes?: SplitIO.Attributes; - /** - * This param indicates to re-evaluate the feature flags if the SDK is updated. For example, a `true` value might be - * the desired behaviour for permission toggles or operation toggles, such as a kill switch, that you want to - * inmediately reflect in your app. A `false` value might be useful for experiment or release toggles, where - * you want to keep the treatment unchanged during the sesion of the user. - * @default false - */ - evalOnUpdate?: boolean; - /** - * This param indicates to evaluate the feature flags if the SDK is ready from cache (i.e., it emits SDK_READY_FROM_CACHE event). - * This params is only relevant when using 'LOCALSTORAGE' as storage type, since otherwise the event is never emitted. - * @default false - */ - evalOnReadyFromCache?: boolean; -} & ({ - /** - * Feature flag name or array of feature flag names to evaluate. Either this or the `flagSets` property must be provided. If both are provided, the `flagSets` option is ignored. - */ - splitNames: string[] | string; - flagSets?: undefined; -} | { - /** - * Feature flag set or array of feature flag sets to evaluate. Either this or the `splitNames` property must be provided. If both are provided, the `flagSets` option is ignored. - */ - flagSets: string[] | string; - splitNames?: undefined; -}); -/** - * Type of the param object passed to `destroySplitSdk` action creator. - */ -export interface IDestroySplitSdkParams { - /** - * optional callback to be invoked once the SDK has gracefully shut down - */ - onDestroy?: () => any; -} -/** - * Type of the param object passed to `track` function helper. - */ -export interface ITrackParams { - /** - * user key used to track event. It is mandatory for node but optional for browser. If not provided in browser, - * it defaults to the key defined in the SDK config object. - */ - key?: SplitIO.SplitKey; - /** - * the traffic type of the key in the track call. If not provided, it defaults to the traffic type defined in the SDK - * config object. If not provided either in the SDK setting, the function logs an error message and returns false. - */ - trafficType?: string; - /** - * The event type that this event should correspond to. The expected data type is String. - */ - eventType: string; - /** - * Optional value to be used in creating the metric. - */ - value?: number; - /** - * Optional object of key-value pairs that can be used to filter your metrics. - */ - properties?: SplitIO.Properties; -} -export declare type ISplitFactoryBuilder = (settings: SplitIO.IBrowserSettings | SplitIO.INodeSettings) => SplitIO.ISDK; diff --git a/types/utils.d.ts b/types/utils.d.ts deleted file mode 100644 index f37d930..0000000 --- a/types/utils.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { IGetTreatmentsParams } from './types'; -/** - * Validates if a value is an object. - */ -export declare function isObject(obj: unknown): boolean; -/** - * Verify type of key and return either its matchingKey or itself - */ -export declare function matching(key: SplitIO.SplitKey): string; -/** - * ClientWithContext interface. - */ -export interface IClientStatus { - isReady: boolean; - isReadyFromCache: boolean; - isOperational: boolean; - hasTimedout: boolean; - isDestroyed: boolean; -} -export declare function getStatus(client: SplitIO.IClient): IClientStatus; -/** - * Validates and sanitizes the parameters passed to the "getTreatments" action creator. - * The returned object is a copy of the passed one, with the "splitNames" and "flagSets" properties converted to an array of strings. - */ -export declare function validateGetTreatmentsParams(params: any): IGetTreatmentsParams | false;