flagsmith-nodejs 2.5.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/.github/workflows/publish.yml +25 -0
  2. package/examples/README.md +3 -0
  3. package/flagsmith-engine/identities/models.ts +3 -1
  4. package/flagsmith-engine/segments/evaluators.ts +4 -3
  5. package/package.json +1 -1
  6. package/tests/engine/unit/segments/segment_evaluators.test.ts +46 -6
  7. package/.vscode/launch.json +0 -18
  8. package/build/flagsmith-engine/environments/integrations/models.d.ts +0 -4
  9. package/build/flagsmith-engine/environments/integrations/models.js +0 -11
  10. package/build/flagsmith-engine/environments/models.d.ts +0 -25
  11. package/build/flagsmith-engine/environments/models.js +0 -29
  12. package/build/flagsmith-engine/environments/util.d.ts +0 -3
  13. package/build/flagsmith-engine/environments/util.js +0 -21
  14. package/build/flagsmith-engine/features/constants.d.ts +0 -4
  15. package/build/flagsmith-engine/features/constants.js +0 -7
  16. package/build/flagsmith-engine/features/models.d.ts +0 -37
  17. package/build/flagsmith-engine/features/models.js +0 -122
  18. package/build/flagsmith-engine/features/util.d.ts +0 -4
  19. package/build/flagsmith-engine/features/util.js +0 -27
  20. package/build/flagsmith-engine/identities/models.d.ts +0 -15
  21. package/build/flagsmith-engine/identities/models.js +0 -112
  22. package/build/flagsmith-engine/identities/traits/models.d.ts +0 -5
  23. package/build/flagsmith-engine/identities/traits/models.js +0 -11
  24. package/build/flagsmith-engine/identities/util.d.ts +0 -4
  25. package/build/flagsmith-engine/identities/util.js +0 -46
  26. package/build/flagsmith-engine/index.d.ts +0 -15
  27. package/build/flagsmith-engine/index.js +0 -129
  28. package/build/flagsmith-engine/organisations/models.d.ts +0 -9
  29. package/build/flagsmith-engine/organisations/models.js +0 -21
  30. package/build/flagsmith-engine/organisations/util.d.ts +0 -2
  31. package/build/flagsmith-engine/organisations/util.js +0 -8
  32. package/build/flagsmith-engine/projects/models.d.ts +0 -10
  33. package/build/flagsmith-engine/projects/models.js +0 -14
  34. package/build/flagsmith-engine/projects/util.d.ts +0 -2
  35. package/build/flagsmith-engine/projects/util.js +0 -15
  36. package/build/flagsmith-engine/segments/constants.d.ts +0 -34
  37. package/build/flagsmith-engine/segments/constants.js +0 -39
  38. package/build/flagsmith-engine/segments/evaluators.d.ts +0 -7
  39. package/build/flagsmith-engine/segments/evaluators.js +0 -44
  40. package/build/flagsmith-engine/segments/models.d.ts +0 -37
  41. package/build/flagsmith-engine/segments/models.js +0 -144
  42. package/build/flagsmith-engine/segments/util.d.ts +0 -6
  43. package/build/flagsmith-engine/segments/util.js +0 -33
  44. package/build/flagsmith-engine/utils/collections.d.ts +0 -3
  45. package/build/flagsmith-engine/utils/collections.js +0 -26
  46. package/build/flagsmith-engine/utils/errors.d.ts +0 -2
  47. package/build/flagsmith-engine/utils/errors.js +0 -26
  48. package/build/flagsmith-engine/utils/hashing/index.d.ts +0 -9
  49. package/build/flagsmith-engine/utils/hashing/index.js +0 -60
  50. package/build/flagsmith-engine/utils/index.d.ts +0 -1
  51. package/build/flagsmith-engine/utils/index.js +0 -17
  52. package/build/index.d.ts +0 -2
  53. package/build/index.js +0 -24
  54. package/build/sdk/analytics.d.ts +0 -31
  55. package/build/sdk/analytics.js +0 -116
  56. package/build/sdk/errors.d.ts +0 -4
  57. package/build/sdk/errors.js +0 -34
  58. package/build/sdk/index.d.ts +0 -120
  59. package/build/sdk/index.js +0 -527
  60. package/build/sdk/models.d.ts +0 -55
  61. package/build/sdk/models.js +0 -149
  62. package/build/sdk/polling_manager.d.ts +0 -9
  63. package/build/sdk/polling_manager.js +0 -72
  64. package/build/sdk/types.d.ts +0 -27
  65. package/build/sdk/types.js +0 -2
  66. package/build/sdk/utils.d.ts +0 -12
  67. package/build/sdk/utils.js +0 -99
  68. package/examples/api-proxy/.babelrc +0 -3
  69. package/examples/api-proxy/.eslintrc +0 -8
  70. package/examples/api-proxy/README.md +0 -12
  71. package/examples/api-proxy/package-lock.json +0 -10889
  72. package/examples/api-proxy/package.json +0 -57
  73. package/examples/api-proxy/src/api/index.js +0 -42
  74. package/examples/api-proxy/src/index.js +0 -29
  75. package/examples/basic/.babelrc +0 -3
  76. package/examples/basic/.eslintrc +0 -8
  77. package/examples/basic/README.md +0 -10
  78. package/examples/basic/package-lock.json +0 -10779
  79. package/examples/basic/package.json +0 -56
  80. package/examples/basic/src/api/index.js +0 -33
  81. package/examples/basic/src/index.js +0 -29
  82. package/examples/caching/.babelrc +0 -3
  83. package/examples/caching/.eslintrc +0 -8
  84. package/examples/caching/README.md +0 -9
  85. package/examples/caching/package-lock.json +0 -6750
  86. package/examples/caching/package.json +0 -56
  87. package/examples/caching/src/api/index.js +0 -38
  88. package/examples/caching/src/index.js +0 -29
  89. package/examples/custom-fetch-agent/.babelrc +0 -3
  90. package/examples/custom-fetch-agent/.eslintrc +0 -8
  91. package/examples/custom-fetch-agent/README.md +0 -12
  92. package/examples/custom-fetch-agent/package-lock.json +0 -6750
  93. package/examples/custom-fetch-agent/package.json +0 -56
  94. package/examples/custom-fetch-agent/src/api/index.js +0 -34
  95. package/examples/custom-fetch-agent/src/index.js +0 -29
  96. package/examples/local-evaluation/.babelrc +0 -3
  97. package/examples/local-evaluation/.eslintrc +0 -8
  98. package/examples/local-evaluation/README.md +0 -18
  99. package/examples/local-evaluation/package-lock.json +0 -6668
  100. package/examples/local-evaluation/package.json +0 -56
  101. package/examples/local-evaluation/src/api/index.js +0 -39
  102. package/examples/local-evaluation/src/index.js +0 -29
  103. package/tests/engine/engine-tests/engine-test-data/data/environment_n9fbf9h3v4fFgH3U3ngWhb.json +0 -12591
  104. package/tests/engine/engine-tests/engine-test-data/readme.md +0 -30
@@ -1,56 +0,0 @@
1
- {
2
- "name": "nodejs-es6-boilerplate",
3
- "version": "1.0.1",
4
- "description": "Node.js boilerplate with ES6, ESLint, and Prettier",
5
- "main": "src/index.js",
6
- "browserslist": [
7
- "last 2 Chrome versions"
8
- ],
9
- "scripts": {
10
- "test": "echo \"Error: no test specified\" && exit 1",
11
- "clean": "rm -rf build && mkdir build",
12
- "build-babel": "babel -d ./build ./src -s",
13
- "build": "npm run clean && npm run build-babel",
14
- "dev": "nodemon --exec npm start --ignore ./build",
15
- "node-cache": "^5.1.2",
16
- "ssg-node-express": "4.16.4",
17
- "start": "npm run build && node ./build/index.js",
18
- "format": "prettier --write \"src/**/*.js\"",
19
- "format:check": "prettier --list-different \"src/**/*.js\"",
20
- "lint": "eslint \"src/**/*.js\"",
21
- "lint:fix": "eslint --fix \"src/**/*.js\""
22
- },
23
- "repository": "github:vferdiansyah/nodejs-es6-boilerplate",
24
- "keywords": [
25
- "javascript",
26
- "node",
27
- "nodejs",
28
- "es6",
29
- "eslint",
30
- "prettier",
31
- "boilerplate"
32
- ],
33
- "author": {
34
- "name": "Veri Ferdiansyah",
35
- "email": "veri.ferdi@gmail.com",
36
- "url": "https://vferdiansyah.github.io"
37
- },
38
- "license": "MIT",
39
- "bugs": "https://github.com/vferdiansyah/nodejs-es6-boilerplate/issues",
40
- "homepage": "https://github.com/vferdiansyah/nodejs-es6-boilerplate#readme",
41
- "devDependencies": {
42
- "@babel/cli": "^7.5.5",
43
- "@babel/core": "^7.5.5",
44
- "@babel/preset-env": "^7.5.5",
45
- "eslint": "^6.2.1",
46
- "eslint-config-prettier": "^6.1.0",
47
- "eslint-plugin-prettier": "^3.1.0",
48
- "express": "^4.18.1",
49
- "nodemon": "^2.0.19",
50
- "prettier": "^1.18.2"
51
- },
52
- "dependencies": {
53
- "flagsmith-nodejs": "^2.2.2",
54
- "node-cache": "^5.1.2"
55
- }
56
- }
@@ -1,33 +0,0 @@
1
- import {Router} from 'express'
2
- import Flagsmith from '../../../../build'
3
-
4
- const environmentKey = 'NowEDzKzNJXZVTVanLVdMQ';
5
-
6
- const flagsmith = new Flagsmith({
7
- environmentKey
8
- });
9
-
10
- const api = () => {
11
- const api = Router();
12
-
13
- api.get('/', async (req, res) => {
14
- const flags = await flagsmith.getEnvironmentFlags();
15
- res.json(flags);
16
- });
17
-
18
- api.get('/:user', async (req, res) => {
19
- const flags = await flagsmith.getIdentityFlags(req.params.user, { checkout_v2: 1 });
20
- const fontSize = flags.getFeatureValue('font_size');
21
- const checkoutV2 = flags.isFeatureEnabled('checkout_v2');
22
- res.json({ fontSize, checkoutV2 });
23
- });
24
-
25
- api.get('/:user/segments', async (req, res) => {
26
- const segments = await flagsmith.getIdentitySegments(req.params.user, { checkout_v2: 1 });
27
- res.json(segments.map(v => v.name));
28
- });
29
-
30
- return api;
31
- };
32
-
33
- export default api
@@ -1,29 +0,0 @@
1
- import http from 'http'
2
- import express from 'express'
3
- import bodyParser from 'body-parser'
4
- import api from './api'
5
- const PORT = process.env.PORT || 3000;
6
- const app = express();
7
-
8
- app.server = http.createServer(app);
9
-
10
- //Apply middleware
11
- // parse various different custom JSON types as JSON
12
- app.use(bodyParser.json());
13
-
14
- // api router
15
- app.use('/api', api());
16
-
17
- app.server.listen(PORT);
18
- console.log('Server started on port ' + PORT);
19
- console.log();
20
- console.log('Go to http://localhost:' + PORT + '/api');
21
- console.log('To get an example response for getFlags');
22
- console.log();
23
- console.log('Go to http://localhost:' + PORT + '/api/flagsmith_sample_user');
24
- console.log('To get an example feature state for a user');
25
- console.log();
26
- console.log('Go to http://localhost:' + PORT + '/api/flagsmith_sample_user/segments');
27
- console.log('To get the segments which the user belongs to');
28
-
29
- module.exports = app;
@@ -1,3 +0,0 @@
1
- {
2
- "presets": ["@babel/preset-env"]
3
- }
@@ -1,8 +0,0 @@
1
- {
2
- "extends": ["eslint:recommended", "prettier"],
3
- "parserOptions": {
4
- "ecmaVersion": 2018,
5
- "sourceType": "module"
6
- },
7
- "env": { "es6": true, "node": true }
8
- }
@@ -1,9 +0,0 @@
1
- <img width="100%" src="https://github.com/Flagsmith/flagsmith/raw/main/static-files/hero.png"/>
2
-
3
- # Flagsmith Node.js example with caching
4
-
5
- This is a simple Flagsmith Node.js example that uses node-cache as a way to cache flags and identities with a TTL. This can also be used with other implementations such as Redis, see [here](https://docs.flagsmith.com/v1.0/clients/node#caching-data) for more information.
6
- ```shell
7
- npm i
8
- npm run dev
9
- ```