@nestia/fetcher 3.13.0 → 3.14.0-dev.20240917

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.
@@ -0,0 +1,78 @@
1
+ /**
2
+ * FormData input type.
3
+ *
4
+ * `FormDataInput<T>` is a type for the input of the `FormData` request, casting
5
+ * `File` property value type as an union of `File` and {@link FormDataInput.IFileProps},
6
+ * especially for the React Native environment.
7
+ *
8
+ * You know what? In the React Native environment, `File` class is not supported.
9
+ * Therefore, when composing a `FormData` request, you have to put the URI address
10
+ * of the local filesystem with file name and contet type that is represented by the
11
+ * {@link FormDataInput.IFileProps} type.
12
+ *
13
+ * This `FormDataInput<T>` type is designed for that purpose. If the property value
14
+ * type is a `File` class, it converts it to an union type of `File` and
15
+ * {@link FormDataInput.IFileProps} type. Also, if the property value type is an array
16
+ * of `File` class, it converts it to an array of union type of `File` and
17
+ * {@link FormDataInput.IFileProps} type too.
18
+ *
19
+ * Before | After
20
+ * ----------|------------------------
21
+ * `boolean` | `boolean`
22
+ * `bigint` | `bigint`
23
+ * `number` | `number`
24
+ * `string` | `string`
25
+ * `File` | `File \| IFileProps`
26
+ * `Object` | `never`
27
+ *
28
+ * @template T Target object type.
29
+ * @author Jeongho Nam - https://github.com/samchon
30
+ */
31
+ export type FormDataInput<T extends object> = T extends Array<any> ? never : T extends Function ? never : {
32
+ [P in keyof T]: T[P] extends Array<infer U> ? FormDataInput.Value<U>[] : FormDataInput.Value<T[P]>;
33
+ };
34
+ export declare namespace FormDataInput {
35
+ /**
36
+ * Value type of the `FormDataInput`.
37
+ *
38
+ * `Value<T>` is a type for the property value defined in the `FormDataInput`.
39
+ *
40
+ * If the original value type is a `File` class, `Value<T>` converts it to an union
41
+ * type of `File` and {@link IFileProps} type which is a structured data for the
42
+ * URI file location in the React Native environment.
43
+ */
44
+ type Value<T> = T extends File ? T | IFileProps : T extends object ? never : T;
45
+ /**
46
+ * Properties of a file.
47
+ *
48
+ * In the React Native, this `IFileProps` structured data can replace the `File`
49
+ * class instance in the `FormData` request.
50
+ *
51
+ * Just put the {@link uri URI address} of the local file system with the file's
52
+ * {@link name} and {@link type}. It would be casted to the `File` class instance
53
+ * automatically in the `FormData` request.
54
+ *
55
+ * Note that, this `IFileProps` type works only in the React Native environment.
56
+ * If you are developing a Web or NodeJS application, you have to utilize the
57
+ * `File` class instance directly.
58
+ */
59
+ interface IFileProps {
60
+ /**
61
+ * URI address of the file.
62
+ *
63
+ * In the React Native, the URI address in the local file system can replace
64
+ * the `File` class instance. If
65
+ *
66
+ * @format uri
67
+ */
68
+ uri: string;
69
+ /**
70
+ * Name of the file.
71
+ */
72
+ name: string;
73
+ /**
74
+ * Content type of the file.
75
+ */
76
+ type: string;
77
+ }
78
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=FormDataInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormDataInput.js","sourceRoot":"","sources":["../src/FormDataInput.ts"],"names":[],"mappings":""}
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from "./FormDataInput";
1
2
  export * from "./HttpError";
2
3
  export * from "./IConnection";
3
4
  export * from "./IEncryptionPassword";
package/lib/index.js CHANGED
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./FormDataInput"), exports);
17
18
  __exportStar(require("./HttpError"), exports);
18
19
  __exportStar(require("./IConnection"), exports);
19
20
  __exportStar(require("./IEncryptionPassword"), exports);
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,gDAA8B;AAC9B,wDAAsC;AACtC,gDAA8B;AAC9B,gDAA8B;AAC9B,iDAA+B;AAC/B,qDAAmC;AACnC,8CAA4B;AAC5B,6CAA2B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,8CAA4B;AAC5B,gDAA8B;AAC9B,wDAAsC;AACtC,gDAA8B;AAC9B,gDAA8B;AAC9B,iDAA+B;AAC/B,qDAAmC;AACnC,8CAA4B;AAC5B,6CAA2B"}
@@ -312,13 +312,10 @@ var request_form_data_body = function (input) {
312
312
  var append = function (key) { return function (value) {
313
313
  if (value === undefined)
314
314
  return;
315
- else if (value instanceof Blob)
316
- if (value instanceof File)
317
- encoded.append(key, value, value.name);
318
- else
319
- encoded.append(key, value);
315
+ else if (typeof File === "function" && value instanceof File)
316
+ encoded.append(key, value, value.name);
320
317
  else
321
- encoded.append(key, String(value));
318
+ encoded.append(key, value);
322
319
  }; };
323
320
  try {
324
321
  for (var _b = __values(Object.entries(input)), _c = _b.next(); !_c.done; _c = _b.next()) {
@@ -1 +1 @@
1
- {"version":3,"file":"FetcherBase.js","sourceRoot":"","sources":["../../src/internal/FetcherBase.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAyC;AAMzC;;GAEG;AACH,IAAiB,WAAW,CAyL3B;AAzLD,WAAiB,WAAW;;IAab,mBAAO,GAClB,UAAC,KAAa;QACd,OAAA,UACE,UAAuB,EACvB,KAAwE,EACxE,KAAa,EACb,SAAoC;;;;4BAErB,qBAAM,UAAU,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAC7C,UAAU,EACV,KAAK,EACL,KAAK,EACL,SAAS,CACV,EAAA;;wBALK,MAAM,GAAG,SAKd;wBACD,IAAK,MAAc,CAAC,OAAO,KAAK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YAAM,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC7B,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
1
+ {"version":3,"file":"FetcherBase.js","sourceRoot":"","sources":["../../src/internal/FetcherBase.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAyC;AAMzC;;GAEG;AACH,IAAiB,WAAW,CAyL3B;AAzLD,WAAiB,WAAW;;IAab,mBAAO,GAClB,UAAC,KAAa;QACd,OAAA,UACE,UAAuB,EACvB,KAAwE,EACxE,KAAa,EACb,SAAoC;;;;4BAErB,qBAAM,UAAU,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAC7C,UAAU,EACV,KAAK,EACL,KAAK,EACL,SAAS,CACV,EAAA;;wBALK,MAAM,GAAG,SAKd;wBACD,IAAK,MAAc,CAAC,OAAO,KAAK,KAAK;4BACnC,MAAM,IAAI,qBAAS,CACjB,KAAK,CAAC,MAAM,EACZ,KAAK,CAAC,IAAI,EACV,MAAM,CAAC,MAAuB,EAC9B,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,IAAc,CACtB,CAAC;wBACJ,sBAAO,MAAM,CAAC,IAAc,EAAC;;;aAC9B;IArBD,CAqBC,CAAC;IAES,qBAAS,GACpB,UAAC,KAAa;QACd,OAAA,UACE,UAAuB,EACvB,KAAwE,EACxE,KAAa,EACb,SAAoC;YAEpC,sBAAA,UAAU,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,EAAA;iBAAA;IANrE,CAMqE,CAAC;IAExE;;OAEG;IACH,IAAM,UAAU,GACd,UAAC,MAAc;QACf,OAAA,UAAC,KAAa;YACd,OAAA,UACE,UAAuB,EACvB,KAAwE,EACxE,KAAa,EACb,S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C,CAAC,KAAK,CAAC,CAAC;SAAA;;;;;;;;;IAC1B,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;GAEG;AACH,IAAM,0BAA0B,GAAG,UACjC,OAAgB;IAEhB,IAAM,MAAM,GAAsC,EAAE,CAAC;IACrD,OAAO,CAAC,OAAO,CAAC,UAAC,KAAK,EAAE,GAAG;;;QACzB,IAAI,GAAG,KAAK,YAAY,EAAE,CAAC;YACzB,MAAA,MAAM,CAAC,GAAG,qCAAV,MAAM,CAAC,GAAG,IAAM,EAAE,EAAC;YACnB,CAAA,KAAC,MAAM,CAAC,GAAG,CAAc,CAAA,CAAC,IAAI,oCACzB,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,UAAC,GAAG,IAAK,OAAA,GAAG,CAAC,IAAI,EAAE,EAAV,CAAU,CAAC,WAC5C;QACJ,CAAC;;YAAM,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC7B,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestia/fetcher",
3
- "version": "3.13.0",
3
+ "version": "3.14.0-dev.20240917",
4
4
  "description": "Fetcher library of Nestia SDK",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -25,6 +25,12 @@
25
25
  "url": "https://github.com/samchon/nestia/issues"
26
26
  },
27
27
  "homepage": "https://nestia.io",
28
+ "dependencies": {
29
+ "@samchon/openapi": "^1.0.2"
30
+ },
31
+ "peerDependencies": {
32
+ "typescript": ">= 4.8.0"
33
+ },
28
34
  "devDependencies": {
29
35
  "@types/node": "^18.11.14",
30
36
  "@typescript-eslint/eslint-plugin": "^5.46.1",
@@ -32,17 +38,11 @@
32
38
  "rimraf": "^3.0.2",
33
39
  "typescript": "5.5.4"
34
40
  },
35
- "peerDependencies": {
36
- "typescript": ">= 4.8.0"
37
- },
38
41
  "files": [
39
42
  "README.md",
40
43
  "LICENSE",
41
44
  "package.json",
42
45
  "lib",
43
46
  "src"
44
- ],
45
- "dependencies": {
46
- "@samchon/openapi": "^1.0.0"
47
- }
47
+ ]
48
48
  }
@@ -0,0 +1,92 @@
1
+ /**
2
+ * FormData input type.
3
+ *
4
+ * `FormDataInput<T>` is a type for the input of the `FormData` request, casting
5
+ * `File` property value type as an union of `File` and {@link FormDataInput.IFileProps},
6
+ * especially for the React Native environment.
7
+ *
8
+ * You know what? In the React Native environment, `File` class is not supported.
9
+ * Therefore, when composing a `FormData` request, you have to put the URI address
10
+ * of the local filesystem with file name and contet type that is represented by the
11
+ * {@link FormDataInput.IFileProps} type.
12
+ *
13
+ * This `FormDataInput<T>` type is designed for that purpose. If the property value
14
+ * type is a `File` class, it converts it to an union type of `File` and
15
+ * {@link FormDataInput.IFileProps} type. Also, if the property value type is an array
16
+ * of `File` class, it converts it to an array of union type of `File` and
17
+ * {@link FormDataInput.IFileProps} type too.
18
+ *
19
+ * Before | After
20
+ * ----------|------------------------
21
+ * `boolean` | `boolean`
22
+ * `bigint` | `bigint`
23
+ * `number` | `number`
24
+ * `string` | `string`
25
+ * `File` | `File \| IFileProps`
26
+ * `Object` | `never`
27
+ *
28
+ * @template T Target object type.
29
+ * @author Jeongho Nam - https://github.com/samchon
30
+ */
31
+ export type FormDataInput<T extends object> =
32
+ T extends Array<any>
33
+ ? never
34
+ : T extends Function
35
+ ? never
36
+ : {
37
+ [P in keyof T]: T[P] extends Array<infer U>
38
+ ? FormDataInput.Value<U>[]
39
+ : FormDataInput.Value<T[P]>;
40
+ };
41
+ export namespace FormDataInput {
42
+ /**
43
+ * Value type of the `FormDataInput`.
44
+ *
45
+ * `Value<T>` is a type for the property value defined in the `FormDataInput`.
46
+ *
47
+ * If the original value type is a `File` class, `Value<T>` converts it to an union
48
+ * type of `File` and {@link IFileProps} type which is a structured data for the
49
+ * URI file location in the React Native environment.
50
+ */
51
+ export type Value<T> = T extends File
52
+ ? T | IFileProps
53
+ : T extends object
54
+ ? never
55
+ : T;
56
+
57
+ /**
58
+ * Properties of a file.
59
+ *
60
+ * In the React Native, this `IFileProps` structured data can replace the `File`
61
+ * class instance in the `FormData` request.
62
+ *
63
+ * Just put the {@link uri URI address} of the local file system with the file's
64
+ * {@link name} and {@link type}. It would be casted to the `File` class instance
65
+ * automatically in the `FormData` request.
66
+ *
67
+ * Note that, this `IFileProps` type works only in the React Native environment.
68
+ * If you are developing a Web or NodeJS application, you have to utilize the
69
+ * `File` class instance directly.
70
+ */
71
+ export interface IFileProps {
72
+ /**
73
+ * URI address of the file.
74
+ *
75
+ * In the React Native, the URI address in the local file system can replace
76
+ * the `File` class instance. If
77
+ *
78
+ * @format uri
79
+ */
80
+ uri: string;
81
+
82
+ /**
83
+ * Name of the file.
84
+ */
85
+ name: string;
86
+
87
+ /**
88
+ * Content type of the file.
89
+ */
90
+ type: string;
91
+ }
92
+ }
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from "./FormDataInput";
1
2
  export * from "./HttpError";
2
3
  export * from "./IConnection";
3
4
  export * from "./IEncryptionPassword";
@@ -214,10 +214,9 @@ const request_form_data_body = (input: Record<string, any>): FormData => {
214
214
  const encoded: FormData = new FormData();
215
215
  const append = (key: string) => (value: any) => {
216
216
  if (value === undefined) return;
217
- else if (value instanceof Blob)
218
- if (value instanceof File) encoded.append(key, value, value.name);
219
- else encoded.append(key, value);
220
- else encoded.append(key, String(value));
217
+ else if (typeof File === "function" && value instanceof File)
218
+ encoded.append(key, value, value.name);
219
+ else encoded.append(key, value);
221
220
  };
222
221
  for (const [key, value] of Object.entries(input))
223
222
  if (Array.isArray(value)) value.map(append(key));