pg-query-sdk 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +99 -370
  2. package/dist/cjs/builders/ConditionBuilder.d.ts +34 -0
  3. package/dist/cjs/builders/ConditionBuilder.js +34 -0
  4. package/dist/cjs/builders/QueryBuilder.d.ts +112 -1
  5. package/dist/cjs/builders/QueryBuilder.js +94 -1
  6. package/dist/cjs/core/Database.d.ts +26 -0
  7. package/dist/cjs/core/Database.js +26 -0
  8. package/dist/cjs/core/ParamContext.d.ts +16 -0
  9. package/dist/cjs/core/ParamContext.js +16 -0
  10. package/dist/cjs/core/QueryExecutor.d.ts +26 -0
  11. package/dist/cjs/core/QueryExecutor.js +26 -0
  12. package/dist/cjs/core/TransactionManager.d.ts +13 -0
  13. package/dist/cjs/core/TransactionManager.js +13 -0
  14. package/dist/cjs/core/UnitOfWork.d.ts +19 -0
  15. package/dist/cjs/core/UnitOfWork.js +19 -0
  16. package/dist/cjs/dialects/Dialect.d.ts +13 -0
  17. package/dist/cjs/dialects/MysqlDialect.d.ts +12 -0
  18. package/dist/cjs/dialects/MysqlDialect.js +12 -0
  19. package/dist/cjs/dialects/PostgresDialect.d.ts +13 -0
  20. package/dist/cjs/dialects/PostgresDialect.js +13 -0
  21. package/dist/cjs/index.d.ts +28 -0
  22. package/dist/cjs/index.js +28 -0
  23. package/dist/cjs/orm/Repository.d.ts +34 -0
  24. package/dist/cjs/orm/Repository.js +34 -0
  25. package/dist/cjs/query/ConditionBuilder.d.ts +33 -0
  26. package/dist/cjs/query/ConditionBuilder.js +33 -0
  27. package/dist/cjs/query/QueryBuilder.d.ts +154 -0
  28. package/dist/cjs/query/QueryBuilder.js +136 -0
  29. package/dist/esm/builders/ConditionBuilder.d.ts +34 -0
  30. package/dist/esm/builders/ConditionBuilder.js +34 -0
  31. package/dist/esm/builders/QueryBuilder.d.ts +112 -1
  32. package/dist/esm/builders/QueryBuilder.js +94 -1
  33. package/dist/esm/core/Database.d.ts +26 -0
  34. package/dist/esm/core/Database.js +26 -0
  35. package/dist/esm/core/ParamContext.d.ts +16 -0
  36. package/dist/esm/core/ParamContext.js +16 -0
  37. package/dist/esm/core/QueryExecutor.d.ts +26 -0
  38. package/dist/esm/core/QueryExecutor.js +26 -0
  39. package/dist/esm/core/TransactionManager.d.ts +13 -0
  40. package/dist/esm/core/TransactionManager.js +13 -0
  41. package/dist/esm/core/UnitOfWork.d.ts +19 -0
  42. package/dist/esm/core/UnitOfWork.js +19 -0
  43. package/dist/esm/dialects/Dialect.d.ts +13 -0
  44. package/dist/esm/dialects/MysqlDialect.d.ts +12 -0
  45. package/dist/esm/dialects/MysqlDialect.js +12 -0
  46. package/dist/esm/dialects/PostgresDialect.d.ts +13 -0
  47. package/dist/esm/dialects/PostgresDialect.js +13 -0
  48. package/dist/esm/index.d.ts +28 -0
  49. package/dist/esm/index.js +28 -0
  50. package/dist/esm/orm/Repository.d.ts +34 -0
  51. package/dist/esm/orm/Repository.js +34 -0
  52. package/dist/esm/query/ConditionBuilder.d.ts +33 -0
  53. package/dist/esm/query/ConditionBuilder.js +33 -0
  54. package/dist/esm/query/QueryBuilder.d.ts +154 -0
  55. package/dist/esm/query/QueryBuilder.js +136 -0
  56. package/package.json +1 -1
@@ -1,55 +1,143 @@
1
1
  import ParamContext from '../core/ParamContext';
2
2
  import ConditionBuilder from './ConditionBuilder';
3
+ /**
4
+ * A fluent SQL query builder for constructing and executing database queries.
5
+ * This builder is specifically designed for the `builders` directory and might have a different scope or feature set
6
+ * compared to other QueryBuilder implementations in the project.
7
+ * @template T The expected type of the results.
8
+ */
3
9
  export default class QueryBuilder {
10
+ /**
11
+ * Creates an instance of QueryBuilder.
12
+ * @param table - The name of the table to query from.
13
+ * @param executor - The query executor to use.
14
+ * @param dialect - The database dialect to use.
15
+ */
4
16
  constructor(table, executor, dialect) {
5
17
  this.executor = executor;
18
+ /**
19
+ * The fields to be selected in the query.
20
+ */
6
21
  this.fields = [];
22
+ /**
23
+ * The join clauses for the query.
24
+ */
7
25
  this.joins = [];
26
+ /**
27
+ * The fields to group by.
28
+ */
8
29
  this.groupByFields = [];
30
+ /**
31
+ * The fields to order by.
32
+ */
9
33
  this.orderByFields = [];
10
- this.ctes = [];
34
+ /**
35
+ * Common Table Expressions (CTEs) defined for the query.
36
+ */
37
+ this.ctes = []; // TODO: Define a proper type for CTEs
11
38
  this.fromClause = table;
12
39
  this.ctx = new ParamContext(dialect);
13
40
  this.condition = new ConditionBuilder(this.ctx);
14
41
  this.havingCondition = new ConditionBuilder(this.ctx);
15
42
  }
43
+ /**
44
+ * Specifies the fields to select.
45
+ * @param fields - An array of field names.
46
+ * @returns The current QueryBuilder instance.
47
+ */
16
48
  select(fields) {
17
49
  this.fields = fields;
18
50
  return this;
19
51
  }
52
+ /**
53
+ * Adds a join clause to the query.
54
+ * @param type - The type of join (INNER, LEFT, RIGHT).
55
+ * @param table - The table to join.
56
+ * @param localKey - The local key for the join condition.
57
+ * @param foreignKey - The foreign key for the join condition.
58
+ * @returns The current QueryBuilder instance.
59
+ */
20
60
  addJoin(type, table, localKey, foreignKey) {
21
61
  this.joins.push(`${type} JOIN ${table} ON ${localKey} = ${foreignKey}`);
22
62
  return this;
23
63
  }
64
+ /**
65
+ * Adds an INNER JOIN clause.
66
+ * @param table - The table to join.
67
+ * @param localKey - The local key for the join condition.
68
+ * @param foreignKey - The foreign key for the join condition.
69
+ * @returns The current QueryBuilder instance.
70
+ */
24
71
  join(table, localKey, foreignKey) {
25
72
  return this.addJoin('INNER', table, localKey, foreignKey);
26
73
  }
74
+ /**
75
+ * Adds a LEFT JOIN clause.
76
+ * @param table - The table to join.
77
+ * @param localKey - The local key for the join condition.
78
+ * @param foreignKey - The foreign key for the join condition.
79
+ * @returns The current QueryBuilder instance.
80
+ */
27
81
  leftJoin(table, localKey, foreignKey) {
28
82
  return this.addJoin('LEFT', table, localKey, foreignKey);
29
83
  }
84
+ /**
85
+ * Adds a RIGHT JOIN clause.
86
+ * @param table - The table to join.
87
+ * @param localKey - The local key for the join condition.
88
+ * @param foreignKey - The foreign key for the join condition.
89
+ * @returns The current QueryBuilder instance.
90
+ */
30
91
  rightJoin(table, localKey, foreignKey) {
31
92
  return this.addJoin('RIGHT', table, localKey, foreignKey);
32
93
  }
94
+ /**
95
+ * Sets the FROM clause to a subquery.
96
+ * @param sub - The QueryBuilder instance representing the subquery.
97
+ * @param alias - The alias for the subquery.
98
+ * @returns The current QueryBuilder instance.
99
+ */
33
100
  fromSubquery(sub, alias) {
34
101
  const { query, params } = sub.build();
35
102
  params.forEach(p => this.ctx.add(p));
36
103
  this.fromClause = `(${query}) AS ${alias}`;
37
104
  return this;
38
105
  }
106
+ /**
107
+ * Adds WHERE conditions based on an object.
108
+ * @param obj - An object where keys are column names and values are the desired values.
109
+ * @returns The current QueryBuilder instance.
110
+ */
39
111
  where(obj) {
40
112
  this.condition.where(obj);
41
113
  return this;
42
114
  }
115
+ /**
116
+ * Adds a WHERE condition with a subquery.
117
+ * @param column - The column to apply the condition to.
118
+ * @param operator - The operator ('IN' or 'NOT IN').
119
+ * @param sub - The QueryBuilder instance representing the subquery.
120
+ * @returns The current QueryBuilder instance.
121
+ */
43
122
  whereSub(column, operator, sub) {
44
123
  const { query, params } = sub.build();
45
124
  params.forEach(p => this.ctx.add(p));
46
125
  this.condition.raw(`${column} ${operator} (${query})`);
47
126
  return this;
48
127
  }
128
+ /**
129
+ * Sets the LIMIT for the query.
130
+ * @param limit - The maximum number of rows to return.
131
+ * @returns The current QueryBuilder instance.
132
+ */
49
133
  limit(limit) {
50
134
  this.limitCount = limit;
51
135
  return this;
52
136
  }
137
+ /**
138
+ * Builds the SQL query string and its parameters without executing it.
139
+ * @returns An object containing the SQL query string and an array of parameters.
140
+ */
53
141
  build() {
54
142
  const select = this.fields.length
55
143
  ? this.fields.join(', ')
@@ -70,6 +158,11 @@ export default class QueryBuilder {
70
158
  params: this.ctx.getParams()
71
159
  };
72
160
  }
161
+ /**
162
+ * Executes the built SQL query and returns the results.
163
+ * @returns A Promise that resolves to an array of results of type T.
164
+ * @throws Error if no QueryExecutor is provided.
165
+ */
73
166
  async execute() {
74
167
  if (!this.executor) {
75
168
  throw new Error('No QueryExecutor provided');
@@ -6,15 +6,41 @@ interface DatabaseOptions {
6
6
  dialect?: Dialect;
7
7
  defaultCacheTTL?: number;
8
8
  }
9
+ /**
10
+ * Represents a database connection and provides methods for querying and managing transactions.
11
+ */
9
12
  export default class Database {
10
13
  private executor;
11
14
  private dialect;
12
15
  private transactionManager;
13
16
  private defaultCacheTTL?;
17
+ /**
18
+ * Creates an instance of the Database.
19
+ * @param options - The options for the database connection.
20
+ */
14
21
  constructor(options: DatabaseOptions);
22
+ /**
23
+ * Creates a QueryBuilder for a specific table.
24
+ * @param name - The name of the table.
25
+ * @returns A QueryBuilder instance.
26
+ */
15
27
  table<T = any>(name: string): QueryBuilder<T>;
28
+ /**
29
+ * Executes a transaction.
30
+ * @param callback - The function to execute within the transaction. It receives a transactional Database instance.
31
+ * @returns The result of the callback function.
32
+ */
16
33
  transaction<T>(callback: (trxDb: Database) => Promise<T>): Promise<T>;
34
+ /**
35
+ * Sets the query executor.
36
+ * @param executor - The QueryExecutor instance to set.
37
+ */
17
38
  setExecutor(executor: QueryExecutor): void;
39
+ /**
40
+ * Creates a repository instance.
41
+ * @param RepoClass - The constructor of the repository class.
42
+ * @returns An instance of the repository.
43
+ */
18
44
  repository<R>(RepoClass: new (executor: QueryExecutor, dialect: Dialect) => R): R;
19
45
  }
20
46
  export {};
@@ -2,16 +2,33 @@ import PostgresDialect from '../dialects/PostgresDialect';
2
2
  import QueryExecutor from './QueryExecutor';
3
3
  import QueryBuilder from '../query/QueryBuilder';
4
4
  import TransactionManager from './TransactionManager';
5
+ /**
6
+ * Represents a database connection and provides methods for querying and managing transactions.
7
+ */
5
8
  export default class Database {
9
+ /**
10
+ * Creates an instance of the Database.
11
+ * @param options - The options for the database connection.
12
+ */
6
13
  constructor(options) {
7
14
  this.dialect = options.dialect ?? new PostgresDialect();
8
15
  this.executor = new QueryExecutor(options);
9
16
  this.transactionManager = new TransactionManager(this.executor.getPool());
10
17
  this.defaultCacheTTL = options.defaultCacheTTL;
11
18
  }
19
+ /**
20
+ * Creates a QueryBuilder for a specific table.
21
+ * @param name - The name of the table.
22
+ * @returns A QueryBuilder instance.
23
+ */
12
24
  table(name) {
13
25
  return new QueryBuilder(name, this.executor, this.dialect, this.defaultCacheTTL);
14
26
  }
27
+ /**
28
+ * Executes a transaction.
29
+ * @param callback - The function to execute within the transaction. It receives a transactional Database instance.
30
+ * @returns The result of the callback function.
31
+ */
15
32
  async transaction(callback) {
16
33
  return this.transactionManager.transaction(async (trxClient) => {
17
34
  const trxExecutor = new QueryExecutor(undefined, trxClient);
@@ -24,9 +41,18 @@ export default class Database {
24
41
  return callback(trxDb);
25
42
  });
26
43
  }
44
+ /**
45
+ * Sets the query executor.
46
+ * @param executor - The QueryExecutor instance to set.
47
+ */
27
48
  setExecutor(executor) {
28
49
  this.executor = executor;
29
50
  }
51
+ /**
52
+ * Creates a repository instance.
53
+ * @param RepoClass - The constructor of the repository class.
54
+ * @returns An instance of the repository.
55
+ */
30
56
  repository(RepoClass) {
31
57
  return new RepoClass(this.executor, this.dialect);
32
58
  }
@@ -1,8 +1,24 @@
1
1
  import { Dialect } from "../dialects/Dialect";
2
+ /**
3
+ * Manages parameters for SQL queries, ensuring proper dialect-specific placeholders.
4
+ */
2
5
  export default class ParamContext {
3
6
  private dialect;
4
7
  private params;
8
+ /**
9
+ * Creates an instance of ParamContext.
10
+ * @param dialect - The dialect to use for generating parameter placeholders.
11
+ */
5
12
  constructor(dialect: Dialect);
13
+ /**
14
+ * Adds a value to the parameter list and returns its dialect-specific placeholder.
15
+ * @param value - The value to add.
16
+ * @returns The placeholder string for the added parameter.
17
+ */
6
18
  add(value: any): string;
19
+ /**
20
+ * Retrieves the list of accumulated parameters.
21
+ * @returns An array of parameters.
22
+ */
7
23
  getParams(): any[];
8
24
  }
@@ -1,12 +1,28 @@
1
+ /**
2
+ * Manages parameters for SQL queries, ensuring proper dialect-specific placeholders.
3
+ */
1
4
  export default class ParamContext {
5
+ /**
6
+ * Creates an instance of ParamContext.
7
+ * @param dialect - The dialect to use for generating parameter placeholders.
8
+ */
2
9
  constructor(dialect) {
3
10
  this.dialect = dialect;
4
11
  this.params = [];
5
12
  }
13
+ /**
14
+ * Adds a value to the parameter list and returns its dialect-specific placeholder.
15
+ * @param value - The value to add.
16
+ * @returns The placeholder string for the added parameter.
17
+ */
6
18
  add(value) {
7
19
  this.params.push(value);
8
20
  return this.dialect.placeholder(this.params.length);
9
21
  }
22
+ /**
23
+ * Retrieves the list of accumulated parameters.
24
+ * @returns An array of parameters.
25
+ */
10
26
  getParams() {
11
27
  return this.params;
12
28
  }
@@ -2,13 +2,39 @@ import { Pool, PoolClient, QueryResult } from 'pg';
2
2
  interface ExecutorOptions {
3
3
  connectionString: string;
4
4
  }
5
+ /**
6
+ * Executes database queries using a PostgreSQL pool or client.
7
+ */
5
8
  export default class QueryExecutor {
6
9
  private pool?;
7
10
  private client?;
11
+ /**
12
+ * Creates an instance of QueryExecutor.
13
+ * @param options - Options for the executor, including the connection string.
14
+ * @param client - An optional PoolClient to use for queries (for transactions).
15
+ */
8
16
  constructor(options?: ExecutorOptions, client?: PoolClient);
17
+ /**
18
+ * Executes a SQL query.
19
+ * @param query - The SQL query string.
20
+ * @param params - An array of parameters for the query.
21
+ * @param cacheTTL - Time-to-live for caching (not currently used in this implementation).
22
+ * @returns A Promise that resolves to the QueryResult.
23
+ */
9
24
  execute(query: string, params: any[] | undefined, cacheTTL: number | undefined): Promise<QueryResult>;
25
+ /**
26
+ * Returns the underlying PostgreSQL Pool instance.
27
+ * @returns The Pool instance or undefined if not initialized with a connection string.
28
+ */
10
29
  getPool(): Pool | undefined;
30
+ /**
31
+ * Returns the underlying PostgreSQL PoolClient instance.
32
+ * @returns The PoolClient instance or undefined if not initialized with a client.
33
+ */
11
34
  getClient(): PoolClient | undefined;
35
+ /**
36
+ * Closes the database connection pool.
37
+ */
12
38
  close(): Promise<void>;
13
39
  }
14
40
  export {};
@@ -1,5 +1,13 @@
1
1
  import { Pool } from 'pg';
2
+ /**
3
+ * Executes database queries using a PostgreSQL pool or client.
4
+ */
2
5
  export default class QueryExecutor {
6
+ /**
7
+ * Creates an instance of QueryExecutor.
8
+ * @param options - Options for the executor, including the connection string.
9
+ * @param client - An optional PoolClient to use for queries (for transactions).
10
+ */
3
11
  constructor(options, client) {
4
12
  if (client) {
5
13
  this.client = client;
@@ -13,6 +21,13 @@ export default class QueryExecutor {
13
21
  }
14
22
  throw new Error('Invalid QueryExecutor initialization');
15
23
  }
24
+ /**
25
+ * Executes a SQL query.
26
+ * @param query - The SQL query string.
27
+ * @param params - An array of parameters for the query.
28
+ * @param cacheTTL - Time-to-live for caching (not currently used in this implementation).
29
+ * @returns A Promise that resolves to the QueryResult.
30
+ */
16
31
  async execute(query, params = [], cacheTTL) {
17
32
  if (this.client) {
18
33
  return this.client.query(query, params);
@@ -22,12 +37,23 @@ export default class QueryExecutor {
22
37
  }
23
38
  throw new Error('Executor not initialized');
24
39
  }
40
+ /**
41
+ * Returns the underlying PostgreSQL Pool instance.
42
+ * @returns The Pool instance or undefined if not initialized with a connection string.
43
+ */
25
44
  getPool() {
26
45
  return this.pool;
27
46
  }
47
+ /**
48
+ * Returns the underlying PostgreSQL PoolClient instance.
49
+ * @returns The PoolClient instance or undefined if not initialized with a client.
50
+ */
28
51
  getClient() {
29
52
  return this.client;
30
53
  }
54
+ /**
55
+ * Closes the database connection pool.
56
+ */
31
57
  async close() {
32
58
  if (this.pool) {
33
59
  await this.pool.end();
@@ -1,6 +1,19 @@
1
1
  import { Pool, PoolClient } from 'pg';
2
+ /**
3
+ * Manages database transactions, providing a method to execute a callback within a transaction.
4
+ */
2
5
  export default class TransactionManager {
3
6
  private pool;
7
+ /**
8
+ * Creates an instance of TransactionManager.
9
+ * @param pool - The PostgreSQL connection pool to use for transactions.
10
+ */
4
11
  constructor(pool: Pool);
12
+ /**
13
+ * Executes a given callback function within a database transaction.
14
+ * The transaction is committed if the callback succeeds, and rolled back if an error occurs.
15
+ * @param callback - The function to execute within the transaction. It receives a PoolClient instance.
16
+ * @returns A Promise that resolves to the result of the callback function.
17
+ */
5
18
  transaction<T>(callback: (trxClient: PoolClient) => Promise<T>): Promise<T>;
6
19
  }
@@ -1,7 +1,20 @@
1
+ /**
2
+ * Manages database transactions, providing a method to execute a callback within a transaction.
3
+ */
1
4
  export default class TransactionManager {
5
+ /**
6
+ * Creates an instance of TransactionManager.
7
+ * @param pool - The PostgreSQL connection pool to use for transactions.
8
+ */
2
9
  constructor(pool) {
3
10
  this.pool = pool;
4
11
  }
12
+ /**
13
+ * Executes a given callback function within a database transaction.
14
+ * The transaction is committed if the callback succeeds, and rolled back if an error occurs.
15
+ * @param callback - The function to execute within the transaction. It receives a PoolClient instance.
16
+ * @returns A Promise that resolves to the result of the callback function.
17
+ */
5
18
  async transaction(callback) {
6
19
  const client = await this.pool.connect();
7
20
  try {
@@ -1,10 +1,29 @@
1
1
  import Repository from "../orm/Repository";
2
+ /**
3
+ * Manages a list of new, dirty, and removed entities for transactional operations.
4
+ */
2
5
  export default class UnitOfWork {
3
6
  private newEntities;
4
7
  private dirtyEntities;
5
8
  private removedEntities;
9
+ /**
10
+ * Registers an entity as new, to be inserted on commit.
11
+ * @param entity - The entity to register.
12
+ */
6
13
  registerNew(entity: any): void;
14
+ /**
15
+ * Registers an entity as dirty, to be updated on commit.
16
+ * @param entity - The entity to register.
17
+ */
7
18
  registerDirty(entity: any): void;
19
+ /**
20
+ * Registers an entity as removed, to be deleted on commit.
21
+ * @param entity - The entity to register.
22
+ */
8
23
  registerRemoved(entity: any): void;
24
+ /**
25
+ * Commits all registered changes (insertions, updates, deletions) using the provided repository.
26
+ * @param repository - The repository to use for committing changes.
27
+ */
9
28
  commit(repository: Repository<any>): Promise<void>;
10
29
  }
@@ -1,18 +1,37 @@
1
+ /**
2
+ * Manages a list of new, dirty, and removed entities for transactional operations.
3
+ */
1
4
  export default class UnitOfWork {
2
5
  constructor() {
3
6
  this.newEntities = [];
4
7
  this.dirtyEntities = [];
5
8
  this.removedEntities = [];
6
9
  }
10
+ /**
11
+ * Registers an entity as new, to be inserted on commit.
12
+ * @param entity - The entity to register.
13
+ */
7
14
  registerNew(entity) {
8
15
  this.newEntities.push(entity);
9
16
  }
17
+ /**
18
+ * Registers an entity as dirty, to be updated on commit.
19
+ * @param entity - The entity to register.
20
+ */
10
21
  registerDirty(entity) {
11
22
  this.dirtyEntities.push(entity);
12
23
  }
24
+ /**
25
+ * Registers an entity as removed, to be deleted on commit.
26
+ * @param entity - The entity to register.
27
+ */
13
28
  registerRemoved(entity) {
14
29
  this.removedEntities.push(entity);
15
30
  }
31
+ /**
32
+ * Commits all registered changes (insertions, updates, deletions) using the provided repository.
33
+ * @param repository - The repository to use for committing changes.
34
+ */
16
35
  async commit(repository) {
17
36
  for (const e of this.newEntities)
18
37
  await repository.insert(e);
@@ -1,4 +1,17 @@
1
+ /**
2
+ * Defines the interface for a database dialect, providing methods for placeholder generation and identifier wrapping.
3
+ */
1
4
  export interface Dialect {
5
+ /**
6
+ * Generates a parameter placeholder for the given index.
7
+ * @param index - The index of the parameter.
8
+ * @returns The dialect-specific parameter placeholder.
9
+ */
2
10
  placeholder(index: number): string;
11
+ /**
12
+ * Wraps an identifier (e.g., table name, column name) with dialect-specific quoting.
13
+ * @param identifier - The identifier to wrap.
14
+ * @returns The wrapped identifier.
15
+ */
3
16
  wrapIdentifier(identifier: string): string;
4
17
  }
@@ -1,5 +1,17 @@
1
1
  import { Dialect } from "./Dialect";
2
+ /**
3
+ * Implements the Dialect interface for MySQL, providing MySQL-specific placeholder and identifier wrapping.
4
+ */
2
5
  export default class MysqlDialect implements Dialect {
6
+ /**
7
+ * Returns a MySQL-specific parameter placeholder '?'.
8
+ * @returns The string '?'.
9
+ */
3
10
  placeholder(): string;
11
+ /**
12
+ * Wraps a MySQL identifier with backticks.
13
+ * @param id - The identifier to wrap.
14
+ * @returns The backtick-wrapped identifier.
15
+ */
4
16
  wrapIdentifier(id: string): string;
5
17
  }
@@ -1,7 +1,19 @@
1
+ /**
2
+ * Implements the Dialect interface for MySQL, providing MySQL-specific placeholder and identifier wrapping.
3
+ */
1
4
  export default class MysqlDialect {
5
+ /**
6
+ * Returns a MySQL-specific parameter placeholder '?'.
7
+ * @returns The string '?'.
8
+ */
2
9
  placeholder() {
3
10
  return '?';
4
11
  }
12
+ /**
13
+ * Wraps a MySQL identifier with backticks.
14
+ * @param id - The identifier to wrap.
15
+ * @returns The backtick-wrapped identifier.
16
+ */
5
17
  wrapIdentifier(id) {
6
18
  return `\`${id}\``;
7
19
  }
@@ -1,5 +1,18 @@
1
1
  import { Dialect } from "./Dialect";
2
+ /**
3
+ * Implements the Dialect interface for PostgreSQL, providing PostgreSQL-specific placeholder and identifier wrapping.
4
+ */
2
5
  export default class PostgresDialect implements Dialect {
6
+ /**
7
+ * Returns a PostgreSQL-specific parameter placeholder (e.g., '$1', '$2').
8
+ * @param index - The index of the parameter.
9
+ * @returns The dollar-prefixed, indexed placeholder.
10
+ */
3
11
  placeholder(index: number): string;
12
+ /**
13
+ * Wraps a PostgreSQL identifier with double quotes.
14
+ * @param id - The identifier to wrap.
15
+ * @returns The double-quoted identifier.
16
+ */
4
17
  wrapIdentifier(id: string): string;
5
18
  }
@@ -1,7 +1,20 @@
1
+ /**
2
+ * Implements the Dialect interface for PostgreSQL, providing PostgreSQL-specific placeholder and identifier wrapping.
3
+ */
1
4
  export default class PostgresDialect {
5
+ /**
6
+ * Returns a PostgreSQL-specific parameter placeholder (e.g., '$1', '$2').
7
+ * @param index - The index of the parameter.
8
+ * @returns The dollar-prefixed, indexed placeholder.
9
+ */
2
10
  placeholder(index) {
3
11
  return `$${index}`;
4
12
  }
13
+ /**
14
+ * Wraps a PostgreSQL identifier with double quotes.
15
+ * @param id - The identifier to wrap.
16
+ * @returns The double-quoted identifier.
17
+ */
5
18
  wrapIdentifier(id) {
6
19
  return `"${id}"`;
7
20
  }
@@ -1,7 +1,35 @@
1
+ /**
2
+ * Re-exports the QueryExecutor class from the core module.
3
+ * @module QueryExecutor
4
+ */
1
5
  export { default as QueryExecutor } from './core/QueryExecutor';
6
+ /**
7
+ * Re-exports the QueryBuilder class from the builders module.
8
+ * @module QueryBuilder
9
+ */
2
10
  export { default as QueryBuilder } from './builders/QueryBuilder';
11
+ /**
12
+ * Re-exports the ConditionBuilder class from the builders module.
13
+ * @module ConditionBuilder
14
+ */
3
15
  export { default as ConditionBuilder } from './builders/ConditionBuilder';
16
+ /**
17
+ * Re-exports the Database class from the core module.
18
+ * @module Database
19
+ */
4
20
  export { default as Database } from './core/Database';
21
+ /**
22
+ * Re-exports the TransactionManager class from the core module.
23
+ * @module TransactionManager
24
+ */
5
25
  export { default as TransactionManager } from './core/TransactionManager';
26
+ /**
27
+ * Re-exports the PostgresDialect class from the dialects module.
28
+ * @module PostgresDialect
29
+ */
6
30
  export { default as PostgresDialect } from './dialects/PostgresDialect';
31
+ /**
32
+ * Re-exports the Repository class from the orm module.
33
+ * @module Repository
34
+ */
7
35
  export { default as Repository } from './orm/Repository';
package/dist/esm/index.js CHANGED
@@ -1,7 +1,35 @@
1
+ /**
2
+ * Re-exports the QueryExecutor class from the core module.
3
+ * @module QueryExecutor
4
+ */
1
5
  export { default as QueryExecutor } from './core/QueryExecutor';
6
+ /**
7
+ * Re-exports the QueryBuilder class from the builders module.
8
+ * @module QueryBuilder
9
+ */
2
10
  export { default as QueryBuilder } from './builders/QueryBuilder';
11
+ /**
12
+ * Re-exports the ConditionBuilder class from the builders module.
13
+ * @module ConditionBuilder
14
+ */
3
15
  export { default as ConditionBuilder } from './builders/ConditionBuilder';
16
+ /**
17
+ * Re-exports the Database class from the core module.
18
+ * @module Database
19
+ */
4
20
  export { default as Database } from './core/Database';
21
+ /**
22
+ * Re-exports the TransactionManager class from the core module.
23
+ * @module TransactionManager
24
+ */
5
25
  export { default as TransactionManager } from './core/TransactionManager';
26
+ /**
27
+ * Re-exports the PostgresDialect class from the dialects module.
28
+ * @module PostgresDialect
29
+ */
6
30
  export { default as PostgresDialect } from './dialects/PostgresDialect';
31
+ /**
32
+ * Re-exports the Repository class from the orm module.
33
+ * @module Repository
34
+ */
7
35
  export { default as Repository } from './orm/Repository';