import { verifyFormatting } from './testutil.js';
describe('tests for commands', () => {
    test('basic create constraint is unique', () => {
        const query = `create constraint for (a: Athlete) require a.id is unique`;
        const expected = `CREATE CONSTRAINT
FOR (a:Athlete)
REQUIRE a.id IS UNIQUE`;
        verifyFormatting(query, expected);
    });
    test('basic create constraint with "::"', () => {
        const query = `create constraint for (a: Athlete) require a.id :: int`;
        const expected = `CREATE CONSTRAINT
FOR (a:Athlete)
REQUIRE a.id :: INT`;
        verifyFormatting(query, expected);
    });
    test('basic create constraint with "is typed"', () => {
        const query = `create constraint for (a: Athlete) require a.id is typed int`;
        const expected = `CREATE CONSTRAINT
FOR (a:Athlete)
REQUIRE a.id IS TYPED INT`;
        verifyFormatting(query, expected);
    });
    test('basic create constraint with key', () => {
        const query = `create constraint for (a: Athlete) require a.id is key`;
        const expected = `CREATE CONSTRAINT
FOR (a:Athlete)
REQUIRE a.id IS KEY`;
        verifyFormatting(query, expected);
    });
    test('basic create constraint with not null', () => {
        const query = `create constraint for (a: Athlete) require a.id is not null`;
        const expected = `CREATE CONSTRAINT
FOR (a:Athlete)
REQUIRE a.id IS NOT NULL`;
        verifyFormatting(query, expected);
    });
    test('basic create index for on', () => {
        const query = `create index index_name for (a: Athlete) on (a.id)`;
        const expected = `CREATE INDEX index_name
FOR (a:Athlete)
ON (a.id)`;
        verifyFormatting(query, expected);
    });
    test('create index with command rel pattern', () => {
        const query = `create index relationship_index for ()-[rel:FRIENDS_WITH]-() on (rel.since, rel.status)`;
        const expected = `CREATE INDEX relationship_index
FOR ()-[rel:FRIENDS_WITH]-()
ON (rel.since, rel.status)`;
        verifyFormatting(query, expected);
    });
    test('create index on relationship with options', () => {
        const query = `create index index_name for ()-[r:RELATIONTYPE]-() on (r.since) options { indexProvider: 'range-1.0' }`;
        const expected = `
CREATE INDEX index_name
FOR ()-[r:RELATIONTYPE]-()
ON (r.since)
OPTIONS {indexProvider: 'range-1.0'}`.trimStart();
        verifyFormatting(query, expected);
    });
    test('create constraint with options', () => {
        const query = `create constraint for (a: Athlete) require a.id is unique options { constraintName: 'Athlete_Id_Unique' }`;
        const expected = `
CREATE CONSTRAINT
FOR (a:Athlete)
REQUIRE a.id IS UNIQUE
OPTIONS {constraintName: 'Athlete_Id_Unique'}`.trimStart();
        verifyFormatting(query, expected);
    });
    test('create constraint with multiple options', () => {
        const query = `create constraint for (a: Athlete) require a.id is unique options { constraintName: 'Athlete_Id_Unique', enforced: true }`;
        const expected = `
CREATE CONSTRAINT
FOR (a:Athlete)
REQUIRE a.id IS UNIQUE
OPTIONS {constraintName: 'Athlete_Id_Unique', enforced: true}`.trimStart();
        verifyFormatting(query, expected);
    });
    test('create fulltext index', () => {
        const query = `create fulltext index index_name for (a: Athlete) on each [a.name]`;
        const expected = `
CREATE FULLTEXT INDEX index_name
FOR (a:Athlete)
ON EACH [a.name]`.trimStart();
        verifyFormatting(query, expected);
    });
    test('create fulltext index with multiple bars', () => {
        const query = `create fulltext index index_name for (a: Athlete|CouchPotato|Olympian) on each [a.name]`;
        const expected = `
CREATE FULLTEXT INDEX index_name
FOR (a:Athlete|CouchPotato|Olympian)
ON EACH [a.name]`.trimStart();
        verifyFormatting(query, expected);
    });
    test('should not break after options', () => {
        const query = `CREATE CONSTRAINT aaaaaa FOR ( aaaaaa : aaaaaa ) REQUIRE ( aaaaaa . aaaaaa ) IS UNIQUE OPTIONS { aaaaaa : "20z9vakp" , aaaaaa : { aaaaaa : [ "aotV0uiw" , "SCxu0Vyn" , "ekTx6ngu" ] , aaaaaa : [ "WqAr9IvS" , "j5fYJwuN" ] , aaaaaa : [ "HUDXLCRN" , "LUfKWGc7" ] , aaaaaa : [ "qbk3JzMe" , "Ca4n1Ea9" , "I96Uwq16" ] , aaaaaa : [ "zcBcWjoJ" , "dz78begI" ] , aaaaaa : [ "MIADLwls" , "qkacQgzY" , "wYYAgiGo" ] , aaaaaa : [ "Jmw0tXjZ" , "ALiXrHno" , "QRYTGYFd" ] , aaaaaa : [ "EEJJKZGC" , "GGDt2msc" ] } }`;
        const expected = `CREATE CONSTRAINT aaaaaa
FOR (aaaaaa:aaaaaa)
REQUIRE (aaaaaa.aaaaaa) IS UNIQUE
OPTIONS {
  aaaaaa: "20z9vakp",
  aaaaaa: {
    aaaaaa: ["aotV0uiw", "SCxu0Vyn", "ekTx6ngu"],
    aaaaaa: ["WqAr9IvS", "j5fYJwuN"],
    aaaaaa: ["HUDXLCRN", "LUfKWGc7"],
    aaaaaa: ["qbk3JzMe", "Ca4n1Ea9", "I96Uwq16"],
    aaaaaa: ["zcBcWjoJ", "dz78begI"],
    aaaaaa: ["MIADLwls", "qkacQgzY", "wYYAgiGo"],
    aaaaaa: ["Jmw0tXjZ", "ALiXrHno", "QRYTGYFd"],
    aaaaaa: ["EEJJKZGC", "GGDt2msc"]
  }
}`;
        verifyFormatting(query, expected);
    });
    test('show indexes with where and return', () => {
        const query = `SHOW INDEXES
YIELD aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa
WHERE aaaaaa = "wjL0ojNI" RETURN aaaaaa, aaaaaa, aaaaaa, aaaaaa`;
        const expected = `SHOW INDEXES
YIELD aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa
WHERE aaaaaa = "wjL0ojNI"
RETURN aaaaaa, aaaaaa, aaaaaa, aaaaaa`;
        verifyFormatting(query, expected);
    });
    test('show indexes with just a where clause', () => {
        const query = `SHOW INDEXES WHERE aaaaaa = "wjL0ojNI"`;
        const expected = `SHOW INDEXES
WHERE aaaaaa = "wjL0ojNI"`;
        verifyFormatting(query, expected);
    });
    test('alter graph type - node', () => {
        const query = `Alter current graph type SET { (:Person => :Resident {name :: STRING NOT NULL}),(:Pet => :Resident&Animal {healthCertificate :: STRING, name :: STRING})}`;
        const expected = `ALTER CURRENT GRAPH TYPE SET {
  (:Person => :Resident {name :: STRING NOT NULL}),
  (:Pet => :Resident&Animal {healthCertificate :: STRING, name :: STRING})
}`;
        verifyFormatting(query, expected);
    });
    test('alter graph type - node v2', () => {
        const query = `Alter current graph type SET { (:Person => {name :: STRING NOT NULL}),(a:Pet => :Resident&Animal {healthCertificate :: STRING, name :: STRING})}`;
        const expected = `ALTER CURRENT GRAPH TYPE SET {
  (:Person => {name :: STRING NOT NULL}),
  (a:Pet => :Resident&Animal {healthCertificate :: STRING, name :: STRING})
}`;
        verifyFormatting(query, expected);
    });
    test('alter graph type - rel', () => {
        const query = `ALTER CURRENT GRAPH TYPE SET {(a:Resident)-[R:LIVES_IN => { since :: DATE NOT NULL}]->(:City)
}`;
        const expected = `ALTER CURRENT GRAPH TYPE SET {
  (a:Resident)-[R:LIVES_IN => {since :: DATE NOT NULL}]->(:City)
}`;
        verifyFormatting(query, expected);
    });
    test('alter graph type - constraint', () => {
        const query = `ALTER CURRENT GRAPH TYPE SET {  CONSTRAINT company_name FOR (c:Company) REQUIRE c.name IS KEY, CONSTRAINT animal_id FOR (a:Animal) REQUIRE a.id IS UNIQUE
}`;
        const expected = `ALTER CURRENT GRAPH TYPE SET {
  CONSTRAINT company_name FOR (c:Company)
  REQUIRE c.name IS KEY,
  CONSTRAINT animal_id FOR (a:Animal)
  REQUIRE a.id IS UNIQUE
}`;
        verifyFormatting(query, expected);
    });
});
describe('tests for vector index commands', () => {
    test('create vector index', () => {
        const query = `create vector index myIndex for (n: Label) on (n.embedding) options { indexProvider: 'vector-2.0' }`;
        const expected = `CREATE VECTOR INDEX myIndex
FOR (n:Label)
ON (n.embedding)
OPTIONS {indexProvider: 'vector-2.0'}`;
        verifyFormatting(query, expected);
    });
    test('create vector index if not exists', () => {
        const query = `create vector index myIndex if not exists for (n: Label) on (n.embedding)`;
        const expected = `CREATE VECTOR INDEX myIndex IF NOT EXISTS
FOR (n:Label)
ON (n.embedding)`;
        verifyFormatting(query, expected);
    });
    test('create vector index with options', () => {
        const query = `create vector index myIndex for (n: Label) on (n.embedding) options { indexProvider: 'vector-2.0' , dimensions: 256 }`;
        const expected = `CREATE VECTOR INDEX myIndex
FOR (n:Label)
ON (n.embedding)
OPTIONS {indexProvider: 'vector-2.0', dimensions: 256}`;
        verifyFormatting(query, expected);
    });
});
describe('tests for auth rule commands', () => {
    test('create auth rule', () => {
        const query = `create auth rule myRule set condition 1 = 1 set enabled true`;
        const expected = `CREATE AUTH RULE myRule
  SET CONDITION 1 = 1
  SET ENABLED TRUE`;
        verifyFormatting(query, expected);
    });
    test('alter auth rule', () => {
        const query = `alter auth rule myRule if exists set enabled false`;
        const expected = `ALTER AUTH RULE myRule IF EXISTS
  SET ENABLED FALSE`;
        verifyFormatting(query, expected);
    });
    test('rename auth rule', () => {
        const query = `rename auth rule myRule if exists to yourRule`;
        const expected = `RENAME AUTH RULE myRule IF EXISTS TO yourRule`;
        verifyFormatting(query, expected);
    });
    test('show auth rule', () => {
        const query = `show auth rule as commands yield name`;
        const expected = `SHOW AUTH RULE AS COMMANDS
YIELD name`;
        verifyFormatting(query, expected);
    });
});
describe('tests for create alias/create database', () => {
    test('create alias with additional info', () => {
        const query = `create  alias \`northwind-2022\` for database \`northwind-graph-2022\` at "neo4j+s://location:7687" properties {newestNorthwind:true,index:3}`;
        const expected = `CREATE ALIAS \`northwind-2022\`
FOR DATABASE \`northwind-graph-2022\`
AT "neo4j+s://location:7687"
PROPERTIES {newestNorthwind: true, index: 3}`;
        verifyFormatting(query, expected);
    });
    test('create database with additional info', () => {
        const query = `create  database neo4j if not exists set default language cypher 25 options {txLogEnrichment:Full} wait 500 sec`;
        const expected = `CREATE DATABASE neo4j IF NOT EXISTS
SET DEFAULT LANGUAGE CYPHER 25
OPTIONS {txLogEnrichment: Full}
WAIT 500 SEC`;
        verifyFormatting(query, expected);
    });
});
describe('tests for explicit newlines in commands', () => {
    test('two indexes with explicit newline inbetween', () => {
        const query = `
CREATE FULLTEXT INDEX index_name FOR (a:Athlete) ON EACH [a.name];

CREATE FULLTEXT INDEX index_name FOR (a:Athlete) ON EACH [a.id];`;
        const expected = `
CREATE FULLTEXT INDEX index_name
FOR (a:Athlete)
ON EACH [a.name];

CREATE FULLTEXT INDEX index_name
FOR (a:Athlete)
ON EACH [a.id];`.trimStart();
        verifyFormatting(query, expected);
    });
    test('two constraints with comments', () => {
        const query = `CREATE CONSTRAINT FOR (a:Athlete) REQUIRE a.id IS UNIQUE

// This is a comment and there is an explicit newline
OPTIONS {constraintName: 'Athlete_Id_Unique'}`;
        const expected = `CREATE CONSTRAINT
FOR (a:Athlete)
REQUIRE a.id IS UNIQUE

// This is a comment and there is an explicit newline
OPTIONS {constraintName: 'Athlete_Id_Unique'}`;
        verifyFormatting(query, expected);
    });
    test('OPTION should be able to have nice map print', () => {
        const query = "CREATE DATABASE testdb OPTIONS {existingData: 'use', seedURI:'s3://bucketpath', seedConfig: 'region=eu-west-1', seedCredentials: 'foo;bar'};";
        const expected = `CREATE DATABASE testdb
OPTIONS {
  existingData: 'use',
  seedURI: 's3://bucketpath',
  seedConfig: 'region=eu-west-1',
  seedCredentials: 'foo;bar'
};`;
        verifyFormatting(query, expected);
    });
});
//# sourceMappingURL=commands.test.js.map