@@ -4,10 +4,28 @@ const BOLT_PORT = 7687;
44const HTTP_PORT = 7474 ;
55const USERNAME = "neo4j" ;
66
7+ export enum Neo4jPlugin {
8+ APOC = "apoc" ,
9+ APOC_EXTENDED = "apoc-extended" ,
10+ BLOOM = "bloom" ,
11+ GEN_AI = "genai" ,
12+ GRAPHQL = "graphql" ,
13+ GRAPH_ALGORITHMS = "graph-algorithms" ,
14+ GRAPH_DATA_SCIENCE = "graph-data-science" ,
15+ NEO_SEMANTICS = "n10s" ,
16+ }
17+
18+ const pluginWhitelists : Partial < Record < Neo4jPlugin , string > > = {
19+ [ Neo4jPlugin . APOC ] : "apoc.*" ,
20+ [ Neo4jPlugin . APOC_EXTENDED ] : "apoc.*" ,
21+ [ Neo4jPlugin . BLOOM ] : "bloom.*" ,
22+ [ Neo4jPlugin . GRAPH_DATA_SCIENCE ] : "gds.*" ,
23+ } ;
24+
725export class Neo4jContainer extends GenericContainer {
826 private password = "pass123!@#WORD" ;
9- private apoc = false ;
1027 private ttl ?: number ;
28+ private plugins : Neo4jPlugin [ ] = [ ] ;
1129
1230 constructor ( image = "neo4j:4.4.12" ) {
1331 super ( image ) ;
@@ -23,11 +41,12 @@ export class Neo4jContainer extends GenericContainer {
2341 }
2442
2543 public withApoc ( ) : this {
26- this . apoc = true ;
27- this . withEnvironment ( {
28- NEO4JLABS_PLUGINS : '["apoc"]' ,
29- NEO4J_dbms_security_procedures_unrestricted : "apoc.*" ,
30- } ) ;
44+ this . plugins . push ( Neo4jPlugin . APOC ) ;
45+ return this ;
46+ }
47+
48+ public withPlugins ( plugins : Neo4jPlugin [ ] ) : this {
49+ this . plugins = plugins ;
3150 return this ;
3251 }
3352
@@ -44,10 +63,18 @@ export class Neo4jContainer extends GenericContainer {
4463 NEO4J_apoc_ttl_schedule : this . ttl . toString ( ) ,
4564 } ) ;
4665 }
47- if ( this . apoc ) {
66+
67+ if ( this . plugins . length > 0 ) {
68+ const whitelists : string = this . plugins
69+ . map ( ( plugin ) => ( plugin in pluginWhitelists ? pluginWhitelists [ plugin ] : null ) )
70+ . filter ( ( whitelisted ) => whitelisted !== null )
71+ . join ( "," ) ;
72+
4873 this . withEnvironment ( {
49- NEO4JLABS_PLUGINS : '["apoc"]' ,
50- NEO4J_dbms_security_procedures_unrestricted : "apoc.*" ,
74+ NEO4JLABS_PLUGINS : JSON . stringify ( this . plugins ) , // Older variant for older images.
75+ NEO4J_PLUGINS : JSON . stringify ( this . plugins ) ,
76+ NEO4J_dbms_security_procedures_unrestricted : whitelists ,
77+ NEO4J_dbms_security_procedures_whitelist : whitelists ,
5178 } ) ;
5279 }
5380 return new StartedNeo4jContainer ( await super . start ( ) , this . password ) ;
0 commit comments