@nestia/fetcher 0.1.0 → 0.2.0
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/README.md +5 -4
- package/lib/Fetcher.js +1 -1
- package/lib/Primitive.d.ts +6 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -11,28 +11,29 @@ npm install --save @nestia/fetcher
|
|
|
11
11
|
|
|
12
12
|
`@nestia/fetcher` is a fetcher library of [**Nestia**](https://github.com/samchon/nestia) SDK.
|
|
13
13
|
|
|
14
|
-
When you build an SDK (Software Development Kit) library interacting with remote HTTP server through the [
|
|
14
|
+
When you build an SDK (Software Development Kit) library interacting with remote HTTP server through the [`@nestia/sdk`](https://github.com/samchon/nestia), the SDK library would be dependent on this `@nestia/fetcher`. Therefore, if you publish the SDK library on the NPM module, you have to add this `@nestia/fetcher` in the `dependencies` field of the `package.json`.
|
|
15
15
|
|
|
16
|
-
Also, if you're a client developer who've installed an SDK library which has been generated by the [
|
|
16
|
+
Also, if you're a client developer who've installed an SDK library which has been generated by the [`@nestia/sdk`](https://github.com/samchon/nestia), you also need to install this `@nestia/fetcher` module. With the `IConnection` and `HttpError` instances provided by this `@nestia/fetcher`, you can enjoy the SDK library much conveniently.
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
## Example
|
|
22
22
|
### `package.json`
|
|
23
|
-
When you build an SDK library who've been generated by the [
|
|
23
|
+
When you build an SDK library who've been generated by the [`@nestia/sdk`](https://github.com/samchon/nestia), you have to add this `@nestia/fetcher` in the `dependencies` field of the `package.json`. If your project had installed the [`@nestia/sdk`](https://github.com/samchon/nestia), you can write the `dependencies`' property by writing the `npx nestia dependencies` command on your console.
|
|
24
24
|
|
|
25
25
|
```json
|
|
26
26
|
{
|
|
27
27
|
"name": "payments-server-api",
|
|
28
28
|
"dependencies": {
|
|
29
|
+
"typia": "^3.4.9",
|
|
29
30
|
"@nestia/fetcher": "^1.0.0"
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
```
|
|
33
34
|
|
|
34
35
|
### SDK Library
|
|
35
|
-
|
|
36
|
+
When you open a source file generated by the [`@nestia/sdk`](https://github.com/samchon/nestia), you can find the SDK library is importing this `@nestia/fetcher` module in every `functional` files. Therefore, I repeat that you have to put this `@nestia/fetcher` down into the `dependencies` field of the `package.json`.
|
|
36
37
|
|
|
37
38
|
```typescript
|
|
38
39
|
import { Fetcher, IConnection, Primitive } from "@nestia/fetcher";
|
package/lib/Fetcher.js
CHANGED
|
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
26
|
function step(op) {
|
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
29
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
30
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
31
|
switch (op[0]) {
|
package/lib/Primitive.d.ts
CHANGED
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
* @template Instance Target argument type.
|
|
29
29
|
* @author Jenogho Nam - https://github.com/samchon
|
|
30
30
|
*/
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
export type Primitive<Instance> = _Equal<Instance, _Primitive<Instance>> extends true ? Instance : _Primitive<Instance>;
|
|
32
|
+
type _Equal<X, Y> = X extends Y ? (Y extends X ? true : false) : false;
|
|
33
|
+
type _Primitive<Instance> = _ValueOf<Instance> extends object ? Instance extends object ? Instance extends IJsonable<infer Raw> ? _ValueOf<Raw> extends object ? Raw extends object ? _PrimitiveObject<Raw> : never : _ValueOf<Raw> : _PrimitiveObject<Instance> : never : _ValueOf<Instance>;
|
|
34
|
+
type _PrimitiveObject<Instance extends object> = Instance extends Array<infer T> ? _Primitive<T>[] : {
|
|
35
35
|
[P in keyof Instance]: Instance[P] extends Function ? never : _Primitive<Instance[P]>;
|
|
36
36
|
};
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
type _ValueOf<Instance> = _IsValueOf<Instance, Boolean> extends true ? boolean : _IsValueOf<Instance, Number> extends true ? number : _IsValueOf<Instance, String> extends true ? string : Instance;
|
|
38
|
+
type _IsValueOf<Instance, Object extends IValueOf<any>> = Instance extends Object ? Object extends IValueOf<infer Primitive> ? Instance extends Primitive ? false : true : false : false;
|
|
39
39
|
interface IValueOf<T> {
|
|
40
40
|
valueOf(): T;
|
|
41
41
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestia/fetcher",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Fetcher library of Nestia SDK",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"bugs": {
|
|
26
26
|
"url": "https://github.com/samchon/nestia/issues"
|
|
27
27
|
},
|
|
28
|
-
"homepage": "https://github.com/samchon/nestia
|
|
28
|
+
"homepage": "https://github.com/samchon/nestia",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/node": "^18.11.14",
|
|
31
31
|
"@typescript-eslint/eslint-plugin": "^5.46.1",
|