diff --git a/src/CreateTableAsSelect.test.ts b/src/CreateTableAsSelect.test.ts index d12e42e..2f5fecf 100644 --- a/src/CreateTableAsSelect.test.ts +++ b/src/CreateTableAsSelect.test.ts @@ -1,8 +1,7 @@ -import { CreateTableAsSelect } from "./CreateTableAsSelect"; import { Cond } from "./Condition"; import { Q } from "./Query"; import { MySQLFlavor } from "./flavors/mysql"; -import { MetadataOperationType } from "./interfaces"; +import { IMetadataOperationType } from "./interfaces"; describe("CreateTableAsSelect", () => { const initialSelectQuery = Q.select() @@ -43,7 +42,7 @@ describe("CreateTableAsSelect", () => { it("should return correct operation type", () => { const ctas = Q.createTableAs(tableName, initialSelectQuery); expect(ctas.getOperationType()).toEqual( - MetadataOperationType.CREATE_TABLE_AS + IMetadataOperationType.CREATE_TABLE_AS ); }); diff --git a/src/CreateTableAsSelect.ts b/src/CreateTableAsSelect.ts index 77e8158..73d5eca 100644 --- a/src/CreateTableAsSelect.ts +++ b/src/CreateTableAsSelect.ts @@ -5,7 +5,7 @@ import { IMetadata, ISequelizable, ISerializable, - MetadataOperationType, + IMetadataOperationType, OperationType, } from "./interfaces"; @@ -18,8 +18,8 @@ export class CreateTableAsSelect return new (this.constructor as any)(this._tableName, this._select.clone()); } - getOperationType(): MetadataOperationType { - return MetadataOperationType.CREATE_TABLE_AS; + getOperationType(): IMetadataOperationType { + return IMetadataOperationType.CREATE_TABLE_AS; } getTableNames(): string[] { diff --git a/src/CreateViewAsSelect.test.ts b/src/CreateViewAsSelect.test.ts index 4541ab7..1236d18 100644 --- a/src/CreateViewAsSelect.test.ts +++ b/src/CreateViewAsSelect.test.ts @@ -1,8 +1,7 @@ -import { CreateViewAsSelect } from "./CreateViewAsSelect"; // Adjust the import path as needed import { Cond } from "./Condition"; import { Q } from "./Query"; import { MySQLFlavor } from "./flavors/mysql"; -import { MetadataOperationType } from "./interfaces"; +import { IMetadataOperationType } from "./interfaces"; describe("CreateViewAsSelect", () => { const initialSelectQuery = Q.select() @@ -51,7 +50,7 @@ describe("CreateViewAsSelect", () => { it("should return correct operation type", () => { const cvas = Q.createViewAs(viewName, initialSelectQuery); expect(cvas.getOperationType()).toEqual( - MetadataOperationType.CREATE_VIEW_AS + IMetadataOperationType.CREATE_VIEW_AS ); }); diff --git a/src/CreateViewAsSelect.ts b/src/CreateViewAsSelect.ts index ba00986..5a0732d 100644 --- a/src/CreateViewAsSelect.ts +++ b/src/CreateViewAsSelect.ts @@ -5,7 +5,7 @@ import { IMetadata, ISequelizable, ISerializable, - MetadataOperationType, + IMetadataOperationType, OperationType, } from "./interfaces"; @@ -26,8 +26,8 @@ export class CreateViewAsSelect ); } - getOperationType(): MetadataOperationType { - return MetadataOperationType.CREATE_VIEW_AS; + getOperationType(): IMetadataOperationType { + return IMetadataOperationType.CREATE_VIEW_AS; } getTableNames(): string[] { diff --git a/src/Mutation-metadata.test.ts b/src/Mutation-metadata.test.ts index 604adc0..eef2e11 100644 --- a/src/Mutation-metadata.test.ts +++ b/src/Mutation-metadata.test.ts @@ -1,5 +1,5 @@ import { Q } from "./Query"; -import { MetadataOperationType } from "./interfaces"; +import { IMetadataOperationType } from "./interfaces"; describe("Query builder metadata", () => { it("should return list of tables in insert query", () => { @@ -19,13 +19,13 @@ describe("Query builder metadata", () => { }); it("should get operation type", () => { expect(Q.insert("table").getOperationType()).toEqual( - MetadataOperationType.INSERT + IMetadataOperationType.INSERT ); expect(Q.update("table").getOperationType()).toEqual( - MetadataOperationType.UPDATE + IMetadataOperationType.UPDATE ); expect(Q.delete("table").getOperationType()).toEqual( - MetadataOperationType.DELETE + IMetadataOperationType.DELETE ); }); }); diff --git a/src/Mutation.ts b/src/Mutation.ts index e174346..d6f2a24 100644 --- a/src/Mutation.ts +++ b/src/Mutation.ts @@ -6,7 +6,7 @@ import { IMetadata, ISequelizable, ISerializable, - MetadataOperationType, + IMetadataOperationType, OperationType, } from "./interfaces"; @@ -48,8 +48,8 @@ export class DeleteMutation { protected _where: Condition[] = []; - public getOperationType(): MetadataOperationType { - return MetadataOperationType.DELETE; + public getOperationType(): IMetadataOperationType { + return IMetadataOperationType.DELETE; } public clone(): this { @@ -101,8 +101,8 @@ export class InsertMutation { protected _values: Record = {}; - public getOperationType(): MetadataOperationType { - return MetadataOperationType.INSERT; + public getOperationType(): IMetadataOperationType { + return IMetadataOperationType.INSERT; } public clone(): this { @@ -155,8 +155,8 @@ export class UpdateMutation protected _values: Record = {}; protected _where: Condition[] = []; - public getOperationType(): MetadataOperationType { - return MetadataOperationType.UPDATE; + public getOperationType(): IMetadataOperationType { + return IMetadataOperationType.UPDATE; } public clone(): this { diff --git a/src/Query-metadata.test.ts b/src/Query-metadata.test.ts index 5080e3d..b10acba 100644 --- a/src/Query-metadata.test.ts +++ b/src/Query-metadata.test.ts @@ -1,6 +1,6 @@ import { Q } from "./Query"; import { Fn } from "./Function"; -import { MetadataOperationType } from "./interfaces"; +import { IMetadataOperationType } from "./interfaces"; describe("Query builder metadata", () => { it("should return list of tables in simple query", () => { @@ -60,6 +60,6 @@ describe("Query builder metadata", () => { it("should get operation type for query", () => { const query = Q.select(); const operation = query.getOperationType(); - expect(operation).toEqual(MetadataOperationType.SELECT); + expect(operation).toEqual(IMetadataOperationType.SELECT); }); }); diff --git a/src/Query.ts b/src/Query.ts index 8ce2b0b..8108f2c 100644 --- a/src/Query.ts +++ b/src/Query.ts @@ -10,7 +10,7 @@ import { IMetadata, ISequelizable, ISerializable, - MetadataOperationType, + IMetadataOperationType, OperationType, } from "./interfaces"; import { DeleteMutation, InsertMutation, UpdateMutation } from "./Mutation"; @@ -77,8 +77,8 @@ export class QueryBase implements ISequelizable, IMetadata { protected _tables: Table[] = []; protected _joins: Join[] = []; - public getOperationType(): MetadataOperationType { - return MetadataOperationType.SELECT; + public getOperationType(): IMetadataOperationType { + return IMetadataOperationType.SELECT; } // @ts-ignore diff --git a/src/index.ts b/src/index.ts index aa30959..87e7f43 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,6 +4,11 @@ export { MySQLFlavor } from "./flavors/mysql"; export { Cond, Condition, type ConditionValue } from "./Condition"; export { Fn, Function } from "./Function"; export { Q, Query, SelectQuery } from "./Query"; -export { type ISequelizable, type ISerializable } from "./interfaces"; +export { + type ISequelizable, + type ISerializable, + type IMetadata, + type IMetadataOperationType, +} from "./interfaces"; export { type ISQLFlavor } from "./Flavor"; diff --git a/src/interfaces.ts b/src/interfaces.ts index bb7a1c6..f56c8b7 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -7,7 +7,7 @@ export interface ISerializable { serialize(): string; } -export enum MetadataOperationType { +export enum IMetadataOperationType { SELECT = "select", INSERT = "insert", UPDATE = "update", @@ -26,5 +26,5 @@ export enum OperationType { export interface IMetadata { getTableNames(): string[]; - getOperationType(): MetadataOperationType; + getOperationType(): IMetadataOperationType; }