@carbonorm/carbonnode 1.0.0 → 1.0.1

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.
@@ -0,0 +1,122 @@
1
+ export declare const C6: {
2
+ ADDDATE: string;
3
+ ADDTIME: string;
4
+ AS: string;
5
+ ASC: string;
6
+ BETWEEN: string;
7
+ CONCAT: string;
8
+ CONVERT_TZ: string;
9
+ COUNT: string;
10
+ COUNT_ALL: string;
11
+ CURRENT_DATE: string;
12
+ CURRENT_TIMESTAMP: string;
13
+ DAY: string;
14
+ DAY_HOUR: string;
15
+ DAY_MICROSECOND: string;
16
+ DAY_MINUTE: string;
17
+ DAY_SECOND: string;
18
+ DAYNAME: string;
19
+ DAYOFMONTH: string;
20
+ DAYOFWEEK: string;
21
+ DAYOFYEAR: string;
22
+ DATE: string;
23
+ DATE_ADD: string;
24
+ DATEDIFF: string;
25
+ DATE_SUB: string;
26
+ DATE_FORMAT: string;
27
+ DESC: string;
28
+ DISTINCT: string;
29
+ EXTRACT: string;
30
+ EQUAL: string;
31
+ EQUAL_NULL_SAFE: string;
32
+ FALSE: string;
33
+ FULL_OUTER: string;
34
+ FROM_DAYS: string;
35
+ FROM_UNIXTIME: string;
36
+ GET_FORMAT: string;
37
+ GREATER_THAN: string;
38
+ GROUP_BY: string;
39
+ GROUP_CONCAT: string;
40
+ GREATER_THAN_OR_EQUAL_TO: string;
41
+ HAVING: string;
42
+ HEX: string;
43
+ HOUR: string;
44
+ HOUR_MICROSECOND: string;
45
+ HOUR_SECOND: string;
46
+ HOUR_MINUTE: string;
47
+ IN: string;
48
+ IS: string;
49
+ IS_NOT: string;
50
+ INNER: string;
51
+ INTERVAL: string;
52
+ JOIN: string;
53
+ LEFT: string;
54
+ LEFT_OUTER: string;
55
+ LESS_THAN: string;
56
+ LESS_THAN_OR_EQUAL_TO: string;
57
+ LIKE: string;
58
+ LIMIT: string;
59
+ LOCALTIME: string;
60
+ LOCALTIMESTAMP: string;
61
+ MAKEDATE: string;
62
+ MAKETIME: string;
63
+ MONTHNAME: string;
64
+ MICROSECOND: string;
65
+ MINUTE: string;
66
+ MINUTE_MICROSECOND: string;
67
+ MINUTE_SECOND: string;
68
+ MIN: string;
69
+ MAX: string;
70
+ MONTH: string;
71
+ NOT_LIKE: string;
72
+ NOT_EQUAL: string;
73
+ NOT_IN: string;
74
+ NOW: string;
75
+ NULL: string;
76
+ ORDER: string;
77
+ PAGE: string;
78
+ PAGINATION: string;
79
+ RIGHT_OUTER: string;
80
+ SECOND: string;
81
+ SECOND_MICROSECOND: string;
82
+ SELECT: string;
83
+ STR_TO_DATE: string;
84
+ SUBDATE: string;
85
+ SUBTIME: string;
86
+ SUM: string;
87
+ SYSDATE: string;
88
+ TIME: string;
89
+ TIME_FORMAT: string;
90
+ TIME_TO_SEC: string;
91
+ TIMEDIFF: string;
92
+ TIMESTAMP: string;
93
+ TIMESTAMPADD: string;
94
+ TIMESTAMPDIFF: string;
95
+ TO_DAYS: string;
96
+ TO_SECONDS: string;
97
+ TRANSACTION_TIMESTAMP: string;
98
+ TRUE: string;
99
+ UNIX_TIMESTAMP: string;
100
+ UNKNOWN: string;
101
+ UPDATE: string;
102
+ UNHEX: string;
103
+ UTC_DATE: string;
104
+ UTC_TIME: string;
105
+ UTC_TIMESTAMP: string;
106
+ WHERE: string;
107
+ WEEKDAY: string;
108
+ WEEKOFYEAR: string;
109
+ YEARWEEK: string;
110
+ DEPENDANT_ON_ENTITY: string;
111
+ OPTIONS: string;
112
+ GET: string;
113
+ POST: string;
114
+ PUT: string;
115
+ REPLACE: string;
116
+ DELETE: string;
117
+ REST_REQUEST_PREPROCESS_CALLBACKS: string;
118
+ PREPROCESS: string;
119
+ REST_REQUEST_FINNISH_CALLBACKS: string;
120
+ FINISH: string;
121
+ VALIDATE_C6_ENTITY_ID_REGEX: string;
122
+ };
@@ -0,0 +1,3 @@
1
+ export default function <RestTableInterfaces extends {
2
+ [key: string]: any;
3
+ }>(restfulObject: RestTableInterfaces, tableName: string | string[], regexErrorHandler?: (message: string) => void): {};
@@ -0,0 +1,27 @@
1
+ export interface stringMap {
2
+ [key: string]: string;
3
+ }
4
+ export interface stringNumberMap {
5
+ [key: string]: string | number;
6
+ }
7
+ export interface RegExpMap {
8
+ [key: string]: RegExp | RegExpMap;
9
+ }
10
+ export interface complexMap {
11
+ [key: string]: stringMap | stringNumberMap | stringMap[] | RegExpMap;
12
+ }
13
+ export interface iTypeValidation {
14
+ MYSQL_TYPE: string;
15
+ MAX_LENGTH: string;
16
+ AUTO_INCREMENT: boolean;
17
+ SKIP_COLUMN_IN_POST: boolean;
18
+ }
19
+ export interface C6RestfulModel<RestShortTableNames extends string = string> {
20
+ TABLE_NAME: RestShortTableNames;
21
+ PRIMARY: string[];
22
+ COLUMNS: stringMap;
23
+ REGEX_VALIDATION: RegExpMap;
24
+ TYPE_VALIDATION: {
25
+ [key: string]: iTypeValidation;
26
+ };
27
+ }
@@ -0,0 +1,131 @@
1
+ import { C6RestfulModel } from "api/interfaces/ormInterfaces";
2
+ import { AxiosInstance, AxiosPromise, AxiosResponse } from "axios";
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
+ export declare function removeInvalidKeys<iRestObject>(request: any, c6Tables: (C6RestfulModel)[]): iRestObject;
5
+ export type Modify<T, R> = Omit<T, keyof R> & R;
6
+ export type ModifyDeep<A, B extends DeepPartialAny<A>> = {
7
+ [K in keyof A | keyof B]?: K extends keyof A ? K extends keyof B ? A[K] extends AnyObject ? B[K] extends AnyObject ? ModifyDeep<A[K], B[K]> : B[K] : B[K] : A[K] : B[K];
8
+ };
9
+ type AnyObject = Record<string, any>;
10
+ type DeepPartialAny<T> = {
11
+ [P in keyof T]?: T[P] extends AnyObject ? DeepPartialAny<T[P]> : any;
12
+ };
13
+ export type iAPI<RestTableInterfaces extends {
14
+ [key: string]: any;
15
+ }> = RestTableInterfaces & {
16
+ dataInsertMultipleRows?: RestTableInterfaces[];
17
+ cacheResults?: boolean;
18
+ fetchDependencies?: boolean;
19
+ debug?: boolean;
20
+ success?: string | ((r: AxiosResponse) => (string | void));
21
+ error?: string | ((r: AxiosResponse) => (string | void));
22
+ blocking?: boolean;
23
+ };
24
+ export declare function checkAllRequestsComplete(): true | (string[]);
25
+ interface iClearCache {
26
+ ignoreWarning: boolean;
27
+ }
28
+ export declare function clearCache(props?: iClearCache): void;
29
+ /**
30
+ * the first argument ....
31
+ *
32
+ * Our api returns a zero argument function iff the method is get and the previous request reached the predefined limit.
33
+ * This function can be aliased as GetNextPageOfResults(). If the end is reached undefined will be returned.
34
+ *
35
+ *
36
+ * For POST, PUT, and DELETE requests one can expect the primary key of the new or modified index, or a boolean success
37
+ * indication if no primary key exists.
38
+ **/
39
+ export declare const POST = "POST";
40
+ export declare const PUT = "PUT";
41
+ export declare const GET = "GET";
42
+ export declare const DELETE = "DELETE";
43
+ export type apiReturn<Response> = null | undefined | AxiosPromise<Response> | (Response extends iGetC6RestResponse<any> ? (() => apiReturn<Response>) : null);
44
+ export type iRestMethods = 'GET' | 'POST' | 'PUT' | 'DELETE';
45
+ export type RequestGetPutDeleteBody = {
46
+ SELECT?: any;
47
+ UPDATE?: any;
48
+ DELETE?: any;
49
+ WHERE?: any;
50
+ JOIN?: {
51
+ LEFT?: any;
52
+ RIGHT?: any;
53
+ INNER?: any;
54
+ };
55
+ PAGINATION?: {
56
+ PAGE?: number;
57
+ LIMIT?: number;
58
+ };
59
+ };
60
+ export type RequestQueryBody<RestTableInterfaces extends {
61
+ [key: string]: any;
62
+ }> = iAPI<RestTableInterfaces> | RequestGetPutDeleteBody;
63
+ export declare function isPromise(x: any): boolean;
64
+ interface iC6RestResponse<RestData> {
65
+ rest: RestData;
66
+ session?: any;
67
+ sql?: any;
68
+ }
69
+ interface iChangeC6Data {
70
+ rowCount: number;
71
+ }
72
+ export interface iDeleteC6RestResponse<RestData = any, RequestData = any> extends iChangeC6Data, iC6RestResponse<RestData> {
73
+ deleted: boolean | number | string | RequestData;
74
+ }
75
+ export interface iPostC6RestResponse<RestData = any> extends iC6RestResponse<RestData> {
76
+ created: boolean | number | string;
77
+ }
78
+ export interface iPutC6RestResponse<RestData = any, RequestData = any> extends iChangeC6Data, iC6RestResponse<RestData> {
79
+ updated: boolean | number | string | RequestData;
80
+ }
81
+ export type iGetC6RestResponse<ResponseDataType, ResponseDataOverrides = {}> = iC6RestResponse<Modify<ResponseDataType, ResponseDataOverrides>[]>;
82
+ interface iRest<CustomAndRequiredFields extends {
83
+ [key: string]: any;
84
+ }, RestTableInterfaces extends {
85
+ [key: string]: any;
86
+ }, RequestTableOverrides = {
87
+ [key in keyof RestTableInterfaces]: any;
88
+ }, ResponseDataType = any, RestShortTableNames extends string = any> {
89
+ C6: {
90
+ TABLES: {
91
+ [key: string]: C6RestfulModel & {
92
+ [key: string]: string | number;
93
+ };
94
+ };
95
+ } & {
96
+ [key: string]: string;
97
+ };
98
+ axios: AxiosInstance;
99
+ restURL: string;
100
+ tableName: RestShortTableNames | RestShortTableNames[];
101
+ requestMethod: iRestMethods;
102
+ clearCache?: () => void;
103
+ skipPrimaryCheck?: boolean;
104
+ queryCallback: RequestQueryBody<Modify<RestTableInterfaces, RequestTableOverrides>> | ((request: iAPI<Modify<RestTableInterfaces, RequestTableOverrides>> & CustomAndRequiredFields) => (null | undefined | RequestQueryBody<Modify<RestTableInterfaces, RequestTableOverrides>>));
105
+ responseCallback: (response: AxiosResponse<ResponseDataType>, request: iAPI<Modify<RestTableInterfaces, RequestTableOverrides>> & CustomAndRequiredFields, success: (ResponseDataType extends iPutC6RestResponse | iDeleteC6RestResponse ? RequestQueryBody<Modify<RestTableInterfaces, RequestTableOverrides>> : string) | string | number | boolean) => any;
106
+ }
107
+ export declare function extendedTypeHints<RestTableInterfaces extends {
108
+ [key: string]: any;
109
+ }, RestShortTableNames extends string>(): <CustomAndRequiredFields extends {
110
+ [key: string]: any;
111
+ } = any, RequestTableTypes extends RestTableInterfaces = any, RequestTableOverrides extends {
112
+ [key: string]: any;
113
+ } = any, ResponseDataType extends {
114
+ [key: string]: any;
115
+ } = any>(argv: any) => (request?: Omit<RequestTableTypes, keyof RequestTableOverrides> & RequestTableOverrides & {
116
+ dataInsertMultipleRows?: Modify<RequestTableTypes, RequestTableOverrides>[] | undefined;
117
+ cacheResults?: boolean | undefined;
118
+ fetchDependencies?: boolean | undefined;
119
+ debug?: boolean | undefined;
120
+ success?: string | ((r: AxiosResponse<any, any>) => string | void) | undefined;
121
+ error?: string | ((r: AxiosResponse<any, any>) => string | void) | undefined;
122
+ blocking?: boolean | undefined;
123
+ } & CustomAndRequiredFields) => apiReturn<ResponseDataType>;
124
+ export default function restApi<CustomAndRequiredFields extends {
125
+ [key: string]: any;
126
+ } = any, RestTableInterfaces extends {
127
+ [key: string]: any;
128
+ } = any, RequestTableOverrides extends {
129
+ [key: string]: any;
130
+ } = any, ResponseDataType = any, RestShortTableNames extends string = any>({ C6, axios, restURL, tableName, requestMethod, queryCallback, responseCallback, skipPrimaryCheck, clearCache }: iRest<CustomAndRequiredFields, RestTableInterfaces, RequestTableOverrides, ResponseDataType, RestShortTableNames>): (request?: iAPI<Modify<RestTableInterfaces, RequestTableOverrides>> & CustomAndRequiredFields) => apiReturn<ResponseDataType>;
131
+ export {};