codegen-openapi-ts 0.4.3 → 0.5.2

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.
Files changed (2) hide show
  1. package/package.json +3 -2
  2. package/types/helper.d.ts +59 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codegen-openapi-ts",
3
- "version": "0.4.3",
3
+ "version": "0.5.2",
4
4
  "description": "Library that generates Typescript clients based on the OpenAPI specification.",
5
5
  "author": "devteaa",
6
6
  "homepage": "https://github.com/devteaa/codegen-openapi-ts",
@@ -37,7 +37,8 @@
37
37
  "files": [
38
38
  "bin/index.js",
39
39
  "dist/index.js",
40
- "types/index.d.ts"
40
+ "types/index.d.ts",
41
+ "types/helper.d.ts"
41
42
  ],
42
43
  "scripts": {
43
44
  "clean": "rimraf ./dist ./test/generated ./test/e2e/generated ./samples/generated ./coverage ./node_modules/.cache",
@@ -0,0 +1,59 @@
1
+ type NonObjectKeysOf<T> = {
2
+ [K in keyof T]: T[K] extends Array<any> ? K : T[K] extends object ? never : K
3
+ }[keyof T];
4
+
5
+ type ValuesOf<T> = T[keyof T];
6
+ type ObjectValuesOf<T extends Object> = Exclude<
7
+ Exclude<Extract<ValuesOf<T>, object>, never>,
8
+ Array<any>
9
+ >;
10
+
11
+ type UnionToIntersection<U> = (U extends any
12
+ ? (k: U) => void
13
+ : never) extends ((k: infer I) => void)
14
+ ? I
15
+ : never;
16
+
17
+ export type DeepFlatten<T> = T extends any
18
+ ? Pick<T, NonObjectKeysOf<T>> &
19
+ UnionToIntersection<DeepFlatten2<ObjectValuesOf<T>>>
20
+ : never;
21
+
22
+ type DeepFlatten2<T> = T extends any
23
+ ? Pick<T, NonObjectKeysOf<T>> &
24
+ UnionToIntersection<DeepFlatten3<ObjectValuesOf<T>>>
25
+ : never;
26
+
27
+ type DeepFlatten3<T> = T extends any
28
+ ? Pick<T, NonObjectKeysOf<T>> &
29
+ UnionToIntersection<DeepFlatten4<ObjectValuesOf<T>>>
30
+ : never;
31
+
32
+ type DeepFlatten4<T> = T extends any
33
+ ? Pick<T, NonObjectKeysOf<T>> &
34
+ UnionToIntersection<DeepFlatten5<ObjectValuesOf<T>>>
35
+ : never;
36
+
37
+ type DeepFlatten5<T> = T extends any
38
+ ? Pick<T, NonObjectKeysOf<T>> &
39
+ UnionToIntersection<DeepFlatten6<ObjectValuesOf<T>>>
40
+ : never;
41
+
42
+ type DeepFlatten6<T> = T extends any
43
+ ? Pick<T, NonObjectKeysOf<T>> &
44
+ UnionToIntersection<DeepFlatten7<ObjectValuesOf<T>>>
45
+ : never;
46
+
47
+ type DeepFlatten7<T> = T extends any
48
+ ? Pick<T, NonObjectKeysOf<T>> &
49
+ UnionToIntersection<DeepFlatten8<ObjectValuesOf<T>>>
50
+ : never;
51
+
52
+ type DeepFlatten8<T> = T extends any
53
+ ? Pick<T, NonObjectKeysOf<T>> &
54
+ UnionToIntersection<DeepFlatten9<ObjectValuesOf<T>>>
55
+ : never;
56
+
57
+ type DeepFlatten9<T> = T extends any
58
+ ? Pick<T, NonObjectKeysOf<T>>
59
+ : UnionToIntersection<ObjectValuesOf<T>>;