d2l-lms-launch-darkly-feature-converter-plugin
Advanced tools
Comparing version 0.5.0 to 0.6.0
{ | ||
"name": "d2l-lms-launch-darkly-feature-converter-plugin", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -18,6 +18,12 @@ const _ = require( 'lodash' ); | ||
const instanceBooleanSchemaV1_0 = require( '../schemas/instance-boolean/v1_0.json' ); | ||
const instanceBooleanSchemaV1_1 = require( '../schemas/instance-boolean/v1_1.json' ); | ||
const instanceMultivariateSchemaV1_0 = require( '../schemas/instance-multivariate/v1_0.json' ); | ||
const instanceMultivariateSchemaV1_1 = require( '../schemas/instance-multivariate/v1_1.json' ); | ||
const orgBooleanSchemaV1_0 = require( '../schemas/org-boolean/v1_0.json' ); | ||
const orgBooleanSchemaV1_1 = require( '../schemas/org-boolean/v1_1.json' ); | ||
const orgMultivariateSchemaV1_0 = require( '../schemas/org-multivariate/v1_0.json' ); | ||
const orgMultivariateSchemaV1_1 = require( '../schemas/org-multivariate/v1_1.json' ); | ||
@@ -58,3 +64,4 @@ const booleanFeatureKind = 'boolean'; | ||
createSchemaValiators( [ | ||
instanceBooleanSchemaV1_0 | ||
instanceBooleanSchemaV1_0, | ||
instanceBooleanSchemaV1_1 | ||
] ), | ||
@@ -69,3 +76,4 @@ booleanVariationMapper, | ||
createSchemaValiators( [ | ||
instanceMultivariateSchemaV1_0 | ||
instanceMultivariateSchemaV1_0, | ||
instanceMultivariateSchemaV1_1 | ||
] ), | ||
@@ -80,3 +88,4 @@ multiVariationMapper, | ||
createSchemaValiators( [ | ||
orgBooleanSchemaV1_0 | ||
orgBooleanSchemaV1_0, | ||
orgBooleanSchemaV1_1 | ||
] ), | ||
@@ -91,3 +100,4 @@ booleanVariationMapper, | ||
createSchemaValiators( [ | ||
orgMultivariateSchemaV1_0 | ||
orgMultivariateSchemaV1_0, | ||
orgMultivariateSchemaV1_1 | ||
] ), | ||
@@ -94,0 +104,0 @@ multiVariationMapper, |
const _ = require( 'lodash' ); | ||
const anyIntersections = require( '../utils.js' ).anyIntersections; | ||
@@ -20,4 +21,20 @@ module.exports = class InstanceTargetsMapper { | ||
const allInstanceIds = _.concat( implicitInstanceIds, explicitInstanceIds ); | ||
const mixedExplicitInstanceIds = _.map( | ||
definition.instances || [], | ||
instance => { | ||
if( _.isString( instance ) ) { | ||
return instance; | ||
} | ||
return instance.instanceId; | ||
} | ||
); | ||
const allInstanceIds = _.concat( | ||
implicitInstanceIds, | ||
explicitInstanceIds, | ||
mixedExplicitInstanceIds | ||
); | ||
const uniqueInstanceIds = _.orderBy( | ||
@@ -30,3 +47,7 @@ _.uniq( allInstanceIds ) | ||
const duplicates = _.orderBy( | ||
_.intersection( implicitInstanceIds, explicitInstanceIds ) | ||
anyIntersections( | ||
implicitInstanceIds, | ||
explicitInstanceIds, | ||
mixedExplicitInstanceIds | ||
) | ||
); | ||
@@ -33,0 +54,0 @@ |
const _ = require( 'lodash' ); | ||
const anyIntersections = require( '../utils.js' ).anyIntersections; | ||
@@ -20,4 +21,20 @@ module.exports = class OrgTargetsMapper { | ||
const allTenantIds = _.concat( implicitTenantIds, explicitTenantIds ); | ||
const mixedExplicitTenantIds = _.map( | ||
definition.tenants || [], | ||
tenant => { | ||
if( _.isString( tenant ) ) { | ||
return tenant; | ||
} | ||
return tenant.tenantId; | ||
} | ||
); | ||
const allTenantIds = _.concat( | ||
implicitTenantIds, | ||
explicitTenantIds, | ||
mixedExplicitTenantIds | ||
); | ||
const uniqueTenantIds = _.orderBy( | ||
@@ -29,3 +46,10 @@ _.uniq( allTenantIds ) | ||
const duplicates = _.intersection( implicitTenantIds, explicitTenantIds ); | ||
const duplicates = _.orderBy( | ||
anyIntersections( | ||
implicitTenantIds, | ||
explicitTenantIds, | ||
mixedExplicitTenantIds | ||
) | ||
); | ||
const duplicatesStr = _.join( duplicates, ', ' ); | ||
@@ -32,0 +56,0 @@ throw new Error( `Tenants are duplicated: ${duplicatesStr}` ); |
@@ -61,2 +61,74 @@ const assert = require( 'chai' ).assert; | ||
it( 'should map instances (strings)', function() { | ||
const definition = { | ||
instances: [ | ||
'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', | ||
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' | ||
], | ||
variation: 'abc' | ||
}; | ||
const target = mapper.mapTarget( definition, variationIndexMap ); | ||
assert.deepEqual( target, { | ||
values: [ | ||
'instance:aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', | ||
'instance:bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb' | ||
], | ||
variation: 2 | ||
} ); | ||
} ); | ||
it( 'should map instances (objects)', function() { | ||
const definition = { | ||
instances: [ | ||
{ | ||
instanceId: 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', | ||
comments: 'bbb' | ||
}, | ||
{ | ||
instanceId: 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', | ||
comments: 'aaa' | ||
} | ||
], | ||
variation: 'abc' | ||
}; | ||
const target = mapper.mapTarget( definition, variationIndexMap ); | ||
assert.deepEqual( target, { | ||
values: [ | ||
'instance:aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', | ||
'instance:bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb' | ||
], | ||
variation: 2 | ||
} ); | ||
} ); | ||
it( 'should map instances (mixed)', function() { | ||
const definition = { | ||
instances: [ | ||
{ | ||
instanceId: 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', | ||
comments: 'bbb' | ||
}, | ||
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' | ||
], | ||
variation: 'abc' | ||
}; | ||
const target = mapper.mapTarget( definition, variationIndexMap ); | ||
assert.deepEqual( target, { | ||
values: [ | ||
'instance:aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', | ||
'instance:bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb' | ||
], | ||
variation: 2 | ||
} ); | ||
} ); | ||
it( 'should merge instance ids & instance names', function() { | ||
@@ -124,2 +196,48 @@ | ||
} ); | ||
it( 'should throw if multiple instances defined both by instance and name', function() { | ||
const definition = { | ||
instances: [ | ||
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', | ||
'cccccccc-cccc-cccc-cccc-cccccccccccc' | ||
], | ||
instanceNames: [ | ||
'instance_c', | ||
'instance_a' | ||
], | ||
variation: 'abc' | ||
}; | ||
assert.throws( | ||
() => mapper.mapTarget( definition, variationIndexMap ), | ||
/Instances are duplicated: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa, cccccccc-cccc-cccc-cccc-cccccccccccc/ | ||
); | ||
} ); | ||
it( 'should throw if multiple instances defined both by instance and id', function() { | ||
const definition = { | ||
instanceIds: [ | ||
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', | ||
'cccccccc-cccc-cccc-cccc-cccccccccccc' | ||
], | ||
instances: [ | ||
{ | ||
instanceId: 'cccccccc-cccc-cccc-cccc-cccccccccccc', | ||
comments: 'ccc' | ||
}, | ||
{ | ||
instanceId: 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', | ||
comments: 'aaa' | ||
} | ||
], | ||
variation: 'abc' | ||
}; | ||
assert.throws( | ||
() => mapper.mapTarget( definition, variationIndexMap ), | ||
/Instances are duplicated: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa, cccccccc-cccc-cccc-cccc-cccccccccccc/ | ||
); | ||
} ); | ||
} ); |
@@ -61,2 +61,74 @@ const assert = require( 'chai' ).assert; | ||
it( 'should map tenants (strings)', function() { | ||
const definition = { | ||
tenants: [ | ||
'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', | ||
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' | ||
], | ||
variation: 'abc' | ||
}; | ||
const target = mapper.mapTarget( definition, variationIndexMap ); | ||
assert.deepEqual( target, { | ||
values: [ | ||
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', | ||
'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb' | ||
], | ||
variation: 2 | ||
} ); | ||
} ); | ||
it( 'should map tenants (objects)', function() { | ||
const definition = { | ||
tenants: [ | ||
{ | ||
tenantId: 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', | ||
comments: 'bbb' | ||
}, | ||
{ | ||
tenantId: 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', | ||
comments: 'aaa' | ||
} | ||
], | ||
variation: 'abc' | ||
}; | ||
const target = mapper.mapTarget( definition, variationIndexMap ); | ||
assert.deepEqual( target, { | ||
values: [ | ||
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', | ||
'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb' | ||
], | ||
variation: 2 | ||
} ); | ||
} ); | ||
it( 'should map tenants (mixed)', function() { | ||
const definition = { | ||
tenants: [ | ||
{ | ||
tenantId: 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', | ||
comments: 'bbb' | ||
}, | ||
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' | ||
], | ||
variation: 'abc' | ||
}; | ||
const target = mapper.mapTarget( definition, variationIndexMap ); | ||
assert.deepEqual( target, { | ||
values: [ | ||
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', | ||
'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb' | ||
], | ||
variation: 2 | ||
} ); | ||
} ); | ||
it( 'should merge tenant ids & tenant domains', function() { | ||
@@ -105,3 +177,3 @@ | ||
it( 'should throw if multiple instances defined both by id and name', function() { | ||
it( 'should throw if multiple tenants defined both by id and name', function() { | ||
@@ -125,2 +197,48 @@ const definition = { | ||
} ); | ||
it( 'should throw if multiple tenants defined both by tenant and name', function() { | ||
const definition = { | ||
tenants: [ | ||
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', | ||
'cccccccc-cccc-cccc-cccc-cccccccccccc' | ||
], | ||
tenantDomains: [ | ||
'www.tenant_a.org', | ||
'www.tenant_c.org' | ||
], | ||
variation: 'abc' | ||
}; | ||
assert.throws( | ||
() => mapper.mapTarget( definition, variationIndexMap ), | ||
/Tenants are duplicated: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa, cccccccc-cccc-cccc-cccc-cccccccccccc/ | ||
); | ||
} ); | ||
it( 'should throw if multiple tenants defined both by tenant and id', function() { | ||
const definition = { | ||
tenantIds: [ | ||
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', | ||
'cccccccc-cccc-cccc-cccc-cccccccccccc' | ||
], | ||
tenants: [ | ||
{ | ||
tenantId: 'cccccccc-cccc-cccc-cccc-cccccccccccc', | ||
comments: 'ccc' | ||
}, | ||
{ | ||
tenantId: 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', | ||
comments: 'aaa' | ||
} | ||
], | ||
variation: 'abc' | ||
}; | ||
assert.throws( | ||
() => mapper.mapTarget( definition, variationIndexMap ), | ||
/Tenants are duplicated: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa, cccccccc-cccc-cccc-cccc-cccccccccccc/ | ||
); | ||
} ); | ||
} ); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
108395
48
4433