@pubtech-ai/testing 2.8.1 → 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.
@@ -1,6 +1,7 @@
1
- import { TCModel } from '@pubtech-ai/core';
1
+ import { TCModel, GVL } from '@pubtech-ai/core';
2
2
  export declare class TCModelFactory {
3
- static noGVL(tcModel?: TCModel): TCModel;
4
- static addPublisherRestrictions(tcModel: TCModel): TCModel;
5
- static withGVL(): TCModel;
3
+ static noGVL(gvl?: GVL): TCModel;
4
+ private static createBaseTCModel;
5
+ static addPublisherRestrictions(tcModel: TCModel, gvl?: GVL): TCModel;
6
+ static withGVL(gvl?: GVL): TCModel;
6
7
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TCModelFactory=void 0;var core_1=require("@pubtech-ai/core"),makeRandomInt_js_1=require("./makeRandomInt.js"),GVLFactory_js_1=require("./GVLFactory.js"),TCModelFactory=function(){function e(){}return e.noGVL=function(e){var n=GVLFactory_js_1.GVLFactory.getLatest();e||(e=new core_1.TCModel),e.cmpId=(0,makeRandomInt_js_1.makeRandomInt)(2,100),e.cmpVersion=(0,makeRandomInt_js_1.makeRandomInt)(1,10),e.consentScreen=(0,makeRandomInt_js_1.makeRandomInt)(1,5),e.isServiceSpecific=!!(0,makeRandomInt_js_1.makeRandomInt)(0,1),e.vendorListVersion=(0,makeRandomInt_js_1.makeRandomInt)(1,n.vendorListVersion);var t=0,o=(0,makeRandomInt_js_1.makeRandomInt)(1,core_1.TCModel.consentLanguages.size);core_1.TCModel.consentLanguages.forEach((function(n){++t===o&&(e.consentLanguage=n)})),e.publisherCountryCode=String.fromCharCode((0,makeRandomInt_js_1.makeRandomInt)(65,90))+String.fromCharCode((0,makeRandomInt_js_1.makeRandomInt)(65,90));var a=new Date,r=new Date(Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate())).getTime();e.created=new Date((0,makeRandomInt_js_1.makeRandomInt)(1576883249,r)),e.lastUpdated=new Date((0,makeRandomInt_js_1.makeRandomInt)(1576883249,r));var s={purposes:["publisherConsents","publisherLegitimateInterests","purposeConsents","purposeLegitimateInterests"],specialFeatures:["specialFeatureOptins"],vendors:["vendorConsents","vendorLegitimateInterests","vendorsAllowed","vendorsDisclosed"]};return Object.keys(s).forEach((function(t){Object.keys(n[t]).map((function(e){return+e})).forEach((function(n){s[t].forEach((function(t){3!==(0,makeRandomInt_js_1.makeRandomInt)(1,4)&&e[t].set(n)}))}))})),e},e.addPublisherRestrictions=function(e){return e.gvl||(e.gvl=GVLFactory_js_1.GVLFactory.getLatest()),Object.keys(e.gvl.vendors).forEach((function(n){var t=e.gvl.vendors[n];if(t.flexiblePurposes.length){var o=t.flexiblePurposes[(0,makeRandomInt_js_1.makeRandomInt)(0,t.flexiblePurposes.length-1)],a=t.purposes.includes(o),r=void 0;r=1===(0,makeRandomInt_js_1.makeRandomInt)(0,1)?new core_1.PurposeRestriction(o,core_1.RestrictionType.NOT_ALLOWED):a?new core_1.PurposeRestriction(o,core_1.RestrictionType.REQUIRE_LI):new core_1.PurposeRestriction(o,core_1.RestrictionType.REQUIRE_CONSENT),e.publisherRestrictions.add(+n,r)}})),e},e.withGVL=function(){var e=this.noGVL();return e.gvl=GVLFactory_js_1.GVLFactory.getLatest(),e},e}();exports.TCModelFactory=TCModelFactory;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TCModelFactory=void 0;var core_1=require("@pubtech-ai/core"),makeRandomInt_js_1=require("./makeRandomInt.js"),GVLFactory_js_1=require("./GVLFactory.js"),TCModelFactory=function(){function e(){}return e.noGVL=function(e){return this.createBaseTCModel(e)},e.createBaseTCModel=function(e){var n=e||GVLFactory_js_1.GVLFactory.getLatest(),t=new core_1.TCModel;t.cmpId=(0,makeRandomInt_js_1.makeRandomInt)(2,100),t.cmpVersion=(0,makeRandomInt_js_1.makeRandomInt)(1,10),t.consentScreen=(0,makeRandomInt_js_1.makeRandomInt)(1,5),t.isServiceSpecific=!!(0,makeRandomInt_js_1.makeRandomInt)(0,1),t.vendorListVersion=(0,makeRandomInt_js_1.makeRandomInt)(1,n.vendorListVersion);var o=0,a=(0,makeRandomInt_js_1.makeRandomInt)(1,core_1.TCModel.consentLanguages.size);core_1.TCModel.consentLanguages.forEach((function(e){++o===a&&(t.consentLanguage=e)})),t.publisherCountryCode=String.fromCharCode((0,makeRandomInt_js_1.makeRandomInt)(65,90))+String.fromCharCode((0,makeRandomInt_js_1.makeRandomInt)(65,90));var r=new Date,s=new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate())).getTime();t.created=new Date((0,makeRandomInt_js_1.makeRandomInt)(1576883249,s)),t.lastUpdated=new Date((0,makeRandomInt_js_1.makeRandomInt)(1576883249,s));var c={purposes:["publisherConsents","publisherLegitimateInterests","purposeConsents","purposeLegitimateInterests"],specialFeatures:["specialFeatureOptins"],vendors:["vendorConsents","vendorLegitimateInterests","vendorsAllowed","vendorsDisclosed"]};return Object.keys(c).forEach((function(e){Object.keys(n[e]).map((function(e){return+e})).forEach((function(n){c[e].forEach((function(e){3!==(0,makeRandomInt_js_1.makeRandomInt)(1,4)&&t[e].set(n)}))}))})),t},e.addPublisherRestrictions=function(e,n){return e.gvl||(e.gvl=n||GVLFactory_js_1.GVLFactory.getLatest()),Object.keys(e.gvl.vendors).forEach((function(n){var t=e.gvl.vendors[n];if(t.flexiblePurposes.length){var o=t.flexiblePurposes[(0,makeRandomInt_js_1.makeRandomInt)(0,t.flexiblePurposes.length-1)],a=t.purposes.includes(o),r=void 0;r=1===(0,makeRandomInt_js_1.makeRandomInt)(0,1)?new core_1.PurposeRestriction(o,core_1.RestrictionType.NOT_ALLOWED):a?new core_1.PurposeRestriction(o,core_1.RestrictionType.REQUIRE_LI):new core_1.PurposeRestriction(o,core_1.RestrictionType.REQUIRE_CONSENT),e.publisherRestrictions.add(+n,r)}})),e},e.withGVL=function(e){var n=this.createBaseTCModel(e);return n.gvl=e||GVLFactory_js_1.GVLFactory.getLatest(),n},e}();exports.TCModelFactory=TCModelFactory;