gg-express 1.0.59 → 1.0.60

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.
@@ -14,18 +14,21 @@ interface responseStructure {
14
14
  }
15
15
  interface requireParamsStructure {
16
16
  parameter: {
17
- [key: string]: "number" | "string";
17
+ [key: string]: "number" | "string" | "number[]" | "string[]";
18
18
  };
19
19
  dataType: "singleObject" | "arrayObject";
20
20
  structure: {
21
21
  [key: string]: paramType;
22
22
  };
23
23
  isPartialStructure?: boolean;
24
+ isPartialParameter?: boolean;
24
25
  }
25
- type numberOrString<T> = T extends "number" ? number : T extends "string" ? string : T extends "any" ? any : T extends string[] ? Unarray<T> : T extends number[] ? Unarray<T> : "error-type";
26
- type singleOrArrayObject<DT extends requireParamsStructure["dataType"], T extends requireParamsStructure["structure"], K extends keyof T, P extends requireParamsStructure["parameter"], J extends requireParamsStructure["isPartialStructure"]> = DT extends "arrayObject" ? {
26
+ type numberOrString<T> = T extends "number" ? number : T extends "string" ? string : T extends "number[]" ? number[] : T extends "string[]" ? string[] : T extends "any" ? any : T extends string[] ? Unarray<T> : T extends number[] ? Unarray<T> : "error-type";
27
+ type singleOrArrayObject<DT extends requireParamsStructure["dataType"], T extends requireParamsStructure["structure"], K extends keyof T, P extends requireParamsStructure["parameter"], J extends requireParamsStructure["isPartialStructure"], L extends requireParamsStructure["isPartialParameter"]> = DT extends "arrayObject" ? {
27
28
  data: {
28
- parameter: {
29
+ parameter: L extends true ? Partial<{
30
+ [Key in keyof P]: numberOrString<P[Key]>;
31
+ }> : {
29
32
  [Key in keyof P]: numberOrString<P[Key]>;
30
33
  };
31
34
  data: (J extends true ? Partial<{
@@ -46,7 +49,7 @@ type singleOrArrayObject<DT extends requireParamsStructure["dataType"], T extend
46
49
  };
47
50
  };
48
51
  };
49
- type MyRequest<DT extends requireParamsStructure["dataType"], T extends requireParamsStructure["structure"], K extends keyof T, P extends requireParamsStructure["parameter"], J extends requireParamsStructure["isPartialStructure"]> = Request<{}, {}, singleOrArrayObject<DT, T, K, P, J>, singleOrArrayObject<DT, T, K, P, J>, {}>;
52
+ type MyRequest<DT extends requireParamsStructure["dataType"], T extends requireParamsStructure["structure"], K extends keyof T, P extends requireParamsStructure["parameter"], J extends requireParamsStructure["isPartialStructure"], L extends requireParamsStructure["isPartialParameter"]> = Request<{}, {}, singleOrArrayObject<DT, T, K, P, J, L>, singleOrArrayObject<DT, T, K, P, J, L>, {}>;
50
53
  type MyResponse<DT extends responseStructure["dataType"], T extends responseStructure["structure"], K extends keyof T, P extends responseStructure["parameter"], J extends requireParamsStructure["isPartialStructure"]> = Response<{
51
54
  status: "SUCCESS" | "ERROR";
52
55
  message: string;
@@ -65,22 +68,22 @@ export default class GGExpress<appName extends string> {
65
68
  appName: string;
66
69
  constructor(app: Express.Express, appName: appName, outputPath: string[]);
67
70
  private rootMethod;
68
- get<M extends requireParamsStructure, T extends M["structure"], K extends keyof T, R extends responseStructure, RS extends R["structure"], KR extends keyof RS, P extends M["parameter"], PP extends R["parameter"], J extends M["isPartialStructure"]>(url: `/api/${appName}/${string}`, options: {
71
+ get<M extends requireParamsStructure, T extends M["structure"], K extends keyof T, R extends responseStructure, RS extends R["structure"], KR extends keyof RS, P extends M["parameter"], PP extends R["parameter"], J extends M["isPartialStructure"], L extends M["isPartialParameter"]>(url: `/api/${appName}/${string}`, options: {
69
72
  requireParams: M;
70
73
  responseStructure: R;
71
- }, ...middlewares: Array<(req: MyRequest<M["dataType"], T, K, P, J>, res: MyResponse<R["dataType"], RS, KR, PP, J>, next: NextFunction) => any>): Express.Express;
72
- post<M extends requireParamsStructure, T extends M["structure"], K extends keyof T, R extends responseStructure, RS extends R["structure"], KR extends keyof RS, P extends M["parameter"], PP extends R["parameter"], J extends M["isPartialStructure"]>(url: `/api/${appName}/${string}`, options: {
74
+ }, ...middlewares: Array<(req: MyRequest<M["dataType"], T, K, P, J, L>, res: MyResponse<R["dataType"], RS, KR, PP, J>, next: NextFunction) => any>): Express.Express;
75
+ post<M extends requireParamsStructure, T extends M["structure"], K extends keyof T, R extends responseStructure, RS extends R["structure"], KR extends keyof RS, P extends M["parameter"], PP extends R["parameter"], J extends M["isPartialStructure"], L extends M["isPartialParameter"]>(url: `/api/${appName}/${string}`, options: {
73
76
  requireParams: M;
74
77
  responseStructure: R;
75
- }, ...middlewares: Array<(req: MyRequest<M["dataType"], T, K, P, J>, res: MyResponse<R["dataType"], RS, KR, PP, J>, next: NextFunction) => any>): Express.Express;
76
- put<M extends requireParamsStructure, T extends M["structure"], K extends keyof T, R extends responseStructure, RS extends R["structure"], KR extends keyof RS, P extends M["parameter"], PP extends R["parameter"], J extends M["isPartialStructure"]>(url: `/api/${appName}/${string}`, options: {
78
+ }, ...middlewares: Array<(req: MyRequest<M["dataType"], T, K, P, J, L>, res: MyResponse<R["dataType"], RS, KR, PP, J>, next: NextFunction) => any>): Express.Express;
79
+ put<M extends requireParamsStructure, T extends M["structure"], K extends keyof T, R extends responseStructure, RS extends R["structure"], KR extends keyof RS, P extends M["parameter"], PP extends R["parameter"], J extends M["isPartialStructure"], L extends M["isPartialParameter"]>(url: `/api/${appName}/${string}`, options: {
77
80
  requireParams: M;
78
81
  responseStructure: R;
79
- }, ...middlewares: Array<(req: MyRequest<M["dataType"], T, K, P, J>, res: MyResponse<R["dataType"], RS, KR, PP, J>, next: NextFunction) => any>): Express.Express;
80
- delete<M extends requireParamsStructure, T extends M["structure"], K extends keyof T, R extends responseStructure, RS extends R["structure"], KR extends keyof RS, P extends M["parameter"], PP extends R["parameter"], J extends M["isPartialStructure"]>(url: `/api/${appName}/${string}`, options: {
82
+ }, ...middlewares: Array<(req: MyRequest<M["dataType"], T, K, P, J, L>, res: MyResponse<R["dataType"], RS, KR, PP, J>, next: NextFunction) => any>): Express.Express;
83
+ delete<M extends requireParamsStructure, T extends M["structure"], K extends keyof T, R extends responseStructure, RS extends R["structure"], KR extends keyof RS, P extends M["parameter"], PP extends R["parameter"], J extends M["isPartialStructure"], L extends M["isPartialParameter"]>(url: `/api/${appName}/${string}`, options: {
81
84
  requireParams: M;
82
85
  responseStructure: R;
83
- }, ...middlewares: Array<(req: MyRequest<M["dataType"], T, K, P, J>, res: MyResponse<R["dataType"], RS, KR, PP, J>, next: NextFunction) => any>): Express.Express;
86
+ }, ...middlewares: Array<(req: MyRequest<M["dataType"], T, K, P, J, L>, res: MyResponse<R["dataType"], RS, KR, PP, J>, next: NextFunction) => any>): Express.Express;
84
87
  generateAPIFiles(): void;
85
88
  private generateStaticRouteFile;
86
89
  private generateGGApi;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gg-express",
3
- "version": "1.0.59",
3
+ "version": "1.0.60",
4
4
  "description": "",
5
5
  "main": "dist/GGExpress.js",
6
6
  "scripts": {
package/src/GGExpress.ts CHANGED
@@ -22,17 +22,22 @@ interface responseStructure {
22
22
  }
23
23
 
24
24
  interface requireParamsStructure {
25
- parameter: { [key: string]: "number" | "string" }
25
+ parameter: { [key: string]: "number" | "string" | "number[]" | "string[]" }
26
26
  dataType: "singleObject" | "arrayObject"
27
27
  structure: {
28
28
  [key: string]: paramType
29
29
  }
30
30
  isPartialStructure?: boolean
31
+ isPartialParameter?: boolean
31
32
  }
32
33
  type numberOrString<T> = T extends "number"
33
34
  ? number
34
35
  : T extends "string"
35
36
  ? string
37
+ : T extends "number[]"
38
+ ? number[]
39
+ : T extends "string[]"
40
+ ? string[]
36
41
  : T extends "any"
37
42
  ? any
38
43
  : T extends string[]
@@ -46,11 +51,14 @@ type singleOrArrayObject<
46
51
  T extends requireParamsStructure["structure"],
47
52
  K extends keyof T,
48
53
  P extends requireParamsStructure["parameter"],
49
- J extends requireParamsStructure["isPartialStructure"]
54
+ J extends requireParamsStructure["isPartialStructure"],
55
+ L extends requireParamsStructure["isPartialParameter"]
50
56
  > = DT extends "arrayObject"
51
57
  ? {
52
58
  data: {
53
- parameter: { [Key in keyof P]: numberOrString<P[Key]> }
59
+ parameter: L extends true ?
60
+ Partial<{ [Key in keyof P]: numberOrString<P[Key]> }>:
61
+ { [Key in keyof P]: numberOrString<P[Key]> }
54
62
  data: (J extends true
55
63
  ? Partial<{ [Key in K]: numberOrString<T[Key]> }>
56
64
  : { [Key in K]: numberOrString<T[Key]> })[]
@@ -70,12 +78,14 @@ type MyRequest<
70
78
  T extends requireParamsStructure["structure"],
71
79
  K extends keyof T,
72
80
  P extends requireParamsStructure["parameter"],
73
- J extends requireParamsStructure["isPartialStructure"]
81
+ J extends requireParamsStructure["isPartialStructure"],
82
+ L extends requireParamsStructure["isPartialParameter"]
83
+
74
84
  > = Request<
75
85
  {},
76
86
  {},
77
- singleOrArrayObject<DT, T, K, P, J>,
78
- singleOrArrayObject<DT, T, K, P, J>,
87
+ singleOrArrayObject<DT, T, K, P, J,L>,
88
+ singleOrArrayObject<DT, T, K, P, J,L>,
79
89
  {}
80
90
  >
81
91
 
@@ -120,7 +130,8 @@ export default class GGExpress<appName extends string> {
120
130
  KR extends keyof RS,
121
131
  P extends M["parameter"],
122
132
  PP extends R["parameter"],
123
- J extends M["isPartialStructure"]
133
+ J extends M["isPartialStructure"],
134
+ L extends M["isPartialParameter"]
124
135
  >(
125
136
  method: "get" | "post" | "put" | "delete",
126
137
  url: string,
@@ -130,7 +141,7 @@ export default class GGExpress<appName extends string> {
130
141
  },
131
142
  ...middlewares: Array<
132
143
  (
133
- req: MyRequest<M["dataType"], T, K, P, J>,
144
+ req: MyRequest<M["dataType"], T, K, P, J,L>,
134
145
  res: MyResponse<R["dataType"], RS, KR, PP, J>,
135
146
  next: NextFunction
136
147
  ) => any
@@ -146,7 +157,7 @@ export default class GGExpress<appName extends string> {
146
157
  return this.express[method](
147
158
  url,
148
159
  (
149
- req: MyRequest<M["dataType"], T, K, P, J>,
160
+ req: MyRequest<M["dataType"], T, K, P, J,L>,
150
161
  res: Response,
151
162
  next: NextFunction
152
163
  ) => {
@@ -164,7 +175,9 @@ export default class GGExpress<appName extends string> {
164
175
  KR extends keyof RS,
165
176
  P extends M["parameter"],
166
177
  PP extends R["parameter"],
167
- J extends M["isPartialStructure"]
178
+ J extends M["isPartialStructure"],
179
+ L extends M["isPartialParameter"]
180
+
168
181
  >(
169
182
  url: `/api/${appName}/${string}`,
170
183
  options: {
@@ -173,7 +186,7 @@ export default class GGExpress<appName extends string> {
173
186
  },
174
187
  ...middlewares: Array<
175
188
  (
176
- req: MyRequest<M["dataType"], T, K, P, J>,
189
+ req: MyRequest<M["dataType"], T, K, P, J,L>,
177
190
  res: MyResponse<R["dataType"], RS, KR, PP, J>,
178
191
  next: NextFunction
179
192
  ) => any
@@ -191,7 +204,9 @@ export default class GGExpress<appName extends string> {
191
204
  KR extends keyof RS,
192
205
  P extends M["parameter"],
193
206
  PP extends R["parameter"],
194
- J extends M["isPartialStructure"]
207
+ J extends M["isPartialStructure"],
208
+ L extends M["isPartialParameter"]
209
+
195
210
  >(
196
211
  url: `/api/${appName}/${string}`,
197
212
  options: {
@@ -200,7 +215,7 @@ export default class GGExpress<appName extends string> {
200
215
  },
201
216
  ...middlewares: Array<
202
217
  (
203
- req: MyRequest<M["dataType"], T, K, P, J>,
218
+ req: MyRequest<M["dataType"], T, K, P, J,L>,
204
219
  res: MyResponse<R["dataType"], RS, KR, PP, J>,
205
220
  next: NextFunction
206
221
  ) => any
@@ -217,7 +232,9 @@ export default class GGExpress<appName extends string> {
217
232
  KR extends keyof RS,
218
233
  P extends M["parameter"],
219
234
  PP extends R["parameter"],
220
- J extends M["isPartialStructure"]
235
+ J extends M["isPartialStructure"],
236
+ L extends M["isPartialParameter"]
237
+
221
238
  >(
222
239
  url: `/api/${appName}/${string}`,
223
240
  options: {
@@ -226,7 +243,7 @@ export default class GGExpress<appName extends string> {
226
243
  },
227
244
  ...middlewares: Array<
228
245
  (
229
- req: MyRequest<M["dataType"], T, K, P, J>,
246
+ req: MyRequest<M["dataType"], T, K, P, J,L>,
230
247
  res: MyResponse<R["dataType"], RS, KR, PP, J>,
231
248
  next: NextFunction
232
249
  ) => any
@@ -243,7 +260,9 @@ export default class GGExpress<appName extends string> {
243
260
  KR extends keyof RS,
244
261
  P extends M["parameter"],
245
262
  PP extends R["parameter"],
246
- J extends M["isPartialStructure"]
263
+ J extends M["isPartialStructure"],
264
+ L extends M["isPartialParameter"]
265
+
247
266
  >(
248
267
  url: `/api/${appName}/${string}`,
249
268
  options: {
@@ -252,7 +271,7 @@ export default class GGExpress<appName extends string> {
252
271
  },
253
272
  ...middlewares: Array<
254
273
  (
255
- req: MyRequest<M["dataType"], T, K, P, J>,
274
+ req: MyRequest<M["dataType"], T, K, P, J,L>,
256
275
  res: MyResponse<R["dataType"], RS, KR, PP, J>,
257
276
  next: NextFunction
258
277
  ) => any