@carbonorm/carbonnode 3.0.1 → 3.0.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/executors/Executor.d.ts +13 -14
- package/dist/api/executors/HttpExecutor.d.ts +14 -11
- package/dist/api/executors/SqlExecutor.d.ts +11 -3
- package/dist/api/restOrm.d.ts +43 -0
- package/dist/api/restRequest.d.ts +7 -5
- package/dist/api/types/ormInterfaces.d.ts +76 -54
- package/dist/api/utils/apiHelpers.d.ts +1 -1
- package/dist/api/utils/determineRuntimeJsType.d.ts +5 -0
- package/dist/index.cjs.js +175 -481
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +173 -481
- package/dist/index.esm.js.map +1 -1
- package/package.json +6 -5
- package/scripts/assets/handlebars/C6.test.ts.handlebars +88 -0
- package/scripts/assets/handlebars/C6.ts.handlebars +42 -8
- package/scripts/generateRestBindings.cjs +3 -8
- package/scripts/generateRestBindings.ts +3 -15
- package/src/api/convertForRequestBody.ts +1 -1
- package/src/api/executors/Executor.ts +70 -18
- package/src/api/executors/HttpExecutor.ts +165 -38
- package/src/api/executors/SqlExecutor.ts +23 -9
- package/src/api/rest/C6.test.ts +88 -0
- package/src/api/rest/C6.ts +5338 -0
- package/src/api/restOrm.ts +61 -0
- package/src/api/restRequest.ts +35 -17
- package/src/api/types/ormInterfaces.ts +148 -42
- package/src/api/utils/apiHelpers.ts +5 -2
- package/src/api/utils/determineRuntimeJsType.ts +46 -0
- package/src/index.ts +2 -0
- package/scripts/assets/handlebars/Table.test.ts.handlebars +0 -126
- package/scripts/assets/handlebars/Table.ts.handlebars +0 -161
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { apiReturn, iAPI, iRest } from "@carbonorm/carbonnode";
|
|
1
|
+
import { apiReturn, DetermineResponseDataType, iAPI, iRest, iRestMethods, iRestReactiveLifecycle } from "@carbonorm/carbonnode";
|
|
2
2
|
import { Modify } from "../types/modifyTypes";
|
|
3
|
-
export declare abstract class Executor<
|
|
3
|
+
export declare abstract class Executor<RequestMethod extends iRestMethods, RestShortTableName extends string = any, RestTableInterface extends {
|
|
4
4
|
[key: string]: any;
|
|
5
|
-
},
|
|
6
|
-
RestTableInterfaces extends {
|
|
5
|
+
} = any, PrimaryKey extends Extract<keyof RestTableInterface, string> = Extract<keyof RestTableInterface, string>, CustomAndRequiredFields extends {
|
|
7
6
|
[key: string]: any;
|
|
8
|
-
},
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
protected
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
} = any, RequestTableOverrides extends {
|
|
8
|
+
[key in keyof RestTableInterface]: any;
|
|
9
|
+
} = {
|
|
10
|
+
[key in keyof RestTableInterface]: any;
|
|
11
|
+
}> {
|
|
12
|
+
protected config: iRest<RestShortTableName, RestTableInterface, PrimaryKey>;
|
|
13
|
+
protected request: iAPI<Modify<RestTableInterface, RequestTableOverrides>> & CustomAndRequiredFields;
|
|
14
|
+
constructor(config: iRest<RestShortTableName, RestTableInterface, PrimaryKey>, request?: iAPI<Modify<RestTableInterface, RequestTableOverrides>> & CustomAndRequiredFields);
|
|
15
|
+
abstract execute(): Promise<apiReturn<DetermineResponseDataType<RequestMethod, RestTableInterface>>>;
|
|
16
|
+
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>;
|
|
18
17
|
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AxiosResponse } from "axios";
|
|
2
|
+
import { Modify } from "../types/modifyTypes";
|
|
3
|
+
import { apiReturn, DetermineResponseDataType, iAPI, iRestMethods } from "../types/ormInterfaces";
|
|
2
4
|
import { Executor } from "./Executor";
|
|
3
|
-
export declare class HttpExecutor<
|
|
5
|
+
export declare class HttpExecutor<RequestMethod extends iRestMethods, RestShortTableName extends string = any, RestTableInterface extends {
|
|
4
6
|
[key: string]: any;
|
|
5
|
-
},
|
|
6
|
-
RestTableInterfaces extends {
|
|
7
|
+
} = any, PrimaryKey extends Extract<keyof RestTableInterface, string> = Extract<keyof RestTableInterface, string>, CustomAndRequiredFields extends {
|
|
7
8
|
[key: string]: any;
|
|
8
|
-
},
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
} = any, RequestTableOverrides extends {
|
|
10
|
+
[key in keyof RestTableInterface]: any;
|
|
11
|
+
} = {
|
|
12
|
+
[key in keyof RestTableInterface]: any;
|
|
13
|
+
}> extends Executor<RequestMethod, RestShortTableName, RestTableInterface, PrimaryKey, CustomAndRequiredFields, RequestTableOverrides> {
|
|
14
|
+
putState(response: AxiosResponse<DetermineResponseDataType<RequestMethod, RestTableInterface>>, request: iAPI<Modify<RestTableInterface, RequestTableOverrides>> & CustomAndRequiredFields, callback: () => void): void;
|
|
15
|
+
postState(response: AxiosResponse<DetermineResponseDataType<RequestMethod, RestTableInterface>>, request: iAPI<Modify<RestTableInterface, RequestTableOverrides>> & CustomAndRequiredFields, callback: () => void): void;
|
|
16
|
+
deleteState(_response: AxiosResponse<DetermineResponseDataType<RequestMethod, RestTableInterface>>, request: iAPI<Modify<RestTableInterface, RequestTableOverrides>> & CustomAndRequiredFields, callback: () => void): void;
|
|
17
|
+
execute(): Promise<apiReturn<DetermineResponseDataType<RequestMethod, RestTableInterface>>>;
|
|
15
18
|
}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { iRestMethods } from "@carbonorm/carbonnode";
|
|
2
2
|
import { RowDataPacket } from 'mysql2/promise';
|
|
3
3
|
import { Executor } from "./Executor";
|
|
4
|
-
export declare class SqlExecutor<
|
|
5
|
-
|
|
4
|
+
export declare class SqlExecutor<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
|
+
execute(): any;
|
|
6
14
|
private withConnection;
|
|
7
15
|
select<RestShortTableNames>(table: RestShortTableNames, primary: string | undefined, args: any): Promise<RowDataPacket[]>;
|
|
8
16
|
insert<RestShortTableNames>(table: RestShortTableNames, data: any): Promise<import("mysql2/promise").QueryResult>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
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
|
+
Get: (request?: Omit<RestTableInterface, keyof RequestTableOverrides> & RequestTableOverrides & {
|
|
12
|
+
dataInsertMultipleRows?: import("..").Modify<RestTableInterface, RequestTableOverrides>[] | undefined;
|
|
13
|
+
cacheResults?: boolean;
|
|
14
|
+
fetchDependencies?: number | import("..").eFetchDependencies | Awaited<import("./types/ormInterfaces").apiReturn<import("./types/ormInterfaces").iGetC6RestResponse<any>>>[];
|
|
15
|
+
debug?: boolean;
|
|
16
|
+
success?: string | ((r: import("axios").AxiosResponse) => (string | void));
|
|
17
|
+
error?: string | ((r: import("axios").AxiosResponse) => (string | void));
|
|
18
|
+
} & CustomAndRequiredFields) => Promise<import("./types/ormInterfaces").apiReturn<import("./types/ormInterfaces").iGetC6RestResponse<RestTableInterface, {}>>>;
|
|
19
|
+
Put: (request?: Omit<RestTableInterface, keyof RequestTableOverrides> & RequestTableOverrides & {
|
|
20
|
+
dataInsertMultipleRows?: import("..").Modify<RestTableInterface, RequestTableOverrides>[] | undefined;
|
|
21
|
+
cacheResults?: boolean;
|
|
22
|
+
fetchDependencies?: number | import("..").eFetchDependencies | Awaited<import("./types/ormInterfaces").apiReturn<import("./types/ormInterfaces").iGetC6RestResponse<any>>>[];
|
|
23
|
+
debug?: boolean;
|
|
24
|
+
success?: string | ((r: import("axios").AxiosResponse) => (string | void));
|
|
25
|
+
error?: string | ((r: import("axios").AxiosResponse) => (string | void));
|
|
26
|
+
} & CustomAndRequiredFields) => Promise<import("./types/ormInterfaces").apiReturn<import("./types/ormInterfaces").iPutC6RestResponse<RestTableInterface, any>>>;
|
|
27
|
+
Post: (request?: Omit<RestTableInterface, keyof RequestTableOverrides> & RequestTableOverrides & {
|
|
28
|
+
dataInsertMultipleRows?: import("..").Modify<RestTableInterface, RequestTableOverrides>[] | undefined;
|
|
29
|
+
cacheResults?: boolean;
|
|
30
|
+
fetchDependencies?: number | import("..").eFetchDependencies | Awaited<import("./types/ormInterfaces").apiReturn<import("./types/ormInterfaces").iGetC6RestResponse<any>>>[];
|
|
31
|
+
debug?: boolean;
|
|
32
|
+
success?: string | ((r: import("axios").AxiosResponse) => (string | void));
|
|
33
|
+
error?: string | ((r: import("axios").AxiosResponse) => (string | void));
|
|
34
|
+
} & CustomAndRequiredFields) => Promise<import("./types/ormInterfaces").apiReturn<import("./types/ormInterfaces").iPostC6RestResponse<RestTableInterface>>>;
|
|
35
|
+
Delete: (request?: Omit<RestTableInterface, keyof RequestTableOverrides> & RequestTableOverrides & {
|
|
36
|
+
dataInsertMultipleRows?: import("..").Modify<RestTableInterface, RequestTableOverrides>[] | undefined;
|
|
37
|
+
cacheResults?: boolean;
|
|
38
|
+
fetchDependencies?: number | import("..").eFetchDependencies | Awaited<import("./types/ormInterfaces").apiReturn<import("./types/ormInterfaces").iGetC6RestResponse<any>>>[];
|
|
39
|
+
debug?: boolean;
|
|
40
|
+
success?: string | ((r: import("axios").AxiosResponse) => (string | void));
|
|
41
|
+
error?: string | ((r: import("axios").AxiosResponse) => (string | void));
|
|
42
|
+
} & CustomAndRequiredFields) => Promise<import("./types/ormInterfaces").apiReturn<import("./types/ormInterfaces").iDeleteC6RestResponse<RestTableInterface, any>>>;
|
|
43
|
+
};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Modify } from "./types/modifyTypes";
|
|
2
|
-
import { apiReturn, iAPI, iRest } from "./types/ormInterfaces";
|
|
2
|
+
import { apiReturn, DetermineResponseDataType, iAPI, iRest, iRestMethods } from "./types/ormInterfaces";
|
|
3
3
|
/**
|
|
4
4
|
* Facade: routes API calls to SQL or HTTP executors based on runtime context.
|
|
5
5
|
*/
|
|
6
|
-
export default function restRequest<
|
|
6
|
+
export default function restRequest<RequestMethod extends iRestMethods, RestShortTableName extends string = any, RestTableInterface extends {
|
|
7
7
|
[key: string]: any;
|
|
8
|
-
} = any,
|
|
8
|
+
} = any, PrimaryKey extends Extract<keyof RestTableInterface, string> = Extract<keyof RestTableInterface, string>, CustomAndRequiredFields extends {
|
|
9
9
|
[key: string]: any;
|
|
10
10
|
} = any, RequestTableOverrides extends {
|
|
11
|
-
[key
|
|
12
|
-
} =
|
|
11
|
+
[key in keyof RestTableInterface]: any;
|
|
12
|
+
} = {
|
|
13
|
+
[key in keyof RestTableInterface]: any;
|
|
14
|
+
}>(config: iRest<RestShortTableName, RestTableInterface, PrimaryKey>): (request?: iAPI<Modify<RestTableInterface, RequestTableOverrides>> & CustomAndRequiredFields) => Promise<apiReturn<DetermineResponseDataType<RequestMethod, RestTableInterface>>>;
|
|
@@ -3,6 +3,7 @@ import { Pool } from "mysql2/promise";
|
|
|
3
3
|
import { eFetchDependencies } from "./dynamicFetching";
|
|
4
4
|
import { Modify } from "./modifyTypes";
|
|
5
5
|
import { JoinType, OrderDirection, SQLComparisonOperator, SQLFunction } from "./mysqlTypes";
|
|
6
|
+
import { CarbonReact } from "@carbonorm/carbonreact";
|
|
6
7
|
export interface stringMap {
|
|
7
8
|
[key: string]: string;
|
|
8
9
|
}
|
|
@@ -21,41 +22,76 @@ export interface iTypeValidation {
|
|
|
21
22
|
AUTO_INCREMENT: boolean;
|
|
22
23
|
SKIP_COLUMN_IN_POST: boolean;
|
|
23
24
|
}
|
|
24
|
-
export type iRestReactiveLifecycle<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
25
|
+
export type iRestReactiveLifecycle<RequestMethod extends iRestMethods, RestShortTableName extends string = any, RestTableInterface extends {
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
} = any, PrimaryKey extends keyof RestTableInterface & string = any, CustomAndRequiredFields extends {
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
} = any, RequestTableOverrides extends {
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
} = {
|
|
32
|
+
[key in keyof RestTableInterface]: any;
|
|
33
|
+
}> = {
|
|
34
|
+
beforeProcessing?: {
|
|
35
|
+
[key: string]: (args: {
|
|
36
|
+
config: iRest<RestShortTableName, RestTableInterface, PrimaryKey>;
|
|
37
|
+
request: iAPI<Modify<RestTableInterface, RequestTableOverrides>> & CustomAndRequiredFields;
|
|
38
|
+
}) => void | Promise<void>;
|
|
39
|
+
};
|
|
40
|
+
beforeExecution?: {
|
|
41
|
+
[key: string]: (args: {
|
|
42
|
+
config: iRest<RestShortTableName, RestTableInterface, PrimaryKey>;
|
|
43
|
+
request: iAPI<Modify<RestTableInterface, RequestTableOverrides>> & CustomAndRequiredFields;
|
|
44
|
+
}) => void | Promise<void>;
|
|
45
|
+
};
|
|
46
|
+
afterExecution?: {
|
|
47
|
+
[key: string]: (args: {
|
|
48
|
+
config: iRest<RestShortTableName, RestTableInterface, PrimaryKey>;
|
|
49
|
+
request: iAPI<Modify<RestTableInterface, RequestTableOverrides>> & CustomAndRequiredFields;
|
|
50
|
+
response: AxiosResponse<DetermineResponseDataType<RequestMethod, RestTableInterface>>;
|
|
51
|
+
}) => void | Promise<void>;
|
|
52
|
+
};
|
|
53
|
+
afterCommit?: {
|
|
54
|
+
[key: string]: (args: {
|
|
55
|
+
config: iRest<RestShortTableName, RestTableInterface, PrimaryKey>;
|
|
56
|
+
request: iAPI<Modify<RestTableInterface, RequestTableOverrides>> & CustomAndRequiredFields;
|
|
57
|
+
response: AxiosResponse<DetermineResponseDataType<RequestMethod, RestTableInterface>>;
|
|
58
|
+
}) => void | Promise<void>;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export type iRestHooks<RestShortTableName extends string = any, RestTableInterface extends {
|
|
62
|
+
[key: string]: any;
|
|
63
|
+
} = any, PrimaryKey extends keyof RestTableInterface & string = any, CustomAndRequiredFields extends {
|
|
64
|
+
[key: string]: any;
|
|
65
|
+
} = any, RequestTableOverrides extends {
|
|
66
|
+
[key: string]: any;
|
|
67
|
+
} = {
|
|
68
|
+
[key in keyof RestTableInterface]: any;
|
|
69
|
+
}> = {
|
|
70
|
+
[Method in iRestMethods]: iRestReactiveLifecycle<Method, RestShortTableName, RestTableInterface, PrimaryKey, CustomAndRequiredFields, RequestTableOverrides>;
|
|
43
71
|
};
|
|
44
72
|
export interface iConstraint {
|
|
45
73
|
TABLE: string;
|
|
46
74
|
COLUMN: string;
|
|
47
75
|
CONSTRAINT: string;
|
|
48
76
|
}
|
|
49
|
-
export
|
|
77
|
+
export type tColumns<TableName extends string, T extends {
|
|
78
|
+
[key: string]: any;
|
|
79
|
+
}> = {
|
|
80
|
+
[K in keyof T & string as `${TableName}.${K}`]: K;
|
|
81
|
+
};
|
|
82
|
+
export type tPrimaryKeys<TableName extends string, PK extends string> = `${TableName}.${PK}`;
|
|
83
|
+
export interface iC6RestfulModel<RestShortTableNames extends string, RestTableInterfaces extends {
|
|
84
|
+
[key: string]: any;
|
|
85
|
+
}, PK extends keyof RestTableInterfaces & string> {
|
|
50
86
|
TABLE_NAME: RestShortTableNames;
|
|
51
|
-
PRIMARY:
|
|
52
|
-
PRIMARY_SHORT:
|
|
53
|
-
COLUMNS:
|
|
54
|
-
LIFECYCLE_HOOKS: iRestReactiveLifecycle<RequestGetPutDeleteBody>[];
|
|
55
|
-
REGEX_VALIDATION: RegExpMap;
|
|
87
|
+
PRIMARY: tPrimaryKeys<RestShortTableNames, PK>[];
|
|
88
|
+
PRIMARY_SHORT: PK[];
|
|
89
|
+
COLUMNS: tColumns<RestShortTableNames, RestTableInterfaces>;
|
|
56
90
|
TYPE_VALIDATION: {
|
|
57
91
|
[key: string]: iTypeValidation;
|
|
58
92
|
};
|
|
93
|
+
REGEX_VALIDATION: RegExpMap;
|
|
94
|
+
LIFECYCLE_HOOKS: iRestHooks<RestShortTableNames, RestTableInterfaces, PK>;
|
|
59
95
|
TABLE_REFERENCES: {
|
|
60
96
|
[columnName: string]: iConstraint[];
|
|
61
97
|
};
|
|
@@ -75,10 +111,12 @@ export interface iDynamicApiImport<RestData = any> {
|
|
|
75
111
|
deleteState?: (response: AxiosResponse<iDeleteC6RestResponse<RestData>>, request: iAPI<any>) => void;
|
|
76
112
|
putState?: (response: AxiosResponse<iPutC6RestResponse<RestData>>, request: iAPI<any>) => void;
|
|
77
113
|
}
|
|
78
|
-
export interface tC6Tables {
|
|
79
|
-
[key: string]:
|
|
114
|
+
export interface tC6Tables<RestShortTableName extends string = any, RestTableInterface extends {
|
|
115
|
+
[key: string]: any;
|
|
116
|
+
} = any, PrimaryKey extends Extract<keyof RestTableInterface, string> = Extract<keyof RestTableInterface, string>> {
|
|
117
|
+
[key: string]: iC6RestfulModel<RestShortTableName, RestTableInterface, PrimaryKey> & {
|
|
80
118
|
[key: string]: any;
|
|
81
|
-
}
|
|
119
|
+
};
|
|
82
120
|
}
|
|
83
121
|
export interface tC6RestApi {
|
|
84
122
|
[key: string]: {
|
|
@@ -172,10 +210,12 @@ export interface iPostC6RestResponse<RestData = any> extends iC6RestResponse<Res
|
|
|
172
210
|
export interface iPutC6RestResponse<RestData = any, RequestData = any> extends iChangeC6Data, iC6RestResponse<RestData> {
|
|
173
211
|
updated: boolean | number | string | RequestData;
|
|
174
212
|
}
|
|
175
|
-
export interface iC6Object {
|
|
213
|
+
export interface iC6Object<RestShortTableName extends string = any, RestTableInterface extends {
|
|
214
|
+
[key: string]: any;
|
|
215
|
+
} = any, PrimaryKey extends Extract<keyof RestTableInterface, string> = Extract<keyof RestTableInterface, string>> {
|
|
176
216
|
C6VERSION: string;
|
|
177
217
|
TABLES: {
|
|
178
|
-
[key: string]: iC6RestfulModel & {
|
|
218
|
+
[key: string]: iC6RestfulModel<RestShortTableName, RestTableInterface, PrimaryKey> & {
|
|
179
219
|
[key: string]: string | number;
|
|
180
220
|
};
|
|
181
221
|
};
|
|
@@ -185,39 +225,21 @@ export interface iC6Object {
|
|
|
185
225
|
}
|
|
186
226
|
export type iGetC6RestResponse<ResponseDataType, ResponseDataOverrides = {}> = iC6RestResponse<Modify<ResponseDataType, ResponseDataOverrides> | Modify<ResponseDataType, ResponseDataOverrides>[]>;
|
|
187
227
|
export type apiReturn<Response> = null | undefined | AxiosPromise<Response> | (Response extends iPutC6RestResponse | iDeleteC6RestResponse | iPostC6RestResponse ? null : (() => apiReturn<Response>));
|
|
188
|
-
export
|
|
228
|
+
export type DetermineResponseDataType<RequestMethod extends iRestMethods, RestTableInterface extends {
|
|
189
229
|
[key: string]: any;
|
|
190
|
-
}
|
|
230
|
+
}> = RequestMethod extends "POST" ? iPostC6RestResponse<RestTableInterface> : RequestMethod extends "GET" ? iGetC6RestResponse<RestTableInterface> : RequestMethod extends "PUT" ? iPutC6RestResponse<RestTableInterface> : RequestMethod extends "DELETE" ? iDeleteC6RestResponse<RestTableInterface> : any;
|
|
231
|
+
export interface iRest<RestShortTableName extends string = any, RestTableInterface extends {
|
|
191
232
|
[key: string]: any;
|
|
192
|
-
},
|
|
193
|
-
[key in keyof RestTableInterfaces]: any;
|
|
194
|
-
}, ResponseDataType = any, RestShortTableNames extends string = any> {
|
|
233
|
+
} = any, PrimaryKey extends keyof RestTableInterface & string = any> {
|
|
195
234
|
C6: iC6Object;
|
|
196
235
|
axios?: AxiosInstance;
|
|
197
236
|
restURL?: string;
|
|
198
237
|
mysqlPool?: Pool;
|
|
199
238
|
withCredentials?: boolean;
|
|
200
|
-
|
|
239
|
+
restModel: iC6RestfulModel<RestShortTableName, RestTableInterface, PrimaryKey>;
|
|
240
|
+
reactBootstrap?: CarbonReact<any, any>;
|
|
201
241
|
requestMethod: iRestMethods;
|
|
202
242
|
clearCache?: () => void;
|
|
203
243
|
skipPrimaryCheck?: boolean;
|
|
204
|
-
queryCallback: RequestQueryBody<Modify<RestTableInterfaces, RequestTableOverrides>> | ((request: iAPI<Modify<RestTableInterfaces, RequestTableOverrides>> & CustomAndRequiredFields) => (null | undefined | RequestQueryBody<Modify<RestTableInterfaces, RequestTableOverrides>>));
|
|
205
|
-
responseCallback?: (response: AxiosResponse<ResponseDataType>, request: iAPI<Modify<RestTableInterfaces, RequestTableOverrides>> & CustomAndRequiredFields, success: (ResponseDataType extends iPutC6RestResponse | iDeleteC6RestResponse ? RequestQueryBody<Modify<RestTableInterfaces, RequestTableOverrides>> : string) | string | number | boolean) => any;
|
|
206
244
|
}
|
|
207
|
-
export declare function extendedTypeHints<RestTableInterfaces extends {
|
|
208
|
-
[key: string]: any;
|
|
209
|
-
}, RestShortTableNames extends string>(): <CustomAndRequiredFields extends {
|
|
210
|
-
[key: string]: any;
|
|
211
|
-
} = any, RequestTableTypes extends RestTableInterfaces = any, RequestTableOverrides extends {
|
|
212
|
-
[key: string]: any;
|
|
213
|
-
} = any, ResponseDataType extends {
|
|
214
|
-
[key: string]: any;
|
|
215
|
-
} = any>(argv: any) => (request?: Omit<RequestTableTypes, keyof RequestTableOverrides> & RequestTableOverrides & {
|
|
216
|
-
dataInsertMultipleRows?: Modify<RequestTableTypes, RequestTableOverrides>[] | undefined;
|
|
217
|
-
cacheResults?: boolean;
|
|
218
|
-
fetchDependencies?: number | eFetchDependencies | Awaited<apiReturn<iGetC6RestResponse<any>>>[];
|
|
219
|
-
debug?: boolean;
|
|
220
|
-
success?: string | ((r: AxiosResponse) => (string | void));
|
|
221
|
-
error?: string | ((r: AxiosResponse) => (string | void));
|
|
222
|
-
} & CustomAndRequiredFields) => Promise<apiReturn<ResponseDataType>>;
|
|
223
245
|
export {};
|
|
@@ -3,7 +3,7 @@ import { iC6RestfulModel } from "../types/ormInterfaces";
|
|
|
3
3
|
export declare function TestRestfulResponse(response: AxiosResponse | any, success: ((r: AxiosResponse) => (string | void)) | string | undefined, error: ((r: AxiosResponse) => (string | void)) | string | undefined): string | boolean | number;
|
|
4
4
|
export declare function removePrefixIfExists(tableName: string, prefix: string): string;
|
|
5
5
|
export declare function removeInvalidKeys<iRestObject>(request: any, c6Tables: {
|
|
6
|
-
[key: string]: (iC6RestfulModel & {
|
|
6
|
+
[key: string]: (iC6RestfulModel<any, any, any> & {
|
|
7
7
|
[key: string]: any;
|
|
8
8
|
});
|
|
9
9
|
}): iRestObject;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { iC6RestfulModel } from "../types/ormInterfaces";
|
|
2
|
+
type JsPrimitive = 'string' | 'number' | 'boolean' | 'buffer' | 'object';
|
|
3
|
+
export declare function determineRuntimeJsType(mysqlType: string): JsPrimitive;
|
|
4
|
+
export declare function getPrimaryKeyTypes(table: iC6RestfulModel<string, any, any>): Record<string, JsPrimitive>;
|
|
5
|
+
export {};
|