@splitsoftware/splitio-commons 1.2.1-rc.9 → 1.3.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 (69) hide show
  1. package/CHANGES.txt +14 -0
  2. package/cjs/{utils/consent.js → consent/index.js} +1 -1
  3. package/cjs/consent/sdkUserConsent.js +58 -0
  4. package/cjs/listeners/browser.js +1 -1
  5. package/cjs/logger/constants.js +3 -2
  6. package/cjs/logger/messages/info.js +1 -0
  7. package/cjs/sdkClient/sdkClient.js +3 -3
  8. package/cjs/sdkClient/sdkClientMethodCS.js +3 -5
  9. package/cjs/sdkClient/sdkClientMethodCSWithTT.js +3 -5
  10. package/cjs/sdkFactory/index.js +3 -2
  11. package/cjs/sync/syncManagerOnline.js +1 -1
  12. package/cjs/utils/inputValidation/attributes.js +1 -1
  13. package/cjs/utils/lang/index.js +4 -2
  14. package/cjs/utils/settingsValidation/index.js +8 -6
  15. package/esm/{utils/consent.js → consent/index.js} +1 -1
  16. package/esm/consent/sdkUserConsent.js +54 -0
  17. package/esm/listeners/browser.js +1 -1
  18. package/esm/logger/constants.js +1 -0
  19. package/esm/logger/messages/info.js +1 -0
  20. package/esm/sdkClient/sdkClient.js +3 -3
  21. package/esm/sdkClient/sdkClientMethodCS.js +3 -5
  22. package/esm/sdkClient/sdkClientMethodCSWithTT.js +3 -5
  23. package/esm/sdkFactory/index.js +3 -2
  24. package/esm/sync/syncManagerOnline.js +1 -1
  25. package/esm/utils/inputValidation/attributes.js +1 -1
  26. package/esm/utils/lang/index.js +4 -2
  27. package/esm/utils/settingsValidation/index.js +8 -6
  28. package/package.json +1 -1
  29. package/src/{utils/consent.ts → consent/index.ts} +1 -1
  30. package/src/consent/sdkUserConsent.ts +58 -0
  31. package/src/evaluator/parser/index.ts +1 -1
  32. package/src/evaluator/types.ts +2 -2
  33. package/src/evaluator/value/index.ts +2 -2
  34. package/src/evaluator/value/sanitize.ts +2 -2
  35. package/src/listeners/browser.ts +1 -1
  36. package/src/logger/constants.ts +1 -0
  37. package/src/logger/messages/info.ts +1 -0
  38. package/src/sdkClient/client.ts +2 -3
  39. package/src/sdkClient/sdkClient.ts +4 -4
  40. package/src/sdkClient/sdkClientMethod.ts +2 -2
  41. package/src/sdkClient/sdkClientMethodCS.ts +4 -5
  42. package/src/sdkClient/sdkClientMethodCSWithTT.ts +4 -5
  43. package/src/sdkFactory/index.ts +3 -2
  44. package/src/sdkFactory/types.ts +13 -3
  45. package/src/sync/syncManagerOnline.ts +1 -1
  46. package/src/utils/inputValidation/attributes.ts +1 -2
  47. package/src/utils/lang/index.ts +7 -3
  48. package/src/utils/settingsValidation/index.ts +8 -6
  49. package/src/utils/settingsValidation/types.ts +4 -2
  50. package/types/consent/index.d.ts +2 -0
  51. package/types/consent/sdkUserConsent.d.ts +13 -0
  52. package/types/evaluator/types.d.ts +2 -2
  53. package/types/evaluator/value/index.d.ts +1 -1
  54. package/types/evaluator/value/sanitize.d.ts +1 -1
  55. package/types/logger/constants.d.ts +1 -0
  56. package/types/sdkClient/client.d.ts +2 -2
  57. package/types/sdkClient/sdkClient.d.ts +2 -2
  58. package/types/sdkClient/sdkClientMethod.d.ts +2 -2
  59. package/types/sdkClient/sdkClientMethodCS.d.ts +2 -2
  60. package/types/sdkClient/sdkClientMethodCSWithTT.d.ts +2 -2
  61. package/types/sdkFactory/types.d.ts +12 -3
  62. package/types/utils/lang/index.d.ts +2 -1
  63. package/types/utils/settingsValidation/types.d.ts +4 -2
  64. package/cjs/sdkClient/types.js +0 -2
  65. package/cjs/sdkFactory/userConsentProps.js +0 -37
  66. package/esm/sdkClient/types.js +0 -1
  67. package/esm/sdkFactory/userConsentProps.js +0 -33
  68. package/src/sdkClient/types.ts +0 -21
  69. package/src/sdkFactory/userConsentProps.ts +0 -40
@@ -1,33 +0,0 @@
1
- import { ERROR_NOT_BOOLEAN, USER_CONSENT_UPDATED, USER_CONSENT_NOT_UPDATED } from '../logger/constants';
2
- import { CONSENT_GRANTED, CONSENT_DECLINED } from '../utils/constants';
3
- import { isBoolean } from '../utils/lang';
4
- // Extend client-side factory instances with user consent getter/setter
5
- export function userConsentProps(settings, syncManager) {
6
- var log = settings.log;
7
- return {
8
- setUserConsent: function (consent) {
9
- var _a, _b;
10
- // validate input param
11
- if (!isBoolean(consent)) {
12
- log.warn(ERROR_NOT_BOOLEAN, ['setUserConsent']);
13
- return false;
14
- }
15
- var newConsentStatus = consent ? CONSENT_GRANTED : CONSENT_DECLINED;
16
- if (settings.userConsent !== newConsentStatus) { // @ts-ignore, modify readonly prop
17
- settings.userConsent = newConsentStatus;
18
- if (consent)
19
- (_a = syncManager === null || syncManager === void 0 ? void 0 : syncManager.submitter) === null || _a === void 0 ? void 0 : _a.start(); // resumes submitters if transitioning to GRANTED
20
- else
21
- (_b = syncManager === null || syncManager === void 0 ? void 0 : syncManager.submitter) === null || _b === void 0 ? void 0 : _b.stop(); // pauses submitters if transitioning to DECLINED
22
- log.info(USER_CONSENT_UPDATED, [settings.userConsent, newConsentStatus]);
23
- }
24
- else {
25
- log.info(USER_CONSENT_NOT_UPDATED, [newConsentStatus]);
26
- }
27
- return true;
28
- },
29
- getUserConsent: function () {
30
- return settings.userConsent;
31
- }
32
- };
33
- }
@@ -1,21 +0,0 @@
1
- import { ISignalListener } from '../listeners/types';
2
- import { ISdkReadinessManager } from '../readiness/types';
3
- import { IStorageAsync, IStorageSync } from '../storages/types';
4
- import { ISyncManager } from '../sync/types';
5
- import { IEventTracker, IImpressionsTracker } from '../trackers/types';
6
- import { ISettings } from '../types';
7
-
8
- export interface IClientFactoryParams {
9
- storage: IStorageSync | IStorageAsync,
10
- sdkReadinessManager: ISdkReadinessManager,
11
- settings: ISettings
12
- impressionsTracker: IImpressionsTracker,
13
- eventTracker: IEventTracker,
14
- // @TODO add time tracker and metricCollectors (a.k.a metricTracker)?
15
- }
16
-
17
- export interface ISdkClientFactoryParams extends IClientFactoryParams {
18
- signalListener?: ISignalListener
19
- syncManager?: ISyncManager,
20
- sharedClient?: boolean
21
- }
@@ -1,40 +0,0 @@
1
- import { ERROR_NOT_BOOLEAN, USER_CONSENT_UPDATED, USER_CONSENT_NOT_UPDATED } from '../logger/constants';
2
- import { ISyncManager } from '../sync/types';
3
- import { ISettings } from '../types';
4
- import { CONSENT_GRANTED, CONSENT_DECLINED } from '../utils/constants';
5
- import { isBoolean } from '../utils/lang';
6
-
7
- // Extend client-side factory instances with user consent getter/setter
8
- export function userConsentProps(settings: ISettings, syncManager?: ISyncManager) {
9
-
10
- const log = settings.log;
11
-
12
- return {
13
- setUserConsent(consent: unknown) {
14
- // validate input param
15
- if (!isBoolean(consent)) {
16
- log.warn(ERROR_NOT_BOOLEAN, ['setUserConsent']);
17
- return false;
18
- }
19
-
20
- const newConsentStatus = consent ? CONSENT_GRANTED : CONSENT_DECLINED;
21
-
22
- if (settings.userConsent !== newConsentStatus) { // @ts-ignore, modify readonly prop
23
- settings.userConsent = newConsentStatus;
24
-
25
- if (consent) syncManager?.submitter?.start(); // resumes submitters if transitioning to GRANTED
26
- else syncManager?.submitter?.stop(); // pauses submitters if transitioning to DECLINED
27
-
28
- log.info(USER_CONSENT_UPDATED, [settings.userConsent, newConsentStatus]);
29
- } else {
30
- log.info(USER_CONSENT_NOT_UPDATED, [newConsentStatus]);
31
- }
32
-
33
- return true;
34
- },
35
-
36
- getUserConsent() {
37
- return settings.userConsent;
38
- }
39
- };
40
- }