@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.
- package/README.md +22 -206
- package/dist/sql_gen/SqlStatement.d.ts +0 -1
- package/dist/sql_gen/SqlStatement.js +3 -5
- package/dist/sql_gen/_statement.d.ts +0 -1
- package/dist/sql_gen/_statement.js +10 -13
- package/dist/sql_gen/mod.d.ts +0 -1
- package/dist/sql_gen/mod.js +10 -19
- package/dist/sql_gen/sql_value/SqlValuesDataset.d.ts +28 -0
- package/dist/sql_gen/sql_value/SqlValuesDataset.js +51 -0
- package/dist/sql_gen/sql_value/ValueSqlTemplate.d.ts +0 -1
- package/dist/sql_gen/sql_value/ValueSqlTemplate.js +2 -5
- package/dist/sql_gen/sql_value/_to_values.d.ts +0 -1
- package/dist/sql_gen/sql_value/_to_values.js +5 -8
- package/dist/sql_gen/sql_value/db_type.d.ts +0 -1
- package/dist/sql_gen/sql_value/db_type.js +2 -5
- package/dist/sql_gen/sql_value/sql_value.d.ts +3 -25
- package/dist/sql_gen/sql_value/sql_value.js +7 -60
- package/dist/sql_gen/sql_value/type.d.ts +0 -1
- package/dist/sql_gen/sql_value/type.js +1 -0
- package/dist/sql_gen/statement/_modify.d.ts +0 -1
- package/dist/sql_gen/statement/_modify.js +1 -0
- package/dist/sql_gen/statement/cte.d.ts +0 -1
- package/dist/sql_gen/statement/cte.js +7 -10
- package/dist/sql_gen/statement/delete.d.ts +0 -1
- package/dist/sql_gen/statement/delete.js +2 -5
- package/dist/sql_gen/statement/delete_chain.d.ts +0 -1
- package/dist/sql_gen/statement/delete_chain.js +1 -0
- package/dist/sql_gen/statement/delete_impl.d.ts +0 -1
- package/dist/sql_gen/statement/delete_impl.js +3 -6
- package/dist/sql_gen/statement/insert.d.ts +0 -1
- package/dist/sql_gen/statement/insert.js +2 -5
- package/dist/sql_gen/statement/insert_chain.d.ts +8 -1
- package/dist/sql_gen/statement/insert_chain.js +1 -0
- package/dist/sql_gen/statement/insert_impl.d.ts +0 -1
- package/dist/sql_gen/statement/insert_impl.js +4 -7
- package/dist/sql_gen/statement/mod.d.ts +0 -1
- package/dist/sql_gen/statement/mod.js +9 -0
- package/dist/sql_gen/statement/select.d.ts +0 -1
- package/dist/sql_gen/statement/select.js +4 -7
- package/dist/sql_gen/statement/select_chain.d.ts +0 -1
- package/dist/sql_gen/statement/select_chain.js +1 -0
- package/dist/sql_gen/statement/select_impl.d.ts +0 -1
- package/dist/sql_gen/statement/select_impl.js +4 -7
- package/dist/sql_gen/statement/update.d.ts +0 -1
- package/dist/sql_gen/statement/update.js +2 -5
- package/dist/sql_gen/statement/update_chain.d.ts +0 -1
- package/dist/sql_gen/statement/update_chain.js +1 -0
- package/dist/sql_gen/statement/update_impl.d.ts +0 -1
- package/dist/sql_gen/statement/update_impl.js +4 -7
- package/dist/sql_gen/util.d.ts +0 -1
- package/dist/sql_gen/util.js +1 -3
- package/dist/sql_gen/your_table/checker.d.ts +0 -1
- package/dist/sql_gen/your_table/checker.js +2 -5
- package/dist/sql_gen/your_table/infer_db_type.d.ts +0 -1
- package/dist/sql_gen/your_table/infer_db_type.js +3 -5
- package/dist/sql_gen/your_table/mod.d.ts +0 -1
- package/dist/sql_gen/your_table/mod.js +3 -0
- package/dist/sql_gen/your_table/table.d.ts +0 -1
- package/dist/sql_gen/your_table/table.js +2 -5
- package/package.json +31 -34
- package/dist/client/DbCursor.d.ts +0 -14
- package/dist/client/DbCursor.js +0 -21
- package/dist/client/DbPoolConnection.d.ts +0 -5
- package/dist/client/DbPoolConnection.js +0 -74
- package/dist/client/DbPoolTransaction.d.ts +0 -9
- package/dist/client/DbPoolTransaction.js +0 -146
- package/dist/client/DbQuery.d.ts +0 -50
- package/dist/client/DbQuery.js +0 -42
- package/dist/client/DbQueryBase.d.ts +0 -38
- package/dist/client/DbQueryBase.js +0 -32
- package/dist/client/DbQueryPool.d.ts +0 -39
- package/dist/client/DbQueryPool.js +0 -56
- package/dist/client/_type.d.ts +0 -2
- package/dist/client/errors.d.ts +0 -9
- package/dist/client/errors.js +0 -14
- package/dist/client/interfaces.d.ts +0 -87
- package/dist/client/mod.d.ts +0 -9
- package/dist/client/mod.js +0 -7
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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
|
|
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
|
|
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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
|
2
|
-
import { SelectChainAfterSelect } from
|
|
3
|
-
import { DeleteChain } from
|
|
4
|
-
import { UpdateChain } from
|
|
5
|
-
import { InsertChain } from
|
|
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,12 +1,9 @@
|
|
|
1
|
-
import { DeleteChain } from
|
|
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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { SqlStatement, SqlTextStatementDataset } from
|
|
2
|
-
import { returningToString, whereToString } from
|
|
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,7 +1,6 @@
|
|
|
1
|
-
import { InsertChain } from
|
|
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 {};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { selectColumns } from
|
|
2
|
-
import {
|
|
3
|
-
import { SqlStatement, SqlTextStatementDataset } from
|
|
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 };
|
|
@@ -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";
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { selectColumns } from
|
|
2
|
-
import { SelectChainAfterSelect } from
|
|
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";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { selectableToString, whereToString
|
|
2
|
-
import { SqlTextStatementDataset } from
|
|
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,12 +1,9 @@
|
|
|
1
|
-
import { UpdateChain } from
|
|
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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { selectColumns } from
|
|
2
|
-
import { SqlStatement, SqlTextStatementDataset } from
|
|
3
|
-
import { createUpdateSetFromObject, whereToString } from
|
|
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 };
|
package/dist/sql_gen/util.d.ts
CHANGED
package/dist/sql_gen/util.js
CHANGED
|
@@ -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 };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { CustomDbType } from
|
|
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 };
|
|
@@ -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,10 +1,9 @@
|
|
|
1
|
-
import { TypeChecker } from
|
|
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.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
"
|
|
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
|
-
"
|
|
41
|
-
"
|
|
28
|
+
"provenance": true,
|
|
29
|
+
"registry": "https://registry.npmjs.org"
|
|
42
30
|
},
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
"
|
|
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
|
-
"
|
|
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
|