@carbonorm/carbonnode 3.0.13 → 3.1.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 (49) hide show
  1. package/dist/api/C6Constants.d.ts +184 -0
  2. package/dist/api/builders/queryHelpers.d.ts +4 -0
  3. package/dist/api/builders/sqlBuilder.d.ts +17 -5
  4. package/dist/api/executors/Executor.d.ts +9 -15
  5. package/dist/api/executors/HttpExecutor.d.ts +7 -14
  6. package/dist/api/executors/SqlExecutor.d.ts +43 -14
  7. package/dist/api/orm/SqlBuilder.d.ts +17 -0
  8. package/dist/api/orm/builders/AggregateBuilder.d.ts +5 -0
  9. package/dist/api/orm/builders/ConditionBuilder.d.ts +11 -0
  10. package/dist/api/orm/builders/JoinBuilder.d.ts +5 -0
  11. package/dist/api/orm/builders/PaginationBuilder.d.ts +5 -0
  12. package/dist/api/orm/queries/DeleteQueryBuilder.d.ts +6 -0
  13. package/dist/api/orm/queries/SelectQueryBuilder.d.ts +6 -0
  14. package/dist/api/orm/queries/UpdateQueryBuilder.d.ts +6 -0
  15. package/dist/api/orm/queryHelpers.d.ts +4 -0
  16. package/dist/api/orm/utils/sqlUtils.d.ts +7 -0
  17. package/dist/api/restOrm.d.ts +3 -10
  18. package/dist/api/restRequest.d.ts +3 -10
  19. package/dist/api/types/ormGenerics.d.ts +13 -0
  20. package/dist/api/types/ormInterfaces.d.ts +23 -40
  21. package/dist/index.cjs.js +444 -249
  22. package/dist/index.cjs.js.map +1 -1
  23. package/dist/index.d.ts +10 -1
  24. package/dist/index.esm.js +432 -249
  25. package/dist/index.esm.js.map +1 -1
  26. package/package.json +7 -2
  27. package/scripts/assets/handlebars/C6.ts.handlebars +2 -4
  28. package/scripts/generateRestBindings.cjs +1 -1
  29. package/scripts/generateRestBindings.ts +1 -1
  30. package/src/api/C6Constants.ts +38 -2
  31. package/src/api/executors/Executor.ts +18 -36
  32. package/src/api/executors/HttpExecutor.ts +46 -59
  33. package/src/api/executors/SqlExecutor.ts +89 -58
  34. package/src/api/handlers/ExpressHandler.ts +3 -2
  35. package/src/api/orm/builders/AggregateBuilder.ts +38 -0
  36. package/src/api/orm/builders/ConditionBuilder.ts +113 -0
  37. package/src/api/orm/builders/JoinBuilder.ts +25 -0
  38. package/src/api/orm/builders/PaginationBuilder.ts +28 -0
  39. package/src/api/orm/queries/DeleteQueryBuilder.ts +28 -0
  40. package/src/api/orm/queries/SelectQueryBuilder.ts +49 -0
  41. package/src/api/orm/queries/UpdateQueryBuilder.ts +42 -0
  42. package/src/api/orm/queryHelpers.ts +18 -0
  43. package/src/api/orm/utils/sqlUtils.ts +24 -0
  44. package/src/api/restOrm.ts +4 -14
  45. package/src/api/restRequest.ts +16 -34
  46. package/src/api/types/ormGenerics.ts +18 -0
  47. package/src/api/types/ormInterfaces.ts +28 -43
  48. package/src/index.ts +10 -1
  49. package/src/api/builders/sqlBuilder.ts +0 -223
@@ -60,6 +60,7 @@ export declare const C6Constants: {
60
60
  LOCALTIMESTAMP: string;
61
61
  MAKEDATE: string;
62
62
  MAKETIME: string;
63
+ MATCH_AGAINST: string;
63
64
  MONTHNAME: string;
64
65
  MICROSECOND: string;
65
66
  MINUTE: string;
@@ -80,6 +81,189 @@ export declare const C6Constants: {
80
81
  SECOND: string;
81
82
  SECOND_MICROSECOND: string;
82
83
  SELECT: string;
84
+ ST_AREA: string;
85
+ ST_ASBINARY: string;
86
+ ST_ASTEXT: string;
87
+ ST_BUFFER: string;
88
+ ST_CONTAINS: string;
89
+ ST_CROSSES: string;
90
+ ST_DIFFERENCE: string;
91
+ ST_DIMENSION: string;
92
+ ST_DISJOINT: string;
93
+ ST_DISTANCE: string;
94
+ ST_DISTANCE_SPHERE: string;
95
+ ST_ENDPOINT: string;
96
+ ST_ENVELOPE: string;
97
+ ST_EQUALS: string;
98
+ ST_GEOMFROMGEOJSON: string;
99
+ ST_GEOMFROMTEXT: string;
100
+ ST_GEOMFROMWKB: string;
101
+ ST_INTERSECTS: string;
102
+ ST_LENGTH: string;
103
+ ST_OVERLAPS: string;
104
+ ST_POINT: string;
105
+ ST_SETSRID: string;
106
+ ST_SRID: string;
107
+ ST_STARTPOINT: string;
108
+ ST_SYMDIFFERENCE: string;
109
+ ST_TOUCHES: string;
110
+ ST_UNION: string;
111
+ ST_WITHIN: string;
112
+ ST_X: string;
113
+ ST_Y: string;
114
+ STR_TO_DATE: string;
115
+ SUBDATE: string;
116
+ SUBTIME: string;
117
+ SUM: string;
118
+ SYSDATE: string;
119
+ TIME: string;
120
+ TIME_FORMAT: string;
121
+ TIME_TO_SEC: string;
122
+ TIMEDIFF: string;
123
+ TIMESTAMP: string;
124
+ TIMESTAMPADD: string;
125
+ TIMESTAMPDIFF: string;
126
+ TO_DAYS: string;
127
+ TO_SECONDS: string;
128
+ TRANSACTION_TIMESTAMP: string;
129
+ TRUE: string;
130
+ UNIX_TIMESTAMP: string;
131
+ UNKNOWN: string;
132
+ UPDATE: string;
133
+ UNHEX: string;
134
+ UTC_DATE: string;
135
+ UTC_TIME: string;
136
+ UTC_TIMESTAMP: string;
137
+ WHERE: string;
138
+ WEEKDAY: string;
139
+ WEEKOFYEAR: string;
140
+ YEARWEEK: string;
141
+ DEPENDANT_ON_ENTITY: string;
142
+ OPTIONS: string;
143
+ GET: string;
144
+ POST: string;
145
+ PUT: string;
146
+ REPLACE: string;
147
+ DELETE: string;
148
+ REST_REQUEST_PREPROCESS_CALLBACKS: string;
149
+ PREPROCESS: string;
150
+ REST_REQUEST_FINNISH_CALLBACKS: string;
151
+ FINISH: string;
152
+ VALIDATE_C6_ENTITY_ID_REGEX: string;
153
+ };
154
+ export declare const C6C: {
155
+ ADDDATE: string;
156
+ ADDTIME: string;
157
+ AS: string;
158
+ ASC: string;
159
+ BETWEEN: string;
160
+ CONCAT: string;
161
+ CONVERT_TZ: string;
162
+ COUNT: string;
163
+ COUNT_ALL: string;
164
+ CURRENT_DATE: string;
165
+ CURRENT_TIMESTAMP: string;
166
+ DAY: string;
167
+ DAY_HOUR: string;
168
+ DAY_MICROSECOND: string;
169
+ DAY_MINUTE: string;
170
+ DAY_SECOND: string;
171
+ DAYNAME: string;
172
+ DAYOFMONTH: string;
173
+ DAYOFWEEK: string;
174
+ DAYOFYEAR: string;
175
+ DATE: string;
176
+ DATE_ADD: string;
177
+ DATEDIFF: string;
178
+ DATE_SUB: string;
179
+ DATE_FORMAT: string;
180
+ DESC: string;
181
+ DISTINCT: string;
182
+ EXTRACT: string;
183
+ EQUAL: string;
184
+ EQUAL_NULL_SAFE: string;
185
+ FALSE: string;
186
+ FULL_OUTER: string;
187
+ FROM_DAYS: string;
188
+ FROM_UNIXTIME: string;
189
+ GET_FORMAT: string;
190
+ GREATER_THAN: string;
191
+ GROUP_BY: string;
192
+ GROUP_CONCAT: string;
193
+ GREATER_THAN_OR_EQUAL_TO: string;
194
+ HAVING: string;
195
+ HEX: string;
196
+ HOUR: string;
197
+ HOUR_MICROSECOND: string;
198
+ HOUR_SECOND: string;
199
+ HOUR_MINUTE: string;
200
+ IN: string;
201
+ IS: string;
202
+ IS_NOT: string;
203
+ INNER: string;
204
+ INTERVAL: string;
205
+ JOIN: string;
206
+ LEFT: string;
207
+ LEFT_OUTER: string;
208
+ LESS_THAN: string;
209
+ LESS_THAN_OR_EQUAL_TO: string;
210
+ LIKE: string;
211
+ LIMIT: string;
212
+ LOCALTIME: string;
213
+ LOCALTIMESTAMP: string;
214
+ MAKEDATE: string;
215
+ MAKETIME: string;
216
+ MATCH_AGAINST: string;
217
+ MONTHNAME: string;
218
+ MICROSECOND: string;
219
+ MINUTE: string;
220
+ MINUTE_MICROSECOND: string;
221
+ MINUTE_SECOND: string;
222
+ MIN: string;
223
+ MAX: string;
224
+ MONTH: string;
225
+ NOT_LIKE: string;
226
+ NOT_EQUAL: string;
227
+ NOT_IN: string;
228
+ NOW: string;
229
+ NULL: string;
230
+ ORDER: string;
231
+ PAGE: string;
232
+ PAGINATION: string;
233
+ RIGHT_OUTER: string;
234
+ SECOND: string;
235
+ SECOND_MICROSECOND: string;
236
+ SELECT: string;
237
+ ST_AREA: string;
238
+ ST_ASBINARY: string;
239
+ ST_ASTEXT: string;
240
+ ST_BUFFER: string;
241
+ ST_CONTAINS: string;
242
+ ST_CROSSES: string;
243
+ ST_DIFFERENCE: string;
244
+ ST_DIMENSION: string;
245
+ ST_DISJOINT: string;
246
+ ST_DISTANCE: string;
247
+ ST_DISTANCE_SPHERE: string;
248
+ ST_ENDPOINT: string;
249
+ ST_ENVELOPE: string;
250
+ ST_EQUALS: string;
251
+ ST_GEOMFROMGEOJSON: string;
252
+ ST_GEOMFROMTEXT: string;
253
+ ST_GEOMFROMWKB: string;
254
+ ST_INTERSECTS: string;
255
+ ST_LENGTH: string;
256
+ ST_OVERLAPS: string;
257
+ ST_POINT: string;
258
+ ST_SETSRID: string;
259
+ ST_SRID: string;
260
+ ST_STARTPOINT: string;
261
+ ST_SYMDIFFERENCE: string;
262
+ ST_TOUCHES: string;
263
+ ST_UNION: string;
264
+ ST_WITHIN: string;
265
+ ST_X: string;
266
+ ST_Y: string;
83
267
  STR_TO_DATE: string;
84
268
  SUBDATE: string;
85
269
  SUBTIME: string;
@@ -0,0 +1,4 @@
1
+ export declare const A: (tableName: string, alias: string) => string;
2
+ export declare const F: (qualifiedCol: string, alias: string) => string;
3
+ export declare const fieldEq: (leftCol: string, rightCol: string, leftAlias: string, rightAlias: string) => Record<string, string>;
4
+ export declare const distSphere: (fromCol: string, toCol: string, fromAlias: string, toAlias: string) => any[];
@@ -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
- /** Generate nested WHERE/JOIN conditions with parameter binding */
15
- protected buildBooleanJoinedConditions(set: any, andMode?: boolean, params?: any[]): string;
16
- /** Translate array or function calls into SQL expressions */
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
- /** Compose a parameterized SELECT query with optional JOIN/WHERE/GROUP/HAVING/PAGINATION */
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,16 +1,10 @@
1
- import { apiReturn, DetermineResponseDataType, iRest, iRestMethods, iRestReactiveLifecycle, RequestQueryBody } from "../types/ormInterfaces";
2
- export declare abstract class Executor<RequestMethod extends iRestMethods, RestShortTableName extends string = any, RestTableInterface extends {
3
- [key: string]: any;
4
- } = any, PrimaryKey extends Extract<keyof RestTableInterface, string> = Extract<keyof RestTableInterface, string>, CustomAndRequiredFields extends {
5
- [key: string]: any;
6
- } = any, RequestTableOverrides extends {
7
- [key in keyof RestTableInterface]: any;
8
- } = {
9
- [key in keyof RestTableInterface]: any;
10
- }> {
11
- protected config: iRest<RestShortTableName, RestTableInterface, PrimaryKey>;
12
- protected request: RequestQueryBody<RequestMethod, RestTableInterface, CustomAndRequiredFields, RequestTableOverrides>;
13
- constructor(config: iRest<RestShortTableName, RestTableInterface, PrimaryKey>, request: RequestQueryBody<RequestMethod, RestTableInterface, CustomAndRequiredFields, RequestTableOverrides>);
14
- abstract execute(): Promise<apiReturn<DetermineResponseDataType<RequestMethod, RestTableInterface>>>;
15
- runLifecycleHooks<Phase extends keyof iRestReactiveLifecycle<RequestMethod, RestShortTableName, RestTableInterface, PrimaryKey, CustomAndRequiredFields, RequestTableOverrides>>(phase: Phase, args: Parameters<NonNullable<iRestReactiveLifecycle<RequestMethod, RestShortTableName, RestTableInterface, PrimaryKey, CustomAndRequiredFields, RequestTableOverrides>[Phase]>[string]>[0]): Promise<void>;
1
+ import { OrmGenerics } from "../types/ormGenerics";
2
+ import { apiReturn, DetermineResponseDataType, iRest, iRestReactiveLifecycle, RequestQueryBody } from "../types/ormInterfaces";
3
+ export declare abstract class Executor<G extends OrmGenerics> {
4
+ protected config: iRest<G['RestShortTableName'], G['RestTableInterface'], G['PrimaryKey']>;
5
+ protected request: RequestQueryBody<G['RequestMethod'], G['RestTableInterface'], G['CustomAndRequiredFields'], G['RequestTableOverrides']>;
6
+ protected useNamedParams: boolean;
7
+ constructor(config: iRest<G['RestShortTableName'], G['RestTableInterface'], G['PrimaryKey']>, request: RequestQueryBody<G['RequestMethod'], G['RestTableInterface'], G['CustomAndRequiredFields'], G['RequestTableOverrides']>, useNamedParams?: boolean);
8
+ abstract execute(): Promise<apiReturn<DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>>>;
9
+ runLifecycleHooks<Phase extends keyof iRestReactiveLifecycle<G>>(phase: Phase, args: Parameters<NonNullable<iRestReactiveLifecycle<G>[Phase]>[string]>[0]): Promise<void>;
16
10
  }
@@ -1,17 +1,10 @@
1
1
  import { AxiosResponse } from "axios";
2
- import { apiReturn, DetermineResponseDataType, iRestMethods, RequestQueryBody } from "../types/ormInterfaces";
2
+ import { OrmGenerics } from "../types/ormGenerics";
3
+ import { apiReturn, DetermineResponseDataType, RequestQueryBody } from "../types/ormInterfaces";
3
4
  import { Executor } from "./Executor";
4
- export declare class HttpExecutor<RequestMethod extends iRestMethods, RestShortTableName extends string = any, RestTableInterface extends {
5
- [key: string]: any;
6
- } = any, PrimaryKey extends Extract<keyof RestTableInterface, string> = Extract<keyof RestTableInterface, string>, CustomAndRequiredFields extends {
7
- [key: string]: any;
8
- } = any, RequestTableOverrides extends {
9
- [key in keyof RestTableInterface]: any;
10
- } = {
11
- [key in keyof RestTableInterface]: any;
12
- }> extends Executor<RequestMethod, RestShortTableName, RestTableInterface, PrimaryKey, CustomAndRequiredFields, RequestTableOverrides> {
13
- putState(response: AxiosResponse<DetermineResponseDataType<RequestMethod, RestTableInterface>>, request: RequestQueryBody<RequestMethod, RestTableInterface, CustomAndRequiredFields, RequestTableOverrides>, callback: () => void): void;
14
- postState(response: AxiosResponse<DetermineResponseDataType<RequestMethod, RestTableInterface>>, request: RequestQueryBody<RequestMethod, RestTableInterface, CustomAndRequiredFields, RequestTableOverrides>, callback: () => void): void;
15
- deleteState(_response: AxiosResponse<DetermineResponseDataType<RequestMethod, RestTableInterface>>, request: RequestQueryBody<RequestMethod, RestTableInterface, CustomAndRequiredFields, RequestTableOverrides>, callback: () => void): void;
16
- execute(): Promise<apiReturn<DetermineResponseDataType<RequestMethod, RestTableInterface>>>;
5
+ export declare class HttpExecutor<G extends OrmGenerics> extends Executor<G> {
6
+ putState(response: AxiosResponse<DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>>, request: RequestQueryBody<G['RequestMethod'], G['RestTableInterface'], G['CustomAndRequiredFields'], G['RequestTableOverrides']>, callback: () => void): void;
7
+ postState(response: AxiosResponse<DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>>, request: RequestQueryBody<G['RequestMethod'], G['RestTableInterface'], G['CustomAndRequiredFields'], G['RequestTableOverrides']>, callback: () => void): void;
8
+ deleteState(_response: AxiosResponse<DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>>, request: RequestQueryBody<G['RequestMethod'], G['RestTableInterface'], G['CustomAndRequiredFields'], G['RequestTableOverrides']>, callback: () => void): void;
9
+ execute(): Promise<apiReturn<DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>>>;
17
10
  }
@@ -1,16 +1,45 @@
1
- import { SqlBuilder } from "api/builders/sqlBuilder";
2
- import { apiReturn, DetermineResponseDataType, iRestMethods } from "../types/ormInterfaces";
3
- import { RowDataPacket, ResultSetHeader } from 'mysql2/promise';
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
- [key in keyof RestTableInterface]: any;
6
- } = {
7
- [key in keyof RestTableInterface]: any;
8
- }> extends SqlBuilder<RequestMethod, RestShortTableName, RestTableInterface, PrimaryKey, CustomAndRequiredFields, RequestTableOverrides> {
9
- execute(): Promise<apiReturn<DetermineResponseDataType<RequestMethod, RestTableInterface>>>;
1
+ import { OrmGenerics } from "../types/ormGenerics";
2
+ import { apiReturn, DetermineResponseDataType } from "../types/ormInterfaces";
3
+ import { ResultSetHeader } from 'mysql2/promise';
4
+ import { Executor } from "./Executor";
5
+ export declare class SqlExecutor<G extends OrmGenerics> extends Executor<G> {
6
+ execute(): Promise<apiReturn<DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>>>;
10
7
  private withConnection;
11
- select<TName extends string>(table: TName, primary: string | undefined, args: any): Promise<RowDataPacket[]>;
12
- insert<TName extends string>(table: TName, data: Record<string, any>): Promise<ResultSetHeader>;
13
- update<TName extends string>(table: TName, primary: string[], data: Record<string, any>): Promise<ResultSetHeader>;
14
- delete<TName extends string>(table: TName, primary: string[], args: Record<string, any>): Promise<ResultSetHeader>;
15
- formatSQLWithParams(sql: string, params: any[]): string;
8
+ serialize: (row: any) => {
9
+ [k: string]: unknown;
10
+ };
11
+ select(table: G['RestShortTableName'], primary: string | undefined, args: any): Promise<{
12
+ rest: {
13
+ [k: string]: unknown;
14
+ }[];
15
+ sql: {
16
+ sql: any;
17
+ values: any;
18
+ };
19
+ }>;
20
+ insert(table: G['RestShortTableName'], data: Record<string, any>): Promise<{
21
+ rest: ResultSetHeader;
22
+ sql: {
23
+ sql: string;
24
+ placeholders: string;
25
+ };
26
+ }>;
27
+ update(table: G['RestShortTableName'], primary: string[], data: Record<string, any>): Promise<{
28
+ rest: ResultSetHeader;
29
+ sql: {
30
+ sql: string;
31
+ values: any[];
32
+ };
33
+ }>;
34
+ delete(table: G['RestShortTableName'], primary: string[], args: Record<string, any>): Promise<{
35
+ rest: ResultSetHeader;
36
+ sql: {
37
+ sql: string;
38
+ args: Record<string, any>;
39
+ };
40
+ }>;
41
+ formatSQLWithParams(sql: string, params: any[] | {
42
+ [key: string]: any;
43
+ }): string;
44
+ private formatValue;
16
45
  }
@@ -0,0 +1,17 @@
1
+ import { Executor } from '../executors/Executor';
2
+ import { OrmGenerics } from "../types/ormGenerics";
3
+ import { SelectQueryBuilder } from './queries/SelectQueryBuilder';
4
+ import { UpdateQueryBuilder } from './queries/UpdateQueryBuilder';
5
+ import { DeleteQueryBuilder } from './queries/DeleteQueryBuilder';
6
+ import { SqlBuilderResult } from "./utils/sqlUtils";
7
+ export declare abstract class SqlBuilder<G extends OrmGenerics> extends Executor<G> {
8
+ protected useNamedParams: boolean;
9
+ private aggregateBuilder;
10
+ private conditionBuilder;
11
+ private joinBuilder;
12
+ private paginationBuilder;
13
+ protected selectQueryBuilder: SelectQueryBuilder<OrmGenerics>;
14
+ protected updateQueryBuilder: UpdateQueryBuilder<OrmGenerics>;
15
+ protected deleteQueryBuilder: DeleteQueryBuilder<OrmGenerics>;
16
+ protected buildSelectQuery(table: RestShortTableName, primary: string | undefined, args: any, isSubSelect?: boolean): SqlBuilderResult;
17
+ }
@@ -0,0 +1,5 @@
1
+ import { Executor } from "../../executors/Executor";
2
+ import { OrmGenerics } from "../../types/ormGenerics";
3
+ export declare abstract class AggregateBuilder<G extends OrmGenerics> extends Executor<G> {
4
+ buildAggregateField(field: string | any[]): string;
5
+ }
@@ -0,0 +1,11 @@
1
+ import { OrmGenerics } from "../../types/ormGenerics";
2
+ import { apiReturn, DetermineResponseDataType } from "../../types/ormInterfaces";
3
+ import { AggregateBuilder } from "./AggregateBuilder";
4
+ export declare class ConditionBuilder<G extends OrmGenerics> extends AggregateBuilder<G> {
5
+ execute(): Promise<apiReturn<DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>>>;
6
+ private readonly OPERATORS;
7
+ private validateOperator;
8
+ private addParam;
9
+ buildBooleanJoinedConditions(set: any, andMode?: boolean, params?: any[] | Record<string, any>): string;
10
+ buildWhereClause(whereArg: any, params: any[] | Record<string, any>): string;
11
+ }
@@ -0,0 +1,5 @@
1
+ import { OrmGenerics } from "../../types/ormGenerics";
2
+ import { ConditionBuilder } from "./ConditionBuilder";
3
+ export declare class JoinBuilder<G extends OrmGenerics> extends ConditionBuilder<G> {
4
+ buildJoinClauses(joinArgs: any, params: any[] | Record<string, any>): string;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { OrmGenerics } from "../../types/ormGenerics";
2
+ import { JoinBuilder } from "./JoinBuilder";
3
+ export declare class PaginationBuilder<G extends OrmGenerics> extends JoinBuilder<G> {
4
+ buildPaginationClause(pagination: any): string;
5
+ }
@@ -0,0 +1,6 @@
1
+ import { OrmGenerics } from "../../types/ormGenerics";
2
+ import { PaginationBuilder } from "../builders/PaginationBuilder";
3
+ import { SqlBuilderResult } from "../utils/sqlUtils";
4
+ export declare class DeleteQueryBuilder<G extends OrmGenerics> extends PaginationBuilder<G> {
5
+ build(table: string, args?: any): SqlBuilderResult;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { OrmGenerics } from "../../types/ormGenerics";
2
+ import { PaginationBuilder } from "../builders/PaginationBuilder";
3
+ import { SqlBuilderResult } from "../utils/sqlUtils";
4
+ export declare class SelectQueryBuilder<G extends OrmGenerics> extends PaginationBuilder<G> {
5
+ build(table: string, args: any, primary?: string, isSubSelect?: boolean): SqlBuilderResult;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { OrmGenerics } from "../../types/ormGenerics";
2
+ import { PaginationBuilder } from '../builders/PaginationBuilder';
3
+ import { SqlBuilderResult } from "../utils/sqlUtils";
4
+ export declare class UpdateQueryBuilder<G extends OrmGenerics> extends PaginationBuilder<G> {
5
+ build(table: string, data: Record<string, any>, args?: any): SqlBuilderResult;
6
+ }
@@ -0,0 +1,4 @@
1
+ export declare const A: (tableName: string, alias: string) => string;
2
+ export declare const F: (qualifiedCol: string, alias: string) => string;
3
+ export declare const fieldEq: (leftCol: string, rightCol: string, leftAlias: string, rightAlias: string) => Record<string, string>;
4
+ export declare const distSphere: (fromCol: string, toCol: string, fromAlias: string, toAlias: string) => any[];
@@ -0,0 +1,7 @@
1
+ export interface SqlBuilderResult {
2
+ sql: string;
3
+ params: any[] | {
4
+ [key: string]: any;
5
+ };
6
+ }
7
+ export declare function convertHexIfBinary(_col: string, val: any, columnDef?: any): any;
@@ -1,12 +1,5 @@
1
+ import { OrmGenerics } from "./types/ormGenerics";
1
2
  import { iRest } from "./types/ormInterfaces";
2
- export declare function restOrm<RestShortTableName extends string = any, RestTableInterface extends {
3
- [key: string]: any;
4
- } = any, PrimaryKey extends Extract<keyof RestTableInterface, string> = Extract<keyof RestTableInterface, string>, CustomAndRequiredFields extends {
5
- [key: string]: any;
6
- } = any, RequestTableOverrides extends {
7
- [key in keyof RestTableInterface]: any;
8
- } = {
9
- [key in keyof RestTableInterface]: any;
10
- }>(config: () => Omit<iRest<RestShortTableName, RestTableInterface, PrimaryKey>, "requestMethod">): {
11
- [k: string]: (request: import("./types/ormInterfaces").iAPI<import("./types/ormInterfaces").RequestGetPutDeleteBody<Omit<RestTableInterface, keyof RequestTableOverrides> & RequestTableOverrides & CustomAndRequiredFields>> | import("./types/ormInterfaces").iAPI<Omit<RestTableInterface, keyof RequestTableOverrides> & RequestTableOverrides & CustomAndRequiredFields>) => Promise<import("./types/ormInterfaces").apiReturn<import("./types/ormInterfaces").iGetC6RestResponse<RestTableInterface, {}> | import("./types/ormInterfaces").iPostC6RestResponse<RestTableInterface> | import("./types/ormInterfaces").iPutC6RestResponse<RestTableInterface, any> | import("./types/ormInterfaces").iDeleteC6RestResponse<RestTableInterface, any>>>;
3
+ export declare function restOrm<G extends Omit<OrmGenerics, "requestMethod">>(config: () => Omit<iRest<G['RestShortTableName'], G['RestTableInterface'], G['PrimaryKey']>, "requestMethod">): {
4
+ [k: string]: (request: import("./types/ormInterfaces").RequestQueryBody<G["RequestMethod"], G["RestTableInterface"], G["CustomAndRequiredFields"], G["RequestTableOverrides"]>) => Promise<import("./types/ormInterfaces").apiReturn<import("./types/ormInterfaces").DetermineResponseDataType<G["RequestMethod"], G["RestTableInterface"]>>>;
12
5
  };
@@ -1,13 +1,6 @@
1
- import { apiReturn, DetermineResponseDataType, iRest, iRestMethods, RequestQueryBody } from "./types/ormInterfaces";
1
+ import { OrmGenerics } from "./types/ormGenerics";
2
+ import { apiReturn, DetermineResponseDataType, iRest, RequestQueryBody } from "./types/ormInterfaces";
2
3
  /**
3
4
  * Facade: routes API calls to SQL or HTTP executors based on runtime context.
4
5
  */
5
- export default function restRequest<RequestMethod extends iRestMethods, RestShortTableName extends string = any, RestTableInterface extends {
6
- [key: string]: any;
7
- } = any, PrimaryKey extends Extract<keyof RestTableInterface, string> = Extract<keyof RestTableInterface, string>, CustomAndRequiredFields extends {
8
- [key: string]: any;
9
- } = any, RequestTableOverrides extends {
10
- [key in keyof RestTableInterface]: any;
11
- } = {
12
- [key in keyof RestTableInterface]: any;
13
- }>(configX: (() => iRest<RestShortTableName, RestTableInterface, PrimaryKey>) | iRest<RestShortTableName, RestTableInterface, PrimaryKey>): (request: RequestQueryBody<RequestMethod, RestTableInterface, CustomAndRequiredFields, RequestTableOverrides>) => Promise<apiReturn<DetermineResponseDataType<RequestMethod, RestTableInterface>>>;
6
+ export default function restRequest<G extends OrmGenerics>(configX: (() => iRest<G['RestTableInterface'], G['RestShortTableName'], G['PrimaryKey']>) | iRest<G['RestShortTableName'], G['RestTableInterface'], G['PrimaryKey']>): (request: RequestQueryBody<G["RequestMethod"], G["RestTableInterface"], G["CustomAndRequiredFields"], G["RequestTableOverrides"]>) => Promise<apiReturn<DetermineResponseDataType<G["RequestMethod"], G["RestTableInterface"]>>>;
@@ -0,0 +1,13 @@
1
+ import { iRestMethods } from './ormInterfaces';
2
+ export type OrmGenerics<RequestMethod extends iRestMethods = iRestMethods, RestShortTableName extends string | string[] = any, RestTableInterface extends Record<string, any> = any, PrimaryKey extends keyof RestTableInterface & string = keyof RestTableInterface & string, CustomAndRequiredFields extends Record<string, any> = any, RequestTableOverrides extends {
3
+ [key in keyof RestTableInterface]: any;
4
+ } = {
5
+ [key in keyof RestTableInterface]: any;
6
+ }> = {
7
+ RequestMethod: RequestMethod;
8
+ RestShortTableName: RestShortTableName;
9
+ RestTableInterface: RestTableInterface;
10
+ PrimaryKey: PrimaryKey;
11
+ CustomAndRequiredFields: CustomAndRequiredFields;
12
+ RequestTableOverrides: RequestTableOverrides;
13
+ };
@@ -4,6 +4,7 @@ import { eFetchDependencies } from "./dynamicFetching";
4
4
  import { Modify } from "./modifyTypes";
5
5
  import { JoinType, OrderDirection, SQLComparisonOperator, SQLFunction } from "./mysqlTypes";
6
6
  import { CarbonReact } from "@carbonorm/carbonreact";
7
+ import { OrmGenerics } from "./ormGenerics";
7
8
  export type iRestMethods = 'GET' | 'POST' | 'PUT' | 'DELETE';
8
9
  export declare const POST = "POST";
9
10
  export declare const PUT = "PUT";
@@ -110,9 +111,7 @@ export type apiReturn<Response> = null | undefined | Response | (Response extend
110
111
  export type DetermineResponseDataType<Method extends iRestMethods, RestTableInterface extends {
111
112
  [key: string]: any;
112
113
  }> = Method extends 'POST' ? iPostC6RestResponse<RestTableInterface> : Method extends 'GET' ? iGetC6RestResponse<RestTableInterface> : Method extends 'PUT' ? iPutC6RestResponse<RestTableInterface> : Method extends 'DELETE' ? iDeleteC6RestResponse<RestTableInterface> : never;
113
- export interface iRest<RestShortTableName extends string = any, RestTableInterface extends {
114
- [key: string]: any;
115
- } = any, PrimaryKey extends keyof RestTableInterface & string = any> {
114
+ export interface iRest<RestShortTableName extends string = any, RestTableInterface extends Record<string, any> = any, PrimaryKey extends keyof RestTableInterface & string = keyof RestTableInterface & string> {
116
115
  C6: iC6Object;
117
116
  axios?: AxiosInstance;
118
117
  restURL?: string;
@@ -135,18 +134,16 @@ export type tColumns<TableName extends string, T extends {
135
134
  [K in keyof T & string as `${TableName}.${K}`]: K;
136
135
  };
137
136
  export type tPrimaryKeys<TableName extends string, PK extends string> = `${TableName}.${PK}`;
138
- export interface iC6RestfulModel<RestShortTableNames extends string, RestTableInterfaces extends {
139
- [key: string]: any;
140
- }, PK extends keyof RestTableInterfaces & string> {
141
- TABLE_NAME: RestShortTableNames;
142
- PRIMARY: tPrimaryKeys<RestShortTableNames, PK>[];
143
- PRIMARY_SHORT: PK[];
144
- COLUMNS: tColumns<RestShortTableNames, RestTableInterfaces>;
137
+ export interface iC6RestfulModel<RestShortTableName extends string, RestTableInterface extends Record<string, any> = any, PrimaryKey extends keyof RestTableInterface & string = keyof RestTableInterface & string> {
138
+ TABLE_NAME: RestShortTableName;
139
+ PRIMARY: tPrimaryKeys<RestShortTableName, PrimaryKey>[];
140
+ PRIMARY_SHORT: PrimaryKey[];
141
+ COLUMNS: tColumns<RestShortTableName, RestTableInterface>;
145
142
  TYPE_VALIDATION: {
146
143
  [key: string]: iTypeValidation;
147
144
  };
148
145
  REGEX_VALIDATION: RegExpMap;
149
- LIFECYCLE_HOOKS: iRestHooks<RestShortTableNames, RestTableInterfaces, PK>;
146
+ LIFECYCLE_HOOKS: iRestHooks<OrmGenerics<any, RestShortTableName, RestTableInterface, PrimaryKey>>;
150
147
  TABLE_REFERENCES: {
151
148
  [columnName: string]: iConstraint[];
152
149
  };
@@ -154,50 +151,36 @@ export interface iC6RestfulModel<RestShortTableNames extends string, RestTableIn
154
151
  [columnName: string]: iConstraint[];
155
152
  };
156
153
  }
157
- export type iRestReactiveLifecycle<Method extends iRestMethods, RestShortTableName extends string, RestTableInterface extends {
158
- [key: string]: any;
159
- }, PrimaryKey extends keyof RestTableInterface & string, CustomAndRequiredFields extends {
160
- [key: string]: any;
161
- }, RequestTableOverrides extends {
162
- [key: string]: any;
163
- }> = {
154
+ export type iRestReactiveLifecycle<G extends OrmGenerics> = {
164
155
  beforeProcessing?: {
165
156
  [key: string]: (args: {
166
- config: iRest<RestShortTableName, RestTableInterface, PrimaryKey>;
167
- request: RequestQueryBody<Method, RestTableInterface, CustomAndRequiredFields, RequestTableOverrides>;
157
+ config: iRest<G['RestShortTableName'], G['RestTableInterface'], G['PrimaryKey']>;
158
+ request: RequestQueryBody<G['RequestMethod'], G['RestTableInterface'], G['CustomAndRequiredFields'], G['RequestTableOverrides']>;
168
159
  }) => void | Promise<void>;
169
160
  };
170
161
  beforeExecution?: {
171
162
  [key: string]: (args: {
172
- config: iRest<RestShortTableName, RestTableInterface, PrimaryKey>;
173
- request: RequestQueryBody<Method, RestTableInterface, CustomAndRequiredFields, RequestTableOverrides>;
163
+ config: iRest<G['RestShortTableName'], G['RestTableInterface'], G['PrimaryKey']>;
164
+ request: RequestQueryBody<G['RequestMethod'], G['RestTableInterface'], G['CustomAndRequiredFields'], G['RequestTableOverrides']>;
174
165
  }) => void | Promise<void>;
175
166
  };
176
167
  afterExecution?: {
177
168
  [key: string]: (args: {
178
- config: iRest<RestShortTableName, RestTableInterface, PrimaryKey>;
179
- request: RequestQueryBody<Method, RestTableInterface, CustomAndRequiredFields, RequestTableOverrides>;
180
- response: AxiosResponse<DetermineResponseDataType<Method, RestTableInterface>>;
169
+ config: iRest<G['RestShortTableName'], G['RestTableInterface'], G['PrimaryKey']>;
170
+ request: RequestQueryBody<G['RequestMethod'], G['RestTableInterface'], G['CustomAndRequiredFields'], G['RequestTableOverrides']>;
171
+ response: AxiosResponse<DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>>;
181
172
  }) => void | Promise<void>;
182
173
  };
183
174
  afterCommit?: {
184
175
  [key: string]: (args: {
185
- config: iRest<RestShortTableName, RestTableInterface, PrimaryKey>;
186
- request: RequestQueryBody<Method, RestTableInterface, CustomAndRequiredFields, RequestTableOverrides>;
187
- response: AxiosResponse<DetermineResponseDataType<Method, RestTableInterface>>;
176
+ config: iRest<G['RestShortTableName'], G['RestTableInterface'], G['PrimaryKey']>;
177
+ request: RequestQueryBody<G['RequestMethod'], G['RestTableInterface'], G['CustomAndRequiredFields'], G['RequestTableOverrides']>;
178
+ response: AxiosResponse<DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>>;
188
179
  }) => void | Promise<void>;
189
180
  };
190
181
  };
191
- export type iRestHooks<RestShortTableName extends string, RestTableInterface extends {
192
- [key: string]: any;
193
- }, PrimaryKey extends keyof RestTableInterface & string, CustomAndRequiredFields extends {
194
- [key: string]: any;
195
- } = any, RequestTableOverrides extends {
196
- [key: string]: any;
197
- } = {
198
- [key in keyof RestTableInterface]: any;
199
- }> = {
200
- [Method in iRestMethods]: iRestReactiveLifecycle<Method, RestShortTableName, RestTableInterface, PrimaryKey, CustomAndRequiredFields, RequestTableOverrides>;
182
+ export type iRestHooks<G extends OrmGenerics> = {
183
+ [Method in iRestMethods]: iRestReactiveLifecycle<G>;
201
184
  };
202
185
  export interface iDynamicApiImport<RestData extends {
203
186
  [key: string]: any;
@@ -217,7 +200,7 @@ export interface iRestApiFunctions<RestData extends {
217
200
  }
218
201
  export interface iC6Object<RestShortTableName extends string = any, RestTableInterface extends {
219
202
  [key: string]: any;
220
- } = any, PrimaryKey extends Extract<keyof RestTableInterface, string> = Extract<keyof RestTableInterface, string>> {
203
+ } = any, PrimaryKey extends keyof RestTableInterface & string = keyof RestTableInterface & string> {
221
204
  C6VERSION: string;
222
205
  TABLES: {
223
206
  [key: string]: iC6RestfulModel<RestShortTableName, RestTableInterface, PrimaryKey> & {
@@ -230,7 +213,7 @@ export interface iC6Object<RestShortTableName extends string = any, RestTableInt
230
213
  }
231
214
  export interface tC6Tables<RestShortTableName extends string = any, RestTableInterface extends {
232
215
  [key: string]: any;
233
- } = any, PrimaryKey extends Extract<keyof RestTableInterface, string> = Extract<keyof RestTableInterface, string>> {
216
+ } = any, PrimaryKey extends keyof RestTableInterface & string = keyof RestTableInterface & string> {
234
217
  [key: string]: iC6RestfulModel<RestShortTableName, RestTableInterface, PrimaryKey> & {
235
218
  [key: string]: any;
236
219
  };