@carbonorm/carbonnode 3.0.13 → 3.0.15
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/dist/api/C6Constants.d.ts +1 -0
- package/dist/api/builders/sqlBuilder.d.ts +17 -5
- package/dist/api/executors/SqlExecutor.d.ts +38 -6
- package/dist/index.cjs.js +392 -153
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +392 -153
- package/dist/index.esm.js.map +1 -1
- package/package.json +7 -2
- package/scripts/generateRestBindings.cjs +1 -1
- package/scripts/generateRestBindings.ts +1 -1
- package/src/api/C6Constants.ts +1 -0
- package/src/api/builders/sqlBuilder.ts +336 -105
- package/src/api/executors/SqlExecutor.ts +76 -33
- package/src/api/handlers/ExpressHandler.ts +3 -2
- package/src/api/types/ormInterfaces.ts +4 -4
|
@@ -2,7 +2,9 @@ import { Executor } from "../executors/Executor";
|
|
|
2
2
|
import { iRestMethods } from "../types/ormInterfaces";
|
|
3
3
|
interface QueryResult {
|
|
4
4
|
sql: string;
|
|
5
|
-
params: any[]
|
|
5
|
+
params: any[] | {
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
};
|
|
6
8
|
}
|
|
7
9
|
export declare abstract class SqlBuilder<RequestMethod extends iRestMethods, RestShortTableName extends string = any, RestTableInterface extends Record<string, any> = any, PrimaryKey extends Extract<keyof RestTableInterface, string> = Extract<keyof RestTableInterface, string>, CustomAndRequiredFields extends {
|
|
8
10
|
[key: string]: any;
|
|
@@ -11,11 +13,21 @@ export declare abstract class SqlBuilder<RequestMethod extends iRestMethods, Res
|
|
|
11
13
|
} = {
|
|
12
14
|
[key in keyof RestTableInterface]: any;
|
|
13
15
|
}> extends Executor<RequestMethod, RestShortTableName, RestTableInterface, PrimaryKey, CustomAndRequiredFields, RequestTableOverrides> {
|
|
14
|
-
/**
|
|
15
|
-
protected
|
|
16
|
-
|
|
16
|
+
/** Flag to determine if named placeholders should be used */
|
|
17
|
+
protected useNamedParams: boolean;
|
|
18
|
+
private convertHexIfBinary;
|
|
19
|
+
/** Generate nested WHERE/ON conditions with parameter binding (supports AND/OR/NOT) */
|
|
20
|
+
protected buildBooleanJoinedConditions(set: any, andMode?: boolean, params?: any[] | {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}): string;
|
|
23
|
+
/** Translate array or function call definitions into SQL expressions (supports nested calls) */
|
|
17
24
|
protected buildAggregateField(field: string | any[]): string;
|
|
18
|
-
|
|
25
|
+
private buildJoinClauses;
|
|
26
|
+
private buildPaginationClause;
|
|
27
|
+
private buildWhereClause;
|
|
19
28
|
protected buildSelectQuery<RestShortTableNames>(table: RestShortTableNames, primary: string | undefined, args: any, isSubSelect?: boolean): QueryResult;
|
|
29
|
+
protected buildUpdateQuery(table: RestShortTableName, data: Partial<RestTableInterface>, args?: any): QueryResult;
|
|
30
|
+
/** Compose a DELETE query with optional JOIN and WHERE clauses */
|
|
31
|
+
protected buildDeleteQuery(table: RestShortTableName, args?: any): QueryResult;
|
|
20
32
|
}
|
|
21
33
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SqlBuilder } from "api/builders/sqlBuilder";
|
|
2
2
|
import { apiReturn, DetermineResponseDataType, iRestMethods } from "../types/ormInterfaces";
|
|
3
|
-
import {
|
|
3
|
+
import { ResultSetHeader } from 'mysql2/promise';
|
|
4
4
|
export declare class SqlExecutor<RequestMethod extends iRestMethods, RestShortTableName extends string = any, RestTableInterface extends Record<string, any> = any, PrimaryKey extends Extract<keyof RestTableInterface, string> = Extract<keyof RestTableInterface, string>, CustomAndRequiredFields extends Record<string, any> = any, RequestTableOverrides extends {
|
|
5
5
|
[key in keyof RestTableInterface]: any;
|
|
6
6
|
} = {
|
|
@@ -8,9 +8,41 @@ export declare class SqlExecutor<RequestMethod extends iRestMethods, RestShortTa
|
|
|
8
8
|
}> extends SqlBuilder<RequestMethod, RestShortTableName, RestTableInterface, PrimaryKey, CustomAndRequiredFields, RequestTableOverrides> {
|
|
9
9
|
execute(): Promise<apiReturn<DetermineResponseDataType<RequestMethod, RestTableInterface>>>;
|
|
10
10
|
private withConnection;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
serialize: (row: any) => {
|
|
12
|
+
[k: string]: unknown;
|
|
13
|
+
};
|
|
14
|
+
select<TName extends string>(table: TName, primary: string | undefined, args: any): Promise<{
|
|
15
|
+
rest: {
|
|
16
|
+
[k: string]: unknown;
|
|
17
|
+
}[];
|
|
18
|
+
sql: {
|
|
19
|
+
sql: any;
|
|
20
|
+
values: any;
|
|
21
|
+
};
|
|
22
|
+
}>;
|
|
23
|
+
insert<TName extends string>(table: TName, data: Record<string, any>): Promise<{
|
|
24
|
+
rest: ResultSetHeader;
|
|
25
|
+
sql: {
|
|
26
|
+
sql: string;
|
|
27
|
+
placeholders: string;
|
|
28
|
+
};
|
|
29
|
+
}>;
|
|
30
|
+
update<TName extends string>(table: TName, primary: string[], data: Record<string, any>): Promise<{
|
|
31
|
+
rest: ResultSetHeader;
|
|
32
|
+
sql: {
|
|
33
|
+
sql: string;
|
|
34
|
+
values: any[];
|
|
35
|
+
};
|
|
36
|
+
}>;
|
|
37
|
+
delete<TName extends string>(table: TName, primary: string[], args: Record<string, any>): Promise<{
|
|
38
|
+
rest: ResultSetHeader;
|
|
39
|
+
sql: {
|
|
40
|
+
sql: string;
|
|
41
|
+
args: Record<string, any>;
|
|
42
|
+
};
|
|
43
|
+
}>;
|
|
44
|
+
formatSQLWithParams(sql: string, params: any[] | {
|
|
45
|
+
[key: string]: any;
|
|
46
|
+
}): string;
|
|
47
|
+
private formatValue;
|
|
16
48
|
}
|