gg-express 1.0.96 → 1.0.97

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,12 +1,13 @@
1
1
  import { TypeResolve } from "./typeResolver";
2
2
  export declare const ReturnOfCalculateEachDateConst: {
3
- readonly itemDetailData: [{
3
+ readonly itemDetailData: {
4
4
  readonly itemID: "number";
5
5
  readonly zoneID: "number";
6
- }];
6
+ }[];
7
7
  readonly itemDetailData_v2: [{
8
8
  readonly id: "number";
9
9
  }];
10
+ readonly bool: "boolean";
10
11
  readonly requisitionQuantity: "number";
11
12
  readonly usedQuantity: "number";
12
13
  readonly date: "string";
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ReturnOfCalculateEachDateConst = void 0;
4
+ const typeResolver_1 = require("./typeResolver");
4
5
  const itemDetailDataConst = {
5
6
  itemID: "number",
6
7
  zoneID: "number",
@@ -9,14 +10,13 @@ const QuantityTypeConst = {
9
10
  requisitionQuantity: "number",
10
11
  usedQuantity: "number",
11
12
  };
12
- exports.ReturnOfCalculateEachDateConst = Object.assign(Object.assign({ date: "string", itemID: "number" }, QuantityTypeConst), { itemDetailData: [itemDetailDataConst], itemDetailData_v2: [{ id: "number" }] });
13
+ exports.ReturnOfCalculateEachDateConst = Object.assign(Object.assign({ date: "string", itemID: "number" }, QuantityTypeConst), { itemDetailData: (0, typeResolver_1.toArray)(itemDetailDataConst), itemDetailData_v2: [{ id: "number" }], bool: "boolean" });
13
14
  const temp = {
14
- itemDetailData: [
15
- {
16
- itemID: 0,
17
- zoneID: 0,
18
- },
19
- ],
15
+ bool: true,
16
+ itemDetailData: (0, typeResolver_1.toArray)({
17
+ itemID: 0,
18
+ zoneID: 0,
19
+ }),
20
20
  itemDetailData_v2: [
21
21
  {
22
22
  id: 1,
@@ -1,12 +1,12 @@
1
1
  type Unarray<T> = T extends (infer U)[] ? U : T;
2
- type BaseType = "string" | "number" | "string[]" | "number[]";
2
+ type BaseType = "string" | "number" | "boolean" | "string[]" | "number[]" | "boolean[]";
3
3
  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
  };
8
- type ResolveBase<T extends BaseType> = T extends "string" ? string : T extends "string[]" ? string[] : T extends "number" ? number : T extends "number[]" ? number[] : never;
9
- export declare const toArray: <T extends ConstSchemaType>(input: T) => T[];
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
+ 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>;
11
11
  type chooseType<T> = T extends InputEnum ? T[number] : T extends any[] ? chooseType<Unarray<T>>[] : T extends object ? TypeResolve<T> : ResolveExtraType<T>;
12
12
  export type TypeResolve<T> = {
@@ -5,54 +5,3 @@ 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
50
- // const data = {} as convertRoot<typeof req2>
51
- // data.booking.bookingStatus
52
- // data.status
53
- // const id = data.booking.id
54
- // const roomNumber = data.booking.bookingStatus === data.booking.bookingStatus
55
- // data.rooms.map((row) => row.status === "OFF")
56
- // data.data.level_1.level_2.id
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.96",
3
+ "version": "1.0.97",
4
4
  "description": "",
5
5
  "main": "dist/main.js",
6
6
  "scripts": {
@@ -1,5 +1,6 @@
1
1
  import express from "express"
2
2
  import GGExpressV2 from "./GGExpressV2"
3
+ import { toArray } from "./typeResolver"
3
4
 
4
5
  export const hotel_model_const_temp = {
5
6
  booking: {
@@ -1,4 +1,4 @@
1
- import { TypeResolve, ConstSchemaType } from "./typeResolver"
1
+ import { TypeResolve, ConstSchemaType, toArray } from "./typeResolver"
2
2
 
3
3
  const itemDetailDataConst = {
4
4
  itemID: "number",
@@ -13,8 +13,9 @@ export const ReturnOfCalculateEachDateConst = {
13
13
  date: "string",
14
14
  itemID: "number",
15
15
  ...QuantityTypeConst,
16
- itemDetailData: [itemDetailDataConst],
16
+ itemDetailData: toArray(itemDetailDataConst),
17
17
  itemDetailData_v2: [{ id: "number" }],
18
+ bool: "boolean",
18
19
  } as const satisfies ConstSchemaType
19
20
 
20
21
  export type ReturnOfCalculateEachDate = TypeResolve<
@@ -22,12 +23,11 @@ export type ReturnOfCalculateEachDate = TypeResolve<
22
23
  >
23
24
 
24
25
  const temp: ReturnOfCalculateEachDate = {
25
- itemDetailData: [
26
- {
27
- itemID: 0,
28
- zoneID: 0,
29
- },
30
- ],
26
+ bool: true,
27
+ itemDetailData: toArray({
28
+ itemID: 0,
29
+ zoneID: 0,
30
+ }),
31
31
  itemDetailData_v2: [
32
32
  {
33
33
  id: 1,
@@ -1,8 +1,14 @@
1
1
  type Unarray<T> = T extends (infer U)[] ? U : T
2
2
 
3
- type BaseType = "string" | "number" | "string[]" | "number[]"
4
- type CustomType = BaseType | `${BaseType}?` | `${BaseType}~` | `${BaseType}?~`
3
+ type BaseType =
4
+ | "string"
5
+ | "number"
6
+ | "boolean"
7
+ | "string[]"
8
+ | "number[]"
9
+ | "boolean[]"
5
10
 
11
+ type CustomType = BaseType | `${BaseType}?` | `${BaseType}~` | `${BaseType}?~`
6
12
  type InputEnum = readonly string[] | readonly number[]
7
13
  export type ConstSchemaType = {
8
14
  [key in string]: CustomType | ConstSchemaType | ConstSchemaType[] | InputEnum
@@ -15,10 +21,14 @@ type ResolveBase<T extends BaseType> = T extends "string"
15
21
  ? number
16
22
  : T extends "number[]"
17
23
  ? number[]
24
+ : T extends "boolean"
25
+ ? boolean
26
+ : T extends "boolean[]"
27
+ ? boolean[]
18
28
  : never
19
29
 
20
- export const toArray = <T extends ConstSchemaType>(input: T) => {
21
- return [input]
30
+ export const toArray = <T>(input: T): T[] => {
31
+ return [input] as T[]
22
32
  }
23
33
 
24
34
  type ResolveExtraType<T> =
@@ -34,8 +44,6 @@ type ResolveExtraType<T> =
34
44
  : // plain primitive
35
45
  ResolveBase<T & BaseType>
36
46
 
37
- // type checkEnum<T> = T extends InputEnum ? T[number] : ResolveExtraType<T>
38
-
39
47
  type chooseType<T> = T extends InputEnum
40
48
  ? T[number]
41
49
  : T extends any[]
@@ -43,62 +51,7 @@ type chooseType<T> = T extends InputEnum
43
51
  : T extends object
44
52
  ? TypeResolve<T>
45
53
  : ResolveExtraType<T>
46
- // : checkEnum<T>
47
54
 
48
55
  export type TypeResolve<T> = {
49
56
  [K in keyof T]: chooseType<T[K]>
50
57
  }
51
-
52
- // let req2 = {
53
- // booking: {
54
- // id: "number",
55
- // bookingGroupID: "number",
56
- // checkInDate: "string",
57
- // checkOutDate: "string",
58
- // checkInTime: "string",
59
- // checkOutTime: "string",
60
- // roomRate: "number",
61
- // extraBedRate: "number",
62
- // roomNumber: "string",
63
- // editTime: "string",
64
- // createTime: "string",
65
- // shiftDate: "string",
66
- // shiftName: "string",
67
- // userName: "string",
68
- // bookingStatus: ["ACTIVE", "CLOSE", "CANCEL", "NO_SHOW"],
69
- // is_specificRoom: "number",
70
- // guestCount: "number",
71
- // reasonToCancel: "string",
72
- // note: "string",
73
- // },
74
- // status: ["ACTIVE", "DISABLE"],
75
- // rooms: toArray({
76
- // id: "number",
77
- // status: ["ON", "OFF"],
78
- // roomNumber: "string",
79
- // log: toArray({
80
- // time: "string",
81
- // logger: [{ info: "string" }],
82
- // }),
83
- // }),
84
-
85
- // data: {
86
- // level_1: {
87
- // title: "string",
88
- // level_2: {
89
- // id: "number",
90
- // name: "string",
91
- // },
92
- // },
93
- // },
94
- // } as const satisfies InputParent
95
- // const data = {} as convertRoot<typeof req2>
96
-
97
- // data.booking.bookingStatus
98
- // data.status
99
- // const id = data.booking.id
100
- // const roomNumber = data.booking.bookingStatus === data.booking.bookingStatus
101
- // data.rooms.map((row) => row.status === "OFF")
102
- // data.data.level_1.level_2.id
103
- // data.booking.createTime
104
- // req2.data.level_1.level_2