@nestia/fetcher 1.3.1 → 1.3.3
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/lib/IConnection.d.ts +23 -14
- package/lib/Primitive.d.ts +3 -1
- package/package.json +4 -1
- package/src/IConnection.ts +25 -15
- package/src/Primitive.ts +7 -1
package/lib/IConnection.d.ts
CHANGED
|
@@ -20,26 +20,35 @@ export interface IConnection {
|
|
|
20
20
|
*/
|
|
21
21
|
host: string;
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Header values delivered to the remote HTTP server.
|
|
24
|
+
*/
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
/**
|
|
27
|
+
* Encryption password of its closure function.
|
|
28
|
+
*/
|
|
29
|
+
encryption?: IEncryptionPassword | IEncryptionPassword.Closure;
|
|
30
|
+
/**
|
|
31
|
+
* Use simulation mode.
|
|
24
32
|
*
|
|
25
|
-
* If you configure this property to be `true` or an {@link IRandomGenerator}
|
|
33
|
+
* If you configure this property to be `true` or assign an {@link IRandomGenerator}
|
|
26
34
|
* instance, your SDK library does not send any request to remote backend server,
|
|
27
|
-
* but just returns
|
|
35
|
+
* but just returns random data generated by `typia.random<T>()` function with
|
|
36
|
+
* request data validation.
|
|
28
37
|
*
|
|
29
|
-
* By the way, to utilize this
|
|
30
|
-
* {@link INestiaConfig.
|
|
31
|
-
* configure {@link INestiaConfig.
|
|
32
|
-
* SDK library would have a built-in
|
|
38
|
+
* By the way, to utilize this simulation mode, SDK library must be generated with
|
|
39
|
+
* {@link INestiaConfig.simulate} option, too. Open `nestia.config.ts` file, and
|
|
40
|
+
* configure {@link INestiaConfig.simulate} property to be `true`. Them, newly
|
|
41
|
+
* generated SDK library would have a built-in mock-up data generator.
|
|
33
42
|
*
|
|
34
43
|
* @default false
|
|
35
44
|
*/
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Header values delivered to the remote HTTP server.
|
|
39
|
-
*/
|
|
40
|
-
headers?: Record<string, string>;
|
|
45
|
+
simulate?: boolean | Partial<IRandomGenerator>;
|
|
41
46
|
/**
|
|
42
|
-
*
|
|
47
|
+
* Use simulation mode.
|
|
48
|
+
*
|
|
49
|
+
* @default false
|
|
50
|
+
* @deprecated Use {@link simulate} property instead.
|
|
51
|
+
* This property would be erased after v2.0 update
|
|
43
52
|
*/
|
|
44
|
-
|
|
53
|
+
random?: boolean | Partial<IRandomGenerator>;
|
|
45
54
|
}
|
package/lib/Primitive.d.ts
CHANGED
|
@@ -27,10 +27,12 @@
|
|
|
27
27
|
*
|
|
28
28
|
* @template Instance Target argument type.
|
|
29
29
|
* @author Jenogho Nam - https://github.com/samchon
|
|
30
|
+
* @author Kyungsu Kang - https://github.com/kakasoo
|
|
31
|
+
* @author Michael - https://github.com/8471919
|
|
30
32
|
*/
|
|
31
33
|
export type Primitive<T> = Equal<T, PrimitiveMain<T>> extends true ? T : PrimitiveMain<T>;
|
|
32
34
|
type Equal<X, Y> = X extends Y ? (Y extends X ? true : false) : false;
|
|
33
|
-
type PrimitiveMain<Instance> = ValueOf<Instance> extends object ? Instance extends object ? Instance extends NativeClass ? {} : Instance extends IJsonable<infer Raw> ? ValueOf<Raw> extends object ? Raw extends object ? PrimitiveObject<Raw> : never : ValueOf<Raw> : PrimitiveObject<Instance> : never : ValueOf<Instance>;
|
|
35
|
+
type PrimitiveMain<Instance> = Instance extends [never] ? never : ValueOf<Instance> extends boolean | number | bigint | string ? ValueOf<Instance> : ValueOf<Instance> extends object ? Instance extends object ? Instance extends NativeClass ? {} : Instance extends IJsonable<infer Raw> ? ValueOf<Raw> extends object ? Raw extends object ? PrimitiveObject<Raw> : never : ValueOf<Raw> : PrimitiveObject<Instance> : never : ValueOf<Instance>;
|
|
34
36
|
type PrimitiveObject<Instance extends object> = Instance extends Array<infer T> ? IsTuple<Instance> extends true ? PrimitiveTuple<Instance> : PrimitiveMain<T>[] : {
|
|
35
37
|
[P in keyof Instance]: Instance[P] extends Function ? never : PrimitiveMain<Instance[P]>;
|
|
36
38
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestia/fetcher",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "Fetcher library of Nestia SDK",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -34,6 +34,9 @@
|
|
|
34
34
|
"rimraf": "^3.0.2",
|
|
35
35
|
"typescript": "^4.9.4"
|
|
36
36
|
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"typescript": ">= 4.7.4"
|
|
39
|
+
},
|
|
37
40
|
"dependencies": {
|
|
38
41
|
"import2": "^1.0.3",
|
|
39
42
|
"node-fetch": "^2.6.7"
|
package/src/IConnection.ts
CHANGED
|
@@ -22,28 +22,38 @@ export interface IConnection {
|
|
|
22
22
|
host: string;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Header values delivered to the remote HTTP server.
|
|
26
|
+
*/
|
|
27
|
+
headers?: Record<string, string>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Encryption password of its closure function.
|
|
31
|
+
*/
|
|
32
|
+
encryption?: IEncryptionPassword | IEncryptionPassword.Closure;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Use simulation mode.
|
|
26
36
|
*
|
|
27
|
-
* If you configure this property to be `true` or an {@link IRandomGenerator}
|
|
37
|
+
* If you configure this property to be `true` or assign an {@link IRandomGenerator}
|
|
28
38
|
* instance, your SDK library does not send any request to remote backend server,
|
|
29
|
-
* but just returns
|
|
39
|
+
* but just returns random data generated by `typia.random<T>()` function with
|
|
40
|
+
* request data validation.
|
|
30
41
|
*
|
|
31
|
-
* By the way, to utilize this
|
|
32
|
-
* {@link INestiaConfig.
|
|
33
|
-
* configure {@link INestiaConfig.
|
|
34
|
-
* SDK library would have a built-in
|
|
42
|
+
* By the way, to utilize this simulation mode, SDK library must be generated with
|
|
43
|
+
* {@link INestiaConfig.simulate} option, too. Open `nestia.config.ts` file, and
|
|
44
|
+
* configure {@link INestiaConfig.simulate} property to be `true`. Them, newly
|
|
45
|
+
* generated SDK library would have a built-in mock-up data generator.
|
|
35
46
|
*
|
|
36
47
|
* @default false
|
|
37
48
|
*/
|
|
38
|
-
|
|
49
|
+
simulate?: boolean | Partial<IRandomGenerator>;
|
|
39
50
|
|
|
40
51
|
/**
|
|
41
|
-
*
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
* Encryption password of its closure function.
|
|
52
|
+
* Use simulation mode.
|
|
53
|
+
*
|
|
54
|
+
* @default false
|
|
55
|
+
* @deprecated Use {@link simulate} property instead.
|
|
56
|
+
* This property would be erased after v2.0 update
|
|
47
57
|
*/
|
|
48
|
-
|
|
58
|
+
random?: boolean | Partial<IRandomGenerator>;
|
|
49
59
|
}
|
package/src/Primitive.ts
CHANGED
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
*
|
|
28
28
|
* @template Instance Target argument type.
|
|
29
29
|
* @author Jenogho Nam - https://github.com/samchon
|
|
30
|
+
* @author Kyungsu Kang - https://github.com/kakasoo
|
|
31
|
+
* @author Michael - https://github.com/8471919
|
|
30
32
|
*/
|
|
31
33
|
export type Primitive<T> = Equal<T, PrimitiveMain<T>> extends true
|
|
32
34
|
? T
|
|
@@ -34,7 +36,11 @@ export type Primitive<T> = Equal<T, PrimitiveMain<T>> extends true
|
|
|
34
36
|
|
|
35
37
|
type Equal<X, Y> = X extends Y ? (Y extends X ? true : false) : false;
|
|
36
38
|
|
|
37
|
-
type PrimitiveMain<Instance> =
|
|
39
|
+
type PrimitiveMain<Instance> = Instance extends [never]
|
|
40
|
+
? never // (special trick for jsonable | null) type
|
|
41
|
+
: ValueOf<Instance> extends boolean | number | bigint | string
|
|
42
|
+
? ValueOf<Instance>
|
|
43
|
+
: ValueOf<Instance> extends object
|
|
38
44
|
? Instance extends object
|
|
39
45
|
? Instance extends NativeClass
|
|
40
46
|
? {}
|