gg-express 1.0.88 → 1.0.90

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.
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.hotel_model_const_temp = void 0;
16
16
  const express_1 = __importDefault(require("express"));
17
17
  const GGExpressV2_1 = __importDefault(require("./GGExpressV2"));
18
- const typeResolver_1 = require("./typeResolver");
19
18
  exports.hotel_model_const_temp = {
20
19
  booking: {
21
20
  id: "number",
@@ -50,21 +49,74 @@ function run() {
50
49
  status: ["on", "off"],
51
50
  },
52
51
  responseStructure: {
53
- userData: (0, typeResolver_1.toArray)({
54
- id: "number",
55
- name: "string",
56
- }),
52
+ x: "string",
53
+ data: [
54
+ {
55
+ zoneID: "number",
56
+ zoneName: "string",
57
+ data: [
58
+ {
59
+ itemID: "number",
60
+ itemEachHotelID: "number",
61
+ itemName: "string",
62
+ requisitionQty: {
63
+ expected: "number",
64
+ actual: "number",
65
+ },
66
+ zoneStockQty: {
67
+ begin: "number",
68
+ end: "number",
69
+ },
70
+ usedQty: "number",
71
+ lossQty: "number",
72
+ damageQty: "number",
73
+ returnQty: {
74
+ expected: "number",
75
+ actual: "number",
76
+ },
77
+ notReturnQty: "number",
78
+ },
79
+ ],
80
+ },
81
+ ],
57
82
  },
58
83
  }, (req, res, next) => {
59
- // req.query.data.bookingStatus===''
60
- req.query.name;
61
- console.log("req.query", req.query);
62
- console.log("req.query.id", req.query.id);
63
- // req.query.data.bookingStatus
84
+ req.query.status === "on";
64
85
  return res.json({
65
86
  message: "",
66
87
  status: "SUCCESS",
67
- data: { userData: [] },
88
+ data: {
89
+ x: "",
90
+ data: [
91
+ {
92
+ zoneID: 0,
93
+ zoneName: "",
94
+ data: [
95
+ {
96
+ itemID: 0,
97
+ itemEachHotelID: 0,
98
+ itemName: "",
99
+ requisitionQty: {
100
+ actual: 0,
101
+ expected: 0,
102
+ },
103
+ zoneStockQty: {
104
+ begin: 0,
105
+ end: 0,
106
+ },
107
+ usedQty: 0,
108
+ lossQty: 0,
109
+ damageQty: 0,
110
+ returnQty: {
111
+ expected: 0,
112
+ actual: 0,
113
+ },
114
+ notReturnQty: 0,
115
+ },
116
+ ],
117
+ },
118
+ ],
119
+ },
68
120
  });
69
121
  });
70
122
  ggapp.post("/api/hotel/booking/id", {
@@ -1,22 +1,14 @@
1
1
  type BaseType = "string" | "number" | "string[]" | "number[]";
2
2
  export type CustomType = BaseType | `${BaseType}?` | `${BaseType}~` | `${BaseType}?~`;
3
- export type InputNest = {
4
- [key in string]: CustomType;
5
- };
6
- type InputEnum = readonly (string | number)[];
3
+ type InputEnum = readonly string[] | readonly number[];
7
4
  export type InputParent = {
8
5
  [key in string]: CustomType | InputParent | InputParent[] | InputEnum;
9
6
  };
10
7
  type ResolveBase<T extends BaseType> = T extends "string" ? string : T extends "string[]" ? string[] : T extends "number" ? number : T extends "number[]" ? number[] : never;
11
8
  export declare const toArray: <T extends InputParent>(input: T) => T[];
12
9
  type ResolveType<T> = T extends `${infer B}?~` ? ResolveBase<B & BaseType> | null | undefined : T extends `${infer B}?` ? ResolveBase<B & BaseType> | undefined : T extends `${infer B}~` ? ResolveBase<B & BaseType> | null : ResolveBase<T & BaseType>;
13
- type convertNest<T> = ResolveType<T>;
14
- type checkEnum<T> = T extends InputEnum ? T[number] : convertNest<T>;
15
- type convertChildObjet<T> = {
16
- [K in keyof T]: chooseType<T[K]>;
17
- };
18
- type convertObject<T> = T extends readonly any[] ? checkEnum<T> : T extends object ? convertChildObjet<T> : checkEnum<T>;
19
- type chooseType<T> = T extends InputEnum ? T[number] : convertObject<T>;
10
+ type checkEnum<T> = T extends InputEnum ? T[number] : ResolveType<T>;
11
+ type chooseType<T> = T extends readonly (string | number)[] ? checkEnum<T> : T extends object ? convertRoot<T> : checkEnum<T>;
20
12
  export type convertRoot<T> = {
21
13
  [K in keyof T]: chooseType<T[K]>;
22
14
  };
@@ -5,6 +5,48 @@ const toArray = (input) => {
5
5
  return [input];
6
6
  };
7
7
  exports.toArray = toArray;
8
+ // let req2 = {
9
+ // booking: {
10
+ // id: "number",
11
+ // bookingGroupID: "number",
12
+ // checkInDate: "string",
13
+ // checkOutDate: "string",
14
+ // checkInTime: "string",
15
+ // checkOutTime: "string",
16
+ // roomRate: "number",
17
+ // extraBedRate: "number",
18
+ // roomNumber: "string",
19
+ // editTime: "string",
20
+ // createTime: "string",
21
+ // shiftDate: "string",
22
+ // shiftName: "string",
23
+ // userName: "string",
24
+ // bookingStatus: ["ACTIVE", "CLOSE", "CANCEL", "NO_SHOW"],
25
+ // is_specificRoom: "number",
26
+ // guestCount: "number",
27
+ // reasonToCancel: "string",
28
+ // note: "string",
29
+ // },
30
+ // status: ["ACTIVE", "DISABLE"],
31
+ // rooms: toArray({
32
+ // id: "number",
33
+ // status: ["ON", "OFF"],
34
+ // roomNumber: "string",
35
+ // log: toArray({
36
+ // time: "string",
37
+ // logger: [{ info: "string" }],
38
+ // }),
39
+ // }),
40
+ // data: {
41
+ // level_1: {
42
+ // title: "string",
43
+ // level_2: {
44
+ // id: "number",
45
+ // name: "string",
46
+ // },
47
+ // },
48
+ // },
49
+ // } as const satisfies InputParent
8
50
  // const data = {} as convertRoot<typeof req2>
9
51
  // data.booking.bookingStatus
10
52
  // data.status
@@ -13,3 +55,4 @@ exports.toArray = toArray;
13
55
  // data.rooms.map((row) => row.status === "OFF")
14
56
  // data.data.level_1.level_2.id
15
57
  // data.booking.createTime
58
+ // req2.data.level_1.level_2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gg-express",
3
- "version": "1.0.88",
3
+ "version": "1.0.90",
4
4
  "description": "",
5
5
  "main": "dist/main.js",
6
6
  "scripts": {
@@ -1,6 +1,6 @@
1
1
  import express, { Express } from "express"
2
2
  import GGExpressV2 from "./GGExpressV2"
3
- import { toArray } from "./typeResolver"
3
+ import { InputParent, toArray } from "./typeResolver"
4
4
  import { GGApi_v2 } from "./output/apiConnector_hotel_v2"
5
5
 
6
6
  export const hotel_model_const_temp = {
@@ -40,22 +40,75 @@ function run() {
40
40
  status: ["on", "off"],
41
41
  },
42
42
  responseStructure: {
43
- userData: toArray({
44
- id: "number",
45
- name: "string",
46
- }),
43
+ x: "string",
44
+ data: [
45
+ {
46
+ zoneID: "number",
47
+ zoneName: "string",
48
+ data: [
49
+ {
50
+ itemID: "number",
51
+ itemEachHotelID: "number",
52
+ itemName: "string",
53
+ requisitionQty: {
54
+ expected: "number",
55
+ actual: "number",
56
+ },
57
+ zoneStockQty: {
58
+ begin: "number",
59
+ end: "number",
60
+ },
61
+ usedQty: "number",
62
+ lossQty: "number",
63
+ damageQty: "number",
64
+ returnQty: {
65
+ expected: "number",
66
+ actual: "number",
67
+ },
68
+ notReturnQty: "number",
69
+ },
70
+ ],
71
+ },
72
+ ],
47
73
  },
48
74
  },
49
75
  (req, res, next) => {
50
- // req.query.data.bookingStatus===''
51
- req.query.name
52
- console.log("req.query", req.query)
53
- console.log("req.query.id", req.query.id)
54
- // req.query.data.bookingStatus
76
+ req.query.status === "on"
55
77
  return res.json({
56
78
  message: "",
57
79
  status: "SUCCESS",
58
- data: { userData: [] },
80
+ data: {
81
+ x: "",
82
+ data: [
83
+ {
84
+ zoneID: 0,
85
+ zoneName: "",
86
+ data: [
87
+ {
88
+ itemID: 0,
89
+ itemEachHotelID: 0,
90
+ itemName: "",
91
+ requisitionQty: {
92
+ actual: 0,
93
+ expected: 0,
94
+ },
95
+ zoneStockQty: {
96
+ begin: 0,
97
+ end: 0,
98
+ },
99
+ usedQty: 0,
100
+ lossQty: 0,
101
+ damageQty: 0,
102
+ returnQty: {
103
+ expected: 0,
104
+ actual: 0,
105
+ },
106
+ notReturnQty: 0,
107
+ },
108
+ ],
109
+ },
110
+ ],
111
+ },
59
112
  })
60
113
  }
61
114
  )
@@ -5,11 +5,10 @@ export type CustomType =
5
5
  | `${BaseType}~`
6
6
  | `${BaseType}?~`
7
7
 
8
- export type InputNest = { [key in string]: CustomType }
8
+ // export type InputNest = { [key in string]: CustomType }
9
9
 
10
- // Allow readonly tuples (from `as const`) to be treated as enums.
11
- // type InputEnum = readonly string[] | readonly number[]
12
- type InputEnum = readonly (string | number)[]
10
+ type InputEnum = readonly string[] | readonly number[]
11
+ // type InputEnum = readonly (string | number)[]
13
12
  export type InputParent = {
14
13
  [key in string]:
15
14
  | CustomType
@@ -33,6 +32,31 @@ export const toArray = <T extends InputParent>(input: T) => {
33
32
  return [input]
34
33
  }
35
34
 
35
+ type ResolveType<T> =
36
+ // both null + undefined
37
+ T extends `${infer B}?~`
38
+ ? ResolveBase<B & BaseType> | null | undefined
39
+ : // undefined only
40
+ T extends `${infer B}?`
41
+ ? ResolveBase<B & BaseType> | undefined
42
+ : // null only
43
+ T extends `${infer B}~`
44
+ ? ResolveBase<B & BaseType> | null
45
+ : // plain primitive
46
+ ResolveBase<T & BaseType>
47
+
48
+ type checkEnum<T> = T extends InputEnum ? T[number] : ResolveType<T>
49
+
50
+ type chooseType<T> = T extends readonly (string | number)[]
51
+ ? checkEnum<T>
52
+ : T extends object
53
+ ? convertRoot<T>
54
+ : checkEnum<T>
55
+
56
+ export type convertRoot<T> = {
57
+ [K in keyof T]: chooseType<T[K]>
58
+ }
59
+
36
60
  // let req2 = {
37
61
  // booking: {
38
62
  // id: "number",
@@ -76,39 +100,6 @@ export const toArray = <T extends InputParent>(input: T) => {
76
100
  // },
77
101
  // },
78
102
  // } as const satisfies InputParent
79
-
80
- type ResolveType<T> =
81
- // both null + undefined
82
- T extends `${infer B}?~`
83
- ? ResolveBase<B & BaseType> | null | undefined
84
- : // undefined only
85
- T extends `${infer B}?`
86
- ? ResolveBase<B & BaseType> | undefined
87
- : // null only
88
- T extends `${infer B}~`
89
- ? ResolveBase<B & BaseType> | null
90
- : // plain primitive
91
- ResolveBase<T & BaseType>
92
-
93
- type convertNest<T> = ResolveType<T>
94
-
95
- type checkEnum<T> = T extends InputEnum ? T[number] : convertNest<T>
96
- type convertChildObjet<T> = {
97
- [K in keyof T]: chooseType<T[K]>
98
- }
99
- // type convertObject<T> = T extends object ? convertChildObjet<T> : checkEnum<T>
100
-
101
- type convertObject<T> = T extends readonly any[]
102
- ? checkEnum<T>
103
- : T extends object
104
- ? convertChildObjet<T>
105
- : checkEnum<T>
106
-
107
- type chooseType<T> = T extends InputEnum ? T[number] : convertObject<T>
108
- export type convertRoot<T> = {
109
- [K in keyof T]: chooseType<T[K]>
110
- }
111
-
112
103
  // const data = {} as convertRoot<typeof req2>
113
104
 
114
105
  // data.booking.bookingStatus
@@ -118,3 +109,4 @@ export type convertRoot<T> = {
118
109
  // data.rooms.map((row) => row.status === "OFF")
119
110
  // data.data.level_1.level_2.id
120
111
  // data.booking.createTime
112
+ // req2.data.level_1.level_2