Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d2l-lms-launch-darkly-feature-converter-plugin

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d2l-lms-launch-darkly-feature-converter-plugin - npm Package Compare versions

Comparing version 0.16.0 to 0.17.0

schemas/org-boolean/v3_2.json

2

package.json
{
"name": "d2l-lms-launch-darkly-feature-converter-plugin",
"version": "0.16.0",
"version": "0.17.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -47,2 +47,3 @@ const _ = require( 'lodash' );

const orgBooleanSchemaV3_0 = require( '../schemas/org-boolean/v3_0.json' );
const orgBooleanSchemaV3_2 = require( '../schemas/org-boolean/v3_2.json' );

@@ -55,2 +56,3 @@ const orgMultivariateSchemaV1_0 = require( '../schemas/org-multivariate/v1_0.json' );

const orgMultivariateSchemaV3_1 = require( '../schemas/org-multivariate/v3_1.json' );
const orgMultivariateSchemaV3_2 = require( '../schemas/org-multivariate/v3_2.json' );

@@ -90,3 +92,3 @@ const booleanFeatureKind = 'boolean';

const orgTargetsMapper = new OrgTargetsMapper( instanceCatalog );
const orgRulesMapper = new OrgRulesMapper();
const orgRulesMapper = new OrgRulesMapper( instanceCatalog );
const orgEnvironmentMapper = new EnvironmentMapper( orgTargetsMapper, orgRulesMapper );

@@ -155,3 +157,4 @@

orgBooleanSchemaV1_2,
orgBooleanSchemaV3_0
orgBooleanSchemaV3_0,
orgBooleanSchemaV3_2
] ),

@@ -171,3 +174,4 @@ booleanVariationMapper,

orgMultivariateSchemaV3_0,
orgMultivariateSchemaV3_1
orgMultivariateSchemaV3_1,
orgMultivariateSchemaV3_2
] ),

@@ -174,0 +178,0 @@ multiVariationMapper,

const _ = require( 'lodash' );
const duplicatesDeep = require( '../utils.js' ).duplicatesDeep;
const instanceTypeMapper = require( '../instanceTypeMapper' );
const sortableVersionRangeParser = require( '../sortableVersionRangeParser.js' );
function* mapClauses( definition ) {
function* mapClauses( definition, instanceCatalog ) {

@@ -66,2 +67,38 @@ if( definition.awsRegions ) {

}
const tenantDomains = definition.tenantDomains;
if( tenantDomains ) {
if( !versions ) {
throw new Error( 'Tenants can only be targetted in rules for specific versions' );
}
const implicitTenantIds = _.map(
tenantDomains || [],
tenantDomain => instanceCatalog.mapTenantDomain( tenantDomain )
);
const uniqueTenantIds = _.orderBy(
_.uniq( implicitTenantIds )
);
if( implicitTenantIds.length !== uniqueTenantIds.length ) {
const duplicates = _.orderBy(
duplicatesDeep( [
implicitTenantIds
] )
);
const duplicatesStr = _.join( duplicates, ', ' );
throw new Error( `Tenant domains are duplicated in rule: ${duplicatesStr}` );
}
yield {
attribute: 'key',
op: 'in',
values: uniqueTenantIds,
negate: false
};
}
}

@@ -71,5 +108,9 @@

constructor( instanceCatalog ) {
this._instanceCatalog = instanceCatalog;
}
mapRule( definition, variationIndexMap ) {
const clauses = Array.from( mapClauses( definition ) );
const clauses = Array.from( mapClauses( definition, this._instanceCatalog ) );
const variation = variationIndexMap.getIndex( definition.variation );

@@ -76,0 +117,0 @@

const _ = require( 'lodash' );
const assert = require( 'chai' ).assert;
const convertersPlugin = require( '../src/index.js' );
const formatFileUrl = require( 'file-url' );
const fsUtil = require( 'fs' );
const pathUtil = require( 'path' );
describe( 'EndToEndTests', function() {

@@ -13,2 +15,6 @@

const path = pathUtil.join( __dirname, 'instanceCatalog.json' );
const fileUrl = formatFileUrl( path );
process.env.D2L_LMS_INSTANCE_CATALOG_SOURCE = fileUrl;
const options = {};

@@ -18,2 +24,3 @@ convertersPlugin( options, ( err, converters ) => {

if( err ) {
delete process.env.D2L_LMS_INSTANCE_CATALOG_SOURCE;
return done( err );

@@ -28,2 +35,3 @@ }

delete process.env.D2L_LMS_INSTANCE_CATALOG_SOURCE;
return done();

@@ -30,0 +38,0 @@ } );

const assert = require( 'chai' ).assert;
const InstanceCatalog = require( '../src/instanceCatalog/InstanceCatalog.js' );
const OrgRulesMapper = require( '../src/org/OrgRulesMapper.js' );
const VariationIndexMap = require( '../src/variations/VariationIndexMap.js' );
const mapper = new OrgRulesMapper();
const instanceCatalog = new InstanceCatalog(
new Map(),
new Map( [
[ 'www.tenant_a.org', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' ],
[ 'www.tenant_c.org', 'cccccccc-cccc-cccc-cccc-cccccccccccc' ]
] )
);
const mapper = new OrgRulesMapper( instanceCatalog );
const variationIndexMap = new VariationIndexMap( { abc: 2 } );

@@ -233,2 +242,100 @@

} );
it( 'should map tenant domains for specific version start', function() {
const definition = {
versions: {
start: '10.8.4.12345'
},
tenantDomains: [
'www.tenant_a.org',
'www.tenant_c.org'
],
variation: 'abc'
};
const rule = mapper.mapRule( definition, variationIndexMap );
assert.deepEqual( rule, {
clauses: [
{
attribute: 'productVersion',
op: 'greaterThanOrEqual',
values: [
10080412345
],
negate: false
},
{
attribute: 'key',
op: 'in',
values: [
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'cccccccc-cccc-cccc-cccc-cccccccccccc'
],
negate: false
}
],
variation: 2
} );
} );
it( 'should throw if unknown tenant domain', function() {
const definition = {
versions: {
start: '10.8.4.12345'
},
tenantDomains: [
'www.tenant_b.org'
],
variation: 'abc'
};
assert.throws(
() => {
mapper.mapRule( definition, variationIndexMap );
},
/^Unknown tenant domain: www.tenant_b.org$/
);
} );
it( 'should throw if tenant domains duplicated', function() {
const definition = {
versions: {
start: '10.8.4.12345'
},
tenantDomains: [
'www.tenant_a.org',
'www.tenant_a.org'
],
variation: 'abc'
};
assert.throws(
() => {
mapper.mapRule( definition, variationIndexMap );
},
/^Tenant domains are duplicated in rule: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa$/
);
} );
it( 'should throw if tenant domains defined without versions', function() {
const definition = {
tenantDomains: [
'www.tenant_a.org'
],
variation: 'abc'
};
assert.throws(
() => {
mapper.mapRule( definition, variationIndexMap );
},
/^Tenants can only be targetted in rules for specific versions$/
);
} );
} );
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc