gg-express 1.0.103 → 1.0.105
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.
- package/dist/v2/GGExpressV2.js +1 -1
- package/dist/v2/generateStaticRouteFileV2.js +10 -4
- package/dist/v2/output/staticRouteInterface_hotel_v2.d.ts +22 -67
- package/dist/v2/run_v2.test.js +36 -122
- package/dist/v2/typeResolver.d.ts +1 -1
- package/package.json +1 -1
- package/src/v2/GGExpressV2.ts +1 -3
- package/src/v2/generateStaticRouteFileV2.ts +12 -5
- package/src/v2/output/staticRouteInterface_hotel_v2.ts +22 -46
- package/src/v2/run_v2.test.ts +37 -131
- package/src/v2/typeResolver.ts +9 -3
package/dist/v2/GGExpressV2.js
CHANGED
|
@@ -37,7 +37,7 @@ class GGExpressV2 {
|
|
|
37
37
|
url: url,
|
|
38
38
|
isPartialRequireParam: options.requireParams.isPartial === true ? true : false,
|
|
39
39
|
requireParams: options.requireParams.data,
|
|
40
|
-
responseStructure:
|
|
40
|
+
responseStructure: options.responseStructure,
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
43
|
return this.express[method](url,
|
|
@@ -24,6 +24,9 @@ function extract(allData, prepareRoute) {
|
|
|
24
24
|
}
|
|
25
25
|
function parentInputToCode(data, isPartialRequireParam) {
|
|
26
26
|
const recursiveExtract = (target, parentKeyName) => {
|
|
27
|
+
console.log("parentKeyName :", parentKeyName);
|
|
28
|
+
console.log("target :", target);
|
|
29
|
+
console.log("-------");
|
|
27
30
|
const getParentKeyCode = (parentKeyName) => {
|
|
28
31
|
if (isPartialRequireParam === true)
|
|
29
32
|
return `${parentKeyName}?`;
|
|
@@ -66,7 +69,8 @@ function parentInputToCode(data, isPartialRequireParam) {
|
|
|
66
69
|
if (parentKeyName === "root")
|
|
67
70
|
result = ` { ${tempResult.join(",")} } `;
|
|
68
71
|
else
|
|
69
|
-
result = `${result} \n ${getParentKeyCode(parentKeyName)}
|
|
72
|
+
result = `${result} \n ${getParentKeyCode(parentKeyName)} /** object parentKeyName = ${parentKeyName}
|
|
73
|
+
)}. ${JSON.stringify(target)} */ : { ${tempResult.join(",")} }`;
|
|
70
74
|
}
|
|
71
75
|
// check array ---------------------------
|
|
72
76
|
else if (Array.isArray(target)) {
|
|
@@ -80,9 +84,11 @@ function parentInputToCode(data, isPartialRequireParam) {
|
|
|
80
84
|
.join("|")} `;
|
|
81
85
|
// nest or input nest
|
|
82
86
|
else if (typeof target[0] === "object")
|
|
83
|
-
for (const row of target) {
|
|
84
|
-
|
|
85
|
-
}
|
|
87
|
+
// for (const row of target as ConstSchemaType[]) {
|
|
88
|
+
// result = result + " " + recursiveExtract(row, parentKeyName) + "[] "
|
|
89
|
+
// }
|
|
90
|
+
result =
|
|
91
|
+
result + " " + recursiveExtract(target[0], parentKeyName) + "[] ";
|
|
86
92
|
}
|
|
87
93
|
return `${result}`;
|
|
88
94
|
};
|
|
@@ -3,6 +3,26 @@ export interface staticRouteInterface_hotel_v2 {
|
|
|
3
3
|
"/api/hotel/users/id": {
|
|
4
4
|
requireParams: {
|
|
5
5
|
id: number;
|
|
6
|
+
bookingGroupID: number;
|
|
7
|
+
checkInDate: string;
|
|
8
|
+
checkOutDate: string;
|
|
9
|
+
checkInTime: string;
|
|
10
|
+
checkOutTime: string;
|
|
11
|
+
roomRate: number;
|
|
12
|
+
extraBedRate: number;
|
|
13
|
+
roomNumber?: string | undefined | null;
|
|
14
|
+
editTime: string;
|
|
15
|
+
createTime: string;
|
|
16
|
+
shiftDate: string;
|
|
17
|
+
shiftName: string;
|
|
18
|
+
userName: string;
|
|
19
|
+
bookingStatus: "ACTIVE" | "CLOSE" | "CANCEL" | "NO_SHOW";
|
|
20
|
+
is_specificRoom: number;
|
|
21
|
+
guestCount: number;
|
|
22
|
+
reasonToCancel: string;
|
|
23
|
+
note: string;
|
|
24
|
+
}[];
|
|
25
|
+
responseStructure: {
|
|
6
26
|
data: {
|
|
7
27
|
id: number;
|
|
8
28
|
bookingGroupID: number;
|
|
@@ -23,78 +43,13 @@ export interface staticRouteInterface_hotel_v2 {
|
|
|
23
43
|
guestCount: number;
|
|
24
44
|
reasonToCancel: string;
|
|
25
45
|
note: string;
|
|
26
|
-
};
|
|
27
|
-
name: string;
|
|
28
|
-
status: "on" | "off";
|
|
29
|
-
};
|
|
30
|
-
responseStructure: {
|
|
31
|
-
data: {
|
|
32
|
-
x: string;
|
|
33
|
-
data: {
|
|
34
|
-
zoneID: number;
|
|
35
|
-
zoneName: string;
|
|
36
|
-
data: {
|
|
37
|
-
itemID: number;
|
|
38
|
-
itemEachHotelID: number;
|
|
39
|
-
itemName: string;
|
|
40
|
-
requisitionQty: {
|
|
41
|
-
expected: number;
|
|
42
|
-
actual: number;
|
|
43
|
-
};
|
|
44
|
-
zoneStockQty: {
|
|
45
|
-
begin: number;
|
|
46
|
-
end: number;
|
|
47
|
-
};
|
|
48
|
-
usedQty: number;
|
|
49
|
-
lossQty: number;
|
|
50
|
-
damageQty: number;
|
|
51
|
-
returnQty: {
|
|
52
|
-
expected: number;
|
|
53
|
-
actual: number;
|
|
54
|
-
};
|
|
55
|
-
notReturnQty: number;
|
|
56
|
-
}[];
|
|
57
|
-
}[];
|
|
58
|
-
};
|
|
59
|
-
status: "SUCCESS" | "ERROR";
|
|
60
|
-
message: string;
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
post: {
|
|
65
|
-
"/api/hotel/booking/id": {
|
|
66
|
-
requireParams: {
|
|
67
|
-
id?: number;
|
|
68
|
-
id2?: number;
|
|
69
|
-
name?: string;
|
|
70
|
-
};
|
|
71
|
-
responseStructure: {
|
|
72
|
-
data: {
|
|
73
|
-
bookingData: {
|
|
74
|
-
id: number;
|
|
75
|
-
roomNumber: string;
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
status: "SUCCESS" | "ERROR";
|
|
79
|
-
message: string;
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
"/api/hotel/testPost": {
|
|
83
|
-
requireParams: {
|
|
84
|
-
id?: number;
|
|
85
|
-
};
|
|
86
|
-
responseStructure: {
|
|
87
|
-
data: {
|
|
88
|
-
bookingData: {
|
|
89
|
-
id: number;
|
|
90
|
-
roomNumber: string;
|
|
91
|
-
};
|
|
92
|
-
};
|
|
46
|
+
}[];
|
|
93
47
|
status: "SUCCESS" | "ERROR";
|
|
94
48
|
message: string;
|
|
95
49
|
};
|
|
96
50
|
};
|
|
97
51
|
};
|
|
52
|
+
post: {};
|
|
98
53
|
put: {};
|
|
99
54
|
delete: {};
|
|
100
55
|
}
|
package/dist/v2/run_v2.test.js
CHANGED
|
@@ -43,131 +43,47 @@ function run() {
|
|
|
43
43
|
const ggapp = new GGExpressV2_1.default(app, "hotel", ["./output"]);
|
|
44
44
|
ggapp.get("/api/hotel/users/id", {
|
|
45
45
|
requireParams: {
|
|
46
|
-
|
|
47
|
-
data: {
|
|
48
|
-
id: "number",
|
|
49
|
-
data: exports.hotel_model_const_temp["booking"],
|
|
50
|
-
name: "string",
|
|
51
|
-
status: ["on", "off"],
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
responseStructure: {
|
|
55
|
-
x: "string",
|
|
56
|
-
data: [
|
|
57
|
-
{
|
|
58
|
-
zoneID: "number",
|
|
59
|
-
zoneName: "string",
|
|
60
|
-
data: [
|
|
61
|
-
{
|
|
62
|
-
itemID: "number",
|
|
63
|
-
itemEachHotelID: "number",
|
|
64
|
-
itemName: "string",
|
|
65
|
-
requisitionQty: {
|
|
66
|
-
expected: "number",
|
|
67
|
-
actual: "number",
|
|
68
|
-
},
|
|
69
|
-
zoneStockQty: {
|
|
70
|
-
begin: "number",
|
|
71
|
-
end: "number",
|
|
72
|
-
},
|
|
73
|
-
usedQty: "number",
|
|
74
|
-
lossQty: "number",
|
|
75
|
-
damageQty: "number",
|
|
76
|
-
returnQty: {
|
|
77
|
-
expected: "number",
|
|
78
|
-
actual: "number",
|
|
79
|
-
},
|
|
80
|
-
notReturnQty: "number",
|
|
81
|
-
},
|
|
82
|
-
],
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
},
|
|
86
|
-
}, (req, res, next) => {
|
|
87
|
-
return res.json({
|
|
88
|
-
message: "",
|
|
89
|
-
status: "SUCCESS",
|
|
90
|
-
data: {
|
|
91
|
-
x: "",
|
|
92
|
-
data: [
|
|
93
|
-
{
|
|
94
|
-
zoneID: 0,
|
|
95
|
-
zoneName: "",
|
|
96
|
-
data: [
|
|
97
|
-
{
|
|
98
|
-
itemID: 0,
|
|
99
|
-
itemEachHotelID: 0,
|
|
100
|
-
itemName: "",
|
|
101
|
-
requisitionQty: {
|
|
102
|
-
actual: 0,
|
|
103
|
-
expected: 0,
|
|
104
|
-
},
|
|
105
|
-
zoneStockQty: {
|
|
106
|
-
begin: 0,
|
|
107
|
-
end: 0,
|
|
108
|
-
},
|
|
109
|
-
usedQty: 0,
|
|
110
|
-
lossQty: 0,
|
|
111
|
-
damageQty: 0,
|
|
112
|
-
returnQty: {
|
|
113
|
-
expected: 0,
|
|
114
|
-
actual: 0,
|
|
115
|
-
},
|
|
116
|
-
notReturnQty: 0,
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
},
|
|
120
|
-
],
|
|
121
|
-
},
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
ggapp.post("/api/hotel/booking/id", {
|
|
125
|
-
requireParams: {
|
|
126
|
-
isPartial: true,
|
|
127
|
-
data: {
|
|
128
|
-
id: "number",
|
|
129
|
-
id2: "number",
|
|
130
|
-
name: "string",
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
responseStructure: {
|
|
134
|
-
bookingData: {
|
|
135
|
-
id: "number",
|
|
136
|
-
roomNumber: "string",
|
|
137
|
-
},
|
|
46
|
+
data: [exports.hotel_model_const_temp.booking],
|
|
138
47
|
},
|
|
48
|
+
responseStructure: [exports.hotel_model_const_temp.booking],
|
|
139
49
|
}, (req, res, next) => {
|
|
140
50
|
return res.json({
|
|
141
51
|
message: "",
|
|
142
52
|
status: "SUCCESS",
|
|
143
|
-
data:
|
|
144
|
-
bookingData: {
|
|
145
|
-
id: 2,
|
|
146
|
-
roomNumber: "dd",
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
ggapp.post("/api/hotel/testPost", {
|
|
152
|
-
requireParams: {
|
|
153
|
-
isPartial: true,
|
|
154
|
-
data: {
|
|
155
|
-
id: "number",
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
responseStructure: {
|
|
159
|
-
bookingData: {
|
|
160
|
-
id: "number",
|
|
161
|
-
roomNumber: "string",
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
}, (req, res, next) => {
|
|
165
|
-
req.body.id;
|
|
166
|
-
return res.json({
|
|
167
|
-
status: "ERROR",
|
|
168
|
-
message: "",
|
|
53
|
+
data: [],
|
|
169
54
|
});
|
|
170
55
|
});
|
|
56
|
+
// ggapp.post(
|
|
57
|
+
// "/api/hotel/booking/id",
|
|
58
|
+
// {
|
|
59
|
+
// requireParams: {
|
|
60
|
+
// isPartial: true,
|
|
61
|
+
// data: {
|
|
62
|
+
// id: "number",
|
|
63
|
+
// id2: "number",
|
|
64
|
+
// name: "string",
|
|
65
|
+
// },
|
|
66
|
+
// },
|
|
67
|
+
// responseStructure: {
|
|
68
|
+
// bookingData: {
|
|
69
|
+
// id: "number",
|
|
70
|
+
// roomNumber: "string",
|
|
71
|
+
// },
|
|
72
|
+
// },
|
|
73
|
+
// },
|
|
74
|
+
// (req, res, next) => {
|
|
75
|
+
// return res.json({
|
|
76
|
+
// message: "",
|
|
77
|
+
// status: "SUCCESS",
|
|
78
|
+
// data: {
|
|
79
|
+
// bookingData: {
|
|
80
|
+
// id: 2,
|
|
81
|
+
// roomNumber: "dd",
|
|
82
|
+
// },
|
|
83
|
+
// },
|
|
84
|
+
// })
|
|
85
|
+
// }
|
|
86
|
+
// )
|
|
171
87
|
app.listen(3002, () => __awaiter(this, void 0, void 0, function* () {
|
|
172
88
|
yield ggapp.generateAPIFiles();
|
|
173
89
|
console.log("done");
|
|
@@ -178,13 +94,11 @@ run();
|
|
|
178
94
|
// setTimeout(() => {
|
|
179
95
|
// const x = new GGApi_v2()
|
|
180
96
|
// //@ts-ignore
|
|
181
|
-
// x.get("http://localhost:3002/api/hotel/users/id",
|
|
182
|
-
// id: 1,
|
|
183
|
-
// })
|
|
97
|
+
// x.get("http://localhost:3002/api/hotel/users/id", [])
|
|
184
98
|
// .then((response) => {
|
|
185
99
|
// console.log("response", response)
|
|
186
100
|
// })
|
|
187
101
|
// .catch((error) => {
|
|
188
|
-
// console.error("fetch error")
|
|
102
|
+
// console.error("fetch error", error)
|
|
189
103
|
// })
|
|
190
104
|
// }, 3000)
|
|
@@ -4,7 +4,7 @@ type CustomType = BaseType | `${BaseType}?` | `${BaseType}~` | `${BaseType}?~`;
|
|
|
4
4
|
type InputEnum = readonly string[] | readonly number[];
|
|
5
5
|
export type ConstSchemaType = {
|
|
6
6
|
[key in string]: CustomType | ConstSchemaType | ConstSchemaType[] | InputEnum;
|
|
7
|
-
};
|
|
7
|
+
} | ConstSchemaType[];
|
|
8
8
|
type ResolveBase<T extends BaseType> = T extends "string" ? string : T extends "string[]" ? string[] : T extends "number" ? number : T extends "number[]" ? number[] : T extends "boolean" ? boolean : T extends "boolean[]" ? boolean[] : never;
|
|
9
9
|
export declare const toArray: <T>(input: T) => T[];
|
|
10
10
|
type ResolveExtraType<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>;
|
package/package.json
CHANGED
package/src/v2/GGExpressV2.ts
CHANGED
|
@@ -122,9 +122,7 @@ export default class GGExpressV2<appName extends string> {
|
|
|
122
122
|
isPartialRequireParam:
|
|
123
123
|
options.requireParams.isPartial === true ? true : false,
|
|
124
124
|
requireParams: options.requireParams.data,
|
|
125
|
-
responseStructure:
|
|
126
|
-
...options.responseStructure,
|
|
127
|
-
},
|
|
125
|
+
responseStructure: options.responseStructure,
|
|
128
126
|
})
|
|
129
127
|
})
|
|
130
128
|
|
|
@@ -51,6 +51,9 @@ function parentInputToCode(
|
|
|
51
51
|
isPartialRequireParam: boolean
|
|
52
52
|
) {
|
|
53
53
|
const recursiveExtract = (target: ConstSchemaType, parentKeyName: string) => {
|
|
54
|
+
console.log("parentKeyName :", parentKeyName)
|
|
55
|
+
console.log("target :", target)
|
|
56
|
+
console.log("-------")
|
|
54
57
|
const getParentKeyCode = (parentKeyName: string) => {
|
|
55
58
|
if (isPartialRequireParam === true) return `${parentKeyName}?`
|
|
56
59
|
else return parentKeyName
|
|
@@ -88,7 +91,8 @@ function parentInputToCode(
|
|
|
88
91
|
else
|
|
89
92
|
result = `${result} \n ${getParentKeyCode(
|
|
90
93
|
parentKeyName
|
|
91
|
-
)}
|
|
94
|
+
)} /** object parentKeyName = ${parentKeyName}
|
|
95
|
+
)}. ${JSON.stringify(target)} */ : { ${tempResult.join(",")} }`
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
// check array ---------------------------
|
|
@@ -100,15 +104,18 @@ function parentInputToCode(
|
|
|
100
104
|
target[0] === null ||
|
|
101
105
|
target[0] === undefined
|
|
102
106
|
)
|
|
103
|
-
return `${getParentKeyCode(parentKeyName)} : ${
|
|
107
|
+
return `${getParentKeyCode(parentKeyName)} : ${target
|
|
104
108
|
.map((word) => ` "${word}" `)
|
|
105
109
|
.join("|")} `
|
|
106
110
|
// nest or input nest
|
|
107
111
|
else if (typeof target[0] === "object")
|
|
108
|
-
for (const row of target as ConstSchemaType[]) {
|
|
109
|
-
|
|
110
|
-
}
|
|
112
|
+
// for (const row of target as ConstSchemaType[]) {
|
|
113
|
+
// result = result + " " + recursiveExtract(row, parentKeyName) + "[] "
|
|
114
|
+
// }
|
|
115
|
+
result =
|
|
116
|
+
result + " " + recursiveExtract(target[0], parentKeyName) + "[] "
|
|
111
117
|
}
|
|
118
|
+
|
|
112
119
|
return `${result}`
|
|
113
120
|
}
|
|
114
121
|
const result = recursiveExtract(data, "root")
|
|
@@ -3,6 +3,26 @@ export interface staticRouteInterface_hotel_v2 {
|
|
|
3
3
|
"/api/hotel/users/id": {
|
|
4
4
|
requireParams: {
|
|
5
5
|
id: number
|
|
6
|
+
bookingGroupID: number
|
|
7
|
+
checkInDate: string
|
|
8
|
+
checkOutDate: string
|
|
9
|
+
checkInTime: string
|
|
10
|
+
checkOutTime: string
|
|
11
|
+
roomRate: number
|
|
12
|
+
extraBedRate: number
|
|
13
|
+
roomNumber?: string | undefined | null
|
|
14
|
+
editTime: string
|
|
15
|
+
createTime: string
|
|
16
|
+
shiftDate: string
|
|
17
|
+
shiftName: string
|
|
18
|
+
userName: string
|
|
19
|
+
bookingStatus: "ACTIVE" | "CLOSE" | "CANCEL" | "NO_SHOW"
|
|
20
|
+
is_specificRoom: number
|
|
21
|
+
guestCount: number
|
|
22
|
+
reasonToCancel: string
|
|
23
|
+
note: string
|
|
24
|
+
}[]
|
|
25
|
+
responseStructure: {
|
|
6
26
|
data: {
|
|
7
27
|
id: number
|
|
8
28
|
bookingGroupID: number
|
|
@@ -23,57 +43,13 @@ export interface staticRouteInterface_hotel_v2 {
|
|
|
23
43
|
guestCount: number
|
|
24
44
|
reasonToCancel: string
|
|
25
45
|
note: string
|
|
26
|
-
}
|
|
27
|
-
name: string
|
|
28
|
-
status: "on" | "off"
|
|
29
|
-
}
|
|
30
|
-
responseStructure: {
|
|
31
|
-
data: {
|
|
32
|
-
x: string
|
|
33
|
-
data: {
|
|
34
|
-
zoneID: number
|
|
35
|
-
zoneName: string
|
|
36
|
-
data: {
|
|
37
|
-
itemID: number
|
|
38
|
-
itemEachHotelID: number
|
|
39
|
-
itemName: string
|
|
40
|
-
requisitionQty: { expected: number; actual: number }
|
|
41
|
-
zoneStockQty: { begin: number; end: number }
|
|
42
|
-
usedQty: number
|
|
43
|
-
lossQty: number
|
|
44
|
-
damageQty: number
|
|
45
|
-
returnQty: { expected: number; actual: number }
|
|
46
|
-
notReturnQty: number
|
|
47
|
-
}[]
|
|
48
|
-
}[]
|
|
49
|
-
}
|
|
50
|
-
status: "SUCCESS" | "ERROR"
|
|
51
|
-
message: string
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
post: {
|
|
56
|
-
"/api/hotel/booking/id": {
|
|
57
|
-
requireParams: { id?: number; id2?: number; name?: string }
|
|
58
|
-
responseStructure: {
|
|
59
|
-
data: {
|
|
60
|
-
bookingData: { id: number; roomNumber: string }
|
|
61
|
-
}
|
|
62
|
-
status: "SUCCESS" | "ERROR"
|
|
63
|
-
message: string
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
"/api/hotel/testPost": {
|
|
67
|
-
requireParams: { id?: number }
|
|
68
|
-
responseStructure: {
|
|
69
|
-
data: {
|
|
70
|
-
bookingData: { id: number; roomNumber: string }
|
|
71
|
-
}
|
|
46
|
+
}[]
|
|
72
47
|
status: "SUCCESS" | "ERROR"
|
|
73
48
|
message: string
|
|
74
49
|
}
|
|
75
50
|
}
|
|
76
51
|
}
|
|
52
|
+
post: {}
|
|
77
53
|
put: {}
|
|
78
54
|
delete: {}
|
|
79
55
|
}
|
package/src/v2/run_v2.test.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import express from "express"
|
|
2
2
|
import GGExpressV2 from "./GGExpressV2"
|
|
3
3
|
import { toArray } from "./typeResolver"
|
|
4
|
+
import { GGApi_v2 } from "./output/apiConnector_hotel_v2"
|
|
4
5
|
|
|
5
6
|
export const hotel_model_const_temp = {
|
|
6
7
|
booking: {
|
|
@@ -33,142 +34,49 @@ function run() {
|
|
|
33
34
|
"/api/hotel/users/id",
|
|
34
35
|
{
|
|
35
36
|
requireParams: {
|
|
36
|
-
|
|
37
|
-
data: {
|
|
38
|
-
id: "number",
|
|
39
|
-
data: hotel_model_const_temp["booking"],
|
|
40
|
-
name: "string",
|
|
41
|
-
status: ["on", "off"],
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
responseStructure: {
|
|
45
|
-
x: "string",
|
|
46
|
-
data: [
|
|
47
|
-
{
|
|
48
|
-
zoneID: "number",
|
|
49
|
-
zoneName: "string",
|
|
50
|
-
data: [
|
|
51
|
-
{
|
|
52
|
-
itemID: "number",
|
|
53
|
-
itemEachHotelID: "number",
|
|
54
|
-
itemName: "string",
|
|
55
|
-
requisitionQty: {
|
|
56
|
-
expected: "number",
|
|
57
|
-
actual: "number",
|
|
58
|
-
},
|
|
59
|
-
zoneStockQty: {
|
|
60
|
-
begin: "number",
|
|
61
|
-
end: "number",
|
|
62
|
-
},
|
|
63
|
-
usedQty: "number",
|
|
64
|
-
lossQty: "number",
|
|
65
|
-
damageQty: "number",
|
|
66
|
-
returnQty: {
|
|
67
|
-
expected: "number",
|
|
68
|
-
actual: "number",
|
|
69
|
-
},
|
|
70
|
-
notReturnQty: "number",
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
(req, res, next) => {
|
|
78
|
-
return res.json({
|
|
79
|
-
message: "",
|
|
80
|
-
status: "SUCCESS",
|
|
81
|
-
data: {
|
|
82
|
-
x: "",
|
|
83
|
-
data: [
|
|
84
|
-
{
|
|
85
|
-
zoneID: 0,
|
|
86
|
-
zoneName: "",
|
|
87
|
-
data: [
|
|
88
|
-
{
|
|
89
|
-
itemID: 0,
|
|
90
|
-
itemEachHotelID: 0,
|
|
91
|
-
itemName: "",
|
|
92
|
-
requisitionQty: {
|
|
93
|
-
actual: 0,
|
|
94
|
-
expected: 0,
|
|
95
|
-
},
|
|
96
|
-
zoneStockQty: {
|
|
97
|
-
begin: 0,
|
|
98
|
-
end: 0,
|
|
99
|
-
},
|
|
100
|
-
usedQty: 0,
|
|
101
|
-
lossQty: 0,
|
|
102
|
-
damageQty: 0,
|
|
103
|
-
returnQty: {
|
|
104
|
-
expected: 0,
|
|
105
|
-
actual: 0,
|
|
106
|
-
},
|
|
107
|
-
notReturnQty: 0,
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
|
-
},
|
|
111
|
-
],
|
|
112
|
-
},
|
|
113
|
-
})
|
|
114
|
-
}
|
|
115
|
-
)
|
|
116
|
-
ggapp.post(
|
|
117
|
-
"/api/hotel/booking/id",
|
|
118
|
-
{
|
|
119
|
-
requireParams: {
|
|
120
|
-
isPartial: true,
|
|
121
|
-
data: {
|
|
122
|
-
id: "number",
|
|
123
|
-
id2: "number",
|
|
124
|
-
name: "string",
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
responseStructure: {
|
|
128
|
-
bookingData: {
|
|
129
|
-
id: "number",
|
|
130
|
-
roomNumber: "string",
|
|
131
|
-
},
|
|
37
|
+
data: [hotel_model_const_temp.booking],
|
|
132
38
|
},
|
|
39
|
+
responseStructure: [hotel_model_const_temp.booking],
|
|
133
40
|
},
|
|
134
41
|
(req, res, next) => {
|
|
135
42
|
return res.json({
|
|
136
43
|
message: "",
|
|
137
44
|
status: "SUCCESS",
|
|
138
|
-
data:
|
|
139
|
-
bookingData: {
|
|
140
|
-
id: 2,
|
|
141
|
-
roomNumber: "dd",
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
})
|
|
145
|
-
}
|
|
146
|
-
)
|
|
147
|
-
|
|
148
|
-
ggapp.post(
|
|
149
|
-
"/api/hotel/testPost",
|
|
150
|
-
{
|
|
151
|
-
requireParams: {
|
|
152
|
-
isPartial: true,
|
|
153
|
-
data: {
|
|
154
|
-
id: "number",
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
responseStructure: {
|
|
158
|
-
bookingData: {
|
|
159
|
-
id: "number",
|
|
160
|
-
roomNumber: "string",
|
|
161
|
-
},
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
(req, res, next) => {
|
|
165
|
-
req.body.id
|
|
166
|
-
return res.json({
|
|
167
|
-
status: "ERROR",
|
|
168
|
-
message: "",
|
|
45
|
+
data: [],
|
|
169
46
|
})
|
|
170
47
|
}
|
|
171
48
|
)
|
|
49
|
+
// ggapp.post(
|
|
50
|
+
// "/api/hotel/booking/id",
|
|
51
|
+
// {
|
|
52
|
+
// requireParams: {
|
|
53
|
+
// isPartial: true,
|
|
54
|
+
// data: {
|
|
55
|
+
// id: "number",
|
|
56
|
+
// id2: "number",
|
|
57
|
+
// name: "string",
|
|
58
|
+
// },
|
|
59
|
+
// },
|
|
60
|
+
// responseStructure: {
|
|
61
|
+
// bookingData: {
|
|
62
|
+
// id: "number",
|
|
63
|
+
// roomNumber: "string",
|
|
64
|
+
// },
|
|
65
|
+
// },
|
|
66
|
+
// },
|
|
67
|
+
// (req, res, next) => {
|
|
68
|
+
// return res.json({
|
|
69
|
+
// message: "",
|
|
70
|
+
// status: "SUCCESS",
|
|
71
|
+
// data: {
|
|
72
|
+
// bookingData: {
|
|
73
|
+
// id: 2,
|
|
74
|
+
// roomNumber: "dd",
|
|
75
|
+
// },
|
|
76
|
+
// },
|
|
77
|
+
// })
|
|
78
|
+
// }
|
|
79
|
+
// )
|
|
172
80
|
|
|
173
81
|
app.listen(3002, async () => {
|
|
174
82
|
await ggapp.generateAPIFiles()
|
|
@@ -181,13 +89,11 @@ run()
|
|
|
181
89
|
// setTimeout(() => {
|
|
182
90
|
// const x = new GGApi_v2()
|
|
183
91
|
// //@ts-ignore
|
|
184
|
-
// x.get("http://localhost:3002/api/hotel/users/id",
|
|
185
|
-
// id: 1,
|
|
186
|
-
// })
|
|
92
|
+
// x.get("http://localhost:3002/api/hotel/users/id", [])
|
|
187
93
|
// .then((response) => {
|
|
188
94
|
// console.log("response", response)
|
|
189
95
|
// })
|
|
190
96
|
// .catch((error) => {
|
|
191
|
-
// console.error("fetch error")
|
|
97
|
+
// console.error("fetch error", error)
|
|
192
98
|
// })
|
|
193
99
|
// }, 3000)
|
package/src/v2/typeResolver.ts
CHANGED
|
@@ -11,9 +11,15 @@ type BaseType =
|
|
|
11
11
|
type CustomType = BaseType | `${BaseType}?` | `${BaseType}~` | `${BaseType}?~`
|
|
12
12
|
type InputEnum = readonly string[] | readonly number[]
|
|
13
13
|
|
|
14
|
-
export type ConstSchemaType =
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
export type ConstSchemaType =
|
|
15
|
+
| {
|
|
16
|
+
[key in string]:
|
|
17
|
+
| CustomType
|
|
18
|
+
| ConstSchemaType
|
|
19
|
+
| ConstSchemaType[]
|
|
20
|
+
| InputEnum
|
|
21
|
+
}
|
|
22
|
+
| ConstSchemaType[]
|
|
17
23
|
|
|
18
24
|
type ResolveBase<T extends BaseType> = T extends "string"
|
|
19
25
|
? string
|