forge-sql-orm 2.0.17 → 2.0.19
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 +95 -4
- package/dist/ForgeSQLORM.js +382 -60
- package/dist/ForgeSQLORM.js.map +1 -1
- package/dist/ForgeSQLORM.mjs +382 -60
- package/dist/ForgeSQLORM.mjs.map +1 -1
- package/dist/core/ForgeSQLAnalyseOperations.d.ts +250 -0
- package/dist/core/ForgeSQLAnalyseOperations.d.ts.map +1 -0
- package/dist/core/ForgeSQLCrudOperations.d.ts +1 -1
- package/dist/core/ForgeSQLCrudOperations.d.ts.map +1 -1
- package/dist/core/ForgeSQLORM.d.ts +12 -2
- package/dist/core/ForgeSQLORM.d.ts.map +1 -1
- package/dist/core/ForgeSQLQueryBuilder.d.ts +112 -21
- package/dist/core/ForgeSQLQueryBuilder.d.ts.map +1 -1
- package/dist/core/ForgeSQLSelectOperations.d.ts.map +1 -1
- package/dist/core/SystemTables.d.ts +167 -0
- package/dist/core/SystemTables.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/utils/forgeDriverProxy.d.ts +11 -0
- package/dist/utils/forgeDriverProxy.d.ts.map +1 -0
- package/dist/utils/sqlHints.d.ts +21 -0
- package/dist/utils/sqlHints.d.ts.map +1 -0
- package/dist/utils/sqlUtils.d.ts +2 -8
- package/dist/utils/sqlUtils.d.ts.map +1 -1
- package/dist/webtriggers/applyMigrationsWebTrigger.d.ts.map +1 -1
- package/dist/webtriggers/dropMigrationWebTrigger.d.ts +2 -4
- package/dist/webtriggers/dropMigrationWebTrigger.d.ts.map +1 -1
- package/package.json +4 -12
- package/src/core/ForgeSQLAnalyseOperations.ts +461 -0
- package/src/core/ForgeSQLCrudOperations.ts +15 -8
- package/src/core/ForgeSQLORM.ts +46 -9
- package/src/core/ForgeSQLQueryBuilder.ts +129 -32
- package/src/core/ForgeSQLSelectOperations.ts +4 -6
- package/src/core/SystemTables.ts +175 -0
- package/src/index.ts +1 -0
- package/src/utils/forgeDriverProxy.ts +27 -0
- package/src/utils/sqlHints.ts +63 -0
- package/src/utils/sqlUtils.ts +36 -32
- package/src/webtriggers/applyMigrationsWebTrigger.ts +32 -16
- package/src/webtriggers/dropMigrationWebTrigger.ts +5 -6
- package/src/webtriggers/fetchSchemaWebTrigger.ts +2 -10
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { ForgeSqlOperation, SchemaAnalyzeForgeSql } from "./ForgeSQLQueryBuilder";
|
|
2
|
+
import { Query } from "drizzle-orm";
|
|
3
|
+
import { ClusterStatementRowCamelCase, ExplainAnalyzeRow, SlowQueryNormalized } from "./SystemTables";
|
|
4
|
+
import { AnyMySqlTable } from "drizzle-orm/mysql-core/index";
|
|
5
|
+
/**
|
|
6
|
+
* Interface representing a raw slow query row from the database
|
|
7
|
+
*/
|
|
8
|
+
interface SlowQueryRaw {
|
|
9
|
+
Time: string;
|
|
10
|
+
Txn_start_ts: number;
|
|
11
|
+
User: string;
|
|
12
|
+
Host: string;
|
|
13
|
+
Conn_ID: number;
|
|
14
|
+
DB: string;
|
|
15
|
+
Query: string;
|
|
16
|
+
Digest: string;
|
|
17
|
+
Query_time: number;
|
|
18
|
+
Compile_time: number;
|
|
19
|
+
Optimize_time: number;
|
|
20
|
+
Process_time: number;
|
|
21
|
+
Wait_time: number;
|
|
22
|
+
Parse_time: number;
|
|
23
|
+
Rewrite_time: number;
|
|
24
|
+
Cop_time: number;
|
|
25
|
+
Cop_proc_avg: number;
|
|
26
|
+
Cop_proc_max: number;
|
|
27
|
+
Cop_proc_p90: number;
|
|
28
|
+
Cop_proc_addr: string;
|
|
29
|
+
Cop_wait_avg: number;
|
|
30
|
+
Cop_wait_max: number;
|
|
31
|
+
Cop_wait_p90: number;
|
|
32
|
+
Cop_wait_addr: string;
|
|
33
|
+
Mem_max: number;
|
|
34
|
+
Disk_max: number;
|
|
35
|
+
Total_keys: number;
|
|
36
|
+
Process_keys: number;
|
|
37
|
+
Request_count: number;
|
|
38
|
+
KV_total: number;
|
|
39
|
+
PD_total: number;
|
|
40
|
+
Result_rows: number;
|
|
41
|
+
Rocksdb_block_cache_hit_count: number;
|
|
42
|
+
Rocksdb_block_read_count: number;
|
|
43
|
+
Rocksdb_block_read_byte: number;
|
|
44
|
+
Plan: string;
|
|
45
|
+
Binary_plan: string;
|
|
46
|
+
Plan_digest: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Interface representing a row from the cluster statements table
|
|
50
|
+
*/
|
|
51
|
+
export interface ClusterStatementRow {
|
|
52
|
+
INSTANCE: string;
|
|
53
|
+
SUMMARY_BEGIN_TIME: string;
|
|
54
|
+
SUMMARY_END_TIME: string;
|
|
55
|
+
STMT_TYPE: string;
|
|
56
|
+
SCHEMA_NAME: string;
|
|
57
|
+
DIGEST: string;
|
|
58
|
+
DIGEST_TEXT: string;
|
|
59
|
+
TABLE_NAMES: string;
|
|
60
|
+
INDEX_NAMES: string | null;
|
|
61
|
+
SAMPLE_USER: string;
|
|
62
|
+
EXEC_COUNT: number;
|
|
63
|
+
SUM_ERRORS: number;
|
|
64
|
+
SUM_WARNINGS: number;
|
|
65
|
+
SUM_LATENCY: number;
|
|
66
|
+
MAX_LATENCY: number;
|
|
67
|
+
MIN_LATENCY: number;
|
|
68
|
+
AVG_LATENCY: number;
|
|
69
|
+
AVG_PARSE_LATENCY: number;
|
|
70
|
+
MAX_PARSE_LATENCY: number;
|
|
71
|
+
AVG_COMPILE_LATENCY: number;
|
|
72
|
+
MAX_COMPILE_LATENCY: number;
|
|
73
|
+
SUM_COP_TASK_NUM: number;
|
|
74
|
+
MAX_COP_PROCESS_TIME: number;
|
|
75
|
+
MAX_COP_PROCESS_ADDRESS: string;
|
|
76
|
+
MAX_COP_WAIT_TIME: number;
|
|
77
|
+
MAX_COP_WAIT_ADDRESS: string;
|
|
78
|
+
AVG_PROCESS_TIME: number;
|
|
79
|
+
MAX_PROCESS_TIME: number;
|
|
80
|
+
AVG_WAIT_TIME: number;
|
|
81
|
+
MAX_WAIT_TIME: number;
|
|
82
|
+
AVG_BACKOFF_TIME: number;
|
|
83
|
+
MAX_BACKOFF_TIME: number;
|
|
84
|
+
AVG_TOTAL_KEYS: number;
|
|
85
|
+
MAX_TOTAL_KEYS: number;
|
|
86
|
+
AVG_PROCESSED_KEYS: number;
|
|
87
|
+
MAX_PROCESSED_KEYS: number;
|
|
88
|
+
AVG_ROCKSDB_DELETE_SKIPPED_COUNT: number;
|
|
89
|
+
MAX_ROCKSDB_DELETE_SKIPPED_COUNT: number;
|
|
90
|
+
AVG_ROCKSDB_KEY_SKIPPED_COUNT: number;
|
|
91
|
+
MAX_ROCKSDB_KEY_SKIPPED_COUNT: number;
|
|
92
|
+
AVG_ROCKSDB_BLOCK_CACHE_HIT_COUNT: number;
|
|
93
|
+
MAX_ROCKSDB_BLOCK_CACHE_HIT_COUNT: number;
|
|
94
|
+
AVG_ROCKSDB_BLOCK_READ_COUNT: number;
|
|
95
|
+
MAX_ROCKSDB_BLOCK_READ_COUNT: number;
|
|
96
|
+
AVG_ROCKSDB_BLOCK_READ_BYTE: number;
|
|
97
|
+
MAX_ROCKSDB_BLOCK_READ_BYTE: number;
|
|
98
|
+
AVG_PREWRITE_TIME: number;
|
|
99
|
+
MAX_PREWRITE_TIME: number;
|
|
100
|
+
AVG_COMMIT_TIME: number;
|
|
101
|
+
MAX_COMMIT_TIME: number;
|
|
102
|
+
AVG_GET_COMMIT_TS_TIME: number;
|
|
103
|
+
MAX_GET_COMMIT_TS_TIME: number;
|
|
104
|
+
AVG_COMMIT_BACKOFF_TIME: number;
|
|
105
|
+
MAX_COMMIT_BACKOFF_TIME: number;
|
|
106
|
+
AVG_RESOLVE_LOCK_TIME: number;
|
|
107
|
+
MAX_RESOLVE_LOCK_TIME: number;
|
|
108
|
+
AVG_LOCAL_LATCH_WAIT_TIME: number;
|
|
109
|
+
MAX_LOCAL_LATCH_WAIT_TIME: number;
|
|
110
|
+
AVG_WRITE_KEYS: number;
|
|
111
|
+
MAX_WRITE_KEYS: number;
|
|
112
|
+
AVG_WRITE_SIZE: number;
|
|
113
|
+
MAX_WRITE_SIZE: number;
|
|
114
|
+
AVG_PREWRITE_REGIONS: number;
|
|
115
|
+
MAX_PREWRITE_REGIONS: number;
|
|
116
|
+
AVG_TXN_RETRY: number;
|
|
117
|
+
MAX_TXN_RETRY: number;
|
|
118
|
+
SUM_EXEC_RETRY: number;
|
|
119
|
+
SUM_EXEC_RETRY_TIME: number;
|
|
120
|
+
SUM_BACKOFF_TIMES: number;
|
|
121
|
+
BACKOFF_TYPES: string | null;
|
|
122
|
+
AVG_MEM: number;
|
|
123
|
+
MAX_MEM: number;
|
|
124
|
+
AVG_DISK: number;
|
|
125
|
+
MAX_DISK: number;
|
|
126
|
+
AVG_KV_TIME: number;
|
|
127
|
+
AVG_PD_TIME: number;
|
|
128
|
+
AVG_BACKOFF_TOTAL_TIME: number;
|
|
129
|
+
AVG_WRITE_SQL_RESP_TIME: number;
|
|
130
|
+
AVG_TIDB_CPU_TIME: number;
|
|
131
|
+
AVG_TIKV_CPU_TIME: number;
|
|
132
|
+
MAX_RESULT_ROWS: number;
|
|
133
|
+
MIN_RESULT_ROWS: number;
|
|
134
|
+
AVG_RESULT_ROWS: number;
|
|
135
|
+
PREPARED: number;
|
|
136
|
+
AVG_AFFECTED_ROWS: number;
|
|
137
|
+
FIRST_SEEN: string;
|
|
138
|
+
LAST_SEEN: string;
|
|
139
|
+
PLAN_IN_CACHE: number;
|
|
140
|
+
PLAN_CACHE_HITS: number;
|
|
141
|
+
PLAN_IN_BINDING: number;
|
|
142
|
+
QUERY_SAMPLE_TEXT: string;
|
|
143
|
+
PREV_SAMPLE_TEXT: string;
|
|
144
|
+
PLAN_DIGEST: string;
|
|
145
|
+
PLAN: string;
|
|
146
|
+
BINARY_PLAN: string;
|
|
147
|
+
CHARSET: string;
|
|
148
|
+
COLLATION: string;
|
|
149
|
+
PLAN_HINT: string;
|
|
150
|
+
MAX_REQUEST_UNIT_READ: number;
|
|
151
|
+
AVG_REQUEST_UNIT_READ: number;
|
|
152
|
+
MAX_REQUEST_UNIT_WRITE: number;
|
|
153
|
+
AVG_REQUEST_UNIT_WRITE: number;
|
|
154
|
+
MAX_QUEUED_RC_TIME: number;
|
|
155
|
+
AVG_QUEUED_RC_TIME: number;
|
|
156
|
+
RESOURCE_GROUP: string;
|
|
157
|
+
PLAN_CACHE_UNQUALIFIED: number;
|
|
158
|
+
PLAN_CACHE_UNQUALIFIED_LAST_REASON: string;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Class implementing SQL analysis operations for ForgeSQL ORM.
|
|
162
|
+
* Provides methods for analyzing query performance, execution plans, and slow queries.
|
|
163
|
+
*/
|
|
164
|
+
export declare class ForgeSQLAnalyseOperation implements SchemaAnalyzeForgeSql {
|
|
165
|
+
private readonly forgeOperations;
|
|
166
|
+
/**
|
|
167
|
+
* Creates a new instance of ForgeSQLAnalizeOperation.
|
|
168
|
+
* @param {ForgeSqlOperation} forgeOperations - The ForgeSQL operations instance
|
|
169
|
+
*/
|
|
170
|
+
constructor(forgeOperations: ForgeSqlOperation);
|
|
171
|
+
/**
|
|
172
|
+
* Executes EXPLAIN on a raw SQL query.
|
|
173
|
+
* @param {string} query - The SQL query to analyze
|
|
174
|
+
* @param {unknown[]} bindParams - The query parameters
|
|
175
|
+
* @returns {Promise<ExplainAnalyzeRow[]>} The execution plan analysis results
|
|
176
|
+
*/
|
|
177
|
+
explainRaw(query: string, bindParams: unknown[]): Promise<ExplainAnalyzeRow[]>;
|
|
178
|
+
/**
|
|
179
|
+
* Executes EXPLAIN on a Drizzle query.
|
|
180
|
+
* @param {{ toSQL: () => Query }} query - The Drizzle query to analyze
|
|
181
|
+
* @returns {Promise<ExplainAnalyzeRow[]>} The execution plan analysis results
|
|
182
|
+
*/
|
|
183
|
+
explain(query: {
|
|
184
|
+
toSQL: () => Query;
|
|
185
|
+
}): Promise<ExplainAnalyzeRow[]>;
|
|
186
|
+
/**
|
|
187
|
+
* Executes EXPLAIN ANALYZE on a raw SQL query.
|
|
188
|
+
* @param {string} query - The SQL query to analyze
|
|
189
|
+
* @param {unknown[]} bindParams - The query parameters
|
|
190
|
+
* @returns {Promise<ExplainAnalyzeRow[]>} The execution plan analysis results
|
|
191
|
+
*/
|
|
192
|
+
explainAnalyzeRaw(query: string, bindParams: unknown[]): Promise<ExplainAnalyzeRow[]>;
|
|
193
|
+
/**
|
|
194
|
+
* Executes EXPLAIN ANALYZE on a Drizzle query.
|
|
195
|
+
* @param {{ toSQL: () => Query }} query - The Drizzle query to analyze
|
|
196
|
+
* @returns {Promise<ExplainAnalyzeRow[]>} The execution plan analysis results
|
|
197
|
+
*/
|
|
198
|
+
explainAnalyze(query: {
|
|
199
|
+
toSQL: () => Query;
|
|
200
|
+
}): Promise<ExplainAnalyzeRow[]>;
|
|
201
|
+
/**
|
|
202
|
+
* Decodes a query execution plan from its string representation.
|
|
203
|
+
* @param {string} input - The raw execution plan string
|
|
204
|
+
* @returns {ExplainAnalyzeRow[]} The decoded execution plan rows
|
|
205
|
+
*/
|
|
206
|
+
decodedPlan(input: string): ExplainAnalyzeRow[];
|
|
207
|
+
/**
|
|
208
|
+
* Normalizes a raw slow query row into a more structured format.
|
|
209
|
+
* @param {SlowQueryRaw} row - The raw slow query data
|
|
210
|
+
* @returns {SlowQueryNormalized} The normalized slow query data
|
|
211
|
+
*/
|
|
212
|
+
normalizeSlowQuery(row: SlowQueryRaw): SlowQueryNormalized;
|
|
213
|
+
/**
|
|
214
|
+
* Builds a SQL query for retrieving cluster statement history.
|
|
215
|
+
* @param {string[]} tables - The tables to analyze
|
|
216
|
+
* @param {Date} [from] - The start date for the analysis
|
|
217
|
+
* @param {Date} [to] - The end date for the analysis
|
|
218
|
+
* @returns {string} The SQL query for cluster statement history
|
|
219
|
+
*/
|
|
220
|
+
buildClusterStatementQuery(tables: string[], from?: Date, to?: Date): string;
|
|
221
|
+
/**
|
|
222
|
+
* Retrieves and analyzes slow queries from the database.
|
|
223
|
+
* @returns {Promise<SlowQueryNormalized[]>} The normalized slow query data
|
|
224
|
+
*/
|
|
225
|
+
analyzeSlowQueries(): Promise<SlowQueryNormalized[]>;
|
|
226
|
+
/**
|
|
227
|
+
* Converts a cluster statement row to camelCase format.
|
|
228
|
+
* @param {Record<string, any>} input - The input row data
|
|
229
|
+
* @returns {ClusterStatementRowCamelCase} The converted row data
|
|
230
|
+
*/
|
|
231
|
+
mapToCamelCaseClusterStatement(input: Record<string, any>): ClusterStatementRowCamelCase;
|
|
232
|
+
/**
|
|
233
|
+
* Analyzes query history for specific tables using raw table names.
|
|
234
|
+
* @param {string[]} tables - The table names to analyze
|
|
235
|
+
* @param {Date} [fromDate] - The start date for the analysis
|
|
236
|
+
* @param {Date} [toDate] - The end date for the analysis
|
|
237
|
+
* @returns {Promise<ClusterStatementRowCamelCase[]>} The analyzed query history
|
|
238
|
+
*/
|
|
239
|
+
analyzeQueriesHistoryRaw(tables: string[], fromDate?: Date, toDate?: Date): Promise<ClusterStatementRowCamelCase[]>;
|
|
240
|
+
/**
|
|
241
|
+
* Analyzes query history for specific tables using Drizzle table objects.
|
|
242
|
+
* @param {AnyMySqlTable[]} tables - The Drizzle table objects to analyze
|
|
243
|
+
* @param {Date} [fromDate] - The start date for the analysis
|
|
244
|
+
* @param {Date} [toDate] - The end date for the analysis
|
|
245
|
+
* @returns {Promise<ClusterStatementRowCamelCase[]>} The analyzed query history
|
|
246
|
+
*/
|
|
247
|
+
analyzeQueriesHistory(tables: AnyMySqlTable[], fromDate?: Date, toDate?: Date): Promise<ClusterStatementRowCamelCase[]>;
|
|
248
|
+
}
|
|
249
|
+
export {};
|
|
250
|
+
//# sourceMappingURL=ForgeSQLAnalyseOperations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ForgeSQLAnalyseOperations.d.ts","sourceRoot":"","sources":["../../src/core/ForgeSQLAnalyseOperations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;IAS1C;;;;;;OAMG;IACG,qBAAqB,CACzB,MAAM,EAAE,aAAa,EAAE,EACvB,QAAQ,CAAC,EAAE,IAAI,EACf,MAAM,CAAC,EAAE,IAAI,GACZ,OAAO,CAAC,4BAA4B,EAAE,CAAC;CAI3C"}
|
|
@@ -27,7 +27,7 @@ export declare class ForgeSQLCrudOperations implements CRUDForgeSQL {
|
|
|
27
27
|
* @returns {Promise<number>} The number of inserted rows
|
|
28
28
|
* @throws {Error} If the insert operation fails
|
|
29
29
|
*/
|
|
30
|
-
insert<T extends AnyMySqlTable>(schema: T, models:
|
|
30
|
+
insert<T extends AnyMySqlTable>(schema: T, models: InferInsertModel<T>[], updateIfExists?: boolean): Promise<number>;
|
|
31
31
|
/**
|
|
32
32
|
* Deletes a record by its primary key with optional version check.
|
|
33
33
|
* If versioning is enabled, ensures the record hasn't been modified since last read.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ForgeSQLCrudOperations.d.ts","sourceRoot":"","sources":["../../src/core/ForgeSQLCrudOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,IAAI,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAa,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAGlC;;;GAGG;AACH,qBAAa,sBAAuB,YAAW,YAAY;IACzD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAoB;IACpD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAE7C;;;;OAIG;gBACS,kBAAkB,EAAE,iBAAiB,EAAE,OAAO,EAAE,kBAAkB;IAK9E;;;;;;;;;;OAUG;IACG,MAAM,CAAC,CAAC,SAAS,aAAa,EAClC,MAAM,EAAE,CAAC,EACT,MAA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,EAAE,CAAC,EACT,KAAK,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,GACnB,OAAO,CAAC,MAAM,CAAC;IAiBlB;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;IAStB;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAoD5B;;;;;;;;;OASG;YACW,iBAAiB;IAyB/B;;;;;;;OAOG;IACH,OAAO,CAAC,uBAAuB;IA0B/B;;;;;;;;OAQG;IACH,OAAO,CAAC,iBAAiB;IAsBzB;;;;;;;;OAQG;YACW,WAAW;CA4B1B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CRUDForgeSQL, ForgeSqlOperation, ForgeSqlOrmOptions, SchemaSqlForgeSql } from "./ForgeSQLQueryBuilder";
|
|
1
|
+
import { CRUDForgeSQL, ForgeSqlOperation, ForgeSqlOrmOptions, SchemaAnalyzeForgeSql, SchemaSqlForgeSql } from "./ForgeSQLQueryBuilder";
|
|
2
2
|
import { MySqlRemoteDatabase, MySqlRemotePreparedQueryHKT } from "drizzle-orm/mysql-proxy";
|
|
3
3
|
import type { SelectedFields } from "drizzle-orm/mysql-core/query-builders/select.types";
|
|
4
4
|
import { MySqlSelectBuilder } from "drizzle-orm/mysql-core";
|
|
@@ -32,7 +32,7 @@ declare class ForgeSQLORM implements ForgeSqlOperation {
|
|
|
32
32
|
*
|
|
33
33
|
* @template TSelection - The type of the selected fields
|
|
34
34
|
* @param {TSelection} fields - Object containing the fields to select, with table schemas as values
|
|
35
|
-
* @returns {MySqlSelectBuilder<TSelection,
|
|
35
|
+
* @returns {MySqlSelectBuilder<TSelection, MySqlRemotePreparedQueryHKT>} A distinct select query builder with unique field aliases
|
|
36
36
|
* @throws {Error} If fields parameter is empty
|
|
37
37
|
* @example
|
|
38
38
|
* ```typescript
|
|
@@ -48,11 +48,21 @@ declare class ForgeSQLORM implements ForgeSqlOperation {
|
|
|
48
48
|
* @returns CRUD operations.
|
|
49
49
|
*/
|
|
50
50
|
crud(): CRUDForgeSQL;
|
|
51
|
+
/**
|
|
52
|
+
* Proxies the `modify` method from `ForgeSQLORMImpl`.
|
|
53
|
+
* @returns Modify operations.
|
|
54
|
+
*/
|
|
55
|
+
modify(): CRUDForgeSQL;
|
|
51
56
|
/**
|
|
52
57
|
* Proxies the `fetch` method from `ForgeSQLORMImpl`.
|
|
53
58
|
* @returns Fetch operations.
|
|
54
59
|
*/
|
|
55
60
|
fetch(): SchemaSqlForgeSql;
|
|
61
|
+
/**
|
|
62
|
+
* Provides query analysis capabilities including EXPLAIN ANALYZE and slow query analysis.
|
|
63
|
+
* @returns {SchemaAnalyzeForgeSql} Interface for analyzing query performance
|
|
64
|
+
*/
|
|
65
|
+
analyze(): SchemaAnalyzeForgeSql;
|
|
56
66
|
/**
|
|
57
67
|
* Returns a Drizzle query builder instance.
|
|
58
68
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ForgeSQLORM.d.ts","sourceRoot":"","sources":["../../src/core/ForgeSQLORM.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAW,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAEpG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"ForgeSQLORM.d.ts","sourceRoot":"","sources":["../../src/core/ForgeSQLORM.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAW,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAEpG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAuJ5D;;;GAGG;AACH,cAAM,WAAY,YAAW,iBAAiB;IAC5C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAoB;gBAEpC,OAAO,CAAC,EAAE,kBAAkB;IAIxC;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,UAAU,SAAS,cAAc,EACtC,MAAM,EAAE,UAAU,GACjB,kBAAkB,CAAC,UAAU,EAAE,2BAA2B,CAAC;IAI9D;;;;;;;;;;;;;;;OAeG;IACH,cAAc,CAAC,UAAU,SAAS,cAAc,EAC9C,MAAM,EAAE,UAAU,GACjB,kBAAkB,CAAC,UAAU,EAAE,2BAA2B,CAAC;IAI9D;;;OAGG;IACH,IAAI,IAAI,YAAY;IAIpB;;;OAGG;IACH,MAAM,IAAI,YAAY;IAItB;;;OAGG;IACH,KAAK,IAAI,iBAAiB;IAI1B;;;OAGG;IACH,OAAO,IAAI,qBAAqB;IAIhC;;;;;;;;OAQG;IACH,sBAAsB;CAGvB;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -2,32 +2,50 @@ import { UpdateQueryResponse } from "@forge/sql";
|
|
|
2
2
|
import { SqlParameters } from "@forge/sql/out/sql-statement";
|
|
3
3
|
import { AnyMySqlSelectQueryBuilder, AnyMySqlTable, MySqlSelectBuilder } from "drizzle-orm/mysql-core";
|
|
4
4
|
import { MySqlSelectDynamic, type SelectedFields } from "drizzle-orm/mysql-core/query-builders/select.types";
|
|
5
|
-
import { InferInsertModel, SQL } from "drizzle-orm";
|
|
5
|
+
import { InferInsertModel, Query, SQL } from "drizzle-orm";
|
|
6
6
|
import { MySqlRemoteDatabase, MySqlRemotePreparedQueryHKT } from "drizzle-orm/mysql-proxy/index";
|
|
7
|
+
import { SqlHints } from "../utils/sqlHints";
|
|
8
|
+
import { ClusterStatementRowCamelCase, ExplainAnalyzeRow, SlowQueryNormalized } from "./SystemTables";
|
|
7
9
|
/**
|
|
8
|
-
*
|
|
9
|
-
* Provides access to CRUD operations
|
|
10
|
+
* Core interface for ForgeSQL operations.
|
|
11
|
+
* Provides access to CRUD operations, schema-level SQL operations, and query analysis capabilities.
|
|
12
|
+
*
|
|
13
|
+
* @interface ForgeSqlOperation
|
|
14
|
+
* @extends {QueryBuilderForgeSql}
|
|
10
15
|
*/
|
|
11
16
|
export interface ForgeSqlOperation extends QueryBuilderForgeSql {
|
|
12
17
|
/**
|
|
13
|
-
* Provides CRUD (Create,
|
|
18
|
+
* Provides CRUD (Create, Update, Delete) operations.
|
|
19
|
+
* @deprecated Use modify() instead for better type safety and consistency
|
|
14
20
|
* @returns {CRUDForgeSQL} Interface for performing CRUD operations
|
|
15
21
|
*/
|
|
16
22
|
crud(): CRUDForgeSQL;
|
|
17
23
|
/**
|
|
18
|
-
* Provides
|
|
24
|
+
* Provides modify (Create, Update, Delete) operations with optimistic locking support.
|
|
25
|
+
* @returns {CRUDForgeSQL} Interface for performing CRUD operations
|
|
26
|
+
*/
|
|
27
|
+
modify(): CRUDForgeSQL;
|
|
28
|
+
/**
|
|
29
|
+
* Provides schema-level SQL fetch operations with type safety.
|
|
19
30
|
* @returns {SchemaSqlForgeSql} Interface for executing schema-bound SQL queries
|
|
20
31
|
*/
|
|
21
32
|
fetch(): SchemaSqlForgeSql;
|
|
33
|
+
/**
|
|
34
|
+
* Provides query analysis capabilities including EXPLAIN ANALYZE and slow query analysis.
|
|
35
|
+
* @returns {SchemaAnalyzeForgeSql} Interface for analyzing query performance
|
|
36
|
+
*/
|
|
37
|
+
analyze(): SchemaAnalyzeForgeSql;
|
|
22
38
|
}
|
|
23
39
|
/**
|
|
24
40
|
* Interface for Query Builder operations.
|
|
25
|
-
* Provides access to the underlying Drizzle ORM query builder.
|
|
41
|
+
* Provides access to the underlying Drizzle ORM query builder with enhanced functionality.
|
|
42
|
+
*
|
|
43
|
+
* @interface QueryBuilderForgeSql
|
|
26
44
|
*/
|
|
27
45
|
export interface QueryBuilderForgeSql {
|
|
28
46
|
/**
|
|
29
47
|
* Creates a new query builder for the given entity.
|
|
30
|
-
* @returns {
|
|
48
|
+
* @returns {MySqlRemoteDatabase<Record<string, unknown>>} The Drizzle database instance for building queries
|
|
31
49
|
*/
|
|
32
50
|
getDrizzleQueryBuilder(): MySqlRemoteDatabase<Record<string, unknown>>;
|
|
33
51
|
/**
|
|
@@ -66,20 +84,22 @@ export interface QueryBuilderForgeSql {
|
|
|
66
84
|
selectDistinct<TSelection extends SelectedFields>(fields: TSelection): MySqlSelectBuilder<TSelection, MySqlRemotePreparedQueryHKT>;
|
|
67
85
|
}
|
|
68
86
|
/**
|
|
69
|
-
* Interface for
|
|
87
|
+
* Interface for Modify (Create, Update, Delete) operations.
|
|
70
88
|
* Provides methods for basic database operations with support for optimistic locking.
|
|
89
|
+
*
|
|
90
|
+
* @interface CRUDForgeSQL
|
|
71
91
|
*/
|
|
72
92
|
export interface CRUDForgeSQL {
|
|
73
93
|
/**
|
|
74
94
|
* Inserts multiple records into the database.
|
|
75
95
|
* @template T - The type of the table schema
|
|
76
96
|
* @param {T} schema - The entity schema
|
|
77
|
-
* @param {
|
|
97
|
+
* @param {InferInsertModel<T>[]} models - The list of entities to insert
|
|
78
98
|
* @param {boolean} [updateIfExists] - Whether to update the row if it already exists (default: false)
|
|
79
99
|
* @returns {Promise<number>} The number of inserted rows
|
|
80
100
|
* @throws {Error} If the insert operation fails
|
|
81
101
|
*/
|
|
82
|
-
insert<T extends AnyMySqlTable>(schema: T, models:
|
|
102
|
+
insert<T extends AnyMySqlTable>(schema: T, models: InferInsertModel<T>[], updateIfExists?: boolean): Promise<number>;
|
|
83
103
|
/**
|
|
84
104
|
* Deletes a record by its ID.
|
|
85
105
|
* @template T - The type of the table schema
|
|
@@ -119,9 +139,70 @@ export interface CRUDForgeSQL {
|
|
|
119
139
|
*/
|
|
120
140
|
updateFields<T extends AnyMySqlTable>(updateData: Partial<InferInsertModel<T>>, schema: T, where?: SQL<unknown>): Promise<number>;
|
|
121
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Interface for schema analysis operations.
|
|
144
|
+
* Provides methods for analyzing query performance and execution plans.
|
|
145
|
+
*
|
|
146
|
+
* @interface SchemaAnalyzeForgeSql
|
|
147
|
+
*/
|
|
148
|
+
export interface SchemaAnalyzeForgeSql {
|
|
149
|
+
/**
|
|
150
|
+
* Executes EXPLAIN on a Drizzle query.
|
|
151
|
+
* @param {{ toSQL: () => Query }} query - The Drizzle query to analyze
|
|
152
|
+
* @returns {Promise<ExplainAnalyzeRow[]>} The execution plan analysis results
|
|
153
|
+
*/
|
|
154
|
+
explain(query: {
|
|
155
|
+
toSQL: () => Query;
|
|
156
|
+
}): Promise<ExplainAnalyzeRow[]>;
|
|
157
|
+
/**
|
|
158
|
+
* Executes EXPLAIN on a raw SQL query.
|
|
159
|
+
* @param {string} query - The SQL query to analyze
|
|
160
|
+
* @param {unknown[]} bindParams - The query parameters
|
|
161
|
+
* @returns {Promise<ExplainAnalyzeRow[]>} The execution plan analysis results
|
|
162
|
+
*/
|
|
163
|
+
explainRaw(query: string, bindParams: unknown[]): Promise<ExplainAnalyzeRow[]>;
|
|
164
|
+
/**
|
|
165
|
+
* Executes EXPLAIN ANALYZE on a Drizzle query.
|
|
166
|
+
* @param {{ toSQL: () => Query }} query - The Drizzle query to analyze
|
|
167
|
+
* @returns {Promise<ExplainAnalyzeRow[]>} The execution plan analysis results
|
|
168
|
+
*/
|
|
169
|
+
explainAnalyze(query: {
|
|
170
|
+
toSQL: () => Query;
|
|
171
|
+
}): Promise<ExplainAnalyzeRow[]>;
|
|
172
|
+
/**
|
|
173
|
+
* Executes EXPLAIN ANALYZE on a raw SQL query.
|
|
174
|
+
* @param {string} query - The SQL query to analyze
|
|
175
|
+
* @param {unknown[]} bindParams - The query parameters
|
|
176
|
+
* @returns {Promise<ExplainAnalyzeRow[]>} The execution plan analysis results
|
|
177
|
+
*/
|
|
178
|
+
explainAnalyzeRaw(query: string, bindParams: unknown[]): Promise<ExplainAnalyzeRow[]>;
|
|
179
|
+
/**
|
|
180
|
+
* Analyzes slow queries from the database.
|
|
181
|
+
* @returns {Promise<SlowQueryNormalized[]>} The normalized slow query data
|
|
182
|
+
*/
|
|
183
|
+
analyzeSlowQueries(): Promise<SlowQueryNormalized[]>;
|
|
184
|
+
/**
|
|
185
|
+
* Analyzes query history for specific tables using Drizzle table objects.
|
|
186
|
+
* @param {AnyMySqlTable[]} tables - The Drizzle table objects to analyze
|
|
187
|
+
* @param {Date} [fromDate] - The start date for the analysis
|
|
188
|
+
* @param {Date} [toDate] - The end date for the analysis
|
|
189
|
+
* @returns {Promise<ClusterStatementRowCamelCase[]>} The analyzed query history
|
|
190
|
+
*/
|
|
191
|
+
analyzeQueriesHistory(tables: AnyMySqlTable[], fromDate?: Date, toDate?: Date): Promise<ClusterStatementRowCamelCase[]>;
|
|
192
|
+
/**
|
|
193
|
+
* Analyzes query history for specific tables using raw table names.
|
|
194
|
+
* @param {string[]} tables - The table names to analyze
|
|
195
|
+
* @param {Date} [fromDate] - The start date for the analysis
|
|
196
|
+
* @param {Date} [toDate] - The end date for the analysis
|
|
197
|
+
* @returns {Promise<ClusterStatementRowCamelCase[]>} The analyzed query history
|
|
198
|
+
*/
|
|
199
|
+
analyzeQueriesHistoryRaw(tables: string[], fromDate?: Date, toDate?: Date): Promise<ClusterStatementRowCamelCase[]>;
|
|
200
|
+
}
|
|
122
201
|
/**
|
|
123
202
|
* Interface for schema-level SQL operations.
|
|
124
203
|
* Provides methods for executing SQL queries with schema binding and type safety.
|
|
204
|
+
*
|
|
205
|
+
* @interface SchemaSqlForgeSql
|
|
125
206
|
*/
|
|
126
207
|
export interface SchemaSqlForgeSql {
|
|
127
208
|
/**
|
|
@@ -154,6 +235,8 @@ export interface SchemaSqlForgeSql {
|
|
|
154
235
|
/**
|
|
155
236
|
* Interface for version field metadata.
|
|
156
237
|
* Defines the configuration for optimistic locking version fields.
|
|
238
|
+
*
|
|
239
|
+
* @interface VersionFieldMetadata
|
|
157
240
|
*/
|
|
158
241
|
export interface VersionFieldMetadata {
|
|
159
242
|
/** Name of the version field */
|
|
@@ -162,6 +245,8 @@ export interface VersionFieldMetadata {
|
|
|
162
245
|
/**
|
|
163
246
|
* Interface for table metadata.
|
|
164
247
|
* Defines the configuration for a specific table.
|
|
248
|
+
*
|
|
249
|
+
* @interface TableMetadata
|
|
165
250
|
*/
|
|
166
251
|
export interface TableMetadata {
|
|
167
252
|
/** Name of the table */
|
|
@@ -172,24 +257,22 @@ export interface TableMetadata {
|
|
|
172
257
|
/**
|
|
173
258
|
* Type for additional metadata configuration.
|
|
174
259
|
* Maps table names to their metadata configuration.
|
|
260
|
+
*
|
|
261
|
+
* @type {AdditionalMetadata}
|
|
175
262
|
*/
|
|
176
263
|
export type AdditionalMetadata = Record<string, TableMetadata>;
|
|
177
264
|
/**
|
|
178
|
-
*
|
|
265
|
+
* Interface for ForgeSQL ORM options
|
|
266
|
+
*
|
|
267
|
+
* @interface ForgeSqlOrmOptions
|
|
179
268
|
*/
|
|
180
269
|
export interface ForgeSqlOrmOptions {
|
|
181
|
-
/**
|
|
182
|
-
* Enables logging of raw SQL queries in the Atlassian Forge Developer Console.
|
|
183
|
-
* Useful for debugging and monitoring SQL operations.
|
|
184
|
-
* @default false
|
|
185
|
-
*/
|
|
270
|
+
/** Whether to log raw SQL queries */
|
|
186
271
|
logRawSqlQuery?: boolean;
|
|
187
|
-
/**
|
|
188
|
-
* Disables optimistic locking for all operations.
|
|
189
|
-
* When enabled, version checks are skipped during updates.
|
|
190
|
-
* @default false
|
|
191
|
-
*/
|
|
272
|
+
/** Whether to disable optimistic locking */
|
|
192
273
|
disableOptimisticLocking?: boolean;
|
|
274
|
+
/** SQL hints to be applied to queries */
|
|
275
|
+
hints?: SqlHints;
|
|
193
276
|
/**
|
|
194
277
|
* Additional metadata for table configuration.
|
|
195
278
|
* Allows specifying table-specific settings and behaviors.
|
|
@@ -212,6 +295,8 @@ export interface ForgeSqlOrmOptions {
|
|
|
212
295
|
/**
|
|
213
296
|
* Custom type for MySQL datetime fields.
|
|
214
297
|
* Handles conversion between JavaScript Date objects and MySQL datetime strings.
|
|
298
|
+
*
|
|
299
|
+
* @type {CustomType}
|
|
215
300
|
*/
|
|
216
301
|
export declare const forgeDateTimeString: {
|
|
217
302
|
(): import("drizzle-orm/mysql-core").MySqlCustomColumnBuilder<{
|
|
@@ -246,6 +331,8 @@ export declare const forgeDateTimeString: {
|
|
|
246
331
|
/**
|
|
247
332
|
* Custom type for MySQL timestamp fields.
|
|
248
333
|
* Handles conversion between JavaScript Date objects and MySQL timestamp strings.
|
|
334
|
+
*
|
|
335
|
+
* @type {CustomType}
|
|
249
336
|
*/
|
|
250
337
|
export declare const forgeTimestampString: {
|
|
251
338
|
(): import("drizzle-orm/mysql-core").MySqlCustomColumnBuilder<{
|
|
@@ -280,6 +367,8 @@ export declare const forgeTimestampString: {
|
|
|
280
367
|
/**
|
|
281
368
|
* Custom type for MySQL date fields.
|
|
282
369
|
* Handles conversion between JavaScript Date objects and MySQL date strings.
|
|
370
|
+
*
|
|
371
|
+
* @type {CustomType}
|
|
283
372
|
*/
|
|
284
373
|
export declare const forgeDateString: {
|
|
285
374
|
(): import("drizzle-orm/mysql-core").MySqlCustomColumnBuilder<{
|
|
@@ -314,6 +403,8 @@ export declare const forgeDateString: {
|
|
|
314
403
|
/**
|
|
315
404
|
* Custom type for MySQL time fields.
|
|
316
405
|
* Handles conversion between JavaScript Date objects and MySQL time strings.
|
|
406
|
+
*
|
|
407
|
+
* @type {CustomType}
|
|
317
408
|
*/
|
|
318
409
|
export declare const forgeTimeString: {
|
|
319
410
|
(): import("drizzle-orm/mysql-core").MySqlCustomColumnBuilder<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ForgeSQLQueryBuilder.d.ts","sourceRoot":"","sources":["../../src/core/ForgeSQLQueryBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAA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;;;GAKG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;iBAGP,MAAM;;;;;;;;;;iBAAN,MAAM;;;;;;;;;CAWzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ForgeSQLSelectOperations.d.ts","sourceRoot":"","sources":["../../src/core/ForgeSQLSelectOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,EACnB,MAAM,oDAAoD,CAAC;AAE5D;;;GAGG;AACH,qBAAa,wBAAyB,YAAW,iBAAiB;IAChE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAE7C;;;OAGG;gBACS,OAAO,EAAE,kBAAkB;IAIvC;;;;;;;;OAQG;IACG,mBAAmB,CAAC,CAAC,SAAS,kBAAkB,CAAC,0BAA0B,CAAC,EAChF,KAAK,EAAE,CAAC,GACP,OAAO,CACR,OAAO,CAAC,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS,CACxF;IAaD;;;;;;;;OAQG;IACG,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"ForgeSQLSelectOperations.d.ts","sourceRoot":"","sources":["../../src/core/ForgeSQLSelectOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC/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