@carbonorm/carbonnode 3.0.15 → 3.1.3
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 +183 -0
- package/dist/api/builders/queryHelpers.d.ts +4 -0
- package/dist/api/executors/Executor.d.ts +9 -15
- package/dist/api/executors/HttpExecutor.d.ts +7 -14
- package/dist/api/executors/SqlExecutor.d.ts +9 -12
- package/dist/api/orm/SqlBuilder.d.ts +17 -0
- package/dist/api/orm/builders/AggregateBuilder.d.ts +5 -0
- package/dist/api/orm/builders/ConditionBuilder.d.ts +11 -0
- package/dist/api/orm/builders/JoinBuilder.d.ts +5 -0
- package/dist/api/orm/builders/PaginationBuilder.d.ts +18 -0
- package/dist/api/orm/queries/DeleteQueryBuilder.d.ts +6 -0
- package/dist/api/orm/queries/SelectQueryBuilder.d.ts +6 -0
- package/dist/api/orm/queries/UpdateQueryBuilder.d.ts +6 -0
- package/dist/api/orm/queryHelpers.d.ts +4 -0
- package/dist/api/orm/utils/sqlUtils.d.ts +7 -0
- package/dist/api/restOrm.d.ts +3 -10
- package/dist/api/restRequest.d.ts +3 -10
- package/dist/api/types/ormGenerics.d.ts +13 -0
- package/dist/api/types/ormInterfaces.d.ts +23 -40
- package/dist/index.cjs.js +389 -407
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.esm.js +377 -407
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/scripts/assets/handlebars/C6.ts.handlebars +2 -4
- package/src/api/C6Constants.ts +37 -2
- package/src/api/executors/Executor.ts +18 -36
- package/src/api/executors/HttpExecutor.ts +46 -59
- package/src/api/executors/SqlExecutor.ts +17 -29
- package/src/api/handlers/ExpressHandler.ts +1 -1
- package/src/api/orm/builders/AggregateBuilder.ts +38 -0
- package/src/api/orm/builders/ConditionBuilder.ts +113 -0
- package/src/api/orm/builders/JoinBuilder.ts +25 -0
- package/src/api/orm/builders/PaginationBuilder.ts +56 -0
- package/src/api/orm/queries/DeleteQueryBuilder.ts +28 -0
- package/src/api/orm/queries/SelectQueryBuilder.ts +49 -0
- package/src/api/orm/queries/UpdateQueryBuilder.ts +42 -0
- package/src/api/orm/queryHelpers.ts +18 -0
- package/src/api/orm/utils/sqlUtils.ts +24 -0
- package/src/api/restOrm.ts +4 -14
- package/src/api/restRequest.ts +16 -34
- package/src/api/types/ormGenerics.ts +18 -0
- package/src/api/types/ormInterfaces.ts +31 -46
- package/src/index.ts +10 -1
- package/src/api/builders/sqlBuilder.ts +0 -454
|
@@ -81,6 +81,189 @@ export declare const C6Constants: {
|
|
|
81
81
|
SECOND: string;
|
|
82
82
|
SECOND_MICROSECOND: string;
|
|
83
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;
|
|
84
267
|
STR_TO_DATE: string;
|
|
85
268
|
SUBDATE: string;
|
|
86
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[];
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[
|
|
8
|
-
|
|
9
|
-
|
|
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 {
|
|
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<
|
|
5
|
-
[
|
|
6
|
-
|
|
7
|
-
[
|
|
8
|
-
|
|
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,17 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { apiReturn, DetermineResponseDataType
|
|
1
|
+
import { OrmGenerics } from "../types/ormGenerics";
|
|
2
|
+
import { apiReturn, DetermineResponseDataType } from "../types/ormInterfaces";
|
|
3
3
|
import { ResultSetHeader } from 'mysql2/promise';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[key in keyof RestTableInterface]: any;
|
|
8
|
-
}> extends SqlBuilder<RequestMethod, RestShortTableName, RestTableInterface, PrimaryKey, CustomAndRequiredFields, RequestTableOverrides> {
|
|
9
|
-
execute(): Promise<apiReturn<DetermineResponseDataType<RequestMethod, RestTableInterface>>>;
|
|
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
8
|
serialize: (row: any) => {
|
|
12
9
|
[k: string]: unknown;
|
|
13
10
|
};
|
|
14
|
-
select
|
|
11
|
+
select(table: G['RestShortTableName'], primary: string | undefined, args: any): Promise<{
|
|
15
12
|
rest: {
|
|
16
13
|
[k: string]: unknown;
|
|
17
14
|
}[];
|
|
@@ -20,21 +17,21 @@ export declare class SqlExecutor<RequestMethod extends iRestMethods, RestShortTa
|
|
|
20
17
|
values: any;
|
|
21
18
|
};
|
|
22
19
|
}>;
|
|
23
|
-
insert
|
|
20
|
+
insert(table: G['RestShortTableName'], data: Record<string, any>): Promise<{
|
|
24
21
|
rest: ResultSetHeader;
|
|
25
22
|
sql: {
|
|
26
23
|
sql: string;
|
|
27
24
|
placeholders: string;
|
|
28
25
|
};
|
|
29
26
|
}>;
|
|
30
|
-
update
|
|
27
|
+
update(table: G['RestShortTableName'], primary: string[], data: Record<string, any>): Promise<{
|
|
31
28
|
rest: ResultSetHeader;
|
|
32
29
|
sql: {
|
|
33
30
|
sql: string;
|
|
34
31
|
values: any[];
|
|
35
32
|
};
|
|
36
33
|
}>;
|
|
37
|
-
delete
|
|
34
|
+
delete(table: G['RestShortTableName'], primary: string[], args: Record<string, any>): Promise<{
|
|
38
35
|
rest: ResultSetHeader;
|
|
39
36
|
sql: {
|
|
40
37
|
sql: string;
|
|
@@ -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,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,18 @@
|
|
|
1
|
+
import { OrmGenerics } from "../../types/ormGenerics";
|
|
2
|
+
import { JoinBuilder } from "./JoinBuilder";
|
|
3
|
+
export declare class PaginationBuilder<G extends OrmGenerics> extends JoinBuilder<G> {
|
|
4
|
+
/**
|
|
5
|
+
* MySQL ORDER/LIMIT/OFFSET generator.
|
|
6
|
+
*
|
|
7
|
+
* Accepted structures:
|
|
8
|
+
* ```ts
|
|
9
|
+
* ORDER: {
|
|
10
|
+
* // simple column with direction
|
|
11
|
+
* [property_units.UNIT_ID]: "DESC",
|
|
12
|
+
* // function call (array of arguments)
|
|
13
|
+
* [C6Constants.ST_DISTANCE_SPHERE]: [property_units.LOCATION, F(property_units.LOCATION, "pu_target")]
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
buildPaginationClause(pagination: any): string;
|
|
18
|
+
}
|
|
@@ -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[];
|
package/dist/api/restOrm.d.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
+
import { OrmGenerics } from "./types/ormGenerics";
|
|
1
2
|
import { iRest } from "./types/ormInterfaces";
|
|
2
|
-
export declare function restOrm<
|
|
3
|
-
[
|
|
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 {
|
|
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<
|
|
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<
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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<
|
|
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<
|
|
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<
|
|
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<
|
|
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<
|
|
180
|
-
response: AxiosResponse<DetermineResponseDataType<
|
|
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<
|
|
187
|
-
response: AxiosResponse<DetermineResponseDataType<
|
|
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<
|
|
192
|
-
[
|
|
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
|
|
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
|
|
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
|
};
|