@carbonorm/carbonnode 3.0.2 → 3.0.4

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.
@@ -1,4 +1,8 @@
1
- import { iC6Object } from "./types/ormInterfaces";
2
- export default function <RestTableInterfaces extends {
1
+ import { iC6Object, iRestMethods, RequestQueryBody } from "./types/ormInterfaces";
2
+ export default function <RequestMethod extends iRestMethods, RestTableInterface extends {
3
3
  [key: string]: any;
4
- }>(restfulObject: RestTableInterfaces, tableName: string | string[], C6: iC6Object, regexErrorHandler?: (message: string) => void): {};
4
+ }, CustomAndRequiredFields extends {
5
+ [key: string]: any;
6
+ } = {}, RequestTableOverrides extends {
7
+ [K in keyof RestTableInterface]?: any;
8
+ } = {}>(restfulObject: RequestQueryBody<RequestMethod, RestTableInterface, CustomAndRequiredFields, RequestTableOverrides>, tableName: string | string[], C6: iC6Object, regexErrorHandler?: (message: string) => void): {};
@@ -1,16 +1,16 @@
1
- import { apiReturn, iAPI, iRest } from "@carbonorm/carbonnode";
2
- import { Modify } from "../types/modifyTypes";
3
- export declare abstract class Executor<RestShortTableName extends string = any, RestTableInterface extends {
1
+ import { apiReturn, DetermineResponseDataType, iRest, iRestMethods, iRestReactiveLifecycle, RequestQueryBody } from "@carbonorm/carbonnode";
2
+ export declare abstract class Executor<RequestMethod extends iRestMethods, RestShortTableName extends string = any, RestTableInterface extends {
4
3
  [key: string]: any;
5
4
  } = any, PrimaryKey extends Extract<keyof RestTableInterface, string> = Extract<keyof RestTableInterface, string>, CustomAndRequiredFields extends {
6
5
  [key: string]: any;
7
6
  } = any, RequestTableOverrides extends {
8
- [key: string]: any;
7
+ [key in keyof RestTableInterface]: any;
9
8
  } = {
10
9
  [key in keyof RestTableInterface]: any;
11
- }, ResponseDataType = any> {
12
- protected config: iRest<RestShortTableName, RestTableInterface, PrimaryKey, CustomAndRequiredFields, RequestTableOverrides, ResponseDataType>;
13
- protected request: iAPI<Modify<RestTableInterface, RequestTableOverrides>> & CustomAndRequiredFields;
14
- constructor(config: iRest<RestShortTableName, RestTableInterface, PrimaryKey, CustomAndRequiredFields, RequestTableOverrides, ResponseDataType>, request?: iAPI<Modify<RestTableInterface, RequestTableOverrides>> & CustomAndRequiredFields);
15
- abstract execute(): Promise<apiReturn<ResponseDataType>>;
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>;
16
16
  }
@@ -1,13 +1,17 @@
1
- import { apiReturn } from "../types/ormInterfaces";
1
+ import { AxiosResponse } from "axios";
2
+ import { apiReturn, DetermineResponseDataType, iRestMethods, RequestQueryBody } from "../types/ormInterfaces";
2
3
  import { Executor } from "./Executor";
3
- export declare class HttpExecutor<RestShortTableName extends string = any, RestTableInterface extends {
4
+ export declare class HttpExecutor<RequestMethod extends iRestMethods, RestShortTableName extends string = any, RestTableInterface extends {
4
5
  [key: string]: any;
5
6
  } = any, PrimaryKey extends Extract<keyof RestTableInterface, string> = Extract<keyof RestTableInterface, string>, CustomAndRequiredFields extends {
6
7
  [key: string]: any;
7
8
  } = any, RequestTableOverrides extends {
8
- [key: string]: any;
9
+ [key in keyof RestTableInterface]: any;
9
10
  } = {
10
11
  [key in keyof RestTableInterface]: any;
11
- }, ResponseDataType = any> extends Executor<RestShortTableName, RestTableInterface, PrimaryKey, CustomAndRequiredFields, RequestTableOverrides, ResponseDataType> {
12
- execute(): Promise<apiReturn<ResponseDataType>>;
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>>>;
13
17
  }
@@ -1,16 +1,16 @@
1
- import { apiReturn } from "@carbonorm/carbonnode";
1
+ import { iRestMethods } from "@carbonorm/carbonnode";
2
2
  import { RowDataPacket } from 'mysql2/promise';
3
3
  import { Executor } from "./Executor";
4
- export declare class SqlExecutor<RestShortTableName extends string = any, RestTableInterface extends {
4
+ export declare class SqlExecutor<RequestMethod extends iRestMethods, RestShortTableName extends string = any, RestTableInterface extends {
5
5
  [key: string]: any;
6
6
  } = any, PrimaryKey extends Extract<keyof RestTableInterface, string> = Extract<keyof RestTableInterface, string>, CustomAndRequiredFields extends {
7
7
  [key: string]: any;
8
8
  } = any, RequestTableOverrides extends {
9
- [key: string]: any;
9
+ [key in keyof RestTableInterface]: any;
10
10
  } = {
11
11
  [key in keyof RestTableInterface]: any;
12
- }, ResponseDataType = any> extends Executor<RestShortTableName, RestTableInterface, PrimaryKey, CustomAndRequiredFields, RequestTableOverrides, ResponseDataType> {
13
- execute(): Promise<apiReturn<ResponseDataType>>;
12
+ }> extends Executor<RequestMethod, RestShortTableName, RestTableInterface, PrimaryKey, CustomAndRequiredFields, RequestTableOverrides> {
13
+ execute(): any;
14
14
  private withConnection;
15
15
  select<RestShortTableNames>(table: RestShortTableNames, primary: string | undefined, args: any): Promise<RowDataPacket[]>;
16
16
  insert<RestShortTableNames>(table: RestShortTableNames, data: any): Promise<import("mysql2/promise").QueryResult>;
@@ -0,0 +1,15 @@
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: import("./types/ormInterfaces").iAPI<import("./types/ormInterfaces").RequestGetPutDeleteBody<Omit<RestTableInterface, keyof RequestTableOverrides> & RequestTableOverrides & CustomAndRequiredFields>>) => Promise<import("./types/ormInterfaces").apiReturn<import("./types/ormInterfaces").iGetC6RestResponse<RestTableInterface, {}>>>;
12
+ Put: (request: import("./types/ormInterfaces").iAPI<import("./types/ormInterfaces").RequestGetPutDeleteBody<Omit<RestTableInterface, keyof RequestTableOverrides> & RequestTableOverrides & CustomAndRequiredFields>>) => Promise<import("./types/ormInterfaces").apiReturn<import("./types/ormInterfaces").iPutC6RestResponse<RestTableInterface, any>>>;
13
+ Post: (request: import("./types/ormInterfaces").iAPI<Omit<RestTableInterface, keyof RequestTableOverrides> & RequestTableOverrides & CustomAndRequiredFields>) => Promise<import("./types/ormInterfaces").apiReturn<import("./types/ormInterfaces").iPostC6RestResponse<RestTableInterface>>>;
14
+ Delete: (request: import("./types/ormInterfaces").iAPI<import("./types/ormInterfaces").RequestGetPutDeleteBody<Omit<RestTableInterface, keyof RequestTableOverrides> & RequestTableOverrides & CustomAndRequiredFields>>) => Promise<import("./types/ormInterfaces").apiReturn<import("./types/ormInterfaces").iDeleteC6RestResponse<RestTableInterface, any>>>;
15
+ };
@@ -1,14 +1,13 @@
1
- import { Modify } from "./types/modifyTypes";
2
- import { apiReturn, iAPI, iRest } from "./types/ormInterfaces";
1
+ import { apiReturn, DetermineResponseDataType, iRest, iRestMethods, RequestQueryBody } from "./types/ormInterfaces";
3
2
  /**
4
3
  * Facade: routes API calls to SQL or HTTP executors based on runtime context.
5
4
  */
6
- export default function restRequest<RestShortTableName extends string = any, RestTableInterface extends {
5
+ export default function restRequest<RequestMethod extends iRestMethods, RestShortTableName extends string = any, RestTableInterface extends {
7
6
  [key: string]: any;
8
7
  } = any, PrimaryKey extends Extract<keyof RestTableInterface, string> = Extract<keyof RestTableInterface, string>, CustomAndRequiredFields extends {
9
8
  [key: string]: any;
10
9
  } = any, RequestTableOverrides extends {
11
- [key: string]: any;
10
+ [key in keyof RestTableInterface]: any;
12
11
  } = {
13
12
  [key in keyof RestTableInterface]: any;
14
- }, ResponseDataType = any>(config: iRest<RestShortTableName, RestTableInterface, PrimaryKey, CustomAndRequiredFields, RequestTableOverrides, ResponseDataType>): (request?: iAPI<Modify<RestTableInterface, RequestTableOverrides>> & CustomAndRequiredFields) => Promise<apiReturn<ResponseDataType>>;
13
+ }>(config: iRest<RestShortTableName, RestTableInterface, PrimaryKey>): (request: RequestQueryBody<RequestMethod, RestTableInterface, CustomAndRequiredFields, RequestTableOverrides>) => Promise<apiReturn<DetermineResponseDataType<RequestMethod, RestTableInterface>>>;
@@ -3,6 +3,12 @@ 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";
7
+ export type iRestMethods = 'GET' | 'POST' | 'PUT' | 'DELETE';
8
+ export declare const POST = "POST";
9
+ export declare const PUT = "PUT";
10
+ export declare const GET = "GET";
11
+ export declare const DELETE = "DELETE";
6
12
  export interface stringMap {
7
13
  [key: string]: string;
8
14
  }
@@ -21,121 +27,17 @@ export interface iTypeValidation {
21
27
  AUTO_INCREMENT: boolean;
22
28
  SKIP_COLUMN_IN_POST: boolean;
23
29
  }
24
- export type iRestReactiveLifecycle<T extends RequestGetPutDeleteBody> = {
25
- beforeProcessing?: (args: {
26
- request: T[];
27
- requestMeta?: any;
28
- }) => void | Promise<void>;
29
- beforeExecution?: (args: {
30
- request: T[];
31
- requestMeta?: any;
32
- }) => void | Promise<void>;
33
- afterExecution?: (args: {
34
- response: T[];
35
- request: T[];
36
- responseMeta?: any;
37
- }) => void | Promise<void>;
38
- afterCommit?: (args: {
39
- response: T[];
40
- request: T[];
41
- responseMeta?: any;
42
- }) => void | Promise<void>;
43
- };
44
- export interface iConstraint {
45
- TABLE: string;
46
- COLUMN: string;
47
- CONSTRAINT: string;
48
- }
49
- export type tColumns<TableName extends string, T extends {
50
- [key: string]: any;
51
- }> = {
52
- [K in keyof T & string as `${TableName}.${K}`]: K;
53
- };
54
- export type tPrimaryKeys<TableName extends string, PK extends string> = `${TableName}.${PK}`;
55
- export interface iC6RestfulModel<RestShortTableNames extends string, RestTableInterfaces extends {
56
- [key: string]: any;
57
- }, PK extends keyof RestTableInterfaces & string> {
58
- TABLE_NAME: RestShortTableNames;
59
- PRIMARY: tPrimaryKeys<RestShortTableNames, PK>[];
60
- PRIMARY_SHORT: PK[];
61
- COLUMNS: tColumns<RestShortTableNames, RestTableInterfaces>;
62
- TYPE_VALIDATION: {
63
- [key: string]: iTypeValidation;
64
- };
65
- REGEX_VALIDATION: RegExpMap;
66
- LIFECYCLE_HOOKS: iRestReactiveLifecycle<RequestGetPutDeleteBody>[];
67
- TABLE_REFERENCES: {
68
- [columnName: string]: iConstraint[];
69
- };
70
- TABLE_REFERENCED_BY: {
71
- [columnName: string]: iConstraint[];
72
- };
73
- }
74
- export interface iRestApiFunctions<RestData = any> {
75
- Delete: (request?: (iAPI<any> & any)) => apiReturn<iDeleteC6RestResponse<RestData>>;
76
- Post: (request?: (iAPI<any> & any)) => apiReturn<iPostC6RestResponse<RestData>>;
77
- Get: (request?: (iAPI<any> & any)) => apiReturn<iGetC6RestResponse<RestData>>;
78
- Put: (request?: (iAPI<any> & any)) => apiReturn<iPutC6RestResponse<RestData>>;
79
- }
80
- export interface iDynamicApiImport<RestData = any> {
81
- default: iRestApiFunctions<RestData>;
82
- postState?: (response: AxiosResponse<iPostC6RestResponse<RestData>>, request: iAPI<any>, id: string | number | boolean) => void;
83
- deleteState?: (response: AxiosResponse<iDeleteC6RestResponse<RestData>>, request: iAPI<any>) => void;
84
- putState?: (response: AxiosResponse<iPutC6RestResponse<RestData>>, request: iAPI<any>) => void;
85
- }
86
- export interface tC6Tables<RestShortTableName extends string = any, RestTableInterface extends {
87
- [key: string]: any;
88
- } = any, PrimaryKey extends Extract<keyof RestTableInterface, string> = Extract<keyof RestTableInterface, string>> {
89
- [key: string]: iC6RestfulModel<RestShortTableName, RestTableInterface, PrimaryKey> & {
90
- [key: string]: any;
91
- };
92
- }
93
- export interface tC6RestApi {
94
- [key: string]: {
95
- REST: iRestApiFunctions;
96
- PUT: Function;
97
- POST: Function;
98
- DELETE: Function;
99
- };
100
- }
101
- export type iAPI<RestTableInterfaces extends {
30
+ export type SubSelect<T extends {
102
31
  [key: string]: any;
103
- }> = RestTableInterfaces & {
104
- dataInsertMultipleRows?: RestTableInterfaces[];
105
- cacheResults?: boolean;
106
- fetchDependencies?: number | eFetchDependencies | Awaited<apiReturn<iGetC6RestResponse<any>>>[];
107
- debug?: boolean;
108
- success?: string | ((r: AxiosResponse) => (string | void));
109
- error?: string | ((r: AxiosResponse) => (string | void));
110
- };
111
- export interface iCacheAPI<ResponseDataType = any> {
112
- requestArgumentsSerialized: string;
113
- request: AxiosPromise<ResponseDataType>;
114
- response?: AxiosResponse;
115
- final?: boolean;
116
- }
117
- /**
118
- * the first argument ....
119
- *
120
- * Our api returns a zero argument function iff the method is get and the previous request reached the predefined limit.
121
- * This function can be aliased as GetNextPageOfResults(). If the end is reached undefined will be returned.
122
- *
123
- *
124
- * For POST, PUT, and DELETE requests one can expect the primary key of the new or modified index, or a boolean success
125
- * indication if no primary key exists.
126
- **/
127
- export declare const POST = "POST";
128
- export declare const PUT = "PUT";
129
- export declare const GET = "GET";
130
- export declare const DELETE = "DELETE";
131
- export type iRestMethods = 'GET' | 'POST' | 'PUT' | 'DELETE';
132
- export type SubSelect<T = any> = {
32
+ } = any> = {
133
33
  subSelect: true;
134
34
  table: string;
135
- args: RequestGetPutDeleteBody<T>;
35
+ args: RequestQueryBody<'GET', T>;
136
36
  alias: string;
137
37
  };
138
- export type SelectField<T = any> = keyof T | [keyof T, 'AS', string] | [SQLFunction, keyof T] | [SQLFunction, keyof T, string] | SubSelect<T>;
38
+ export type SelectField<T extends {
39
+ [key: string]: any;
40
+ } = any> = keyof T | [keyof T, 'AS', string] | [SQLFunction, keyof T] | [SQLFunction, keyof T, string] | SubSelect<T>;
139
41
  export type WhereClause<T = any> = Partial<T> | LogicalGroup<T> | ComparisonClause<T>;
140
42
  export type LogicalGroup<T = any> = {
141
43
  [logicalGroup: string]: Array<WhereClause<T>>;
@@ -153,7 +55,9 @@ export type Pagination<T = any> = {
153
55
  LIMIT?: number | null;
154
56
  ORDER?: Partial<Record<keyof T, OrderDirection>>;
155
57
  };
156
- export type RequestGetPutDeleteBody<T = any> = {
58
+ export type RequestGetPutDeleteBody<T extends {
59
+ [key: string]: any;
60
+ } = any> = {
157
61
  SELECT?: SelectField<T>[];
158
62
  UPDATE?: Partial<T>;
159
63
  DELETE?: boolean;
@@ -161,16 +65,30 @@ export type RequestGetPutDeleteBody<T = any> = {
161
65
  JOIN?: Join<T>;
162
66
  PAGINATION?: Pagination<T>;
163
67
  };
164
- export type RequestQueryBody<RestTableInterfaces extends {
68
+ export type iAPI<T extends {
165
69
  [key: string]: any;
166
- }> = iAPI<RestTableInterfaces> | RequestGetPutDeleteBody;
167
- export declare function isPromise(x: any): boolean;
168
- interface iC6RestResponse<RestData> {
169
- rest: RestData;
170
- session?: any;
171
- sql?: any;
70
+ }> = T & {
71
+ dataInsertMultipleRows?: T[];
72
+ cacheResults?: boolean;
73
+ fetchDependencies?: number | eFetchDependencies | Awaited<apiReturn<iGetC6RestResponse<any>>>[];
74
+ debug?: boolean;
75
+ success?: string | ((r: AxiosResponse) => string | void);
76
+ error?: string | ((r: AxiosResponse) => string | void);
77
+ };
78
+ export type RequestQueryBody<Method extends iRestMethods, T extends {
79
+ [key: string]: any;
80
+ }, Custom extends {
81
+ [key: string]: any;
82
+ } = {}, Overrides extends {
83
+ [key: string]: any;
84
+ } = {}> = Method extends 'GET' | 'PUT' | 'DELETE' ? iAPI<RequestGetPutDeleteBody<Modify<T, Overrides> & Custom>> : iAPI<Modify<T, Overrides> & Custom>;
85
+ export interface iCacheAPI<ResponseDataType = any> {
86
+ requestArgumentsSerialized: string;
87
+ request: AxiosPromise<ResponseDataType>;
88
+ response?: AxiosResponse;
89
+ final?: boolean;
172
90
  }
173
- interface iChangeC6Data {
91
+ export interface iChangeC6Data {
174
92
  rowCount: number;
175
93
  }
176
94
  export interface iDeleteC6RestResponse<RestData = any, RequestData = any> extends iChangeC6Data, iC6RestResponse<RestData> {
@@ -182,6 +100,121 @@ export interface iPostC6RestResponse<RestData = any> extends iC6RestResponse<Res
182
100
  export interface iPutC6RestResponse<RestData = any, RequestData = any> extends iChangeC6Data, iC6RestResponse<RestData> {
183
101
  updated: boolean | number | string | RequestData;
184
102
  }
103
+ export interface iC6RestResponse<RestData> {
104
+ rest: RestData;
105
+ session?: any;
106
+ sql?: any;
107
+ }
108
+ export type iGetC6RestResponse<ResponseDataType, ResponseDataOverrides = {}> = iC6RestResponse<Modify<ResponseDataType, ResponseDataOverrides> | Modify<ResponseDataType, ResponseDataOverrides>[]>;
109
+ export type apiReturn<Response> = null | undefined | AxiosPromise<Response> | (Response extends iPutC6RestResponse | iDeleteC6RestResponse | iPostC6RestResponse ? null : () => apiReturn<Response>);
110
+ export type DetermineResponseDataType<Method extends iRestMethods, RestTableInterface extends {
111
+ [key: string]: any;
112
+ }> = 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> {
116
+ C6: iC6Object;
117
+ axios?: AxiosInstance;
118
+ restURL?: string;
119
+ mysqlPool?: Pool;
120
+ withCredentials?: boolean;
121
+ restModel: iC6RestfulModel<RestShortTableName, RestTableInterface, PrimaryKey>;
122
+ reactBootstrap?: CarbonReact<any, any>;
123
+ requestMethod: iRestMethods;
124
+ clearCache?: () => void;
125
+ skipPrimaryCheck?: boolean;
126
+ }
127
+ export interface iConstraint {
128
+ TABLE: string;
129
+ COLUMN: string;
130
+ CONSTRAINT: string;
131
+ }
132
+ export type tColumns<TableName extends string, T extends {
133
+ [key: string]: any;
134
+ }> = {
135
+ [K in keyof T & string as `${TableName}.${K}`]: K;
136
+ };
137
+ 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>;
145
+ TYPE_VALIDATION: {
146
+ [key: string]: iTypeValidation;
147
+ };
148
+ REGEX_VALIDATION: RegExpMap;
149
+ LIFECYCLE_HOOKS: iRestHooks<RestShortTableNames, RestTableInterfaces, PK>;
150
+ TABLE_REFERENCES: {
151
+ [columnName: string]: iConstraint[];
152
+ };
153
+ TABLE_REFERENCED_BY: {
154
+ [columnName: string]: iConstraint[];
155
+ };
156
+ }
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
+ }> = {
164
+ beforeProcessing?: {
165
+ [key: string]: (args: {
166
+ config: iRest<RestShortTableName, RestTableInterface, PrimaryKey>;
167
+ request: RequestQueryBody<Method, RestTableInterface, CustomAndRequiredFields, RequestTableOverrides>;
168
+ }) => void | Promise<void>;
169
+ };
170
+ beforeExecution?: {
171
+ [key: string]: (args: {
172
+ config: iRest<RestShortTableName, RestTableInterface, PrimaryKey>;
173
+ request: RequestQueryBody<Method, RestTableInterface, CustomAndRequiredFields, RequestTableOverrides>;
174
+ }) => void | Promise<void>;
175
+ };
176
+ afterExecution?: {
177
+ [key: string]: (args: {
178
+ config: iRest<RestShortTableName, RestTableInterface, PrimaryKey>;
179
+ request: RequestQueryBody<Method, RestTableInterface, CustomAndRequiredFields, RequestTableOverrides>;
180
+ response: AxiosResponse<DetermineResponseDataType<Method, RestTableInterface>>;
181
+ }) => void | Promise<void>;
182
+ };
183
+ afterCommit?: {
184
+ [key: string]: (args: {
185
+ config: iRest<RestShortTableName, RestTableInterface, PrimaryKey>;
186
+ request: RequestQueryBody<Method, RestTableInterface, CustomAndRequiredFields, RequestTableOverrides>;
187
+ response: AxiosResponse<DetermineResponseDataType<Method, RestTableInterface>>;
188
+ }) => void | Promise<void>;
189
+ };
190
+ };
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>;
201
+ };
202
+ export interface iDynamicApiImport<RestData extends {
203
+ [key: string]: any;
204
+ } = any> {
205
+ default: iRestApiFunctions<RestData>;
206
+ postState?: (response: AxiosResponse<iPostC6RestResponse<RestData>>, request: iAPI<any>, id: string | number | boolean) => void;
207
+ deleteState?: (response: AxiosResponse<iDeleteC6RestResponse<RestData>>, request: iAPI<any>) => void;
208
+ putState?: (response: AxiosResponse<iPutC6RestResponse<RestData>>, request: iAPI<any>) => void;
209
+ }
210
+ export interface iRestApiFunctions<RestData extends {
211
+ [key: string]: any;
212
+ } = any> {
213
+ Delete: (request?: RequestQueryBody<'DELETE', RestData>) => apiReturn<iDeleteC6RestResponse<RestData>>;
214
+ Post: (request?: RequestQueryBody<'POST', RestData>) => apiReturn<iPostC6RestResponse<RestData>>;
215
+ Get: (request?: RequestQueryBody<'GET', RestData>) => apiReturn<iGetC6RestResponse<RestData>>;
216
+ Put: (request?: RequestQueryBody<'PUT', RestData>) => apiReturn<iPutC6RestResponse<RestData>>;
217
+ }
185
218
  export interface iC6Object<RestShortTableName extends string = any, RestTableInterface extends {
186
219
  [key: string]: any;
187
220
  } = any, PrimaryKey extends Extract<keyof RestTableInterface, string> = Extract<keyof RestTableInterface, string>> {
@@ -195,25 +228,18 @@ export interface iC6Object<RestShortTableName extends string = any, RestTableInt
195
228
  IMPORT: (tableName: string) => Promise<iDynamicApiImport>;
196
229
  [key: string]: any;
197
230
  }
198
- export type iGetC6RestResponse<ResponseDataType, ResponseDataOverrides = {}> = iC6RestResponse<Modify<ResponseDataType, ResponseDataOverrides> | Modify<ResponseDataType, ResponseDataOverrides>[]>;
199
- export type apiReturn<Response> = null | undefined | AxiosPromise<Response> | (Response extends iPutC6RestResponse | iDeleteC6RestResponse | iPostC6RestResponse ? null : (() => apiReturn<Response>));
200
- export interface iRest<RestShortTableName extends string = any, RestTableInterface extends {
201
- [key: string]: any;
202
- } = any, PrimaryKey extends Extract<keyof RestTableInterface, string> = Extract<keyof RestTableInterface, string>, CustomAndRequiredFields extends {
231
+ export interface tC6Tables<RestShortTableName extends string = any, RestTableInterface extends {
203
232
  [key: string]: any;
204
- } = any, RequestTableOverrides = {
205
- [key in keyof RestTableInterface]: any;
206
- }, ResponseDataType = any> {
207
- C6: iC6Object;
208
- axios?: AxiosInstance;
209
- restURL?: string;
210
- mysqlPool?: Pool;
211
- withCredentials?: boolean;
212
- restModel: iC6RestfulModel<RestShortTableName, RestTableInterface, PrimaryKey>;
213
- requestMethod: iRestMethods;
214
- clearCache?: () => void;
215
- skipPrimaryCheck?: boolean;
216
- queryCallback: RequestQueryBody<Modify<RestTableInterface, RequestTableOverrides>> | ((request: iAPI<Modify<RestTableInterface, RequestTableOverrides>> & CustomAndRequiredFields) => (null | undefined | RequestQueryBody<Modify<RestTableInterface, RequestTableOverrides>>));
217
- responseCallback?: (response: AxiosResponse<ResponseDataType>, request: iAPI<Modify<RestTableInterface, RequestTableOverrides>> & CustomAndRequiredFields, success: (ResponseDataType extends iPutC6RestResponse | iDeleteC6RestResponse ? RequestQueryBody<Modify<RestTableInterface, RequestTableOverrides>> : string) | RestTableInterface[PrimaryKey] | string | number | boolean) => any;
233
+ } = any, PrimaryKey extends Extract<keyof RestTableInterface, string> = Extract<keyof RestTableInterface, string>> {
234
+ [key: string]: iC6RestfulModel<RestShortTableName, RestTableInterface, PrimaryKey> & {
235
+ [key: string]: any;
236
+ };
237
+ }
238
+ export interface tC6RestApi {
239
+ [key: string]: {
240
+ REST: iRestApiFunctions;
241
+ PUT: Function;
242
+ POST: Function;
243
+ DELETE: Function;
244
+ };
218
245
  }
219
- export {};