gg-express 1.0.86 → 1.0.88
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/run_v2.test.d.ts
CHANGED
|
@@ -1 +1,23 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export declare const hotel_model_const_temp: {
|
|
2
|
+
readonly booking: {
|
|
3
|
+
readonly id: "number";
|
|
4
|
+
readonly bookingGroupID: "number";
|
|
5
|
+
readonly checkInDate: "string";
|
|
6
|
+
readonly checkOutDate: "string";
|
|
7
|
+
readonly checkInTime: "string";
|
|
8
|
+
readonly checkOutTime: "string";
|
|
9
|
+
readonly roomRate: "number";
|
|
10
|
+
readonly extraBedRate: "number";
|
|
11
|
+
readonly roomNumber: "string";
|
|
12
|
+
readonly editTime: "string";
|
|
13
|
+
readonly createTime: "string";
|
|
14
|
+
readonly shiftDate: "string";
|
|
15
|
+
readonly shiftName: "string";
|
|
16
|
+
readonly userName: "string";
|
|
17
|
+
readonly bookingStatus: readonly ["ACTIVE", "CLOSE", "CANCEL", "NO_SHOW"];
|
|
18
|
+
readonly is_specificRoom: "number";
|
|
19
|
+
readonly guestCount: "number";
|
|
20
|
+
readonly reasonToCancel: "string";
|
|
21
|
+
readonly note: "string";
|
|
22
|
+
};
|
|
23
|
+
};
|
package/dist/v2/run_v2.test.js
CHANGED
|
@@ -12,15 +12,42 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.hotel_model_const_temp = void 0;
|
|
15
16
|
const express_1 = __importDefault(require("express"));
|
|
16
17
|
const GGExpressV2_1 = __importDefault(require("./GGExpressV2"));
|
|
17
18
|
const typeResolver_1 = require("./typeResolver");
|
|
19
|
+
exports.hotel_model_const_temp = {
|
|
20
|
+
booking: {
|
|
21
|
+
id: "number",
|
|
22
|
+
bookingGroupID: "number",
|
|
23
|
+
checkInDate: "string",
|
|
24
|
+
checkOutDate: "string",
|
|
25
|
+
checkInTime: "string",
|
|
26
|
+
checkOutTime: "string",
|
|
27
|
+
roomRate: "number",
|
|
28
|
+
extraBedRate: "number",
|
|
29
|
+
roomNumber: "string",
|
|
30
|
+
editTime: "string",
|
|
31
|
+
createTime: "string",
|
|
32
|
+
shiftDate: "string",
|
|
33
|
+
shiftName: "string",
|
|
34
|
+
userName: "string",
|
|
35
|
+
bookingStatus: ["ACTIVE", "CLOSE", "CANCEL", "NO_SHOW"],
|
|
36
|
+
is_specificRoom: "number",
|
|
37
|
+
guestCount: "number",
|
|
38
|
+
reasonToCancel: "string",
|
|
39
|
+
note: "string",
|
|
40
|
+
},
|
|
41
|
+
};
|
|
18
42
|
function run() {
|
|
19
43
|
const app = (0, express_1.default)();
|
|
20
44
|
const ggapp = new GGExpressV2_1.default(app, "hotel", ["./output"]);
|
|
21
45
|
ggapp.get("/api/hotel/users/id", {
|
|
22
46
|
requireParams: {
|
|
23
47
|
id: "number",
|
|
48
|
+
data: exports.hotel_model_const_temp["booking"],
|
|
49
|
+
name: "string",
|
|
50
|
+
status: ["on", "off"],
|
|
24
51
|
},
|
|
25
52
|
responseStructure: {
|
|
26
53
|
userData: (0, typeResolver_1.toArray)({
|
|
@@ -29,8 +56,11 @@ function run() {
|
|
|
29
56
|
}),
|
|
30
57
|
},
|
|
31
58
|
}, (req, res, next) => {
|
|
59
|
+
// req.query.data.bookingStatus===''
|
|
60
|
+
req.query.name;
|
|
32
61
|
console.log("req.query", req.query);
|
|
33
62
|
console.log("req.query.id", req.query.id);
|
|
63
|
+
// req.query.data.bookingStatus
|
|
34
64
|
return res.json({
|
|
35
65
|
message: "",
|
|
36
66
|
status: "SUCCESS",
|
|
@@ -3,9 +3,9 @@ export type CustomType = BaseType | `${BaseType}?` | `${BaseType}~` | `${BaseTyp
|
|
|
3
3
|
export type InputNest = {
|
|
4
4
|
[key in string]: CustomType;
|
|
5
5
|
};
|
|
6
|
-
type InputEnum = string
|
|
6
|
+
type InputEnum = readonly (string | number)[];
|
|
7
7
|
export type InputParent = {
|
|
8
|
-
[key in string]: CustomType |
|
|
8
|
+
[key in string]: CustomType | InputParent | InputParent[] | InputEnum;
|
|
9
9
|
};
|
|
10
10
|
type ResolveBase<T extends BaseType> = T extends "string" ? string : T extends "string[]" ? string[] : T extends "number" ? number : T extends "number[]" ? number[] : never;
|
|
11
11
|
export declare const toArray: <T extends InputParent>(input: T) => T[];
|
|
@@ -15,7 +15,7 @@ type checkEnum<T> = T extends InputEnum ? T[number] : convertNest<T>;
|
|
|
15
15
|
type convertChildObjet<T> = {
|
|
16
16
|
[K in keyof T]: chooseType<T[K]>;
|
|
17
17
|
};
|
|
18
|
-
type convertObject<T> = T extends object ? convertChildObjet<T> : checkEnum<T>;
|
|
18
|
+
type convertObject<T> = T extends readonly any[] ? checkEnum<T> : T extends object ? convertChildObjet<T> : checkEnum<T>;
|
|
19
19
|
type chooseType<T> = T extends InputEnum ? T[number] : convertObject<T>;
|
|
20
20
|
export type convertRoot<T> = {
|
|
21
21
|
[K in keyof T]: chooseType<T[K]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Method } from "./GGExpressV2"
|
|
2
|
-
import {
|
|
3
|
-
import fs from "fs"
|
|
2
|
+
import { InputParent } from "./typeResolver"
|
|
4
3
|
type routeList = {
|
|
5
4
|
method: Method
|
|
6
5
|
url: string
|
|
@@ -91,7 +90,7 @@ function parentInputToCode(data: InputParent) {
|
|
|
91
90
|
.join(",")}] `
|
|
92
91
|
// nest or input nest
|
|
93
92
|
else if (typeof target[0] === "object")
|
|
94
|
-
for (const row of target as
|
|
93
|
+
for (const row of target as InputParent[]) {
|
|
95
94
|
result = result + " " + recursiveExtract(row, parentKeyName) + "[] "
|
|
96
95
|
}
|
|
97
96
|
}
|
package/src/v2/run_v2.test.ts
CHANGED
|
@@ -2,6 +2,31 @@ import express, { Express } from "express"
|
|
|
2
2
|
import GGExpressV2 from "./GGExpressV2"
|
|
3
3
|
import { toArray } from "./typeResolver"
|
|
4
4
|
import { GGApi_v2 } from "./output/apiConnector_hotel_v2"
|
|
5
|
+
|
|
6
|
+
export const hotel_model_const_temp = {
|
|
7
|
+
booking: {
|
|
8
|
+
id: "number",
|
|
9
|
+
bookingGroupID: "number",
|
|
10
|
+
checkInDate: "string",
|
|
11
|
+
checkOutDate: "string",
|
|
12
|
+
checkInTime: "string",
|
|
13
|
+
checkOutTime: "string",
|
|
14
|
+
roomRate: "number",
|
|
15
|
+
extraBedRate: "number",
|
|
16
|
+
roomNumber: "string",
|
|
17
|
+
editTime: "string",
|
|
18
|
+
createTime: "string",
|
|
19
|
+
shiftDate: "string",
|
|
20
|
+
shiftName: "string",
|
|
21
|
+
userName: "string",
|
|
22
|
+
bookingStatus: ["ACTIVE", "CLOSE", "CANCEL", "NO_SHOW"],
|
|
23
|
+
is_specificRoom: "number",
|
|
24
|
+
guestCount: "number",
|
|
25
|
+
reasonToCancel: "string",
|
|
26
|
+
note: "string",
|
|
27
|
+
},
|
|
28
|
+
} as const
|
|
29
|
+
|
|
5
30
|
function run() {
|
|
6
31
|
const app = express()
|
|
7
32
|
const ggapp = new GGExpressV2<"hotel">(app, "hotel", ["./output"])
|
|
@@ -10,6 +35,9 @@ function run() {
|
|
|
10
35
|
{
|
|
11
36
|
requireParams: {
|
|
12
37
|
id: "number",
|
|
38
|
+
data: hotel_model_const_temp["booking"],
|
|
39
|
+
name: "string",
|
|
40
|
+
status: ["on", "off"],
|
|
13
41
|
},
|
|
14
42
|
responseStructure: {
|
|
15
43
|
userData: toArray({
|
|
@@ -19,9 +47,11 @@ function run() {
|
|
|
19
47
|
},
|
|
20
48
|
},
|
|
21
49
|
(req, res, next) => {
|
|
50
|
+
// req.query.data.bookingStatus===''
|
|
51
|
+
req.query.name
|
|
22
52
|
console.log("req.query", req.query)
|
|
23
53
|
console.log("req.query.id", req.query.id)
|
|
24
|
-
|
|
54
|
+
// req.query.data.bookingStatus
|
|
25
55
|
return res.json({
|
|
26
56
|
message: "",
|
|
27
57
|
status: "SUCCESS",
|
package/src/v2/typeResolver.ts
CHANGED
|
@@ -6,12 +6,15 @@ export type CustomType =
|
|
|
6
6
|
| `${BaseType}?~`
|
|
7
7
|
|
|
8
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
13
|
export type InputParent = {
|
|
11
14
|
[key in string]:
|
|
12
15
|
| CustomType
|
|
13
|
-
| InputNest
|
|
14
|
-
| InputNest[]
|
|
16
|
+
// | InputNest
|
|
17
|
+
// | InputNest[]
|
|
15
18
|
| InputParent
|
|
16
19
|
| InputParent[]
|
|
17
20
|
| InputEnum
|
|
@@ -93,7 +96,14 @@ type checkEnum<T> = T extends InputEnum ? T[number] : convertNest<T>
|
|
|
93
96
|
type convertChildObjet<T> = {
|
|
94
97
|
[K in keyof T]: chooseType<T[K]>
|
|
95
98
|
}
|
|
96
|
-
type convertObject<T> = T extends object ? convertChildObjet<T> : checkEnum<T>
|
|
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
|
+
|
|
97
107
|
type chooseType<T> = T extends InputEnum ? T[number] : convertObject<T>
|
|
98
108
|
export type convertRoot<T> = {
|
|
99
109
|
[K in keyof T]: chooseType<T[K]>
|