@fecommunity/reactpress-toolkit 1.0.0 → 3.0.4

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 (116) hide show
  1. package/README.md +9 -27
  2. package/dist/config/env.d.ts +1 -0
  3. package/dist/config/env.js +89 -0
  4. package/dist/config/global.d.ts +34 -0
  5. package/dist/config/global.js +390 -0
  6. package/dist/config/i18n.d.ts +4 -0
  7. package/dist/config/i18n.js +43 -0
  8. package/dist/config/index.d.ts +15 -0
  9. package/dist/config/index.js +25 -0
  10. package/dist/index.d.ts +11 -5
  11. package/dist/index.js +17 -20
  12. package/dist/locales/en.json +97 -0
  13. package/dist/locales/zh.json +97 -0
  14. package/package.json +15 -3
  15. package/dist/Article.d.ts +0 -121
  16. package/dist/Article.js +0 -189
  17. package/dist/Auth.d.ts +0 -30
  18. package/dist/Auth.js +0 -59
  19. package/dist/Category.d.ts +0 -49
  20. package/dist/Category.js +0 -85
  21. package/dist/Comment.d.ts +0 -58
  22. package/dist/Comment.js +0 -98
  23. package/dist/File.d.ts +0 -40
  24. package/dist/File.js +0 -72
  25. package/dist/HttpClient.d.ts +0 -41
  26. package/dist/HttpClient.js +0 -94
  27. package/dist/Knowledge.d.ts +0 -76
  28. package/dist/Knowledge.js +0 -124
  29. package/dist/Page.d.ts +0 -58
  30. package/dist/Page.js +0 -98
  31. package/dist/Search.d.ts +0 -30
  32. package/dist/Search.js +0 -59
  33. package/dist/Setting.d.ts +0 -22
  34. package/dist/Setting.js +0 -46
  35. package/dist/Smtp.d.ts +0 -31
  36. package/dist/Smtp.js +0 -59
  37. package/dist/Tag.d.ts +0 -58
  38. package/dist/Tag.js +0 -98
  39. package/dist/User.d.ts +0 -41
  40. package/dist/User.js +0 -73
  41. package/dist/View.d.ts +0 -49
  42. package/dist/View.js +0 -85
  43. package/dist/api/Admin.d.ts +0 -14
  44. package/dist/api/Admin.js +0 -32
  45. package/dist/api/All.d.ts +0 -14
  46. package/dist/api/All.js +0 -32
  47. package/dist/api/ApiInstance.d.ts +0 -39
  48. package/dist/api/ApiInstance.js +0 -46
  49. package/dist/api/Archives.d.ts +0 -14
  50. package/dist/api/Archives.js +0 -32
  51. package/dist/api/ArticleRoute.d.ts +0 -201
  52. package/dist/api/ArticleRoute.js +0 -12
  53. package/dist/api/AuthRoute.d.ts +0 -44
  54. package/dist/api/AuthRoute.js +0 -12
  55. package/dist/api/Book.d.ts +0 -15
  56. package/dist/api/Book.js +0 -33
  57. package/dist/api/CategoryRoute.d.ts +0 -79
  58. package/dist/api/CategoryRoute.js +0 -12
  59. package/dist/api/Chapter.d.ts +0 -15
  60. package/dist/api/Chapter.js +0 -33
  61. package/dist/api/CommentRoute.d.ts +0 -95
  62. package/dist/api/CommentRoute.js +0 -12
  63. package/dist/api/FileRoute.d.ts +0 -63
  64. package/dist/api/FileRoute.js +0 -12
  65. package/dist/api/Get.d.ts +0 -14
  66. package/dist/api/Get.js +0 -32
  67. package/dist/api/Github.d.ts +0 -14
  68. package/dist/api/Github.js +0 -32
  69. package/dist/api/Host.d.ts +0 -14
  70. package/dist/api/Host.js +0 -32
  71. package/dist/api/Id.d.ts +0 -284
  72. package/dist/api/Id.js +0 -422
  73. package/dist/api/KnowledgeRoute.d.ts +0 -125
  74. package/dist/api/KnowledgeRoute.js +0 -12
  75. package/dist/api/Login.d.ts +0 -14
  76. package/dist/api/Login.js +0 -32
  77. package/dist/api/PageRoute.d.ts +0 -95
  78. package/dist/api/PageRoute.js +0 -12
  79. package/dist/api/Password.d.ts +0 -15
  80. package/dist/api/Password.js +0 -33
  81. package/dist/api/Recommend.d.ts +0 -14
  82. package/dist/api/Recommend.js +0 -32
  83. package/dist/api/Register.d.ts +0 -15
  84. package/dist/api/Register.js +0 -33
  85. package/dist/api/SearchRoute.d.ts +0 -46
  86. package/dist/api/SearchRoute.js +0 -12
  87. package/dist/api/SettingRoute.d.ts +0 -31
  88. package/dist/api/SettingRoute.js +0 -12
  89. package/dist/api/SmtpRoute.d.ts +0 -47
  90. package/dist/api/SmtpRoute.js +0 -12
  91. package/dist/api/TagRoute.d.ts +0 -95
  92. package/dist/api/TagRoute.js +0 -12
  93. package/dist/api/Update.d.ts +0 -15
  94. package/dist/api/Update.js +0 -33
  95. package/dist/api/Upload.d.ts +0 -15
  96. package/dist/api/Upload.js +0 -33
  97. package/dist/api/Url.d.ts +0 -14
  98. package/dist/api/Url.js +0 -32
  99. package/dist/api/UserRoute.d.ts +0 -60
  100. package/dist/api/UserRoute.js +0 -12
  101. package/dist/api/ViewRoute.d.ts +0 -77
  102. package/dist/api/ViewRoute.js +0 -12
  103. package/dist/api/api-instance.d.ts +0 -39
  104. package/dist/api/api-instance.js +0 -46
  105. package/dist/api/http-client.d.ts +0 -41
  106. package/dist/api/http-client.js +0 -94
  107. package/dist/data-contracts.d.ts +0 -245
  108. package/dist/data-contracts.js +0 -12
  109. package/dist/types/data-contracts.d.ts +0 -177
  110. package/dist/types/data-contracts.js +0 -12
  111. package/dist/utils/common.d.ts +0 -21
  112. package/dist/utils/common.js +0 -52
  113. package/dist/utils/http.d.ts +0 -3
  114. package/dist/utils/http.js +0 -45
  115. /package/dist/api/{httpClient.d.ts → HttpClient.d.ts} +0 -0
  116. /package/dist/api/{httpClient.js → HttpClient.js} +0 -0
@@ -1,95 +0,0 @@
1
- import { ITag } from '../types/data-contracts';
2
- export declare namespace Tag {
3
- /**
4
- * No description
5
- * @tags Tag
6
- * @name create
7
- * @request POST:/tag
8
- * @response `200` `(ITag)[]` 创建标签
9
- */
10
- namespace create {
11
- type RequestParams = {};
12
- type RequestQuery = {};
13
- type RequestBody = never;
14
- type RequestHeaders = {};
15
- type ResponseBody = ITag[];
16
- }
17
- /**
18
- * No description
19
- * @tags Tag
20
- * @name findAll
21
- * @request GET:/tag
22
- * @response `200` `void`
23
- */
24
- namespace findAll {
25
- type RequestParams = {};
26
- type RequestQuery = {};
27
- type RequestBody = never;
28
- type RequestHeaders = {};
29
- type ResponseBody = void;
30
- }
31
- /**
32
- * No description
33
- * @tags Tag
34
- * @name findById
35
- * @request GET:/tag/{id}
36
- * @response `200` `void`
37
- */
38
- namespace findById {
39
- type RequestParams = {
40
- id: string;
41
- };
42
- type RequestQuery = {};
43
- type RequestBody = never;
44
- type RequestHeaders = {};
45
- type ResponseBody = void;
46
- }
47
- /**
48
- * No description
49
- * @tags Tag
50
- * @name updateById
51
- * @request PATCH:/tag/{id}
52
- * @response `200` `void`
53
- */
54
- namespace updateById {
55
- type RequestParams = {
56
- id: string;
57
- };
58
- type RequestQuery = {};
59
- type RequestBody = never;
60
- type RequestHeaders = {};
61
- type ResponseBody = void;
62
- }
63
- /**
64
- * No description
65
- * @tags Tag
66
- * @name deleteById
67
- * @request DELETE:/tag/{id}
68
- * @response `200` `void`
69
- */
70
- namespace deleteById {
71
- type RequestParams = {
72
- id: string;
73
- };
74
- type RequestQuery = {};
75
- type RequestBody = never;
76
- type RequestHeaders = {};
77
- type ResponseBody = void;
78
- }
79
- /**
80
- * No description
81
- * @tags Tag
82
- * @name getArticleById
83
- * @request GET:/tag/{id}/article
84
- * @response `200` `void`
85
- */
86
- namespace getArticleById {
87
- type RequestParams = {
88
- id: string;
89
- };
90
- type RequestQuery = {};
91
- type RequestBody = never;
92
- type RequestHeaders = {};
93
- type ResponseBody = void;
94
- }
95
- }
@@ -1,12 +0,0 @@
1
- "use strict";
2
- /* eslint-disable */
3
- /* tslint:disable */
4
- /*
5
- * ---------------------------------------------------------------
6
- * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
7
- * ## ##
8
- * ## AUTHOR: acacode ##
9
- * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
10
- * ---------------------------------------------------------------
11
- */
12
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,15 +0,0 @@
1
- import { IUser } from '../types/data-contracts';
2
- import { HttpClient, RequestParams } from './http-client';
3
- export declare class Update<SecurityDataType = unknown> {
4
- http: HttpClient<SecurityDataType>;
5
- constructor(http: HttpClient<SecurityDataType>);
6
- /**
7
- * No description
8
- *
9
- * @tags User
10
- * @name UserControllerUpdate
11
- * @request POST:/user/update
12
- * @response `200` `(IUser)[]` 更新用户成功
13
- */
14
- userControllerUpdate: (params?: RequestParams) => Promise<import("axios").AxiosResponse<IUser[], any, {}>>;
15
- }
@@ -1,33 +0,0 @@
1
- "use strict";
2
- /* eslint-disable */
3
- /* tslint:disable */
4
- /*
5
- * ---------------------------------------------------------------
6
- * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
7
- * ## ##
8
- * ## AUTHOR: acacode ##
9
- * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
10
- * ---------------------------------------------------------------
11
- */
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.Update = void 0;
14
- class Update {
15
- constructor(http) {
16
- /**
17
- * No description
18
- *
19
- * @tags User
20
- * @name UserControllerUpdate
21
- * @request POST:/user/update
22
- * @response `200` `(IUser)[]` 更新用户成功
23
- */
24
- this.userControllerUpdate = (params = {}) => this.http.request({
25
- path: `/user/update`,
26
- method: 'POST',
27
- format: 'json',
28
- ...params,
29
- });
30
- this.http = http;
31
- }
32
- }
33
- exports.Update = Update;
@@ -1,15 +0,0 @@
1
- import { IFile } from '../types/data-contracts';
2
- import { HttpClient, RequestParams } from './http-client';
3
- export declare class Upload<SecurityDataType = unknown> {
4
- http: HttpClient<SecurityDataType>;
5
- constructor(http: HttpClient<SecurityDataType>);
6
- /**
7
- * No description
8
- *
9
- * @tags File
10
- * @name FileControllerUploadFile
11
- * @request POST:/file/upload
12
- * @response `200` `(IFile)[]` 上传文件
13
- */
14
- fileControllerUploadFile: (params?: RequestParams) => Promise<import("axios").AxiosResponse<IFile[], any, {}>>;
15
- }
@@ -1,33 +0,0 @@
1
- "use strict";
2
- /* eslint-disable */
3
- /* tslint:disable */
4
- /*
5
- * ---------------------------------------------------------------
6
- * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
7
- * ## ##
8
- * ## AUTHOR: acacode ##
9
- * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
10
- * ---------------------------------------------------------------
11
- */
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.Upload = void 0;
14
- class Upload {
15
- constructor(http) {
16
- /**
17
- * No description
18
- *
19
- * @tags File
20
- * @name FileControllerUploadFile
21
- * @request POST:/file/upload
22
- * @response `200` `(IFile)[]` 上传文件
23
- */
24
- this.fileControllerUploadFile = (params = {}) => this.http.request({
25
- path: `/file/upload`,
26
- method: 'POST',
27
- format: 'json',
28
- ...params,
29
- });
30
- this.http = http;
31
- }
32
- }
33
- exports.Upload = Upload;
package/dist/api/Url.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import { HttpClient, RequestParams } from './http-client';
2
- export declare class Url<SecurityDataType = unknown> {
3
- http: HttpClient<SecurityDataType>;
4
- constructor(http: HttpClient<SecurityDataType>);
5
- /**
6
- * No description
7
- *
8
- * @tags View
9
- * @name ViewControllerFindByUrl
10
- * @request GET:/view/url
11
- * @response `200` `void`
12
- */
13
- viewControllerFindByUrl: (params?: RequestParams) => Promise<import("axios").AxiosResponse<void, any, {}>>;
14
- }
package/dist/api/Url.js DELETED
@@ -1,32 +0,0 @@
1
- "use strict";
2
- /* eslint-disable */
3
- /* tslint:disable */
4
- /*
5
- * ---------------------------------------------------------------
6
- * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
7
- * ## ##
8
- * ## AUTHOR: acacode ##
9
- * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
10
- * ---------------------------------------------------------------
11
- */
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.Url = void 0;
14
- class Url {
15
- constructor(http) {
16
- /**
17
- * No description
18
- *
19
- * @tags View
20
- * @name ViewControllerFindByUrl
21
- * @request GET:/view/url
22
- * @response `200` `void`
23
- */
24
- this.viewControllerFindByUrl = (params = {}) => this.http.request({
25
- path: `/view/url`,
26
- method: 'GET',
27
- ...params,
28
- });
29
- this.http = http;
30
- }
31
- }
32
- exports.Url = Url;
@@ -1,60 +0,0 @@
1
- import { IUser } from '../types/data-contracts';
2
- export declare namespace User {
3
- /**
4
- * No description
5
- * @tags User
6
- * @name findAll
7
- * @request GET:/user
8
- * @response `200` `(IUser)[]` 获取用户列表
9
- * @response `403` `void` 无权获取用户列表
10
- */
11
- namespace findAll {
12
- type RequestParams = {};
13
- type RequestQuery = {};
14
- type RequestBody = never;
15
- type RequestHeaders = {};
16
- type ResponseBody = IUser[];
17
- }
18
- /**
19
- * No description
20
- * @tags User
21
- * @name register
22
- * @request POST:/user/register
23
- * @response `201` `(IUser)[]` 创建用户
24
- */
25
- namespace register {
26
- type RequestParams = {};
27
- type RequestQuery = {};
28
- type RequestBody = never;
29
- type RequestHeaders = {};
30
- type ResponseBody = IUser[];
31
- }
32
- /**
33
- * No description
34
- * @tags User
35
- * @name update
36
- * @request POST:/user/update
37
- * @response `200` `(IUser)[]` 更新用户成功
38
- */
39
- namespace update {
40
- type RequestParams = {};
41
- type RequestQuery = {};
42
- type RequestBody = never;
43
- type RequestHeaders = {};
44
- type ResponseBody = IUser[];
45
- }
46
- /**
47
- * No description
48
- * @tags User
49
- * @name updatePassword
50
- * @request POST:/user/password
51
- * @response `201` `(IUser)[]` 更新密码成功
52
- */
53
- namespace updatePassword {
54
- type RequestParams = {};
55
- type RequestQuery = {};
56
- type RequestBody = never;
57
- type RequestHeaders = {};
58
- type ResponseBody = IUser[];
59
- }
60
- }
@@ -1,12 +0,0 @@
1
- "use strict";
2
- /* eslint-disable */
3
- /* tslint:disable */
4
- /*
5
- * ---------------------------------------------------------------
6
- * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
7
- * ## ##
8
- * ## AUTHOR: acacode ##
9
- * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
10
- * ---------------------------------------------------------------
11
- */
12
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,77 +0,0 @@
1
- import { IView } from '../types/data-contracts';
2
- export declare namespace View {
3
- /**
4
- * No description
5
- * @tags View
6
- * @name create
7
- * @request POST:/view
8
- * @response `200` `(IView)[]` 访问记录添加成功
9
- */
10
- namespace create {
11
- type RequestParams = {};
12
- type RequestQuery = {};
13
- type RequestBody = never;
14
- type RequestHeaders = {};
15
- type ResponseBody = IView[];
16
- }
17
- /**
18
- * No description
19
- * @tags View
20
- * @name findAll
21
- * @request GET:/view
22
- * @response `200` `void`
23
- */
24
- namespace findAll {
25
- type RequestParams = {};
26
- type RequestQuery = {};
27
- type RequestBody = never;
28
- type RequestHeaders = {};
29
- type ResponseBody = void;
30
- }
31
- /**
32
- * No description
33
- * @tags View
34
- * @name findByUrl
35
- * @request GET:/view/url
36
- * @response `200` `void`
37
- */
38
- namespace findByUrl {
39
- type RequestParams = {};
40
- type RequestQuery = {};
41
- type RequestBody = never;
42
- type RequestHeaders = {};
43
- type ResponseBody = void;
44
- }
45
- /**
46
- * No description
47
- * @tags View
48
- * @name findById
49
- * @request GET:/view/{id}
50
- * @response `200` `void`
51
- */
52
- namespace findById {
53
- type RequestParams = {
54
- id: string;
55
- };
56
- type RequestQuery = {};
57
- type RequestBody = never;
58
- type RequestHeaders = {};
59
- type ResponseBody = void;
60
- }
61
- /**
62
- * No description
63
- * @tags View
64
- * @name deleteById
65
- * @request DELETE:/view/{id}
66
- * @response `200` `void`
67
- */
68
- namespace deleteById {
69
- type RequestParams = {
70
- id: string;
71
- };
72
- type RequestQuery = {};
73
- type RequestBody = never;
74
- type RequestHeaders = {};
75
- type ResponseBody = void;
76
- }
77
- }
@@ -1,12 +0,0 @@
1
- "use strict";
2
- /* eslint-disable */
3
- /* tslint:disable */
4
- /*
5
- * ---------------------------------------------------------------
6
- * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
7
- * ## ##
8
- * ## AUTHOR: acacode ##
9
- * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
10
- * ---------------------------------------------------------------
11
- */
12
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,39 +0,0 @@
1
- import { HttpClientConfig } from './httpClient';
2
- import { Article } from './Article';
3
- import { Auth } from './Auth';
4
- import { Category } from './Category';
5
- import { Comment } from './Comment';
6
- import { File } from './File';
7
- import { Knowledge } from './Knowledge';
8
- import { Page } from './Page';
9
- import { Search } from './Search';
10
- import { Setting } from './Setting';
11
- import { Smtp } from './Smtp';
12
- import { Tag } from './Tag';
13
- import { User } from './User';
14
- import { View } from './View';
15
- export interface ApiConfig<SecurityDataType = unknown> extends HttpClientConfig<SecurityDataType> {
16
- }
17
- export interface ApiInstance<SecurityDataType = unknown> {
18
- article: Article<SecurityDataType>;
19
- auth: Auth<SecurityDataType>;
20
- category: Category<SecurityDataType>;
21
- comment: Comment<SecurityDataType>;
22
- file: File<SecurityDataType>;
23
- knowledge: Knowledge<SecurityDataType>;
24
- page: Page<SecurityDataType>;
25
- search: Search<SecurityDataType>;
26
- setting: Setting<SecurityDataType>;
27
- smtp: Smtp<SecurityDataType>;
28
- tag: Tag<SecurityDataType>;
29
- user: User<SecurityDataType>;
30
- view: View<SecurityDataType>;
31
- }
32
- /**
33
- * 创建 API 实例
34
- * @param config API 配置
35
- * @returns API 实例对象
36
- */
37
- export declare function createApiInstance<SecurityDataType = unknown>(config?: ApiConfig<SecurityDataType>): ApiInstance<SecurityDataType>;
38
- export declare const api: ApiInstance<unknown>;
39
- export default api;
@@ -1,46 +0,0 @@
1
- "use strict";
2
- // API 实例化文件
3
- // 自动生成,请勿手动修改
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.api = exports.createApiInstance = void 0;
6
- const httpClient_1 = require("./httpClient");
7
- const Article_1 = require("./Article");
8
- const Auth_1 = require("./Auth");
9
- const Category_1 = require("./Category");
10
- const Comment_1 = require("./Comment");
11
- const File_1 = require("./File");
12
- const Knowledge_1 = require("./Knowledge");
13
- const Page_1 = require("./Page");
14
- const Search_1 = require("./Search");
15
- const Setting_1 = require("./Setting");
16
- const Smtp_1 = require("./Smtp");
17
- const Tag_1 = require("./Tag");
18
- const User_1 = require("./User");
19
- const View_1 = require("./View");
20
- /**
21
- * 创建 API 实例
22
- * @param config API 配置
23
- * @returns API 实例对象
24
- */
25
- function createApiInstance(config = {}) {
26
- const httpClient = new httpClient_1.HttpClient(config);
27
- return {
28
- article: new Article_1.Article(config),
29
- auth: new Auth_1.Auth(config),
30
- category: new Category_1.Category(config),
31
- comment: new Comment_1.Comment(config),
32
- file: new File_1.File(config),
33
- knowledge: new Knowledge_1.Knowledge(config),
34
- page: new Page_1.Page(config),
35
- search: new Search_1.Search(config),
36
- setting: new Setting_1.Setting(config),
37
- smtp: new Smtp_1.Smtp(config),
38
- tag: new Tag_1.Tag(config),
39
- user: new User_1.User(config),
40
- view: new View_1.View(config),
41
- };
42
- }
43
- exports.createApiInstance = createApiInstance;
44
- // 默认 API 实例
45
- exports.api = createApiInstance();
46
- exports.default = exports.api;
@@ -1,41 +0,0 @@
1
- import { AxiosInstance, AxiosRequestConfig, AxiosResponse, ResponseType } from 'axios';
2
- export declare type QueryParamsType = Record<string | number, any>;
3
- export interface FullRequestParams extends Omit<AxiosRequestConfig, 'data' | 'params' | 'url' | 'responseType'> {
4
- /** set parameter to `true` for call `securityWorker` for this request */
5
- secure?: boolean;
6
- /** request path */
7
- path: string;
8
- /** content type of request body */
9
- type?: ContentType;
10
- /** query params */
11
- query?: QueryParamsType;
12
- /** format of response (i.e. response.json() -> format: "json") */
13
- format?: ResponseType;
14
- /** request body */
15
- body?: unknown;
16
- }
17
- export declare type RequestParams = Omit<FullRequestParams, 'body' | 'method' | 'query' | 'path'>;
18
- export interface ApiConfig<SecurityDataType = unknown> extends Omit<AxiosRequestConfig, 'data' | 'cancelToken'> {
19
- securityWorker?: (securityData: SecurityDataType | null) => Promise<AxiosRequestConfig | void> | AxiosRequestConfig | void;
20
- secure?: boolean;
21
- format?: ResponseType;
22
- }
23
- export declare enum ContentType {
24
- Json = "application/json",
25
- FormData = "multipart/form-data",
26
- UrlEncoded = "application/x-www-form-urlencoded",
27
- Text = "text/plain"
28
- }
29
- export declare class HttpClient<SecurityDataType = unknown> {
30
- instance: AxiosInstance;
31
- private securityData;
32
- private securityWorker?;
33
- private secure?;
34
- private format?;
35
- constructor({ securityWorker, secure, format, ...axiosConfig }?: ApiConfig<SecurityDataType>);
36
- setSecurityData: (data: SecurityDataType | null) => void;
37
- protected mergeRequestParams(params1: AxiosRequestConfig, params2?: AxiosRequestConfig): AxiosRequestConfig;
38
- protected stringifyFormItem(formItem: unknown): string;
39
- protected createFormData(input: Record<string, unknown>): FormData;
40
- request: <T = any, _E = any>({ secure, path, type, query, format, body, ...params }: FullRequestParams) => Promise<AxiosResponse<T, any, {}>>;
41
- }
@@ -1,94 +0,0 @@
1
- "use strict";
2
- /* eslint-disable */
3
- /* tslint:disable */
4
- /*
5
- * ---------------------------------------------------------------
6
- * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
7
- * ## ##
8
- * ## AUTHOR: acacode ##
9
- * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
10
- * ---------------------------------------------------------------
11
- */
12
- var __importDefault = (this && this.__importDefault) || function (mod) {
13
- return (mod && mod.__esModule) ? mod : { "default": mod };
14
- };
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.HttpClient = exports.ContentType = void 0;
17
- const axios_1 = __importDefault(require("axios"));
18
- var ContentType;
19
- (function (ContentType) {
20
- ContentType["Json"] = "application/json";
21
- ContentType["FormData"] = "multipart/form-data";
22
- ContentType["UrlEncoded"] = "application/x-www-form-urlencoded";
23
- ContentType["Text"] = "text/plain";
24
- })(ContentType = exports.ContentType || (exports.ContentType = {}));
25
- class HttpClient {
26
- constructor({ securityWorker, secure, format, ...axiosConfig } = {}) {
27
- this.securityData = null;
28
- this.setSecurityData = (data) => {
29
- this.securityData = data;
30
- };
31
- this.request = async ({ secure, path, type, query, format, body, ...params }) => {
32
- const secureParams = ((typeof secure === 'boolean' ? secure : this.secure) &&
33
- this.securityWorker &&
34
- (await this.securityWorker(this.securityData))) ||
35
- {};
36
- const requestParams = this.mergeRequestParams(params, secureParams);
37
- const responseFormat = format || this.format || undefined;
38
- if (type === ContentType.FormData && body && body !== null && typeof body === 'object') {
39
- body = this.createFormData(body);
40
- }
41
- if (type === ContentType.Text && body && body !== null && typeof body !== 'string') {
42
- body = JSON.stringify(body);
43
- }
44
- return this.instance.request({
45
- ...requestParams,
46
- headers: {
47
- ...(requestParams.headers || {}),
48
- ...(type && type !== ContentType.FormData ? { 'Content-Type': type } : {}),
49
- },
50
- params: query,
51
- responseType: responseFormat,
52
- data: body,
53
- url: path,
54
- });
55
- };
56
- this.instance = axios_1.default.create({ ...axiosConfig, baseURL: axiosConfig.baseURL || 'http://localhost:3002' });
57
- this.secure = secure;
58
- this.format = format;
59
- this.securityWorker = securityWorker;
60
- }
61
- mergeRequestParams(params1, params2) {
62
- const method = params1.method || (params2 && params2.method);
63
- return {
64
- ...this.instance.defaults,
65
- ...params1,
66
- ...(params2 || {}),
67
- headers: {
68
- ...((method && this.instance.defaults.headers[method.toLowerCase()]) || {}),
69
- ...(params1.headers || {}),
70
- ...((params2 && params2.headers) || {}),
71
- },
72
- };
73
- }
74
- stringifyFormItem(formItem) {
75
- if (typeof formItem === 'object' && formItem !== null) {
76
- return JSON.stringify(formItem);
77
- }
78
- else {
79
- return `${formItem}`;
80
- }
81
- }
82
- createFormData(input) {
83
- return Object.keys(input || {}).reduce((formData, key) => {
84
- const property = input[key];
85
- const propertyContent = property instanceof Array ? property : [property];
86
- for (const formItem of propertyContent) {
87
- const isFileType = formItem instanceof Blob || formItem instanceof File;
88
- formData.append(key, isFileType ? formItem : this.stringifyFormItem(formItem));
89
- }
90
- return formData;
91
- }, new FormData());
92
- }
93
- }
94
- exports.HttpClient = HttpClient;