@carbonorm/carbonnode 3.1.3 → 3.2.0

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,11 +1,11 @@
1
1
  // Refined TypeScript types for CarbonORM
2
2
 
3
- import { AxiosInstance, AxiosPromise, AxiosResponse } from "axios";
4
- import { Pool } from "mysql2/promise";
5
- import { eFetchDependencies } from "./dynamicFetching";
6
- import { Modify } from "./modifyTypes";
7
- import { JoinType, OrderDirection, SQLComparisonOperator, SQLFunction } from "./mysqlTypes";
8
- import { CarbonReact } from "@carbonorm/carbonreact";
3
+ import {AxiosInstance, AxiosPromise, AxiosResponse} from "axios";
4
+ import {Pool} from "mysql2/promise";
5
+ import {eFetchDependencies} from "./dynamicFetching";
6
+ import {Modify} from "./modifyTypes";
7
+ import {JoinType, OrderDirection, SQLComparisonOperator, SQLFunction} from "./mysqlTypes";
8
+ import {CarbonReact} from "@carbonorm/carbonreact";
9
9
  import {OrmGenerics} from "./ormGenerics";
10
10
 
11
11
  export type iRestMethods = 'GET' | 'POST' | 'PUT' | 'DELETE';
@@ -14,10 +14,21 @@ export const PUT = 'PUT';
14
14
  export const GET = 'GET';
15
15
  export const DELETE = 'DELETE';
16
16
 
17
- export interface stringMap { [key: string]: string; }
18
- export interface stringNumberMap { [key: string]: string | number; }
19
- export interface RegExpMap { [key: string]: RegExp | RegExpMap; }
20
- export interface complexMap { [key: string]: stringMap | stringNumberMap | stringMap[] | RegExpMap; }
17
+ export interface stringMap {
18
+ [key: string]: string;
19
+ }
20
+
21
+ export interface stringNumberMap {
22
+ [key: string]: string | number;
23
+ }
24
+
25
+ export interface RegExpMap {
26
+ [key: string]: RegExp | RegExpMap;
27
+ }
28
+
29
+ export interface complexMap {
30
+ [key: string]: stringMap | stringNumberMap | stringMap[] | RegExpMap;
31
+ }
21
32
 
22
33
  export interface iTypeValidation {
23
34
  MYSQL_TYPE: string;
@@ -66,7 +77,7 @@ export type RequestGetPutDeleteBody<T extends { [key: string]: any } = any> = {
66
77
  export type iAPI<T extends { [key: string]: any }> = T & {
67
78
  dataInsertMultipleRows?: T[];
68
79
  cacheResults?: boolean;
69
- fetchDependencies?: number | eFetchDependencies | Awaited<apiReturn<iGetC6RestResponse<any>>>[];
80
+ fetchDependencies?: number | eFetchDependencies | Awaited<iGetC6RestResponse<any>>[];
70
81
  debug?: boolean;
71
82
  success?: string | ((r: AxiosResponse) => string | void);
72
83
  error?: string | ((r: AxiosResponse) => string | void);
@@ -88,7 +99,9 @@ export interface iCacheAPI<ResponseDataType = any> {
88
99
  final?: boolean;
89
100
  }
90
101
 
91
- export interface iChangeC6Data { rowCount: number; }
102
+ export interface iChangeC6Data {
103
+ rowCount: number;
104
+ }
92
105
 
93
106
  export interface iDeleteC6RestResponse<RestData = any, RequestData = any> extends iChangeC6Data, iC6RestResponse<RestData> {
94
107
  deleted: boolean | number | string | RequestData;
@@ -108,28 +121,31 @@ export interface iC6RestResponse<RestData> {
108
121
  sql?: any;
109
122
  }
110
123
 
111
- export type iGetC6RestResponse<ResponseDataType, ResponseDataOverrides = {}> = iC6RestResponse<
124
+ export interface iGetC6RestResponse<
125
+ ResponseDataType extends { [key: string]: any },
126
+ ResponseDataOverrides = {}
127
+ > extends iC6RestResponse<
112
128
  Modify<ResponseDataType, ResponseDataOverrides> | Modify<ResponseDataType, ResponseDataOverrides>[]
113
- >;
114
-
115
- export type apiReturn<Response> =
116
- | null
117
- | undefined
118
- | Response
119
- | (Response extends iPutC6RestResponse | iDeleteC6RestResponse | iPostC6RestResponse ? null : () => apiReturn<Response>);
129
+ > {
130
+ next?: () => Promise<DetermineResponseDataType<"GET", ResponseDataType, ResponseDataOverrides>>;
131
+ }
120
132
 
121
133
  export type DetermineResponseDataType<
122
134
  Method extends iRestMethods,
123
- RestTableInterface extends { [key: string]: any }
124
- > = Method extends 'POST'
135
+ RestTableInterface extends { [key: string]: any },
136
+ ResponseDataOverrides = {}
137
+ > =
138
+ null
139
+ | undefined
140
+ | (Method extends 'POST'
125
141
  ? iPostC6RestResponse<RestTableInterface>
126
142
  : Method extends 'GET'
127
- ? iGetC6RestResponse<RestTableInterface>
143
+ ? iGetC6RestResponse<RestTableInterface, ResponseDataOverrides>
128
144
  : Method extends 'PUT'
129
145
  ? iPutC6RestResponse<RestTableInterface>
130
146
  : Method extends 'DELETE'
131
147
  ? iDeleteC6RestResponse<RestTableInterface>
132
- : never;
148
+ : never);
133
149
 
134
150
  export interface iRest<
135
151
  RestShortTableName extends string = any,
@@ -217,10 +233,10 @@ export interface iDynamicApiImport<RestData extends { [key: string]: any } = any
217
233
  }
218
234
 
219
235
  export interface iRestApiFunctions<RestData extends { [key: string]: any } = any> {
220
- Delete: (request?: RequestQueryBody<'DELETE', RestData>) => apiReturn<iDeleteC6RestResponse<RestData>>;
221
- Post: (request?: RequestQueryBody<'POST', RestData>) => apiReturn<iPostC6RestResponse<RestData>>;
222
- Get: (request?: RequestQueryBody<'GET', RestData>) => apiReturn<iGetC6RestResponse<RestData>>;
223
- Put: (request?: RequestQueryBody<'PUT', RestData>) => apiReturn<iPutC6RestResponse<RestData>>;
236
+ Delete: (request?: RequestQueryBody<'DELETE', RestData>) => iDeleteC6RestResponse<RestData>;
237
+ Post: (request?: RequestQueryBody<'POST', RestData>) => iPostC6RestResponse<RestData>;
238
+ Get: (request?: RequestQueryBody<'GET', RestData>) => iGetC6RestResponse<RestData>;
239
+ Put: (request?: RequestQueryBody<'PUT', RestData>) => iPutC6RestResponse<RestData>;
224
240
  }
225
241
 
226
242
  export interface iC6Object<
@@ -236,6 +252,7 @@ export interface iC6Object<
236
252
  };
237
253
  PREFIX: string;
238
254
  IMPORT: (tableName: string) => Promise<iDynamicApiImport>;
255
+
239
256
  [key: string]: any;
240
257
  }
241
258