@asla/yoursql 0.13.0 → 0.14.0

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 (78) hide show
  1. package/README.md +22 -206
  2. package/dist/sql_gen/SqlStatement.d.ts +0 -1
  3. package/dist/sql_gen/SqlStatement.js +3 -5
  4. package/dist/sql_gen/_statement.d.ts +0 -1
  5. package/dist/sql_gen/_statement.js +10 -13
  6. package/dist/sql_gen/mod.d.ts +0 -1
  7. package/dist/sql_gen/mod.js +10 -19
  8. package/dist/sql_gen/sql_value/SqlValuesDataset.d.ts +28 -0
  9. package/dist/sql_gen/sql_value/SqlValuesDataset.js +51 -0
  10. package/dist/sql_gen/sql_value/ValueSqlTemplate.d.ts +0 -1
  11. package/dist/sql_gen/sql_value/ValueSqlTemplate.js +2 -5
  12. package/dist/sql_gen/sql_value/_to_values.d.ts +0 -1
  13. package/dist/sql_gen/sql_value/_to_values.js +5 -8
  14. package/dist/sql_gen/sql_value/db_type.d.ts +0 -1
  15. package/dist/sql_gen/sql_value/db_type.js +2 -5
  16. package/dist/sql_gen/sql_value/sql_value.d.ts +3 -25
  17. package/dist/sql_gen/sql_value/sql_value.js +7 -60
  18. package/dist/sql_gen/sql_value/type.d.ts +0 -1
  19. package/dist/sql_gen/sql_value/type.js +1 -0
  20. package/dist/sql_gen/statement/_modify.d.ts +0 -1
  21. package/dist/sql_gen/statement/_modify.js +1 -0
  22. package/dist/sql_gen/statement/cte.d.ts +0 -1
  23. package/dist/sql_gen/statement/cte.js +7 -10
  24. package/dist/sql_gen/statement/delete.d.ts +0 -1
  25. package/dist/sql_gen/statement/delete.js +2 -5
  26. package/dist/sql_gen/statement/delete_chain.d.ts +0 -1
  27. package/dist/sql_gen/statement/delete_chain.js +1 -0
  28. package/dist/sql_gen/statement/delete_impl.d.ts +0 -1
  29. package/dist/sql_gen/statement/delete_impl.js +3 -6
  30. package/dist/sql_gen/statement/insert.d.ts +0 -1
  31. package/dist/sql_gen/statement/insert.js +2 -5
  32. package/dist/sql_gen/statement/insert_chain.d.ts +8 -1
  33. package/dist/sql_gen/statement/insert_chain.js +1 -0
  34. package/dist/sql_gen/statement/insert_impl.d.ts +0 -1
  35. package/dist/sql_gen/statement/insert_impl.js +4 -7
  36. package/dist/sql_gen/statement/mod.d.ts +0 -1
  37. package/dist/sql_gen/statement/mod.js +9 -0
  38. package/dist/sql_gen/statement/select.d.ts +0 -1
  39. package/dist/sql_gen/statement/select.js +4 -7
  40. package/dist/sql_gen/statement/select_chain.d.ts +0 -1
  41. package/dist/sql_gen/statement/select_chain.js +1 -0
  42. package/dist/sql_gen/statement/select_impl.d.ts +0 -1
  43. package/dist/sql_gen/statement/select_impl.js +4 -7
  44. package/dist/sql_gen/statement/update.d.ts +0 -1
  45. package/dist/sql_gen/statement/update.js +2 -5
  46. package/dist/sql_gen/statement/update_chain.d.ts +0 -1
  47. package/dist/sql_gen/statement/update_chain.js +1 -0
  48. package/dist/sql_gen/statement/update_impl.d.ts +0 -1
  49. package/dist/sql_gen/statement/update_impl.js +4 -7
  50. package/dist/sql_gen/util.d.ts +0 -1
  51. package/dist/sql_gen/util.js +1 -3
  52. package/dist/sql_gen/your_table/checker.d.ts +0 -1
  53. package/dist/sql_gen/your_table/checker.js +2 -5
  54. package/dist/sql_gen/your_table/infer_db_type.d.ts +0 -1
  55. package/dist/sql_gen/your_table/infer_db_type.js +3 -5
  56. package/dist/sql_gen/your_table/mod.d.ts +0 -1
  57. package/dist/sql_gen/your_table/mod.js +3 -0
  58. package/dist/sql_gen/your_table/table.d.ts +0 -1
  59. package/dist/sql_gen/your_table/table.js +2 -5
  60. package/package.json +31 -34
  61. package/dist/client/DbCursor.d.ts +0 -14
  62. package/dist/client/DbCursor.js +0 -21
  63. package/dist/client/DbPoolConnection.d.ts +0 -5
  64. package/dist/client/DbPoolConnection.js +0 -74
  65. package/dist/client/DbPoolTransaction.d.ts +0 -9
  66. package/dist/client/DbPoolTransaction.js +0 -146
  67. package/dist/client/DbQuery.d.ts +0 -50
  68. package/dist/client/DbQuery.js +0 -42
  69. package/dist/client/DbQueryBase.d.ts +0 -38
  70. package/dist/client/DbQueryBase.js +0 -32
  71. package/dist/client/DbQueryPool.d.ts +0 -39
  72. package/dist/client/DbQueryPool.js +0 -56
  73. package/dist/client/_type.d.ts +0 -2
  74. package/dist/client/errors.d.ts +0 -9
  75. package/dist/client/errors.js +0 -14
  76. package/dist/client/interfaces.d.ts +0 -87
  77. package/dist/client/mod.d.ts +0 -9
  78. package/dist/client/mod.js +0 -7
@@ -1,11 +1,12 @@
1
- import { TemplateSqlStatement } from './ValueSqlTemplate.js';
2
- import { AssertError, getColumnInfo, internalObjectToValues, getObjectValueInfo } from './_to_values.js';
3
-
1
+ import { ExplicitSqlValues } from "./SqlValuesDataset.js";
2
+ import { TemplateSqlStatement } from "./ValueSqlTemplate.js";
3
+ import { AssertError, getColumnInfo, getObjectValueInfo, internalObjectToValues, } from "./_to_values.js";
4
+ export { TemplateSqlStatement } from "./ValueSqlTemplate.js";
4
5
  /**
5
6
  * SQL value 生成器
6
7
  * @public
7
8
  */
8
- class SqlValuesCreator {
9
+ export class SqlValuesCreator {
9
10
  static create(map) {
10
11
  const obj = new this(map);
11
12
  const fn = obj.toSqlStr.bind(obj);
@@ -161,13 +162,13 @@ class SqlValuesCreator {
161
162
  let message = error instanceof Error ? error.message : String(error);
162
163
  throw new Error("第 " + i + " 项,字段 '" + keys[j] + "' 异常," + message);
163
164
  }
164
- return new SqlValuesDataset(keys, firstRow.types, firstRow.values, rows);
165
+ return new ExplicitSqlValues(keys, firstRow.types, firstRow.values, rows);
165
166
  }
166
167
  _objectToValue(object, keys_types, option = {}) {
167
168
  const { keys, type } = getObjectValueInfo(object, keys_types);
168
169
  const undefinedDefault = option.undefinedDefault || "DEFAULT";
169
170
  const res = internalObjectToValues(object, keys, type, undefinedDefault, this);
170
- return new SqlValuesDataset(keys, res.types, res.values, []);
171
+ return new ExplicitSqlValues(keys, res.types, res.values, []);
171
172
  }
172
173
  /**
173
174
  * 将数组列表转为 SQL 的一个 value
@@ -182,57 +183,3 @@ class SqlValuesCreator {
182
183
  return values.map((v) => this.toSqlStr(v)).join(",");
183
184
  }
184
185
  }
185
- /** @public */
186
- class SqlValuesDataset {
187
- columns;
188
- columnsSqlType;
189
- constructor(columns, columnsSqlType, firstValues, nextRows) {
190
- this.columns = columns;
191
- this.columnsSqlType = columnsSqlType;
192
- this.#firstValues = firstValues;
193
- this.#rows = nextRows;
194
- }
195
- #rows;
196
- #firstValues;
197
- #text;
198
- get text() {
199
- if (!this.#text) {
200
- this.#text = this.#genText();
201
- }
202
- return this.#text;
203
- }
204
- #genText() {
205
- const { columnsSqlType } = this;
206
- const firstValues = this.#firstValues;
207
- let firstRow = new Array(firstValues.length);
208
- for (let i = 0; i < firstValues.length; i++) {
209
- firstRow[i] = firstValues[i];
210
- if (columnsSqlType[i])
211
- firstRow[i] += "::" + columnsSqlType[i];
212
- }
213
- const base = "(" + firstRow.join(",") + ")";
214
- if (this.#rows.length === 0) {
215
- return base;
216
- }
217
- return "(" + firstRow.join(",") + "),\n" + this.#rows.join(",\n");
218
- }
219
- /**
220
- * @example
221
- * ```ts
222
- * const t = v.createImplicitValues(
223
- * [
224
- * { id: 1, name: "name1" },
225
- * { id: 2, name: "name2" },
226
- * ],
227
- * { id: "INT", name: "VARCHAR" },
228
- * );
229
- * // 返回 (VALUES (1::INT,'name1'::VARCHAR),(2,'name2')) AS t1(id,name)
230
- * t.toSelect("t1(id,name)")
231
- * ```
232
- */
233
- toSelect(name) {
234
- return `(VALUES\n${this.text})\nAS ${name}(${this.columns.join(",")})`;
235
- }
236
- }
237
-
238
- export { SqlValuesCreator, SqlValuesDataset, TemplateSqlStatement as ValueSqlTemplate };
@@ -15,4 +15,3 @@ export type ObjectToValueKeys<T extends {}> = readonly string[] | ({
15
15
  } & {
16
16
  [key: string]: string | undefined | ColumnToValueConfig;
17
17
  });
18
- //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ export {};
@@ -3,4 +3,3 @@ import { SqlStatementDataset, SqlStatement } from "../SqlStatement.ts";
3
3
  export interface ChainModifyReturning extends SqlStatement {
4
4
  returning<R extends TableType>(columns: Constructable<SelectParam>): SqlStatementDataset<R>;
5
5
  }
6
- //# sourceMappingURL=_modify.d.ts.map
@@ -0,0 +1 @@
1
+ export {};
@@ -49,4 +49,3 @@ export declare function withAs(name: string, statement: Constructable<string>):
49
49
  export declare function withRecursiveAs(statement: Constructable<string>): ChainCTE;
50
50
  /** @public */
51
51
  export declare function withRecursiveAs(name: string, statement: Constructable<string>): ChainCTE;
52
- //# sourceMappingURL=cte.d.ts.map
@@ -1,13 +1,12 @@
1
- import { selectColumns } from '../util.js';
2
- import { SelectChainAfterSelect } from './select_impl.js';
3
- import { DeleteChain } from './delete_impl.js';
4
- import { UpdateChain } from './update_impl.js';
5
- import { InsertChain } from './insert_impl.js';
6
-
7
- function withAs(nameOrStatement, statement) {
1
+ import { selectColumns } from "../util.js";
2
+ import { SelectChainAfterSelect } from "./select_impl.js";
3
+ import { DeleteChain } from "./delete_impl.js";
4
+ import { UpdateChain } from "./update_impl.js";
5
+ import { InsertChain } from "./insert_impl.js";
6
+ export function withAs(nameOrStatement, statement) {
8
7
  return new ChainCETImpl(`WITH \n${concat(nameOrStatement, statement)}`);
9
8
  }
10
- function withRecursiveAs(nameOrStatement, statement) {
9
+ export function withRecursiveAs(nameOrStatement, statement) {
11
10
  return new ChainCETImpl(`WITH RECURSIVE \n${concat(nameOrStatement, statement)}`);
12
11
  }
13
12
  class ChainCETImpl {
@@ -64,5 +63,3 @@ function concat(nameOrStatement, statement) {
64
63
  return statement;
65
64
  }
66
65
  }
67
-
68
- export { withAs, withRecursiveAs };
@@ -1,4 +1,3 @@
1
1
  import { DeleteFromSqlGenerator } from "./delete_chain.ts";
2
2
  /** @public */
3
3
  export declare const deleteFrom: DeleteFromSqlGenerator;
4
- //# sourceMappingURL=delete.d.ts.map
@@ -1,12 +1,9 @@
1
- import { DeleteChain } from './delete_impl.js';
2
-
1
+ import { DeleteChain } from "./delete_impl.js";
3
2
  /** @public */
4
- const deleteFrom = function deleteFrom(table, option) {
3
+ export const deleteFrom = function deleteFrom(table, option) {
5
4
  let sql = `DELETE FROM ${table}`;
6
5
  if (option?.as) {
7
6
  sql += ` AS ${option.as}`;
8
7
  }
9
8
  return new DeleteChain(sql);
10
9
  };
11
-
12
- export { deleteFrom };
@@ -38,4 +38,3 @@ export interface ChainDeleteAfterUsing extends ChainDeleteReturning {
38
38
  /** @public */
39
39
  export interface ChainDeleteReturning extends ChainModifyReturning {
40
40
  }
41
- //# sourceMappingURL=delete_chain.d.ts.map
@@ -0,0 +1 @@
1
+ export {};
@@ -9,4 +9,3 @@ export declare class DeleteChain extends SqlStatement implements ChainDelete {
9
9
  where(where: Constructable<ConditionParam | void>): ChainDeleteReturning;
10
10
  genSql(): string;
11
11
  }
12
- //# sourceMappingURL=delete_impl.d.ts.map
@@ -1,7 +1,6 @@
1
- import { SqlStatement, SqlTextStatementDataset } from '../SqlStatement.js';
2
- import { returningToString, whereToString } from '../_statement.js';
3
-
4
- class DeleteChain extends SqlStatement {
1
+ import { SqlStatement, SqlTextStatementDataset } from "../SqlStatement.js";
2
+ import { returningToString, whereToString } from "../_statement.js";
3
+ export class DeleteChain extends SqlStatement {
5
4
  sql;
6
5
  constructor(sql) {
7
6
  super();
@@ -27,5 +26,3 @@ class DeleteChain extends SqlStatement {
27
26
  return this.sql;
28
27
  }
29
28
  }
30
-
31
- export { DeleteChain };
@@ -1,4 +1,3 @@
1
1
  import { InsertIntoSqlGenerator } from "./insert_chain.ts";
2
2
  /** @public */
3
3
  export declare const insertInto: InsertIntoSqlGenerator;
4
- //# sourceMappingURL=insert.d.ts.map
@@ -1,7 +1,6 @@
1
- import { InsertChain } from './insert_impl.js';
2
-
1
+ import { InsertChain } from "./insert_impl.js";
3
2
  /** @public */
4
- const insertInto = function insertInto(table, columns) {
3
+ export const insertInto = function insertInto(table, columns) {
5
4
  if (columns) {
6
5
  return new InsertChain(`INSERT INTO ${table}(${columns.join(",")})`);
7
6
  }
@@ -9,5 +8,3 @@ const insertInto = function insertInto(table, columns) {
9
8
  return new InsertChain(`INSERT INTO ${table}`);
10
9
  }
11
10
  };
12
-
13
- export { insertInto };
@@ -8,6 +8,14 @@ export interface InsertIntoSqlGenerator {
8
8
  /** @public */
9
9
  export interface ChainAfterConflict {
10
10
  doNotThing(): ChainInsertReturning;
11
+ /**
12
+ * @example
13
+ * ```ts
14
+ * doUpdate("SET level= 89,name= 11") // " DO UPDATE SET level= 89,name= 11"
15
+ * doUpdate(["level= 89", "name= 11"]) // " DO UPDATE SET\nlevel= 89,name= 11"
16
+ * doUpdate({level: "89", name: "11"}) // " DO UPDATE SET\nlevel= 89,name= 11"
17
+ * ```
18
+ */
11
19
  doUpdate(set: Constructable<string | readonly string[] | Record<string, string>>): ChainInsertReturning;
12
20
  toString(): string;
13
21
  }
@@ -30,4 +38,3 @@ export interface ChainInsertAfterValues extends ChainInsertReturning {
30
38
  /** @public */
31
39
  export interface ChainInsertReturning extends ChainModifyReturning {
32
40
  }
33
- //# sourceMappingURL=insert_chain.d.ts.map
@@ -0,0 +1 @@
1
+ export {};
@@ -11,4 +11,3 @@ export declare class InsertChain extends SqlStatement implements ChainInsert {
11
11
  where(where: Constructable<ConditionParam | void>): ChainInsertReturning;
12
12
  genSql(): string;
13
13
  }
14
- //# sourceMappingURL=insert_impl.d.ts.map
@@ -1,8 +1,7 @@
1
- import { selectColumns } from '../util.js';
2
- import { whereToString, createUpdateSetFromObject } from '../_statement.js';
3
- import { SqlStatement, SqlTextStatementDataset } from '../SqlStatement.js';
4
-
5
- class InsertChain extends SqlStatement {
1
+ import { selectColumns } from "../util.js";
2
+ import { createUpdateSetFromObject, whereToString } from "../_statement.js";
3
+ import { SqlStatement, SqlTextStatementDataset } from "../SqlStatement.js";
4
+ export class InsertChain extends SqlStatement {
6
5
  sql;
7
6
  constructor(sql) {
8
7
  super();
@@ -95,5 +94,3 @@ class InsertAfterOnConflict {
95
94
  return this.sql;
96
95
  }
97
96
  }
98
-
99
- export { InsertChain };
@@ -7,4 +7,3 @@ export * from "./update_chain.ts";
7
7
  export * from "./delete.ts";
8
8
  export * from "./delete_chain.ts";
9
9
  export * from "./cte.ts";
10
- //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1,9 @@
1
+ export * from "./select.js";
2
+ export * from "./select_chain.js";
3
+ export * from "./insert.js";
4
+ export * from "./insert_chain.js";
5
+ export * from "./update.js";
6
+ export * from "./update_chain.js";
7
+ export * from "./delete.js";
8
+ export * from "./delete_chain.js";
9
+ export * from "./cte.js";
@@ -2,4 +2,3 @@ import { SelectSqlGenerator } from "./select_chain.ts";
2
2
  /** @public */
3
3
  export declare const select: SelectSqlGenerator;
4
4
  export { orderBy } from "./select_impl.ts";
5
- //# sourceMappingURL=select.d.ts.map
@@ -1,14 +1,11 @@
1
- import { selectColumns } from '../util.js';
2
- import { SelectChainAfterSelect } from './select_impl.js';
3
- export { orderBy } from './select_impl.js';
4
-
1
+ import { selectColumns } from "../util.js";
2
+ import { SelectChainAfterSelect } from "./select_impl.js";
5
3
  /** @public */
6
- const select = function select(columns) {
4
+ export const select = function select(columns) {
7
5
  if (!columns)
8
6
  return new SelectChainAfterSelect("SELECT ");
9
7
  if (typeof columns === "function")
10
8
  columns = columns();
11
9
  return new SelectChainAfterSelect("SELECT " + selectColumns(columns));
12
10
  };
13
-
14
- export { select };
11
+ export { orderBy } from "./select_impl.js";
@@ -111,4 +111,3 @@ export type OrderBehavior = {
111
111
  /** @public */
112
112
  export type OrderByParam = string | OrderBehavior | (string | OrderBehavior)[];
113
113
  export {};
114
- //# sourceMappingURL=select_chain.d.ts.map
@@ -0,0 +1 @@
1
+ export {};
@@ -28,4 +28,3 @@ export declare class SelectChainAfterSelect<T extends TableType> implements Chai
28
28
  * ```
29
29
  */
30
30
  export declare function orderBy(by?: Constructable<OrderByParam | void>): string;
31
- //# sourceMappingURL=select_impl.d.ts.map
@@ -1,7 +1,6 @@
1
- import { selectableToString, whereToString, condition } from '../_statement.js';
2
- import { SqlTextStatementDataset } from '../SqlStatement.js';
3
-
4
- class SelectChainAfterSelect {
1
+ import { condition, selectableToString, whereToString } from "../_statement.js";
2
+ import { SqlTextStatementDataset } from "../SqlStatement.js";
3
+ export class SelectChainAfterSelect {
5
4
  constructor(sql) {
6
5
  this.#sql = sql;
7
6
  }
@@ -107,7 +106,7 @@ function havingToString(conditions, type) {
107
106
  *
108
107
  * ```
109
108
  */
110
- function orderBy(by) {
109
+ export function orderBy(by) {
111
110
  if (typeof by === "function")
112
111
  by = by();
113
112
  let sql = "";
@@ -142,5 +141,3 @@ function handlerOrderValue(value) {
142
141
  }
143
142
  return value.key + " " + target;
144
143
  }
145
-
146
- export { SelectChainAfterSelect, orderBy };
@@ -1,4 +1,3 @@
1
1
  import { UpdateSqlGenerator } from "./update_chain.ts";
2
2
  /** @public */
3
3
  export declare const update: UpdateSqlGenerator;
4
- //# sourceMappingURL=update.d.ts.map
@@ -1,12 +1,9 @@
1
- import { UpdateChain } from './update_impl.js';
2
-
1
+ import { UpdateChain } from "./update_impl.js";
3
2
  /** @public */
4
- const update = function update(table, options) {
3
+ export const update = function update(table, options) {
5
4
  let sql = `UPDATE ${table}`;
6
5
  if (options?.as) {
7
6
  sql += ` AS ${options.as}`;
8
7
  }
9
8
  return new UpdateChain(sql);
10
9
  };
11
-
12
- export { update };
@@ -49,4 +49,3 @@ export interface ChainUpdateAfterForm extends ChainUpdateReturning {
49
49
  /** @public */
50
50
  export interface ChainUpdateReturning extends ChainModifyReturning {
51
51
  }
52
- //# sourceMappingURL=update_chain.d.ts.map
@@ -0,0 +1 @@
1
+ export {};
@@ -20,4 +20,3 @@ export declare class UpdateChain extends SqlStatement implements ChainUpdate {
20
20
  where(where: Constructable<ConditionParam | void>): ChainUpdateReturning;
21
21
  genSql(): string;
22
22
  }
23
- //# sourceMappingURL=update_impl.d.ts.map
@@ -1,8 +1,7 @@
1
- import { selectColumns } from '../util.js';
2
- import { SqlStatement, SqlTextStatementDataset } from '../SqlStatement.js';
3
- import { createUpdateSetFromObject, whereToString } from '../_statement.js';
4
-
5
- class UpdateChain extends SqlStatement {
1
+ import { selectColumns } from "../util.js";
2
+ import { SqlStatement, SqlTextStatementDataset } from "../SqlStatement.js";
3
+ import { createUpdateSetFromObject, whereToString } from "../_statement.js";
4
+ export class UpdateChain extends SqlStatement {
6
5
  sql;
7
6
  constructor(sql) {
8
7
  super();
@@ -68,5 +67,3 @@ class UpdateChain extends SqlStatement {
68
67
  return this.sql;
69
68
  }
70
69
  }
71
-
72
- export { UpdateChain };
@@ -34,4 +34,3 @@ export type UpdateRowValue<T extends object> = {
34
34
  export type TableType = {
35
35
  [key: string]: any;
36
36
  };
37
- //# sourceMappingURL=util.d.ts.map
@@ -6,7 +6,7 @@
6
6
  * selectColumns("c1,count(*) AS c2,column as c3") // "c1,count(*) AS c2,column as c3"
7
7
  * ```
8
8
  */
9
- function selectColumns(columns) {
9
+ export function selectColumns(columns) {
10
10
  if (typeof columns === "function")
11
11
  columns = columns();
12
12
  switch (typeof columns) {
@@ -45,5 +45,3 @@ function selectColumns(columns) {
45
45
  throw new TypeError("columns 应为 string 或 object 类型");
46
46
  }
47
47
  }
48
-
49
- export { selectColumns };
@@ -10,4 +10,3 @@ export declare class TypeChecker<T> {
10
10
  private checkArray;
11
11
  private checkItem;
12
12
  }
13
- //# sourceMappingURL=checker.d.ts.map
@@ -1,7 +1,6 @@
1
- import { CustomDbType } from './infer_db_type.js';
2
-
1
+ import { CustomDbType } from "./infer_db_type.js";
3
2
  /** @public */
4
- class TypeChecker {
3
+ export class TypeChecker {
5
4
  map;
6
5
  constructor(map) {
7
6
  this.map = map;
@@ -78,5 +77,3 @@ class TypeChecker {
78
77
  function getErrStr(expect, actual) {
79
78
  return `Expect ${expect}, Actual ${actual}`;
80
79
  }
81
-
82
- export { TypeChecker };
@@ -71,4 +71,3 @@ export type InferTableDefined<T extends TableDefined> = {
71
71
  [key in keyof T]: T[key] extends ColumnMeta<infer P> ? P : unknown;
72
72
  };
73
73
  export {};
74
- //# sourceMappingURL=infer_db_type.d.ts.map
@@ -2,7 +2,7 @@
2
2
  * 表格列的信息
3
3
  * @public
4
4
  */
5
- class ColumnMeta {
5
+ export class ColumnMeta {
6
6
  type;
7
7
  sqlType;
8
8
  notNull;
@@ -34,7 +34,7 @@ class ColumnMeta {
34
34
  * 数据库类型到JS类型的映射
35
35
  * @public
36
36
  */
37
- class YourTypeMap {
37
+ export class YourTypeMap {
38
38
  typeMap;
39
39
  static create(rawTypeMap) {
40
40
  return new this(rawTypeMap);
@@ -60,7 +60,7 @@ function baseType(v) {
60
60
  * 自定义数据类型
61
61
  * @public
62
62
  */
63
- class CustomDbType {
63
+ export class CustomDbType {
64
64
  is;
65
65
  name;
66
66
  static bigint = new CustomDbType(baseType, "bigint");
@@ -72,5 +72,3 @@ class CustomDbType {
72
72
  this.name = name;
73
73
  }
74
74
  }
75
-
76
- export { ColumnMeta, CustomDbType, YourTypeMap };
@@ -1,4 +1,3 @@
1
1
  export * from "./checker.ts";
2
2
  export * from "./infer_db_type.ts";
3
3
  export * from "./table.ts";
4
- //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1,3 @@
1
+ export * from "./checker.js";
2
+ export * from "./infer_db_type.js";
3
+ export * from "./table.js";
@@ -13,4 +13,3 @@ export declare class YourTable<T extends TableType = TableType> {
13
13
  getColumnMeta(name: keyof T): ColumnMeta<unknown>;
14
14
  createTypeChecker<T>(keys: readonly string[]): TypeChecker<T>;
15
15
  }
16
- //# sourceMappingURL=table.d.ts.map
@@ -1,10 +1,9 @@
1
- import { TypeChecker } from './checker.js';
2
-
1
+ import { TypeChecker } from "./checker.js";
3
2
  /**
4
3
  * 完整数据库表数据
5
4
  * @public
6
5
  */
7
- class YourTable {
6
+ export class YourTable {
8
7
  name;
9
8
  define;
10
9
  constructor(name, define) {
@@ -29,5 +28,3 @@ class YourTable {
29
28
  return new TypeChecker(map);
30
29
  }
31
30
  }
32
-
33
- export { YourTable };
package/package.json CHANGED
@@ -1,54 +1,51 @@
1
1
  {
2
2
  "name": "@asla/yoursql",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "",
5
- "type": "module",
6
- "types": "./dist/mod.d.ts",
7
- "packageManager": "pnpm@10.4.0",
8
- "scripts": {
9
- "ci:test": "vitest run",
10
- "ci:build": "pnpm rollup -c build/rollup.config.js",
11
- "build": "pnpm rollup -c build/rollup.config.js && pnpm run ci:check-api -l",
12
- "test": "vitest",
13
- "type:check": "tsc",
14
- "publish-check": "deno publish --dry-run --allow-dirty",
15
- "ci:check-api": "api-extractor run -c api-extractor.jsonc -v"
16
- },
17
- "devDependencies": {
18
- "@microsoft/api-extractor": "^7.47.9",
19
- "@rollup/plugin-typescript": "^12.1.0",
20
- "prettier": "^3.5.3",
21
- "rollup": "^4.22.4",
22
- "tslib": "^2.7.0",
23
- "typescript": "^5.6.2",
24
- "vitest": "^2.1.1"
5
+ "keywords": [
6
+ "sql"
7
+ ],
8
+ "license": "MIT",
9
+ "author": {
10
+ "name": "Eavid",
11
+ "url": "https://github.com/eavidy"
25
12
  },
26
13
  "repository": {
27
14
  "type": "git",
28
15
  "url": "https://github.com/asnowc/yoursql"
29
16
  },
30
- "exports": {
31
- ".": "./dist/sql_gen/mod.js",
32
- "./client": "./dist/client/mod.js"
33
- },
34
17
  "files": [
35
18
  "dist/**/*.js",
36
19
  "dist/**/*d.ts"
37
20
  ],
21
+ "type": "module",
22
+ "types": "./dist/mod.d.ts",
23
+ "exports": {
24
+ ".": "./dist/sql_gen/mod.js"
25
+ },
38
26
  "publishConfig": {
39
27
  "access": "public",
40
- "registry": "https://registry.npmjs.org",
41
- "provenance": true
28
+ "provenance": true,
29
+ "registry": "https://registry.npmjs.org"
42
30
  },
43
- "keywords": [
44
- "sql"
45
- ],
46
- "author": {
47
- "name": "Eavid",
48
- "url": "https://github.com/eavidy"
31
+ "scripts": {
32
+ "ci:test": "vitest run",
33
+ "ci:build": "tsc -p tsconfig.lib.json",
34
+ "build": "tsc -p tsconfig.lib.json",
35
+ "test": "vitest",
36
+ "type:check": "tsc -p tsconfig.lib.json --noEmit && tsc -p tsconfig.node.json --noEmit",
37
+ "publish-check": "deno publish --dry-run --allow-dirty"
38
+ },
39
+ "devDependencies": {
40
+ "@types/node": "^25.6.2",
41
+ "oxfmt": "^0.48.0",
42
+ "tslib": "^2.8.1",
43
+ "typescript": "^6.0.3",
44
+ "vite": "^8.0.11",
45
+ "vitest": "^4.1.5"
49
46
  },
50
47
  "engines": {
51
48
  "node": ">=18"
52
49
  },
53
- "license": "MIT"
50
+ "packageManager": "pnpm@11.0.9"
54
51
  }
@@ -1,14 +0,0 @@
1
- /** @public */
2
- export interface DbCursorOption {
3
- defaultSize?: number;
4
- }
5
- /** @public */
6
- export declare abstract class DbCursor<T> implements AsyncDisposable, AsyncIterable<T> {
7
- /** 读取游标,如果读取结束,返回空数组 */
8
- abstract read(maxSize?: number): Promise<T[]>;
9
- /** 提前关闭游标,如果多次调用,会被忽略 */
10
- abstract close(): Promise<void>;
11
- [Symbol.asyncDispose](): Promise<void>;
12
- [Symbol.asyncIterator](): AsyncGenerator<T, undefined, void>;
13
- }
14
- //# sourceMappingURL=DbCursor.d.ts.map